@waniwani/sdk 0.14.2 → 0.14.4

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.
Files changed (41) hide show
  1. package/README.md +5 -5
  2. package/dist/chat/embed.js +69 -70
  3. package/dist/chat/embed.js.map +1 -1
  4. package/dist/chat/express-js/index.d.ts +4 -4
  5. package/dist/chat/express-js/index.js.map +1 -1
  6. package/dist/chat/index.d.ts +14 -9
  7. package/dist/chat/index.js +7 -8
  8. package/dist/chat/index.js.map +1 -1
  9. package/dist/chat/next-js/index.d.ts +5 -5
  10. package/dist/chat/next-js/index.js.map +1 -1
  11. package/dist/chat/server/index.d.ts +4 -4
  12. package/dist/chat/server/index.js.map +1 -1
  13. package/dist/index.d.ts +9 -9
  14. package/dist/index.js +1 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/kb/index.js.map +1 -1
  17. package/dist/legacy/chat/express-js/index.d.ts +4 -4
  18. package/dist/legacy/chat/express-js/index.js.map +1 -1
  19. package/dist/legacy/chat/next-js/index.d.ts +5 -5
  20. package/dist/legacy/chat/next-js/index.js.map +1 -1
  21. package/dist/legacy/index.d.ts +16 -11
  22. package/dist/legacy/index.js +13 -14
  23. package/dist/legacy/index.js.map +1 -1
  24. package/dist/legacy/mcp/react.d.ts +1 -1
  25. package/dist/legacy/mcp/react.js +1 -1
  26. package/dist/legacy/mcp/react.js.map +1 -1
  27. package/dist/mcp/index.d.ts +15 -15
  28. package/dist/mcp/index.js +5 -5
  29. package/dist/mcp/index.js.map +1 -1
  30. package/dist/mcp/react.d.ts +3 -3
  31. package/dist/mcp/react.js +1 -1
  32. package/dist/mcp/react.js.map +1 -1
  33. package/dist/{mcp-apps-client-OFYMQOI3.js → mcp-apps-client-WEXKWHUI.js} +2 -2
  34. package/dist/{mcp-apps-client-OFYMQOI3.js.map → mcp-apps-client-WEXKWHUI.js.map} +1 -1
  35. package/dist/{mcp-apps-client-RY3VD4L7.js → mcp-apps-client-Z5ICFYSR.js} +2 -2
  36. package/dist/{mcp-apps-client-RY3VD4L7.js.map → mcp-apps-client-Z5ICFYSR.js.map} +1 -1
  37. package/dist/{openai-client-TZIOCMXP.js → openai-client-PUBKF5TI.js} +2 -2
  38. package/dist/{openai-client-TZIOCMXP.js.map → openai-client-PUBKF5TI.js.map} +1 -1
  39. package/dist/{openai-client-XYLENCIC.js → openai-client-VRJPAPFR.js} +2 -2
  40. package/dist/{openai-client-XYLENCIC.js.map → openai-client-VRJPAPFR.js.map} +1 -1
  41. package/package.json +2 -2
@@ -180,7 +180,7 @@ interface UnstableSendFollowUpWithGhostGuardResult {
180
180
  * on mount — if it sees a record set by a different `mountId` within
181
181
  * `ADVANCED_WINDOW_MS`, it collapses the iframe to 0×0.
182
182
  *
183
- * On every other host (WaniWani embed, MCP Apps, etc.) the hook is a
183
+ * On every other host (Waniwani embed, MCP Apps, etc.) the hook is a
184
184
  * pure pass-through: `sendFollowUp` is your function unchanged and
185
185
  * `Guard` is a transparent fragment.
186
186
  *
@@ -59,7 +59,7 @@ import{a as K,b as De,c as Ie}from"../../chunk-DP6SAQTK.js";import{b as O,c as Y
59
59
  0 25px 50px -12px rgba(0, 0, 0, 0.6),
60
60
  0 0 0 1px rgba(255, 255, 255, 0.05),
61
61
  inset 0 1px 0 rgba(255, 255, 255, 0.04)
62
- `},children:[p("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid rgba(255, 255, 255, 0.06)"},children:[p("div",{className:"flex items-center gap-2",children:[o(Z,{className:"w-4 h-4 text-gray-400"}),o("span",{className:"text-sm font-medium text-white",children:"Dev Controls"})]}),p("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-[10px] font-medium text-gray-500 px-1.5 py-0.5 rounded",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:typeof navigator<"u"&&navigator.platform?.includes("Mac")?"\u2318\u21E7D":"Ctrl+Shift+D"}),o("button",{type:"button",onClick:M,className:"p-1 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:o(He,{className:"w-4 h-4"})})]})]}),p("div",{className:"p-4 space-y-5 overflow-y-auto",style:{maxHeight:"calc(100vh - 200px)"},children:[p("div",{children:[o("label",{htmlFor:"display-mode",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Display Mode"}),o(ee,{options:We,value:w,onChange:Te})]}),p("div",{children:[o("label",{htmlFor:"theme",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Theme"}),o(ee,{options:Ae,value:s,onChange:Re})]}),p("div",{children:[o("label",{htmlFor:"safe-area",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Safe Area (Chat Input)"}),p("button",{type:"button",onClick:()=>r(!c),className:`w-full flex items-center justify-between px-3 py-2.5 rounded-lg text-xs font-medium transition-all duration-150 ${c?"text-emerald-400":"text-gray-400"}`,style:{background:c?"rgba(34, 197, 94, 0.1)":"rgba(255, 255, 255, 0.04)",border:c?"1px solid rgba(34, 197, 94, 0.3)":"1px solid rgba(255, 255, 255, 0.06)"},children:[o("span",{children:"Mock ChatGPT Input Bar"}),o("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold ${c?"bg-emerald-500/20 text-emerald-400":"bg-gray-500/20 text-gray-500"}`,children:c?"ON":"OFF"})]}),c&&p("p",{className:"text-[10px] text-gray-500 mt-1.5",children:["bottom: ",H,"px"]})]}),p("div",{children:[o("label",{htmlFor:"widget-props",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Widget Props"}),o("textarea",{value:x,onChange:a=>Ne(a.target.value),onBlur:Oe,className:"dev-json-editor w-full min-h-[160px] text-xs text-gray-200 p-3 rounded-lg resize-none focus:outline-none transition-colors",style:{background:"rgba(0, 0, 0, 0.3)",border:f?"1px solid rgba(239, 68, 68, 0.5)":"1px solid rgba(255, 255, 255, 0.06)",fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",lineHeight:1.6},onFocus:a=>{f||(a.target.style.borderColor="rgba(99, 102, 241, 0.5)")},onBlurCapture:a=>{f||(a.target.style.borderColor="rgba(255, 255, 255, 0.06)")},spellCheck:!1}),f&&p("p",{className:"text-red-400 text-[11px] mt-1.5 flex items-center gap-1",children:[o("svg",{"aria-hidden":"true","aria-label":"Error",className:"w-3 h-3",viewBox:"0 0 16 16",fill:"currentColor",children:o("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"})}),f]})]}),p("button",{type:"button",onClick:Ue,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-xs font-medium text-gray-400 transition-all duration-150 hover:text-gray-200",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},onMouseEnter:a=>{a.currentTarget.style.background="rgba(255, 255, 255, 0.08)",a.currentTarget.style.borderColor="rgba(255, 255, 255, 0.1)"},onMouseLeave:a=>{a.currentTarget.style.background="rgba(255, 255, 255, 0.04)",a.currentTarget.style.borderColor="rgba(255, 255, 255, 0.06)"},children:[o(Je,{className:"w-3.5 h-3.5"}),"Reset to Defaults"]})]})]})]}),c&&p("div",{className:"fixed bottom-0 left-0 right-0 z-[9998] flex items-center justify-center pointer-events-none",style:{height:`${H}px`,background:"linear-gradient(to top, #1a1a1a 0%, #1a1a1a 80%, transparent 100%)"},children:[p("div",{className:"w-full max-w-2xl mx-4 px-4 py-3 rounded-2xl bg-[#2f2f2f] border border-[#424242] flex items-center gap-3",children:[o("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:o("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),o("div",{className:"flex-1 text-gray-400 text-sm",children:"Ask me anything..."}),o("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:o("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})})]}),p("div",{className:"absolute bottom-1 text-[10px] text-gray-600 font-mono",children:["Mock SafeArea: bottom=",H,"px"]})]})]})}import{useCallback as Ye,useContext as Qe,useLayoutEffect as Ze,useMemo as et,useRef as oe}from"react";import{createContext as Xe}from"react";var E=Xe(null);import{Fragment as ne,jsx as $}from"react/jsx-runtime";var tt="waniwani:send-follow-up:advanced:",ot=1e4;function re(e){return`${tt}${e??"default"}`}function nt(e){try{let t=globalThis.localStorage?.getItem(re(e));if(!t)return null;let n=JSON.parse(t);return typeof n?.at!="number"||typeof n?.byMountId!="string"?null:n}catch{return null}}function rt(e,t){try{globalThis.localStorage?.setItem(re(e),JSON.stringify({at:Date.now(),byMountId:t}))}catch{}}function V(){return typeof window>"u"?!1:typeof window.openai=="object"}function it(){return V()?window.openai:null}function at(){return Ze(()=>{let e=document.documentElement,t=document.body,n=e.getAttribute("style"),d=t.getAttribute("style"),u="margin:0!important;padding:0!important;border:0!important;background:transparent!important;background-color:transparent!important;height:0!important;min-height:0!important;max-height:0!important;overflow:hidden!important;";return e.setAttribute("style",u),t.setAttribute("style",u),()=>{n===null?e.removeAttribute("style"):e.setAttribute("style",n),d===null?t.removeAttribute("style"):t.setAttribute("style",d)}},[]),null}function ie(e){let t=Qe(E),n=oe(e);n.current=e;let d=t?.getToolResponseMetadata?.()??null,u=it()?.toolResponseMetadata??null,m=d??u,h=m&&typeof m.viewUUID=="string"?m.viewUUID:void 0,w=oe("");w.current===""&&(w.current=crypto.randomUUID());let g=Ye((i,c)=>{V()&&rt(h,w.current);try{Promise.resolve(n.current(i)).catch(r=>{console.error("[unstable_useSendFollowUpWithGhostGuard]",r)})}catch(r){console.error("[unstable_useSendFollowUpWithGhostGuard]",r)}},[h]),s=et(()=>{let i=w.current;return function({children:r}){if(!V())return $(ne,{children:r});let x=nt(h);return x&&x.byMountId!==i&&Date.now()-x.at<ot?$(at,{}):$(ne,{children:r})}},[h]);return{sendFollowUp:g,Guard:s}}import{useCallback as dt}from"react";import F,{useCallback as se,useContext as st,useEffect as le,useState as q,useSyncExternalStore as lt}from"react";async function ae(){let{detectPlatform:e}=await import("../../platform-LKQFC3AJ.js");if(e()==="openai"){let{OpenAIWidgetClient:n}=await import("../../openai-client-TZIOCMXP.js");return new n}else{let{MCPAppsWidgetClient:n}=await import("../../mcp-apps-client-OFYMQOI3.js");return new n}}function de({children:e,loading:t=null,onError:n}){let[d,u]=q(null),[m,h]=q(null),[w,g]=q(!0);return le(()=>{let s=!0,i=null;async function c(){try{let r=await ae();await r.connect(),s?(i=r,u(r),g(!1)):r.close()}catch(r){s&&(console.error("error",r),h(r instanceof Error?r:new Error(String(r))),g(!1))}}return c(),()=>{s=!1,i?.close()}},[]),le(()=>{if(!d)return;let s=i=>{document.documentElement.classList.toggle("dark",i==="dark"),document.documentElement.style.colorScheme=i==="dark"?"dark":"auto"};return s(d.getTheme()),d.onThemeChange(s)},[d]),m&&n?F.createElement(F.Fragment,null,n(m)):w||!d?F.createElement(F.Fragment,null,t):F.createElement(E.Provider,{value:d},e)}function l(e){let t=st(E);if(!t)throw new Error("useWidgetClient must be used within a WidgetProvider");let n=se(m=>e==="toolOutput"?t.onToolResult(()=>m()):e==="theme"?t.onThemeChange(()=>m()):e==="displayMode"?t.onDisplayModeChange(()=>m()):e==="safeArea"?t.onSafeAreaChange(()=>m()):e==="maxHeight"?t.onMaxHeightChange(()=>m()):e==="toolResponseMetadata"?t.onToolResponseMetadataChange(()=>m()):e==="widgetState"?t.onWidgetStateChange(()=>m()):()=>{},[t,e]),d=se(()=>e==="toolOutput"?t.getToolOutput():e==="theme"?t.getTheme():e==="displayMode"?t.getDisplayMode():e==="locale"?t.getLocale():e==="safeArea"?t.getSafeArea():e==="maxHeight"?t.getMaxHeight():e==="toolResponseMetadata"?t.getToolResponseMetadata():e==="widgetState"?t.getWidgetState():null,[t,e]),u=lt(n,d,d);return e?u:t}function ue(){let e=l();return dt((t,n)=>e.callTool(t,n),[e])}function ce(){return l("displayMode")}function _(){return l("toolOutput")}function pe(){return{data:_()}}import{useSyncExternalStore as ut}from"react";function me(){return ut(()=>()=>{},()=>typeof window>"u"?!1:window.__isChatGptApp===!0,()=>!1)}function ge(){return l("locale")}function fe(){return l("maxHeight")}import{useCallback as ct}from"react";function he(){let e=l();return ct(t=>e.openExternal(t),[e])}import{useCallback as pt}from"react";function we(){let e=l();return pt(t=>e.requestDisplayMode(t),[e])}function xe(){return l("safeArea")}import{useCallback as mt}from"react";function ye(){let e=l();return mt((t,n)=>{(async()=>{Y(n?.modelContext)&&await Promise.resolve(e.updateModelContext(n.modelContext)),await Promise.resolve(e.sendFollowUp(t))})().catch(d=>{console.error("Failed to send follow-up message:",d)})},[e])}function be(){return l("theme")}function ve(){return l("toolResponseMetadata")}import{useCallback as gt}from"react";function ke(){let e=l();return gt(async t=>{await Promise.resolve(e.updateModelContext(t))},[e])}import{useCallback as ft,useEffect as ht,useState as wt}from"react";function Ce(e){let t=l("widgetState"),[n,d]=wt(()=>t??(typeof e=="function"?e():e??null));ht(()=>{d(t)},[t]);let u=ft(m=>{d(h=>{let w=typeof m=="function"?m(h):m;return K()==="openai"&&w!=null&&window.openai?.setWidgetState(w),w})},[]);return[n,u]}import{jsx as T,jsxs as Me}from"react/jsx-runtime";var xt=()=>Me("div",{className:"flex flex-col items-center justify-center h-full min-h-[120px] gap-4",children:[Me("div",{className:"flex gap-2",children:[T("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-blue-400 to-cyan-400 animate-bounce [animation-delay:-0.3s]"}),T("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-cyan-400 to-teal-400 animate-bounce [animation-delay:-0.15s]"}),T("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-teal-400 to-emerald-400 animate-bounce"})]}),T("p",{className:"text-sm font-medium text-transparent bg-clip-text bg-gradient-to-r from-slate-400 via-slate-200 to-slate-400 bg-[length:200%_100%] animate-[shimmer_1.5s_ease-in-out_infinite]",children:"Loading widget..."}),T("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:T("div",{className:"w-16 h-16 rounded-full border-2 border-blue-400/20 animate-ping"})}),T("style",{children:`
62
+ `},children:[p("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid rgba(255, 255, 255, 0.06)"},children:[p("div",{className:"flex items-center gap-2",children:[o(Z,{className:"w-4 h-4 text-gray-400"}),o("span",{className:"text-sm font-medium text-white",children:"Dev Controls"})]}),p("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-[10px] font-medium text-gray-500 px-1.5 py-0.5 rounded",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:typeof navigator<"u"&&navigator.platform?.includes("Mac")?"\u2318\u21E7D":"Ctrl+Shift+D"}),o("button",{type:"button",onClick:M,className:"p-1 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:o(He,{className:"w-4 h-4"})})]})]}),p("div",{className:"p-4 space-y-5 overflow-y-auto",style:{maxHeight:"calc(100vh - 200px)"},children:[p("div",{children:[o("label",{htmlFor:"display-mode",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Display Mode"}),o(ee,{options:We,value:w,onChange:Te})]}),p("div",{children:[o("label",{htmlFor:"theme",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Theme"}),o(ee,{options:Ae,value:s,onChange:Re})]}),p("div",{children:[o("label",{htmlFor:"safe-area",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Safe Area (Chat Input)"}),p("button",{type:"button",onClick:()=>r(!c),className:`w-full flex items-center justify-between px-3 py-2.5 rounded-lg text-xs font-medium transition-all duration-150 ${c?"text-emerald-400":"text-gray-400"}`,style:{background:c?"rgba(34, 197, 94, 0.1)":"rgba(255, 255, 255, 0.04)",border:c?"1px solid rgba(34, 197, 94, 0.3)":"1px solid rgba(255, 255, 255, 0.06)"},children:[o("span",{children:"Mock ChatGPT Input Bar"}),o("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold ${c?"bg-emerald-500/20 text-emerald-400":"bg-gray-500/20 text-gray-500"}`,children:c?"ON":"OFF"})]}),c&&p("p",{className:"text-[10px] text-gray-500 mt-1.5",children:["bottom: ",H,"px"]})]}),p("div",{children:[o("label",{htmlFor:"widget-props",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Widget Props"}),o("textarea",{value:x,onChange:a=>Ne(a.target.value),onBlur:Oe,className:"dev-json-editor w-full min-h-[160px] text-xs text-gray-200 p-3 rounded-lg resize-none focus:outline-none transition-colors",style:{background:"rgba(0, 0, 0, 0.3)",border:f?"1px solid rgba(239, 68, 68, 0.5)":"1px solid rgba(255, 255, 255, 0.06)",fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",lineHeight:1.6},onFocus:a=>{f||(a.target.style.borderColor="rgba(99, 102, 241, 0.5)")},onBlurCapture:a=>{f||(a.target.style.borderColor="rgba(255, 255, 255, 0.06)")},spellCheck:!1}),f&&p("p",{className:"text-red-400 text-[11px] mt-1.5 flex items-center gap-1",children:[o("svg",{"aria-hidden":"true","aria-label":"Error",className:"w-3 h-3",viewBox:"0 0 16 16",fill:"currentColor",children:o("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"})}),f]})]}),p("button",{type:"button",onClick:Ue,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-xs font-medium text-gray-400 transition-all duration-150 hover:text-gray-200",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},onMouseEnter:a=>{a.currentTarget.style.background="rgba(255, 255, 255, 0.08)",a.currentTarget.style.borderColor="rgba(255, 255, 255, 0.1)"},onMouseLeave:a=>{a.currentTarget.style.background="rgba(255, 255, 255, 0.04)",a.currentTarget.style.borderColor="rgba(255, 255, 255, 0.06)"},children:[o(Je,{className:"w-3.5 h-3.5"}),"Reset to Defaults"]})]})]})]}),c&&p("div",{className:"fixed bottom-0 left-0 right-0 z-[9998] flex items-center justify-center pointer-events-none",style:{height:`${H}px`,background:"linear-gradient(to top, #1a1a1a 0%, #1a1a1a 80%, transparent 100%)"},children:[p("div",{className:"w-full max-w-2xl mx-4 px-4 py-3 rounded-2xl bg-[#2f2f2f] border border-[#424242] flex items-center gap-3",children:[o("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:o("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),o("div",{className:"flex-1 text-gray-400 text-sm",children:"Ask me anything..."}),o("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:o("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})})]}),p("div",{className:"absolute bottom-1 text-[10px] text-gray-600 font-mono",children:["Mock SafeArea: bottom=",H,"px"]})]})]})}import{useCallback as Ye,useContext as Qe,useLayoutEffect as Ze,useMemo as et,useRef as oe}from"react";import{createContext as Xe}from"react";var E=Xe(null);import{Fragment as ne,jsx as $}from"react/jsx-runtime";var tt="waniwani:send-follow-up:advanced:",ot=1e4;function re(e){return`${tt}${e??"default"}`}function nt(e){try{let t=globalThis.localStorage?.getItem(re(e));if(!t)return null;let n=JSON.parse(t);return typeof n?.at!="number"||typeof n?.byMountId!="string"?null:n}catch{return null}}function rt(e,t){try{globalThis.localStorage?.setItem(re(e),JSON.stringify({at:Date.now(),byMountId:t}))}catch{}}function V(){return typeof window>"u"?!1:typeof window.openai=="object"}function it(){return V()?window.openai:null}function at(){return Ze(()=>{let e=document.documentElement,t=document.body,n=e.getAttribute("style"),d=t.getAttribute("style"),u="margin:0!important;padding:0!important;border:0!important;background:transparent!important;background-color:transparent!important;height:0!important;min-height:0!important;max-height:0!important;overflow:hidden!important;";return e.setAttribute("style",u),t.setAttribute("style",u),()=>{n===null?e.removeAttribute("style"):e.setAttribute("style",n),d===null?t.removeAttribute("style"):t.setAttribute("style",d)}},[]),null}function ie(e){let t=Qe(E),n=oe(e);n.current=e;let d=t?.getToolResponseMetadata?.()??null,u=it()?.toolResponseMetadata??null,m=d??u,h=m&&typeof m.viewUUID=="string"?m.viewUUID:void 0,w=oe("");w.current===""&&(w.current=crypto.randomUUID());let g=Ye((i,c)=>{V()&&rt(h,w.current);try{Promise.resolve(n.current(i)).catch(r=>{console.error("[unstable_useSendFollowUpWithGhostGuard]",r)})}catch(r){console.error("[unstable_useSendFollowUpWithGhostGuard]",r)}},[h]),s=et(()=>{let i=w.current;return function({children:r}){if(!V())return $(ne,{children:r});let x=nt(h);return x&&x.byMountId!==i&&Date.now()-x.at<ot?$(at,{}):$(ne,{children:r})}},[h]);return{sendFollowUp:g,Guard:s}}import{useCallback as dt}from"react";import F,{useCallback as se,useContext as st,useEffect as le,useState as q,useSyncExternalStore as lt}from"react";async function ae(){let{detectPlatform:e}=await import("../../platform-LKQFC3AJ.js");if(e()==="openai"){let{OpenAIWidgetClient:n}=await import("../../openai-client-PUBKF5TI.js");return new n}else{let{MCPAppsWidgetClient:n}=await import("../../mcp-apps-client-WEXKWHUI.js");return new n}}function de({children:e,loading:t=null,onError:n}){let[d,u]=q(null),[m,h]=q(null),[w,g]=q(!0);return le(()=>{let s=!0,i=null;async function c(){try{let r=await ae();await r.connect(),s?(i=r,u(r),g(!1)):r.close()}catch(r){s&&(console.error("error",r),h(r instanceof Error?r:new Error(String(r))),g(!1))}}return c(),()=>{s=!1,i?.close()}},[]),le(()=>{if(!d)return;let s=i=>{document.documentElement.classList.toggle("dark",i==="dark"),document.documentElement.style.colorScheme=i==="dark"?"dark":"auto"};return s(d.getTheme()),d.onThemeChange(s)},[d]),m&&n?F.createElement(F.Fragment,null,n(m)):w||!d?F.createElement(F.Fragment,null,t):F.createElement(E.Provider,{value:d},e)}function l(e){let t=st(E);if(!t)throw new Error("useWidgetClient must be used within a WidgetProvider");let n=se(m=>e==="toolOutput"?t.onToolResult(()=>m()):e==="theme"?t.onThemeChange(()=>m()):e==="displayMode"?t.onDisplayModeChange(()=>m()):e==="safeArea"?t.onSafeAreaChange(()=>m()):e==="maxHeight"?t.onMaxHeightChange(()=>m()):e==="toolResponseMetadata"?t.onToolResponseMetadataChange(()=>m()):e==="widgetState"?t.onWidgetStateChange(()=>m()):()=>{},[t,e]),d=se(()=>e==="toolOutput"?t.getToolOutput():e==="theme"?t.getTheme():e==="displayMode"?t.getDisplayMode():e==="locale"?t.getLocale():e==="safeArea"?t.getSafeArea():e==="maxHeight"?t.getMaxHeight():e==="toolResponseMetadata"?t.getToolResponseMetadata():e==="widgetState"?t.getWidgetState():null,[t,e]),u=lt(n,d,d);return e?u:t}function ue(){let e=l();return dt((t,n)=>e.callTool(t,n),[e])}function ce(){return l("displayMode")}function _(){return l("toolOutput")}function pe(){return{data:_()}}import{useSyncExternalStore as ut}from"react";function me(){return ut(()=>()=>{},()=>typeof window>"u"?!1:window.__isChatGptApp===!0,()=>!1)}function ge(){return l("locale")}function fe(){return l("maxHeight")}import{useCallback as ct}from"react";function he(){let e=l();return ct(t=>e.openExternal(t),[e])}import{useCallback as pt}from"react";function we(){let e=l();return pt(t=>e.requestDisplayMode(t),[e])}function xe(){return l("safeArea")}import{useCallback as mt}from"react";function ye(){let e=l();return mt((t,n)=>{(async()=>{Y(n?.modelContext)&&await Promise.resolve(e.updateModelContext(n.modelContext)),await Promise.resolve(e.sendFollowUp(t))})().catch(d=>{console.error("Failed to send follow-up message:",d)})},[e])}function be(){return l("theme")}function ve(){return l("toolResponseMetadata")}import{useCallback as gt}from"react";function ke(){let e=l();return gt(async t=>{await Promise.resolve(e.updateModelContext(t))},[e])}import{useCallback as ft,useEffect as ht,useState as wt}from"react";function Ce(e){let t=l("widgetState"),[n,d]=wt(()=>t??(typeof e=="function"?e():e??null));ht(()=>{d(t)},[t]);let u=ft(m=>{d(h=>{let w=typeof m=="function"?m(h):m;return K()==="openai"&&w!=null&&window.openai?.setWidgetState(w),w})},[]);return[n,u]}import{jsx as T,jsxs as Me}from"react/jsx-runtime";var xt=()=>Me("div",{className:"flex flex-col items-center justify-center h-full min-h-[120px] gap-4",children:[Me("div",{className:"flex gap-2",children:[T("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-blue-400 to-cyan-400 animate-bounce [animation-delay:-0.3s]"}),T("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-cyan-400 to-teal-400 animate-bounce [animation-delay:-0.15s]"}),T("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-teal-400 to-emerald-400 animate-bounce"})]}),T("p",{className:"text-sm font-medium text-transparent bg-clip-text bg-gradient-to-r from-slate-400 via-slate-200 to-slate-400 bg-[length:200%_100%] animate-[shimmer_1.5s_ease-in-out_infinite]",children:"Loading widget..."}),T("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:T("div",{className:"w-16 h-16 rounded-full border-2 border-blue-400/20 animate-ping"})}),T("style",{children:`
63
63
  @keyframes shimmer {
64
64
  0% { background-position: 200% 0; }
65
65
  100% { background-position: -200% 0; }