@waniwani/sdk 0.9.12-beta.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/index.js +1 -1
- package/dist/chat/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/react.js +1 -1
- package/dist/mcp/react.js.map +1 -1
- package/package.json +4 -2
package/dist/chat/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import{a as Go,b as Wo,c as zo,d as je,e as Ve,f as Xt,g as jo,h as Vo,i as $o,j
|
|
|
13
13
|
`}));let g={type:"element",tagName:"span",properties:{class:"line"},children:[]},w=0;for(let m of I){let C={type:"element",tagName:"span",properties:{...m.htmlAttrs},children:[{type:"text",value:m.content}]},x=Lo(m.htmlStyle||Ia(m));x&&(C.properties.style=x);for(let S of r)C=S?.span?.call(p,C,L+1,w,g,m)||C;i==="inline"?n.children.push(C):i==="classic"&&g.children.push(C),w+=m.content.length}if(i==="classic"){for(let m of r)g=m?.line?.call(p,g,L+1)||g;c.push(g),s.push(g)}else i==="inline"&&c.push(g)}),i==="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(i==="inline"){let I=[],L={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let m of n.children)m.type==="element"&&m.tagName==="br"?(I.push(L),L={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(m.type==="element"||m.type==="text")&&L.children.push(m);I.push(L);let w={type:"element",tagName:"code",properties:{},children:I};for(let m of r)w=m?.code?.call(p,w)||w;n.children=[];for(let m=0;m<w.children.length;m++){m>0&&n.children.push({type:"element",tagName:"br",properties:{},children:[]});let C=w.children[m];C.type==="element"&&n.children.push(...C.children)}}let h=n;for(let I of r)h=I?.root?.call(p,h)||h;return o&&Pa(h,o),h}function Qu(e){return e.map(t=>{let a=[],o="",r;return t.forEach((s,n)=>{let l=!(s.fontStyle&&(s.fontStyle&ae.Underline||s.fontStyle&ae.Strikethrough));l&&s.content.match(/^\s+$/)&&t[n+1]?(r===void 0&&(r=s.offset),o+=s.content):o?(l?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 Ku(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 i=[{...a,offset:a.offset+r.length,content:s}];return r&&i.unshift({content:r,offset:a.offset}),n&&i.push({content:n,offset:a.offset+r.length+s.length}),i}))}function Ju(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=Lo(r.htmlStyle||Ia(r)),n=Lo(o.htmlStyle||Ia(o)),i=r.fontStyle&&(r.fontStyle&ae.Underline||r.fontStyle&ae.Strikethrough),l=o.fontStyle&&(o.fontStyle&ae.Underline||o.fontStyle&ae.Strikethrough);!i&&!l&&s===n?r.content+=o.content:a.push({...o})}return a})}var Zu=ho;function Yu(e,t,a){let o={meta:{},options:a,codeToHast:(s,n)=>ka(e,s,n),codeToTokens:(s,n)=>ya(e,s,n)},r=Zu(ka(e,t,a,o));for(let s of Sa(a))r=s.postprocess?.call(o,r,a)||r;return r}var Ms={light:"#333333",dark:"#bbbbbb"},Rs={light:"#fffffe",dark:"#1e1e1e"},Bs="__shiki_resolved";function Po(e){if(e?.[Bs])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 i=t.settings?t.settings.find(l=>!l.name&&!l.scope):void 0;i?.settings?.foreground&&(o=i.settings.foreground),i?.settings?.background&&(a=i.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"?Ms.light:Ms.dark),a||(a=t.type==="light"?Rs.light:Rs.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(i){if(s.has(i))return s.get(i);r+=1;let l=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?n(i):(s.set(i,l),l)}t.settings=t.settings.map(i=>{let l=i.settings?.foreground&&!i.settings.foreground.startsWith("#"),u=i.settings?.background&&!i.settings.background.startsWith("#");if(!l&&!u)return i;let f={...i,settings:{...i.settings}};if(l){let d=n(i.settings.foreground);t.colorReplacements[d]=i.settings.foreground,f.settings.foreground=d}if(u){let d=n(i.settings.background);t.colorReplacements[d]=i.settings.background,f.settings.background=d}return f});for(let i of Object.keys(t.colors||{}))if((i==="editor.foreground"||i==="editor.background"||i.startsWith("terminal.ansi"))&&!t.colors[i]?.startsWith("#")){let l=n(t.colors[i]);t.colorReplacements[l]=t.colors[i],t.colors[i]=l}return Object.defineProperty(t,Bs,{enumerable:!1,writable:!1,value:!0}),t}async function Gs(e){return Array.from(new Set((await Promise.all(e.filter(t=>!_s(t)).map(async t=>await Ds(t).then(a=>Array.isArray(a)?a:[a])))).flat()))}async function Ws(e){return(await Promise.all(e.map(async a=>Es(a)?null:Po(await Ds(a))))).filter(a=>!!a)}var wo=3,ed=!1;function td(e,t=3){if(wo&&!(typeof wo=="number"&&t>wo)){if(ed)throw new Error(`[SHIKI DEPRECATE]: ${e}`);console.trace(`[SHIKI DEPRECATE]: ${e}`)}}var Fe=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function zs(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 Fe(`Circular alias \`${Array.from(a).join(" -> ")} -> ${e}\``);a.add(e)}}return e}var xo=class extends is{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=Po(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=Bt.createFromRawTheme(t),this._textmateThemeCache.set(t,a)),this._syncRegistry.setTheme(a)}getGrammar(t){return t=zs(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(l=>o.map(([u])=>u).includes(l)):!1).filter(s=>!o.includes(s));throw new Fe(`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))}},Co=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}},qt=0;function ad(e){qt+=1,e.warnings!==!1&&qt>=10&&qt%10===0&&console.warn(`[Shiki] ${qt} 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 Fe("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),o=(e.themes||[]).flat(1).map(Po),r=new Co(e.engine,a),s=new xo(r,o,a,e.langAlias),n;function i(m){return zs(m,e.langAlias)}function l(m){g();let C=s.getGrammar(typeof m=="string"?m:m.name);if(!C)throw new Fe(`Language \`${m}\` not found, you may need to load it first`);return C}function u(m){if(m==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};g();let C=s.getTheme(m);if(!C)throw new Fe(`Theme \`${m}\` not found, you may need to load it first`);return C}function f(m){g();let C=u(m);n!==m&&(s.setTheme(C),n=m);let x=s.getColorMap();return{theme:C,colorMap:x}}function d(){return g(),s.getLoadedThemes()}function c(){return g(),s.getLoadedLanguages()}function p(...m){g(),s.loadLanguages(m.flat(1))}async function h(...m){return p(await Gs(m))}function I(...m){g();for(let C of m.flat(1))s.loadTheme(C)}async function L(...m){return g(),I(await Ws(m))}function g(){if(t)throw new Fe("Shiki instance has been disposed")}function w(){t||(t=!0,s.dispose(),qt-=1)}return{setTheme:f,getTheme:u,getLanguage:l,getLoadedThemes:d,getLoadedLanguages:c,resolveLangAlias:i,loadLanguage:h,loadLanguageSync:p,loadTheme:L,loadThemeSync:I,dispose:w,[Symbol.dispose]:w}}async function od(e){e.engine||td("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,o]=await Promise.all([Ws(e.themes||[]),Gs(e.langs||[]),e.engine]);return ad({...e,themes:t,langs:a,engine:o})}async function rd(e){let t=await od(e);return{getLastGrammarState:(...a)=>Uu(t,...a),codeToTokensBase:(a,o)=>ko(t,a,o),codeToTokensWithThemes:(a,o)=>Us(t,a,o),codeToTokens:(a,o)=>ya(t,a,o),codeToHast:(a,o)=>ka(t,a,o),codeToHtml:(a,o)=>Yu(t,a,o),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function js(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,_s(d))return[];let c=t[d];if(!c)throw new j(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return c}return d}function i(d){if(Es(d))return"none";if(typeof d=="string"){let c=a[d];if(!c)throw new j(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return c}return d}let l=(s.themes??[]).map(d=>i(d)),u=(s.langs??[]).map(d=>n(d)),f=await rd({engine:s.engine??o(),...s,themes:l,langs:u});return{...f,loadLanguage(...d){return f.loadLanguage(...d.map(n))},loadTheme(...d){return f.loadTheme(...d.map(i))},getBundledLanguages(){return t},getBundledThemes(){return a}}}return r}function sd(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 Vs(e,t){let a=sd(e);async function o(r,s){let n=await a({langs:[s.lang],themes:"theme"in s?[s.theme]:Object.values(s.themes)}),i=await t?.guessEmbeddedLanguages?.(r,s.lang,n);return i&&await n.loadLanguage(...i),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 To=[{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"))}],$s=Object.fromEntries(To.map(e=>[e.id,e.import])),Xs=Object.fromEntries(To.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),Ut={...$s,...Xs};var nd=[{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"))}],Qs=Object.fromEntries(nd.map(e=>[e.id,e.import]));var Gt=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function ld(){return 2147483648}function id(){return typeof performance<"u"?performance.now():Date.now()}var ud=(e,t)=>e+(t-e%t)%t;async function dd(e){let t,a,o={};function r(p){a=p,o.HEAPU8=new Uint8Array(p),o.HEAPU32=new Uint32Array(p)}function s(p,h,I){o.HEAPU8.copyWithin(p,h,h+I)}function n(p){try{return t.grow(p-a.byteLength+65535>>>16),r(t.buffer),1}catch{}}function i(p){let h=o.HEAPU8.length;p=p>>>0;let I=ld();if(p>I)return!1;for(let L=1;L<=4;L*=2){let g=h*(1+.2/L);g=Math.min(g,p+100663296);let w=Math.min(I,ud(Math.max(p,g),65536));if(n(w))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function u(p,h,I=1024){let L=h+I,g=h;for(;p[g]&&!(g>=L);)++g;if(g-h>16&&p.buffer&&l)return l.decode(p.subarray(h,g));let w="";for(;h<g;){let m=p[h++];if(!(m&128)){w+=String.fromCharCode(m);continue}let C=p[h++]&63;if((m&224)===192){w+=String.fromCharCode((m&31)<<6|C);continue}let x=p[h++]&63;if((m&240)===224?m=(m&15)<<12|C<<6|x:m=(m&7)<<18|C<<12|x<<6|p[h++]&63,m<65536)w+=String.fromCharCode(m);else{let S=m-65536;w+=String.fromCharCode(55296|S>>10,56320|S&1023)}}return w}function f(p,h){return p?u(o.HEAPU8,p,h):""}let d={emscripten_get_now:id,emscripten_memcpy_big:s,emscripten_resize_heap:i,fd_write:()=>0};async function c(){let h=await e({env:d,wasi_snapshot_preview1:d});t=h.memory,r(t.buffer),Object.assign(o,h),o.UTF8ToString=f}return await c(),o}var fd=Object.defineProperty,cd=(e,t,a)=>t in e?fd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,Q=(e,t,a)=>cd(e,typeof t!="symbol"?t+"":t,a),Y=null;function pd(e){throw new Gt(e.UTF8ToString(e.getLastOnigError()))}var Aa=class e{constructor(t){Q(this,"utf16Length"),Q(this,"utf8Length"),Q(this,"utf16Value"),Q(this,"utf8Value"),Q(this,"utf16OffsetToUtf8"),Q(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 i=new Uint8Array(o),l=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]=l,c&&(s[u+1]=l),d<=127?n[l+0]=u:d<=2047?(n[l+0]=u,n[l+1]=u):d<=65535?(n[l+0]=u,n[l+1]=u,n[l+2]=u):(n[l+0]=u,n[l+1]=u,n[l+2]=u,n[l+3]=u)),d<=127?i[l++]=d:d<=2047?(i[l++]=192|(d&1984)>>>6,i[l++]=128|(d&63)>>>0):d<=65535?(i[l++]=224|(d&61440)>>>12,i[l++]=128|(d&4032)>>>6,i[l++]=128|(d&63)>>>0):(i[l++]=240|(d&1835008)>>>18,i[l++]=128|(d&258048)>>>12,i[l++]=128|(d&4032)>>>6,i[l++]=128|(d&63)>>>0),c&&u++}this.utf16Length=a,this.utf8Length=o,this.utf16Value=t,this.utf8Value=i,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,i=!1;if(s>=55296&&s<=56319&&o+1<r){let l=t.charCodeAt(o+1);l>=56320&&l<=57343&&(n=(s-55296<<10)+65536|l-56320,i=!0)}n<=127?a+=1:n<=2047?a+=2:n<=65535?a+=3:a+=4,i&&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(Q(this,"id",++Ie.LAST_ID),Q(this,"_onigBinding"),Q(this,"content"),Q(this,"utf16Length"),Q(this,"utf8Length"),Q(this,"utf16OffsetToUtf8"),Q(this,"utf8OffsetToUtf16"),Q(this,"ptr"),!Y)throw new Gt("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)}};Q(va,"LAST_ID",0);Q(va,"_sharedPtr",0);Q(va,"_sharedPtrInUse",!1);var Ks=va,vo=class{constructor(t){if(Q(this,"_onigBinding"),Q(this,"_ptr"),!Y)throw new Gt("Must invoke loadWasm first.");let a=[],o=[];for(let i=0,l=t.length;i<l;i++){let u=new Aa(t[i]);a[i]=u.createString(Y),o[i]=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 i=0,l=t.length;i<l;i++)Y.ofree(a[i]);Y.ofree(s),Y.ofree(r),n===0&&pd(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 Ks(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 i=s.HEAPU32,l=n/4,u=i[l++],f=i[l++],d=[];for(let c=0;c<f;c++){let p=t.convertUtf8OffsetToUtf16(i[l++]),h=t.convertUtf8OffsetToUtf16(i[l++]);d[c]={start:p,end:h,length:h-p}}return{index:u,captureIndices:d}}};function md(e){return typeof e.instantiator=="function"}function hd(e){return typeof e.default=="function"}function gd(e){return typeof e.data<"u"}function wd(e){return typeof Response<"u"&&e instanceof Response}function Ld(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 xd(e){if(Ta)return Ta;async function t(){Y=await dd(async a=>{let o=e;return o=await o,typeof o=="function"&&(o=await o(a)),typeof o=="function"&&(o=await o(a)),md(o)?o=await o.instantiator(a):hd(o)?o=await o.default(a):(gd(o)&&(o=o.data),wd(o)?typeof WebAssembly.instantiateStreaming=="function"?o=await Cd(o)(a):o=await Id(o)(a):Ld(o)?o=await Ao(o)(a):o instanceof WebAssembly.Module?o=await Ao(o)(a):"default"in o&&o.default instanceof WebAssembly.Module&&(o=await Ao(o.default)(a))),"instance"in o&&(o=o.instance),"exports"in o&&(o=o.exports),o})}return Ta=t(),Ta}function Ao(e){return t=>WebAssembly.instantiate(e,t)}function Cd(e){return t=>WebAssembly.instantiateStreaming(e,t)}function Id(e){return async t=>{let a=await e.arrayBuffer();return WebAssembly.instantiate(a,t)}}async function Js(e){return e&&await xd(e),{createScanner(t){return new vo(t.map(a=>typeof a=="string"?a:a.source))},createString(t){return new Ks(t)}}}var Fa=js({langs:Ut,themes:Qs,engine:()=>Js(import("../wasm-EOPKAILK.js"))}),{codeToHtml:Sd,codeToHast:yd,codeToTokens:kd,codeToTokensBase:bd,codeToTokensWithThemes:Pd,getSingletonHighlighter:Td,getLastGrammarState:Ad}=Vs(Fa,{guessEmbeddedLanguages:Os});var Zs=new Set(Object.keys(Ut)),Fo=new Map,Mo=new Map,nt=new Map,vd=(e,t)=>`${e}-${t[0]}-${t[1]}`,Fd=(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}`},Md=(e,t)=>{let a=vd(e,t);if(Fo.has(a))return Fo.get(a);let o=Fa({themes:t,langs:[e]});return Fo.set(a,o),o};function Rd(e={}){var t;let a=(t=e.themes)!=null?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(o){return Zs.has(o)},getSupportedLanguages(){return Array.from(Zs)},getThemes(){return a},highlight({code:o,language:r,themes:s},n){let i=Fd(o,r,s);return Mo.has(i)?Mo.get(i):(n&&(nt.has(i)||nt.set(i,new Set),nt.get(i).add(n)),Md(r,s).then(l=>{let u=l.getLoadedLanguages().includes(r)?r:"text",f=l.codeToTokens(o,{lang:u,themes:{light:s[0],dark:s[1]}});Mo.set(i,f);let d=nt.get(i);if(d){for(let c of d)c(f);nt.delete(i)}}).catch(l=>{console.error("[Streamdown Code] Failed to highlight code:",l),nt.delete(i)}),null)}}}var Ys=Rd();import{memo as Bd}from"react";import{jsx as Ma}from"react/jsx-runtime";var Ra=({className:e,from:t,children:a,...o})=>Ma("div",{className:b("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:Ma("div",{className:b("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),Ba=({children:e,className:t,...a})=>Ma("div",{className:b("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}),Dd={cjk:Er,code:Ys},Da=Bd(({className:e,...t})=>Ma(Wa,{className:b("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),plugins:Dd,...t}),(e,t)=>e.children===t.children);Da.displayName="MessageResponse";import{jsx as _d}from"react/jsx-runtime";function en({className:e,text:t,...a}){return t?_d("pre",{className:b("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 Ed,useCallback as Nd,useContext as rn,useEffect as Od,useMemo as Bo,useRef as qd,useState as Do}from"react";import{Fragment as on,jsx as G,jsxs as Re}from"react/jsx-runtime";function Hd(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,i]of o){if(s<=8)break;let l=n.length>4?`${n.slice(0,4)}\u2026`:n,u;typeof i=="string"?u=i.length>2?`'${i.slice(0,1)}\u2026`:`'${i}'`:Array.isArray(i)?u=`Array(${i.length})`:typeof i=="object"&&i!==null?u="{\u2026}":u=String(i);let f=`${l}\u2009${u}`;r.push(f),s-=f.length+3}return`{${r.join(", ")}}`}function Ud({text:e,className:t}){let[a,o]=Do(!1),r=qd(null);Od(()=>()=>{r.current&&clearTimeout(r.current)},[]);let s=Nd(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:b("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?Re(on,{children:[G(Ct,{className:"ww:size-3.5"}),G("span",{children:"Copied"})]}):Re(on,{children:[G(yt,{className:"ww:size-3.5"}),G("span",{children:"Copy"})]})})}function sn({data:e,label:t,className:a,...o}){let[r,s]=Do(!1),n=Bo(()=>JSON.stringify(e,null,2),[e]),i=Hd(e);return Re("div",{className:b("ww:rounded-lg ww:bg-tool-card",a),...o,children:[Re("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(Ud,{text:n})]}),Re("button",{type:"button",onClick:()=>s(l=>!l),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[G(St,{className:b("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:i})]})]})}var _o=Ed({open:!1,toggle:()=>{}});function nn({className:e,defaultOpen:t=!1,children:a,...o}){let[r,s]=Do(t);return G(_o.Provider,{value:{open:r,toggle:()=>s(n=>!n)},children:G("div",{className:b("ww:mb-4 ww:w-full",e),"data-state":r?"open":"closed",...o,children:a})})}function ln({className:e,title:t,state:a,...o}){let{open:r,toggle:s}=rn(_o),n=a==="input-available"||a==="input-streaming";return Re("button",{type:"button",onClick:s,className:b("ww:flex ww:w-full ww:items-center ww:justify-between ww:gap-3 ww:py-1.5",e),"aria-expanded":r,...o,children:[Re("div",{className:"ww:flex ww:min-w-0 ww:items-center ww:gap-2",children:[G(Te,{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(It,{className:b("ww:size-4 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function un({className:e,children:t,...a}){let{open:o}=rn(_o);return G("div",{className:b("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:b("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 dn({className:e,input:t,debug:a,...o}){let r=Bo(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:s,...n}=t;return n}return t},[t,a]);return G(sn,{data:r,label:"Request",className:e,...o})}function Ro(e){if(!(typeof e!="object"||e===null))return e}function fn(e){return Ro(e?.ui)}function cn(e){return Ro(Ro(e)?._meta)}function tn(e){if(!e)return;let t=fn(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 an(e){return fn(e)?.autoHeight===!0}function _a(e,t,a){if(e){let o=tn(a?.[e]?._meta);if(o)return o}return tn(cn(t))}function pn(e,t,a){return e&&an(a?.[e]?._meta)?!0:an(cn(t))}function mn({className:e,output:t,errorText:a,debug:o,...r}){let s=Bo(()=>{if(!o&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:n,...i}=t;return i}return t},[t,o]);return t||a?a?Re("div",{className:b("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(sn,{data:s,label:"Response",className:e,...r}):null}import{useCallback as Gd,useEffect as gn,useMemo as Wd,useRef as ne,useState as wn}from"react";function lt(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 hn(e,t){return!lt(e)&&!lt(t)?null:lt(e)?lt(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 ef}from"react/jsx-runtime";var zd="/api/mcp/resource",jd=500,Vd=0,$d=16,Xd="2026-01-26",Qd=300,Kd=3e3,Jd=3;function Zd(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Yd(e,t,a){return _a(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function Eo({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:o=zd,chatSessionId:r,isDark:s=!1,className:n,autoHeight:i=!1,onOpenLink:l,onFollowUp:u,onCallTool:f,onDisplayModeChange:d,isFullscreen:c=!1,toolDefinitions:p}){let h=ne(null),I=ne(t),L=ne(a),g=ne({width:0,height:0}),w=ne(null),m=ne(!1),C=ne(0),x=ne("inline"),[S,k]=wn(Vd),[F,_]=wn(void 0),T=ne(l),y=ne(u),A=ne(f),E=ne(d),O=ne(r),B=ne(p);I.current=t,L.current=a,T.current=l,y.current=u,A.current=f,E.current=d,O.current=r,B.current=p;let ee=Gd(M=>i?Math.max(M+$d,0):Math.min(Math.max(M,50),jd),[i]),ge=Wd(()=>`${o}?uri=${encodeURIComponent(e)}`,[o,e]),we=ne(s);return we.current=s,gn(()=>{if(!m.current)return;let M=h.current;M?.contentWindow&&M.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:s?"dark":"light"}},"*")},[s]),gn(()=>{let M=h.current;if(!M)return;let q=!1,me=!1,R=null,H=null,Se=setTimeout(()=>{if(q||me||C.current>=Jd)return;C.current+=1;let D=new URL(M.src);D.searchParams.set("_retry",String(C.current)),M.src=D.toString()},Kd),J=D=>{M.contentWindow?.postMessage(D,"*")},P=D=>{if(q||D.source!==M.contentWindow)return;let N=D.data;if(!N||typeof N!="object"||N.jsonrpc!=="2.0")return;let V=N.method,Z=N.id;if(V==="ui/initialize"&&Z!=null){me=!0,clearTimeout(Se),J({jsonrpc:"2.0",id:Z,result:{protocolVersion:N.params?.protocolVersion??Xd,hostInfo:{name:"WaniWani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:we.current?"dark":"light",displayMode:x.current}}});return}if(V==="ui/notifications/initialized"){m.current=!0;let W=I.current,z=L.current,$=z._meta&&typeof z._meta=="object"?z._meta:null,oe=Zd(O.current),ce=$&&typeof $.waniwani=="object"&&$.waniwani!==null?$.waniwani:null,We=ce||oe?{...ce??{},...oe?{sessionId:oe}:{}}:void 0,ze=$||We?{...$??{},...We?{waniwani:We}:{}}:void 0;J({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:W}});let Vt=z.content??[{type:"text",text:JSON.stringify(z)}];J({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:Vt,structuredContent:z.structuredContent,_meta:ze,meta:ze}});return}if(V==="ui/notifications/size-changed"){let W=N.params,z=typeof W?.height=="number"?W.height:void 0,$=typeof W?.width=="number"?W.width:void 0,oe=g.current,ce=z!==void 0&&z!==oe.height,We=$!==void 0&&$!==oe.width;if(!ce&&!We)return;if(ce&&z!==void 0){oe.height=z;let ze=ee(z),Vt=M.getBoundingClientRect().height;if(w.current&&(w.current.cancel(),w.current=null),k(ze),M.animate&&Math.abs(Vt-ze)>2){let $t=M.animate([{height:`${Vt}px`},{height:`${ze}px`}],{duration:Qd,easing:"ease-out",fill:"forwards"});w.current=$t,$t.onfinish=()=>{w.current===$t&&($t.cancel(),w.current=null)}}}We&&i&&$!==void 0&&(oe.width=$,_($));return}if(V==="ui/open-link"&&Z!=null){let W=N.params?.url;typeof W=="string"&&(T.current?T.current(W):window.open(W,"_blank","noopener,noreferrer")),J({jsonrpc:"2.0",id:Z,result:{}});return}if(V==="ui/message"&&Z!=null){if(y.current&&N.params){let W=N.params,z=R;if(R=null,H){clearTimeout(H.timer);let $=H.text;H=null;let oe=(W.content??[]).map(ce=>ce.text??"").join("").trim();W={...W,content:[{type:"text",text:`${oe}
|
|
14
14
|
|
|
15
15
|
${$}`}]}}y.current({...W,...z?{modelContext:z}:{}})}J({jsonrpc:"2.0",id:Z,result:{}});return}if(V==="ui/update-model-context"&&Z!=null){R=hn(R,N.params),J({jsonrpc:"2.0",id:Z,result:{}});return}if(V==="tools/call"&&Z!=null){let W=A.current;if(!W){J({jsonrpc:"2.0",id:Z,error:{code:-32601,message:"tools/call not supported"}});return}let z=N.params?.name;W({name:z,arguments:N.params?.arguments??{}}).then($=>{J({jsonrpc:"2.0",id:Z,result:$});let oe=$.content?.map(ce=>ce.text??"").join("").trim();oe&&Yd(z,$,B.current)&&(H&&clearTimeout(H.timer),H={text:oe,timer:setTimeout(()=>{if(q)return;let ce=R;R=null,H=null,y.current?.({role:"user",content:[{type:"text",text:oe}],...ce?{modelContext:ce}:{}})},500)})}).catch($=>{let oe=$ instanceof Error?$.message:"Tool call failed";J({jsonrpc:"2.0",id:Z,error:{code:-32e3,message:oe}})});return}if(V==="ui/request-display-mode"&&Z!=null){let W=N.params?.mode,z=W==="fullscreen"||W==="inline"||W==="pip"?W:"inline";x.current=z,J({jsonrpc:"2.0",id:Z,result:{mode:z}}),J({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:z}}),E.current?.(z);return}if(V==="ui/resource-teardown"&&Z!=null){J({jsonrpc:"2.0",id:Z,result:{}});return}V==="ping"&&Z!=null&&J({jsonrpc:"2.0",id:Z,result:{}})};return window.addEventListener("message",P),()=>{q=!0,clearTimeout(Se),H&&clearTimeout(H.timer),window.removeEventListener("message",P)}},[i,ee]),ef("iframe",{ref:h,src:ge,sandbox:"allow-scripts allow-forms allow-same-origin",className:b(!c&&"ww:rounded-md ww:border ww:border-border",n),style:{height:c?"100%":S,minWidth:c||!F?void 0:`min(${F}px, 100%)`,width:"100%",border:"none",colorScheme:s?"dark":"auto"},title:"MCP App"})}import{jsx as Wt,jsxs as tf}from"react/jsx-runtime";function Ln({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return tf("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&&Wt("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}),Wt("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&Wt("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&Wt("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)=>Wt("button",{type:"button",onClick:()=>r?.(s),className:b("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 af}from"react";import{jsx as xn,jsxs as of}from"react/jsx-runtime";var Ea=class extends af{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[WaniWani] Widget failed to render:",t.message)}render(){return this.state.hasError?of("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:[xn("span",{children:"Widget failed to load"}),xn("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 sf,jsx as K,jsxs as it}from"react/jsx-runtime";function rf(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function ut({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:s,chatSessionId:n,isDark:i,onFollowUp:l,onCallTool:u,onWidgetDisplayModeChange:f,fullscreenToolCallId:d,debug:c,toolDefinitions:p}){let h=t==="submitted"||t==="streaming",I=e[e.length-1],L=e.length>0,g=h&&(!L||I.role==="user"),w=d!=null;return it(sf,{children:[!w&&(!L&&o?K(Ln,{...o,onSuggestionSelect:r}):a&&K(Ra,{from:"assistant",children:K(Ba,{children:K(Da,{children:a})})})),e.map(m=>{let C=m.parts.filter(y=>y.type==="text"),x=m.parts.filter(y=>y.type==="reasoning"),S=m.parts.filter(y=>y.type==="file"),k=m.parts.filter(y=>"toolCallId"in y),F=m===I&&m.role==="assistant",_=C.length>0,T=w?k.some(y=>y.toolCallId===d):!1;return w&&!T?K("div",{style:{display:"none"}},m.id):it(Ra,{from:m.role,children:[!T&&x.map((y,A)=>K(en,{text:y.text},`reasoning-${m.id}-${A}`)),k.map(y=>{let A="output"in y?y.output:void 0,E=_a(y.toolName,A,p),O=pn(y.toolName,A,p),B=y.toolCallId===d;return it("div",{style:B?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:[K("div",{style:B?{display:"none"}:void 0,children:it(nn,{children:[K(ln,{title:y.title??rf(y.toolName),state:y.state}),it(un,{children:[K(dn,{input:y.input,debug:c}),A!==void 0&&K(mn,{output:A,errorText:"errorText"in y?y.errorText:void 0,debug:c})]})]})}),E&&s&&A!==void 0&&K(Ea,{children:K(Eo,{isFullscreen:B,resourceUri:E,toolInput:y.input??{},toolResult:{content:A.content,structuredContent:A.structuredContent,_meta:A._meta},resourceEndpoint:s,chatSessionId:n,isDark:i,autoHeight:O,toolDefinitions:p,onFollowUp:l,onCallTool:u,onDisplayModeChange:f?ee=>f(ee,{toolCallId:y.toolCallId,resourceUri:E,toolInput:y.input??{},toolResult:{content:A.content,structuredContent:A.structuredContent,_meta:A._meta},autoHeight:O}):void 0})})]},y.toolCallId)}),!T&&K("div",{children:it(Ba,{children:[S.length>0&&K(Ir,{files:S}),_?C.map((y,A)=>K(Da,{children:y.type==="text"?y.text:""},`${m.id}-${A}`)):F&&h&&K(Za,{})]})})]},m.id)}),!w&&g&&K(Ra,{from:"assistant",children:K(Ba,{children:K(Za,{})})})]})}import{jsx as Na}from"react/jsx-runtime";function dt({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:Na("div",{className:b("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:b("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 nf,useRef as lf}from"react";function ft(e){let t=lf(e);return t.current=e,nf(async a=>{let{api:o,headers:r,onCallTool:s,sessionId:n}=t.current;if(s)return s(a);let i=`${o??"/api/waniwani"}/tool`,l=typeof n=="string"&&n.trim().length>0?n.trim():void 0,u=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...l?{"X-Session-Id":l}:{},...r},body:JSON.stringify(a)});if(!u.ok)throw new Error(`Tool call failed: ${u.status} ${u.statusText}`);return u.json()},[])}import{useChat as wf}from"@ai-sdk/react";import{useCallback as be,useEffect as ct,useRef as Pe,useState as qa}from"react";import{DefaultChatTransport as uf,uiMessageChunkSchema as df}from"ai";function ff(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(i=>(i.code==="invalid_value"||i.code==="invalid_literal")&&i.path?.[0]==="type"))continue;let n=r.filter(i=>i.code==="unrecognized_keys").flatMap(i=>i.keys??[]);if(n.length>0)return n}return null}var Oa=class extends uf{processResponseStream(t){let a="",o=df(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(s,n){a+=s;let i=a.split(`
|
|
16
|
-
`);a=i.pop()??"";for(let l of i){let u=l.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=ff(c.error);if(p?.length){let h={...d};for(let L of p)delete h[L];let I=await r(h);I.success&&n.enqueue(I.value)}}catch{}}}}))}};var Cn="waniwani-visitor-id";function In(e,t){return e.match(t)?.[1]??null}function cf(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=In(e,o);if(r)return{name:a,version:r}}return null}function pf(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=In(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function mf(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 hf(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 gf(){try{let a=localStorage.getItem(Cn);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 hf(e);try{localStorage.setItem(Cn,t)}catch{}return t}async function Sn(){let e=navigator.userAgent,t=await gf();return{userAgent:e,browser:cf(e),os:pf(e),deviceType:mf(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 Lf="x-session-id";function yn(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function xf(e){let t=`${e.replace(/\/$/,"")}/tools`,a=await fetch(t,{method:"GET"});if(!a.ok)throw new Error(`[WaniWani] Failed to fetch /tools: ${a.status} ${a.statusText}`);let o=await a.json();if(!o||!Array.isArray(o.tools))return{};let r={};for(let s of o.tools)s&&typeof s.name=="string"&&(r[s.name]=s);return r}function pt(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:s}=e,n=Pe(a),i=Pe(o),l=Pe(void 0),u=Pe(null),[f,d]=qa(void 0),c=Pe(f),p=be(()=>c.current,[]),h=be(P=>{let D=yn(P);D&&c.current!==D&&(c.current=D,d(D))},[]),I=be(()=>{c.current=void 0,d(void 0)},[]);ct(()=>{n.current=a},[a]),ct(()=>{i.current=o},[o]),ct(()=>{Sn().then(P=>{u.current=P}).catch(()=>{})},[]);let L=Pe(new Oa({api:t,headers:()=>({...n.current}),body:()=>{let P={...i.current??{}},D=Object.hasOwn(P,"sessionId"),N=yn(P.sessionId);if(N)h(N),P.sessionId=N;else if(D)I(),delete P.sessionId;else{let V=p();V&&(P.sessionId=V)}if(lt(l.current)&&(P.modelContext=l.current),u.current){let V=u.current;P.visitorContext={timezone:V.timezone,language:V.language,languages:V.languages,deviceType:V.deviceType,referrer:V.referrer,visitorId:V.visitorId}}return P},fetch:async(P,D)=>{let N=await fetch(P,D);return l.current=void 0,h(N.headers.get(Lf)),N}})),g=Pe(null),w=Pe(null),m=Pe({}),[C,x]=qa(0),S=be(async()=>{try{let P=await xf(t);m.current=P,x(D=>D+1)}catch(P){console.warn("[WaniWani] Failed to fetch tool definitions:",P instanceof Error?P.message:P)}},[t]);ct(()=>{S()},[S]);let{messages:k,sendMessage:F,setMessages:_,status:T}=wf({messages:e.initialMessages,transport:L.current,onFinish({message:P}){s?.(),g.current&&(w.current=P)},onError(P){console.warn("[WaniWani] Chat error:",P.message),g.current&&(g.current.reject(P),g.current=null)}});ct(()=>{if(T==="ready"&&g.current&&w.current){let P=g.current,D=w.current;g.current=null,w.current=null,P.resolve(D)}},[T]);let[y,A]=qa(""),[E,O]=qa([]),B=T==="submitted"||T==="streaming",ee=be(P=>{O(D=>D.filter(N=>N.id!==P))},[]),ge=B&&E.length>0,we=be(P=>{let D=!!P.text?.trim(),N=!!P.files?.length;if(D||N){if(B){if(E.length>0)return;O(V=>[...V,{id:Yt(),text:P.text||"",files:P.files??[],modelContext:P.modelContext}]),A("");return}l.current=P.modelContext,F({text:P.text||"",files:P.files}),r?.(P.text||""),A("")}},[F,r,B,E.length]),M=be(P=>new Promise((D,N)=>{g.current={resolve:D,reject:N},F({text:P}),r?.(P)}),[F,r]);ct(()=>{if(T!=="ready"||E.length===0)return;let[P,...D]=E;O(D),l.current=P.modelContext,F({text:P.text,files:P.files.length>0?P.files:void 0}),r?.(P.text)},[T,F,r,E]);let q=be(()=>{_([]),O([]),I(),A(""),m.current={},x(P=>P+1),S()},[_,I,S]),me=be(P=>{A(P.target.value)},[]),R=k[k.length-1],H=k.length>0,Se=B&&(!H||R.role==="user"),J=m.current;return{messages:k,status:T,text:y,setText:A,handleSubmit:we,handleTextChange:me,isLoading:B,showLoaderBubble:Se,lastMessage:R,hasMessages:H,sendMessage:F,sendMessageAndWait:M,reset:q,queuedMessages:E,queueFull:ge,removeQueuedMessage:ee,sessionId:f,toolDefinitions:J,refreshToolDefinitions:S}}import{useEffect as Cf,useState as If}from"react";var Sf={debug:!1,eval:!1};function mt(e="/api/waniwani"){let[t,a]=If(Sf);return Cf(()=>{(async()=>{try{let r=await(await fetch(`${e}/config`)).json();a({debug:r.debug===!0,eval:r.eval===!0})}catch{}})()},[e]),t}import{useCallback as yf,useEffect as kn,useRef as kf,useState as bf}from"react";function Pf(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 bn(e){return typeof e=="object"&&e!==null&&"initial"in e}function ht(e){let{messages:t,status:a,config:o}=e,[r,s]=bf((bn(o)&&o.initial?o.initial:[])??[]),n=kf(a),i=o===!0||bn(o)&&o.dynamic!==!1,l=yf(()=>{s([])},[]),u=t[t.length-1];return kn(()=>{u?.role==="user"&&l()},[u,l]),kn(()=>{let f=n.current;if(n.current=a,f==="streaming"&&a==="ready"&&i){let d=[...t].reverse().find(p=>p.role==="assistant");if(!d)return;console.log("[WaniWani] Assistant parts:",d.parts);let c=Pf(d);console.log("[WaniWani] Extracted suggestions:",c),c&&s(c)}},[a,i,t]),{suggestions:r,isLoading:!1,clear:l}}import{useEffect as Tf,useRef as Af,useState as vf}from"react";var Ff=50,Mf=30,Rf=2e3,Pn=500;function gt(e,t=!0){let[a,o]=vf(""),r=Af(void 0);return Tf(()=>{if(!t){o("");return}let s=0,n=!1,i=!1,l=()=>{i||(n?(s--,o(e.slice(0,s)),s<=0?(n=!1,r.current=setTimeout(l,Pn)):r.current=setTimeout(l,Mf)):(s++,o(e.slice(0,s)),s>=e.length?(n=!0,r.current=setTimeout(l,Rf)):r.current=setTimeout(l,Ff)))};return r.current=setTimeout(l,Pn),()=>{i=!0,clearTimeout(r.current)}},[e,t]),a}var Tn={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"},Bf={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"},Df={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 Ue(e){return{...Tn,...e}}function wt(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 Ge(e){let t={};for(let[a,o]of Object.entries(Df)){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 le,jsxs as zt}from"react/jsx-runtime";var Oo=_f(function(t,a){let{theme:o,title:r="Assistant",width:s=600,expandedWidth:n,expandedHeight:i=400,allowAttachments:l=!1,welcomeMessage:u,welcome:f,placeholder:d="Ask me anything...",triggerEvent:c="triggerDemoRequest",api:p}=t,h=n??Math.round((typeof s=="number"?s:600)*1.2),I=p??"/api/waniwani",L=`${I}/resource`,g=Ue(o),w=Ge(g),m=wt(g),C=mt(p),x=pt(t),S=ft({...t,sessionId:x.sessionId}),k=ht({messages:x.messages,status:x.status,config:t.suggestions}),F=Ha(R=>{let H=R.content.map(Se=>Se.text??"").join("").trim();H&&x.handleSubmit({text:H,files:[],modelContext:R.modelContext})},[x.handleSubmit]),_=Ha(R=>{k.clear(),x.handleSubmit({text:R,files:[]})},[k.clear,x.handleSubmit]),T=gt(d,!x.text),[y,A]=No(!1),[E,O]=No(!1),[B,ee]=No(null),ge=vn(null),we=vn(void 0),M=Ha(()=>{let R=ge.current;if(!R)return;R.scrollIntoView({behavior:"smooth",block:"center"});let H=R.querySelector("textarea");H&&setTimeout(()=>H.focus(),300),A(!0),O(!0),clearTimeout(we.current),we.current=setTimeout(()=>O(!1),2e3)},[]);Ef(a,()=>({sendMessage:R=>{x.handleSubmit({text:R,files:[]}),M()},sendMessageAndWait:R=>x.sendMessageAndWait(R),reset:x.reset,focus:M,get messages(){return x.messages}}),[x.handleSubmit,x.sendMessageAndWait,x.reset,x.messages,M]),An(()=>{if(!c)return;let R=H=>{let Se=H.detail,J=typeof Se?.message=="string"?Se.message:void 0;J&&x.handleSubmit({text:J,files:[]}),M()};return window.addEventListener(c,R),()=>window.removeEventListener(c,R)},[c,x.handleSubmit,M]);let q=y||B!==null;An(()=>{if(!y)return;let R=H=>{ge.current&&!ge.current.contains(H.target)&&A(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[y]);let me=Ha(()=>{A(!0)},[]);return zt("div",{ref:ge,style:{...w,width:q?h:s,transition:"width 0.4s cubic-bezier(0.16, 1, 0.3, 1)"},"data-waniwani-chat":"","data-waniwani-layout":"bar",...m?{"data-waniwani-dark":""}:{},className:"ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground",children:[zt("div",{style:{overflow:"hidden",backgroundColor:g.backgroundColor,borderRadius:"var(--ww-radius) var(--ww-radius) 0 0",maxHeight:q?i+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:[zt("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[le("div",{className:"ww:text-sm ww:font-semibold ww:truncate",children:r}),le(ea,{messages:x.messages,evalEnabled:C.eval,api:I})]}),zt(Xe,{className:"ww:flex-1",style:{height:i},children:[le(Qe,{scrollClassName:B?"ww:!relative ww:!overflow-hidden":void 0,children:le(ut,{messages:x.messages,status:x.status,welcomeMessage:u,welcome:f,onSuggestionSelect:_,resourceEndpoint:L,chatSessionId:x.sessionId,isDark:m,onFollowUp:F,onCallTool:S,fullscreenToolCallId:B,toolDefinitions:x.toolDefinitions,onWidgetDisplayModeChange:(R,H)=>{ee(R==="fullscreen"?H.toolCallId:null)}})}),le(Ke,{})]}),le("div",{style:B?{display:"none"}:void 0,children:le(dt,{suggestions:k.suggestions,isLoading:k.isLoading,onSelect:_})}),le("div",{style:B?{display:"none"}:void 0,children:le(ot,{queuedMessages:x.queuedMessages,onRemove:x.removeQueuedMessage})})]}),le("div",{style:{backgroundColor:q?g.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:le(Ze,{onSubmit:x.handleSubmit,globalDrop:l,multiple:l,className:b("ww:rounded-2xl ww:border-border ww:bg-input ww:transition-all ww:duration-300",!q&&"ww:shadow-sm",E&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background"),children:zt("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&le(tt,{}),le(Ye,{onChange:x.handleTextChange,value:x.text,placeholder:T,onFocus:me,className:"ww:min-h-0 ww:py-1 ww:px-0"}),le(et,{status:x.status,disabled:x.queueFull})]})})})]})});import{useEffect as Of,useRef as Bn,useState as jt}from"react";import{useCallback as Fn,useEffect as Nf,useState as Mn}from"react";function Rn(e,t){let[a,o]=Mn([]),[r,s]=Mn(!1),n=Fn(()=>{t&&(s(!0),fetch(`${e}/scenarios`).then(l=>l.json()).then(l=>o(l)).catch(()=>{}).finally(()=>s(!1)))},[e,t]);Nf(()=>{n()},[n]);let i=Fn(async(l,u)=>{let f=await fetch(`${e}/scenarios/${l}`,{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===l?{...c,name:u}:c))},[e]);return{scenarios:a,isLoading:r,reload:n,rename:i}}import{jsx as v,jsxs as fe}from"react/jsx-runtime";function qf(e){return e.parts.filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join("")}function Hf({className:e}){return fe("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:[v("title",{children:"Run scenario"}),v("path",{d:"M6 4l15 8-15 8V4z"})]})}function Uf({className:e}){return fe("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:[v("title",{children:"Rename scenario"}),v("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 Gf({className:e}){return fe("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:[v("title",{children:"Confirm"}),v("path",{d:"M20 6 9 17l-5-5"})]})}function Wf({className:e}){return fe("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:[v("title",{children:"Cancel"}),v("path",{d:"M18 6 6 18"}),v("path",{d:"m6 6 12 12"})]})}function Dn({className:e}){return fe("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:b("ww:animate-spin",e),role:"img",children:[v("title",{children:"Running"}),v("path",{d:"M12 2v4"}),v("path",{d:"M12 18v4"}),v("path",{d:"m4.93 4.93 2.83 2.83"}),v("path",{d:"m16.24 16.24 2.83 2.83"}),v("path",{d:"M2 12h4"}),v("path",{d:"M18 12h4"}),v("path",{d:"m4.93 19.07 2.83-2.83"}),v("path",{d:"m16.24 4.93 2.83 2.83"})]})}function zf(){return v("div",{className:"ww:px-3 ww:py-2 ww:space-y-3",children:[1,2,3,4].map(e=>fe("div",{className:"ww:flex ww:items-center ww:gap-2",children:[v("div",{className:"ww:h-1.5 ww:w-1.5 ww:rounded-full ww:bg-muted-foreground/20 ww:shrink-0 ww:animate-pulse"}),v("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 jf({initialName:e,onSave:t,onCancel:a}){let o=Bn(null),[r,s]=jt(e),[n,i]=jt(!1);Of(()=>{o.current?.focus(),o.current?.select()},[]);let l=r.trim()!==""&&r.trim()!==e;async function u(){if(!(!l||n)){i(!0);try{await t(r.trim())}finally{i(!1)}}}function f(d){d.key==="Enter"?u():d.key==="Escape"&&a()}return fe("div",{className:"ww:flex ww:items-center ww:gap-1",children:[v("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"}),v("button",{type:"button",onClick:u,disabled:!l||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?v(Dn,{}):v(Gf,{})}),v("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:v(Wf,{})})]})}var Vf=320;function $f({api:e,chatRef:t}){let a=e??"/api/waniwani",[o,r]=jt(null),[s,n]=jt(null),[i,l]=jt(null),u=Bn(null),f=mt(a),{scenarios:d,isLoading:c,reload:p,rename:h}=Rn(a,f.eval);async function I(g){u.current?.abort(),u.current=new AbortController,r(g.id);try{if(!t?.current)throw new Error("ScenarioPanel requires a chatRef prop pointing to the ChatCard/ChatBar");t.current.reset();let w=g.messages.filter(m=>m.role==="user");for(let m of w){let C=qf(m);C&&await t.current.sendMessageAndWait(C)}}catch(w){w.name!=="AbortError"&&console.error("[ScenarioPanel] run failed:",w)}finally{r(null)}}async function L(g,w){l(null);try{await h(g,w)}catch(m){let C=m instanceof Error?m.message:"Failed to rename scenario";l(C)}n(m=>m===g?null:m)}return f.eval?fe("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:Vf},children:[fe("div",{className:"ww:px-3 ww:py-2 ww:border-b ww:border-border/50 ww:flex ww:items-center ww:justify-between",children:[v("span",{className:"ww:text-[10px] ww:font-mono ww:uppercase ww:tracking-widest ww:text-foreground/60",children:"Scenarios"}),v("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:fe("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:[v("title",{children:"Reload scenarios"}),v("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),v("path",{d:"M21 3v5h-5"})]})})]}),i&&fe("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:[v("span",{className:"ww:flex-1",children:i}),v("button",{type:"button",onClick:()=>l(null),className:"ww:shrink-0 ww:text-red-400 ww:hover:text-red-300 ww:cursor-pointer",children:"\xD7"})]}),v("div",{className:"ww:flex-1 ww:overflow-y-auto ww:min-h-0",children:c?v(zf,{}):d.length===0?v("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(g=>{let w=o===g.id,m=s===g.id;return fe("div",{className:b("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:[v("div",{className:"ww:flex-1 ww:min-w-0",children:m?v(jf,{initialName:g.name,onSave:C=>L(g.id,C),onCancel:()=>n(null)}):v("span",{className:"ww:block ww:truncate ww:text-xs ww:font-mono ww:text-foreground",title:g.name,children:g.name})}),!m&&fe("div",{className:"ww:flex ww:items-center ww:gap-1 ww:shrink-0",children:[!w&&v("button",{type:"button",onClick:()=>n(g.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:v(Uf,{})}),v("button",{type:"button",onClick:()=>I(g),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?v(Dn,{}):v(Hf,{})})]})]},g.id)})})]}):null}import{forwardRef as Xf,useCallback as qo,useEffect as Qf,useImperativeHandle as Kf,useRef as _n,useState as En}from"react";import{jsx as se,jsxs as Ua}from"react/jsx-runtime";var Jf=Xf(function(t,a){let{theme:o,title:r="Assistant",width:s,height:n,className:i,allowAttachments:l=!1,welcomeMessage:u,welcome:f,placeholder:d="Ask me anything...",triggerEvent:c="triggerDemoRequest",api:p,debug:h}=t,I=p??"/api/waniwani",L=`${I}/resource`,g=Ue(o),w=Ge(g),m=wt(g),C=mt(I),x=h??C.debug,S=pt({...t,api:I}),k=ft({...t,api:I,sessionId:S.sessionId}),F=gt(d,!S.text),[_,T]=En(!1),[y,A]=En(null),E=_n(null),O=_n(void 0),B=qo(()=>{let M=E.current;if(!M)return;M.scrollIntoView({behavior:"smooth",block:"center"});let q=M.querySelector("textarea");q&&setTimeout(()=>q.focus(),300),T(!0),clearTimeout(O.current),O.current=setTimeout(()=>T(!1),2e3)},[]),ee=ht({messages:S.messages,status:S.status,config:t.suggestions}),ge=qo(M=>{let q=M.content.map(me=>me.text??"").join("").trim();q&&S.handleSubmit({text:q,files:[],modelContext:M.modelContext})},[S.handleSubmit]),we=qo(M=>{ee.clear(),S.handleSubmit({text:M,files:[]})},[ee.clear,S.handleSubmit]);return Kf(a,()=>({sendMessage:M=>{S.handleSubmit({text:M,files:[]}),B()},sendMessageAndWait:M=>S.sendMessageAndWait(M),reset:S.reset,focus:B,get messages(){return S.messages}}),[S.handleSubmit,S.sendMessageAndWait,S.reset,S.messages,B]),Qf(()=>{if(!c)return;let M=q=>{let me=q.detail,R=typeof me?.message=="string"?me.message:void 0;R&&S.handleSubmit({text:R,files:[]}),B()};return window.addEventListener(c,M),()=>window.removeEventListener(c,M)},[c,S.handleSubmit,B]),Ua("div",{ref:E,style:{...w,width:s,height:n},"data-waniwani-chat":"","data-waniwani-layout":"card",...m?{"data-waniwani-dark":""}:{},className:b("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",i),children:[Ua("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[se("div",{className:"ww:text-sm ww:font-semibold ww:truncate",children:r}),se(ea,{messages:S.messages,evalEnabled:C.eval,api:I})]}),Ua(Xe,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[se(Qe,{scrollClassName:y?"ww:!relative ww:!overflow-hidden":void 0,children:se(ut,{messages:S.messages,status:S.status,welcomeMessage:u,welcome:f,onSuggestionSelect:we,resourceEndpoint:L,chatSessionId:S.sessionId,isDark:m,onFollowUp:ge,onCallTool:k,fullscreenToolCallId:y,debug:x,toolDefinitions:S.toolDefinitions,onWidgetDisplayModeChange:(M,q)=>{A(M==="fullscreen"?q.toolCallId:null)}})}),se(Ke,{})]}),se("div",{style:y?{display:"none"}:void 0,children:se(dt,{suggestions:ee.suggestions,isLoading:ee.isLoading,onSelect:we})}),se("div",{style:y?{display:"none"}:void 0,children:se(ot,{queuedMessages:S.queuedMessages,onRemove:S.removeQueuedMessage})}),se("div",{style:y?{display:"none"}:void 0,children:se("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:se("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:se(Ze,{onSubmit:S.handleSubmit,globalDrop:l,multiple:l,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:Ua("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&se(tt,{}),se(Ye,{onChange:S.handleTextChange,value:S.text,placeholder:F,className:"ww:min-h-0 ww:py-1 ww:px-0"}),se(et,{status:S.status,disabled:S.queueFull})]})})})})})]})});import{forwardRef as Zf,useCallback as Ho,useEffect as Yf,useImperativeHandle as ec,useRef as tc,useState as ac}from"react";import{jsx as ie,jsxs as Uo}from"react/jsx-runtime";var oc=Zf(function(t,a){let{theme:o,className:r,allowAttachments:s=!1,welcomeMessage:n,welcome:i,placeholder:l="Ask me anything...",triggerEvent:u="triggerDemoRequest",api:f,mcp:d,debug:c=!1}=t,p=Ue(o),h=Ge(p),I=wt(p),L=pt({...t,api:f}),g=ft({...t,api:f,sessionId:L.sessionId,onCallTool:d?.onCallTool}),w=gt(l,!L.text),[m,C]=ac(null),x=tc(null),S=Ho(()=>{let T=x.current;if(!T)return;let y=T.querySelector("textarea");y&&y.focus()},[]),k=ht({messages:L.messages,status:L.status,config:t.suggestions}),F=Ho(T=>{let y=T.content.map(A=>A.text??"").join("").trim();y&&L.handleSubmit({text:y,files:[],modelContext:T.modelContext})},[L.handleSubmit]),_=Ho(T=>{k.clear(),L.handleSubmit({text:T,files:[]})},[k.clear,L.handleSubmit]);return ec(a,()=>({sendMessage:T=>{L.handleSubmit({text:T,files:[]}),S()},sendMessageAndWait:T=>L.sendMessageAndWait(T),reset:L.reset,focus:S,get messages(){return L.messages}}),[L.handleSubmit,L.sendMessageAndWait,L.reset,L.messages,S]),Yf(()=>{if(!u)return;let T=y=>{let A=y.detail,E=typeof A?.message=="string"?A.message:void 0;E&&L.handleSubmit({text:E,files:[]}),S()};return window.addEventListener(u,T),()=>window.removeEventListener(u,T)},[u,L.handleSubmit,S]),Uo("div",{ref:x,style:h,"data-waniwani-chat":"","data-waniwani-layout":"embed",...I?{"data-waniwani-dark":""}:{},className:b("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:[Uo(Xe,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[ie(Qe,{scrollClassName:m?"ww:!relative ww:!overflow-hidden":void 0,children:ie(ut,{messages:L.messages,status:L.status,welcomeMessage:n,welcome:i,onSuggestionSelect:_,resourceEndpoint:d?.resourceEndpoint,chatSessionId:L.sessionId,isDark:I,onFollowUp:F,onCallTool:g,fullscreenToolCallId:m,debug:c,toolDefinitions:L.toolDefinitions,onWidgetDisplayModeChange:(T,y)=>{C(T==="fullscreen"?y.toolCallId:null)}})}),ie(Ke,{})]}),ie("div",{style:m?{display:"none"}:void 0,children:ie(dt,{suggestions:k.suggestions,isLoading:k.isLoading,onSelect:_})}),ie("div",{style:m?{display:"none"}:void 0,children:ie(ot,{queuedMessages:L.queuedMessages,onRemove:L.removeQueuedMessage})}),ie("div",{style:m?{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(Ze,{onSubmit:L.handleSubmit,globalDrop:s,multiple:s,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:Uo("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[s&&ie(tt,{}),ie(Ye,{onChange:L.handleTextChange,value:L.text,placeholder:w,className:"ww:min-h-0 ww:py-1 ww:px-0"}),ie(et,{status:L.status,disabled:L.queueFull})]})})})})})]})});export{Oo as ChatBar,Jf as ChatCard,oc as ChatEmbed,Oo as ChatWidget,Bf as DARK_THEME,Tn as DEFAULT_THEME,Eo as McpAppFrame,$f as ScenarioPanel,Ue as mergeTheme,Ge as themeToCSSProperties};
|
|
16
|
+
`);a=i.pop()??"";for(let l of i){let u=l.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=ff(c.error);if(p?.length){let h={...d};for(let L of p)delete h[L];let I=await r(h);I.success&&n.enqueue(I.value)}}catch{}}}}))}};var Cn="waniwani-visitor-id";function In(e,t){return e.match(t)?.[1]??null}function cf(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=In(e,o);if(r)return{name:a,version:r}}return null}function pf(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=In(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function mf(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 hf(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 gf(){try{let a=localStorage.getItem(Cn);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 hf(e);try{localStorage.setItem(Cn,t)}catch{}return t}async function Sn(){let e=navigator.userAgent,t=await gf();return{userAgent:e,browser:cf(e),os:pf(e),deviceType:mf(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 Lf="x-session-id";function yn(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function xf(e){let t=`${e.replace(/\/$/,"")}/tools`,a=await fetch(t,{method:"GET"});if(!a.ok)throw new Error(`[WaniWani] Failed to fetch /tools: ${a.status} ${a.statusText}`);let o=await a.json();if(!o||!Array.isArray(o.tools))return{};let r={};for(let s of o.tools)s&&typeof s.name=="string"&&(r[s.name]=s);return r}function pt(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:s}=e,n=Pe(a),i=Pe(o),l=Pe(void 0),u=Pe(null),[f,d]=qa(void 0),c=Pe(f),p=be(()=>c.current,[]),h=be(P=>{let D=yn(P);D&&c.current!==D&&(c.current=D,d(D))},[]),I=be(()=>{c.current=void 0,d(void 0)},[]);ct(()=>{n.current=a},[a]),ct(()=>{i.current=o},[o]),ct(()=>{Sn().then(P=>{u.current=P}).catch(()=>{})},[]);let L=Pe(new Oa({api:t,headers:()=>({...n.current}),body:()=>{let P={...i.current??{}},D=Object.hasOwn(P,"sessionId"),N=yn(P.sessionId);if(N)h(N),P.sessionId=N;else if(D)I(),delete P.sessionId;else{let V=p();V&&(P.sessionId=V)}if(lt(l.current)&&(P.modelContext=l.current),u.current){let V=u.current;P.visitorContext={timezone:V.timezone,language:V.language,languages:V.languages,deviceType:V.deviceType,referrer:V.referrer,visitorId:V.visitorId}}return P},fetch:(async(P,D)=>{let N=await fetch(P,D);return l.current=void 0,h(N.headers.get(Lf)),N})})),g=Pe(null),w=Pe(null),m=Pe({}),[C,x]=qa(0),S=be(async()=>{try{let P=await xf(t);m.current=P,x(D=>D+1)}catch(P){console.warn("[WaniWani] Failed to fetch tool definitions:",P instanceof Error?P.message:P)}},[t]);ct(()=>{S()},[S]);let{messages:k,sendMessage:F,setMessages:_,status:T}=wf({messages:e.initialMessages,transport:L.current,onFinish({message:P}){s?.(),g.current&&(w.current=P)},onError(P){console.warn("[WaniWani] Chat error:",P.message),g.current&&(g.current.reject(P),g.current=null)}});ct(()=>{if(T==="ready"&&g.current&&w.current){let P=g.current,D=w.current;g.current=null,w.current=null,P.resolve(D)}},[T]);let[y,A]=qa(""),[E,O]=qa([]),B=T==="submitted"||T==="streaming",ee=be(P=>{O(D=>D.filter(N=>N.id!==P))},[]),ge=B&&E.length>0,we=be(P=>{let D=!!P.text?.trim(),N=!!P.files?.length;if(D||N){if(B){if(E.length>0)return;O(V=>[...V,{id:Yt(),text:P.text||"",files:P.files??[],modelContext:P.modelContext}]),A("");return}l.current=P.modelContext,F({text:P.text||"",files:P.files}),r?.(P.text||""),A("")}},[F,r,B,E.length]),M=be(P=>new Promise((D,N)=>{g.current={resolve:D,reject:N},F({text:P}),r?.(P)}),[F,r]);ct(()=>{if(T!=="ready"||E.length===0)return;let[P,...D]=E;O(D),l.current=P.modelContext,F({text:P.text,files:P.files.length>0?P.files:void 0}),r?.(P.text)},[T,F,r,E]);let q=be(()=>{_([]),O([]),I(),A(""),m.current={},x(P=>P+1),S()},[_,I,S]),me=be(P=>{A(P.target.value)},[]),R=k[k.length-1],H=k.length>0,Se=B&&(!H||R.role==="user"),J=m.current;return{messages:k,status:T,text:y,setText:A,handleSubmit:we,handleTextChange:me,isLoading:B,showLoaderBubble:Se,lastMessage:R,hasMessages:H,sendMessage:F,sendMessageAndWait:M,reset:q,queuedMessages:E,queueFull:ge,removeQueuedMessage:ee,sessionId:f,toolDefinitions:J,refreshToolDefinitions:S}}import{useEffect as Cf,useState as If}from"react";var Sf={debug:!1,eval:!1};function mt(e="/api/waniwani"){let[t,a]=If(Sf);return Cf(()=>{(async()=>{try{let r=await(await fetch(`${e}/config`)).json();a({debug:r.debug===!0,eval:r.eval===!0})}catch{}})()},[e]),t}import{useCallback as yf,useEffect as kn,useRef as kf,useState as bf}from"react";function Pf(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 bn(e){return typeof e=="object"&&e!==null&&"initial"in e}function ht(e){let{messages:t,status:a,config:o}=e,[r,s]=bf((bn(o)&&o.initial?o.initial:[])??[]),n=kf(a),i=o===!0||bn(o)&&o.dynamic!==!1,l=yf(()=>{s([])},[]),u=t[t.length-1];return kn(()=>{u?.role==="user"&&l()},[u,l]),kn(()=>{let f=n.current;if(n.current=a,f==="streaming"&&a==="ready"&&i){let d=[...t].reverse().find(p=>p.role==="assistant");if(!d)return;console.log("[WaniWani] Assistant parts:",d.parts);let c=Pf(d);console.log("[WaniWani] Extracted suggestions:",c),c&&s(c)}},[a,i,t]),{suggestions:r,isLoading:!1,clear:l}}import{useEffect as Tf,useRef as Af,useState as vf}from"react";var Ff=50,Mf=30,Rf=2e3,Pn=500;function gt(e,t=!0){let[a,o]=vf(""),r=Af(void 0);return Tf(()=>{if(!t){o("");return}let s=0,n=!1,i=!1,l=()=>{i||(n?(s--,o(e.slice(0,s)),s<=0?(n=!1,r.current=setTimeout(l,Pn)):r.current=setTimeout(l,Mf)):(s++,o(e.slice(0,s)),s>=e.length?(n=!0,r.current=setTimeout(l,Rf)):r.current=setTimeout(l,Ff)))};return r.current=setTimeout(l,Pn),()=>{i=!0,clearTimeout(r.current)}},[e,t]),a}var Tn={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"},Bf={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"},Df={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 Ue(e){return{...Tn,...e}}function wt(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 Ge(e){let t={};for(let[a,o]of Object.entries(Df)){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 le,jsxs as zt}from"react/jsx-runtime";var Oo=_f(function(t,a){let{theme:o,title:r="Assistant",width:s=600,expandedWidth:n,expandedHeight:i=400,allowAttachments:l=!1,welcomeMessage:u,welcome:f,placeholder:d="Ask me anything...",triggerEvent:c="triggerDemoRequest",api:p}=t,h=n??Math.round((typeof s=="number"?s:600)*1.2),I=p??"/api/waniwani",L=`${I}/resource`,g=Ue(o),w=Ge(g),m=wt(g),C=mt(p),x=pt(t),S=ft({...t,sessionId:x.sessionId}),k=ht({messages:x.messages,status:x.status,config:t.suggestions}),F=Ha(R=>{let H=R.content.map(Se=>Se.text??"").join("").trim();H&&x.handleSubmit({text:H,files:[],modelContext:R.modelContext})},[x.handleSubmit]),_=Ha(R=>{k.clear(),x.handleSubmit({text:R,files:[]})},[k.clear,x.handleSubmit]),T=gt(d,!x.text),[y,A]=No(!1),[E,O]=No(!1),[B,ee]=No(null),ge=vn(null),we=vn(void 0),M=Ha(()=>{let R=ge.current;if(!R)return;R.scrollIntoView({behavior:"smooth",block:"center"});let H=R.querySelector("textarea");H&&setTimeout(()=>H.focus(),300),A(!0),O(!0),clearTimeout(we.current),we.current=setTimeout(()=>O(!1),2e3)},[]);Ef(a,()=>({sendMessage:R=>{x.handleSubmit({text:R,files:[]}),M()},sendMessageAndWait:R=>x.sendMessageAndWait(R),reset:x.reset,focus:M,get messages(){return x.messages}}),[x.handleSubmit,x.sendMessageAndWait,x.reset,x.messages,M]),An(()=>{if(!c)return;let R=H=>{let Se=H.detail,J=typeof Se?.message=="string"?Se.message:void 0;J&&x.handleSubmit({text:J,files:[]}),M()};return window.addEventListener(c,R),()=>window.removeEventListener(c,R)},[c,x.handleSubmit,M]);let q=y||B!==null;An(()=>{if(!y)return;let R=H=>{ge.current&&!ge.current.contains(H.target)&&A(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[y]);let me=Ha(()=>{A(!0)},[]);return zt("div",{ref:ge,style:{...w,width:q?h:s,transition:"width 0.4s cubic-bezier(0.16, 1, 0.3, 1)"},"data-waniwani-chat":"","data-waniwani-layout":"bar",...m?{"data-waniwani-dark":""}:{},className:"ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground",children:[zt("div",{style:{overflow:"hidden",backgroundColor:g.backgroundColor,borderRadius:"var(--ww-radius) var(--ww-radius) 0 0",maxHeight:q?i+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:[zt("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[le("div",{className:"ww:text-sm ww:font-semibold ww:truncate",children:r}),le(ea,{messages:x.messages,evalEnabled:C.eval,api:I})]}),zt(Xe,{className:"ww:flex-1",style:{height:i},children:[le(Qe,{scrollClassName:B?"ww:!relative ww:!overflow-hidden":void 0,children:le(ut,{messages:x.messages,status:x.status,welcomeMessage:u,welcome:f,onSuggestionSelect:_,resourceEndpoint:L,chatSessionId:x.sessionId,isDark:m,onFollowUp:F,onCallTool:S,fullscreenToolCallId:B,toolDefinitions:x.toolDefinitions,onWidgetDisplayModeChange:(R,H)=>{ee(R==="fullscreen"?H.toolCallId:null)}})}),le(Ke,{})]}),le("div",{style:B?{display:"none"}:void 0,children:le(dt,{suggestions:k.suggestions,isLoading:k.isLoading,onSelect:_})}),le("div",{style:B?{display:"none"}:void 0,children:le(ot,{queuedMessages:x.queuedMessages,onRemove:x.removeQueuedMessage})})]}),le("div",{style:{backgroundColor:q?g.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:le(Ze,{onSubmit:x.handleSubmit,globalDrop:l,multiple:l,className:b("ww:rounded-2xl ww:border-border ww:bg-input ww:transition-all ww:duration-300",!q&&"ww:shadow-sm",E&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background"),children:zt("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&le(tt,{}),le(Ye,{onChange:x.handleTextChange,value:x.text,placeholder:T,onFocus:me,className:"ww:min-h-0 ww:py-1 ww:px-0"}),le(et,{status:x.status,disabled:x.queueFull})]})})})]})});import{useEffect as Of,useRef as Bn,useState as jt}from"react";import{useCallback as Fn,useEffect as Nf,useState as Mn}from"react";function Rn(e,t){let[a,o]=Mn([]),[r,s]=Mn(!1),n=Fn(()=>{t&&(s(!0),fetch(`${e}/scenarios`).then(l=>l.json()).then(l=>o(Array.isArray(l)?l:[])).catch(()=>{}).finally(()=>s(!1)))},[e,t]);Nf(()=>{n()},[n]);let i=Fn(async(l,u)=>{let f=await fetch(`${e}/scenarios/${l}`,{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===l?{...c,name:u}:c))},[e]);return{scenarios:a,isLoading:r,reload:n,rename:i}}import{jsx as v,jsxs as fe}from"react/jsx-runtime";function qf(e){return e.parts.filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join("")}function Hf({className:e}){return fe("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:[v("title",{children:"Run scenario"}),v("path",{d:"M6 4l15 8-15 8V4z"})]})}function Uf({className:e}){return fe("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:[v("title",{children:"Rename scenario"}),v("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 Gf({className:e}){return fe("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:[v("title",{children:"Confirm"}),v("path",{d:"M20 6 9 17l-5-5"})]})}function Wf({className:e}){return fe("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:[v("title",{children:"Cancel"}),v("path",{d:"M18 6 6 18"}),v("path",{d:"m6 6 12 12"})]})}function Dn({className:e}){return fe("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:b("ww:animate-spin",e),role:"img",children:[v("title",{children:"Running"}),v("path",{d:"M12 2v4"}),v("path",{d:"M12 18v4"}),v("path",{d:"m4.93 4.93 2.83 2.83"}),v("path",{d:"m16.24 16.24 2.83 2.83"}),v("path",{d:"M2 12h4"}),v("path",{d:"M18 12h4"}),v("path",{d:"m4.93 19.07 2.83-2.83"}),v("path",{d:"m16.24 4.93 2.83 2.83"})]})}function zf(){return v("div",{className:"ww:px-3 ww:py-2 ww:space-y-3",children:[1,2,3,4].map(e=>fe("div",{className:"ww:flex ww:items-center ww:gap-2",children:[v("div",{className:"ww:h-1.5 ww:w-1.5 ww:rounded-full ww:bg-muted-foreground/20 ww:shrink-0 ww:animate-pulse"}),v("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 jf({initialName:e,onSave:t,onCancel:a}){let o=Bn(null),[r,s]=jt(e),[n,i]=jt(!1);Of(()=>{o.current?.focus(),o.current?.select()},[]);let l=r.trim()!==""&&r.trim()!==e;async function u(){if(!(!l||n)){i(!0);try{await t(r.trim())}finally{i(!1)}}}function f(d){d.key==="Enter"?u():d.key==="Escape"&&a()}return fe("div",{className:"ww:flex ww:items-center ww:gap-1",children:[v("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"}),v("button",{type:"button",onClick:u,disabled:!l||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?v(Dn,{}):v(Gf,{})}),v("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:v(Wf,{})})]})}var Vf=320;function $f({api:e,chatRef:t}){let a=e??"/api/waniwani",[o,r]=jt(null),[s,n]=jt(null),[i,l]=jt(null),u=Bn(null),f=mt(a),{scenarios:d,isLoading:c,reload:p,rename:h}=Rn(a,f.eval);async function I(g){u.current?.abort(),u.current=new AbortController,r(g.id);try{if(!t?.current)throw new Error("ScenarioPanel requires a chatRef prop pointing to the ChatCard/ChatBar");t.current.reset();let w=g.messages.filter(m=>m.role==="user");for(let m of w){let C=qf(m);C&&await t.current.sendMessageAndWait(C)}}catch(w){w.name!=="AbortError"&&console.error("[ScenarioPanel] run failed:",w)}finally{r(null)}}async function L(g,w){l(null);try{await h(g,w)}catch(m){let C=m instanceof Error?m.message:"Failed to rename scenario";l(C)}n(m=>m===g?null:m)}return f.eval?fe("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:Vf},children:[fe("div",{className:"ww:px-3 ww:py-2 ww:border-b ww:border-border/50 ww:flex ww:items-center ww:justify-between",children:[v("span",{className:"ww:text-[10px] ww:font-mono ww:uppercase ww:tracking-widest ww:text-foreground/60",children:"Scenarios"}),v("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:fe("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:[v("title",{children:"Reload scenarios"}),v("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),v("path",{d:"M21 3v5h-5"})]})})]}),i&&fe("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:[v("span",{className:"ww:flex-1",children:i}),v("button",{type:"button",onClick:()=>l(null),className:"ww:shrink-0 ww:text-red-400 ww:hover:text-red-300 ww:cursor-pointer",children:"\xD7"})]}),v("div",{className:"ww:flex-1 ww:overflow-y-auto ww:min-h-0",children:c?v(zf,{}):d.length===0?v("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(g=>{let w=o===g.id,m=s===g.id;return fe("div",{className:b("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:[v("div",{className:"ww:flex-1 ww:min-w-0",children:m?v(jf,{initialName:g.name,onSave:C=>L(g.id,C),onCancel:()=>n(null)}):v("span",{className:"ww:block ww:truncate ww:text-xs ww:font-mono ww:text-foreground",title:g.name,children:g.name})}),!m&&fe("div",{className:"ww:flex ww:items-center ww:gap-1 ww:shrink-0",children:[!w&&v("button",{type:"button",onClick:()=>n(g.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:v(Uf,{})}),v("button",{type:"button",onClick:()=>I(g),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?v(Dn,{}):v(Hf,{})})]})]},g.id)})})]}):null}import{forwardRef as Xf,useCallback as qo,useEffect as Qf,useImperativeHandle as Kf,useRef as _n,useState as En}from"react";import{jsx as se,jsxs as Ua}from"react/jsx-runtime";var Jf=Xf(function(t,a){let{theme:o,title:r="Assistant",width:s,height:n,className:i,allowAttachments:l=!1,welcomeMessage:u,welcome:f,placeholder:d="Ask me anything...",triggerEvent:c="triggerDemoRequest",api:p,debug:h}=t,I=p??"/api/waniwani",L=`${I}/resource`,g=Ue(o),w=Ge(g),m=wt(g),C=mt(I),x=h??C.debug,S=pt({...t,api:I}),k=ft({...t,api:I,sessionId:S.sessionId}),F=gt(d,!S.text),[_,T]=En(!1),[y,A]=En(null),E=_n(null),O=_n(void 0),B=qo(()=>{let M=E.current;if(!M)return;M.scrollIntoView({behavior:"smooth",block:"center"});let q=M.querySelector("textarea");q&&setTimeout(()=>q.focus(),300),T(!0),clearTimeout(O.current),O.current=setTimeout(()=>T(!1),2e3)},[]),ee=ht({messages:S.messages,status:S.status,config:t.suggestions}),ge=qo(M=>{let q=M.content.map(me=>me.text??"").join("").trim();q&&S.handleSubmit({text:q,files:[],modelContext:M.modelContext})},[S.handleSubmit]),we=qo(M=>{ee.clear(),S.handleSubmit({text:M,files:[]})},[ee.clear,S.handleSubmit]);return Kf(a,()=>({sendMessage:M=>{S.handleSubmit({text:M,files:[]}),B()},sendMessageAndWait:M=>S.sendMessageAndWait(M),reset:S.reset,focus:B,get messages(){return S.messages}}),[S.handleSubmit,S.sendMessageAndWait,S.reset,S.messages,B]),Qf(()=>{if(!c)return;let M=q=>{let me=q.detail,R=typeof me?.message=="string"?me.message:void 0;R&&S.handleSubmit({text:R,files:[]}),B()};return window.addEventListener(c,M),()=>window.removeEventListener(c,M)},[c,S.handleSubmit,B]),Ua("div",{ref:E,style:{...w,width:s,height:n},"data-waniwani-chat":"","data-waniwani-layout":"card",...m?{"data-waniwani-dark":""}:{},className:b("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",i),children:[Ua("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[se("div",{className:"ww:text-sm ww:font-semibold ww:truncate",children:r}),se(ea,{messages:S.messages,evalEnabled:C.eval,api:I})]}),Ua(Xe,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[se(Qe,{scrollClassName:y?"ww:!relative ww:!overflow-hidden":void 0,children:se(ut,{messages:S.messages,status:S.status,welcomeMessage:u,welcome:f,onSuggestionSelect:we,resourceEndpoint:L,chatSessionId:S.sessionId,isDark:m,onFollowUp:ge,onCallTool:k,fullscreenToolCallId:y,debug:x,toolDefinitions:S.toolDefinitions,onWidgetDisplayModeChange:(M,q)=>{A(M==="fullscreen"?q.toolCallId:null)}})}),se(Ke,{})]}),se("div",{style:y?{display:"none"}:void 0,children:se(dt,{suggestions:ee.suggestions,isLoading:ee.isLoading,onSelect:we})}),se("div",{style:y?{display:"none"}:void 0,children:se(ot,{queuedMessages:S.queuedMessages,onRemove:S.removeQueuedMessage})}),se("div",{style:y?{display:"none"}:void 0,children:se("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:se("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:se(Ze,{onSubmit:S.handleSubmit,globalDrop:l,multiple:l,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:Ua("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&se(tt,{}),se(Ye,{onChange:S.handleTextChange,value:S.text,placeholder:F,className:"ww:min-h-0 ww:py-1 ww:px-0"}),se(et,{status:S.status,disabled:S.queueFull})]})})})})})]})});import{forwardRef as Zf,useCallback as Ho,useEffect as Yf,useImperativeHandle as ec,useRef as tc,useState as ac}from"react";import{jsx as ie,jsxs as Uo}from"react/jsx-runtime";var oc=Zf(function(t,a){let{theme:o,className:r,allowAttachments:s=!1,welcomeMessage:n,welcome:i,placeholder:l="Ask me anything...",triggerEvent:u="triggerDemoRequest",api:f,mcp:d,debug:c=!1}=t,p=Ue(o),h=Ge(p),I=wt(p),L=pt({...t,api:f}),g=ft({...t,api:f,sessionId:L.sessionId,onCallTool:d?.onCallTool}),w=gt(l,!L.text),[m,C]=ac(null),x=tc(null),S=Ho(()=>{let T=x.current;if(!T)return;let y=T.querySelector("textarea");y&&y.focus()},[]),k=ht({messages:L.messages,status:L.status,config:t.suggestions}),F=Ho(T=>{let y=T.content.map(A=>A.text??"").join("").trim();y&&L.handleSubmit({text:y,files:[],modelContext:T.modelContext})},[L.handleSubmit]),_=Ho(T=>{k.clear(),L.handleSubmit({text:T,files:[]})},[k.clear,L.handleSubmit]);return ec(a,()=>({sendMessage:T=>{L.handleSubmit({text:T,files:[]}),S()},sendMessageAndWait:T=>L.sendMessageAndWait(T),reset:L.reset,focus:S,get messages(){return L.messages}}),[L.handleSubmit,L.sendMessageAndWait,L.reset,L.messages,S]),Yf(()=>{if(!u)return;let T=y=>{let A=y.detail,E=typeof A?.message=="string"?A.message:void 0;E&&L.handleSubmit({text:E,files:[]}),S()};return window.addEventListener(u,T),()=>window.removeEventListener(u,T)},[u,L.handleSubmit,S]),Uo("div",{ref:x,style:h,"data-waniwani-chat":"","data-waniwani-layout":"embed",...I?{"data-waniwani-dark":""}:{},className:b("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:[Uo(Xe,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[ie(Qe,{scrollClassName:m?"ww:!relative ww:!overflow-hidden":void 0,children:ie(ut,{messages:L.messages,status:L.status,welcomeMessage:n,welcome:i,onSuggestionSelect:_,resourceEndpoint:d?.resourceEndpoint,chatSessionId:L.sessionId,isDark:I,onFollowUp:F,onCallTool:g,fullscreenToolCallId:m,debug:c,toolDefinitions:L.toolDefinitions,onWidgetDisplayModeChange:(T,y)=>{C(T==="fullscreen"?y.toolCallId:null)}})}),ie(Ke,{})]}),ie("div",{style:m?{display:"none"}:void 0,children:ie(dt,{suggestions:k.suggestions,isLoading:k.isLoading,onSelect:_})}),ie("div",{style:m?{display:"none"}:void 0,children:ie(ot,{queuedMessages:L.queuedMessages,onRemove:L.removeQueuedMessage})}),ie("div",{style:m?{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(Ze,{onSubmit:L.handleSubmit,globalDrop:s,multiple:s,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:Uo("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[s&&ie(tt,{}),ie(Ye,{onChange:L.handleTextChange,value:L.text,placeholder:w,className:"ww:min-h-0 ww:py-1 ww:px-0"}),ie(et,{status:L.status,disabled:L.queueFull})]})})})})})]})});export{Oo as ChatBar,Jf as ChatCard,oc as ChatEmbed,Oo as ChatWidget,Bf as DARK_THEME,Tn as DEFAULT_THEME,Eo as McpAppFrame,$f as ScenarioPanel,Ue as mergeTheme,Ge as themeToCSSProperties};
|
|
17
17
|
/*! Bundled license information:
|
|
18
18
|
|
|
19
19
|
lucide-react/dist/esm/shared/src/utils/mergeClasses.js:
|