@autoai-ui/autoui 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/autoui.css +1 -0
  2. package/dist/index.cjs +286 -40
  3. package/dist/index.mjs +3947 -2628
  4. package/dist/lib/index.d.ts +1 -0
  5. package/dist/lib/plugin.d.ts +2 -0
  6. package/dist/plugin.cjs +42160 -0
  7. package/dist/plugin.d.ts +2 -0
  8. package/dist/plugin.mjs +223418 -0
  9. package/package.json +14 -4
  10. package/dist/lib/bin/index.d.ts +0 -1
  11. package/dist/lib/components/chat/context/chatContext.d.ts +0 -3
  12. package/dist/lib/components/chat/context/modalChatContext.d.ts +0 -9
  13. package/dist/lib/components/chat/hooks/useAutoUiChat.d.ts +0 -4
  14. package/dist/lib/components/chat/hooks/useChat.d.ts +0 -3
  15. package/dist/lib/components/chat/hooks/useChatState.d.ts +0 -7
  16. package/dist/lib/components/chat/hooks/useRendering.d.ts +0 -7
  17. package/dist/lib/components/chat/hooks/useSpeechToText.d.ts +0 -9
  18. package/dist/lib/components/chat/hooks/useTheme.d.ts +0 -6
  19. package/dist/lib/components/chat/index.d.ts +0 -2
  20. package/dist/lib/components/chat/types/index.d.ts +0 -114
  21. package/dist/lib/components/chat/ui/Chat.d.ts +0 -3
  22. package/dist/lib/components/chat/ui/ChatHeader.d.ts +0 -1
  23. package/dist/lib/components/chat/ui/ChatInput.d.ts +0 -4
  24. package/dist/lib/components/chat/ui/ChatMenu.d.ts +0 -1
  25. package/dist/lib/components/chat/ui/ChatMessageList.d.ts +0 -3
  26. package/dist/lib/components/chat/ui/ChatMessageListItem.d.ts +0 -6
  27. package/dist/lib/components/chat/ui/ChatTextBox.d.ts +0 -5
  28. package/dist/lib/components/chat/ui/MicButton.d.ts +0 -4
  29. package/dist/lib/components/chat/ui/ModalChat.d.ts +0 -2
  30. package/dist/lib/components/chat/ui/ScrollToBottomButton.d.ts +0 -7
  31. package/dist/lib/components/chat/ui/SendButton.d.ts +0 -1
  32. package/dist/lib/components/chat/ui/btnOpenChat/index.d.ts +0 -3
  33. package/dist/lib/components/index.d.ts +0 -2
  34. package/dist/lib/components/menu/index.d.ts +0 -1
  35. package/dist/lib/components/menu/ui/Menu.d.ts +0 -6
  36. package/dist/lib/components/menu/ui/MenuItem.d.ts +0 -16
  37. package/dist/lib/components/menu/ui/MenuSelectedIcon.d.ts +0 -4
  38. package/dist/lib/components/popover/index.d.ts +0 -2
  39. package/dist/lib/components/popover/ui/Popover.d.ts +0 -10
  40. package/dist/lib/components/popover/ui/PopoverMenu.d.ts +0 -10
  41. package/dist/lib/components/spinner/index.d.ts +0 -1
  42. package/dist/lib/components/spinner/ui/Spinner.d.ts +0 -16
  43. package/dist/lib/components/switch/index.d.ts +0 -1
  44. package/dist/lib/components/switch/ui/Switch.d.ts +0 -30
  45. package/dist/lib/core/buildDataAnalyzingPrompt.d.ts +0 -3
  46. package/dist/lib/core/buildIntentPrompt.d.ts +0 -2
  47. package/dist/lib/core/extraDataAnalyzingWithLLM.d.ts +0 -3
  48. package/dist/lib/core/index.d.ts +0 -1
  49. package/dist/lib/core/llmClient.d.ts +0 -3
  50. package/dist/lib/core/sseParser.d.ts +0 -1
  51. package/dist/lib/runtime/index.d.ts +0 -1
  52. package/dist/lib/runtime/rerenderChatFromHistory.d.ts +0 -3
  53. package/dist/lib/runtime/runtimeEngine.d.ts +0 -9
  54. package/dist/lib/runtime/stepExecutor.d.ts +0 -7
  55. package/dist/lib/types/index.d.ts +0 -79
  56. package/dist/lib/types/llmTypes.d.ts +0 -21
  57. package/dist/lib/utils/clsx.d.ts +0 -1
  58. package/dist/lib/utils/debounce.d.ts +0 -11
  59. package/dist/lib/utils/index.d.ts +0 -1
  60. package/dist/lib/utils/resolveProps.d.ts +0 -2
  61. package/dist/stats.html +0 -4949
package/dist/index.cjs CHANGED
@@ -1,60 +1,306 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(".spinner-base{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;background-color:transparent;position:absolute;bottom:0;left:50%;transform:translate(-50%)}.spinner-label{margin-top:.5rem;font-size:14px;color:#666}.spinner-dots-wrapper{display:flex;gap:6px}.spinner-dot{width:8px;height:8px;border-radius:50%;animation:bounce .6s infinite ease-in-out}@keyframes bounce{0%,80%,to{transform:scale(.4)}40%{transform:scale(1)}}.spinner-simple{animation:spin 1s linear infinite}.spinner-simple-circle1{opacity:.25}.spinner-simple-circle2{opacity:.75}@keyframes spin{to{transform:rotate(360deg)}}.spinner-bars-wrapper{position:relative;width:24px;height:24px}.spinner-bar{position:absolute;left:50%;top:50%;width:3px;height:6px;opacity:.2;animation:pulse 1s infinite linear;transform-origin:center}@keyframes pulse{0%,20%{opacity:1}to{opacity:.2}}.spinner-default{position:relative;width:32px;height:32px}.spinner-default-circle1,.spinner-default-circle2{position:absolute;inset:0;border-width:4px;border-style:solid;border-radius:50%}.spinner-default-circle1{opacity:.25}.spinner-default-circle2{border-top-color:transparent!important;animation:spin 1s linear infinite}:root{--hero-bg: #ffffff;--hero-text: #111111;--hero-hover: rgba(0, 0, 0, .05);--hero-selected: rgba(0, 0, 0, .07);--hero-muted: rgba(0, 0, 0, .6);--hero-accent: #007aff}[data-theme=dark]{--hero-bg: #2c2c2e;--hero-text: #f2f2f7;--hero-hover: rgba(255, 255, 255, .06);--hero-selected: rgba(255, 255, 255, .1);--hero-muted: rgba(255, 255, 255, .6);--hero-accent: #0a84ff}.hero-menu{list-style:none;padding:6px;margin:0;width:240px;background:var(--hero-bg);color:var(--hero-text);border-radius:10px}.hero-menu-item{display:flex;align-items:center;padding:8px 10px;gap:10px;cursor:pointer;border-radius:8px;-webkit-user-select:none;-moz-user-select:none;user-select:none;transition:background .15s ease}.content .label{display:flex;align-items:center}.hero-menu-item:hover{background:var(--hero-hover)}.hero-menu-item.selected{background:var(--hero-selected);font-weight:500}.hero-menu-item.disabled{opacity:.4;pointer-events:none}.hero-menu-item .content{flex:1;display:flex;flex-direction:column}.hero-menu-item .description{font-size:12px;margin-top:-2px;color:var(--hero-muted)}.hero-menu-item .shortcut{font-size:12px;color:var(--hero-muted)}.selected-icon svg{width:16px;height:16px;color:var(--hero-accent)}.autoui-switch{--sw-track-off: color-mix(in srgb, var(--autoui-border, #e5e5e5) 85%, transparent);--sw-track-on: var(--autoui-accent, #007aff);--sw-thumb: var(--autoui-bg, #fff);--sw-ring: color-mix(in srgb, var(--autoui-accent, #007aff) 35%, transparent);--sw-text: var(--autoui-text, #111);display:inline-flex;align-items:center;gap:10px;-webkit-user-select:none;-moz-user-select:none;user-select:none;color:var(--sw-text)}.autoui-switch.is-disabled{opacity:.5;pointer-events:none}.autoui-switch__control{position:relative;display:inline-flex;align-items:center}.autoui-switch__input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}.autoui-switch__track{display:block;border-radius:999px;background:var(--sw-track-off);transition:background .16s ease;box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--autoui-border, #e5e5e5) 55%,transparent)}.autoui-switch__thumb{position:absolute;top:50%;transform:translateY(-50%);border-radius:999px;background:var(--sw-thumb);display:grid;place-items:center;transition:left .16s ease,width .16s ease,height .16s ease,transform .16s ease;box-shadow:0 2px 8px #0000002e,inset 0 0 0 1px color-mix(in srgb,var(--autoui-border, #e5e5e5) 45%,transparent)}.autoui-switch__thumbContent{display:inline-flex;align-items:center;justify-content:center;line-height:0}.autoui-switch__input:focus-visible~.autoui-switch__track{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--autoui-border, #e5e5e5) 55%,transparent),0 0 0 4px var(--sw-ring)}.autoui-switch__input:checked~.autoui-switch__track{background:var(--sw-track-on)}.autoui-switch--sm .autoui-switch__track{width:36px;height:20px}.autoui-switch--sm .autoui-switch__thumb{width:16px;height:16px;left:2px}.autoui-switch--sm .autoui-switch__input:checked~.autoui-switch__thumb{left:18px}.autoui-switch--md .autoui-switch__track{width:44px;height:24px}.autoui-switch--md .autoui-switch__thumb{width:20px;height:20px;left:2px}.autoui-switch--md .autoui-switch__input:checked~.autoui-switch__thumb{left:22px}.autoui-switch--lg .autoui-switch__track{width:54px;height:30px}.autoui-switch--lg .autoui-switch__thumb{width:26px;height:26px;left:2px}.autoui-switch--lg .autoui-switch__input:checked~.autoui-switch__thumb{left:26px}.autoui-switch__text{display:flex;flex-direction:column;gap:2px;min-width:0}.autoui-switch__label{display:flex;align-items:center;font-weight:600}.autoui-switch__description{font-size:12px;opacity:.7}:root{--autoui-bg: #ffffff;--autoui-bg-alt: #f4f4f5;--autoui-text: #111111;--autoui-accent: #007aff;--autoui-border: #e5e5e5;--icon-filter-text: invert(0%);--icon-filter-accent: invert(77%) sepia(82%) saturate(1012%) hue-rotate(359deg) brightness(103%) contrast(103%)}[data-theme=dark]{--autoui-bg: #1c1c1e;--autoui-bg-alt: #2c2c2e;--autoui-text: #f2f2f7;--autoui-accent: #004d99;--autoui-border: #3a3a3c;--icon-filter-text: invert(100%);--icon-filter-accent: invert(77%) sepia(82%) saturate(1012%) hue-rotate(359deg) brightness(103%) contrast(103%)}.autoui-chat{background:var(--autoui-bg);color:var(--autoui-text);border:1px solid var(--autoui-border);border-radius:1rem;display:flex;flex-direction:column;width:400px;height:560px;font-family:system-ui,sans-serif}.autoui-chat-header{background:var(--autoui-bg-alt);padding:.75rem 1rem;border-bottom:1px solid var(--autoui-border);display:flex;justify-content:space-between;align-items:center;border-top-left-radius:1rem;border-top-right-radius:1rem}.autoui-chat-title{font-size:1rem;display:flex;color:var(--autoui-text);align-items:center;font-weight:600;margin:0}.autoui-chat-closebtn{width:2rem;height:2rem!important;display:flex;justify-content:center;border:none;cursor:pointer;font-size:1rem;fill:var(--autoui-text);color:var(--autoui-text);background-color:transparent;align-items:center;border-radius:100%}.autoui-chat-messages{position:relative;flex:1;overflow-y:auto;padding:0 .5rem;display:flex;flex-direction:column;gap:.5rem;scroll-behavior:smooth}.autoui-chat-messages-wrapper{padding:.5rem 0}[data-testid=virtuoso-item-list]{padding-right:.5rem!important}.autoui-chat-messages::-webkit-scrollbar{width:8px}.autoui-chat-messages::-webkit-scrollbar-track{background:transparent}.autoui-chat-messages::-webkit-scrollbar-thumb{background:linear-gradient(180deg,#444,#666);border-radius:6px;-webkit-transition:background .3s ease;transition:background .3s ease}.autoui-chat-messages::-webkit-scrollbar-thumb:hover{background:linear-gradient(180deg,#555,#777)}.autoui-chat-messages{scrollbar-width:thin;scrollbar-color:#555 transparent}.autoui-message-row{padding:.6rem 0}.autoui-message-row.is-user{justify-self:flex-end;display:flex;justify-content:flex-end}.autoui-chat-bubble{background:var(--autoui-bg-alt);padding:.5rem .75rem;border-radius:16px;max-width:80%;word-break:break-word}.autoui-chat-message.assistant .autoui-chat-bubble:has(>div[class*=w-full]){max-width:100%;width:100%;background:transparent}.autoui-chat-bubble>div[class*=w-full]{max-width:100%;width:100%;min-width:0}.autoui-chat-bubble--react-node{background:transparent;padding:0}.autoui-chat-message.user .autoui-chat-bubble{background:var(--autoui-accent);color:#fff;justify-content:flex-end;justify-self:flex-end}.autoui-chat-input{width:100%;display:flex;position:relative;background:transparent;padding:.5rem;gap:.5rem}.autoui-chat-textbox{flex:1;border:1px solid var(--autoui-border);border-radius:1rem;width:100%;padding:.5rem 5rem .5rem 2rem;background:var(--autoui-bg);color:var(--autoui-text);outline:none;transition:border-color .25s ease,box-shadow .25s ease}.autoui-chat-textbox:focus{border-color:color-mix(in srgb,var(--autoui-accent, #4a8cff) 45%,transparent);box-shadow:0 0}.autoui-chat-send{background:transparent;border:none;color:color-mix(in srgb,var(--autoui-accent, #4a8cff) 45%,transparent);border-radius:100%;display:flex;justify-content:center;align-items:center;box-shadow:0 2px 4px #00000014,0 6px 12px #0000000f;cursor:pointer;position:absolute!important;right:.9rem;top:20%;width:2rem;height:2rem;font-size:1rem}[data-theme=dark] .autoui-chat-send{box-shadow:0 2px 4px #00000073,0 6px 12px #00000059}.autoui-chat-messages>div{scrollbar-width:thin;scrollbar-color:color-mix(in srgb,var(--autoui-border) 40%,transparent) transparent}.autoui-chat-messages>div::-webkit-scrollbar{width:6px;padding-right:8px;padding-ещз:8px}.autoui-chat-messages>div::-webkit-scrollbar-track{background:transparent}.autoui-chat-messages>div::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--autoui-border) 50%,transparent);border-radius:8px;-webkit-transition:background .2s ease;transition:background .2s ease}.autoui-chat-messages>div::-webkit-scrollbar-thumb:hover{background:color-mix(in srgb,var(--autoui-accent) 40%,var(--autoui-border))}.autoui-chat-send img{height:1.5rem;color:var(--autoui-accent)}.autoui-chat-send:hover{opacity:.9}.autoui-chat-open-btn{width:50px;height:50px;border-radius:50%;border:1px solid var(--autoui-border);background:#fff;cursor:pointer;font-size:1rem;display:flex;align-items:center;justify-content:center;box-shadow:0 2px 4px #0000001a;transition:all .2s ease;position:fixed;bottom:1.75rem;right:1.75rem;background:var(--autoui-bg);color:var(--autoui-text);z-index:999}.autoui-chat-open-btn:hover{background:var(--autoui-accent);color:#fff;transform:translateY(-2px)}.autoui-chat-open-btn:active{transform:translateY(0);opacity:.9}.autoui-chat-input-start{width:1.5rem;height:1.5rem;left:1rem;position:absolute;top:30%}.autoui-chat-portal{position:fixed;right:4rem;bottom:4rem;z-index:1000;display:flex;justify-content:flex-end;align-items:flex-end;background:transparent}.autoui-chat-wrapper{pointer-events:auto;margin:1rem;width:full;max-height:600px;background:var(--autoui-bg);border-radius:16px;box-shadow:0 8px 24px #00000026;transform:translateY(20px);opacity:0;animation:autoui-slide-up .25s ease forwards}@keyframes autoui-slide-up{0%{transform:translateY(20px);opacity:0}to{transform:translateY(0);opacity:1}}@media(max-width:520px){.autoui-chat-portal{position:fixed;inset:0;margin:0;padding:0;z-index:1000;display:flex;justify-content:center;align-items:flex-end;pointer-events:auto!important}.autoui-chat-wrapper{width:100vw!important;height:100vh!important;max-height:none;max-width:none;margin:0!important;border-radius:0!important;box-shadow:none!important}.autoui-chat{width:100vw!important;height:100vh!important;max-width:none;max-height:none;border-radius:0!important}}.empty__palceholder{display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:100%}.empty__palceholder--main{font-size:1.2rem}.empty__palceholder--secondary{font-size:.8rem}.autoui-icon{width:16px;height:16px;color:red}.chat-scroll-bottom{position:absolute;right:1.5rem;bottom:1.5rem;display:flex;justify-content:center;align-items:center;width:2.5rem;height:2.5rem;border-radius:100%;border:none;background:var(--autoui-bg);color:var(--autoui-text);font-size:1.2rem;cursor:pointer;box-shadow:0 4px 12px #0003;transition:transform .15s ease,opacity .15s ease}.chat-scroll-bottom:hover{transform:translateY(-2px)}.chat-mic-btn{position:absolute;right:3.2rem;top:50%;transform:translateY(-50%);width:2rem;height:2rem;border-radius:50%;display:flex;align-items:center;justify-content:center;background:transparent;border:none;cursor:pointer;transition:opacity .2s ease,background .2s ease,transform .2s ease}.chat-mic-btn:hover{opacity:.9;background:color-mix(in srgb,var(--autoui-accent) 12%,transparent)}.chat-mic-btn img{width:20px;height:20px;filter:var(--icon-filter-text);transition:filter .2s ease}.chat-mic-btn.is-active{opacity:1;background:color-mix(in srgb,var(--autoui-accent) 20%,transparent);animation:mic-pulse 1.2s ease-in-out infinite}@keyframes mic-pulse{0%{box-shadow:0 0 color-mix(in srgb,var(--autoui-accent) 40%,transparent)}70%{box-shadow:0 0 0 8px color-mix(in srgb,var(--autoui-accent) 0%,transparent)}to{box-shadow:0 0 0 0 transparent}}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react"),zn=require("react-dom");function To(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const kt=To(x);var gt={exports:{}},tt={};var sn;function bo(){if(sn)return tt;sn=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(o,r,s){var i=null;if(s!==void 0&&(i=""+s),r.key!==void 0&&(i=""+r.key),"key"in r){s={};for(var l in r)l!=="key"&&(s[l]=r[l])}else s=r;return r=s.ref,{$$typeof:e,type:o,key:i,ref:r!==void 0?r:null,props:s}}return tt.Fragment=t,tt.jsx=n,tt.jsxs=n,tt}var nt={};var ln;function yo(){return ln||(ln=1,process.env.NODE_ENV!=="production"&&(function(){function e(w){if(w==null)return null;if(typeof w=="function")return w.$$typeof===H?null:w.displayName||w.name||null;if(typeof w=="string")return w;switch(w){case v:return"Fragment";case h:return"Profiler";case f:return"StrictMode";case M:return"Suspense";case d:return"SuspenseList";case k:return"Activity"}if(typeof w=="object")switch(typeof w.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),w.$$typeof){case E:return"Portal";case P:return w.displayName||"Context";case b:return(w._context.displayName||"Context")+".Consumer";case z:var L=w.render;return w=w.displayName,w||(w=L.displayName||L.name||"",w=w!==""?"ForwardRef("+w+")":"ForwardRef"),w;case C:return L=w.displayName||null,L!==null?L:e(w.type)||"Memo";case y:L=w._payload,w=w._init;try{return e(w(L))}catch{}}return null}function t(w){return""+w}function n(w){try{t(w);var L=!1}catch{L=!0}if(L){L=console;var J=L.error,Q=typeof Symbol=="function"&&Symbol.toStringTag&&w[Symbol.toStringTag]||w.constructor.name||"Object";return J.call(L,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",Q),t(w)}}function o(w){if(w===v)return"<>";if(typeof w=="object"&&w!==null&&w.$$typeof===y)return"<...>";try{var L=e(w);return L?"<"+L+">":"<...>"}catch{return"<...>"}}function r(){var w=F.A;return w===null?null:w.getOwner()}function s(){return Error("react-stack-top-frame")}function i(w){if(D.call(w,"key")){var L=Object.getOwnPropertyDescriptor(w,"key").get;if(L&&L.isReactWarning)return!1}return w.key!==void 0}function l(w,L){function J(){X||(X=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",L))}J.isReactWarning=!0,Object.defineProperty(w,"key",{get:J,configurable:!0})}function a(){var w=e(this.type);return K[w]||(K[w]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),w=this.props.ref,w!==void 0?w:null}function c(w,L,J,Q,Be,Me){var ee=J.ref;return w={$$typeof:R,type:w,key:L,props:J,_owner:Q},(ee!==void 0?ee:null)!==null?Object.defineProperty(w,"ref",{enumerable:!1,get:a}):Object.defineProperty(w,"ref",{enumerable:!1,value:null}),w._store={},Object.defineProperty(w._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(w,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(w,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Be}),Object.defineProperty(w,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Me}),Object.freeze&&(Object.freeze(w.props),Object.freeze(w)),w}function u(w,L,J,Q,Be,Me){var ee=L.children;if(ee!==void 0)if(Q)if(A(ee)){for(Q=0;Q<ee.length;Q++)g(ee[Q]);Object.freeze&&Object.freeze(ee)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else g(ee);if(D.call(L,"key")){ee=e(w);var j=Object.keys(L).filter(function(oe){return oe!=="key"});Q=0<j.length?"{key: someKey, "+j.join(": ..., ")+": ...}":"{key: someKey}",Ce[ee+Q]||(j=0<j.length?"{"+j.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react"),_o=require("react-dom");function Mn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const Mt=Mn(C);var xt={exports:{}},ot={};var fo;function Vn(){if(fo)return ot;fo=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(n,r,s){var a=null;if(s!==void 0&&(a=""+s),r.key!==void 0&&(a=""+r.key),"key"in r){s={};for(var i in r)i!=="key"&&(s[i]=r[i])}else s=r;return r=s.ref,{$$typeof:e,type:n,key:a,ref:r!==void 0?r:null,props:s}}return ot.Fragment=t,ot.jsx=o,ot.jsxs=o,ot}var nt={};var mo;function Nn(){return mo||(mo=1,process.env.NODE_ENV!=="production"&&(function(){function e(I){if(I==null)return null;if(typeof I=="function")return I.$$typeof===j?null:I.displayName||I.name||null;if(typeof I=="string")return I;switch(I){case w:return"Fragment";case d:return"Profiler";case y:return"StrictMode";case E:return"Suspense";case f:return"SuspenseList";case A:return"Activity"}if(typeof I=="object")switch(typeof I.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),I.$$typeof){case x:return"Portal";case T:return I.displayName||"Context";case g:return(I._context.displayName||"Context")+".Consumer";case b:var _=I.render;return I=I.displayName,I||(I=_.displayName||_.name||"",I=I!==""?"ForwardRef("+I+")":"ForwardRef"),I;case v:return _=I.displayName||null,_!==null?_:e(I.type)||"Memo";case k:_=I._payload,I=I._init;try{return e(I(_))}catch{}}return null}function t(I){return""+I}function o(I){try{t(I);var _=!1}catch{_=!0}if(_){_=console;var G=_.error,K=typeof Symbol=="function"&&Symbol.toStringTag&&I[Symbol.toStringTag]||I.constructor.name||"Object";return G.call(_,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",K),t(I)}}function n(I){if(I===w)return"<>";if(typeof I=="object"&&I!==null&&I.$$typeof===k)return"<...>";try{var _=e(I);return _?"<"+_+">":"<...>"}catch{return"<...>"}}function r(){var I=N.A;return I===null?null:I.getOwner()}function s(){return Error("react-stack-top-frame")}function a(I){if(z.call(I,"key")){var _=Object.getOwnPropertyDescriptor(I,"key").get;if(_&&_.isReactWarning)return!1}return I.key!==void 0}function i(I,_){function G(){X||(X=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",_))}G.isReactWarning=!0,Object.defineProperty(I,"key",{get:G,configurable:!0})}function l(){var I=e(this.type);return Q[I]||(Q[I]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),I=this.props.ref,I!==void 0?I:null}function c(I,_,G,K,Le,Me){var ee=G.ref;return I={$$typeof:$,type:I,key:_,props:G,_owner:K},(ee!==void 0?ee:null)!==null?Object.defineProperty(I,"ref",{enumerable:!1,get:l}):Object.defineProperty(I,"ref",{enumerable:!1,value:null}),I._store={},Object.defineProperty(I._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(I,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(I,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Le}),Object.defineProperty(I,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Me}),Object.freeze&&(Object.freeze(I.props),Object.freeze(I)),I}function u(I,_,G,K,Le,Me){var ee=_.children;if(ee!==void 0)if(K)if(V(ee)){for(K=0;K<ee.length;K++)p(ee[K]);Object.freeze&&Object.freeze(ee)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else p(ee);if(z.call(_,"key")){ee=e(I);var P=Object.keys(_).filter(function(ne){return ne!=="key"});K=0<P.length?"{key: someKey, "+P.join(": ..., ")+": ...}":"{key: someKey}",ve[ee+K]||(P=0<P.length?"{"+P.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
3
2
  let props = %s;
4
3
  <%s {...props} />
5
4
  React keys must be passed directly to JSX without using spread:
6
5
  let props = %s;
7
- <%s key={someKey} {...props} />`,Q,ee,j,ee),Ce[ee+Q]=!0)}if(ee=null,J!==void 0&&(n(J),ee=""+J),i(L)&&(n(L.key),ee=""+L.key),"key"in L){J={};for(var G in L)G!=="key"&&(J[G]=L[G])}else J=L;return ee&&l(J,typeof w=="function"?w.displayName||w.name||"Unknown":w),c(w,ee,J,r(),Be,Me)}function g(w){p(w)?w._store&&(w._store.validated=1):typeof w=="object"&&w!==null&&w.$$typeof===y&&(w._payload.status==="fulfilled"?p(w._payload.value)&&w._payload.value._store&&(w._payload.value._store.validated=1):w._store&&(w._store.validated=1))}function p(w){return typeof w=="object"&&w!==null&&w.$$typeof===R}var S=x,R=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),P=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),k=Symbol.for("react.activity"),H=Symbol.for("react.client.reference"),F=S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=Object.prototype.hasOwnProperty,A=Array.isArray,V=console.createTask?console.createTask:function(){return null};S={react_stack_bottom_frame:function(w){return w()}};var X,K={},ve=S.react_stack_bottom_frame.bind(S,s)(),we=V(o(s)),Ce={};nt.Fragment=v,nt.jsx=function(w,L,J){var Q=1e4>F.recentlyCreatedOwnerStacks++;return u(w,L,J,!1,Q?Error("react-stack-top-frame"):ve,Q?V(o(w)):we)},nt.jsxs=function(w,L,J){var Q=1e4>F.recentlyCreatedOwnerStacks++;return u(w,L,J,!0,Q?Error("react-stack-top-frame"):ve,Q?V(o(w)):we)}})()),nt}var an;function Io(){return an||(an=1,process.env.NODE_ENV==="production"?gt.exports=bo():gt.exports=yo()),gt.exports}var m=Io();function On(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=On(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function xe(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=On(e))&&(o&&(o+=" "),o+=t);return o}const Ro=x.forwardRef(({variant:e="default",label:t,className:n,classNames:o={},color:r="currentColor",...s},i)=>{const l=x.useMemo(()=>{switch(e){case"wave":case"dots":return m.jsx("div",{className:xe("spinner-dots-wrapper",o.wrapper),children:[0,1,2].map(a=>m.jsx("i",{className:xe("spinner-dot",o.dots),style:{animationDelay:`${a*.2}s`,backgroundColor:r}},a))});case"simple":return m.jsxs("svg",{className:xe("spinner-simple",o.wrapper),width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",style:{color:r},children:[m.jsx("circle",{className:xe("spinner-simple-circle1",o.circle1),cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),m.jsx("path",{className:xe("spinner-simple-circle2",o.circle2),fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.37 0 0 5.37 0 12h4z"})]});case"spinner":return m.jsx("div",{className:xe("spinner-bars-wrapper",o.wrapper),children:[...Array(12)].map((a,c)=>m.jsx("i",{className:xe("spinner-bar",o.spinnerBars),style:{transform:`rotate(${c*30}deg) translateY(-8px)`,animationDelay:`${c*.1}s`,backgroundColor:r}},c))});default:return m.jsxs("div",{className:xe("spinner-default",o.wrapper),children:[m.jsx("i",{className:xe("spinner-default-circle1",o.circle1),style:{borderColor:r}}),m.jsx("i",{className:xe("spinner-default-circle2",o.circle2),style:{borderColor:r}})]})}},[e,o,r]);return m.jsxs("div",{ref:i,className:xe("spinner-base",n),"aria-label":t||"Loading",...s,children:[l,t&&m.jsx("span",{className:xe("spinner-label",o.label),children:t})]})}),Pn=x.createContext(void 0),Eo=({children:e,value:t,config:n})=>m.jsx(Pn.Provider,{value:{...t,config:n},children:e}),Ye=()=>{const e=x.useContext(Pn);if(!e)throw new Error("useChatContext must be used within a ChatProvider");return e};function Oe(...e){return e.filter(Boolean).join(" ")}const Hn="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2012H20M12%204V20'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Bn="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20640%20640'%3e%3c!--!Font%20Awesome%20Free%207.1.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license/free%20Copyright%202025%20Fonticons,%20Inc.--%3e%3cpath%20d='M183.1%20137.4C170.6%20124.9%20150.3%20124.9%20137.8%20137.4C125.3%20149.9%20125.3%20170.2%20137.8%20182.7L275.2%20320L137.9%20457.4C125.4%20469.9%20125.4%20490.2%20137.9%20502.7C150.4%20515.2%20170.7%20515.2%20183.2%20502.7L320.5%20365.3L457.9%20502.6C470.4%20515.1%20490.7%20515.1%20503.2%20502.6C515.7%20490.1%20515.7%20469.8%20503.2%20457.3L365.8%20320L503.1%20182.6C515.6%20170.1%20515.6%20149.8%20503.1%20137.3C490.6%20124.8%20470.3%20124.8%20457.8%20137.3L320.5%20274.7L183.1%20137.4z'/%3e%3c/svg%3e",Mn="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%206V18M12%206L7%2011M12%206L17%2011'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",ko="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2018L20%2018'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M4%2012L20%2012'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M4%206L20%206'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'/%3e%3c/svg%3e",jo="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%201024%201024'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill='%23000000'%20d='M352%20192V95.936a32%2032%200%200%201%2032-32h256a32%2032%200%200%201%2032%2032V192h256a32%2032%200%201%201%200%2064H96a32%2032%200%200%201%200-64h256zm64%200h192v-64H416v64zM192%20960a32%2032%200%200%201-32-32V256h704v672a32%2032%200%200%201-32%2032H192zm224-192a32%2032%200%200%200%2032-32V416a32%2032%200%200%200-64%200v320a32%2032%200%200%200%2032%2032zm192%200a32%2032%200%200%200%2032-32V416a32%2032%200%200%200-64%200v320a32%2032%200%200%200%2032%2032z'/%3e%3c/svg%3e",zo="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20640%20640'%3e%3c!--!Font%20Awesome%20Free%207.1.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license/free%20Copyright%202025%20Fonticons,%20Inc.--%3e%3cpath%20d='M210.2%2053.9C217.6%2050.8%20226%2051.7%20232.7%2056.1L320.5%20114.3L408.3%2056.1C415%2051.7%20423.4%2050.9%20430.8%2053.9C438.2%2056.9%20443.4%2063.5%20445%2071.3L465.9%20174.5L569.1%20195.4C576.9%20197%20583.5%20202.4%20586.5%20209.7C589.5%20217%20588.7%20225.5%20584.3%20232.2L526.1%20320L584.3%20407.8C588.7%20414.5%20589.5%20422.9%20586.5%20430.3C583.5%20437.7%20576.9%20443.1%20569.1%20444.6L465.8%20465.4L445%20568.7C443.4%20576.5%20438%20583.1%20430.7%20586.1C423.4%20589.1%20414.9%20588.3%20408.2%20583.9L320.4%20525.7L232.6%20583.9C225.9%20588.3%20217.5%20589.1%20210.1%20586.1C202.7%20583.1%20197.3%20576.5%20195.8%20568.7L175%20465.4L71.7%20444.5C63.9%20442.9%2057.3%20437.5%2054.3%20430.2C51.3%20422.9%2052.1%20414.4%2056.5%20407.7L114.7%20320L56.5%20232.2C52.1%20225.5%2051.3%20217.1%2054.3%20209.7C57.3%20202.3%2063.9%20196.9%2071.7%20195.4L175%20174.6L195.9%2071.3C197.5%2063.5%20202.9%2056.9%20210.2%2053.9zM239.6%20320C239.6%20275.6%20275.6%20239.6%20320%20239.6C364.4%20239.6%20400.4%20275.6%20400.4%20320C400.4%20364.4%20364.4%20400.4%20320%20400.4C275.6%20400.4%20239.6%20364.4%20239.6%20320zM448.4%20320C448.4%20249.1%20390.9%20191.6%20320%20191.6C249.1%20191.6%20191.6%20249.1%20191.6%20320C191.6%20390.9%20249.1%20448.4%20320%20448.4C390.9%20448.4%20448.4%20390.9%20448.4%20320z'/%3e%3c/svg%3e",Oo="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20640%20640'%3e%3c!--!Font%20Awesome%20Free%207.1.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license/free%20Copyright%202025%20Fonticons,%20Inc.--%3e%3cpath%20d='M320%2064C178.6%2064%2064%20178.6%2064%20320C64%20461.4%20178.6%20576%20320%20576C388.8%20576%20451.3%20548.8%20497.3%20504.6C504.6%20497.6%20506.7%20486.7%20502.6%20477.5C498.5%20468.3%20488.9%20462.6%20478.8%20463.4C473.9%20463.8%20469%20464%20464%20464C362.4%20464%20280%20381.6%20280%20280C280%20207.9%20321.5%20145.4%20382.1%20115.2C391.2%20110.7%20396.4%20100.9%20395.2%2090.8C394%2080.7%20386.6%2072.5%20376.7%2070.3C358.4%2066.2%20339.4%2064%20320%2064z'/%3e%3c/svg%3e",Po="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20640%20640'%3e%3c!--!Font%20Awesome%20Free%207.1.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license/free%20Copyright%202025%20Fonticons,%20Inc.--%3e%3cpath%20d='M320%2064C267%2064%20224%20107%20224%20160L224%20288C224%20341%20267%20384%20320%20384C373%20384%20416%20341%20416%20288L416%20160C416%20107%20373%2064%20320%2064zM176%20248C176%20234.7%20165.3%20224%20152%20224C138.7%20224%20128%20234.7%20128%20248L128%20288C128%20385.9%20201.3%20466.7%20296%20478.5L296%20528L248%20528C234.7%20528%20224%20538.7%20224%20552C224%20565.3%20234.7%20576%20248%20576L392%20576C405.3%20576%20416%20565.3%20416%20552C416%20538.7%20405.3%20528%20392%20528L344%20528L344%20478.5C438.7%20466.7%20512%20385.9%20512%20288L512%20248C512%20234.7%20501.3%20224%20488%20224C474.7%20224%20464%20234.7%20464%20248L464%20288C464%20367.5%20399.5%20432%20320%20432C240.5%20432%20176%20367.5%20176%20288L176%20248z'/%3e%3c/svg%3e",Ho=({isOpen:e,onClose:t,triggerRef:n,children:o,styles:r,position:s="top-center"})=>{const i=x.useRef(null);if(x.useEffect(()=>{const c=u=>{i.current&&!i.current.contains(u.target)&&!n.current?.contains(u.target)&&t()};return e&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[e,t,n]),!e||!n.current)return null;const l=n.current.getBoundingClientRect();let a={};switch(s){case"top-center":a={width:"50%",transform:"translate(-2.5%, -110%)"};break;case"bottom-left":a={top:l.bottom+6+window.scrollY,left:l.left+window.scrollX};break;case"bottom-right":a={top:l.bottom+6+window.scrollY,left:l.right+window.scrollX,transform:"translateX(-100%)"};break}return m.jsx("div",{ref:i,style:{position:"absolute",zIndex:9999,...a,...r},children:o})};function Bo({isSelected:e,disableAnimation:t,...n}){return m.jsx("svg",{"aria-hidden":"true","data-selected":e,role:"presentation",viewBox:"0 0 17 18",...n,children:m.jsx("polyline",{fill:"none",points:"1 9 7 14 15 4",stroke:"currentColor",strokeDasharray:22,strokeDashoffset:e?44:66,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,style:t?{}:{transition:"stroke-dashoffset 200ms ease"}})})}const Mo=({label:e,description:t,shortcut:n,startContent:o,endContent:r,isSelected:s,isDisabled:i,onSelect:l,disableAnimation:a,hideSelectedIcon:c,selectedIcon:u})=>{const g=x.useMemo(()=>{const p=m.jsx(Bo,{disableAnimation:a,isSelected:!!s});return typeof u=="function"?u({icon:p,isSelected:s,isDisabled:i}):u||p},[u,s,i,a]);return m.jsxs("li",{className:`hero-menu-item ${s?"selected":""} ${i?"disabled":""}`,onClick:()=>{console.log(1),!i&&l?.()},children:[o&&m.jsx("span",{className:"start",children:o}),m.jsxs("div",{className:"content",children:[m.jsx("span",{className:"label",children:e}),t&&m.jsx("span",{className:"description",children:t})]}),n&&m.jsx("kbd",{className:"shortcut",children:n}),!c&&m.jsx("span",{className:"selected-icon",children:g}),r&&m.jsx("span",{className:"end",children:r})]})},Ao=({items:e,defaultSelectedKey:t,onSelectionChange:n})=>{const[o,r]=x.useState(t),s=i=>{r(i),n?.(i)};return m.jsx("ul",{className:"hero-menu",children:e.map(i=>m.jsx(Mo,{label:i.label,description:i.description,shortcut:i.shortcut,startContent:i.startContent,endContent:i.endContent,isSelected:i.key===o,isDisabled:i.isDisabled,onSelect:()=>{i?.onSelect?.(),s(i.key)}},i.key))})},Lo=({items:e,button:t,popoverStyles:n,defaultSelectedKey:o,closeAfterSelect:r,onSelectionChange:s})=>{const i=x.useRef(null),[l,a]=x.useState(!1),c={ref:i,onClick:()=>{a(u=>!u)},style:{cursor:"pointer"}};return m.jsxs(m.Fragment,{children:[t?x.cloneElement(t,c):m.jsx("button",{ref:i,onClick:()=>a(u=>!u),style:{cursor:"pointer"},children:m.jsx("img",{src:ko,alt:"menu"})}),m.jsx(Ho,{styles:n,isOpen:l,onClose:()=>a(!1),triggerRef:i,children:m.jsx("div",{style:{borderRadius:10,zIndex:9999,boxShadow:"0 4px 12px rgba(0,0,0,0.12)"},children:m.jsx(Ao,{items:e,defaultSelectedKey:o,onSelectionChange:u=>{s?.(u),r?.(u)&&a(!1)}})})})]})},No=kt.forwardRef(function({checked:t,defaultChecked:n,onCheckedChange:o,disabled:r=!1,required:s=!1,name:i,value:l,id:a,label:c,description:u,size:g="md",className:p,trackClassName:S,thumbClassName:R,labelClassName:E,startContent:v,endContent:f,thumb:h,"aria-label":b,"aria-labelledby":P},z){const M=typeof t=="boolean",[d,C]=kt.useState(!!n),y=M?!!t:d,k=a??kt.useId(),H=D=>{const A=D.target.checked;M||C(A),o?.(A,D)},F=h?.({checked:y,disabled:r,size:g})??(y?f:v);return m.jsxs("label",{className:Oe("autoui-switch",`autoui-switch--${g}`,r&&"is-disabled",p),htmlFor:k,children:[m.jsxs("span",{className:Oe("autoui-switch__control",S),"aria-hidden":"true",children:[m.jsx("input",{ref:z,id:k,className:"autoui-switch__input",type:"checkbox",checked:y,defaultChecked:n,onChange:H,disabled:r,required:s,name:i,value:l,"aria-label":b,"aria-labelledby":P}),m.jsx("span",{className:Oe("autoui-switch__track")}),m.jsx("span",{className:Oe("autoui-switch__thumb",R),children:F?m.jsx("span",{className:"autoui-switch__thumbContent",children:F}):null})]}),(c||u)&&m.jsxs("span",{className:Oe("autoui-switch__text",E),children:[c&&m.jsx("span",{className:"autoui-switch__label",children:c}),u&&m.jsx("span",{className:"autoui-switch__description",children:u})]})]})}),_o=()=>{const{handleClear:e,setTheme:t,theme:n,mode:o}=Ye();return console.log(o),m.jsx(Lo,{popoverStyles:{position:"absolute"},button:m.jsx("button",{type:"button",className:"autoui-chat-input-start",children:m.jsx("img",{src:Hn,alt:"menu",width:20,height:20,style:{filter:"var(--icon-filter-text)"}})}),items:[{startContent:m.jsx("img",{src:jo,width:16,height:16,style:{filter:"var(--icon-filter-text)"}}),key:"clear",label:"Clear Messages",onSelect:e},{key:"switchTheme",label:m.jsx(No,{defaultChecked:n==="light",onCheckedChange:r=>{t?.(r?"light":"dark")},label:"Theme mode",thumb:({checked:r})=>m.jsx(m.Fragment,{children:r?m.jsx("img",{src:zo,width:14,height:14,style:{filter:"var(--icon-filter-accent)"}}):m.jsx("img",{src:Oo,width:14,height:14,style:{filter:"var(--icon-filter-text)"}})})})}],closeAfterSelect:r=>r!=="switchTheme",onSelectionChange:r=>console.log("Selected:",r)})},Fo=({value:e,setValue:t})=>{const{classNames:n}=Ye();return m.jsx("input",{role:"input",className:Oe("autoui-chat-textbox",n?.input),type:"text",value:e,autoFocus:!0,onChange:o=>t(o.target.value),placeholder:"Type a message...","aria-label":"Message input"})},Do=()=>{const{classNames:e}=Ye();return m.jsx("button",{role:"inputButton",type:"submit",className:Oe("autoui-chat-send",e?.inputButton),"aria-label":"Send message",children:m.jsx("img",{src:Mn,alt:"arrow up",width:24,height:24,style:{filter:"var(--icon-filter-text)"}})})},Wo=({lang:e="en-us"}={})=>{const t=x.useRef(null),[n,o]=x.useState(""),[r,s]=x.useState(!1),i=typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window),l=x.useCallback(()=>{if(!i||r)return;const c=window.SpeechRecognition||window.webkitSpeechRecognition;if(!c)return;const u=new c;u.lang=e,u.continuous=!1,u.interimResults=!1,u.onstart=()=>s(!0),u.onend=()=>s(!1),u.onresult=g=>{const p=g.results[0][0].transcript;o(p),s(!1)},u.onerror=()=>{u.stop(),s(!1)},t.current=u,u.start()},[i,r,e]),a=x.useCallback(()=>{t.current?.stop(),s(!1)},[]);return{start:l,stop:a,text:n,listening:r,isSupported:i}},Vo=({active:e,onClick:t})=>m.jsx("button",{type:"button",className:`chat-mic-btn ${e?"is-active":""}`,onClick:t,"aria-label":"Voice input",children:m.jsx("img",{src:Po,width:20,height:20,style:{filter:"var(--icon-filter-text)"}})}),$o=()=>{const{classNames:e,handleSend:t}=Ye(),[n,o]=x.useState(""),r=Wo({lang:"en-us"});x.useEffect(()=>{r.text&&o(i=>i?`${i} ${r.text}`:r.text)},[r.text]);const s=i=>{i.preventDefault(),t(n),o("")};return m.jsxs("form",{className:Oe("autoui-chat-input",e?.inputWrapper),onSubmit:s,children:[m.jsx(_o,{}),m.jsx(Fo,{value:n,setValue:o}),r.isSupported&&m.jsx(Vo,{active:r.listening,onClick:()=>{r.listening?r.stop():r.start()}}),m.jsx(Do,{})]})},Uo=({message:e})=>{const t=e.role==="user",{classNames:n}=Ye(),o=typeof e.content=="string"||e.content instanceof String;return m.jsx("div",{role:"message",className:xe("autoui-chat-message",t?"user":"assistant",n?.message),"aria-label":t?"User message":"Assistant message",children:m.jsx("div",{className:`autoui-chat-bubble ${o?"autoui-chat-bubble--string":"autoui-chat-bubble--react-node"}`,children:e.content})})},bt=0,De=1,Qe=2,An=4;function cn(e){return()=>e}function Go(e){e()}function Ln(e,t){return n=>e(t(n))}function un(e,t){return()=>e(t)}function Yo(e,t){return n=>e(t,n)}function Dt(e){return e!==void 0}function Jo(...e){return()=>{e.map(Go)}}function et(){}function yt(e,t){return t(e),e}function qo(e,t){return t(e)}function ie(...e){return e}function Z(e,t){return e(De,t)}function $(e,t){e(bt,t)}function Wt(e){e(Qe)}function ae(e){return e(An)}function B(e,t){return Z(e,Yo(t,bt))}function Pe(e,t){const n=e(De,o=>{n(),t(o)});return n}function dn(e){let t,n;return o=>r=>{t=r,n&&clearTimeout(n),n=setTimeout(()=>{o(t)},e)}}function Nn(e,t){return e===t}function se(e=Nn){let t;return n=>o=>{e(t,o)||(t=o,n(o))}}function _(e){return t=>n=>{e(n)&&t(n)}}function O(e){return t=>Ln(t,e)}function Ae(e){return t=>()=>{t(e)}}function T(e,...t){const n=Xo(...t);return(o,r)=>{switch(o){case Qe:Wt(e);return;case De:return Z(e,n(r))}}}function Le(e,t){return n=>o=>{n(t=e(t,o))}}function Ge(e){return t=>n=>{e>0?e--:t(n)}}function _e(e){let t=null,n;return o=>r=>{t=r,!n&&(n=setTimeout(()=>{n=void 0,o(t)},e))}}function U(...e){const t=new Array(e.length);let n=0,o=null;const r=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const l=Math.pow(2,i);Z(s,a=>{const c=n;n=n|l,t[i]=a,c!==r&&n===r&&o&&(o(),o=null)})}),s=>i=>{const l=()=>{s([i].concat(t))};n===r?l():o=l}}function Xo(...e){return t=>e.reduceRight(qo,t)}function Zo(e){let t,n;const o=()=>t?.();return function(r,s){switch(r){case De:return s?n===s?void 0:(o(),n=s,t=Z(e,s),t):(o(),et);case Qe:o(),n=null;return}}}function I(e){let t=e;const n=Y();return(o,r)=>{switch(o){case bt:t=r;break;case De:{r(t);break}case An:return t}return n(o,r)}}function Te(e,t){return yt(I(t),n=>B(e,n))}function Y(){const e=[];return(t,n)=>{switch(t){case bt:e.slice().forEach(o=>{o(n)});return;case Qe:e.splice(0,e.length);return;case De:return e.push(n),()=>{const o=e.indexOf(n);o>-1&&e.splice(o,1)}}}}function Re(e){return yt(Y(),t=>B(e,t))}function q(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Ko(),singleton:n}}const Ko=()=>Symbol();function Qo(e){const t=new Map,n=({constructor:o,dependencies:r,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const l=o(r.map(a=>n(a)));return i&&t.set(s,l),l};return n(e)}function de(...e){const t=Y(),n=new Array(e.length);let o=0;const r=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const l=Math.pow(2,i);Z(s,a=>{n[i]=a,o=o|l,o===r&&$(t,n)})}),function(s,i){switch(s){case Qe:{Wt(t);return}case De:return o===r&&i(n),Z(t,i)}}}function N(e,t=Nn){return T(e,se(t))}function Bt(...e){return function(t,n){switch(t){case Qe:return;case De:return Jo(...e.map(o=>Z(o,n)))}}}var ye=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(ye||{});const er={0:"debug",3:"error",1:"log",2:"warn"},tr=()=>typeof globalThis>"u"?window:globalThis,We=q(()=>{const e=I(3);return{log:I((t,n,o=1)=>{var r;const s=(r=tr().VIRTUOSO_LOG_LEVEL)!=null?r:ae(e);o>=s&&console[er[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Je(e,t,n){return Vt(e,t,n).callbackRef}function Vt(e,t,n){const o=x.useRef(null);let r=i=>{};const s=x.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const l=()=>{const a=i[0].target;a.offsetParent!==null&&e(a)};n?l():requestAnimationFrame(l)}):null,[e,n]);return r=i=>{i&&t?(s?.observe(i),o.current=i):(o.current&&s?.unobserve(o.current),o.current=null)},{callbackRef:r,ref:o}}function nr(e,t,n,o,r,s,i,l,a){const c=x.useCallback(u=>{const g=or(u.children,t,l?"offsetWidth":"offsetHeight",r);let p=u.parentElement;for(;!p.dataset.virtuosoScroller;)p=p.parentElement;const S=p.lastElementChild.dataset.viewportType==="window";let R;S&&(R=p.ownerDocument.defaultView);const E=i?l?i.scrollLeft:i.scrollTop:S?l?R.scrollX||R.document.documentElement.scrollLeft:R.scrollY||R.document.documentElement.scrollTop:l?p.scrollLeft:p.scrollTop,v=i?l?i.scrollWidth:i.scrollHeight:S?l?R.document.documentElement.scrollWidth:R.document.documentElement.scrollHeight:l?p.scrollWidth:p.scrollHeight,f=i?l?i.offsetWidth:i.offsetHeight:S?l?R.innerWidth:R.innerHeight:l?p.offsetWidth:p.offsetHeight;o({scrollHeight:v,scrollTop:Math.max(E,0),viewportHeight:f}),s?.(l?fn("column-gap",getComputedStyle(u).columnGap,r):fn("row-gap",getComputedStyle(u).rowGap,r)),g!==null&&e(g)},[e,t,r,s,i,o,l]);return Vt(c,n,a)}function or(e,t,n,o){const r=e.length;if(r===0)return null;const s=[];for(let i=0;i<r;i++){const l=e.item(i);if(l.dataset.index===void 0)continue;const a=parseInt(l.dataset.index),c=parseFloat(l.dataset.knownSize),u=t(l,n);if(u===0&&o("Zero-sized element, this should not happen",{child:l},ye.ERROR),u===c)continue;const g=s[s.length-1];s.length===0||g.size!==u||g.endIndex!==a-1?s.push({endIndex:a,size:u,startIndex:a}):s[s.length-1].endIndex++}return s}function fn(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,ye.WARN),t==="normal"?0:parseInt(t??"0",10)}function _n(e,t,n){const o=x.useRef(null),r=x.useCallback(a=>{if(!(a!=null&&a.offsetParent))return;const c=a.getBoundingClientRect(),u=c.width;let g,p;if(t){const S=t.getBoundingClientRect(),R=c.top-S.top;p=S.height-Math.max(0,R),g=R+t.scrollTop}else{const S=i.current.ownerDocument.defaultView;p=S.innerHeight-Math.max(0,c.top),g=c.top+S.scrollY}o.current={offsetTop:g,visibleHeight:p,visibleWidth:u},e(o.current)},[e,t]),{callbackRef:s,ref:i}=Vt(r,!0,n),l=x.useCallback(()=>{r(i.current)},[r,i]);return x.useEffect(()=>{var a;if(t){t.addEventListener("scroll",l);const c=new ResizeObserver(()=>{requestAnimationFrame(l)});return c.observe(t),()=>{t.removeEventListener("scroll",l),c.unobserve(t)}}else{const c=(a=i.current)==null?void 0:a.ownerDocument.defaultView;return c?.addEventListener("scroll",l),c?.addEventListener("resize",l),()=>{c?.removeEventListener("scroll",l),c?.removeEventListener("resize",l)}}},[l,t,i]),s}const be=q(()=>{const e=Y(),t=Y(),n=I(0),o=Y(),r=I(0),s=Y(),i=Y(),l=I(0),a=I(0),c=I(0),u=I(0),g=Y(),p=Y(),S=I(!1),R=I(!1),E=I(!1);return B(T(e,O(({scrollTop:v})=>v)),t),B(T(e,O(({scrollHeight:v})=>v)),i),B(t,r),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:a,footerHeight:u,headerHeight:l,horizontalDirection:R,scrollBy:p,scrollContainerState:e,scrollHeight:i,scrollingInProgress:S,scrollTo:g,scrollTop:t,skipAnimationFrameInResizeObserver:E,smoothScrollTargetReached:o,statefulScrollTop:r,viewportHeight:s}},[],{singleton:!0}),st={lvl:0};function Fn(e,t){const n=e.length;if(n===0)return[];let{index:o,value:r}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:l,value:a}=t(e[i]);s.push({end:l-1,start:o,value:r}),o=l,r=a}return s.push({end:1/0,start:o,value:r}),s}function ne(e){return e===st}function it(e,t){if(!ne(e))return t===e.k?e.v:t<e.k?it(e.l,t):it(e.r,t)}function He(e,t,n="k"){if(ne(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const o=He(e.r,t,n);return o[0]===-1/0?[e.k,e.v]:o}return He(e.l,t,n)}function Ie(e,t,n){return ne(e)?Vn(t,n,1):t===e.k?he(e,{k:t,v:n}):t<e.k?hn(he(e,{l:Ie(e.l,t,n)})):hn(he(e,{r:Ie(e.r,t,n)}))}function Ze(){return st}function Ke(e,t,n){if(ne(e))return[];const o=He(e,t)[0];return rr(At(e,o,n))}function Mt(e,t){if(ne(e))return st;const{k:n,l:o,r}=e;if(t===n){if(ne(o))return r;if(ne(r))return o;{const[s,i]=Wn(o);return wt(he(e,{k:s,l:Dn(o),v:i}))}}else return t<n?wt(he(e,{l:Mt(o,t)})):wt(he(e,{r:Mt(r,t)}))}function Ue(e){return ne(e)?[]:[...Ue(e.l),{k:e.k,v:e.v},...Ue(e.r)]}function At(e,t,n){if(ne(e))return[];const{k:o,l:r,r:s,v:i}=e;let l=[];return o>t&&(l=l.concat(At(r,t,n))),o>=t&&o<=n&&l.push({k:o,v:i}),o<=n&&(l=l.concat(At(s,t,n))),l}function wt(e){const{l:t,lvl:n,r:o}=e;if(o.lvl>=n-1&&t.lvl>=n-1)return e;if(n>o.lvl+1){if(jt(t))return $n(he(e,{lvl:n-1}));if(!ne(t)&&!ne(t.r))return he(t.r,{l:he(t,{r:t.r.l}),lvl:n,r:he(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(jt(e))return Lt(he(e,{lvl:n-1}));if(!ne(o)&&!ne(o.l)){const r=o.l,s=jt(r)?o.lvl-1:o.lvl;return he(r,{l:he(e,{lvl:n-1,r:r.l}),lvl:r.lvl+1,r:Lt(he(o,{l:r.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function he(e,t){return Vn(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function Dn(e){return ne(e.r)?e.l:wt(he(e,{r:Dn(e.r)}))}function jt(e){return ne(e)||e.lvl>e.r.lvl}function Wn(e){return ne(e.r)?[e.k,e.v]:Wn(e.r)}function Vn(e,t,n,o=st,r=st){return{k:e,l:o,lvl:n,r,v:t}}function hn(e){return Lt($n(e))}function $n(e){const{l:t}=e;return!ne(t)&&t.lvl===e.lvl?he(t,{r:he(e,{l:t.r})}):e}function Lt(e){const{lvl:t,r:n}=e;return!ne(n)&&!ne(n.r)&&n.lvl===t&&n.r.lvl===t?he(n,{l:he(e,{r:n.l}),lvl:t+1}):e}function rr(e){return Fn(e,({k:t,v:n})=>({index:t,value:n}))}function Un(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function lt(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const $t=q(()=>({recalcInProgress:I(!1)}),[],{singleton:!0});function Gn(e,t,n){return e[St(e,t,n)]}function St(e,t,n,o=0){let r=e.length-1;for(;o<=r;){const s=Math.floor((o+r)/2),i=e[s],l=n(i,t);if(l===0)return s;if(l===-1){if(r-o<2)return s-1;r=s-1}else{if(r===o)return s;o=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function sr(e,t,n,o){const r=St(e,t,o),s=St(e,n,o,r);return e.slice(r,s+1)}function Fe(e,t){return Math.round(e.getBoundingClientRect()[t])}function It(e){return!ne(e.groupOffsetTree)}function Ut({index:e},t){return t===e?0:t<e?-1:1}function ir(){return{groupIndices:[],groupOffsetTree:Ze(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Ze()}}function lr(e,t){let n=ne(e)?0:1/0;for(const o of t){const{endIndex:r,size:s,startIndex:i}=o;if(n=Math.min(n,i),ne(e)){e=Ie(e,0,s);continue}const l=Ke(e,i-1,r+1);if(l.some(mr(o)))continue;let a=!1,c=!1;for(const{end:u,start:g,value:p}of l)a?(r>=g||s===p)&&(e=Mt(e,g)):(c=p!==s,a=!0),u>r&&r>=g&&p!==s&&(e=Ie(e,r+1,p));c&&(e=Ie(e,i,s))}return[e,n]}function ar(e){return typeof e.groupIndex<"u"}function cr({offset:e},t){return t===e?0:t<e?-1:1}function at(e,t,n){if(t.length===0)return 0;const{index:o,offset:r,size:s}=Gn(t,e,Ut),i=e-o,l=s*i+(i-1)*n+r;return l>0?l+n:l}function Yn(e,t){if(!It(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Jn(e,t,n){if(ar(e))return t.groupIndices[e.groupIndex]+1;{const o=e.index==="LAST"?n:e.index;let r=Yn(o,t);return r=Math.max(0,r,Math.min(n,r)),r}}function ur(e,t,n,o=0){return o>0&&(t=Math.max(t,Gn(e,o,Ut).offset)),Fn(sr(e,t,n,cr),hr)}function dr(e,[t,n,o,r]){t.length>0&&o("received item sizes",t,ye.DEBUG);const s=e.sizeTree;let i=s,l=0;if(n.length>0&&ne(s)&&t.length===2){const p=t[0].size,S=t[1].size;i=n.reduce((R,E)=>Ie(Ie(R,E,p),E+1,S),i)}else[i,l]=lr(i,t);if(i===s)return e;const{lastIndex:a,lastOffset:c,lastSize:u,offsetTree:g}=Nt(e.offsetTree,l,i,r);return{groupIndices:n,groupOffsetTree:n.reduce((p,S)=>Ie(p,S,at(S,g,r)),Ze()),lastIndex:a,lastOffset:c,lastSize:u,offsetTree:g,sizeTree:i}}function fr(e){return Ue(e).map(({k:t,v:n},o,r)=>{const s=r[o+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function mn(e,t){let n=0,o=0;for(;n<e;)n+=t[o+1]-t[o]-1,o++;return o-(n===e?0:1)}function Nt(e,t,n,o){let r=e,s=0,i=0,l=0,a=0;if(t!==0){a=St(r,t-1,Ut),l=r[a].offset;const c=He(n,t-1);s=c[0],i=c[1],r.length&&r[a].size===He(n,t)[1]&&(a-=1),r=r.slice(0,a+1)}else r=[];for(const{start:c,value:u}of Ke(n,t,1/0)){const g=c-s,p=g*i+l+g*o;r.push({index:c,offset:p,size:u}),s=c,l=p,i=u}return{lastIndex:s,lastOffset:l,lastSize:i,offsetTree:r}}function hr(e){return{index:e.index,value:e}}function mr(e){const{endIndex:t,size:n,startIndex:o}=e;return r=>r.start===o&&(r.end===t||r.end===1/0)&&r.value===n}const pr={offsetHeight:"height",offsetWidth:"width"},Ne=q(([{log:e},{recalcInProgress:t}])=>{const n=Y(),o=Y(),r=Te(o,0),s=Y(),i=Y(),l=I(0),a=I([]),c=I(void 0),u=I(void 0),g=I(void 0),p=I(void 0),S=I((d,C)=>Fe(d,pr[C])),R=I(void 0),E=I(0),v=ir(),f=Te(T(n,U(a,e,E),Le(dr,v),se()),v),h=Te(T(a,se(),Le((d,C)=>({current:C,prev:d.current}),{current:[],prev:[]}),O(({prev:d})=>d)),[]);B(T(a,_(d=>d.length>0),U(f,E),O(([d,C,y])=>{const k=d.reduce((H,F,D)=>Ie(H,F,at(F,C.offsetTree,y)||D),Ze());return{...C,groupIndices:d,groupOffsetTree:k}})),f),B(T(o,U(f),_(([d,{lastIndex:C}])=>d<C),O(([d,{lastIndex:C,lastSize:y}])=>[{endIndex:C,size:y,startIndex:d}])),n),B(c,u);const b=Te(T(c,O(d=>d===void 0)),!0);B(T(u,_(d=>d!==void 0&&ne(ae(f).sizeTree)),O(d=>{const C=ae(g),y=ae(a).length>0;return C?y?[{endIndex:0,size:C,startIndex:0},{endIndex:1,size:d,startIndex:1}]:[]:[{endIndex:0,size:d,startIndex:0}]})),n),B(T(p,_(d=>d!==void 0&&d.length>0&&ne(ae(f).sizeTree)),O(d=>{const C=[];let y=d[0],k=0;for(let H=1;H<d.length;H++){const F=d[H];F!==y&&(C.push({endIndex:H-1,size:y,startIndex:k}),y=F,k=H)}return C.push({endIndex:d.length-1,size:y,startIndex:k}),C})),n),B(T(a,U(g,u),_(([,d,C])=>d!==void 0&&C!==void 0),O(([d,C,y])=>{const k=[];for(let H=0;H<d.length;H++){const F=d[H],D=d[H+1];k.push({startIndex:F,endIndex:F,size:C}),D!==void 0&&k.push({startIndex:F+1,endIndex:D-1,size:y})}return k})),n);const P=Re(T(n,U(f),Le(({sizes:d},[C,y])=>({changed:y!==d,sizes:y}),{changed:!1,sizes:v}),O(d=>d.changed)));Z(T(l,Le((d,C)=>({diff:d.prev-C,prev:C}),{diff:0,prev:0}),O(d=>d.diff)),d=>{const{groupIndices:C}=ae(f);if(d>0)$(t,!0),$(s,d+mn(d,C));else if(d<0){const y=ae(h);y.length>0&&(d-=mn(-d,y)),$(i,d)}}),Z(T(l,U(e)),([d,C])=>{d<0&&C("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:l},ye.ERROR)});const z=Re(s);B(T(s,U(f),O(([d,C])=>{const y=C.groupIndices.length>0,k=[],H=C.lastSize;if(y){const F=it(C.sizeTree,0);let D=0,A=0;for(;D<d;){const X=C.groupIndices[A],K=C.groupIndices.length===A+1?1/0:C.groupIndices[A+1]-X-1;k.push({endIndex:X,size:F,startIndex:X}),k.push({endIndex:X+1+K-1,size:H,startIndex:X+1}),A++,D+=K+1}const V=Ue(C.sizeTree);return D!==d&&V.shift(),V.reduce((X,{k:K,v:ve})=>{let we=X.ranges;return X.prevSize!==0&&(we=[...X.ranges,{endIndex:K+d-1,size:X.prevSize,startIndex:X.prevIndex}]),{prevIndex:K+d,prevSize:ve,ranges:we}},{prevIndex:d,prevSize:0,ranges:k}).ranges}return Ue(C.sizeTree).reduce((F,{k:D,v:A})=>({prevIndex:D+d,prevSize:A,ranges:[...F.ranges,{endIndex:D+d-1,size:F.prevSize,startIndex:F.prevIndex}]}),{prevIndex:0,prevSize:H,ranges:[]}).ranges})),n);const M=Re(T(i,U(f,E),O(([d,{offsetTree:C},y])=>{const k=-d;return at(k,C,y)})));return B(T(i,U(f,E),O(([d,C,y])=>{if(C.groupIndices.length>0){if(ne(C.sizeTree))return C;let k=Ze();const H=ae(h);let F=0,D=0,A=0;for(;F<-d;){A=H[D];const V=H[D+1]-A-1;D++,F+=V+1}if(k=Ue(C.sizeTree).reduce((V,{k:X,v:K})=>Ie(V,Math.max(0,X+d),K),k),F!==-d){const V=it(C.sizeTree,A);k=Ie(k,0,V);const X=He(C.sizeTree,-d+1)[1];k=Ie(k,1,X)}return{...C,sizeTree:k,...Nt(C.offsetTree,0,k,y)}}else{const k=Ue(C.sizeTree).reduce((H,{k:F,v:D})=>Ie(H,Math.max(0,F+d),D),Ze());return{...C,sizeTree:k,...Nt(C.offsetTree,0,k,y)}}})),f),{beforeUnshiftWith:z,data:R,defaultItemSize:u,firstItemIndex:l,fixedItemSize:c,fixedGroupSize:g,gap:E,groupIndices:a,heightEstimates:p,itemSize:S,listRefresh:P,shiftWith:i,shiftWithOffset:M,sizeRanges:n,sizes:f,statefulTotalCount:r,totalCount:o,trackItemSizes:b,unshiftWith:s}},ie(We,$t),{singleton:!0});function gr(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const qn=q(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:o,scrollTop:r}])=>{const s=Y(),i=Y(),l=Re(T(s,O(gr)));return B(T(l,O(a=>a.totalCount)),n),B(T(l,O(a=>a.groupIndices)),e),B(T(de(r,t,o),_(([a,c])=>It(c)),O(([a,c,u])=>He(c.groupOffsetTree,Math.max(a-u,0),"v")[0]),se(),O(a=>[a])),i),{groupCounts:s,topItemsIndexes:i}},ie(Ne,be)),Ve=q(([{log:e}])=>{const t=I(!1),n=Re(T(t,_(o=>o),se()));return Z(t,o=>{o&&ae(e)("props updated",{},ye.DEBUG)}),{didMount:n,propsReady:t}},ie(We),{singleton:!0}),xr=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Xn(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!xr)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const ft=q(([{gap:e,listRefresh:t,sizes:n,totalCount:o},{fixedFooterHeight:r,fixedHeaderHeight:s,footerHeight:i,headerHeight:l,scrollingInProgress:a,scrollTo:c,smoothScrollTargetReached:u,viewportHeight:g},{log:p}])=>{const S=Y(),R=Y(),E=I(0);let v=null,f=null,h=null;function b(){v&&(v(),v=null),h&&(h(),h=null),f&&(clearTimeout(f),f=null),$(a,!1)}return B(T(S,U(n,g,o,E,l,i,p),U(e,s,r),O(([[P,z,M,d,C,y,k,H],F,D,A])=>{const V=Xn(P),{align:X,behavior:K,offset:ve}=V,we=d-1,Ce=Jn(V,z,we);let w=at(Ce,z.offsetTree,F)+y;X==="end"?(w+=D+He(z.sizeTree,Ce)[1]-M+A,Ce===we&&(w+=k)):X==="center"?w+=(D+He(z.sizeTree,Ce)[1]-M+A)/2:w-=C,ve&&(w+=ve);const L=J=>{b(),J?(H("retrying to scroll to",{location:P},ye.DEBUG),$(S,P)):($(R,!0),H("list did not change, scroll successful",{},ye.DEBUG))};if(b(),K==="smooth"){let J=!1;h=Z(t,Q=>{J=J||Q}),v=Pe(u,()=>{L(J)})}else v=Pe(T(t,vr(150)),L);return f=setTimeout(()=>{b()},1200),$(a,!0),H("scrolling from index to",{behavior:K,index:Ce,top:w},ye.DEBUG),{behavior:K,top:w}})),c),{scrollTargetReached:R,scrollToIndex:S,topListHeight:E}},ie(Ne,be,We),{singleton:!0});function vr(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return o=>{o&&(t(!0),clearTimeout(n))}}}function Gt(e,t){e==0?t():requestAnimationFrame(()=>{Gt(e-1,t)})}function Yt(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const ht=q(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:o},{scrollTargetReached:r,scrollToIndex:s},{didMount:i}])=>{const l=I(!0),a=I(0),c=I(!0);return B(T(i,U(a),_(([u,g])=>!!g),Ae(!1)),l),B(T(i,U(a),_(([u,g])=>!!g),Ae(!1)),c),Z(T(de(t,i),U(l,n,e,c),_(([[,u],g,{sizeTree:p},S,R])=>u&&(!ne(p)||Dt(S))&&!g&&!R),U(a)),([,u])=>{Pe(r,()=>{$(c,!0)}),Gt(4,()=>{Pe(o,()=>{$(l,!0)}),$(s,u)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:a,scrolledToInitialItem:l}},ie(Ne,be,ft,Ve),{singleton:!0});function Zn(e,t){return Math.abs(e-t)<1.01}const ct="up",ot="down",wr="none",Cr={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Sr=0,mt=q(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:o,scrollTop:r,viewportHeight:s}])=>{const i=I(!1),l=I(!0),a=Y(),c=Y(),u=I(4),g=I(Sr),p=Te(T(Bt(T(N(r),Ge(1),Ae(!0)),T(N(r),Ge(1),Ae(!1),dn(100))),se()),!1),S=Te(T(Bt(T(n,Ae(!0)),T(n,Ae(!1),dn(200))),se()),!1);B(T(de(N(r),N(g)),O(([h,b])=>h<=b),se()),l),B(T(l,_e(50)),c);const R=Re(T(de(o,N(s),N(t),N(e),N(u)),Le((h,[{scrollHeight:b,scrollTop:P},z,M,d,C])=>{const y=P+z-b>-C,k={scrollHeight:b,scrollTop:P,viewportHeight:z};if(y){let F,D;return P>h.state.scrollTop?(F="SCROLLED_DOWN",D=h.state.scrollTop-P):(F="SIZE_DECREASED",D=h.state.scrollTop-P||h.scrollTopDelta),{atBottom:!0,atBottomBecause:F,scrollTopDelta:D,state:k}}let H;return k.scrollHeight>h.state.scrollHeight?H="SIZE_INCREASED":z<h.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":P<h.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:k}},Cr),se((h,b)=>h&&h.atBottom===b.atBottom))),E=Te(T(o,Le((h,{scrollHeight:b,scrollTop:P,viewportHeight:z})=>{if(Zn(h.scrollHeight,b))return{changed:!1,jump:0,scrollHeight:b,scrollTop:P};{const M=b-(P+z)<1;return h.scrollTop!==P&&M?{changed:!0,jump:h.scrollTop-P,scrollHeight:b,scrollTop:P}:{changed:!0,jump:0,scrollHeight:b,scrollTop:P}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),_(h=>h.changed),O(h=>h.jump)),0);B(T(R,O(h=>h.atBottom)),i),B(T(i,_e(50)),a);const v=I(ot);B(T(o,O(({scrollTop:h})=>h),se(),Le((h,b)=>ae(S)?{direction:h.direction,prevScrollTop:b}:{direction:b<h.prevScrollTop?ct:ot,prevScrollTop:b},{direction:ot,prevScrollTop:0}),O(h=>h.direction)),v),B(T(o,_e(50),Ae(wr)),v);const f=I(0);return B(T(p,_(h=>!h),Ae(0)),f),B(T(r,_e(100),U(p),_(([h,b])=>!!b),Le(([h,b],[P])=>[b,P],[0,0]),O(([h,b])=>b-h)),f),{atBottomState:R,atBottomStateChange:a,atBottomThreshold:u,atTopStateChange:c,atTopThreshold:g,isAtBottom:i,isAtTop:l,isScrolling:p,lastJumpDueToItemResize:E,scrollDirection:v,scrollVelocity:f}},ie(be)),ut="top",dt="bottom",pn="none";function gn(e,t,n){return typeof e=="number"?n===ct&&t===ut||n===ot&&t===dt?e:0:n===ct?t===ut?e.main:e.reverse:t===dt?e.main:e.reverse}function xn(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Jt=q(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:o,viewportHeight:r}])=>{const s=Y(),i=I(0),l=I(0),a=I(0),c=Te(T(de(N(o),N(r),N(n),N(s,lt),N(a),N(i),N(t),N(e),N(l)),O(([u,g,p,[S,R],E,v,f,h,b])=>{const P=u-h,z=v+f,M=Math.max(p-P,0);let d=pn;const C=xn(b,ut),y=xn(b,dt);return S-=h,S+=p+f,R+=p+f,R-=h,S>u+z-C&&(d=ct),R<u-M+g+y&&(d=ot),d!==pn?[Math.max(P-p-gn(E,ut,d)-C,0),P-M-f+g+gn(E,dt,d)+y]:null}),_(u=>u!=null),se(lt)),[0,0]);return{increaseViewportBy:l,listBoundary:s,overscan:a,topListHeight:i,visibleRange:c}},ie(be),{singleton:!0});function Tr(e,t,n){if(It(t)){const o=Yn(e,t);return[{index:He(t.groupOffsetTree,o)[0],offset:0,size:0},{data:n?.[0],index:o,offset:0,size:0}]}return[{data:n?.[0],index:e,offset:0,size:0}]}const zt={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ct(e,t,n,o,r,s){const{lastIndex:i,lastOffset:l,lastSize:a}=r;let c=0,u=0;if(e.length>0){c=e[0].offset;const E=e[e.length-1];u=E.offset+E.size}const g=n-i,p=l+g*a+(g-1)*o,S=c,R=p-u;return{bottom:u,firstItemIndex:s,items:vn(e,r,s),offsetBottom:R,offsetTop:c,top:S,topItems:vn(t,r,s),topListHeight:t.reduce((E,v)=>v.size+E,0),totalCount:n}}function Kn(e,t,n,o,r,s){let i=0;if(n.groupIndices.length>0)for(const u of n.groupIndices){if(u-i>=e)break;i++}const l=e+i,a=Yt(t,l),c=Array.from({length:l}).map((u,g)=>({data:s[g+a],index:g+a,offset:0,size:0}));return Ct(c,[],l,r,n,o)}function vn(e,t,n){if(e.length===0)return[];if(!It(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const o=e[0].index,r=e[e.length-1].index,s=[],i=Ke(t.groupOffsetTree,o,r);let l,a=0;for(const c of e){(!l||l.end<c.index)&&(l=i.shift(),a=t.groupIndices.indexOf(l.start));let u;c.index===l.start?u={index:a,type:"group"}:u={groupIndex:a,index:c.index-(a+1)+n},s.push({...u,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}function wn(e,t){var n;return e===void 0?0:typeof e=="number"?e:(n=e[t])!=null?n:0}const qe=q(([{data:e,firstItemIndex:t,gap:n,sizes:o,totalCount:r},s,{listBoundary:i,topListHeight:l,visibleRange:a},{initialTopMostItemIndex:c,scrolledToInitialItem:u},{topListHeight:g},p,{didMount:S},{recalcInProgress:R}])=>{const E=I([]),v=I(0),f=Y(),h=I(0);B(s.topItemsIndexes,E);const b=Te(T(de(S,R,N(a,lt),N(r),N(o),N(c),u,N(E),N(t),N(n),N(h),e),_(([d,C,,y,,,,,,,,k])=>{const H=k&&k.length!==y;return d&&!C&&!H}),O(([,,[d,C],y,k,H,F,D,A,V,X,K])=>{var ve,we,Ce,w;const L=k,{offsetTree:J,sizeTree:Q}=L,Be=ae(v);if(y===0)return{...zt,totalCount:y};if(d===0&&C===0)return Be===0?{...zt,totalCount:y}:Kn(Be,H,k,A,V,K||[]);if(ne(Q))return Be>0?null:Ct(Tr(Yt(H,y),L,K),[],y,V,L,A);const Me=[];if(D.length>0){const fe=D[0],ce=D[D.length-1];let me=0;for(const ue of Ke(Q,fe,ce)){const te=ue.value,re=Math.max(ue.start,fe),ke=Math.min(ue.end,ce);for(let ge=re;ge<=ke;ge++)Me.push({data:K?.[ge],index:ge,offset:me,size:te}),me+=te}}if(!F)return Ct([],Me,y,V,L,A);const ee=D.length>0?D[D.length-1]+1:0,j=ur(J,d,C,ee);if(j.length===0)return null;const G=y-1,oe=yt([],fe=>{for(const ce of j){const me=ce.value;let ue=me.offset,te=ce.start;const re=me.size;if(me.offset<d){te+=Math.floor((d-me.offset+V)/(re+V));const ge=te-ce.start;ue+=ge*re+ge*V}te<ee&&(ue+=(ee-te)*re,te=ee);const ke=Math.min(ce.end,G);for(let ge=te;ge<=ke&&!(ue>=C);ge++)fe.push({data:K?.[ge],index:ge,offset:ue,size:re}),ue+=re+V}}),pe=wn(X,ut),Ee=wn(X,dt);if(oe.length>0&&(pe>0||Ee>0)){const fe=oe[0],ce=oe[oe.length-1];if(pe>0&&fe.index>ee){const me=Math.min(pe,fe.index-ee),ue=[];let te=fe.offset;for(let re=fe.index-1;re>=fe.index-me;re--){const ke=(we=(ve=Ke(Q,re,re)[0])==null?void 0:ve.value)!=null?we:fe.size;te-=ke+V,ue.unshift({data:K?.[re],index:re,offset:te,size:ke})}oe.unshift(...ue)}if(Ee>0&&ce.index<G){const me=Math.min(Ee,G-ce.index);let ue=ce.offset+ce.size+V;for(let te=ce.index+1;te<=ce.index+me;te++){const re=(w=(Ce=Ke(Q,te,te)[0])==null?void 0:Ce.value)!=null?w:ce.size;oe.push({data:K?.[te],index:te,offset:ue,size:re}),ue+=re+V}}}return Ct(oe,Me,y,V,L,A)}),_(d=>d!==null),se()),zt);B(T(e,_(Dt),O(d=>d?.length)),r),B(T(b,O(d=>d.topListHeight)),g),B(g,l),B(T(b,O(d=>[d.top,d.bottom])),i),B(T(b,O(d=>d.items)),f);const P=Re(T(b,_(({items:d})=>d.length>0),U(r,e),_(([{items:d},C])=>d[d.length-1].originalIndex===C-1),O(([,d,C])=>[d-1,C]),se(lt),O(([d])=>d))),z=Re(T(b,_e(200),_(({items:d,topItems:C})=>d.length>0&&d[0].originalIndex===C.length),O(({items:d})=>d[0].index),se())),M=Re(T(b,_(({items:d})=>d.length>0),O(({items:d})=>{let C=0,y=d.length-1;for(;d[C].type==="group"&&C<y;)C++;for(;d[y].type==="group"&&y>C;)y--;return{endIndex:d[y].index,startIndex:d[C].index}}),se(Un)));return{endReached:P,initialItemCount:v,itemsRendered:f,listState:b,minOverscanItemCount:h,rangeChanged:M,startReached:z,topItemsIndexes:E,...p}},ie(Ne,qn,Jt,ht,ft,mt,Ve,$t),{singleton:!0}),Qn=q(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:o},{listState:r}])=>{const s=Y(),i=Te(T(de(n,e,o,t,r),O(([l,a,c,u,g])=>l+a+c+u+g.offsetBottom+g.bottom)),0);return B(N(i),s),{totalListHeight:i,totalListHeightChanged:s}},ie(be,qe),{singleton:!0}),br=q(([{viewportHeight:e},{totalListHeight:t}])=>{const n=I(!1),o=Te(T(de(n,e,t),_(([r])=>r),O(([,r,s])=>Math.max(0,r-s)),_e(0),se()),0);return{alignToBottom:n,paddingTopAddition:o}},ie(be,Qn),{singleton:!0}),eo=q(()=>({context:I(null)})),yr=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:o,...r},viewportBottom:s,viewportTop:i})=>t<i?{...r,align:n??"start",behavior:o}:e>s?{...r,align:n??"end",behavior:o}:null,to=q(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:o,fixedHeaderHeight:r,headerHeight:s,scrollingInProgress:i,scrollTop:l,viewportHeight:a},{scrollToIndex:c}])=>{const u=Y();return B(T(u,U(t,a,n,s,r,o,l),U(e),O(([[g,p,S,R,E,v,f,h],b])=>{const{align:P,behavior:z,calculateViewLocation:M=yr,done:d,...C}=g,y=Jn(g,p,R-1),k=at(y,p.offsetTree,b)+E+v,H=k+He(p.sizeTree,y)[1],F=h+v,D=h+S-f,A=M({itemBottom:H,itemTop:k,locationParams:{align:P,behavior:z,...C},viewportBottom:D,viewportTop:F});return A?d&&Pe(T(i,_(V=>!V),Ge(ae(i)?1:2)),d):d&&d(),A}),_(g=>g!==null)),c),{scrollIntoView:u}},ie(Ne,be,ft,qe,We),{singleton:!0});function Cn(e){return e?e==="smooth"?"smooth":"auto":!1}const Ir=(e,t)=>typeof e=="function"?Cn(e(t)):t&&Cn(e),Rr=q(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:o},{atBottomState:r,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:l},{didMount:a,propsReady:c},{log:u},{scrollingInProgress:g},{context:p},{scrollIntoView:S}])=>{const R=I(!1),E=Y();let v=null;function f(z){$(i,{align:"end",behavior:z,index:"LAST"})}Z(T(de(T(N(t),Ge(1)),a),U(N(R),s,l,g),O(([[z,M],d,C,y,k])=>{let H=M&&y,F="auto";return H&&(F=Ir(d,C||k),H=H&&!!F),{followOutputBehavior:F,shouldFollow:H,totalCount:z}}),_(({shouldFollow:z})=>z)),({followOutputBehavior:z,totalCount:M})=>{v&&(v(),v=null),ae(n)?requestAnimationFrame(()=>{ae(u)("following output to ",{totalCount:M},ye.DEBUG),f(z)}):v=Pe(e,()=>{ae(u)("following output to ",{totalCount:M},ye.DEBUG),f(z),v=null})});function h(z){const M=Pe(r,d=>{z&&!d.atBottom&&d.notAtBottomBecause==="SIZE_INCREASED"&&!v&&(ae(u)("scrolling to bottom due to increased size",{},ye.DEBUG),f("auto"))});setTimeout(M,100)}Z(T(de(N(R),t,c),_(([z,,M])=>z&&M),Le(({value:z},[,M])=>({refreshed:z===M,value:M}),{refreshed:!1,value:0}),_(({refreshed:z})=>z),U(R,t)),([,z])=>{ae(l)&&h(z!==!1)}),Z(E,()=>{h(ae(R)!==!1)}),Z(de(N(R),r),([z,M])=>{z&&!M.atBottom&&M.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&f("auto")});const b=I(null),P=Y();return B(Bt(T(N(o),O(z=>{var M;return(M=z?.length)!=null?M:0})),T(N(t))),P),Z(T(de(T(P,Ge(1)),a),U(N(b),l,g,p),O(([[z,M],d,C,y,k])=>M&&C&&d?.({context:k,totalCount:z,scrollingInProgress:y})),_(z=>!!z),_e(0)),z=>{v&&(v(),v=null),ae(n)?requestAnimationFrame(()=>{ae(u)("scrolling into view",{}),$(S,z)}):v=Pe(e,()=>{ae(u)("scrolling into view",{}),$(S,z),v=null})}),{autoscrollToBottom:E,followOutput:R,scrollIntoViewOnChange:b}},ie(Ne,mt,ft,ht,Ve,We,be,eo,to)),Er=q(([{data:e,firstItemIndex:t,gap:n,sizes:o},{initialTopMostItemIndex:r},{initialItemCount:s,listState:i},{didMount:l}])=>(B(T(l,U(s),_(([,a])=>a!==0),U(r,o,t,n,e),O(([[,a],c,u,g,p,S=[]])=>Kn(a,c,u,g,p,S))),i),{}),ie(Ne,ht,qe,Ve),{singleton:!0}),kr=q(([{didMount:e},{scrollTo:t},{listState:n}])=>{const o=I(0);return Z(T(e,U(o),_(([,r])=>r!==0),O(([,r])=>({top:r}))),r=>{Pe(T(n,Ge(1),_(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{$(t,r)})})}),{initialScrollTop:o}},ie(Ve,be,qe),{singleton:!0}),no=q(([{scrollVelocity:e}])=>{const t=I(!1),n=Y(),o=I(!1);return B(T(e,U(o,t,n),_(([r,s])=>!!s),O(([r,s,i,l])=>{const{enter:a,exit:c}=s;if(i){if(c(r,l))return!1}else if(a(r,l))return!0;return i}),se()),t),Z(T(de(t,e,n),U(o)),([[r,s,i],l])=>{r&&l&&l.change&&l.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:o,scrollSeekRangeChanged:n,scrollVelocity:e}},ie(mt),{singleton:!0}),qt=q(([{scrollContainerState:e,scrollTo:t}])=>{const n=Y(),o=Y(),r=Y(),s=I(!1),i=I(void 0);return B(T(de(n,o),O(([{scrollHeight:l,scrollTop:a,viewportHeight:c},{offsetTop:u}])=>({scrollHeight:l,scrollTop:Math.max(0,a-u),viewportHeight:c}))),e),B(T(t,U(o),O(([l,{offsetTop:a}])=>({...l,top:l.top+a}))),r),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:r,windowViewportRect:o}},ie(be)),jr=q(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:o},{initialTopMostItemIndex:r},{didMount:s},{useWindowScroll:i,windowScrollContainerState:l,windowViewportRect:a}])=>{const c=Y(),u=I(void 0),g=I(null),p=I(null);return B(l,g),B(a,p),Z(T(c,U(t,o,i,g,p,n)),([S,R,E,v,f,h,b])=>{const P=fr(R.sizeTree);v&&f!==null&&h!==null&&(E=f.scrollTop-h.offsetTop),E-=b,S({ranges:P,scrollTop:E})}),B(T(u,_(Dt),O(zr)),r),B(T(s,U(u),_(([,S])=>S!==void 0),se(),O(([,S])=>S.ranges)),e),{getState:c,restoreStateFrom:u}},ie(Ne,be,ht,Ve,qt));function zr(e){return{align:"start",index:0,offset:e.scrollTop}}const Or=q(([{topItemsIndexes:e}])=>{const t=I(0);return B(T(t,_(n=>n>=0),O(n=>Array.from({length:n}).map((o,r)=>r))),e),{topItemCount:t}},ie(qe));function oo(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Pr=oo(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Hr=q(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:o},{isAtBottom:r,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:l},{listState:a},{beforeUnshiftWith:c,gap:u,shiftWithOffset:g,sizes:p},{log:S},{recalcInProgress:R}])=>{const E=Re(T(a,U(i),Le(([,f,h,b],[{bottom:P,items:z,offsetBottom:M,totalCount:d},C])=>{const y=P+M;let k=0;return h===d&&f.length>0&&z.length>0&&(z[0].originalIndex===0&&f[0].originalIndex===0||(k=y-b,k!==0&&(k+=C))),[k,z,d,y]},[0,[],0,0]),_(([f])=>f!==0),U(o,l,n,r,S,R),_(([,f,h,b,,,P])=>!P&&!b&&f!==0&&h===ct),O(([[f],,,,,h])=>(h("Upward scrolling compensation",{amount:f},ye.DEBUG),f))));function v(f){f>0?($(t,{behavior:"auto",top:-f}),$(e,0)):($(e,0),$(t,{behavior:"auto",top:-f}))}return Z(T(E,U(e,s)),([f,h,b])=>{b&&Pr()?$(e,h-f):v(-f)}),Z(T(de(Te(s,!1),e,R),_(([f,h,b])=>!f&&!b&&h!==0),O(([f,h])=>h),_e(1)),v),B(T(g,O(f=>({top:-f}))),t),Z(T(c,U(p,u),O(([f,{groupIndices:h,lastSize:b,sizeTree:P},z])=>{function M(d){return d*(b+z)}if(h.length===0)return M(f);{let d=0;const C=it(P,0);let y=0,k=0;for(;y<f;){y++,d+=C;let H=h.length===k+1?1/0:h[k+1]-h[k]-1;y+H>f&&(d-=C,H=f-y+1),y+=H,d+=M(H),k++}return d}})),f=>{$(e,f),requestAnimationFrame(()=>{$(t,{top:f}),requestAnimationFrame(()=>{$(e,0),$(R,!1)})})}),{deviation:e}},ie(be,mt,qe,Ne,We,$t)),Br=q(([e,t,n,o,r,s,i,l,a,c,u])=>({...e,...t,...n,...o,...r,...s,...i,...l,...a,...c,...u}),ie(Jt,Er,Ve,no,Qn,kr,br,qt,to,We,eo)),ro=q(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:o,fixedGroupSize:r,gap:s,groupIndices:i,heightEstimates:l,itemSize:a,sizeRanges:c,sizes:u,statefulTotalCount:g,totalCount:p,trackItemSizes:S},{initialItemFinalLocationReached:R,initialTopMostItemIndex:E,scrolledToInitialItem:v},f,h,b,P,{scrollToIndex:z},M,{topItemCount:d},{groupCounts:C},y])=>{const{listState:k,minOverscanItemCount:H,topItemsIndexes:F,rangeChanged:D,...A}=P;return B(D,y.scrollSeekRangeChanged),B(T(y.windowViewportRect,O(V=>V.visibleHeight)),f.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:o,fixedGroupHeight:r,gap:s,groupCounts:C,heightEstimates:l,initialItemFinalLocationReached:R,initialTopMostItemIndex:E,scrolledToInitialItem:v,sizeRanges:c,topItemCount:d,topItemsIndexes:F,totalCount:p,...b,groupIndices:i,itemSize:a,listState:k,minOverscanItemCount:H,scrollToIndex:z,statefulTotalCount:g,trackItemSizes:S,rangeChanged:D,...A,...y,...f,sizes:u,...h}},ie(Ne,ht,be,jr,Rr,qe,ft,Hr,Or,qn,Br));function Mr(e,t){const n={},o={};let r=0;const s=e.length;for(;r<s;)o[e[r]]=1,r+=1;for(const i in t)Object.hasOwn(o,i)||(n[i]=t[i]);return n}const xt=typeof document<"u"?x.useLayoutEffect:x.useEffect;function so(e,t,n){const o=Object.keys(t.required||{}),r=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),l=x.createContext({});function a(v,f){v.propsReady&&$(v.propsReady,!1);for(const h of o){const b=v[t.required[h]];$(b,f[h])}for(const h of r)if(h in f){const b=v[t.optional[h]];$(b,f[h])}v.propsReady&&$(v.propsReady,!0)}function c(v){return s.reduce((f,h)=>(f[h]=b=>{const P=v[t.methods[h]];$(P,b)},f),{})}function u(v){return i.reduce((f,h)=>(f[h]=Zo(v[t.events[h]]),f),{})}const g=x.forwardRef((v,f)=>{const{children:h,...b}=v,[P]=x.useState(()=>yt(Qo(e),d=>{a(d,b)})),[z]=x.useState(un(u,P));xt(()=>{for(const d of i)d in b&&Z(z[d],b[d]);return()=>{Object.values(z).map(Wt)}},[b,z,P]),xt(()=>{a(P,b)}),x.useImperativeHandle(f,cn(c(P)));const M=n;return m.jsx(l.Provider,{value:P,children:n?m.jsx(M,{...Mr([...o,...r,...i],b),children:h}):h})}),p=v=>{const f=x.useContext(l);return x.useCallback(h=>{$(f[v],h)},[f,v])},S=v=>{const f=x.useContext(l)[v],h=x.useCallback(b=>Z(f,b),[f]);return x.useSyncExternalStore(h,()=>ae(f),()=>ae(f))},R=v=>{const f=x.useContext(l)[v],[h,b]=x.useState(un(ae,f));return xt(()=>Z(f,P=>{P!==h&&b(cn(P))}),[f,h]),h},E=x.version.startsWith("18")?S:R;return{Component:g,useEmitter:(v,f)=>{const h=x.useContext(l)[v];xt(()=>Z(h,f),[f,h])},useEmitterValue:E,usePublisher:p}}const io=x.createContext(void 0),lo=x.createContext(void 0),ao=typeof document<"u"?x.useLayoutEffect:x.useEffect;function Ot(e){return"self"in e}function Ar(e){return"body"in e}function co(e,t,n,o=et,r,s){const i=x.useRef(null),l=x.useRef(null),a=x.useRef(null),c=x.useCallback(p=>{let S,R,E;const v=p.target;if(Ar(v)||Ot(v)){const h=Ot(v)?v:v.defaultView;E=s?h.scrollX:h.scrollY,S=s?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight,R=s?h.innerWidth:h.innerHeight}else E=s?v.scrollLeft:v.scrollTop,S=s?v.scrollWidth:v.scrollHeight,R=s?v.offsetWidth:v.offsetHeight;const f=()=>{e({scrollHeight:S,scrollTop:Math.max(E,0),viewportHeight:R})};p.suppressFlushSync?f():zn.flushSync(f),l.current!==null&&(E===l.current||E<=0||E===S-R)&&(l.current=null,t(!0),a.current&&(clearTimeout(a.current),a.current=null))},[e,t,s]);x.useEffect(()=>{const p=r||i.current;return o(r||i.current),c({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",c,{passive:!0}),()=>{o(null),p.removeEventListener("scroll",c)}},[i,c,n,o,r]);function u(p){const S=i.current;if(!S||(s?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const R=p.behavior==="smooth";let E,v,f;Ot(S)?(v=Math.max(Fe(S.document.documentElement,s?"width":"height"),s?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),E=s?S.innerWidth:S.innerHeight,f=s?window.scrollX:window.scrollY):(v=S[s?"scrollWidth":"scrollHeight"],E=Fe(S,s?"width":"height"),f=S[s?"scrollLeft":"scrollTop"]);const h=v-E;if(p.top=Math.ceil(Math.max(Math.min(h,p.top),0)),Zn(E,v)||p.top===f){e({scrollHeight:v,scrollTop:f,viewportHeight:E}),R&&t(!0);return}R?(l.current=p.top,a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,l.current=null,t(!0)},1e3)):l.current=null,s&&(p={behavior:p.behavior,left:p.top}),S.scrollTo(p)}function g(p){s&&(p={behavior:p.behavior,left:p.top}),i.current.scrollBy(p)}return{scrollByCallback:g,scrollerRef:i,scrollToCallback:u}}const Pt="-webkit-sticky",Sn="sticky",Xt=oo(()=>{if(typeof document>"u")return Sn;const e=document.createElement("div");return e.style.position=Pt,e.style.position===Pt?Pt:Sn});function Zt(e){return e}const Lr=q(()=>{const e=I(l=>`Item ${l}`),t=I(l=>`Group ${l}`),n=I({}),o=I(Zt),r=I("div"),s=I(et),i=(l,a=null)=>Te(T(n,O(c=>c[l]),se()),a);return{components:n,computeItemKey:o,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:r,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),Nr=q(([e,t])=>({...e,...t}),ie(ro,Lr)),_r=({height:e})=>m.jsx("div",{style:{height:e}}),Fr={overflowAnchor:"none",position:Xt(),zIndex:1},uo={overflowAnchor:"none"},Dr={...uo,display:"inline-block",height:"100%"},Tn=x.memo(function({showTopList:e=!1}){const t=W("listState"),n=je("sizeRanges"),o=W("useWindowScroll"),r=W("customScrollParent"),s=je("windowScrollContainerState"),i=je("scrollContainerState"),l=r||o?s:i,a=W("itemContent"),c=W("context"),u=W("groupContent"),g=W("trackItemSizes"),p=W("itemSize"),S=W("log"),R=je("gap"),E=W("horizontalDirection"),{callbackRef:v}=nr(n,p,g,e?et:l,S,R,r,E,W("skipAnimationFrameInResizeObserver")),[f,h]=x.useState(0);Kt("deviation",A=>{f!==A&&h(A)});const b=W("EmptyPlaceholder"),P=W("ScrollSeekPlaceholder")||_r,z=W("ListComponent"),M=W("ItemComponent"),d=W("GroupComponent"),C=W("computeItemKey"),y=W("isSeeking"),k=W("groupIndices").length>0,H=W("alignToBottom"),F=W("initialItemFinalLocationReached"),D=e?{}:{boxSizing:"border-box",...E?{display:"inline-block",height:"100%",marginLeft:f!==0?f:H?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:f!==0?f:H?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...F?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&b?m.jsx(b,{...Se(b,c)}):m.jsx(z,{...Se(z,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:v,style:D,children:(e?t.topItems:t.items).map(A=>{const V=A.originalIndex,X=C(V+t.firstItemIndex,A.data,c);return y?x.createElement(P,{...Se(P,c),height:A.size,index:A.index,key:X,type:A.type||"item",...A.type==="group"?{}:{groupIndex:A.groupIndex}}):A.type==="group"?x.createElement(d,{...Se(d,c),"data-index":V,"data-item-index":A.index,"data-known-size":A.size,key:X,style:Fr},u(A.index,c)):x.createElement(M,{...Se(M,c),...Ur(M,A.data),"data-index":V,"data-item-group-index":A.groupIndex,"data-item-index":A.index,"data-known-size":A.size,key:X,style:E?Dr:uo},k?a(A.index,A.groupIndex,A.data,c):a(A.index,A.data,c))})})}),Wr={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Vr={outline:"none",overflowX:"auto",position:"relative"},Rt=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),$r={position:Xt(),top:0,width:"100%",zIndex:1};function Se(e,t){if(typeof e!="string")return{context:t}}function Ur(e,t){return{item:typeof e=="string"?void 0:t}}const Gr=x.memo(function(){const e=W("HeaderComponent"),t=je("headerHeight"),n=W("HeaderFooterTag"),o=Je(x.useMemo(()=>s=>{t(Fe(s,"height"))},[t]),!0,W("skipAnimationFrameInResizeObserver")),r=W("context");return e?m.jsx(n,{ref:o,children:m.jsx(e,{...Se(e,r)})}):null}),Yr=x.memo(function(){const e=W("FooterComponent"),t=je("footerHeight"),n=W("HeaderFooterTag"),o=Je(x.useMemo(()=>s=>{t(Fe(s,"height"))},[t]),!0,W("skipAnimationFrameInResizeObserver")),r=W("context");return e?m.jsx(n,{ref:o,children:m.jsx(e,{...Se(e,r)})}):null});function fo({useEmitter:e,useEmitterValue:t,usePublisher:n}){return x.memo(function({children:o,style:r,context:s,...i}){const l=n("scrollContainerState"),a=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),u=t("scrollerRef"),g=t("horizontalDirection")||!1,{scrollByCallback:p,scrollerRef:S,scrollToCallback:R}=co(l,c,a,u,void 0,g);return e("scrollTo",R),e("scrollBy",p),m.jsx(a,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...g?Vr:Wr,...r},tabIndex:0,...i,...Se(a,s),children:o})})}function ho({useEmitter:e,useEmitterValue:t,usePublisher:n}){return x.memo(function({children:o,style:r,context:s,...i}){const l=n("windowScrollContainerState"),a=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),u=t("totalListHeight"),g=t("deviation"),p=t("customScrollParent"),S=x.useRef(null),R=t("scrollerRef"),{scrollByCallback:E,scrollerRef:v,scrollToCallback:f}=co(l,c,a,R,p);return ao(()=>{var h;return v.current=p||((h=S.current)==null?void 0:h.ownerDocument.defaultView),()=>{v.current=null}},[v,p]),e("windowScrollTo",f),e("scrollBy",E),m.jsx(a,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...r,...u!==0?{height:u+g}:{}},...i,...Se(a,s),children:o})})}const Jr=({children:e})=>{const t=x.useContext(io),n=je("viewportHeight"),o=je("fixedItemHeight"),r=W("alignToBottom"),s=W("horizontalDirection"),i=x.useMemo(()=>Ln(n,a=>Fe(a,s?"width":"height")),[n,s]),l=Je(i,!0,W("skipAnimationFrameInResizeObserver"));return x.useEffect(()=>{t&&(n(t.viewportHeight),o(t.itemHeight))},[t,n,o]),m.jsx("div",{"data-viewport-type":"element",ref:l,style:Rt(r),children:e})},qr=({children:e})=>{const t=x.useContext(io),n=je("windowViewportRect"),o=je("fixedItemHeight"),r=W("customScrollParent"),s=_n(n,r,W("skipAnimationFrameInResizeObserver")),i=W("alignToBottom");return x.useEffect(()=>{t&&(o(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,o]),m.jsx("div",{"data-viewport-type":"window",ref:s,style:Rt(i),children:e})},Xr=({children:e})=>{const t=W("TopItemListComponent")||"div",n=W("headerHeight"),o={...$r,marginTop:`${n}px`},r=W("context");return m.jsx(t,{style:o,...Se(t,r),children:e})},Zr=x.memo(function(e){const t=W("useWindowScroll"),n=W("topItemsIndexes").length>0,o=W("customScrollParent"),r=W("context");return m.jsxs(o||t?es:Qr,{...e,context:r,children:[n&&m.jsx(Xr,{children:m.jsx(Tn,{showTopList:!0})}),m.jsxs(o||t?qr:Jr,{children:[m.jsx(Gr,{}),m.jsx(Tn,{}),m.jsx(Yr,{})]})]})}),{Component:Kr,useEmitter:Kt,useEmitterValue:W,usePublisher:je}=so(Nr,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Zr),Qr=fo({useEmitter:Kt,useEmitterValue:W,usePublisher:je}),es=ho({useEmitter:Kt,useEmitterValue:W,usePublisher:je}),ts=Kr,ns=q(()=>{const e=I(c=>m.jsxs("td",{children:["Item $",c]})),t=I(null),n=I(c=>m.jsxs("td",{colSpan:1e3,children:["Group ",c]})),o=I(null),r=I(null),s=I({}),i=I(Zt),l=I(et),a=(c,u=null)=>Te(T(s,O(g=>g[c]),se()),u);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:a("EmptyPlaceholder"),FillerRow:a("FillerRow"),fixedFooterContent:r,fixedHeaderContent:o,itemContent:e,groupContent:n,ScrollerComponent:a("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:a("ScrollSeekPlaceholder"),TableBodyComponent:a("TableBody","tbody"),TableComponent:a("Table","table"),TableFooterComponent:a("TableFoot","tfoot"),TableHeadComponent:a("TableHead","thead"),TableRowComponent:a("TableRow","tr"),GroupComponent:a("Group","tr")}});ie(ro,ns);Xt();const bn={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},os={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:yn,floor:Tt,max:rt,min:Ht,round:In}=Math;function Rn(e,t,n){return Array.from({length:t-e+1}).map((o,r)=>({data:n===null?null:n[r+e],index:r+e}))}function rs(e){return{...os,items:e}}function vt(e,t){return e&&e.width===t.width&&e.height===t.height}function ss(e,t){return e&&e.column===t.column&&e.row===t.row}const is=q(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:o},{footerHeight:r,headerHeight:s,scrollBy:i,scrollContainerState:l,scrollTo:a,scrollTop:c,smoothScrollTargetReached:u,viewportHeight:g},p,S,{didMount:R,propsReady:E},{customScrollParent:v,useWindowScroll:f,windowScrollContainerState:h,windowScrollTo:b,windowViewportRect:P},z])=>{const M=I(0),d=I(0),C=I(bn),y=I({height:0,width:0}),k=I({height:0,width:0}),H=Y(),F=Y(),D=I(0),A=I(null),V=I({column:0,row:0}),X=Y(),K=Y(),ve=I(!1),we=I(0),Ce=I(!0),w=I(!1),L=I(!1);Z(T(R,U(we),_(([j,G])=>!!G)),()=>{$(Ce,!1)}),Z(T(de(R,Ce,k,y,we,w),_(([j,G,oe,pe,,Ee])=>j&&!G&&oe.height!==0&&pe.height!==0&&!Ee)),([,,,,j])=>{$(w,!0),Gt(1,()=>{$(H,j)}),Pe(T(c),()=>{$(t,[0,0]),$(Ce,!0)})}),B(T(K,_(j=>j!=null&&j.scrollTop>0),Ae(0)),d),Z(T(R,U(K),_(([,j])=>j!=null)),([,j])=>{j&&($(y,j.viewport),$(k,j.item),$(V,j.gap),j.scrollTop>0&&($(ve,!0),Pe(T(c,Ge(1)),G=>{$(ve,!1)}),$(a,{top:j.scrollTop})))}),B(T(y,O(({height:j})=>j)),g),B(T(de(N(y,vt),N(k,vt),N(V,(j,G)=>j&&j.column===G.column&&j.row===G.row),N(c)),O(([j,G,oe,pe])=>({gap:oe,item:G,scrollTop:pe,viewport:j}))),X),B(T(de(N(M),o,N(V,ss),N(k,vt),N(y,vt),N(A),N(d),N(ve),N(Ce),N(we)),_(([,,,,,,,j])=>!j),O(([j,[G,oe],pe,Ee,fe,ce,me,,ue,te])=>{const{column:re,row:ke}=pe,{height:ge,width:Et}=Ee,{width:Qt}=fe;if(me===0&&(j===0||Qt===0))return bn;if(Et===0){const rn=Yt(te,j),So=rn+Math.max(me-1,0);return rs(Rn(rn,So,ce))}const pt=mo(Qt,Et,re);let Xe,$e;ue?G===0&&oe===0&&me>0?(Xe=0,$e=me-1):(Xe=pt*Tt((G+ke)/(ge+ke)),$e=pt*yn((oe+ke)/(ge+ke))-1,$e=Ht(j-1,rt($e,pt-1)),Xe=Ht($e,rt(0,Xe))):(Xe=0,$e=-1);const en=Rn(Xe,$e,ce),{bottom:tn,top:nn}=En(fe,pe,Ee,en),on=yn(j/pt),Co=on*ge+(on-1)*ke-tn;return{bottom:tn,itemHeight:ge,items:en,itemWidth:Et,offsetBottom:Co,offsetTop:nn,top:nn}})),C),B(T(A,_(j=>j!==null),O(j=>j.length)),M),B(T(de(y,k,C,V),_(([j,G,{items:oe}])=>oe.length>0&&G.height!==0&&j.height!==0),O(([j,G,{items:oe},pe])=>{const{bottom:Ee,top:fe}=En(j,pe,G,oe);return[fe,Ee]}),se(lt)),t);const J=I(!1);B(T(c,U(J),O(([j,G])=>G||j!==0)),J);const Q=Re(T(de(C,M),_(([{items:j}])=>j.length>0),U(J),_(([[j,G],oe])=>{const pe=j.items[j.items.length-1].index===G-1;return(oe||j.bottom>0&&j.itemHeight>0&&j.offsetBottom===0&&j.items.length===G)&&pe}),O(([[,j]])=>j-1),se())),Be=Re(T(N(C),_(({items:j})=>j.length>0&&j[0].index===0),Ae(0),se())),Me=Re(T(N(C),U(ve),_(([{items:j},G])=>j.length>0&&!G),O(([{items:j}])=>({endIndex:j[j.length-1].index,startIndex:j[0].index})),se(Un),_e(0)));B(Me,S.scrollSeekRangeChanged),B(T(H,U(y,k,M,V),O(([j,G,oe,pe,Ee])=>{const fe=Xn(j),{align:ce,behavior:me,offset:ue}=fe;let te=fe.index;te==="LAST"&&(te=pe-1),te=rt(0,te,Ht(pe-1,te));let re=_t(G,Ee,oe,te);return ce==="end"?re=In(re-G.height+oe.height):ce==="center"&&(re=In(re-G.height/2+oe.height/2)),ue&&(re+=ue),{behavior:me,top:re}})),a);const ee=Te(T(C,O(j=>j.offsetBottom+j.bottom)),0);return B(T(P,O(j=>({height:j.visibleHeight,width:j.visibleWidth}))),y),{customScrollParent:v,data:A,deviation:D,footerHeight:r,gap:V,headerHeight:s,increaseViewportBy:e,initialItemCount:d,itemDimensions:k,overscan:n,restoreStateFrom:K,scrollBy:i,scrollContainerState:l,scrollHeight:F,scrollTo:a,scrollToIndex:H,scrollTop:c,smoothScrollTargetReached:u,totalCount:M,useWindowScroll:f,viewportDimensions:y,windowScrollContainerState:h,windowScrollTo:b,windowViewportRect:P,...S,gridState:C,horizontalDirection:L,initialTopMostItemIndex:we,totalListHeight:ee,...p,endReached:Q,propsReady:E,rangeChanged:Me,startReached:Be,stateChanged:X,stateRestoreInProgress:ve,...z}},ie(Jt,be,mt,no,Ve,qt,We));function mo(e,t,n){return rt(1,Tt((e+n)/(Tt(t)+n)))}function En(e,t,n,o){const{height:r}=n;if(r===void 0||o.length===0)return{bottom:0,top:0};const s=_t(e,t,n,o[0].index);return{bottom:_t(e,t,n,o[o.length-1].index)+r,top:s}}function _t(e,t,n,o){const r=mo(e.width,n.width,t.column),s=Tt(o/r),i=s*n.height+rt(0,s-1)*t.row;return i>0?i+t.row:i}const ls=q(()=>{const e=I(g=>`Item ${g}`),t=I({}),n=I(null),o=I("virtuoso-grid-item"),r=I("virtuoso-grid-list"),s=I(Zt),i=I("div"),l=I(et),a=(g,p=null)=>Te(T(t,O(S=>S[g]),se()),p),c=I(!1),u=I(!1);return B(N(u),c),{components:t,computeItemKey:s,context:n,FooterComponent:a("Footer"),HeaderComponent:a("Header"),headerFooterTag:i,itemClassName:o,ItemComponent:a("Item","div"),itemContent:e,listClassName:r,ListComponent:a("List","div"),readyStateChanged:c,reportReadyState:u,ScrollerComponent:a("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:a("ScrollSeekPlaceholder","div")}}),as=q(([e,t])=>({...e,...t}),ie(is,ls)),cs=x.memo(function(){const e=le("gridState"),t=le("listClassName"),n=le("itemClassName"),o=le("itemContent"),r=le("computeItemKey"),s=le("isSeeking"),i=ze("scrollHeight"),l=le("ItemComponent"),a=le("ListComponent"),c=le("ScrollSeekPlaceholder"),u=le("context"),g=ze("itemDimensions"),p=ze("gap"),S=le("log"),R=le("stateRestoreInProgress"),E=ze("reportReadyState"),v=Je(x.useMemo(()=>f=>{const h=f.parentElement.parentElement.scrollHeight;i(h);const b=f.firstChild;if(b){const{height:P,width:z}=b.getBoundingClientRect();g({height:P,width:z})}p({column:kn("column-gap",getComputedStyle(f).columnGap,S),row:kn("row-gap",getComputedStyle(f).rowGap,S)})},[i,g,p,S]),!0,!1);return ao(()=>{e.itemHeight>0&&e.itemWidth>0&&E(!0)},[e]),R?null:m.jsx(a,{className:t,ref:v,...Se(a,u),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(f=>{const h=r(f.index,f.data,u);return s?m.jsx(c,{...Se(c,u),height:e.itemHeight,index:f.index,width:e.itemWidth},h):x.createElement(l,{...Se(l,u),className:n,"data-index":f.index,key:h},o(f.index,f.data,u))})})}),us=x.memo(function(){const e=le("HeaderComponent"),t=ze("headerHeight"),n=le("headerFooterTag"),o=Je(x.useMemo(()=>s=>{t(Fe(s,"height"))},[t]),!0,!1),r=le("context");return e?m.jsx(n,{ref:o,children:m.jsx(e,{...Se(e,r)})}):null}),ds=x.memo(function(){const e=le("FooterComponent"),t=ze("footerHeight"),n=le("headerFooterTag"),o=Je(x.useMemo(()=>s=>{t(Fe(s,"height"))},[t]),!0,!1),r=le("context");return e?m.jsx(n,{ref:o,children:m.jsx(e,{...Se(e,r)})}):null}),fs=({children:e})=>{const t=x.useContext(lo),n=ze("itemDimensions"),o=ze("viewportDimensions"),r=Je(x.useMemo(()=>s=>{o(s.getBoundingClientRect())},[o]),!0,!1);return x.useEffect(()=>{t&&(o({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,o,n]),m.jsx("div",{ref:r,style:Rt(!1),children:e})},hs=({children:e})=>{const t=x.useContext(lo),n=ze("windowViewportRect"),o=ze("itemDimensions"),r=le("customScrollParent"),s=_n(n,r,!1);return x.useEffect(()=>{t&&(o({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,o]),m.jsx("div",{ref:s,style:Rt(!1),children:e})},ms=x.memo(function({...e}){const t=le("useWindowScroll"),n=le("customScrollParent"),o=n||t?gs:ps,r=n||t?hs:fs,s=le("context");return m.jsx(o,{...e,...Se(o,s),children:m.jsxs(r,{children:[m.jsx(us,{}),m.jsx(cs,{}),m.jsx(ds,{})]})})}),{useEmitter:po,useEmitterValue:le,usePublisher:ze}=so(as,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},ms),ps=fo({useEmitter:po,useEmitterValue:le,usePublisher:ze}),gs=ho({useEmitter:po,useEmitterValue:le,usePublisher:ze});function kn(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,ye.WARN),t==="normal"?0:parseInt(t??"0",10)}const xs=({visible:e,onClick:t})=>e?m.jsx("button",{type:"button",className:"chat-scroll-bottom",onClick:t,"aria-label":"Scroll to bottom",children:m.jsx("img",{src:Mn,alt:"arrow up",width:24,height:24,style:{transform:"rotate(180deg)",filter:"var(--icon-filter-text)"}})}):null,vs=()=>{const{messages:e=[],classNames:t,isOpen:n,isLoading:o}=Ye(),[r,s]=x.useState(!1),i=x.useRef(null),l=()=>{i.current?.scrollToIndex({index:e.length-1,behavior:"smooth"})},a=e?.length??1;return x.useEffect(()=>{n&&setTimeout(l,0)},[n]),x.useEffect(()=>{l()},[e?.length]),m.jsxs("div",{className:Oe("autoui-chat-messages",t?.messageList),children:[m.jsx(ts,{ref:i,data:e,overscan:100,followOutput:"smooth",atBottomStateChange:c=>s(!c),components:{EmptyPlaceholder:()=>m.jsxs("div",{className:"empty__palceholder",children:[m.jsx("span",{className:"empty__palceholder--main",children:"Nothing here yet"}),m.jsx("span",{className:"empty__palceholder--secondary",children:"Start the conversation!"})]})},initialTopMostItemIndex:a-1,itemContent:(c,u)=>m.jsx("div",{className:Oe("autoui-message-row",u.role==="user"&&"is-user",u.role==="assistant"&&"is-assistant"),children:m.jsx(Uo,{message:u})})}),m.jsx(xs,{visible:r,onClick:l}),o&&m.jsx(Ro,{variant:"dots",color:"#0a84ff"})]})};async function go(e){const t=e.getReader(),n=new TextDecoder;let o="",r="";for(;;){const{value:i,done:l}=await t.read();if(l)break;o+=n.decode(i,{stream:!0});const a=o.split(`
8
-
9
- `);o=a.pop()??"";for(const c of a){if(!c.startsWith("data:"))continue;const u=c.slice(5).trim();if(u==="[DONE]"){t.cancel();break}try{const p=JSON.parse(u).choices?.[0]?.delta?.content;p&&(r+=p)}catch{}}}const s=r.match(/\{[\s\S]*\}$/);if(!s)throw new Error("LLM did not return valid JSON InstructionPlan");return JSON.parse(s[0])}function ws(e,t){const n=Object.entries(t.functions).map(([i,l])=>{const a=l.params?Object.entries(l.params).map(([c,u])=>`- ${c}: ${u}`).join(`
10
- `):"(no documented params)";return`FUNCTION ${i}:
11
- Description: ${l.prompt}
12
- Params:
13
- ${a}`}),o=Object.entries(t.components).map(([i,l])=>{const a=l.props?Object.entries(l.props).map(([c,u])=>`- ${c}: ${u}`).join(`
14
- `):"(no documented props)";return`COMPONENT ${i}:
15
- Description: ${l.prompt}
16
- Props:
17
- ${a}`});return[`You are AutoUI Intent Planner.
18
- Return ONLY a valid JSON InstructionPlan and nothing else.
19
- Do not wrap in markdown fences. Do not include any fields outside the schema.
20
-
21
- SCHEMA (must match exactly):
6
+ <%s key={someKey} {...props} />`,K,ee,P,ee),ve[ee+K]=!0)}if(ee=null,G!==void 0&&(o(G),ee=""+G),a(_)&&(o(_.key),ee=""+_.key),"key"in _){G={};for(var J in _)J!=="key"&&(G[J]=_[J])}else G=_;return ee&&i(G,typeof I=="function"?I.displayName||I.name||"Unknown":I),c(I,ee,G,r(),Le,Me)}function p(I){m(I)?I._store&&(I._store.validated=1):typeof I=="object"&&I!==null&&I.$$typeof===k&&(I._payload.status==="fulfilled"?m(I._payload.value)&&I._payload.value._store&&(I._payload.value._store.validated=1):I._store&&(I._store.validated=1))}function m(I){return typeof I=="object"&&I!==null&&I.$$typeof===$}var h=C,$=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),g=Symbol.for("react.consumer"),T=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),j=Symbol.for("react.client.reference"),N=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=Object.prototype.hasOwnProperty,V=Array.isArray,D=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(I){return I()}};var X,Q={},we=h.react_stack_bottom_frame.bind(h,s)(),xe=D(n(s)),ve={};nt.Fragment=w,nt.jsx=function(I,_,G){var K=1e4>N.recentlyCreatedOwnerStacks++;return u(I,_,G,!1,K?Error("react-stack-top-frame"):we,K?D(n(I)):xe)},nt.jsxs=function(I,_,G){var K=1e4>N.recentlyCreatedOwnerStacks++;return u(I,_,G,!0,K?Error("react-stack-top-frame"):we,K?D(n(I)):xe)}})()),nt}var ho;function zn(){return ho||(ho=1,process.env.NODE_ENV==="production"?xt.exports=Vn():xt.exports=Nn()),xt.exports}var S=zn();function Ho(e){var t,o,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(o=Ho(e[t]))&&(n&&(n+=" "),n+=o)}else for(o in e)e[o]&&(n&&(n+=" "),n+=o);return n}function ye(){for(var e,t,o=0,n="",r=arguments.length;o<r;o++)(e=arguments[o])&&(t=Ho(e))&&(n&&(n+=" "),n+=t);return n}const _n=C.forwardRef(({variant:e="default",label:t,className:o,classNames:n={},color:r="currentColor",...s},a)=>{const i=C.useMemo(()=>{switch(e){case"wave":case"dots":return S.jsx("div",{className:ye("spinner-dots-wrapper",n.wrapper),children:[0,1,2].map(l=>S.jsx("i",{className:ye("spinner-dot",n.dots),style:{animationDelay:`${l*.2}s`,backgroundColor:r}},l))});case"simple":return S.jsxs("svg",{className:ye("spinner-simple",n.wrapper),width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",style:{color:r},children:[S.jsx("circle",{className:ye("spinner-simple-circle1",n.circle1),cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),S.jsx("path",{className:ye("spinner-simple-circle2",n.circle2),fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.37 0 0 5.37 0 12h4z"})]});case"spinner":return S.jsx("div",{className:ye("spinner-bars-wrapper",n.wrapper),children:[...Array(12)].map((l,c)=>S.jsx("i",{className:ye("spinner-bar",n.spinnerBars),style:{transform:`rotate(${c*30}deg) translateY(-8px)`,animationDelay:`${c*.1}s`,backgroundColor:r}},c))});default:return S.jsxs("div",{className:ye("spinner-default",n.wrapper),children:[S.jsx("i",{className:ye("spinner-default-circle1",n.circle1),style:{borderColor:r}}),S.jsx("i",{className:ye("spinner-default-circle2",n.circle2),style:{borderColor:r}})]})}},[e,n,r]);return S.jsxs("div",{ref:a,className:ye("spinner-base",o),"aria-label":t||"Loading",...s,children:[i,t&&S.jsx("span",{className:ye("spinner-label",n.label),children:t})]})}),Bo=C.createContext(void 0),Hn=({children:e,value:t,config:o})=>S.jsx(Bo.Provider,{value:{...t,config:o},children:e}),Ge=()=>{const e=C.useContext(Bo);if(!e)throw new Error("useChatContext must be used within a ChatProvider");return e};function Ae(...e){return e.filter(Boolean).join(" ")}const Fo="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2012H20M12%204V20'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Do="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20640%20640'%3e%3c!--!Font%20Awesome%20Free%207.1.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license/free%20Copyright%202025%20Fonticons,%20Inc.--%3e%3cpath%20d='M183.1%20137.4C170.6%20124.9%20150.3%20124.9%20137.8%20137.4C125.3%20149.9%20125.3%20170.2%20137.8%20182.7L275.2%20320L137.9%20457.4C125.4%20469.9%20125.4%20490.2%20137.9%20502.7C150.4%20515.2%20170.7%20515.2%20183.2%20502.7L320.5%20365.3L457.9%20502.6C470.4%20515.1%20490.7%20515.1%20503.2%20502.6C515.7%20490.1%20515.7%20469.8%20503.2%20457.3L365.8%20320L503.1%20182.6C515.6%20170.1%20515.6%20149.8%20503.1%20137.3C490.6%20124.8%20470.3%20124.8%20457.8%20137.3L320.5%20274.7L183.1%20137.4z'/%3e%3c/svg%3e",Uo="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%206V18M12%206L7%2011M12%206L17%2011'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",Bn="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4%2018L20%2018'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M4%2012L20%2012'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M4%206L20%206'%20stroke='%23000000'%20stroke-width='2'%20stroke-linecap='round'/%3e%3c/svg%3e",Fn="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%201024%201024'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill='%23000000'%20d='M352%20192V95.936a32%2032%200%200%201%2032-32h256a32%2032%200%200%201%2032%2032V192h256a32%2032%200%201%201%200%2064H96a32%2032%200%200%201%200-64h256zm64%200h192v-64H416v64zM192%20960a32%2032%200%200%201-32-32V256h704v672a32%2032%200%200%201-32%2032H192zm224-192a32%2032%200%200%200%2032-32V416a32%2032%200%200%200-64%200v320a32%2032%200%200%200%2032%2032zm192%200a32%2032%200%200%200%2032-32V416a32%2032%200%200%200-64%200v320a32%2032%200%200%200%2032%2032z'/%3e%3c/svg%3e",Dn="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20640%20640'%3e%3c!--!Font%20Awesome%20Free%207.1.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license/free%20Copyright%202025%20Fonticons,%20Inc.--%3e%3cpath%20d='M210.2%2053.9C217.6%2050.8%20226%2051.7%20232.7%2056.1L320.5%20114.3L408.3%2056.1C415%2051.7%20423.4%2050.9%20430.8%2053.9C438.2%2056.9%20443.4%2063.5%20445%2071.3L465.9%20174.5L569.1%20195.4C576.9%20197%20583.5%20202.4%20586.5%20209.7C589.5%20217%20588.7%20225.5%20584.3%20232.2L526.1%20320L584.3%20407.8C588.7%20414.5%20589.5%20422.9%20586.5%20430.3C583.5%20437.7%20576.9%20443.1%20569.1%20444.6L465.8%20465.4L445%20568.7C443.4%20576.5%20438%20583.1%20430.7%20586.1C423.4%20589.1%20414.9%20588.3%20408.2%20583.9L320.4%20525.7L232.6%20583.9C225.9%20588.3%20217.5%20589.1%20210.1%20586.1C202.7%20583.1%20197.3%20576.5%20195.8%20568.7L175%20465.4L71.7%20444.5C63.9%20442.9%2057.3%20437.5%2054.3%20430.2C51.3%20422.9%2052.1%20414.4%2056.5%20407.7L114.7%20320L56.5%20232.2C52.1%20225.5%2051.3%20217.1%2054.3%20209.7C57.3%20202.3%2063.9%20196.9%2071.7%20195.4L175%20174.6L195.9%2071.3C197.5%2063.5%20202.9%2056.9%20210.2%2053.9zM239.6%20320C239.6%20275.6%20275.6%20239.6%20320%20239.6C364.4%20239.6%20400.4%20275.6%20400.4%20320C400.4%20364.4%20364.4%20400.4%20320%20400.4C275.6%20400.4%20239.6%20364.4%20239.6%20320zM448.4%20320C448.4%20249.1%20390.9%20191.6%20320%20191.6C249.1%20191.6%20191.6%20249.1%20191.6%20320C191.6%20390.9%20249.1%20448.4%20320%20448.4C390.9%20448.4%20448.4%20390.9%20448.4%20320z'/%3e%3c/svg%3e",Un="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20640%20640'%3e%3c!--!Font%20Awesome%20Free%207.1.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license/free%20Copyright%202025%20Fonticons,%20Inc.--%3e%3cpath%20d='M320%2064C178.6%2064%2064%20178.6%2064%20320C64%20461.4%20178.6%20576%20320%20576C388.8%20576%20451.3%20548.8%20497.3%20504.6C504.6%20497.6%20506.7%20486.7%20502.6%20477.5C498.5%20468.3%20488.9%20462.6%20478.8%20463.4C473.9%20463.8%20469%20464%20464%20464C362.4%20464%20280%20381.6%20280%20280C280%20207.9%20321.5%20145.4%20382.1%20115.2C391.2%20110.7%20396.4%20100.9%20395.2%2090.8C394%2080.7%20386.6%2072.5%20376.7%2070.3C358.4%2066.2%20339.4%2064%20320%2064z'/%3e%3c/svg%3e",Wn="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20640%20640'%3e%3c!--!Font%20Awesome%20Free%207.1.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license/free%20Copyright%202025%20Fonticons,%20Inc.--%3e%3cpath%20d='M320%2064C267%2064%20224%20107%20224%20160L224%20288C224%20341%20267%20384%20320%20384C373%20384%20416%20341%20416%20288L416%20160C416%20107%20373%2064%20320%2064zM176%20248C176%20234.7%20165.3%20224%20152%20224C138.7%20224%20128%20234.7%20128%20248L128%20288C128%20385.9%20201.3%20466.7%20296%20478.5L296%20528L248%20528C234.7%20528%20224%20538.7%20224%20552C224%20565.3%20234.7%20576%20248%20576L392%20576C405.3%20576%20416%20565.3%20416%20552C416%20538.7%20405.3%20528%20392%20528L344%20528L344%20478.5C438.7%20466.7%20512%20385.9%20512%20288L512%20248C512%20234.7%20501.3%20224%20488%20224C474.7%20224%20464%20234.7%20464%20248L464%20288C464%20367.5%20399.5%20432%20320%20432C240.5%20432%20176%20367.5%20176%20288L176%20248z'/%3e%3c/svg%3e",Jn=({isOpen:e,onClose:t,triggerRef:o,children:n,styles:r,position:s="top-center"})=>{const a=C.useRef(null);if(C.useEffect(()=>{const c=u=>{a.current&&!a.current.contains(u.target)&&!o.current?.contains(u.target)&&t()};return e&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[e,t,o]),!e||!o.current)return null;const i=o.current.getBoundingClientRect();let l={};switch(s){case"top-center":l={width:"50%",transform:"translate(-2.5%, -110%)"};break;case"bottom-left":l={top:i.bottom+6+window.scrollY,left:i.left+window.scrollX};break;case"bottom-right":l={top:i.bottom+6+window.scrollY,left:i.right+window.scrollX,transform:"translateX(-100%)"};break}return S.jsx("div",{ref:a,style:{position:"absolute",zIndex:9999,...l,...r},children:n})};function qn({isSelected:e,disableAnimation:t,...o}){return S.jsx("svg",{"aria-hidden":"true","data-selected":e,role:"presentation",viewBox:"0 0 17 18",...o,children:S.jsx("polyline",{fill:"none",points:"1 9 7 14 15 4",stroke:"currentColor",strokeDasharray:22,strokeDashoffset:e?44:66,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,style:t?{}:{transition:"stroke-dashoffset 200ms ease"}})})}const Gn=({label:e,description:t,shortcut:o,startContent:n,endContent:r,isSelected:s,isDisabled:a,onSelect:i,disableAnimation:l,hideSelectedIcon:c,selectedIcon:u})=>{const p=C.useMemo(()=>{const m=S.jsx(qn,{disableAnimation:l,isSelected:!!s});return typeof u=="function"?u({icon:m,isSelected:s,isDisabled:a}):u||m},[u,s,a,l]);return S.jsxs("li",{className:`hero-menu-item ${s?"selected":""} ${a?"disabled":""}`,onClick:()=>{console.log(1),!a&&i?.()},children:[n&&S.jsx("span",{className:"start",children:n}),S.jsxs("div",{className:"content",children:[S.jsx("span",{className:"label",children:e}),t&&S.jsx("span",{className:"description",children:t})]}),o&&S.jsx("kbd",{className:"shortcut",children:o}),!c&&S.jsx("span",{className:"selected-icon",children:p}),r&&S.jsx("span",{className:"end",children:r})]})},Yn=({items:e,defaultSelectedKey:t,onSelectionChange:o})=>{const[n,r]=C.useState(t),s=a=>{r(a),o?.(a)};return S.jsx("ul",{className:"hero-menu",children:e.map(a=>S.jsx(Gn,{label:a.label,description:a.description,shortcut:a.shortcut,startContent:a.startContent,endContent:a.endContent,isSelected:a.key===n,isDisabled:a.isDisabled,onSelect:()=>{a?.onSelect?.(),s(a.key)}},a.key))})},Xn=({items:e,button:t,popoverStyles:o,defaultSelectedKey:n,closeAfterSelect:r,onSelectionChange:s})=>{const a=C.useRef(null),[i,l]=C.useState(!1),c={ref:a,onClick:()=>{l(u=>!u)},style:{cursor:"pointer"}};return S.jsxs(S.Fragment,{children:[t?C.cloneElement(t,c):S.jsx("button",{ref:a,onClick:()=>l(u=>!u),style:{cursor:"pointer"},children:S.jsx("img",{src:Bn,alt:"menu"})}),S.jsx(Jn,{styles:o,isOpen:i,onClose:()=>l(!1),triggerRef:a,children:S.jsx("div",{style:{borderRadius:10,zIndex:9999,boxShadow:"0 4px 12px rgba(0,0,0,0.12)"},children:S.jsx(Yn,{items:e,defaultSelectedKey:n,onSelectionChange:u=>{s?.(u),r?.(u)&&l(!1)}})})})]})},Zn=Mt.forwardRef(function({checked:t,defaultChecked:o,onCheckedChange:n,disabled:r=!1,required:s=!1,name:a,value:i,id:l,label:c,description:u,size:p="md",className:m,trackClassName:h,thumbClassName:$,labelClassName:x,startContent:w,endContent:y,thumb:d,"aria-label":g,"aria-labelledby":T},b){const E=typeof t=="boolean",[f,v]=Mt.useState(!!o),k=E?!!t:f,A=l??Mt.useId(),j=z=>{const V=z.target.checked;E||v(V),n?.(V,z)},N=d?.({checked:k,disabled:r,size:p})??(k?y:w);return S.jsxs("label",{className:Ae("autoui-switch",`autoui-switch--${p}`,r&&"is-disabled",m),htmlFor:A,children:[S.jsxs("span",{className:Ae("autoui-switch__control",h),"aria-hidden":"true",children:[S.jsx("input",{ref:b,id:A,className:"autoui-switch__input",type:"checkbox",checked:k,defaultChecked:o,onChange:j,disabled:r,required:s,name:a,value:i,"aria-label":g,"aria-labelledby":T}),S.jsx("span",{className:Ae("autoui-switch__track")}),S.jsx("span",{className:Ae("autoui-switch__thumb",$),children:N?S.jsx("span",{className:"autoui-switch__thumbContent",children:N}):null})]}),(c||u)&&S.jsxs("span",{className:Ae("autoui-switch__text",x),children:[c&&S.jsx("span",{className:"autoui-switch__label",children:c}),u&&S.jsx("span",{className:"autoui-switch__description",children:u})]})]})}),Qn=()=>{const{handleClear:e,setTheme:t,theme:o}=Ge();return S.jsx(Xn,{popoverStyles:{position:"absolute"},button:S.jsx("button",{type:"button",className:"autoui-chat-input-start",children:S.jsx("img",{src:Fo,alt:"menu",width:20,height:20,style:{filter:"var(--icon-filter-text)"}})}),items:[{startContent:S.jsx("img",{src:Fn,width:16,height:16,style:{filter:"var(--icon-filter-text)"}}),key:"clear",label:"Clear Messages",onSelect:e},{key:"switchTheme",label:S.jsx(Zn,{defaultChecked:o==="light",onCheckedChange:n=>{t?.(n?"light":"dark")},label:"Theme mode",thumb:({checked:n})=>S.jsx(S.Fragment,{children:n?S.jsx("img",{src:Dn,width:14,height:14,style:{filter:"var(--icon-filter-accent)"}}):S.jsx("img",{src:Un,width:14,height:14,style:{filter:"var(--icon-filter-text)"}})})})}],closeAfterSelect:n=>n!=="switchTheme",onSelectionChange:n=>console.log("Selected:",n)})},Kn=({value:e,setValue:t})=>{const{classNames:o}=Ge();return S.jsx("input",{role:"input",className:Ae("autoui-chat-textbox",o?.input),type:"text",value:e,autoFocus:!0,onChange:n=>t(n.target.value),placeholder:"Type a message...","aria-label":"Message input"})},er=()=>{const{classNames:e}=Ge();return S.jsx("button",{role:"inputButton",type:"submit",className:Ae("autoui-chat-send",e?.inputButton),"aria-label":"Send message",children:S.jsx("img",{src:Uo,alt:"arrow up",width:24,height:24,style:{filter:"var(--icon-filter-text)"}})})},tr=({lang:e="en-us"}={})=>{const t=C.useRef(null),[o,n]=C.useState(""),[r,s]=C.useState(!1),a=typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window),i=C.useCallback(()=>{if(!a||r)return;const c=window.SpeechRecognition||window.webkitSpeechRecognition;if(!c)return;const u=new c;u.lang=e,u.continuous=!1,u.interimResults=!1,u.onstart=()=>s(!0),u.onend=()=>s(!1),u.onresult=p=>{const m=p.results[0][0].transcript;n(m),s(!1)},u.onerror=()=>{u.stop(),s(!1)},t.current=u,u.start()},[a,r,e]),l=C.useCallback(()=>{t.current?.stop(),s(!1)},[]);return{start:i,stop:l,text:o,listening:r,isSupported:a}},or=({active:e,onClick:t})=>S.jsx("button",{type:"button",className:`chat-mic-btn ${e?"is-active":""}`,onClick:t,"aria-label":"Voice input",children:S.jsx("img",{src:Wn,width:20,height:20,style:{filter:"var(--icon-filter-text)"}})}),nr=()=>{const{classNames:e,handleSend:t}=Ge(),[o,n]=C.useState(""),r=tr({lang:"en-us"});C.useEffect(()=>{r.text&&n(a=>a?`${a} ${r.text}`:r.text)},[r.text]);const s=a=>{a.preventDefault(),t(o),n("")};return S.jsxs("form",{className:Ae("autoui-chat-input",e?.inputWrapper),onSubmit:s,children:[S.jsx(Qn,{}),S.jsx(Kn,{value:o,setValue:n}),r.isSupported&&S.jsx(or,{active:r.listening,onClick:()=>{r.listening?r.stop():r.start()}}),S.jsx(er,{})]})},rr=({message:e})=>{const t=e.role==="user",{classNames:o}=Ge(),n=typeof e.content=="string"||e.content instanceof String;return S.jsx("div",{role:"message",className:ye("autoui-chat-message",t?"user":"assistant",o?.message),"aria-label":t?"User message":"Assistant message",children:S.jsx("div",{className:`autoui-chat-bubble ${n?"autoui-chat-bubble--string":"autoui-chat-bubble--react-node"}`,children:e.content})})},Ot=0,Be=1,et=2,Wo=4;function go(e){return()=>e}function sr(e){e()}function Jo(e,t){return o=>e(t(o))}function yo(e,t){return()=>e(t)}function ir(e,t){return o=>e(t,o)}function qt(e){return e!==void 0}function ar(...e){return()=>{e.map(sr)}}function tt(){}function At(e,t){return t(e),e}function lr(e,t){return t(e)}function ie(...e){return e}function Z(e,t){return e(Be,t)}function U(e,t){e(Ot,t)}function Gt(e){e(et)}function le(e){return e(Wo)}function M(e,t){return Z(e,ir(t,Ot))}function je(e,t){const o=e(Be,n=>{o(),t(n)});return o}function wo(e){let t,o;return n=>r=>{t=r,o&&clearTimeout(o),o=setTimeout(()=>{n(t)},e)}}function qo(e,t){return e===t}function se(e=qo){let t;return o=>n=>{e(t,n)||(t=n,o(n))}}function B(e){return t=>o=>{e(o)&&t(o)}}function L(e){return t=>Jo(t,e)}function Ve(e){return t=>()=>{t(e)}}function R(e,...t){const o=cr(...t);return(n,r)=>{switch(n){case et:Gt(e);return;case Be:return Z(e,o(r))}}}function Ne(e,t){return o=>n=>{o(t=e(t,n))}}function qe(e){return t=>o=>{e>0?e--:t(o)}}function _e(e){let t=null,o;return n=>r=>{t=r,!o&&(o=setTimeout(()=>{o=void 0,n(t)},e))}}function W(...e){const t=new Array(e.length);let o=0,n=null;const r=Math.pow(2,e.length)-1;return e.forEach((s,a)=>{const i=Math.pow(2,a);Z(s,l=>{const c=o;o=o|i,t[a]=l,c!==r&&o===r&&n&&(n(),n=null)})}),s=>a=>{const i=()=>{s([a].concat(t))};o===r?i():n=i}}function cr(...e){return t=>e.reduceRight(lr,t)}function ur(e){let t,o;const n=()=>t?.();return function(r,s){switch(r){case Be:return s?o===s?void 0:(n(),o=s,t=Z(e,s),t):(n(),tt);case et:n(),o=null;return}}}function O(e){let t=e;const o=q();return(n,r)=>{switch(n){case Ot:t=r;break;case Be:{r(t);break}case Wo:return t}return o(n,r)}}function be(e,t){return At(O(t),o=>M(e,o))}function q(){const e=[];return(t,o)=>{switch(t){case Ot:e.slice().forEach(n=>{n(o)});return;case et:e.splice(0,e.length);return;case Be:return e.push(o),()=>{const n=e.indexOf(o);n>-1&&e.splice(n,1)}}}}function $e(e){return At(q(),t=>M(e,t))}function Y(e,t=[],{singleton:o}={singleton:!0}){return{constructor:e,dependencies:t,id:dr(),singleton:o}}const dr=()=>Symbol();function pr(e){const t=new Map,o=({constructor:n,dependencies:r,id:s,singleton:a})=>{if(a&&t.has(s))return t.get(s);const i=n(r.map(l=>o(l)));return a&&t.set(s,i),i};return o(e)}function de(...e){const t=q(),o=new Array(e.length);let n=0;const r=Math.pow(2,e.length)-1;return e.forEach((s,a)=>{const i=Math.pow(2,a);Z(s,l=>{o[a]=l,n=n|i,n===r&&U(t,o)})}),function(s,a){switch(s){case et:{Gt(t);return}case Be:return n===r&&a(o),Z(t,a)}}}function H(e,t=qo){return R(e,se(t))}function Bt(...e){return function(t,o){switch(t){case et:return;case Be:return ar(...e.map(n=>Z(n,o)))}}}var Ce=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ce||{});const fr={0:"debug",3:"error",1:"log",2:"warn"},mr=()=>typeof globalThis>"u"?window:globalThis,Fe=Y(()=>{const e=O(3);return{log:O((t,o,n=1)=>{var r;const s=(r=mr().VIRTUOSO_LOG_LEVEL)!=null?r:le(e);n>=s&&console[fr[n]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,o)}),logLevel:e}},[],{singleton:!0});function Ye(e,t,o){return Yt(e,t,o).callbackRef}function Yt(e,t,o){const n=C.useRef(null);let r=a=>{};const s=C.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(a=>{const i=()=>{const l=a[0].target;l.offsetParent!==null&&e(l)};o?i():requestAnimationFrame(i)}):null,[e,o]);return r=a=>{a&&t?(s?.observe(a),n.current=a):(n.current&&s?.unobserve(n.current),n.current=null)},{callbackRef:r,ref:n}}function hr(e,t,o,n,r,s,a,i,l){const c=C.useCallback(u=>{const p=gr(u.children,t,i?"offsetWidth":"offsetHeight",r);let m=u.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const h=m.lastElementChild.dataset.viewportType==="window";let $;h&&($=m.ownerDocument.defaultView);const x=a?i?a.scrollLeft:a.scrollTop:h?i?$.scrollX||$.document.documentElement.scrollLeft:$.scrollY||$.document.documentElement.scrollTop:i?m.scrollLeft:m.scrollTop,w=a?i?a.scrollWidth:a.scrollHeight:h?i?$.document.documentElement.scrollWidth:$.document.documentElement.scrollHeight:i?m.scrollWidth:m.scrollHeight,y=a?i?a.offsetWidth:a.offsetHeight:h?i?$.innerWidth:$.innerHeight:i?m.offsetWidth:m.offsetHeight;n({scrollHeight:w,scrollTop:Math.max(x,0),viewportHeight:y}),s?.(i?xo("column-gap",getComputedStyle(u).columnGap,r):xo("row-gap",getComputedStyle(u).rowGap,r)),p!==null&&e(p)},[e,t,r,s,a,n,i]);return Yt(c,o,l)}function gr(e,t,o,n){const r=e.length;if(r===0)return null;const s=[];for(let a=0;a<r;a++){const i=e.item(a);if(i.dataset.index===void 0)continue;const l=parseInt(i.dataset.index),c=parseFloat(i.dataset.knownSize),u=t(i,o);if(u===0&&n("Zero-sized element, this should not happen",{child:i},Ce.ERROR),u===c)continue;const p=s[s.length-1];s.length===0||p.size!==u||p.endIndex!==l-1?s.push({endIndex:l,size:u,startIndex:l}):s[s.length-1].endIndex++}return s}function xo(e,t,o){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&o(`${e} was not resolved to pixel value correctly`,t,Ce.WARN),t==="normal"?0:parseInt(t??"0",10)}function Go(e,t,o){const n=C.useRef(null),r=C.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),u=c.width;let p,m;if(t){const h=t.getBoundingClientRect(),$=c.top-h.top;m=h.height-Math.max(0,$),p=$+t.scrollTop}else{const h=a.current.ownerDocument.defaultView;m=h.innerHeight-Math.max(0,c.top),p=c.top+h.scrollY}n.current={offsetTop:p,visibleHeight:m,visibleWidth:u},e(n.current)},[e,t]),{callbackRef:s,ref:a}=Yt(r,!0,o),i=C.useCallback(()=>{r(a.current)},[r,a]);return C.useEffect(()=>{var l;if(t){t.addEventListener("scroll",i);const c=new ResizeObserver(()=>{requestAnimationFrame(i)});return c.observe(t),()=>{t.removeEventListener("scroll",i),c.unobserve(t)}}else{const c=(l=a.current)==null?void 0:l.ownerDocument.defaultView;return c?.addEventListener("scroll",i),c?.addEventListener("resize",i),()=>{c?.removeEventListener("scroll",i),c?.removeEventListener("resize",i)}}},[i,t,a]),s}const Te=Y(()=>{const e=q(),t=q(),o=O(0),n=q(),r=O(0),s=q(),a=q(),i=O(0),l=O(0),c=O(0),u=O(0),p=q(),m=q(),h=O(!1),$=O(!1),x=O(!1);return M(R(e,L(({scrollTop:w})=>w)),t),M(R(e,L(({scrollHeight:w})=>w)),a),M(t,r),{deviation:o,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:u,headerHeight:i,horizontalDirection:$,scrollBy:m,scrollContainerState:e,scrollHeight:a,scrollingInProgress:h,scrollTo:p,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:n,statefulScrollTop:r,viewportHeight:s}},[],{singleton:!0}),at={lvl:0};function Yo(e,t){const o=e.length;if(o===0)return[];let{index:n,value:r}=t(e[0]);const s=[];for(let a=1;a<o;a++){const{index:i,value:l}=t(e[a]);s.push({end:i-1,start:n,value:r}),n=i,r=l}return s.push({end:1/0,start:n,value:r}),s}function oe(e){return e===at}function lt(e,t){if(!oe(e))return t===e.k?e.v:t<e.k?lt(e.l,t):lt(e.r,t)}function Pe(e,t,o="k"){if(oe(e))return[-1/0,void 0];if(Number(e[o])===t)return[e.k,e.v];if(Number(e[o])<t){const n=Pe(e.r,t,o);return n[0]===-1/0?[e.k,e.v]:n}return Pe(e.l,t,o)}function Ie(e,t,o){return oe(e)?Qo(t,o,1):t===e.k?fe(e,{k:t,v:o}):t<e.k?vo(fe(e,{l:Ie(e.l,t,o)})):vo(fe(e,{r:Ie(e.r,t,o)}))}function Qe(){return at}function Ke(e,t,o){if(oe(e))return[];const n=Pe(e,t)[0];return yr(Dt(e,n,o))}function Ft(e,t){if(oe(e))return at;const{k:o,l:n,r}=e;if(t===o){if(oe(n))return r;if(oe(r))return n;{const[s,a]=Zo(n);return Tt(fe(e,{k:s,l:Xo(n),v:a}))}}else return t<o?Tt(fe(e,{l:Ft(n,t)})):Tt(fe(e,{r:Ft(r,t)}))}function We(e){return oe(e)?[]:[...We(e.l),{k:e.k,v:e.v},...We(e.r)]}function Dt(e,t,o){if(oe(e))return[];const{k:n,l:r,r:s,v:a}=e;let i=[];return n>t&&(i=i.concat(Dt(r,t,o))),n>=t&&n<=o&&i.push({k:n,v:a}),n<=o&&(i=i.concat(Dt(s,t,o))),i}function Tt(e){const{l:t,lvl:o,r:n}=e;if(n.lvl>=o-1&&t.lvl>=o-1)return e;if(o>n.lvl+1){if(Vt(t))return Ko(fe(e,{lvl:o-1}));if(!oe(t)&&!oe(t.r))return fe(t.r,{l:fe(t,{r:t.r.l}),lvl:o,r:fe(e,{l:t.r.r,lvl:o-1})});throw new Error("Unexpected empty nodes")}else{if(Vt(e))return Ut(fe(e,{lvl:o-1}));if(!oe(n)&&!oe(n.l)){const r=n.l,s=Vt(r)?n.lvl-1:n.lvl;return fe(r,{l:fe(e,{lvl:o-1,r:r.l}),lvl:r.lvl+1,r:Ut(fe(n,{l:r.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function fe(e,t){return Qo(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function Xo(e){return oe(e.r)?e.l:Tt(fe(e,{r:Xo(e.r)}))}function Vt(e){return oe(e)||e.lvl>e.r.lvl}function Zo(e){return oe(e.r)?[e.k,e.v]:Zo(e.r)}function Qo(e,t,o,n=at,r=at){return{k:e,l:n,lvl:o,r,v:t}}function vo(e){return Ut(Ko(e))}function Ko(e){const{l:t}=e;return!oe(t)&&t.lvl===e.lvl?fe(t,{r:fe(e,{l:t.r})}):e}function Ut(e){const{lvl:t,r:o}=e;return!oe(o)&&!oe(o.r)&&o.lvl===t&&o.r.lvl===t?fe(o,{l:fe(e,{r:o.l}),lvl:t+1}):e}function yr(e){return Yo(e,({k:t,v:o})=>({index:t,value:o}))}function en(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function ct(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Xt=Y(()=>({recalcInProgress:O(!1)}),[],{singleton:!0});function tn(e,t,o){return e[It(e,t,o)]}function It(e,t,o,n=0){let r=e.length-1;for(;n<=r;){const s=Math.floor((n+r)/2),a=e[s],i=o(a,t);if(i===0)return s;if(i===-1){if(r-n<2)return s-1;r=s-1}else{if(r===n)return s;n=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function wr(e,t,o,n){const r=It(e,t,n),s=It(e,o,n,r);return e.slice(r,s+1)}function He(e,t){return Math.round(e.getBoundingClientRect()[t])}function jt(e){return!oe(e.groupOffsetTree)}function Zt({index:e},t){return t===e?0:t<e?-1:1}function xr(){return{groupIndices:[],groupOffsetTree:Qe(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Qe()}}function vr(e,t){let o=oe(e)?0:1/0;for(const n of t){const{endIndex:r,size:s,startIndex:a}=n;if(o=Math.min(o,a),oe(e)){e=Ie(e,0,s);continue}const i=Ke(e,a-1,r+1);if(i.some(Er(n)))continue;let l=!1,c=!1;for(const{end:u,start:p,value:m}of i)l?(r>=p||s===m)&&(e=Ft(e,p)):(c=m!==s,l=!0),u>r&&r>=p&&m!==s&&(e=Ie(e,r+1,m));c&&(e=Ie(e,a,s))}return[e,o]}function Sr(e){return typeof e.groupIndex<"u"}function br({offset:e},t){return t===e?0:t<e?-1:1}function ut(e,t,o){if(t.length===0)return 0;const{index:n,offset:r,size:s}=tn(t,e,Zt),a=e-n,i=s*a+(a-1)*o+r;return i>0?i+o:i}function on(e,t){if(!jt(t))return e;let o=0;for(;t.groupIndices[o]<=e+o;)o++;return e+o}function nn(e,t,o){if(Sr(e))return t.groupIndices[e.groupIndex]+1;{const n=e.index==="LAST"?o:e.index;let r=on(n,t);return r=Math.max(0,r,Math.min(o,r)),r}}function Tr(e,t,o,n=0){return n>0&&(t=Math.max(t,tn(e,n,Zt).offset)),Yo(wr(e,t,o,br),$r)}function Cr(e,[t,o,n,r]){t.length>0&&n("received item sizes",t,Ce.DEBUG);const s=e.sizeTree;let a=s,i=0;if(o.length>0&&oe(s)&&t.length===2){const m=t[0].size,h=t[1].size;a=o.reduce(($,x)=>Ie(Ie($,x,m),x+1,h),a)}else[a,i]=vr(a,t);if(a===s)return e;const{lastIndex:l,lastOffset:c,lastSize:u,offsetTree:p}=Wt(e.offsetTree,i,a,r);return{groupIndices:o,groupOffsetTree:o.reduce((m,h)=>Ie(m,h,ut(h,p,r)),Qe()),lastIndex:l,lastOffset:c,lastSize:u,offsetTree:p,sizeTree:a}}function Ir(e){return We(e).map(({k:t,v:o},n,r)=>{const s=r[n+1];return{endIndex:s?s.k-1:1/0,size:o,startIndex:t}})}function So(e,t){let o=0,n=0;for(;o<e;)o+=t[n+1]-t[n]-1,n++;return n-(o===e?0:1)}function Wt(e,t,o,n){let r=e,s=0,a=0,i=0,l=0;if(t!==0){l=It(r,t-1,Zt),i=r[l].offset;const c=Pe(o,t-1);s=c[0],a=c[1],r.length&&r[l].size===Pe(o,t)[1]&&(l-=1),r=r.slice(0,l+1)}else r=[];for(const{start:c,value:u}of Ke(o,t,1/0)){const p=c-s,m=p*a+i+p*n;r.push({index:c,offset:m,size:u}),s=c,i=m,a=u}return{lastIndex:s,lastOffset:i,lastSize:a,offsetTree:r}}function $r(e){return{index:e.index,value:e}}function Er(e){const{endIndex:t,size:o,startIndex:n}=e;return r=>r.start===n&&(r.end===t||r.end===1/0)&&r.value===o}const Rr={offsetHeight:"height",offsetWidth:"width"},ze=Y(([{log:e},{recalcInProgress:t}])=>{const o=q(),n=q(),r=be(n,0),s=q(),a=q(),i=O(0),l=O([]),c=O(void 0),u=O(void 0),p=O(void 0),m=O(void 0),h=O((f,v)=>He(f,Rr[v])),$=O(void 0),x=O(0),w=xr(),y=be(R(o,W(l,e,x),Ne(Cr,w),se()),w),d=be(R(l,se(),Ne((f,v)=>({current:v,prev:f.current}),{current:[],prev:[]}),L(({prev:f})=>f)),[]);M(R(l,B(f=>f.length>0),W(y,x),L(([f,v,k])=>{const A=f.reduce((j,N,z)=>Ie(j,N,ut(N,v.offsetTree,k)||z),Qe());return{...v,groupIndices:f,groupOffsetTree:A}})),y),M(R(n,W(y),B(([f,{lastIndex:v}])=>f<v),L(([f,{lastIndex:v,lastSize:k}])=>[{endIndex:v,size:k,startIndex:f}])),o),M(c,u);const g=be(R(c,L(f=>f===void 0)),!0);M(R(u,B(f=>f!==void 0&&oe(le(y).sizeTree)),L(f=>{const v=le(p),k=le(l).length>0;return v?k?[{endIndex:0,size:v,startIndex:0},{endIndex:1,size:f,startIndex:1}]:[]:[{endIndex:0,size:f,startIndex:0}]})),o),M(R(m,B(f=>f!==void 0&&f.length>0&&oe(le(y).sizeTree)),L(f=>{const v=[];let k=f[0],A=0;for(let j=1;j<f.length;j++){const N=f[j];N!==k&&(v.push({endIndex:j-1,size:k,startIndex:A}),k=N,A=j)}return v.push({endIndex:f.length-1,size:k,startIndex:A}),v})),o),M(R(l,W(p,u),B(([,f,v])=>f!==void 0&&v!==void 0),L(([f,v,k])=>{const A=[];for(let j=0;j<f.length;j++){const N=f[j],z=f[j+1];A.push({startIndex:N,endIndex:N,size:v}),z!==void 0&&A.push({startIndex:N+1,endIndex:z-1,size:k})}return A})),o);const T=$e(R(o,W(y),Ne(({sizes:f},[v,k])=>({changed:k!==f,sizes:k}),{changed:!1,sizes:w}),L(f=>f.changed)));Z(R(i,Ne((f,v)=>({diff:f.prev-v,prev:v}),{diff:0,prev:0}),L(f=>f.diff)),f=>{const{groupIndices:v}=le(y);if(f>0)U(t,!0),U(s,f+So(f,v));else if(f<0){const k=le(d);k.length>0&&(f-=So(-f,k)),U(a,f)}}),Z(R(i,W(e)),([f,v])=>{f<0&&v("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:i},Ce.ERROR)});const b=$e(s);M(R(s,W(y),L(([f,v])=>{const k=v.groupIndices.length>0,A=[],j=v.lastSize;if(k){const N=lt(v.sizeTree,0);let z=0,V=0;for(;z<f;){const X=v.groupIndices[V],Q=v.groupIndices.length===V+1?1/0:v.groupIndices[V+1]-X-1;A.push({endIndex:X,size:N,startIndex:X}),A.push({endIndex:X+1+Q-1,size:j,startIndex:X+1}),V++,z+=Q+1}const D=We(v.sizeTree);return z!==f&&D.shift(),D.reduce((X,{k:Q,v:we})=>{let xe=X.ranges;return X.prevSize!==0&&(xe=[...X.ranges,{endIndex:Q+f-1,size:X.prevSize,startIndex:X.prevIndex}]),{prevIndex:Q+f,prevSize:we,ranges:xe}},{prevIndex:f,prevSize:0,ranges:A}).ranges}return We(v.sizeTree).reduce((N,{k:z,v:V})=>({prevIndex:z+f,prevSize:V,ranges:[...N.ranges,{endIndex:z+f-1,size:N.prevSize,startIndex:N.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),o);const E=$e(R(a,W(y,x),L(([f,{offsetTree:v},k])=>{const A=-f;return ut(A,v,k)})));return M(R(a,W(y,x),L(([f,v,k])=>{if(v.groupIndices.length>0){if(oe(v.sizeTree))return v;let A=Qe();const j=le(d);let N=0,z=0,V=0;for(;N<-f;){V=j[z];const D=j[z+1]-V-1;z++,N+=D+1}if(A=We(v.sizeTree).reduce((D,{k:X,v:Q})=>Ie(D,Math.max(0,X+f),Q),A),N!==-f){const D=lt(v.sizeTree,V);A=Ie(A,0,D);const X=Pe(v.sizeTree,-f+1)[1];A=Ie(A,1,X)}return{...v,sizeTree:A,...Wt(v.offsetTree,0,A,k)}}else{const A=We(v.sizeTree).reduce((j,{k:N,v:z})=>Ie(j,Math.max(0,N+f),z),Qe());return{...v,sizeTree:A,...Wt(v.offsetTree,0,A,k)}}})),y),{beforeUnshiftWith:b,data:$,defaultItemSize:u,firstItemIndex:i,fixedItemSize:c,fixedGroupSize:p,gap:x,groupIndices:l,heightEstimates:m,itemSize:h,listRefresh:T,shiftWith:a,shiftWithOffset:E,sizeRanges:o,sizes:y,statefulTotalCount:r,totalCount:n,trackItemSizes:g,unshiftWith:s}},ie(Fe,Xt),{singleton:!0});function kr(e){return e.reduce((t,o)=>(t.groupIndices.push(t.totalCount),t.totalCount+=o+1,t),{groupIndices:[],totalCount:0})}const rn=Y(([{groupIndices:e,sizes:t,totalCount:o},{headerHeight:n,scrollTop:r}])=>{const s=q(),a=q(),i=$e(R(s,L(kr)));return M(R(i,L(l=>l.totalCount)),o),M(R(i,L(l=>l.groupIndices)),e),M(R(de(r,t,n),B(([l,c])=>jt(c)),L(([l,c,u])=>Pe(c.groupOffsetTree,Math.max(l-u,0),"v")[0]),se(),L(l=>[l])),a),{groupCounts:s,topItemsIndexes:a}},ie(ze,Te)),De=Y(([{log:e}])=>{const t=O(!1),o=$e(R(t,B(n=>n),se()));return Z(t,n=>{n&&le(e)("props updated",{},Ce.DEBUG)}),{didMount:o,propsReady:t}},ie(Fe),{singleton:!0}),Or=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function sn(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Or)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const ht=Y(([{gap:e,listRefresh:t,sizes:o,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:s,footerHeight:a,headerHeight:i,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:u,viewportHeight:p},{log:m}])=>{const h=q(),$=q(),x=O(0);let w=null,y=null,d=null;function g(){w&&(w(),w=null),d&&(d(),d=null),y&&(clearTimeout(y),y=null),U(l,!1)}return M(R(h,W(o,p,n,x,i,a,m),W(e,s,r),L(([[T,b,E,f,v,k,A,j],N,z,V])=>{const D=sn(T),{align:X,behavior:Q,offset:we}=D,xe=f-1,ve=nn(D,b,xe);let I=ut(ve,b.offsetTree,N)+k;X==="end"?(I+=z+Pe(b.sizeTree,ve)[1]-E+V,ve===xe&&(I+=A)):X==="center"?I+=(z+Pe(b.sizeTree,ve)[1]-E+V)/2:I-=v,we&&(I+=we);const _=G=>{g(),G?(j("retrying to scroll to",{location:T},Ce.DEBUG),U(h,T)):(U($,!0),j("list did not change, scroll successful",{},Ce.DEBUG))};if(g(),Q==="smooth"){let G=!1;d=Z(t,K=>{G=G||K}),w=je(u,()=>{_(G)})}else w=je(R(t,Ar(150)),_);return y=setTimeout(()=>{g()},1200),U(l,!0),j("scrolling from index to",{behavior:Q,index:ve,top:I},Ce.DEBUG),{behavior:Q,top:I}})),c),{scrollTargetReached:$,scrollToIndex:h,topListHeight:x}},ie(ze,Te,Fe),{singleton:!0});function Ar(e){return t=>{const o=setTimeout(()=>{t(!1)},e);return n=>{n&&(t(!0),clearTimeout(o))}}}function Qt(e,t){e==0?t():requestAnimationFrame(()=>{Qt(e-1,t)})}function Kt(e,t){const o=t-1;return typeof e=="number"?e:e.index==="LAST"?o:e.index}const gt=Y(([{defaultItemSize:e,listRefresh:t,sizes:o},{scrollTop:n},{scrollTargetReached:r,scrollToIndex:s},{didMount:a}])=>{const i=O(!0),l=O(0),c=O(!0);return M(R(a,W(l),B(([u,p])=>!!p),Ve(!1)),i),M(R(a,W(l),B(([u,p])=>!!p),Ve(!1)),c),Z(R(de(t,a),W(i,o,e,c),B(([[,u],p,{sizeTree:m},h,$])=>u&&(!oe(m)||qt(h))&&!p&&!$),W(l)),([,u])=>{je(r,()=>{U(c,!0)}),Qt(4,()=>{je(n,()=>{U(i,!0)}),U(s,u)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:i}},ie(ze,Te,ht,De),{singleton:!0});function an(e,t){return Math.abs(e-t)<1.01}const dt="up",rt="down",jr="none",Pr={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Lr=0,yt=Y(([{footerHeight:e,headerHeight:t,scrollBy:o,scrollContainerState:n,scrollTop:r,viewportHeight:s}])=>{const a=O(!1),i=O(!0),l=q(),c=q(),u=O(4),p=O(Lr),m=be(R(Bt(R(H(r),qe(1),Ve(!0)),R(H(r),qe(1),Ve(!1),wo(100))),se()),!1),h=be(R(Bt(R(o,Ve(!0)),R(o,Ve(!1),wo(200))),se()),!1);M(R(de(H(r),H(p)),L(([d,g])=>d<=g),se()),i),M(R(i,_e(50)),c);const $=$e(R(de(n,H(s),H(t),H(e),H(u)),Ne((d,[{scrollHeight:g,scrollTop:T},b,E,f,v])=>{const k=T+b-g>-v,A={scrollHeight:g,scrollTop:T,viewportHeight:b};if(k){let N,z;return T>d.state.scrollTop?(N="SCROLLED_DOWN",z=d.state.scrollTop-T):(N="SIZE_DECREASED",z=d.state.scrollTop-T||d.scrollTopDelta),{atBottom:!0,atBottomBecause:N,scrollTopDelta:z,state:A}}let j;return A.scrollHeight>d.state.scrollHeight?j="SIZE_INCREASED":b<d.state.viewportHeight?j="VIEWPORT_HEIGHT_DECREASING":T<d.state.scrollTop?j="SCROLLING_UPWARDS":j="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:j,state:A}},Pr),se((d,g)=>d&&d.atBottom===g.atBottom))),x=be(R(n,Ne((d,{scrollHeight:g,scrollTop:T,viewportHeight:b})=>{if(an(d.scrollHeight,g))return{changed:!1,jump:0,scrollHeight:g,scrollTop:T};{const E=g-(T+b)<1;return d.scrollTop!==T&&E?{changed:!0,jump:d.scrollTop-T,scrollHeight:g,scrollTop:T}:{changed:!0,jump:0,scrollHeight:g,scrollTop:T}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),B(d=>d.changed),L(d=>d.jump)),0);M(R($,L(d=>d.atBottom)),a),M(R(a,_e(50)),l);const w=O(rt);M(R(n,L(({scrollTop:d})=>d),se(),Ne((d,g)=>le(h)?{direction:d.direction,prevScrollTop:g}:{direction:g<d.prevScrollTop?dt:rt,prevScrollTop:g},{direction:rt,prevScrollTop:0}),L(d=>d.direction)),w),M(R(n,_e(50),Ve(jr)),w);const y=O(0);return M(R(m,B(d=>!d),Ve(0)),y),M(R(r,_e(100),W(m),B(([d,g])=>!!g),Ne(([d,g],[T])=>[g,T],[0,0]),L(([d,g])=>g-d)),y),{atBottomState:$,atBottomStateChange:l,atBottomThreshold:u,atTopStateChange:c,atTopThreshold:p,isAtBottom:a,isAtTop:i,isScrolling:m,lastJumpDueToItemResize:x,scrollDirection:w,scrollVelocity:y}},ie(Te)),pt="top",ft="bottom",bo="none";function To(e,t,o){return typeof e=="number"?o===dt&&t===pt||o===rt&&t===ft?e:0:o===dt?t===pt?e.main:e.reverse:t===ft?e.main:e.reverse}function Co(e,t){var o;return typeof e=="number"?e:(o=e[t])!=null?o:0}const eo=Y(([{deviation:e,fixedHeaderHeight:t,headerHeight:o,scrollTop:n,viewportHeight:r}])=>{const s=q(),a=O(0),i=O(0),l=O(0),c=be(R(de(H(n),H(r),H(o),H(s,ct),H(l),H(a),H(t),H(e),H(i)),L(([u,p,m,[h,$],x,w,y,d,g])=>{const T=u-d,b=w+y,E=Math.max(m-T,0);let f=bo;const v=Co(g,pt),k=Co(g,ft);return h-=d,h+=m+y,$+=m+y,$-=d,h>u+b-v&&(f=dt),$<u-E+p+k&&(f=rt),f!==bo?[Math.max(T-m-To(x,pt,f)-v,0),T-E-y+p+To(x,ft,f)+k]:null}),B(u=>u!=null),se(ct)),[0,0]);return{increaseViewportBy:i,listBoundary:s,overscan:l,topListHeight:a,visibleRange:c}},ie(Te),{singleton:!0});function Mr(e,t,o){if(jt(t)){const n=on(e,t);return[{index:Pe(t.groupOffsetTree,n)[0],offset:0,size:0},{data:o?.[0],index:n,offset:0,size:0}]}return[{data:o?.[0],index:e,offset:0,size:0}]}const Nt={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ct(e,t,o,n,r,s){const{lastIndex:a,lastOffset:i,lastSize:l}=r;let c=0,u=0;if(e.length>0){c=e[0].offset;const x=e[e.length-1];u=x.offset+x.size}const p=o-a,m=i+p*l+(p-1)*n,h=c,$=m-u;return{bottom:u,firstItemIndex:s,items:Io(e,r,s),offsetBottom:$,offsetTop:c,top:h,topItems:Io(t,r,s),topListHeight:t.reduce((x,w)=>w.size+x,0),totalCount:o}}function ln(e,t,o,n,r,s){let a=0;if(o.groupIndices.length>0)for(const u of o.groupIndices){if(u-a>=e)break;a++}const i=e+a,l=Kt(t,i),c=Array.from({length:i}).map((u,p)=>({data:s[p+l],index:p+l,offset:0,size:0}));return Ct(c,[],i,r,o,n)}function Io(e,t,o){if(e.length===0)return[];if(!jt(t))return e.map(c=>({...c,index:c.index+o,originalIndex:c.index}));const n=e[0].index,r=e[e.length-1].index,s=[],a=Ke(t.groupOffsetTree,n,r);let i,l=0;for(const c of e){(!i||i.end<c.index)&&(i=a.shift(),l=t.groupIndices.indexOf(i.start));let u;c.index===i.start?u={index:l,type:"group"}:u={groupIndex:l,index:c.index-(l+1)+o},s.push({...u,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}function $o(e,t){var o;return e===void 0?0:typeof e=="number"?e:(o=e[t])!=null?o:0}const Xe=Y(([{data:e,firstItemIndex:t,gap:o,sizes:n,totalCount:r},s,{listBoundary:a,topListHeight:i,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:u},{topListHeight:p},m,{didMount:h},{recalcInProgress:$}])=>{const x=O([]),w=O(0),y=q(),d=O(0);M(s.topItemsIndexes,x);const g=be(R(de(h,$,H(l,ct),H(r),H(n),H(c),u,H(x),H(t),H(o),H(d),e),B(([f,v,,k,,,,,,,,A])=>{const j=A&&A.length!==k;return f&&!v&&!j}),L(([,,[f,v],k,A,j,N,z,V,D,X,Q])=>{var we,xe,ve,I;const _=A,{offsetTree:G,sizeTree:K}=_,Le=le(w);if(k===0)return{...Nt,totalCount:k};if(f===0&&v===0)return Le===0?{...Nt,totalCount:k}:ln(Le,j,A,V,D,Q||[]);if(oe(K))return Le>0?null:Ct(Mr(Kt(j,k),_,Q),[],k,D,_,V);const Me=[];if(z.length>0){const pe=z[0],ce=z[z.length-1];let me=0;for(const ue of Ke(K,pe,ce)){const te=ue.value,re=Math.max(ue.start,pe),Re=Math.min(ue.end,ce);for(let ge=re;ge<=Re;ge++)Me.push({data:Q?.[ge],index:ge,offset:me,size:te}),me+=te}}if(!N)return Ct([],Me,k,D,_,V);const ee=z.length>0?z[z.length-1]+1:0,P=Tr(G,f,v,ee);if(P.length===0)return null;const J=k-1,ne=At([],pe=>{for(const ce of P){const me=ce.value;let ue=me.offset,te=ce.start;const re=me.size;if(me.offset<f){te+=Math.floor((f-me.offset+D)/(re+D));const ge=te-ce.start;ue+=ge*re+ge*D}te<ee&&(ue+=(ee-te)*re,te=ee);const Re=Math.min(ce.end,J);for(let ge=te;ge<=Re&&!(ue>=v);ge++)pe.push({data:Q?.[ge],index:ge,offset:ue,size:re}),ue+=re+D}}),he=$o(X,pt),Ee=$o(X,ft);if(ne.length>0&&(he>0||Ee>0)){const pe=ne[0],ce=ne[ne.length-1];if(he>0&&pe.index>ee){const me=Math.min(he,pe.index-ee),ue=[];let te=pe.offset;for(let re=pe.index-1;re>=pe.index-me;re--){const Re=(xe=(we=Ke(K,re,re)[0])==null?void 0:we.value)!=null?xe:pe.size;te-=Re+D,ue.unshift({data:Q?.[re],index:re,offset:te,size:Re})}ne.unshift(...ue)}if(Ee>0&&ce.index<J){const me=Math.min(Ee,J-ce.index);let ue=ce.offset+ce.size+D;for(let te=ce.index+1;te<=ce.index+me;te++){const re=(I=(ve=Ke(K,te,te)[0])==null?void 0:ve.value)!=null?I:ce.size;ne.push({data:Q?.[te],index:te,offset:ue,size:re}),ue+=re+D}}}return Ct(ne,Me,k,D,_,V)}),B(f=>f!==null),se()),Nt);M(R(e,B(qt),L(f=>f?.length)),r),M(R(g,L(f=>f.topListHeight)),p),M(p,i),M(R(g,L(f=>[f.top,f.bottom])),a),M(R(g,L(f=>f.items)),y);const T=$e(R(g,B(({items:f})=>f.length>0),W(r,e),B(([{items:f},v])=>f[f.length-1].originalIndex===v-1),L(([,f,v])=>[f-1,v]),se(ct),L(([f])=>f))),b=$e(R(g,_e(200),B(({items:f,topItems:v})=>f.length>0&&f[0].originalIndex===v.length),L(({items:f})=>f[0].index),se())),E=$e(R(g,B(({items:f})=>f.length>0),L(({items:f})=>{let v=0,k=f.length-1;for(;f[v].type==="group"&&v<k;)v++;for(;f[k].type==="group"&&k>v;)k--;return{endIndex:f[k].index,startIndex:f[v].index}}),se(en)));return{endReached:T,initialItemCount:w,itemsRendered:y,listState:g,minOverscanItemCount:d,rangeChanged:E,startReached:b,topItemsIndexes:x,...m}},ie(ze,rn,eo,gt,ht,yt,De,Xt),{singleton:!0}),cn=Y(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:o,headerHeight:n},{listState:r}])=>{const s=q(),a=be(R(de(o,e,n,t,r),L(([i,l,c,u,p])=>i+l+c+u+p.offsetBottom+p.bottom)),0);return M(H(a),s),{totalListHeight:a,totalListHeightChanged:s}},ie(Te,Xe),{singleton:!0}),Vr=Y(([{viewportHeight:e},{totalListHeight:t}])=>{const o=O(!1),n=be(R(de(o,e,t),B(([r])=>r),L(([,r,s])=>Math.max(0,r-s)),_e(0),se()),0);return{alignToBottom:o,paddingTopAddition:n}},ie(Te,cn),{singleton:!0}),un=Y(()=>({context:O(null)})),Nr=({itemBottom:e,itemTop:t,locationParams:{align:o,behavior:n,...r},viewportBottom:s,viewportTop:a})=>t<a?{...r,align:o??"start",behavior:n}:e>s?{...r,align:o??"end",behavior:n}:null,dn=Y(([{gap:e,sizes:t,totalCount:o},{fixedFooterHeight:n,fixedHeaderHeight:r,headerHeight:s,scrollingInProgress:a,scrollTop:i,viewportHeight:l},{scrollToIndex:c}])=>{const u=q();return M(R(u,W(t,l,o,s,r,n,i),W(e),L(([[p,m,h,$,x,w,y,d],g])=>{const{align:T,behavior:b,calculateViewLocation:E=Nr,done:f,...v}=p,k=nn(p,m,$-1),A=ut(k,m.offsetTree,g)+x+w,j=A+Pe(m.sizeTree,k)[1],N=d+w,z=d+h-y,V=E({itemBottom:j,itemTop:A,locationParams:{align:T,behavior:b,...v},viewportBottom:z,viewportTop:N});return V?f&&je(R(a,B(D=>!D),qe(le(a)?1:2)),f):f&&f(),V}),B(p=>p!==null)),c),{scrollIntoView:u}},ie(ze,Te,ht,Xe,Fe),{singleton:!0});function Eo(e){return e?e==="smooth"?"smooth":"auto":!1}const zr=(e,t)=>typeof e=="function"?Eo(e(t)):t&&Eo(e),_r=Y(([{listRefresh:e,totalCount:t,fixedItemSize:o,data:n},{atBottomState:r,isAtBottom:s},{scrollToIndex:a},{scrolledToInitialItem:i},{didMount:l,propsReady:c},{log:u},{scrollingInProgress:p},{context:m},{scrollIntoView:h}])=>{const $=O(!1),x=q();let w=null;function y(b){U(a,{align:"end",behavior:b,index:"LAST"})}Z(R(de(R(H(t),qe(1)),l),W(H($),s,i,p),L(([[b,E],f,v,k,A])=>{let j=E&&k,N="auto";return j&&(N=zr(f,v||A),j=j&&!!N),{followOutputBehavior:N,shouldFollow:j,totalCount:b}}),B(({shouldFollow:b})=>b)),({followOutputBehavior:b,totalCount:E})=>{w&&(w(),w=null),le(o)?requestAnimationFrame(()=>{le(u)("following output to ",{totalCount:E},Ce.DEBUG),y(b)}):w=je(e,()=>{le(u)("following output to ",{totalCount:E},Ce.DEBUG),y(b),w=null})});function d(b){const E=je(r,f=>{b&&!f.atBottom&&f.notAtBottomBecause==="SIZE_INCREASED"&&!w&&(le(u)("scrolling to bottom due to increased size",{},Ce.DEBUG),y("auto"))});setTimeout(E,100)}Z(R(de(H($),t,c),B(([b,,E])=>b&&E),Ne(({value:b},[,E])=>({refreshed:b===E,value:E}),{refreshed:!1,value:0}),B(({refreshed:b})=>b),W($,t)),([,b])=>{le(i)&&d(b!==!1)}),Z(x,()=>{d(le($)!==!1)}),Z(de(H($),r),([b,E])=>{b&&!E.atBottom&&E.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const g=O(null),T=q();return M(Bt(R(H(n),L(b=>{var E;return(E=b?.length)!=null?E:0})),R(H(t))),T),Z(R(de(R(T,qe(1)),l),W(H(g),i,p,m),L(([[b,E],f,v,k,A])=>E&&v&&f?.({context:A,totalCount:b,scrollingInProgress:k})),B(b=>!!b),_e(0)),b=>{w&&(w(),w=null),le(o)?requestAnimationFrame(()=>{le(u)("scrolling into view",{}),U(h,b)}):w=je(e,()=>{le(u)("scrolling into view",{}),U(h,b),w=null})}),{autoscrollToBottom:x,followOutput:$,scrollIntoViewOnChange:g}},ie(ze,yt,ht,gt,De,Fe,Te,un,dn)),Hr=Y(([{data:e,firstItemIndex:t,gap:o,sizes:n},{initialTopMostItemIndex:r},{initialItemCount:s,listState:a},{didMount:i}])=>(M(R(i,W(s),B(([,l])=>l!==0),W(r,n,t,o,e),L(([[,l],c,u,p,m,h=[]])=>ln(l,c,u,p,m,h))),a),{}),ie(ze,gt,Xe,De),{singleton:!0}),Br=Y(([{didMount:e},{scrollTo:t},{listState:o}])=>{const n=O(0);return Z(R(e,W(n),B(([,r])=>r!==0),L(([,r])=>({top:r}))),r=>{je(R(o,qe(1),B(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{U(t,r)})})}),{initialScrollTop:n}},ie(De,Te,Xe),{singleton:!0}),pn=Y(([{scrollVelocity:e}])=>{const t=O(!1),o=q(),n=O(!1);return M(R(e,W(n,t,o),B(([r,s])=>!!s),L(([r,s,a,i])=>{const{enter:l,exit:c}=s;if(a){if(c(r,i))return!1}else if(l(r,i))return!0;return a}),se()),t),Z(R(de(t,e,o),W(n)),([[r,s,a],i])=>{r&&i&&i.change&&i.change(s,a)}),{isSeeking:t,scrollSeekConfiguration:n,scrollSeekRangeChanged:o,scrollVelocity:e}},ie(yt),{singleton:!0}),to=Y(([{scrollContainerState:e,scrollTo:t}])=>{const o=q(),n=q(),r=q(),s=O(!1),a=O(void 0);return M(R(de(o,n),L(([{scrollHeight:i,scrollTop:l,viewportHeight:c},{offsetTop:u}])=>({scrollHeight:i,scrollTop:Math.max(0,l-u),viewportHeight:c}))),e),M(R(t,W(n),L(([i,{offsetTop:l}])=>({...i,top:i.top+l}))),r),{customScrollParent:a,useWindowScroll:s,windowScrollContainerState:o,windowScrollTo:r,windowViewportRect:n}},ie(Te)),Fr=Y(([{sizeRanges:e,sizes:t},{headerHeight:o,scrollTop:n},{initialTopMostItemIndex:r},{didMount:s},{useWindowScroll:a,windowScrollContainerState:i,windowViewportRect:l}])=>{const c=q(),u=O(void 0),p=O(null),m=O(null);return M(i,p),M(l,m),Z(R(c,W(t,n,a,p,m,o)),([h,$,x,w,y,d,g])=>{const T=Ir($.sizeTree);w&&y!==null&&d!==null&&(x=y.scrollTop-d.offsetTop),x-=g,h({ranges:T,scrollTop:x})}),M(R(u,B(qt),L(Dr)),r),M(R(s,W(u),B(([,h])=>h!==void 0),se(),L(([,h])=>h.ranges)),e),{getState:c,restoreStateFrom:u}},ie(ze,Te,gt,De,to));function Dr(e){return{align:"start",index:0,offset:e.scrollTop}}const Ur=Y(([{topItemsIndexes:e}])=>{const t=O(0);return M(R(t,B(o=>o>=0),L(o=>Array.from({length:o}).map((n,r)=>r))),e),{topItemCount:t}},ie(Xe));function fn(e){let t=!1,o;return()=>(t||(t=!0,o=e()),o)}const Wr=fn(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Jr=Y(([{deviation:e,scrollBy:t,scrollingInProgress:o,scrollTop:n},{isAtBottom:r,isScrolling:s,lastJumpDueToItemResize:a,scrollDirection:i},{listState:l},{beforeUnshiftWith:c,gap:u,shiftWithOffset:p,sizes:m},{log:h},{recalcInProgress:$}])=>{const x=$e(R(l,W(a),Ne(([,y,d,g],[{bottom:T,items:b,offsetBottom:E,totalCount:f},v])=>{const k=T+E;let A=0;return d===f&&y.length>0&&b.length>0&&(b[0].originalIndex===0&&y[0].originalIndex===0||(A=k-g,A!==0&&(A+=v))),[A,b,f,k]},[0,[],0,0]),B(([y])=>y!==0),W(n,i,o,r,h,$),B(([,y,d,g,,,T])=>!T&&!g&&y!==0&&d===dt),L(([[y],,,,,d])=>(d("Upward scrolling compensation",{amount:y},Ce.DEBUG),y))));function w(y){y>0?(U(t,{behavior:"auto",top:-y}),U(e,0)):(U(e,0),U(t,{behavior:"auto",top:-y}))}return Z(R(x,W(e,s)),([y,d,g])=>{g&&Wr()?U(e,d-y):w(-y)}),Z(R(de(be(s,!1),e,$),B(([y,d,g])=>!y&&!g&&d!==0),L(([y,d])=>d),_e(1)),w),M(R(p,L(y=>({top:-y}))),t),Z(R(c,W(m,u),L(([y,{groupIndices:d,lastSize:g,sizeTree:T},b])=>{function E(f){return f*(g+b)}if(d.length===0)return E(y);{let f=0;const v=lt(T,0);let k=0,A=0;for(;k<y;){k++,f+=v;let j=d.length===A+1?1/0:d[A+1]-d[A]-1;k+j>y&&(f-=v,j=y-k+1),k+=j,f+=E(j),A++}return f}})),y=>{U(e,y),requestAnimationFrame(()=>{U(t,{top:y}),requestAnimationFrame(()=>{U(e,0),U($,!1)})})}),{deviation:e}},ie(Te,yt,Xe,ze,Fe,Xt)),qr=Y(([e,t,o,n,r,s,a,i,l,c,u])=>({...e,...t,...o,...n,...r,...s,...a,...i,...l,...c,...u}),ie(eo,Hr,De,pn,cn,Br,Vr,to,dn,Fe,un)),mn=Y(([{data:e,defaultItemSize:t,firstItemIndex:o,fixedItemSize:n,fixedGroupSize:r,gap:s,groupIndices:a,heightEstimates:i,itemSize:l,sizeRanges:c,sizes:u,statefulTotalCount:p,totalCount:m,trackItemSizes:h},{initialItemFinalLocationReached:$,initialTopMostItemIndex:x,scrolledToInitialItem:w},y,d,g,T,{scrollToIndex:b},E,{topItemCount:f},{groupCounts:v},k])=>{const{listState:A,minOverscanItemCount:j,topItemsIndexes:N,rangeChanged:z,...V}=T;return M(z,k.scrollSeekRangeChanged),M(R(k.windowViewportRect,L(D=>D.visibleHeight)),y.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:o,fixedItemHeight:n,fixedGroupHeight:r,gap:s,groupCounts:v,heightEstimates:i,initialItemFinalLocationReached:$,initialTopMostItemIndex:x,scrolledToInitialItem:w,sizeRanges:c,topItemCount:f,topItemsIndexes:N,totalCount:m,...g,groupIndices:a,itemSize:l,listState:A,minOverscanItemCount:j,scrollToIndex:b,statefulTotalCount:p,trackItemSizes:h,rangeChanged:z,...V,...k,...y,sizes:u,...d}},ie(ze,gt,Te,Fr,_r,Xe,ht,Jr,Ur,rn,qr));function Gr(e,t){const o={},n={};let r=0;const s=e.length;for(;r<s;)n[e[r]]=1,r+=1;for(const a in t)Object.hasOwn(n,a)||(o[a]=t[a]);return o}const vt=typeof document<"u"?C.useLayoutEffect:C.useEffect;function hn(e,t,o){const n=Object.keys(t.required||{}),r=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),a=Object.keys(t.events||{}),i=C.createContext({});function l(w,y){w.propsReady&&U(w.propsReady,!1);for(const d of n){const g=w[t.required[d]];U(g,y[d])}for(const d of r)if(d in y){const g=w[t.optional[d]];U(g,y[d])}w.propsReady&&U(w.propsReady,!0)}function c(w){return s.reduce((y,d)=>(y[d]=g=>{const T=w[t.methods[d]];U(T,g)},y),{})}function u(w){return a.reduce((y,d)=>(y[d]=ur(w[t.events[d]]),y),{})}const p=C.forwardRef((w,y)=>{const{children:d,...g}=w,[T]=C.useState(()=>At(pr(e),f=>{l(f,g)})),[b]=C.useState(yo(u,T));vt(()=>{for(const f of a)f in g&&Z(b[f],g[f]);return()=>{Object.values(b).map(Gt)}},[g,b,T]),vt(()=>{l(T,g)}),C.useImperativeHandle(y,go(c(T)));const E=o;return S.jsx(i.Provider,{value:T,children:o?S.jsx(E,{...Gr([...n,...r,...a],g),children:d}):d})}),m=w=>{const y=C.useContext(i);return C.useCallback(d=>{U(y[w],d)},[y,w])},h=w=>{const y=C.useContext(i)[w],d=C.useCallback(g=>Z(y,g),[y]);return C.useSyncExternalStore(d,()=>le(y),()=>le(y))},$=w=>{const y=C.useContext(i)[w],[d,g]=C.useState(yo(le,y));return vt(()=>Z(y,T=>{T!==d&&g(go(T))}),[y,d]),d},x=C.version.startsWith("18")?h:$;return{Component:p,useEmitter:(w,y)=>{const d=C.useContext(i)[w];vt(()=>Z(d,y),[y,d])},useEmitterValue:x,usePublisher:m}}const gn=C.createContext(void 0),yn=C.createContext(void 0),wn=typeof document<"u"?C.useLayoutEffect:C.useEffect;function zt(e){return"self"in e}function Yr(e){return"body"in e}function xn(e,t,o,n=tt,r,s){const a=C.useRef(null),i=C.useRef(null),l=C.useRef(null),c=C.useCallback(m=>{let h,$,x;const w=m.target;if(Yr(w)||zt(w)){const d=zt(w)?w:w.defaultView;x=s?d.scrollX:d.scrollY,h=s?d.document.documentElement.scrollWidth:d.document.documentElement.scrollHeight,$=s?d.innerWidth:d.innerHeight}else x=s?w.scrollLeft:w.scrollTop,h=s?w.scrollWidth:w.scrollHeight,$=s?w.offsetWidth:w.offsetHeight;const y=()=>{e({scrollHeight:h,scrollTop:Math.max(x,0),viewportHeight:$})};m.suppressFlushSync?y():_o.flushSync(y),i.current!==null&&(x===i.current||x<=0||x===h-$)&&(i.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);C.useEffect(()=>{const m=r||a.current;return n(r||a.current),c({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",c,{passive:!0}),()=>{n(null),m.removeEventListener("scroll",c)}},[a,c,o,n,r]);function u(m){const h=a.current;if(!h||(s?"offsetWidth"in h&&h.offsetWidth===0:"offsetHeight"in h&&h.offsetHeight===0))return;const $=m.behavior==="smooth";let x,w,y;zt(h)?(w=Math.max(He(h.document.documentElement,s?"width":"height"),s?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight),x=s?h.innerWidth:h.innerHeight,y=s?window.scrollX:window.scrollY):(w=h[s?"scrollWidth":"scrollHeight"],x=He(h,s?"width":"height"),y=h[s?"scrollLeft":"scrollTop"]);const d=w-x;if(m.top=Math.ceil(Math.max(Math.min(d,m.top),0)),an(x,w)||m.top===y){e({scrollHeight:w,scrollTop:y,viewportHeight:x}),$&&t(!0);return}$?(i.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,i.current=null,t(!0)},1e3)):i.current=null,s&&(m={behavior:m.behavior,left:m.top}),h.scrollTo(m)}function p(m){s&&(m={behavior:m.behavior,left:m.top}),a.current.scrollBy(m)}return{scrollByCallback:p,scrollerRef:a,scrollToCallback:u}}const _t="-webkit-sticky",Ro="sticky",oo=fn(()=>{if(typeof document>"u")return Ro;const e=document.createElement("div");return e.style.position=_t,e.style.position===_t?_t:Ro});function no(e){return e}const Xr=Y(()=>{const e=O(i=>`Item ${i}`),t=O(i=>`Group ${i}`),o=O({}),n=O(no),r=O("div"),s=O(tt),a=(i,l=null)=>be(R(o,L(c=>c[i]),se()),l);return{components:o,computeItemKey:n,EmptyPlaceholder:a("EmptyPlaceholder"),FooterComponent:a("Footer"),GroupComponent:a("Group","div"),groupContent:t,HeaderComponent:a("Header"),HeaderFooterTag:r,ItemComponent:a("Item","div"),itemContent:e,ListComponent:a("List","div"),ScrollerComponent:a("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:a("ScrollSeekPlaceholder"),TopItemListComponent:a("TopItemList")}}),Zr=Y(([e,t])=>({...e,...t}),ie(mn,Xr)),Qr=({height:e})=>S.jsx("div",{style:{height:e}}),Kr={overflowAnchor:"none",position:oo(),zIndex:1},vn={overflowAnchor:"none"},es={...vn,display:"inline-block",height:"100%"},ko=C.memo(function({showTopList:e=!1}){const t=F("listState"),o=ke("sizeRanges"),n=F("useWindowScroll"),r=F("customScrollParent"),s=ke("windowScrollContainerState"),a=ke("scrollContainerState"),i=r||n?s:a,l=F("itemContent"),c=F("context"),u=F("groupContent"),p=F("trackItemSizes"),m=F("itemSize"),h=F("log"),$=ke("gap"),x=F("horizontalDirection"),{callbackRef:w}=hr(o,m,p,e?tt:i,h,$,r,x,F("skipAnimationFrameInResizeObserver")),[y,d]=C.useState(0);ro("deviation",V=>{y!==V&&d(V)});const g=F("EmptyPlaceholder"),T=F("ScrollSeekPlaceholder")||Qr,b=F("ListComponent"),E=F("ItemComponent"),f=F("GroupComponent"),v=F("computeItemKey"),k=F("isSeeking"),A=F("groupIndices").length>0,j=F("alignToBottom"),N=F("initialItemFinalLocationReached"),z=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:y!==0?y:j?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:j?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...N?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&g?S.jsx(g,{...Se(g,c)}):S.jsx(b,{...Se(b,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:w,style:z,children:(e?t.topItems:t.items).map(V=>{const D=V.originalIndex,X=v(D+t.firstItemIndex,V.data,c);return k?C.createElement(T,{...Se(T,c),height:V.size,index:V.index,key:X,type:V.type||"item",...V.type==="group"?{}:{groupIndex:V.groupIndex}}):V.type==="group"?C.createElement(f,{...Se(f,c),"data-index":D,"data-item-index":V.index,"data-known-size":V.size,key:X,style:Kr},u(V.index,c)):C.createElement(E,{...Se(E,c),...rs(E,V.data),"data-index":D,"data-item-group-index":V.groupIndex,"data-item-index":V.index,"data-known-size":V.size,key:X,style:x?es:vn},A?l(V.index,V.groupIndex,V.data,c):l(V.index,V.data,c))})})}),ts={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},os={outline:"none",overflowX:"auto",position:"relative"},Pt=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),ns={position:oo(),top:0,width:"100%",zIndex:1};function Se(e,t){if(typeof e!="string")return{context:t}}function rs(e,t){return{item:typeof e=="string"?void 0:t}}const ss=C.memo(function(){const e=F("HeaderComponent"),t=ke("headerHeight"),o=F("HeaderFooterTag"),n=Ye(C.useMemo(()=>s=>{t(He(s,"height"))},[t]),!0,F("skipAnimationFrameInResizeObserver")),r=F("context");return e?S.jsx(o,{ref:n,children:S.jsx(e,{...Se(e,r)})}):null}),is=C.memo(function(){const e=F("FooterComponent"),t=ke("footerHeight"),o=F("HeaderFooterTag"),n=Ye(C.useMemo(()=>s=>{t(He(s,"height"))},[t]),!0,F("skipAnimationFrameInResizeObserver")),r=F("context");return e?S.jsx(o,{ref:n,children:S.jsx(e,{...Se(e,r)})}):null});function Sn({useEmitter:e,useEmitterValue:t,usePublisher:o}){return C.memo(function({children:n,style:r,context:s,...a}){const i=o("scrollContainerState"),l=t("ScrollerComponent"),c=o("smoothScrollTargetReached"),u=t("scrollerRef"),p=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:h,scrollToCallback:$}=xn(i,c,l,u,void 0,p);return e("scrollTo",$),e("scrollBy",m),S.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:h,style:{...p?os:ts,...r},tabIndex:0,...a,...Se(l,s),children:n})})}function bn({useEmitter:e,useEmitterValue:t,usePublisher:o}){return C.memo(function({children:n,style:r,context:s,...a}){const i=o("windowScrollContainerState"),l=t("ScrollerComponent"),c=o("smoothScrollTargetReached"),u=t("totalListHeight"),p=t("deviation"),m=t("customScrollParent"),h=C.useRef(null),$=t("scrollerRef"),{scrollByCallback:x,scrollerRef:w,scrollToCallback:y}=xn(i,c,l,$,m);return wn(()=>{var d;return w.current=m||((d=h.current)==null?void 0:d.ownerDocument.defaultView),()=>{w.current=null}},[w,m]),e("windowScrollTo",y),e("scrollBy",x),S.jsx(l,{ref:h,"data-virtuoso-scroller":!0,style:{position:"relative",...r,...u!==0?{height:u+p}:{}},...a,...Se(l,s),children:n})})}const as=({children:e})=>{const t=C.useContext(gn),o=ke("viewportHeight"),n=ke("fixedItemHeight"),r=F("alignToBottom"),s=F("horizontalDirection"),a=C.useMemo(()=>Jo(o,l=>He(l,s?"width":"height")),[o,s]),i=Ye(a,!0,F("skipAnimationFrameInResizeObserver"));return C.useEffect(()=>{t&&(o(t.viewportHeight),n(t.itemHeight))},[t,o,n]),S.jsx("div",{"data-viewport-type":"element",ref:i,style:Pt(r),children:e})},ls=({children:e})=>{const t=C.useContext(gn),o=ke("windowViewportRect"),n=ke("fixedItemHeight"),r=F("customScrollParent"),s=Go(o,r,F("skipAnimationFrameInResizeObserver")),a=F("alignToBottom");return C.useEffect(()=>{t&&(n(t.itemHeight),o({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,o,n]),S.jsx("div",{"data-viewport-type":"window",ref:s,style:Pt(a),children:e})},cs=({children:e})=>{const t=F("TopItemListComponent")||"div",o=F("headerHeight"),n={...ns,marginTop:`${o}px`},r=F("context");return S.jsx(t,{style:n,...Se(t,r),children:e})},us=C.memo(function(e){const t=F("useWindowScroll"),o=F("topItemsIndexes").length>0,n=F("customScrollParent"),r=F("context");return S.jsxs(n||t?fs:ps,{...e,context:r,children:[o&&S.jsx(cs,{children:S.jsx(ko,{showTopList:!0})}),S.jsxs(n||t?ls:as,{children:[S.jsx(ss,{}),S.jsx(ko,{}),S.jsx(is,{})]})]})}),{Component:ds,useEmitter:ro,useEmitterValue:F,usePublisher:ke}=hn(Zr,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},us),ps=Sn({useEmitter:ro,useEmitterValue:F,usePublisher:ke}),fs=bn({useEmitter:ro,useEmitterValue:F,usePublisher:ke}),ms=ds,hs=Y(()=>{const e=O(c=>S.jsxs("td",{children:["Item $",c]})),t=O(null),o=O(c=>S.jsxs("td",{colSpan:1e3,children:["Group ",c]})),n=O(null),r=O(null),s=O({}),a=O(no),i=O(tt),l=(c,u=null)=>be(R(s,L(p=>p[c]),se()),u);return{components:s,computeItemKey:a,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:r,fixedHeaderContent:n,itemContent:e,groupContent:o,ScrollerComponent:l("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}});ie(mn,hs);oo();const Oo={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},gs={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ao,floor:$t,max:st,min:Ht,round:jo}=Math;function Po(e,t,o){return Array.from({length:t-e+1}).map((n,r)=>({data:o===null?null:o[r+e],index:r+e}))}function ys(e){return{...gs,items:e}}function St(e,t){return e&&e.width===t.width&&e.height===t.height}function ws(e,t){return e&&e.column===t.column&&e.row===t.row}const xs=Y(([{increaseViewportBy:e,listBoundary:t,overscan:o,visibleRange:n},{footerHeight:r,headerHeight:s,scrollBy:a,scrollContainerState:i,scrollTo:l,scrollTop:c,smoothScrollTargetReached:u,viewportHeight:p},m,h,{didMount:$,propsReady:x},{customScrollParent:w,useWindowScroll:y,windowScrollContainerState:d,windowScrollTo:g,windowViewportRect:T},b])=>{const E=O(0),f=O(0),v=O(Oo),k=O({height:0,width:0}),A=O({height:0,width:0}),j=q(),N=q(),z=O(0),V=O(null),D=O({column:0,row:0}),X=q(),Q=q(),we=O(!1),xe=O(0),ve=O(!0),I=O(!1),_=O(!1);Z(R($,W(xe),B(([P,J])=>!!J)),()=>{U(ve,!1)}),Z(R(de($,ve,A,k,xe,I),B(([P,J,ne,he,,Ee])=>P&&!J&&ne.height!==0&&he.height!==0&&!Ee)),([,,,,P])=>{U(I,!0),Qt(1,()=>{U(j,P)}),je(R(c),()=>{U(t,[0,0]),U(ve,!0)})}),M(R(Q,B(P=>P!=null&&P.scrollTop>0),Ve(0)),f),Z(R($,W(Q),B(([,P])=>P!=null)),([,P])=>{P&&(U(k,P.viewport),U(A,P.item),U(D,P.gap),P.scrollTop>0&&(U(we,!0),je(R(c,qe(1)),J=>{U(we,!1)}),U(l,{top:P.scrollTop})))}),M(R(k,L(({height:P})=>P)),p),M(R(de(H(k,St),H(A,St),H(D,(P,J)=>P&&P.column===J.column&&P.row===J.row),H(c)),L(([P,J,ne,he])=>({gap:ne,item:J,scrollTop:he,viewport:P}))),X),M(R(de(H(E),n,H(D,ws),H(A,St),H(k,St),H(V),H(f),H(we),H(ve),H(xe)),B(([,,,,,,,P])=>!P),L(([P,[J,ne],he,Ee,pe,ce,me,,ue,te])=>{const{column:re,row:Re}=he,{height:ge,width:Lt}=Ee,{width:io}=pe;if(me===0&&(P===0||io===0))return Oo;if(Lt===0){const po=Kt(te,P),Ln=po+Math.max(me-1,0);return ys(Po(po,Ln,ce))}const wt=Tn(io,Lt,re);let Ze,Ue;ue?J===0&&ne===0&&me>0?(Ze=0,Ue=me-1):(Ze=wt*$t((J+Re)/(ge+Re)),Ue=wt*Ao((ne+Re)/(ge+Re))-1,Ue=Ht(P-1,st(Ue,wt-1)),Ze=Ht(Ue,st(0,Ze))):(Ze=0,Ue=-1);const ao=Po(Ze,Ue,ce),{bottom:lo,top:co}=Lo(pe,he,Ee,ao),uo=Ao(P/wt),Pn=uo*ge+(uo-1)*Re-lo;return{bottom:lo,itemHeight:ge,items:ao,itemWidth:Lt,offsetBottom:Pn,offsetTop:co,top:co}})),v),M(R(V,B(P=>P!==null),L(P=>P.length)),E),M(R(de(k,A,v,D),B(([P,J,{items:ne}])=>ne.length>0&&J.height!==0&&P.height!==0),L(([P,J,{items:ne},he])=>{const{bottom:Ee,top:pe}=Lo(P,he,J,ne);return[pe,Ee]}),se(ct)),t);const G=O(!1);M(R(c,W(G),L(([P,J])=>J||P!==0)),G);const K=$e(R(de(v,E),B(([{items:P}])=>P.length>0),W(G),B(([[P,J],ne])=>{const he=P.items[P.items.length-1].index===J-1;return(ne||P.bottom>0&&P.itemHeight>0&&P.offsetBottom===0&&P.items.length===J)&&he}),L(([[,P]])=>P-1),se())),Le=$e(R(H(v),B(({items:P})=>P.length>0&&P[0].index===0),Ve(0),se())),Me=$e(R(H(v),W(we),B(([{items:P},J])=>P.length>0&&!J),L(([{items:P}])=>({endIndex:P[P.length-1].index,startIndex:P[0].index})),se(en),_e(0)));M(Me,h.scrollSeekRangeChanged),M(R(j,W(k,A,E,D),L(([P,J,ne,he,Ee])=>{const pe=sn(P),{align:ce,behavior:me,offset:ue}=pe;let te=pe.index;te==="LAST"&&(te=he-1),te=st(0,te,Ht(he-1,te));let re=Jt(J,Ee,ne,te);return ce==="end"?re=jo(re-J.height+ne.height):ce==="center"&&(re=jo(re-J.height/2+ne.height/2)),ue&&(re+=ue),{behavior:me,top:re}})),l);const ee=be(R(v,L(P=>P.offsetBottom+P.bottom)),0);return M(R(T,L(P=>({height:P.visibleHeight,width:P.visibleWidth}))),k),{customScrollParent:w,data:V,deviation:z,footerHeight:r,gap:D,headerHeight:s,increaseViewportBy:e,initialItemCount:f,itemDimensions:A,overscan:o,restoreStateFrom:Q,scrollBy:a,scrollContainerState:i,scrollHeight:N,scrollTo:l,scrollToIndex:j,scrollTop:c,smoothScrollTargetReached:u,totalCount:E,useWindowScroll:y,viewportDimensions:k,windowScrollContainerState:d,windowScrollTo:g,windowViewportRect:T,...h,gridState:v,horizontalDirection:_,initialTopMostItemIndex:xe,totalListHeight:ee,...m,endReached:K,propsReady:x,rangeChanged:Me,startReached:Le,stateChanged:X,stateRestoreInProgress:we,...b}},ie(eo,Te,yt,pn,De,to,Fe));function Tn(e,t,o){return st(1,$t((e+o)/($t(t)+o)))}function Lo(e,t,o,n){const{height:r}=o;if(r===void 0||n.length===0)return{bottom:0,top:0};const s=Jt(e,t,o,n[0].index);return{bottom:Jt(e,t,o,n[n.length-1].index)+r,top:s}}function Jt(e,t,o,n){const r=Tn(e.width,o.width,t.column),s=$t(n/r),a=s*o.height+st(0,s-1)*t.row;return a>0?a+t.row:a}const vs=Y(()=>{const e=O(p=>`Item ${p}`),t=O({}),o=O(null),n=O("virtuoso-grid-item"),r=O("virtuoso-grid-list"),s=O(no),a=O("div"),i=O(tt),l=(p,m=null)=>be(R(t,L(h=>h[p]),se()),m),c=O(!1),u=O(!1);return M(H(u),c),{components:t,computeItemKey:s,context:o,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:a,itemClassName:n,ItemComponent:l("Item","div"),itemContent:e,listClassName:r,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:u,ScrollerComponent:l("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),Ss=Y(([e,t])=>({...e,...t}),ie(xs,vs)),bs=C.memo(function(){const e=ae("gridState"),t=ae("listClassName"),o=ae("itemClassName"),n=ae("itemContent"),r=ae("computeItemKey"),s=ae("isSeeking"),a=Oe("scrollHeight"),i=ae("ItemComponent"),l=ae("ListComponent"),c=ae("ScrollSeekPlaceholder"),u=ae("context"),p=Oe("itemDimensions"),m=Oe("gap"),h=ae("log"),$=ae("stateRestoreInProgress"),x=Oe("reportReadyState"),w=Ye(C.useMemo(()=>y=>{const d=y.parentElement.parentElement.scrollHeight;a(d);const g=y.firstChild;if(g){const{height:T,width:b}=g.getBoundingClientRect();p({height:T,width:b})}m({column:Mo("column-gap",getComputedStyle(y).columnGap,h),row:Mo("row-gap",getComputedStyle(y).rowGap,h)})},[a,p,m,h]),!0,!1);return wn(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),$?null:S.jsx(l,{className:t,ref:w,...Se(l,u),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const d=r(y.index,y.data,u);return s?S.jsx(c,{...Se(c,u),height:e.itemHeight,index:y.index,width:e.itemWidth},d):C.createElement(i,{...Se(i,u),className:o,"data-index":y.index,key:d},n(y.index,y.data,u))})})}),Ts=C.memo(function(){const e=ae("HeaderComponent"),t=Oe("headerHeight"),o=ae("headerFooterTag"),n=Ye(C.useMemo(()=>s=>{t(He(s,"height"))},[t]),!0,!1),r=ae("context");return e?S.jsx(o,{ref:n,children:S.jsx(e,{...Se(e,r)})}):null}),Cs=C.memo(function(){const e=ae("FooterComponent"),t=Oe("footerHeight"),o=ae("headerFooterTag"),n=Ye(C.useMemo(()=>s=>{t(He(s,"height"))},[t]),!0,!1),r=ae("context");return e?S.jsx(o,{ref:n,children:S.jsx(e,{...Se(e,r)})}):null}),Is=({children:e})=>{const t=C.useContext(yn),o=Oe("itemDimensions"),n=Oe("viewportDimensions"),r=Ye(C.useMemo(()=>s=>{n(s.getBoundingClientRect())},[n]),!0,!1);return C.useEffect(()=>{t&&(n({height:t.viewportHeight,width:t.viewportWidth}),o({height:t.itemHeight,width:t.itemWidth}))},[t,n,o]),S.jsx("div",{ref:r,style:Pt(!1),children:e})},$s=({children:e})=>{const t=C.useContext(yn),o=Oe("windowViewportRect"),n=Oe("itemDimensions"),r=ae("customScrollParent"),s=Go(o,r,!1);return C.useEffect(()=>{t&&(n({height:t.itemHeight,width:t.itemWidth}),o({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,o,n]),S.jsx("div",{ref:s,style:Pt(!1),children:e})},Es=C.memo(function({...e}){const t=ae("useWindowScroll"),o=ae("customScrollParent"),n=o||t?ks:Rs,r=o||t?$s:Is,s=ae("context");return S.jsx(n,{...e,...Se(n,s),children:S.jsxs(r,{children:[S.jsx(Ts,{}),S.jsx(bs,{}),S.jsx(Cs,{})]})})}),{useEmitter:Cn,useEmitterValue:ae,usePublisher:Oe}=hn(Ss,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},Es),Rs=Sn({useEmitter:Cn,useEmitterValue:ae,usePublisher:Oe}),ks=bn({useEmitter:Cn,useEmitterValue:ae,usePublisher:Oe});function Mo(e,t,o){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&o(`${e} was not resolved to pixel value correctly`,t,Ce.WARN),t==="normal"?0:parseInt(t??"0",10)}const Os=({visible:e,onClick:t})=>e?S.jsx("button",{type:"button",className:"chat-scroll-bottom",onClick:t,"aria-label":"Scroll to bottom",children:S.jsx("img",{src:Uo,alt:"arrow up",width:24,height:24,style:{transform:"rotate(180deg)",filter:"var(--icon-filter-text)"}})}):null,As=()=>{const{messages:e=[],classNames:t,isOpen:o,isLoading:n}=Ge(),[r,s]=C.useState(!1),a=C.useRef(null),i=()=>{a.current?.scrollToIndex({index:e.length-1,behavior:"smooth"})},l=e?.length??1;return C.useEffect(()=>{o&&setTimeout(i,0)},[o]),C.useEffect(()=>{i()},[e?.length]),S.jsxs("div",{className:Ae("autoui-chat-messages",t?.messageList),children:[S.jsx(ms,{ref:a,data:e,overscan:100,followOutput:"smooth",atBottomStateChange:c=>s(!c),components:{EmptyPlaceholder:()=>S.jsxs("div",{className:"empty__palceholder",children:[S.jsx("span",{className:"empty__palceholder--main",children:"Nothing here yet"}),S.jsx("span",{className:"empty__palceholder--secondary",children:"Start the conversation!"})]})},initialTopMostItemIndex:l-1,itemContent:(c,u)=>S.jsx("div",{className:Ae("autoui-message-row",u.role==="user"&&"is-user",u.role==="assistant"&&"is-assistant"),children:S.jsx(rr,{message:u})})}),S.jsx(Os,{visible:r,onClick:i}),n&&S.jsx(_n,{variant:"dots",color:"#0a84ff"})]})};async function js(e){const t=e.getReader(),o=new TextDecoder;let n="",r="";for(;;){const{value:a,done:i}=await t.read();if(i)break;n+=o.decode(a,{stream:!0});const l=n.split(`
7
+
8
+ `);n=l.pop()??"";for(const c of l){if(!c.startsWith("data:"))continue;const u=c.slice(5).trim();if(u==="[DONE]"){t.cancel();break}try{const m=JSON.parse(u).choices?.[0]?.delta?.content;m&&(r+=m)}catch(p){console.error(p)}}}const s=r.match(/\{[\s\S]*\}$/);if(!s)throw new Error("LLM did not return valid JSON InstructionPlan");return JSON.parse(s[0])}function Ps(e,t,o){const n=Object.entries(t.functions).map(([a,i])=>{const l=i.params?Object.entries(i.params).map(([u,p])=>` ${u}: ${p}`).join(`
9
+ `):" (no params)",c=i.canShareDataWithLLM?`
10
+ [Can share data with LLM - set hasToShareDataWithLLM based on user intent]`:"";return`${a}:
11
+ ${i.prompt}
12
+ Params:
13
+ ${l}${c}`}),r=Object.entries(t.components).map(([a,i])=>{const l=i.props?Object.entries(i.props).map(([c,u])=>` ${c}: ${u}`).join(`
14
+ `):" (no props)";return`${a}:
15
+ ${i.prompt}
16
+ Props:
17
+ ${l}`});return`You are an Intent Planner. Analyze available functions/components, user message, and message history to create an InstructionPlan.
18
+
19
+ OUTPUT SCHEMA:
22
20
  {
23
21
  "type": "sequence",
24
22
  "steps": [
25
- { "type": "function", "name": "<function name>", "params": { /* optional */ }, "assign": "<ctxKey>", "hasToShareDataWithLLM": true|false },
26
- { "type": "component", "name": "<component name>", "props": { /* optional, may reference {{ctxKey}} */ } }
27
- { "type": "text", "text": "<actual generated text>"} }
23
+ {
24
+ "type": "function",
25
+ "name": "<function name>",
26
+ "params": { /* required if function has params */ },
27
+ "assign": "<contextKey>",
28
+ "hasToShareDataWithLLM": true | false
29
+ },
30
+ {
31
+ "type": "component",
32
+ "name": "<component name>",
33
+ "props": { /* may reference {{contextKey}} */ }
34
+ },
35
+ {
36
+ "type": "text",
37
+ "text": "<message>"
38
+ }
28
39
  ]
29
40
  }
30
41
 
31
42
  RULES:
32
- - "type" must be exactly "sequence".
33
- - "steps" must be a non-empty array.
34
- - Use ONLY declared function/component names from the lists below.
35
- - If a component needs data, call a function first and save it under an "assign" key, then reference it in props via "{{assignKey}}".
36
- - Do not add "intent", "explanations", or any keys not in the schema.
37
- - Output a single JSON object (no arrays or strings at top-level).
43
+ 1. Analyze user message + history to understand intent. Use history ONLY if message references prior conversation.
44
+ 2. If function has params listed, they are REQUIRED. Chain functions if needed: call data-fetching function first, assign result, then use {{contextKey}} in params.
45
+ IMPORTANT: When a function requires a param that should come from a previous step's assign key, use {{contextKey}} syntax in the params object.
46
+ Example: If step 1 has assign: "tasks", and step 2 function needs "tasks" param, use params: { "tasks": "{{tasks}}" }
47
+ 3. hasToShareDataWithLLM: Set to true if user requests FILTERED/SPECIFIC data (criteria, conditions, analysis, explanations) OR false if user wants ALL/COMPLETE data.
48
+ 4. Extract component props from user message or use context variables. Function params can also use context variables with {{contextKey}} syntax.
49
+ 5. Be minimal - only include necessary steps.
50
+ 6. Return ONLY valid JSON, no markdown or comments.
51
+
52
+ ${t.llm.appDescriptionPrompt?`
53
+ APP CONTEXT:
54
+ ${t.llm.appDescriptionPrompt}${t.metadata?.appName?`
55
+ App: ${t.metadata.appName}`:""}
56
+ `:""}AVAILABLE FUNCTIONS:
57
+ ${n.join(`
58
+
59
+ `)}
38
60
 
39
- ${t.llm.appDescriptionPrompt&&`Here is the description of the current app using AUTOUI library made by developer so that you would know the context of what your answers must be about. If userMessages are not related to that description below then inform user that you can only answer questions related to this current website: ${t.llm.appDescriptionPrompt} ${t.metadata?.appName}`}
40
- `,"","Available functions:",n.join(`
61
+ AVAILABLE COMPONENTS:
62
+ ${r.join(`
41
63
 
42
- `),"","Available components:",o.join(`
64
+ `)}
43
65
 
44
- `),"",`VALID EXAMPLE:
66
+ EXAMPLE 1:
67
+ User: "show tasks related to food"
45
68
  {
46
69
  "type": "sequence",
47
70
  "steps": [
48
- { "type": "function", "name": "fetchProducts", "params": { "color": "red" }, "assign": "items", hasToShareDataWithLLM: true },
49
- { "type": "component", "name": "ProductList", "props": { "products": "{{items}}", "onAddToCart": "addToCart" } }
50
- { "type": "text", "text": "Here is the product list we found for you" }
71
+ {
72
+ "type": "function",
73
+ "name": "fetchTasks",
74
+ "params": {},
75
+ "assign": "tasks",
76
+ "hasToShareDataWithLLM": true
77
+ },
78
+ {
79
+ "type": "component",
80
+ "name": "TasksList",
81
+ "props": { "tasks": "{{tasks}}" }
82
+ }
51
83
  ]
52
- }`,"",`USER MESSAGE: "${e}"`,"","Respond with ONLY the plan JSON (no code fences, no commentary)."].join(`
53
- `)}async function Cs(e,t){const n=await fetch(`${t.llm.proxyUrl}/chat/create`,{method:"POST",headers:{"Content-Type":"application/json","X-AUTOUI-APP-ID":t.appId,...t.llm.sharedSecret&&{"X-AUTOUI-SECRET":t.llm.sharedSecret}},body:JSON.stringify({messages:[{role:"user",content:ws(e,t)}],temperature:t.llm.temperature,maxTokens:t.llm.maxTokens,appDescriptionPrompt:t.llm.appDescriptionPrompt})});if(!n.ok||!n.body)throw new Error(`AutoUI proxy error: ${n.status}`);return go(n.body)}function Ss(e){return{processMessage:x.useCallback(async n=>{let o=await Cs(n,e);if(console.log("RAW PLAN FROM LLM:",o),typeof o=="string")try{o=JSON.parse(o)}catch{throw console.error("❌ Failed to parse plan JSON:",o),new Error("Invalid plan format: could not parse JSON")}if(!o||typeof o!="object"||!o.type||!o.steps)throw console.error("❌ Invalid plan structure:",o),new Error("Plan must be an object with 'type' and 'steps'.");return o},[e])}}function Ft(e,t,n){if(e==null)return e;if(typeof e=="string"){if(e.startsWith("{{")&&e.endsWith("}}")){const o=e.slice(2,-2).trim();return t[o]}return e}if(Array.isArray(e))return e.map(o=>Ft(o,t,n));if(typeof e=="object"){const o={};for(const[r,s]of Object.entries(e))if(typeof s=="string"&&/^on[A-Z]/.test(r)&&n.functions[s]){const i=s;o[r]=async(...l)=>await n.functions[i].callFunc({args:l})}else o[r]=Ft(s,t,n);return o}return e}const Ts=(e,t,n,o,r)=>{const s=o.steps.find(a=>a.type=="function"&&a.name===r);console.log("Building data analyzing prompt for current step: ",s);const i=o.steps.indexOf(s)+1;return console.log("Data being passed to the next step, which is ",o.steps[i]),`You are an expert data analyst. Analyze the following data according to that user's message ${n}.
84
+ }
85
+ Note: hasToShareDataWithLLM: true because user requested filtered data (tasks "related to food").
86
+
87
+ EXAMPLE 2 (Function params using context):
88
+ User: "fetch tasks and then summarize them"
89
+ {
90
+ "type": "sequence",
91
+ "steps": [
92
+ {
93
+ "type": "function",
94
+ "name": "fetchTasks",
95
+ "params": {},
96
+ "assign": "tasks",
97
+ "hasToShareDataWithLLM": false
98
+ },
99
+ {
100
+ "type": "function",
101
+ "name": "summarizeTasks",
102
+ "params": { "tasks": "{{tasks}}" },
103
+ "assign": "summary"
104
+ }
105
+ ]
106
+ }
107
+ Note: The second function uses {{tasks}} in params to reference the assign key from the first step.
108
+
109
+ MESSAGE HISTORY:
110
+ ${o||"(none)"}
111
+
112
+ CURRENT USER MESSAGE:
113
+ "${e}"
114
+
115
+ Return InstructionPlan JSON:`.trim()}async function Ls(e,t,o){const n=t.llm.proxyUrl??"https://autoui-proxy.onrender.com",r=Ps(e,t,o),s=await fetch(`${n}/chat/create`,{method:"POST",headers:{"Content-Type":"application/json","X-AUTOUI-APP-ID":t.appId,...t.llm.sharedSecret&&{"X-AUTOUI-SECRET":t.llm.sharedSecret,authorization:"Bearer "+t.llm.sharedSecret}},body:JSON.stringify({messages:[{role:"user",content:r}],temperature:t.llm.temperature,maxTokens:t.llm.maxTokens,appDescriptionPrompt:t.llm.appDescriptionPrompt,appId:t.appId})});if(!s.ok||!s.body)throw new Error(`AutoUI proxy error: ${s.status}`);return console.log("Response received from LLM proxy for instruction plan.: ",JSON.stringify(s.body)),js(s.body)}function Ms(e){return{processMessage:C.useCallback(async(o,n)=>{let r=await Ls(o,e,n);if(console.log("RAW PLAN FROM LLM:",r),typeof r=="string")try{r=JSON.parse(r)}catch{throw console.error("❌ Failed to parse plan JSON:",r),new Error("Invalid plan format: could not parse JSON")}if(!r||typeof r!="object"||!r.type||!r.steps)throw console.error("❌ Invalid plan structure:",r),new Error("Plan must be an object with 'type' and 'steps'.");return r},[e])}}function Et(e,t,o){if(e==null)return e;if(typeof e=="string"){if(e.startsWith("{{")&&e.endsWith("}}")){const n=e.slice(2,-2).trim(),r=t[n];return r===void 0&&console.warn(`⚠️ [ResolveProps] Context key "${n}" not found. Available keys:`,Object.keys(t)),r}return e}if(Array.isArray(e))return e.map(n=>Et(n,t,o));if(typeof e=="object"){const n={};for(const[r,s]of Object.entries(e))if(typeof s=="string"&&/^on[A-Z]/.test(r)&&o.functions[s]){const a=s;n[r]=async(...i)=>await o.functions[a].callFunc({args:i})}else n[r]=Et(s,t,o);return n}return e}const Vs=(e,t,o)=>{e(n=>t?.children?[...n,{id:`${Date.now()}-a`,role:"assistant",kind:"ui",ui:{t:"fragment",children:t.children}}]:[...n,{id:`${Date.now()}-a`,role:"assistant",kind:"ui",ui:{t:"component",name:o.name,props:t}}])},Ns=e=>!!e&&typeof e=="object"&&!Array.isArray(e),zs=async(e,t)=>{const o=e.callFunc,n=t,r=Array.isArray(n.args),s=!!n.params&&typeof n.params=="object";let a;if(r){let i=n.args;if(i.length===1&&Ns(i[0])&&Array.isArray(e.params)&&e.params.length>0){const l=i[0];i=e.params.map(c=>l[c])}try{a=await o(...i)}catch{a=await o(i)}}else s?a=await o(n.params):a=await o();return a};function In(e,t){return e?e.type==="component"?JSON.stringify(e.props??{}).includes(`{{${t}}}`):e.type==="function"?JSON.stringify(e.params??{}).includes(`{{${t}}}`)||JSON.stringify(e.args??[]).includes(`{{${t}}}`):!1:!1}function $n(e,t){if(!e)return null;if(e.type==="component"){const o=t.components[e.name];return o?.props?{parseTo:"object",schema:o.props}:null}if(e.type==="function"){const o=t.functions[e.name];return o?.params?{parseTo:"object",schema:o.params}:null}return null}async function _s(e,t,o){for(const n of t)if(In(n,e)){let r;if(n.type==="function"){const i=n.params??{};r=Object.keys(i).find(l=>{const c=i[l];return typeof c=="string"&&c.includes(`{{${e}}}`)})}else if(n.type==="component"){const i=n.props??{};r=Object.keys(i).find(l=>{const c=i[l];return typeof c=="string"&&c.includes(`{{${e}}}`)})}const s=await Promise.resolve().then(()=>mt),a=await s.getRuntimeSchemaAsync(o);if(a&&r){if(n.type==="function"){const i=a.functions.find(l=>l.name===n.name);if(i&&i.params[r]){const l=i.params[r],c=s.resolveType(l.type,a);if(c){let u="primitive";return c.type==="array"?u="array":c.type==="object"&&(u="object"),{parseTo:u,schema:c,paramName:r}}}}else if(n.type==="component"){const i=a.components.find(l=>l.name===n.name);if(i&&i.props[r]){const l=i.props[r],c=s.resolveType(l.type,a);if(c){let u="primitive";return c.type==="array"?u="array":c.type==="object"&&(u="object"),{parseTo:u,schema:c,paramName:r}}}}}return $n(n,o)}return null}function En(e,t){if(!e||e.type!=="component")return[];const o=e.props??{};return Object.entries(o).filter(([,n])=>typeof n=="string"&&n.includes(`{{${t}}}`)).map(([n])=>n)}function Rn(e,t){return t.length===1&&e&&typeof e=="object"&&!Array.isArray(e)&&t[0]in e?e[t[0]]:e}const Hs=Object.freeze(Object.defineProperty({__proto__:null,getConsumerKeysForAssign:En,getExpectedSchemaForAssignKey:_s,getExpectedSchemaForStep:$n,normalizeForCtx:Rn,stepConsumesAssign:In},Symbol.toStringTag,{value:"Module"})),Bs=async(e,t,o,n,r,s,a,i)=>{const l=i?.parseTo??"primitive",c=r.steps.slice(a+1),u={type:r.type,steps:c},p=i&&i.parseTo!=="primitive"?JSON.stringify(i.schema,null,2):null;let m=e;if(JSON.stringify(e).length>2e3){if(Array.isArray(e))m={_type:"array",_length:e.length,_preview:e.slice(0,3),_note:`... and ${e.length-3} more items`};else if(typeof e=="object"&&e!==null){const d=Object.keys(e);m={_type:"object",_keys:d,_preview:Object.fromEntries(d.slice(0,5).map(g=>[g,e[g]])),_note:d.length>5?`... and ${d.length-5} more properties`:""}}}const $=n&&n.length>0&&n.length<500,x=new Set,w=new Set;c.forEach(d=>{d.type==="component"?x.add(d.name):d.type==="function"&&w.add(d.name)});let y="";if(x.size>0||w.size>0){const{getRuntimeSchemaAsync:d}=await Promise.resolve().then(()=>mt),g=await d(t);if(g){const T=[];x.size>0&&x.forEach(b=>{const E=g.components.find(f=>f.name===b);if(E){const f=Object.entries(E.props).filter(([A,j])=>j.required).map(([A,j])=>`${A} (${j.type}${j.required?", required":""})`),v=Object.entries(E.props).filter(([A,j])=>!j.required).map(([A,j])=>`${A} (${j.type}, optional)`);let k=`COMPONENT "${b}":`;f.length>0&&(k+=`
116
+ REQUIRED PROPS: ${f.join(", ")}`),v.length>0&&(k+=`
117
+ OPTIONAL PROPS: ${v.join(", ")}`),T.push(k)}}),w.size>0&&w.forEach(b=>{const E=g.functions.find(f=>f.name===b);if(E){const f=Object.entries(E.params).filter(([A,j])=>j.required).map(([A,j])=>`${A} (${j.type}${j.required?", required":""})`),v=Object.entries(E.params).filter(([A,j])=>!j.required).map(([A,j])=>`${A} (${j.type}, optional)`);let k=`FUNCTION "${b}":`;f.length>0&&(k+=`
118
+ REQUIRED PARAMS: ${f.join(", ")}`),v.length>0&&(k+=`
119
+ OPTIONAL PARAMS: ${v.join(", ")}`),k+=`
120
+ RETURNS: ${E.returns.type}`,T.push(k)}}),T.length>0&&(y=`
121
+
122
+ AVAILABLE COMPONENTS/FUNCTIONS IN PLAN (use ONLY these props/params):
123
+ ${T.join(`
124
+
125
+ `)}
126
+ `)}}return`You are AutoUI Data Analyzer. Analyze function output and refine downstream steps.
127
+
128
+ RULES:
129
+ 1. Return ONLY JSON: { "parseTo": "${l}", "data": <value>, "newInstructionPlan": <plan|null> }
130
+ 2. "data" MUST match expected schema (preserve structure for arrays/objects)
131
+ 3. "newInstructionPlan" is null by default - only set if downstream steps need refinement
132
+ 4. Only modify steps AFTER the data-consuming step
133
+ 5. Keep structured data intact - use text steps for explanations
134
+
135
+ CRITICAL: FILTER AND TRANSFORM DATA BASED ON USER INTENT
136
+ - If the user requests SPECIFIC/FILTERED data (e.g., "tasks related to food", "items with status X", "tasks matching Y"),
137
+ you MUST filter/transform the data array/object to only include matching items BEFORE returning it in the "data" field.
138
+ - The "data" field should contain the FILTERED/TRANSFORMED data that matches what the user asked for.
139
+ - Do NOT return all data if the user asked for a subset - filter it first.
140
+ - Examples:
141
+ * User: "tasks related to food" → Filter array to only tasks with food-related titles
142
+ * User: "high priority items" → Filter array to only items with priority="high"
143
+ * User: "completed tasks" → Filter array to only tasks with status="done"
144
+ - If the user asks for ALL/COMPLETE data without filters, return the data as-is.
145
+
146
+ CONTEXT:
147
+ User: "${o}"
148
+ ${$?`Previous: ${n.substring(0,300)}`:""}
149
+
150
+ REMAINING STEPS (modify only these):
151
+ ${JSON.stringify(u,null,2)}
152
+
153
+ FUNCTION OUTPUT:
154
+ ${JSON.stringify(m,null,2)}
155
+ ${p?`
156
+ EXPECTED SCHEMA:
157
+ ${p}`:""}
158
+ ${y}
159
+
160
+ CRITICAL RULES FOR newInstructionPlan:
161
+ - When modifying component props, use ONLY the props listed above for that component
162
+ - When modifying function params, use ONLY the params listed above for that function
163
+ - DO NOT create props/params that don't exist in the schema above
164
+ - Use context variables ({{contextKey}}) to reference data from previous steps
165
+ - If a component requires a prop (marked as required), you MUST include it in the props object
166
+ - Example: If TaskStats requires "tasks" prop, use: { "tasks": "{{tasks}}" } NOT { "filter": "food" }
167
+
168
+ Return JSON only.`.trim()};function Fs(e){if(e==null)throw new Error("Invalid LLM response: null or undefined");if(typeof e=="string"){let s=e;const a=s.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/);a&&(s=a[1].trim());try{e=JSON.parse(s)}catch{throw new Error(`Invalid LLM response: content is a string but not valid JSON: ${e.substring(0,100)}`)}}if(typeof e!="object"||Array.isArray(e))throw new Error(`Invalid LLM response: expected object but got ${typeof e}${Array.isArray(e)?" (array)":""}`);const{parseTo:t,data:o,newInstructionPlan:n}=e;if(o===void 0)throw new Error("Invalid LLM response: missing data field");let r;if(t==="array")if(Array.isArray(o))r=o;else if(typeof o=="object"&&o!==null&&!Array.isArray(o)){const s=Object.values(o);if(s.length!==1)throw new Error(`LLM data object must contain exactly one value when parseTo is 'array', got ${s.length}`);if(r=s[0],!Array.isArray(r))throw new Error(`Expected array but got ${typeof r}`)}else throw new Error(`Expected array or object containing array, got ${typeof o}`);else if(t==="object"){if(typeof o!="object"||o===null||Array.isArray(o))throw new Error(`Expected object but got ${Array.isArray(o)?"array":typeof o}`);const s=Object.values(o);if(s.length!==1)throw new Error(`LLM data object must contain exactly one value when parseTo is 'object', got ${s.length}`);r=s[0]}else r=o;return{parseTo:t??"primitive",data:r,newInstructionPlan:n??null}}const Ds=async(e,t,o,n,r,s,a,i)=>{try{const l=await Bs(e,t,o,n,r,s,a,i);console.log(`📤 [ExtraAnalysis] Sending request to LLM (prompt length: ${l.length} chars)`);const c=t.llm.proxyUrl??"https://autoui-proxy.onrender.com",u=await fetch(`${c}/chat/extraAnalysis`,{method:"POST",headers:{"Content-Type":"application/json","X-AUTOUI-APP-ID":t.appId,...t.llm.sharedSecret&&{"X-AUTOUI-SECRET":t.llm.sharedSecret}},body:JSON.stringify({messages:[{role:"user",content:l}],temperature:t.llm.temperature??.2,appId:t.appId})});if(!u.ok){const x=await u.text();throw console.error(`❌ [ExtraAnalysis] API error ${u.status}:`,x),new Error(`AutoUI proxy error: ${u.status} - ${x}`)}let p=await u.text();console.log("✅ [ExtraAnalysis] Raw response received (text):",p.substring(0,200));const m=p.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/);m&&(p=m[1].trim(),console.log("✅ [ExtraAnalysis] Stripped markdown code blocks"));let h;try{h=JSON.parse(p),console.log("✅ [ExtraAnalysis] Parsed JSON response")}catch(x){throw console.error("❌ [ExtraAnalysis] Response is not valid JSON:",x),console.error("❌ [ExtraAnalysis] Response text:",p),new Error(`Invalid JSON response from LLM: ${p.substring(0,200)}`)}if(h&&typeof h=="object"){if("content"in h&&typeof h.content=="string")try{let x=h.content;const w=x.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/);w&&(x=w[1].trim(),console.log("✅ [ExtraAnalysis] Stripped markdown code blocks from nested content")),h=JSON.parse(x),console.log("✅ [ExtraAnalysis] Extracted and parsed content from wrapper")}catch{console.warn("⚠️ [ExtraAnalysis] content.content is not JSON, using original")}else if("response"in h)if(typeof h.response=="string"){let x=h.response;const w=x.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/);if(w){x=w[1].trim();try{h=JSON.parse(x),console.log("✅ [ExtraAnalysis] Extracted and parsed response from wrapper (stripped markdown)")}catch{h=x,console.log("✅ [ExtraAnalysis] Extracted response from wrapper (as string)")}}else h=h.response,console.log("✅ [ExtraAnalysis] Extracted response from wrapper")}else h=h.response,console.log("✅ [ExtraAnalysis] Extracted response from wrapper");else if("message"in h&&typeof h.message=="string")try{let x=h.message;const w=x.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/);w&&(x=w[1].trim(),console.log("✅ [ExtraAnalysis] Stripped markdown code blocks from message")),h=JSON.parse(x),console.log("✅ [ExtraAnalysis] Extracted and parsed message from wrapper")}catch{console.warn("⚠️ [ExtraAnalysis] message is not JSON, using original")}}console.log("✅ [ExtraAnalysis] Final content to parse:",typeof h,h);const $=Fs(h);return console.log("✅ [ExtraAnalysis] Parsed response:",{hasData:!!$.data,hasNewPlan:!!$.newInstructionPlan,parseTo:$.parseTo}),$}catch(l){return console.error("❌ [ExtraAnalysis] Error during analysis:",l),{parseTo:i?.parseTo??"primitive",data:e,newInstructionPlan:null}}},Us=async(e,t,o,n,r,s,a,i,l,c,u,p,m)=>{console.log(`🔍 [AnalyzeDataStep] Starting analysis for step "${n.name}" at index ${r}`),console.log("🔍 [AnalyzeDataStep] Output data type:",typeof t,Array.isArray(t)?"array":"object"),console.log("🔍 [AnalyzeDataStep] Assign key:",o),console.log("🔍 [AnalyzeDataStep] Next step:",s?.type,s?.type==="component"||s?.type==="function"?s.name:"");const h=c.steps.slice(r+1);let $=null;if(o&&h.length>0){const{getExpectedSchemaForAssignKey:x}=await Promise.resolve().then(()=>Hs);$=await x(o,h,e),$?console.log(`📋 [AnalyzeDataStep] Expected schema found for assign key "${o}":`,$):console.log(`ℹ️ [AnalyzeDataStep] No expected schema - no remaining steps consume assign key "${o}"`)}else console.log("ℹ️ [AnalyzeDataStep] No expected schema - no assign key or no remaining steps");try{console.log("🚀 [AnalyzeDataStep] Calling extraAnalysisWithLLM...");const x=await Ds(t,e,a,i,c,n,r,$);console.log("✅ [AnalyzeDataStep] Received analysis result:",{hasData:!!x.data,hasNewPlan:!!x.newInstructionPlan,parseTo:x.parseTo});const w=En(s,o),y=Rn(x.data,w);if(console.log("Extra analysis data received from LLM:",x),console.log("Normalized ctx value:",y),o&&(l[o]=y),x.newInstructionPlan!=null&&x.newInstructionPlan!=""){if(console.log("analyzed.newInstructionPlan: ",x.newInstructionPlan),o){const d=JSON.parse(JSON.stringify(x.newInstructionPlan));d.steps&&d.steps.forEach(g=>{g.type==="component"&&g.props&&Object.keys(g.props).forEach(T=>{typeof g.props[T]=="string"&&g.props[T]==="{{data}}"&&(g.props[T]=`{{${o}}}`)})}),kt(d,e,u,p,m,a,i,l)}else kt(x.newInstructionPlan,e,u,p,m,a,i,l);return!0}return!1}catch(x){return console.error(x),!0}},bt=new Map,Vo=new Set;async function Ws(e){const t=e;if(Vo.has(t))return bt.get(t)||null;Vo.add(t);try{let o;if(t.startsWith("http://")||t.startsWith("https://")){console.log(`📥 [Runtime Validation] Fetching schema from URL: ${t}`);const n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch schema: ${n.status} ${n.statusText}`);o=await n.json()}else{const n=[t.startsWith("/")?t:`/${t}`,`/public/${t}`,t];let r=null;for(const s of n)try{console.log(`📥 [Runtime Validation] Trying to fetch schema from: ${s}`);const a=await fetch(s);if(a.ok){o=await a.json(),console.log(`✅ [Runtime Validation] Successfully loaded schema from: ${s}`);break}else r=new Error(`HTTP ${a.status}: ${a.statusText}`)}catch(a){r=a instanceof Error?a:new Error(String(a));continue}if(!o)throw r||new Error(`Failed to load schema from any path: ${n.join(", ")}`)}return o&&o.types&&o.components&&o.functions?(console.log("✅ [Runtime Validation] Runtime schema loaded successfully",{path:t,types:Object.keys(o.types).length,components:o.components.length,functions:o.functions.length}),bt.set(t,o),o):(console.warn("⚠️ [Runtime Validation] Runtime schema has invalid structure"),bt.set(t,null),null)}catch(o){return console.warn(`⚠️ [Runtime Validation] Runtime schema file not found at "${t}":`,o),bt.set(t,null),null}}async function so(e){const t=e?.runtime?.runtimeSchemaPath||".autoui-runtime-schema.json";return await Ws(t)}function Je(e,t){return t.types[e]||null}function it(e,t,o,n,r=""){const s=[],a=r||"value",i=" ".repeat((r.match(/\./g)||[]).length+1);if(console.log(`${i}🔎 [Type Validation] Validating "${a}" against type "${o}"`),console.log(`${i} 📦 Value:`,e),console.log(`${i} 🔍 Value type: ${typeof e}, isArray: ${Array.isArray(e)}, isNull: ${e===null}`),console.log(`${i} 📋 Type definition:`,JSON.stringify(t,null,2)),e==null)return console.log(`${i} ℹ️ Value is ${e===void 0?"undefined":"null"} - skipping (optionality checked at prop/param level)`),s;switch(t.type){case"primitive":if(console.log(`${i} 🔍 Checking primitive type: "${o}"`),o==="string"&&typeof e!="string"){const l=`${a} must be a string, got ${typeof e}`;console.log(`${i} ❌ ${l}`),s.push(l)}else if(o==="number"&&(typeof e!="number"||isNaN(e))){const l=`${a} must be a number, got ${typeof e}`;console.log(`${i} ❌ ${l}`),s.push(l)}else if(o==="boolean"&&typeof e!="boolean"){const l=`${a} must be a boolean, got ${typeof e}`;console.log(`${i} ❌ ${l}`),s.push(l)}else console.log(`${i} ✅ Primitive type check passed`);break;case"enum":if(console.log(`${i} 🔍 Checking enum type with values:`,t.values),t.values&&Array.isArray(t.values))if(t.values.includes(e))console.log(`${i} ✅ Enum value check passed`);else{const l=`${a} must be one of: ${t.values.join(", ")}, got: ${e}`;console.log(`${i} ❌ ${l}`),s.push(l)}break;case"array":if(console.log(`${i} 🔍 Checking array type`),Array.isArray(e)){if(console.log(`${i} ✅ Array type check passed (length: ${e.length})`),t.items){const l=t.items.type;console.log(`${i} 🔍 Validating array items against type: "${l}"`);const c=Je(l,n);c?e.forEach((u,p)=>{console.log(`${i} 📦 Validating item [${p}]:`,u);const m=it(u,c,l,n,`${r}[${p}]`);s.push(...m)}):console.log(`${i} ⚠️ Item type "${l}" not found in schema`)}}else{const l=`${a} must be an array, got ${typeof e}`;if(console.log(`${i} ❌ ${l}`),console.log(`${i} 💡 Value is:`,e),console.log(`${i} 💡 Value constructor:`,e?.constructor?.name),typeof e=="string"){console.log(`${i} 💡 String value might be JSON - attempting to parse...`);try{const c=JSON.parse(e);console.log(`${i} 💡 Parsed successfully! Type: ${typeof c}, isArray: ${Array.isArray(c)}`),Array.isArray(c)&&console.log(`${i} ⚠️ WARNING: Value is a JSON string that should be parsed before validation!`)}catch{console.log(`${i} 💡 String is not valid JSON`)}}s.push(l)}break;case"object":if(console.log(`${i} 🔍 Checking object type`),typeof e!="object"||e===null||Array.isArray(e)){const l=`${a} must be an object, got ${typeof e}`;console.log(`${i} ❌ ${l}`),s.push(l)}else t.properties&&(console.log(`${i} ✅ Object type check passed`),console.log(`${i} 🔍 Validating object properties:`,Object.keys(t.properties)),Object.entries(t.properties).forEach(([l,c])=>{const u=e[l],p=r?`${r}.${l}`:l;if(console.log(`${i} 📦 Property "${l}":`,u),c.required&&u==null){const m=`${p} is required but was ${u===void 0?"undefined":"null"}`;console.log(`${i} ❌ ${m}`),s.push(m)}if(u!=null){const m=Je(c.type,n);if(m){const h=it(u,m,c.type,n,p);s.push(...h)}}}));break;case"union":if(console.log(`${i} 🔍 Checking union type with members:`,t.refs),t.refs&&t.refs.length>0){const l=[];for(const u of t.refs){console.log(`${i} 🔍 Trying union member: "${u}"`);const p=Je(u,n);if(p){const m=it(e,p,u,n,r);if(m.length===0)return console.log(`${i} ✅ Union member "${u}" validated successfully`),[];console.log(`${i} ❌ Union member "${u}" failed:`,m),l.push(...m)}}const c=`${a} does not match any union member. Errors: ${l.join("; ")}`;console.log(`${i} ❌ ${c}`),s.push(c)}break}return s.length===0?console.log(`${i} ✅ Type validation passed for "${a}"`):console.log(`${i} ❌ Type validation failed for "${a}" with ${s.length} error(s)`),s}function Js(e,t,o){const n=[];console.log(`
169
+ 🔍 [Runtime Validation] ==========================================`),console.log(`🔍 [Runtime Validation] Starting validation for component: "${e}"`),console.log("🔍 [Runtime Validation] Raw props received:",JSON.stringify(t,null,2)),console.log("🔍 [Runtime Validation] Props type check:",Object.entries(t).map(([s,a])=>`${s}: ${typeof a} (${Array.isArray(a)?"array":typeof a})`));const r=o.components.find(s=>s.name===e);return r?(console.log(`✅ [Runtime Validation] Found component schema for "${e}"`),console.log("📋 [Runtime Validation] Component schema:",JSON.stringify(r.props,null,2)),Object.entries(r.props).forEach(([s,a])=>{console.log(`
170
+ 📌 [Runtime Validation] Validating prop: "${s}"`),console.log(" 📥 [Runtime Validation] Prop reference:",JSON.stringify(a,null,2));const i=t[s];if(console.log(" 📦 [Runtime Validation] Prop value received:",i),console.log(` 🔎 [Runtime Validation] Prop value type: ${typeof i}`),console.log(` 🔎 [Runtime Validation] Prop value isArray: ${Array.isArray(i)}`),console.log(` 🔎 [Runtime Validation] Prop value isNull: ${i===null}`),console.log(` 🔎 [Runtime Validation] Prop value isUndefined: ${i===void 0}`),typeof i=="string"){console.log(` 📝 [Runtime Validation] String value length: ${i.length}`),console.log(` 📝 [Runtime Validation] String preview: ${i.substring(0,100)}${i.length>100?"...":""}`);try{const l=JSON.parse(i);console.log(" 🔄 [Runtime Validation] String appears to be JSON! Parsed as:",typeof l),Array.isArray(l)&&console.log(` 🔄 [Runtime Validation] Parsed JSON is an array with ${l.length} items`)}catch{console.log(" ℹ️ [Runtime Validation] String is not valid JSON")}}if(a.required&&i==null){const l=`Prop "${s}" is required but was ${i===void 0?"undefined":"null"}`;console.log(` ❌ [Runtime Validation] ${l}`),n.push(l);return}if(i!=null){console.log(` 🔍 [Runtime Validation] Resolving type: "${a.type}"`);const l=Je(a.type,o);if(l){console.log(" ✅ [Runtime Validation] Type definition found:",JSON.stringify(l,null,2)),console.log(" 🔄 [Runtime Validation] Starting type validation...");const c=it(i,l,a.type,o,s);c.length>0?console.log(` ❌ [Runtime Validation] Validation failed with ${c.length} error(s):`,c):console.log(` ✅ [Runtime Validation] Prop "${s}" passed validation`),n.push(...c)}else console.warn(` ⚠️ [Runtime Validation] Type "${a.type}" not found in schema for prop "${s}"`),console.log(" 📋 [Runtime Validation] Available types:",Object.keys(o.types).slice(0,10))}else console.log(` ℹ️ [Runtime Validation] Prop "${s}" is ${i===void 0?"undefined":"null"} - skipping validation`)}),console.log(`
171
+ 📊 [Runtime Validation] Validation summary for "${e}":`),n.length===0?console.log(" ✅ All props validated successfully"):console.log(` ❌ Found ${n.length} validation error(s):`,n),console.log(`🔍 [Runtime Validation] ==========================================
172
+ `),n):(console.warn(`⚠️ [Runtime Validation] Component "${e}" not found in schema`),console.log(" Available components:",o.components.map(s=>s.name)),n)}function qs(e,t,o){const n=[],r=[],s={...e},a=o.components.find(i=>i.name===t);return a?(Object.entries(a.props).forEach(([i,l])=>{const c=s[i];if(typeof c=="string"){const u=Je(l.type,o);if(u&&(u.type==="array"||u.type==="object")){const p=u.type,m=c.length>100?`${c.substring(0,100)}... (${c.length} chars)`:c;console.log(`🔄 [Parse Props] Attempting to parse prop "${i}" (expected type: ${p}, value: "${m}")`);try{const h=JSON.parse(c);if(p==="array"&&Array.isArray(h))console.log(`✅ [Parse Props] Successfully parsed JSON string for prop "${i}" as array (${h.length} items)`),s[i]=h;else if(p==="object"&&typeof h=="object"&&h!==null&&!Array.isArray(h))console.log(`✅ [Parse Props] Successfully parsed JSON string for prop "${i}" as object`),s[i]=h;else{const $=Array.isArray(h)?"array":typeof h;n.push({propName:i,expectedType:p,receivedValue:c,errorType:"type_mismatch",message:`Prop "${i}" was parsed as JSON but type doesn't match. Expected ${p}, got ${$}`,suggestion:`Ensure the context variable contains a valid ${p} JSON string (e.g., ${p==="array"?"[...]":"{...}"})`}),console.warn(`⚠️ [Parse Props] ${n[n.length-1].message}`)}}catch(h){const $=c.trim().startsWith("[")||c.trim().startsWith("{"),x=h instanceof Error?h.message:String(h);$?(n.push({propName:i,expectedType:p,receivedValue:c,errorType:"parsing_failed",message:`Prop "${i}" appears to be JSON but failed to parse: ${x}`,suggestion:`Check that the JSON string is valid. Received: "${m}"`}),console.error(`❌ [Parse Props] Failed to parse JSON string for prop "${i}" (expected ${p}): ${x}`)):(n.push({propName:i,expectedType:p,receivedValue:c,errorType:"invalid_json",message:`Prop "${i}" is a string but not in JSON format. Expected ${p}, got: "${c}"`,suggestion:l.required?`The prop "${i}" is required and should be a ${p} (array or object). Check that the context variable contains the correct data structure.`:`The prop "${i}" should be a ${p} if provided. Current value: "${c}"`}),console.warn(`⚠️ [Parse Props] Prop "${i}" is a string but not JSON format (expected ${p}, got: "${c}")`))}}}}),{props:s,errors:n,warnings:r}):(r.push(`Component "${t}" not found in schema - skipping JSON parsing`),{props:s,errors:n,warnings:r})}function Gs(e,t,o){const n=[];console.log(`
173
+ 🔍 [Runtime Validation] ==========================================`),console.log(`🔍 [Runtime Validation] Starting validation for function: "${e}"`),console.log("🔍 [Runtime Validation] Raw params received:",JSON.stringify(t,null,2)),console.log("🔍 [Runtime Validation] Params type check:",Object.entries(t).map(([s,a])=>`${s}: ${typeof a} (${Array.isArray(a)?"array":typeof a})`));const r=o.functions.find(s=>s.name===e);return r?(console.log(`✅ [Runtime Validation] Found function schema for "${e}"`),console.log("📋 [Runtime Validation] Function schema:",JSON.stringify(r.params,null,2)),Object.entries(r.params).forEach(([s,a])=>{console.log(`
174
+ 📌 [Runtime Validation] Validating param: "${s}"`),console.log(" 📥 [Runtime Validation] Param reference:",JSON.stringify(a,null,2));const i=t[s];if(console.log(" 📦 [Runtime Validation] Param value received:",i),console.log(` 🔎 [Runtime Validation] Param value type: ${typeof i}`),console.log(` 🔎 [Runtime Validation] Param value isArray: ${Array.isArray(i)}`),a.required&&i==null){const l=`Param "${s}" is required but was ${i===void 0?"undefined":"null"}`;console.log(` ❌ [Runtime Validation] ${l}`),n.push(l);return}if(i!=null){console.log(` 🔍 [Runtime Validation] Resolving type: "${a.type}"`);const l=Je(a.type,o);if(l){console.log(" ✅ [Runtime Validation] Type definition found:",JSON.stringify(l,null,2)),console.log(" 🔄 [Runtime Validation] Starting type validation...");const c=it(i,l,a.type,o,s);c.length>0?console.log(` ❌ [Runtime Validation] Validation failed with ${c.length} error(s):`,c):console.log(` ✅ [Runtime Validation] Param "${s}" passed validation`),n.push(...c)}else console.warn(` ⚠️ [Runtime Validation] Type "${a.type}" not found in schema for param "${s}"`)}else console.log(` ℹ️ [Runtime Validation] Param "${s}" is ${i===void 0?"undefined":"null"} - skipping validation`)}),console.log(`
175
+ 📊 [Runtime Validation] Validation summary for "${e}":`),n.length===0?console.log(" ✅ All params validated successfully"):console.log(` ❌ Found ${n.length} validation error(s):`,n),console.log(`🔍 [Runtime Validation] ==========================================
176
+ `),n):(console.warn(`⚠️ [Runtime Validation] Function "${e}" not found in schema`),console.log(" Available functions:",o.functions.map(s=>s.name)),n)}async function kn(e,t,o){const n=await so(e);if(!n)return console.warn("⚠️ [Runtime Validation] Runtime schema not available"),null;const r=e.metadata?.appVersion||"1.0.0";(n.appId!==e.appId||n.version!==r)&&console.warn(`⚠️ [Runtime Validation] Schema version mismatch. Expected: ${e.appId}@${r}, Got: ${n.appId}@${n.version}`);const s=o?n.components.filter(i=>i.name===o):n.components,a=t?n.functions.filter(i=>i.name===t):n.functions;return{components:s.map(i=>({name:i.name,props:i.props})),functions:a.map(i=>({name:i.name,params:i.params,returns:i.returns}))}}const mt=Object.freeze(Object.defineProperty({__proto__:null,getRuntimeSchemaAsync:so,getValidationSchemaRuntime:kn,parseJsonStringsInProps:qs,resolveType:Je,validateComponentPropsRuntime:Js,validateFunctionParamsRuntime:Gs},Symbol.toStringTag,{value:"Module"}));async function No(e,t,o){try{if(!await so(e))return console.warn("⚠️ [Validation] Runtime schema not found. Make sure .autoui-runtime-schema.json is generated and accessible."),console.warn(" The schema is generated at build-time by the AutoUI plugin."),console.warn(" Check that the plugin is configured and the schema file exists."),null;console.log("💾 [Validation] Using runtime schema (client-side validation, no backend needed)");const r=await kn(e,t,o);return r?{components:r.components.map(s=>({name:s.name,props:Object.fromEntries(Object.entries(s.props).map(([a,i])=>[a,{type:"object",optional:!i.required}]))})),functions:r.functions.map(s=>({name:s.name,params:Object.fromEntries(Object.entries(s.params).map(([a,i])=>[a,{type:"object",optional:!i.required}])),returns:{type:"object"}}))}:null}catch(n){return console.warn("⚠️ [Validation] Error getting validation schema:",n),null}}function Rt(e,t,o=""){const n=[],r=o||"value";if(t.optional&&e==null)return console.log(` ✓ [Validation] ${r} is optional and ${e===void 0?"undefined":"null"} - skipping validation`),n;if(!t.optional&&e==null){const s=`${r} is required but was ${e===void 0?"undefined":"null"}`;return n.push(s),console.log(` ✗ [Validation] ${s}`),n}switch(console.log(` 🔎 [Validation] Validating ${r} as type "${t.type}"`),t.type){case"string":if(typeof e!="string"){const s=`${r} must be a string, got ${typeof e}`;n.push(s),console.log(` ✗ [Validation] ${s}`)}else console.log(` ✓ [Validation] ${r} is a valid string`);break;case"number":if(typeof e!="number"||isNaN(e)){const s=`${r} must be a number, got ${typeof e}`;n.push(s),console.log(` ✗ [Validation] ${s}`)}else console.log(` ✓ [Validation] ${r} is a valid number: ${e}`);break;case"boolean":if(typeof e!="boolean"){const s=`${r} must be a boolean, got ${typeof e}`;n.push(s),console.log(` ✗ [Validation] ${s}`)}else console.log(` ✓ [Validation] ${r} is a valid boolean: ${e}`);break;case"array":if(Array.isArray(e))console.log(` ✓ [Validation] ${r} is an array with ${e.length} item(s)`),t.items&&(console.log(` 🔍 [Validation] Validating array items of ${r}...`),e.forEach((s,a)=>{const i=Rt(s,t.items,`${o}[${a}]`);n.push(...i)}));else{const s=`${r} must be an array, got ${typeof e}`;n.push(s),console.log(` ✗ [Validation] ${s}`)}break;case"object":if(typeof e!="object"||e===null||Array.isArray(e)){const s=`${r} must be an object, got ${typeof e}`;n.push(s),console.log(` ✗ [Validation] ${s}`)}else t.properties?(console.log(` ✓ [Validation] ${r} is an object, validating properties...`),Object.entries(t.properties).forEach(([s,a])=>{const i=e[s],l=o?`${o}.${s}`:s,c=Rt(i,a,l);n.push(...c)})):console.log(` ✓ [Validation] ${r} is an object (no properties schema to validate)`);break}return n}function Ys(e,t){const o=[];return console.log(`🔍 [Validation] Validating function "${t.name}" parameters:`,e),console.log("📋 [Validation] Using schema:",JSON.stringify(t.params,null,2)),Object.entries(t.params).forEach(([n,r])=>{const s=e[n],a=Rt(s,r,n);o.push(...a)}),o.length===0?console.log(`✅ [Validation] Function "${t.name}" parameters validated successfully`):console.log(`❌ [Validation] Function "${t.name}" parameter validation found ${o.length} error(s):`,o),o}function Xs(e,t){const o=[];return console.log(`🔍 [Validation] Validating component "${t.name}" props:`,e),console.log("📋 [Validation] Using schema:",JSON.stringify(t.props,null,2)),Object.entries(t.props).forEach(([n,r])=>{const s=e[n];console.log(`
177
+ 📌 [Validation] Validating prop "${n}":`),console.log(" Value:",s,`(type: ${typeof s})`),console.log(" Schema:",JSON.stringify(r,null,2));const a=Rt(s,r,n);a.length===0?console.log(` ✅ [Validation] Prop "${n}" passed validation`):console.log(` ❌ [Validation] Prop "${n}" failed validation:`,a),o.push(...a)}),console.log(`
178
+ 📊 [Validation] Component "${t.name}" validation summary:`),o.length===0?console.log(" ✅ All props validated successfully"):console.log(` ❌ Found ${o.length} validation error(s):`,o),o}const Zs=async(e,t,o)=>{const n=await Ks(e,t,o),r=o.llm.proxyUrl??"https://autoui-proxy.onrender.com",s=await fetch(`${r}/chat/errorHandling`,{method:"POST",headers:{"Content-Type":"application/json","X-AUTOUI-APP-ID":o.appId,...o.llm.sharedSecret&&{"X-AUTOUI-SECRET":o.llm.sharedSecret}},body:JSON.stringify({messages:[{role:"user",content:n}],temperature:o.llm.temperature??.2,appId:o.appId})});if(!s.ok){console.error(`[Error Handling] API failed with status ${s.status}. Technical errors:`,e.failedStep.errors);let a="",i="complete";if(e.failedStep.step.type==="component"){const c=e.failedStep.step,u=o.components[c.name];if(u){a=u.prompt;const p=a.toLowerCase();p.includes("show")||p.includes("display")?i="show you":p.includes("load")||p.includes("fetch")?i="load":(p.includes("point")||p.includes("highlight"))&&(i="point to")}}else if(e.failedStep.step.type==="function"){const c=e.failedStep.step,u=o.functions[c.name];if(u){a=u.prompt;const p=a.toLowerCase();p.includes("fetch")||p.includes("load")||p.includes("get")?i="fetch":(p.includes("save")||p.includes("update"))&&(i="save")}}let l=`I couldn't ${i} ${a||"that"} for you. `;return e.failedStep.errorType==="validation"?e.failedStep.errors.some(u=>u.toLowerCase().includes("required")||u.toLowerCase().includes("missing"))?(l+="I need a bit more information to help you with that. ",a.toLowerCase().includes("point")||a.toLowerCase().includes("highlight")?l+="Could you tell me exactly which element you'd like me to point to? For example, you could say 'show me where the filters are' or 'point to the search button'.":a.toLowerCase().includes("show")||a.toLowerCase().includes("display")?l+="Could you be more specific about what you'd like to see? For example, you could say 'show me all tasks' or 'display my completed items'.":l+="Could you provide more details about what you're looking for?"):l+="The information provided doesn't quite match what I need. Could you try rephrasing your request?":l+="Could you try rephrasing your request or being more specific about what you'd like me to do?",{errorMessage:l,shouldRetry:!1}}try{const a=await s.json();if(console.log("Error handling response:",a),typeof a=="string")try{return JSON.parse(a)}catch{return{errorMessage:a,shouldRetry:!1}}return{newInstructionPlan:a.newInstructionPlan??null,errorMessage:a.errorMessage??null,shouldRetry:a.shouldRetry??!1,modifiedContext:a.modifiedContext??null,fallbackSuggestion:a.fallbackSuggestion??null}}catch(a){console.error("[Error Handling] Failed to parse response. Technical error:",a),console.error("[Error Handling] Original errors:",e.failedStep.errors);let i="",l="complete";if(e.failedStep.step.type==="component"){const u=e.failedStep.step,p=o.components[u.name];if(p){i=p.prompt;const m=i.toLowerCase();m.includes("show")||m.includes("display")?l="show you":m.includes("load")||m.includes("fetch")?l="load":(m.includes("point")||m.includes("highlight"))&&(l="point to")}}else if(e.failedStep.step.type==="function"){const u=e.failedStep.step,p=o.functions[u.name];if(p){i=p.prompt;const m=i.toLowerCase();m.includes("fetch")||m.includes("load")||m.includes("get")?l="fetch":(m.includes("save")||m.includes("update"))&&(l="save")}}let c=`I couldn't ${l} ${i||"that"} for you. `;return e.failedStep.errorType==="validation"&&e.failedStep.errors.some(u=>u.includes("required"))?(c+="I need a bit more information to help you with that. ",i.toLowerCase().includes("point")||i.toLowerCase().includes("highlight")?c+="Could you tell me exactly which element you'd like me to point to? For example, you could say 'show me where the filters are' or 'point to the search button'.":i.toLowerCase().includes("show")||i.toLowerCase().includes("display")?c+="Could you be more specific about what you'd like to see? For example, you could say 'show me all tasks' or 'display my completed items'.":c+="Could you provide more details about what you're looking for?"):c+="Could you try rephrasing your request or being more specific about what you'd like me to do?",{errorMessage:c,shouldRetry:!1}}};function Qs(e,t,o){const n=e.errorType,r=e.errors;let s="";if(n==="validation")if(r.some(i=>i.toLowerCase().includes("required")||i.toLowerCase().includes("missing"))){s=`The ${e.step.type==="component"?"component":"function"} needs some information that wasn't provided. `;const i=[];r.forEach(l=>{const c=l.match(/['"]([^'"]+)['"]/);c&&i.push(c[1])}),i.length>0&&(s+=`Specifically, information about: ${i.join(", ")}. `),s+="This information needs to be extracted from the user's request or provided explicitly."}else s=`The ${e.step.type==="component"?"component":"function"} received information that doesn't match what it expects. `,s+="This might be because the user's request wasn't specific enough or the information couldn't be extracted correctly.";else n==="runtime"?(s=`The ${e.step.type==="component"?"component":"function"} encountered a problem while trying to execute. `,s+="This could be because the requested data isn't available, the operation isn't possible right now, or there's a temporary issue."):n==="component_render"?(s="The component couldn't be displayed. ",s+="This might be because some required information is missing or the component needs different information than what was provided."):(s=`Something went wrong while trying to ${t||"complete the action"}. `,s+="The user's request might need to be more specific or rephrased.");return o&&(s+=`
179
+
180
+ The user's request was: "${o}". Consider this context when suggesting how they can rephrase or provide more information.`),s}async function Ks(e,t,o){const{userMessage:n,plan:r,executedSteps:s,failedStep:a}=e,i=new Set,l=new Set;r.steps.forEach(d=>{d.type==="function"?i.add(d.name):d.type==="component"&&l.add(d.name)});const c=[],u=[];i.forEach(d=>{const g=o.functions[d];if(g){const T=g.params?Object.entries(g.params).map(([b,E])=>` ${b}: ${E}`).join(`
181
+ `):" (no params)";c.push(`${d}:
182
+ ${g.prompt}
183
+ Params:
184
+ ${T}`)}}),l.forEach(d=>{const g=o.components[d];if(g){const T=g.props?Object.entries(g.props).map(([b,E])=>` ${b}: ${E}`).join(`
185
+ `):" (no props)";u.push(`${d}:
186
+ ${g.prompt}
187
+ Props:
188
+ ${T}`)}});let p="",m="";if(a.step.type==="component"){const d=a.step;m=d.name;const g=o.components[d.name];g&&(p=g.prompt)}else if(a.step.type==="function"){const d=a.step;m=d.name;const g=o.functions[d.name];g&&(p=g.prompt)}else a.step.type==="text"&&(p="displaying text message",m="text step");const{getRuntimeSchemaAsync:h}=await Promise.resolve().then(()=>mt),$=await h(o),x=[];$&&(i.forEach(d=>{const g=$.functions.find(T=>T.name===d);if(g){const T=Object.entries(g.params).filter(([f,v])=>v.required).map(([f,v])=>`${f} (${v.type})`),b=Object.entries(g.params).filter(([f,v])=>!v.required).map(([f,v])=>`${f} (${v.type})`);let E=`FUNCTION "${d}":`;T.length>0&&(E+=`
189
+ REQUIRED PARAMS: ${T.join(", ")}`),b.length>0&&(E+=`
190
+ OPTIONAL PARAMS: ${b.join(", ")}`),E+=`
191
+ RETURNS: ${g.returns.type}`,x.push(E)}}),l.forEach(d=>{const g=$.components.find(T=>T.name===d);if(g){const T=Object.entries(g.props).filter(([f,v])=>v.required).map(([f,v])=>`${f} (${v.type})`),b=Object.entries(g.props).filter(([f,v])=>!v.required).map(([f,v])=>`${f} (${v.type})`);let E=`COMPONENT "${d}":`;T.length>0&&(E+=`
192
+ REQUIRED PROPS: ${T.join(", ")}`),b.length>0&&(E+=`
193
+ OPTIONAL PROPS: ${b.join(", ")}`),x.push(E)}}));const w=s.map((d,g)=>{let T=` ${g+1}. ${d.type}`;if(d.type==="function"){const b=d;T+=`: ${b.name}`,b.params&&Object.keys(b.params).length>0&&(T+=` (params: ${JSON.stringify(b.params)})`)}else if(d.type==="component"){const b=d;T+=`: ${b.name}`,b.props&&Object.keys(b.props).length>0&&(T+=` (props: ${JSON.stringify(b.props)})`)}else if(d.type==="text"){const b=d;T+=`: "${b.text.substring(0,50)}${b.text.length>50?"...":""}"`}return T}).join(`
194
+ `),y=Qs(a,p,n);return`You are an error handling assistant for an AutoUI application. A step in the instruction plan has failed.
195
+
196
+ USER'S ORIGINAL REQUEST: "${n}"
54
197
 
55
- Data:
56
- ${JSON.stringify(e,null,2)}
57
- Please provide response the same way as data structurized so that the data would fit for the next step to be executed properly. Note that the response which you give will most probably be passed as the params to the next step in the InstructionPlan. Here is the whole instruction plan for context: ${JSON.stringify(o,null,2)}.
58
- Current step name is: ${r}. Next step will use the data you provide as input parameters, so make sure to provide data in the correct format. The data about the next step is: ${o.steps[i]}.
198
+ WHAT THE USER WAS TRYING TO DO:
199
+ The user wanted to: ${p||"perform an action"}
200
+ Failed step: ${m}
201
+
202
+ WHAT ACTUALLY HAPPENED:
203
+ ${y}
204
+
205
+ ORIGINAL PLAN:
206
+ ${JSON.stringify(r,null,2)}
207
+
208
+ SUCCESSFULLY EXECUTED STEPS (${s.length}):
209
+ ${w||" (none)"}
210
+
211
+ FAILED STEP DETAILS:
212
+ Type: ${a.step.type}
213
+ Name: ${m}
214
+ Description: ${p}
215
+ Step Details:
216
+ ${JSON.stringify(a.step,null,2)}
217
+
218
+ ERROR TYPE: ${a.errorType}
219
+ SPECIFIC ERROR (for context only - DO NOT mention technical details to the user):
220
+ ${a.errors.map(d=>` - ${d}`).join(`
221
+ `)}
222
+
223
+ CURRENT CONTEXT:
224
+ ${JSON.stringify(t,null,2)}
225
+
226
+ ${a.props?`ATTEMPTED PROPS/PARAMS:
227
+ ${JSON.stringify(a.props,null,2)}
228
+ `:""}
229
+
230
+ AVAILABLE FUNCTIONS (only those in the plan):
231
+ ${c.length>0?c.join(`
232
+
233
+ `):" (none)"}
234
+
235
+ AVAILABLE COMPONENTS (only those in the plan):
236
+ ${u.length>0?u.join(`
237
+
238
+ `):" (none)"}
239
+
240
+ TYPE SCHEMAS (only for functions/components in the plan):
241
+ ${x.length>0?x.join(`
242
+
243
+ `):" (none)"}
244
+
245
+ YOUR TASK:
246
+ Analyze what went wrong and provide a helpful response to the user.
247
+
248
+ 1. If the error can be fixed by modifying the plan, return a newInstructionPlan that:
249
+ - Keeps all successfully executed steps (they should not be repeated)
250
+ - Modifies or replaces the failed step with corrected information
251
+ - Continues with the remaining steps if applicable
252
+ - When providing a newInstructionPlan, ALSO provide a fallbackSuggestion message that will be shown if the retry also fails
253
+
254
+ 2. If the error cannot be fixed by retrying, return an errorMessage and set shouldRetry to false.
255
+
256
+ CRITICAL REQUIREMENTS for errorMessage and fallbackSuggestion:
257
+ - MUST be completely non-technical - never mention "validation", "props", "parameters", "schema", "type", "undefined", or any technical terms
258
+ - MUST specifically describe what you were trying to do for the user in plain language (e.g., "I couldn't show you the data", "I couldn't point to that element", "I couldn't load the information")
259
+ - MUST explain what went wrong in simple, user-friendly terms based on the error analysis above
260
+ - MUST provide specific, actionable suggestions that relate directly to what the user asked for
261
+ - MUST use the user's original request context to make suggestions relevant
262
+ - The suggestions should help the user understand what information they need to provide or how to rephrase their request
263
+ - fallbackSuggestion should be a smart, human-readable message explaining what the user should probably change if the retry also fails
264
+
265
+ EXAMPLES OF GOOD ERROR MESSAGES (generic patterns):
266
+ - User asked to display data but required information is missing:
267
+ Message: "I couldn't show you that information because I don't have access to the data right now. Could you ask me to load it first? For example, you could say 'show me all items' or 'load the data'."
268
+
269
+ - User asked to point to something but target is unclear:
270
+ Message: "I couldn't point to that for you because I need to know exactly which element you're referring to. Could you be more specific? For example, you could say 'show me where the filters are' or 'point to the button'."
271
+
272
+ - User asked to load filtered data but request is unclear:
273
+ Message: "I couldn't load that for you. Could you try rephrasing your request? For example, you could say 'show me items matching X' or 'find items with Y property'."
274
+
275
+ - User asked to save/create but details are missing:
276
+ Message: "I couldn't save that because I need more details. What would you like to name it? You could say something like 'save an item called X' or 'create an item for Y'."
277
+
278
+ BAD EXAMPLES (DO NOT DO THIS):
279
+ - "Validation failed: required prop 'tasks' is missing" (too technical)
280
+ - "I couldn't complete that action" (too vague)
281
+ - "An error occurred" (not helpful)
282
+ - "The component requires a 'target' parameter" (too technical)
283
+
284
+ 3. Optionally, you can modify the context if needed by providing modifiedContext.
285
+
286
+ Response format (JSON):
287
+ {
288
+ "newInstructionPlan": { ... } | null,
289
+ "errorMessage": "string" | null,
290
+ "shouldRetry": boolean,
291
+ "modifiedContext": { ... } | null,
292
+ "fallbackSuggestion": "string" | null
293
+ }
59
294
 
60
- Provide only the JSON response without any additional text. The config for the next step is ${JSON.stringify(t.functions[o.steps[i].name])}`},bs=async(e,t,n,o,r)=>{const s=await fetch(`${t.llm.proxyUrl}/chat/extra-analysis`,{method:"POST",headers:{"Content-Type":"application/json","X-AUTOUI-APP-ID":t.appId,...t.llm.sharedSecret&&{"X-AUTOUI-SECRET":t.llm.sharedSecret}},body:JSON.stringify({messages:[{role:"user",content:Ts(e,t,n,o,r)}],temperature:t.llm.temperature})});if(!s.ok||!s.body)throw new Error(`AutoUI proxy error: ${s.status}`);return go(s.body)};async function ys(e,t,n,o,r,s){const i={};for(const l of e.steps)await Is(l,i,t,n,o,r,s,e);return i}async function Is(e,t,n,o,r,s,i,l){const a=u=>!!u&&typeof u=="object"&&!Array.isArray(u);if(e.type==="function"){const u=n.functions[e.name];if(!u)throw new Error(`Unknown function: ${e.name}`);const g=u.callFunc,p=e,S=Array.isArray(p.args),R=!!p.params&&typeof p.params=="object";let E;if(S){let v=p.args;if(v.length===1&&a(v[0])&&Array.isArray(u.params)&&u.params.length>0){const f=v[0];v=u.params.map(h=>f[h])}try{E=await g(...v)}catch{E=await g(v)}}else R?E=await g(p.params):E=await g();if(u.canShareDataWithLLM&&e.hasToShareDataWithLLM){const v=await bs(E,n,i,l,e.name);e.assign&&(t[e.assign]=v)}else e.assign&&(t[e.assign]=E);return}if(e.type==="component"){const u=Ft(e.props??{},t,n),g=o(e.name,u);r(g),s(p=>u?.children?[...p,{id:`${Date.now()}-a`,role:"assistant",kind:"ui",ui:{t:"fragment",children:u.children}}]:[...p,{id:`${Date.now()}-a`,role:"assistant",kind:"ui",ui:{t:"component",name:e.name,props:u}}]);return}if(e.type==="text"){const u=e;s(g=>[...g,{id:`${Date.now()}-a`,role:"assistant",kind:"text",text:u.text}]),r(u.text??"");return}return e}function Rs(e){if(typeof e!="object"||e===null)throw new Error("Plan must be an object.");if(e.type!=="sequence")throw new Error('Plan.type must be "sequence".');if(!Array.isArray(e.steps))throw new Error("Plan.steps must be an array.");const t=new Set(["function","component","text"]);e.steps.forEach((n,o)=>{if(typeof n!="object"||n===null)throw new Error(`Step[${o}] must be an object.`);if(!t.has(n.type))throw new Error(`Step[${o}].type must be one of "function" | "component" | "text".`);if(n.type==="function"){if(typeof n.name!="string"||!n.name)throw new Error(`Step[${o}].name (function) must be a non-empty string.`);if(n.params!==void 0&&typeof n.params!="object")throw new Error(`Step[${o}].params (function) must be an object if provided.`);if(n.assign!==void 0&&typeof n.assign!="string")throw new Error(`Step[${o}].assign (function) must be a string if provided.`)}if(n.type==="component"){if(typeof n.name!="string"||!n.name)throw new Error(`Step[${o}].name (component) must be a non-empty string.`);if(n.props!==void 0&&typeof n.props!="object")throw new Error(`Step[${o}].props (component) must be an object if provided.`)}if(n.type==="text"&&typeof n.text!="string")throw new Error(`Step[${o}].text (text) must be a string.`)})}async function Es(e,t,n,o,r,s,i){return console.log("Running instruction plan:",e,"userMessage: ",s),Rs(e),await ys(e,t,n,o,r,s)}const ks=(e,t,n)=>{let o=[];for(let r of e){if(r.kind=="ui"){const{t:s}=r.ui;let i=s=="component"?t(r.ui.name,r.ui.props):"unsuccessful rerender";i&&n(i),o.push({id:r.id,role:r.role,content:i})}r.kind=="text"&&(n(r.text),o.push({id:r.id,role:r.role,content:r.text}))}return o};function xo(e){const t=x.useRef(null),n=x.useCallback(s=>{t.current=s},[]),o=x.useCallback((s,i)=>{const l=e?.components?.[s];if(!l?.callComponent)return;const a=l.callComponent;return m.jsx(a,{...i})},[e?.components]),r=x.useCallback(s=>{t.current?.(s)},[]);return{setUIRenderer:n,resolveComponent:o,setUI:r}}function js(e,t){const{resolveComponent:n,setUI:o}=xo(t),[r,s]=x.useState(()=>{try{const a=sessionStorage.getItem(e);return a?JSON.parse(a):[]}catch{return[]}}),i=x.useRef(!1);x.useEffect(()=>{i.current=!0},[]),x.useEffect(()=>{try{const a=sessionStorage.getItem(e);s(a?JSON.parse(a):[])}catch{s([])}},[e]);const l=x.useMemo(()=>ks(r,n,o),[r,n,o]);return x.useEffect(()=>{if(!i.current)return;const a=setTimeout(()=>{sessionStorage.setItem(e,JSON.stringify(r))},50);return()=>clearTimeout(a)},[r,e]),{messages:l,serializedMessages:r,setSerializedMessages:s}}function zs({config:e,theme:t,mode:n,setTheme:o,onError:r,onClose:s,storageKey:i="autoui_chat_history",title:l,classNames:a,isOpen:c}){const{messages:u,setSerializedMessages:g}=js(i,e),{processMessage:p}=Ss(e),{resolveComponent:S,setUI:R}=xo(e),[E,v]=x.useState(!1),f=x.useCallback(async d=>{if(!d.trim())return;const y={id:Date.now().toString(),role:"user",kind:"text",text:d,ts:Date.now()};g(k=>[...k,y]);try{v(!0);const k=await p(d);await Es(k,e,S,R,g,d,{validate:!0})}catch(k){g(H=>[...H,{id:`${Date.now()}-e`,role:"assistant",kind:"text",text:"⚠️ Something went wrong.",ts:Date.now()}]),r?.(k)}finally{v(!1)}},[p,e,S,R,g,r]),h=x.useCallback(()=>{g([]),sessionStorage.removeItem(i)},[g,i]),b=x.useCallback(()=>({onSend:f,disabled:E}),[f,E]),P=x.useCallback(()=>({title:"AutoUI Chat",onClose:s}),[s]),z=x.useCallback(()=>({messages:u}),[u]);return x.useMemo(()=>({config:e,isOpen:c,title:l,theme:t,mode:n,classNames:a,messages:u,isLoading:E,setTheme:o,handleSend:f,onClose:s,handleClear:h,getChatInputProps:b,getChatHeaderProps:P,getMessageListProps:z}),[e,c,l,a,u,E,f,s,h,b,P,z])}const Os=()=>{const{title:e,classNames:t,onClose:n,closeIcon:o}=Ye();return m.jsxs("header",{role:"header",className:xe("autoui-chat-header",t?.header),children:[m.jsx("h2",{role:"title",className:xe("autoui-chat-title",t?.title),children:e}),n&&m.jsx("button",{role:"closeButton",className:xe("autoui-chat-closebtn",t?.closeButton),onClick:n,children:o??m.jsx("img",{src:Bn,alt:"Open char",width:20,height:20,style:{filter:"var(--icon-filter-text)"}})})]})},jn="theme-mode",Ps=()=>{const e=()=>window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",t=()=>typeof window>"u"?"auto":localStorage.getItem(jn)||"auto",[n,o]=x.useState(t),[r,s]=x.useState(n==="auto"?e():n),i=x.useCallback(l=>{const a=l==="auto"?e():l;o(l),s(a),localStorage.setItem(jn,l),document.documentElement.dataset.theme=a},[]);return x.useEffect(()=>{i(n)},[n,i]),x.useEffect(()=>{if(n!=="auto")return;const l=window.matchMedia("(prefers-color-scheme: dark)"),a=()=>{const c=l.matches?"dark":"light";s(c),document.documentElement.dataset.theme=c};return l.addEventListener("change",a),()=>l.removeEventListener("change",a)},[n]),{mode:n,theme:r,setTheme:i}},vo=x.memo(({config:e,title:t="AutoUI Chat",isOpen:n=!0,classNames:o,onClose:r,onError:s,closeIcon:i})=>{const{theme:l,mode:a,setTheme:c}=Ps(),u=zs({config:e,title:t,isOpen:n,classNames:o,onClose:r,theme:l,mode:a,setTheme:c,onError:s});return n?m.jsx(Eo,{config:e,value:u,children:m.jsxs("section",{role:"base",className:xe("autoui-chat",o?.base),"aria-label":"Chat",children:[m.jsx(Os,{}),m.jsx(vs,{}),m.jsx($o,{})]})}):null}),Hs=Object.freeze(Object.defineProperty({__proto__:null,Chat:vo},Symbol.toStringTag,{value:"Module"})),wo=x.createContext(void 0),Bs=({config:e,children:t})=>{const[n,o]=x.useState({isOpen:!1}),r=x.useMemo(()=>({value:n,setValue:o,config:e}),[n,o,e]);return m.jsx(wo.Provider,{value:r,children:t})},Ms=()=>{const e=x.useContext(wo);if(!e)throw new Error("useModalChatContext must be used within a ModalChatProvider");return e},As=({onOpenChange:e,isOpen:t,className:n})=>{const o=t??!0,r=o?Bn:Hn;return m.jsx("button",{onClick:e,className:Oe("autoui-chat-open-btn",n),children:m.jsx("img",{src:r,alt:o?"Close chat":"Open chat",width:24,height:24,style:{filter:"var(--icon-filter-text)"}})})},Ls=x.lazy(()=>Promise.resolve().then(()=>Hs).then(e=>({default:e.Chat}))),Ns=x.memo(({config:e,portalContainer:t})=>m.jsx(Bs,{config:e,children:m.jsx(_s,{config:e,portalContainer:t})})),_s=({config:e,portalContainer:t})=>{const{value:n,setValue:o}=Ms(),{isOpen:r}=n,s=()=>o(a=>({...a,isOpen:!1})),i=()=>o(a=>({...a,isOpen:!a.isOpen})),l=t??document.body;return m.jsxs(m.Fragment,{children:[m.jsx(As,{onOpenChange:i,isOpen:r}),r&&zn.createPortal(m.jsx("div",{className:"autoui-chat-portal",children:m.jsx("div",{className:"autoui-chat-wrapper",children:m.jsx(Ls,{config:e,...n,onClose:s})})}),l)]})};exports.Chat=vo;exports.ModalChat=Ns;
295
+ Important:
296
+ - If you provide a newInstructionPlan, set shouldRetry to true AND provide a fallbackSuggestion
297
+ - If you provide only an errorMessage, set shouldRetry to false
298
+ - The errorMessage and fallbackSuggestion MUST be user-friendly, helpful, and guide the user forward
299
+ - ALWAYS mention the specific action that failed in plain language
300
+ - ALWAYS include suggestions or questions in error messages - never just state what went wrong
301
+ - NEVER use technical terms - translate everything to user-friendly language
302
+ - Do not include steps that were already successfully executed in the newInstructionPlan`}async function kt(e,t,o,n,r,s,a,i,l=0,c){console.log("Running instruction plan:",e,"userMessage: ",s);const u=i??{};console.log("📦 [ExecutePlanSteps] Context vars:",Object.keys(u),"Values:",u);const p=[],m=2;for(let h=0;h<e.steps.length;h++){const $=e.steps[h];try{const x=await ei($,u,t,o,n,r,s,a,e,h);if(p.push($),x)break}catch(x){const w=x instanceof Error?x.message:String(x);console.error(`❌ [Step Execution] Step ${h+1} failed:`,w);const y=t.runtime?.errorHandling?.retryOnFail??!1,d=t.runtime?.errorHandling?.showToUser??!0;if(y&&l<m){let g="validation";w.includes("failed to render")?g="component_render":w.includes("validation failed")?g="validation":g="runtime";const T={step:$,stepIndex:h,errorType:g,errors:[w],context:{...u}};$.type==="component"&&"props"in $&&(T.props=$.props);let b=null;try{if(b=await Zs({userMessage:s,prevMessagesForContext:a,plan:e,executedSteps:p,failedStep:T},u,t),b){const E=b;if(E.shouldRetry&&E.newInstructionPlan){console.log(`🔄 [Error Recovery] Retrying with modified plan (attempt ${l+1}/${m})`),E.modifiedContext&&Object.assign(u,E.modifiedContext);try{return await kt(E.newInstructionPlan,t,o,n,r,s,a,u,l+1,E.fallbackSuggestion)}catch(f){if(E.fallbackSuggestion&&d)return console.log("⚠️ [Error Recovery] Retry failed, using fallback suggestion"),r(v=>[...v,{id:`${Date.now()}-error-fallback`,role:"assistant",kind:"text",text:E.fallbackSuggestion}]),n(E.fallbackSuggestion),u;throw f}}else if(E.errorMessage&&d)return r(f=>[...f,{id:`${Date.now()}-error`,role:"assistant",kind:"text",text:E.errorMessage}]),n(E.errorMessage),u}}catch(E){console.error("Error handling API failed:",E)}if(b&&b.errorMessage&&d)return r(E=>[...E,{id:`${Date.now()}-error`,role:"assistant",kind:"text",text:b.errorMessage}]),n(b.errorMessage),u}if(d){const g=c||"I couldn't complete that action. Could you try rephrasing your request or providing more details?";r(T=>[...T,{id:`${Date.now()}-error`,role:"assistant",kind:"text",text:g}]),n(g)}return u}}return u}async function ei(e,t,o,n,r,s,a,i,l,c){if(e.type==="function"){const p=o.functions[e.name];if(!p)throw new Error(`Unknown function: ${e.name}`);const m=e;let h={};m.params&&typeof m.params=="object"&&!Array.isArray(m.params)?h=m.params:Array.isArray(m.args)&&m.args.length===1&&typeof m.args[0]=="object"&&(h=m.args[0]),h=Et(h,t,o),console.log("🔧 [ResolveProps] Function params after resolution:",h),e.params=h;const{getRuntimeSchemaAsync:$,validateFunctionParamsRuntime:x}=await Promise.resolve().then(()=>mt),w=await $(o);if(w){console.log(`🔎 [Runtime Validation] Validating function "${e.name}" params...`);const g=x(e.name,h,w);g.length>0&&console.warn(`⚠️ [Runtime Validation] Function ${e.name} parameter validation errors:`,g)}else{console.log(`🔎 [Validation] Checking for validation schema for function: "${e.name}"`);const g=await No(o,e.name);if(g){const T=g.functions.find(b=>b.name===e.name);if(T){console.log(`✅ [Validation] Found schema for function "${e.name}", validating parameters...`);const b=Ys(h,T);b.length>0&&console.warn(`⚠️ [Validation] Function ${e.name} parameter validation errors:`,b)}}}let y=await zs(p,e);if(p.canShareDataWithLLM&&e.hasToShareDataWithLLM){console.log(`🔍 [Extra Analysis] Function "${e.name}" returned data, starting LLM analysis...`);const g=e.assign,T=l.steps.indexOf(e),b=l.steps[T+1],E=await Us(o,y,g,e,T,b,a,i,t,l,n,r,s);return console.log("✅ [Extra Analysis] Analysis complete, result:",E),E}else return e.assign&&(t[e.assign]=y,console.log(`📦 [Context] Stored function output in context key: "${e.assign}"`)),p.canShareDataWithLLM?e.hasToShareDataWithLLM||console.log("ℹ️ [Extra Analysis] Skipped - step has hasToShareDataWithLLM=false"):console.log(`ℹ️ [Extra Analysis] Skipped - function "${e.name}" has canShareDataWithLLM=false`),!1}if(e.type==="component"){console.log("🔧 [ResolveProps] Before resolution - step.props:",e.props,"ctx:",t);let p=Et(e.props??{},t,o);console.log("🔧 [ResolveProps] After resolution - props:",p);const{getRuntimeSchemaAsync:m,validateComponentPropsRuntime:h,parseJsonStringsInProps:$}=await Promise.resolve().then(()=>mt),x=await m(o);if(x){console.log(`🔎 [Runtime Validation] Validating component "${e.name}" props...`);const w=$(p,e.name,x);p=w.props,w.warnings.length>0&&w.warnings.forEach(g=>console.warn(`⚠️ [Parse Props] ${g}`)),w.errors.length>0&&(console.error(`
303
+ ❌ [Parse Props] Found ${w.errors.length} error(s) while parsing props for component "${e.name}":`),w.errors.forEach((g,T)=>{console.error(`
304
+ Error ${T+1}: ${g.message}`),console.error(` Prop: "${g.propName}"`),console.error(` Expected Type: ${g.expectedType}`),console.error(` Received Value: ${typeof g.receivedValue=="string"&&g.receivedValue.length>100?`"${g.receivedValue.substring(0,100)}..." (${g.receivedValue.length} chars)`:JSON.stringify(g.receivedValue)}`),g.suggestion&&console.error(` 💡 Suggestion: ${g.suggestion}`)}));const y=h(e.name,p,x),d=[...w.errors.map(g=>g.message),...y];if(d.length>0&&(console.error(`
305
+ ❌ [Component Props] Component "${e.name}" has ${d.length} total error(s):`),d.forEach((T,b)=>{console.error(` ${b+1}. ${T}`)}),w.errors.some(T=>T.errorType==="type_mismatch"||T.errorType==="parsing_failed")||y.length>0)){console.error(`[Validation] Component "${e.name}" validation failed with errors:`,d);const T=`Component "${e.name}" validation failed: ${d.join("; ")}`;throw new Error(T)}}else{console.log(`🔎 [Validation] Checking for validation schema for component: "${e.name}"`);const w=await No(o,void 0,e.name);if(w){const y=w.components.find(d=>d.name===e.name);if(y){console.log(`✅ [Validation] Found schema for component "${e.name}", validating props...`);const d=Xs(p,y);d.length>0&&console.warn(`⚠️ [Validation] Component ${e.name} prop validation errors:`,d)}}}try{const w=n(e.name,p);r(w),Vs(s,p,e)}catch(w){const y=`Component "${e.name}" failed to render: ${w instanceof Error?w.message:String(w)}`;throw console.error("[Component Render] Technical error:",y),new Error(y)}return!1}if(e.type==="text"){const p=e;return s(m=>[...m,{id:`${Date.now()}-a`,role:"assistant",kind:"text",text:p.text}]),r(p.text??""),!1}return e}function ti(e){if(typeof e!="object"||e===null)throw new Error("Plan must be an object.");if(e.type!=="sequence")throw new Error('Plan.type must be "sequence".');if(!Array.isArray(e.steps))throw new Error("Plan.steps must be an array.");const t=new Set(["function","component","text"]);e.steps.forEach((o,n)=>{if(typeof o!="object"||o===null)throw new Error(`Step[${n}] must be an object.`);if(!t.has(o.type))throw new Error(`Step[${n}].type must be one of "function" | "component" | "text".`);if(o.type==="function"){if(typeof o.name!="string"||!o.name)throw new Error(`Step[${n}].name (function) must be a non-empty string.`);if(o.params!==void 0&&typeof o.params!="object")throw new Error(`Step[${n}].params (function) must be an object if provided.`);if(o.assign!==void 0&&typeof o.assign!="string")throw new Error(`Step[${n}].assign (function) must be a string if provided.`)}if(o.type==="component"){if(typeof o.name!="string"||!o.name)throw new Error(`Step[${n}].name (component) must be a non-empty string.`);if(o.props!==void 0&&typeof o.props!="object")throw new Error(`Step[${n}].props (component) must be an object if provided.`)}if(o.type==="text"&&typeof o.text!="string")throw new Error(`Step[${n}].text (text) must be a string.`)})}async function oi(e,t,o,n,r,s,a,i){return ti(e),await kt(e,t,o,n,r,s,a)}const ni=(e,t,o)=>{let n=[];for(let r of e){if(r.kind=="ui"){const{t:s}=r.ui;let a=s=="component"?t(r.ui.name,r.ui.props):"unsuccessful rerender";a&&o(a),n.push({id:r.id,role:r.role,content:a})}r.kind=="text"&&(o(r.text),n.push({id:r.id,role:r.role,content:r.text}))}return n};function On(e){const t=C.useRef(null),o=C.useCallback(s=>{t.current=s},[]),n=C.useCallback((s,a)=>{const i=e?.components?.[s];if(!i?.callComponent)return;const l=i.callComponent,c={...i.defaults,...a};return S.jsx(l,{...c})},[e?.components]),r=C.useCallback(s=>{t.current?.(s)},[]);return{setUIRenderer:o,resolveComponent:n,setUI:r}}function ri(e,t){const{resolveComponent:o,setUI:n}=On(t),[r,s]=C.useState(()=>{try{const l=sessionStorage.getItem(e);return l?JSON.parse(l):[]}catch{return[]}}),a=C.useRef(!1);C.useEffect(()=>{a.current=!0},[]),C.useEffect(()=>{try{const l=sessionStorage.getItem(e);s(l?JSON.parse(l):[])}catch{s([])}},[e]);const i=C.useMemo(()=>ni(r,o,n),[r,o,n]);return C.useEffect(()=>{if(!a.current)return;const l=setTimeout(()=>{sessionStorage.setItem(e,JSON.stringify(r))},50);return()=>clearTimeout(l)},[r,e]),{messages:i,serializedMessages:r,setSerializedMessages:s}}const si=e=>{if(!e?.length)return"";const t=e.map((s,a)=>({m:s,index:a})),o=t.filter(({m:s})=>s.role==="user").slice(-8),n=t.filter(({m:s})=>s.role==="assistant").slice(-7);return[...o,...n].sort((s,a)=>s.index-a.index).map(({m:s},a)=>{const i=s.role==="user"?"from user":"from ai assistant";if(s.kind==="text")return`${a}. ${i} text: ${s.text}`;const l=s.ui;if(!l)return`${a}. ${i} ui`;if(l.t==="component"){const c=l.props?Object.keys(l.props).join(","):"",u=l.children?.length??0;return`${a}. ${i} ui: component ${l.name}`+(c?` props:${c}`:"")+(u?` children:${u}`:"")}return l.t==="fragment"?`${a}. ${i} ui: fragment children:${l.children?.length??0}`:`${a}. ${i} ui: text`}).join(`
306
+ `)};function ii({config:e,theme:t,mode:o,setTheme:n,onError:r,onClose:s,storageKey:a="autoui_chat_history",title:i,classNames:l,isOpen:c}){const{messages:u,serializedMessages:p,setSerializedMessages:m}=ri(a,e),{processMessage:h}=Ms(e),{resolveComponent:$,setUI:x}=On(e),[w,y]=C.useState(!1),d=C.useCallback(async v=>{if(!v.trim())return;const A={id:Date.now().toString(),role:"user",kind:"text",text:v,ts:Date.now()};m(j=>[...j,A]);try{y(!0);let j=p?si(p):"";const N=await h(v,j);await oi(N,e,$,x,m,v,j,{validate:!0})}catch(j){console.error("[Chat] Error during plan execution:",j);const N="I encountered an issue while processing your request. Could you try rephrasing it?";m(z=>[...z,{id:`${Date.now()}-e`,role:"assistant",kind:"text",text:`⚠️ ${N}`,ts:Date.now()}]),r?.(j)}finally{y(!1)}},[h,e,$,x,m,r]),g=C.useCallback(()=>{m([]),sessionStorage.removeItem(a)},[m,a]),T=C.useCallback(()=>({onSend:d,disabled:w}),[d,w]),b=C.useCallback(()=>({title:"AutoUI Chat",onClose:s}),[s]),E=C.useCallback(()=>({messages:u}),[u]);return C.useMemo(()=>({config:e,isOpen:c,title:i,theme:t,mode:o,classNames:l,messages:u,isLoading:w,setTheme:n,handleSend:d,onClose:s,handleClear:g,getChatInputProps:T,getChatHeaderProps:b,getMessageListProps:E}),[e,c,i,l,u,w,d,s,g,T,b,E])}const ai=()=>{const{title:e,classNames:t,onClose:o,closeIcon:n}=Ge();return S.jsxs("header",{role:"header",className:ye("autoui-chat-header",t?.header),children:[S.jsx("h2",{role:"title",className:ye("autoui-chat-title",t?.title),children:e}),o&&S.jsx("button",{role:"closeButton",className:ye("autoui-chat-closebtn",t?.closeButton),onClick:o,children:n??S.jsx("img",{src:Do,alt:"Open char",width:20,height:20,style:{filter:"var(--icon-filter-text)"}})})]})},zo="theme-mode",li=()=>{const e=()=>window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",t=()=>typeof window>"u"?"auto":localStorage.getItem(zo)||"auto",[o,n]=C.useState(t),[r,s]=C.useState(o==="auto"?e():o),a=C.useCallback(i=>{const l=i==="auto"?e():i;n(i),s(l),localStorage.setItem(zo,i),document.documentElement.dataset.theme=l},[]);return C.useEffect(()=>{a(o)},[o,a]),C.useEffect(()=>{if(o!=="auto")return;const i=window.matchMedia("(prefers-color-scheme: dark)"),l=()=>{const c=i.matches?"dark":"light";s(c),document.documentElement.dataset.theme=c};return i.addEventListener("change",l),()=>i.removeEventListener("change",l)},[o]),{mode:o,theme:r,setTheme:a}},An=C.memo(({config:e,title:t="AutoUI Chat",isOpen:o=!0,classNames:n,onClose:r,onError:s,closeIcon:a})=>{const{theme:i,mode:l,setTheme:c}=li(),u=ii({config:e,title:t,isOpen:o,classNames:n,onClose:r,theme:i,mode:l,setTheme:c,onError:s});return o?S.jsx(Hn,{config:e,value:u,children:S.jsxs("section",{role:"base",className:ye("autoui-chat",n?.base),"aria-label":"Chat",children:[S.jsx(ai,{}),S.jsx(As,{}),S.jsx(nr,{})]})}):null}),ci=Object.freeze(Object.defineProperty({__proto__:null,Chat:An},Symbol.toStringTag,{value:"Module"})),jn=C.createContext(void 0),ui=({config:e,children:t})=>{const[o,n]=C.useState({isOpen:!1}),r=C.useMemo(()=>({value:o,setValue:n,config:e}),[o,n,e]);return S.jsx(jn.Provider,{value:r,children:t})},di=()=>{const e=C.useContext(jn);if(!e)throw new Error("useModalChatContext must be used within a ModalChatProvider");return e},pi=({onOpenChange:e,isOpen:t,className:o})=>{const n=t??!0,r=n?Do:Fo;return S.jsx("button",{onClick:e,className:Ae("autoui-chat-open-btn",o),children:S.jsx("img",{src:r,alt:n?"Close chat":"Open chat",width:24,height:24,style:{filter:"var(--icon-filter-text)"}})})},fi=C.lazy(()=>Promise.resolve().then(()=>ci).then(e=>({default:e.Chat}))),mi=C.memo(({config:e,portalContainer:t})=>S.jsx(ui,{config:e,children:S.jsx(hi,{config:e,portalContainer:t})})),hi=({config:e,portalContainer:t})=>{const{value:o,setValue:n}=di(),{isOpen:r}=o,s=()=>n(l=>({...l,isOpen:!1})),a=()=>n(l=>({...l,isOpen:!l.isOpen})),i=t??document.body;return S.jsxs(S.Fragment,{children:[S.jsx(pi,{onOpenChange:a,isOpen:r}),r&&_o.createPortal(S.jsx("div",{className:"autoui-chat-portal",children:S.jsx("div",{className:"autoui-chat-wrapper",children:S.jsx(fi,{config:e,...o,onClose:s})})}),i)]})};function gi(e){}function yi(e){}exports.Chat=An;exports.ModalChat=mi;exports.autouiRegisterComponentPropsSchema=gi;exports.autouiRegisterFunctionParamsSchema=yi;