@gram-ai/elements 1.20.0 → 1.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Chat/index.d.ts +5 -1
- package/dist/components/Chat/stories/Variants.stories.d.ts +2 -1
- package/dist/components/assistant-ui/assistant-modal.d.ts +5 -1
- package/dist/components/assistant-ui/assistant-sidecar.d.ts +5 -1
- package/dist/components/assistant-ui/thread-list.d.ts +5 -1
- package/dist/components/assistant-ui/thread.d.ts +5 -1
- package/dist/elements.cjs +1 -1
- package/dist/elements.cjs.map +1 -1
- package/dist/elements.css +1 -1
- package/dist/elements.js +81 -77
- package/dist/elements.js.map +1 -1
- package/dist/index-B52U8PL6.cjs.map +1 -1
- package/dist/index-DaF9fGY-.js.map +1 -1
- package/package.json +4 -2
- package/src/components/Chat/index.tsx +8 -4
- package/src/components/Chat/stories/Variants.stories.tsx +28 -1
- package/src/components/assistant-ui/assistant-modal.tsx +7 -2
- package/src/components/assistant-ui/assistant-sidecar.tsx +7 -2
- package/src/components/assistant-ui/thread-list.tsx +8 -3
- package/src/components/assistant-ui/thread.tsx +7 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Chat } from '..';
|
|
2
|
-
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
2
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
|
|
3
3
|
declare const meta: Meta<typeof Chat>;
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryFn<typeof Chat>;
|
|
6
6
|
export declare const Default: Story;
|
|
7
7
|
export declare const Standalone: Story;
|
|
8
|
+
export declare const StandaloneWithHistory: StoryObj<typeof Chat>;
|
|
8
9
|
export declare const Sidecar: Story;
|
|
9
10
|
export declare const ModalWithHistory: Story;
|
|
10
11
|
export declare const SidecarWithHistory: Story;
|
package/dist/elements.cjs
CHANGED
|
@@ -157,5 +157,5 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
157
157
|
`},r),o}function uK(e,t){return e&&"run"in e?async function(n,i){const r=Fy(n,{file:i,...t});await e.run(r,i)}:function(n,i){return Fy(n,{file:i,...e||t})}}function By(e){if(e)throw e}var $c,Zy;function cK(){if(Zy)return $c;Zy=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,r=function(l){return typeof Array.isArray=="function"?Array.isArray(l):t.call(l)==="[object Array]"},o=function(l){if(!l||t.call(l)!=="[object Object]")return!1;var c=e.call(l,"constructor"),d=l.constructor&&l.constructor.prototype&&e.call(l.constructor.prototype,"isPrototypeOf");if(l.constructor&&!c&&!d)return!1;var f;for(f in l);return typeof f>"u"||e.call(l,f)},a=function(l,c){n&&c.name==="__proto__"?n(l,c.name,{enumerable:!0,configurable:!0,value:c.newValue,writable:!0}):l[c.name]=c.newValue},s=function(l,c){if(c==="__proto__")if(e.call(l,c)){if(i)return i(l,c).value}else return;return l[c]};return $c=function u(){var l,c,d,f,p,g,m=arguments[0],y=1,v=arguments.length,w=!1;for(typeof m=="boolean"&&(w=m,m=arguments[1]||{},y=2),(m==null||typeof m!="object"&&typeof m!="function")&&(m={});y<v;++y)if(l=arguments[y],l!=null)for(c in l)d=s(m,c),f=s(l,c),m!==f&&(w&&f&&(o(f)||(p=r(f)))?(p?(p=!1,g=d&&r(d)?d:[]):g=d&&o(d)?d:{},a(m,{name:c,newValue:u(w,g,f)})):typeof f<"u"&&a(m,{name:c,newValue:f}));return m},$c}var dK=cK();const Cc=ga(dK);function Ud(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function pK(){const e=[],t={run:n,use:i};return t;function n(...r){let o=-1;const a=r.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);s(null,...r);function s(u,...l){const c=e[++o];let d=-1;if(u){a(u);return}for(;++d<r.length;)(l[d]===null||l[d]===void 0)&&(l[d]=r[d]);r=l,c?fK(c,s)(...l):a(null,...l)}}function i(r){if(typeof r!="function")throw new TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),t}}function fK(e,t){let n;return i;function i(...a){const s=e.length>a.length;let u;s&&a.push(r);try{u=e.apply(this,a)}catch(l){const c=l;if(s&&n)throw c;return r(c)}s||(u&&u.then&&typeof u.then=="function"?u.then(o,r):u instanceof Error?r(u):o(u))}function r(a,...s){n||(n=!0,t(a,...s))}function o(a){r(null,a)}}const bn={basename:hK,dirname:mK,extname:gK,join:vK,sep:"/"};function hK(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');$a(e);let n=0,i=-1,r=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;r--;)if(e.codePointAt(r)===47){if(o){n=r+1;break}}else i<0&&(o=!0,i=r+1);return i<0?"":e.slice(n,i)}if(t===e)return"";let a=-1,s=t.length-1;for(;r--;)if(e.codePointAt(r)===47){if(o){n=r+1;break}}else a<0&&(o=!0,a=r+1),s>-1&&(e.codePointAt(r)===t.codePointAt(s--)?s<0&&(i=r):(s=-1,i=a));return n===i?i=a:i<0&&(i=e.length),e.slice(n,i)}function mK(e){if($a(e),e.length===0)return".";let t=-1,n=e.length,i;for(;--n;)if(e.codePointAt(n)===47){if(i){t=n;break}}else i||(i=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function gK(e){$a(e);let t=e.length,n=-1,i=0,r=-1,o=0,a;for(;t--;){const s=e.codePointAt(t);if(s===47){if(a){i=t+1;break}continue}n<0&&(a=!0,n=t+1),s===46?r<0?r=t:o!==1&&(o=1):r>-1&&(o=-1)}return r<0||n<0||o===0||o===1&&r===n-1&&r===i+1?"":e.slice(r,n)}function vK(...e){let t=-1,n;for(;++t<e.length;)$a(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":yK(n)}function yK(e){$a(e);const t=e.codePointAt(0)===47;let n=bK(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function bK(e,t){let n="",i=0,r=-1,o=0,a=-1,s,u;for(;++a<=e.length;){if(a<e.length)s=e.codePointAt(a);else{if(s===47)break;s=47}if(s===47){if(!(r===a-1||o===1))if(r!==a-1&&o===2){if(n.length<2||i!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(u=n.lastIndexOf("/"),u!==n.length-1){u<0?(n="",i=0):(n=n.slice(0,u),i=n.length-1-n.lastIndexOf("/")),r=a,o=0;continue}}else if(n.length>0){n="",i=0,r=a,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",i=2)}else n.length>0?n+="/"+e.slice(r+1,a):n=e.slice(r+1,a),i=a-r-1;r=a,o=0}else s===46&&o>-1?o++:o=-1}return n}function $a(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const _K={cwd:wK};function wK(){return"/"}function Ld(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function xK(e){if(typeof e=="string")e=new URL(e);else if(!Ld(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return SK(e)}function SK(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const i=t.codePointAt(n+2);if(i===70||i===102){const r=new TypeError("File URL path must not include encoded / characters");throw r.code="ERR_INVALID_FILE_URL_PATH",r}}return decodeURIComponent(t)}const Ac=["history","path","basename","stem","extname","dirname"];class aP{constructor(t){let n;t?Ld(t)?n={path:t}:typeof t=="string"||IK(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":_K.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<Ac.length;){const o=Ac[i];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let r;for(r in n)Ac.includes(r)||(this[r]=n[r])}get basename(){return typeof this.path=="string"?bn.basename(this.path):void 0}set basename(t){Rc(t,"basename"),Pc(t,"basename"),this.path=bn.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?bn.dirname(this.path):void 0}set dirname(t){qy(this.basename,"dirname"),this.path=bn.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?bn.extname(this.path):void 0}set extname(t){if(Pc(t,"extname"),qy(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=bn.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ld(t)&&(t=xK(t)),Rc(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?bn.basename(this.path,this.extname):void 0}set stem(t){Rc(t,"stem"),Pc(t,"stem"),this.path=bn.join(this.dirname||"",t+(this.extname||""))}fail(t,n,i){const r=this.message(t,n,i);throw r.fatal=!0,r}info(t,n,i){const r=this.message(t,n,i);return r.fatal=void 0,r}message(t,n,i){const r=new lt(t,n,i);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Pc(e,t){if(e&&e.includes(bn.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+bn.sep+"`")}function Rc(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function qy(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function IK(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const kK=(function(e){const i=this.constructor.prototype,r=i[e],o=function(){return r.apply(o,arguments)};return Object.setPrototypeOf(o,i),o}),EK={}.hasOwnProperty;class nm extends kK{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=pK()}copy(){const t=new nm;let n=-1;for(;++n<this.attachers.length;){const i=this.attachers[n];t.use(...i)}return t.data(Cc(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(jc("data",this.frozen),this.namespace[t]=n,this):EK.call(this.namespace,t)&&this.namespace[t]||void 0:t?(jc("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const r=n.call(t,...i);typeof r=="function"&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=is(t),i=this.parser||this.Parser;return Oc("parse",i),i(String(n),n)}process(t,n){const i=this;return this.freeze(),Oc("process",this.parser||this.Parser),Nc("process",this.compiler||this.Compiler),n?r(void 0,n):new Promise(r);function r(o,a){const s=is(t),u=i.parse(s);i.run(u,s,function(c,d,f){if(c||!d||!f)return l(c);const p=d,g=i.stringify(p,f);CK(g)?f.value=g:f.result=g,l(c,f)});function l(c,d){c||!d?a(c):o?o(d):n(void 0,d)}}}processSync(t){let n=!1,i;return this.freeze(),Oc("processSync",this.parser||this.Parser),Nc("processSync",this.compiler||this.Compiler),this.process(t,r),Hy("processSync","process",n),i;function r(o,a){n=!0,By(o),i=a}}run(t,n,i){Vy(t),this.freeze();const r=this.transformers;return!i&&typeof n=="function"&&(i=n,n=void 0),i?o(void 0,i):new Promise(o);function o(a,s){const u=is(n);r.run(t,u,l);function l(c,d,f){const p=d||t;c?s(c):a?a(p):i(void 0,p,f)}}}runSync(t,n){let i=!1,r;return this.run(t,n,o),Hy("runSync","run",i),r;function o(a,s){By(a),r=s,i=!0}}stringify(t,n){this.freeze();const i=is(n),r=this.compiler||this.Compiler;return Nc("stringify",r),Vy(t),r(t,i)}use(t,...n){const i=this.attachers,r=this.namespace;if(jc("use",this.frozen),t!=null)if(typeof t=="function")u(t,n);else if(typeof t=="object")Array.isArray(t)?s(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(l){if(typeof l=="function")u(l,[]);else if(typeof l=="object")if(Array.isArray(l)){const[c,...d]=l;u(c,d)}else a(l);else throw new TypeError("Expected usable value, not `"+l+"`")}function a(l){if(!("plugins"in l)&&!("settings"in l))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");s(l.plugins),l.settings&&(r.settings=Cc(!0,r.settings,l.settings))}function s(l){let c=-1;if(l!=null)if(Array.isArray(l))for(;++c<l.length;){const d=l[c];o(d)}else throw new TypeError("Expected a list of plugins, not `"+l+"`")}function u(l,c){let d=-1,f=-1;for(;++d<i.length;)if(i[d][0]===l){f=d;break}if(f===-1)i.push([l,...c]);else if(c.length>0){let[p,...g]=c;const m=i[f][1];Ud(m)&&Ud(p)&&(p=Cc(!0,m,p)),i[f]=[l,p,...g]}}}}const TK=new nm().freeze();function Oc(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Nc(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function jc(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Vy(e){if(!Ud(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Hy(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function is(e){return $K(e)?e:new aP(e)}function $K(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function CK(e){return typeof e=="string"||AK(e)}function AK(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const PK="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Jy=[],Wy={allowDangerousHtml:!0},RK=/^(https?|ircs?|mailto|xmpp)$/i,OK=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function NK(e){const t=jK(e),n=MK(e);return DK(t.runSync(t.parse(n),n),e)}function jK(e){const t=e.rehypePlugins||Jy,n=e.remarkPlugins||Jy,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Wy}:Wy;return TK().use(h7).use(n).use(uK,i).use(t)}function MK(e){const t=e.children||"",n=new aP;return typeof t=="string"&&(n.value=t),n}function DK(e,t){const n=t.allowedElements,i=t.allowElement,r=t.components,o=t.disallowedElements,a=t.skipHtml,s=t.unwrapDisallowed,u=t.urlTransform||zK;for(const c of OK)Object.hasOwn(t,c.from)&&(""+c.from+(c.to?"use `"+c.to+"` instead":"remove it")+PK+c.id,void 0);return oP(e,l),JJ(e,{Fragment:h.Fragment,components:r,ignoreInvalidStyle:!0,jsx:h.jsx,jsxs:h.jsxs,passKeys:!0,passNode:!0});function l(c,d,f){if(c.type==="raw"&&f&&typeof d=="number")return a?f.children.splice(d,1):f.children[d]={type:"text",value:c.value},d;if(c.type==="element"){let p;for(p in kc)if(Object.hasOwn(kc,p)&&Object.hasOwn(c.properties,p)){const g=c.properties[p],m=kc[p];(m===null||m.includes(c.tagName))&&(c.properties[p]=u(String(g||""),p,c))}}if(c.type==="element"){let p=n?!n.includes(c.tagName):o?o.includes(c.tagName):!1;if(!p&&i&&typeof d=="number"&&(p=!i(c,d,f)),p&&f&&typeof d=="number")return s&&c.children?f.children.splice(d,1,...c.children):f.children.splice(d,1),d}}}function zK(e){const t=e.indexOf(":"),n=e.indexOf("?"),i=e.indexOf("#"),r=e.indexOf("/");return t===-1||r!==-1&&t>r||n!==-1&&t>n||i!==-1&&t>i||RK.test(e.slice(0,t))?e:""}const UK=(e,t)=>typeof e=="string"?e===t:JSON.stringify(e)===JSON.stringify(t),LK=(e,t)=>{if(!e||!t)return!1;const n=i=>{const{position:r,data:o,...a}=i||{};return a};return JSON.stringify(n(e.properties))===JSON.stringify(n(t.properties))&&UK(e.children,t.children)},rm=(e,t)=>LK(e.node,t.node),FK=(e={})=>Object.fromEntries(Object.entries(e??{}).map(([t,n])=>{if(!n)return[t,n];const i=n,r=({node:o,...a})=>h.jsx(i,{...a});return[t,k.memo(r,rm)]})),im=k.createContext(null),sP=()=>k.useContext(im)!==null,BK=({children:e,...t})=>h.jsx(im.Provider,{value:t,children:e}),ZK=k.memo(BK,rm),qK=({node:e,...t})=>h.jsx("pre",{...t}),VK=({node:e,...t})=>h.jsx("code",{...t}),om=({node:e,components:{Pre:t,Code:n},code:i})=>h.jsx(t,{children:h.jsx(n,{node:e,children:i})}),HK=()=>null,JK=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:i,CodeHeader:r},language:o,code:a})=>{const s=k.useMemo(()=>({Pre:t,Code:n}),[t,n]),u=o?i:om;return h.jsxs(h.Fragment,{children:[h.jsx(r,{node:e,language:o,code:a}),h.jsx(u,{node:e,components:s,language:o??"unknown",code:a})]})};var Mc={exports:{}};var Gy;function WK(){return Gy||(Gy=1,(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var o="",a=0;a<arguments.length;a++){var s=arguments[a];s&&(o=r(o,i(s)))}return o}function i(o){if(typeof o=="string"||typeof o=="number")return o;if(typeof o!="object")return"";if(Array.isArray(o))return n.apply(null,o);if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]"))return o.toString();var a="";for(var s in o)t.call(o,s)&&o[s]&&(a=r(a,s));return a}function r(o,a){return a?o?o+" "+a:o+a:o}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(Mc)),Mc.exports}var GK=WK();const lP=ga(GK),Ky=({className:e,...t})=>({className:n,...i})=>({className:lP(e,n),...t,...i}),KK=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:i,CodeHeader:r},componentsByLanguage:o={},children:a,...s})=>{const u=k.useContext(im),l=Ky(u),c=Rt(y=>h.jsx(t,{...l(y)})),d=Ky(s),f=Rt(y=>h.jsx(n,{...d(y)})),p=/language-(\w+)/.exec(s.className||"")?.[1]??"";if(typeof a!="string")return h.jsx(om,{node:e,components:{Pre:c,Code:f},code:a});const g=o[p]?.SyntaxHighlighter??i,m=o[p]?.CodeHeader??r;return h.jsx(JK,{node:e,components:{Pre:c,Code:f,SyntaxHighlighter:g,CodeHeader:m},language:p||"unknown",code:a})},YK=({node:e,components:t,componentsByLanguage:n,...i})=>sP()?h.jsx(KK,{node:e,components:t,componentsByLanguage:n,...i}):h.jsx(t.Code,{...i}),XK=k.memo(YK,(e,t)=>e.components===t.components&&e.componentsByLanguage===t.componentsByLanguage&&rm(e,t)),{useSmooth:QK,useSmoothStatus:e8,withSmoothContextProvider:t8}=OE,n8=({components:e,componentsByLanguage:t,smooth:n=!0,preprocess:i,...r})=>{const o=LT(),a=k.useMemo(()=>i?{...o,text:i(o.text)}:o,[o,i]),{text:s}=QK(a,n),{pre:u=qK,code:l=VK,SyntaxHighlighter:c=om,CodeHeader:d=HK}=e??{},f=k.useMemo(()=>({Pre:u,Code:l,SyntaxHighlighter:c,CodeHeader:d}),[u,l,c,d]),p=Rt(m=>h.jsx(XK,{components:f,componentsByLanguage:t,...m})),g=k.useMemo(()=>{const{pre:m,code:y,SyntaxHighlighter:v,CodeHeader:w,...x}=e??{};return{...x,pre:ZK,code:p}},[p,e]);return h.jsx(NK,{components:g,...r,children:s})},uP=k.forwardRef(({className:e,containerProps:t,containerComponent:n="div",...i},r)=>{const o=e8();return h.jsx(n,{"data-status":o.type,...t,className:lP(e,t?.className),ref:r,children:h.jsx(n8,{...i})})});uP.displayName="MarkdownTextPrimitive";const r8=t8(uP);function i8(e){return k.useMemo(()=>e.reduce((t,n)=>(t?.[n.language]&&!n.overrideExisting||(t={...t,[n.language]:{CodeHeader:n.Header??(()=>null),SyntaxHighlighter:n.Component??void 0}}),t),{}),[e])}const o8=()=>{const{plugins:e}=R.useElements(),t=i8(e);return h.jsx(r8,{remarkPlugins:[$P],className:"aui-md",components:l8,componentsByLanguage:t})},cP=k.memo(o8),a8=({language:e,code:t})=>{const i=ee(({message:s})=>s).status?.type==="complete",{isCopied:r,copyToClipboard:o}=s8(),a=()=>{!t||r||o(t)};return i?h.jsxs("div",{className:"aui-code-header-root bg-muted-foreground/15 text-foreground dark:bg-muted-foreground/20 mt-4 flex items-center justify-between gap-4 rounded-t-lg px-4 py-2 text-sm font-semibold",children:[h.jsx("span",{className:"aui-code-header-language lowercase [&>span]:text-xs",children:e}),h.jsxs(Wt,{tooltip:"Copy",onClick:a,children:[!r&&h.jsx(gh,{}),r&&h.jsx(ir,{})]})]}):null},s8=({copiedDuration:e=3e3}={})=>{const[t,n]=k.useState(!1);return{isCopied:t,copyToClipboard:r=>{r&&navigator.clipboard.writeText(r).then(()=>{n(!0),setTimeout(()=>n(!1),e)})}}},l8=FK({h1:({className:e,...t})=>h.jsx("h1",{className:R.cn("aui-md-h1 mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0",e),...t}),h2:({className:e,...t})=>h.jsx("h2",{className:R.cn("aui-md-h2 mt-8 mb-4 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h3:({className:e,...t})=>h.jsx("h3",{className:R.cn("aui-md-h3 mt-6 mb-4 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h4:({className:e,...t})=>h.jsx("h4",{className:R.cn("aui-md-h4 mt-6 mb-4 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h5:({className:e,...t})=>h.jsx("h5",{className:R.cn("aui-md-h5 my-4 text-lg font-semibold first:mt-0 last:mb-0",e),...t}),h6:({className:e,...t})=>h.jsx("h6",{className:R.cn("aui-md-h6 my-4 font-semibold first:mt-0 last:mb-0",e),...t}),p:({className:e,...t})=>h.jsx("p",{className:R.cn("aui-md-p mt-5 mb-5 leading-7 first:mt-0 last:mb-0",e),...t}),a:({className:e,...t})=>h.jsx("a",{className:R.cn("aui-md-a text-primary font-medium underline underline-offset-4",e),...t}),blockquote:({className:e,...t})=>h.jsx("blockquote",{className:R.cn("aui-md-blockquote border-l-2 pl-6 italic",e),...t}),ul:({className:e,...t})=>h.jsx("ul",{className:R.cn("aui-md-ul my-5 ml-6 list-disc [&>li]:mt-2",e),...t}),ol:({className:e,...t})=>h.jsx("ol",{className:R.cn("aui-md-ol my-5 ml-6 list-decimal [&>li]:mt-2",e),...t}),hr:({className:e,...t})=>h.jsx("hr",{className:R.cn("aui-md-hr my-5 border-b",e),...t}),table:({className:e,...t})=>h.jsx("table",{className:R.cn("aui-md-table my-5 w-full border-separate border-spacing-0 overflow-y-auto",e),...t}),th:({className:e,...t})=>h.jsx("th",{className:R.cn("aui-md-th bg-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [[align=center]]:text-center [[align=right]]:text-right",e),...t}),td:({className:e,...t})=>h.jsx("td",{className:R.cn("aui-md-td border-b border-l px-4 py-2 text-left last:border-r [[align=center]]:text-center [[align=right]]:text-right",e),...t}),tr:({className:e,...t})=>h.jsx("tr",{className:R.cn("aui-md-tr m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg",e),...t}),sup:({className:e,...t})=>h.jsx("sup",{className:R.cn("aui-md-sup [&>a]:text-xs [&>a]:no-underline",e),...t}),pre:({className:e,...t})=>h.jsx("pre",{className:R.cn("aui-md-pre text-foreground bg-muted overflow-x-auto rounded-t-none! rounded-b-lg border border-t-0 p-4",e),...t}),code:function({className:t,...n}){const i=sP();return h.jsx("code",{className:R.cn(!i&&"aui-md-inline-code bg-muted rounded border font-semibold",t),...n})},CodeHeader:a8});var Pu="Collapsible",[u8]=ya(Pu),[c8,am]=u8(Pu),dP=_.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:i,defaultOpen:r,disabled:o,onOpenChange:a,...s}=e,[u,l]=gu({prop:i,defaultProp:r??!1,onChange:a,caller:Pu});return h.jsx(c8,{scope:n,disabled:o,contentId:ri(),open:u,onOpenToggle:_.useCallback(()=>l(c=>!c),[l]),children:h.jsx(Xe.div,{"data-state":lm(u),"data-disabled":o?"":void 0,...s,ref:t})})});dP.displayName=Pu;var pP="CollapsibleTrigger",fP=_.forwardRef((e,t)=>{const{__scopeCollapsible:n,...i}=e,r=am(pP,n);return h.jsx(Xe.button,{type:"button","aria-controls":r.contentId,"aria-expanded":r.open||!1,"data-state":lm(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...i,ref:t,onClick:Pe(e.onClick,r.onOpenToggle)})});fP.displayName=pP;var sm="CollapsibleContent",hP=_.forwardRef((e,t)=>{const{forceMount:n,...i}=e,r=am(sm,e.__scopeCollapsible);return h.jsx(Hn,{present:n||r.open,children:({present:o})=>h.jsx(d8,{...i,ref:t,present:o})})});hP.displayName=sm;var d8=_.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:i,children:r,...o}=e,a=am(sm,n),[s,u]=_.useState(i),l=_.useRef(null),c=Qe(t,l),d=_.useRef(0),f=d.current,p=_.useRef(0),g=p.current,m=a.open||s,y=_.useRef(m),v=_.useRef(void 0);return _.useEffect(()=>{const w=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(w)},[]),Jt(()=>{const w=l.current;if(w){v.current=v.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const x=w.getBoundingClientRect();d.current=x.height,p.current=x.width,y.current||(w.style.transitionDuration=v.current.transitionDuration,w.style.animationName=v.current.animationName),u(i)}},[a.open,i]),h.jsx(Xe.div,{"data-state":lm(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!m,...o,ref:c,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:m&&r})});function lm(e){return e?"open":"closed"}var p8=dP;function f8({...e}){return h.jsx(p8,{"data-slot":"collapsible",...e})}function h8({...e}){return h.jsx(fP,{"data-slot":"collapsible-trigger",...e})}function m8({...e}){return h.jsx(hP,{"data-slot":"collapsible-content",...e})}const Yy=200,mP=({className:e,children:t})=>{const n=k.useRef(null),[i,r]=k.useState(!1),o=N6(n,Yy),a=k.useCallback(s=>{s||o(),r(s)},[o]);return h.jsx(f8,{ref:n,open:i,onOpenChange:a,className:R.cn("aui-reasoning-root mb-4 w-full",e),style:{"--animation-duration":`${Yy}ms`},children:t})};mP.displayName="ReasoningRoot";const g8=({className:e})=>h.jsx("div",{className:R.cn("aui-reasoning-fade pointer-events-none absolute inset-x-0 bottom-0 z-10 h-16","bg-[linear-gradient(to_top,var(--color-background),transparent)]","fade-in-0 animate-in","group-data-[state=open]/collapsible-content:animate-out","group-data-[state=open]/collapsible-content:fade-out-0","group-data-[state=open]/collapsible-content:delay-[calc(var(--animation-duration)*0.75)]","group-data-[state=open]/collapsible-content:fill-mode-forwards","duration-(--animation-duration)","group-data-[state=open]/collapsible-content:duration-(--animation-duration)",e)}),v8=({active:e,className:t})=>h.jsxs(h8,{className:R.cn("aui-reasoning-trigger group/trigger text-muted-foreground hover:text-foreground -mb-2 flex max-w-[75%] items-center gap-2 py-2 text-sm transition-colors",t,e&&"shimmer"),children:[h.jsx(H6,{className:"aui-reasoning-trigger-icon size-4 shrink-0"}),h.jsxs("span",{className:"aui-reasoning-trigger-label-wrapper relative inline-block leading-none",children:[h.jsx("span",{children:"Reasoning"}),e?h.jsx("span",{"aria-hidden":!0,className:"aui-reasoning-trigger-shimmer shimmer pointer-events-none absolute inset-0 motion-reduce:animate-none",children:"Reasoning"}):null]}),h.jsx(Vs,{className:R.cn("aui-reasoning-trigger-chevron mt-0.5 size-4 shrink-0","transition-transform duration-(--animation-duration) ease-out","group-data-[state=closed]/trigger:-rotate-90","group-data-[state=open]/trigger:rotate-0")})]}),gP=({className:e,children:t,"aria-busy":n})=>h.jsxs(m8,{className:R.cn("aui-reasoning-content text-muted-foreground relative overflow-hidden text-sm outline-none","group/collapsible-content ease-out","data-[state=closed]:animate-collapsible-up","data-[state=open]:animate-collapsible-down","data-[state=closed]:fill-mode-forwards","data-[state=closed]:pointer-events-none","data-[state=open]:duration-(--animation-duration)","data-[state=closed]:duration-(--animation-duration)",e),"aria-busy":n,children:[t,h.jsx(g8,{})]});gP.displayName="ReasoningContent";const vP=({className:e,children:t})=>h.jsx("div",{className:R.cn("aui-reasoning-text relative z-0 space-y-4 pt-4 pl-6 leading-relaxed","transform-gpu transition-[transform,opacity]","group-data-[state=open]/collapsible-content:animate-in","group-data-[state=closed]/collapsible-content:animate-out","group-data-[state=open]/collapsible-content:fade-in-0","group-data-[state=closed]/collapsible-content:fade-out-0","group-data-[state=open]/collapsible-content:slide-in-from-top-4","group-data-[state=closed]/collapsible-content:slide-out-to-top-4","group-data-[state=open]/collapsible-content:duration-(--animation-duration)","group-data-[state=closed]/collapsible-content:duration-(--animation-duration)","[&_p]:-mb-2",e),children:t});vP.displayName="ReasoningText";const y8=()=>h.jsx(cP,{}),b8=({children:e,startIndex:t,endIndex:n})=>{const i=ee(({message:r})=>{if(r.status?.type!=="running")return!1;const o=r.parts.length-1;return o<0||r.parts[o]?.type!=="reasoning"?!1:o>=t&&o<=n});return h.jsxs(mP,{children:[h.jsx(v8,{active:i}),h.jsx(gP,{"aria-busy":i,children:h.jsx(vP,{children:e})})]})},yP=k.memo(y8);yP.displayName="Reasoning";const bP=k.memo(b8);bP.displayName="ReasoningGroup";function _P({...e}){return h.jsx(E2,{"data-slot":"popover",...e})}function wP({...e}){return h.jsx(T2,{"data-slot":"popover-trigger",...e})}function xP({className:e,align:t="center",sideOffset:n=4,...i}){return h.jsx($2,{children:h.jsx(C2,{"data-slot":"popover-content",align:t,sideOffset:n,className:R.cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-20 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...i})})}const _8=SA("flex size-5 items-center justify-center rounded-full",{variants:{status:{pending:"border border-dashed border-muted-foreground/50",running:"text-primary",complete:"text-green-600 dark:text-green-500",error:"text-destructive",approval:"text-amber-500"}},defaultVariants:{status:"pending"}});function w8(e){switch(e){case"text/markdown":return"markdown";case"text/html":return"html";case"text/css":return"css";case"application/json":return"json";case"text/javascript":return"javascript";case"text/typescript":return"typescript";case"text/python":return"python";default:return}}function x8(e,t){if(t==="json")try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}return e}function S8(e){return typeof e=="object"&&e!==null&&"content"in e&&Array.isArray(e.content)}function SP({status:e}){return h.jsxs("div",{className:R.cn(_8({status:e})),children:[e==="pending"&&null,e==="running"&&h.jsx(Hs,{className:"size-4 animate-spin"}),e==="complete"&&h.jsx(ir,{className:"size-4"}),e==="error"&&h.jsx(xa,{className:"size-4"}),e==="approval"&&h.jsx(Hs,{className:"text-muted-foreground size-4 animate-spin"})]})}function I8({content:e}){const[t,n]=k.useState(!1),i=async r=>{r.stopPropagation(),await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)};return h.jsx("button",{onClick:i,className:"text-muted-foreground hover:bg-accent hover:text-foreground rounded p-1 transition-colors","aria-label":"Copy to clipboard",children:t?h.jsx(ir,{className:"size-4"}):h.jsx(gh,{className:"size-4"})})}function IP({text:e,language:t,className:n}){const[i,r]=k.useState(null);return k.useEffect(()=>{t&&CP.codeToHtml(e,{lang:t,theme:"github-dark-default",rootStyle:"background-color: transparent;",transformers:[{pre(o){o.properties.class="w-full py-3 px-4 max-h-[300px] overflow-y-auto whitespace-pre-wrap text-left text-sm"}}]}).then(r)},[e,t]),i?h.jsx("div",{className:R.cn("w-full bg-slate-800/90",n),dangerouslySetInnerHTML:{__html:i}}):h.jsx("pre",{className:R.cn("w-full bg-slate-800/90 px-4 py-3 text-sm whitespace-pre-wrap text-slate-100",n),children:e})}function k8({data:e}){const t=`data:image/png;base64,${e}`;return h.jsx("div",{className:"flex items-center justify-center rounded-lg p-5",style:{backgroundImage:`linear-gradient(45deg, #ccc 25%, transparent 25%),
|
|
158
158
|
linear-gradient(135deg, #ccc 25%, transparent 25%),
|
|
159
159
|
linear-gradient(45deg, transparent 75%, #ccc 75%),
|
|
160
|
-
linear-gradient(135deg, transparent 75%, #ccc 75%)`,backgroundSize:"25px 25px",backgroundPosition:"0 0, 12.5px 0, 12.5px -12.5px, 0px 12.5px"},children:h.jsx("img",{src:t,className:"max-h-[300px] max-w-full object-contain"})})}function E8({content:e}){return h.jsx("div",{className:"w-full",children:e.content.map((t,n)=>{switch(t.type){case"text":{const i=w8(t._meta?.["getgram.ai/mime-type"]??"text/plain"),r=x8(t.text,i);return h.jsx(IP,{text:r,language:i},n)}case"image":return h.jsx(k8,{data:t.data},n);default:return h.jsx("pre",{className:"px-4 py-3 text-sm whitespace-pre-wrap",children:JSON.stringify(t,null,2)},n)}})})}function Xy({title:e,content:t,defaultExpanded:n=!1,highlightSyntax:i=!0,language:r="json"}){const[o,a]=k.useState(n),s=S8(t),u=s?JSON.stringify(t,null,2):typeof t=="string"?t:JSON.stringify(t,null,2);return h.jsxs("div",{"data-slot":"tool-ui-section",className:"border-border border-t",children:[h.jsxs("button",{onClick:()=>a(!o),className:"hover:bg-accent/50 flex w-full cursor-pointer items-center justify-between px-4 py-2.5 text-left transition-colors",children:[h.jsx("span",{className:"text-muted-foreground text-sm",children:e}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(I8,{content:u}),h.jsx(h0,{className:R.cn("text-muted-foreground size-4 transition-transform duration-200",o&&"rotate-90")})]})]}),o&&h.jsx("div",{className:"border-border border-t",children:s?h.jsx(E8,{content:t}):i?h.jsx(IP,{text:u,language:r}):h.jsx("pre",{className:"text-foreground overflow-x-auto px-4 py-3 text-sm whitespace-pre-wrap",children:u})})]})}function T8({name:e,icon:t,provider:n,status:i="complete",request:r,result:o,defaultExpanded:a=!1,className:s,onApproveOnce:u,onApproveForSession:l,onDeny:c}){const d=i==="approval"&&u!==void 0&&c!==void 0,[f,p]=k.useState(a),g=r!==void 0||o!==void 0,[m,y]=k.useState("one-time"),[v,w]=k.useState(!1);k.useEffect(()=>{!d&&f&&!a&&p(!1)},[d]);const x=()=>{m==="for-session"&&l?l():u&&u()};return h.jsxs("div",{"data-slot":"tool-ui",className:R.cn("border-border bg-card overflow-hidden rounded-lg border",s),children:[n&&h.jsxs("div",{"data-slot":"tool-ui-provider",className:R.cn("border-border flex items-center gap-2 border-b px-4 py-2.5"),children:[t?h.jsx("span",{className:"flex size-5 items-center justify-center",children:t}):h.jsx("span",{className:"bg-muted flex size-5 items-center justify-center rounded text-xs font-medium",children:n.charAt(0).toUpperCase()}),h.jsx("span",{className:"text-sm font-medium",children:n})]}),h.jsxs("button",{onClick:()=>g&&p(!f),disabled:!g,className:R.cn("flex w-full items-center gap-2 px-4 py-3 text-left",g&&"hover:bg-accent/50 cursor-pointer transition-colors"),children:[h.jsx(SP,{status:i}),h.jsx("span",{className:R.cn("flex-1 text-sm",!n&&d&&"shimmer"),children:e}),g&&h.jsx(Vs,{className:R.cn("text-muted-foreground size-4 transition-transform duration-200",f&&"rotate-180")})]}),f&&g&&h.jsxs("div",{"data-slot":"tool-ui-content",children:[r!==void 0&&h.jsx(Xy,{title:"Arguments",content:r,highlightSyntax:!0,language:"json"}),o!==void 0&&h.jsx(Xy,{title:"Output",content:o,highlightSyntax:!0,language:"json"})]}),d&&h.jsxs("div",{"data-slot":"tool-ui-approval-actions",className:"border-border flex items-center justify-end gap-2 border-t px-4 py-3",children:[h.jsx("div",{children:h.jsx("span",{className:"text-muted-foreground text-sm",children:"This tool requires approval"})}),h.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[h.jsxs(Vt,{variant:"outline",size:"sm",onClick:c,className:"text-destructive hover:bg-destructive/10",children:[h.jsx(xa,{className:"mr-1 size-3"}),"Deny"]}),h.jsxs("div",{className:"flex items-center",children:[h.jsxs(Vt,{variant:"default",size:"sm",onClick:x,className:"flex cursor-pointer justify-between gap-1 rounded-r-none bg-emerald-600 hover:bg-emerald-700",children:[h.jsx(ir,{className:"mr-1 size-3"}),h.jsx("span",{className:"min-w-[110px]",children:m==="one-time"?"Approve this time":"Approve always"})]}),h.jsxs(_P,{open:v,onOpenChange:w,children:[h.jsx(wP,{asChild:!0,children:h.jsx(Vt,{variant:"default",size:"sm",className:"cursor-pointer rounded-l-none border-l border-emerald-700 bg-emerald-600 px-2 hover:bg-emerald-700",children:h.jsx(Vs,{className:"size-3"})})}),h.jsxs(xP,{align:"end",className:"w-64 p-1",sideOffset:4,children:[h.jsxs("button",{onClick:()=>{y("one-time"),w(!1)},className:"hover:bg-accent relative flex w-full items-start gap-2 rounded-sm px-2 py-2 text-left",children:[h.jsx(ir,{className:R.cn("relative top-1 mt-0.5 size-3 shrink-0",m!=="one-time"&&"invisible")}),h.jsxs("div",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-sm",children:"Approve only once"}),h.jsx("span",{className:"text-muted-foreground text-xs",children:"You'll be asked again next time"})]})]}),l&&h.jsxs("button",{onClick:()=>{y("for-session"),w(!1)},className:"hover:bg-accent relative flex w-full items-start gap-2 rounded-sm px-2 py-2 text-left",children:[h.jsx(ir,{className:R.cn("relative top-1 mt-0.5 size-3 shrink-0",m!=="for-session"&&"invisible")}),h.jsxs("div",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-sm",children:"Approve always"}),h.jsx("span",{className:"text-muted-foreground text-xs",children:"Trust this tool for the session"})]})]})]})]})]})]})]})]})}function $8({title:e,icon:t,status:n="complete",defaultExpanded:i=!1,children:r,className:o}){const[a,s]=k.useState(i);return h.jsxs("div",{"data-slot":"tool-ui-group",className:R.cn("border-border bg-card overflow-hidden rounded-lg border",o),children:[h.jsxs("button",{onClick:()=>s(!a),className:"hover:bg-accent/50 flex w-full items-center gap-2 px-4 py-3 text-left transition-colors",children:[t||h.jsx(SP,{status:n==="running"?"running":"complete"}),h.jsx("span",{className:R.cn("flex-1 text-sm font-medium",n==="running"&&"shimmer"),children:e}),h.jsx(Vs,{className:R.cn("text-muted-foreground size-4 transition-transform duration-200",a&&"rotate-180")})]}),a&&h.jsx("div",{"data-slot":"tool-ui-group-content",className:"border-border border-t",children:r})]})}const C8=({toolName:e,toolCallId:t,status:n,result:i,args:r})=>{const{pendingApprovals:o,whitelistTool:a,confirmPendingApproval:s,rejectPendingApproval:u}=Lk(),l=o.get(t),d=ee(({message:w})=>w).parts.filter(w=>w.type==="tool-call"),f=d.findIndex(w=>w.toolName===e),p=()=>{s(t)},g=()=>{a(e),s(t)},m=()=>{u(t)},y=()=>l?"approval":n.type==="incomplete"?"error":n.type==="complete"?i&&typeof i=="object"&&"isError"in i&&i.isError?"error":"complete":"running",v=()=>{if(i!==void 0)return typeof i=="object"&&i!==null&&"content"in i&&Array.isArray(i.content)||typeof i=="string",i};return h.jsx("div",{className:R.cn("aui-tool-fallback-root flex w-full flex-col",f!==-1&&f!==d.length-1&&"border-b"),children:h.jsx(T8,{name:e,status:y(),request:r,result:v(),onApproveOnce:l?p:void 0,onApproveForSession:l?g:void 0,onDeny:l?m:void 0,className:"rounded-none border-0"})})},um=()=>{const{config:e}=R.useElements(),t=e.theme??{};return k.useMemo(()=>{const{colorScheme:n="light"}=t;return{className:n==="dark"||n==="system"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":void 0}},[t])},or=[.23,1,.32,1];function A8(e){return e.replace(/[-_]/g," ").split(/(?=[A-Z])/).join(" ").split(/\s+/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const P8=({children:e})=>{const t=ee(({message:s})=>s).parts,n=t.filter(s=>s.type==="tool-call"),i=n.some(s=>s.status?.type==="running"),{config:r}=R.useElements(),o=r.tools?.expandToolGroupsByDefault??!1,a=k.useMemo(()=>{const s=t.filter(u=>u.type==="tool-call");return s.length===0?"No tools called":s.length===1?`Calling ${A8(s[0].toolName)}...`:i?`Calling ${s.length} tools...`:`Executed ${s.length} tools`},[t,i]);return r.tools?.components?.[n[0]?.toolName]?e:n.length===1?h.jsx("div",{className:R.cn("my-4 w-full max-w-xl"),children:h.jsx("div",{className:"border-border bg-card overflow-hidden rounded-lg border",children:e})}):h.jsx("div",{className:"my-4 w-full max-w-xl",children:h.jsx($8,{title:a,status:i?"running":"complete",defaultExpanded:o,children:e})})},R8=()=>h.jsxs("div",{className:"m-2 rounded-md border border-amber-500 bg-amber-100 px-4 py-3 text-sm text-amber-800 dark:border-amber-600 dark:bg-amber-900/30 dark:text-amber-200",children:[h.jsx("strong",{children:"Warning:"})," You are using an API key directly in the client. Please"," ",h.jsx("a",{href:"https://github.com/speakeasy-api/gram/tree/main/elements#setting-up-your-backend",target:"_blank",rel:"noopener noreferrer",className:"text-amber-700 underline hover:text-amber-800 dark:text-amber-300 dark:hover:text-amber-200",children:"set up a session endpoint"})," ","before deploying to production."]}),cm=()=>{const e=um(),t=R.useDensity(),{config:n}=R.useElements(),i=n.components??{},r=n.api&&"UNSAFE_apiKey"in n.api;return h.jsx(zn.LazyMotion,{features:zn.domAnimation,children:h.jsx(zn.MotionConfig,{reducedMotion:"user",children:h.jsx(n0,{className:R.cn("aui-root aui-thread-root bg-background @container flex h-full flex-col",e.className),children:h.jsxs(i0,{className:R.cn("aui-thread-viewport relative mx-auto flex w-full flex-1 flex-col overflow-x-auto overflow-y-scroll pb-0!",t("p-lg")),children:[h.jsx(To,{empty:!0,children:i.ThreadWelcome?h.jsx(i.ThreadWelcome,{}):h.jsx(N8,{})}),r&&h.jsx(R8,{}),h.jsx(T6,{components:{UserMessage:i.UserMessage??Z8,EditComposer:i.EditComposer??V8,AssistantMessage:i.AssistantMessage??L8}}),h.jsx(To,{empty:!1,children:h.jsx("div",{className:"aui-thread-viewport-spacer min-h-8 grow"})}),h.jsx(M8,{})]})})})})},O8=()=>h.jsx(C6,{asChild:!0,children:h.jsx(Wt,{tooltip:"Scroll to bottom",variant:"outline",className:"aui-thread-scroll-to-bottom dark:bg-background dark:hover:bg-accent absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible",children:h.jsx(B6,{})})}),N8=()=>{const{config:e}=R.useElements(),t=R.useDensity(),{title:n,subtitle:i}=e.welcome??{},r=e.variant==="standalone";return h.jsxs("div",{className:R.cn("aui-thread-welcome-root my-auto flex w-full grow flex-col",r?"items-center justify-center":"",t("gap-lg")),children:[h.jsx("div",{className:R.cn("aui-thread-welcome-center flex w-full grow flex-col items-center justify-start"),children:h.jsxs("div",{className:R.cn("aui-thread-welcome-message flex flex-col",r?"items-center text-center":"size-full justify-start",t("gap-sm"),!r&&t("py-md")),children:[h.jsx(Mn.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,ease:or},className:R.cn("aui-thread-welcome-message-motion-1 text-foreground font-semibold",t("text-title")),children:n}),h.jsx(Mn.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,delay:.05,ease:or},className:R.cn("aui-thread-welcome-message-motion-2 text-muted-foreground/65",t("text-subtitle")),children:i})]})}),h.jsx(j8,{})]})},j8=()=>{const{config:e}=R.useElements(),t=R.useRadius(),n=R.useDensity(),i=e.welcome?.suggestions??[],r=e.variant==="standalone";return i.length===0?null:h.jsx("div",{className:R.cn("aui-thread-welcome-suggestions w-full",n("gap-md"),n("py-lg"),r?"flex flex-wrap items-center justify-center":i.length===1?"flex":"grid max-w-fit @md:grid-cols-2"),children:i.map((o,a)=>h.jsx(Mn.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.25,delay:.03*a,ease:or},className:R.cn("aui-thread-welcome-suggestion-display",!r&&"nth-[n+3]:hidden @md:nth-[n+3]:block"),children:h.jsx(P6,{prompt:o.action,send:!0,asChild:!0,children:h.jsxs(Vt,{variant:"ghost",className:R.cn("aui-thread-welcome-suggestion dark:hover:bg-accent/60 h-auto w-full border text-left whitespace-break-spaces",n("text-base"),r?`flex-row items-center ${n("gap-sm")} ${n("px-md")} ${n("py-sm")} ${t("full")}`:`w-full flex-1 flex-col flex-wrap items-start justify-start ${n("gap-sm")} ${n("px-lg")} ${n("py-md")} ${t("xl")}`),"aria-label":o.action,children:[h.jsx("span",{className:"aui-thread-welcome-suggestion-text-1 text-foreground text-sm font-medium",children:o.title}),h.jsx("span",{className:"aui-thread-welcome-suggestion-text-2 text-muted-foreground text-sm",children:o.label})]})})},`suggested-action-${o.title}-${a}`))})},M8=()=>{const{config:e}=R.useElements(),t=R.useRadius(),n=R.useDensity(),i=e.composer??{placeholder:"Send a message...",attachments:!0},r=e.components??{};return r.Composer?h.jsx(r.Composer,{}):h.jsxs("div",{className:R.cn("aui-composer-wrapper bg-background sticky bottom-0 flex w-full flex-col overflow-visible",n("gap-md"),n("py-md"),t("xl")),children:[h.jsx(O8,{}),h.jsxs(fh,{className:R.cn("aui-composer-root group/input-group border-input bg-background has-[textarea:focus-visible]:border-ring has-[textarea:focus-visible]:ring-ring/5 dark:bg-background relative flex w-full flex-col border px-1 pt-2 shadow-xs transition-[color,box-shadow] outline-none has-[textarea:focus-visible]:ring-1",t("xl")),children:[i.attachments&&h.jsx(vJ,{}),h.jsx(mh,{placeholder:i.placeholder,className:R.cn("aui-composer-input placeholder:text-muted-foreground mb-1 max-h-32 w-full resize-none bg-transparent px-3.5 pt-1.5 pb-3 outline-none focus-visible:ring-0",n("h-input"),n("text-base")),rows:1,autoFocus:!0,"aria-label":"Message input"}),h.jsx(z8,{})]})]})},D8=()=>{const{model:e,setModel:t}=R.useElements(),[n,i]=k.useState(!1),[r,o]=k.useState(!1),a=k.useRef(null),s=k.useRef(0),u=k.useRef(!1);k.useEffect(()=>{n&&!u.current&&requestAnimationFrame(()=>{const c=a.current;c&&c.scrollHeight>0&&(c.scrollTop=s.current)}),u.current=n},[n]),k.useEffect(()=>{n&&o(!1)},[n]);const l=c=>{s.current=c.currentTarget.scrollTop};return h.jsx(tA,{children:h.jsxs(Mh,{open:r&&!n,onOpenChange:o,children:[h.jsxs(_P,{open:n,onOpenChange:i,children:[h.jsx(Dh,{asChild:!0,children:h.jsx(wP,{asChild:!0,children:h.jsx(Vt,{variant:"ghost",size:"icon","data-state":n?"open":"closed",className:"aui-composer-model-picker data-[state=open]:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 flex w-fit items-center gap-2 rounded-full px-2.5 py-1 text-xs font-semibold","aria-label":"Model Settings",children:h.jsx(yF,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})})}),h.jsx(xP,{side:"top",align:"start",className:"w-min p-0 shadow-none",children:h.jsx("div",{ref:a,className:"max-h-48 overflow-y-auto",onScroll:l,children:jf.map(c=>h.jsxs(Vt,{onClick:()=>{t(c)},variant:"ghost",className:"w-full justify-start gap-2 rounded-none px-2",children:[c===e?h.jsx("div",{children:h.jsx(ir,{className:"size-4 text-emerald-500"})}):h.jsx("div",{className:"size-4",children:" "}),c]},c))})})]}),h.jsx(zh,{side:"bottom",align:"start",children:"Model Settings"})]})})},z8=()=>{const{config:e}=R.useElements(),t=R.useRadius(),n=e.composer??{attachments:!0};return h.jsxs("div",{className:"aui-composer-action-wrapper relative mx-1 mt-2 mb-2 flex items-center justify-between",children:[h.jsxs("div",{className:"aui-composer-action-wrapper-inner flex items-center",children:[n.attachments?h.jsx(yJ,{}):h.jsx("div",{className:"aui-composer-add-attachment-placeholder"}),e.model?.showModelPicker&&!e.languageModel&&h.jsx(D8,{})]}),h.jsx(To,{running:!1,children:h.jsx(GT,{asChild:!0,children:h.jsx(Wt,{tooltip:"Send message",side:"bottom",type:"submit",variant:"default",size:"icon",className:R.cn("aui-composer-send size-[34px] p-1",t("full")),"aria-label":"Send message",children:h.jsx(q6,{className:"aui-composer-send-icon size-5"})})})}),h.jsx(To,{running:!0,children:h.jsx(YT,{asChild:!0,children:h.jsx(Vt,{type:"button",variant:"default",size:"icon",className:R.cn("aui-composer-cancel border-muted-foreground/60 hover:bg-primary/75 dark:border-muted-foreground/90 size-[34px] border",t("full")),"aria-label":"Stop generating",children:h.jsx(_F,{className:"aui-composer-cancel-icon size-3.5 fill-white dark:fill-black"})})})})]})},U8=()=>h.jsx(HT,{children:h.jsx(e0,{className:"aui-message-error-root border-destructive bg-destructive/10 text-destructive dark:bg-destructive/5 mt-2 rounded-md border p-3 text-sm dark:text-red-200",children:h.jsx(t0,{className:"aui-message-error-message line-clamp-2"})})}),L8=()=>{const{config:e}=R.useElements(),t=e.tools??{},n=e.components??{};return h.jsx(dh,{asChild:!0,children:h.jsxs("div",{className:"aui-assistant-message-root animate-in fade-in slide-in-from-bottom-1 relative mx-auto w-full py-4 duration-150 ease-out last:mb-24","data-role":"assistant",children:[h.jsxs("div",{className:"aui-assistant-message-content text-foreground mx-2 leading-7 wrap-break-word",children:[h.jsx(ph,{components:{Text:n.Text??cP,Image:n.Image??F8,tools:{by_name:t.components,Fallback:n.ToolFallback??C8},Reasoning:n.Reasoning??yP,ReasoningGroup:n.ReasoningGroup??bP,ToolGroup:n.ToolGroup??P8}}),h.jsx(U8,{})]}),h.jsxs("div",{className:"aui-assistant-message-footer mt-2 ml-2 flex",children:[h.jsx(kP,{}),h.jsx(B8,{})]})]})})},F8=e=>h.jsx("img",{src:e.image}),B8=()=>h.jsxs(Kf,{hideWhenRunning:!0,autohide:"not-last",autohideFloat:"single-branch",className:"aui-assistant-action-bar-root text-muted-foreground data-floating:bg-background col-start-3 row-start-2 -ml-1 flex gap-1 data-floating:absolute data-floating:rounded-md data-floating:border data-floating:p-1 data-floating:shadow-sm",children:[h.jsx(zE,{asChild:!0,children:h.jsxs(Wt,{tooltip:"Copy",children:[h.jsx(Zs,{copied:!0,children:h.jsx(ir,{})}),h.jsx(Zs,{copied:!1,children:h.jsx(gh,{})})]})}),h.jsx(P4,{asChild:!0,children:h.jsx(Wt,{tooltip:"Refresh",children:h.jsx(gF,{})})})]}),Z8=()=>{const e=R.useRadius();return h.jsx(dh,{asChild:!0,children:h.jsxs("div",{className:"aui-user-message-root animate-in fade-in slide-in-from-bottom-1 mx-auto grid w-full auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-2 px-2 py-4 duration-150 ease-out first:mt-3 last:mb-5 [&:where(>*)]:col-start-2","data-role":"user",children:[h.jsx(gJ,{}),h.jsxs("div",{className:"aui-user-message-content-wrapper relative col-start-2 min-w-0",children:[h.jsx("div",{className:R.cn("aui-user-message-content bg-muted text-foreground px-5 py-2.5 wrap-break-word",e("xl")),children:h.jsx(ph,{})}),h.jsx("div",{className:"aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2",children:h.jsx(q8,{})})]}),h.jsx(kP,{className:"aui-user-branch-picker col-span-full col-start-1 row-start-3 -mr-1 justify-end"})]})})},q8=()=>h.jsx(Kf,{hideWhenRunning:!0,autohide:"not-last",className:"aui-user-action-bar-root flex flex-col items-end",children:h.jsx(O4,{asChild:!0,children:h.jsx(Wt,{tooltip:"Edit",className:"aui-user-action-edit p-4",children:h.jsx(fF,{})})})}),V8=()=>h.jsx("div",{className:"aui-edit-composer-wrapper mx-auto flex w-full flex-col gap-4 px-2 first:mt-4",children:h.jsxs(fh,{className:"aui-edit-composer-root bg-muted ml-auto flex w-full max-w-7/8 flex-col rounded-xl",children:[h.jsx(mh,{className:"aui-edit-composer-input text-foreground flex min-h-[60px] w-full resize-none bg-transparent p-4 outline-none",autoFocus:!0}),h.jsxs("div",{className:"aui-edit-composer-footer mx-3 mb-3 flex items-center justify-center gap-2 self-end",children:[h.jsx(YT,{asChild:!0,children:h.jsx(Vt,{variant:"ghost",size:"sm","aria-label":"Cancel edit",children:"Cancel"})}),h.jsx(GT,{asChild:!0,children:h.jsx(Vt,{size:"sm","aria-label":"Update message",children:"Update"})})]})]})}),kP=({className:e,...t})=>h.jsxs(JT,{hideWhenSingleBranch:!0,className:R.cn("aui-branch-picker-root text-muted-foreground mr-2 -ml-2 inline-flex items-center text-xs",e),...t,children:[h.jsx(j2,{asChild:!0,children:h.jsx(Wt,{tooltip:"Previous",children:h.jsx(K6,{})})}),h.jsxs("span",{className:"aui-branch-picker-state font-medium",children:[h.jsx(DT,{})," / ",h.jsx(MT,{})]}),h.jsx(O2,{asChild:!0,children:h.jsx(Wt,{tooltip:"Next",children:h.jsx(h0,{})})})]});function H8({className:e,...t}){return h.jsx("div",{"data-slot":"skeleton",className:R.cn("bg-accent animate-pulse rounded-md",e),...t})}const dm=()=>{const e=R.useDensity();return h.jsxs(d0,{className:R.cn("aui-root aui-thread-list-root flex flex-col items-stretch",e("gap-sm")),children:[h.jsx("div",{className:R.cn("aui-thread-list-new-section border-b pb-2",e("py-sm"),e("px-sm")),children:h.jsx(J8,{})}),h.jsx("div",{className:R.cn("aui-thread-list-items-section flex flex-col gap-1",e("py-xs"),e("px-sm")),children:h.jsx(W8,{})})]})},J8=()=>{const e=R.useDensity();return h.jsx(l0,{asChild:!0,children:h.jsxs(Vt,{className:R.cn("aui-thread-list-new hover:bg-muted-foreground/10 data-[active=true]:bg-muted-foreground/20! flex w-full cursor-pointer items-center justify-start gap-1 rounded-lg px-2.5 py-2 text-start",e("p-sm"),e("py-xs")),variant:"ghost",children:[h.jsx(m0,{}),"New Thread"]})})},W8=()=>ee(({threads:t})=>t.isLoading)?h.jsx(G8,{}):h.jsx(c0,{components:{ThreadListItem:K8}}),G8=()=>h.jsx(h.Fragment,{children:Array.from({length:5},(e,t)=>h.jsx("div",{role:"status","aria-label":"Loading threads","aria-live":"polite",className:"aui-thread-list-skeleton-wrapper flex items-center gap-2 rounded-md px-3 py-2",children:h.jsx(H8,{className:"aui-thread-list-skeleton h-[22px] grow"})},t))}),K8=()=>{const e=R.useRadius(),t=R.useDensity();return h.jsx(p0,{className:R.cn("aui-thread-list-item group hover:bg-muted focus-visible:bg-muted focus-visible:ring-ring data-[active=true]:bg-muted-foreground/20 flex items-center gap-2 rounded-lg transition-all focus-visible:ring-2 focus-visible:outline-none",e("md")),children:h.jsx(O6,{className:R.cn("aui-thread-list-item-trigger flex grow cursor-pointer items-center text-start",t("px-lg"),t("py-sm")),children:h.jsx(Y8,{})})})},Y8=()=>h.jsx("span",{className:"aui-thread-list-item-title text-sm",children:h.jsx(f0,{fallback:"New Chat"})}),EP=()=>{const{config:e,isExpanded:t,setIsExpanded:n}=R.useElements(),i=e.modal?.defaultExpanded??!1;return{expandable:e.modal?.expandable??!1,isExpanded:t,setIsExpanded:n,defaultExpanded:i}},X8={layout:{duration:.25,ease:or}},Q8=()=>{const{config:e}=R.useElements(),t=um(),n=R.useRadius(),i=R.useDensity(),[r,o]=k.useState(e.modal?.defaultOpen??!1),{expandable:a,isExpanded:s,setIsExpanded:u}=EP(),l=e.modal?.title,c=e.modal?.icon,d=e.history?.enabled&&e.history?.showThreadList!==!1,f=e.modal?.position??"bottom-right",p=eY(f),g=k.useMemo(()=>e.modal?.dimensions?.default??{width:"500px",height:"600px",maxHeight:"95vh"},[e.modal?.dimensions?.default]),m=k.useMemo(()=>e.modal?.dimensions?.expanded??{width:"70vw",height:"90vh"},[e.modal?.dimensions?.expanded]),v=ee(({thread:C})=>C).messages.some(C=>C.status?.type==="running"),w=s?m.width:g.width,x=s?m.height:g.height,b=g.maxHeight;return h.jsx(zn.LazyMotion,{features:zn.domMax,children:h.jsx(zn.MotionConfig,{reducedMotion:"user",transition:X8,children:h.jsx("div",{className:R.cn("aui-root aui-modal-anchor fixed z-10",p,t.className,n("lg"),r&&"shadow-xl"),children:h.jsx(zn.AnimatePresence,{mode:"wait",children:r?h.jsxs(Mn.div,{layout:!0,layoutId:"chat-container",className:R.cn("aui-modal-content bg-popover text-popover-foreground flex flex-col overflow-hidden border [&>.aui-thread-root]:bg-inherit",n("lg")),initial:!1,style:{originX:f.includes("left")?0:1,originY:f.includes("top")?0:1,width:w,height:x,maxHeight:b},children:[h.jsxs(Mn.div,{className:R.cn("aui-modal-header flex shrink-0 items-center justify-between border-b",i("h-header"),i("px-lg")),initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.1,ease:or},children:[h.jsx("div",{className:R.cn("flex min-w-0 items-center"),children:h.jsxs("span",{className:R.cn("text-md flex items-center gap-2 truncate font-medium",v&&"shimmer"),children:[h.jsx("span",{className:"truncate",children:l}),v&&h.jsx(Hs,{className:"text-muted-foreground size-4.5 animate-spin",strokeWidth:1.25})]})}),h.jsxs("div",{className:"flex flex-row items-center justify-end gap-1",children:[a?h.jsx("button",{type:"button",onClick:()=>u(C=>!C),className:R.cn("text-muted-foreground hover:text-foreground hover:bg-accent flex h-8 cursor-pointer items-center rounded-md px-2 text-xs transition-colors"),"aria-pressed":s,"aria-label":s?"Collapse assistant":"Expand assistant",children:s?h.jsx(sF,{strokeWidth:2,className:"size-3.5 rotate-90"}):h.jsx(rF,{strokeWidth:2,className:"size-3.5 rotate-90"})}):null,h.jsx("button",{onClick:()=>{o(!1),u(!1)},className:"text-muted-foreground hover:text-foreground hover:bg-accent -mr-1 flex size-8 cursor-pointer items-center justify-center rounded-md transition-colors","aria-label":`Close ${l}`,children:h.jsx(xa,{className:"size-4.5"})})]})]}),h.jsxs(Mn.div,{className:"aui-modal-body flex flex-1 overflow-hidden",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.05,ease:or},children:[d&&h.jsx("div",{className:"aui-modal-thread-list w-56 shrink-0 overflow-y-auto border-r",children:h.jsx(dm,{})}),h.jsx("div",{className:"aui-modal-thread w-full flex-1 overflow-hidden",children:h.jsx(cm,{})})]})]},"chat"):h.jsx(Mn.button,{layout:!0,layoutId:"chat-container",onClick:()=>o(!0),className:R.cn("aui-modal-button bg-primary text-primary-foreground flex size-12 cursor-pointer items-center justify-center border shadow-lg transition-shadow hover:shadow-xl",n("full")),initial:!1,"aria-label":`Open ${l}`,style:{originX:1,originY:1},children:h.jsx(Mn.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2,ease:or},className:"flex size-full items-center justify-center",children:c?c("closed"):h.jsx(oF,{className:"size-6"})})},"button")})})})})};function eY(e){switch(e){case"bottom-left":return"left-4 bottom-4";case"top-right":return"right-4 top-4";case"top-left":return"left-4 top-4";case"bottom-right":return"right-4 bottom-4";default:R.assertNever(e)}}const tY=()=>{const{config:e}=R.useElements(),t=um(),n=e.sidecar??{},{title:i,dimensions:r}=n,{isExpanded:o,setIsExpanded:a}=EP(),u=ee(({thread:c})=>c).messages.some(c=>c.status?.type==="running"),l=e.history?.enabled&&e.history?.showThreadList!==!1;return h.jsx(zn.LazyMotion,{features:zn.domMax,children:h.jsxs(Mn.div,{initial:{width:r?.default?.width??"400px",height:r?.default?.height??"100vh"},animate:{width:o?r?.expanded?.width??"800px":r?.default?.width??"400px",height:o?r?.expanded?.height??"100%":r?.default?.height??"100vh"},transition:{duration:.3,ease:or},className:R.cn("aui-root aui-sidecar bg-popover text-popover-foreground fixed top-0 right-0 border-l",t.className),children:[h.jsxs("div",{className:"aui-sidecar-header flex h-14 items-center justify-between border-b px-4",children:[h.jsxs("span",{className:R.cn("text-md flex items-center gap-2 font-medium",u&&"shimmer"),children:[i,u&&h.jsx(Hs,{className:"text-muted-foreground size-4.5 animate-spin",strokeWidth:1.25})]}),h.jsx("div",{className:"aui-sidecar-header-actions flex items-center gap-1",children:h.jsx(Wt,{tooltip:o?"Collapse":"Pop out",variant:"ghost",className:"aui-sidecar-popout size-8",onClick:()=>a(c=>!c),children:o?h.jsx(uF,{className:"size-4.5"}):h.jsx(dF,{className:"size-4.5"})})})]}),h.jsxs("div",{className:"aui-sidecar-body flex h-[calc(100%-3.5rem)] overflow-hidden",children:[l&&h.jsx("div",{className:"aui-sidecar-thread-list w-56 shrink-0 overflow-y-auto border-r",children:h.jsx(dm,{})}),h.jsx("div",{className:"aui-sidecar-content flex-1 overflow-hidden",children:h.jsx(cm,{})})]})]})})},nY=()=>{const{config:e}=R.useElements();switch(e.variant){case"standalone":return h.jsx(cm,{});case"sidecar":return h.jsx(tY,{});default:return h.jsx(Q8,{})}};exports.useElements=R.useElements;exports.useGramElements=R.useElements;exports.Chat=nY;exports.ChatHistory=dm;exports.ElementsProvider=qC;exports.GramElementsProvider=qC;exports.MODELS=jf;exports.defineFrontendTool=U6;
|
|
160
|
+
linear-gradient(135deg, transparent 75%, #ccc 75%)`,backgroundSize:"25px 25px",backgroundPosition:"0 0, 12.5px 0, 12.5px -12.5px, 0px 12.5px"},children:h.jsx("img",{src:t,className:"max-h-[300px] max-w-full object-contain"})})}function E8({content:e}){return h.jsx("div",{className:"w-full",children:e.content.map((t,n)=>{switch(t.type){case"text":{const i=w8(t._meta?.["getgram.ai/mime-type"]??"text/plain"),r=x8(t.text,i);return h.jsx(IP,{text:r,language:i},n)}case"image":return h.jsx(k8,{data:t.data},n);default:return h.jsx("pre",{className:"px-4 py-3 text-sm whitespace-pre-wrap",children:JSON.stringify(t,null,2)},n)}})})}function Xy({title:e,content:t,defaultExpanded:n=!1,highlightSyntax:i=!0,language:r="json"}){const[o,a]=k.useState(n),s=S8(t),u=s?JSON.stringify(t,null,2):typeof t=="string"?t:JSON.stringify(t,null,2);return h.jsxs("div",{"data-slot":"tool-ui-section",className:"border-border border-t",children:[h.jsxs("button",{onClick:()=>a(!o),className:"hover:bg-accent/50 flex w-full cursor-pointer items-center justify-between px-4 py-2.5 text-left transition-colors",children:[h.jsx("span",{className:"text-muted-foreground text-sm",children:e}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(I8,{content:u}),h.jsx(h0,{className:R.cn("text-muted-foreground size-4 transition-transform duration-200",o&&"rotate-90")})]})]}),o&&h.jsx("div",{className:"border-border border-t",children:s?h.jsx(E8,{content:t}):i?h.jsx(IP,{text:u,language:r}):h.jsx("pre",{className:"text-foreground overflow-x-auto px-4 py-3 text-sm whitespace-pre-wrap",children:u})})]})}function T8({name:e,icon:t,provider:n,status:i="complete",request:r,result:o,defaultExpanded:a=!1,className:s,onApproveOnce:u,onApproveForSession:l,onDeny:c}){const d=i==="approval"&&u!==void 0&&c!==void 0,[f,p]=k.useState(a),g=r!==void 0||o!==void 0,[m,y]=k.useState("one-time"),[v,w]=k.useState(!1);k.useEffect(()=>{!d&&f&&!a&&p(!1)},[d]);const x=()=>{m==="for-session"&&l?l():u&&u()};return h.jsxs("div",{"data-slot":"tool-ui",className:R.cn("border-border bg-card overflow-hidden rounded-lg border",s),children:[n&&h.jsxs("div",{"data-slot":"tool-ui-provider",className:R.cn("border-border flex items-center gap-2 border-b px-4 py-2.5"),children:[t?h.jsx("span",{className:"flex size-5 items-center justify-center",children:t}):h.jsx("span",{className:"bg-muted flex size-5 items-center justify-center rounded text-xs font-medium",children:n.charAt(0).toUpperCase()}),h.jsx("span",{className:"text-sm font-medium",children:n})]}),h.jsxs("button",{onClick:()=>g&&p(!f),disabled:!g,className:R.cn("flex w-full items-center gap-2 px-4 py-3 text-left",g&&"hover:bg-accent/50 cursor-pointer transition-colors"),children:[h.jsx(SP,{status:i}),h.jsx("span",{className:R.cn("flex-1 text-sm",!n&&d&&"shimmer"),children:e}),g&&h.jsx(Vs,{className:R.cn("text-muted-foreground size-4 transition-transform duration-200",f&&"rotate-180")})]}),f&&g&&h.jsxs("div",{"data-slot":"tool-ui-content",children:[r!==void 0&&h.jsx(Xy,{title:"Arguments",content:r,highlightSyntax:!0,language:"json"}),o!==void 0&&h.jsx(Xy,{title:"Output",content:o,highlightSyntax:!0,language:"json"})]}),d&&h.jsxs("div",{"data-slot":"tool-ui-approval-actions",className:"border-border flex items-center justify-end gap-2 border-t px-4 py-3",children:[h.jsx("div",{children:h.jsx("span",{className:"text-muted-foreground text-sm",children:"This tool requires approval"})}),h.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[h.jsxs(Vt,{variant:"outline",size:"sm",onClick:c,className:"text-destructive hover:bg-destructive/10",children:[h.jsx(xa,{className:"mr-1 size-3"}),"Deny"]}),h.jsxs("div",{className:"flex items-center",children:[h.jsxs(Vt,{variant:"default",size:"sm",onClick:x,className:"flex cursor-pointer justify-between gap-1 rounded-r-none bg-emerald-600 hover:bg-emerald-700",children:[h.jsx(ir,{className:"mr-1 size-3"}),h.jsx("span",{className:"min-w-[110px]",children:m==="one-time"?"Approve this time":"Approve always"})]}),h.jsxs(_P,{open:v,onOpenChange:w,children:[h.jsx(wP,{asChild:!0,children:h.jsx(Vt,{variant:"default",size:"sm",className:"cursor-pointer rounded-l-none border-l border-emerald-700 bg-emerald-600 px-2 hover:bg-emerald-700",children:h.jsx(Vs,{className:"size-3"})})}),h.jsxs(xP,{align:"end",className:"w-64 p-1",sideOffset:4,children:[h.jsxs("button",{onClick:()=>{y("one-time"),w(!1)},className:"hover:bg-accent relative flex w-full items-start gap-2 rounded-sm px-2 py-2 text-left",children:[h.jsx(ir,{className:R.cn("relative top-1 mt-0.5 size-3 shrink-0",m!=="one-time"&&"invisible")}),h.jsxs("div",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-sm",children:"Approve only once"}),h.jsx("span",{className:"text-muted-foreground text-xs",children:"You'll be asked again next time"})]})]}),l&&h.jsxs("button",{onClick:()=>{y("for-session"),w(!1)},className:"hover:bg-accent relative flex w-full items-start gap-2 rounded-sm px-2 py-2 text-left",children:[h.jsx(ir,{className:R.cn("relative top-1 mt-0.5 size-3 shrink-0",m!=="for-session"&&"invisible")}),h.jsxs("div",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-sm",children:"Approve always"}),h.jsx("span",{className:"text-muted-foreground text-xs",children:"Trust this tool for the session"})]})]})]})]})]})]})]})]})}function $8({title:e,icon:t,status:n="complete",defaultExpanded:i=!1,children:r,className:o}){const[a,s]=k.useState(i);return h.jsxs("div",{"data-slot":"tool-ui-group",className:R.cn("border-border bg-card overflow-hidden rounded-lg border",o),children:[h.jsxs("button",{onClick:()=>s(!a),className:"hover:bg-accent/50 flex w-full items-center gap-2 px-4 py-3 text-left transition-colors",children:[t||h.jsx(SP,{status:n==="running"?"running":"complete"}),h.jsx("span",{className:R.cn("flex-1 text-sm font-medium",n==="running"&&"shimmer"),children:e}),h.jsx(Vs,{className:R.cn("text-muted-foreground size-4 transition-transform duration-200",a&&"rotate-180")})]}),a&&h.jsx("div",{"data-slot":"tool-ui-group-content",className:"border-border border-t",children:r})]})}const C8=({toolName:e,toolCallId:t,status:n,result:i,args:r})=>{const{pendingApprovals:o,whitelistTool:a,confirmPendingApproval:s,rejectPendingApproval:u}=Lk(),l=o.get(t),d=ee(({message:w})=>w).parts.filter(w=>w.type==="tool-call"),f=d.findIndex(w=>w.toolName===e),p=()=>{s(t)},g=()=>{a(e),s(t)},m=()=>{u(t)},y=()=>l?"approval":n.type==="incomplete"?"error":n.type==="complete"?i&&typeof i=="object"&&"isError"in i&&i.isError?"error":"complete":"running",v=()=>{if(i!==void 0)return typeof i=="object"&&i!==null&&"content"in i&&Array.isArray(i.content)||typeof i=="string",i};return h.jsx("div",{className:R.cn("aui-tool-fallback-root flex w-full flex-col",f!==-1&&f!==d.length-1&&"border-b"),children:h.jsx(T8,{name:e,status:y(),request:r,result:v(),onApproveOnce:l?p:void 0,onApproveForSession:l?g:void 0,onDeny:l?m:void 0,className:"rounded-none border-0"})})},um=()=>{const{config:e}=R.useElements(),t=e.theme??{};return k.useMemo(()=>{const{colorScheme:n="light"}=t;return{className:n==="dark"||n==="system"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":void 0}},[t])},or=[.23,1,.32,1];function A8(e){return e.replace(/[-_]/g," ").split(/(?=[A-Z])/).join(" ").split(/\s+/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const P8=({children:e})=>{const t=ee(({message:s})=>s).parts,n=t.filter(s=>s.type==="tool-call"),i=n.some(s=>s.status?.type==="running"),{config:r}=R.useElements(),o=r.tools?.expandToolGroupsByDefault??!1,a=k.useMemo(()=>{const s=t.filter(u=>u.type==="tool-call");return s.length===0?"No tools called":s.length===1?`Calling ${A8(s[0].toolName)}...`:i?`Calling ${s.length} tools...`:`Executed ${s.length} tools`},[t,i]);return r.tools?.components?.[n[0]?.toolName]?e:n.length===1?h.jsx("div",{className:R.cn("my-4 w-full max-w-xl"),children:h.jsx("div",{className:"border-border bg-card overflow-hidden rounded-lg border",children:e})}):h.jsx("div",{className:"my-4 w-full max-w-xl",children:h.jsx($8,{title:a,status:i?"running":"complete",defaultExpanded:o,children:e})})},R8=()=>h.jsxs("div",{className:"m-2 rounded-md border border-amber-500 bg-amber-100 px-4 py-3 text-sm text-amber-800 dark:border-amber-600 dark:bg-amber-900/30 dark:text-amber-200",children:[h.jsx("strong",{children:"Warning:"})," You are using an API key directly in the client. Please"," ",h.jsx("a",{href:"https://github.com/speakeasy-api/gram/tree/main/elements#setting-up-your-backend",target:"_blank",rel:"noopener noreferrer",className:"text-amber-700 underline hover:text-amber-800 dark:text-amber-300 dark:hover:text-amber-200",children:"set up a session endpoint"})," ","before deploying to production."]}),cm=({className:e})=>{const t=um(),n=R.useDensity(),{config:i}=R.useElements(),r=i.components??{},o=i.api&&"UNSAFE_apiKey"in i.api;return h.jsx(zn.LazyMotion,{features:zn.domAnimation,children:h.jsx(zn.MotionConfig,{reducedMotion:"user",children:h.jsx(n0,{className:R.cn("aui-root aui-thread-root bg-background @container flex h-full flex-col",t.className,e),children:h.jsxs(i0,{className:R.cn("aui-thread-viewport relative mx-auto flex w-full flex-1 flex-col overflow-x-auto overflow-y-scroll pb-0!",n("p-lg")),children:[h.jsx(To,{empty:!0,children:r.ThreadWelcome?h.jsx(r.ThreadWelcome,{}):h.jsx(N8,{})}),o&&h.jsx(R8,{}),h.jsx(T6,{components:{UserMessage:r.UserMessage??Z8,EditComposer:r.EditComposer??V8,AssistantMessage:r.AssistantMessage??L8}}),h.jsx(To,{empty:!1,children:h.jsx("div",{className:"aui-thread-viewport-spacer min-h-8 grow"})}),h.jsx(M8,{})]})})})})},O8=()=>h.jsx(C6,{asChild:!0,children:h.jsx(Wt,{tooltip:"Scroll to bottom",variant:"outline",className:"aui-thread-scroll-to-bottom dark:bg-background dark:hover:bg-accent absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible",children:h.jsx(B6,{})})}),N8=()=>{const{config:e}=R.useElements(),t=R.useDensity(),{title:n,subtitle:i}=e.welcome??{},r=e.variant==="standalone";return h.jsxs("div",{className:R.cn("aui-thread-welcome-root my-auto flex w-full grow flex-col",r?"items-center justify-center":"",t("gap-lg")),children:[h.jsx("div",{className:R.cn("aui-thread-welcome-center flex w-full grow flex-col items-center justify-start"),children:h.jsxs("div",{className:R.cn("aui-thread-welcome-message flex flex-col",r?"items-center text-center":"size-full justify-start",t("gap-sm"),!r&&t("py-md")),children:[h.jsx(Mn.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,ease:or},className:R.cn("aui-thread-welcome-message-motion-1 text-foreground font-semibold",t("text-title")),children:n}),h.jsx(Mn.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,delay:.05,ease:or},className:R.cn("aui-thread-welcome-message-motion-2 text-muted-foreground/65",t("text-subtitle")),children:i})]})}),h.jsx(j8,{})]})},j8=()=>{const{config:e}=R.useElements(),t=R.useRadius(),n=R.useDensity(),i=e.welcome?.suggestions??[],r=e.variant==="standalone";return i.length===0?null:h.jsx("div",{className:R.cn("aui-thread-welcome-suggestions w-full",n("gap-md"),n("py-lg"),r?"flex flex-wrap items-center justify-center":i.length===1?"flex":"grid max-w-fit @md:grid-cols-2"),children:i.map((o,a)=>h.jsx(Mn.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.25,delay:.03*a,ease:or},className:R.cn("aui-thread-welcome-suggestion-display",!r&&"nth-[n+3]:hidden @md:nth-[n+3]:block"),children:h.jsx(P6,{prompt:o.action,send:!0,asChild:!0,children:h.jsxs(Vt,{variant:"ghost",className:R.cn("aui-thread-welcome-suggestion dark:hover:bg-accent/60 h-auto w-full border text-left whitespace-break-spaces",n("text-base"),r?`flex-row items-center ${n("gap-sm")} ${n("px-md")} ${n("py-sm")} ${t("full")}`:`w-full flex-1 flex-col flex-wrap items-start justify-start ${n("gap-sm")} ${n("px-lg")} ${n("py-md")} ${t("xl")}`),"aria-label":o.action,children:[h.jsx("span",{className:"aui-thread-welcome-suggestion-text-1 text-foreground text-sm font-medium",children:o.title}),h.jsx("span",{className:"aui-thread-welcome-suggestion-text-2 text-muted-foreground text-sm",children:o.label})]})})},`suggested-action-${o.title}-${a}`))})},M8=()=>{const{config:e}=R.useElements(),t=R.useRadius(),n=R.useDensity(),i=e.composer??{placeholder:"Send a message...",attachments:!0},r=e.components??{};return r.Composer?h.jsx(r.Composer,{}):h.jsxs("div",{className:R.cn("aui-composer-wrapper bg-background sticky bottom-0 flex w-full flex-col overflow-visible",n("gap-md"),n("py-md"),t("xl")),children:[h.jsx(O8,{}),h.jsxs(fh,{className:R.cn("aui-composer-root group/input-group border-input bg-background has-[textarea:focus-visible]:border-ring has-[textarea:focus-visible]:ring-ring/5 dark:bg-background relative flex w-full flex-col border px-1 pt-2 shadow-xs transition-[color,box-shadow] outline-none has-[textarea:focus-visible]:ring-1",t("xl")),children:[i.attachments&&h.jsx(vJ,{}),h.jsx(mh,{placeholder:i.placeholder,className:R.cn("aui-composer-input placeholder:text-muted-foreground mb-1 max-h-32 w-full resize-none bg-transparent px-3.5 pt-1.5 pb-3 outline-none focus-visible:ring-0",n("h-input"),n("text-base")),rows:1,autoFocus:!0,"aria-label":"Message input"}),h.jsx(z8,{})]})]})},D8=()=>{const{model:e,setModel:t}=R.useElements(),[n,i]=k.useState(!1),[r,o]=k.useState(!1),a=k.useRef(null),s=k.useRef(0),u=k.useRef(!1);k.useEffect(()=>{n&&!u.current&&requestAnimationFrame(()=>{const c=a.current;c&&c.scrollHeight>0&&(c.scrollTop=s.current)}),u.current=n},[n]),k.useEffect(()=>{n&&o(!1)},[n]);const l=c=>{s.current=c.currentTarget.scrollTop};return h.jsx(tA,{children:h.jsxs(Mh,{open:r&&!n,onOpenChange:o,children:[h.jsxs(_P,{open:n,onOpenChange:i,children:[h.jsx(Dh,{asChild:!0,children:h.jsx(wP,{asChild:!0,children:h.jsx(Vt,{variant:"ghost",size:"icon","data-state":n?"open":"closed",className:"aui-composer-model-picker data-[state=open]:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 flex w-fit items-center gap-2 rounded-full px-2.5 py-1 text-xs font-semibold","aria-label":"Model Settings",children:h.jsx(yF,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})})}),h.jsx(xP,{side:"top",align:"start",className:"w-min p-0 shadow-none",children:h.jsx("div",{ref:a,className:"max-h-48 overflow-y-auto",onScroll:l,children:jf.map(c=>h.jsxs(Vt,{onClick:()=>{t(c)},variant:"ghost",className:"w-full justify-start gap-2 rounded-none px-2",children:[c===e?h.jsx("div",{children:h.jsx(ir,{className:"size-4 text-emerald-500"})}):h.jsx("div",{className:"size-4",children:" "}),c]},c))})})]}),h.jsx(zh,{side:"bottom",align:"start",children:"Model Settings"})]})})},z8=()=>{const{config:e}=R.useElements(),t=R.useRadius(),n=e.composer??{attachments:!0};return h.jsxs("div",{className:"aui-composer-action-wrapper relative mx-1 mt-2 mb-2 flex items-center justify-between",children:[h.jsxs("div",{className:"aui-composer-action-wrapper-inner flex items-center",children:[n.attachments?h.jsx(yJ,{}):h.jsx("div",{className:"aui-composer-add-attachment-placeholder"}),e.model?.showModelPicker&&!e.languageModel&&h.jsx(D8,{})]}),h.jsx(To,{running:!1,children:h.jsx(GT,{asChild:!0,children:h.jsx(Wt,{tooltip:"Send message",side:"bottom",type:"submit",variant:"default",size:"icon",className:R.cn("aui-composer-send size-[34px] p-1",t("full")),"aria-label":"Send message",children:h.jsx(q6,{className:"aui-composer-send-icon size-5"})})})}),h.jsx(To,{running:!0,children:h.jsx(YT,{asChild:!0,children:h.jsx(Vt,{type:"button",variant:"default",size:"icon",className:R.cn("aui-composer-cancel border-muted-foreground/60 hover:bg-primary/75 dark:border-muted-foreground/90 size-[34px] border",t("full")),"aria-label":"Stop generating",children:h.jsx(_F,{className:"aui-composer-cancel-icon size-3.5 fill-white dark:fill-black"})})})})]})},U8=()=>h.jsx(HT,{children:h.jsx(e0,{className:"aui-message-error-root border-destructive bg-destructive/10 text-destructive dark:bg-destructive/5 mt-2 rounded-md border p-3 text-sm dark:text-red-200",children:h.jsx(t0,{className:"aui-message-error-message line-clamp-2"})})}),L8=()=>{const{config:e}=R.useElements(),t=e.tools??{},n=e.components??{};return h.jsx(dh,{asChild:!0,children:h.jsxs("div",{className:"aui-assistant-message-root animate-in fade-in slide-in-from-bottom-1 relative mx-auto w-full py-4 duration-150 ease-out last:mb-24","data-role":"assistant",children:[h.jsxs("div",{className:"aui-assistant-message-content text-foreground mx-2 leading-7 wrap-break-word",children:[h.jsx(ph,{components:{Text:n.Text??cP,Image:n.Image??F8,tools:{by_name:t.components,Fallback:n.ToolFallback??C8},Reasoning:n.Reasoning??yP,ReasoningGroup:n.ReasoningGroup??bP,ToolGroup:n.ToolGroup??P8}}),h.jsx(U8,{})]}),h.jsxs("div",{className:"aui-assistant-message-footer mt-2 ml-2 flex",children:[h.jsx(kP,{}),h.jsx(B8,{})]})]})})},F8=e=>h.jsx("img",{src:e.image}),B8=()=>h.jsxs(Kf,{hideWhenRunning:!0,autohide:"not-last",autohideFloat:"single-branch",className:"aui-assistant-action-bar-root text-muted-foreground data-floating:bg-background col-start-3 row-start-2 -ml-1 flex gap-1 data-floating:absolute data-floating:rounded-md data-floating:border data-floating:p-1 data-floating:shadow-sm",children:[h.jsx(zE,{asChild:!0,children:h.jsxs(Wt,{tooltip:"Copy",children:[h.jsx(Zs,{copied:!0,children:h.jsx(ir,{})}),h.jsx(Zs,{copied:!1,children:h.jsx(gh,{})})]})}),h.jsx(P4,{asChild:!0,children:h.jsx(Wt,{tooltip:"Refresh",children:h.jsx(gF,{})})})]}),Z8=()=>{const e=R.useRadius();return h.jsx(dh,{asChild:!0,children:h.jsxs("div",{className:"aui-user-message-root animate-in fade-in slide-in-from-bottom-1 mx-auto grid w-full auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-2 px-2 py-4 duration-150 ease-out first:mt-3 last:mb-5 [&:where(>*)]:col-start-2","data-role":"user",children:[h.jsx(gJ,{}),h.jsxs("div",{className:"aui-user-message-content-wrapper relative col-start-2 min-w-0",children:[h.jsx("div",{className:R.cn("aui-user-message-content bg-muted text-foreground px-5 py-2.5 wrap-break-word",e("xl")),children:h.jsx(ph,{})}),h.jsx("div",{className:"aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2",children:h.jsx(q8,{})})]}),h.jsx(kP,{className:"aui-user-branch-picker col-span-full col-start-1 row-start-3 -mr-1 justify-end"})]})})},q8=()=>h.jsx(Kf,{hideWhenRunning:!0,autohide:"not-last",className:"aui-user-action-bar-root flex flex-col items-end",children:h.jsx(O4,{asChild:!0,children:h.jsx(Wt,{tooltip:"Edit",className:"aui-user-action-edit p-4",children:h.jsx(fF,{})})})}),V8=()=>h.jsx("div",{className:"aui-edit-composer-wrapper mx-auto flex w-full flex-col gap-4 px-2 first:mt-4",children:h.jsxs(fh,{className:"aui-edit-composer-root bg-muted ml-auto flex w-full max-w-7/8 flex-col rounded-xl",children:[h.jsx(mh,{className:"aui-edit-composer-input text-foreground flex min-h-[60px] w-full resize-none bg-transparent p-4 outline-none",autoFocus:!0}),h.jsxs("div",{className:"aui-edit-composer-footer mx-3 mb-3 flex items-center justify-center gap-2 self-end",children:[h.jsx(YT,{asChild:!0,children:h.jsx(Vt,{variant:"ghost",size:"sm","aria-label":"Cancel edit",children:"Cancel"})}),h.jsx(GT,{asChild:!0,children:h.jsx(Vt,{size:"sm","aria-label":"Update message",children:"Update"})})]})]})}),kP=({className:e,...t})=>h.jsxs(JT,{hideWhenSingleBranch:!0,className:R.cn("aui-branch-picker-root text-muted-foreground mr-2 -ml-2 inline-flex items-center text-xs",e),...t,children:[h.jsx(j2,{asChild:!0,children:h.jsx(Wt,{tooltip:"Previous",children:h.jsx(K6,{})})}),h.jsxs("span",{className:"aui-branch-picker-state font-medium",children:[h.jsx(DT,{})," / ",h.jsx(MT,{})]}),h.jsx(O2,{asChild:!0,children:h.jsx(Wt,{tooltip:"Next",children:h.jsx(h0,{})})})]});function H8({className:e,...t}){return h.jsx("div",{"data-slot":"skeleton",className:R.cn("bg-accent animate-pulse rounded-md",e),...t})}const dm=({className:e})=>{const t=R.useDensity();return h.jsxs(d0,{className:R.cn("aui-root aui-thread-list-root bg-background flex flex-col items-stretch",t("gap-sm"),e),children:[h.jsx("div",{className:R.cn("aui-thread-list-new-section border-b pb-2",t("py-sm"),t("px-sm")),children:h.jsx(J8,{})}),h.jsx("div",{className:R.cn("aui-thread-list-items-section flex flex-col gap-1",t("py-xs"),t("px-sm")),children:h.jsx(W8,{})})]})},J8=()=>{const e=R.useDensity();return h.jsx(l0,{asChild:!0,children:h.jsxs(Vt,{className:R.cn("aui-thread-list-new hover:bg-muted-foreground/10 data-[active=true]:bg-muted-foreground/20! flex w-full cursor-pointer items-center justify-start gap-1 rounded-lg px-2.5 py-2 text-start",e("p-sm"),e("py-xs")),variant:"ghost",children:[h.jsx(m0,{}),"New Thread"]})})},W8=()=>ee(({threads:t})=>t.isLoading)?h.jsx(G8,{}):h.jsx(c0,{components:{ThreadListItem:K8}}),G8=()=>h.jsx(h.Fragment,{children:Array.from({length:5},(e,t)=>h.jsx("div",{role:"status","aria-label":"Loading threads","aria-live":"polite",className:"aui-thread-list-skeleton-wrapper flex items-center gap-2 rounded-md px-3 py-2",children:h.jsx(H8,{className:"aui-thread-list-skeleton h-[22px] grow"})},t))}),K8=()=>{const e=R.useRadius(),t=R.useDensity();return h.jsx(p0,{className:R.cn("aui-thread-list-item group hover:bg-muted focus-visible:bg-muted focus-visible:ring-ring data-[active=true]:bg-muted-foreground/20 flex items-center gap-2 rounded-lg transition-all focus-visible:ring-2 focus-visible:outline-none",e("md")),children:h.jsx(O6,{className:R.cn("aui-thread-list-item-trigger flex grow cursor-pointer items-center text-start",t("px-lg"),t("py-sm")),children:h.jsx(Y8,{})})})},Y8=()=>h.jsx("span",{className:"aui-thread-list-item-title text-sm",children:h.jsx(f0,{fallback:"New Chat"})}),EP=()=>{const{config:e,isExpanded:t,setIsExpanded:n}=R.useElements(),i=e.modal?.defaultExpanded??!1;return{expandable:e.modal?.expandable??!1,isExpanded:t,setIsExpanded:n,defaultExpanded:i}},X8={layout:{duration:.25,ease:or}},Q8=({className:e})=>{const{config:t}=R.useElements(),n=um(),i=R.useRadius(),r=R.useDensity(),[o,a]=k.useState(t.modal?.defaultOpen??!1),{expandable:s,isExpanded:u,setIsExpanded:l}=EP(),c=t.modal?.title,d=t.modal?.icon,f=t.history?.enabled&&t.history?.showThreadList!==!1,p=t.modal?.position??"bottom-right",g=eY(p),m=k.useMemo(()=>t.modal?.dimensions?.default??{width:"500px",height:"600px",maxHeight:"95vh"},[t.modal?.dimensions?.default]),y=k.useMemo(()=>t.modal?.dimensions?.expanded??{width:"70vw",height:"90vh"},[t.modal?.dimensions?.expanded]),w=ee(({thread:E})=>E).messages.some(E=>E.status?.type==="running"),x=u?y.width:m.width,b=u?y.height:m.height,C=m.maxHeight;return h.jsx(zn.LazyMotion,{features:zn.domMax,children:h.jsx(zn.MotionConfig,{reducedMotion:"user",transition:X8,children:h.jsx("div",{className:R.cn("aui-root aui-modal-anchor fixed z-10",g,n.className,i("lg"),o&&"shadow-xl",e),children:h.jsx(zn.AnimatePresence,{mode:"wait",children:o?h.jsxs(Mn.div,{layout:!0,layoutId:"chat-container",className:R.cn("aui-modal-content bg-popover text-popover-foreground flex flex-col overflow-hidden border [&>.aui-thread-root]:bg-inherit",i("lg")),initial:!1,style:{originX:p.includes("left")?0:1,originY:p.includes("top")?0:1,width:x,height:b,maxHeight:C},children:[h.jsxs(Mn.div,{className:R.cn("aui-modal-header flex shrink-0 items-center justify-between border-b",r("h-header"),r("px-lg")),initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.1,ease:or},children:[h.jsx("div",{className:R.cn("flex min-w-0 items-center"),children:h.jsxs("span",{className:R.cn("text-md flex items-center gap-2 truncate font-medium",w&&"shimmer"),children:[h.jsx("span",{className:"truncate",children:c}),w&&h.jsx(Hs,{className:"text-muted-foreground size-4.5 animate-spin",strokeWidth:1.25})]})}),h.jsxs("div",{className:"flex flex-row items-center justify-end gap-1",children:[s?h.jsx("button",{type:"button",onClick:()=>l(E=>!E),className:R.cn("text-muted-foreground hover:text-foreground hover:bg-accent flex h-8 cursor-pointer items-center rounded-md px-2 text-xs transition-colors"),"aria-pressed":u,"aria-label":u?"Collapse assistant":"Expand assistant",children:u?h.jsx(sF,{strokeWidth:2,className:"size-3.5 rotate-90"}):h.jsx(rF,{strokeWidth:2,className:"size-3.5 rotate-90"})}):null,h.jsx("button",{onClick:()=>{a(!1),l(!1)},className:"text-muted-foreground hover:text-foreground hover:bg-accent -mr-1 flex size-8 cursor-pointer items-center justify-center rounded-md transition-colors","aria-label":`Close ${c}`,children:h.jsx(xa,{className:"size-4.5"})})]})]}),h.jsxs(Mn.div,{className:"aui-modal-body flex flex-1 overflow-hidden",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.05,ease:or},children:[f&&h.jsx("div",{className:"aui-modal-thread-list w-56 shrink-0 overflow-y-auto border-r",children:h.jsx(dm,{})}),h.jsx("div",{className:"aui-modal-thread w-full flex-1 overflow-hidden",children:h.jsx(cm,{})})]})]},"chat"):h.jsx(Mn.button,{layout:!0,layoutId:"chat-container",onClick:()=>a(!0),className:R.cn("aui-modal-button bg-primary text-primary-foreground flex size-12 cursor-pointer items-center justify-center border shadow-lg transition-shadow hover:shadow-xl",i("full")),initial:!1,"aria-label":`Open ${c}`,style:{originX:1,originY:1},children:h.jsx(Mn.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2,ease:or},className:"flex size-full items-center justify-center",children:d?d("closed"):h.jsx(oF,{className:"size-6"})})},"button")})})})})};function eY(e){switch(e){case"bottom-left":return"left-4 bottom-4";case"top-right":return"right-4 top-4";case"top-left":return"left-4 top-4";case"bottom-right":return"right-4 bottom-4";default:R.assertNever(e)}}const tY=({className:e})=>{const{config:t}=R.useElements(),n=um(),i=t.sidecar??{},{title:r,dimensions:o}=i,{isExpanded:a,setIsExpanded:s}=EP(),l=ee(({thread:d})=>d).messages.some(d=>d.status?.type==="running"),c=t.history?.enabled&&t.history?.showThreadList!==!1;return h.jsx(zn.LazyMotion,{features:zn.domMax,children:h.jsxs(Mn.div,{initial:{width:o?.default?.width??"400px",height:o?.default?.height??"100vh"},animate:{width:a?o?.expanded?.width??"800px":o?.default?.width??"400px",height:a?o?.expanded?.height??"100%":o?.default?.height??"100vh"},transition:{duration:.3,ease:or},className:R.cn("aui-root aui-sidecar bg-popover text-popover-foreground fixed top-0 right-0 border-l",n.className,e),children:[h.jsxs("div",{className:"aui-sidecar-header flex h-14 items-center justify-between border-b px-4",children:[h.jsxs("span",{className:R.cn("text-md flex items-center gap-2 font-medium",l&&"shimmer"),children:[r,l&&h.jsx(Hs,{className:"text-muted-foreground size-4.5 animate-spin",strokeWidth:1.25})]}),h.jsx("div",{className:"aui-sidecar-header-actions flex items-center gap-1",children:h.jsx(Wt,{tooltip:a?"Collapse":"Pop out",variant:"ghost",className:"aui-sidecar-popout size-8",onClick:()=>s(d=>!d),children:a?h.jsx(uF,{className:"size-4.5"}):h.jsx(dF,{className:"size-4.5"})})})]}),h.jsxs("div",{className:"aui-sidecar-body flex h-[calc(100%-3.5rem)] overflow-hidden",children:[c&&h.jsx("div",{className:"aui-sidecar-thread-list w-56 shrink-0 overflow-y-auto border-r",children:h.jsx(dm,{})}),h.jsx("div",{className:"aui-sidecar-content flex-1 overflow-hidden",children:h.jsx(cm,{})})]})]})})},nY=({className:e})=>{const{config:t}=R.useElements();switch(t.variant){case"standalone":return h.jsx(cm,{className:e});case"sidecar":return h.jsx(tY,{className:e});default:return h.jsx(Q8,{className:e})}};exports.useElements=R.useElements;exports.useGramElements=R.useElements;exports.Chat=nY;exports.ChatHistory=dm;exports.ElementsProvider=qC;exports.GramElementsProvider=qC;exports.MODELS=jf;exports.defineFrontendTool=U6;
|
|
161
161
|
//# sourceMappingURL=elements.cjs.map
|