@waniwani/sdk 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/embed.js +1 -1
- package/dist/chat/embed.js.map +1 -1
- package/dist/chat/express-js/index.d.ts +406 -0
- package/dist/chat/express-js/index.js +10 -0
- package/dist/chat/express-js/index.js.map +1 -0
- package/dist/chat/index.js +1 -1
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/next-js/index.d.ts +5 -1
- package/dist/chat/next-js/index.js +3 -3
- package/dist/chat/next-js/index.js.map +1 -1
- package/dist/mcp/index.js +5 -5
- package/dist/mcp/index.js.map +1 -1
- package/package.json +6 -1
package/dist/chat/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import{a as zo,b as jo,c as Vo,d as ze,e as je,f as Xt,g as $o,h as Xo,i as Qo,j
|
|
|
13
13
|
`}));let m={type:"element",tagName:"span",properties:{class:"line"},children:[]},w=0;for(let h of I){let L={type:"element",tagName:"span",properties:{...h.htmlAttrs},children:[{type:"text",value:h.content}]},x=xo(h.htmlStyle||Ia(h));x&&(L.properties.style=x);for(let S of r)L=S?.span?.call(p,L,C+1,w,m,h)||L;l==="inline"?n.children.push(L):l==="classic"&&m.children.push(L),w+=h.content.length}if(l==="classic"){for(let h of r)m=h?.line?.call(p,m,C+1)||m;c.push(m),s.push(m)}else l==="inline"&&c.push(m)}),l==="classic"){for(let I of r)d=I?.code?.call(p,d)||d;f.children.push(d);for(let I of r)f=I?.pre?.call(p,f)||f;n.children.push(f)}else if(l==="inline"){let I=[],C={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let h of n.children)h.type==="element"&&h.tagName==="br"?(I.push(C),C={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(h.type==="element"||h.type==="text")&&C.children.push(h);I.push(C);let w={type:"element",tagName:"code",properties:{},children:I};for(let h of r)w=h?.code?.call(p,w)||w;n.children=[];for(let h=0;h<w.children.length;h++){h>0&&n.children.push({type:"element",tagName:"br",properties:{},children:[]});let L=w.children[h];L.type==="element"&&n.children.push(...L.children)}}let g=n;for(let I of r)g=I?.root?.call(p,g)||g;return o&&Pa(g,o),g}function Ju(e){return e.map(t=>{let a=[],o="",r;return t.forEach((s,n)=>{let i=!(s.fontStyle&&(s.fontStyle&te.Underline||s.fontStyle&te.Strikethrough));i&&s.content.match(/^\s+$/)&&t[n+1]?(r===void 0&&(r=s.offset),o+=s.content):o?(i?a.push({...s,offset:r,content:o+s.content}):a.push({content:o,offset:r},s),r=void 0,o=""):a.push(s)}),a})}function Zu(e){return e.map(t=>t.flatMap(a=>{if(a.content.match(/^\s+$/))return a;let o=a.content.match(/^(\s*)(.*?)(\s*)$/);if(!o)return a;let[,r,s,n]=o;if(!r&&!n)return a;let l=[{...a,offset:a.offset+r.length,content:s}];return r&&l.unshift({content:r,offset:a.offset}),n&&l.push({content:n,offset:a.offset+r.length+s.length}),l}))}function Yu(e){return e.map(t=>{let a=[];for(let o of t){if(a.length===0){a.push({...o});continue}let r=a[a.length-1],s=xo(r.htmlStyle||Ia(r)),n=xo(o.htmlStyle||Ia(o)),l=r.fontStyle&&(r.fontStyle&te.Underline||r.fontStyle&te.Strikethrough),i=o.fontStyle&&(o.fontStyle&te.Underline||o.fontStyle&te.Strikethrough);!l&&!i&&s===n?r.content+=o.content:a.push({...o})}return a})}var ed=go;function td(e,t,a){let o={meta:{},options:a,codeToHast:(s,n)=>ka(e,s,n),codeToTokens:(s,n)=>ya(e,s,n)},r=ed(ka(e,t,a,o));for(let s of Sa(a))r=s.postprocess?.call(o,r,a)||r;return r}var Bs={light:"#333333",dark:"#bbbbbb"},Ds={light:"#fffffe",dark:"#1e1e1e"},_s="__shiki_resolved";function To(e){if(e?.[_s])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:a,fg:o}=t;if(!a||!o){let l=t.settings?t.settings.find(i=>!i.name&&!i.scope):void 0;l?.settings?.foreground&&(o=l.settings.foreground),l?.settings?.background&&(a=l.settings.background),!o&&t?.colors?.["editor.foreground"]&&(o=t.colors["editor.foreground"]),!a&&t?.colors?.["editor.background"]&&(a=t.colors["editor.background"]),o||(o=t.type==="light"?Bs.light:Bs.dark),a||(a=t.type==="light"?Ds.light:Ds.dark),t.fg=o,t.bg=a}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let r=0,s=new Map;function n(l){if(s.has(l))return s.get(l);r+=1;let i=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${i}`]?n(l):(s.set(l,i),i)}t.settings=t.settings.map(l=>{let i=l.settings?.foreground&&!l.settings.foreground.startsWith("#"),u=l.settings?.background&&!l.settings.background.startsWith("#");if(!i&&!u)return l;let f={...l,settings:{...l.settings}};if(i){let d=n(l.settings.foreground);t.colorReplacements[d]=l.settings.foreground,f.settings.foreground=d}if(u){let d=n(l.settings.background);t.colorReplacements[d]=l.settings.background,f.settings.background=d}return f});for(let l of Object.keys(t.colors||{}))if((l==="editor.foreground"||l==="editor.background"||l.startsWith("terminal.ansi"))&&!t.colors[l]?.startsWith("#")){let i=n(t.colors[l]);t.colorReplacements[i]=t.colors[l],t.colors[l]=i}return Object.defineProperty(t,_s,{enumerable:!1,writable:!1,value:!0}),t}async function zs(e){return Array.from(new Set((await Promise.all(e.filter(t=>!Ns(t)).map(async t=>await Es(t).then(a=>Array.isArray(a)?a:[a])))).flat()))}async function js(e){return(await Promise.all(e.map(async a=>Os(a)?null:To(await Es(a))))).filter(a=>!!a)}var Lo=3,ad=!1;function od(e,t=3){if(Lo&&!(typeof Lo=="number"&&t>Lo)){if(ad)throw new Error(`[SHIKI DEPRECATE]: ${e}`);console.trace(`[SHIKI DEPRECATE]: ${e}`)}}var ve=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Vs(e,t){if(!t)return e;if(t[e]){let a=new Set([e]);for(;t[e];){if(e=t[e],a.has(e))throw new ve(`Circular alias \`${Array.from(a).join(" -> ")} -> ${e}\``);a.add(e)}}return e}var Co=class extends ds{constructor(t,a,o,r={}){super(t),this._resolver=t,this._themes=a,this._langs=o,this._alias=r,this._themes.map(s=>this.loadTheme(s)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){let a=To(t);return a.name&&(this._resolvedThemes.set(a.name,a),this._loadedThemesCache=null),a}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(t){let a=this._textmateThemeCache.get(t);a||(a=Rt.createFromRawTheme(t),this._textmateThemeCache.set(t,a)),this._syncRegistry.setTheme(a)}getGrammar(t){return t=Vs(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){if(this.getGrammar(t.name))return;let a=new Set([...this._langMap.values()].filter(s=>s.embeddedLangsLazy?.includes(t.name)));this._resolver.addLanguage(t);let o={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);let r=this.loadGrammarWithConfiguration(t.scopeName,1,o);if(r.name=t.name,this._resolvedGrammars.set(t.name,r),t.aliases&&t.aliases.forEach(s=>{this._alias[s]=t.name}),this._loadedLanguagesCache=null,a.size)for(let s of a)this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(let r of t)this.resolveEmbeddedLanguages(r);let a=Array.from(this._langGraph.entries()),o=a.filter(([r,s])=>!s);if(o.length){let r=a.filter(([s,n])=>n?(n.embeddedLanguages||n.embeddedLangs)?.some(i=>o.map(([u])=>u).includes(i)):!1).filter(s=>!o.includes(s));throw new ve(`Missing languages ${o.map(([s])=>`\`${s}\``).join(", ")}, required by ${r.map(([s])=>`\`${s}\``).join(", ")}`)}for(let[r,s]of a)this._resolver.addLanguage(s);for(let[r,s]of a)this.loadLanguage(s)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);let a=t.embeddedLanguages??t.embeddedLangs;if(a)for(let o of a)this._langGraph.set(o,this._langMap.get(o))}},Io=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(t,a){this._onigLib={createOnigScanner:o=>t.createScanner(o),createOnigString:o=>t.createString(o)},a.forEach(o=>this.addLanguage(o))}get onigLib(){return this._onigLib}getLangRegistration(t){return this._langs.get(t)}loadGrammar(t){return this._scopeToLang.get(t)}addLanguage(t){this._langs.set(t.name,t),t.aliases&&t.aliases.forEach(a=>{this._langs.set(a,t)}),this._scopeToLang.set(t.scopeName,t),t.injectTo&&t.injectTo.forEach(a=>{this._injections.get(a)||this._injections.set(a,[]),this._injections.get(a).push(t.scopeName)})}getInjections(t){let a=t.split("."),o=[];for(let r=1;r<=a.length;r++){let s=a.slice(0,r).join(".");o=[...o,...this._injections.get(s)||[]]}return o}},Ot=0;function rd(e){Ot+=1,e.warnings!==!1&&Ot>=10&&Ot%10===0&&console.warn(`[Shiki] ${Ot} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new ve("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),o=(e.themes||[]).flat(1).map(To),r=new Io(e.engine,a),s=new Co(r,o,a,e.langAlias),n;function l(h){return Vs(h,e.langAlias)}function i(h){m();let L=s.getGrammar(typeof h=="string"?h:h.name);if(!L)throw new ve(`Language \`${h}\` not found, you may need to load it first`);return L}function u(h){if(h==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};m();let L=s.getTheme(h);if(!L)throw new ve(`Theme \`${h}\` not found, you may need to load it first`);return L}function f(h){m();let L=u(h);n!==h&&(s.setTheme(L),n=h);let x=s.getColorMap();return{theme:L,colorMap:x}}function d(){return m(),s.getLoadedThemes()}function c(){return m(),s.getLoadedLanguages()}function p(...h){m(),s.loadLanguages(h.flat(1))}async function g(...h){return p(await zs(h))}function I(...h){m();for(let L of h.flat(1))s.loadTheme(L)}async function C(...h){return m(),I(await js(h))}function m(){if(t)throw new ve("Shiki instance has been disposed")}function w(){t||(t=!0,s.dispose(),Ot-=1)}return{setTheme:f,getTheme:u,getLanguage:i,getLoadedThemes:d,getLoadedLanguages:c,resolveLangAlias:l,loadLanguage:g,loadLanguageSync:p,loadTheme:C,loadThemeSync:I,dispose:w,[Symbol.dispose]:w}}async function sd(e){e.engine||od("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,o]=await Promise.all([js(e.themes||[]),zs(e.langs||[]),e.engine]);return rd({...e,themes:t,langs:a,engine:o})}async function nd(e){let t=await sd(e);return{getLastGrammarState:(...a)=>Wu(t,...a),codeToTokensBase:(a,o)=>bo(t,a,o),codeToTokensWithThemes:(a,o)=>Ws(t,a,o),codeToTokens:(a,o)=>ya(t,a,o),codeToHast:(a,o)=>ka(t,a,o),codeToHtml:(a,o)=>td(t,a,o),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function $s(e){let t=e.langs,a=e.themes,o=e.engine;async function r(s){function n(d){if(typeof d=="string"){if(d=s.langAlias?.[d]||d,Ns(d))return[];let c=t[d];if(!c)throw new V(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return c}return d}function l(d){if(Os(d))return"none";if(typeof d=="string"){let c=a[d];if(!c)throw new V(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return c}return d}let i=(s.themes??[]).map(d=>l(d)),u=(s.langs??[]).map(d=>n(d)),f=await nd({engine:s.engine??o(),...s,themes:i,langs:u});return{...f,loadLanguage(...d){return f.loadLanguage(...d.map(n))},loadTheme(...d){return f.loadTheme(...d.map(l))},getBundledLanguages(){return t},getBundledThemes(){return a}}}return r}function id(e){let t;async function a(o={}){if(t){let r=await t;return await Promise.all([r.loadTheme(...o.themes||[]),r.loadLanguage(...o.langs||[])]),r}else{t=e({...o,themes:[],langs:[]});let r=await t;return await Promise.all([r.loadTheme(...o.themes||[]),r.loadLanguage(...o.langs||[])]),r}}return a}function Xs(e,t){let a=id(e);async function o(r,s){let n=await a({langs:[s.lang],themes:"theme"in s?[s.theme]:Object.values(s.themes)}),l=await t?.guessEmbeddedLanguages?.(r,s.lang,n);return l&&await n.loadLanguage(...l),n}return{getSingletonHighlighter(r){return a(r)},async codeToHtml(r,s){return(await o(r,s)).codeToHtml(r,s)},async codeToHast(r,s){return(await o(r,s)).codeToHast(r,s)},async codeToTokens(r,s){return(await o(r,s)).codeToTokens(r,s)},async codeToTokensBase(r,s){return(await o(r,s)).codeToTokensBase(r,s)},async codeToTokensWithThemes(r,s){return(await o(r,s)).codeToTokensWithThemes(r,s)},async getLastGrammarState(r,s){return(await a({langs:[s.lang],themes:[s.theme]})).getLastGrammarState(r,s)}}}var Ao=[{id:"abap",name:"ABAP",import:(()=>import("../abap-KGVIZMDC.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("../actionscript-3-2UHK5QYP.js"))},{id:"ada",name:"Ada",import:(()=>import("../ada-JKTWR5BV.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("../angular-html-EOIKHM3D.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("../angular-ts-A7ZNTSV6.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("../apache-MPGFGQFB.js"))},{id:"apex",name:"Apex",import:(()=>import("../apex-BOAZL66Z.js"))},{id:"apl",name:"APL",import:(()=>import("../apl-QBN4KIYA.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("../applescript-C4CJ3STL.js"))},{id:"ara",name:"Ara",import:(()=>import("../ara-FSFFBRSD.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("../asciidoc-QQK2LANG.js"))},{id:"asm",name:"Assembly",import:(()=>import("../asm-X43A2VYW.js"))},{id:"astro",name:"Astro",import:(()=>import("../astro-OQUOYMBE.js"))},{id:"awk",name:"AWK",import:(()=>import("../awk-4Z3PRTF7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("../ballerina-JCXSJ2QD.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("../bat-XFWR7RMZ.js"))},{id:"beancount",name:"Beancount",import:(()=>import("../beancount-7BBDB4BH.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("../berry-PQ2BEJIZ.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("../bibtex-J2PAB23I.js"))},{id:"bicep",name:"Bicep",import:(()=>import("../bicep-TNKT6R3W.js"))},{id:"blade",name:"Blade",import:(()=>import("../blade-QBDEYXMB.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("../bsl-PQW6E45S.js"))},{id:"c",name:"C",import:(()=>import("../c-PZBJFNXE.js"))},{id:"c3",name:"C3",import:(()=>import("../c3-GP7XYHE6.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("../cadence-NABGDHKY.js"))},{id:"cairo",name:"Cairo",import:(()=>import("../cairo-WQSC2GLN.js"))},{id:"clarity",name:"Clarity",import:(()=>import("../clarity-NXNSINKX.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("../clojure-Y57BKRMA.js"))},{id:"cmake",name:"CMake",import:(()=>import("../cmake-LVMEA3JZ.js"))},{id:"cobol",name:"COBOL",import:(()=>import("../cobol-6DNJTKH3.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("../codeowners-JYHOTXQS.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("../codeql-IWWSYR3L.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("../coffee-NNDQ5QXC.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("../common-lisp-JKXCDYH3.js"))},{id:"coq",name:"Coq",import:(()=>import("../coq-BEHPNP64.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("../cpp-IALOHSZA.js"))},{id:"crystal",name:"Crystal",import:(()=>import("../crystal-ZDP3FIUI.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("../csharp-ODFBXRGA.js"))},{id:"css",name:"CSS",import:(()=>import("../css-CJGL5AVH.js"))},{id:"csv",name:"CSV",import:(()=>import("../csv-LIK4TU3Z.js"))},{id:"cue",name:"CUE",import:(()=>import("../cue-UAAEAKHI.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("../cypher-SZPVUQZJ.js"))},{id:"d",name:"D",import:(()=>import("../d-VSCA3XHG.js"))},{id:"dart",name:"Dart",import:(()=>import("../dart-A4PE6FIS.js"))},{id:"dax",name:"DAX",import:(()=>import("../dax-TILIKSFB.js"))},{id:"desktop",name:"Desktop",import:(()=>import("../desktop-75KK3D55.js"))},{id:"diff",name:"Diff",import:(()=>import("../diff-HOT6P45M.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("../docker-FF35TY6T.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("../dotenv-FVPPHJI3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("../dream-maker-SYE3ZPSJ.js"))},{id:"edge",name:"Edge",import:(()=>import("../edge-CCLQ2CKA.js"))},{id:"elixir",name:"Elixir",import:(()=>import("../elixir-F6DQGRKA.js"))},{id:"elm",name:"Elm",import:(()=>import("../elm-5QRQXDZ6.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("../emacs-lisp-NJ4S4OHV.js"))},{id:"erb",name:"ERB",import:(()=>import("../erb-HGSLHT5Y.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("../erlang-APEONNZ6.js"))},{id:"fennel",name:"Fennel",import:(()=>import("../fennel-7OCMFVPS.js"))},{id:"fish",name:"Fish",import:(()=>import("../fish-BC46ME2N.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("../fluent-MXZS6EX3.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("../fortran-fixed-form-35BC2KX6.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("../fortran-free-form-AXRAI2HH.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("../fsharp-JKNSQXHD.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("../gdresource-ZMKZGPZV.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("../gdscript-HNCVXEYB.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("../gdshader-XAJ4QRYP.js"))},{id:"genie",name:"Genie",import:(()=>import("../genie-HEFVQZAP.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("../gherkin-OFBRDPXX.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("../git-commit-ZE2M3Q5H.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("../git-rebase-3N3INGLU.js"))},{id:"gleam",name:"Gleam",import:(()=>import("../gleam-NFFQFQLP.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("../glimmer-js-RSUW6JYN.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("../glimmer-ts-EZGWLX5T.js"))},{id:"glsl",name:"GLSL",import:(()=>import("../glsl-VJLRYEVJ.js"))},{id:"gn",name:"GN",import:(()=>import("../gn-UH2XQWLG.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("../gnuplot-K6IV6NNR.js"))},{id:"go",name:"Go",import:(()=>import("../go-BDV7RR5G.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("../graphql-YEJQLMOO.js"))},{id:"groovy",name:"Groovy",import:(()=>import("../groovy-SX7K3XGL.js"))},{id:"hack",name:"Hack",import:(()=>import("../hack-3TGPQNR2.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("../haml-335RVEQR.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("../handlebars-73IS6B2J.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("../haskell-P5PTJARU.js"))},{id:"haxe",name:"Haxe",import:(()=>import("../haxe-RCPSSA3N.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("../hcl-AKKZAVC2.js"))},{id:"hjson",name:"Hjson",import:(()=>import("../hjson-REXV6F6N.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("../hlsl-AJ7VWOVL.js"))},{id:"html",name:"HTML",import:(()=>import("../html-654LNGWF.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("../html-derivative-CMQ7BFDQ.js"))},{id:"http",name:"HTTP",import:(()=>import("../http-NEPTRAQZ.js"))},{id:"hurl",name:"Hurl",import:(()=>import("../hurl-V6ZX2Q3F.js"))},{id:"hxml",name:"HXML",import:(()=>import("../hxml-5BXJCAAU.js"))},{id:"hy",name:"Hy",import:(()=>import("../hy-SB4TMFE7.js"))},{id:"imba",name:"Imba",import:(()=>import("../imba-Y64MHYWP.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("../ini-J2OP4CNW.js"))},{id:"java",name:"Java",import:(()=>import("../java-MJKJ5GPP.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("../javascript-IYAGHPR6.js"))},{id:"jinja",name:"Jinja",import:(()=>import("../jinja-WPD26JJ6.js"))},{id:"jison",name:"Jison",import:(()=>import("../jison-UYDZQBN5.js"))},{id:"json",name:"JSON",import:(()=>import("../json-5V4JESJO.js"))},{id:"json5",name:"JSON5",import:(()=>import("../json5-7SHUZD3R.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("../jsonc-X3Z34FN3.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("../jsonl-6I3D2HM6.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("../jsonnet-PZEQIBYV.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("../jssm-GJJ25IKR.js"))},{id:"jsx",name:"JSX",import:(()=>import("../jsx-NI2J427C.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("../julia-QPZ7EOS6.js"))},{id:"kdl",name:"KDL",import:(()=>import("../kdl-IA7HA2TL.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("../kotlin-CCRMGYMI.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("../kusto-7DW25GYH.js"))},{id:"latex",name:"LaTeX",import:(()=>import("../latex-F2CTDTFG.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("../lean-MGJJWBTR.js"))},{id:"less",name:"Less",import:(()=>import("../less-WFSIMX5G.js"))},{id:"liquid",name:"Liquid",import:(()=>import("../liquid-7CFNUD3V.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("../llvm-CFQSEDXB.js"))},{id:"log",name:"Log file",import:(()=>import("../log-YQNML6LA.js"))},{id:"logo",name:"Logo",import:(()=>import("../logo-2PPKBL2M.js"))},{id:"lua",name:"Lua",import:(()=>import("../lua-RPAMRKNG.js"))},{id:"luau",name:"Luau",import:(()=>import("../luau-GR2DOH6N.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("../make-DQQEEPI4.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("../markdown-OC5ILZSY.js"))},{id:"marko",name:"Marko",import:(()=>import("../marko-XSB3CTWQ.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("../matlab-YQY6FS4U.js"))},{id:"mdc",name:"MDC",import:(()=>import("../mdc-TEVTGSC7.js"))},{id:"mdx",name:"MDX",import:(()=>import("../mdx-ZIH2JLVR.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("../mermaid-WPX56SBB.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("../mipsasm-IDXQRZ2B.js"))},{id:"mojo",name:"Mojo",import:(()=>import("../mojo-MH7EQVOK.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("../moonbit-5JDFTWKE.js"))},{id:"move",name:"Move",import:(()=>import("../move-RWSXKYDY.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("../narrat-QJUEXMVV.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("../nextflow-2EICNZA3.js"))},{id:"nginx",name:"Nginx",import:(()=>import("../nginx-RIWAEC5Z.js"))},{id:"nim",name:"Nim",import:(()=>import("../nim-JPSYX5KC.js"))},{id:"nix",name:"Nix",import:(()=>import("../nix-XCKQVWCN.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("../nushell-QGW7HANA.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("../objective-c-V7KYXFHL.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("../objective-cpp-NKUEWVGU.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("../ocaml-QT2CZJZN.js"))},{id:"odin",name:"Odin",import:(()=>import("../odin-MVMIXBHP.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("../openscad-BJDUXUUZ.js"))},{id:"pascal",name:"Pascal",import:(()=>import("../pascal-HGWEFD6L.js"))},{id:"perl",name:"Perl",import:(()=>import("../perl-X4IFZB22.js"))},{id:"php",name:"PHP",import:(()=>import("../php-3V7EPUAN.js"))},{id:"pkl",name:"Pkl",import:(()=>import("../pkl-VA5ZK5DW.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("../plsql-J7A7YWFH.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("../po-5RDI65JX.js"))},{id:"polar",name:"Polar",import:(()=>import("../polar-VUJL2E7F.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("../postcss-ESTB5G7N.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("../powerquery-ODTEKQCW.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("../powershell-ZOYRAWBJ.js"))},{id:"prisma",name:"Prisma",import:(()=>import("../prisma-QHG2W5GE.js"))},{id:"prolog",name:"Prolog",import:(()=>import("../prolog-CSAPG5PH.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("../proto-WDNJBTSW.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("../pug-P7LS6DER.js"))},{id:"puppet",name:"Puppet",import:(()=>import("../puppet-LHFWHTY3.js"))},{id:"purescript",name:"PureScript",import:(()=>import("../purescript-DUFJP4FY.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("../python-5ZNZSNQ2.js"))},{id:"qml",name:"QML",import:(()=>import("../qml-LTAXB6W5.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("../qmldir-7Z2ODQLM.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("../qss-FDFD3HQD.js"))},{id:"r",name:"R",import:(()=>import("../r-6ZOS53WN.js"))},{id:"racket",name:"Racket",import:(()=>import("../racket-7AYZPEUI.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("../raku-A4F6VHVG.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("../razor-4QOCK4UD.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("../reg-FAPHGG66.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("../regexp-5BYLYA2R.js"))},{id:"rel",name:"Rel",import:(()=>import("../rel-7DJ7HHU4.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("../riscv-YIYJATFG.js"))},{id:"ron",name:"RON",import:(()=>import("../ron-HYYMCHTX.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("../rosmsg-FDNH6QF7.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("../rst-WIWCR2KQ.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("../ruby-LXZJUMFB.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("../rust-V3GMJA2K.js"))},{id:"sas",name:"SAS",import:(()=>import("../sas-D3G4GB3X.js"))},{id:"sass",name:"Sass",import:(()=>import("../sass-JTO65AGR.js"))},{id:"scala",name:"Scala",import:(()=>import("../scala-4XQGFSVM.js"))},{id:"scheme",name:"Scheme",import:(()=>import("../scheme-CB7AC7IL.js"))},{id:"scss",name:"SCSS",import:(()=>import("../scss-6SKV4OGI.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("../sdbl-LKGZFJ46.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("../shaderlab-K536DHEB.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("../shellscript-LRNUKUSZ.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("../shellsession-IBQK7VWQ.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("../smalltalk-DQOSWAW7.js"))},{id:"solidity",name:"Solidity",import:(()=>import("../solidity-V2FMZEG4.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("../soy-VW3CKXWF.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("../sparql-L2VKP7YP.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("../splunk-KDKHP7GC.js"))},{id:"sql",name:"SQL",import:(()=>import("../sql-UF27CALT.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("../ssh-config-JC2DQ6ED.js"))},{id:"stata",name:"Stata",import:(()=>import("../stata-7PXCUY24.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("../stylus-2L7N3EZD.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("../surrealql-ZY3E6XEL.js"))},{id:"svelte",name:"Svelte",import:(()=>import("../svelte-Q45XIK2A.js"))},{id:"swift",name:"Swift",import:(()=>import("../swift-XBH5HZSC.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("../system-verilog-VRAUSZY3.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("../systemd-JOTSGJD4.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("../talonscript-NNZRZKOU.js"))},{id:"tasl",name:"Tasl",import:(()=>import("../tasl-MBFZ4QNC.js"))},{id:"tcl",name:"Tcl",import:(()=>import("../tcl-4GEDCBVE.js"))},{id:"templ",name:"Templ",import:(()=>import("../templ-3XM7DLQ3.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("../terraform-XTHOS4UK.js"))},{id:"tex",name:"TeX",import:(()=>import("../tex-UXMN2CV7.js"))},{id:"toml",name:"TOML",import:(()=>import("../toml-J6K55ZSV.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("../ts-tags-7WGDLEKX.js"))},{id:"tsv",name:"TSV",import:(()=>import("../tsv-DOUJHQDQ.js"))},{id:"tsx",name:"TSX",import:(()=>import("../tsx-G5BMVRHK.js"))},{id:"turtle",name:"Turtle",import:(()=>import("../turtle-JHJ7W6U5.js"))},{id:"twig",name:"Twig",import:(()=>import("../twig-C6YWFFZU.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("../typescript-LMKEAHFC.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("../typespec-5CLTIJYY.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("../typst-4W4Z436Z.js"))},{id:"v",name:"V",import:(()=>import("../v-Y4SBDBN7.js"))},{id:"vala",name:"Vala",import:(()=>import("../vala-UMKT2MFA.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("../vb-DQ7A5WJU.js"))},{id:"verilog",name:"Verilog",import:(()=>import("../verilog-N6ZF7GQD.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("../vhdl-BNYDT37G.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("../viml-37RMDCBC.js"))},{id:"vue",name:"Vue",import:(()=>import("../vue-O6SLORWU.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("../vue-html-ZLTZN573.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("../vue-vine-6JKAZ54I.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("../vyper-GVXF46KD.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("../wasm-NTB4O7GL.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("../wenyan-W7WB3BC7.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("../wgsl-7GTDVXHG.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("../wikitext-ASAFPAIL.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("../wit-ZBCR6544.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("../wolfram-SZRZOETJ.js"))},{id:"xml",name:"XML",import:(()=>import("../xml-EBTJCOTU.js"))},{id:"xsl",name:"XSL",import:(()=>import("../xsl-IBYEXWDX.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("../yaml-GMVQNECR.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("../zenscript-O2TZFP4A.js"))},{id:"zig",name:"Zig",import:(()=>import("../zig-ZLGM7IMN.js"))}],Qs=Object.fromEntries(Ao.map(e=>[e.id,e.import])),Ks=Object.fromEntries(Ao.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),Ht={...Qs,...Ks};var ld=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>import("../andromeeda-HAPOYWX3.js"))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>import("../aurora-x-R6WAWEBC.js"))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>import("../ayu-dark-KMD4YO7F.js"))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>import("../ayu-light-2ATPDILG.js"))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>import("../ayu-mirage-LJ7PG5AM.js"))},{id:"catppuccin-frappe",displayName:"Catppuccin Frapp\xE9",type:"dark",import:(()=>import("../catppuccin-frappe-Z4Y2POK6.js"))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>import("../catppuccin-latte-4TQUIKX4.js"))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>import("../catppuccin-macchiato-B7YYPERT.js"))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>import("../catppuccin-mocha-KX33VXKA.js"))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>import("../dark-plus-LNHXUR7U.js"))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>import("../dracula-T2CMBBQ5.js"))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>import("../dracula-soft-SMFRNKX2.js"))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>import("../everforest-dark-DBZHIUAO.js"))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>import("../everforest-light-TDAGYJUK.js"))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>import("../github-dark-3E25TTAN.js"))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>import("../github-dark-default-KCBFVSS5.js"))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>import("../github-dark-dimmed-WRCBXEVS.js"))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>import("../github-dark-high-contrast-ET7SAHAV.js"))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>import("../github-light-6FNTZH5H.js"))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>import("../github-light-default-GGTAKNM7.js"))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>import("../github-light-high-contrast-LHYKPR5E.js"))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>import("../gruvbox-dark-hard-IQWZCHF7.js"))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>import("../gruvbox-dark-medium-ARPWF4FS.js"))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>import("../gruvbox-dark-soft-ODS6FPID.js"))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>import("../gruvbox-light-hard-KFA5YFDW.js"))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>import("../gruvbox-light-medium-MMET4L3Y.js"))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>import("../gruvbox-light-soft-DBZDERMK.js"))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>import("../horizon-FSOMPXNP.js"))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>import("../houston-FAQBCORN.js"))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>import("../kanagawa-dragon-JNDVF5RJ.js"))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>import("../kanagawa-lotus-S7JK6TQ6.js"))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>import("../kanagawa-wave-QJJIMVEV.js"))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>import("../laserwave-YFP3EJVX.js"))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>import("../light-plus-NGDHCPUZ.js"))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>import("../material-theme-H2BHKUKX.js"))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>import("../material-theme-darker-VENCGWTB.js"))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>import("../material-theme-lighter-SDMLS22W.js"))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>import("../material-theme-ocean-UHDBRLVF.js"))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>import("../material-theme-palenight-3TB2BEET.js"))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>import("../min-dark-CQ5WKNT7.js"))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>import("../min-light-LZRD4NPR.js"))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>import("../monokai-WHRY6275.js"))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>import("../night-owl-7PNEW2JB.js"))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>import("../night-owl-light-GJUYOOJR.js"))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>import("../nord-EVGUMUX2.js"))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>import("../one-dark-pro-PMTR3SA7.js"))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>import("../one-light-O7WH4N5X.js"))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>import("../plastic-FBVUW6NJ.js"))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>import("../poimandres-WBB7GZAD.js"))},{id:"red",displayName:"Red",type:"dark",import:(()=>import("../red-7KAMONOP.js"))},{id:"rose-pine",displayName:"Ros\xE9 Pine",type:"dark",import:(()=>import("../rose-pine-F2G5IHZD.js"))},{id:"rose-pine-dawn",displayName:"Ros\xE9 Pine Dawn",type:"light",import:(()=>import("../rose-pine-dawn-ALZ7XGH2.js"))},{id:"rose-pine-moon",displayName:"Ros\xE9 Pine Moon",type:"dark",import:(()=>import("../rose-pine-moon-D3K4SWUL.js"))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>import("../slack-dark-YFPJODWS.js"))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>import("../slack-ochin-H67AWZOI.js"))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>import("../snazzy-light-OUVS63VK.js"))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>import("../solarized-dark-2RCAVEXJ.js"))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>import("../solarized-light-XFSENHTC.js"))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>import("../synthwave-84-5XXB3K6S.js"))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>import("../tokyo-night-CHJCCBJH.js"))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>import("../vesper-Y5GIEAN4.js"))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>import("../vitesse-black-7TI33KHX.js"))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>import("../vitesse-dark-FOB25MRB.js"))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>import("../vitesse-light-4WCNCTCO.js"))}],Js=Object.fromEntries(ld.map(e=>[e.id,e.import]));var Ut=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function ud(){return 2147483648}function dd(){return typeof performance<"u"?performance.now():Date.now()}var fd=(e,t)=>e+(t-e%t)%t;async function cd(e){let t,a,o={};function r(p){a=p,o.HEAPU8=new Uint8Array(p),o.HEAPU32=new Uint32Array(p)}function s(p,g,I){o.HEAPU8.copyWithin(p,g,g+I)}function n(p){try{return t.grow(p-a.byteLength+65535>>>16),r(t.buffer),1}catch{}}function l(p){let g=o.HEAPU8.length;p=p>>>0;let I=ud();if(p>I)return!1;for(let C=1;C<=4;C*=2){let m=g*(1+.2/C);m=Math.min(m,p+100663296);let w=Math.min(I,fd(Math.max(p,m),65536));if(n(w))return!0}return!1}let i=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function u(p,g,I=1024){let C=g+I,m=g;for(;p[m]&&!(m>=C);)++m;if(m-g>16&&p.buffer&&i)return i.decode(p.subarray(g,m));let w="";for(;g<m;){let h=p[g++];if(!(h&128)){w+=String.fromCharCode(h);continue}let L=p[g++]&63;if((h&224)===192){w+=String.fromCharCode((h&31)<<6|L);continue}let x=p[g++]&63;if((h&240)===224?h=(h&15)<<12|L<<6|x:h=(h&7)<<18|L<<12|x<<6|p[g++]&63,h<65536)w+=String.fromCharCode(h);else{let S=h-65536;w+=String.fromCharCode(55296|S>>10,56320|S&1023)}}return w}function f(p,g){return p?u(o.HEAPU8,p,g):""}let d={emscripten_get_now:dd,emscripten_memcpy_big:s,emscripten_resize_heap:l,fd_write:()=>0};async function c(){let g=await e({env:d,wasi_snapshot_preview1:d});t=g.memory,r(t.buffer),Object.assign(o,g),o.UTF8ToString=f}return await c(),o}var pd=Object.defineProperty,md=(e,t,a)=>t in e?pd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,K=(e,t,a)=>md(e,typeof t!="symbol"?t+"":t,a),Y=null;function hd(e){throw new Ut(e.UTF8ToString(e.getLastOnigError()))}var Aa=class e{constructor(t){K(this,"utf16Length"),K(this,"utf8Length"),K(this,"utf16Value"),K(this,"utf8Value"),K(this,"utf16OffsetToUtf8"),K(this,"utf8OffsetToUtf16");let a=t.length,o=e._utf8ByteLength(t),r=o!==a,s=r?new Uint32Array(a+1):null;r&&(s[a]=o);let n=r?new Uint32Array(o+1):null;r&&(n[o]=a);let l=new Uint8Array(o),i=0;for(let u=0;u<a;u++){let f=t.charCodeAt(u),d=f,c=!1;if(f>=55296&&f<=56319&&u+1<a){let p=t.charCodeAt(u+1);p>=56320&&p<=57343&&(d=(f-55296<<10)+65536|p-56320,c=!0)}r&&(s[u]=i,c&&(s[u+1]=i),d<=127?n[i+0]=u:d<=2047?(n[i+0]=u,n[i+1]=u):d<=65535?(n[i+0]=u,n[i+1]=u,n[i+2]=u):(n[i+0]=u,n[i+1]=u,n[i+2]=u,n[i+3]=u)),d<=127?l[i++]=d:d<=2047?(l[i++]=192|(d&1984)>>>6,l[i++]=128|(d&63)>>>0):d<=65535?(l[i++]=224|(d&61440)>>>12,l[i++]=128|(d&4032)>>>6,l[i++]=128|(d&63)>>>0):(l[i++]=240|(d&1835008)>>>18,l[i++]=128|(d&258048)>>>12,l[i++]=128|(d&4032)>>>6,l[i++]=128|(d&63)>>>0),c&&u++}this.utf16Length=a,this.utf8Length=o,this.utf16Value=t,this.utf8Value=l,this.utf16OffsetToUtf8=s,this.utf8OffsetToUtf16=n}static _utf8ByteLength(t){let a=0;for(let o=0,r=t.length;o<r;o++){let s=t.charCodeAt(o),n=s,l=!1;if(s>=55296&&s<=56319&&o+1<r){let i=t.charCodeAt(o+1);i>=56320&&i<=57343&&(n=(s-55296<<10)+65536|i-56320,l=!0)}n<=127?a+=1:n<=2047?a+=2:n<=65535?a+=3:a+=4,l&&o++}return a}createString(t){let a=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,a),a}},va=class Ie{constructor(t){if(K(this,"id",++Ie.LAST_ID),K(this,"_onigBinding"),K(this,"content"),K(this,"utf16Length"),K(this,"utf8Length"),K(this,"utf16OffsetToUtf8"),K(this,"utf8OffsetToUtf16"),K(this,"ptr"),!Y)throw new Ut("Must invoke loadWasm first.");this._onigBinding=Y,this.content=t;let a=new Aa(t);this.utf16Length=a.utf16Length,this.utf8Length=a.utf8Length,this.utf16OffsetToUtf8=a.utf16OffsetToUtf8,this.utf8OffsetToUtf16=a.utf8OffsetToUtf16,this.utf8Length<1e4&&!Ie._sharedPtrInUse?(Ie._sharedPtr||(Ie._sharedPtr=Y.omalloc(1e4)),Ie._sharedPtrInUse=!0,Y.HEAPU8.set(a.utf8Value,Ie._sharedPtr),this.ptr=Ie._sharedPtr):this.ptr=a.createString(Y)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===Ie._sharedPtr?Ie._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};K(va,"LAST_ID",0);K(va,"_sharedPtr",0);K(va,"_sharedPtrInUse",!1);var Zs=va,Mo=class{constructor(t){if(K(this,"_onigBinding"),K(this,"_ptr"),!Y)throw new Ut("Must invoke loadWasm first.");let a=[],o=[];for(let l=0,i=t.length;l<i;l++){let u=new Aa(t[l]);a[l]=u.createString(Y),o[l]=u.utf8Length}let r=Y.omalloc(4*t.length);Y.HEAPU32.set(a,r/4);let s=Y.omalloc(4*t.length);Y.HEAPU32.set(o,s/4);let n=Y.createOnigScanner(r,s,t.length);for(let l=0,i=t.length;l<i;l++)Y.ofree(a[l]);Y.ofree(s),Y.ofree(r),n===0&&hd(Y),this._onigBinding=Y,this._ptr=n}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,a,o){let r=0;if(typeof o=="number"&&(r=o),typeof t=="string"){t=new Zs(t);let s=this._findNextMatchSync(t,a,!1,r);return t.dispose(),s}return this._findNextMatchSync(t,a,!1,r)}_findNextMatchSync(t,a,o,r){let s=this._onigBinding,n=s.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(a),r);if(n===0)return null;let l=s.HEAPU32,i=n/4,u=l[i++],f=l[i++],d=[];for(let c=0;c<f;c++){let p=t.convertUtf8OffsetToUtf16(l[i++]),g=t.convertUtf8OffsetToUtf16(l[i++]);d[c]={start:p,end:g,length:g-p}}return{index:u,captureIndices:d}}};function gd(e){return typeof e.instantiator=="function"}function wd(e){return typeof e.default=="function"}function Ld(e){return typeof e.data<"u"}function xd(e){return typeof Response<"u"&&e instanceof Response}function Cd(e){return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}var Ta;function Id(e){if(Ta)return Ta;async function t(){Y=await cd(async a=>{let o=e;return o=await o,typeof o=="function"&&(o=await o(a)),typeof o=="function"&&(o=await o(a)),gd(o)?o=await o.instantiator(a):wd(o)?o=await o.default(a):(Ld(o)&&(o=o.data),xd(o)?typeof WebAssembly.instantiateStreaming=="function"?o=await Sd(o)(a):o=await yd(o)(a):Cd(o)?o=await vo(o)(a):o instanceof WebAssembly.Module?o=await vo(o)(a):"default"in o&&o.default instanceof WebAssembly.Module&&(o=await vo(o.default)(a))),"instance"in o&&(o=o.instance),"exports"in o&&(o=o.exports),o})}return Ta=t(),Ta}function vo(e){return t=>WebAssembly.instantiate(e,t)}function Sd(e){return t=>WebAssembly.instantiateStreaming(e,t)}function yd(e){return async t=>{let a=await e.arrayBuffer();return WebAssembly.instantiate(a,t)}}async function Ys(e){return e&&await Id(e),{createScanner(t){return new Mo(t.map(a=>typeof a=="string"?a:a.source))},createString(t){return new Zs(t)}}}var Ma=$s({langs:Ht,themes:Js,engine:()=>Ys(import("../wasm-EOPKAILK.js"))}),{codeToHtml:kd,codeToHast:bd,codeToTokens:Pd,codeToTokensBase:Td,codeToTokensWithThemes:Ad,getSingletonHighlighter:vd,getLastGrammarState:Md}=Xs(Ma,{guessEmbeddedLanguages:Hs});var en=new Set(Object.keys(Ht)),Fo=new Map,Ro=new Map,st=new Map,Fd=(e,t)=>`${e}-${t[0]}-${t[1]}`,Rd=(e,t,a)=>{let o=e.slice(0,100),r=e.length>100?e.slice(-100):"";return`${t}:${a[0]}:${a[1]}:${e.length}:${o}:${r}`},Bd=(e,t)=>{let a=Fd(e,t);if(Fo.has(a))return Fo.get(a);let o=Ma({themes:t,langs:[e]});return Fo.set(a,o),o};function Dd(e={}){var t;let a=(t=e.themes)!=null?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(o){return en.has(o)},getSupportedLanguages(){return Array.from(en)},getThemes(){return a},highlight({code:o,language:r,themes:s},n){let l=Rd(o,r,s);return Ro.has(l)?Ro.get(l):(n&&(st.has(l)||st.set(l,new Set),st.get(l).add(n)),Bd(r,s).then(i=>{let u=i.getLoadedLanguages().includes(r)?r:"text",f=i.codeToTokens(o,{lang:u,themes:{light:s[0],dark:s[1]}});Ro.set(l,f);let d=st.get(l);if(d){for(let c of d)c(f);st.delete(l)}}).catch(i=>{console.error("[Streamdown Code] Failed to highlight code:",i),st.delete(l)}),null)}}}var tn=Dd();import{memo as _d}from"react";import{jsx as Fa}from"react/jsx-runtime";var Ra=({className:e,from:t,children:a,...o})=>Fa("div",{className:P("ww:group ww:flex ww:w-full",t==="user"?"is-user ww:ml-auto ww:max-w-[80%] ww:flex-col ww:items-end":"is-assistant ww:flex-col",e),...o,children:Fa("div",{className:P("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),Ba=({children:e,className:t,...a})=>Fa("div",{className:P("ww:flex ww:w-fit ww:min-w-0 ww:max-w-full ww:flex-col ww:gap-2 ww:overflow-hidden ww:text-base","ww:group-[.is-user]:ml-auto ww:group-[.is-user]:rounded-lg ww:group-[.is-user]:bg-user-bubble ww:group-[.is-user]:px-4 ww:group-[.is-user]:py-3 ww:group-[.is-user]:text-primary-foreground","ww:group-[.is-assistant]:text-foreground",t),...a,children:e}),Ed={cjk:Or,code:tn},Da=_d(({className:e,...t})=>Fa(za,{className:P("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),plugins:Ed,...t}),(e,t)=>e.children===t.children);Da.displayName="MessageResponse";import{jsx as Nd}from"react/jsx-runtime";function an({className:e,text:t,...a}){return t?Nd("pre",{className:P("ww:mb-2 ww:overflow-x-auto ww:whitespace-pre-wrap ww:break-words ww:text-xs ww:font-mono ww:text-muted-foreground",e),...a,children:t}):null}import{createContext as Od,useCallback as qd,useContext as nn,useEffect as Hd,useMemo as Do,useRef as Ud,useState as _o}from"react";import{Fragment as sn,jsx as G,jsxs as Fe}from"react/jsx-runtime";function Gd(e,t=80){if(e==null)return String(e);if(typeof e!="object")return String(e).slice(0,t);if(Array.isArray(e))return`Array(${e.length})`;let a=JSON.stringify(e);if(a.length<=t)return a;let o=Object.entries(e),r=[],s=t-2;for(let[n,l]of o){if(s<=8)break;let i=n.length>4?`${n.slice(0,4)}\u2026`:n,u;typeof l=="string"?u=l.length>2?`'${l.slice(0,1)}\u2026`:`'${l}'`:Array.isArray(l)?u=`Array(${l.length})`:typeof l=="object"&&l!==null?u="{\u2026}":u=String(l);let f=`${i}\u2009${u}`;r.push(f),s-=f.length+3}return`{${r.join(", ")}}`}function Wd({text:e,className:t}){let[a,o]=_o(!1),r=Ud(null);Hd(()=>()=>{r.current&&clearTimeout(r.current)},[]);let s=qd(async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(e),o(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>o(!1),2e3)}catch{}},[e]);return G(Le,{variant:"ghost",size:"sm",onClick:s,className:P("ww:h-auto ww:gap-1 ww:px-1.5 ww:py-0.5 ww:text-xs ww:text-muted-foreground ww:hover:text-foreground",t),children:a?Fe(sn,{children:[G(xt,{className:"ww:size-3.5"}),G("span",{children:"Copied"})]}):Fe(sn,{children:[G(St,{className:"ww:size-3.5"}),G("span",{children:"Copy"})]})})}function ln({data:e,label:t,className:a,...o}){let[r,s]=_o(!1),n=Do(()=>JSON.stringify(e,null,2),[e]),l=Gd(e);return Fe("div",{className:P("ww:rounded-lg ww:bg-tool-card",a),...o,children:[Fe("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[G("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),G(Wd,{text:n})]}),Fe("button",{type:"button",onClick:()=>s(i=>!i),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[G(It,{className:P("ww:mt-0.5 ww:size-3.5 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-150",r&&"ww:rotate-90")}),r?G("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:G("code",{children:n})}):G("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:l})]})]})}var Eo=Od({open:!1,toggle:()=>{}});function un({className:e,defaultOpen:t=!1,children:a,...o}){let[r,s]=_o(t);return G(Eo.Provider,{value:{open:r,toggle:()=>s(n=>!n)},children:G("div",{className:P("ww:mb-4 ww:w-full",e),"data-state":r?"open":"closed",...o,children:a})})}function dn({className:e,title:t,state:a,...o}){let{open:r,toggle:s}=nn(Eo),n=a==="input-available"||a==="input-streaming";return Fe("button",{type:"button",onClick:s,className:P("ww:flex ww:w-full ww:items-center ww:justify-between ww:gap-3 ww:py-1.5",e),"aria-expanded":r,...o,children:[Fe("div",{className:"ww:flex ww:min-w-0 ww:items-center ww:gap-2",children:[G(Pe,{className:"ww:size-4 ww:shrink-0 ww:text-muted-foreground"}),G("span",{className:"ww:truncate ww:text-sm ww:font-medium",children:t}),n&&G("span",{className:"ww:size-2 ww:shrink-0 ww:rounded-full ww:bg-primary ww:animate-pulse"})]}),G(Ct,{className:P("ww:size-4 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function fn({className:e,children:t,...a}){let{open:o}=nn(Eo);return G("div",{className:P("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",o?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:G("div",{className:"ww:min-h-0 ww:overflow-hidden",children:G("div",{className:P("ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",e),...a,children:t})})})}function cn({className:e,input:t,debug:a,...o}){let r=Do(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:s,...n}=t;return n}return t},[t,a]);return G(ln,{data:r,label:"Request",className:e,...o})}function Bo(e){if(!(typeof e!="object"||e===null))return e}function pn(e){return Bo(e?.ui)}function mn(e){return Bo(Bo(e)?._meta)}function on(e){if(!e)return;let t=pn(e)?.resourceUri;if(typeof t=="string"&&t.length>0)return t;let a=e["ui/resourceUri"];if(typeof a=="string"&&a.length>0)return a;let o=e["openai/outputTemplate"];if(typeof o=="string"&&o.length>0)return o}function rn(e){return pn(e)?.autoHeight===!0}function _a(e,t,a){if(e){let o=on(a?.[e]?._meta);if(o)return o}return on(mn(t))}function hn(e,t,a){return e&&rn(a?.[e]?._meta)?!0:rn(mn(t))}function gn({className:e,output:t,errorText:a,debug:o,...r}){let s=Do(()=>{if(!o&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:n,...l}=t;return l}return t},[t,o]);return t||a?a?Fe("div",{className:P("ww:space-y-2",e),...r,children:[G("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:"Error"}),G("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):G(ln,{data:s,label:"Response",className:e,...r}):null}import{useCallback as zd,useEffect as Ln,useMemo as jd,useRef as se,useState as xn}from"react";function nt(e){if(!e)return!1;let t=Array.isArray(e.content)&&e.content.length>0,a=typeof e.structuredContent=="object"&&e.structuredContent!==null&&Object.keys(e.structuredContent).length>0;return t||a}function wn(e,t){return!nt(e)&&!nt(t)?null:nt(e)?nt(t)?{...e.content||t.content?{content:[...e.content??[],...t.content??[]]}:{},...e.structuredContent||t.structuredContent?{structuredContent:{...e.structuredContent??{},...t.structuredContent??{}}}:{}}:{...e.content?{content:[...e.content]}:{},...e.structuredContent?{structuredContent:{...e.structuredContent}}:{}}:{...t?.content?{content:[...t.content]}:{},...t?.structuredContent?{structuredContent:{...t.structuredContent}}:{}}}import{jsx as af}from"react/jsx-runtime";var Vd="/api/mcp/resource",$d=500,Xd=0,Qd=16,Kd="2026-01-26",Jd=300,Zd=3e3,Yd=3;function ef(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function tf(e,t,a){return _a(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function No({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:o=Vd,chatSessionId:r,isDark:s=!1,className:n,autoHeight:l=!1,onOpenLink:i,onFollowUp:u,onCallTool:f,onDisplayModeChange:d,isFullscreen:c=!1,toolDefinitions:p}){let g=se(null),I=se(t),C=se(a),m=se({width:0,height:0}),w=se(null),h=se(!1),L=se(0),x=se("inline"),[S,k]=xn(Xd),[v,_]=xn(void 0),F=se(i),y=se(u),T=se(f),O=se(d),B=se(r),E=se(p);I.current=t,C.current=a,F.current=i,y.current=u,T.current=f,O.current=d,B.current=r,E.current=p;let $=zd(M=>l?Math.max(M+Qd,0):Math.min(Math.max(M,50),$d),[l]),he=jd(()=>{let M=o.includes("?")?"&":"?";return`${o}${M}uri=${encodeURIComponent(e)}`},[o,e]),ge=se(s);return ge.current=s,Ln(()=>{if(!h.current)return;let M=g.current;M?.contentWindow&&M.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:s?"dark":"light"}},"*")},[s]),Ln(()=>{let M=g.current;if(!M)return;let q=!1,pe=!1,D=null,H=null,we=setTimeout(()=>{if(q||pe||L.current>=Yd)return;L.current+=1;let b=new URL(M.src);b.searchParams.set("_retry",String(L.current)),M.src=b.toString()},Zd),Z=b=>{M.contentWindow?.postMessage(b,"*")},jt=b=>{if(q||b.source!==M.contentWindow)return;let R=b.data;if(!R||typeof R!="object"||R.jsonrpc!=="2.0")return;let W=R.method,N=R.id;if(W==="ui/initialize"&&N!=null){pe=!0,clearTimeout(we),Z({jsonrpc:"2.0",id:N,result:{protocolVersion:R.params?.protocolVersion??Kd,hostInfo:{name:"WaniWani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:ge.current?"dark":"light",displayMode:x.current}}});return}if(W==="ui/notifications/initialized"){h.current=!0;let z=I.current,j=C.current,X=j._meta&&typeof j._meta=="object"?j._meta:null,ae=ef(B.current),fe=X&&typeof X.waniwani=="object"&&X.waniwani!==null?X.waniwani:null,Ge=fe||ae?{...fe??{},...ae?{sessionId:ae}:{}}:void 0,We=X||Ge?{...X??{},...Ge?{waniwani:Ge}:{}}:void 0;Z({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:z}});let Vt=j.content??[{type:"text",text:JSON.stringify(j)}];Z({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:Vt,structuredContent:j.structuredContent,_meta:We,meta:We}});return}if(W==="ui/notifications/size-changed"){let z=R.params,j=typeof z?.height=="number"?z.height:void 0,X=typeof z?.width=="number"?z.width:void 0,ae=m.current,fe=j!==void 0&&j!==ae.height,Ge=X!==void 0&&X!==ae.width;if(!fe&&!Ge)return;if(fe&&j!==void 0){ae.height=j;let We=$(j),Vt=M.getBoundingClientRect().height;if(w.current&&(w.current.cancel(),w.current=null),k(We),M.animate&&Math.abs(Vt-We)>2){let $t=M.animate([{height:`${Vt}px`},{height:`${We}px`}],{duration:Jd,easing:"ease-out",fill:"forwards"});w.current=$t,$t.onfinish=()=>{w.current===$t&&($t.cancel(),w.current=null)}}}Ge&&l&&X!==void 0&&(ae.width=X,_(X));return}if(W==="ui/open-link"&&N!=null){let z=R.params?.url;typeof z=="string"&&(F.current?F.current(z):window.open(z,"_blank","noopener,noreferrer")),Z({jsonrpc:"2.0",id:N,result:{}});return}if(W==="ui/message"&&N!=null){if(y.current&&R.params){let z=R.params,j=D;if(D=null,H){clearTimeout(H.timer);let X=H.text;H=null;let ae=(z.content??[]).map(fe=>fe.text??"").join("").trim();z={...z,content:[{type:"text",text:`${ae}
|
|
14
14
|
|
|
15
15
|
${X}`}]}}y.current({...z,...j?{modelContext:j}:{}})}Z({jsonrpc:"2.0",id:N,result:{}});return}if(W==="ui/update-model-context"&&N!=null){D=wn(D,R.params),Z({jsonrpc:"2.0",id:N,result:{}});return}if(W==="tools/call"&&N!=null){let z=T.current;if(!z){Z({jsonrpc:"2.0",id:N,error:{code:-32601,message:"tools/call not supported"}});return}let j=R.params?.name;z({name:j,arguments:R.params?.arguments??{}}).then(X=>{Z({jsonrpc:"2.0",id:N,result:X});let ae=X.content?.map(fe=>fe.text??"").join("").trim();ae&&tf(j,X,E.current)&&(H&&clearTimeout(H.timer),H={text:ae,timer:setTimeout(()=>{if(q)return;let fe=D;D=null,H=null,y.current?.({role:"user",content:[{type:"text",text:ae}],...fe?{modelContext:fe}:{}})},500)})}).catch(X=>{let ae=X instanceof Error?X.message:"Tool call failed";Z({jsonrpc:"2.0",id:N,error:{code:-32e3,message:ae}})});return}if(W==="ui/request-display-mode"&&N!=null){let z=R.params?.mode,j=z==="fullscreen"||z==="inline"||z==="pip"?z:"inline";x.current=j,Z({jsonrpc:"2.0",id:N,result:{mode:j}}),Z({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:j}}),O.current?.(j);return}if(W==="ui/resource-teardown"&&N!=null){Z({jsonrpc:"2.0",id:N,result:{}});return}W==="ping"&&N!=null&&Z({jsonrpc:"2.0",id:N,result:{}})};return window.addEventListener("message",jt),()=>{q=!0,clearTimeout(we),H&&clearTimeout(H.timer),window.removeEventListener("message",jt)}},[l,$]),af("iframe",{ref:g,src:he,sandbox:"allow-scripts allow-forms allow-same-origin",className:P(!c&&"ww:rounded-md ww:border ww:border-border",n),style:{height:c?"100%":S,minWidth:c||!v?void 0:`min(${v}px, 100%)`,width:"100%",border:"none",colorScheme:s?"dark":"auto"},title:"MCP App"})}import{jsx as Gt,jsxs as of}from"react/jsx-runtime";function Cn({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return of("div",{className:"ww:flex ww:flex-col ww:items-center ww:justify-center ww:py-12 ww:px-6 ww:text-center ww:min-h-full",children:[e&&Gt("div",{className:"ww:mb-4 ww:flex ww:items-center ww:justify-center ww:size-12 ww:rounded-xl ww:bg-foreground ww:text-background",children:e}),Gt("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&Gt("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&Gt("div",{className:"ww:mt-6 ww:w-full ww:max-w-md ww:flex ww:flex-col ww:gap-2",children:o.map((s,n)=>Gt("button",{type:"button",onClick:()=>r?.(s),className:P("ww:w-full ww:text-left ww:rounded-xl ww:border ww:border-border ww:bg-background ww:px-4 ww:py-3 ww:text-sm","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})]})}import{Component as rf}from"react";import{jsx as In,jsxs as sf}from"react/jsx-runtime";var Ea=class extends rf{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[WaniWani] Widget failed to render:",t.message)}render(){return this.state.hasError?sf("div",{className:"ww:flex ww:items-center ww:justify-between ww:rounded-md ww:border ww:border-border ww:bg-muted/50 ww:px-4 ww:py-3 ww:text-sm ww:text-muted-foreground",children:[In("span",{children:"Widget failed to load"}),In("button",{type:"button",onClick:()=>this.setState({hasError:!1}),className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:"Retry"})]}):this.props.children}};import{Fragment as lf,jsx as J,jsxs as it}from"react/jsx-runtime";function nf(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function lt({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:s,chatSessionId:n,isDark:l,onFollowUp:i,onCallTool:u,onWidgetDisplayModeChange:f,fullscreenToolCallId:d,debug:c,toolDefinitions:p}){let g=t==="submitted"||t==="streaming",I=e[e.length-1],C=e.length>0,m=g&&(!C||I.role==="user"),w=d!=null;return it(lf,{children:[!w&&(!C&&o?J(Cn,{...o,onSuggestionSelect:r}):a&&J(Ra,{from:"assistant",children:J(Ba,{children:J(Da,{children:a})})})),e.map(h=>{let L=h.parts.filter(y=>y.type==="text"),x=h.parts.filter(y=>y.type==="reasoning"),S=h.parts.filter(y=>y.type==="file"),k=h.parts.filter(y=>"toolCallId"in y),v=h===I&&h.role==="assistant",_=L.length>0,F=w?k.some(y=>y.toolCallId===d):!1;return w&&!F?J("div",{style:{display:"none"}},h.id):it(Ra,{from:h.role,children:[!F&&x.map((y,T)=>J(an,{text:y.text},`reasoning-${h.id}-${T}`)),k.map(y=>{let T="output"in y?y.output:void 0,O=_a(y.toolName,T,p),B=hn(y.toolName,T,p),E=y.toolCallId===d;return it("div",{style:E?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:[J("div",{style:E?{display:"none"}:void 0,children:it(un,{children:[J(dn,{title:y.title??nf(y.toolName),state:y.state}),it(fn,{children:[J(cn,{input:y.input,debug:c}),T!==void 0&&J(gn,{output:T,errorText:"errorText"in y?y.errorText:void 0,debug:c})]})]})}),O&&s&&T!==void 0&&J(Ea,{children:J(No,{isFullscreen:E,resourceUri:O,toolInput:y.input??{},toolResult:{content:T.content,structuredContent:T.structuredContent,_meta:T._meta},resourceEndpoint:s,chatSessionId:n,isDark:l,autoHeight:B,toolDefinitions:p,onFollowUp:i,onCallTool:u,onDisplayModeChange:f?$=>f($,{toolCallId:y.toolCallId,resourceUri:O,toolInput:y.input??{},toolResult:{content:T.content,structuredContent:T.structuredContent,_meta:T._meta},autoHeight:B}):void 0})})]},y.toolCallId)}),!F&&J("div",{children:it(Ba,{children:[S.length>0&&J(yr,{files:S}),_?L.map((y,T)=>J(Da,{children:y.type==="text"?y.text:""},`${h.id}-${T}`)):v&&g&&J(Ya,{})]})})]},h.id)}),!w&&m&&J(Ra,{from:"assistant",children:J(Ba,{children:J(Ya,{})})})]})}import{jsx as Na}from"react/jsx-runtime";function ut({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:Na("div",{className:P("ww:px-4 ww:py-2",o),...r,children:Na("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl ww:flex ww:flex-wrap ww:gap-2",children:t?[0,1,2].map(s=>Na("div",{className:"ww:h-7 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+s*20}px`}},s)):e.map((s,n)=>Na("button",{type:"button",onClick:()=>a(s),className:P("ww:rounded-full ww:border ww:border-border ww:bg-background ww:px-3 ww:py-1 ww:text-xs","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})})}import{useCallback as uf,useRef as df}from"react";function dt(e){let t=df(e);return t.current=e,uf(async a=>{let{api:o,headers:r,onCallTool:s,sessionId:n}=t.current;if(s)return s(a);let l=`${o??"/api/waniwani"}/tool`,i=typeof n=="string"&&n.trim().length>0?n.trim():void 0,u=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json",...i?{"X-Session-Id":i}:{},...r},body:JSON.stringify(a)});if(!u.ok)throw new Error(`Tool call failed: ${u.status} ${u.statusText}`);return u.json()},[])}import{useChat as xf}from"@ai-sdk/react";import{useCallback as ke,useEffect as ft,useRef as be,useState as qa}from"react";import{DefaultChatTransport as ff,uiMessageChunkSchema as cf}from"ai";function pf(e){let t=e?.cause,a=t?.issues??t?.errors;if(!Array.isArray(a))return null;let o=a.find(r=>r.code==="invalid_union");if(!o?.errors)return null;for(let r of o.errors){if(!Array.isArray(r)||r.some(l=>(l.code==="invalid_value"||l.code==="invalid_literal")&&l.path?.[0]==="type"))continue;let n=r.filter(l=>l.code==="unrecognized_keys").flatMap(l=>l.keys??[]);if(n.length>0)return n}return null}var Oa=class extends ff{processResponseStream(t){let a="",o=cf(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(s,n){a+=s;let l=a.split(`
|
|
16
|
-
`);a=l.pop()??"";for(let i of l){let u=i.trim();if(!u.startsWith("data:"))continue;let f=u.slice(5).trim();if(f!=="[DONE]")try{let d=JSON.parse(f);if(!r){n.enqueue(d);continue}let c=await r(d);if(c.success){n.enqueue(c.value);continue}let p=pf(c.error);if(p?.length){let g={...d};for(let C of p)delete g[C];let I=await r(g);I.success&&n.enqueue(I.value)}}catch{}}}}))}};var Sn="waniwani-visitor-id";function yn(e,t){return e.match(t)?.[1]??null}function mf(e){let t=[["Edge",/Edg(?:e|A|iOS)?\/(\S+)/],["Opera",/(?:OPR|Opera)\/(\S+)/],["Samsung Internet",/SamsungBrowser\/(\S+)/],["Firefox",/Firefox\/(\S+)/],["Chrome",/Chrome\/(\S+)/],["Safari",/Version\/(\S+).*Safari/]];for(let[a,o]of t){let r=yn(e,o);if(r)return{name:a,version:r}}return null}function hf(e){let t=[["iOS",/(?:iPhone|iPad|iPod).+?OS (\d+[_.\d]*)/],["Android",/Android (\d+[.\d]*)/],["macOS",/Mac OS X (\d+[_.\d]*)/],["Windows",/Windows NT (\d+[.\d]*)/],["ChromeOS",/CrOS \S+ (\d+[.\d]*)/],["Linux",/Linux/]];for(let[a,o]of t){let r=yn(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function gf(e){return typeof navigator<"u"&&"userAgentData"in navigator&&navigator.userAgentData?.mobile?"mobile":/iPad|tablet|PlayBook/i.test(e)?"tablet":/Mobi|Android.*Mobile|iPhone|iPod/i.test(e)?"mobile":"desktop"}async function wf(e){let t=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}async function Lf(){try{let a=localStorage.getItem(Sn);if(a)return a}catch{}let e=[navigator.userAgent,screen.width,screen.height,screen.colorDepth,Intl.DateTimeFormat().resolvedOptions().timeZone,navigator.language,navigator.hardwareConcurrency??"",navigator.platform??""].join("|"),t=await wf(e);try{localStorage.setItem(Sn,t)}catch{}return t}async function kn(){let e=navigator.userAgent,t=await Lf();return{userAgent:e,browser:mf(e),os:hf(e),deviceType:gf(e),language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,colorDepth:screen.colorDepth,devicePixelRatio:window.devicePixelRatio??1,touchSupport:"ontouchstart"in window||navigator.maxTouchPoints>0,connectionType:navigator.connection?.effectiveType??"unknown",referrer:document.referrer,visitorId:t}}var Cf="x-session-id";function bn(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function If(e,t){let a=`${e.replace(/\/$/,"")}/tools`,o=await fetch(a,{method:"GET",headers:t?{...t}:void 0});if(!o.ok)throw new Error(`[WaniWani] Failed to fetch /tools: ${o.status} ${o.statusText}`);let r=await o.json();if(!r||!Array.isArray(r.tools))return{};let s={};for(let n of r.tools)n&&typeof n.name=="string"&&(s[n.name]=n);return s}function ct(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:s}=e,n=be(a),l=be(o),i=be(void 0),u=be(null),[f,d]=qa(void 0),c=be(f),p=ke(()=>c.current,[]),g=ke(b=>{let R=bn(b);R&&c.current!==R&&(c.current=R,d(R))},[]),I=ke(()=>{c.current=void 0,d(void 0)},[]);ft(()=>{n.current=a},[a]),ft(()=>{l.current=o},[o]),ft(()=>{kn().then(b=>{u.current=b}).catch(()=>{})},[]);let C=be(new Oa({api:t,headers:()=>({...n.current}),body:()=>{let b={...l.current??{}},R=Object.hasOwn(b,"sessionId"),W=bn(b.sessionId);if(W)g(W),b.sessionId=W;else if(R)I(),delete b.sessionId;else{let N=p();N&&(b.sessionId=N)}if(nt(i.current)&&(b.modelContext=i.current),u.current){let N=u.current;b.visitorContext={timezone:N.timezone,language:N.language,languages:N.languages,deviceType:N.deviceType,referrer:N.referrer,visitorId:N.visitorId}}return b},fetch:(async(b,R)=>{let W=await fetch(b,R);return i.current=void 0,g(W.headers.get(Cf)),W})})),m=be(null),w=be(null),h=be({}),[L,x]=qa(0),S=e.skipRemoteConfig===!0,k=ke(async()=>{if(!S)try{let b=await If(t,n.current);h.current=b,x(R=>R+1)}catch(b){console.warn("[WaniWani] Failed to fetch tool definitions:",b instanceof Error?b.message:b)}},[t,S]);ft(()=>{k()},[k]);let{messages:v,sendMessage:_,setMessages:F,status:y}=xf({messages:e.initialMessages,transport:C.current,onFinish({message:b}){s?.(),m.current&&(w.current=b)},onError(b){console.warn("[WaniWani] Chat error:",b.message),m.current&&(m.current.reject(b),m.current=null)}});ft(()=>{if(y==="ready"&&m.current&&w.current){let b=m.current,R=w.current;m.current=null,w.current=null,b.resolve(R)}},[y]);let[T,O]=qa(""),[B,E]=qa([]),$=y==="submitted"||y==="streaming",he=ke(b=>{E(R=>R.filter(W=>W.id!==b))},[]),ge=$&&B.length>0,M=ke(b=>{let R=!!b.text?.trim(),W=!!b.files?.length;if(R||W){if($){if(B.length>0)return;E(N=>[...N,{id:Yt(),text:b.text||"",files:b.files??[],modelContext:b.modelContext}]),O("");return}i.current=b.modelContext,_({text:b.text||"",files:b.files}),r?.(b.text||""),O("")}},[_,r,$,B.length]),q=ke(b=>new Promise((R,W)=>{m.current={resolve:R,reject:W},_({text:b}),r?.(b)}),[_,r]);ft(()=>{if(y!=="ready"||B.length===0)return;let[b,...R]=B;E(R),i.current=b.modelContext,_({text:b.text,files:b.files.length>0?b.files:void 0}),r?.(b.text)},[y,_,r,B]);let pe=ke(()=>{F([]),E([]),I(),O(""),h.current={},x(b=>b+1),k()},[F,I,k]),D=ke(b=>{O(b.target.value)},[]),H=v[v.length-1],we=v.length>0,Z=$&&(!we||H.role==="user"),jt=h.current;return{messages:v,status:y,text:T,setText:O,handleSubmit:M,handleTextChange:D,isLoading:$,showLoaderBubble:Z,lastMessage:H,hasMessages:we,sendMessage:_,sendMessageAndWait:q,reset:pe,queuedMessages:B,queueFull:ge,removeQueuedMessage:he,sessionId:f,toolDefinitions:jt,refreshToolDefinitions:k}}import{useEffect as Pn,useRef as Sf,useState as yf}from"react";var kf={debug:!1,eval:!1};function pt(e="/api/waniwani",t,a=!1){let[o,r]=yf(kf),s=Sf(t);return Pn(()=>{s.current=t},[t]),Pn(()=>{a||(async()=>{try{let n=s.current,i=await(await fetch(`${e}/config`,{headers:n?{...n}:void 0})).json();r({debug:i.debug===!0,eval:i.eval===!0})}catch{}})()},[e,a]),o}import{useCallback as bf,useEffect as Oo,useRef as Pf,useState as Tf}from"react";function Af(e){for(let t of e.parts){let a=t;if(a.type==="data"||a.type==="data-suggestions"){let o=a.data;if(o&&Array.isArray(o.suggestions))return o.suggestions}}return null}function Tn(e){return typeof e=="object"&&e!==null&&"initial"in e}function mt(e){let{messages:t,status:a,config:o}=e,r=Tn(o)&&o.initial?o.initial:void 0,[s,n]=Tf(r??[]),l=Pf(a),i=o===!0||Tn(o)&&o.dynamic!==!1,u=bf(()=>{n([])},[]),f=t.length>0;Oo(()=>{!f&&r&&r.length>0&&n(r)},[r,f]);let d=t[t.length-1];return Oo(()=>{d?.role==="user"&&u()},[d,u]),Oo(()=>{let c=l.current;if(l.current=a,c==="streaming"&&a==="ready"&&i){let p=[...t].reverse().find(I=>I.role==="assistant");if(!p)return;console.log("[WaniWani] Assistant parts:",p.parts);let g=Af(p);console.log("[WaniWani] Extracted suggestions:",g),g&&n(g)}},[a,i,t]),{suggestions:s,isLoading:!1,clear:u}}import{useEffect as vf,useRef as Mf,useState as Ff}from"react";var Rf=50,Bf=30,Df=2e3,An=500;function ht(e,t=!0){let[a,o]=Ff(""),r=Mf(void 0);return vf(()=>{if(!t){o("");return}let s=0,n=!1,l=!1,i=()=>{l||(n?(s--,o(e.slice(0,s)),s<=0?(n=!1,r.current=setTimeout(i,An)):r.current=setTimeout(i,Bf)):(s++,o(e.slice(0,s)),s>=e.length?(n=!0,r.current=setTimeout(i,Df)):r.current=setTimeout(i,Rf)))};return r.current=setTimeout(i,An),()=>{l=!0,clearTimeout(r.current)}},[e,t]),a}function Ha(e,t){let a=t?.Authorization,o=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return o?`${e}/resource?token=${encodeURIComponent(o)}`:`${e}/resource`}var vn={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",assistantBubbleColor:"#f3f4f6",userBubbleColor:"#f4f4f4",inputBackgroundColor:"#f9fafb",borderRadius:16,messageBorderRadius:12,fontFamily:"system-ui, -apple-system, 'Segoe UI', sans-serif",headerBackgroundColor:"#ffffff",headerTextColor:"#1f2937",statusColor:"#22c55e",toolCardColor:"#f4f4f5"},_f={backgroundColor:"#212121",headerBackgroundColor:"#1e1e1e",headerTextColor:"#ececec",textColor:"#ececec",primaryForeground:"#ffffff",mutedColor:"#8e8ea0",borderColor:"#444444",assistantBubbleColor:"#2f2f2f",userBubbleColor:"#303030",inputBackgroundColor:"#2f2f2f",primaryColor:"#6366f1",statusColor:"#22c55e",toolCardColor:"#262626"},Ef={primaryColor:["--ww-primary","--ww-color-primary"],primaryForeground:["--ww-primary-fg","--ww-color-primary-foreground"],backgroundColor:["--ww-bg","--ww-color-background"],textColor:["--ww-text","--ww-color-foreground","--ww-color-accent-foreground"],mutedColor:["--ww-muted","--ww-color-muted-foreground"],borderColor:["--ww-border","--ww-color-border"],assistantBubbleColor:["--ww-assistant-bubble","--ww-color-accent"],userBubbleColor:["--ww-user-bubble"],inputBackgroundColor:["--ww-input-bg","--ww-color-input"],borderRadius:["--ww-radius"],messageBorderRadius:["--ww-msg-radius"],fontFamily:["--ww-font"],headerBackgroundColor:["--ww-header-bg"],headerTextColor:["--ww-header-text"],statusColor:["--ww-status"],toolCardColor:["--ww-tool-card","--ww-color-tool-card"]};function He(e){return{...vn,...e}}function gt(e){let t=e.backgroundColor.replace("#",""),a=parseInt(t.substring(0,2),16),o=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16);return(a*299+o*587+r*114)/1e3<128}function Ue(e){let t={};for(let[a,o]of Object.entries(Ef)){let r=e[a],s=typeof r=="number"?`${r}px`:String(r);for(let n of o)t[n]=s}return t}import{jsx as ne,jsxs as Wt}from"react/jsx-runtime";var Ho=Nf(function(t,a){let{theme:o,title:r="Assistant",width:s=600,expandedWidth:n,expandedHeight:l=400,allowAttachments:i=!1,welcomeMessage:u,welcome:f,placeholder:d="Ask me anything...",triggerEvent:c="triggerDemoRequest",api:p}=t,g=n??Math.round((typeof s=="number"?s:600)*1.2),I=p??"/api/waniwani",C=Ha(I,t.headers),m=He(o),w=Ue(m),h=gt(m),L=pt(p,t.headers,t.skipRemoteConfig),x=ct(t),S=dt({...t,sessionId:x.sessionId}),k=mt({messages:x.messages,status:x.status,config:t.suggestions}),v=Ua(D=>{let H=D.content.map(we=>we.text??"").join("").trim();H&&x.handleSubmit({text:H,files:[],modelContext:D.modelContext})},[x.handleSubmit]),_=Ua(D=>{k.clear(),x.handleSubmit({text:D,files:[]})},[k.clear,x.handleSubmit]),F=ht(d,!x.text),[y,T]=qo(!1),[O,B]=qo(!1),[E,$]=qo(null),he=Fn(null),ge=Fn(void 0),M=Ua(()=>{let D=he.current;if(!D)return;D.scrollIntoView({behavior:"smooth",block:"center"});let H=D.querySelector("textarea");H&&setTimeout(()=>H.focus(),300),T(!0),B(!0),clearTimeout(ge.current),ge.current=setTimeout(()=>B(!1),2e3)},[]);Of(a,()=>({sendMessage:D=>{x.handleSubmit({text:D,files:[]}),M()},sendMessageAndWait:D=>x.sendMessageAndWait(D),reset:x.reset,focus:M,get messages(){return x.messages}}),[x.handleSubmit,x.sendMessageAndWait,x.reset,x.messages,M]),Mn(()=>{if(!c)return;let D=H=>{let we=H.detail,Z=typeof we?.message=="string"?we.message:void 0;Z&&x.handleSubmit({text:Z,files:[]}),M()};return window.addEventListener(c,D),()=>window.removeEventListener(c,D)},[c,x.handleSubmit,M]);let q=y||E!==null;Mn(()=>{if(!y)return;let D=H=>{he.current&&!he.current.contains(H.target)&&T(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[y]);let pe=Ua(()=>{T(!0)},[]);return Wt("div",{ref:he,style:{...w,width:q?g:s,transition:"width 0.4s cubic-bezier(0.16, 1, 0.3, 1)"},"data-waniwani-chat":"","data-waniwani-layout":"bar",...h?{"data-waniwani-dark":""}:{},className:"ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground",children:[Wt("div",{style:{overflow:"hidden",backgroundColor:m.backgroundColor,borderRadius:"var(--ww-radius) var(--ww-radius) 0 0",maxHeight:q?l+200:0,opacity:q?1:0,transform:q?"scaleX(1)":"scaleX(0.88)",transformOrigin:"center bottom",transition:"max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease-out, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1)"},children:[Wt("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:px-6 ww:py-3",style:{backgroundColor:m.headerBackgroundColor,color:m.headerTextColor},children:[ne("div",{className:"ww:text-sm ww:font-semibold ww:truncate",children:r}),ne(ea,{messages:x.messages,evalEnabled:L.eval,api:I})]}),Wt($e,{className:"ww:flex-1",style:{height:l},children:[ne(Xe,{scrollClassName:E?"ww:!relative ww:!overflow-hidden":void 0,children:ne(lt,{messages:x.messages,status:x.status,welcomeMessage:u,welcome:f,onSuggestionSelect:_,resourceEndpoint:C,chatSessionId:x.sessionId,isDark:h,onFollowUp:v,onCallTool:S,fullscreenToolCallId:E,toolDefinitions:x.toolDefinitions,onWidgetDisplayModeChange:(D,H)=>{$(D==="fullscreen"?H.toolCallId:null)}})}),ne(Qe,{})]}),ne("div",{style:E?{display:"none"}:void 0,children:ne(ut,{suggestions:k.suggestions,isLoading:k.isLoading,onSelect:_})}),ne("div",{style:E?{display:"none"}:void 0,children:ne(at,{queuedMessages:x.queuedMessages,onRemove:x.removeQueuedMessage})})]}),ne("div",{style:{backgroundColor:q?m.backgroundColor:"transparent",borderRadius:q?"0 0 var(--ww-radius) var(--ww-radius)":void 0,boxShadow:q?"0 8px 24px rgba(0,0,0,0.1)":"none",transition:"background-color 0.2s ease, border-radius 0.3s ease, box-shadow 0.35s ease, padding 0.3s ease",padding:q?"8px 16px 16px":"0"},children:ne(Je,{onSubmit:x.handleSubmit,globalDrop:i,multiple:i,className:P("ww:rounded-2xl ww:border-border ww:bg-input ww:transition-all ww:duration-300",!q&&"ww:shadow-sm",O&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background"),children:Wt("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[i&&ne(et,{}),ne(Ze,{onChange:x.handleTextChange,value:x.text,placeholder:F,onFocus:pe,className:"ww:min-h-0 ww:py-1 ww:px-0"}),ne(Ye,{status:x.status,disabled:x.queueFull})]})})})]})});import{useEffect as Hf,useRef as _n,useState as zt}from"react";import{useCallback as Rn,useEffect as qf,useState as Bn}from"react";function Dn(e,t){let[a,o]=Bn([]),[r,s]=Bn(!1),n=Rn(()=>{t&&(s(!0),fetch(`${e}/scenarios`).then(i=>i.json()).then(i=>o(Array.isArray(i)?i:[])).catch(()=>{}).finally(()=>s(!1)))},[e,t]);qf(()=>{n()},[n]);let l=Rn(async(i,u)=>{let f=await fetch(`${e}/scenarios/${i}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:u})});if(!f.ok){let d=await f.json().catch(()=>null);throw new Error(d?.error??`Failed to rename scenario (${f.status})`)}o(d=>d.map(c=>c.id===i?{...c,name:u}:c))},[e]);return{scenarios:a,isLoading:r,reload:n,rename:l}}import{jsx as A,jsxs as de}from"react/jsx-runtime";function Uf(e){return e.parts.filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join("")}function Gf({className:e}){return de("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",className:e,role:"img",children:[A("title",{children:"Run scenario"}),A("path",{d:"M6 4l15 8-15 8V4z"})]})}function Wf({className:e}){return de("svg",{xmlns:"http://www.w3.org/2000/svg",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,role:"img",children:[A("title",{children:"Rename scenario"}),A("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"})]})}function zf({className:e}){return de("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:e,role:"img",children:[A("title",{children:"Confirm"}),A("path",{d:"M20 6 9 17l-5-5"})]})}function jf({className:e}){return de("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:e,role:"img",children:[A("title",{children:"Cancel"}),A("path",{d:"M18 6 6 18"}),A("path",{d:"m6 6 12 12"})]})}function En({className:e}){return de("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:P("ww:animate-spin",e),role:"img",children:[A("title",{children:"Running"}),A("path",{d:"M12 2v4"}),A("path",{d:"M12 18v4"}),A("path",{d:"m4.93 4.93 2.83 2.83"}),A("path",{d:"m16.24 16.24 2.83 2.83"}),A("path",{d:"M2 12h4"}),A("path",{d:"M18 12h4"}),A("path",{d:"m4.93 19.07 2.83-2.83"}),A("path",{d:"m16.24 4.93 2.83 2.83"})]})}function Vf(){return A("div",{className:"ww:px-3 ww:py-2 ww:space-y-3",children:[1,2,3,4].map(e=>de("div",{className:"ww:flex ww:items-center ww:gap-2",children:[A("div",{className:"ww:h-1.5 ww:w-1.5 ww:rounded-full ww:bg-muted-foreground/20 ww:shrink-0 ww:animate-pulse"}),A("div",{className:"ww:h-3.5 ww:rounded ww:bg-muted-foreground/10 ww:animate-pulse",style:{width:`${50+e*10}%`,animationDelay:`${e*100}ms`}})]},e))})}function $f({initialName:e,onSave:t,onCancel:a}){let o=_n(null),[r,s]=zt(e),[n,l]=zt(!1);Hf(()=>{o.current?.focus(),o.current?.select()},[]);let i=r.trim()!==""&&r.trim()!==e;async function u(){if(!(!i||n)){l(!0);try{await t(r.trim())}finally{l(!1)}}}function f(d){d.key==="Enter"?u():d.key==="Escape"&&a()}return de("div",{className:"ww:flex ww:items-center ww:gap-1",children:[A("input",{ref:o,type:"text",value:r,onChange:d=>s(d.target.value),onKeyDown:f,disabled:n,className:"ww:flex-1 ww:min-w-0 ww:bg-transparent ww:text-xs ww:leading-normal ww:font-mono ww:text-foreground ww:outline-none ww:border-b ww:border-foreground/30 ww:p-0 ww:disabled:opacity-50"}),A("button",{type:"button",onClick:u,disabled:!i||n,className:"ww:bg-foreground ww:text-background ww:rounded-full ww:p-1 ww:disabled:opacity-30 ww:transition-colors ww:cursor-pointer ww:shrink-0",title:"Confirm rename",children:n?A(En,{}):A(zf,{})}),A("button",{type:"button",onClick:a,className:"ww:bg-foreground ww:text-background ww:rounded-full ww:p-1 ww:transition-colors ww:cursor-pointer ww:shrink-0",title:"Cancel",children:A(jf,{})})]})}var Xf=320;function Qf({api:e,chatRef:t}){let a=e??"/api/waniwani",[o,r]=zt(null),[s,n]=zt(null),[l,i]=zt(null),u=_n(null),f=pt(a),{scenarios:d,isLoading:c,reload:p,rename:g}=Dn(a,f.eval);async function I(m){u.current?.abort(),u.current=new AbortController,r(m.id);try{if(!t?.current)throw new Error("ScenarioPanel requires a chatRef prop pointing to the ChatCard/ChatBar");t.current.reset();let w=m.messages.filter(h=>h.role==="user");for(let h of w){let L=Uf(h);L&&await t.current.sendMessageAndWait(L)}}catch(w){w.name!=="AbortError"&&console.error("[ScenarioPanel] run failed:",w)}finally{r(null)}}async function C(m,w){i(null);try{await g(m,w)}catch(h){let L=h instanceof Error?h.message:"Failed to rename scenario";i(L)}n(h=>h===m?null:h)}return f.eval?de("div",{"data-waniwani-chat":"",className:"ww:flex ww:flex-col ww:h-full ww:overflow-hidden ww:text-foreground ww:border-l ww:border-border ww:shrink-0",style:{width:Xf},children:[de("div",{className:"ww:px-3 ww:py-2 ww:border-b ww:border-border/50 ww:flex ww:items-center ww:justify-between",children:[A("span",{className:"ww:text-[10px] ww:font-mono ww:uppercase ww:tracking-widest ww:text-foreground/60",children:"Scenarios"}),A("button",{type:"button",onClick:p,className:"ww:bg-foreground ww:text-background ww:rounded-full ww:p-1 ww:transition-colors ww:cursor-pointer",title:"Reload scenarios",children:de("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img",children:[A("title",{children:"Reload scenarios"}),A("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),A("path",{d:"M21 3v5h-5"})]})})]}),l&&de("div",{className:"ww:mx-3 ww:my-2 ww:px-2 ww:py-1.5 ww:text-[11px] ww:font-mono ww:text-red-400 ww:bg-red-500/10 ww:rounded ww:flex ww:items-start ww:gap-1.5",children:[A("span",{className:"ww:flex-1",children:l}),A("button",{type:"button",onClick:()=>i(null),className:"ww:shrink-0 ww:text-red-400 ww:hover:text-red-300 ww:cursor-pointer",children:"\xD7"})]}),A("div",{className:"ww:flex-1 ww:overflow-y-auto ww:min-h-0",children:c?A(Vf,{}):d.length===0?A("p",{className:"ww:text-xs ww:font-mono ww:text-foreground/50 ww:text-center ww:py-8 ww:px-4",children:"No scenarios found"}):d.map(m=>{let w=o===m.id,h=s===m.id;return de("div",{className:P("ww:group ww:flex ww:items-center ww:gap-1 ww:px-3 ww:py-2 ww:border-l-2 ww:transition-colors",w?"ww:border-[#03d916] ww:bg-[#03d916]/10":"ww:border-transparent ww:hover:bg-muted/50"),children:[A("div",{className:"ww:flex-1 ww:min-w-0",children:h?A($f,{initialName:m.name,onSave:L=>C(m.id,L),onCancel:()=>n(null)}):A("span",{className:"ww:block ww:truncate ww:text-xs ww:font-mono ww:text-foreground",title:m.name,children:m.name})}),!h&&de("div",{className:"ww:flex ww:items-center ww:gap-1 ww:shrink-0",children:[!w&&A("button",{type:"button",onClick:()=>n(m.id),className:"ww:opacity-0 ww:group-hover:opacity-100 ww:bg-foreground ww:text-background ww:rounded-full ww:p-1 ww:transition-all ww:cursor-pointer",title:"Rename scenario",children:A(Wf,{})}),A("button",{type:"button",onClick:()=>I(m),disabled:o!==null,className:"ww:bg-foreground ww:text-background ww:rounded-full ww:p-1 ww:disabled:opacity-40 ww:transition-colors ww:cursor-pointer",title:"Run scenario",children:w?A(En,{}):A(Gf,{})})]})]},m.id)})})]}):null}import{forwardRef as Kf,useCallback as Uo,useEffect as Jf,useImperativeHandle as Zf,useRef as Nn,useState as On}from"react";import{jsx as re,jsxs as Ga}from"react/jsx-runtime";var Yf=Kf(function(t,a){let{theme:o,title:r="Assistant",width:s,height:n,className:l,allowAttachments:i=!1,welcomeMessage:u,welcome:f,placeholder:d="Ask me anything...",triggerEvent:c="triggerDemoRequest",api:p,debug:g}=t,I=p??"/api/waniwani",C=Ha(I,t.headers),m=He(o),w=Ue(m),h=gt(m),L=pt(I,t.headers,t.skipRemoteConfig),x=g??L.debug,S=ct({...t,api:I}),k=dt({...t,api:I,sessionId:S.sessionId}),v=ht(d,!S.text),[_,F]=On(!1),[y,T]=On(null),O=Nn(null),B=Nn(void 0),E=Uo(()=>{let M=O.current;if(!M)return;M.scrollIntoView({behavior:"smooth",block:"center"});let q=M.querySelector("textarea");q&&setTimeout(()=>q.focus(),300),F(!0),clearTimeout(B.current),B.current=setTimeout(()=>F(!1),2e3)},[]),$=mt({messages:S.messages,status:S.status,config:t.suggestions}),he=Uo(M=>{let q=M.content.map(pe=>pe.text??"").join("").trim();q&&S.handleSubmit({text:q,files:[],modelContext:M.modelContext})},[S.handleSubmit]),ge=Uo(M=>{$.clear(),S.handleSubmit({text:M,files:[]})},[$.clear,S.handleSubmit]);return Zf(a,()=>({sendMessage:M=>{S.handleSubmit({text:M,files:[]}),E()},sendMessageAndWait:M=>S.sendMessageAndWait(M),reset:S.reset,focus:E,get messages(){return S.messages}}),[S.handleSubmit,S.sendMessageAndWait,S.reset,S.messages,E]),Jf(()=>{if(!c)return;let M=q=>{let pe=q.detail,D=typeof pe?.message=="string"?pe.message:void 0;D&&S.handleSubmit({text:D,files:[]}),E()};return window.addEventListener(c,M),()=>window.removeEventListener(c,M)},[c,S.handleSubmit,E]),Ga("div",{ref:O,style:{...w,width:s,height:n},"data-waniwani-chat":"","data-waniwani-layout":"card",...h?{"data-waniwani-dark":""}:{},className:P("ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:rounded-[var(--ww-radius)] ww:overflow-hidden",_&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",l),children:[Ga("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:px-6 ww:py-3",style:{backgroundColor:m.headerBackgroundColor,color:m.headerTextColor},children:[re("div",{className:"ww:text-sm ww:font-semibold ww:truncate",children:r}),re(ea,{messages:S.messages,evalEnabled:L.eval,api:I})]}),Ga($e,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[re(Xe,{scrollClassName:y?"ww:!relative ww:!overflow-hidden":void 0,children:re(lt,{messages:S.messages,status:S.status,welcomeMessage:u,welcome:f,onSuggestionSelect:ge,resourceEndpoint:C,chatSessionId:S.sessionId,isDark:h,onFollowUp:he,onCallTool:k,fullscreenToolCallId:y,debug:x,toolDefinitions:S.toolDefinitions,onWidgetDisplayModeChange:(M,q)=>{T(M==="fullscreen"?q.toolCallId:null)}})}),re(Qe,{})]}),re("div",{style:y?{display:"none"}:void 0,children:re(ut,{suggestions:$.suggestions,isLoading:$.isLoading,onSelect:ge})}),re("div",{style:y?{display:"none"}:void 0,children:re(at,{queuedMessages:S.queuedMessages,onRemove:S.removeQueuedMessage})}),re("div",{style:y?{display:"none"}:void 0,children:re("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:re("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:re(Je,{onSubmit:S.handleSubmit,globalDrop:i,multiple:i,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:Ga("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[i&&re(et,{}),re(Ze,{onChange:S.handleTextChange,value:S.text,placeholder:v,className:"ww:min-h-0 ww:py-1 ww:px-0"}),re(Ye,{status:S.status,disabled:S.queueFull})]})})})})})]})});import{forwardRef as ec,useCallback as Go,useEffect as tc,useImperativeHandle as ac,useRef as oc,useState as rc}from"react";import{jsx as ie,jsxs as Wo}from"react/jsx-runtime";var sc=ec(function(t,a){let{theme:o,className:r,allowAttachments:s=!1,welcomeMessage:n,welcome:l,placeholder:i="Ask me anything...",triggerEvent:u="triggerDemoRequest",api:f,mcp:d,debug:c=!1,readOnly:p=!1}=t,g=He(o),I=Ue(g),C=gt(g),m=ct({...t,api:f}),w=dt({...t,api:f,sessionId:m.sessionId,onCallTool:d?.onCallTool}),h=ht(i,!m.text),[L,x]=rc(null),S=oc(null),k=Go(()=>{let y=S.current;if(!y)return;let T=y.querySelector("textarea");T&&T.focus()},[]),v=mt({messages:m.messages,status:m.status,config:t.suggestions}),_=Go(y=>{let T=y.content.map(O=>O.text??"").join("").trim();T&&m.handleSubmit({text:T,files:[],modelContext:y.modelContext})},[m.handleSubmit]),F=Go(y=>{v.clear(),m.handleSubmit({text:y,files:[]})},[v.clear,m.handleSubmit]);return ac(a,()=>({sendMessage:y=>{m.handleSubmit({text:y,files:[]}),k()},sendMessageAndWait:y=>m.sendMessageAndWait(y),reset:m.reset,focus:k,get messages(){return m.messages}}),[m.handleSubmit,m.sendMessageAndWait,m.reset,m.messages,k]),tc(()=>{if(!u)return;let y=T=>{let O=T.detail,B=typeof O?.message=="string"?O.message:void 0;B&&m.handleSubmit({text:B,files:[]}),k()};return window.addEventListener(u,y),()=>window.removeEventListener(u,y)},[u,m.handleSubmit,k]),Wo("div",{ref:S,style:I,"data-waniwani-chat":"","data-waniwani-layout":"embed",...C?{"data-waniwani-dark":""}:{},className:P("ww:flex ww:flex-col ww:w-full ww:h-full ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:overflow-hidden",r),children:[Wo($e,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[ie(Xe,{scrollClassName:L?"ww:!relative ww:!overflow-hidden":void 0,children:ie(lt,{messages:m.messages,status:m.status,welcomeMessage:n,welcome:l,onSuggestionSelect:F,resourceEndpoint:d?.resourceEndpoint,chatSessionId:m.sessionId,isDark:C,onFollowUp:_,onCallTool:w,fullscreenToolCallId:L,debug:c,toolDefinitions:m.toolDefinitions,onWidgetDisplayModeChange:(y,T)=>{x(y==="fullscreen"?T.toolCallId:null)}})}),ie(Qe,{})]}),!p&&ie("div",{style:L?{display:"none"}:void 0,children:ie(ut,{suggestions:v.suggestions,isLoading:v.isLoading,onSelect:F})}),!p&&ie("div",{style:L?{display:"none"}:void 0,children:ie(at,{queuedMessages:m.queuedMessages,onRemove:m.removeQueuedMessage})}),!p&&ie("div",{style:L?{display:"none"}:void 0,children:ie("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:ie("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:ie(Je,{onSubmit:m.handleSubmit,globalDrop:s,multiple:s,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:Wo("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[s&&ie(et,{}),ie(Ze,{onChange:m.handleTextChange,value:m.text,placeholder:h,className:"ww:min-h-0 ww:py-1 ww:px-0"}),ie(Ye,{status:m.status,disabled:m.queueFull})]})})})})})]})});export{Ho as ChatBar,Yf as ChatCard,sc as ChatEmbed,Ho as ChatWidget,_f as DARK_THEME,vn as DEFAULT_THEME,No as McpAppFrame,Qf as ScenarioPanel,He as mergeTheme,Ue as themeToCSSProperties};
|
|
16
|
+
`);a=l.pop()??"";for(let i of l){let u=i.trim();if(!u.startsWith("data:"))continue;let f=u.slice(5).trim();if(f!=="[DONE]")try{let d=JSON.parse(f);if(!r){n.enqueue(d);continue}let c=await r(d);if(c.success){n.enqueue(c.value);continue}let p=pf(c.error);if(p?.length){let g={...d};for(let C of p)delete g[C];let I=await r(g);I.success&&n.enqueue(I.value)}}catch{}}}}))}};var Sn="waniwani-visitor-id";function yn(e,t){return e.match(t)?.[1]??null}function mf(e){let t=[["Edge",/Edg(?:e|A|iOS)?\/(\S+)/],["Opera",/(?:OPR|Opera)\/(\S+)/],["Samsung Internet",/SamsungBrowser\/(\S+)/],["Firefox",/Firefox\/(\S+)/],["Chrome",/Chrome\/(\S+)/],["Safari",/Version\/(\S+).*Safari/]];for(let[a,o]of t){let r=yn(e,o);if(r)return{name:a,version:r}}return null}function hf(e){let t=[["iOS",/(?:iPhone|iPad|iPod).+?OS (\d+[_.\d]*)/],["Android",/Android (\d+[.\d]*)/],["macOS",/Mac OS X (\d+[_.\d]*)/],["Windows",/Windows NT (\d+[.\d]*)/],["ChromeOS",/CrOS \S+ (\d+[.\d]*)/],["Linux",/Linux/]];for(let[a,o]of t){let r=yn(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function gf(e){return typeof navigator<"u"&&"userAgentData"in navigator&&navigator.userAgentData?.mobile?"mobile":/iPad|tablet|PlayBook/i.test(e)?"tablet":/Mobi|Android.*Mobile|iPhone|iPod/i.test(e)?"mobile":"desktop"}async function wf(e){let t=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}async function Lf(){try{let a=localStorage.getItem(Sn);if(a)return a}catch{}let e=[navigator.userAgent,screen.width,screen.height,screen.colorDepth,Intl.DateTimeFormat().resolvedOptions().timeZone,navigator.language,navigator.hardwareConcurrency??"",navigator.platform??""].join("|"),t=await wf(e);try{localStorage.setItem(Sn,t)}catch{}return t}async function kn(){let e=navigator.userAgent,t=await Lf();return{userAgent:e,browser:mf(e),os:hf(e),deviceType:gf(e),language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,colorDepth:screen.colorDepth,devicePixelRatio:window.devicePixelRatio??1,touchSupport:"ontouchstart"in window||navigator.maxTouchPoints>0,connectionType:navigator.connection?.effectiveType??"unknown",referrer:document.referrer,visitorId:t}}var Cf="x-session-id";function bn(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function If(e,t){let a=`${e.replace(/\/$/,"")}/tools`,o=await fetch(a,{method:"GET",headers:t?{...t}:void 0});if(!o.ok)throw new Error(`[WaniWani] Failed to fetch /tools: ${o.status} ${o.statusText}`);let r=await o.json();if(!r||!Array.isArray(r.tools))return{};let s={};for(let n of r.tools)n&&typeof n.name=="string"&&(s[n.name]=n);return s}function ct(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:s}=e,n=be(a),l=be(o),i=be(void 0),u=be(null),[f,d]=qa(void 0),c=be(f),p=ke(()=>c.current,[]),g=ke(b=>{let R=bn(b);R&&c.current!==R&&(c.current=R,d(R))},[]),I=ke(()=>{c.current=void 0,d(void 0)},[]);ft(()=>{n.current=a},[a]),ft(()=>{l.current=o},[o]),ft(()=>{kn().then(b=>{u.current=b}).catch(()=>{})},[]);let C=be(new Oa({api:t,headers:()=>({...n.current}),body:()=>{let b={...l.current??{}},R=Object.hasOwn(b,"sessionId"),W=bn(b.sessionId);if(W)g(W),b.sessionId=W;else if(R)I(),delete b.sessionId;else{let N=p();N&&(b.sessionId=N)}if(nt(i.current)&&(b.modelContext=i.current),u.current){let N=u.current;b.visitorContext={timezone:N.timezone,language:N.language,languages:N.languages,deviceType:N.deviceType,referrer:N.referrer,visitorId:N.visitorId}}return b},fetch:(async(b,R)=>{let W=await fetch(b,R);return i.current=void 0,g(W.headers.get(Cf)),W})})),m=be(null),w=be(null),h=be({}),[L,x]=qa(0),S=e.skipRemoteConfig===!0,k=ke(async()=>{if(!S)try{let b=await If(t,n.current);h.current=b,x(R=>R+1)}catch(b){console.warn("[WaniWani] Failed to fetch tool definitions:",b instanceof Error?b.message:b)}},[t,S]);ft(()=>{k()},[k]);let{messages:v,sendMessage:_,setMessages:F,status:y}=xf({messages:e.initialMessages,transport:C.current,onFinish({message:b}){s?.(),m.current&&(w.current=b)},onError(b){console.warn("[WaniWani] Chat error:",b.message),m.current&&(m.current.reject(b),m.current=null)}});ft(()=>{if(y==="ready"&&m.current&&w.current){let b=m.current,R=w.current;m.current=null,w.current=null,b.resolve(R)}},[y]);let[T,O]=qa(""),[B,E]=qa([]),$=y==="submitted"||y==="streaming",he=ke(b=>{E(R=>R.filter(W=>W.id!==b))},[]),ge=$&&B.length>0,M=ke(b=>{let R=!!b.text?.trim(),W=!!b.files?.length;if(R||W){if($){if(B.length>0)return;E(N=>[...N,{id:Yt(),text:b.text||"",files:b.files??[],modelContext:b.modelContext}]),O("");return}i.current=b.modelContext,_({text:b.text||"",files:b.files}),r?.(b.text||""),O("")}},[_,r,$,B.length]),q=ke(b=>new Promise((R,W)=>{m.current={resolve:R,reject:W},_({text:b}),r?.(b)}),[_,r]);ft(()=>{if(y!=="ready"||B.length===0)return;let[b,...R]=B;E(R),i.current=b.modelContext,_({text:b.text,files:b.files.length>0?b.files:void 0}),r?.(b.text)},[y,_,r,B]);let pe=ke(()=>{F([]),E([]),I(),O(""),h.current={},x(b=>b+1),k()},[F,I,k]),D=ke(b=>{O(b.target.value)},[]),H=v[v.length-1],we=v.length>0,Z=$&&(!we||H.role==="user"),jt=h.current;return{messages:v,status:y,text:T,setText:O,handleSubmit:M,handleTextChange:D,isLoading:$,showLoaderBubble:Z,lastMessage:H,hasMessages:we,sendMessage:_,sendMessageAndWait:q,reset:pe,queuedMessages:B,queueFull:ge,removeQueuedMessage:he,sessionId:f,toolDefinitions:jt,refreshToolDefinitions:k}}import{useEffect as Pn,useRef as Sf,useState as yf}from"react";var kf={debug:!1,eval:!1};function pt(e="/api/waniwani",t,a=!1){let[o,r]=yf(kf),s=Sf(t);return Pn(()=>{s.current=t},[t]),Pn(()=>{a||(async()=>{try{let n=s.current,i=await(await fetch(`${e}/config`,{headers:n?{...n}:void 0})).json();r({debug:i.debug===!0,eval:i.eval===!0})}catch{}})()},[e,a]),o}import{useCallback as bf,useEffect as Oo,useRef as Pf,useState as Tf}from"react";function Af(e){for(let t of e.parts){let a=t;if(a.type==="data"||a.type==="data-suggestions"){let o=a.data;if(o&&Array.isArray(o.suggestions))return o.suggestions}}return null}function Tn(e){return typeof e=="object"&&e!==null&&"initial"in e}function mt(e){let{messages:t,status:a,config:o}=e,r=Tn(o)&&o.initial?o.initial:void 0,[s,n]=Tf(r??[]),l=Pf(a),i=o===!0||Tn(o)&&o.dynamic!==!1,u=bf(()=>{n([])},[]),f=t.length>0;Oo(()=>{!f&&r&&r.length>0&&n(r)},[r,f]);let d=t[t.length-1];return Oo(()=>{d?.role==="user"&&u()},[d,u]),Oo(()=>{let c=l.current;if(l.current=a,c==="streaming"&&a==="ready"&&i){let p=[...t].reverse().find(I=>I.role==="assistant");if(!p)return;let g=Af(p);g&&n(g)}},[a,i,t]),{suggestions:s,isLoading:!1,clear:u}}import{useEffect as vf,useRef as Mf,useState as Ff}from"react";var Rf=50,Bf=30,Df=2e3,An=500;function ht(e,t=!0){let[a,o]=Ff(""),r=Mf(void 0);return vf(()=>{if(!t){o("");return}let s=0,n=!1,l=!1,i=()=>{l||(n?(s--,o(e.slice(0,s)),s<=0?(n=!1,r.current=setTimeout(i,An)):r.current=setTimeout(i,Bf)):(s++,o(e.slice(0,s)),s>=e.length?(n=!0,r.current=setTimeout(i,Df)):r.current=setTimeout(i,Rf)))};return r.current=setTimeout(i,An),()=>{l=!0,clearTimeout(r.current)}},[e,t]),a}function Ha(e,t){let a=t?.Authorization,o=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return o?`${e}/resource?token=${encodeURIComponent(o)}`:`${e}/resource`}var vn={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",assistantBubbleColor:"#f3f4f6",userBubbleColor:"#f4f4f4",inputBackgroundColor:"#f9fafb",borderRadius:16,messageBorderRadius:12,fontFamily:"system-ui, -apple-system, 'Segoe UI', sans-serif",headerBackgroundColor:"#ffffff",headerTextColor:"#1f2937",statusColor:"#22c55e",toolCardColor:"#f4f4f5"},_f={backgroundColor:"#212121",headerBackgroundColor:"#1e1e1e",headerTextColor:"#ececec",textColor:"#ececec",primaryForeground:"#ffffff",mutedColor:"#8e8ea0",borderColor:"#444444",assistantBubbleColor:"#2f2f2f",userBubbleColor:"#303030",inputBackgroundColor:"#2f2f2f",primaryColor:"#6366f1",statusColor:"#22c55e",toolCardColor:"#262626"},Ef={primaryColor:["--ww-primary","--ww-color-primary"],primaryForeground:["--ww-primary-fg","--ww-color-primary-foreground"],backgroundColor:["--ww-bg","--ww-color-background"],textColor:["--ww-text","--ww-color-foreground","--ww-color-accent-foreground"],mutedColor:["--ww-muted","--ww-color-muted-foreground"],borderColor:["--ww-border","--ww-color-border"],assistantBubbleColor:["--ww-assistant-bubble","--ww-color-accent"],userBubbleColor:["--ww-user-bubble"],inputBackgroundColor:["--ww-input-bg","--ww-color-input"],borderRadius:["--ww-radius"],messageBorderRadius:["--ww-msg-radius"],fontFamily:["--ww-font"],headerBackgroundColor:["--ww-header-bg"],headerTextColor:["--ww-header-text"],statusColor:["--ww-status"],toolCardColor:["--ww-tool-card","--ww-color-tool-card"]};function He(e){return{...vn,...e}}function gt(e){let t=e.backgroundColor.replace("#",""),a=parseInt(t.substring(0,2),16),o=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16);return(a*299+o*587+r*114)/1e3<128}function Ue(e){let t={};for(let[a,o]of Object.entries(Ef)){let r=e[a],s=typeof r=="number"?`${r}px`:String(r);for(let n of o)t[n]=s}return t}import{jsx as ne,jsxs as Wt}from"react/jsx-runtime";var Ho=Nf(function(t,a){let{theme:o,title:r="Assistant",width:s=600,expandedWidth:n,expandedHeight:l=400,allowAttachments:i=!1,welcomeMessage:u,welcome:f,placeholder:d="Ask me anything...",triggerEvent:c="triggerDemoRequest",api:p}=t,g=n??Math.round((typeof s=="number"?s:600)*1.2),I=p??"/api/waniwani",C=Ha(I,t.headers),m=He(o),w=Ue(m),h=gt(m),L=pt(p,t.headers,t.skipRemoteConfig),x=ct(t),S=dt({...t,sessionId:x.sessionId}),k=mt({messages:x.messages,status:x.status,config:t.suggestions}),v=Ua(D=>{let H=D.content.map(we=>we.text??"").join("").trim();H&&x.handleSubmit({text:H,files:[],modelContext:D.modelContext})},[x.handleSubmit]),_=Ua(D=>{k.clear(),x.handleSubmit({text:D,files:[]})},[k.clear,x.handleSubmit]),F=ht(d,!x.text),[y,T]=qo(!1),[O,B]=qo(!1),[E,$]=qo(null),he=Fn(null),ge=Fn(void 0),M=Ua(()=>{let D=he.current;if(!D)return;D.scrollIntoView({behavior:"smooth",block:"center"});let H=D.querySelector("textarea");H&&setTimeout(()=>H.focus(),300),T(!0),B(!0),clearTimeout(ge.current),ge.current=setTimeout(()=>B(!1),2e3)},[]);Of(a,()=>({sendMessage:D=>{x.handleSubmit({text:D,files:[]}),M()},sendMessageAndWait:D=>x.sendMessageAndWait(D),reset:x.reset,focus:M,get messages(){return x.messages}}),[x.handleSubmit,x.sendMessageAndWait,x.reset,x.messages,M]),Mn(()=>{if(!c)return;let D=H=>{let we=H.detail,Z=typeof we?.message=="string"?we.message:void 0;Z&&x.handleSubmit({text:Z,files:[]}),M()};return window.addEventListener(c,D),()=>window.removeEventListener(c,D)},[c,x.handleSubmit,M]);let q=y||E!==null;Mn(()=>{if(!y)return;let D=H=>{he.current&&!he.current.contains(H.target)&&T(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[y]);let pe=Ua(()=>{T(!0)},[]);return Wt("div",{ref:he,style:{...w,width:q?g:s,transition:"width 0.4s cubic-bezier(0.16, 1, 0.3, 1)"},"data-waniwani-chat":"","data-waniwani-layout":"bar",...h?{"data-waniwani-dark":""}:{},className:"ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground",children:[Wt("div",{style:{overflow:"hidden",backgroundColor:m.backgroundColor,borderRadius:"var(--ww-radius) var(--ww-radius) 0 0",maxHeight:q?l+200:0,opacity:q?1:0,transform:q?"scaleX(1)":"scaleX(0.88)",transformOrigin:"center bottom",transition:"max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease-out, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1)"},children:[Wt("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:px-6 ww:py-3",style:{backgroundColor:m.headerBackgroundColor,color:m.headerTextColor},children:[ne("div",{className:"ww:text-sm ww:font-semibold ww:truncate",children:r}),ne(ea,{messages:x.messages,evalEnabled:L.eval,api:I})]}),Wt($e,{className:"ww:flex-1",style:{height:l},children:[ne(Xe,{scrollClassName:E?"ww:!relative ww:!overflow-hidden":void 0,children:ne(lt,{messages:x.messages,status:x.status,welcomeMessage:u,welcome:f,onSuggestionSelect:_,resourceEndpoint:C,chatSessionId:x.sessionId,isDark:h,onFollowUp:v,onCallTool:S,fullscreenToolCallId:E,toolDefinitions:x.toolDefinitions,onWidgetDisplayModeChange:(D,H)=>{$(D==="fullscreen"?H.toolCallId:null)}})}),ne(Qe,{})]}),ne("div",{style:E?{display:"none"}:void 0,children:ne(ut,{suggestions:k.suggestions,isLoading:k.isLoading,onSelect:_})}),ne("div",{style:E?{display:"none"}:void 0,children:ne(at,{queuedMessages:x.queuedMessages,onRemove:x.removeQueuedMessage})})]}),ne("div",{style:{backgroundColor:q?m.backgroundColor:"transparent",borderRadius:q?"0 0 var(--ww-radius) var(--ww-radius)":void 0,boxShadow:q?"0 8px 24px rgba(0,0,0,0.1)":"none",transition:"background-color 0.2s ease, border-radius 0.3s ease, box-shadow 0.35s ease, padding 0.3s ease",padding:q?"8px 16px 16px":"0"},children:ne(Je,{onSubmit:x.handleSubmit,globalDrop:i,multiple:i,className:P("ww:rounded-2xl ww:border-border ww:bg-input ww:transition-all ww:duration-300",!q&&"ww:shadow-sm",O&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background"),children:Wt("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[i&&ne(et,{}),ne(Ze,{onChange:x.handleTextChange,value:x.text,placeholder:F,onFocus:pe,className:"ww:min-h-0 ww:py-1 ww:px-0"}),ne(Ye,{status:x.status,disabled:x.queueFull})]})})})]})});import{useEffect as Hf,useRef as _n,useState as zt}from"react";import{useCallback as Rn,useEffect as qf,useState as Bn}from"react";function Dn(e,t){let[a,o]=Bn([]),[r,s]=Bn(!1),n=Rn(()=>{t&&(s(!0),fetch(`${e}/scenarios`).then(i=>i.json()).then(i=>o(Array.isArray(i)?i:[])).catch(()=>{}).finally(()=>s(!1)))},[e,t]);qf(()=>{n()},[n]);let l=Rn(async(i,u)=>{let f=await fetch(`${e}/scenarios/${i}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:u})});if(!f.ok){let d=await f.json().catch(()=>null);throw new Error(d?.error??`Failed to rename scenario (${f.status})`)}o(d=>d.map(c=>c.id===i?{...c,name:u}:c))},[e]);return{scenarios:a,isLoading:r,reload:n,rename:l}}import{jsx as A,jsxs as de}from"react/jsx-runtime";function Uf(e){return e.parts.filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join("")}function Gf({className:e}){return de("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",className:e,role:"img",children:[A("title",{children:"Run scenario"}),A("path",{d:"M6 4l15 8-15 8V4z"})]})}function Wf({className:e}){return de("svg",{xmlns:"http://www.w3.org/2000/svg",width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,role:"img",children:[A("title",{children:"Rename scenario"}),A("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"})]})}function zf({className:e}){return de("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:e,role:"img",children:[A("title",{children:"Confirm"}),A("path",{d:"M20 6 9 17l-5-5"})]})}function jf({className:e}){return de("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:e,role:"img",children:[A("title",{children:"Cancel"}),A("path",{d:"M18 6 6 18"}),A("path",{d:"m6 6 12 12"})]})}function En({className:e}){return de("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:P("ww:animate-spin",e),role:"img",children:[A("title",{children:"Running"}),A("path",{d:"M12 2v4"}),A("path",{d:"M12 18v4"}),A("path",{d:"m4.93 4.93 2.83 2.83"}),A("path",{d:"m16.24 16.24 2.83 2.83"}),A("path",{d:"M2 12h4"}),A("path",{d:"M18 12h4"}),A("path",{d:"m4.93 19.07 2.83-2.83"}),A("path",{d:"m16.24 4.93 2.83 2.83"})]})}function Vf(){return A("div",{className:"ww:px-3 ww:py-2 ww:space-y-3",children:[1,2,3,4].map(e=>de("div",{className:"ww:flex ww:items-center ww:gap-2",children:[A("div",{className:"ww:h-1.5 ww:w-1.5 ww:rounded-full ww:bg-muted-foreground/20 ww:shrink-0 ww:animate-pulse"}),A("div",{className:"ww:h-3.5 ww:rounded ww:bg-muted-foreground/10 ww:animate-pulse",style:{width:`${50+e*10}%`,animationDelay:`${e*100}ms`}})]},e))})}function $f({initialName:e,onSave:t,onCancel:a}){let o=_n(null),[r,s]=zt(e),[n,l]=zt(!1);Hf(()=>{o.current?.focus(),o.current?.select()},[]);let i=r.trim()!==""&&r.trim()!==e;async function u(){if(!(!i||n)){l(!0);try{await t(r.trim())}finally{l(!1)}}}function f(d){d.key==="Enter"?u():d.key==="Escape"&&a()}return de("div",{className:"ww:flex ww:items-center ww:gap-1",children:[A("input",{ref:o,type:"text",value:r,onChange:d=>s(d.target.value),onKeyDown:f,disabled:n,className:"ww:flex-1 ww:min-w-0 ww:bg-transparent ww:text-xs ww:leading-normal ww:font-mono ww:text-foreground ww:outline-none ww:border-b ww:border-foreground/30 ww:p-0 ww:disabled:opacity-50"}),A("button",{type:"button",onClick:u,disabled:!i||n,className:"ww:bg-foreground ww:text-background ww:rounded-full ww:p-1 ww:disabled:opacity-30 ww:transition-colors ww:cursor-pointer ww:shrink-0",title:"Confirm rename",children:n?A(En,{}):A(zf,{})}),A("button",{type:"button",onClick:a,className:"ww:bg-foreground ww:text-background ww:rounded-full ww:p-1 ww:transition-colors ww:cursor-pointer ww:shrink-0",title:"Cancel",children:A(jf,{})})]})}var Xf=320;function Qf({api:e,chatRef:t}){let a=e??"/api/waniwani",[o,r]=zt(null),[s,n]=zt(null),[l,i]=zt(null),u=_n(null),f=pt(a),{scenarios:d,isLoading:c,reload:p,rename:g}=Dn(a,f.eval);async function I(m){u.current?.abort(),u.current=new AbortController,r(m.id);try{if(!t?.current)throw new Error("ScenarioPanel requires a chatRef prop pointing to the ChatCard/ChatBar");t.current.reset();let w=m.messages.filter(h=>h.role==="user");for(let h of w){let L=Uf(h);L&&await t.current.sendMessageAndWait(L)}}catch(w){w.name!=="AbortError"&&console.error("[ScenarioPanel] run failed:",w)}finally{r(null)}}async function C(m,w){i(null);try{await g(m,w)}catch(h){let L=h instanceof Error?h.message:"Failed to rename scenario";i(L)}n(h=>h===m?null:h)}return f.eval?de("div",{"data-waniwani-chat":"",className:"ww:flex ww:flex-col ww:h-full ww:overflow-hidden ww:text-foreground ww:border-l ww:border-border ww:shrink-0",style:{width:Xf},children:[de("div",{className:"ww:px-3 ww:py-2 ww:border-b ww:border-border/50 ww:flex ww:items-center ww:justify-between",children:[A("span",{className:"ww:text-[10px] ww:font-mono ww:uppercase ww:tracking-widest ww:text-foreground/60",children:"Scenarios"}),A("button",{type:"button",onClick:p,className:"ww:bg-foreground ww:text-background ww:rounded-full ww:p-1 ww:transition-colors ww:cursor-pointer",title:"Reload scenarios",children:de("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img",children:[A("title",{children:"Reload scenarios"}),A("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),A("path",{d:"M21 3v5h-5"})]})})]}),l&&de("div",{className:"ww:mx-3 ww:my-2 ww:px-2 ww:py-1.5 ww:text-[11px] ww:font-mono ww:text-red-400 ww:bg-red-500/10 ww:rounded ww:flex ww:items-start ww:gap-1.5",children:[A("span",{className:"ww:flex-1",children:l}),A("button",{type:"button",onClick:()=>i(null),className:"ww:shrink-0 ww:text-red-400 ww:hover:text-red-300 ww:cursor-pointer",children:"\xD7"})]}),A("div",{className:"ww:flex-1 ww:overflow-y-auto ww:min-h-0",children:c?A(Vf,{}):d.length===0?A("p",{className:"ww:text-xs ww:font-mono ww:text-foreground/50 ww:text-center ww:py-8 ww:px-4",children:"No scenarios found"}):d.map(m=>{let w=o===m.id,h=s===m.id;return de("div",{className:P("ww:group ww:flex ww:items-center ww:gap-1 ww:px-3 ww:py-2 ww:border-l-2 ww:transition-colors",w?"ww:border-[#03d916] ww:bg-[#03d916]/10":"ww:border-transparent ww:hover:bg-muted/50"),children:[A("div",{className:"ww:flex-1 ww:min-w-0",children:h?A($f,{initialName:m.name,onSave:L=>C(m.id,L),onCancel:()=>n(null)}):A("span",{className:"ww:block ww:truncate ww:text-xs ww:font-mono ww:text-foreground",title:m.name,children:m.name})}),!h&&de("div",{className:"ww:flex ww:items-center ww:gap-1 ww:shrink-0",children:[!w&&A("button",{type:"button",onClick:()=>n(m.id),className:"ww:opacity-0 ww:group-hover:opacity-100 ww:bg-foreground ww:text-background ww:rounded-full ww:p-1 ww:transition-all ww:cursor-pointer",title:"Rename scenario",children:A(Wf,{})}),A("button",{type:"button",onClick:()=>I(m),disabled:o!==null,className:"ww:bg-foreground ww:text-background ww:rounded-full ww:p-1 ww:disabled:opacity-40 ww:transition-colors ww:cursor-pointer",title:"Run scenario",children:w?A(En,{}):A(Gf,{})})]})]},m.id)})})]}):null}import{forwardRef as Kf,useCallback as Uo,useEffect as Jf,useImperativeHandle as Zf,useRef as Nn,useState as On}from"react";import{jsx as re,jsxs as Ga}from"react/jsx-runtime";var Yf=Kf(function(t,a){let{theme:o,title:r="Assistant",width:s,height:n,className:l,allowAttachments:i=!1,welcomeMessage:u,welcome:f,placeholder:d="Ask me anything...",triggerEvent:c="triggerDemoRequest",api:p,debug:g}=t,I=p??"/api/waniwani",C=Ha(I,t.headers),m=He(o),w=Ue(m),h=gt(m),L=pt(I,t.headers,t.skipRemoteConfig),x=g??L.debug,S=ct({...t,api:I}),k=dt({...t,api:I,sessionId:S.sessionId}),v=ht(d,!S.text),[_,F]=On(!1),[y,T]=On(null),O=Nn(null),B=Nn(void 0),E=Uo(()=>{let M=O.current;if(!M)return;M.scrollIntoView({behavior:"smooth",block:"center"});let q=M.querySelector("textarea");q&&setTimeout(()=>q.focus(),300),F(!0),clearTimeout(B.current),B.current=setTimeout(()=>F(!1),2e3)},[]),$=mt({messages:S.messages,status:S.status,config:t.suggestions}),he=Uo(M=>{let q=M.content.map(pe=>pe.text??"").join("").trim();q&&S.handleSubmit({text:q,files:[],modelContext:M.modelContext})},[S.handleSubmit]),ge=Uo(M=>{$.clear(),S.handleSubmit({text:M,files:[]})},[$.clear,S.handleSubmit]);return Zf(a,()=>({sendMessage:M=>{S.handleSubmit({text:M,files:[]}),E()},sendMessageAndWait:M=>S.sendMessageAndWait(M),reset:S.reset,focus:E,get messages(){return S.messages}}),[S.handleSubmit,S.sendMessageAndWait,S.reset,S.messages,E]),Jf(()=>{if(!c)return;let M=q=>{let pe=q.detail,D=typeof pe?.message=="string"?pe.message:void 0;D&&S.handleSubmit({text:D,files:[]}),E()};return window.addEventListener(c,M),()=>window.removeEventListener(c,M)},[c,S.handleSubmit,E]),Ga("div",{ref:O,style:{...w,width:s,height:n},"data-waniwani-chat":"","data-waniwani-layout":"card",...h?{"data-waniwani-dark":""}:{},className:P("ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:rounded-[var(--ww-radius)] ww:overflow-hidden",_&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",l),children:[Ga("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:px-6 ww:py-3",style:{backgroundColor:m.headerBackgroundColor,color:m.headerTextColor},children:[re("div",{className:"ww:text-sm ww:font-semibold ww:truncate",children:r}),re(ea,{messages:S.messages,evalEnabled:L.eval,api:I})]}),Ga($e,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[re(Xe,{scrollClassName:y?"ww:!relative ww:!overflow-hidden":void 0,children:re(lt,{messages:S.messages,status:S.status,welcomeMessage:u,welcome:f,onSuggestionSelect:ge,resourceEndpoint:C,chatSessionId:S.sessionId,isDark:h,onFollowUp:he,onCallTool:k,fullscreenToolCallId:y,debug:x,toolDefinitions:S.toolDefinitions,onWidgetDisplayModeChange:(M,q)=>{T(M==="fullscreen"?q.toolCallId:null)}})}),re(Qe,{})]}),re("div",{style:y?{display:"none"}:void 0,children:re(ut,{suggestions:$.suggestions,isLoading:$.isLoading,onSelect:ge})}),re("div",{style:y?{display:"none"}:void 0,children:re(at,{queuedMessages:S.queuedMessages,onRemove:S.removeQueuedMessage})}),re("div",{style:y?{display:"none"}:void 0,children:re("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:re("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:re(Je,{onSubmit:S.handleSubmit,globalDrop:i,multiple:i,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:Ga("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[i&&re(et,{}),re(Ze,{onChange:S.handleTextChange,value:S.text,placeholder:v,className:"ww:min-h-0 ww:py-1 ww:px-0"}),re(Ye,{status:S.status,disabled:S.queueFull})]})})})})})]})});import{forwardRef as ec,useCallback as Go,useEffect as tc,useImperativeHandle as ac,useRef as oc,useState as rc}from"react";import{jsx as ie,jsxs as Wo}from"react/jsx-runtime";var sc=ec(function(t,a){let{theme:o,className:r,allowAttachments:s=!1,welcomeMessage:n,welcome:l,placeholder:i="Ask me anything...",triggerEvent:u="triggerDemoRequest",api:f,mcp:d,debug:c=!1,readOnly:p=!1}=t,g=He(o),I=Ue(g),C=gt(g),m=ct({...t,api:f}),w=dt({...t,api:f,sessionId:m.sessionId,onCallTool:d?.onCallTool}),h=ht(i,!m.text),[L,x]=rc(null),S=oc(null),k=Go(()=>{let y=S.current;if(!y)return;let T=y.querySelector("textarea");T&&T.focus()},[]),v=mt({messages:m.messages,status:m.status,config:t.suggestions}),_=Go(y=>{let T=y.content.map(O=>O.text??"").join("").trim();T&&m.handleSubmit({text:T,files:[],modelContext:y.modelContext})},[m.handleSubmit]),F=Go(y=>{v.clear(),m.handleSubmit({text:y,files:[]})},[v.clear,m.handleSubmit]);return ac(a,()=>({sendMessage:y=>{m.handleSubmit({text:y,files:[]}),k()},sendMessageAndWait:y=>m.sendMessageAndWait(y),reset:m.reset,focus:k,get messages(){return m.messages}}),[m.handleSubmit,m.sendMessageAndWait,m.reset,m.messages,k]),tc(()=>{if(!u)return;let y=T=>{let O=T.detail,B=typeof O?.message=="string"?O.message:void 0;B&&m.handleSubmit({text:B,files:[]}),k()};return window.addEventListener(u,y),()=>window.removeEventListener(u,y)},[u,m.handleSubmit,k]),Wo("div",{ref:S,style:I,"data-waniwani-chat":"","data-waniwani-layout":"embed",...C?{"data-waniwani-dark":""}:{},className:P("ww:flex ww:flex-col ww:w-full ww:h-full ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:overflow-hidden",r),children:[Wo($e,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[ie(Xe,{scrollClassName:L?"ww:!relative ww:!overflow-hidden":void 0,children:ie(lt,{messages:m.messages,status:m.status,welcomeMessage:n,welcome:l,onSuggestionSelect:F,resourceEndpoint:d?.resourceEndpoint,chatSessionId:m.sessionId,isDark:C,onFollowUp:_,onCallTool:w,fullscreenToolCallId:L,debug:c,toolDefinitions:m.toolDefinitions,onWidgetDisplayModeChange:(y,T)=>{x(y==="fullscreen"?T.toolCallId:null)}})}),ie(Qe,{})]}),!p&&ie("div",{style:L?{display:"none"}:void 0,children:ie(ut,{suggestions:v.suggestions,isLoading:v.isLoading,onSelect:F})}),!p&&ie("div",{style:L?{display:"none"}:void 0,children:ie(at,{queuedMessages:m.queuedMessages,onRemove:m.removeQueuedMessage})}),!p&&ie("div",{style:L?{display:"none"}:void 0,children:ie("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:ie("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:ie(Je,{onSubmit:m.handleSubmit,globalDrop:s,multiple:s,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:Wo("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[s&&ie(et,{}),ie(Ze,{onChange:m.handleTextChange,value:m.text,placeholder:h,className:"ww:min-h-0 ww:py-1 ww:px-0"}),ie(Ye,{status:m.status,disabled:m.queueFull})]})})})})})]})});export{Ho as ChatBar,Yf as ChatCard,sc as ChatEmbed,Ho as ChatWidget,_f as DARK_THEME,vn as DEFAULT_THEME,No as McpAppFrame,Qf as ScenarioPanel,He as mergeTheme,Ue as themeToCSSProperties};
|
|
17
17
|
/*! Bundled license information:
|
|
18
18
|
|
|
19
19
|
lucide-react/dist/esm/shared/src/utils/mergeClasses.js:
|