@waniwani/sdk 0.0.8 → 0.0.9
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/mcp/react.js +6 -6
- package/dist/mcp/react.js.map +1 -1
- package/package.json +1 -1
package/dist/mcp/react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{a as $}from"../chunk-SCDEAZN4.js";import{b as T}from"../chunk-OVQDB7QX.js";import{Fragment as
|
|
2
|
+
import{a as $}from"../chunk-SCDEAZN4.js";import{b as T}from"../chunk-OVQDB7QX.js";import{Fragment as Se,jsx as E,jsxs as Te}from"react/jsx-runtime";function Ce({baseUrl:e}){return Te(Se,{children:[E("base",{href:e}),E("script",{children:`window.innerBaseUrl = ${JSON.stringify(e)}`}),E("script",{children:'window.__isChatGptApp = typeof window.openai !== "undefined";'}),E("script",{children:"("+(()=>{let t=window.innerBaseUrl,i=document.documentElement;new MutationObserver(m=>{m.forEach(n=>{if(n.type==="attributes"&&n.target===i){let s=n.attributeName;s&&s!=="suppresshydrationwarning"&&s!=="class"&&s!=="style"&&i.removeAttribute(s)}})}).observe(i,{attributes:!0,attributeOldValue:!0});let u=history.replaceState;history.replaceState=(m,n,s)=>{let r=new URL(s??"",window.location.href),h=r.pathname+r.search+r.hash;u.call(history,n,h)};let p=history.pushState;history.pushState=(m,n,s)=>{let r=new URL(s??"",window.location.href),h=r.pathname+r.search+r.hash;p.call(history,n,h)};let g=new URL(t).origin,f=window.self!==window.top;if(window.addEventListener("click",m=>{let n=m?.target?.closest("a");if(!n||!n.href)return;let s=new URL(n.href,window.location.href);if(s.origin!==window.location.origin&&s.origin!==g)try{window.openai&&(window.openai?.openExternal({href:n.href}),m.preventDefault())}catch{console.warn("openExternal failed, likely not in OpenAI client")}},!0),f&&window.location.origin!==g){let m=window.fetch;window.fetch=(n,s)=>{let r;if(typeof n=="string"||n instanceof URL?r=new URL(n,window.location.href):r=new URL(n.url,window.location.href),r.origin===g)return typeof n=="string"||n instanceof URL?n=r.toString():n=new Request(r.toString(),n),m.call(window,n,{...s,mode:"cors"});if(r.origin===window.location.origin){let h=new URL(t);return h.pathname=r.pathname,h.search=r.search,h.hash=r.hash,r=h,typeof n=="string"||n instanceof URL?n=r.toString():n=new Request(r.toString(),n),m.call(window,n,{...s,mode:"cors"})}return m.call(window,n,s)}}}).toString()+")()"})]})}import{useCallback as w,useEffect as M,useRef as K,useState as b}from"react";var J={theme:"dark",userAgent:{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:"en",maxHeight:800,displayMode:"inline",safeArea:{insets:{top:0,bottom:0,left:0,right:0}},toolInput:{},toolOutput:null,toolResponseMetadata:null,widgetState:null},N={...J};function R(e){typeof window>"u"||window.openai||(N={...J,toolOutput:e??null},window.openai={...N,requestDisplayMode:async({mode:t})=>(v("displayMode",t),{mode:t}),callTool:async(t,i)=>(console.log(`[DevMode] callTool: ${t}`,i),{result:JSON.stringify({mock:!0,tool:t,args:i})}),sendFollowUpMessage:async({prompt:t})=>{console.log(`[DevMode] sendFollowUpMessage: ${t}`)},openExternal:({href:t})=>{console.log(`[DevMode] openExternal: ${t}`),window.open(t,"_blank")},setWidgetState:async t=>{v("widgetState",t)}},window.dispatchEvent(new T({globals:N})))}function v(e,t){typeof window>"u"||!window.openai||(N[e]=t,window.openai[e]=t,window.dispatchEvent(new T({globals:{[e]:t}})))}function L(){return{...N}}function W(e){v("toolOutput",e)}function O(e){v("displayMode",e)}function A(e){v("theme",e)}import{Fragment as B,jsx as o,jsxs as l}from"react/jsx-runtime";var U=150;function q({className:e}){return l("svg",{className:e,viewBox:"0 0 24 24",fill:"none",role:"img","aria-label":"Dev Controls",children:[o("rect",{x:"4",y:"4",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),o("rect",{x:"10",y:"10",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5",fill:"currentColor",fillOpacity:"0.15"})]})}function Ne({className:e}){return o("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o("path",{d:"M18 6L6 18M6 6l12 12"})})}function Re({className:e}){return o("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:o("rect",{x:"2",y:"4",width:"12",height:"8",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"})})}function We({className:e}){return l("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[o("rect",{x:"1.5",y:"3",width:"13",height:"10",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"}),o("rect",{x:"8.5",y:"7",width:"5",height:"4",rx:"0.75",fill:"currentColor"})]})}function Oe({className:e}){return o("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:o("path",{d:"M2 5.5V3.5C2 2.95 2.45 2.5 3 2.5H5.5M10.5 2.5H13C13.55 2.5 14 2.95 14 3.5V5.5M14 10.5V12.5C14 13.05 13.55 13.5 13 13.5H10.5M5.5 13.5H3C2.45 13.5 2 13.05 2 12.5V10.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ae({className:e}){return l("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[o("circle",{cx:"8",cy:"8",r:"2.5",stroke:"currentColor",strokeWidth:"1.25"}),o("path",{d:"M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.11 4.11l1.06 1.06M10.83 10.83l1.06 1.06M4.11 11.89l1.06-1.06M10.83 5.17l1.06-1.06",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})]})}function De({className:e}){return o("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:o("path",{d:"M13.5 9.5a5.5 5.5 0 01-7-7 5.5 5.5 0 107 7z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ie({className:e}){return l("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[o("path",{d:"M2.5 8a5.5 5.5 0 019.37-3.9M13.5 8a5.5 5.5 0 01-9.37 3.9",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"}),o("path",{d:"M12.5 2v3h-3M3.5 14v-3h3",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}var Ee=`
|
|
3
3
|
@keyframes devPanelSlideIn {
|
|
4
4
|
0% {
|
|
5
5
|
opacity: 0;
|
|
@@ -47,22 +47,22 @@ import{a as $}from"../chunk-SCDEAZN4.js";import{b as T}from"../chunk-OVQDB7QX.js
|
|
|
47
47
|
.dev-json-editor::-webkit-scrollbar-thumb:hover {
|
|
48
48
|
background: rgba(255, 255, 255, 0.15);
|
|
49
49
|
}
|
|
50
|
-
`;function Y({defaultProps:e,widgetPaths:t,children:i}){let[
|
|
50
|
+
`;function Y({defaultProps:e,widgetPaths:t,children:i}){let[c,u]=b(!1),[p,g]=b(!1);return M(()=>{if(new URLSearchParams(window.location.search).get("platform")==="mcp-apps"){u(!0);return}if(t&&t.length>0){let m=window.location.pathname,n=t.some(s=>m===s||m.startsWith(`${s}/`));g(n),n&&R(e)}else R(e),g(!0);u(!0)},[e,t]),c?p?l(B,{children:[o(Le,{children:i}),o(Ue,{defaultProps:e})]}):o(B,{children:i}):null}function Le({children:e}){return o("div",{className:"min-h-screen bg-[#212121] flex items-center justify-center p-8",children:o("div",{className:"relative w-full max-w-md overflow-hidden rounded-2xl sm:rounded-3xl border border-[#414141]",style:{boxShadow:"0px 0px 0px 1px #414141, 0px 4px 14px rgba(0,0,0,0.24)"},children:e})})}function V({options:e,value:t,onChange:i}){let c=e.findIndex(u=>u.value===t);return l("div",{className:"relative flex p-0.5 rounded-lg",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:[o("div",{className:"absolute top-0.5 bottom-0.5 rounded-md transition-transform duration-150 ease-out",style:{width:`calc(${100/e.length}% - 2px)`,left:"2px",transform:`translateX(calc(${c*100}% + ${c*2}px))`,background:"rgba(255, 255, 255, 0.1)"}}),e.map(u=>l("button",{type:"button",onClick:()=>i(u.value),className:`
|
|
51
51
|
relative z-10 flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5
|
|
52
52
|
text-xs font-medium rounded-md transition-colors duration-150
|
|
53
53
|
${t===u.value?"text-white":"text-gray-400 hover:text-gray-300"}
|
|
54
|
-
`,children:[u.icon,o("span",{className:"capitalize",children:u.label})]},u.value))]})}function Ue({defaultProps:e}){let[t,i]=b(()=>typeof window>"u"?!1:localStorage.getItem("dev-controls-open")==="true"),[
|
|
54
|
+
`,children:[u.icon,o("span",{className:"capitalize",children:u.label})]},u.value))]})}function Ue({defaultProps:e}){let[t,i]=b(()=>typeof window>"u"?!1:localStorage.getItem("dev-controls-open")==="true"),[c,u]=b(!1),[p,g]=b(t),[f,m]=b("inline"),[n,s]=b("dark"),[r,h]=b(!1),[P,z]=b(()=>JSON.stringify(e??{},null,2)),[C,H]=b(null),S=K(null),he=K(null),j=K(null);M(()=>{let a=L();m(a.displayMode),s(a.theme)},[]),M(()=>{typeof window>"u"||(window.openai||(window.openai={}),window.openai.safeArea={insets:{top:0,bottom:r?U:0,left:0,right:0}},window.dispatchEvent(new T({globals:{safeArea:window.openai.safeArea}})))},[r]),M(()=>{localStorage.setItem("dev-controls-open",String(t))},[t]);let G=w(()=>{g(!0),requestAnimationFrame(()=>{i(!0)})},[]),y=w(()=>{u(!0),i(!1),setTimeout(()=>{g(!1),u(!1)},150)},[]),F=w(()=>{t?y():G()},[t,G,y]);M(()=>{let a=x=>{(x.metaKey||x.ctrlKey)&&x.shiftKey&&x.key==="d"&&(x.preventDefault(),F()),x.key==="Escape"&&t&&y()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,F,y]),M(()=>{if(!t)return;let a=x=>{j.current&&!j.current.contains(x.target)&&y()};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[t,y]);let xe=w(a=>{m(a),O(a)},[]),be=w(a=>{s(a),A(a)},[]),I=w(a=>{try{let x=JSON.parse(a);H(null),W(x)}catch{H("Invalid JSON")}},[]),we=w(a=>{z(a),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{I(a)},500)},[I]),ye=w(()=>{S.current&&clearTimeout(S.current),I(P)},[I,P]),ve=w(()=>{let a=JSON.stringify(e??{},null,2);z(a),H(null),W(e??{}),m("inline"),O("inline"),s("dark"),A("dark")},[e]),ke=[{value:"inline",label:"inline",icon:o(Re,{className:"w-3.5 h-3.5"})},{value:"pip",label:"pip",icon:o(We,{className:"w-3.5 h-3.5"})},{value:"fullscreen",label:"full",icon:o(Oe,{className:"w-3.5 h-3.5"})}],Me=[{value:"light",label:"light",icon:o(Ae,{className:"w-3.5 h-3.5"})},{value:"dark",label:"dark",icon:o(De,{className:"w-3.5 h-3.5"})}];return l(B,{children:[o("style",{dangerouslySetInnerHTML:{__html:Ee}}),l("div",{ref:j,className:"fixed bottom-4 right-4 z-[9999] font-['Inter',_system-ui,_sans-serif]",children:[l("button",{type:"button",onClick:F,className:"group relative flex items-center justify-center w-11 h-11 rounded-xl transition-all duration-200 ease-out hover:scale-105 active:scale-95",style:{background:"rgba(14, 14, 16, 0.95)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",border:"1px solid rgba(255, 255, 255, 0.08)",boxShadow:`
|
|
55
55
|
0 4px 12px rgba(0, 0, 0, 0.4),
|
|
56
56
|
0 0 0 1px rgba(255, 255, 255, 0.05),
|
|
57
57
|
inset 0 1px 0 rgba(255, 255, 255, 0.04)
|
|
58
|
-
`},"aria-label":"Toggle Dev Controls","aria-expanded":t,children:[o(q,{className:`w-5 h-5 transition-all duration-200 ${t?"text-indigo-400 scale-110":"text-gray-300 group-hover:text-white"}`}),o("div",{className:"absolute inset-0 rounded-xl opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none",style:{background:"radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, transparent 70%)"}})]}),
|
|
58
|
+
`},"aria-label":"Toggle Dev Controls","aria-expanded":t,children:[o(q,{className:`w-5 h-5 transition-all duration-200 ${t?"text-indigo-400 scale-110":"text-gray-300 group-hover:text-white"}`}),o("div",{className:"absolute inset-0 rounded-xl opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none",style:{background:"radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, transparent 70%)"}})]}),p&&l("div",{ref:he,className:`absolute bottom-14 right-0 w-80 ${t&&!c?"dev-panel-enter":"dev-panel-exit"}`,style:{maxHeight:"calc(100vh - 120px)",background:"rgba(14, 14, 16, 0.92)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",border:"1px solid rgba(255, 255, 255, 0.06)",borderRadius:"16px",boxShadow:`
|
|
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:[
|
|
62
|
+
`},children:[l("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid rgba(255, 255, 255, 0.06)"},children:[l("div",{className:"flex items-center gap-2",children:[o(q,{className:"w-4 h-4 text-gray-400"}),o("span",{className:"text-sm font-medium text-white",children:"Dev Controls"})]}),l("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:y,className:"p-1 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:o(Ne,{className:"w-4 h-4"})})]})]}),l("div",{className:"p-4 space-y-5 overflow-y-auto",style:{maxHeight:"calc(100vh - 200px)"},children:[l("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(V,{options:ke,value:f,onChange:xe})]}),l("div",{children:[o("label",{htmlFor:"theme",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Theme"}),o(V,{options:Me,value:n,onChange:be})]}),l("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)"}),l("button",{type:"button",onClick:()=>h(!r),className:`w-full flex items-center justify-between px-3 py-2.5 rounded-lg text-xs font-medium transition-all duration-150 ${r?"text-emerald-400":"text-gray-400"}`,style:{background:r?"rgba(34, 197, 94, 0.1)":"rgba(255, 255, 255, 0.04)",border:r?"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 ${r?"bg-emerald-500/20 text-emerald-400":"bg-gray-500/20 text-gray-500"}`,children:r?"ON":"OFF"})]}),r&&l("p",{className:"text-[10px] text-gray-500 mt-1.5",children:["bottom: ",U,"px"]})]}),l("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:P,onChange:a=>we(a.target.value),onBlur:ye,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:C?"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=>{C||(a.target.style.borderColor="rgba(99, 102, 241, 0.5)")},onBlurCapture:a=>{C||(a.target.style.borderColor="rgba(255, 255, 255, 0.06)")},spellCheck:!1}),C&&l("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"})}),C]})]}),l("button",{type:"button",onClick:ve,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(Ie,{className:"w-3.5 h-3.5"}),"Reset to Defaults"]})]})]})]}),r&&l("div",{className:"fixed bottom-0 left-0 right-0 z-[9998] flex items-center justify-center pointer-events-none",style:{height:`${U}px`,background:"linear-gradient(to top, #1a1a1a 0%, #1a1a1a 80%, transparent 100%)"},children:[l("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 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"})})})]}),l("div",{className:"absolute bottom-1 text-[10px] text-gray-600 font-mono",children:["Mock SafeArea: bottom=",U,"px"]})]})]})}import{useCallback as Fe}from"react";import D,{createContext as Pe,useCallback as Q,useContext as He,useEffect as Z,useState as _,useSyncExternalStore as je}from"react";async function X(){let{detectPlatform:e}=await import("../platform-4QZXTYT5.js");if(e()==="openai"){let{OpenAIWidgetClient:i}=await import("../openai-client-UL6T463M.js");return new i}else{let{MCPAppsWidgetClient:i}=await import("../mcp-apps-client-DZ3L5O3U.js");return new i}}var ee=Pe(null);function te({children:e,loading:t=null,onError:i}){let[c,u]=_(null),[p,g]=_(null),[f,m]=_(!0);return Z(()=>{let n=!0;async function s(){try{let r=await X();await r.connect(),n&&(u(r),m(!1))}catch(r){n&&(console.log("error",r),g(r instanceof Error?r:new Error(String(r))),m(!1))}}return s(),()=>{n=!1}},[]),Z(()=>{if(!c)return;let n=s=>{document.documentElement.classList.toggle("dark",s==="dark")};return n(c.getTheme()),c.onThemeChange(n)},[c]),p&&i?D.createElement(D.Fragment,null,i(p)):f||!c?D.createElement(D.Fragment,null,t):D.createElement(ee.Provider,{value:c},e)}function d(e){let t=He(ee);if(!t)throw new Error("useWidgetClient must be used within a WidgetProvider");let i=Q(p=>e==="toolOutput"?t.onToolResult(()=>p()):e==="theme"?t.onThemeChange(()=>p()):e==="displayMode"?t.onDisplayModeChange(()=>p()):e==="safeArea"?t.onSafeAreaChange(()=>p()):e==="maxHeight"?t.onMaxHeightChange(()=>p()):e==="toolResponseMetadata"?t.onToolResponseMetadataChange(()=>p()):e==="widgetState"?t.onWidgetStateChange(()=>p()):()=>{},[t,e]),c=Q(()=>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=je(i,c,c);return e?u:t}function oe(){let e=d();return Fe((t,i)=>e.callTool(t,i),[e])}function ne(){return d("displayMode")}import{useSyncExternalStore as Ke}from"react";function re(){return Ke(()=>()=>{},()=>typeof window>"u"?!1:window.__isChatGptApp===!0,()=>!1)}function ae(){return d("locale")}function ie(){return d("maxHeight")}import{useCallback as Be}from"react";function se(){let e=d();return Be(t=>e.openExternal(t),[e])}import{useCallback as _e}from"react";function le(){let e=d();return _e(t=>e.requestDisplayMode(t),[e])}function de(){return d("safeArea")}import{useCallback as ze}from"react";function ue(){let e=d();return ze(t=>e.sendFollowUp(t),[e])}function ce(){return d("theme")}function pe(){return d("toolOutput")}function me(){return d("toolResponseMetadata")}import{useCallback as Ge,useEffect as $e,useState as Je}from"react";function ge(e){let t=d("widgetState"),[i,c]=Je(()=>t??(typeof e=="function"?e():e??null));$e(()=>{c(t)},[t]);let u=Ge(p=>{c(g=>{let f=typeof p=="function"?p(g):p;return $()==="openai"&&f!=null&&window.openai?.setWidgetState(f),f})},[]);return[i,u]}import{jsx as k,jsxs as fe}from"react/jsx-runtime";var qe=()=>fe("div",{className:"flex flex-col items-center justify-center h-full min-h-[120px] gap-4",children:[fe("div",{className:"flex gap-2",children:[k("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-blue-400 to-cyan-400 animate-bounce [animation-delay:-0.3s]"}),k("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-cyan-400 to-teal-400 animate-bounce [animation-delay:-0.15s]"}),k("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-teal-400 to-emerald-400 animate-bounce"})]}),k("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..."}),k("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:k("div",{className:"w-16 h-16 rounded-full border-2 border-blue-400/20 animate-ping"})}),k("style",{children:`
|
|
63
63
|
@keyframes shimmer {
|
|
64
64
|
0% { background-position: 200% 0; }
|
|
65
65
|
100% { background-position: -200% 0; }
|
|
66
66
|
}
|
|
67
|
-
`})]});export{Y as DevModeProvider,
|
|
67
|
+
`})]});export{Y as DevModeProvider,Ce as InitializeNextJsInChatGpt,qe as LoadingWidget,te as WidgetProvider,L as getMockState,R as initializeMockOpenAI,O as updateMockDisplayMode,v as updateMockGlobal,A as updateMockTheme,W as updateMockToolOutput,oe as useCallTool,ne as useDisplayMode,re as useIsChatGptApp,ae as useLocale,ie as useMaxHeight,se as useOpenExternal,le as useRequestDisplayMode,de as useSafeArea,ue as useSendFollowUp,ce as useTheme,pe as useToolOutput,me as useToolResponseMetadata,d as useWidgetClient,ge as useWidgetState};
|
|
68
68
|
//# sourceMappingURL=react.js.map
|
package/dist/mcp/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mcp/components/initialize-next-in-chat-gpt.tsx","../../src/mcp/dev/dev-controls.tsx","../../src/mcp/dev/mock-openai.ts","../../src/mcp/hooks/use-call-tool.ts","../../src/mcp/hooks/use-widget.ts","../../src/mcp/widgets/@utils/widget-client.ts","../../src/mcp/hooks/use-display-mode.ts","../../src/mcp/hooks/use-is-chatgpt-app.ts","../../src/mcp/hooks/use-locale.ts","../../src/mcp/hooks/use-max-height.ts","../../src/mcp/hooks/use-open-external.ts","../../src/mcp/hooks/use-request-display-mode.ts","../../src/mcp/hooks/use-safe-area.ts","../../src/mcp/hooks/use-send-follow-up.ts","../../src/mcp/hooks/use-theme.ts","../../src/mcp/hooks/use-tool-output.ts","../../src/mcp/hooks/use-tool-response-metadata.ts","../../src/mcp/hooks/use-widget-state.ts","../../src/mcp/widgets/@utils/loading-widget.tsx"],"sourcesContent":["/**\n *\n * Initializes & patches Next.js functionalities\n * so it can be run inside the ChatGPT iframe:\n * - history.pushState / history.replaceState - Prevents full-origin URLs in history\n * - window.fetch - Rewrites same-origin requests to use the correct base URL\n * - html attribute observer - Prevents ChatGPT from modifying the root element\n *\n * More information about this component can be found here:\n *\n * https://vercel.com/blog/running-next-js-inside-chatgpt-a-deep-dive-into-native-app-integration\n */\nexport function InitializeNextJsInChatGpt({ baseUrl }: { baseUrl: string }) {\n\treturn (\n\t\t<>\n\t\t\t<base href={baseUrl}></base>\n\t\t\t<script>{`window.innerBaseUrl = ${JSON.stringify(baseUrl)}`}</script>\n\t\t\t<script>{`window.__isChatGptApp = typeof window.openai !== \"undefined\";`}</script>\n\t\t\t<script>\n\t\t\t\t{\"(\" +\n\t\t\t\t\t(() => {\n\t\t\t\t\t\tconst baseUrl = window.innerBaseUrl;\n\t\t\t\t\t\tconst htmlElement = document.documentElement;\n\t\t\t\t\t\tconst observer = new MutationObserver((mutations) => {\n\t\t\t\t\t\t\tmutations.forEach((mutation) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tmutation.type === \"attributes\" &&\n\t\t\t\t\t\t\t\t\tmutation.target === htmlElement\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tconst attrName = mutation.attributeName;\n\t\t\t\t\t\t\t\t\t// Preserve class/style so consumers can use html.dark { ... } for theming\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tattrName &&\n\t\t\t\t\t\t\t\t\t\tattrName !== \"suppresshydrationwarning\" &&\n\t\t\t\t\t\t\t\t\t\tattrName !== \"class\" &&\n\t\t\t\t\t\t\t\t\t\tattrName !== \"style\"\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\thtmlElement.removeAttribute(attrName);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t\tobserver.observe(htmlElement, {\n\t\t\t\t\t\t\tattributes: true,\n\t\t\t\t\t\t\tattributeOldValue: true,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst originalReplaceState = history.replaceState;\n\t\t\t\t\t\thistory.replaceState = (_s, unused, url) => {\n\t\t\t\t\t\t\tconst u = new URL(url ?? \"\", window.location.href);\n\t\t\t\t\t\t\tconst href = u.pathname + u.search + u.hash;\n\t\t\t\t\t\t\toriginalReplaceState.call(history, unused, href);\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst originalPushState = history.pushState;\n\t\t\t\t\t\thistory.pushState = (_s, unused, url) => {\n\t\t\t\t\t\t\tconst u = new URL(url ?? \"\", window.location.href);\n\t\t\t\t\t\t\tconst href = u.pathname + u.search + u.hash;\n\t\t\t\t\t\t\toriginalPushState.call(history, unused, href);\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst appOrigin = new URL(baseUrl).origin;\n\t\t\t\t\t\tconst isInIframe = window.self !== window.top;\n\n\t\t\t\t\t\twindow.addEventListener(\n\t\t\t\t\t\t\t\"click\",\n\t\t\t\t\t\t\t(e) => {\n\t\t\t\t\t\t\t\tconst a = (e?.target as HTMLElement)?.closest(\"a\");\n\t\t\t\t\t\t\t\tif (!a || !a.href) return;\n\t\t\t\t\t\t\t\tconst url = new URL(a.href, window.location.href);\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\turl.origin !== window.location.origin &&\n\t\t\t\t\t\t\t\t\turl.origin !== appOrigin\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tif (window.openai) {\n\t\t\t\t\t\t\t\t\t\t\twindow.openai?.openExternal({ href: a.href });\n\t\t\t\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t\t\t\t\t\"openExternal failed, likely not in OpenAI client\",\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif (isInIframe && window.location.origin !== appOrigin) {\n\t\t\t\t\t\t\tconst originalFetch = window.fetch;\n\n\t\t\t\t\t\t\twindow.fetch = (\n\t\t\t\t\t\t\t\tinput: URL | RequestInfo,\n\t\t\t\t\t\t\t\tinit?: RequestInit,\n\t\t\t\t\t\t\t): Promise<Response> => {\n\t\t\t\t\t\t\t\tlet url: URL;\n\t\t\t\t\t\t\t\tif (typeof input === \"string\" || input instanceof URL) {\n\t\t\t\t\t\t\t\t\turl = new URL(input, window.location.href);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\turl = new URL(input.url, window.location.href);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (url.origin === appOrigin) {\n\t\t\t\t\t\t\t\t\tif (typeof input === \"string\" || input instanceof URL) {\n\t\t\t\t\t\t\t\t\t\tinput = url.toString();\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tinput = new Request(url.toString(), input);\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\treturn originalFetch.call(window, input, {\n\t\t\t\t\t\t\t\t\t\t...init,\n\t\t\t\t\t\t\t\t\t\tmode: \"cors\",\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (url.origin === window.location.origin) {\n\t\t\t\t\t\t\t\t\tconst newUrl = new URL(baseUrl);\n\t\t\t\t\t\t\t\t\tnewUrl.pathname = url.pathname;\n\t\t\t\t\t\t\t\t\tnewUrl.search = url.search;\n\t\t\t\t\t\t\t\t\tnewUrl.hash = url.hash;\n\t\t\t\t\t\t\t\t\turl = newUrl;\n\n\t\t\t\t\t\t\t\t\tif (typeof input === \"string\" || input instanceof URL) {\n\t\t\t\t\t\t\t\t\t\tinput = url.toString();\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tinput = new Request(url.toString(), input);\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\treturn originalFetch.call(window, input, {\n\t\t\t\t\t\t\t\t\t\t...init,\n\t\t\t\t\t\t\t\t\t\tmode: \"cors\",\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn originalFetch.call(window, input, init);\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}).toString() +\n\t\t\t\t\t\")()\"}\n\t\t\t</script>\n\t\t</>\n\t);\n}\n","\"use client\";\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { DisplayMode, Theme } from \"../hooks/@types\";\nimport { SetGlobalsEvent } from \"../hooks/@types\";\nimport {\n\tgetMockState,\n\tinitializeMockOpenAI,\n\tupdateMockDisplayMode,\n\tupdateMockTheme,\n\tupdateMockToolOutput,\n} from \"./mock-openai\";\n\nconst MOCK_SAFE_AREA_HEIGHT = 150;\n\n// ============================================================================\n// SVG Icons\n// ============================================================================\n\nfunction DevIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 24 24\"\n\t\t\tfill=\"none\"\n\t\t\trole=\"img\"\n\t\t\taria-label=\"Dev Controls\"\n\t\t>\n\t\t\t{/* Minimal: two stacked squares offset */}\n\t\t\t<rect\n\t\t\t\tx=\"4\"\n\t\t\t\ty=\"4\"\n\t\t\t\twidth=\"10\"\n\t\t\t\theight=\"10\"\n\t\t\t\trx=\"2\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.5\"\n\t\t\t/>\n\t\t\t<rect\n\t\t\t\tx=\"10\"\n\t\t\t\ty=\"10\"\n\t\t\t\twidth=\"10\"\n\t\t\t\theight=\"10\"\n\t\t\t\trx=\"2\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.5\"\n\t\t\t\tfill=\"currentColor\"\n\t\t\t\tfillOpacity=\"0.15\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\nfunction CloseIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 24 24\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeWidth=\"2\"\n\t\t\tstrokeLinecap=\"round\"\n\t\t\tstrokeLinejoin=\"round\"\n\t\t>\n\t\t\t<path d=\"M18 6L6 18M6 6l12 12\" />\n\t\t</svg>\n\t);\n}\n\nfunction InlineIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<rect\n\t\t\t\tx=\"2\"\n\t\t\t\ty=\"4\"\n\t\t\t\twidth=\"12\"\n\t\t\t\theight=\"8\"\n\t\t\t\trx=\"1.5\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\nfunction PipIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<rect\n\t\t\t\tx=\"1.5\"\n\t\t\t\ty=\"3\"\n\t\t\t\twidth=\"13\"\n\t\t\t\theight=\"10\"\n\t\t\t\trx=\"1.5\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t/>\n\t\t\t<rect x=\"8.5\" y=\"7\" width=\"5\" height=\"4\" rx=\"0.75\" fill=\"currentColor\" />\n\t\t</svg>\n\t);\n}\n\nfunction FullscreenIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<path\n\t\t\t\td=\"M2 5.5V3.5C2 2.95 2.45 2.5 3 2.5H5.5M10.5 2.5H13C13.55 2.5 14 2.95 14 3.5V5.5M14 10.5V12.5C14 13.05 13.55 13.5 13 13.5H10.5M5.5 13.5H3C2.45 13.5 2 13.05 2 12.5V10.5\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\nfunction SunIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<circle cx=\"8\" cy=\"8\" r=\"2.5\" stroke=\"currentColor\" strokeWidth=\"1.25\" />\n\t\t\t<path\n\t\t\t\td=\"M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.11 4.11l1.06 1.06M10.83 10.83l1.06 1.06M4.11 11.89l1.06-1.06M10.83 5.17l1.06-1.06\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\nfunction MoonIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<path\n\t\t\t\td=\"M13.5 9.5a5.5 5.5 0 01-7-7 5.5 5.5 0 107 7z\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\nfunction ResetIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<path\n\t\t\t\td=\"M2.5 8a5.5 5.5 0 019.37-3.9M13.5 8a5.5 5.5 0 01-9.37 3.9\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\td=\"M12.5 2v3h-3M3.5 14v-3h3\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\n// ============================================================================\n// Styles\n// ============================================================================\n\nconst panelAnimationStyles = `\n @keyframes devPanelSlideIn {\n 0% {\n opacity: 0;\n transform: translateY(12px) scale(0.98);\n }\n 100% {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n }\n\n @keyframes devPanelSlideOut {\n 0% {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n 100% {\n opacity: 0;\n transform: translateY(8px) scale(0.98);\n }\n }\n\n .dev-panel-enter {\n animation: devPanelSlideIn 200ms cubic-bezier(0.16, 1, 0.3, 1) forwards;\n }\n\n .dev-panel-exit {\n animation: devPanelSlideOut 150ms cubic-bezier(0.4, 0, 1, 1) forwards;\n }\n\n .dev-json-editor::-webkit-scrollbar {\n width: 6px;\n height: 6px;\n }\n\n .dev-json-editor::-webkit-scrollbar-track {\n background: transparent;\n }\n\n .dev-json-editor::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.1);\n border-radius: 3px;\n }\n\n .dev-json-editor::-webkit-scrollbar-thumb:hover {\n background: rgba(255, 255, 255, 0.15);\n }\n`;\n\n// ============================================================================\n// Components\n// ============================================================================\n\ninterface DevControlsProps {\n\tdefaultProps?: Record<string, unknown>;\n\twidgetPaths?: string[];\n}\n\nexport function DevModeProvider({\n\tdefaultProps,\n\twidgetPaths,\n\tchildren,\n}: DevControlsProps & { children: React.ReactNode }) {\n\tconst [isInitialized, setIsInitialized] = useState(false);\n\tconst [isWidgetPage, setIsWidgetPage] = useState(false);\n\n\tuseEffect(() => {\n\t\t// When loaded inside the MCP harness iframe, skip the OpenAI mock\n\t\t// so the real MCPAppsWidgetClient + App class is used instead.\n\t\tconst params = new URLSearchParams(window.location.search);\n\t\tif (params.get(\"platform\") === \"mcp-apps\") {\n\t\t\tsetIsInitialized(true);\n\t\t\treturn;\n\t\t}\n\n\t\t// Check if current path is a widget page\n\t\tif (widgetPaths && widgetPaths.length > 0) {\n\t\t\tconst currentPath = window.location.pathname;\n\t\t\tconst isWidget = widgetPaths.some(\n\t\t\t\t(path) => currentPath === path || currentPath.startsWith(`${path}/`),\n\t\t\t);\n\t\t\tsetIsWidgetPage(isWidget);\n\n\t\t\tif (isWidget) {\n\t\t\t\tinitializeMockOpenAI(defaultProps);\n\t\t\t}\n\t\t} else {\n\t\t\t// If no widgetPaths specified, treat all pages as widget pages (backwards compat)\n\t\t\tinitializeMockOpenAI(defaultProps);\n\t\t\tsetIsWidgetPage(true);\n\t\t}\n\t\tsetIsInitialized(true);\n\t}, [defaultProps, widgetPaths]);\n\n\tif (!isInitialized) {\n\t\treturn null;\n\t}\n\n\t// If not a widget page, just render children without the dev frame\n\tif (!isWidgetPage) {\n\t\treturn <>{children}</>;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<WidgetPreviewFrame>{children}</WidgetPreviewFrame>\n\t\t\t<DevControls defaultProps={defaultProps} />\n\t\t</>\n\t);\n}\n\nfunction WidgetPreviewFrame({ children }: { children: React.ReactNode }) {\n\treturn (\n\t\t<div className=\"min-h-screen bg-[#212121] flex items-center justify-center p-8\">\n\t\t\t<div\n\t\t\t\tclassName=\"relative w-full max-w-md overflow-hidden rounded-2xl sm:rounded-3xl border border-[#414141]\"\n\t\t\t\tstyle={{\n\t\t\t\t\tboxShadow: \"0px 0px 0px 1px #414141, 0px 4px 14px rgba(0,0,0,0.24)\",\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n// ============================================================================\n// Segmented Control\n// ============================================================================\n\ninterface SegmentOption<T extends string> {\n\tvalue: T;\n\tlabel: string;\n\ticon: React.ReactNode;\n}\n\ninterface SegmentedControlProps<T extends string> {\n\toptions: SegmentOption<T>[];\n\tvalue: T;\n\tonChange: (value: T) => void;\n}\n\nfunction SegmentedControl<T extends string>({\n\toptions,\n\tvalue,\n\tonChange,\n}: SegmentedControlProps<T>) {\n\tconst activeIndex = options.findIndex((opt) => opt.value === value);\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"relative flex p-0.5 rounded-lg\"\n\t\t\tstyle={{\n\t\t\t\tbackground: \"rgba(255, 255, 255, 0.04)\",\n\t\t\t\tborder: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t}}\n\t\t>\n\t\t\t{/* Sliding indicator */}\n\t\t\t<div\n\t\t\t\tclassName=\"absolute top-0.5 bottom-0.5 rounded-md transition-transform duration-150 ease-out\"\n\t\t\t\tstyle={{\n\t\t\t\t\twidth: `calc(${100 / options.length}% - 2px)`,\n\t\t\t\t\tleft: \"2px\",\n\t\t\t\t\ttransform: `translateX(calc(${activeIndex * 100}% + ${activeIndex * 2}px))`,\n\t\t\t\t\tbackground: \"rgba(255, 255, 255, 0.1)\",\n\t\t\t\t}}\n\t\t\t/>\n\n\t\t\t{options.map((option) => (\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tkey={option.value}\n\t\t\t\t\tonClick={() => onChange(option.value)}\n\t\t\t\t\tclassName={`\n relative z-10 flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5\n text-xs font-medium rounded-md transition-colors duration-150\n ${value === option.value ? \"text-white\" : \"text-gray-400 hover:text-gray-300\"}\n `}\n\t\t\t\t>\n\t\t\t\t\t{option.icon}\n\t\t\t\t\t<span className=\"capitalize\">{option.label}</span>\n\t\t\t\t</button>\n\t\t\t))}\n\t\t</div>\n\t);\n}\n\n// ============================================================================\n// Main DevControls Component\n// ============================================================================\n\nfunction DevControls({ defaultProps }: DevControlsProps) {\n\tconst [isOpen, setIsOpen] = useState(() => {\n\t\tif (typeof window === \"undefined\") return false;\n\t\treturn localStorage.getItem(\"dev-controls-open\") === \"true\";\n\t});\n\tconst [isAnimating, setIsAnimating] = useState(false);\n\tconst [shouldRender, setShouldRender] = useState(isOpen);\n\tconst [displayMode, setDisplayMode] = useState<DisplayMode>(\"inline\");\n\tconst [theme, setTheme] = useState<Theme>(\"dark\");\n\tconst [showSafeArea, setShowSafeArea] = useState(false);\n\tconst [propsJson, setPropsJson] = useState(() =>\n\t\tJSON.stringify(defaultProps ?? {}, null, 2),\n\t);\n\tconst [jsonError, setJsonError] = useState<string | null>(null);\n\tconst debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tconst panelRef = useRef<HTMLDivElement>(null);\n\tconst containerRef = useRef<HTMLDivElement>(null);\n\n\t// Initialize from mock state\n\tuseEffect(() => {\n\t\tconst state = getMockState();\n\t\tsetDisplayMode(state.displayMode);\n\t\tsetTheme(state.theme);\n\t}, []);\n\n\t// Update safeArea when toggled\n\tuseEffect(() => {\n\t\tif (typeof window === \"undefined\") return;\n\t\tif (!window.openai) {\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: window.openai may not exist yet\n\t\t\t(window as any).openai = {};\n\t\t}\n\t\twindow.openai.safeArea = {\n\t\t\tinsets: {\n\t\t\t\ttop: 0,\n\t\t\t\tbottom: showSafeArea ? MOCK_SAFE_AREA_HEIGHT : 0,\n\t\t\t\tleft: 0,\n\t\t\t\tright: 0,\n\t\t\t},\n\t\t};\n\t\twindow.dispatchEvent(\n\t\t\tnew SetGlobalsEvent({ globals: { safeArea: window.openai.safeArea } }),\n\t\t);\n\t}, [showSafeArea]);\n\n\t// Persist open state\n\tuseEffect(() => {\n\t\tlocalStorage.setItem(\"dev-controls-open\", String(isOpen));\n\t}, [isOpen]);\n\n\tconst openPanel = useCallback(() => {\n\t\tsetShouldRender(true);\n\t\t// Small delay to ensure DOM is ready for animation\n\t\trequestAnimationFrame(() => {\n\t\t\tsetIsOpen(true);\n\t\t});\n\t}, []);\n\n\tconst closePanel = useCallback(() => {\n\t\tsetIsAnimating(true);\n\t\tsetIsOpen(false);\n\t\t// Wait for exit animation\n\t\tsetTimeout(() => {\n\t\t\tsetShouldRender(false);\n\t\t\tsetIsAnimating(false);\n\t\t}, 150);\n\t}, []);\n\n\tconst togglePanel = useCallback(() => {\n\t\tif (isOpen) {\n\t\t\tclosePanel();\n\t\t} else {\n\t\t\topenPanel();\n\t\t}\n\t}, [isOpen, openPanel, closePanel]);\n\n\t// Keyboard shortcuts\n\tuseEffect(() => {\n\t\tconst handleKeyDown = (e: KeyboardEvent) => {\n\t\t\t// Cmd/Ctrl + Shift + D to toggle\n\t\t\tif ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key === \"d\") {\n\t\t\t\te.preventDefault();\n\t\t\t\ttogglePanel();\n\t\t\t}\n\t\t\t// Escape to close\n\t\t\tif (e.key === \"Escape\" && isOpen) {\n\t\t\t\tclosePanel();\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener(\"keydown\", handleKeyDown);\n\t\treturn () => window.removeEventListener(\"keydown\", handleKeyDown);\n\t}, [isOpen, togglePanel, closePanel]);\n\n\t// Click outside to close\n\tuseEffect(() => {\n\t\tif (!isOpen) return;\n\n\t\tconst handleClickOutside = (e: MouseEvent) => {\n\t\t\tif (\n\t\t\t\tcontainerRef.current &&\n\t\t\t\t!containerRef.current.contains(e.target as Node)\n\t\t\t) {\n\t\t\t\tclosePanel();\n\t\t\t}\n\t\t};\n\n\t\tdocument.addEventListener(\"mousedown\", handleClickOutside);\n\t\treturn () => document.removeEventListener(\"mousedown\", handleClickOutside);\n\t}, [isOpen, closePanel]);\n\n\tconst handleDisplayModeChange = useCallback((mode: DisplayMode) => {\n\t\tsetDisplayMode(mode);\n\t\tupdateMockDisplayMode(mode);\n\t}, []);\n\n\tconst handleThemeChange = useCallback((newTheme: Theme) => {\n\t\tsetTheme(newTheme);\n\t\tupdateMockTheme(newTheme);\n\t}, []);\n\n\tconst applyProps = useCallback((json: string) => {\n\t\ttry {\n\t\t\tconst parsed = JSON.parse(json);\n\t\t\tsetJsonError(null);\n\t\t\tupdateMockToolOutput(parsed);\n\t\t} catch {\n\t\t\tsetJsonError(\"Invalid JSON\");\n\t\t}\n\t}, []);\n\n\tconst handlePropsChange = useCallback(\n\t\t(json: string) => {\n\t\t\tsetPropsJson(json);\n\t\t\tif (debounceRef.current) {\n\t\t\t\tclearTimeout(debounceRef.current);\n\t\t\t}\n\t\t\tdebounceRef.current = setTimeout(() => {\n\t\t\t\tapplyProps(json);\n\t\t\t}, 500);\n\t\t},\n\t\t[applyProps],\n\t);\n\n\tconst handlePropsBlur = useCallback(() => {\n\t\tif (debounceRef.current) {\n\t\t\tclearTimeout(debounceRef.current);\n\t\t}\n\t\tapplyProps(propsJson);\n\t}, [applyProps, propsJson]);\n\n\tconst handleReset = useCallback(() => {\n\t\tconst defaultJson = JSON.stringify(defaultProps ?? {}, null, 2);\n\t\tsetPropsJson(defaultJson);\n\t\tsetJsonError(null);\n\t\tupdateMockToolOutput(defaultProps ?? {});\n\t\tsetDisplayMode(\"inline\");\n\t\tupdateMockDisplayMode(\"inline\");\n\t\tsetTheme(\"dark\");\n\t\tupdateMockTheme(\"dark\");\n\t}, [defaultProps]);\n\n\tconst displayModeOptions: SegmentOption<DisplayMode>[] = [\n\t\t{\n\t\t\tvalue: \"inline\",\n\t\t\tlabel: \"inline\",\n\t\t\ticon: <InlineIcon className=\"w-3.5 h-3.5\" />,\n\t\t},\n\t\t{ value: \"pip\", label: \"pip\", icon: <PipIcon className=\"w-3.5 h-3.5\" /> },\n\t\t{\n\t\t\tvalue: \"fullscreen\",\n\t\t\tlabel: \"full\",\n\t\t\ticon: <FullscreenIcon className=\"w-3.5 h-3.5\" />,\n\t\t},\n\t];\n\n\tconst themeOptions: SegmentOption<Theme>[] = [\n\t\t{\n\t\t\tvalue: \"light\",\n\t\t\tlabel: \"light\",\n\t\t\ticon: <SunIcon className=\"w-3.5 h-3.5\" />,\n\t\t},\n\t\t{\n\t\t\tvalue: \"dark\",\n\t\t\tlabel: \"dark\",\n\t\t\ticon: <MoonIcon className=\"w-3.5 h-3.5\" />,\n\t\t},\n\t];\n\n\treturn (\n\t\t<>\n\t\t\t{/* Inject animation styles */}\n\t\t\t{/** biome-ignore lint/security/noDangerouslySetInnerHtml: we need to inject styles into the DOM */}\n\t\t\t<style dangerouslySetInnerHTML={{ __html: panelAnimationStyles }} />\n\n\t\t\t<div\n\t\t\t\tref={containerRef}\n\t\t\t\tclassName=\"fixed bottom-4 right-4 z-[9999] font-['Inter',_system-ui,_sans-serif]\"\n\t\t\t>\n\t\t\t\t{/* Toggle Button */}\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonClick={togglePanel}\n\t\t\t\t\tclassName=\"group relative flex items-center justify-center w-11 h-11 rounded-xl transition-all duration-200 ease-out hover:scale-105 active:scale-95\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tbackground: \"rgba(14, 14, 16, 0.95)\",\n\t\t\t\t\t\tbackdropFilter: \"blur(16px)\",\n\t\t\t\t\t\tWebkitBackdropFilter: \"blur(16px)\",\n\t\t\t\t\t\tborder: \"1px solid rgba(255, 255, 255, 0.08)\",\n\t\t\t\t\t\tboxShadow: `\n 0 4px 12px rgba(0, 0, 0, 0.4),\n 0 0 0 1px rgba(255, 255, 255, 0.05),\n inset 0 1px 0 rgba(255, 255, 255, 0.04)\n `,\n\t\t\t\t\t}}\n\t\t\t\t\taria-label=\"Toggle Dev Controls\"\n\t\t\t\t\taria-expanded={isOpen}\n\t\t\t\t>\n\t\t\t\t\t<DevIcon\n\t\t\t\t\t\tclassName={`w-5 h-5 transition-all duration-200 ${\n\t\t\t\t\t\t\tisOpen\n\t\t\t\t\t\t\t\t? \"text-indigo-400 scale-110\"\n\t\t\t\t\t\t\t\t: \"text-gray-300 group-hover:text-white\"\n\t\t\t\t\t\t}`}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{/* Subtle glow on hover */}\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"absolute inset-0 rounded-xl opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none\"\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tbackground:\n\t\t\t\t\t\t\t\t\"radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, transparent 70%)\",\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</button>\n\n\t\t\t\t{/* Panel */}\n\t\t\t\t{shouldRender && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tref={panelRef}\n\t\t\t\t\t\tclassName={`absolute bottom-14 right-0 w-80 ${\n\t\t\t\t\t\t\tisOpen && !isAnimating ? \"dev-panel-enter\" : \"dev-panel-exit\"\n\t\t\t\t\t\t}`}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tmaxHeight: \"calc(100vh - 120px)\",\n\t\t\t\t\t\t\tbackground: \"rgba(14, 14, 16, 0.92)\",\n\t\t\t\t\t\t\tbackdropFilter: \"blur(24px)\",\n\t\t\t\t\t\t\tWebkitBackdropFilter: \"blur(24px)\",\n\t\t\t\t\t\t\tborder: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t\t\t\t\tborderRadius: \"16px\",\n\t\t\t\t\t\t\tboxShadow: `\n 0 25px 50px -12px rgba(0, 0, 0, 0.6),\n 0 0 0 1px rgba(255, 255, 255, 0.05),\n inset 0 1px 0 rgba(255, 255, 255, 0.04)\n `,\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{/* Header */}\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"flex items-center justify-between px-4 py-3\"\n\t\t\t\t\t\t\tstyle={{ borderBottom: \"1px solid rgba(255, 255, 255, 0.06)\" }}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"flex items-center gap-2\">\n\t\t\t\t\t\t\t\t<DevIcon className=\"w-4 h-4 text-gray-400\" />\n\t\t\t\t\t\t\t\t<span className=\"text-sm font-medium text-white\">\n\t\t\t\t\t\t\t\t\tDev Controls\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t<div className=\"flex items-center gap-2\">\n\t\t\t\t\t\t\t\t{/* Keyboard shortcut badge */}\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\tclassName=\"text-[10px] font-medium text-gray-500 px-1.5 py-0.5 rounded\"\n\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\tbackground: \"rgba(255, 255, 255, 0.04)\",\n\t\t\t\t\t\t\t\t\t\tborder: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{typeof navigator !== \"undefined\" &&\n\t\t\t\t\t\t\t\t\tnavigator.platform?.includes(\"Mac\")\n\t\t\t\t\t\t\t\t\t\t? \"⌘⇧D\"\n\t\t\t\t\t\t\t\t\t\t: \"Ctrl+Shift+D\"}\n\t\t\t\t\t\t\t\t</span>\n\n\t\t\t\t\t\t\t\t{/* Close button */}\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tonClick={closePanel}\n\t\t\t\t\t\t\t\t\tclassName=\"p-1 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<CloseIcon className=\"w-4 h-4\" />\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t{/* Content */}\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"p-4 space-y-5 overflow-y-auto\"\n\t\t\t\t\t\t\tstyle={{ maxHeight: \"calc(100vh - 200px)\" }}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{/* Display Mode */}\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\thtmlFor=\"display-mode\"\n\t\t\t\t\t\t\t\t\tclassName=\"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tDisplay Mode\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t<SegmentedControl\n\t\t\t\t\t\t\t\t\toptions={displayModeOptions}\n\t\t\t\t\t\t\t\t\tvalue={displayMode}\n\t\t\t\t\t\t\t\t\tonChange={handleDisplayModeChange}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t{/* Theme */}\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\thtmlFor=\"theme\"\n\t\t\t\t\t\t\t\t\tclassName=\"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tTheme\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t<SegmentedControl\n\t\t\t\t\t\t\t\t\toptions={themeOptions}\n\t\t\t\t\t\t\t\t\tvalue={theme}\n\t\t\t\t\t\t\t\t\tonChange={handleThemeChange}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t{/* Safe Area Mock */}\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\thtmlFor=\"safe-area\"\n\t\t\t\t\t\t\t\t\tclassName=\"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tSafe Area (Chat Input)\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tonClick={() => setShowSafeArea(!showSafeArea)}\n\t\t\t\t\t\t\t\t\tclassName={`w-full flex items-center justify-between px-3 py-2.5 rounded-lg text-xs font-medium transition-all duration-150 ${\n\t\t\t\t\t\t\t\t\t\tshowSafeArea ? \"text-emerald-400\" : \"text-gray-400\"\n\t\t\t\t\t\t\t\t\t}`}\n\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\tbackground: showSafeArea\n\t\t\t\t\t\t\t\t\t\t\t? \"rgba(34, 197, 94, 0.1)\"\n\t\t\t\t\t\t\t\t\t\t\t: \"rgba(255, 255, 255, 0.04)\",\n\t\t\t\t\t\t\t\t\t\tborder: showSafeArea\n\t\t\t\t\t\t\t\t\t\t\t? \"1px solid rgba(34, 197, 94, 0.3)\"\n\t\t\t\t\t\t\t\t\t\t\t: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span>Mock ChatGPT Input Bar</span>\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tclassName={`px-2 py-0.5 rounded text-[10px] font-semibold ${\n\t\t\t\t\t\t\t\t\t\t\tshowSafeArea\n\t\t\t\t\t\t\t\t\t\t\t\t? \"bg-emerald-500/20 text-emerald-400\"\n\t\t\t\t\t\t\t\t\t\t\t\t: \"bg-gray-500/20 text-gray-500\"\n\t\t\t\t\t\t\t\t\t\t}`}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{showSafeArea ? \"ON\" : \"OFF\"}\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t{showSafeArea && (\n\t\t\t\t\t\t\t\t\t<p className=\"text-[10px] text-gray-500 mt-1.5\">\n\t\t\t\t\t\t\t\t\t\tbottom: {MOCK_SAFE_AREA_HEIGHT}px\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t{/* Widget Props */}\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\thtmlFor=\"widget-props\"\n\t\t\t\t\t\t\t\t\tclassName=\"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tWidget Props\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t<textarea\n\t\t\t\t\t\t\t\t\tvalue={propsJson}\n\t\t\t\t\t\t\t\t\tonChange={(e) => handlePropsChange(e.target.value)}\n\t\t\t\t\t\t\t\t\tonBlur={handlePropsBlur}\n\t\t\t\t\t\t\t\t\tclassName=\"dev-json-editor w-full min-h-[160px] text-xs text-gray-200 p-3 rounded-lg resize-none focus:outline-none transition-colors\"\n\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\tbackground: \"rgba(0, 0, 0, 0.3)\",\n\t\t\t\t\t\t\t\t\t\tborder: jsonError\n\t\t\t\t\t\t\t\t\t\t\t? \"1px solid rgba(239, 68, 68, 0.5)\"\n\t\t\t\t\t\t\t\t\t\t\t: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t\t\t\t\t\t\t\tfontFamily:\n\t\t\t\t\t\t\t\t\t\t\t\"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace\",\n\t\t\t\t\t\t\t\t\t\tlineHeight: 1.6,\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tonFocus={(e) => {\n\t\t\t\t\t\t\t\t\t\tif (!jsonError) {\n\t\t\t\t\t\t\t\t\t\t\te.target.style.borderColor = \"rgba(99, 102, 241, 0.5)\";\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tonBlurCapture={(e) => {\n\t\t\t\t\t\t\t\t\t\tif (!jsonError) {\n\t\t\t\t\t\t\t\t\t\t\te.target.style.borderColor = \"rgba(255, 255, 255, 0.06)\";\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tspellCheck={false}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{jsonError && (\n\t\t\t\t\t\t\t\t\t<p className=\"text-red-400 text-[11px] mt-1.5 flex items-center gap-1\">\n\t\t\t\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\t\t\taria-label=\"Error\"\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"w-3 h-3\"\n\t\t\t\t\t\t\t\t\t\t\tviewBox=\"0 0 16 16\"\n\t\t\t\t\t\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<path d=\"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z\" />\n\t\t\t\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t\t\t\t\t{jsonError}\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t{/* Reset Button */}\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tonClick={handleReset}\n\t\t\t\t\t\t\t\tclassName=\"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\"\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tbackground: \"rgba(255, 255, 255, 0.04)\",\n\t\t\t\t\t\t\t\t\tborder: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tonMouseEnter={(e) => {\n\t\t\t\t\t\t\t\t\te.currentTarget.style.background =\n\t\t\t\t\t\t\t\t\t\t\"rgba(255, 255, 255, 0.08)\";\n\t\t\t\t\t\t\t\t\te.currentTarget.style.borderColor =\n\t\t\t\t\t\t\t\t\t\t\"rgba(255, 255, 255, 0.1)\";\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tonMouseLeave={(e) => {\n\t\t\t\t\t\t\t\t\te.currentTarget.style.background =\n\t\t\t\t\t\t\t\t\t\t\"rgba(255, 255, 255, 0.04)\";\n\t\t\t\t\t\t\t\t\te.currentTarget.style.borderColor =\n\t\t\t\t\t\t\t\t\t\t\"rgba(255, 255, 255, 0.06)\";\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ResetIcon className=\"w-3.5 h-3.5\" />\n\t\t\t\t\t\t\t\tReset to Defaults\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\n\t\t\t{/* Mock ChatGPT Input Bar */}\n\t\t\t{showSafeArea && (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"fixed bottom-0 left-0 right-0 z-[9998] flex items-center justify-center pointer-events-none\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\theight: `${MOCK_SAFE_AREA_HEIGHT}px`,\n\t\t\t\t\t\tbackground:\n\t\t\t\t\t\t\t\"linear-gradient(to top, #1a1a1a 0%, #1a1a1a 80%, transparent 100%)\",\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<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\">\n\t\t\t\t\t\t<div className=\"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center\">\n\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\tclassName=\"w-4 h-4 text-gray-400\"\n\t\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<path\n\t\t\t\t\t\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\t\t\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t\t\t\t\t\t\tstrokeWidth={2}\n\t\t\t\t\t\t\t\t\td=\"M12 4v16m8-8H4\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"flex-1 text-gray-400 text-sm\">Ask anything...</div>\n\t\t\t\t\t\t<div className=\"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center\">\n\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\tclassName=\"w-4 h-4 text-gray-400\"\n\t\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<path\n\t\t\t\t\t\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\t\t\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t\t\t\t\t\t\tstrokeWidth={2}\n\t\t\t\t\t\t\t\t\td=\"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\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"absolute bottom-1 text-[10px] text-gray-600 font-mono\">\n\t\t\t\t\t\tMock SafeArea: bottom={MOCK_SAFE_AREA_HEIGHT}px\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</>\n\t);\n}\n","import {\n\ttype DisplayMode,\n\ttype OpenAIGlobals,\n\tSetGlobalsEvent,\n\ttype Theme,\n} from \"../hooks/@types\";\n\nconst DEFAULT_MOCK_CONFIG: Omit<OpenAIGlobals, \"setWidgetState\"> = {\n\ttheme: \"dark\",\n\tuserAgent: {\n\t\tdevice: { type: \"desktop\" },\n\t\tcapabilities: { hover: true, touch: false },\n\t},\n\tlocale: \"en\",\n\tmaxHeight: 800,\n\tdisplayMode: \"inline\",\n\tsafeArea: { insets: { top: 0, bottom: 0, left: 0, right: 0 } },\n\ttoolInput: {},\n\ttoolOutput: null,\n\ttoolResponseMetadata: null,\n\twidgetState: null,\n};\n\nlet mockState: Omit<OpenAIGlobals, \"setWidgetState\"> = {\n\t...DEFAULT_MOCK_CONFIG,\n};\n\nexport function initializeMockOpenAI(\n\tinitialToolOutput?: Record<string, unknown>,\n): void {\n\tif (typeof window === \"undefined\") return;\n\tif (window.openai) return; // Already initialized (real ChatGPT or previous mock)\n\n\tmockState = {\n\t\t...DEFAULT_MOCK_CONFIG,\n\t\ttoolOutput: initialToolOutput ?? null,\n\t};\n\n\twindow.openai = {\n\t\t...mockState,\n\t\t// Mock API functions\n\t\trequestDisplayMode: async ({ mode }) => {\n\t\t\tupdateMockGlobal(\"displayMode\", mode);\n\t\t\treturn { mode };\n\t\t},\n\t\tcallTool: async (name, args) => {\n\t\t\tconsole.log(`[DevMode] callTool: ${name}`, args);\n\t\t\treturn { result: JSON.stringify({ mock: true, tool: name, args }) };\n\t\t},\n\t\tsendFollowUpMessage: async ({ prompt }) => {\n\t\t\tconsole.log(`[DevMode] sendFollowUpMessage: ${prompt}`);\n\t\t},\n\t\topenExternal: ({ href }) => {\n\t\t\tconsole.log(`[DevMode] openExternal: ${href}`);\n\t\t\twindow.open(href, \"_blank\");\n\t\t},\n\t\tsetWidgetState: async (state) => {\n\t\t\tupdateMockGlobal(\"widgetState\", state);\n\t\t},\n\t};\n\n\t// Dispatch initial event so hooks pick up the values\n\twindow.dispatchEvent(new SetGlobalsEvent({ globals: mockState }));\n}\n\nexport function updateMockGlobal<K extends keyof OpenAIGlobals>(\n\tkey: K,\n\tvalue: OpenAIGlobals[K],\n): void {\n\tif (typeof window === \"undefined\" || !window.openai) return;\n\n\t(mockState as Record<string, unknown>)[key] = value;\n\t(window.openai as Record<string, unknown>)[key] = value;\n\n\twindow.dispatchEvent(new SetGlobalsEvent({ globals: { [key]: value } }));\n}\n\nexport function getMockState(): typeof mockState {\n\treturn { ...mockState };\n}\n\nexport function updateMockToolOutput(props: Record<string, unknown>): void {\n\tupdateMockGlobal(\"toolOutput\", props);\n}\n\nexport function updateMockDisplayMode(mode: DisplayMode): void {\n\tupdateMockGlobal(\"displayMode\", mode);\n}\n\nexport function updateMockTheme(theme: Theme): void {\n\tupdateMockGlobal(\"theme\", theme);\n}\n","\"use client\";\n\nimport { useCallback } from \"react\";\nimport type { ToolCallResult } from \"../widgets/@utils/widget-client\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get a function to call other tools.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @returns A function to call tools with their name and arguments\n */\nexport function useCallTool(): (\n\tname: string,\n\targs: Record<string, unknown>,\n) => Promise<ToolCallResult> {\n\tconst client = useWidgetClient();\n\treturn useCallback(\n\t\t(name: string, args: Record<string, unknown>) =>\n\t\t\tclient.callTool(name, args),\n\t\t[client],\n\t);\n}\n","\"use client\";\n\nimport React, {\n\tcreateContext,\n\ttype ReactNode,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseState,\n\tuseSyncExternalStore,\n} from \"react\";\nimport {\n\tcreateWidgetClient,\n\ttype UnifiedWidgetClient,\n} from \"../widgets/@utils/widget-client\";\nimport type { DisplayMode, SafeArea, Theme, UnknownObject } from \"./@types\";\n\n/**\n * Context for the unified widget client.\n */\nconst WidgetClientContext = createContext<UnifiedWidgetClient | null>(null);\n\n/**\n * Provider props\n */\ninterface WidgetProviderProps {\n\tchildren: ReactNode;\n\t/** Optional loading component while connecting */\n\tloading?: ReactNode;\n\t/** Optional error component */\n\tonError?: (error: Error) => ReactNode;\n}\n\n/**\n * Provider component that initializes the correct widget client based on platform.\n * Wrap your widget component with this provider.\n *\n * @example\n * ```tsx\n * function App() {\n * return (\n * <WidgetProvider loading={<Spinner />}>\n * <MyWidget />\n * </WidgetProvider>\n * );\n * }\n * ```\n */\nexport function WidgetProvider({\n\tchildren,\n\tloading = null,\n\tonError,\n}: WidgetProviderProps) {\n\tconst [client, setClient] = useState<UnifiedWidgetClient | null>(null);\n\tconst [error, setError] = useState<Error | null>(null);\n\tconst [isConnecting, setIsConnecting] = useState(true);\n\n\tuseEffect(() => {\n\t\tlet mounted = true;\n\n\t\tasync function initClient() {\n\t\t\ttry {\n\t\t\t\tconst widgetClient = await createWidgetClient();\n\n\t\t\t\tawait widgetClient.connect();\n\n\t\t\t\tif (mounted) {\n\t\t\t\t\tsetClient(widgetClient);\n\t\t\t\t\tsetIsConnecting(false);\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tif (mounted) {\n\t\t\t\t\tconsole.log(\"error\", err);\n\t\t\t\t\tsetError(err instanceof Error ? err : new Error(String(err)));\n\t\t\t\t\tsetIsConnecting(false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tinitClient();\n\n\t\treturn () => {\n\t\t\tmounted = false;\n\t\t};\n\t}, []);\n\n\tif (error && onError) {\n\t\treturn React.createElement(React.Fragment, null, onError(error));\n\t}\n\n\tif (isConnecting || !client) {\n\t\treturn React.createElement(React.Fragment, null, loading);\n\t}\n\n\treturn React.createElement(\n\t\tWidgetClientContext.Provider,\n\t\t{ value: client },\n\t\tchildren,\n\t);\n}\n\n/**\n * Keys that can be selected from the widget client.\n */\ntype WidgetKey =\n\t| \"toolOutput\"\n\t| \"theme\"\n\t| \"displayMode\"\n\t| \"locale\"\n\t| \"safeArea\"\n\t| \"maxHeight\"\n\t| \"toolResponseMetadata\"\n\t| \"widgetState\";\n\n/**\n * Value types for each widget key.\n */\ntype WidgetKeyValues = {\n\ttoolOutput: Record<string, unknown> | null;\n\ttheme: Theme;\n\tdisplayMode: DisplayMode;\n\tlocale: string;\n\tsafeArea: SafeArea | null;\n\tmaxHeight: number | null;\n\ttoolResponseMetadata: UnknownObject | null;\n\twidgetState: UnknownObject | null;\n};\n\n/**\n * Get the unified widget client instance.\n * Must be used within a WidgetProvider.\n *\n * @example\n * ```tsx\n * // Full client for actions\n * const client = useWidgetClient();\n * client.callTool(\"foo\", {});\n *\n * // Key selector for reactive values\n * const toolOutput = useWidgetClient(\"toolOutput\");\n * const theme = useWidgetClient(\"theme\");\n * ```\n */\nexport function useWidgetClient(): UnifiedWidgetClient;\nexport function useWidgetClient<K extends WidgetKey>(\n\tkey: K,\n): WidgetKeyValues[K];\nexport function useWidgetClient<K extends WidgetKey>(key?: K) {\n\tconst client = useContext(WidgetClientContext);\n\n\tif (!client) {\n\t\tthrow new Error(\"useWidgetClient must be used within a WidgetProvider\");\n\t}\n\n\t// Key selector - use useSyncExternalStore\n\tconst subscribe = useCallback(\n\t\t(onChange: () => void) => {\n\t\t\tif (key === \"toolOutput\") return client.onToolResult(() => onChange());\n\t\t\tif (key === \"theme\") return client.onThemeChange(() => onChange());\n\t\t\tif (key === \"displayMode\")\n\t\t\t\treturn client.onDisplayModeChange(() => onChange());\n\t\t\tif (key === \"safeArea\") return client.onSafeAreaChange(() => onChange());\n\t\t\tif (key === \"maxHeight\")\n\t\t\t\treturn client.onMaxHeightChange(() => onChange());\n\t\t\tif (key === \"toolResponseMetadata\")\n\t\t\t\treturn client.onToolResponseMetadataChange(() => onChange());\n\t\t\tif (key === \"widgetState\")\n\t\t\t\treturn client.onWidgetStateChange(() => onChange());\n\t\t\treturn () => {};\n\t\t},\n\t\t[client, key],\n\t);\n\n\tconst getSnapshot = useCallback(() => {\n\t\tif (key === \"toolOutput\") return client.getToolOutput();\n\t\tif (key === \"theme\") return client.getTheme();\n\t\tif (key === \"displayMode\") return client.getDisplayMode();\n\t\tif (key === \"locale\") return client.getLocale();\n\t\tif (key === \"safeArea\") return client.getSafeArea();\n\t\tif (key === \"maxHeight\") return client.getMaxHeight();\n\t\tif (key === \"toolResponseMetadata\") return client.getToolResponseMetadata();\n\t\tif (key === \"widgetState\") return client.getWidgetState();\n\t\treturn null;\n\t}, [client, key]);\n\n\tconst store = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n\t// No key - return full client\n\tif (!key) return client;\n\n\treturn store;\n}\n","import type {\n\tDisplayMode,\n\tSafeArea,\n\tTheme,\n\tUnknownObject,\n} from \"../../hooks/@types\";\n\n/**\n * Result from calling a tool\n */\nexport type ToolCallResult = {\n\tcontent?: Array<{ type: string; text?: string }>;\n\tstructuredContent?: Record<string, unknown>;\n};\n\n/**\n * Tool result notification (what the host pushes to the widget)\n */\nexport type ToolResult = {\n\tcontent?: Array<{ type: string; text?: string }>;\n\tstructuredContent?: Record<string, unknown>;\n};\n\n/**\n * Host context - all values available from the host.\n */\nexport type HostContext = {\n\ttheme: Theme;\n\tlocale: string;\n\tdisplayMode: DisplayMode;\n\tmaxHeight: number | null;\n\tsafeArea: SafeArea | null;\n\ttoolOutput: UnknownObject | null;\n\ttoolResponseMetadata: UnknownObject | null;\n\twidgetState: UnknownObject | null;\n};\n\n/**\n * Store interface for useSyncExternalStore compatibility.\n */\nexport type HostContextStore<K extends keyof HostContext> = {\n\tsubscribe: (onStoreChange: () => void) => () => void;\n\tgetSnapshot: () => HostContext[K];\n};\n\n/**\n * Unified widget client interface that works on both OpenAI and MCP Apps.\n *\n * Platform-specific behavior:\n * - Display mode: OpenAI-only. MCP Apps returns \"inline\" and requestDisplayMode is a no-op.\n * - Follow-up messages: Unified API, different underlying implementations.\n */\nexport interface UnifiedWidgetClient {\n\t/**\n\t * Connect to the host. Must be called before using other methods.\n\t * On OpenAI, this is a no-op (already connected via window.openai).\n\t * On MCP Apps, this establishes the postMessage connection.\n\t */\n\tconnect(): Promise<void>;\n\n\t/**\n\t * Get the tool output (structured content returned by the tool handler).\n\t * This is the main data source for widget rendering.\n\t */\n\tgetToolOutput<T = Record<string, unknown>>(): T | null;\n\n\t/**\n\t * Register a callback for when tool results are received.\n\t * On OpenAI, this subscribes to toolOutput changes.\n\t * On MCP Apps, this sets app.ontoolresult.\n\t */\n\tonToolResult(callback: (result: ToolResult) => void): () => void;\n\n\t/**\n\t * Call another tool on the server.\n\t */\n\tcallTool(\n\t\tname: string,\n\t\targs: Record<string, unknown>,\n\t): Promise<ToolCallResult>;\n\n\t/**\n\t * Open an external URL.\n\t * On OpenAI: openai.openExternal({ href })\n\t * On MCP Apps: app.sendOpenLink(url)\n\t */\n\topenExternal(url: string): void;\n\n\t/**\n\t * Send a follow-up message to the AI.\n\t * On OpenAI: openai.sendFollowUpMessage({ prompt })\n\t * On MCP Apps: app.sendMessages([{ role: 'user', content: { type: 'text', text: prompt } }])\n\t */\n\tsendFollowUp(prompt: string): void;\n\n\t/**\n\t * Get the current theme.\n\t */\n\tgetTheme(): Theme;\n\n\t/**\n\t * Subscribe to theme changes.\n\t */\n\tonThemeChange(callback: (theme: Theme) => void): () => void;\n\n\t/**\n\t * Get the current locale.\n\t */\n\tgetLocale(): string;\n\n\t/**\n\t * Get the current display mode.\n\t * OpenAI-only: returns \"pip\" | \"inline\" | \"fullscreen\"\n\t * MCP Apps: always returns \"inline\"\n\t */\n\tgetDisplayMode(): DisplayMode;\n\n\t/**\n\t * Request a display mode change.\n\t * OpenAI-only: requests the mode from the host.\n\t * MCP Apps: no-op (returns current mode).\n\t */\n\trequestDisplayMode(mode: DisplayMode): Promise<DisplayMode>;\n\n\t/**\n\t * Subscribe to display mode changes.\n\t * OpenAI-only: subscribes to displayMode changes.\n\t * MCP Apps: callback is never called.\n\t */\n\tonDisplayModeChange(callback: (mode: DisplayMode) => void): () => void;\n\n\t/**\n\t * Get the safe area insets.\n\t * OpenAI-only: returns insets from window.openai.safeArea.\n\t * MCP Apps: returns null.\n\t */\n\tgetSafeArea(): SafeArea | null;\n\n\t/**\n\t * Subscribe to safe area changes.\n\t * OpenAI-only: subscribes to safeArea changes.\n\t * MCP Apps: callback is never called.\n\t */\n\tonSafeAreaChange(callback: (safeArea: SafeArea | null) => void): () => void;\n\n\t/**\n\t * Get the max height constraint.\n\t * OpenAI-only: returns maxHeight from window.openai.maxHeight.\n\t * MCP Apps: returns null.\n\t */\n\tgetMaxHeight(): number | null;\n\n\t/**\n\t * Subscribe to max height changes.\n\t * OpenAI-only: subscribes to maxHeight changes.\n\t * MCP Apps: callback is never called.\n\t */\n\tonMaxHeightChange(callback: (maxHeight: number | null) => void): () => void;\n\n\t/**\n\t * Get the tool response metadata.\n\t * OpenAI-only: returns metadata from window.openai.toolResponseMetadata.\n\t * MCP Apps: returns null.\n\t */\n\tgetToolResponseMetadata(): UnknownObject | null;\n\n\t/**\n\t * Subscribe to tool response metadata changes.\n\t * OpenAI-only: subscribes to toolResponseMetadata changes.\n\t * MCP Apps: callback is never called.\n\t */\n\tonToolResponseMetadataChange(\n\t\tcallback: (metadata: UnknownObject | null) => void,\n\t): () => void;\n\n\t/**\n\t * Get the widget state.\n\t * OpenAI-only: returns state from window.openai.widgetState.\n\t * MCP Apps: returns null.\n\t */\n\tgetWidgetState(): UnknownObject | null;\n\n\t/**\n\t * Subscribe to widget state changes.\n\t * OpenAI-only: subscribes to widgetState changes.\n\t * MCP Apps: callback is never called.\n\t */\n\tonWidgetStateChange(\n\t\tcallback: (state: UnknownObject | null) => void,\n\t): () => void;\n}\n\n/**\n * Creates a unified widget client for the current platform.\n */\nexport async function createWidgetClient(): Promise<UnifiedWidgetClient> {\n\tconst { detectPlatform } = await import(\"./platform\");\n\tconst platform = detectPlatform();\n\n\tif (platform === \"openai\") {\n\t\tconst { OpenAIWidgetClient } = await import(\"./openai-client\");\n\t\treturn new OpenAIWidgetClient();\n\t} else {\n\t\tconst { MCPAppsWidgetClient } = await import(\"./mcp-apps-client\");\n\t\treturn new MCPAppsWidgetClient();\n\t}\n}\n","\"use client\";\n\nimport type { DisplayMode } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get the current display mode.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @returns The current display mode (\"pip\" | \"inline\" | \"fullscreen\")\n */\nexport function useDisplayMode(): DisplayMode {\n\treturn useWidgetClient(\"displayMode\");\n}\n","\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\n\n/**\n * Check if running in ChatGPT app (OpenAI-only).\n * Returns false on MCP Apps.\n *\n * @returns Whether the widget is running in ChatGPT app\n */\nexport function useIsChatGptApp(): boolean {\n\treturn useSyncExternalStore(\n\t\t() => () => {},\n\t\t() => {\n\t\t\tif (typeof window === \"undefined\") return false;\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: __isChatGptApp is injected by ChatGPT\n\t\t\treturn (window as any).__isChatGptApp === true;\n\t\t},\n\t\t() => false,\n\t);\n}\n","\"use client\";\n\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get the current locale.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @returns The current locale string (e.g., \"en-US\")\n */\nexport function useLocale(): string {\n\treturn useWidgetClient(\"locale\");\n}\n","\"use client\";\n\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get the maximum height available for the widget (OpenAI-only).\n * Useful for responsive layouts that need to adapt to container constraints.\n * Returns null on MCP Apps.\n *\n * @returns The maximum height in pixels, or null if not available\n */\nexport function useMaxHeight(): number | null {\n\treturn useWidgetClient(\"maxHeight\");\n}\n","\"use client\";\n\nimport { useCallback } from \"react\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get a function to open external URLs.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @returns A function that opens external URLs\n */\nexport function useOpenExternal(): (url: string) => void {\n\tconst client = useWidgetClient();\n\treturn useCallback((url: string) => client.openExternal(url), [client]);\n}\n","\"use client\";\n\nimport { useCallback } from \"react\";\nimport type { DisplayMode } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get a function to request display mode changes.\n * On MCP Apps, this may be a no-op depending on host support.\n *\n * @returns A function to request a specific display mode\n */\nexport function useRequestDisplayMode(): (\n\tmode: DisplayMode,\n) => Promise<DisplayMode> {\n\tconst client = useWidgetClient();\n\treturn useCallback(\n\t\t(mode: DisplayMode) => client.requestDisplayMode(mode),\n\t\t[client],\n\t);\n}\n","\"use client\";\n\nimport type { SafeArea } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get safe area insets (OpenAI-only).\n * Useful for ensuring UI elements don't get hidden behind the chat input.\n * Returns null on MCP Apps.\n *\n * @returns The safe area insets, or null if not available\n */\nexport function useSafeArea(): SafeArea | null {\n\treturn useWidgetClient(\"safeArea\");\n}\n","\"use client\";\n\nimport { useCallback } from \"react\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get a function to send follow-up messages to the AI.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @returns A function that sends a follow-up message\n */\nexport function useSendFollowUp(): (prompt: string) => void {\n\tconst client = useWidgetClient();\n\treturn useCallback((prompt: string) => client.sendFollowUp(prompt), [client]);\n}\n","\"use client\";\n\nimport type { Theme } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get the current theme.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @returns The current theme (\"light\" | \"dark\")\n */\nexport function useTheme(): Theme {\n\treturn useWidgetClient(\"theme\");\n}\n","\"use client\";\n\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get the tool output (structured content returned by the tool handler).\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @returns The tool output or null\n */\nexport function useToolOutput<T extends Record<string, unknown>>(): T | null {\n\treturn useWidgetClient(\"toolOutput\") as T | null;\n}\n","\"use client\";\n\nimport type { UnknownObject } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get tool response metadata (OpenAI-only).\n * Contains identifiers like `openai/widgetSessionId` for correlating\n * multiple tool calls or logs for the same widget instance.\n * Returns null on MCP Apps.\n *\n * @returns The tool response metadata object or null if not available\n */\nexport function useToolResponseMetadata(): UnknownObject | null {\n\treturn useWidgetClient(\"toolResponseMetadata\");\n}\n","\"use client\";\n\nimport { type SetStateAction, useCallback, useEffect, useState } from \"react\";\nimport { detectPlatform } from \"../widgets/@utils/platform\";\nimport type { UnknownObject } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Widget state that persists across widget lifecycles (OpenAI-only).\n * State is synchronized with the ChatGPT parent window and survives widget minimize/restore.\n * On MCP Apps, returns [null, no-op].\n *\n * @param defaultState - Initial state value or function to compute it\n * @returns A tuple of [state, setState] similar to useState\n */\nexport function useWidgetState<T extends UnknownObject>(\n\tdefaultState?: T | (() => T | null) | null,\n): readonly [T | null, (state: SetStateAction<T | null>) => void] {\n\tconst widgetStateFromWindow = useWidgetClient(\"widgetState\") as T | null;\n\n\tconst [widgetState, _setWidgetState] = useState<T | null>(() => {\n\t\tif (widgetStateFromWindow != null) {\n\t\t\treturn widgetStateFromWindow;\n\t\t}\n\t\treturn typeof defaultState === \"function\"\n\t\t\t? defaultState()\n\t\t\t: (defaultState ?? null);\n\t});\n\n\tuseEffect(() => {\n\t\t_setWidgetState(widgetStateFromWindow);\n\t}, [widgetStateFromWindow]);\n\n\tconst setWidgetState = useCallback((state: SetStateAction<T | null>) => {\n\t\t_setWidgetState((prevState) => {\n\t\t\tconst newState = typeof state === \"function\" ? state(prevState) : state;\n\n\t\t\tif (detectPlatform() === \"openai\" && newState != null) {\n\t\t\t\twindow.openai?.setWidgetState(newState);\n\t\t\t}\n\n\t\t\treturn newState;\n\t\t});\n\t}, []);\n\n\treturn [widgetState, setWidgetState] as const;\n}\n","export const LoadingWidget = () => {\n\treturn (\n\t\t<div className=\"flex flex-col items-center justify-center h-full min-h-[120px] gap-4\">\n\t\t\t{/* Animated dots */}\n\t\t\t<div className=\"flex gap-2\">\n\t\t\t\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]\" />\n\t\t\t\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]\" />\n\t\t\t\t<div className=\"w-3 h-3 rounded-full bg-gradient-to-r from-teal-400 to-emerald-400 animate-bounce\" />\n\t\t\t</div>\n\n\t\t\t{/* Shimmer text */}\n\t\t\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]\">\n\t\t\t\tLoading widget...\n\t\t\t</p>\n\n\t\t\t{/* Pulsing ring */}\n\t\t\t<div className=\"absolute inset-0 flex items-center justify-center pointer-events-none\">\n\t\t\t\t<div className=\"w-16 h-16 rounded-full border-2 border-blue-400/20 animate-ping\" />\n\t\t\t</div>\n\n\t\t\t<style>{`\n @keyframes shimmer {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0;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G,CAACH,CAAM,CAAC,CAC7E,CCHO,SAASI,IAAkB,CACjC,OAAOC,EAAgB,OAAO,CAC/B,CCHO,SAASC,IAA6D,CAC5E,OAAOC,EAAgB,YAAY,CACpC,CCCO,SAASC,IAAgD,CAC/D,OAAOC,EAAgB,sBAAsB,CAC9C,CCbA,OAA8B,eAAAC,GAAa,aAAAC,GAAW,YAAAC,OAAgB,QAa/D,SAASC,GACfC,EACiE,CACjE,IAAMC,EAAwBC,EAAgB,aAAa,EAErD,CAACC,EAAaC,CAAe,EAAIC,GAAmB,IACrDJ,IAGG,OAAOD,GAAiB,WAC5BA,EAAa,EACZA,GAAgB,KACpB,EAEDM,GAAU,IAAM,CACfF,EAAgBH,CAAqB,CACtC,EAAG,CAACA,CAAqB,CAAC,EAE1B,IAAMM,EAAiBC,GAAaC,GAAoC,CACvEL,EAAiBM,GAAc,CAC9B,IAAMC,EAAW,OAAOF,GAAU,WAAaA,EAAMC,CAAS,EAAID,EAElE,OAAIG,EAAe,IAAM,UAAYD,GAAY,MAChD,OAAO,QAAQ,eAAeA,CAAQ,EAGhCA,CACR,CAAC,CACF,EAAG,CAAC,CAAC,EAEL,MAAO,CAACR,EAAaI,CAAc,CACpC,CC1CG,OACC,OAAAM,EADD,QAAAC,OAAA,oBAJI,IAAMC,GAAgB,IAE3BD,GAAC,OAAI,UAAU,uEAEd,UAAAA,GAAC,OAAI,UAAU,aACd,UAAAD,EAAC,OAAI,UAAU,yGAAyG,EACxHA,EAAC,OAAI,UAAU,0GAA0G,EACzHA,EAAC,OAAI,UAAU,oFAAoF,GACpG,EAGAA,EAAC,KAAE,UAAU,iLAAiL,6BAE9L,EAGAA,EAAC,OAAI,UAAU,wEACd,SAAAA,EAAC,OAAI,UAAU,kEAAkE,EAClF,EAEAA,EAAC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA,QAKH,GACN","names":["Fragment","jsx","jsxs","InitializeNextJsInChatGpt","baseUrl","htmlElement","mutations","mutation","attrName","originalReplaceState","_s","unused","url","u","href","originalPushState","appOrigin","isInIframe","e","a","originalFetch","input","init","newUrl","useCallback","useEffect","useRef","useState","DEFAULT_MOCK_CONFIG","mockState","initializeMockOpenAI","initialToolOutput","mode","updateMockGlobal","name","args","prompt","href","state","SetGlobalsEvent","key","value","getMockState","updateMockToolOutput","props","updateMockDisplayMode","updateMockTheme","theme","Fragment","jsx","jsxs","MOCK_SAFE_AREA_HEIGHT","DevIcon","className","CloseIcon","InlineIcon","PipIcon","FullscreenIcon","SunIcon","MoonIcon","ResetIcon","panelAnimationStyles","DevModeProvider","defaultProps","widgetPaths","children","isInitialized","setIsInitialized","useState","isWidgetPage","setIsWidgetPage","useEffect","currentPath","isWidget","path","initializeMockOpenAI","WidgetPreviewFrame","DevControls","SegmentedControl","options","value","onChange","activeIndex","opt","option","isOpen","setIsOpen","isAnimating","setIsAnimating","shouldRender","setShouldRender","displayMode","setDisplayMode","theme","setTheme","showSafeArea","setShowSafeArea","propsJson","setPropsJson","jsonError","setJsonError","debounceRef","useRef","panelRef","containerRef","state","getMockState","SetGlobalsEvent","openPanel","useCallback","closePanel","togglePanel","handleKeyDown","e","handleClickOutside","handleDisplayModeChange","mode","updateMockDisplayMode","handleThemeChange","newTheme","updateMockTheme","applyProps","json","parsed","updateMockToolOutput","handlePropsChange","handlePropsBlur","handleReset","defaultJson","displayModeOptions","themeOptions","useCallback","React","createContext","useCallback","useContext","useEffect","useState","useSyncExternalStore","createWidgetClient","detectPlatform","OpenAIWidgetClient","MCPAppsWidgetClient","WidgetClientContext","createContext","WidgetProvider","children","loading","onError","client","setClient","useState","error","setError","isConnecting","setIsConnecting","useEffect","mounted","initClient","widgetClient","createWidgetClient","err","React","useWidgetClient","key","useContext","subscribe","useCallback","onChange","getSnapshot","store","useSyncExternalStore","useCallTool","client","useWidgetClient","useCallback","name","args","useDisplayMode","useWidgetClient","useSyncExternalStore","useIsChatGptApp","useLocale","useWidgetClient","useMaxHeight","useWidgetClient","useCallback","useOpenExternal","client","useWidgetClient","useCallback","url","useCallback","useRequestDisplayMode","client","useWidgetClient","useCallback","mode","useSafeArea","useWidgetClient","useCallback","useSendFollowUp","client","useWidgetClient","useCallback","prompt","useTheme","useWidgetClient","useToolOutput","useWidgetClient","useToolResponseMetadata","useWidgetClient","useCallback","useEffect","useState","useWidgetState","defaultState","widgetStateFromWindow","useWidgetClient","widgetState","_setWidgetState","useState","useEffect","setWidgetState","useCallback","state","prevState","newState","detectPlatform","jsx","jsxs","LoadingWidget"]}
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/components/initialize-next-in-chat-gpt.tsx","../../src/mcp/dev/dev-controls.tsx","../../src/mcp/dev/mock-openai.ts","../../src/mcp/hooks/use-call-tool.ts","../../src/mcp/hooks/use-widget.ts","../../src/mcp/widgets/@utils/widget-client.ts","../../src/mcp/hooks/use-display-mode.ts","../../src/mcp/hooks/use-is-chatgpt-app.ts","../../src/mcp/hooks/use-locale.ts","../../src/mcp/hooks/use-max-height.ts","../../src/mcp/hooks/use-open-external.ts","../../src/mcp/hooks/use-request-display-mode.ts","../../src/mcp/hooks/use-safe-area.ts","../../src/mcp/hooks/use-send-follow-up.ts","../../src/mcp/hooks/use-theme.ts","../../src/mcp/hooks/use-tool-output.ts","../../src/mcp/hooks/use-tool-response-metadata.ts","../../src/mcp/hooks/use-widget-state.ts","../../src/mcp/widgets/@utils/loading-widget.tsx"],"sourcesContent":["/**\n *\n * Initializes & patches Next.js functionalities\n * so it can be run inside the ChatGPT iframe:\n * - history.pushState / history.replaceState - Prevents full-origin URLs in history\n * - window.fetch - Rewrites same-origin requests to use the correct base URL\n * - html attribute observer - Prevents ChatGPT from modifying the root element\n *\n * More information about this component can be found here:\n *\n * https://vercel.com/blog/running-next-js-inside-chatgpt-a-deep-dive-into-native-app-integration\n */\nexport function InitializeNextJsInChatGpt({ baseUrl }: { baseUrl: string }) {\n\treturn (\n\t\t<>\n\t\t\t<base href={baseUrl}></base>\n\t\t\t<script>{`window.innerBaseUrl = ${JSON.stringify(baseUrl)}`}</script>\n\t\t\t<script>{`window.__isChatGptApp = typeof window.openai !== \"undefined\";`}</script>\n\t\t\t<script>\n\t\t\t\t{\"(\" +\n\t\t\t\t\t(() => {\n\t\t\t\t\t\tconst baseUrl = window.innerBaseUrl;\n\t\t\t\t\t\tconst htmlElement = document.documentElement;\n\t\t\t\t\t\tconst observer = new MutationObserver((mutations) => {\n\t\t\t\t\t\t\tmutations.forEach((mutation) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tmutation.type === \"attributes\" &&\n\t\t\t\t\t\t\t\t\tmutation.target === htmlElement\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tconst attrName = mutation.attributeName;\n\t\t\t\t\t\t\t\t\t// Preserve class/style so consumers can use html.dark { ... } for theming\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tattrName &&\n\t\t\t\t\t\t\t\t\t\tattrName !== \"suppresshydrationwarning\" &&\n\t\t\t\t\t\t\t\t\t\tattrName !== \"class\" &&\n\t\t\t\t\t\t\t\t\t\tattrName !== \"style\"\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\thtmlElement.removeAttribute(attrName);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t\tobserver.observe(htmlElement, {\n\t\t\t\t\t\t\tattributes: true,\n\t\t\t\t\t\t\tattributeOldValue: true,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst originalReplaceState = history.replaceState;\n\t\t\t\t\t\thistory.replaceState = (_s, unused, url) => {\n\t\t\t\t\t\t\tconst u = new URL(url ?? \"\", window.location.href);\n\t\t\t\t\t\t\tconst href = u.pathname + u.search + u.hash;\n\t\t\t\t\t\t\toriginalReplaceState.call(history, unused, href);\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst originalPushState = history.pushState;\n\t\t\t\t\t\thistory.pushState = (_s, unused, url) => {\n\t\t\t\t\t\t\tconst u = new URL(url ?? \"\", window.location.href);\n\t\t\t\t\t\t\tconst href = u.pathname + u.search + u.hash;\n\t\t\t\t\t\t\toriginalPushState.call(history, unused, href);\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst appOrigin = new URL(baseUrl).origin;\n\t\t\t\t\t\tconst isInIframe = window.self !== window.top;\n\n\t\t\t\t\t\twindow.addEventListener(\n\t\t\t\t\t\t\t\"click\",\n\t\t\t\t\t\t\t(e) => {\n\t\t\t\t\t\t\t\tconst a = (e?.target as HTMLElement)?.closest(\"a\");\n\t\t\t\t\t\t\t\tif (!a || !a.href) return;\n\t\t\t\t\t\t\t\tconst url = new URL(a.href, window.location.href);\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\turl.origin !== window.location.origin &&\n\t\t\t\t\t\t\t\t\turl.origin !== appOrigin\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tif (window.openai) {\n\t\t\t\t\t\t\t\t\t\t\twindow.openai?.openExternal({ href: a.href });\n\t\t\t\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t\t\t\t\t\"openExternal failed, likely not in OpenAI client\",\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif (isInIframe && window.location.origin !== appOrigin) {\n\t\t\t\t\t\t\tconst originalFetch = window.fetch;\n\n\t\t\t\t\t\t\twindow.fetch = (\n\t\t\t\t\t\t\t\tinput: URL | RequestInfo,\n\t\t\t\t\t\t\t\tinit?: RequestInit,\n\t\t\t\t\t\t\t): Promise<Response> => {\n\t\t\t\t\t\t\t\tlet url: URL;\n\t\t\t\t\t\t\t\tif (typeof input === \"string\" || input instanceof URL) {\n\t\t\t\t\t\t\t\t\turl = new URL(input, window.location.href);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\turl = new URL(input.url, window.location.href);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (url.origin === appOrigin) {\n\t\t\t\t\t\t\t\t\tif (typeof input === \"string\" || input instanceof URL) {\n\t\t\t\t\t\t\t\t\t\tinput = url.toString();\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tinput = new Request(url.toString(), input);\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\treturn originalFetch.call(window, input, {\n\t\t\t\t\t\t\t\t\t\t...init,\n\t\t\t\t\t\t\t\t\t\tmode: \"cors\",\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (url.origin === window.location.origin) {\n\t\t\t\t\t\t\t\t\tconst newUrl = new URL(baseUrl);\n\t\t\t\t\t\t\t\t\tnewUrl.pathname = url.pathname;\n\t\t\t\t\t\t\t\t\tnewUrl.search = url.search;\n\t\t\t\t\t\t\t\t\tnewUrl.hash = url.hash;\n\t\t\t\t\t\t\t\t\turl = newUrl;\n\n\t\t\t\t\t\t\t\t\tif (typeof input === \"string\" || input instanceof URL) {\n\t\t\t\t\t\t\t\t\t\tinput = url.toString();\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tinput = new Request(url.toString(), input);\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\treturn originalFetch.call(window, input, {\n\t\t\t\t\t\t\t\t\t\t...init,\n\t\t\t\t\t\t\t\t\t\tmode: \"cors\",\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn originalFetch.call(window, input, init);\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}).toString() +\n\t\t\t\t\t\")()\"}\n\t\t\t</script>\n\t\t</>\n\t);\n}\n","\"use client\";\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { DisplayMode, Theme } from \"../hooks/@types\";\nimport { SetGlobalsEvent } from \"../hooks/@types\";\nimport {\n\tgetMockState,\n\tinitializeMockOpenAI,\n\tupdateMockDisplayMode,\n\tupdateMockTheme,\n\tupdateMockToolOutput,\n} from \"./mock-openai\";\n\nconst MOCK_SAFE_AREA_HEIGHT = 150;\n\n// ============================================================================\n// SVG Icons\n// ============================================================================\n\nfunction DevIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 24 24\"\n\t\t\tfill=\"none\"\n\t\t\trole=\"img\"\n\t\t\taria-label=\"Dev Controls\"\n\t\t>\n\t\t\t{/* Minimal: two stacked squares offset */}\n\t\t\t<rect\n\t\t\t\tx=\"4\"\n\t\t\t\ty=\"4\"\n\t\t\t\twidth=\"10\"\n\t\t\t\theight=\"10\"\n\t\t\t\trx=\"2\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.5\"\n\t\t\t/>\n\t\t\t<rect\n\t\t\t\tx=\"10\"\n\t\t\t\ty=\"10\"\n\t\t\t\twidth=\"10\"\n\t\t\t\theight=\"10\"\n\t\t\t\trx=\"2\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.5\"\n\t\t\t\tfill=\"currentColor\"\n\t\t\t\tfillOpacity=\"0.15\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\nfunction CloseIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 24 24\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeWidth=\"2\"\n\t\t\tstrokeLinecap=\"round\"\n\t\t\tstrokeLinejoin=\"round\"\n\t\t>\n\t\t\t<path d=\"M18 6L6 18M6 6l12 12\" />\n\t\t</svg>\n\t);\n}\n\nfunction InlineIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<rect\n\t\t\t\tx=\"2\"\n\t\t\t\ty=\"4\"\n\t\t\t\twidth=\"12\"\n\t\t\t\theight=\"8\"\n\t\t\t\trx=\"1.5\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\nfunction PipIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<rect\n\t\t\t\tx=\"1.5\"\n\t\t\t\ty=\"3\"\n\t\t\t\twidth=\"13\"\n\t\t\t\theight=\"10\"\n\t\t\t\trx=\"1.5\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t/>\n\t\t\t<rect x=\"8.5\" y=\"7\" width=\"5\" height=\"4\" rx=\"0.75\" fill=\"currentColor\" />\n\t\t</svg>\n\t);\n}\n\nfunction FullscreenIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<path\n\t\t\t\td=\"M2 5.5V3.5C2 2.95 2.45 2.5 3 2.5H5.5M10.5 2.5H13C13.55 2.5 14 2.95 14 3.5V5.5M14 10.5V12.5C14 13.05 13.55 13.5 13 13.5H10.5M5.5 13.5H3C2.45 13.5 2 13.05 2 12.5V10.5\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\nfunction SunIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<circle cx=\"8\" cy=\"8\" r=\"2.5\" stroke=\"currentColor\" strokeWidth=\"1.25\" />\n\t\t\t<path\n\t\t\t\td=\"M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.11 4.11l1.06 1.06M10.83 10.83l1.06 1.06M4.11 11.89l1.06-1.06M10.83 5.17l1.06-1.06\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\nfunction MoonIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<path\n\t\t\t\td=\"M13.5 9.5a5.5 5.5 0 01-7-7 5.5 5.5 0 107 7z\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\nfunction ResetIcon({ className }: { className?: string }) {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden=\"true\"\n\t\t\tclassName={className}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\tfill=\"none\"\n\t\t>\n\t\t\t<path\n\t\t\t\td=\"M2.5 8a5.5 5.5 0 019.37-3.9M13.5 8a5.5 5.5 0 01-9.37 3.9\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t/>\n\t\t\t<path\n\t\t\t\td=\"M12.5 2v3h-3M3.5 14v-3h3\"\n\t\t\t\tstroke=\"currentColor\"\n\t\t\t\tstrokeWidth=\"1.25\"\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t/>\n\t\t</svg>\n\t);\n}\n\n// ============================================================================\n// Styles\n// ============================================================================\n\nconst panelAnimationStyles = `\n @keyframes devPanelSlideIn {\n 0% {\n opacity: 0;\n transform: translateY(12px) scale(0.98);\n }\n 100% {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n }\n\n @keyframes devPanelSlideOut {\n 0% {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n 100% {\n opacity: 0;\n transform: translateY(8px) scale(0.98);\n }\n }\n\n .dev-panel-enter {\n animation: devPanelSlideIn 200ms cubic-bezier(0.16, 1, 0.3, 1) forwards;\n }\n\n .dev-panel-exit {\n animation: devPanelSlideOut 150ms cubic-bezier(0.4, 0, 1, 1) forwards;\n }\n\n .dev-json-editor::-webkit-scrollbar {\n width: 6px;\n height: 6px;\n }\n\n .dev-json-editor::-webkit-scrollbar-track {\n background: transparent;\n }\n\n .dev-json-editor::-webkit-scrollbar-thumb {\n background: rgba(255, 255, 255, 0.1);\n border-radius: 3px;\n }\n\n .dev-json-editor::-webkit-scrollbar-thumb:hover {\n background: rgba(255, 255, 255, 0.15);\n }\n`;\n\n// ============================================================================\n// Components\n// ============================================================================\n\ninterface DevControlsProps {\n\tdefaultProps?: Record<string, unknown>;\n\twidgetPaths?: string[];\n}\n\nexport function DevModeProvider({\n\tdefaultProps,\n\twidgetPaths,\n\tchildren,\n}: DevControlsProps & { children: React.ReactNode }) {\n\tconst [isInitialized, setIsInitialized] = useState(false);\n\tconst [isWidgetPage, setIsWidgetPage] = useState(false);\n\n\tuseEffect(() => {\n\t\t// When loaded inside the MCP harness iframe, skip the OpenAI mock\n\t\t// so the real MCPAppsWidgetClient + App class is used instead.\n\t\tconst params = new URLSearchParams(window.location.search);\n\t\tif (params.get(\"platform\") === \"mcp-apps\") {\n\t\t\tsetIsInitialized(true);\n\t\t\treturn;\n\t\t}\n\n\t\t// Check if current path is a widget page\n\t\tif (widgetPaths && widgetPaths.length > 0) {\n\t\t\tconst currentPath = window.location.pathname;\n\t\t\tconst isWidget = widgetPaths.some(\n\t\t\t\t(path) => currentPath === path || currentPath.startsWith(`${path}/`),\n\t\t\t);\n\t\t\tsetIsWidgetPage(isWidget);\n\n\t\t\tif (isWidget) {\n\t\t\t\tinitializeMockOpenAI(defaultProps);\n\t\t\t}\n\t\t} else {\n\t\t\t// If no widgetPaths specified, treat all pages as widget pages (backwards compat)\n\t\t\tinitializeMockOpenAI(defaultProps);\n\t\t\tsetIsWidgetPage(true);\n\t\t}\n\t\tsetIsInitialized(true);\n\t}, [defaultProps, widgetPaths]);\n\n\tif (!isInitialized) {\n\t\treturn null;\n\t}\n\n\t// If not a widget page, just render children without the dev frame\n\tif (!isWidgetPage) {\n\t\treturn <>{children}</>;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<WidgetPreviewFrame>{children}</WidgetPreviewFrame>\n\t\t\t<DevControls defaultProps={defaultProps} />\n\t\t</>\n\t);\n}\n\nfunction WidgetPreviewFrame({ children }: { children: React.ReactNode }) {\n\treturn (\n\t\t<div className=\"min-h-screen bg-[#212121] flex items-center justify-center p-8\">\n\t\t\t<div\n\t\t\t\tclassName=\"relative w-full max-w-md overflow-hidden rounded-2xl sm:rounded-3xl border border-[#414141]\"\n\t\t\t\tstyle={{\n\t\t\t\t\tboxShadow: \"0px 0px 0px 1px #414141, 0px 4px 14px rgba(0,0,0,0.24)\",\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n// ============================================================================\n// Segmented Control\n// ============================================================================\n\ninterface SegmentOption<T extends string> {\n\tvalue: T;\n\tlabel: string;\n\ticon: React.ReactNode;\n}\n\ninterface SegmentedControlProps<T extends string> {\n\toptions: SegmentOption<T>[];\n\tvalue: T;\n\tonChange: (value: T) => void;\n}\n\nfunction SegmentedControl<T extends string>({\n\toptions,\n\tvalue,\n\tonChange,\n}: SegmentedControlProps<T>) {\n\tconst activeIndex = options.findIndex((opt) => opt.value === value);\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"relative flex p-0.5 rounded-lg\"\n\t\t\tstyle={{\n\t\t\t\tbackground: \"rgba(255, 255, 255, 0.04)\",\n\t\t\t\tborder: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t}}\n\t\t>\n\t\t\t{/* Sliding indicator */}\n\t\t\t<div\n\t\t\t\tclassName=\"absolute top-0.5 bottom-0.5 rounded-md transition-transform duration-150 ease-out\"\n\t\t\t\tstyle={{\n\t\t\t\t\twidth: `calc(${100 / options.length}% - 2px)`,\n\t\t\t\t\tleft: \"2px\",\n\t\t\t\t\ttransform: `translateX(calc(${activeIndex * 100}% + ${activeIndex * 2}px))`,\n\t\t\t\t\tbackground: \"rgba(255, 255, 255, 0.1)\",\n\t\t\t\t}}\n\t\t\t/>\n\n\t\t\t{options.map((option) => (\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tkey={option.value}\n\t\t\t\t\tonClick={() => onChange(option.value)}\n\t\t\t\t\tclassName={`\n relative z-10 flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5\n text-xs font-medium rounded-md transition-colors duration-150\n ${value === option.value ? \"text-white\" : \"text-gray-400 hover:text-gray-300\"}\n `}\n\t\t\t\t>\n\t\t\t\t\t{option.icon}\n\t\t\t\t\t<span className=\"capitalize\">{option.label}</span>\n\t\t\t\t</button>\n\t\t\t))}\n\t\t</div>\n\t);\n}\n\n// ============================================================================\n// Main DevControls Component\n// ============================================================================\n\nfunction DevControls({ defaultProps }: DevControlsProps) {\n\tconst [isOpen, setIsOpen] = useState(() => {\n\t\tif (typeof window === \"undefined\") return false;\n\t\treturn localStorage.getItem(\"dev-controls-open\") === \"true\";\n\t});\n\tconst [isAnimating, setIsAnimating] = useState(false);\n\tconst [shouldRender, setShouldRender] = useState(isOpen);\n\tconst [displayMode, setDisplayMode] = useState<DisplayMode>(\"inline\");\n\tconst [theme, setTheme] = useState<Theme>(\"dark\");\n\tconst [showSafeArea, setShowSafeArea] = useState(false);\n\tconst [propsJson, setPropsJson] = useState(() =>\n\t\tJSON.stringify(defaultProps ?? {}, null, 2),\n\t);\n\tconst [jsonError, setJsonError] = useState<string | null>(null);\n\tconst debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tconst panelRef = useRef<HTMLDivElement>(null);\n\tconst containerRef = useRef<HTMLDivElement>(null);\n\n\t// Initialize from mock state\n\tuseEffect(() => {\n\t\tconst state = getMockState();\n\t\tsetDisplayMode(state.displayMode);\n\t\tsetTheme(state.theme);\n\t}, []);\n\n\t// Update safeArea when toggled\n\tuseEffect(() => {\n\t\tif (typeof window === \"undefined\") return;\n\t\tif (!window.openai) {\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: window.openai may not exist yet\n\t\t\t(window as any).openai = {};\n\t\t}\n\t\twindow.openai.safeArea = {\n\t\t\tinsets: {\n\t\t\t\ttop: 0,\n\t\t\t\tbottom: showSafeArea ? MOCK_SAFE_AREA_HEIGHT : 0,\n\t\t\t\tleft: 0,\n\t\t\t\tright: 0,\n\t\t\t},\n\t\t};\n\t\twindow.dispatchEvent(\n\t\t\tnew SetGlobalsEvent({ globals: { safeArea: window.openai.safeArea } }),\n\t\t);\n\t}, [showSafeArea]);\n\n\t// Persist open state\n\tuseEffect(() => {\n\t\tlocalStorage.setItem(\"dev-controls-open\", String(isOpen));\n\t}, [isOpen]);\n\n\tconst openPanel = useCallback(() => {\n\t\tsetShouldRender(true);\n\t\t// Small delay to ensure DOM is ready for animation\n\t\trequestAnimationFrame(() => {\n\t\t\tsetIsOpen(true);\n\t\t});\n\t}, []);\n\n\tconst closePanel = useCallback(() => {\n\t\tsetIsAnimating(true);\n\t\tsetIsOpen(false);\n\t\t// Wait for exit animation\n\t\tsetTimeout(() => {\n\t\t\tsetShouldRender(false);\n\t\t\tsetIsAnimating(false);\n\t\t}, 150);\n\t}, []);\n\n\tconst togglePanel = useCallback(() => {\n\t\tif (isOpen) {\n\t\t\tclosePanel();\n\t\t} else {\n\t\t\topenPanel();\n\t\t}\n\t}, [isOpen, openPanel, closePanel]);\n\n\t// Keyboard shortcuts\n\tuseEffect(() => {\n\t\tconst handleKeyDown = (e: KeyboardEvent) => {\n\t\t\t// Cmd/Ctrl + Shift + D to toggle\n\t\t\tif ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key === \"d\") {\n\t\t\t\te.preventDefault();\n\t\t\t\ttogglePanel();\n\t\t\t}\n\t\t\t// Escape to close\n\t\t\tif (e.key === \"Escape\" && isOpen) {\n\t\t\t\tclosePanel();\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener(\"keydown\", handleKeyDown);\n\t\treturn () => window.removeEventListener(\"keydown\", handleKeyDown);\n\t}, [isOpen, togglePanel, closePanel]);\n\n\t// Click outside to close\n\tuseEffect(() => {\n\t\tif (!isOpen) return;\n\n\t\tconst handleClickOutside = (e: MouseEvent) => {\n\t\t\tif (\n\t\t\t\tcontainerRef.current &&\n\t\t\t\t!containerRef.current.contains(e.target as Node)\n\t\t\t) {\n\t\t\t\tclosePanel();\n\t\t\t}\n\t\t};\n\n\t\tdocument.addEventListener(\"mousedown\", handleClickOutside);\n\t\treturn () => document.removeEventListener(\"mousedown\", handleClickOutside);\n\t}, [isOpen, closePanel]);\n\n\tconst handleDisplayModeChange = useCallback((mode: DisplayMode) => {\n\t\tsetDisplayMode(mode);\n\t\tupdateMockDisplayMode(mode);\n\t}, []);\n\n\tconst handleThemeChange = useCallback((newTheme: Theme) => {\n\t\tsetTheme(newTheme);\n\t\tupdateMockTheme(newTheme);\n\t}, []);\n\n\tconst applyProps = useCallback((json: string) => {\n\t\ttry {\n\t\t\tconst parsed = JSON.parse(json);\n\t\t\tsetJsonError(null);\n\t\t\tupdateMockToolOutput(parsed);\n\t\t} catch {\n\t\t\tsetJsonError(\"Invalid JSON\");\n\t\t}\n\t}, []);\n\n\tconst handlePropsChange = useCallback(\n\t\t(json: string) => {\n\t\t\tsetPropsJson(json);\n\t\t\tif (debounceRef.current) {\n\t\t\t\tclearTimeout(debounceRef.current);\n\t\t\t}\n\t\t\tdebounceRef.current = setTimeout(() => {\n\t\t\t\tapplyProps(json);\n\t\t\t}, 500);\n\t\t},\n\t\t[applyProps],\n\t);\n\n\tconst handlePropsBlur = useCallback(() => {\n\t\tif (debounceRef.current) {\n\t\t\tclearTimeout(debounceRef.current);\n\t\t}\n\t\tapplyProps(propsJson);\n\t}, [applyProps, propsJson]);\n\n\tconst handleReset = useCallback(() => {\n\t\tconst defaultJson = JSON.stringify(defaultProps ?? {}, null, 2);\n\t\tsetPropsJson(defaultJson);\n\t\tsetJsonError(null);\n\t\tupdateMockToolOutput(defaultProps ?? {});\n\t\tsetDisplayMode(\"inline\");\n\t\tupdateMockDisplayMode(\"inline\");\n\t\tsetTheme(\"dark\");\n\t\tupdateMockTheme(\"dark\");\n\t}, [defaultProps]);\n\n\tconst displayModeOptions: SegmentOption<DisplayMode>[] = [\n\t\t{\n\t\t\tvalue: \"inline\",\n\t\t\tlabel: \"inline\",\n\t\t\ticon: <InlineIcon className=\"w-3.5 h-3.5\" />,\n\t\t},\n\t\t{ value: \"pip\", label: \"pip\", icon: <PipIcon className=\"w-3.5 h-3.5\" /> },\n\t\t{\n\t\t\tvalue: \"fullscreen\",\n\t\t\tlabel: \"full\",\n\t\t\ticon: <FullscreenIcon className=\"w-3.5 h-3.5\" />,\n\t\t},\n\t];\n\n\tconst themeOptions: SegmentOption<Theme>[] = [\n\t\t{\n\t\t\tvalue: \"light\",\n\t\t\tlabel: \"light\",\n\t\t\ticon: <SunIcon className=\"w-3.5 h-3.5\" />,\n\t\t},\n\t\t{\n\t\t\tvalue: \"dark\",\n\t\t\tlabel: \"dark\",\n\t\t\ticon: <MoonIcon className=\"w-3.5 h-3.5\" />,\n\t\t},\n\t];\n\n\treturn (\n\t\t<>\n\t\t\t{/* Inject animation styles */}\n\t\t\t{/** biome-ignore lint/security/noDangerouslySetInnerHtml: we need to inject styles into the DOM */}\n\t\t\t<style dangerouslySetInnerHTML={{ __html: panelAnimationStyles }} />\n\n\t\t\t<div\n\t\t\t\tref={containerRef}\n\t\t\t\tclassName=\"fixed bottom-4 right-4 z-[9999] font-['Inter',_system-ui,_sans-serif]\"\n\t\t\t>\n\t\t\t\t{/* Toggle Button */}\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonClick={togglePanel}\n\t\t\t\t\tclassName=\"group relative flex items-center justify-center w-11 h-11 rounded-xl transition-all duration-200 ease-out hover:scale-105 active:scale-95\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tbackground: \"rgba(14, 14, 16, 0.95)\",\n\t\t\t\t\t\tbackdropFilter: \"blur(16px)\",\n\t\t\t\t\t\tWebkitBackdropFilter: \"blur(16px)\",\n\t\t\t\t\t\tborder: \"1px solid rgba(255, 255, 255, 0.08)\",\n\t\t\t\t\t\tboxShadow: `\n 0 4px 12px rgba(0, 0, 0, 0.4),\n 0 0 0 1px rgba(255, 255, 255, 0.05),\n inset 0 1px 0 rgba(255, 255, 255, 0.04)\n `,\n\t\t\t\t\t}}\n\t\t\t\t\taria-label=\"Toggle Dev Controls\"\n\t\t\t\t\taria-expanded={isOpen}\n\t\t\t\t>\n\t\t\t\t\t<DevIcon\n\t\t\t\t\t\tclassName={`w-5 h-5 transition-all duration-200 ${\n\t\t\t\t\t\t\tisOpen\n\t\t\t\t\t\t\t\t? \"text-indigo-400 scale-110\"\n\t\t\t\t\t\t\t\t: \"text-gray-300 group-hover:text-white\"\n\t\t\t\t\t\t}`}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{/* Subtle glow on hover */}\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"absolute inset-0 rounded-xl opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none\"\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tbackground:\n\t\t\t\t\t\t\t\t\"radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, transparent 70%)\",\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</button>\n\n\t\t\t\t{/* Panel */}\n\t\t\t\t{shouldRender && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tref={panelRef}\n\t\t\t\t\t\tclassName={`absolute bottom-14 right-0 w-80 ${\n\t\t\t\t\t\t\tisOpen && !isAnimating ? \"dev-panel-enter\" : \"dev-panel-exit\"\n\t\t\t\t\t\t}`}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tmaxHeight: \"calc(100vh - 120px)\",\n\t\t\t\t\t\t\tbackground: \"rgba(14, 14, 16, 0.92)\",\n\t\t\t\t\t\t\tbackdropFilter: \"blur(24px)\",\n\t\t\t\t\t\t\tWebkitBackdropFilter: \"blur(24px)\",\n\t\t\t\t\t\t\tborder: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t\t\t\t\tborderRadius: \"16px\",\n\t\t\t\t\t\t\tboxShadow: `\n 0 25px 50px -12px rgba(0, 0, 0, 0.6),\n 0 0 0 1px rgba(255, 255, 255, 0.05),\n inset 0 1px 0 rgba(255, 255, 255, 0.04)\n `,\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{/* Header */}\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"flex items-center justify-between px-4 py-3\"\n\t\t\t\t\t\t\tstyle={{ borderBottom: \"1px solid rgba(255, 255, 255, 0.06)\" }}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"flex items-center gap-2\">\n\t\t\t\t\t\t\t\t<DevIcon className=\"w-4 h-4 text-gray-400\" />\n\t\t\t\t\t\t\t\t<span className=\"text-sm font-medium text-white\">\n\t\t\t\t\t\t\t\t\tDev Controls\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t<div className=\"flex items-center gap-2\">\n\t\t\t\t\t\t\t\t{/* Keyboard shortcut badge */}\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\tclassName=\"text-[10px] font-medium text-gray-500 px-1.5 py-0.5 rounded\"\n\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\tbackground: \"rgba(255, 255, 255, 0.04)\",\n\t\t\t\t\t\t\t\t\t\tborder: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{typeof navigator !== \"undefined\" &&\n\t\t\t\t\t\t\t\t\tnavigator.platform?.includes(\"Mac\")\n\t\t\t\t\t\t\t\t\t\t? \"⌘⇧D\"\n\t\t\t\t\t\t\t\t\t\t: \"Ctrl+Shift+D\"}\n\t\t\t\t\t\t\t\t</span>\n\n\t\t\t\t\t\t\t\t{/* Close button */}\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tonClick={closePanel}\n\t\t\t\t\t\t\t\t\tclassName=\"p-1 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<CloseIcon className=\"w-4 h-4\" />\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t{/* Content */}\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"p-4 space-y-5 overflow-y-auto\"\n\t\t\t\t\t\t\tstyle={{ maxHeight: \"calc(100vh - 200px)\" }}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{/* Display Mode */}\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\thtmlFor=\"display-mode\"\n\t\t\t\t\t\t\t\t\tclassName=\"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tDisplay Mode\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t<SegmentedControl\n\t\t\t\t\t\t\t\t\toptions={displayModeOptions}\n\t\t\t\t\t\t\t\t\tvalue={displayMode}\n\t\t\t\t\t\t\t\t\tonChange={handleDisplayModeChange}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t{/* Theme */}\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\thtmlFor=\"theme\"\n\t\t\t\t\t\t\t\t\tclassName=\"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tTheme\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t<SegmentedControl\n\t\t\t\t\t\t\t\t\toptions={themeOptions}\n\t\t\t\t\t\t\t\t\tvalue={theme}\n\t\t\t\t\t\t\t\t\tonChange={handleThemeChange}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t{/* Safe Area Mock */}\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\thtmlFor=\"safe-area\"\n\t\t\t\t\t\t\t\t\tclassName=\"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tSafe Area (Chat Input)\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tonClick={() => setShowSafeArea(!showSafeArea)}\n\t\t\t\t\t\t\t\t\tclassName={`w-full flex items-center justify-between px-3 py-2.5 rounded-lg text-xs font-medium transition-all duration-150 ${\n\t\t\t\t\t\t\t\t\t\tshowSafeArea ? \"text-emerald-400\" : \"text-gray-400\"\n\t\t\t\t\t\t\t\t\t}`}\n\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\tbackground: showSafeArea\n\t\t\t\t\t\t\t\t\t\t\t? \"rgba(34, 197, 94, 0.1)\"\n\t\t\t\t\t\t\t\t\t\t\t: \"rgba(255, 255, 255, 0.04)\",\n\t\t\t\t\t\t\t\t\t\tborder: showSafeArea\n\t\t\t\t\t\t\t\t\t\t\t? \"1px solid rgba(34, 197, 94, 0.3)\"\n\t\t\t\t\t\t\t\t\t\t\t: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span>Mock ChatGPT Input Bar</span>\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tclassName={`px-2 py-0.5 rounded text-[10px] font-semibold ${\n\t\t\t\t\t\t\t\t\t\t\tshowSafeArea\n\t\t\t\t\t\t\t\t\t\t\t\t? \"bg-emerald-500/20 text-emerald-400\"\n\t\t\t\t\t\t\t\t\t\t\t\t: \"bg-gray-500/20 text-gray-500\"\n\t\t\t\t\t\t\t\t\t\t}`}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{showSafeArea ? \"ON\" : \"OFF\"}\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t{showSafeArea && (\n\t\t\t\t\t\t\t\t\t<p className=\"text-[10px] text-gray-500 mt-1.5\">\n\t\t\t\t\t\t\t\t\t\tbottom: {MOCK_SAFE_AREA_HEIGHT}px\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t{/* Widget Props */}\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\thtmlFor=\"widget-props\"\n\t\t\t\t\t\t\t\t\tclassName=\"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tWidget Props\n\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t<textarea\n\t\t\t\t\t\t\t\t\tvalue={propsJson}\n\t\t\t\t\t\t\t\t\tonChange={(e) => handlePropsChange(e.target.value)}\n\t\t\t\t\t\t\t\t\tonBlur={handlePropsBlur}\n\t\t\t\t\t\t\t\t\tclassName=\"dev-json-editor w-full min-h-[160px] text-xs text-gray-200 p-3 rounded-lg resize-none focus:outline-none transition-colors\"\n\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\tbackground: \"rgba(0, 0, 0, 0.3)\",\n\t\t\t\t\t\t\t\t\t\tborder: jsonError\n\t\t\t\t\t\t\t\t\t\t\t? \"1px solid rgba(239, 68, 68, 0.5)\"\n\t\t\t\t\t\t\t\t\t\t\t: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t\t\t\t\t\t\t\tfontFamily:\n\t\t\t\t\t\t\t\t\t\t\t\"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace\",\n\t\t\t\t\t\t\t\t\t\tlineHeight: 1.6,\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tonFocus={(e) => {\n\t\t\t\t\t\t\t\t\t\tif (!jsonError) {\n\t\t\t\t\t\t\t\t\t\t\te.target.style.borderColor = \"rgba(99, 102, 241, 0.5)\";\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tonBlurCapture={(e) => {\n\t\t\t\t\t\t\t\t\t\tif (!jsonError) {\n\t\t\t\t\t\t\t\t\t\t\te.target.style.borderColor = \"rgba(255, 255, 255, 0.06)\";\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tspellCheck={false}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{jsonError && (\n\t\t\t\t\t\t\t\t\t<p className=\"text-red-400 text-[11px] mt-1.5 flex items-center gap-1\">\n\t\t\t\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\t\t\taria-label=\"Error\"\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"w-3 h-3\"\n\t\t\t\t\t\t\t\t\t\t\tviewBox=\"0 0 16 16\"\n\t\t\t\t\t\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<path d=\"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z\" />\n\t\t\t\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t\t\t\t\t{jsonError}\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t{/* Reset Button */}\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tonClick={handleReset}\n\t\t\t\t\t\t\t\tclassName=\"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\"\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tbackground: \"rgba(255, 255, 255, 0.04)\",\n\t\t\t\t\t\t\t\t\tborder: \"1px solid rgba(255, 255, 255, 0.06)\",\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tonMouseEnter={(e) => {\n\t\t\t\t\t\t\t\t\te.currentTarget.style.background =\n\t\t\t\t\t\t\t\t\t\t\"rgba(255, 255, 255, 0.08)\";\n\t\t\t\t\t\t\t\t\te.currentTarget.style.borderColor =\n\t\t\t\t\t\t\t\t\t\t\"rgba(255, 255, 255, 0.1)\";\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tonMouseLeave={(e) => {\n\t\t\t\t\t\t\t\t\te.currentTarget.style.background =\n\t\t\t\t\t\t\t\t\t\t\"rgba(255, 255, 255, 0.04)\";\n\t\t\t\t\t\t\t\t\te.currentTarget.style.borderColor =\n\t\t\t\t\t\t\t\t\t\t\"rgba(255, 255, 255, 0.06)\";\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ResetIcon className=\"w-3.5 h-3.5\" />\n\t\t\t\t\t\t\t\tReset to Defaults\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\n\t\t\t{/* Mock ChatGPT Input Bar */}\n\t\t\t{showSafeArea && (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"fixed bottom-0 left-0 right-0 z-[9998] flex items-center justify-center pointer-events-none\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\theight: `${MOCK_SAFE_AREA_HEIGHT}px`,\n\t\t\t\t\t\tbackground:\n\t\t\t\t\t\t\t\"linear-gradient(to top, #1a1a1a 0%, #1a1a1a 80%, transparent 100%)\",\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<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\">\n\t\t\t\t\t\t<div className=\"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center\">\n\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\tclassName=\"w-4 h-4 text-gray-400\"\n\t\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<path\n\t\t\t\t\t\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\t\t\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t\t\t\t\t\t\tstrokeWidth={2}\n\t\t\t\t\t\t\t\t\td=\"M12 4v16m8-8H4\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"flex-1 text-gray-400 text-sm\">Ask anything...</div>\n\t\t\t\t\t\t<div className=\"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center\">\n\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\tclassName=\"w-4 h-4 text-gray-400\"\n\t\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<path\n\t\t\t\t\t\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\t\t\t\t\t\tstrokeLinejoin=\"round\"\n\t\t\t\t\t\t\t\t\tstrokeWidth={2}\n\t\t\t\t\t\t\t\t\td=\"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\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"absolute bottom-1 text-[10px] text-gray-600 font-mono\">\n\t\t\t\t\t\tMock SafeArea: bottom={MOCK_SAFE_AREA_HEIGHT}px\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</>\n\t);\n}\n","import {\n\ttype DisplayMode,\n\ttype OpenAIGlobals,\n\tSetGlobalsEvent,\n\ttype Theme,\n} from \"../hooks/@types\";\n\nconst DEFAULT_MOCK_CONFIG: Omit<OpenAIGlobals, \"setWidgetState\"> = {\n\ttheme: \"dark\",\n\tuserAgent: {\n\t\tdevice: { type: \"desktop\" },\n\t\tcapabilities: { hover: true, touch: false },\n\t},\n\tlocale: \"en\",\n\tmaxHeight: 800,\n\tdisplayMode: \"inline\",\n\tsafeArea: { insets: { top: 0, bottom: 0, left: 0, right: 0 } },\n\ttoolInput: {},\n\ttoolOutput: null,\n\ttoolResponseMetadata: null,\n\twidgetState: null,\n};\n\nlet mockState: Omit<OpenAIGlobals, \"setWidgetState\"> = {\n\t...DEFAULT_MOCK_CONFIG,\n};\n\nexport function initializeMockOpenAI(\n\tinitialToolOutput?: Record<string, unknown>,\n): void {\n\tif (typeof window === \"undefined\") return;\n\tif (window.openai) return; // Already initialized (real ChatGPT or previous mock)\n\n\tmockState = {\n\t\t...DEFAULT_MOCK_CONFIG,\n\t\ttoolOutput: initialToolOutput ?? null,\n\t};\n\n\twindow.openai = {\n\t\t...mockState,\n\t\t// Mock API functions\n\t\trequestDisplayMode: async ({ mode }) => {\n\t\t\tupdateMockGlobal(\"displayMode\", mode);\n\t\t\treturn { mode };\n\t\t},\n\t\tcallTool: async (name, args) => {\n\t\t\tconsole.log(`[DevMode] callTool: ${name}`, args);\n\t\t\treturn { result: JSON.stringify({ mock: true, tool: name, args }) };\n\t\t},\n\t\tsendFollowUpMessage: async ({ prompt }) => {\n\t\t\tconsole.log(`[DevMode] sendFollowUpMessage: ${prompt}`);\n\t\t},\n\t\topenExternal: ({ href }) => {\n\t\t\tconsole.log(`[DevMode] openExternal: ${href}`);\n\t\t\twindow.open(href, \"_blank\");\n\t\t},\n\t\tsetWidgetState: async (state) => {\n\t\t\tupdateMockGlobal(\"widgetState\", state);\n\t\t},\n\t};\n\n\t// Dispatch initial event so hooks pick up the values\n\twindow.dispatchEvent(new SetGlobalsEvent({ globals: mockState }));\n}\n\nexport function updateMockGlobal<K extends keyof OpenAIGlobals>(\n\tkey: K,\n\tvalue: OpenAIGlobals[K],\n): void {\n\tif (typeof window === \"undefined\" || !window.openai) return;\n\n\t(mockState as Record<string, unknown>)[key] = value;\n\t(window.openai as Record<string, unknown>)[key] = value;\n\n\twindow.dispatchEvent(new SetGlobalsEvent({ globals: { [key]: value } }));\n}\n\nexport function getMockState(): typeof mockState {\n\treturn { ...mockState };\n}\n\nexport function updateMockToolOutput(props: Record<string, unknown>): void {\n\tupdateMockGlobal(\"toolOutput\", props);\n}\n\nexport function updateMockDisplayMode(mode: DisplayMode): void {\n\tupdateMockGlobal(\"displayMode\", mode);\n}\n\nexport function updateMockTheme(theme: Theme): void {\n\tupdateMockGlobal(\"theme\", theme);\n}\n","\"use client\";\n\nimport { useCallback } from \"react\";\nimport type { ToolCallResult } from \"../widgets/@utils/widget-client\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get a function to call other tools.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @returns A function to call tools with their name and arguments\n */\nexport function useCallTool(): (\n\tname: string,\n\targs: Record<string, unknown>,\n) => Promise<ToolCallResult> {\n\tconst client = useWidgetClient();\n\treturn useCallback(\n\t\t(name: string, args: Record<string, unknown>) =>\n\t\t\tclient.callTool(name, args),\n\t\t[client],\n\t);\n}\n","\"use client\";\n\nimport React, {\n\tcreateContext,\n\ttype ReactNode,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseState,\n\tuseSyncExternalStore,\n} from \"react\";\nimport {\n\tcreateWidgetClient,\n\ttype UnifiedWidgetClient,\n} from \"../widgets/@utils/widget-client\";\nimport type { DisplayMode, SafeArea, Theme, UnknownObject } from \"./@types\";\n\n/**\n * Context for the unified widget client.\n */\nconst WidgetClientContext = createContext<UnifiedWidgetClient | null>(null);\n\n/**\n * Provider props\n */\ninterface WidgetProviderProps {\n\tchildren: ReactNode;\n\t/** Optional loading component while connecting */\n\tloading?: ReactNode;\n\t/** Optional error component */\n\tonError?: (error: Error) => ReactNode;\n}\n\n/**\n * Provider component that initializes the correct widget client based on platform.\n * Wrap your widget component with this provider.\n *\n * @example\n * ```tsx\n * function App() {\n * return (\n * <WidgetProvider loading={<Spinner />}>\n * <MyWidget />\n * </WidgetProvider>\n * );\n * }\n * ```\n */\nexport function WidgetProvider({\n\tchildren,\n\tloading = null,\n\tonError,\n}: WidgetProviderProps) {\n\tconst [client, setClient] = useState<UnifiedWidgetClient | null>(null);\n\tconst [error, setError] = useState<Error | null>(null);\n\tconst [isConnecting, setIsConnecting] = useState(true);\n\n\tuseEffect(() => {\n\t\tlet mounted = true;\n\n\t\tasync function initClient() {\n\t\t\ttry {\n\t\t\t\tconst widgetClient = await createWidgetClient();\n\n\t\t\t\tawait widgetClient.connect();\n\n\t\t\t\tif (mounted) {\n\t\t\t\t\tsetClient(widgetClient);\n\t\t\t\t\tsetIsConnecting(false);\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tif (mounted) {\n\t\t\t\t\tconsole.log(\"error\", err);\n\t\t\t\t\tsetError(err instanceof Error ? err : new Error(String(err)));\n\t\t\t\t\tsetIsConnecting(false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tinitClient();\n\n\t\treturn () => {\n\t\t\tmounted = false;\n\t\t};\n\t}, []);\n\n\t// Sync theme to <html> class so consumers can use html.dark { ... } or dark: variants\n\tuseEffect(() => {\n\t\tif (!client) return;\n\n\t\tconst syncTheme = (theme: Theme) => {\n\t\t\tdocument.documentElement.classList.toggle(\"dark\", theme === \"dark\");\n\t\t};\n\n\t\tsyncTheme(client.getTheme());\n\t\treturn client.onThemeChange(syncTheme);\n\t}, [client]);\n\n\tif (error && onError) {\n\t\treturn React.createElement(React.Fragment, null, onError(error));\n\t}\n\n\tif (isConnecting || !client) {\n\t\treturn React.createElement(React.Fragment, null, loading);\n\t}\n\n\treturn React.createElement(\n\t\tWidgetClientContext.Provider,\n\t\t{ value: client },\n\t\tchildren,\n\t);\n}\n\n/**\n * Keys that can be selected from the widget client.\n */\ntype WidgetKey =\n\t| \"toolOutput\"\n\t| \"theme\"\n\t| \"displayMode\"\n\t| \"locale\"\n\t| \"safeArea\"\n\t| \"maxHeight\"\n\t| \"toolResponseMetadata\"\n\t| \"widgetState\";\n\n/**\n * Value types for each widget key.\n */\ntype WidgetKeyValues = {\n\ttoolOutput: Record<string, unknown> | null;\n\ttheme: Theme;\n\tdisplayMode: DisplayMode;\n\tlocale: string;\n\tsafeArea: SafeArea | null;\n\tmaxHeight: number | null;\n\ttoolResponseMetadata: UnknownObject | null;\n\twidgetState: UnknownObject | null;\n};\n\n/**\n * Get the unified widget client instance.\n * Must be used within a WidgetProvider.\n *\n * @example\n * ```tsx\n * // Full client for actions\n * const client = useWidgetClient();\n * client.callTool(\"foo\", {});\n *\n * // Key selector for reactive values\n * const toolOutput = useWidgetClient(\"toolOutput\");\n * const theme = useWidgetClient(\"theme\");\n * ```\n */\nexport function useWidgetClient(): UnifiedWidgetClient;\nexport function useWidgetClient<K extends WidgetKey>(\n\tkey: K,\n): WidgetKeyValues[K];\nexport function useWidgetClient<K extends WidgetKey>(key?: K) {\n\tconst client = useContext(WidgetClientContext);\n\n\tif (!client) {\n\t\tthrow new Error(\"useWidgetClient must be used within a WidgetProvider\");\n\t}\n\n\t// Key selector - use useSyncExternalStore\n\tconst subscribe = useCallback(\n\t\t(onChange: () => void) => {\n\t\t\tif (key === \"toolOutput\") return client.onToolResult(() => onChange());\n\t\t\tif (key === \"theme\") return client.onThemeChange(() => onChange());\n\t\t\tif (key === \"displayMode\")\n\t\t\t\treturn client.onDisplayModeChange(() => onChange());\n\t\t\tif (key === \"safeArea\") return client.onSafeAreaChange(() => onChange());\n\t\t\tif (key === \"maxHeight\")\n\t\t\t\treturn client.onMaxHeightChange(() => onChange());\n\t\t\tif (key === \"toolResponseMetadata\")\n\t\t\t\treturn client.onToolResponseMetadataChange(() => onChange());\n\t\t\tif (key === \"widgetState\")\n\t\t\t\treturn client.onWidgetStateChange(() => onChange());\n\t\t\treturn () => {};\n\t\t},\n\t\t[client, key],\n\t);\n\n\tconst getSnapshot = useCallback(() => {\n\t\tif (key === \"toolOutput\") return client.getToolOutput();\n\t\tif (key === \"theme\") return client.getTheme();\n\t\tif (key === \"displayMode\") return client.getDisplayMode();\n\t\tif (key === \"locale\") return client.getLocale();\n\t\tif (key === \"safeArea\") return client.getSafeArea();\n\t\tif (key === \"maxHeight\") return client.getMaxHeight();\n\t\tif (key === \"toolResponseMetadata\") return client.getToolResponseMetadata();\n\t\tif (key === \"widgetState\") return client.getWidgetState();\n\t\treturn null;\n\t}, [client, key]);\n\n\tconst store = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n\t// No key - return full client\n\tif (!key) return client;\n\n\treturn store;\n}\n","import type {\n\tDisplayMode,\n\tSafeArea,\n\tTheme,\n\tUnknownObject,\n} from \"../../hooks/@types\";\n\n/**\n * Result from calling a tool\n */\nexport type ToolCallResult = {\n\tcontent?: Array<{ type: string; text?: string }>;\n\tstructuredContent?: Record<string, unknown>;\n};\n\n/**\n * Tool result notification (what the host pushes to the widget)\n */\nexport type ToolResult = {\n\tcontent?: Array<{ type: string; text?: string }>;\n\tstructuredContent?: Record<string, unknown>;\n};\n\n/**\n * Host context - all values available from the host.\n */\nexport type HostContext = {\n\ttheme: Theme;\n\tlocale: string;\n\tdisplayMode: DisplayMode;\n\tmaxHeight: number | null;\n\tsafeArea: SafeArea | null;\n\ttoolOutput: UnknownObject | null;\n\ttoolResponseMetadata: UnknownObject | null;\n\twidgetState: UnknownObject | null;\n};\n\n/**\n * Store interface for useSyncExternalStore compatibility.\n */\nexport type HostContextStore<K extends keyof HostContext> = {\n\tsubscribe: (onStoreChange: () => void) => () => void;\n\tgetSnapshot: () => HostContext[K];\n};\n\n/**\n * Unified widget client interface that works on both OpenAI and MCP Apps.\n *\n * Platform-specific behavior:\n * - Display mode: OpenAI-only. MCP Apps returns \"inline\" and requestDisplayMode is a no-op.\n * - Follow-up messages: Unified API, different underlying implementations.\n */\nexport interface UnifiedWidgetClient {\n\t/**\n\t * Connect to the host. Must be called before using other methods.\n\t * On OpenAI, this is a no-op (already connected via window.openai).\n\t * On MCP Apps, this establishes the postMessage connection.\n\t */\n\tconnect(): Promise<void>;\n\n\t/**\n\t * Get the tool output (structured content returned by the tool handler).\n\t * This is the main data source for widget rendering.\n\t */\n\tgetToolOutput<T = Record<string, unknown>>(): T | null;\n\n\t/**\n\t * Register a callback for when tool results are received.\n\t * On OpenAI, this subscribes to toolOutput changes.\n\t * On MCP Apps, this sets app.ontoolresult.\n\t */\n\tonToolResult(callback: (result: ToolResult) => void): () => void;\n\n\t/**\n\t * Call another tool on the server.\n\t */\n\tcallTool(\n\t\tname: string,\n\t\targs: Record<string, unknown>,\n\t): Promise<ToolCallResult>;\n\n\t/**\n\t * Open an external URL.\n\t * On OpenAI: openai.openExternal({ href })\n\t * On MCP Apps: app.sendOpenLink(url)\n\t */\n\topenExternal(url: string): void;\n\n\t/**\n\t * Send a follow-up message to the AI.\n\t * On OpenAI: openai.sendFollowUpMessage({ prompt })\n\t * On MCP Apps: app.sendMessages([{ role: 'user', content: { type: 'text', text: prompt } }])\n\t */\n\tsendFollowUp(prompt: string): void;\n\n\t/**\n\t * Get the current theme.\n\t */\n\tgetTheme(): Theme;\n\n\t/**\n\t * Subscribe to theme changes.\n\t */\n\tonThemeChange(callback: (theme: Theme) => void): () => void;\n\n\t/**\n\t * Get the current locale.\n\t */\n\tgetLocale(): string;\n\n\t/**\n\t * Get the current display mode.\n\t * OpenAI-only: returns \"pip\" | \"inline\" | \"fullscreen\"\n\t * MCP Apps: always returns \"inline\"\n\t */\n\tgetDisplayMode(): DisplayMode;\n\n\t/**\n\t * Request a display mode change.\n\t * OpenAI-only: requests the mode from the host.\n\t * MCP Apps: no-op (returns current mode).\n\t */\n\trequestDisplayMode(mode: DisplayMode): Promise<DisplayMode>;\n\n\t/**\n\t * Subscribe to display mode changes.\n\t * OpenAI-only: subscribes to displayMode changes.\n\t * MCP Apps: callback is never called.\n\t */\n\tonDisplayModeChange(callback: (mode: DisplayMode) => void): () => void;\n\n\t/**\n\t * Get the safe area insets.\n\t * OpenAI-only: returns insets from window.openai.safeArea.\n\t * MCP Apps: returns null.\n\t */\n\tgetSafeArea(): SafeArea | null;\n\n\t/**\n\t * Subscribe to safe area changes.\n\t * OpenAI-only: subscribes to safeArea changes.\n\t * MCP Apps: callback is never called.\n\t */\n\tonSafeAreaChange(callback: (safeArea: SafeArea | null) => void): () => void;\n\n\t/**\n\t * Get the max height constraint.\n\t * OpenAI-only: returns maxHeight from window.openai.maxHeight.\n\t * MCP Apps: returns null.\n\t */\n\tgetMaxHeight(): number | null;\n\n\t/**\n\t * Subscribe to max height changes.\n\t * OpenAI-only: subscribes to maxHeight changes.\n\t * MCP Apps: callback is never called.\n\t */\n\tonMaxHeightChange(callback: (maxHeight: number | null) => void): () => void;\n\n\t/**\n\t * Get the tool response metadata.\n\t * OpenAI-only: returns metadata from window.openai.toolResponseMetadata.\n\t * MCP Apps: returns null.\n\t */\n\tgetToolResponseMetadata(): UnknownObject | null;\n\n\t/**\n\t * Subscribe to tool response metadata changes.\n\t * OpenAI-only: subscribes to toolResponseMetadata changes.\n\t * MCP Apps: callback is never called.\n\t */\n\tonToolResponseMetadataChange(\n\t\tcallback: (metadata: UnknownObject | null) => void,\n\t): () => void;\n\n\t/**\n\t * Get the widget state.\n\t * OpenAI-only: returns state from window.openai.widgetState.\n\t * MCP Apps: returns null.\n\t */\n\tgetWidgetState(): UnknownObject | null;\n\n\t/**\n\t * Subscribe to widget state changes.\n\t * OpenAI-only: subscribes to widgetState changes.\n\t * MCP Apps: callback is never called.\n\t */\n\tonWidgetStateChange(\n\t\tcallback: (state: UnknownObject | null) => void,\n\t): () => void;\n}\n\n/**\n * Creates a unified widget client for the current platform.\n */\nexport async function createWidgetClient(): Promise<UnifiedWidgetClient> {\n\tconst { detectPlatform } = await import(\"./platform\");\n\tconst platform = detectPlatform();\n\n\tif (platform === \"openai\") {\n\t\tconst { OpenAIWidgetClient } = await import(\"./openai-client\");\n\t\treturn new OpenAIWidgetClient();\n\t} else {\n\t\tconst { MCPAppsWidgetClient } = await import(\"./mcp-apps-client\");\n\t\treturn new MCPAppsWidgetClient();\n\t}\n}\n","\"use client\";\n\nimport type { DisplayMode } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get the current display mode.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @returns The current display mode (\"pip\" | \"inline\" | \"fullscreen\")\n */\nexport function useDisplayMode(): DisplayMode {\n\treturn useWidgetClient(\"displayMode\");\n}\n","\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\n\n/**\n * Check if running in ChatGPT app (OpenAI-only).\n * Returns false on MCP Apps.\n *\n * @returns Whether the widget is running in ChatGPT app\n */\nexport function useIsChatGptApp(): boolean {\n\treturn useSyncExternalStore(\n\t\t() => () => {},\n\t\t() => {\n\t\t\tif (typeof window === \"undefined\") return false;\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: __isChatGptApp is injected by ChatGPT\n\t\t\treturn (window as any).__isChatGptApp === true;\n\t\t},\n\t\t() => false,\n\t);\n}\n","\"use client\";\n\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get the current locale.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @returns The current locale string (e.g., \"en-US\")\n */\nexport function useLocale(): string {\n\treturn useWidgetClient(\"locale\");\n}\n","\"use client\";\n\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get the maximum height available for the widget (OpenAI-only).\n * Useful for responsive layouts that need to adapt to container constraints.\n * Returns null on MCP Apps.\n *\n * @returns The maximum height in pixels, or null if not available\n */\nexport function useMaxHeight(): number | null {\n\treturn useWidgetClient(\"maxHeight\");\n}\n","\"use client\";\n\nimport { useCallback } from \"react\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get a function to open external URLs.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @returns A function that opens external URLs\n */\nexport function useOpenExternal(): (url: string) => void {\n\tconst client = useWidgetClient();\n\treturn useCallback((url: string) => client.openExternal(url), [client]);\n}\n","\"use client\";\n\nimport { useCallback } from \"react\";\nimport type { DisplayMode } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get a function to request display mode changes.\n * On MCP Apps, this may be a no-op depending on host support.\n *\n * @returns A function to request a specific display mode\n */\nexport function useRequestDisplayMode(): (\n\tmode: DisplayMode,\n) => Promise<DisplayMode> {\n\tconst client = useWidgetClient();\n\treturn useCallback(\n\t\t(mode: DisplayMode) => client.requestDisplayMode(mode),\n\t\t[client],\n\t);\n}\n","\"use client\";\n\nimport type { SafeArea } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get safe area insets (OpenAI-only).\n * Useful for ensuring UI elements don't get hidden behind the chat input.\n * Returns null on MCP Apps.\n *\n * @returns The safe area insets, or null if not available\n */\nexport function useSafeArea(): SafeArea | null {\n\treturn useWidgetClient(\"safeArea\");\n}\n","\"use client\";\n\nimport { useCallback } from \"react\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get a function to send follow-up messages to the AI.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @returns A function that sends a follow-up message\n */\nexport function useSendFollowUp(): (prompt: string) => void {\n\tconst client = useWidgetClient();\n\treturn useCallback((prompt: string) => client.sendFollowUp(prompt), [client]);\n}\n","\"use client\";\n\nimport type { Theme } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get the current theme.\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @returns The current theme (\"light\" | \"dark\")\n */\nexport function useTheme(): Theme {\n\treturn useWidgetClient(\"theme\");\n}\n","\"use client\";\n\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get the tool output (structured content returned by the tool handler).\n * Works on both OpenAI widgets and MCP Apps.\n *\n * @returns The tool output or null\n */\nexport function useToolOutput<T extends Record<string, unknown>>(): T | null {\n\treturn useWidgetClient(\"toolOutput\") as T | null;\n}\n","\"use client\";\n\nimport type { UnknownObject } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Get tool response metadata (OpenAI-only).\n * Contains identifiers like `openai/widgetSessionId` for correlating\n * multiple tool calls or logs for the same widget instance.\n * Returns null on MCP Apps.\n *\n * @returns The tool response metadata object or null if not available\n */\nexport function useToolResponseMetadata(): UnknownObject | null {\n\treturn useWidgetClient(\"toolResponseMetadata\");\n}\n","\"use client\";\n\nimport { type SetStateAction, useCallback, useEffect, useState } from \"react\";\nimport { detectPlatform } from \"../widgets/@utils/platform\";\nimport type { UnknownObject } from \"./@types\";\nimport { useWidgetClient } from \"./use-widget\";\n\n/**\n * Widget state that persists across widget lifecycles (OpenAI-only).\n * State is synchronized with the ChatGPT parent window and survives widget minimize/restore.\n * On MCP Apps, returns [null, no-op].\n *\n * @param defaultState - Initial state value or function to compute it\n * @returns A tuple of [state, setState] similar to useState\n */\nexport function useWidgetState<T extends UnknownObject>(\n\tdefaultState?: T | (() => T | null) | null,\n): readonly [T | null, (state: SetStateAction<T | null>) => void] {\n\tconst widgetStateFromWindow = useWidgetClient(\"widgetState\") as T | null;\n\n\tconst [widgetState, _setWidgetState] = useState<T | null>(() => {\n\t\tif (widgetStateFromWindow != null) {\n\t\t\treturn widgetStateFromWindow;\n\t\t}\n\t\treturn typeof defaultState === \"function\"\n\t\t\t? defaultState()\n\t\t\t: (defaultState ?? null);\n\t});\n\n\tuseEffect(() => {\n\t\t_setWidgetState(widgetStateFromWindow);\n\t}, [widgetStateFromWindow]);\n\n\tconst setWidgetState = useCallback((state: SetStateAction<T | null>) => {\n\t\t_setWidgetState((prevState) => {\n\t\t\tconst newState = typeof state === \"function\" ? state(prevState) : state;\n\n\t\t\tif (detectPlatform() === \"openai\" && newState != null) {\n\t\t\t\twindow.openai?.setWidgetState(newState);\n\t\t\t}\n\n\t\t\treturn newState;\n\t\t});\n\t}, []);\n\n\treturn [widgetState, setWidgetState] as const;\n}\n","export const LoadingWidget = () => {\n\treturn (\n\t\t<div className=\"flex flex-col items-center justify-center h-full min-h-[120px] gap-4\">\n\t\t\t{/* Animated dots */}\n\t\t\t<div className=\"flex gap-2\">\n\t\t\t\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]\" />\n\t\t\t\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]\" />\n\t\t\t\t<div className=\"w-3 h-3 rounded-full bg-gradient-to-r from-teal-400 to-emerald-400 animate-bounce\" />\n\t\t\t</div>\n\n\t\t\t{/* Shimmer text */}\n\t\t\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]\">\n\t\t\t\tLoading widget...\n\t\t\t</p>\n\n\t\t\t{/* Pulsing ring */}\n\t\t\t<div className=\"absolute inset-0 flex items-center justify-center pointer-events-none\">\n\t\t\t\t<div className=\"w-16 h-16 rounded-full border-2 border-blue-400/20 animate-ping\" />\n\t\t\t</div>\n\n\t\t\t<style>{`\n @keyframes shimmer {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n }\n `}</style>\n\t\t</div>\n\t);\n};\n"],"mappings":";kFAcE,mBAAAA,GACC,OAAAC,EADD,QAAAC,OAAA,oBAFK,SAASC,GAA0B,CAAE,QAAAC,CAAQ,EAAwB,CAC3E,OACCF,GAAAF,GAAA,CACC,UAA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","names":["Fragment","jsx","jsxs","InitializeNextJsInChatGpt","baseUrl","htmlElement","mutations","mutation","attrName","originalReplaceState","_s","unused","url","u","href","originalPushState","appOrigin","isInIframe","e","a","originalFetch","input","init","newUrl","useCallback","useEffect","useRef","useState","DEFAULT_MOCK_CONFIG","mockState","initializeMockOpenAI","initialToolOutput","mode","updateMockGlobal","name","args","prompt","href","state","SetGlobalsEvent","key","value","getMockState","updateMockToolOutput","props","updateMockDisplayMode","updateMockTheme","theme","Fragment","jsx","jsxs","MOCK_SAFE_AREA_HEIGHT","DevIcon","className","CloseIcon","InlineIcon","PipIcon","FullscreenIcon","SunIcon","MoonIcon","ResetIcon","panelAnimationStyles","DevModeProvider","defaultProps","widgetPaths","children","isInitialized","setIsInitialized","useState","isWidgetPage","setIsWidgetPage","useEffect","currentPath","isWidget","path","initializeMockOpenAI","WidgetPreviewFrame","DevControls","SegmentedControl","options","value","onChange","activeIndex","opt","option","isOpen","setIsOpen","isAnimating","setIsAnimating","shouldRender","setShouldRender","displayMode","setDisplayMode","theme","setTheme","showSafeArea","setShowSafeArea","propsJson","setPropsJson","jsonError","setJsonError","debounceRef","useRef","panelRef","containerRef","state","getMockState","SetGlobalsEvent","openPanel","useCallback","closePanel","togglePanel","handleKeyDown","e","handleClickOutside","handleDisplayModeChange","mode","updateMockDisplayMode","handleThemeChange","newTheme","updateMockTheme","applyProps","json","parsed","updateMockToolOutput","handlePropsChange","handlePropsBlur","handleReset","defaultJson","displayModeOptions","themeOptions","useCallback","React","createContext","useCallback","useContext","useEffect","useState","useSyncExternalStore","createWidgetClient","detectPlatform","OpenAIWidgetClient","MCPAppsWidgetClient","WidgetClientContext","createContext","WidgetProvider","children","loading","onError","client","setClient","useState","error","setError","isConnecting","setIsConnecting","useEffect","mounted","initClient","widgetClient","createWidgetClient","err","syncTheme","theme","React","useWidgetClient","key","useContext","subscribe","useCallback","onChange","getSnapshot","store","useSyncExternalStore","useCallTool","client","useWidgetClient","useCallback","name","args","useDisplayMode","useWidgetClient","useSyncExternalStore","useIsChatGptApp","useLocale","useWidgetClient","useMaxHeight","useWidgetClient","useCallback","useOpenExternal","client","useWidgetClient","useCallback","url","useCallback","useRequestDisplayMode","client","useWidgetClient","useCallback","mode","useSafeArea","useWidgetClient","useCallback","useSendFollowUp","client","useWidgetClient","useCallback","prompt","useTheme","useWidgetClient","useToolOutput","useWidgetClient","useToolResponseMetadata","useWidgetClient","useCallback","useEffect","useState","useWidgetState","defaultState","widgetStateFromWindow","useWidgetClient","widgetState","_setWidgetState","useState","useEffect","setWidgetState","useCallback","state","prevState","newState","detectPlatform","jsx","jsxs","LoadingWidget"]}
|