teodor-new-chat-ui 2.0.49 → 2.0.51

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/index.umd.js CHANGED
@@ -1,13 +1,13 @@
1
- (function(ae,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react/jsx-runtime"),require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom"),require("react-markdown"),require("remark-gfm")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","react-markdown","remark-gfm"],i):(ae=typeof globalThis<"u"?globalThis:ae||self,i(ae.NewChatUI={},ae.jsxRuntime,ae.React,ae.LucideReact,ae.reactSlot,ae.classVarianceAuthority,ae.clsx,ae.tailwindMerge,ae.ReactDOM,ae.ReactMarkdown,ae.remarkGfm))})(this,function(ae,i,N,q,Be,Jt,tu,nu,As,ru,ou){"use strict";var Vr=typeof document<"u"?document.currentScript:null;function Is(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const l=Is(N),Tn=Is(As);function ks(e,t){return function(){return e.apply(t,arguments)}}const{toString:su}=Object.prototype,{getPrototypeOf:jr}=Object,{iterator:An,toStringTag:_s}=Symbol,In=(e=>t=>{const n=su.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Re=e=>(e=e.toLowerCase(),t=>In(t)===e),kn=e=>t=>typeof t===e,{isArray:Dt}=Array,Lt=kn("undefined");function Zt(e){return e!==null&&!Lt(e)&&e.constructor!==null&&!Lt(e.constructor)&&Me(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ps=Re("ArrayBuffer");function au(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ps(e.buffer),t}const iu=kn("string"),Me=kn("function"),Os=kn("number"),Qt=e=>e!==null&&typeof e=="object",cu=e=>e===!0||e===!1,_n=e=>{if(In(e)!=="object")return!1;const t=jr(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(_s in e)&&!(An in e)},lu=e=>{if(!Qt(e)||Zt(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},du=Re("Date"),uu=Re("File"),fu=Re("Blob"),pu=Re("FileList"),hu=e=>Qt(e)&&Me(e.pipe),gu=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Me(e.append)&&((t=In(e))==="formdata"||t==="object"&&Me(e.toString)&&e.toString()==="[object FormData]"))},mu=Re("URLSearchParams"),[bu,vu,wu,yu]=["ReadableStream","Request","Response","Headers"].map(Re),xu=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function en(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Dt(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Zt(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),a=s.length;let c;for(r=0;r<a;r++)c=s[r],t.call(null,e[c],c,e)}}function Ms(e,t){if(Zt(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Ct=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ds=e=>!Lt(e)&&e!==Ct;function Rr(){const{caseless:e,skipUndefined:t}=Ds(this)&&this||{},n={},r=(o,s)=>{const a=e&&Ms(n,s)||s;_n(n[a])&&_n(o)?n[a]=Rr(n[a],o):_n(o)?n[a]=Rr({},o):Dt(o)?n[a]=o.slice():(!t||!Lt(o))&&(n[a]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&en(arguments[o],r);return n}const Su=(e,t,n,{allOwnKeys:r}={})=>(en(t,(o,s)=>{n&&Me(o)?e[s]=ks(o,n):e[s]=o},{allOwnKeys:r}),e),Cu=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Eu=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Nu=(e,t,n,r)=>{let o,s,a;const c={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)a=o[s],(!r||r(a,e,t))&&!c[a]&&(t[a]=e[a],c[a]=!0);e=n!==!1&&jr(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Tu=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Au=e=>{if(!e)return null;if(Dt(e))return e;let t=e.length;if(!Os(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Iu=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&jr(Uint8Array)),ku=(e,t)=>{const r=(e&&e[An]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},_u=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Pu=Re("HTMLFormElement"),Ou=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Ls=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Mu=Re("RegExp"),Fs=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};en(n,(o,s)=>{let a;(a=t(o,s,e))!==!1&&(r[s]=a||o)}),Object.defineProperties(e,r)},Du=e=>{Fs(e,(t,n)=>{if(Me(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Me(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Lu=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Dt(e)?r(e):r(String(e).split(t)),n},Fu=()=>{},$u=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Bu(e){return!!(e&&Me(e.append)&&e[_s]==="FormData"&&e[An])}const Uu=e=>{const t=new Array(10),n=(r,o)=>{if(Qt(r)){if(t.indexOf(r)>=0)return;if(Zt(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Dt(r)?[]:{};return en(r,(a,c)=>{const d=n(a,o+1);!Lt(d)&&(s[c]=d)}),t[o]=void 0,s}}return r};return n(e,0)},Hu=Re("AsyncFunction"),zu=e=>e&&(Qt(e)||Me(e))&&Me(e.then)&&Me(e.catch),$s=((e,t)=>e?setImmediate:t?((n,r)=>(Ct.addEventListener("message",({source:o,data:s})=>{o===Ct&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Ct.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Me(Ct.postMessage)),Wu=typeof queueMicrotask<"u"?queueMicrotask.bind(Ct):typeof process<"u"&&process.nextTick||$s,S={isArray:Dt,isArrayBuffer:Ps,isBuffer:Zt,isFormData:gu,isArrayBufferView:au,isString:iu,isNumber:Os,isBoolean:cu,isObject:Qt,isPlainObject:_n,isEmptyObject:lu,isReadableStream:bu,isRequest:vu,isResponse:wu,isHeaders:yu,isUndefined:Lt,isDate:du,isFile:uu,isBlob:fu,isRegExp:Mu,isFunction:Me,isStream:hu,isURLSearchParams:mu,isTypedArray:Iu,isFileList:pu,forEach:en,merge:Rr,extend:Su,trim:xu,stripBOM:Cu,inherits:Eu,toFlatObject:Nu,kindOf:In,kindOfTest:Re,endsWith:Tu,toArray:Au,forEachEntry:ku,matchAll:_u,isHTMLForm:Pu,hasOwnProperty:Ls,hasOwnProp:Ls,reduceDescriptors:Fs,freezeMethods:Du,toObjectSet:Lu,toCamelCase:Ou,noop:Fu,toFiniteNumber:$u,findKey:Ms,global:Ct,isContextDefined:Ds,isSpecCompliantForm:Bu,toJSONObject:Uu,isAsyncFn:Hu,isThenable:zu,setImmediate:$s,asap:Wu,isIterable:e=>e!=null&&Me(e[An])};function ce(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}S.inherits(ce,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:S.toJSONObject(this.config),code:this.code,status:this.status}}});const Bs=ce.prototype,Us={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Us[e]={value:e}}),Object.defineProperties(ce,Us),Object.defineProperty(Bs,"isAxiosError",{value:!0}),ce.from=(e,t,n,r,o,s)=>{const a=Object.create(Bs);S.toFlatObject(e,a,function(u){return u!==Error.prototype},f=>f!=="isAxiosError");const c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return ce.call(a,c,d,n,r,o),e&&a.cause==null&&Object.defineProperty(a,"cause",{value:e,configurable:!0}),a.name=e&&e.name||"Error",s&&Object.assign(a,s),a};const Vu=null;function Kr(e){return S.isPlainObject(e)||S.isArray(e)}function Hs(e){return S.endsWith(e,"[]")?e.slice(0,-2):e}function zs(e,t,n){return e?e.concat(t).map(function(o,s){return o=Hs(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function ju(e){return S.isArray(e)&&!e.some(Kr)}const Ru=S.toFlatObject(S,{},null,function(t){return/^is[A-Z]/.test(t)});function Pn(e,t,n){if(!S.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=S.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,b){return!S.isUndefined(b[h])});const r=n.metaTokens,o=n.visitor||u,s=n.dots,a=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&S.isSpecCompliantForm(t);if(!S.isFunction(o))throw new TypeError("visitor must be a function");function f(g){if(g===null)return"";if(S.isDate(g))return g.toISOString();if(S.isBoolean(g))return g.toString();if(!d&&S.isBlob(g))throw new ce("Blob is not supported. Use a Buffer instead.");return S.isArrayBuffer(g)||S.isTypedArray(g)?d&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function u(g,h,b){let w=g;if(g&&!b&&typeof g=="object"){if(S.endsWith(h,"{}"))h=r?h:h.slice(0,-2),g=JSON.stringify(g);else if(S.isArray(g)&&ju(g)||(S.isFileList(g)||S.endsWith(h,"[]"))&&(w=S.toArray(g)))return h=Hs(h),w.forEach(function(x,C){!(S.isUndefined(x)||x===null)&&t.append(a===!0?zs([h],C,s):a===null?h:h+"[]",f(x))}),!1}return Kr(g)?!0:(t.append(zs(b,h,s),f(g)),!1)}const p=[],m=Object.assign(Ru,{defaultVisitor:u,convertValue:f,isVisitable:Kr});function v(g,h){if(!S.isUndefined(g)){if(p.indexOf(g)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(g),S.forEach(g,function(w,y){(!(S.isUndefined(w)||w===null)&&o.call(t,w,S.isString(y)?y.trim():y,h,m))===!0&&v(w,h?h.concat(y):[y])}),p.pop()}}if(!S.isObject(e))throw new TypeError("data must be an object");return v(e),t}function Ws(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Gr(e,t){this._pairs=[],e&&Pn(e,this,t)}const Vs=Gr.prototype;Vs.append=function(t,n){this._pairs.push([t,n])},Vs.toString=function(t){const n=t?function(r){return t.call(this,r,Ws)}:Ws;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Ku(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function js(e,t,n){if(!t)return e;const r=n&&n.encode||Ku;S.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=S.isURLSearchParams(t)?t.toString():new Gr(t,n).toString(r),s){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Rs{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){S.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ks={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Gu={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Gr,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},qr=typeof window<"u"&&typeof document<"u",Xr=typeof navigator=="object"&&navigator||void 0,qu=qr&&(!Xr||["ReactNative","NativeScript","NS"].indexOf(Xr.product)<0),Xu=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Yu=qr&&window.location.href||"http://localhost",ke={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:qr,hasStandardBrowserEnv:qu,hasStandardBrowserWebWorkerEnv:Xu,navigator:Xr,origin:Yu},Symbol.toStringTag,{value:"Module"})),...Gu};function Ju(e,t){return Pn(e,new ke.classes.URLSearchParams,{visitor:function(n,r,o,s){return ke.isNode&&S.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Zu(e){return S.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Qu(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function Gs(e){function t(n,r,o,s){let a=n[s++];if(a==="__proto__")return!0;const c=Number.isFinite(+a),d=s>=n.length;return a=!a&&S.isArray(o)?o.length:a,d?(S.hasOwnProp(o,a)?o[a]=[o[a],r]:o[a]=r,!c):((!o[a]||!S.isObject(o[a]))&&(o[a]=[]),t(n,r,o[a],s)&&S.isArray(o[a])&&(o[a]=Qu(o[a])),!c)}if(S.isFormData(e)&&S.isFunction(e.entries)){const n={};return S.forEachEntry(e,(r,o)=>{t(Zu(r),o,n,0)}),n}return null}function ef(e,t,n){if(S.isString(e))try{return(t||JSON.parse)(e),S.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const tn={transitional:Ks,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=S.isObject(t);if(s&&S.isHTMLForm(t)&&(t=new FormData(t)),S.isFormData(t))return o?JSON.stringify(Gs(t)):t;if(S.isArrayBuffer(t)||S.isBuffer(t)||S.isStream(t)||S.isFile(t)||S.isBlob(t)||S.isReadableStream(t))return t;if(S.isArrayBufferView(t))return t.buffer;if(S.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Ju(t,this.formSerializer).toString();if((c=S.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return Pn(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),ef(t)):t}],transformResponse:[function(t){const n=this.transitional||tn.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(S.isResponse(t)||S.isReadableStream(t))return t;if(t&&S.isString(t)&&(r&&!this.responseType||o)){const a=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(c){if(a)throw c.name==="SyntaxError"?ce.from(c,ce.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ke.classes.FormData,Blob:ke.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};S.forEach(["delete","get","head","post","put","patch"],e=>{tn.headers[e]={}});const tf=S.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),nf=e=>{const t={};let n,r,o;return e&&e.split(`
2
- `).forEach(function(a){o=a.indexOf(":"),n=a.substring(0,o).trim().toLowerCase(),r=a.substring(o+1).trim(),!(!n||t[n]&&tf[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},qs=Symbol("internals");function nn(e){return e&&String(e).trim().toLowerCase()}function On(e){return e===!1||e==null?e:S.isArray(e)?e.map(On):String(e)}function rf(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const of=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Yr(e,t,n,r,o){if(S.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!S.isString(t)){if(S.isString(r))return t.indexOf(r)!==-1;if(S.isRegExp(r))return r.test(t)}}function sf(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function af(e,t){const n=S.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,a){return this[r].call(this,t,o,s,a)},configurable:!0})})}let De=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(c,d,f){const u=nn(d);if(!u)throw new Error("header name must be a non-empty string");const p=S.findKey(o,u);(!p||o[p]===void 0||f===!0||f===void 0&&o[p]!==!1)&&(o[p||d]=On(c))}const a=(c,d)=>S.forEach(c,(f,u)=>s(f,u,d));if(S.isPlainObject(t)||t instanceof this.constructor)a(t,n);else if(S.isString(t)&&(t=t.trim())&&!of(t))a(nf(t),n);else if(S.isObject(t)&&S.isIterable(t)){let c={},d,f;for(const u of t){if(!S.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[f=u[0]]=(d=c[f])?S.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}a(c,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=nn(t),t){const r=S.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return rf(o);if(S.isFunction(n))return n.call(this,o,r);if(S.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=nn(t),t){const r=S.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Yr(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(a){if(a=nn(a),a){const c=S.findKey(r,a);c&&(!n||Yr(r,r[c],c,n))&&(delete r[c],o=!0)}}return S.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||Yr(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return S.forEach(this,(o,s)=>{const a=S.findKey(r,s);if(a){n[a]=On(o),delete n[s];return}const c=t?sf(s):String(s).trim();c!==s&&delete n[s],n[c]=On(o),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return S.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&S.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
3
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[qs]=this[qs]={accessors:{}}).accessors,o=this.prototype;function s(a){const c=nn(a);r[c]||(af(o,a),r[c]=!0)}return S.isArray(t)?t.forEach(s):s(t),this}};De.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),S.reduceDescriptors(De.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),S.freezeMethods(De);function Jr(e,t){const n=this||tn,r=t||n,o=De.from(r.headers);let s=r.data;return S.forEach(e,function(c){s=c.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Xs(e){return!!(e&&e.__CANCEL__)}function Ft(e,t,n){ce.call(this,e??"canceled",ce.ERR_CANCELED,t,n),this.name="CanceledError"}S.inherits(Ft,ce,{__CANCEL__:!0});function Ys(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new ce("Request failed with status code "+n.status,[ce.ERR_BAD_REQUEST,ce.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function cf(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function lf(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,a;return t=t!==void 0?t:1e3,function(d){const f=Date.now(),u=r[s];a||(a=f),n[o]=d,r[o]=f;let p=s,m=0;for(;p!==o;)m+=n[p++],p=p%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),f-a<t)return;const v=u&&f-u;return v?Math.round(m*1e3/v):void 0}}function df(e,t){let n=0,r=1e3/t,o,s;const a=(f,u=Date.now())=>{n=u,o=null,s&&(clearTimeout(s),s=null),e(...f)};return[(...f)=>{const u=Date.now(),p=u-n;p>=r?a(f,u):(o=f,s||(s=setTimeout(()=>{s=null,a(o)},r-p)))},()=>o&&a(o)]}const Mn=(e,t,n=3)=>{let r=0;const o=lf(50,250);return df(s=>{const a=s.loaded,c=s.lengthComputable?s.total:void 0,d=a-r,f=o(d),u=a<=c;r=a;const p={loaded:a,total:c,progress:c?a/c:void 0,bytes:d,rate:f||void 0,estimated:f&&c&&u?(c-a)/f:void 0,event:s,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(p)},n)},Js=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Zs=e=>(...t)=>S.asap(()=>e(...t)),uf=ke.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,ke.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(ke.origin),ke.navigator&&/(msie|trident)/i.test(ke.navigator.userAgent)):()=>!0,ff=ke.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const a=[e+"="+encodeURIComponent(t)];S.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),S.isString(r)&&a.push("path="+r),S.isString(o)&&a.push("domain="+o),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function pf(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function hf(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Qs(e,t,n){let r=!pf(t);return e&&(r||n==!1)?hf(e,t):t}const ea=e=>e instanceof De?{...e}:e;function Et(e,t){t=t||{};const n={};function r(f,u,p,m){return S.isPlainObject(f)&&S.isPlainObject(u)?S.merge.call({caseless:m},f,u):S.isPlainObject(u)?S.merge({},u):S.isArray(u)?u.slice():u}function o(f,u,p,m){if(S.isUndefined(u)){if(!S.isUndefined(f))return r(void 0,f,p,m)}else return r(f,u,p,m)}function s(f,u){if(!S.isUndefined(u))return r(void 0,u)}function a(f,u){if(S.isUndefined(u)){if(!S.isUndefined(f))return r(void 0,f)}else return r(void 0,u)}function c(f,u,p){if(p in t)return r(f,u);if(p in e)return r(void 0,f)}const d={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c,headers:(f,u,p)=>o(ea(f),ea(u),p,!0)};return S.forEach(Object.keys({...e,...t}),function(u){const p=d[u]||o,m=p(e[u],t[u],u);S.isUndefined(m)&&p!==c||(n[u]=m)}),n}const ta=e=>{const t=Et({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:a,auth:c}=t;if(t.headers=a=De.from(a),t.url=js(Qs(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),S.isFormData(n)){if(ke.hasStandardBrowserEnv||ke.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(S.isFunction(n.getHeaders)){const d=n.getHeaders(),f=["content-type","content-length"];Object.entries(d).forEach(([u,p])=>{f.includes(u.toLowerCase())&&a.set(u,p)})}}if(ke.hasStandardBrowserEnv&&(r&&S.isFunction(r)&&(r=r(t)),r||r!==!1&&uf(t.url))){const d=o&&s&&ff.read(s);d&&a.set(o,d)}return t},gf=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=ta(e);let s=o.data;const a=De.from(o.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:f}=o,u,p,m,v,g;function h(){v&&v(),g&&g(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let b=new XMLHttpRequest;b.open(o.method.toUpperCase(),o.url,!0),b.timeout=o.timeout;function w(){if(!b)return;const x=De.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),E={data:!c||c==="text"||c==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:x,config:e,request:b};Ys(function(T){n(T),h()},function(T){r(T),h()},E),b=null}"onloadend"in b?b.onloadend=w:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(w)},b.onabort=function(){b&&(r(new ce("Request aborted",ce.ECONNABORTED,e,b)),b=null)},b.onerror=function(C){const E=C&&C.message?C.message:"Network Error",P=new ce(E,ce.ERR_NETWORK,e,b);P.event=C||null,r(P),b=null},b.ontimeout=function(){let C=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const E=o.transitional||Ks;o.timeoutErrorMessage&&(C=o.timeoutErrorMessage),r(new ce(C,E.clarifyTimeoutError?ce.ETIMEDOUT:ce.ECONNABORTED,e,b)),b=null},s===void 0&&a.setContentType(null),"setRequestHeader"in b&&S.forEach(a.toJSON(),function(C,E){b.setRequestHeader(E,C)}),S.isUndefined(o.withCredentials)||(b.withCredentials=!!o.withCredentials),c&&c!=="json"&&(b.responseType=o.responseType),f&&([m,g]=Mn(f,!0),b.addEventListener("progress",m)),d&&b.upload&&([p,v]=Mn(d),b.upload.addEventListener("progress",p),b.upload.addEventListener("loadend",v)),(o.cancelToken||o.signal)&&(u=x=>{b&&(r(!x||x.type?new Ft(null,e,b):x),b.abort(),b=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const y=cf(o.url);if(y&&ke.protocols.indexOf(y)===-1){r(new ce("Unsupported protocol "+y+":",ce.ERR_BAD_REQUEST,e));return}b.send(s||null)})},mf=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(f){if(!o){o=!0,c();const u=f instanceof Error?f:this.reason;r.abort(u instanceof ce?u:new Ft(u instanceof Error?u.message:u))}};let a=t&&setTimeout(()=>{a=null,s(new ce(`timeout ${t} of ms exceeded`,ce.ETIMEDOUT))},t);const c=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(f=>{f.unsubscribe?f.unsubscribe(s):f.removeEventListener("abort",s)}),e=null)};e.forEach(f=>f.addEventListener("abort",s));const{signal:d}=r;return d.unsubscribe=()=>S.asap(c),d}},bf=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},vf=async function*(e,t){for await(const n of wf(e))yield*bf(n,t)},wf=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},na=(e,t,n,r)=>{const o=vf(e,t);let s=0,a,c=d=>{a||(a=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:f,value:u}=await o.next();if(f){c(),d.close();return}let p=u.byteLength;if(n){let m=s+=p;n(m)}d.enqueue(new Uint8Array(u))}catch(f){throw c(f),f}},cancel(d){return c(d),o.return()}},{highWaterMark:2})},ra=64*1024,{isFunction:Dn}=S,yf=(({Request:e,Response:t})=>({Request:e,Response:t}))(S.global),{ReadableStream:oa,TextEncoder:sa}=S.global,aa=(e,...t)=>{try{return!!e(...t)}catch{return!1}},xf=e=>{e=S.merge.call({skipUndefined:!0},yf,e);const{fetch:t,Request:n,Response:r}=e,o=t?Dn(t):typeof fetch=="function",s=Dn(n),a=Dn(r);if(!o)return!1;const c=o&&Dn(oa),d=o&&(typeof sa=="function"?(g=>h=>g.encode(h))(new sa):async g=>new Uint8Array(await new n(g).arrayBuffer())),f=s&&c&&aa(()=>{let g=!1;const h=new n(ke.origin,{body:new oa,method:"POST",get duplex(){return g=!0,"half"}}).headers.has("Content-Type");return g&&!h}),u=a&&c&&aa(()=>S.isReadableStream(new r("").body)),p={stream:u&&(g=>g.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(g=>{!p[g]&&(p[g]=(h,b)=>{let w=h&&h[g];if(w)return w.call(h);throw new ce(`Response type '${g}' is not supported`,ce.ERR_NOT_SUPPORT,b)})});const m=async g=>{if(g==null)return 0;if(S.isBlob(g))return g.size;if(S.isSpecCompliantForm(g))return(await new n(ke.origin,{method:"POST",body:g}).arrayBuffer()).byteLength;if(S.isArrayBufferView(g)||S.isArrayBuffer(g))return g.byteLength;if(S.isURLSearchParams(g)&&(g=g+""),S.isString(g))return(await d(g)).byteLength},v=async(g,h)=>{const b=S.toFiniteNumber(g.getContentLength());return b??m(h)};return async g=>{let{url:h,method:b,data:w,signal:y,cancelToken:x,timeout:C,onDownloadProgress:E,onUploadProgress:P,responseType:T,headers:F,withCredentials:M="same-origin",fetchOptions:B}=ta(g),V=t||fetch;T=T?(T+"").toLowerCase():"text";let J=mf([y,x&&x.toAbortSignal()],C),H=null;const O=J&&J.unsubscribe&&(()=>{J.unsubscribe()});let ne;try{if(P&&f&&b!=="get"&&b!=="head"&&(ne=await v(F,w))!==0){let j=new n(h,{method:"POST",body:w,duplex:"half"}),te;if(S.isFormData(w)&&(te=j.headers.get("content-type"))&&F.setContentType(te),j.body){const[D,W]=Js(ne,Mn(Zs(P)));w=na(j.body,ra,D,W)}}S.isString(M)||(M=M?"include":"omit");const L=s&&"credentials"in n.prototype,z={...B,signal:J,method:b.toUpperCase(),headers:F.normalize().toJSON(),body:w,duplex:"half",credentials:L?M:void 0};H=s&&new n(h,z);let k=await(s?V(H,B):V(h,z));const I=u&&(T==="stream"||T==="response");if(u&&(E||I&&O)){const j={};["status","statusText","headers"].forEach(xe=>{j[xe]=k[xe]});const te=S.toFiniteNumber(k.headers.get("content-length")),[D,W]=E&&Js(te,Mn(Zs(E),!0))||[];k=new r(na(k.body,ra,D,()=>{W&&W(),O&&O()}),j)}T=T||"text";let Z=await p[S.findKey(p,T)||"text"](k,g);return!I&&O&&O(),await new Promise((j,te)=>{Ys(j,te,{data:Z,headers:De.from(k.headers),status:k.status,statusText:k.statusText,config:g,request:H})})}catch(L){throw O&&O(),L&&L.name==="TypeError"&&/Load failed|fetch/i.test(L.message)?Object.assign(new ce("Network Error",ce.ERR_NETWORK,g,H),{cause:L.cause||L}):ce.from(L,L&&L.code,g,H)}}},Sf=new Map,ia=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let a=s.length,c=a,d,f,u=Sf;for(;c--;)d=s[c],f=u.get(d),f===void 0&&u.set(d,f=c?new Map:xf(t)),u=f;return f};ia();const Zr={http:Vu,xhr:gf,fetch:{get:ia}};S.forEach(Zr,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const ca=e=>`- ${e}`,Cf=e=>S.isFunction(e)||e===null||e===!1,la={getAdapter:(e,t)=>{e=S.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let a=0;a<n;a++){r=e[a];let c;if(o=r,!Cf(r)&&(o=Zr[(c=String(r)).toLowerCase()],o===void 0))throw new ce(`Unknown adapter '${c}'`);if(o&&(S.isFunction(o)||(o=o.get(t))))break;s[c||"#"+a]=o}if(!o){const a=Object.entries(s).map(([d,f])=>`adapter ${d} `+(f===!1?"is not supported by the environment":"is not available in the build"));let c=n?a.length>1?`since :
4
- `+a.map(ca).join(`
5
- `):" "+ca(a[0]):"as no adapter specified";throw new ce("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return o},adapters:Zr};function Qr(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Ft(null,e)}function da(e){return Qr(e),e.headers=De.from(e.headers),e.data=Jr.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),la.getAdapter(e.adapter||tn.adapter,e)(e).then(function(r){return Qr(e),r.data=Jr.call(e,e.transformResponse,r),r.headers=De.from(r.headers),r},function(r){return Xs(r)||(Qr(e),r&&r.response&&(r.response.data=Jr.call(e,e.transformResponse,r.response),r.response.headers=De.from(r.response.headers))),Promise.reject(r)})}const ua="1.12.2",Ln={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ln[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const fa={};Ln.transitional=function(t,n,r){function o(s,a){return"[Axios v"+ua+"] Transitional option '"+s+"'"+a+(r?". "+r:"")}return(s,a,c)=>{if(t===!1)throw new ce(o(a," has been removed"+(n?" in "+n:"")),ce.ERR_DEPRECATED);return n&&!fa[a]&&(fa[a]=!0,console.warn(o(a," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,a,c):!0}},Ln.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Ef(e,t,n){if(typeof e!="object")throw new ce("options must be an object",ce.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],a=t[s];if(a){const c=e[s],d=c===void 0||a(c,s,e);if(d!==!0)throw new ce("option "+s+" must be "+d,ce.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new ce("Unknown option "+s,ce.ERR_BAD_OPTION)}}const Fn={assertOptions:Ef,validators:Ln},nt=Fn.validators;let Nt=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Rs,response:new Rs}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
6
- `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Et(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Fn.assertOptions(r,{silentJSONParsing:nt.transitional(nt.boolean),forcedJSONParsing:nt.transitional(nt.boolean),clarifyTimeoutError:nt.transitional(nt.boolean)},!1),o!=null&&(S.isFunction(o)?n.paramsSerializer={serialize:o}:Fn.assertOptions(o,{encode:nt.function,serialize:nt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Fn.assertOptions(n,{baseUrl:nt.spelling("baseURL"),withXsrfToken:nt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let a=s&&S.merge(s.common,s[n.method]);s&&S.forEach(["delete","get","head","post","put","patch","common"],g=>{delete s[g]}),n.headers=De.concat(a,s);const c=[];let d=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(n)===!1||(d=d&&h.synchronous,c.unshift(h.fulfilled,h.rejected))});const f=[];this.interceptors.response.forEach(function(h){f.push(h.fulfilled,h.rejected)});let u,p=0,m;if(!d){const g=[da.bind(this),void 0];for(g.unshift(...c),g.push(...f),m=g.length,u=Promise.resolve(n);p<m;)u=u.then(g[p++],g[p++]);return u}m=c.length;let v=n;for(;p<m;){const g=c[p++],h=c[p++];try{v=g(v)}catch(b){h.call(this,b);break}}try{u=da.call(this,v)}catch(g){return Promise.reject(g)}for(p=0,m=f.length;p<m;)u=u.then(f[p++],f[p++]);return u}getUri(t){t=Et(this.defaults,t);const n=Qs(t.baseURL,t.url,t.allowAbsoluteUrls);return js(n,t.params,t.paramsSerializer)}};S.forEach(["delete","get","head","options"],function(t){Nt.prototype[t]=function(n,r){return this.request(Et(r||{},{method:t,url:n,data:(r||{}).data}))}}),S.forEach(["post","put","patch"],function(t){function n(r){return function(s,a,c){return this.request(Et(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}Nt.prototype[t]=n(),Nt.prototype[t+"Form"]=n(!0)});let Nf=class eu{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const a=new Promise(c=>{r.subscribe(c),s=c}).then(o);return a.cancel=function(){r.unsubscribe(s)},a},t(function(s,a,c){r.reason||(r.reason=new Ft(s,a,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new eu(function(o){t=o}),cancel:t}}};function Tf(e){return function(n){return e.apply(null,n)}}function Af(e){return S.isObject(e)&&e.isAxiosError===!0}const eo={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(eo).forEach(([e,t])=>{eo[t]=e});function pa(e){const t=new Nt(e),n=ks(Nt.prototype.request,t);return S.extend(n,Nt.prototype,t,{allOwnKeys:!0}),S.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return pa(Et(e,o))},n}const Ce=pa(tn);Ce.Axios=Nt,Ce.CanceledError=Ft,Ce.CancelToken=Nf,Ce.isCancel=Xs,Ce.VERSION=ua,Ce.toFormData=Pn,Ce.AxiosError=ce,Ce.Cancel=Ce.CanceledError,Ce.all=function(t){return Promise.all(t)},Ce.spread=Tf,Ce.isAxiosError=Af,Ce.mergeConfig=Et,Ce.AxiosHeaders=De,Ce.formToJSON=e=>Gs(S.isHTMLForm(e)?new FormData(e):e),Ce.getAdapter=la.getAdapter,Ce.HttpStatusCode=eo,Ce.default=Ce;const{Axios:Vw,AxiosError:jw,CanceledError:Rw,isCancel:Kw,CancelToken:Gw,VERSION:qw,all:Xw,Cancel:Yw,isAxiosError:Jw,spread:Zw,toFormData:Qw,AxiosHeaders:ey,HttpStatusCode:ty,formToJSON:ny,getAdapter:ry,mergeConfig:oy}=Ce,to={};function rn(){var e;try{return typeof window<"u"&&((e=window.localStorage)==null?void 0:e.getItem("chat-debug"))==="1"}catch{return!1}}const ha=to==null?void 0:to.VITE_API_BASE_URL,ga=ha?ha.replace(/\/+$/,""):void 0;!ga&&typeof window<"u"&&console.warn("VITE_API_BASE_URL is not set. The API client will need to be configured via apiConfig prop.");let $n=null;const no=new Set;function ro(){return $n}function oo(e){$n=e,no.forEach(t=>t(e))}function ma(e){return no.add(e),()=>no.delete(e)}const rt=Ce.create({baseURL:ga||"http://localhost:8000",timeout:3e4,withCredentials:!0});rt.interceptors.request.use(e=>($n&&(e.headers.Authorization=`Bearer ${$n}`),e)),rt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function Tt(e,t){return(await rt.get(e,t)).data}async function so(e,t,n){return(await rt.post(e,t,n)).data}async function ba(e,t,n){return(await rt.put(e,t,n)).data}async function va(e,t){return(await rt.delete(e,t)).data}async function If(e,t){var m;if(rn()){let v=t.body;try{const g=JSON.parse(JSON.stringify(t.body));(m=g==null?void 0:g.payload)!=null&&m.files_info&&Array.isArray(g.payload.files_info)&&(g.payload.files_info=g.payload.files_info.map(h=>({...h,data:h!=null&&h.data?`<base64 ${String(h.data).length} chars>`:h==null?void 0:h.data}))),v=g}catch{}console.debug("[api.stream]",t.method,`${rt.defaults.baseURL}${e}`,v)}const r=(rt.defaults.baseURL||"").replace(/\/+$|^\s+|\s+$/g,""),o=t.method??"POST",s=ro(),a=t.headers??{},c=e?e.startsWith("/")?e:`/${e}`:"",d=r?`${r}${c}`:c||r,f=await fetch(d,{method:o,headers:{"Content-Type":"application/json",...s?{Authorization:`Bearer ${s}`}:{},...a},body:t.body!==void 0?JSON.stringify(t.body):void 0,credentials:"include",signal:t.signal});if(!f.ok||!f.body){const v=await f.text().catch(()=>"");throw rn()&&console.debug("[api.stream] non-OK",f.status,v==null?void 0:v.slice(0,500)),new Error(`Stream failed: ${f.status} ${f.statusText}${v?": "+v:""}`)}const u=f.body.getReader(),p=new TextDecoder;for(;;){const{done:v,value:g}=await u.read();if(v)break;const h=p.decode(g,{stream:!0});rn()&&console.debug("[api.stream] chunk",h.slice(0,200)),t.onChunk(h)}}function ot(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Bn{get baseUrl(){const t=rt.defaults.baseURL||"";return String(t).replace(/\/+$|^\s+|\s+$/g,"")}updateConfig(t){t.baseUrl&&(rt.defaults.baseURL=String(t.baseUrl).replace(/\/+$/g,"")),t.authToken!==void 0&&oo(t.authToken)}getAuthToken(){return ro()}setAuthToken(t){oo(t)}onTokenChange(t){return ma(t)}async listThreads(){const t=await Tt("/chat/threads"),n=ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await so("/chat/threads",t?{title:t}:void 0);return ot(r)}async updateThread(t,n){const r=await ba(`/chat/threads/${t}`,{title:n});return ot(r)}async deleteThread(t){const n=await va(`/chat/threads/${t}`);return ot(n)}async threadInfo(t){const n=await Tt(`/chat/threads/${t}/info`);return ot(n)}async getMessages(t){const n=await Tt("/chat/messages",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs,limit:t.limit,before_id:t.beforeId??void 0}});return ot(n)}async getState(t){const n=await Tt("/chat/state",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return ot(n)}async getStateHistory(t){const n=await Tt("/chat/state/history",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return ot(n)}async listCheckpoints(t){const n=await Tt("/chat/checkpoints",{params:{thread_id:t}});return ot(n)}async uploadImage(t,n="/upload"){const r=new FormData;r.append("file",t,t.name),rn()&&console.debug("[api.uploadImage] ->",n,{name:t.name,type:t.type,size:t.size});const o=await so(n,r,{headers:{Accept:"application/json"},maxBodyLength:1/0}),s=ot(o);if(rn()&&console.debug("[api.uploadImage] <-",s),!(s!=null&&s.url))throw new Error("Invalid upload response: missing url");return{url:s.url,mimeType:s.mimeType??t.type,name:s.name??t.name,size:s.size??t.size}}}const ut=new Bn;function wa(e={}){const t=e.baseUrl??"/api/chat",n=e.streamPath??"/stream",[r,o]=N.useState(e.token??null),s=N.useRef(e.headers??{}),[a,c]=N.useState(!1),[d,f]=N.useState(null),[u,p]=N.useState(""),[m,v]=N.useState(null),g=N.useRef(null),h=N.useCallback(x=>{o(x)},[]),b=N.useCallback(()=>{var x;(x=g.current)==null||x.abort(),g.current=null,c(!1)},[]),w=N.useCallback(()=>{p(""),v(null),f(null)},[]),y=N.useCallback((x,C,E)=>{g.current&&(g.current.abort(),g.current=null),c(!0),f(null),e.autoAppendAssistant!==!1&&p("");const P=new AbortController;return g.current=P,(async()=>{var M,B,V,J;const T=(()=>{var H;try{return typeof window<"u"&&((H=window.localStorage)==null?void 0:H.getItem("chat-debug"))==="1"}catch{return!1}})(),F=H=>{var O;try{const ne=JSON.parse(JSON.stringify(H));return(O=ne==null?void 0:ne.payload)!=null&&O.files_info&&Array.isArray(ne.payload.files_info)&&(ne.payload.files_info=ne.payload.files_info.map(L=>({...L,data:L!=null&&L.data?`<base64 ${String(L.data).length} chars>`:L==null?void 0:L.data}))),ne}catch{return H}};try{let H={};try{if(r)H={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const I=window.__AUTH_TOKEN__,Z=((M=window.localStorage)==null?void 0:M.getItem("authToken"))||null;let j=null;try{const D=(B=window.localStorage)==null?void 0:B.getItem("chat-settings");D&&(j=((V=JSON.parse(D))==null?void 0:V.apiKey)||null)}catch{}const te=I||Z||j||null;te&&(H={Authorization:`Bearer ${te}`})}}catch{}T&&console.debug("[use-chat] POST",t+n,F(x));const O=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...H,...s.current},body:JSON.stringify(x),signal:P.signal});if(!O.ok||!O.body){const k=await O.text().catch(()=>"");throw T&&console.debug("[use-chat] non-OK response",O.status,k==null?void 0:k.slice(0,500)),new Error(`stream ${O.status}${k?": "+k:""}`)}const ne=O.body.getReader(),L=new TextDecoder;let z="";for(;;){const{value:k,done:I}=await ne.read();if(I)break;z+=L.decode(k,{stream:!0});let Z;for(;(Z=z.indexOf(`
1
+ (function(ee,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react/jsx-runtime"),require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom"),require("react-markdown"),require("remark-gfm")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","react-markdown","remark-gfm"],i):(ee=typeof globalThis<"u"?globalThis:ee||self,i(ee.NewChatUI={},ee.jsxRuntime,ee.React,ee.LucideReact,ee.reactSlot,ee.classVarianceAuthority,ee.clsx,ee.tailwindMerge,ee.ReactDOM,ee.ReactMarkdown,ee.remarkGfm))})(this,function(ee,i,A,X,Se,Dt,Od,Md,es,kd,Dd){"use strict";var vn=typeof document<"u"?document.currentScript:null;function ts(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const l=ts(A),ar=ts(es);function rs(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ld}=Object.prototype,{getPrototypeOf:wn}=Object,{iterator:ir,toStringTag:ns}=Symbol,cr=(e=>t=>{const r=Ld.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Ie=e=>(e=e.toLowerCase(),t=>cr(t)===e),lr=e=>t=>typeof t===e,{isArray:bt}=Array,vt=lr("undefined");function Lt(e){return e!==null&&!vt(e)&&e.constructor!==null&&!vt(e.constructor)&&we(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const os=Ie("ArrayBuffer");function Fd(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&os(e.buffer),t}const $d=lr("string"),we=lr("function"),ss=lr("number"),Ft=e=>e!==null&&typeof e=="object",Bd=e=>e===!0||e===!1,dr=e=>{if(cr(e)!=="object")return!1;const t=wn(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ns in e)&&!(ir in e)},Ud=e=>{if(!Ft(e)||Lt(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Hd=Ie("Date"),zd=Ie("File"),Wd=Ie("Blob"),Rd=Ie("FileList"),Vd=e=>Ft(e)&&we(e.pipe),jd=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||we(e.append)&&((t=cr(e))==="formdata"||t==="object"&&we(e.toString)&&e.toString()==="[object FormData]"))},Kd=Ie("URLSearchParams"),[Gd,qd,Xd,Yd]=["ReadableStream","Request","Response","Headers"].map(Ie),Jd=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function $t(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),bt(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{if(Lt(e))return;const s=r?Object.getOwnPropertyNames(e):Object.keys(e),a=s.length;let c;for(n=0;n<a;n++)c=s[n],t.call(null,e[c],c,e)}}function as(e,t){if(Lt(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n=r.length,o;for(;n-- >0;)if(o=r[n],t===o.toLowerCase())return o;return null}const st=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,is=e=>!vt(e)&&e!==st;function yn(){const{caseless:e,skipUndefined:t}=is(this)&&this||{},r={},n=(o,s)=>{const a=e&&as(r,s)||s;dr(r[a])&&dr(o)?r[a]=yn(r[a],o):dr(o)?r[a]=yn({},o):bt(o)?r[a]=o.slice():(!t||!vt(o))&&(r[a]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&$t(arguments[o],n);return r}const Zd=(e,t,r,{allOwnKeys:n}={})=>($t(t,(o,s)=>{r&&we(o)?e[s]=rs(o,r):e[s]=o},{allOwnKeys:n}),e),Qd=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),eu=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},tu=(e,t,r,n)=>{let o,s,a;const c={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)a=o[s],(!n||n(a,e,t))&&!c[a]&&(t[a]=e[a],c[a]=!0);e=r!==!1&&wn(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},ru=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},nu=e=>{if(!e)return null;if(bt(e))return e;let t=e.length;if(!ss(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},ou=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&wn(Uint8Array)),su=(e,t)=>{const n=(e&&e[ir]).call(e);let o;for(;(o=n.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},au=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},iu=Ie("HTMLFormElement"),cu=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),cs=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),lu=Ie("RegExp"),ls=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};$t(r,(o,s)=>{let a;(a=t(o,s,e))!==!1&&(n[s]=a||o)}),Object.defineProperties(e,n)},du=e=>{ls(e,(t,r)=>{if(we(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(we(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},uu=(e,t)=>{const r={},n=o=>{o.forEach(s=>{r[s]=!0})};return bt(e)?n(e):n(String(e).split(t)),r},fu=()=>{},pu=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function hu(e){return!!(e&&we(e.append)&&e[ns]==="FormData"&&e[ir])}const gu=e=>{const t=new Array(10),r=(n,o)=>{if(Ft(n)){if(t.indexOf(n)>=0)return;if(Lt(n))return n;if(!("toJSON"in n)){t[o]=n;const s=bt(n)?[]:{};return $t(n,(a,c)=>{const d=r(a,o+1);!vt(d)&&(s[c]=d)}),t[o]=void 0,s}}return n};return r(e,0)},mu=Ie("AsyncFunction"),bu=e=>e&&(Ft(e)||we(e))&&we(e.then)&&we(e.catch),ds=((e,t)=>e?setImmediate:t?((r,n)=>(st.addEventListener("message",({source:o,data:s})=>{o===st&&s===r&&n.length&&n.shift()()},!1),o=>{n.push(o),st.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",we(st.postMessage)),vu=typeof queueMicrotask<"u"?queueMicrotask.bind(st):typeof process<"u"&&process.nextTick||ds,S={isArray:bt,isArrayBuffer:os,isBuffer:Lt,isFormData:jd,isArrayBufferView:Fd,isString:$d,isNumber:ss,isBoolean:Bd,isObject:Ft,isPlainObject:dr,isEmptyObject:Ud,isReadableStream:Gd,isRequest:qd,isResponse:Xd,isHeaders:Yd,isUndefined:vt,isDate:Hd,isFile:zd,isBlob:Wd,isRegExp:lu,isFunction:we,isStream:Vd,isURLSearchParams:Kd,isTypedArray:ou,isFileList:Rd,forEach:$t,merge:yn,extend:Zd,trim:Jd,stripBOM:Qd,inherits:eu,toFlatObject:tu,kindOf:cr,kindOfTest:Ie,endsWith:ru,toArray:nu,forEachEntry:su,matchAll:au,isHTMLForm:iu,hasOwnProperty:cs,hasOwnProp:cs,reduceDescriptors:ls,freezeMethods:du,toObjectSet:uu,toCamelCase:cu,noop:fu,toFiniteNumber:pu,findKey:as,global:st,isContextDefined:is,isSpecCompliantForm:hu,toJSONObject:gu,isAsyncFn:mu,isThenable:bu,setImmediate:ds,asap:vu,isIterable:e=>e!=null&&we(e[ir])};function te(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o,this.status=o.status?o.status:null)}S.inherits(te,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:S.toJSONObject(this.config),code:this.code,status:this.status}}});const us=te.prototype,fs={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{fs[e]={value:e}}),Object.defineProperties(te,fs),Object.defineProperty(us,"isAxiosError",{value:!0}),te.from=(e,t,r,n,o,s)=>{const a=Object.create(us);S.toFlatObject(e,a,function(u){return u!==Error.prototype},f=>f!=="isAxiosError");const c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return te.call(a,c,d,r,n,o),e&&a.cause==null&&Object.defineProperty(a,"cause",{value:e,configurable:!0}),a.name=e&&e.name||"Error",s&&Object.assign(a,s),a};const wu=null;function xn(e){return S.isPlainObject(e)||S.isArray(e)}function ps(e){return S.endsWith(e,"[]")?e.slice(0,-2):e}function hs(e,t,r){return e?e.concat(t).map(function(o,s){return o=ps(o),!r&&s?"["+o+"]":o}).join(r?".":""):t}function yu(e){return S.isArray(e)&&!e.some(xn)}const xu=S.toFlatObject(S,{},null,function(t){return/^is[A-Z]/.test(t)});function ur(e,t,r){if(!S.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=S.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,b){return!S.isUndefined(b[h])});const n=r.metaTokens,o=r.visitor||u,s=r.dots,a=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&S.isSpecCompliantForm(t);if(!S.isFunction(o))throw new TypeError("visitor must be a function");function f(g){if(g===null)return"";if(S.isDate(g))return g.toISOString();if(S.isBoolean(g))return g.toString();if(!d&&S.isBlob(g))throw new te("Blob is not supported. Use a Buffer instead.");return S.isArrayBuffer(g)||S.isTypedArray(g)?d&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function u(g,h,b){let w=g;if(g&&!b&&typeof g=="object"){if(S.endsWith(h,"{}"))h=n?h:h.slice(0,-2),g=JSON.stringify(g);else if(S.isArray(g)&&yu(g)||(S.isFileList(g)||S.endsWith(h,"[]"))&&(w=S.toArray(g)))return h=ps(h),w.forEach(function(x,C){!(S.isUndefined(x)||x===null)&&t.append(a===!0?hs([h],C,s):a===null?h:h+"[]",f(x))}),!1}return xn(g)?!0:(t.append(hs(b,h,s),f(g)),!1)}const p=[],m=Object.assign(xu,{defaultVisitor:u,convertValue:f,isVisitable:xn});function v(g,h){if(!S.isUndefined(g)){if(p.indexOf(g)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(g),S.forEach(g,function(w,y){(!(S.isUndefined(w)||w===null)&&o.call(t,w,S.isString(y)?y.trim():y,h,m))===!0&&v(w,h?h.concat(y):[y])}),p.pop()}}if(!S.isObject(e))throw new TypeError("data must be an object");return v(e),t}function gs(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Sn(e,t){this._pairs=[],e&&ur(e,this,t)}const ms=Sn.prototype;ms.append=function(t,r){this._pairs.push([t,r])},ms.toString=function(t){const r=t?function(n){return t.call(this,n,gs)}:gs;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};function Su(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function bs(e,t,r){if(!t)return e;const n=r&&r.encode||Su;S.isFunction(r)&&(r={serialize:r});const o=r&&r.serialize;let s;if(o?s=o(t,r):s=S.isURLSearchParams(t)?t.toString():new Sn(t,r).toString(n),s){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class vs{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){S.forEach(this.handlers,function(n){n!==null&&t(n)})}}const ws={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Cu={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Sn,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Cn=typeof window<"u"&&typeof document<"u",En=typeof navigator=="object"&&navigator||void 0,Eu=Cn&&(!En||["ReactNative","NativeScript","NS"].indexOf(En.product)<0),Nu=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Tu=Cn&&window.location.href||"http://localhost",be={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Cn,hasStandardBrowserEnv:Eu,hasStandardBrowserWebWorkerEnv:Nu,navigator:En,origin:Tu},Symbol.toStringTag,{value:"Module"})),...Cu};function Au(e,t){return ur(e,new be.classes.URLSearchParams,{visitor:function(r,n,o,s){return be.isNode&&S.isBuffer(r)?(this.append(n,r.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Pu(e){return S.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function _u(e){const t={},r=Object.keys(e);let n;const o=r.length;let s;for(n=0;n<o;n++)s=r[n],t[s]=e[s];return t}function ys(e){function t(r,n,o,s){let a=r[s++];if(a==="__proto__")return!0;const c=Number.isFinite(+a),d=s>=r.length;return a=!a&&S.isArray(o)?o.length:a,d?(S.hasOwnProp(o,a)?o[a]=[o[a],n]:o[a]=n,!c):((!o[a]||!S.isObject(o[a]))&&(o[a]=[]),t(r,n,o[a],s)&&S.isArray(o[a])&&(o[a]=_u(o[a])),!c)}if(S.isFormData(e)&&S.isFunction(e.entries)){const r={};return S.forEachEntry(e,(n,o)=>{t(Pu(n),o,r,0)}),r}return null}function Iu(e,t,r){if(S.isString(e))try{return(t||JSON.parse)(e),S.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const Bt={transitional:ws,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",o=n.indexOf("application/json")>-1,s=S.isObject(t);if(s&&S.isHTMLForm(t)&&(t=new FormData(t)),S.isFormData(t))return o?JSON.stringify(ys(t)):t;if(S.isArrayBuffer(t)||S.isBuffer(t)||S.isStream(t)||S.isFile(t)||S.isBlob(t)||S.isReadableStream(t))return t;if(S.isArrayBufferView(t))return t.buffer;if(S.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Au(t,this.formSerializer).toString();if((c=S.isFileList(t))||n.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return ur(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return s||o?(r.setContentType("application/json",!1),Iu(t)):t}],transformResponse:[function(t){const r=this.transitional||Bt.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(S.isResponse(t)||S.isReadableStream(t))return t;if(t&&S.isString(t)&&(n&&!this.responseType||o)){const a=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(c){if(a)throw c.name==="SyntaxError"?te.from(c,te.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:be.classes.FormData,Blob:be.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};S.forEach(["delete","get","head","post","put","patch"],e=>{Bt.headers[e]={}});const Ou=S.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Mu=e=>{const t={};let r,n,o;return e&&e.split(`
2
+ `).forEach(function(a){o=a.indexOf(":"),r=a.substring(0,o).trim().toLowerCase(),n=a.substring(o+1).trim(),!(!r||t[r]&&Ou[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},xs=Symbol("internals");function Ut(e){return e&&String(e).trim().toLowerCase()}function fr(e){return e===!1||e==null?e:S.isArray(e)?e.map(fr):String(e)}function ku(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const Du=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Nn(e,t,r,n,o){if(S.isFunction(n))return n.call(this,t,r);if(o&&(t=r),!!S.isString(t)){if(S.isString(n))return t.indexOf(n)!==-1;if(S.isRegExp(n))return n.test(t)}}function Lu(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function Fu(e,t){const r=S.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(o,s,a){return this[n].call(this,t,o,s,a)},configurable:!0})})}let ye=class{constructor(t){t&&this.set(t)}set(t,r,n){const o=this;function s(c,d,f){const u=Ut(d);if(!u)throw new Error("header name must be a non-empty string");const p=S.findKey(o,u);(!p||o[p]===void 0||f===!0||f===void 0&&o[p]!==!1)&&(o[p||d]=fr(c))}const a=(c,d)=>S.forEach(c,(f,u)=>s(f,u,d));if(S.isPlainObject(t)||t instanceof this.constructor)a(t,r);else if(S.isString(t)&&(t=t.trim())&&!Du(t))a(Mu(t),r);else if(S.isObject(t)&&S.isIterable(t)){let c={},d,f;for(const u of t){if(!S.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[f=u[0]]=(d=c[f])?S.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}a(c,r)}else t!=null&&s(r,t,n);return this}get(t,r){if(t=Ut(t),t){const n=S.findKey(this,t);if(n){const o=this[n];if(!r)return o;if(r===!0)return ku(o);if(S.isFunction(r))return r.call(this,o,n);if(S.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=Ut(t),t){const n=S.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||Nn(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let o=!1;function s(a){if(a=Ut(a),a){const c=S.findKey(n,a);c&&(!r||Nn(n,n[c],c,r))&&(delete n[c],o=!0)}}return S.isArray(t)?t.forEach(s):s(t),o}clear(t){const r=Object.keys(this);let n=r.length,o=!1;for(;n--;){const s=r[n];(!t||Nn(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const r=this,n={};return S.forEach(this,(o,s)=>{const a=S.findKey(n,s);if(a){r[a]=fr(o),delete r[s];return}const c=t?Lu(s):String(s).trim();c!==s&&delete r[s],r[c]=fr(o),n[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return S.forEach(this,(n,o)=>{n!=null&&n!==!1&&(r[o]=t&&S.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
3
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){const n=(this[xs]=this[xs]={accessors:{}}).accessors,o=this.prototype;function s(a){const c=Ut(a);n[c]||(Fu(o,a),n[c]=!0)}return S.isArray(t)?t.forEach(s):s(t),this}};ye.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),S.reduceDescriptors(ye.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),S.freezeMethods(ye);function Tn(e,t){const r=this||Bt,n=t||r,o=ye.from(n.headers);let s=n.data;return S.forEach(e,function(c){s=c.call(r,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Ss(e){return!!(e&&e.__CANCEL__)}function wt(e,t,r){te.call(this,e??"canceled",te.ERR_CANCELED,t,r),this.name="CanceledError"}S.inherits(wt,te,{__CANCEL__:!0});function Cs(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new te("Request failed with status code "+r.status,[te.ERR_BAD_REQUEST,te.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function $u(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Bu(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o=0,s=0,a;return t=t!==void 0?t:1e3,function(d){const f=Date.now(),u=n[s];a||(a=f),r[o]=d,n[o]=f;let p=s,m=0;for(;p!==o;)m+=r[p++],p=p%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),f-a<t)return;const v=u&&f-u;return v?Math.round(m*1e3/v):void 0}}function Uu(e,t){let r=0,n=1e3/t,o,s;const a=(f,u=Date.now())=>{r=u,o=null,s&&(clearTimeout(s),s=null),e(...f)};return[(...f)=>{const u=Date.now(),p=u-r;p>=n?a(f,u):(o=f,s||(s=setTimeout(()=>{s=null,a(o)},n-p)))},()=>o&&a(o)]}const pr=(e,t,r=3)=>{let n=0;const o=Bu(50,250);return Uu(s=>{const a=s.loaded,c=s.lengthComputable?s.total:void 0,d=a-n,f=o(d),u=a<=c;n=a;const p={loaded:a,total:c,progress:c?a/c:void 0,bytes:d,rate:f||void 0,estimated:f&&c&&u?(c-a)/f:void 0,event:s,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(p)},r)},Es=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},Ns=e=>(...t)=>S.asap(()=>e(...t)),Hu=be.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,be.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(be.origin),be.navigator&&/(msie|trident)/i.test(be.navigator.userAgent)):()=>!0,zu=be.hasStandardBrowserEnv?{write(e,t,r,n,o,s){const a=[e+"="+encodeURIComponent(t)];S.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),S.isString(n)&&a.push("path="+n),S.isString(o)&&a.push("domain="+o),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Wu(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Ru(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Ts(e,t,r){let n=!Wu(t);return e&&(n||r==!1)?Ru(e,t):t}const As=e=>e instanceof ye?{...e}:e;function at(e,t){t=t||{};const r={};function n(f,u,p,m){return S.isPlainObject(f)&&S.isPlainObject(u)?S.merge.call({caseless:m},f,u):S.isPlainObject(u)?S.merge({},u):S.isArray(u)?u.slice():u}function o(f,u,p,m){if(S.isUndefined(u)){if(!S.isUndefined(f))return n(void 0,f,p,m)}else return n(f,u,p,m)}function s(f,u){if(!S.isUndefined(u))return n(void 0,u)}function a(f,u){if(S.isUndefined(u)){if(!S.isUndefined(f))return n(void 0,f)}else return n(void 0,u)}function c(f,u,p){if(p in t)return n(f,u);if(p in e)return n(void 0,f)}const d={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c,headers:(f,u,p)=>o(As(f),As(u),p,!0)};return S.forEach(Object.keys({...e,...t}),function(u){const p=d[u]||o,m=p(e[u],t[u],u);S.isUndefined(m)&&p!==c||(r[u]=m)}),r}const Ps=e=>{const t=at({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:s,headers:a,auth:c}=t;if(t.headers=a=ye.from(a),t.url=bs(Ts(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),S.isFormData(r)){if(be.hasStandardBrowserEnv||be.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(S.isFunction(r.getHeaders)){const d=r.getHeaders(),f=["content-type","content-length"];Object.entries(d).forEach(([u,p])=>{f.includes(u.toLowerCase())&&a.set(u,p)})}}if(be.hasStandardBrowserEnv&&(n&&S.isFunction(n)&&(n=n(t)),n||n!==!1&&Hu(t.url))){const d=o&&s&&zu.read(s);d&&a.set(o,d)}return t},Vu=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const o=Ps(e);let s=o.data;const a=ye.from(o.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:f}=o,u,p,m,v,g;function h(){v&&v(),g&&g(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let b=new XMLHttpRequest;b.open(o.method.toUpperCase(),o.url,!0),b.timeout=o.timeout;function w(){if(!b)return;const x=ye.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),E={data:!c||c==="text"||c==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:x,config:e,request:b};Cs(function(N){r(N),h()},function(N){n(N),h()},E),b=null}"onloadend"in b?b.onloadend=w:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(w)},b.onabort=function(){b&&(n(new te("Request aborted",te.ECONNABORTED,e,b)),b=null)},b.onerror=function(C){const E=C&&C.message?C.message:"Network Error",O=new te(E,te.ERR_NETWORK,e,b);O.event=C||null,n(O),b=null},b.ontimeout=function(){let C=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const E=o.transitional||ws;o.timeoutErrorMessage&&(C=o.timeoutErrorMessage),n(new te(C,E.clarifyTimeoutError?te.ETIMEDOUT:te.ECONNABORTED,e,b)),b=null},s===void 0&&a.setContentType(null),"setRequestHeader"in b&&S.forEach(a.toJSON(),function(C,E){b.setRequestHeader(E,C)}),S.isUndefined(o.withCredentials)||(b.withCredentials=!!o.withCredentials),c&&c!=="json"&&(b.responseType=o.responseType),f&&([m,g]=pr(f,!0),b.addEventListener("progress",m)),d&&b.upload&&([p,v]=pr(d),b.upload.addEventListener("progress",p),b.upload.addEventListener("loadend",v)),(o.cancelToken||o.signal)&&(u=x=>{b&&(n(!x||x.type?new wt(null,e,b):x),b.abort(),b=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const y=$u(o.url);if(y&&be.protocols.indexOf(y)===-1){n(new te("Unsupported protocol "+y+":",te.ERR_BAD_REQUEST,e));return}b.send(s||null)})},ju=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,o;const s=function(f){if(!o){o=!0,c();const u=f instanceof Error?f:this.reason;n.abort(u instanceof te?u:new wt(u instanceof Error?u.message:u))}};let a=t&&setTimeout(()=>{a=null,s(new te(`timeout ${t} of ms exceeded`,te.ETIMEDOUT))},t);const c=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(f=>{f.unsubscribe?f.unsubscribe(s):f.removeEventListener("abort",s)}),e=null)};e.forEach(f=>f.addEventListener("abort",s));const{signal:d}=n;return d.unsubscribe=()=>S.asap(c),d}},Ku=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,o;for(;n<r;)o=n+t,yield e.slice(n,o),n=o},Gu=async function*(e,t){for await(const r of qu(e))yield*Ku(r,t)},qu=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},_s=(e,t,r,n)=>{const o=Gu(e,t);let s=0,a,c=d=>{a||(a=!0,n&&n(d))};return new ReadableStream({async pull(d){try{const{done:f,value:u}=await o.next();if(f){c(),d.close();return}let p=u.byteLength;if(r){let m=s+=p;r(m)}d.enqueue(new Uint8Array(u))}catch(f){throw c(f),f}},cancel(d){return c(d),o.return()}},{highWaterMark:2})},Is=64*1024,{isFunction:hr}=S,Xu=(({Request:e,Response:t})=>({Request:e,Response:t}))(S.global),{ReadableStream:Os,TextEncoder:Ms}=S.global,ks=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Yu=e=>{e=S.merge.call({skipUndefined:!0},Xu,e);const{fetch:t,Request:r,Response:n}=e,o=t?hr(t):typeof fetch=="function",s=hr(r),a=hr(n);if(!o)return!1;const c=o&&hr(Os),d=o&&(typeof Ms=="function"?(g=>h=>g.encode(h))(new Ms):async g=>new Uint8Array(await new r(g).arrayBuffer())),f=s&&c&&ks(()=>{let g=!1;const h=new r(be.origin,{body:new Os,method:"POST",get duplex(){return g=!0,"half"}}).headers.has("Content-Type");return g&&!h}),u=a&&c&&ks(()=>S.isReadableStream(new n("").body)),p={stream:u&&(g=>g.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(g=>{!p[g]&&(p[g]=(h,b)=>{let w=h&&h[g];if(w)return w.call(h);throw new te(`Response type '${g}' is not supported`,te.ERR_NOT_SUPPORT,b)})});const m=async g=>{if(g==null)return 0;if(S.isBlob(g))return g.size;if(S.isSpecCompliantForm(g))return(await new r(be.origin,{method:"POST",body:g}).arrayBuffer()).byteLength;if(S.isArrayBufferView(g)||S.isArrayBuffer(g))return g.byteLength;if(S.isURLSearchParams(g)&&(g=g+""),S.isString(g))return(await d(g)).byteLength},v=async(g,h)=>{const b=S.toFiniteNumber(g.getContentLength());return b??m(h)};return async g=>{let{url:h,method:b,data:w,signal:y,cancelToken:x,timeout:C,onDownloadProgress:E,onUploadProgress:O,responseType:N,headers:F,withCredentials:B="same-origin",fetchOptions:_}=Ps(g),U=t||fetch;N=N?(N+"").toLowerCase():"text";let G=ju([y,x&&x.toAbortSignal()],C),L=null;const $=G&&G.unsubscribe&&(()=>{G.unsubscribe()});let q;try{if(O&&f&&b!=="get"&&b!=="head"&&(q=await v(F,w))!==0){let Q=new r(h,{method:"POST",body:w,duplex:"half"}),re;if(S.isFormData(w)&&(re=Q.headers.get("content-type"))&&F.setContentType(re),Q.body){const[H,R]=Es(q,pr(Ns(O)));w=_s(Q.body,Is,H,R)}}S.isString(B)||(B=B?"include":"omit");const k=s&&"credentials"in r.prototype,V={..._,signal:G,method:b.toUpperCase(),headers:F.normalize().toJSON(),body:w,duplex:"half",credentials:k?B:void 0};L=s&&new r(h,V);let D=await(s?U(L,_):U(h,V));const I=u&&(N==="stream"||N==="response");if(u&&(E||I&&$)){const Q={};["status","statusText","headers"].forEach(ue=>{Q[ue]=D[ue]});const re=S.toFiniteNumber(D.headers.get("content-length")),[H,R]=E&&Es(re,pr(Ns(E),!0))||[];D=new n(_s(D.body,Is,H,()=>{R&&R(),$&&$()}),Q)}N=N||"text";let J=await p[S.findKey(p,N)||"text"](D,g);return!I&&$&&$(),await new Promise((Q,re)=>{Cs(Q,re,{data:J,headers:ye.from(D.headers),status:D.status,statusText:D.statusText,config:g,request:L})})}catch(k){throw $&&$(),k&&k.name==="TypeError"&&/Load failed|fetch/i.test(k.message)?Object.assign(new te("Network Error",te.ERR_NETWORK,g,L),{cause:k.cause||k}):te.from(k,k&&k.code,g,L)}}},Ju=new Map,Ds=e=>{let t=e?e.env:{};const{fetch:r,Request:n,Response:o}=t,s=[n,o,r];let a=s.length,c=a,d,f,u=Ju;for(;c--;)d=s[c],f=u.get(d),f===void 0&&u.set(d,f=c?new Map:Yu(t)),u=f;return f};Ds();const An={http:wu,xhr:Vu,fetch:{get:Ds}};S.forEach(An,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Ls=e=>`- ${e}`,Zu=e=>S.isFunction(e)||e===null||e===!1,Fs={getAdapter:(e,t)=>{e=S.isArray(e)?e:[e];const{length:r}=e;let n,o;const s={};for(let a=0;a<r;a++){n=e[a];let c;if(o=n,!Zu(n)&&(o=An[(c=String(n)).toLowerCase()],o===void 0))throw new te(`Unknown adapter '${c}'`);if(o&&(S.isFunction(o)||(o=o.get(t))))break;s[c||"#"+a]=o}if(!o){const a=Object.entries(s).map(([d,f])=>`adapter ${d} `+(f===!1?"is not supported by the environment":"is not available in the build"));let c=r?a.length>1?`since :
4
+ `+a.map(Ls).join(`
5
+ `):" "+Ls(a[0]):"as no adapter specified";throw new te("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return o},adapters:An};function Pn(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new wt(null,e)}function $s(e){return Pn(e),e.headers=ye.from(e.headers),e.data=Tn.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Fs.getAdapter(e.adapter||Bt.adapter,e)(e).then(function(n){return Pn(e),n.data=Tn.call(e,e.transformResponse,n),n.headers=ye.from(n.headers),n},function(n){return Ss(n)||(Pn(e),n&&n.response&&(n.response.data=Tn.call(e,e.transformResponse,n.response),n.response.headers=ye.from(n.response.headers))),Promise.reject(n)})}const Bs="1.12.2",gr={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{gr[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const Us={};gr.transitional=function(t,r,n){function o(s,a){return"[Axios v"+Bs+"] Transitional option '"+s+"'"+a+(n?". "+n:"")}return(s,a,c)=>{if(t===!1)throw new te(o(a," has been removed"+(r?" in "+r:"")),te.ERR_DEPRECATED);return r&&!Us[a]&&(Us[a]=!0,console.warn(o(a," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(s,a,c):!0}},gr.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function Qu(e,t,r){if(typeof e!="object")throw new te("options must be an object",te.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const s=n[o],a=t[s];if(a){const c=e[s],d=c===void 0||a(c,s,e);if(d!==!0)throw new te("option "+s+" must be "+d,te.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new te("Unknown option "+s,te.ERR_BAD_OPTION)}}const mr={assertOptions:Qu,validators:gr},$e=mr.validators;let it=class{constructor(t){this.defaults=t||{},this.interceptors={request:new vs,response:new vs}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
6
+ `+s):n.stack=s}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=at(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&mr.assertOptions(n,{silentJSONParsing:$e.transitional($e.boolean),forcedJSONParsing:$e.transitional($e.boolean),clarifyTimeoutError:$e.transitional($e.boolean)},!1),o!=null&&(S.isFunction(o)?r.paramsSerializer={serialize:o}:mr.assertOptions(o,{encode:$e.function,serialize:$e.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),mr.assertOptions(r,{baseUrl:$e.spelling("baseURL"),withXsrfToken:$e.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let a=s&&S.merge(s.common,s[r.method]);s&&S.forEach(["delete","get","head","post","put","patch","common"],g=>{delete s[g]}),r.headers=ye.concat(a,s);const c=[];let d=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(r)===!1||(d=d&&h.synchronous,c.unshift(h.fulfilled,h.rejected))});const f=[];this.interceptors.response.forEach(function(h){f.push(h.fulfilled,h.rejected)});let u,p=0,m;if(!d){const g=[$s.bind(this),void 0];for(g.unshift(...c),g.push(...f),m=g.length,u=Promise.resolve(r);p<m;)u=u.then(g[p++],g[p++]);return u}m=c.length;let v=r;for(;p<m;){const g=c[p++],h=c[p++];try{v=g(v)}catch(b){h.call(this,b);break}}try{u=$s.call(this,v)}catch(g){return Promise.reject(g)}for(p=0,m=f.length;p<m;)u=u.then(f[p++],f[p++]);return u}getUri(t){t=at(this.defaults,t);const r=Ts(t.baseURL,t.url,t.allowAbsoluteUrls);return bs(r,t.params,t.paramsSerializer)}};S.forEach(["delete","get","head","options"],function(t){it.prototype[t]=function(r,n){return this.request(at(n||{},{method:t,url:r,data:(n||{}).data}))}}),S.forEach(["post","put","patch"],function(t){function r(n){return function(s,a,c){return this.request(at(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}it.prototype[t]=r(),it.prototype[t+"Form"]=r(!0)});let ef=class Id{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});const n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s;const a=new Promise(c=>{n.subscribe(c),s=c}).then(o);return a.cancel=function(){n.unsubscribe(s)},a},t(function(s,a,c){n.reason||(n.reason=new wt(s,a,c),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Id(function(o){t=o}),cancel:t}}};function tf(e){return function(r){return e.apply(null,r)}}function rf(e){return S.isObject(e)&&e.isAxiosError===!0}const _n={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(_n).forEach(([e,t])=>{_n[t]=e});function Hs(e){const t=new it(e),r=rs(it.prototype.request,t);return S.extend(r,it.prototype,t,{allOwnKeys:!0}),S.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return Hs(at(e,o))},r}const pe=Hs(Bt);pe.Axios=it,pe.CanceledError=wt,pe.CancelToken=ef,pe.isCancel=Ss,pe.VERSION=Bs,pe.toFormData=ur,pe.AxiosError=te,pe.Cancel=pe.CanceledError,pe.all=function(t){return Promise.all(t)},pe.spread=tf,pe.isAxiosError=rf,pe.mergeConfig=at,pe.AxiosHeaders=ye,pe.formToJSON=e=>ys(S.isHTMLForm(e)?new FormData(e):e),pe.getAdapter=Fs.getAdapter,pe.HttpStatusCode=_n,pe.default=pe;const{Axios:yw,AxiosError:xw,CanceledError:Sw,isCancel:Cw,CancelToken:Ew,VERSION:Nw,all:Tw,Cancel:Aw,isAxiosError:Pw,spread:_w,toFormData:Iw,AxiosHeaders:Ow,HttpStatusCode:Mw,formToJSON:kw,getAdapter:Dw,mergeConfig:Lw}=pe,In={};function Ht(){var e;try{return typeof window<"u"&&((e=window.localStorage)==null?void 0:e.getItem("chat-debug"))==="1"}catch{return!1}}const zs=In==null?void 0:In.VITE_API_BASE_URL,Ws=zs?zs.replace(/\/+$/,""):void 0;!Ws&&typeof window<"u"&&console.warn("VITE_API_BASE_URL is not set. The API client will need to be configured via apiConfig prop.");let br=null;const On=new Set;function Mn(){return br}function kn(e){br=e,On.forEach(t=>t(e))}function Rs(e){return On.add(e),()=>On.delete(e)}const Be=pe.create({baseURL:Ws||"http://localhost:8000",timeout:3e4,withCredentials:!0});Be.interceptors.request.use(e=>(br&&(e.headers.Authorization=`Bearer ${br}`),e)),Be.interceptors.response.use(e=>e,e=>Promise.reject(e));async function ct(e,t){return(await Be.get(e,t)).data}async function Dn(e,t,r){return(await Be.post(e,t,r)).data}async function Vs(e,t,r){return(await Be.put(e,t,r)).data}async function js(e,t){return(await Be.delete(e,t)).data}async function nf(e,t){var m;if(Ht()){let v=t.body;try{const g=JSON.parse(JSON.stringify(t.body));(m=g==null?void 0:g.payload)!=null&&m.files_info&&Array.isArray(g.payload.files_info)&&(g.payload.files_info=g.payload.files_info.map(h=>({...h,data:h!=null&&h.data?`<base64 ${String(h.data).length} chars>`:h==null?void 0:h.data}))),v=g}catch{}console.debug("[api.stream]",t.method,`${Be.defaults.baseURL}${e}`,v)}const n=(Be.defaults.baseURL||"").replace(/\/+$|^\s+|\s+$/g,""),o=t.method??"POST",s=Mn(),a=t.headers??{},c=e?e.startsWith("/")?e:`/${e}`:"",d=n?`${n}${c}`:c||n,f=await fetch(d,{method:o,headers:{"Content-Type":"application/json",...s?{Authorization:`Bearer ${s}`}:{},...a},body:t.body!==void 0?JSON.stringify(t.body):void 0,credentials:"include",signal:t.signal});if(!f.ok||!f.body){const v=await f.text().catch(()=>"");throw Ht()&&console.debug("[api.stream] non-OK",f.status,v==null?void 0:v.slice(0,500)),new Error(`Stream failed: ${f.status} ${f.statusText}${v?": "+v:""}`)}const u=f.body.getReader(),p=new TextDecoder;for(;;){const{done:v,value:g}=await u.read();if(v)break;const h=p.decode(g,{stream:!0});Ht()&&console.debug("[api.stream] chunk",h.slice(0,200)),t.onChunk(h)}}function Ue(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class vr{get baseUrl(){const t=Be.defaults.baseURL||"";return String(t).replace(/\/+$|^\s+|\s+$/g,"")}updateConfig(t){t.baseUrl&&(Be.defaults.baseURL=String(t.baseUrl).replace(/\/+$/g,"")),t.authToken!==void 0&&kn(t.authToken)}getAuthToken(){return Mn()}setAuthToken(t){kn(t)}onTokenChange(t){return Rs(t)}async listThreads(){const t=await ct("/chat/threads"),r=Ue(t);return(r==null?void 0:r.items)??(t==null?void 0:t.items)??[]}async createThread(t){const n=await Dn("/chat/threads",t?{title:t}:void 0);return Ue(n)}async updateThread(t,r){const n=await Vs(`/chat/threads/${t}`,{title:r});return Ue(n)}async deleteThread(t){const r=await js(`/chat/threads/${t}`);return Ue(r)}async threadInfo(t){const r=await ct(`/chat/threads/${t}/info`);return Ue(r)}async getMessages(t){const r=await ct("/chat/messages",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs,limit:t.limit,before_id:t.beforeId??void 0}});return Ue(r)}async getState(t){const r=await ct("/chat/state",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ue(r)}async getStateHistory(t){const r=await ct("/chat/state/history",{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ue(r)}async listCheckpoints(t){const r=await ct("/chat/checkpoints",{params:{thread_id:t}});return Ue(r)}async uploadImage(t,r="/upload"){const n=new FormData;n.append("file",t,t.name),Ht()&&console.debug("[api.uploadImage] ->",r,{name:t.name,type:t.type,size:t.size});const o=await Dn(r,n,{headers:{Accept:"application/json"},maxBodyLength:1/0}),s=Ue(o);if(Ht()&&console.debug("[api.uploadImage] <-",s),!(s!=null&&s.url))throw new Error("Invalid upload response: missing url");return{url:s.url,mimeType:s.mimeType??t.type,name:s.name??t.name,size:s.size??t.size}}}const Ge=new vr;function Ks(e={}){const t=e.baseUrl??"/api/chat",r=e.streamPath??"/stream",[n,o]=A.useState(e.token??null),s=A.useRef(e.headers??{}),[a,c]=A.useState(!1),[d,f]=A.useState(null),[u,p]=A.useState(""),[m,v]=A.useState(null),g=A.useRef(null),h=A.useCallback(x=>{o(x)},[]),b=A.useCallback(()=>{var x;(x=g.current)==null||x.abort(),g.current=null,c(!1)},[]),w=A.useCallback(()=>{p(""),v(null),f(null)},[]),y=A.useCallback((x,C,E)=>{g.current&&(g.current.abort(),g.current=null),c(!0),f(null),e.autoAppendAssistant!==!1&&p("");const O=new AbortController;return g.current=O,(async()=>{var B,_,U,G;const N=(()=>{var L;try{return typeof window<"u"&&((L=window.localStorage)==null?void 0:L.getItem("chat-debug"))==="1"}catch{return!1}})(),F=L=>{var $;try{const q=JSON.parse(JSON.stringify(L));return($=q==null?void 0:q.payload)!=null&&$.files_info&&Array.isArray(q.payload.files_info)&&(q.payload.files_info=q.payload.files_info.map(k=>({...k,data:k!=null&&k.data?`<base64 ${String(k.data).length} chars>`:k==null?void 0:k.data}))),q}catch{return L}};try{let L={};try{if(n)L={Authorization:`Bearer ${n}`};else if(typeof window<"u"){const I=window.__AUTH_TOKEN__,J=((B=window.localStorage)==null?void 0:B.getItem("authToken"))||null;let Q=null;try{const H=(_=window.localStorage)==null?void 0:_.getItem("chat-settings");H&&(Q=((U=JSON.parse(H))==null?void 0:U.apiKey)||null)}catch{}const re=I||J||Q||null;re&&(L={Authorization:`Bearer ${re}`})}}catch{}N&&console.debug("[use-chat] POST",t+r,F(x));const $=await fetch(t+r,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...L,...s.current},body:JSON.stringify(x),signal:O.signal});if(!$.ok||!$.body){const D=await $.text().catch(()=>"");throw N&&console.debug("[use-chat] non-OK response",$.status,D==null?void 0:D.slice(0,500)),new Error(`stream ${$.status}${D?": "+D:""}`)}const q=$.body.getReader(),k=new TextDecoder;let V="";for(;;){const{value:D,done:I}=await q.read();if(I)break;V+=k.decode(D,{stream:!0});let J;for(;(J=V.indexOf(`
7
7
 
8
- `))>=0;){const j=z.slice(0,Z);z=z.slice(Z+2);const te=_f(j);if(!te)continue;let D;try{D=JSON.parse(te)}catch{T&&console.debug("[use-chat] skip malformed SSE data:",te==null?void 0:te.slice(0,200));continue}const W=kf(D)?D.data:D;if(T&&console.debug("[use-chat] event:",W==null?void 0:W.type,W),C==null||C(W),W.type==="token")e.autoAppendAssistant!==!1&&p(xe=>xe+W.content);else if(W.type==="message_delta"){const xe=W.delta.filter(ie=>ie.type==="text").map(ie=>ie.text).join("");xe&&e.autoAppendAssistant!==!1&&p(ie=>ie+xe)}else W.type==="checkpoint"?v(W.checkpointId):W.type==="error"&&f(W.message)}}}catch(H){if((H==null?void 0:H.name)==="AbortError")return;const O=(H==null?void 0:H.message)||String(H);T&&console.debug("[use-chat] error:",O),f(O),(J=E==null?void 0:E.onError)==null||J.call(E,O)}finally{c(!1),g.current=null}})(),{close:()=>P.abort()}},[t,r,e.autoAppendAssistant]);return N.useEffect(()=>()=>{var x;return(x=g.current)==null?void 0:x.abort()},[]),{isStreaming:a,error:d,assistantText:u,lastCheckpointId:m,stream:y,stop:b,clear:w,setToken:h}}function kf(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function _f(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
9
- `)}const Pf={messages:[],assemblingId:null,lastCheckpointId:null,toolIndex:{},lastBranch:null};function Of(e,t){var n,r;switch(t.type){case"reset":return{messages:ao(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,toolIndex:{},lastBranch:null};case"seed":return{...e,messages:ao(t.payload.messages)};case"prepend":{const o=ao(t.payload.messages);if(!o.length)return e;const s=new Set(e.messages.map(c=>c.id)),a=o.filter(c=>!s.has(c.id));return a.length?{...e,messages:[...a,...e.messages]}:e}case"user_message":{const o=t.payload.message;if(e.assemblingId){const s=e.messages.findIndex(a=>a.id===e.assemblingId&&a.role==="assistant");if(s>=0){const a=e.messages.slice(0,s),c=e.messages.slice(s);return{...e,messages:[...a,o,...c]}}}return{...e,messages:[...e.messages,o]}}case"event":{const o=t.payload.ev;if(o.type==="message_start"&&o.role==="assistant"){const s=o.id,a=Ff(o.model),c={id:s,role:"assistant",name:a||void 0,model:o.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,c]}}if(o.type==="token"){const s=e.assemblingId??io(e.messages);return s?{...e,messages:Mf(e.messages,s,o.content)}:e}if(o.type==="message_delta"){const s=e.assemblingId??io(e.messages);return s?{...e,messages:xa(e.messages,s,o.delta)}:e}if(o.type==="message_end"){const s=e.assemblingId??io(e.messages);if(!s)return{...e,assemblingId:null};const a=e.messages,c=a.findIndex(d=>d.id===s&&d.role==="assistant");if(c>=0&&!((r=a[c].content)==null?void 0:r.some(u=>{var p;return(u==null?void 0:u.type)==="text"&&((p=u.text)==null?void 0:p.trim())}))){const u=[...a.slice(0,c),...a.slice(c+1)];return{...e,assemblingId:null,messages:u}}return{...e,assemblingId:null}}if(o.type==="tool_start"){const s=`tool-${o.id}`,a={type:"tool_call",id:o.id,name:o.name,args:o.args},c={id:s,role:"tool",name:o.name,createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,c],toolIndex:{...e.toolIndex,[o.id]:s}}}if(o.type==="tool_result"){const s=e.toolIndex[o.id]??`tool-${o.id}`,a={type:"tool_result",toolCallId:o.id,output:o.output,error:o.error},c=e.messages.find(u=>u.id===s),d={id:s,role:"tool",content:[a],createdAt:new Date().toISOString()},f=c?xa(e.messages,s,[a]):[...e.messages,d];return{...e,messages:f}}if(o.type==="checkpoint"){const s=Lf(e.messages,o.checkpointId);return{...e,lastCheckpointId:o.checkpointId,messages:s}}if(o.type==="branch"){const s=o.checkpointId??e.lastCheckpointId;return{...e,lastBranch:o,lastCheckpointId:s??null}}if(o.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${o.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}return e}default:return e}}function ya(e=[]){const[t,n]=N.useReducer(Of,{...Pf,messages:e}),r=N.useCallback(s=>{n({type:"event",payload:{ev:s}})},[]),o=N.useMemo(()=>({reset:s=>n({type:"reset",payload:{messages:s}}),seed:s=>n({type:"seed",payload:{messages:s}}),prepend:s=>n({type:"prepend",payload:{messages:s}}),pushUser:s=>n({type:"user_message",payload:{message:s}}),onEvent:r}),[r]);return{state:t,dispatch:n,...o}}function ao(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function io(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function Mf(e,t,n){return e.map(r=>{if(r.id!==t)return r;const o=r.content.slice(),s=o[o.length-1];return s&&s.type==="text"?s.text+=n:o.push({type:"text",text:n}),{...r,content:o}})}function xa(e,t,n){return e.map(r=>r.id===t?{...r,content:Df(r.content,n)}:r)}function Df(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1];(o==null?void 0:o.type)==="text"?o.text+=r.text:n.push({type:"text",text:r.text})}else n.push(r);return n}function Lf(e,t){for(let n=e.length-1;n>=0;n--)if(e[n].role==="assistant"){const o={...e[n],checkpointId:t};return[...e.slice(0,n),o,...e.slice(n+1)]}return e}function Ff(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const Sa=N.createContext(null);function on({children:e,apiConfig:t,onError:n,onThreadChange:r,initialThreadId:o=null,historyPageSize:s}){const a=ut;N.useEffect(()=>{t&&a.updateConfig({baseUrl:t.baseUrl,authToken:t.apiKey})},[a,t]);const{isStreaming:c,error:d,stream:f,stop:u,setToken:p}=wa({baseUrl:a.baseUrl,token:null,headers:t==null?void 0:t.headers,streamPath:"/chat/stream"}),[m,v]=N.useState(()=>typeof a.getAuthToken=="function"?a.getAuthToken():null);N.useEffect(()=>{p(typeof a.getAuthToken=="function"?a.getAuthToken():null);const G=a.onTokenChange(X=>{v(X),p(X)});return()=>{G()}},[a,p]);const g=N.useCallback(G=>{a.setAuthToken(G)},[a]),{state:h,seed:b,prepend:w,pushUser:y,onEvent:x,reset:C}=ya(),E=s&&s>0?s:6,[P,T]=N.useState(!1),[F,M]=N.useState(!1),[B,V]=N.useState(null),[J,H]=N.useState(void 0),O=N.useCallback((G,X)=>{const ye=Array.isArray(G==null?void 0:G.messages)?G.messages:[];X==="replace"?b(ye):X==="prepend"&&ye.length&&w(ye),V((G==null?void 0:G.nextCursor)??null),T(!!(G!=null&&G.hasMore)),H(se=>(G==null?void 0:G.checkpointId)??se??void 0)},[b,w]),[ne,L]=N.useState([]),[z,k]=N.useState(null),I=N.useCallback(async()=>{const G=await a.listThreads();L(G)},[a]);N.useEffect(()=>{I().catch(()=>{})},[I]),N.useEffect(()=>{r==null||r(z)},[z,r]);const Z=N.useRef(null);N.useEffect(()=>{o&&Z.current!==o&&(Z.current=o,te(o).catch(()=>{}))},[o]);const j=N.useRef(null),te=N.useCallback(async(G,X,ye)=>{var se;if(j.current!==G){j.current=G;try{const Se=X??((se=(await a.listCheckpoints(G)).checkpoints.slice().sort((ve,_e)=>new Date(_e.createdAt).getTime()-new Date(ve.createdAt).getTime())[0])==null?void 0:se.checkpointId);T(!1),V(null),H(void 0);const fe=await a.getMessages({threadId:G,checkpointId:Se,checkpointNs:ye,limit:E});k(G),O(fe,"replace")}finally{j.current=null}}},[a,O]),D=N.useCallback(async G=>a.listCheckpoints(G),[a]),W=N.useCallback(async G=>{if(!z)throw new Error("No active thread");T(!1),V(null),H(void 0);const X=await a.getMessages({threadId:z,checkpointId:G,limit:E});O(X,"replace")},[a,z,O]),xe=N.useCallback(async()=>{if(!z)throw new Error("No active thread");await te(z)},[z,te]),ie=N.useRef(!1);N.useEffect(()=>{const G=ie.current;if(ie.current=c,G&&!c&&z){const X=h.lastCheckpointId??void 0;(async()=>{try{const ye=await a.getMessages({threadId:z,checkpointId:X,limit:E});O(ye,"replace")}catch{}try{await I()}catch{}})()}},[c,z,h.lastCheckpointId,a,O,I]);const R=N.useCallback(async G=>{const X=await a.createThread(G);return await I(),await te(X.threadId),X.threadId},[a,I,te]),le=N.useCallback(async G=>{await a.deleteThread(G),await I(),z===G&&(k(null),C([]),T(!1),V(null),H(void 0))},[a,I,z,C]),he=N.useCallback(async(G,X)=>{await a.updateThread(G,X),await I()},[a,I]),de=N.useCallback(async(G,X)=>{var $r;if(!z)throw new Error("No active thread");async function ye(me){return await new Promise((Ie,$e)=>{const Ze=new FileReader;Ze.onload=()=>Ie(String(Ze.result)),Ze.onerror=gt=>$e(gt),Ze.readAsDataURL(me)})}async function se(me){return await new Promise((Ie,$e)=>{const Ze=new FileReader;Ze.onload=()=>{try{const gt=Ze.result;let Br="";const _=new Uint8Array(gt),$=_.byteLength;for(let K=0;K<$;K++)Br+=String.fromCharCode(_[K]);Ie(btoa(Br))}catch(gt){$e(gt)}},Ze.onerror=gt=>$e(gt),Ze.readAsArrayBuffer(me)})}const Se=[];G&&Se.push({type:"text",text:G});const fe=(X==null?void 0:X.attachments)||[];let ve=[];if(fe.length>0)for(const me of fe)if(me.type&&me.type.startsWith("image/")){let Ie=null;try{const $e=await a.uploadImage(me,(t==null?void 0:t.uploadPath)||"/upload").catch(()=>null);Ie=($e==null?void 0:$e.url)||null}catch{}if(!Ie)try{Ie=await ye(me)}catch{Ie=null}if(Ie){const $e={type:"image_url",url:Ie,mimeType:me.type,alt:me.name};Se.push($e)}try{ve.push({filename:me.name,data:await se(me),mime_type:me.type||"application/octet-stream"})}catch{}}else{const Ie=await ye(me).catch(()=>null),$e={type:"file",url:String(Ie),mimeType:me.type||void 0,name:me.name,size:me.size};Se.push($e);try{ve.push({filename:me.name,data:await se(me),mime_type:me.type||"application/octet-stream"})}catch{}}const _e={id:(($r=crypto.randomUUID)==null?void 0:$r.call(crypto))||`user-${Date.now()}`,role:"user",content:Se,createdAt:new Date().toISOString(),checkpointId:(X==null?void 0:X.checkpointId)??h.lastCheckpointId??void 0};y(_e);const Fe={..._e,content:_e.content.filter(me=>me.type==="text"||me.type==="image_url")},ht={...(X==null?void 0:X.payloadExtras)??{}},Es=!!ht.edit,En=ht.originalMessageId,Ns=typeof En=="string"?En:void 0,Fr=ht.branchLabel,Nn=typeof Fr=="string"?Fr:void 0,Ts={threadId:z,payload:{messages:[Fe],attachments:_e.content.filter(me=>me.type==="file").map(me=>({type:"file",url:me.url,mimeType:me.mimeType,name:me.name,size:me.size})),files_info:ve,...ht},checkpointId:(X==null?void 0:X.checkpointId)??h.lastCheckpointId??void 0,checkpointNs:X==null?void 0:X.checkpointNs,nodeFilter:X==null?void 0:X.nodeFilter,config:X==null?void 0:X.config,edit:Es,originalMessageId:Ns,branchLabel:Nn};f(Ts,me=>x(me),{onError:me=>console.warn("stream error",me)})},[z,y,f,x,h.lastCheckpointId,a,t==null?void 0:t.uploadPath]),be=N.useCallback(async G=>{if(!z)throw new Error("No active thread");if(F||!P)return;const X=B;if(X){M(!0);try{const ye=await a.getMessages({threadId:z,checkpointId:J,limit:(G==null?void 0:G.limit)??E,beforeId:X});O(ye,"prepend")}finally{M(!1)}}},[a,z,J,B,P,F,O]),ge={baseUrl:a.baseUrl,token:m,setToken:g,api:a,threads:ne,currentThreadId:z,setCurrentThreadId:k,messages:h.messages,isStreaming:c,error:d,lastCheckpointId:h.lastCheckpointId,lastBranchEvent:h.lastBranch,streamingAssistantId:h.assemblingId,hasMoreHistory:P,isLoadingHistory:F,loadOlderMessages:be,historyPageSize:E,refreshThreads:I,createThread:R,deleteThread:le,renameThread:he,loadThread:te,listCheckpoints:D,navigateToCheckpoint:W,returnToLatest:xe,send:de,stop:u};return i.jsx(Sa.Provider,{value:ge,children:e})}function co(){const e=N.useContext(Sa);if(!e)throw new Error("useChat must be used within ChatProvider");return e}function A(...e){return nu.twMerge(tu.clsx(e))}const $f=Jt.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),we=l.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const a=r?Be.Slot:"button";return i.jsx(a,{className:A($f({variant:t,size:n,className:e})),ref:s,...o})});we.displayName="Button";const Ca=l.forwardRef(({className:e,...t},n)=>i.jsx("textarea",{className:A("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ca.displayName="Textarea";const Bf=Jt.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ea({className:e,variant:t,...n}){return i.jsx("div",{className:A(Bf({variant:t}),e),...n})}function U(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Uf(e,t){const n=l.createContext(t),r=s=>{const{children:a,...c}=s,d=l.useMemo(()=>c,Object.values(c));return i.jsx(n.Provider,{value:d,children:a})};r.displayName=e+"Provider";function o(s){const a=l.useContext(n);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function Ke(e,t=[]){let n=[];function r(s,a){const c=l.createContext(a),d=n.length;n=[...n,a];const f=p=>{var w;const{scope:m,children:v,...g}=p,h=((w=m==null?void 0:m[e])==null?void 0:w[d])||c,b=l.useMemo(()=>g,Object.values(g));return i.jsx(h.Provider,{value:b,children:v})};f.displayName=s+"Provider";function u(p,m){var h;const v=((h=m==null?void 0:m[e])==null?void 0:h[d])||c,g=l.useContext(v);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[f,u]}const o=()=>{const s=n.map(a=>l.createContext(a));return function(c){const d=(c==null?void 0:c[e])||s;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[r,Hf(o,...t)]}function Hf(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const a=r.reduce((c,{useScope:d,scopeName:f})=>{const p=d(s)[`__scope${f}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}var Ne=globalThis!=null&&globalThis.document?l.useLayoutEffect:()=>{},zf=l[" useInsertionEffect ".trim().toString()]||Ne;function mt({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,a]=Wf({defaultProp:t,onChange:n}),c=e!==void 0,d=c?e:o;{const u=l.useRef(e!==void 0);l.useEffect(()=>{const p=u.current;p!==c&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=c},[c,r])}const f=l.useCallback(u=>{var p;if(c){const m=Vf(u)?u(e):u;m!==e&&((p=a.current)==null||p.call(a,m))}else s(u)},[c,e,s,a]);return[d,f]}function Wf({defaultProp:e,onChange:t}){const[n,r]=l.useState(e),o=l.useRef(n),s=l.useRef(t);return zf(()=>{s.current=t},[t]),l.useEffect(()=>{var a;o.current!==n&&((a=s.current)==null||a.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Vf(e){return typeof e=="function"}function Na(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function lo(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Na(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Na(e[o],null)}}}}function ue(...e){return l.useCallback(lo(...e),e)}var jf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],oe=jf.reduce((e,t)=>{const n=Be.createSlot(`Primitive.${t}`),r=l.forwardRef((o,s)=>{const{asChild:a,...c}=o,d=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(d,{...c,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ta(e,t){e&&Tn.flushSync(()=>e.dispatchEvent(t))}function Rf(e,t){return l.useReducer((n,r)=>t[n][r]??n,e)}var Le=e=>{const{present:t,children:n}=e,r=Kf(t),o=typeof n=="function"?n({present:r.isPresent}):l.Children.only(n),s=ue(r.ref,Gf(o));return typeof n=="function"||r.isPresent?l.cloneElement(o,{ref:s}):null};Le.displayName="Presence";function Kf(e){const[t,n]=l.useState(),r=l.useRef(null),o=l.useRef(e),s=l.useRef("none"),a=e?"mounted":"unmounted",[c,d]=Rf(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const f=Un(r.current);s.current=c==="mounted"?f:"none"},[c]),Ne(()=>{const f=r.current,u=o.current;if(u!==e){const m=s.current,v=Un(f);e?d("MOUNT"):v==="none"||(f==null?void 0:f.display)==="none"?d("UNMOUNT"):d(u&&m!==v?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),Ne(()=>{if(t){let f;const u=t.ownerDocument.defaultView??window,p=v=>{const h=Un(r.current).includes(CSS.escape(v.animationName));if(v.target===t&&h&&(d("ANIMATION_END"),!o.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",f=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},m=v=>{v.target===t&&(s.current=Un(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{u.clearTimeout(f),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:l.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function Un(e){return(e==null?void 0:e.animationName)||"none"}function Gf(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var qf=l[" useId ".trim().toString()]||(()=>{}),Xf=0;function Ge(e){const[t,n]=l.useState(qf());return Ne(()=>{n(r=>r??String(Xf++))},[e]),t?`radix-${t}`:""}var Hn="Collapsible",[Yf,sy]=Ke(Hn),[Jf,uo]=Yf(Hn),Aa=l.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:a,...c}=e,[d,f]=mt({prop:r,defaultProp:o??!1,onChange:a,caller:Hn});return i.jsx(Jf,{scope:n,disabled:s,contentId:Ge(),open:d,onOpenToggle:l.useCallback(()=>f(u=>!u),[f]),children:i.jsx(oe.div,{"data-state":po(d),"data-disabled":s?"":void 0,...c,ref:t})})});Aa.displayName=Hn;var Ia="CollapsibleTrigger",ka=l.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=uo(Ia,n);return i.jsx(oe.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":po(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:U(e.onClick,o.onOpenToggle)})});ka.displayName=Ia;var fo="CollapsibleContent",Zf=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=uo(fo,e.__scopeCollapsible);return i.jsx(Le,{present:n||o.open,children:({present:s})=>i.jsx(Qf,{...r,ref:t,present:s})})});Zf.displayName=fo;var Qf=l.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,a=uo(fo,n),[c,d]=l.useState(r),f=l.useRef(null),u=ue(t,f),p=l.useRef(0),m=p.current,v=l.useRef(0),g=v.current,h=a.open||c,b=l.useRef(h),w=l.useRef(void 0);return l.useEffect(()=>{const y=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(y)},[]),Ne(()=>{const y=f.current;if(y){w.current=w.current||{transitionDuration:y.style.transitionDuration,animationName:y.style.animationName},y.style.transitionDuration="0s",y.style.animationName="none";const x=y.getBoundingClientRect();p.current=x.height,v.current=x.width,b.current||(y.style.transitionDuration=w.current.transitionDuration,y.style.animationName=w.current.animationName),d(r)}},[a.open,r]),i.jsx(oe.div,{"data-state":po(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!h,...s,ref:u,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:h&&o})});function po(e){return e?"open":"closed"}var ep=Aa;const _a=ep,Pa=ka;function sn({content:e,className:t=""}){const n=N.useMemo(()=>({table:({node:f,className:u,...p})=>i.jsx("div",{className:"max-w-full",children:i.jsx("table",{...p,className:A("w-full table-fixed border-collapse break-words",u)})}),th:({node:f,className:u,...p})=>i.jsx("th",{...p,className:A("break-words whitespace-normal border-b border-border/60 px-3 py-2 text-left align-top",u)}),td:({node:f,className:u,...p})=>i.jsx("td",{...p,className:A("break-words whitespace-normal border-b border-border/30 px-3 py-2 align-top",u)}),pre:({node:f,className:u,...p})=>i.jsx("pre",{...p,className:A("whitespace-pre-wrap break-words",u)}),code:({node:f,className:u,children:p,...m})=>{const{inline:v,...g}=m;return v?i.jsx("code",{...g,className:A("break-words whitespace-normal",u),children:p}):i.jsx("code",{...g,className:A("block break-words whitespace-pre-wrap",u),children:p})}}),[]),r=A("prose prose-sm max-w-none break-words dark:prose-invert leading-relaxed","prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words","prose-a:break-all prose-blockquote:break-words prose-strong:break-words prose-em:break-words","prose-code:break-words prose-pre:rounded prose-pre:border prose-pre:bg-background/50","prose-code:bg-background/50 prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-table:my-4 prose-th:px-2 prose-td:px-2",t);return i.jsx("div",{className:r,style:{wordBreak:"break-word",overflowWrap:"anywhere"},children:i.jsx(ru,{remarkPlugins:[ou],components:n,children:e})})}const zn="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function tp({className:e}){const[t,n]=N.useState(0);return N.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),i.jsxs("span",{"aria-live":"polite",className:A("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function Oa({message:e,messageIndex:t,isStreamingMessage:n=!1,streamingDebounceMs:r=40,isEditing:o=!1,showActions:s=!0,showTimestamp:a=!0,showAgentName:c=!0,layoutSize:d="desktop",truncateToolMessages:f=!0,toolMessagePreviewLength:u=200,truncateUserMessages:p=!0,userMessagePreviewLength:m=200,customStyles:v={},checkpointBranches:g=[],currentCheckpointId:h,onSwitchToCheckpoint:b,onReturnToMainThread:w,temporalNavigation:y,onNavigateToPreviousBranch:x,onNavigateToNextBranch:C,onEdit:E,onRegenerate:P,onEditFromCheckpoint:T,onCancelEdit:F,onCopy:M}){const[B,V]=N.useState(!1),[J,H]=N.useState(!1),[O,ne]=N.useState(!1),[L,z]=N.useState(!1),k=d==="phone"||d==="half-screen",I=e.role,Z=I==="tool",j=N.useMemo(()=>{switch(I){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-foreground"}},[I]),te=N.useMemo(()=>np(e.content),[e.content]),D=N.useMemo(()=>cp(e.content),[e.content]),W=N.useMemo(()=>e.content.filter(se=>se.type==="image_url"),[e.content]),xe=N.useMemo(()=>e.content.filter(se=>se.type==="file"),[e.content]),ie=up(te,n?r:0),R=async()=>{try{const se=Z?$t(e.content):te;await navigator.clipboard.writeText(se),V(!0),setTimeout(()=>V(!1),2e3),M==null||M(se)}catch(se){console.error("Failed to copy:",se)}},le=()=>{if(!E)return;const se=Z?$t(e.content):te;E(e.id,se)},he=()=>P==null?void 0:P(t),de=()=>{const Se=A(k?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",j);switch(I){case"user":return i.jsx(q.User,{className:Se});case"assistant":return i.jsx(q.Bot,{className:Se});case"tool":return i.jsx(q.Wrench,{className:Se});default:return i.jsx(q.Bot,{className:Se})}},be=()=>{const se="group relative mb-4 flex w-full";switch(I){case"user":return A(se,"justify-end");case"assistant":case"tool":case"system":return A(se,"justify-start");default:return se}},ge=()=>{const se=A("rounded-lg px-4 py-3 relative transition-all duration-200 min-w-0 max-w-full break-words",k&&"px-3 py-2 text-sm");switch(I){case"user":return A(se,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return A(se,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return A(se,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return A(se,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return se}},G=se=>{if(!se)return"";try{return new Date(se).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}},X=()=>{if(e.model==="reflection"){const fe=te.trim(),ve=ho(fe);if(ve&&typeof ve=="object")return i.jsx(fp,{data:ve})}if(Z&&D.name==="get_issues"){const fe=e.content.find(Fe=>Fe.type==="tool_result"),ve=(fe==null?void 0:fe.output)??$t(e.content),_e=Da(ve);if(_e)return i.jsx(pp,{issues:_e})}if(Z&&!O){const fe=$t(e.content).slice(0,80).replace(/\s+/g," ");return i.jsx("div",{className:A("text-xs font-mono opacity-70 flex items-center justify-between gap-2 text-current",k&&"text-[10px]"),children:i.jsxs("span",{className:"truncate max-w-full text-current",children:[fe,fe.length>=80?"…":""]})})}if(Z&&f){const fe=$t(e.content),ve=fe.length>u;return i.jsx(_a,{open:J,onOpenChange:H,children:i.jsxs("div",{className:"font-mono text-sm text-current",children:[i.jsx("pre",{className:A("whitespace-pre-wrap break-words text-current",k&&"text-xs"),children:ve&&!J?fe.substring(0,u)+"...":fe}),ve&&i.jsx(Pa,{asChild:!0,children:i.jsx(we,{variant:"ghost",size:"sm",className:"h-6 text-xs text-current",children:J?i.jsxs(i.Fragment,{children:[i.jsx(q.ChevronUp,{className:"h-3 w-3 mr-1"}),"Show less"]}):i.jsxs(i.Fragment,{children:[i.jsx(q.ChevronDown,{className:"h-3 w-3 mr-1"}),"Show more (",fe.length-u," chars)"]})})})]})})}if(Z&&O&&!f){const fe=ip(e.content);if(fe&&rp(fe))return i.jsx(sn,{content:fe.trim()});const ve=$t(e.content);return i.jsx("div",{className:"font-mono text-sm text-current",children:i.jsx("pre",{className:A("whitespace-pre-wrap break-words text-current",k&&"text-xs"),children:ve})})}const se=W.length>0&&I!=="tool",Se=xe.length>0&&I!=="tool";return i.jsxs("div",{children:[n?i.jsxs("div",{className:"relative",children:[(()=>{const fe=ho(ie);return fe!==null?i.jsx(Ma,{data:fe}):i.jsx(sn,{content:sp(op(ie))})})(),i.jsx(tp,{className:A(j,k?"text-xs":"text-sm")})]}):(()=>{const fe=ho(te.trim());if(fe!==null)return i.jsx(Ma,{data:fe});if(I==="user"&&p){const ve=te.trim();if(ve.length>m)return i.jsxs(_a,{open:L,onOpenChange:z,children:[i.jsx("div",{className:A("text-sm text-[hsl(var(--chat-bubble-user-text))]",k&&"text-xs"),children:L?i.jsx(sn,{content:ve}):i.jsxs("pre",{className:A("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",k&&"text-xs"),children:[ve.substring(0,m),"..."]})}),i.jsx(Pa,{asChild:!0,children:i.jsx(we,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:L?i.jsxs(i.Fragment,{children:[i.jsx(q.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):i.jsxs(i.Fragment,{children:[i.jsx(q.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",ve.length-m," chars)"]})})})]})}return i.jsx(sn,{content:te.trim()})})(),se&&i.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:W.map((fe,ve)=>i.jsxs("div",{className:"relative border rounded overflow-hidden",children:[i.jsx("img",{src:fe.url,alt:fe.alt??"image",className:"w-full h-auto"}),i.jsxs("div",{className:"absolute top-1 right-1 bg-background/70 rounded px-1 py-0.5 text-[10px] flex items-center gap-1",children:[i.jsx(q.Image,{className:"h-3 w-3"}),i.jsx("span",{children:"image"})]})]},ve))}),Se&&i.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:xe.map((fe,ve)=>{const _e=fe,Fe=_e.name||"file";return i.jsxs("a",{href:_e.url,download:Fe,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-2 bg-gray-100 border border-gray-200 rounded px-2 py-1 text-xs hover:bg-gray-200",title:Fe,children:[i.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-gray-400"}),i.jsx("span",{className:"truncate max-w-[180px]",children:Fe})]},ve)})})]})},ye=N.useMemo(()=>lp(e),[e]);return N.useMemo(()=>dp(e,h),[e,h]),i.jsx("div",{className:A(be(),v.container),children:i.jsxs("div",{className:A(ge(),v.content),children:[(a||c||Z)&&i.jsxs("div",{className:A("flex items-center justify-between mb-2 pb-2 border-b border-current/10",k&&"mb-1 pb-1",j,v.header),children:[i.jsxs("div",{className:"flex items-center gap-2",children:[de(),c&&ye&&i.jsx("span",{className:A("font-medium",k?"text-xs":"text-sm"),children:ye}),Z&&D.name&&i.jsxs(Ea,{variant:"outline",className:A("text-xs flex items-center gap-1 cursor-pointer",j,"border border-current/40",k&&"text-xs h-4"),onClick:()=>ne(se=>!se),children:[i.jsx("span",{children:D.name}),i.jsx("span",{className:"inline-flex items-center",children:O?i.jsx(q.ChevronUp,{className:"h-3 w-3"}):i.jsx(q.ChevronDown,{className:"h-3 w-3"})})]}),Z&&!D.name&&i.jsx(we,{variant:"ghost",size:"sm",className:A("h-6 px-1",j,"hover:bg-foreground/10"),onClick:()=>ne(se=>!se),children:i.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",O?i.jsx(q.ChevronUp,{className:"h-3 w-3"}):i.jsx(q.ChevronDown,{className:"h-3 w-3"})]})})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[a&&i.jsx("span",{className:A("text-xs opacity-60",j,k&&"text-xs"),children:G(e.createdAt)}),s&&!o&&i.jsxs("div",{className:A("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",v.actions),children:[i.jsx(we,{variant:"ghost",size:"sm",onClick:R,className:A("h-6 w-6 p-0 hover:bg-foreground/10",j,k&&"h-5 w-5"),children:i.jsx(q.Copy,{className:A(B?"text-success":j,k?"h-3 w-3":"h-4 w-4")})}),I==="user"&&E&&i.jsx(we,{variant:"ghost",size:"sm",onClick:le,className:A("h-6 w-6 p-0 hover:bg-foreground/10",j,k&&"h-5 w-5"),children:i.jsx(q.Edit,{className:A(j,k?"h-3 w-3":"h-4 w-4")})}),I==="assistant"&&P&&i.jsx(we,{variant:"ghost",size:"sm",onClick:he,className:A("h-6 w-6 p-0 hover:bg-foreground/10",j,k&&"h-5 w-5"),children:i.jsx(q.RotateCcw,{className:A(j,k?"h-3 w-3":"h-4 w-4")})})]})]})]}),i.jsx("div",{className:"relative",children:X()}),Z&&O&&(D.toolCallId||D.name)&&i.jsxs("div",{className:A("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",k&&"text-xs"),children:[D.name&&i.jsxs("div",{children:["Function: ",D.name]}),D.toolCallId&&i.jsxs("div",{children:["Call ID: ",D.toolCallId]})]}),s&&I==="user"&&y&&y.totalBranches>1&&i.jsxs("div",{className:"flex items-center gap-2 mt-2 p-2 bg-muted/30 rounded border",children:[i.jsx(q.GitBranch,{className:"h-3 w-3 text-muted-foreground"}),i.jsxs("span",{className:"text-xs text-muted-foreground",children:["Branch ",y.currentIndex+1," of ",y.totalBranches,y.currentLabel?` • ${y.currentLabel}`:""]}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx(we,{variant:"ghost",size:"sm",className:A("h-6 w-6 p-0",j),disabled:!y.canGoBack,onClick:()=>x==null?void 0:x(),title:"Go back to previous branch",children:i.jsx(q.ChevronLeft,{className:A("h-3 w-3",j)})}),i.jsx(we,{variant:"ghost",size:"sm",className:A("h-6 w-6 p-0",j),disabled:!y.canGoForward,onClick:()=>C==null?void 0:C(),title:"Go forward to next branch",children:i.jsx(q.ChevronRight,{className:A("h-3 w-3",j)})})]})]}),!(a||c||Z)&&s&&!o&&i.jsxs("div",{className:A("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",v.actions),children:[i.jsx(we,{variant:"ghost",size:"sm",onClick:R,className:A("h-6 w-6 p-0 hover:bg-background/50 text-current",k&&"h-5 w-5"),children:i.jsx(q.Copy,{className:A(B?"text-success":"text-current",k?"h-3 w-3":"h-4 w-4")})}),I==="user"&&E&&i.jsx(we,{variant:"ghost",size:"sm",onClick:le,className:A("h-6 w-6 p-0 hover:bg-background/50 text-current",k&&"h-5 w-5"),children:i.jsx(q.Edit,{className:A("text-current",k?"h-3 w-3":"h-4 w-4")})}),I==="assistant"&&P&&i.jsx(we,{variant:"ghost",size:"sm",onClick:he,className:A("h-6 w-6 p-0 hover:bg-background/50 text-current",k&&"h-5 w-5"),children:i.jsx(q.RotateCcw,{className:A("text-current",k?"h-3 w-3":"h-4 w-4")})})]})]})})}function np(e){const t=e.filter(n=>n.type==="text").map(n=>n.text).join("");return t||JSON.stringify(e)}function rp(e){return e.includes(`
10
- `)||e.includes("```")||/[-*] /.test(e)||/#+\s/.test(e)}function op(e){let t=e;try{(t.match(/```/g)||[]).length%2===1&&(t+="\n```"),(t.replace(/```[\s\S]*?```/g,"").match(new RegExp("(?<!`)`(?!`)","g"))||[]).length%2===1&&(t+="`")}catch{}return t}function sp(e){let t=e;try{const n=[],r=[],o="\0F",s="\0I";let a=t.replace(/```[\s\S]*?```/g,c=>(n.push(c),`${o}${n.length-1}\0`));a=a.replace(/`[^`]*`/g,c=>(r.push(c),`${s}${r.length-1}\0`)),a=a.replace(/\b([A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/\b([A-Za-z0-9_&\/-]+\s+[A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/([\.,;:!\?\-])\1+/g,"$1").replace(/([:;!\?\)])([A-Za-z])/g,"$1 $2").replace(/\s{3,}/g," "),a=a.replace(/\u0000F(\d+)\u0000/g,(c,d)=>n[Number(d)]??""),a=a.replace(/\u0000I(\d+)\u0000/g,(c,d)=>r[Number(d)]??""),t=a}catch{}return t}function ho(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function Ma({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?i.jsx("div",{className:zn,children:i.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>i.jsx("li",{children:String(n)},r))})}):i.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:an(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return i.jsxs("div",{className:zn,children:[typeof r=="boolean"&&i.jsxs("p",{children:[i.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&i.jsxs("div",{children:[i.jsx("p",{children:i.jsx("strong",{children:"Follow-up queries:"})}),i.jsx("ul",{className:"list-disc pl-5",children:n.map((s,a)=>i.jsx("li",{children:String(s)},a))})]}),t&&t.length>0&&i.jsxs("div",{children:[i.jsx("p",{children:i.jsx("strong",{children:"Facts:"})}),i.jsx("ul",{className:"list-disc pl-5",children:t.map((s,a)=>i.jsx("li",{children:String(s)},a))})]})]});const o=Object.entries(e);return i.jsx("div",{className:zn,children:i.jsx("dl",{className:"mt-0",children:o.map(([s,a])=>i.jsxs("div",{className:"mb-1",children:[i.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),i.jsx("dd",{className:"inline",children:ap(a)})]},s))})})}return i.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:an(e)})}function ap(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return i.jsx("code",{className:"text-xs",children:JSON.stringify(e)})}catch{return String(e)}}function $t(e){const t=e.filter(n=>n.type==="tool_result");if(t.length)try{return t.length===1?an(t[0].output):an(t.map(n=>({toolCallId:n.toolCallId,output:n.output})))}catch{}return an(e)}function ip(e){const t=e.find(r=>r.type==="tool_result");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function an(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function cp(e){const t=e.find(r=>r.type==="tool_call"),n=e.find(r=>r.type==="tool_result");return{name:t==null?void 0:t.name,toolCallId:(n==null?void 0:n.toolCallId)??(t==null?void 0:t.id)}}function lp(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function dp(e,t){return e.checkpointId||t||null}function up(e,t){const[n,r]=N.useState(e);return N.useEffect(()=>{if(!t){r(e);return}const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),n}function fp({data:e}){return i.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>i.jsxs("div",{className:"flex",children:[i.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),i.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>i.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Da(e){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){if(e.desirability||e.feasibility||e.viability||e.other)return{desirability:Array.isArray(e.desirability)?e.desirability:[],feasibility:Array.isArray(e.feasibility)?e.feasibility:[],viability:Array.isArray(e.viability)?e.viability:[],other:Array.isArray(e.other)?e.other:[]};if(e.output&&typeof e.output!="object")e=e.output;else if(e.output&&typeof e.output=="object")return Da(e.output)}const t=String(e),n={desirability:[],feasibility:[],viability:[],other:[]};let r=t;const o=Math.min(...["desirability=","feasibility=","viability=","other="].map(a=>{const c=r.toLowerCase().indexOf(a);return c===-1?Number.MAX_SAFE_INTEGER:c}));o!==Number.MAX_SAFE_INTEGER&&(r=r.slice(o));for(const a of Object.keys(n)){const d=new RegExp(a+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!d)continue;const f=d[1],u=/Issue\(([\s\S]*?)\)(?:,|$)/g;let p=null;for(;(p=u.exec(f))!==null;){const m=p[1],v=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(m),g=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(m),h=v?v[2].trim():"",b=g?g[2].trim():"";n[a].push({title:h,description:b})}}return Object.values(n).some(a=>a.length>0)?n:null}function pp({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return i.jsx("div",{className:zn,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:i.jsxs("div",{className:"mb-4",children:[i.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),i.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>i.jsxs("li",{children:[i.jsx("div",{className:"font-medium",children:o.title}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const Bt=1e4;function hp(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
8
+ `))>=0;){const Q=V.slice(0,J);V=V.slice(J+2);const re=sf(Q);if(!re)continue;let H;try{H=JSON.parse(re)}catch{N&&console.debug("[use-chat] skip malformed SSE data:",re==null?void 0:re.slice(0,200));continue}const R=of(H)?H.data:H;if(N&&console.debug("[use-chat] event:",R==null?void 0:R.type,R),C==null||C(R),R.type==="token")e.autoAppendAssistant!==!1&&p(ue=>ue+R.content);else if(R.type==="message_delta"){const ue=R.delta.filter(de=>de.type==="text").map(de=>de.text).join("");ue&&e.autoAppendAssistant!==!1&&p(de=>de+ue)}else R.type==="checkpoint"?v(R.checkpointId):R.type==="error"&&f(R.message)}}}catch(L){if((L==null?void 0:L.name)==="AbortError")return;const $=(L==null?void 0:L.message)||String(L);N&&console.debug("[use-chat] error:",$),f($),(G=E==null?void 0:E.onError)==null||G.call(E,$)}finally{c(!1),g.current=null}})(),{close:()=>O.abort()}},[t,n,e.autoAppendAssistant]);return A.useEffect(()=>()=>{var x;return(x=g.current)==null?void 0:x.abort()},[]),{isStreaming:a,error:d,assistantText:u,lastCheckpointId:m,stream:y,stop:b,clear:w,setToken:h}}function of(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function sf(e){const t=e.split(/\r?\n/),r=[];for(const n of t)if(n&&!n.startsWith(":")&&n.startsWith("data:")){const o=n.slice(5);r.push(o.startsWith(" ")?o.slice(1):o)}return r.length===0?null:r.join(`
9
+ `)}const af={messages:[],assemblingId:null,lastCheckpointId:null,toolIndex:{},lastBranch:null};function cf(e,t){var r,n;switch(t.type){case"reset":return{messages:Ln(((r=t.payload)==null?void 0:r.messages)??[]),assemblingId:null,lastCheckpointId:null,toolIndex:{},lastBranch:null};case"seed":return{...e,messages:Ln(t.payload.messages)};case"prepend":{const o=Ln(t.payload.messages);if(!o.length)return e;const s=new Set(e.messages.map(c=>c.id)),a=o.filter(c=>!s.has(c.id));return a.length?{...e,messages:[...a,...e.messages]}:e}case"user_message":{const o=t.payload.message;if(e.assemblingId){const s=e.messages.findIndex(a=>a.id===e.assemblingId&&a.role==="assistant");if(s>=0){const a=e.messages.slice(0,s),c=e.messages.slice(s);return{...e,messages:[...a,o,...c]}}}return{...e,messages:[...e.messages,o]}}case"event":{const o=t.payload.ev;if(o.type==="message_start"&&o.role==="assistant"){const s=o.id,a=ff(o.model),c={id:s,role:"assistant",name:a||void 0,model:o.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,c]}}if(o.type==="token"){const s=e.assemblingId??Fn(e.messages);return s?{...e,messages:lf(e.messages,s,o.content)}:e}if(o.type==="message_delta"){const s=e.assemblingId??Fn(e.messages);return s?{...e,messages:qs(e.messages,s,o.delta)}:e}if(o.type==="message_end"){const s=e.assemblingId??Fn(e.messages);if(!s)return{...e,assemblingId:null};const a=e.messages,c=a.findIndex(d=>d.id===s&&d.role==="assistant");if(c>=0&&!((n=a[c].content)==null?void 0:n.some(u=>{var p;return(u==null?void 0:u.type)==="text"&&((p=u.text)==null?void 0:p.trim())}))){const u=[...a.slice(0,c),...a.slice(c+1)];return{...e,assemblingId:null,messages:u}}return{...e,assemblingId:null}}if(o.type==="tool_start"){const s=`tool-${o.id}`,a={type:"tool_call",id:o.id,name:o.name,args:o.args},c={id:s,role:"tool",name:o.name,createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,c],toolIndex:{...e.toolIndex,[o.id]:s}}}if(o.type==="tool_result"){const s=e.toolIndex[o.id]??`tool-${o.id}`,a={type:"tool_result",toolCallId:o.id,output:o.output,error:o.error},c=e.messages.find(u=>u.id===s),d={id:s,role:"tool",content:[a],createdAt:new Date().toISOString()},f=c?qs(e.messages,s,[a]):[...e.messages,d];return{...e,messages:f}}if(o.type==="checkpoint"){const s=uf(e.messages,o.checkpointId);return{...e,lastCheckpointId:o.checkpointId,messages:s}}if(o.type==="branch"){const s=o.checkpointId??e.lastCheckpointId;return{...e,lastBranch:o,lastCheckpointId:s??null}}if(o.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${o.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}return e}default:return e}}function Gs(e=[]){const[t,r]=A.useReducer(cf,{...af,messages:e}),n=A.useCallback(s=>{r({type:"event",payload:{ev:s}})},[]),o=A.useMemo(()=>({reset:s=>r({type:"reset",payload:{messages:s}}),seed:s=>r({type:"seed",payload:{messages:s}}),prepend:s=>r({type:"prepend",payload:{messages:s}}),pushUser:s=>r({type:"user_message",payload:{message:s}}),onEvent:n}),[n]);return{state:t,dispatch:r,...o}}function Ln(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const r=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),n=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(r||n)})}function Fn(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function lf(e,t,r){return e.map(n=>{if(n.id!==t)return n;const o=n.content.slice(),s=o[o.length-1];return s&&s.type==="text"?s.text+=r:o.push({type:"text",text:r}),{...n,content:o}})}function qs(e,t,r){return e.map(n=>n.id===t?{...n,content:df(n.content,r)}:n)}function df(e,t){const r=e.slice();for(const n of t)if(n.type==="text"){const o=r[r.length-1];(o==null?void 0:o.type)==="text"?o.text+=n.text:r.push({type:"text",text:n.text})}else r.push(n);return r}function uf(e,t){for(let r=e.length-1;r>=0;r--)if(e[r].role==="assistant"){const o={...e[r],checkpointId:t};return[...e.slice(0,r),o,...e.slice(r+1)]}return e}function ff(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const Xs=A.createContext(null);function zt({children:e,apiConfig:t,onError:r,onThreadChange:n,initialThreadId:o=null,historyPageSize:s}){const a=Ge;A.useEffect(()=>{t&&a.updateConfig({baseUrl:t.baseUrl,authToken:t.apiKey})},[a,t]);const{isStreaming:c,error:d,stream:f,stop:u,setToken:p}=Ks({baseUrl:a.baseUrl,token:null,headers:t==null?void 0:t.headers,streamPath:"/chat/stream"}),[m,v]=A.useState(()=>typeof a.getAuthToken=="function"?a.getAuthToken():null);A.useEffect(()=>{p(typeof a.getAuthToken=="function"?a.getAuthToken():null);const P=a.onTokenChange(M=>{v(M),p(M)});return()=>{P()}},[a,p]);const g=A.useCallback(P=>{a.setAuthToken(P)},[a]),{state:h,seed:b,prepend:w,pushUser:y,onEvent:x,reset:C}=Gs(),E=s&&s>0?s:6,[O,N]=A.useState(!1),[F,B]=A.useState(!1),[_,U]=A.useState(null),[G,L]=A.useState(void 0),$=A.useCallback((P,M)=>{const Y=Array.isArray(P==null?void 0:P.messages)?P.messages:[];M==="replace"?b(Y):M==="prepend"&&Y.length&&w(Y),U((P==null?void 0:P.nextCursor)??null),N(!!(P!=null&&P.hasMore)),L(le=>(P==null?void 0:P.checkpointId)??le??void 0)},[b,w]),[q,k]=A.useState([]),[V,D]=A.useState(null),I=A.useCallback(async()=>{const P=await a.listThreads();k(P)},[a]);A.useEffect(()=>{I().catch(()=>{})},[I]),A.useEffect(()=>{n==null||n(V)},[V,n]);const J=A.useRef(null);A.useEffect(()=>{o&&J.current!==o&&(J.current=o,re(o).catch(()=>{}))},[o]);const Q=A.useRef(null),re=A.useCallback(async(P,M,Y)=>{if(Q.current!==P){Q.current=P;try{N(!1),U(null),L(void 0);const le=await a.getMessages({threadId:P,checkpointId:M,checkpointNs:Y,limit:E});D(P),$(le,"replace")}finally{Q.current=null}}},[a,$]),H=A.useRef(!1);A.useEffect(()=>{const P=H.current;if(H.current=c,P&&!c&&V){const M=h.lastCheckpointId??void 0;(async()=>{try{const Y=await a.getMessages({threadId:V,checkpointId:M,limit:E});$(Y,"replace")}catch{}try{await I()}catch{}})()}},[c,V,h.lastCheckpointId,a,$,I]);const R=A.useCallback(async P=>{const M=await a.createThread(P);return await I(),await re(M.threadId),M.threadId},[a,I,re]),ue=A.useCallback(async P=>{await a.deleteThread(P),await I(),V===P&&(D(null),C([]),N(!1),U(null),L(void 0))},[a,I,V,C]),de=A.useCallback(async(P,M)=>{await a.updateThread(P,M),await I()},[a,I]),j=A.useCallback(async(P,M)=>{var Ad;if(!V)throw new Error("No active thread");async function Y(ae){return await new Promise((Pe,_e)=>{const Ye=new FileReader;Ye.onload=()=>Pe(String(Ye.result)),Ye.onerror=mt=>_e(mt),Ye.readAsDataURL(ae)})}async function le(ae){return await new Promise((Pe,_e)=>{const Ye=new FileReader;Ye.onload=()=>{try{const mt=Ye.result;let Pd="";const _d=new Uint8Array(mt),pw=_d.byteLength;for(let Qo=0;Qo<pw;Qo++)Pd+=String.fromCharCode(_d[Qo]);Pe(btoa(Pd))}catch(mt){_e(mt)}},Ye.onerror=mt=>_e(mt),Ye.readAsArrayBuffer(ae)})}const me=[];P&&me.push({type:"text",text:P});const Ke=(M==null?void 0:M.attachments)||[];let W=[];if(Ke.length>0)for(const ae of Ke)if(ae.type&&ae.type.startsWith("image/")){let Pe=null;try{const _e=await a.uploadImage(ae,(t==null?void 0:t.uploadPath)||"/upload").catch(()=>null);Pe=(_e==null?void 0:_e.url)||null}catch{}if(!Pe)try{Pe=await Y(ae)}catch{Pe=null}if(Pe){const _e={type:"image_url",url:Pe,mimeType:ae.type,alt:ae.name};me.push(_e)}try{W.push({filename:ae.name,data:await le(ae),mime_type:ae.type||"application/octet-stream"})}catch{}}else{const Pe=await Y(ae).catch(()=>null),_e={type:"file",url:String(Pe),mimeType:ae.type||void 0,name:ae.name,size:ae.size};me.push(_e);try{W.push({filename:ae.name,data:await le(ae),mime_type:ae.type||"application/octet-stream"})}catch{}}const ne={id:((Ad=crypto.randomUUID)==null?void 0:Ad.call(crypto))||`user-${Date.now()}`,role:"user",content:me,createdAt:new Date().toISOString(),checkpointId:(M==null?void 0:M.checkpointId)??h.lastCheckpointId??void 0};y(ne);const fe={...ne,content:ne.content.filter(ae=>ae.type==="text"||ae.type==="image_url")},ie={...(M==null?void 0:M.payloadExtras)??{}},ot=!!ie.edit,bn=ie.originalMessageId,uw=typeof bn=="string"?bn:void 0,fw={threadId:V,payload:{messages:[fe],attachments:ne.content.filter(ae=>ae.type==="file").map(ae=>({type:"file",url:ae.url,mimeType:ae.mimeType,name:ae.name,size:ae.size})),files_info:W,...ie},checkpointId:(M==null?void 0:M.checkpointId)??h.lastCheckpointId??void 0,checkpointNs:M==null?void 0:M.checkpointNs,nodeFilter:M==null?void 0:M.nodeFilter,config:M==null?void 0:M.config,edit:ot,originalMessageId:uw};f(fw,ae=>x(ae),{onError:ae=>console.warn("stream error",ae)})},[V,y,f,x,h.lastCheckpointId,a,t==null?void 0:t.uploadPath]),K=A.useCallback(async P=>{if(!V)throw new Error("No active thread");if(F||!O)return;const M=_;if(M){B(!0);try{const Y=await a.getMessages({threadId:V,checkpointId:G,limit:(P==null?void 0:P.limit)??E,beforeId:M});$(Y,"prepend")}finally{B(!1)}}},[a,V,G,_,O,F,$]),oe={baseUrl:a.baseUrl,token:m,setToken:g,api:a,threads:q,currentThreadId:V,setCurrentThreadId:D,messages:h.messages,isStreaming:c,error:d,lastCheckpointId:h.lastCheckpointId,streamingAssistantId:h.assemblingId,hasMoreHistory:O,isLoadingHistory:F,loadOlderMessages:K,historyPageSize:E,refreshThreads:I,createThread:R,deleteThread:ue,renameThread:de,loadThread:re,send:j,stop:u};return i.jsx(Xs.Provider,{value:oe,children:e})}function $n(){const e=A.useContext(Xs);if(!e)throw new Error("useChat must be used within ChatProvider");return e}function T(...e){return Md.twMerge(Od.clsx(e))}const pf=Dt.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),ce=l.forwardRef(({className:e,variant:t,size:r,asChild:n=!1,...o},s)=>{const a=n?Se.Slot:"button";return i.jsx(a,{className:T(pf({variant:t,size:r,className:e})),ref:s,...o})});ce.displayName="Button";const Ys=l.forwardRef(({className:e,...t},r)=>i.jsx("textarea",{className:T("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...t}));Ys.displayName="Textarea";const hf=Dt.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Js({className:e,variant:t,...r}){return i.jsx("div",{className:T(hf({variant:t}),e),...r})}function z(e,t,{checkForDefaultPrevented:r=!0}={}){return function(o){if(e==null||e(o),r===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function gf(e,t){const r=l.createContext(t),n=s=>{const{children:a,...c}=s,d=l.useMemo(()=>c,Object.values(c));return i.jsx(r.Provider,{value:d,children:a})};n.displayName=e+"Provider";function o(s){const a=l.useContext(r);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[n,o]}function Oe(e,t=[]){let r=[];function n(s,a){const c=l.createContext(a),d=r.length;r=[...r,a];const f=p=>{var w;const{scope:m,children:v,...g}=p,h=((w=m==null?void 0:m[e])==null?void 0:w[d])||c,b=l.useMemo(()=>g,Object.values(g));return i.jsx(h.Provider,{value:b,children:v})};f.displayName=s+"Provider";function u(p,m){var h;const v=((h=m==null?void 0:m[e])==null?void 0:h[d])||c,g=l.useContext(v);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[f,u]}const o=()=>{const s=r.map(a=>l.createContext(a));return function(c){const d=(c==null?void 0:c[e])||s;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[n,mf(o,...t)]}function mf(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const n=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const a=n.reduce((c,{useScope:d,scopeName:f})=>{const p=d(s)[`__scope${f}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return r.scopeName=t.scopeName,r}var he=globalThis!=null&&globalThis.document?l.useLayoutEffect:()=>{},bf=l[" useInsertionEffect ".trim().toString()]||he;function Je({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[o,s,a]=vf({defaultProp:t,onChange:r}),c=e!==void 0,d=c?e:o;{const u=l.useRef(e!==void 0);l.useEffect(()=>{const p=u.current;p!==c&&console.warn(`${n} is changing from ${p?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=c},[c,n])}const f=l.useCallback(u=>{var p;if(c){const m=wf(u)?u(e):u;m!==e&&((p=a.current)==null||p.call(a,m))}else s(u)},[c,e,s,a]);return[d,f]}function vf({defaultProp:e,onChange:t}){const[r,n]=l.useState(e),o=l.useRef(r),s=l.useRef(t);return bf(()=>{s.current=t},[t]),l.useEffect(()=>{var a;o.current!==r&&((a=s.current)==null||a.call(s,r),o.current=r)},[r,o]),[r,n,s]}function wf(e){return typeof e=="function"}function Zs(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Bn(...e){return t=>{let r=!1;const n=e.map(o=>{const s=Zs(o,t);return!r&&typeof s=="function"&&(r=!0),s});if(r)return()=>{for(let o=0;o<n.length;o++){const s=n[o];typeof s=="function"?s():Zs(e[o],null)}}}}function se(...e){return l.useCallback(Bn(...e),e)}var yf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Z=yf.reduce((e,t)=>{const r=Se.createSlot(`Primitive.${t}`),n=l.forwardRef((o,s)=>{const{asChild:a,...c}=o,d=a?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(d,{...c,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function Qs(e,t){e&&ar.flushSync(()=>e.dispatchEvent(t))}function xf(e,t){return l.useReducer((r,n)=>t[r][n]??r,e)}var xe=e=>{const{present:t,children:r}=e,n=Sf(t),o=typeof r=="function"?r({present:n.isPresent}):l.Children.only(r),s=se(n.ref,Cf(o));return typeof r=="function"||n.isPresent?l.cloneElement(o,{ref:s}):null};xe.displayName="Presence";function Sf(e){const[t,r]=l.useState(),n=l.useRef(null),o=l.useRef(e),s=l.useRef("none"),a=e?"mounted":"unmounted",[c,d]=xf(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const f=wr(n.current);s.current=c==="mounted"?f:"none"},[c]),he(()=>{const f=n.current,u=o.current;if(u!==e){const m=s.current,v=wr(f);e?d("MOUNT"):v==="none"||(f==null?void 0:f.display)==="none"?d("UNMOUNT"):d(u&&m!==v?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),he(()=>{if(t){let f;const u=t.ownerDocument.defaultView??window,p=v=>{const h=wr(n.current).includes(CSS.escape(v.animationName));if(v.target===t&&h&&(d("ANIMATION_END"),!o.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",f=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},m=v=>{v.target===t&&(s.current=wr(n.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{u.clearTimeout(f),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:l.useCallback(f=>{n.current=f?getComputedStyle(f):null,r(f)},[])}}function wr(e){return(e==null?void 0:e.animationName)||"none"}function Cf(e){var n,o;let t=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Ef=l[" useId ".trim().toString()]||(()=>{}),Nf=0;function Me(e){const[t,r]=l.useState(Ef());return he(()=>{r(n=>n??String(Nf++))},[e]),t?`radix-${t}`:""}var yr="Collapsible",[Tf,Fw]=Oe(yr),[Af,Un]=Tf(yr),ea=l.forwardRef((e,t)=>{const{__scopeCollapsible:r,open:n,defaultOpen:o,disabled:s,onOpenChange:a,...c}=e,[d,f]=Je({prop:n,defaultProp:o??!1,onChange:a,caller:yr});return i.jsx(Af,{scope:r,disabled:s,contentId:Me(),open:d,onOpenToggle:l.useCallback(()=>f(u=>!u),[f]),children:i.jsx(Z.div,{"data-state":zn(d),"data-disabled":s?"":void 0,...c,ref:t})})});ea.displayName=yr;var ta="CollapsibleTrigger",ra=l.forwardRef((e,t)=>{const{__scopeCollapsible:r,...n}=e,o=Un(ta,r);return i.jsx(Z.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":zn(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...n,ref:t,onClick:z(e.onClick,o.onOpenToggle)})});ra.displayName=ta;var Hn="CollapsibleContent",Pf=l.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Un(Hn,e.__scopeCollapsible);return i.jsx(xe,{present:r||o.open,children:({present:s})=>i.jsx(_f,{...n,ref:t,present:s})})});Pf.displayName=Hn;var _f=l.forwardRef((e,t)=>{const{__scopeCollapsible:r,present:n,children:o,...s}=e,a=Un(Hn,r),[c,d]=l.useState(n),f=l.useRef(null),u=se(t,f),p=l.useRef(0),m=p.current,v=l.useRef(0),g=v.current,h=a.open||c,b=l.useRef(h),w=l.useRef(void 0);return l.useEffect(()=>{const y=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(y)},[]),he(()=>{const y=f.current;if(y){w.current=w.current||{transitionDuration:y.style.transitionDuration,animationName:y.style.animationName},y.style.transitionDuration="0s",y.style.animationName="none";const x=y.getBoundingClientRect();p.current=x.height,v.current=x.width,b.current||(y.style.transitionDuration=w.current.transitionDuration,y.style.animationName=w.current.animationName),d(n)}},[a.open,n]),i.jsx(Z.div,{"data-state":zn(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!h,...s,ref:u,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:h&&o})});function zn(e){return e?"open":"closed"}var If=ea;const na=If,oa=ra;function Wt({content:e,className:t=""}){const r=A.useMemo(()=>({table:({node:f,className:u,...p})=>i.jsx("div",{className:"max-w-full",children:i.jsx("table",{...p,className:T("w-full table-fixed border-collapse break-words",u)})}),th:({node:f,className:u,...p})=>i.jsx("th",{...p,className:T("break-words whitespace-normal border-b border-border/60 px-3 py-2 text-left align-top",u)}),td:({node:f,className:u,...p})=>i.jsx("td",{...p,className:T("break-words whitespace-normal border-b border-border/30 px-3 py-2 align-top",u)}),pre:({node:f,className:u,...p})=>i.jsx("pre",{...p,className:T("whitespace-pre-wrap break-words",u)}),code:({node:f,className:u,children:p,...m})=>{const{inline:v,...g}=m;return v?i.jsx("code",{...g,className:T("break-words whitespace-normal",u),children:p}):i.jsx("code",{...g,className:T("block break-words whitespace-pre-wrap",u),children:p})}}),[]),n=T("prose prose-sm max-w-none break-words dark:prose-invert leading-relaxed","prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words","prose-a:break-all prose-blockquote:break-words prose-strong:break-words prose-em:break-words","prose-code:break-words prose-pre:rounded prose-pre:border prose-pre:bg-background/50","prose-code:bg-background/50 prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-table:my-4 prose-th:px-2 prose-td:px-2",t);return i.jsx("div",{className:n,style:{wordBreak:"break-word",overflowWrap:"anywhere"},children:i.jsx(kd,{remarkPlugins:[Dd],components:r,children:e})})}const xr="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function Of({className:e}){const[t,r]=A.useState(0);return A.useEffect(()=>{const n=setInterval(()=>r(o=>(o+1)%4),500);return()=>clearInterval(n)},[]),i.jsxs("span",{"aria-live":"polite",className:T("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function sa({message:e,messageIndex:t,isStreamingMessage:r=!1,streamingDebounceMs:n=40,isEditing:o=!1,showActions:s=!0,showTimestamp:a=!0,showAgentName:c=!0,layoutSize:d="desktop",truncateToolMessages:f=!0,toolMessagePreviewLength:u=200,truncateUserMessages:p=!0,userMessagePreviewLength:m=200,customStyles:v={},onEdit:g,onRegenerate:h,onCancelEdit:b,onCopy:w}){const[y,x]=A.useState(!1),[C,E]=A.useState(!1),[O,N]=A.useState(!1),[F,B]=A.useState(!1),_=d==="phone"||d==="half-screen",U=e.role,G=U==="tool",L=A.useMemo(()=>{switch(U){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-foreground"}},[U]),$=A.useMemo(()=>Mf(e.content),[e.content]),q=A.useMemo(()=>Bf(e.content),[e.content]),k=A.useMemo(()=>e.content.filter(K=>K.type==="image_url"),[e.content]),V=A.useMemo(()=>e.content.filter(K=>K.type==="file"),[e.content]),D=Hf($,r?n:0),I=async()=>{try{const K=G?yt(e.content):$;await navigator.clipboard.writeText(K),x(!0),setTimeout(()=>x(!1),2e3),w==null||w(K)}catch(K){console.error("Failed to copy:",K)}},J=()=>{if(!g)return;const K=G?yt(e.content):$;g(e.id,K)},Q=()=>h==null?void 0:h(t),re=()=>{const oe=T(_?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",L);switch(U){case"user":return i.jsx(X.User,{className:oe});case"assistant":return i.jsx(X.Bot,{className:oe});case"tool":return i.jsx(X.Wrench,{className:oe});default:return i.jsx(X.Bot,{className:oe})}},H=()=>{const K="group relative mb-4 flex w-full";switch(U){case"user":return T(K,"justify-end");case"assistant":case"tool":case"system":return T(K,"justify-start");default:return K}},R=()=>{const K=T("rounded-lg px-4 py-3 relative transition-all duration-200 min-w-0 max-w-full break-words",_&&"px-3 py-2 text-sm");switch(U){case"user":return T(K,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return T(K,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return T(K,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return T(K,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return K}},ue=K=>{if(!K)return"";try{return new Date(K).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}},de=()=>{if(e.model==="reflection"){const P=$.trim(),M=Wn(P);if(M&&typeof M=="object")return i.jsx(zf,{data:M})}if(G&&q.name==="get_issues"){const P=e.content.find(le=>le.type==="tool_result"),M=(P==null?void 0:P.output)??yt(e.content),Y=ia(M);if(Y)return i.jsx(Wf,{issues:Y})}if(G&&!O){const P=yt(e.content).slice(0,80).replace(/\s+/g," ");return i.jsx("div",{className:T("text-xs font-mono opacity-70 flex items-center justify-between gap-2 text-current",_&&"text-[10px]"),children:i.jsxs("span",{className:"truncate max-w-full text-current",children:[P,P.length>=80?"…":""]})})}if(G&&f){const P=yt(e.content),M=P.length>u;return i.jsx(na,{open:C,onOpenChange:E,children:i.jsxs("div",{className:"font-mono text-sm text-current",children:[i.jsx("pre",{className:T("whitespace-pre-wrap break-words text-current",_&&"text-xs"),children:M&&!C?P.substring(0,u)+"...":P}),M&&i.jsx(oa,{asChild:!0,children:i.jsx(ce,{variant:"ghost",size:"sm",className:"h-6 text-xs text-current",children:C?i.jsxs(i.Fragment,{children:[i.jsx(X.ChevronUp,{className:"h-3 w-3 mr-1"}),"Show less"]}):i.jsxs(i.Fragment,{children:[i.jsx(X.ChevronDown,{className:"h-3 w-3 mr-1"}),"Show more (",P.length-u," chars)"]})})})]})})}if(G&&O&&!f){const P=$f(e.content);if(P&&kf(P))return i.jsx(Wt,{content:P.trim()});const M=yt(e.content);return i.jsx("div",{className:"font-mono text-sm text-current",children:i.jsx("pre",{className:T("whitespace-pre-wrap break-words text-current",_&&"text-xs"),children:M})})}const K=k.length>0&&U!=="tool",oe=V.length>0&&U!=="tool";return i.jsxs("div",{children:[r?i.jsxs("div",{className:"relative",children:[(()=>{const P=Wn(D);return P!==null?i.jsx(aa,{data:P}):i.jsx(Wt,{content:Lf(Df(D))})})(),i.jsx(Of,{className:T(L,_?"text-xs":"text-sm")})]}):(()=>{const P=Wn($.trim());if(P!==null)return i.jsx(aa,{data:P});if(U==="user"&&p){const M=$.trim();if(M.length>m)return i.jsxs(na,{open:F,onOpenChange:B,children:[i.jsx("div",{className:T("text-sm text-[hsl(var(--chat-bubble-user-text))]",_&&"text-xs"),children:F?i.jsx(Wt,{content:M}):i.jsxs("pre",{className:T("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",_&&"text-xs"),children:[M.substring(0,m),"..."]})}),i.jsx(oa,{asChild:!0,children:i.jsx(ce,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:F?i.jsxs(i.Fragment,{children:[i.jsx(X.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):i.jsxs(i.Fragment,{children:[i.jsx(X.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",M.length-m," chars)"]})})})]})}return i.jsx(Wt,{content:$.trim()})})(),K&&i.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:k.map((P,M)=>i.jsxs("div",{className:"relative border rounded overflow-hidden",children:[i.jsx("img",{src:P.url,alt:P.alt??"image",className:"w-full h-auto"}),i.jsxs("div",{className:"absolute top-1 right-1 bg-background/70 rounded px-1 py-0.5 text-[10px] flex items-center gap-1",children:[i.jsx(X.Image,{className:"h-3 w-3"}),i.jsx("span",{children:"image"})]})]},M))}),oe&&i.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:V.map((P,M)=>{const Y=P,le=Y.name||"file";return i.jsxs("a",{href:Y.url,download:le,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-2 bg-gray-100 border border-gray-200 rounded px-2 py-1 text-xs hover:bg-gray-200",title:le,children:[i.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-gray-400"}),i.jsx("span",{className:"truncate max-w-[180px]",children:le})]},M)})})]})},j=A.useMemo(()=>Uf(e),[e]);return i.jsx("div",{className:T(H(),v.container),children:i.jsxs("div",{className:T(R(),v.content),children:[(a||c||G)&&i.jsxs("div",{className:T("flex items-center justify-between mb-2 pb-2 border-b border-current/10",_&&"mb-1 pb-1",L,v.header),children:[i.jsxs("div",{className:"flex items-center gap-2",children:[re(),c&&j&&i.jsx("span",{className:T("font-medium",_?"text-xs":"text-sm"),children:j}),G&&q.name&&i.jsxs(Js,{variant:"outline",className:T("text-xs flex items-center gap-1 cursor-pointer",L,"border border-current/40",_&&"text-xs h-4"),onClick:()=>N(K=>!K),children:[i.jsx("span",{children:q.name}),i.jsx("span",{className:"inline-flex items-center",children:O?i.jsx(X.ChevronUp,{className:"h-3 w-3"}):i.jsx(X.ChevronDown,{className:"h-3 w-3"})})]}),G&&!q.name&&i.jsx(ce,{variant:"ghost",size:"sm",className:T("h-6 px-1",L,"hover:bg-foreground/10"),onClick:()=>N(K=>!K),children:i.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",O?i.jsx(X.ChevronUp,{className:"h-3 w-3"}):i.jsx(X.ChevronDown,{className:"h-3 w-3"})]})})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[a&&i.jsx("span",{className:T("text-xs opacity-60",L,_&&"text-xs"),children:ue(e.createdAt)}),s&&!o&&i.jsxs("div",{className:T("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",v.actions),children:[i.jsx(ce,{variant:"ghost",size:"sm",onClick:I,className:T("h-6 w-6 p-0 hover:bg-foreground/10",L,_&&"h-5 w-5"),children:i.jsx(X.Copy,{className:T(y?"text-success":L,_?"h-3 w-3":"h-4 w-4")})}),U==="user"&&g&&i.jsx(ce,{variant:"ghost",size:"sm",onClick:J,className:T("h-6 w-6 p-0 hover:bg-foreground/10",L,_&&"h-5 w-5"),children:i.jsx(X.Edit,{className:T(L,_?"h-3 w-3":"h-4 w-4")})}),U==="assistant"&&h&&i.jsx(ce,{variant:"ghost",size:"sm",onClick:Q,className:T("h-6 w-6 p-0 hover:bg-foreground/10",L,_&&"h-5 w-5"),children:i.jsx(X.RotateCcw,{className:T(L,_?"h-3 w-3":"h-4 w-4")})})]})]})]}),i.jsx("div",{className:"relative",children:de()}),G&&O&&(q.toolCallId||q.name)&&i.jsxs("div",{className:T("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",_&&"text-xs"),children:[q.name&&i.jsxs("div",{children:["Function: ",q.name]}),q.toolCallId&&i.jsxs("div",{children:["Call ID: ",q.toolCallId]})]}),!(a||c||G)&&s&&!o&&i.jsxs("div",{className:T("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",v.actions),children:[i.jsx(ce,{variant:"ghost",size:"sm",onClick:I,className:T("h-6 w-6 p-0 hover:bg-background/50 text-current",_&&"h-5 w-5"),children:i.jsx(X.Copy,{className:T(y?"text-success":"text-current",_?"h-3 w-3":"h-4 w-4")})}),U==="user"&&g&&i.jsx(ce,{variant:"ghost",size:"sm",onClick:J,className:T("h-6 w-6 p-0 hover:bg-background/50 text-current",_&&"h-5 w-5"),children:i.jsx(X.Edit,{className:T("text-current",_?"h-3 w-3":"h-4 w-4")})}),U==="assistant"&&h&&i.jsx(ce,{variant:"ghost",size:"sm",onClick:Q,className:T("h-6 w-6 p-0 hover:bg-background/50 text-current",_&&"h-5 w-5"),children:i.jsx(X.RotateCcw,{className:T("text-current",_?"h-3 w-3":"h-4 w-4")})})]})]})})}function Mf(e){const t=e.filter(r=>r.type==="text").map(r=>r.text).join("");return t||JSON.stringify(e)}function kf(e){return e.includes(`
10
+ `)||e.includes("```")||/[-*] /.test(e)||/#+\s/.test(e)}function Df(e){let t=e;try{(t.match(/```/g)||[]).length%2===1&&(t+="\n```"),(t.replace(/```[\s\S]*?```/g,"").match(new RegExp("(?<!`)`(?!`)","g"))||[]).length%2===1&&(t+="`")}catch{}return t}function Lf(e){let t=e;try{const r=[],n=[],o="\0F",s="\0I";let a=t.replace(/```[\s\S]*?```/g,c=>(r.push(c),`${o}${r.length-1}\0`));a=a.replace(/`[^`]*`/g,c=>(n.push(c),`${s}${n.length-1}\0`)),a=a.replace(/\b([A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/\b([A-Za-z0-9_&\/-]+\s+[A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/([\.,;:!\?\-])\1+/g,"$1").replace(/([:;!\?\)])([A-Za-z])/g,"$1 $2").replace(/\s{3,}/g," "),a=a.replace(/\u0000F(\d+)\u0000/g,(c,d)=>r[Number(d)]??""),a=a.replace(/\u0000I(\d+)\u0000/g,(c,d)=>n[Number(d)]??""),t=a}catch{}return t}function Wn(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function aa({data:e}){if(Array.isArray(e))return e.every(r=>r===null||["string","number","boolean"].includes(typeof r))?i.jsx("div",{className:xr,children:i.jsx("ul",{className:"list-disc pl-5",children:e.map((r,n)=>i.jsx("li",{children:String(r)},n))})}):i.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Rt(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,r=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,n=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||r||typeof n=="boolean")return i.jsxs("div",{className:xr,children:[typeof n=="boolean"&&i.jsxs("p",{children:[i.jsx("strong",{children:"Is sufficient:"})," ",n?"Yes":"No"]}),r&&r.length>0&&i.jsxs("div",{children:[i.jsx("p",{children:i.jsx("strong",{children:"Follow-up queries:"})}),i.jsx("ul",{className:"list-disc pl-5",children:r.map((s,a)=>i.jsx("li",{children:String(s)},a))})]}),t&&t.length>0&&i.jsxs("div",{children:[i.jsx("p",{children:i.jsx("strong",{children:"Facts:"})}),i.jsx("ul",{className:"list-disc pl-5",children:t.map((s,a)=>i.jsx("li",{children:String(s)},a))})]})]});const o=Object.entries(e);return i.jsx("div",{className:xr,children:i.jsx("dl",{className:"mt-0",children:o.map(([s,a])=>i.jsxs("div",{className:"mb-1",children:[i.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),i.jsx("dd",{className:"inline",children:Ff(a)})]},s))})})}return i.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Rt(e)})}function Ff(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(n=>n===null||["string","number","boolean"].includes(typeof n)))return e.join(", ");try{return i.jsx("code",{className:"text-xs",children:JSON.stringify(e)})}catch{return String(e)}}function yt(e){const t=e.filter(r=>r.type==="tool_result");if(t.length)try{return t.length===1?Rt(t[0].output):Rt(t.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return Rt(e)}function $f(e){const t=e.find(n=>n.type==="tool_result");if(!t)return null;const r=t.output;return typeof r=="string"?r:null}function Rt(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Bf(e){const t=e.find(n=>n.type==="tool_call"),r=e.find(n=>n.type==="tool_result");return{name:t==null?void 0:t.name,toolCallId:(r==null?void 0:r.toolCallId)??(t==null?void 0:t.id)}}function Uf(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Hf(e,t){const[r,n]=A.useState(e);return A.useEffect(()=>{if(!t){n(e);return}const o=setTimeout(()=>n(e),t);return()=>clearTimeout(o)},[e,t]),r}function zf({data:e}){return i.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,r])=>i.jsxs("div",{className:"flex",children:[i.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),i.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(r)?r.map((n,o)=>i.jsxs("div",{className:"ml-4 break-words",children:["- ",String(n)]},o)):String(r)})]},t))})}function ia(e){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){if(e.desirability||e.feasibility||e.viability||e.other)return{desirability:Array.isArray(e.desirability)?e.desirability:[],feasibility:Array.isArray(e.feasibility)?e.feasibility:[],viability:Array.isArray(e.viability)?e.viability:[],other:Array.isArray(e.other)?e.other:[]};if(e.output&&typeof e.output!="object")e=e.output;else if(e.output&&typeof e.output=="object")return ia(e.output)}const t=String(e),r={desirability:[],feasibility:[],viability:[],other:[]};let n=t;const o=Math.min(...["desirability=","feasibility=","viability=","other="].map(a=>{const c=n.toLowerCase().indexOf(a);return c===-1?Number.MAX_SAFE_INTEGER:c}));o!==Number.MAX_SAFE_INTEGER&&(n=n.slice(o));for(const a of Object.keys(r)){const d=new RegExp(a+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(n);if(!d)continue;const f=d[1],u=/Issue\(([\s\S]*?)\)(?:,|$)/g;let p=null;for(;(p=u.exec(f))!==null;){const m=p[1],v=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(m),g=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(m),h=v?v[2].trim():"",b=g?g[2].trim():"";r[a].push({title:h,description:b})}}return Object.values(r).some(a=>a.length>0)?r:null}function Wf({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return i.jsx("div",{className:xr,children:t.map(r=>{const n=e[r.key];return!n||!n.length?null:i.jsxs("div",{className:"mb-4",children:[i.jsxs("h4",{className:"font-semibold mb-2",children:[r.title," (",n.length,")"]}),i.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:n.map((o,s)=>i.jsxs("li",{children:[i.jsx("div",{className:"font-medium",children:o.title}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},r.key)})})}const xt=1e4;function Rf(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let r=e;for(const o of t)r=r.replace(o,"");return/<[^>]+>/.test(r)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(r)?r.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
11
11
  `).replace(/<p>(.*?)<\/p>/gi,`$1
12
12
 
13
13
  `).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,a)=>`${"#".repeat(parseInt(s))} ${a}
@@ -15,48 +15,48 @@
15
15
  `).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
16
16
  `).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
17
17
  `).replace(/<li>(.*?)<\/li>/gi,`- $1
18
- `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function gp(e,t=Bt){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function mp(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),gp(t),hp(t)}function go(e){const t=e+"CollectionProvider",[n,r]=Ke(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=h=>{const{scope:b,children:w}=h,y=N.useRef(null),x=N.useRef(new Map).current;return i.jsx(o,{scope:b,itemMap:x,collectionRef:y,children:w})};a.displayName=t;const c=e+"CollectionSlot",d=Be.createSlot(c),f=N.forwardRef((h,b)=>{const{scope:w,children:y}=h,x=s(c,w),C=ue(b,x.collectionRef);return i.jsx(d,{ref:C,children:y})});f.displayName=c;const u=e+"CollectionItemSlot",p="data-radix-collection-item",m=Be.createSlot(u),v=N.forwardRef((h,b)=>{const{scope:w,children:y,...x}=h,C=N.useRef(null),E=ue(b,C),P=s(u,w);return N.useEffect(()=>(P.itemMap.set(C,{ref:C,...x}),()=>void P.itemMap.delete(C))),i.jsx(m,{[p]:"",ref:E,children:y})});v.displayName=u;function g(h){const b=s(e+"CollectionConsumer",h);return N.useCallback(()=>{const y=b.collectionRef.current;if(!y)return[];const x=Array.from(y.querySelectorAll(`[${p}]`));return Array.from(b.itemMap.values()).sort((P,T)=>x.indexOf(P.ref.current)-x.indexOf(T.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:a,Slot:f,ItemSlot:v},g,r]}var bp=l.createContext(void 0);function Wn(e){const t=l.useContext(bp);return e||t||"ltr"}function Ae(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function vp(e,t=globalThis==null?void 0:globalThis.document){const n=Ae(e);l.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var wp="DismissableLayer",mo="dismissableLayer.update",yp="dismissableLayer.pointerDownOutside",xp="dismissableLayer.focusOutside",La,Fa=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),cn=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:c,...d}=e,f=l.useContext(Fa),[u,p]=l.useState(null),m=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,v]=l.useState({}),g=ue(t,T=>p(T)),h=Array.from(f.layers),[b]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),w=h.indexOf(b),y=u?h.indexOf(u):-1,x=f.layersWithOutsidePointerEventsDisabled.size>0,C=y>=w,E=Ep(T=>{const F=T.target,M=[...f.branches].some(B=>B.contains(F));!C||M||(o==null||o(T),a==null||a(T),T.defaultPrevented||c==null||c())},m),P=Np(T=>{const F=T.target;[...f.branches].some(B=>B.contains(F))||(s==null||s(T),a==null||a(T),T.defaultPrevented||c==null||c())},m);return vp(T=>{y===f.layers.size-1&&(r==null||r(T),!T.defaultPrevented&&c&&(T.preventDefault(),c()))},m),l.useEffect(()=>{if(u)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(La=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(u)),f.layers.add(u),$a(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=La)}},[u,m,n,f]),l.useEffect(()=>()=>{u&&(f.layers.delete(u),f.layersWithOutsidePointerEventsDisabled.delete(u),$a())},[u,f]),l.useEffect(()=>{const T=()=>v({});return document.addEventListener(mo,T),()=>document.removeEventListener(mo,T)},[]),i.jsx(oe.div,{...d,ref:g,style:{pointerEvents:x?C?"auto":"none":void 0,...e.style},onFocusCapture:U(e.onFocusCapture,P.onFocusCapture),onBlurCapture:U(e.onBlurCapture,P.onBlurCapture),onPointerDownCapture:U(e.onPointerDownCapture,E.onPointerDownCapture)})});cn.displayName=wp;var Sp="DismissableLayerBranch",Cp=l.forwardRef((e,t)=>{const n=l.useContext(Fa),r=l.useRef(null),o=ue(t,r);return l.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),i.jsx(oe.div,{...e,ref:o})});Cp.displayName=Sp;function Ep(e,t=globalThis==null?void 0:globalThis.document){const n=Ae(e),r=l.useRef(!1),o=l.useRef(()=>{});return l.useEffect(()=>{const s=c=>{if(c.target&&!r.current){let d=function(){Ba(yp,n,f,{discrete:!0})};const f={originalEvent:c};c.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=d,t.addEventListener("click",o.current,{once:!0})):d()}else t.removeEventListener("click",o.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Np(e,t=globalThis==null?void 0:globalThis.document){const n=Ae(e),r=l.useRef(!1);return l.useEffect(()=>{const o=s=>{s.target&&!r.current&&Ba(xp,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function $a(){const e=new CustomEvent(mo);document.dispatchEvent(e)}function Ba(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Ta(o,s):o.dispatchEvent(s)}var bo=0;function vo(){l.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ua()),document.body.insertAdjacentElement("beforeend",e[1]??Ua()),bo++,()=>{bo===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),bo--}},[])}function Ua(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var wo="focusScope.autoFocusOnMount",yo="focusScope.autoFocusOnUnmount",Ha={bubbles:!1,cancelable:!0},Tp="FocusScope",Vn=l.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=e,[c,d]=l.useState(null),f=Ae(o),u=Ae(s),p=l.useRef(null),m=ue(t,h=>d(h)),v=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(r){let h=function(x){if(v.paused||!c)return;const C=x.target;c.contains(C)?p.current=C:bt(p.current,{select:!0})},b=function(x){if(v.paused||!c)return;const C=x.relatedTarget;C!==null&&(c.contains(C)||bt(p.current,{select:!0}))},w=function(x){if(document.activeElement===document.body)for(const E of x)E.removedNodes.length>0&&bt(c)};document.addEventListener("focusin",h),document.addEventListener("focusout",b);const y=new MutationObserver(w);return c&&y.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",b),y.disconnect()}}},[r,c,v.paused]),l.useEffect(()=>{if(c){Va.add(v);const h=document.activeElement;if(!c.contains(h)){const w=new CustomEvent(wo,Ha);c.addEventListener(wo,f),c.dispatchEvent(w),w.defaultPrevented||(Ap(Op(za(c)),{select:!0}),document.activeElement===h&&bt(c))}return()=>{c.removeEventListener(wo,f),setTimeout(()=>{const w=new CustomEvent(yo,Ha);c.addEventListener(yo,u),c.dispatchEvent(w),w.defaultPrevented||bt(h??document.body,{select:!0}),c.removeEventListener(yo,u),Va.remove(v)},0)}}},[c,f,u,v]);const g=l.useCallback(h=>{if(!n&&!r||v.paused)return;const b=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,w=document.activeElement;if(b&&w){const y=h.currentTarget,[x,C]=Ip(y);x&&C?!h.shiftKey&&w===C?(h.preventDefault(),n&&bt(x,{select:!0})):h.shiftKey&&w===x&&(h.preventDefault(),n&&bt(C,{select:!0})):w===y&&h.preventDefault()}},[n,r,v.paused]);return i.jsx(oe.div,{tabIndex:-1,...a,ref:m,onKeyDown:g})});Vn.displayName=Tp;function Ap(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(bt(r,{select:t}),document.activeElement!==n)return}function Ip(e){const t=za(e),n=Wa(t,e),r=Wa(t.reverse(),e);return[n,r]}function za(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Wa(e,t){for(const n of e)if(!kp(n,{upTo:t}))return n}function kp(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function _p(e){return e instanceof HTMLInputElement&&"select"in e}function bt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&_p(e)&&t&&e.select()}}var Va=Pp();function Pp(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ja(e,t),e.unshift(t)},remove(t){var n;e=ja(e,t),(n=e[0])==null||n.resume()}}}function ja(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Op(e){return e.filter(t=>t.tagName!=="A")}const Mp=["top","right","bottom","left"],vt=Math.min,Ue=Math.max,jn=Math.round,Rn=Math.floor,st=e=>({x:e,y:e}),Dp={left:"right",right:"left",bottom:"top",top:"bottom"},Lp={start:"end",end:"start"};function xo(e,t,n){return Ue(e,vt(t,n))}function ft(e,t){return typeof e=="function"?e(t):e}function pt(e){return e.split("-")[0]}function Ut(e){return e.split("-")[1]}function So(e){return e==="x"?"y":"x"}function Co(e){return e==="y"?"height":"width"}const Fp=new Set(["top","bottom"]);function at(e){return Fp.has(pt(e))?"y":"x"}function Eo(e){return So(at(e))}function $p(e,t,n){n===void 0&&(n=!1);const r=Ut(e),o=Eo(e),s=Co(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Kn(a)),[a,Kn(a)]}function Bp(e){const t=Kn(e);return[No(e),t,No(t)]}function No(e){return e.replace(/start|end/g,t=>Lp[t])}const Ra=["left","right"],Ka=["right","left"],Up=["top","bottom"],Hp=["bottom","top"];function zp(e,t,n){switch(e){case"top":case"bottom":return n?t?Ka:Ra:t?Ra:Ka;case"left":case"right":return t?Up:Hp;default:return[]}}function Wp(e,t,n,r){const o=Ut(e);let s=zp(pt(e),n==="start",r);return o&&(s=s.map(a=>a+"-"+o),t&&(s=s.concat(s.map(No)))),s}function Kn(e){return e.replace(/left|right|bottom|top/g,t=>Dp[t])}function Vp(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ga(e){return typeof e!="number"?Vp(e):{top:e,right:e,bottom:e,left:e}}function Gn(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function qa(e,t,n){let{reference:r,floating:o}=e;const s=at(t),a=Eo(t),c=Co(a),d=pt(t),f=s==="y",u=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[c]/2-o[c]/2;let v;switch(d){case"top":v={x:u,y:r.y-o.height};break;case"bottom":v={x:u,y:r.y+r.height};break;case"right":v={x:r.x+r.width,y:p};break;case"left":v={x:r.x-o.width,y:p};break;default:v={x:r.x,y:r.y}}switch(Ut(t)){case"start":v[a]-=m*(n&&f?-1:1);break;case"end":v[a]+=m*(n&&f?-1:1);break}return v}const jp=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:a}=n,c=s.filter(Boolean),d=await(a.isRTL==null?void 0:a.isRTL(t));let f=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:p}=qa(f,r,d),m=r,v={},g=0;for(let h=0;h<c.length;h++){const{name:b,fn:w}=c[h],{x:y,y:x,data:C,reset:E}=await w({x:u,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:v,rects:f,platform:a,elements:{reference:e,floating:t}});u=y??u,p=x??p,v={...v,[b]:{...v[b],...C}},E&&g<=50&&(g++,typeof E=="object"&&(E.placement&&(m=E.placement),E.rects&&(f=E.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):E.rects),{x:u,y:p}=qa(f,m,d)),h=-1)}return{x:u,y:p,placement:m,strategy:o,middlewareData:v}};async function ln(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:a,elements:c,strategy:d}=e,{boundary:f="clippingAncestors",rootBoundary:u="viewport",elementContext:p="floating",altBoundary:m=!1,padding:v=0}=ft(t,e),g=Ga(v),b=c[m?p==="floating"?"reference":"floating":p],w=Gn(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(b)))==null||n?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(c.floating)),boundary:f,rootBoundary:u,strategy:d})),y=p==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c.floating)),C=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},E=Gn(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:y,offsetParent:x,strategy:d}):y);return{top:(w.top-E.top+g.top)/C.y,bottom:(E.bottom-w.bottom+g.bottom)/C.y,left:(w.left-E.left+g.left)/C.x,right:(E.right-w.right+g.right)/C.x}}const Rp=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:a,elements:c,middlewareData:d}=t,{element:f,padding:u=0}=ft(e,t)||{};if(f==null)return{};const p=Ga(u),m={x:n,y:r},v=Eo(o),g=Co(v),h=await a.getDimensions(f),b=v==="y",w=b?"top":"left",y=b?"bottom":"right",x=b?"clientHeight":"clientWidth",C=s.reference[g]+s.reference[v]-m[v]-s.floating[g],E=m[v]-s.reference[v],P=await(a.getOffsetParent==null?void 0:a.getOffsetParent(f));let T=P?P[x]:0;(!T||!await(a.isElement==null?void 0:a.isElement(P)))&&(T=c.floating[x]||s.floating[g]);const F=C/2-E/2,M=T/2-h[g]/2-1,B=vt(p[w],M),V=vt(p[y],M),J=B,H=T-h[g]-V,O=T/2-h[g]/2+F,ne=xo(J,O,H),L=!d.arrow&&Ut(o)!=null&&O!==ne&&s.reference[g]/2-(O<J?B:V)-h[g]/2<0,z=L?O<J?O-J:O-H:0;return{[v]:m[v]+z,data:{[v]:ne,centerOffset:O-ne-z,...L&&{alignmentOffset:z}},reset:L}}}),Kp=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:a,initialPlacement:c,platform:d,elements:f}=t,{mainAxis:u=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...b}=ft(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=pt(o),y=at(c),x=pt(c)===c,C=await(d.isRTL==null?void 0:d.isRTL(f.floating)),E=m||(x||!h?[Kn(c)]:Bp(c)),P=g!=="none";!m&&P&&E.push(...Wp(c,h,g,C));const T=[c,...E],F=await ln(t,b),M=[];let B=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&M.push(F[w]),p){const O=$p(o,a,C);M.push(F[O[0]],F[O[1]])}if(B=[...B,{placement:o,overflows:M}],!M.every(O=>O<=0)){var V,J;const O=(((V=s.flip)==null?void 0:V.index)||0)+1,ne=T[O];if(ne&&(!(p==="alignment"?y!==at(ne):!1)||B.every(k=>at(k.placement)===y?k.overflows[0]>0:!0)))return{data:{index:O,overflows:B},reset:{placement:ne}};let L=(J=B.filter(z=>z.overflows[0]<=0).sort((z,k)=>z.overflows[1]-k.overflows[1])[0])==null?void 0:J.placement;if(!L)switch(v){case"bestFit":{var H;const z=(H=B.filter(k=>{if(P){const I=at(k.placement);return I===y||I==="y"}return!0}).map(k=>[k.placement,k.overflows.filter(I=>I>0).reduce((I,Z)=>I+Z,0)]).sort((k,I)=>k[1]-I[1])[0])==null?void 0:H[0];z&&(L=z);break}case"initialPlacement":L=c;break}if(o!==L)return{reset:{placement:L}}}return{}}}};function Xa(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ya(e){return Mp.some(t=>e[t]>=0)}const Gp=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=ft(e,t);switch(r){case"referenceHidden":{const s=await ln(t,{...o,elementContext:"reference"}),a=Xa(s,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Ya(a)}}}case"escaped":{const s=await ln(t,{...o,altBoundary:!0}),a=Xa(s,n.floating);return{data:{escapedOffsets:a,escaped:Ya(a)}}}default:return{}}}}},Ja=new Set(["left","top"]);async function qp(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=pt(n),c=Ut(n),d=at(n)==="y",f=Ja.has(a)?-1:1,u=s&&d?-1:1,p=ft(t,e);let{mainAxis:m,crossAxis:v,alignmentAxis:g}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return c&&typeof g=="number"&&(v=c==="end"?g*-1:g),d?{x:v*u,y:m*f}:{x:m*f,y:v*u}}const Xp=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:a,middlewareData:c}=t,d=await qp(t,e);return a===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:o+d.x,y:s+d.y,data:{...d,placement:a}}}}},Yp=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:a=!1,limiter:c={fn:b=>{let{x:w,y}=b;return{x:w,y}}},...d}=ft(e,t),f={x:n,y:r},u=await ln(t,d),p=at(pt(o)),m=So(p);let v=f[m],g=f[p];if(s){const b=m==="y"?"top":"left",w=m==="y"?"bottom":"right",y=v+u[b],x=v-u[w];v=xo(y,v,x)}if(a){const b=p==="y"?"top":"left",w=p==="y"?"bottom":"right",y=g+u[b],x=g-u[w];g=xo(y,g,x)}const h=c.fn({...t,[m]:v,[p]:g});return{...h,data:{x:h.x-n,y:h.y-r,enabled:{[m]:s,[p]:a}}}}}},Jp=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:a}=t,{offset:c=0,mainAxis:d=!0,crossAxis:f=!0}=ft(e,t),u={x:n,y:r},p=at(o),m=So(p);let v=u[m],g=u[p];const h=ft(c,t),b=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(d){const x=m==="y"?"height":"width",C=s.reference[m]-s.floating[x]+b.mainAxis,E=s.reference[m]+s.reference[x]-b.mainAxis;v<C?v=C:v>E&&(v=E)}if(f){var w,y;const x=m==="y"?"width":"height",C=Ja.has(pt(o)),E=s.reference[p]-s.floating[x]+(C&&((w=a.offset)==null?void 0:w[p])||0)+(C?0:b.crossAxis),P=s.reference[p]+s.reference[x]+(C?0:((y=a.offset)==null?void 0:y[p])||0)-(C?b.crossAxis:0);g<E?g=E:g>P&&(g=P)}return{[m]:v,[p]:g}}}},Zp=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:a,elements:c}=t,{apply:d=()=>{},...f}=ft(e,t),u=await ln(t,f),p=pt(o),m=Ut(o),v=at(o)==="y",{width:g,height:h}=s.floating;let b,w;p==="top"||p==="bottom"?(b=p,w=m===(await(a.isRTL==null?void 0:a.isRTL(c.floating))?"start":"end")?"left":"right"):(w=p,b=m==="end"?"top":"bottom");const y=h-u.top-u.bottom,x=g-u.left-u.right,C=vt(h-u[b],y),E=vt(g-u[w],x),P=!t.middlewareData.shift;let T=C,F=E;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(F=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(T=y),P&&!m){const B=Ue(u.left,0),V=Ue(u.right,0),J=Ue(u.top,0),H=Ue(u.bottom,0);v?F=g-2*(B!==0||V!==0?B+V:Ue(u.left,u.right)):T=h-2*(J!==0||H!==0?J+H:Ue(u.top,u.bottom))}await d({...t,availableWidth:F,availableHeight:T});const M=await a.getDimensions(c.floating);return g!==M.width||h!==M.height?{reset:{rects:!0}}:{}}}};function qn(){return typeof window<"u"}function Ht(e){return Za(e)?(e.nodeName||"").toLowerCase():"#document"}function He(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function it(e){var t;return(t=(Za(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Za(e){return qn()?e instanceof Node||e instanceof He(e).Node:!1}function qe(e){return qn()?e instanceof Element||e instanceof He(e).Element:!1}function ct(e){return qn()?e instanceof HTMLElement||e instanceof He(e).HTMLElement:!1}function Qa(e){return!qn()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof He(e).ShadowRoot}const Qp=new Set(["inline","contents"]);function dn(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Xe(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Qp.has(o)}const eh=new Set(["table","td","th"]);function th(e){return eh.has(Ht(e))}const nh=[":popover-open",":modal"];function Xn(e){return nh.some(t=>{try{return e.matches(t)}catch{return!1}})}const rh=["transform","translate","scale","rotate","perspective"],oh=["transform","translate","scale","rotate","perspective","filter"],sh=["paint","layout","strict","content"];function To(e){const t=Ao(),n=qe(e)?Xe(e):e;return rh.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||oh.some(r=>(n.willChange||"").includes(r))||sh.some(r=>(n.contain||"").includes(r))}function ah(e){let t=wt(e);for(;ct(t)&&!zt(t);){if(To(t))return t;if(Xn(t))return null;t=wt(t)}return null}function Ao(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const ih=new Set(["html","body","#document"]);function zt(e){return ih.has(Ht(e))}function Xe(e){return He(e).getComputedStyle(e)}function Yn(e){return qe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function wt(e){if(Ht(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Qa(e)&&e.host||it(e);return Qa(t)?t.host:t}function ei(e){const t=wt(e);return zt(t)?e.ownerDocument?e.ownerDocument.body:e.body:ct(t)&&dn(t)?t:ei(t)}function un(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ei(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),a=He(o);if(s){const c=Io(a);return t.concat(a,a.visualViewport||[],dn(o)?o:[],c&&n?un(c):[])}return t.concat(o,un(o,[],n))}function Io(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ti(e){const t=Xe(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=ct(e),s=o?e.offsetWidth:n,a=o?e.offsetHeight:r,c=jn(n)!==s||jn(r)!==a;return c&&(n=s,r=a),{width:n,height:r,$:c}}function ko(e){return qe(e)?e:e.contextElement}function Wt(e){const t=ko(e);if(!ct(t))return st(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=ti(t);let a=(s?jn(n.width):n.width)/r,c=(s?jn(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!c||!Number.isFinite(c))&&(c=1),{x:a,y:c}}const ch=st(0);function ni(e){const t=He(e);return!Ao()||!t.visualViewport?ch:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function lh(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==He(e)?!1:t}function At(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ko(e);let a=st(1);t&&(r?qe(r)&&(a=Wt(r)):a=Wt(e));const c=lh(s,n,r)?ni(s):st(0);let d=(o.left+c.x)/a.x,f=(o.top+c.y)/a.y,u=o.width/a.x,p=o.height/a.y;if(s){const m=He(s),v=r&&qe(r)?He(r):r;let g=m,h=Io(g);for(;h&&r&&v!==g;){const b=Wt(h),w=h.getBoundingClientRect(),y=Xe(h),x=w.left+(h.clientLeft+parseFloat(y.paddingLeft))*b.x,C=w.top+(h.clientTop+parseFloat(y.paddingTop))*b.y;d*=b.x,f*=b.y,u*=b.x,p*=b.y,d+=x,f+=C,g=He(h),h=Io(g)}}return Gn({width:u,height:p,x:d,y:f})}function Jn(e,t){const n=Yn(e).scrollLeft;return t?t.left+n:At(it(e)).left+n}function ri(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Jn(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function dh(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",a=it(r),c=t?Xn(t.floating):!1;if(r===a||c&&s)return n;let d={scrollLeft:0,scrollTop:0},f=st(1);const u=st(0),p=ct(r);if((p||!p&&!s)&&((Ht(r)!=="body"||dn(a))&&(d=Yn(r)),ct(r))){const v=At(r);f=Wt(r),u.x=v.x+r.clientLeft,u.y=v.y+r.clientTop}const m=a&&!p&&!s?ri(a,d):st(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-d.scrollLeft*f.x+u.x+m.x,y:n.y*f.y-d.scrollTop*f.y+u.y+m.y}}function uh(e){return Array.from(e.getClientRects())}function fh(e){const t=it(e),n=Yn(e),r=e.ownerDocument.body,o=Ue(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ue(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Jn(e);const c=-n.scrollTop;return Xe(r).direction==="rtl"&&(a+=Ue(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:a,y:c}}const oi=25;function ph(e,t){const n=He(e),r=it(e),o=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,c=0,d=0;if(o){s=o.width,a=o.height;const u=Ao();(!u||u&&t==="fixed")&&(c=o.offsetLeft,d=o.offsetTop)}const f=Jn(r);if(f<=0){const u=r.ownerDocument,p=u.body,m=getComputedStyle(p),v=u.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(r.clientWidth-p.clientWidth-v);g<=oi&&(s-=g)}else f<=oi&&(s+=f);return{width:s,height:a,x:c,y:d}}const hh=new Set(["absolute","fixed"]);function gh(e,t){const n=At(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=ct(e)?Wt(e):st(1),a=e.clientWidth*s.x,c=e.clientHeight*s.y,d=o*s.x,f=r*s.y;return{width:a,height:c,x:d,y:f}}function si(e,t,n){let r;if(t==="viewport")r=ph(e,n);else if(t==="document")r=fh(it(e));else if(qe(t))r=gh(t,n);else{const o=ni(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Gn(r)}function ai(e,t){const n=wt(e);return n===t||!qe(n)||zt(n)?!1:Xe(n).position==="fixed"||ai(n,t)}function mh(e,t){const n=t.get(e);if(n)return n;let r=un(e,[],!1).filter(c=>qe(c)&&Ht(c)!=="body"),o=null;const s=Xe(e).position==="fixed";let a=s?wt(e):e;for(;qe(a)&&!zt(a);){const c=Xe(a),d=To(a);!d&&c.position==="fixed"&&(o=null),(s?!d&&!o:!d&&c.position==="static"&&!!o&&hh.has(o.position)||dn(a)&&!d&&ai(e,a))?r=r.filter(u=>u!==a):o=c,a=wt(a)}return t.set(e,r),r}function bh(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?Xn(t)?[]:mh(t,this._c):[].concat(n),r],c=a[0],d=a.reduce((f,u)=>{const p=si(t,u,o);return f.top=Ue(p.top,f.top),f.right=vt(p.right,f.right),f.bottom=vt(p.bottom,f.bottom),f.left=Ue(p.left,f.left),f},si(t,c,o));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function vh(e){const{width:t,height:n}=ti(e);return{width:t,height:n}}function wh(e,t,n){const r=ct(t),o=it(t),s=n==="fixed",a=At(e,!0,s,t);let c={scrollLeft:0,scrollTop:0};const d=st(0);function f(){d.x=Jn(o)}if(r||!r&&!s)if((Ht(t)!=="body"||dn(o))&&(c=Yn(t)),r){const v=At(t,!0,s,t);d.x=v.x+t.clientLeft,d.y=v.y+t.clientTop}else o&&f();s&&!r&&o&&f();const u=o&&!r&&!s?ri(o,c):st(0),p=a.left+c.scrollLeft-d.x-u.x,m=a.top+c.scrollTop-d.y-u.y;return{x:p,y:m,width:a.width,height:a.height}}function _o(e){return Xe(e).position==="static"}function ii(e,t){if(!ct(e)||Xe(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return it(e)===n&&(n=n.ownerDocument.body),n}function ci(e,t){const n=He(e);if(Xn(e))return n;if(!ct(e)){let o=wt(e);for(;o&&!zt(o);){if(qe(o)&&!_o(o))return o;o=wt(o)}return n}let r=ii(e,t);for(;r&&th(r)&&_o(r);)r=ii(r,t);return r&&zt(r)&&_o(r)&&!To(r)?n:r||ah(e)||n}const yh=async function(e){const t=this.getOffsetParent||ci,n=this.getDimensions,r=await n(e.floating);return{reference:wh(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function xh(e){return Xe(e).direction==="rtl"}const Sh={convertOffsetParentRelativeRectToViewportRelativeRect:dh,getDocumentElement:it,getClippingRect:bh,getOffsetParent:ci,getElementRects:yh,getClientRects:uh,getDimensions:vh,getScale:Wt,isElement:qe,isRTL:xh};function li(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ch(e,t){let n=null,r;const o=it(e);function s(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function a(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),s();const f=e.getBoundingClientRect(),{left:u,top:p,width:m,height:v}=f;if(c||t(),!m||!v)return;const g=Rn(p),h=Rn(o.clientWidth-(u+m)),b=Rn(o.clientHeight-(p+v)),w=Rn(u),x={rootMargin:-g+"px "+-h+"px "+-b+"px "+-w+"px",threshold:Ue(0,vt(1,d))||1};let C=!0;function E(P){const T=P[0].intersectionRatio;if(T!==d){if(!C)return a();T?a(!1,T):r=setTimeout(()=>{a(!1,1e-7)},1e3)}T===1&&!li(f,e.getBoundingClientRect())&&a(),C=!1}try{n=new IntersectionObserver(E,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(E,x)}n.observe(e)}return a(!0),s}function Eh(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,f=ko(e),u=o||s?[...f?un(f):[],...un(t)]:[];u.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const p=f&&c?Ch(f,n):null;let m=-1,v=null;a&&(v=new ResizeObserver(w=>{let[y]=w;y&&y.target===f&&v&&(v.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var x;(x=v)==null||x.observe(t)})),n()}),f&&!d&&v.observe(f),v.observe(t));let g,h=d?At(e):null;d&&b();function b(){const w=At(e);h&&!li(h,w)&&n(),h=w,g=requestAnimationFrame(b)}return n(),()=>{var w;u.forEach(y=>{o&&y.removeEventListener("scroll",n),s&&y.removeEventListener("resize",n)}),p==null||p(),(w=v)==null||w.disconnect(),v=null,d&&cancelAnimationFrame(g)}}const Nh=Xp,Th=Yp,Ah=Kp,Ih=Zp,kh=Gp,di=Rp,_h=Jp,Ph=(e,t,n)=>{const r=new Map,o={platform:Sh,...n},s={...o.platform,_c:r};return jp(e,t,{...o,platform:s})};var Oh=typeof document<"u",Mh=function(){},Zn=Oh?N.useLayoutEffect:Mh;function Qn(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Qn(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Qn(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function ui(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function fi(e,t){const n=ui(e);return Math.round(t*n)/n}function Po(e){const t=l.useRef(e);return Zn(()=>{t.current=e}),t}function Dh(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:a}={},transform:c=!0,whileElementsMounted:d,open:f}=e,[u,p]=l.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,v]=l.useState(r);Qn(m,r)||v(r);const[g,h]=l.useState(null),[b,w]=l.useState(null),y=l.useCallback(k=>{k!==P.current&&(P.current=k,h(k))},[]),x=l.useCallback(k=>{k!==T.current&&(T.current=k,w(k))},[]),C=s||g,E=a||b,P=l.useRef(null),T=l.useRef(null),F=l.useRef(u),M=d!=null,B=Po(d),V=Po(o),J=Po(f),H=l.useCallback(()=>{if(!P.current||!T.current)return;const k={placement:t,strategy:n,middleware:m};V.current&&(k.platform=V.current),Ph(P.current,T.current,k).then(I=>{const Z={...I,isPositioned:J.current!==!1};O.current&&!Qn(F.current,Z)&&(F.current=Z,Tn.flushSync(()=>{p(Z)}))})},[m,t,n,V,J]);Zn(()=>{f===!1&&F.current.isPositioned&&(F.current.isPositioned=!1,p(k=>({...k,isPositioned:!1})))},[f]);const O=l.useRef(!1);Zn(()=>(O.current=!0,()=>{O.current=!1}),[]),Zn(()=>{if(C&&(P.current=C),E&&(T.current=E),C&&E){if(B.current)return B.current(C,E,H);H()}},[C,E,H,B,M]);const ne=l.useMemo(()=>({reference:P,floating:T,setReference:y,setFloating:x}),[y,x]),L=l.useMemo(()=>({reference:C,floating:E}),[C,E]),z=l.useMemo(()=>{const k={position:n,left:0,top:0};if(!L.floating)return k;const I=fi(L.floating,u.x),Z=fi(L.floating,u.y);return c?{...k,transform:"translate("+I+"px, "+Z+"px)",...ui(L.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:Z}},[n,c,L.floating,u.x,u.y]);return l.useMemo(()=>({...u,update:H,refs:ne,elements:L,floatingStyles:z}),[u,H,ne,L,z])}const Lh=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?di({element:r.current,padding:o}).fn(n):{}:r?di({element:r,padding:o}).fn(n):{}}}},Fh=(e,t)=>({...Nh(e),options:[e,t]}),$h=(e,t)=>({...Th(e),options:[e,t]}),Bh=(e,t)=>({..._h(e),options:[e,t]}),Uh=(e,t)=>({...Ah(e),options:[e,t]}),Hh=(e,t)=>({...Ih(e),options:[e,t]}),zh=(e,t)=>({...kh(e),options:[e,t]}),Wh=(e,t)=>({...Lh(e),options:[e,t]});var Vh="Arrow",pi=l.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return i.jsx(oe.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:i.jsx("polygon",{points:"0,0 30,0 15,10"})})});pi.displayName=Vh;var jh=pi;function hi(e){const[t,n]=l.useState(void 0);return Ne(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let a,c;if("borderBoxSize"in s){const d=s.borderBoxSize,f=Array.isArray(d)?d[0]:d;a=f.inlineSize,c=f.blockSize}else a=e.offsetWidth,c=e.offsetHeight;n({width:a,height:c})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Oo="Popper",[gi,Vt]=Ke(Oo),[Rh,mi]=gi(Oo),bi=e=>{const{__scopePopper:t,children:n}=e,[r,o]=l.useState(null);return i.jsx(Rh,{scope:t,anchor:r,onAnchorChange:o,children:n})};bi.displayName=Oo;var vi="PopperAnchor",wi=l.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=mi(vi,n),a=l.useRef(null),c=ue(t,a),d=l.useRef(null);return l.useEffect(()=>{const f=d.current;d.current=(r==null?void 0:r.current)||a.current,f!==d.current&&s.onAnchorChange(d.current)}),r?null:i.jsx(oe.div,{...o,ref:c})});wi.displayName=vi;var Mo="PopperContent",[Kh,Gh]=gi(Mo),yi=l.forwardRef((e,t)=>{var R,le,he,de,be,ge;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:f=[],collisionPadding:u=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:v="optimized",onPlaced:g,...h}=e,b=mi(Mo,n),[w,y]=l.useState(null),x=ue(t,G=>y(G)),[C,E]=l.useState(null),P=hi(C),T=(P==null?void 0:P.width)??0,F=(P==null?void 0:P.height)??0,M=r+(s!=="center"?"-"+s:""),B=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},V=Array.isArray(f)?f:[f],J=V.length>0,H={padding:B,boundary:V.filter(Xh),altBoundary:J},{refs:O,floatingStyles:ne,placement:L,isPositioned:z,middlewareData:k}=Dh({strategy:"fixed",placement:M,whileElementsMounted:(...G)=>Eh(...G,{animationFrame:v==="always"}),elements:{reference:b.anchor},middleware:[Fh({mainAxis:o+F,alignmentAxis:a}),d&&$h({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?Bh():void 0,...H}),d&&Uh({...H}),Hh({...H,apply:({elements:G,rects:X,availableWidth:ye,availableHeight:se})=>{const{width:Se,height:fe}=X.reference,ve=G.floating.style;ve.setProperty("--radix-popper-available-width",`${ye}px`),ve.setProperty("--radix-popper-available-height",`${se}px`),ve.setProperty("--radix-popper-anchor-width",`${Se}px`),ve.setProperty("--radix-popper-anchor-height",`${fe}px`)}}),C&&Wh({element:C,padding:c}),Yh({arrowWidth:T,arrowHeight:F}),m&&zh({strategy:"referenceHidden",...H})]}),[I,Z]=Ci(L),j=Ae(g);Ne(()=>{z&&(j==null||j())},[z,j]);const te=(R=k.arrow)==null?void 0:R.x,D=(le=k.arrow)==null?void 0:le.y,W=((he=k.arrow)==null?void 0:he.centerOffset)!==0,[xe,ie]=l.useState();return Ne(()=>{w&&ie(window.getComputedStyle(w).zIndex)},[w]),i.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...ne,transform:z?ne.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:xe,"--radix-popper-transform-origin":[(de=k.transformOrigin)==null?void 0:de.x,(be=k.transformOrigin)==null?void 0:be.y].join(" "),...((ge=k.hide)==null?void 0:ge.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:i.jsx(Kh,{scope:n,placedSide:I,onArrowChange:E,arrowX:te,arrowY:D,shouldHideArrow:W,children:i.jsx(oe.div,{"data-side":I,"data-align":Z,...h,ref:x,style:{...h.style,animation:z?void 0:"none"}})})})});yi.displayName=Mo;var xi="PopperArrow",qh={top:"bottom",right:"left",bottom:"top",left:"right"},Si=l.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Gh(xi,r),a=qh[s.placedSide];return i.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:i.jsx(jh,{...o,ref:n,style:{...o.style,display:"block"}})})});Si.displayName=xi;function Xh(e){return e!==null}var Yh=e=>({name:"transformOrigin",options:e,fn(t){var b,w,y;const{placement:n,rects:r,middlewareData:o}=t,a=((b=o.arrow)==null?void 0:b.centerOffset)!==0,c=a?0:e.arrowWidth,d=a?0:e.arrowHeight,[f,u]=Ci(n),p={start:"0%",center:"50%",end:"100%"}[u],m=(((w=o.arrow)==null?void 0:w.x)??0)+c/2,v=(((y=o.arrow)==null?void 0:y.y)??0)+d/2;let g="",h="";return f==="bottom"?(g=a?p:`${m}px`,h=`${-d}px`):f==="top"?(g=a?p:`${m}px`,h=`${r.floating.height+d}px`):f==="right"?(g=`${-d}px`,h=a?p:`${v}px`):f==="left"&&(g=`${r.floating.width+d}px`,h=a?p:`${v}px`),{data:{x:g,y:h}}}});function Ci(e){const[t,n="center"]=e.split("-");return[t,n]}var Do=bi,Lo=wi,Fo=yi,$o=Si,Jh="Portal",er=l.forwardRef((e,t)=>{var c;const{container:n,...r}=e,[o,s]=l.useState(!1);Ne(()=>s(!0),[]);const a=n||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return a?As.createPortal(i.jsx(oe.div,{...r,ref:t}),a):null});er.displayName=Jh;var Bo="rovingFocusGroup.onEntryFocus",Zh={bubbles:!1,cancelable:!0},fn="RovingFocusGroup",[Uo,Ei,Qh]=go(fn),[eg,Ni]=Ke(fn,[Qh]),[tg,ng]=eg(fn),Ti=l.forwardRef((e,t)=>i.jsx(Uo.Provider,{scope:e.__scopeRovingFocusGroup,children:i.jsx(Uo.Slot,{scope:e.__scopeRovingFocusGroup,children:i.jsx(rg,{...e,ref:t})})}));Ti.displayName=fn;var rg=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:u=!1,...p}=e,m=l.useRef(null),v=ue(t,m),g=Wn(s),[h,b]=mt({prop:a,defaultProp:c??null,onChange:d,caller:fn}),[w,y]=l.useState(!1),x=Ae(f),C=Ei(n),E=l.useRef(!1),[P,T]=l.useState(0);return l.useEffect(()=>{const F=m.current;if(F)return F.addEventListener(Bo,x),()=>F.removeEventListener(Bo,x)},[x]),i.jsx(tg,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:h,onItemFocus:l.useCallback(F=>b(F),[b]),onItemShiftTab:l.useCallback(()=>y(!0),[]),onFocusableItemAdd:l.useCallback(()=>T(F=>F+1),[]),onFocusableItemRemove:l.useCallback(()=>T(F=>F-1),[]),children:i.jsx(oe.div,{tabIndex:w||P===0?-1:0,"data-orientation":r,...p,ref:v,style:{outline:"none",...e.style},onMouseDown:U(e.onMouseDown,()=>{E.current=!0}),onFocus:U(e.onFocus,F=>{const M=!E.current;if(F.target===F.currentTarget&&M&&!w){const B=new CustomEvent(Bo,Zh);if(F.currentTarget.dispatchEvent(B),!B.defaultPrevented){const V=C().filter(L=>L.focusable),J=V.find(L=>L.active),H=V.find(L=>L.id===h),ne=[J,H,...V].filter(Boolean).map(L=>L.ref.current);ki(ne,u)}}E.current=!1}),onBlur:U(e.onBlur,()=>y(!1))})})}),Ai="RovingFocusGroupItem",Ii=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:a,...c}=e,d=Ge(),f=s||d,u=ng(Ai,n),p=u.currentTabStopId===f,m=Ei(n),{onFocusableItemAdd:v,onFocusableItemRemove:g,currentTabStopId:h}=u;return l.useEffect(()=>{if(r)return v(),()=>g()},[r,v,g]),i.jsx(Uo.ItemSlot,{scope:n,id:f,focusable:r,active:o,children:i.jsx(oe.span,{tabIndex:p?0:-1,"data-orientation":u.orientation,...c,ref:t,onMouseDown:U(e.onMouseDown,b=>{r?u.onItemFocus(f):b.preventDefault()}),onFocus:U(e.onFocus,()=>u.onItemFocus(f)),onKeyDown:U(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){u.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const w=ag(b,u.orientation,u.dir);if(w!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let x=m().filter(C=>C.focusable).map(C=>C.ref.current);if(w==="last")x.reverse();else if(w==="prev"||w==="next"){w==="prev"&&x.reverse();const C=x.indexOf(b.currentTarget);x=u.loop?ig(x,C+1):x.slice(C+1)}setTimeout(()=>ki(x))}}),children:typeof a=="function"?a({isCurrentTabStop:p,hasTabStop:h!=null}):a})})});Ii.displayName=Ai;var og={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function sg(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ag(e,t,n){const r=sg(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return og[r]}function ki(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function ig(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var cg=Ti,lg=Ii,dg=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},jt=new WeakMap,tr=new WeakMap,nr={},Ho=0,_i=function(e){return e&&(e.host||_i(e.parentNode))},ug=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=_i(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},fg=function(e,t,n,r){var o=ug(t,Array.isArray(e)?e:[e]);nr[n]||(nr[n]=new WeakMap);var s=nr[n],a=[],c=new Set,d=new Set(o),f=function(p){!p||c.has(p)||(c.add(p),f(p.parentNode))};o.forEach(f);var u=function(p){!p||d.has(p)||Array.prototype.forEach.call(p.children,function(m){if(c.has(m))u(m);else try{var v=m.getAttribute(r),g=v!==null&&v!=="false",h=(jt.get(m)||0)+1,b=(s.get(m)||0)+1;jt.set(m,h),s.set(m,b),a.push(m),h===1&&g&&tr.set(m,!0),b===1&&m.setAttribute(n,"true"),g||m.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",m,w)}})};return u(t),c.clear(),Ho++,function(){a.forEach(function(p){var m=jt.get(p)-1,v=s.get(p)-1;jt.set(p,m),s.set(p,v),m||(tr.has(p)||p.removeAttribute(r),tr.delete(p)),v||p.removeAttribute(n)}),Ho--,Ho||(jt=new WeakMap,jt=new WeakMap,tr=new WeakMap,nr={})}},zo=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=dg(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),fg(r,o,n,"aria-hidden")):function(){return null}},lt=function(){return lt=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},lt.apply(this,arguments)};function Pi(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function pg(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var rr="right-scroll-bar-position",or="width-before-scroll-bar",hg="with-scroll-bars-hidden",gg="--removed-body-scroll-bar-size";function Wo(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function mg(e,t){var n=N.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var bg=typeof window<"u"?l.useLayoutEffect:l.useEffect,Oi=new WeakMap;function vg(e,t){var n=mg(null,function(r){return e.forEach(function(o){return Wo(o,r)})});return bg(function(){var r=Oi.get(n);if(r){var o=new Set(r),s=new Set(e),a=n.current;o.forEach(function(c){s.has(c)||Wo(c,null)}),s.forEach(function(c){o.has(c)||Wo(c,a)})}Oi.set(n,e)},[e]),n}function wg(e){return e}function yg(e,t){t===void 0&&(t=wg);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var a=t(s,r);return n.push(a),function(){n=n.filter(function(c){return c!==a})}},assignSyncMedium:function(s){for(r=!0;n.length;){var a=n;n=[],a.forEach(s)}n={push:function(c){return s(c)},filter:function(){return n}}},assignMedium:function(s){r=!0;var a=[];if(n.length){var c=n;n=[],c.forEach(s),a=n}var d=function(){var u=a;a=[],u.forEach(s)},f=function(){return Promise.resolve().then(d)};f(),n={push:function(u){a.push(u),f()},filter:function(u){return a=a.filter(u),n}}}};return o}function xg(e){e===void 0&&(e={});var t=yg(null);return t.options=lt({async:!0,ssr:!1},e),t}var Mi=function(e){var t=e.sideCar,n=Pi(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return l.createElement(r,lt({},n))};Mi.isSideCarExport=!0;function Sg(e,t){return e.useMedium(t),Mi}var Di=xg(),Vo=function(){},sr=l.forwardRef(function(e,t){var n=l.useRef(null),r=l.useState({onScrollCapture:Vo,onWheelCapture:Vo,onTouchMoveCapture:Vo}),o=r[0],s=r[1],a=e.forwardProps,c=e.children,d=e.className,f=e.removeScrollBar,u=e.enabled,p=e.shards,m=e.sideCar,v=e.noRelative,g=e.noIsolation,h=e.inert,b=e.allowPinchZoom,w=e.as,y=w===void 0?"div":w,x=e.gapMode,C=Pi(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),E=m,P=vg([n,t]),T=lt(lt({},C),o);return l.createElement(l.Fragment,null,u&&l.createElement(E,{sideCar:Di,removeScrollBar:f,shards:p,noRelative:v,noIsolation:g,inert:h,setCallbacks:s,allowPinchZoom:!!b,lockRef:n,gapMode:x}),a?l.cloneElement(l.Children.only(c),lt(lt({},T),{ref:P})):l.createElement(y,lt({},T,{className:d,ref:P}),c))});sr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},sr.classNames={fullWidth:or,zeroRight:rr};var Cg=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Eg(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Cg();return t&&e.setAttribute("nonce",t),e}function Ng(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Tg(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Ag=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Eg())&&(Ng(t,n),Tg(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Ig=function(){var e=Ag();return function(t,n){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Li=function(){var e=Ig(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},kg={left:0,top:0,right:0,gap:0},jo=function(e){return parseInt(e||"",10)||0},_g=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[jo(n),jo(r),jo(o)]},Pg=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return kg;var t=_g(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Og=Li(),Rt="data-scroll-locked",Mg=function(e,t,n,r){var o=e.left,s=e.top,a=e.right,c=e.gap;return n===void 0&&(n="margin"),`
19
- .`.concat(hg,` {
20
- overflow: hidden `).concat(r,`;
21
- padding-right: `).concat(c,"px ").concat(r,`;
18
+ `).trim():r.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function Vf(e,t=xt){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function jf(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Vf(t),Rf(t)}function Rn(e){const t=e+"CollectionProvider",[r,n]=Oe(t),[o,s]=r(t,{collectionRef:{current:null},itemMap:new Map}),a=h=>{const{scope:b,children:w}=h,y=A.useRef(null),x=A.useRef(new Map).current;return i.jsx(o,{scope:b,itemMap:x,collectionRef:y,children:w})};a.displayName=t;const c=e+"CollectionSlot",d=Se.createSlot(c),f=A.forwardRef((h,b)=>{const{scope:w,children:y}=h,x=s(c,w),C=se(b,x.collectionRef);return i.jsx(d,{ref:C,children:y})});f.displayName=c;const u=e+"CollectionItemSlot",p="data-radix-collection-item",m=Se.createSlot(u),v=A.forwardRef((h,b)=>{const{scope:w,children:y,...x}=h,C=A.useRef(null),E=se(b,C),O=s(u,w);return A.useEffect(()=>(O.itemMap.set(C,{ref:C,...x}),()=>void O.itemMap.delete(C))),i.jsx(m,{[p]:"",ref:E,children:y})});v.displayName=u;function g(h){const b=s(e+"CollectionConsumer",h);return A.useCallback(()=>{const y=b.collectionRef.current;if(!y)return[];const x=Array.from(y.querySelectorAll(`[${p}]`));return Array.from(b.itemMap.values()).sort((O,N)=>x.indexOf(O.ref.current)-x.indexOf(N.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:a,Slot:f,ItemSlot:v},g,n]}var Kf=l.createContext(void 0);function Sr(e){const t=l.useContext(Kf);return e||t||"ltr"}function ge(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useMemo(()=>(...r)=>{var n;return(n=t.current)==null?void 0:n.call(t,...r)},[])}function Gf(e,t=globalThis==null?void 0:globalThis.document){const r=ge(e);l.useEffect(()=>{const n=o=>{o.key==="Escape"&&r(o)};return t.addEventListener("keydown",n,{capture:!0}),()=>t.removeEventListener("keydown",n,{capture:!0})},[r,t])}var qf="DismissableLayer",Vn="dismissableLayer.update",Xf="dismissableLayer.pointerDownOutside",Yf="dismissableLayer.focusOutside",ca,la=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Vt=l.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:c,...d}=e,f=l.useContext(la),[u,p]=l.useState(null),m=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,v]=l.useState({}),g=se(t,N=>p(N)),h=Array.from(f.layers),[b]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),w=h.indexOf(b),y=u?h.indexOf(u):-1,x=f.layersWithOutsidePointerEventsDisabled.size>0,C=y>=w,E=Qf(N=>{const F=N.target,B=[...f.branches].some(_=>_.contains(F));!C||B||(o==null||o(N),a==null||a(N),N.defaultPrevented||c==null||c())},m),O=ep(N=>{const F=N.target;[...f.branches].some(_=>_.contains(F))||(s==null||s(N),a==null||a(N),N.defaultPrevented||c==null||c())},m);return Gf(N=>{y===f.layers.size-1&&(n==null||n(N),!N.defaultPrevented&&c&&(N.preventDefault(),c()))},m),l.useEffect(()=>{if(u)return r&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(ca=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(u)),f.layers.add(u),da(),()=>{r&&f.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=ca)}},[u,m,r,f]),l.useEffect(()=>()=>{u&&(f.layers.delete(u),f.layersWithOutsidePointerEventsDisabled.delete(u),da())},[u,f]),l.useEffect(()=>{const N=()=>v({});return document.addEventListener(Vn,N),()=>document.removeEventListener(Vn,N)},[]),i.jsx(Z.div,{...d,ref:g,style:{pointerEvents:x?C?"auto":"none":void 0,...e.style},onFocusCapture:z(e.onFocusCapture,O.onFocusCapture),onBlurCapture:z(e.onBlurCapture,O.onBlurCapture),onPointerDownCapture:z(e.onPointerDownCapture,E.onPointerDownCapture)})});Vt.displayName=qf;var Jf="DismissableLayerBranch",Zf=l.forwardRef((e,t)=>{const r=l.useContext(la),n=l.useRef(null),o=se(t,n);return l.useEffect(()=>{const s=n.current;if(s)return r.branches.add(s),()=>{r.branches.delete(s)}},[r.branches]),i.jsx(Z.div,{...e,ref:o})});Zf.displayName=Jf;function Qf(e,t=globalThis==null?void 0:globalThis.document){const r=ge(e),n=l.useRef(!1),o=l.useRef(()=>{});return l.useEffect(()=>{const s=c=>{if(c.target&&!n.current){let d=function(){ua(Xf,r,f,{discrete:!0})};const f={originalEvent:c};c.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=d,t.addEventListener("click",o.current,{once:!0})):d()}else t.removeEventListener("click",o.current);n.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,r]),{onPointerDownCapture:()=>n.current=!0}}function ep(e,t=globalThis==null?void 0:globalThis.document){const r=ge(e),n=l.useRef(!1);return l.useEffect(()=>{const o=s=>{s.target&&!n.current&&ua(Yf,r,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function da(){const e=new CustomEvent(Vn);document.dispatchEvent(e)}function ua(e,t,r,{discrete:n}){const o=r.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&o.addEventListener(e,t,{once:!0}),n?Qs(o,s):o.dispatchEvent(s)}var jn=0;function Kn(){l.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??fa()),document.body.insertAdjacentElement("beforeend",e[1]??fa()),jn++,()=>{jn===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),jn--}},[])}function fa(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Gn="focusScope.autoFocusOnMount",qn="focusScope.autoFocusOnUnmount",pa={bubbles:!1,cancelable:!0},tp="FocusScope",Cr=l.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...a}=e,[c,d]=l.useState(null),f=ge(o),u=ge(s),p=l.useRef(null),m=se(t,h=>d(h)),v=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(n){let h=function(x){if(v.paused||!c)return;const C=x.target;c.contains(C)?p.current=C:Ze(p.current,{select:!0})},b=function(x){if(v.paused||!c)return;const C=x.relatedTarget;C!==null&&(c.contains(C)||Ze(p.current,{select:!0}))},w=function(x){if(document.activeElement===document.body)for(const E of x)E.removedNodes.length>0&&Ze(c)};document.addEventListener("focusin",h),document.addEventListener("focusout",b);const y=new MutationObserver(w);return c&&y.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",b),y.disconnect()}}},[n,c,v.paused]),l.useEffect(()=>{if(c){ma.add(v);const h=document.activeElement;if(!c.contains(h)){const w=new CustomEvent(Gn,pa);c.addEventListener(Gn,f),c.dispatchEvent(w),w.defaultPrevented||(rp(ip(ha(c)),{select:!0}),document.activeElement===h&&Ze(c))}return()=>{c.removeEventListener(Gn,f),setTimeout(()=>{const w=new CustomEvent(qn,pa);c.addEventListener(qn,u),c.dispatchEvent(w),w.defaultPrevented||Ze(h??document.body,{select:!0}),c.removeEventListener(qn,u),ma.remove(v)},0)}}},[c,f,u,v]);const g=l.useCallback(h=>{if(!r&&!n||v.paused)return;const b=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,w=document.activeElement;if(b&&w){const y=h.currentTarget,[x,C]=np(y);x&&C?!h.shiftKey&&w===C?(h.preventDefault(),r&&Ze(x,{select:!0})):h.shiftKey&&w===x&&(h.preventDefault(),r&&Ze(C,{select:!0})):w===y&&h.preventDefault()}},[r,n,v.paused]);return i.jsx(Z.div,{tabIndex:-1,...a,ref:m,onKeyDown:g})});Cr.displayName=tp;function rp(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(Ze(n,{select:t}),document.activeElement!==r)return}function np(e){const t=ha(e),r=ga(t,e),n=ga(t.reverse(),e);return[r,n]}function ha(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const o=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||o?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function ga(e,t){for(const r of e)if(!op(r,{upTo:t}))return r}function op(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function sp(e){return e instanceof HTMLInputElement&&"select"in e}function Ze(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&sp(e)&&t&&e.select()}}var ma=ap();function ap(){let e=[];return{add(t){const r=e[0];t!==r&&(r==null||r.pause()),e=ba(e,t),e.unshift(t)},remove(t){var r;e=ba(e,t),(r=e[0])==null||r.resume()}}}function ba(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function ip(e){return e.filter(t=>t.tagName!=="A")}const cp=["top","right","bottom","left"],Qe=Math.min,Ce=Math.max,Er=Math.round,Nr=Math.floor,He=e=>({x:e,y:e}),lp={left:"right",right:"left",bottom:"top",top:"bottom"},dp={start:"end",end:"start"};function Xn(e,t,r){return Ce(e,Qe(t,r))}function qe(e,t){return typeof e=="function"?e(t):e}function Xe(e){return e.split("-")[0]}function St(e){return e.split("-")[1]}function Yn(e){return e==="x"?"y":"x"}function Jn(e){return e==="y"?"height":"width"}const up=new Set(["top","bottom"]);function ze(e){return up.has(Xe(e))?"y":"x"}function Zn(e){return Yn(ze(e))}function fp(e,t,r){r===void 0&&(r=!1);const n=St(e),o=Zn(e),s=Jn(o);let a=o==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=Tr(a)),[a,Tr(a)]}function pp(e){const t=Tr(e);return[Qn(e),t,Qn(t)]}function Qn(e){return e.replace(/start|end/g,t=>dp[t])}const va=["left","right"],wa=["right","left"],hp=["top","bottom"],gp=["bottom","top"];function mp(e,t,r){switch(e){case"top":case"bottom":return r?t?wa:va:t?va:wa;case"left":case"right":return t?hp:gp;default:return[]}}function bp(e,t,r,n){const o=St(e);let s=mp(Xe(e),r==="start",n);return o&&(s=s.map(a=>a+"-"+o),t&&(s=s.concat(s.map(Qn)))),s}function Tr(e){return e.replace(/left|right|bottom|top/g,t=>lp[t])}function vp(e){return{top:0,right:0,bottom:0,left:0,...e}}function ya(e){return typeof e!="number"?vp(e):{top:e,right:e,bottom:e,left:e}}function Ar(e){const{x:t,y:r,width:n,height:o}=e;return{width:n,height:o,top:r,left:t,right:t+n,bottom:r+o,x:t,y:r}}function xa(e,t,r){let{reference:n,floating:o}=e;const s=ze(t),a=Zn(t),c=Jn(a),d=Xe(t),f=s==="y",u=n.x+n.width/2-o.width/2,p=n.y+n.height/2-o.height/2,m=n[c]/2-o[c]/2;let v;switch(d){case"top":v={x:u,y:n.y-o.height};break;case"bottom":v={x:u,y:n.y+n.height};break;case"right":v={x:n.x+n.width,y:p};break;case"left":v={x:n.x-o.width,y:p};break;default:v={x:n.x,y:n.y}}switch(St(t)){case"start":v[a]-=m*(r&&f?-1:1);break;case"end":v[a]+=m*(r&&f?-1:1);break}return v}const wp=async(e,t,r)=>{const{placement:n="bottom",strategy:o="absolute",middleware:s=[],platform:a}=r,c=s.filter(Boolean),d=await(a.isRTL==null?void 0:a.isRTL(t));let f=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:p}=xa(f,n,d),m=n,v={},g=0;for(let h=0;h<c.length;h++){const{name:b,fn:w}=c[h],{x:y,y:x,data:C,reset:E}=await w({x:u,y:p,initialPlacement:n,placement:m,strategy:o,middlewareData:v,rects:f,platform:a,elements:{reference:e,floating:t}});u=y??u,p=x??p,v={...v,[b]:{...v[b],...C}},E&&g<=50&&(g++,typeof E=="object"&&(E.placement&&(m=E.placement),E.rects&&(f=E.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):E.rects),{x:u,y:p}=xa(f,m,d)),h=-1)}return{x:u,y:p,placement:m,strategy:o,middlewareData:v}};async function jt(e,t){var r;t===void 0&&(t={});const{x:n,y:o,platform:s,rects:a,elements:c,strategy:d}=e,{boundary:f="clippingAncestors",rootBoundary:u="viewport",elementContext:p="floating",altBoundary:m=!1,padding:v=0}=qe(t,e),g=ya(v),b=c[m?p==="floating"?"reference":"floating":p],w=Ar(await s.getClippingRect({element:(r=await(s.isElement==null?void 0:s.isElement(b)))==null||r?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(c.floating)),boundary:f,rootBoundary:u,strategy:d})),y=p==="floating"?{x:n,y:o,width:a.floating.width,height:a.floating.height}:a.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c.floating)),C=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},E=Ar(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:y,offsetParent:x,strategy:d}):y);return{top:(w.top-E.top+g.top)/C.y,bottom:(E.bottom-w.bottom+g.bottom)/C.y,left:(w.left-E.left+g.left)/C.x,right:(E.right-w.right+g.right)/C.x}}const yp=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:o,rects:s,platform:a,elements:c,middlewareData:d}=t,{element:f,padding:u=0}=qe(e,t)||{};if(f==null)return{};const p=ya(u),m={x:r,y:n},v=Zn(o),g=Jn(v),h=await a.getDimensions(f),b=v==="y",w=b?"top":"left",y=b?"bottom":"right",x=b?"clientHeight":"clientWidth",C=s.reference[g]+s.reference[v]-m[v]-s.floating[g],E=m[v]-s.reference[v],O=await(a.getOffsetParent==null?void 0:a.getOffsetParent(f));let N=O?O[x]:0;(!N||!await(a.isElement==null?void 0:a.isElement(O)))&&(N=c.floating[x]||s.floating[g]);const F=C/2-E/2,B=N/2-h[g]/2-1,_=Qe(p[w],B),U=Qe(p[y],B),G=_,L=N-h[g]-U,$=N/2-h[g]/2+F,q=Xn(G,$,L),k=!d.arrow&&St(o)!=null&&$!==q&&s.reference[g]/2-($<G?_:U)-h[g]/2<0,V=k?$<G?$-G:$-L:0;return{[v]:m[v]+V,data:{[v]:q,centerOffset:$-q-V,...k&&{alignmentOffset:V}},reset:k}}}),xp=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,n;const{placement:o,middlewareData:s,rects:a,initialPlacement:c,platform:d,elements:f}=t,{mainAxis:u=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...b}=qe(e,t);if((r=s.arrow)!=null&&r.alignmentOffset)return{};const w=Xe(o),y=ze(c),x=Xe(c)===c,C=await(d.isRTL==null?void 0:d.isRTL(f.floating)),E=m||(x||!h?[Tr(c)]:pp(c)),O=g!=="none";!m&&O&&E.push(...bp(c,h,g,C));const N=[c,...E],F=await jt(t,b),B=[];let _=((n=s.flip)==null?void 0:n.overflows)||[];if(u&&B.push(F[w]),p){const $=fp(o,a,C);B.push(F[$[0]],F[$[1]])}if(_=[..._,{placement:o,overflows:B}],!B.every($=>$<=0)){var U,G;const $=(((U=s.flip)==null?void 0:U.index)||0)+1,q=N[$];if(q&&(!(p==="alignment"?y!==ze(q):!1)||_.every(D=>ze(D.placement)===y?D.overflows[0]>0:!0)))return{data:{index:$,overflows:_},reset:{placement:q}};let k=(G=_.filter(V=>V.overflows[0]<=0).sort((V,D)=>V.overflows[1]-D.overflows[1])[0])==null?void 0:G.placement;if(!k)switch(v){case"bestFit":{var L;const V=(L=_.filter(D=>{if(O){const I=ze(D.placement);return I===y||I==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(I=>I>0).reduce((I,J)=>I+J,0)]).sort((D,I)=>D[1]-I[1])[0])==null?void 0:L[0];V&&(k=V);break}case"initialPlacement":k=c;break}if(o!==k)return{reset:{placement:k}}}return{}}}};function Sa(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ca(e){return cp.some(t=>e[t]>=0)}const Sp=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r}=t,{strategy:n="referenceHidden",...o}=qe(e,t);switch(n){case"referenceHidden":{const s=await jt(t,{...o,elementContext:"reference"}),a=Sa(s,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Ca(a)}}}case"escaped":{const s=await jt(t,{...o,altBoundary:!0}),a=Sa(s,r.floating);return{data:{escapedOffsets:a,escaped:Ca(a)}}}default:return{}}}}},Ea=new Set(["left","top"]);async function Cp(e,t){const{placement:r,platform:n,elements:o}=e,s=await(n.isRTL==null?void 0:n.isRTL(o.floating)),a=Xe(r),c=St(r),d=ze(r)==="y",f=Ea.has(a)?-1:1,u=s&&d?-1:1,p=qe(t,e);let{mainAxis:m,crossAxis:v,alignmentAxis:g}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return c&&typeof g=="number"&&(v=c==="end"?g*-1:g),d?{x:v*u,y:m*f}:{x:m*f,y:v*u}}const Ep=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:o,y:s,placement:a,middlewareData:c}=t,d=await Cp(t,e);return a===((r=c.offset)==null?void 0:r.placement)&&(n=c.arrow)!=null&&n.alignmentOffset?{}:{x:o+d.x,y:s+d.y,data:{...d,placement:a}}}}},Np=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:o}=t,{mainAxis:s=!0,crossAxis:a=!1,limiter:c={fn:b=>{let{x:w,y}=b;return{x:w,y}}},...d}=qe(e,t),f={x:r,y:n},u=await jt(t,d),p=ze(Xe(o)),m=Yn(p);let v=f[m],g=f[p];if(s){const b=m==="y"?"top":"left",w=m==="y"?"bottom":"right",y=v+u[b],x=v-u[w];v=Xn(y,v,x)}if(a){const b=p==="y"?"top":"left",w=p==="y"?"bottom":"right",y=g+u[b],x=g-u[w];g=Xn(y,g,x)}const h=c.fn({...t,[m]:v,[p]:g});return{...h,data:{x:h.x-r,y:h.y-n,enabled:{[m]:s,[p]:a}}}}}},Tp=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:n,placement:o,rects:s,middlewareData:a}=t,{offset:c=0,mainAxis:d=!0,crossAxis:f=!0}=qe(e,t),u={x:r,y:n},p=ze(o),m=Yn(p);let v=u[m],g=u[p];const h=qe(c,t),b=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(d){const x=m==="y"?"height":"width",C=s.reference[m]-s.floating[x]+b.mainAxis,E=s.reference[m]+s.reference[x]-b.mainAxis;v<C?v=C:v>E&&(v=E)}if(f){var w,y;const x=m==="y"?"width":"height",C=Ea.has(Xe(o)),E=s.reference[p]-s.floating[x]+(C&&((w=a.offset)==null?void 0:w[p])||0)+(C?0:b.crossAxis),O=s.reference[p]+s.reference[x]+(C?0:((y=a.offset)==null?void 0:y[p])||0)-(C?b.crossAxis:0);g<E?g=E:g>O&&(g=O)}return{[m]:v,[p]:g}}}},Ap=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:o,rects:s,platform:a,elements:c}=t,{apply:d=()=>{},...f}=qe(e,t),u=await jt(t,f),p=Xe(o),m=St(o),v=ze(o)==="y",{width:g,height:h}=s.floating;let b,w;p==="top"||p==="bottom"?(b=p,w=m===(await(a.isRTL==null?void 0:a.isRTL(c.floating))?"start":"end")?"left":"right"):(w=p,b=m==="end"?"top":"bottom");const y=h-u.top-u.bottom,x=g-u.left-u.right,C=Qe(h-u[b],y),E=Qe(g-u[w],x),O=!t.middlewareData.shift;let N=C,F=E;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(F=x),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(N=y),O&&!m){const _=Ce(u.left,0),U=Ce(u.right,0),G=Ce(u.top,0),L=Ce(u.bottom,0);v?F=g-2*(_!==0||U!==0?_+U:Ce(u.left,u.right)):N=h-2*(G!==0||L!==0?G+L:Ce(u.top,u.bottom))}await d({...t,availableWidth:F,availableHeight:N});const B=await a.getDimensions(c.floating);return g!==B.width||h!==B.height?{reset:{rects:!0}}:{}}}};function Pr(){return typeof window<"u"}function Ct(e){return Na(e)?(e.nodeName||"").toLowerCase():"#document"}function Ee(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function We(e){var t;return(t=(Na(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Na(e){return Pr()?e instanceof Node||e instanceof Ee(e).Node:!1}function ke(e){return Pr()?e instanceof Element||e instanceof Ee(e).Element:!1}function Re(e){return Pr()?e instanceof HTMLElement||e instanceof Ee(e).HTMLElement:!1}function Ta(e){return!Pr()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ee(e).ShadowRoot}const Pp=new Set(["inline","contents"]);function Kt(e){const{overflow:t,overflowX:r,overflowY:n,display:o}=De(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&!Pp.has(o)}const _p=new Set(["table","td","th"]);function Ip(e){return _p.has(Ct(e))}const Op=[":popover-open",":modal"];function _r(e){return Op.some(t=>{try{return e.matches(t)}catch{return!1}})}const Mp=["transform","translate","scale","rotate","perspective"],kp=["transform","translate","scale","rotate","perspective","filter"],Dp=["paint","layout","strict","content"];function eo(e){const t=to(),r=ke(e)?De(e):e;return Mp.some(n=>r[n]?r[n]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!t&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!t&&(r.filter?r.filter!=="none":!1)||kp.some(n=>(r.willChange||"").includes(n))||Dp.some(n=>(r.contain||"").includes(n))}function Lp(e){let t=et(e);for(;Re(t)&&!Et(t);){if(eo(t))return t;if(_r(t))return null;t=et(t)}return null}function to(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Fp=new Set(["html","body","#document"]);function Et(e){return Fp.has(Ct(e))}function De(e){return Ee(e).getComputedStyle(e)}function Ir(e){return ke(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function et(e){if(Ct(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ta(e)&&e.host||We(e);return Ta(t)?t.host:t}function Aa(e){const t=et(e);return Et(t)?e.ownerDocument?e.ownerDocument.body:e.body:Re(t)&&Kt(t)?t:Aa(t)}function Gt(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const o=Aa(e),s=o===((n=e.ownerDocument)==null?void 0:n.body),a=Ee(o);if(s){const c=ro(a);return t.concat(a,a.visualViewport||[],Kt(o)?o:[],c&&r?Gt(c):[])}return t.concat(o,Gt(o,[],r))}function ro(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Pa(e){const t=De(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const o=Re(e),s=o?e.offsetWidth:r,a=o?e.offsetHeight:n,c=Er(r)!==s||Er(n)!==a;return c&&(r=s,n=a),{width:r,height:n,$:c}}function no(e){return ke(e)?e:e.contextElement}function Nt(e){const t=no(e);if(!Re(t))return He(1);const r=t.getBoundingClientRect(),{width:n,height:o,$:s}=Pa(t);let a=(s?Er(r.width):r.width)/n,c=(s?Er(r.height):r.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!c||!Number.isFinite(c))&&(c=1),{x:a,y:c}}const $p=He(0);function _a(e){const t=Ee(e);return!to()||!t.visualViewport?$p:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Bp(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Ee(e)?!1:t}function lt(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const o=e.getBoundingClientRect(),s=no(e);let a=He(1);t&&(n?ke(n)&&(a=Nt(n)):a=Nt(e));const c=Bp(s,r,n)?_a(s):He(0);let d=(o.left+c.x)/a.x,f=(o.top+c.y)/a.y,u=o.width/a.x,p=o.height/a.y;if(s){const m=Ee(s),v=n&&ke(n)?Ee(n):n;let g=m,h=ro(g);for(;h&&n&&v!==g;){const b=Nt(h),w=h.getBoundingClientRect(),y=De(h),x=w.left+(h.clientLeft+parseFloat(y.paddingLeft))*b.x,C=w.top+(h.clientTop+parseFloat(y.paddingTop))*b.y;d*=b.x,f*=b.y,u*=b.x,p*=b.y,d+=x,f+=C,g=Ee(h),h=ro(g)}}return Ar({width:u,height:p,x:d,y:f})}function Or(e,t){const r=Ir(e).scrollLeft;return t?t.left+r:lt(We(e)).left+r}function Ia(e,t){const r=e.getBoundingClientRect(),n=r.left+t.scrollLeft-Or(e,r),o=r.top+t.scrollTop;return{x:n,y:o}}function Up(e){let{elements:t,rect:r,offsetParent:n,strategy:o}=e;const s=o==="fixed",a=We(n),c=t?_r(t.floating):!1;if(n===a||c&&s)return r;let d={scrollLeft:0,scrollTop:0},f=He(1);const u=He(0),p=Re(n);if((p||!p&&!s)&&((Ct(n)!=="body"||Kt(a))&&(d=Ir(n)),Re(n))){const v=lt(n);f=Nt(n),u.x=v.x+n.clientLeft,u.y=v.y+n.clientTop}const m=a&&!p&&!s?Ia(a,d):He(0);return{width:r.width*f.x,height:r.height*f.y,x:r.x*f.x-d.scrollLeft*f.x+u.x+m.x,y:r.y*f.y-d.scrollTop*f.y+u.y+m.y}}function Hp(e){return Array.from(e.getClientRects())}function zp(e){const t=We(e),r=Ir(e),n=e.ownerDocument.body,o=Ce(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=Ce(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let a=-r.scrollLeft+Or(e);const c=-r.scrollTop;return De(n).direction==="rtl"&&(a+=Ce(t.clientWidth,n.clientWidth)-o),{width:o,height:s,x:a,y:c}}const Oa=25;function Wp(e,t){const r=Ee(e),n=We(e),o=r.visualViewport;let s=n.clientWidth,a=n.clientHeight,c=0,d=0;if(o){s=o.width,a=o.height;const u=to();(!u||u&&t==="fixed")&&(c=o.offsetLeft,d=o.offsetTop)}const f=Or(n);if(f<=0){const u=n.ownerDocument,p=u.body,m=getComputedStyle(p),v=u.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(n.clientWidth-p.clientWidth-v);g<=Oa&&(s-=g)}else f<=Oa&&(s+=f);return{width:s,height:a,x:c,y:d}}const Rp=new Set(["absolute","fixed"]);function Vp(e,t){const r=lt(e,!0,t==="fixed"),n=r.top+e.clientTop,o=r.left+e.clientLeft,s=Re(e)?Nt(e):He(1),a=e.clientWidth*s.x,c=e.clientHeight*s.y,d=o*s.x,f=n*s.y;return{width:a,height:c,x:d,y:f}}function Ma(e,t,r){let n;if(t==="viewport")n=Wp(e,r);else if(t==="document")n=zp(We(e));else if(ke(t))n=Vp(t,r);else{const o=_a(e);n={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ar(n)}function ka(e,t){const r=et(e);return r===t||!ke(r)||Et(r)?!1:De(r).position==="fixed"||ka(r,t)}function jp(e,t){const r=t.get(e);if(r)return r;let n=Gt(e,[],!1).filter(c=>ke(c)&&Ct(c)!=="body"),o=null;const s=De(e).position==="fixed";let a=s?et(e):e;for(;ke(a)&&!Et(a);){const c=De(a),d=eo(a);!d&&c.position==="fixed"&&(o=null),(s?!d&&!o:!d&&c.position==="static"&&!!o&&Rp.has(o.position)||Kt(a)&&!d&&ka(e,a))?n=n.filter(u=>u!==a):o=c,a=et(a)}return t.set(e,n),n}function Kp(e){let{element:t,boundary:r,rootBoundary:n,strategy:o}=e;const a=[...r==="clippingAncestors"?_r(t)?[]:jp(t,this._c):[].concat(r),n],c=a[0],d=a.reduce((f,u)=>{const p=Ma(t,u,o);return f.top=Ce(p.top,f.top),f.right=Qe(p.right,f.right),f.bottom=Qe(p.bottom,f.bottom),f.left=Ce(p.left,f.left),f},Ma(t,c,o));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function Gp(e){const{width:t,height:r}=Pa(e);return{width:t,height:r}}function qp(e,t,r){const n=Re(t),o=We(t),s=r==="fixed",a=lt(e,!0,s,t);let c={scrollLeft:0,scrollTop:0};const d=He(0);function f(){d.x=Or(o)}if(n||!n&&!s)if((Ct(t)!=="body"||Kt(o))&&(c=Ir(t)),n){const v=lt(t,!0,s,t);d.x=v.x+t.clientLeft,d.y=v.y+t.clientTop}else o&&f();s&&!n&&o&&f();const u=o&&!n&&!s?Ia(o,c):He(0),p=a.left+c.scrollLeft-d.x-u.x,m=a.top+c.scrollTop-d.y-u.y;return{x:p,y:m,width:a.width,height:a.height}}function oo(e){return De(e).position==="static"}function Da(e,t){if(!Re(e)||De(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return We(e)===r&&(r=r.ownerDocument.body),r}function La(e,t){const r=Ee(e);if(_r(e))return r;if(!Re(e)){let o=et(e);for(;o&&!Et(o);){if(ke(o)&&!oo(o))return o;o=et(o)}return r}let n=Da(e,t);for(;n&&Ip(n)&&oo(n);)n=Da(n,t);return n&&Et(n)&&oo(n)&&!eo(n)?r:n||Lp(e)||r}const Xp=async function(e){const t=this.getOffsetParent||La,r=this.getDimensions,n=await r(e.floating);return{reference:qp(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Yp(e){return De(e).direction==="rtl"}const Jp={convertOffsetParentRelativeRectToViewportRelativeRect:Up,getDocumentElement:We,getClippingRect:Kp,getOffsetParent:La,getElementRects:Xp,getClientRects:Hp,getDimensions:Gp,getScale:Nt,isElement:ke,isRTL:Yp};function Fa(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Zp(e,t){let r=null,n;const o=We(e);function s(){var c;clearTimeout(n),(c=r)==null||c.disconnect(),r=null}function a(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),s();const f=e.getBoundingClientRect(),{left:u,top:p,width:m,height:v}=f;if(c||t(),!m||!v)return;const g=Nr(p),h=Nr(o.clientWidth-(u+m)),b=Nr(o.clientHeight-(p+v)),w=Nr(u),x={rootMargin:-g+"px "+-h+"px "+-b+"px "+-w+"px",threshold:Ce(0,Qe(1,d))||1};let C=!0;function E(O){const N=O[0].intersectionRatio;if(N!==d){if(!C)return a();N?a(!1,N):n=setTimeout(()=>{a(!1,1e-7)},1e3)}N===1&&!Fa(f,e.getBoundingClientRect())&&a(),C=!1}try{r=new IntersectionObserver(E,{...x,root:o.ownerDocument})}catch{r=new IntersectionObserver(E,x)}r.observe(e)}return a(!0),s}function Qp(e,t,r,n){n===void 0&&(n={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=n,f=no(e),u=o||s?[...f?Gt(f):[],...Gt(t)]:[];u.forEach(w=>{o&&w.addEventListener("scroll",r,{passive:!0}),s&&w.addEventListener("resize",r)});const p=f&&c?Zp(f,r):null;let m=-1,v=null;a&&(v=new ResizeObserver(w=>{let[y]=w;y&&y.target===f&&v&&(v.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var x;(x=v)==null||x.observe(t)})),r()}),f&&!d&&v.observe(f),v.observe(t));let g,h=d?lt(e):null;d&&b();function b(){const w=lt(e);h&&!Fa(h,w)&&r(),h=w,g=requestAnimationFrame(b)}return r(),()=>{var w;u.forEach(y=>{o&&y.removeEventListener("scroll",r),s&&y.removeEventListener("resize",r)}),p==null||p(),(w=v)==null||w.disconnect(),v=null,d&&cancelAnimationFrame(g)}}const eh=Ep,th=Np,rh=xp,nh=Ap,oh=Sp,$a=yp,sh=Tp,ah=(e,t,r)=>{const n=new Map,o={platform:Jp,...r},s={...o.platform,_c:n};return wp(e,t,{...o,platform:s})};var ih=typeof document<"u",ch=function(){},Mr=ih?A.useLayoutEffect:ch;function kr(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,n,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(n=r;n--!==0;)if(!kr(e[n],t[n]))return!1;return!0}if(o=Object.keys(e),r=o.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(t,o[n]))return!1;for(n=r;n--!==0;){const s=o[n];if(!(s==="_owner"&&e.$$typeof)&&!kr(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ba(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ua(e,t){const r=Ba(e);return Math.round(t*r)/r}function so(e){const t=l.useRef(e);return Mr(()=>{t.current=e}),t}function lh(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:n=[],platform:o,elements:{reference:s,floating:a}={},transform:c=!0,whileElementsMounted:d,open:f}=e,[u,p]=l.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[m,v]=l.useState(n);kr(m,n)||v(n);const[g,h]=l.useState(null),[b,w]=l.useState(null),y=l.useCallback(D=>{D!==O.current&&(O.current=D,h(D))},[]),x=l.useCallback(D=>{D!==N.current&&(N.current=D,w(D))},[]),C=s||g,E=a||b,O=l.useRef(null),N=l.useRef(null),F=l.useRef(u),B=d!=null,_=so(d),U=so(o),G=so(f),L=l.useCallback(()=>{if(!O.current||!N.current)return;const D={placement:t,strategy:r,middleware:m};U.current&&(D.platform=U.current),ah(O.current,N.current,D).then(I=>{const J={...I,isPositioned:G.current!==!1};$.current&&!kr(F.current,J)&&(F.current=J,ar.flushSync(()=>{p(J)}))})},[m,t,r,U,G]);Mr(()=>{f===!1&&F.current.isPositioned&&(F.current.isPositioned=!1,p(D=>({...D,isPositioned:!1})))},[f]);const $=l.useRef(!1);Mr(()=>($.current=!0,()=>{$.current=!1}),[]),Mr(()=>{if(C&&(O.current=C),E&&(N.current=E),C&&E){if(_.current)return _.current(C,E,L);L()}},[C,E,L,_,B]);const q=l.useMemo(()=>({reference:O,floating:N,setReference:y,setFloating:x}),[y,x]),k=l.useMemo(()=>({reference:C,floating:E}),[C,E]),V=l.useMemo(()=>{const D={position:r,left:0,top:0};if(!k.floating)return D;const I=Ua(k.floating,u.x),J=Ua(k.floating,u.y);return c?{...D,transform:"translate("+I+"px, "+J+"px)",...Ba(k.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:I,top:J}},[r,c,k.floating,u.x,u.y]);return l.useMemo(()=>({...u,update:L,refs:q,elements:k,floatingStyles:V}),[u,L,q,k,V])}const dh=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:n,padding:o}=typeof e=="function"?e(r):e;return n&&t(n)?n.current!=null?$a({element:n.current,padding:o}).fn(r):{}:n?$a({element:n,padding:o}).fn(r):{}}}},uh=(e,t)=>({...eh(e),options:[e,t]}),fh=(e,t)=>({...th(e),options:[e,t]}),ph=(e,t)=>({...sh(e),options:[e,t]}),hh=(e,t)=>({...rh(e),options:[e,t]}),gh=(e,t)=>({...nh(e),options:[e,t]}),mh=(e,t)=>({...oh(e),options:[e,t]}),bh=(e,t)=>({...dh(e),options:[e,t]});var vh="Arrow",Ha=l.forwardRef((e,t)=>{const{children:r,width:n=10,height:o=5,...s}=e;return i.jsx(Z.svg,{...s,ref:t,width:n,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:i.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ha.displayName=vh;var wh=Ha;function za(e){const[t,r]=l.useState(void 0);return he(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const n=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let a,c;if("borderBoxSize"in s){const d=s.borderBoxSize,f=Array.isArray(d)?d[0]:d;a=f.inlineSize,c=f.blockSize}else a=e.offsetWidth,c=e.offsetHeight;r({width:a,height:c})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else r(void 0)},[e]),t}var ao="Popper",[Wa,Tt]=Oe(ao),[yh,Ra]=Wa(ao),Va=e=>{const{__scopePopper:t,children:r}=e,[n,o]=l.useState(null);return i.jsx(yh,{scope:t,anchor:n,onAnchorChange:o,children:r})};Va.displayName=ao;var ja="PopperAnchor",Ka=l.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...o}=e,s=Ra(ja,r),a=l.useRef(null),c=se(t,a),d=l.useRef(null);return l.useEffect(()=>{const f=d.current;d.current=(n==null?void 0:n.current)||a.current,f!==d.current&&s.onAnchorChange(d.current)}),n?null:i.jsx(Z.div,{...o,ref:c})});Ka.displayName=ja;var io="PopperContent",[xh,Sh]=Wa(io),Ga=l.forwardRef((e,t)=>{var j,K,oe,P,M,Y;const{__scopePopper:r,side:n="bottom",sideOffset:o=0,align:s="center",alignOffset:a=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:f=[],collisionPadding:u=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:v="optimized",onPlaced:g,...h}=e,b=Ra(io,r),[w,y]=l.useState(null),x=se(t,le=>y(le)),[C,E]=l.useState(null),O=za(C),N=(O==null?void 0:O.width)??0,F=(O==null?void 0:O.height)??0,B=n+(s!=="center"?"-"+s:""),_=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},U=Array.isArray(f)?f:[f],G=U.length>0,L={padding:_,boundary:U.filter(Eh),altBoundary:G},{refs:$,floatingStyles:q,placement:k,isPositioned:V,middlewareData:D}=lh({strategy:"fixed",placement:B,whileElementsMounted:(...le)=>Qp(...le,{animationFrame:v==="always"}),elements:{reference:b.anchor},middleware:[uh({mainAxis:o+F,alignmentAxis:a}),d&&fh({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?ph():void 0,...L}),d&&hh({...L}),gh({...L,apply:({elements:le,rects:me,availableWidth:Ke,availableHeight:W})=>{const{width:ne,height:fe}=me.reference,ie=le.floating.style;ie.setProperty("--radix-popper-available-width",`${Ke}px`),ie.setProperty("--radix-popper-available-height",`${W}px`),ie.setProperty("--radix-popper-anchor-width",`${ne}px`),ie.setProperty("--radix-popper-anchor-height",`${fe}px`)}}),C&&bh({element:C,padding:c}),Nh({arrowWidth:N,arrowHeight:F}),m&&mh({strategy:"referenceHidden",...L})]}),[I,J]=Ya(k),Q=ge(g);he(()=>{V&&(Q==null||Q())},[V,Q]);const re=(j=D.arrow)==null?void 0:j.x,H=(K=D.arrow)==null?void 0:K.y,R=((oe=D.arrow)==null?void 0:oe.centerOffset)!==0,[ue,de]=l.useState();return he(()=>{w&&de(window.getComputedStyle(w).zIndex)},[w]),i.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...q,transform:V?q.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ue,"--radix-popper-transform-origin":[(P=D.transformOrigin)==null?void 0:P.x,(M=D.transformOrigin)==null?void 0:M.y].join(" "),...((Y=D.hide)==null?void 0:Y.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:i.jsx(xh,{scope:r,placedSide:I,onArrowChange:E,arrowX:re,arrowY:H,shouldHideArrow:R,children:i.jsx(Z.div,{"data-side":I,"data-align":J,...h,ref:x,style:{...h.style,animation:V?void 0:"none"}})})})});Ga.displayName=io;var qa="PopperArrow",Ch={top:"bottom",right:"left",bottom:"top",left:"right"},Xa=l.forwardRef(function(t,r){const{__scopePopper:n,...o}=t,s=Sh(qa,n),a=Ch[s.placedSide];return i.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:i.jsx(wh,{...o,ref:r,style:{...o.style,display:"block"}})})});Xa.displayName=qa;function Eh(e){return e!==null}var Nh=e=>({name:"transformOrigin",options:e,fn(t){var b,w,y;const{placement:r,rects:n,middlewareData:o}=t,a=((b=o.arrow)==null?void 0:b.centerOffset)!==0,c=a?0:e.arrowWidth,d=a?0:e.arrowHeight,[f,u]=Ya(r),p={start:"0%",center:"50%",end:"100%"}[u],m=(((w=o.arrow)==null?void 0:w.x)??0)+c/2,v=(((y=o.arrow)==null?void 0:y.y)??0)+d/2;let g="",h="";return f==="bottom"?(g=a?p:`${m}px`,h=`${-d}px`):f==="top"?(g=a?p:`${m}px`,h=`${n.floating.height+d}px`):f==="right"?(g=`${-d}px`,h=a?p:`${v}px`):f==="left"&&(g=`${n.floating.width+d}px`,h=a?p:`${v}px`),{data:{x:g,y:h}}}});function Ya(e){const[t,r="center"]=e.split("-");return[t,r]}var co=Va,lo=Ka,uo=Ga,fo=Xa,Th="Portal",Dr=l.forwardRef((e,t)=>{var c;const{container:r,...n}=e,[o,s]=l.useState(!1);he(()=>s(!0),[]);const a=r||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return a?es.createPortal(i.jsx(Z.div,{...n,ref:t}),a):null});Dr.displayName=Th;var po="rovingFocusGroup.onEntryFocus",Ah={bubbles:!1,cancelable:!0},qt="RovingFocusGroup",[ho,Ja,Ph]=Rn(qt),[_h,Za]=Oe(qt,[Ph]),[Ih,Oh]=_h(qt),Qa=l.forwardRef((e,t)=>i.jsx(ho.Provider,{scope:e.__scopeRovingFocusGroup,children:i.jsx(ho.Slot,{scope:e.__scopeRovingFocusGroup,children:i.jsx(Mh,{...e,ref:t})})}));Qa.displayName=qt;var Mh=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:u=!1,...p}=e,m=l.useRef(null),v=se(t,m),g=Sr(s),[h,b]=Je({prop:a,defaultProp:c??null,onChange:d,caller:qt}),[w,y]=l.useState(!1),x=ge(f),C=Ja(r),E=l.useRef(!1),[O,N]=l.useState(0);return l.useEffect(()=>{const F=m.current;if(F)return F.addEventListener(po,x),()=>F.removeEventListener(po,x)},[x]),i.jsx(Ih,{scope:r,orientation:n,dir:g,loop:o,currentTabStopId:h,onItemFocus:l.useCallback(F=>b(F),[b]),onItemShiftTab:l.useCallback(()=>y(!0),[]),onFocusableItemAdd:l.useCallback(()=>N(F=>F+1),[]),onFocusableItemRemove:l.useCallback(()=>N(F=>F-1),[]),children:i.jsx(Z.div,{tabIndex:w||O===0?-1:0,"data-orientation":n,...p,ref:v,style:{outline:"none",...e.style},onMouseDown:z(e.onMouseDown,()=>{E.current=!0}),onFocus:z(e.onFocus,F=>{const B=!E.current;if(F.target===F.currentTarget&&B&&!w){const _=new CustomEvent(po,Ah);if(F.currentTarget.dispatchEvent(_),!_.defaultPrevented){const U=C().filter(k=>k.focusable),G=U.find(k=>k.active),L=U.find(k=>k.id===h),q=[G,L,...U].filter(Boolean).map(k=>k.ref.current);ri(q,u)}}E.current=!1}),onBlur:z(e.onBlur,()=>y(!1))})})}),ei="RovingFocusGroupItem",ti=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:s,children:a,...c}=e,d=Me(),f=s||d,u=Oh(ei,r),p=u.currentTabStopId===f,m=Ja(r),{onFocusableItemAdd:v,onFocusableItemRemove:g,currentTabStopId:h}=u;return l.useEffect(()=>{if(n)return v(),()=>g()},[n,v,g]),i.jsx(ho.ItemSlot,{scope:r,id:f,focusable:n,active:o,children:i.jsx(Z.span,{tabIndex:p?0:-1,"data-orientation":u.orientation,...c,ref:t,onMouseDown:z(e.onMouseDown,b=>{n?u.onItemFocus(f):b.preventDefault()}),onFocus:z(e.onFocus,()=>u.onItemFocus(f)),onKeyDown:z(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){u.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const w=Lh(b,u.orientation,u.dir);if(w!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let x=m().filter(C=>C.focusable).map(C=>C.ref.current);if(w==="last")x.reverse();else if(w==="prev"||w==="next"){w==="prev"&&x.reverse();const C=x.indexOf(b.currentTarget);x=u.loop?Fh(x,C+1):x.slice(C+1)}setTimeout(()=>ri(x))}}),children:typeof a=="function"?a({isCurrentTabStop:p,hasTabStop:h!=null}):a})})});ti.displayName=ei;var kh={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Dh(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Lh(e,t,r){const n=Dh(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return kh[n]}function ri(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function Fh(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var $h=Qa,Bh=ti,Uh=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},At=new WeakMap,Lr=new WeakMap,Fr={},go=0,ni=function(e){return e&&(e.host||ni(e.parentNode))},Hh=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=ni(r);return n&&e.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},zh=function(e,t,r,n){var o=Hh(t,Array.isArray(e)?e:[e]);Fr[r]||(Fr[r]=new WeakMap);var s=Fr[r],a=[],c=new Set,d=new Set(o),f=function(p){!p||c.has(p)||(c.add(p),f(p.parentNode))};o.forEach(f);var u=function(p){!p||d.has(p)||Array.prototype.forEach.call(p.children,function(m){if(c.has(m))u(m);else try{var v=m.getAttribute(n),g=v!==null&&v!=="false",h=(At.get(m)||0)+1,b=(s.get(m)||0)+1;At.set(m,h),s.set(m,b),a.push(m),h===1&&g&&Lr.set(m,!0),b===1&&m.setAttribute(r,"true"),g||m.setAttribute(n,"true")}catch(w){console.error("aria-hidden: cannot operate on ",m,w)}})};return u(t),c.clear(),go++,function(){a.forEach(function(p){var m=At.get(p)-1,v=s.get(p)-1;At.set(p,m),s.set(p,v),m||(Lr.has(p)||p.removeAttribute(n),Lr.delete(p)),v||p.removeAttribute(r)}),go--,go||(At=new WeakMap,At=new WeakMap,Lr=new WeakMap,Fr={})}},mo=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),o=Uh(e);return o?(n.push.apply(n,Array.from(o.querySelectorAll("[aria-live], script"))),zh(n,o,r,"aria-hidden")):function(){return null}},Ve=function(){return Ve=Object.assign||function(t){for(var r,n=1,o=arguments.length;n<o;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},Ve.apply(this,arguments)};function oi(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function Wh(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,s;n<o;n++)(s||!(n in t))&&(s||(s=Array.prototype.slice.call(t,0,n)),s[n]=t[n]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var $r="right-scroll-bar-position",Br="width-before-scroll-bar",Rh="with-scroll-bars-hidden",Vh="--removed-body-scroll-bar-size";function bo(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function jh(e,t){var r=A.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(n){var o=r.value;o!==n&&(r.value=n,r.callback(n,o))}}}})[0];return r.callback=t,r.facade}var Kh=typeof window<"u"?l.useLayoutEffect:l.useEffect,si=new WeakMap;function Gh(e,t){var r=jh(null,function(n){return e.forEach(function(o){return bo(o,n)})});return Kh(function(){var n=si.get(r);if(n){var o=new Set(n),s=new Set(e),a=r.current;o.forEach(function(c){s.has(c)||bo(c,null)}),s.forEach(function(c){o.has(c)||bo(c,a)})}si.set(r,e)},[e]),r}function qh(e){return e}function Xh(e,t){t===void 0&&(t=qh);var r=[],n=!1,o={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(s){var a=t(s,n);return r.push(a),function(){r=r.filter(function(c){return c!==a})}},assignSyncMedium:function(s){for(n=!0;r.length;){var a=r;r=[],a.forEach(s)}r={push:function(c){return s(c)},filter:function(){return r}}},assignMedium:function(s){n=!0;var a=[];if(r.length){var c=r;r=[],c.forEach(s),a=r}var d=function(){var u=a;a=[],u.forEach(s)},f=function(){return Promise.resolve().then(d)};f(),r={push:function(u){a.push(u),f()},filter:function(u){return a=a.filter(u),r}}}};return o}function Yh(e){e===void 0&&(e={});var t=Xh(null);return t.options=Ve({async:!0,ssr:!1},e),t}var ai=function(e){var t=e.sideCar,r=oi(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=t.read();if(!n)throw new Error("Sidecar medium not found");return l.createElement(n,Ve({},r))};ai.isSideCarExport=!0;function Jh(e,t){return e.useMedium(t),ai}var ii=Yh(),vo=function(){},Ur=l.forwardRef(function(e,t){var r=l.useRef(null),n=l.useState({onScrollCapture:vo,onWheelCapture:vo,onTouchMoveCapture:vo}),o=n[0],s=n[1],a=e.forwardProps,c=e.children,d=e.className,f=e.removeScrollBar,u=e.enabled,p=e.shards,m=e.sideCar,v=e.noRelative,g=e.noIsolation,h=e.inert,b=e.allowPinchZoom,w=e.as,y=w===void 0?"div":w,x=e.gapMode,C=oi(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),E=m,O=Gh([r,t]),N=Ve(Ve({},C),o);return l.createElement(l.Fragment,null,u&&l.createElement(E,{sideCar:ii,removeScrollBar:f,shards:p,noRelative:v,noIsolation:g,inert:h,setCallbacks:s,allowPinchZoom:!!b,lockRef:r,gapMode:x}),a?l.cloneElement(l.Children.only(c),Ve(Ve({},N),{ref:O})):l.createElement(y,Ve({},N,{className:d,ref:O}),c))});Ur.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Ur.classNames={fullWidth:Br,zeroRight:$r};var Zh=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Qh(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Zh();return t&&e.setAttribute("nonce",t),e}function eg(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function tg(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var rg=function(){var e=0,t=null;return{add:function(r){e==0&&(t=Qh())&&(eg(t,r),tg(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},ng=function(){var e=rg();return function(t,r){l.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},ci=function(){var e=ng(),t=function(r){var n=r.styles,o=r.dynamic;return e(n,o),null};return t},og={left:0,top:0,right:0,gap:0},wo=function(e){return parseInt(e||"",10)||0},sg=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],n=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[wo(r),wo(n),wo(o)]},ag=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return og;var t=sg(e),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,n-r+t[2]-t[0])}},ig=ci(),Pt="data-scroll-locked",cg=function(e,t,r,n){var o=e.left,s=e.top,a=e.right,c=e.gap;return r===void 0&&(r="margin"),`
19
+ .`.concat(Rh,` {
20
+ overflow: hidden `).concat(n,`;
21
+ padding-right: `).concat(c,"px ").concat(n,`;
22
22
  }
23
- body[`).concat(Rt,`] {
24
- overflow: hidden `).concat(r,`;
23
+ body[`).concat(Pt,`] {
24
+ overflow: hidden `).concat(n,`;
25
25
  overscroll-behavior: contain;
26
- `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
26
+ `).concat([t&&"position: relative ".concat(n,";"),r==="margin"&&`
27
27
  padding-left: `.concat(o,`px;
28
28
  padding-top: `).concat(s,`px;
29
29
  padding-right: `).concat(a,`px;
30
30
  margin-left:0;
31
31
  margin-top:0;
32
- margin-right: `).concat(c,"px ").concat(r,`;
33
- `),n==="padding"&&"padding-right: ".concat(c,"px ").concat(r,";")].filter(Boolean).join(""),`
32
+ margin-right: `).concat(c,"px ").concat(n,`;
33
+ `),r==="padding"&&"padding-right: ".concat(c,"px ").concat(n,";")].filter(Boolean).join(""),`
34
34
  }
35
35
 
36
- .`).concat(rr,` {
37
- right: `).concat(c,"px ").concat(r,`;
36
+ .`).concat($r,` {
37
+ right: `).concat(c,"px ").concat(n,`;
38
38
  }
39
39
 
40
- .`).concat(or,` {
41
- margin-right: `).concat(c,"px ").concat(r,`;
40
+ .`).concat(Br,` {
41
+ margin-right: `).concat(c,"px ").concat(n,`;
42
42
  }
43
43
 
44
- .`).concat(rr," .").concat(rr,` {
45
- right: 0 `).concat(r,`;
44
+ .`).concat($r," .").concat($r,` {
45
+ right: 0 `).concat(n,`;
46
46
  }
47
47
 
48
- .`).concat(or," .").concat(or,` {
49
- margin-right: 0 `).concat(r,`;
48
+ .`).concat(Br," .").concat(Br,` {
49
+ margin-right: 0 `).concat(n,`;
50
50
  }
51
51
 
52
- body[`).concat(Rt,`] {
53
- `).concat(gg,": ").concat(c,`px;
52
+ body[`).concat(Pt,`] {
53
+ `).concat(Vh,": ").concat(c,`px;
54
54
  }
55
- `)},Fi=function(){var e=parseInt(document.body.getAttribute(Rt)||"0",10);return isFinite(e)?e:0},Dg=function(){l.useEffect(function(){return document.body.setAttribute(Rt,(Fi()+1).toString()),function(){var e=Fi()-1;e<=0?document.body.removeAttribute(Rt):document.body.setAttribute(Rt,e.toString())}},[])},Lg=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Dg();var s=l.useMemo(function(){return Pg(o)},[o]);return l.createElement(Og,{styles:Mg(s,!t,o,n?"":"!important")})},Ro=!1;if(typeof window<"u")try{var ar=Object.defineProperty({},"passive",{get:function(){return Ro=!0,!0}});window.addEventListener("test",ar,ar),window.removeEventListener("test",ar,ar)}catch{Ro=!1}var Kt=Ro?{passive:!1}:!1,Fg=function(e){return e.tagName==="TEXTAREA"},$i=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Fg(e)&&n[t]==="visible")},$g=function(e){return $i(e,"overflowY")},Bg=function(e){return $i(e,"overflowX")},Bi=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Ui(e,r);if(o){var s=Hi(e,r),a=s[1],c=s[2];if(a>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Ug=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Hg=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Ui=function(e,t){return e==="v"?$g(t):Bg(t)},Hi=function(e,t){return e==="v"?Ug(t):Hg(t)},zg=function(e,t){return e==="h"&&t==="rtl"?-1:1},Wg=function(e,t,n,r,o){var s=zg(e,window.getComputedStyle(t).direction),a=s*r,c=n.target,d=t.contains(c),f=!1,u=a>0,p=0,m=0;do{if(!c)break;var v=Hi(e,c),g=v[0],h=v[1],b=v[2],w=h-b-s*g;(g||w)&&Ui(e,c)&&(p+=w,m+=g);var y=c.parentNode;c=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!d&&c!==document.body||d&&(t.contains(c)||t===c));return(u&&Math.abs(p)<1||!u&&Math.abs(m)<1)&&(f=!0),f},ir=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},zi=function(e){return[e.deltaX,e.deltaY]},Wi=function(e){return e&&"current"in e?e.current:e},Vg=function(e,t){return e[0]===t[0]&&e[1]===t[1]},jg=function(e){return`
55
+ `)},li=function(){var e=parseInt(document.body.getAttribute(Pt)||"0",10);return isFinite(e)?e:0},lg=function(){l.useEffect(function(){return document.body.setAttribute(Pt,(li()+1).toString()),function(){var e=li()-1;e<=0?document.body.removeAttribute(Pt):document.body.setAttribute(Pt,e.toString())}},[])},dg=function(e){var t=e.noRelative,r=e.noImportant,n=e.gapMode,o=n===void 0?"margin":n;lg();var s=l.useMemo(function(){return ag(o)},[o]);return l.createElement(ig,{styles:cg(s,!t,o,r?"":"!important")})},yo=!1;if(typeof window<"u")try{var Hr=Object.defineProperty({},"passive",{get:function(){return yo=!0,!0}});window.addEventListener("test",Hr,Hr),window.removeEventListener("test",Hr,Hr)}catch{yo=!1}var _t=yo?{passive:!1}:!1,ug=function(e){return e.tagName==="TEXTAREA"},di=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!ug(e)&&r[t]==="visible")},fg=function(e){return di(e,"overflowY")},pg=function(e){return di(e,"overflowX")},ui=function(e,t){var r=t.ownerDocument,n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var o=fi(e,n);if(o){var s=pi(e,n),a=s[1],c=s[2];if(a>c)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},hg=function(e){var t=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[t,r,n]},gg=function(e){var t=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[t,r,n]},fi=function(e,t){return e==="v"?fg(t):pg(t)},pi=function(e,t){return e==="v"?hg(t):gg(t)},mg=function(e,t){return e==="h"&&t==="rtl"?-1:1},bg=function(e,t,r,n,o){var s=mg(e,window.getComputedStyle(t).direction),a=s*n,c=r.target,d=t.contains(c),f=!1,u=a>0,p=0,m=0;do{if(!c)break;var v=pi(e,c),g=v[0],h=v[1],b=v[2],w=h-b-s*g;(g||w)&&fi(e,c)&&(p+=w,m+=g);var y=c.parentNode;c=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!d&&c!==document.body||d&&(t.contains(c)||t===c));return(u&&Math.abs(p)<1||!u&&Math.abs(m)<1)&&(f=!0),f},zr=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},hi=function(e){return[e.deltaX,e.deltaY]},gi=function(e){return e&&"current"in e?e.current:e},vg=function(e,t){return e[0]===t[0]&&e[1]===t[1]},wg=function(e){return`
56
56
  .block-interactivity-`.concat(e,` {pointer-events: none;}
57
57
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
58
- `)},Rg=0,Gt=[];function Kg(e){var t=l.useRef([]),n=l.useRef([0,0]),r=l.useRef(),o=l.useState(Rg++)[0],s=l.useState(Li)[0],a=l.useRef(e);l.useEffect(function(){a.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=pg([e.lockRef.current],(e.shards||[]).map(Wi),!0).filter(Boolean);return h.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),h.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(h,b){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!a.current.allowPinchZoom;var w=ir(h),y=n.current,x="deltaX"in h?h.deltaX:y[0]-w[0],C="deltaY"in h?h.deltaY:y[1]-w[1],E,P=h.target,T=Math.abs(x)>Math.abs(C)?"h":"v";if("touches"in h&&T==="h"&&P.type==="range")return!1;var F=Bi(T,P);if(!F)return!0;if(F?E=T:(E=T==="v"?"h":"v",F=Bi(T,P)),!F)return!1;if(!r.current&&"changedTouches"in h&&(x||C)&&(r.current=E),!E)return!0;var M=r.current||E;return Wg(M,b,h,M==="h"?x:C)},[]),d=l.useCallback(function(h){var b=h;if(!(!Gt.length||Gt[Gt.length-1]!==s)){var w="deltaY"in b?zi(b):ir(b),y=t.current.filter(function(E){return E.name===b.type&&(E.target===b.target||b.target===E.shadowParent)&&Vg(E.delta,w)})[0];if(y&&y.should){b.cancelable&&b.preventDefault();return}if(!y){var x=(a.current.shards||[]).map(Wi).filter(Boolean).filter(function(E){return E.contains(b.target)}),C=x.length>0?c(b,x[0]):!a.current.noIsolation;C&&b.cancelable&&b.preventDefault()}}},[]),f=l.useCallback(function(h,b,w,y){var x={name:h,delta:b,target:w,should:y,shadowParent:Gg(w)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(C){return C!==x})},1)},[]),u=l.useCallback(function(h){n.current=ir(h),r.current=void 0},[]),p=l.useCallback(function(h){f(h.type,zi(h),h.target,c(h,e.lockRef.current))},[]),m=l.useCallback(function(h){f(h.type,ir(h),h.target,c(h,e.lockRef.current))},[]);l.useEffect(function(){return Gt.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",d,Kt),document.addEventListener("touchmove",d,Kt),document.addEventListener("touchstart",u,Kt),function(){Gt=Gt.filter(function(h){return h!==s}),document.removeEventListener("wheel",d,Kt),document.removeEventListener("touchmove",d,Kt),document.removeEventListener("touchstart",u,Kt)}},[]);var v=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(s,{styles:jg(o)}):null,v?l.createElement(Lg,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Gg(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const qg=Sg(Di,Kg);var cr=l.forwardRef(function(e,t){return l.createElement(sr,lt({},e,{ref:t,sideCar:qg}))});cr.classNames=sr.classNames;var Ko=["Enter"," "],Xg=["ArrowDown","PageUp","Home"],Vi=["ArrowUp","PageDown","End"],Yg=[...Xg,...Vi],Jg={ltr:[...Ko,"ArrowRight"],rtl:[...Ko,"ArrowLeft"]},Zg={ltr:["ArrowLeft"],rtl:["ArrowRight"]},pn="Menu",[hn,Qg,em]=go(pn),[It,ji]=Ke(pn,[em,Vt,Ni]),lr=Vt(),Ri=Ni(),[tm,kt]=It(pn),[nm,gn]=It(pn),Ki=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:a=!0}=e,c=lr(t),[d,f]=l.useState(null),u=l.useRef(!1),p=Ae(s),m=Wn(o);return l.useEffect(()=>{const v=()=>{u.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>u.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),i.jsx(Do,{...c,children:i.jsx(tm,{scope:t,open:n,onOpenChange:p,content:d,onContentChange:f,children:i.jsx(nm,{scope:t,onClose:l.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:u,dir:m,modal:a,children:r})})})};Ki.displayName=pn;var rm="MenuAnchor",Go=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=lr(n);return i.jsx(Lo,{...o,...r,ref:t})});Go.displayName=rm;var qo="MenuPortal",[om,Gi]=It(qo,{forceMount:void 0}),qi=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=kt(qo,t);return i.jsx(om,{scope:t,forceMount:n,children:i.jsx(Le,{present:n||s.open,children:i.jsx(er,{asChild:!0,container:o,children:r})})})};qi.displayName=qo;var ze="MenuContent",[sm,Xo]=It(ze),Xi=l.forwardRef((e,t)=>{const n=Gi(ze,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=kt(ze,e.__scopeMenu),a=gn(ze,e.__scopeMenu);return i.jsx(hn.Provider,{scope:e.__scopeMenu,children:i.jsx(Le,{present:r||s.open,children:i.jsx(hn.Slot,{scope:e.__scopeMenu,children:a.modal?i.jsx(am,{...o,ref:t}):i.jsx(im,{...o,ref:t})})})})}),am=l.forwardRef((e,t)=>{const n=kt(ze,e.__scopeMenu),r=l.useRef(null),o=ue(t,r);return l.useEffect(()=>{const s=r.current;if(s)return zo(s)},[]),i.jsx(Yo,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:U(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),im=l.forwardRef((e,t)=>{const n=kt(ze,e.__scopeMenu);return i.jsx(Yo,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),cm=Be.createSlot("MenuContent.ScrollLock"),Yo=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:m,onDismiss:v,disableOutsideScroll:g,...h}=e,b=kt(ze,n),w=gn(ze,n),y=lr(n),x=Ri(n),C=Qg(n),[E,P]=l.useState(null),T=l.useRef(null),F=ue(t,T,b.onContentChange),M=l.useRef(0),B=l.useRef(""),V=l.useRef(0),J=l.useRef(null),H=l.useRef("right"),O=l.useRef(0),ne=g?cr:l.Fragment,L=g?{as:cm,allowPinchZoom:!0}:void 0,z=I=>{var R,le;const Z=B.current+I,j=C().filter(he=>!he.disabled),te=document.activeElement,D=(R=j.find(he=>he.ref.current===te))==null?void 0:R.textValue,W=j.map(he=>he.textValue),xe=ym(W,Z,D),ie=(le=j.find(he=>he.textValue===xe))==null?void 0:le.ref.current;(function he(de){B.current=de,window.clearTimeout(M.current),de!==""&&(M.current=window.setTimeout(()=>he(""),1e3))})(Z),ie&&setTimeout(()=>ie.focus())};l.useEffect(()=>()=>window.clearTimeout(M.current),[]),vo();const k=l.useCallback(I=>{var j,te;return H.current===((j=J.current)==null?void 0:j.side)&&Sm(I,(te=J.current)==null?void 0:te.area)},[]);return i.jsx(sm,{scope:n,searchRef:B,onItemEnter:l.useCallback(I=>{k(I)&&I.preventDefault()},[k]),onItemLeave:l.useCallback(I=>{var Z;k(I)||((Z=T.current)==null||Z.focus(),P(null))},[k]),onTriggerLeave:l.useCallback(I=>{k(I)&&I.preventDefault()},[k]),pointerGraceTimerRef:V,onPointerGraceIntentChange:l.useCallback(I=>{J.current=I},[]),children:i.jsx(ne,{...L,children:i.jsx(Vn,{asChild:!0,trapped:o,onMountAutoFocus:U(s,I=>{var Z;I.preventDefault(),(Z=T.current)==null||Z.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:i.jsx(cn,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:m,onDismiss:v,children:i.jsx(cg,{asChild:!0,...x,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:E,onCurrentTabStopIdChange:P,onEntryFocus:U(d,I=>{w.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:i.jsx(Fo,{role:"menu","aria-orientation":"vertical","data-state":fc(b.open),"data-radix-menu-content":"",dir:w.dir,...y,...h,ref:F,style:{outline:"none",...h.style},onKeyDown:U(h.onKeyDown,I=>{const j=I.target.closest("[data-radix-menu-content]")===I.currentTarget,te=I.ctrlKey||I.altKey||I.metaKey,D=I.key.length===1;j&&(I.key==="Tab"&&I.preventDefault(),!te&&D&&z(I.key));const W=T.current;if(I.target!==W||!Yg.includes(I.key))return;I.preventDefault();const ie=C().filter(R=>!R.disabled).map(R=>R.ref.current);Vi.includes(I.key)&&ie.reverse(),vm(ie)}),onBlur:U(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(M.current),B.current="")}),onPointerMove:U(e.onPointerMove,bn(I=>{const Z=I.target,j=O.current!==I.clientX;if(I.currentTarget.contains(Z)&&j){const te=I.clientX>O.current?"right":"left";H.current=te,O.current=I.clientX}}))})})})})})})});Xi.displayName=ze;var lm="MenuGroup",Jo=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(oe.div,{role:"group",...r,ref:t})});Jo.displayName=lm;var dm="MenuLabel",Yi=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(oe.div,{...r,ref:t})});Yi.displayName=dm;var dr="MenuItem",Ji="menu.itemSelect",ur=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=l.useRef(null),a=gn(dr,e.__scopeMenu),c=Xo(dr,e.__scopeMenu),d=ue(t,s),f=l.useRef(!1),u=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(Ji,{bubbles:!0,cancelable:!0});p.addEventListener(Ji,v=>r==null?void 0:r(v),{once:!0}),Ta(p,m),m.defaultPrevented?f.current=!1:a.onClose()}};return i.jsx(Zi,{...o,ref:d,disabled:n,onClick:U(e.onClick,u),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),f.current=!0},onPointerUp:U(e.onPointerUp,p=>{var m;f.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:U(e.onKeyDown,p=>{const m=c.searchRef.current!=="";n||m&&p.key===" "||Ko.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});ur.displayName=dr;var Zi=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,a=Xo(dr,n),c=Ri(n),d=l.useRef(null),f=ue(t,d),[u,p]=l.useState(!1),[m,v]=l.useState("");return l.useEffect(()=>{const g=d.current;g&&v((g.textContent??"").trim())},[s.children]),i.jsx(hn.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:i.jsx(lg,{asChild:!0,...c,focusable:!r,children:i.jsx(oe.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:f,onPointerMove:U(e.onPointerMove,bn(g=>{r?a.onItemLeave(g):(a.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:U(e.onPointerLeave,bn(g=>a.onItemLeave(g))),onFocus:U(e.onFocus,()=>p(!0)),onBlur:U(e.onBlur,()=>p(!1))})})})}),um="MenuCheckboxItem",Qi=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return i.jsx(oc,{scope:e.__scopeMenu,checked:n,children:i.jsx(ur,{role:"menuitemcheckbox","aria-checked":fr(n)?"mixed":n,...o,ref:t,"data-state":Qo(n),onSelect:U(o.onSelect,()=>r==null?void 0:r(fr(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Qi.displayName=um;var ec="MenuRadioGroup",[fm,pm]=It(ec,{value:void 0,onValueChange:()=>{}}),tc=l.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Ae(r);return i.jsx(fm,{scope:e.__scopeMenu,value:n,onValueChange:s,children:i.jsx(Jo,{...o,ref:t})})});tc.displayName=ec;var nc="MenuRadioItem",rc=l.forwardRef((e,t)=>{const{value:n,...r}=e,o=pm(nc,e.__scopeMenu),s=n===o.value;return i.jsx(oc,{scope:e.__scopeMenu,checked:s,children:i.jsx(ur,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Qo(s),onSelect:U(r.onSelect,()=>{var a;return(a=o.onValueChange)==null?void 0:a.call(o,n)},{checkForDefaultPrevented:!1})})})});rc.displayName=nc;var Zo="MenuItemIndicator",[oc,hm]=It(Zo,{checked:!1}),sc=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=hm(Zo,n);return i.jsx(Le,{present:r||fr(s.checked)||s.checked===!0,children:i.jsx(oe.span,{...o,ref:t,"data-state":Qo(s.checked)})})});sc.displayName=Zo;var gm="MenuSeparator",ac=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return i.jsx(oe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ac.displayName=gm;var mm="MenuArrow",ic=l.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=lr(n);return i.jsx($o,{...o,...r,ref:t})});ic.displayName=mm;var bm="MenuSub",[ay,cc]=It(bm),mn="MenuSubTrigger",lc=l.forwardRef((e,t)=>{const n=kt(mn,e.__scopeMenu),r=gn(mn,e.__scopeMenu),o=cc(mn,e.__scopeMenu),s=Xo(mn,e.__scopeMenu),a=l.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=s,f={__scopeMenu:e.__scopeMenu},u=l.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return l.useEffect(()=>u,[u]),l.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),d(null)}},[c,d]),i.jsx(Go,{asChild:!0,...f,children:i.jsx(Zi,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":fc(n.open),...e,ref:lo(t,o.onTriggerChange),onClick:p=>{var m;(m=e.onClick)==null||m.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:U(e.onPointerMove,bn(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!a.current&&(s.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:U(e.onPointerLeave,bn(p=>{var v,g;u();const m=(v=n.content)==null?void 0:v.getBoundingClientRect();if(m){const h=(g=n.content)==null?void 0:g.dataset.side,b=h==="right",w=b?-5:5,y=m[b?"left":"right"],x=m[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+w,y:p.clientY},{x:y,y:m.top},{x,y:m.top},{x,y:m.bottom},{x:y,y:m.bottom}],side:h}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:U(e.onKeyDown,p=>{var v;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||Jg[r.dir].includes(p.key)&&(n.onOpenChange(!0),(v=n.content)==null||v.focus(),p.preventDefault())})})})});lc.displayName=mn;var dc="MenuSubContent",uc=l.forwardRef((e,t)=>{const n=Gi(ze,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=kt(ze,e.__scopeMenu),a=gn(ze,e.__scopeMenu),c=cc(dc,e.__scopeMenu),d=l.useRef(null),f=ue(t,d);return i.jsx(hn.Provider,{scope:e.__scopeMenu,children:i.jsx(Le,{present:r||s.open,children:i.jsx(hn.Slot,{scope:e.__scopeMenu,children:i.jsx(Yo,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:f,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var p;a.isUsingKeyboardRef.current&&((p=d.current)==null||p.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:U(e.onFocusOutside,u=>{u.target!==c.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:U(e.onEscapeKeyDown,u=>{a.onClose(),u.preventDefault()}),onKeyDown:U(e.onKeyDown,u=>{var v;const p=u.currentTarget.contains(u.target),m=Zg[a.dir].includes(u.key);p&&m&&(s.onOpenChange(!1),(v=c.trigger)==null||v.focus(),u.preventDefault())})})})})})});uc.displayName=dc;function fc(e){return e?"open":"closed"}function fr(e){return e==="indeterminate"}function Qo(e){return fr(e)?"indeterminate":e?"checked":"unchecked"}function vm(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function wm(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function ym(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let a=wm(e,Math.max(s,0));o.length===1&&(a=a.filter(f=>f!==n));const d=a.find(f=>f.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function xm(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const c=t[s],d=t[a],f=c.x,u=c.y,p=d.x,m=d.y;u>r!=m>r&&n<(p-f)*(r-u)/(m-u)+f&&(o=!o)}return o}function Sm(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return xm(n,t)}function bn(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Cm=Ki,Em=Go,Nm=qi,Tm=Xi,Am=Jo,Im=Yi,km=ur,_m=Qi,Pm=tc,Om=rc,Mm=sc,Dm=ac,Lm=ic,Fm=lc,$m=uc,pr="DropdownMenu",[Bm,iy]=Ke(pr,[ji]),Oe=ji(),[Um,pc]=Bm(pr),hc=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:a,modal:c=!0}=e,d=Oe(t),f=l.useRef(null),[u,p]=mt({prop:o,defaultProp:s??!1,onChange:a,caller:pr});return i.jsx(Um,{scope:t,triggerId:Ge(),triggerRef:f,contentId:Ge(),open:u,onOpenChange:p,onOpenToggle:l.useCallback(()=>p(m=>!m),[p]),modal:c,children:i.jsx(Cm,{...d,open:u,onOpenChange:p,dir:r,modal:c,children:n})})};hc.displayName=pr;var gc="DropdownMenuTrigger",mc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=pc(gc,n),a=Oe(n);return i.jsx(Em,{asChild:!0,...a,children:i.jsx(oe.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:lo(t,s.triggerRef),onPointerDown:U(e.onPointerDown,c=>{!r&&c.button===0&&c.ctrlKey===!1&&(s.onOpenToggle(),s.open||c.preventDefault())}),onKeyDown:U(e.onKeyDown,c=>{r||(["Enter"," "].includes(c.key)&&s.onOpenToggle(),c.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});mc.displayName=gc;var Hm="DropdownMenuPortal",bc=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Oe(t);return i.jsx(Nm,{...r,...n})};bc.displayName=Hm;var vc="DropdownMenuContent",wc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=pc(vc,n),s=Oe(n),a=l.useRef(!1);return i.jsx(Tm,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:U(e.onCloseAutoFocus,c=>{var d;a.current||(d=o.triggerRef.current)==null||d.focus(),a.current=!1,c.preventDefault()}),onInteractOutside:U(e.onInteractOutside,c=>{const d=c.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0,u=d.button===2||f;(!o.modal||u)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});wc.displayName=vc;var zm="DropdownMenuGroup",Wm=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Am,{...o,...r,ref:t})});Wm.displayName=zm;var Vm="DropdownMenuLabel",yc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Im,{...o,...r,ref:t})});yc.displayName=Vm;var jm="DropdownMenuItem",xc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(km,{...o,...r,ref:t})});xc.displayName=jm;var Rm="DropdownMenuCheckboxItem",Sc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(_m,{...o,...r,ref:t})});Sc.displayName=Rm;var Km="DropdownMenuRadioGroup",Gm=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Pm,{...o,...r,ref:t})});Gm.displayName=Km;var qm="DropdownMenuRadioItem",Cc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Om,{...o,...r,ref:t})});Cc.displayName=qm;var Xm="DropdownMenuItemIndicator",Ec=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Mm,{...o,...r,ref:t})});Ec.displayName=Xm;var Ym="DropdownMenuSeparator",Nc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Dm,{...o,...r,ref:t})});Nc.displayName=Ym;var Jm="DropdownMenuArrow",Zm=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Lm,{...o,...r,ref:t})});Zm.displayName=Jm;var Qm="DropdownMenuSubTrigger",Tc=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx(Fm,{...o,...r,ref:t})});Tc.displayName=Qm;var eb="DropdownMenuSubContent",Ac=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Oe(n);return i.jsx($m,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Ac.displayName=eb;var tb=hc,nb=mc,rb=bc,Ic=wc,kc=yc,_c=xc,Pc=Sc,Oc=Cc,Mc=Ec,Dc=Nc,Lc=Tc,Fc=Ac;const ob=tb,sb=nb,ab=l.forwardRef(({className:e,inset:t,children:n,...r},o)=>i.jsxs(Lc,{ref:o,className:A("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,i.jsx(q.ChevronRight,{className:"ml-auto h-4 w-4"})]}));ab.displayName=Lc.displayName;const ib=l.forwardRef(({className:e,...t},n)=>i.jsx(Fc,{ref:n,className:A("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",e),...t}));ib.displayName=Fc.displayName;const $c=l.forwardRef(({className:e,sideOffset:t=4,...n},r)=>i.jsx(rb,{children:i.jsx(Ic,{ref:r,sideOffset:t,className:A("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",e),...n})}));$c.displayName=Ic.displayName;const Bc=l.forwardRef(({className:e,inset:t,...n},r)=>i.jsx(_c,{ref:r,className:A("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Bc.displayName=_c.displayName;const cb=l.forwardRef(({className:e,children:t,checked:n,...r},o)=>i.jsxs(Pc,{ref:o,className:A("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Mc,{children:i.jsx(q.Check,{className:"h-4 w-4"})})}),t]}));cb.displayName=Pc.displayName;const lb=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(Oc,{ref:r,className:A("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Mc,{children:i.jsx(q.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));lb.displayName=Oc.displayName;const db=l.forwardRef(({className:e,inset:t,...n},r)=>i.jsx(kc,{ref:r,className:A("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));db.displayName=kc.displayName;const ub=l.forwardRef(({className:e,...t},n)=>i.jsx(Dc,{ref:n,className:A("-mx-1 my-1 h-px bg-muted",e),...t}));ub.displayName=Dc.displayName;const We=e=>{if(!e)return null;const t=Date.parse(e);return Number.isFinite(t)?t:null},fb=e=>{const t=We(e);return t!==null?new Date(t).toLocaleString():e??"Unknown"};function vn({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=40,enableFileUpload:s=!0,enableMessageEditing:a=!0,customStyles:c={},onMessageSent:d,onError:f}){const{currentThreadId:u,messages:p,isStreaming:m,streamingAssistantId:v,error:g,send:h,stop:b,lastCheckpointId:w,lastBranchEvent:y,listCheckpoints:x,navigateToCheckpoint:C,returnToLatest:E,hasMoreHistory:P,isLoadingHistory:T,loadOlderMessages:F}=co(),[M,B]=N.useState(""),[V,J]=N.useState(null),[H,O]=N.useState(null),[ne,L]=N.useState([]),[z,k]=N.useState(!1),[I,Z]=N.useState([]),[j,te]=N.useState(null),[D,W]=N.useState({}),xe=N.useRef(null),ie=N.useRef(null),R=N.useRef(null),le=N.useRef(null),he=N.useRef(!1),de=N.useRef(!0),be=N.useRef(0),ge=N.useRef(null),[G,X]=N.useState("desktop");N.useEffect(()=>{const _=()=>{const $=window.innerWidth;X($<640?"phone":$<1024?"tablet":"desktop")};return _(),window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]),N.useEffect(()=>{W({}),ge.current=null},[u]);const ye=N.useCallback(_=>{if(!_.length)return[];let $=null,K=-1/0,Y=null,re=-1/0;for(const ee of _){const Te=ee.createdAt??null,pe=typeof Te=="number"&&Number.isFinite(Te)?Te:null;if(ee.parentCheckpointId===null){($==null||(pe??-1/0)>K)&&($=ee,K=pe??-1/0);continue}if(ee.parentCheckpointId!==null){const Ee=pe??(ee.checkpointId?Number.MAX_SAFE_INTEGER:-1/0);(Y==null||Ee>re)&&(Y=ee,re=Ee)}}const Q=[];return $&&Q.push({...$}),Y&&Q.push({...Y}),Q},[]),se=N.useCallback(_=>{const $=new Map;for(const Q of _)Q.checkpointId&&$.set(Q.checkpointId,Q);const K={},Y=Q=>(K[Q]||(K[Q]=[]),K[Q]),re=(Q,ee)=>{const Te=ee.checkpointId??"__root__",pe=Q.find(Ee=>(Ee.checkpointId??"__root__")===Te);if(pe){ee.parentCheckpointId!==void 0&&pe.parentCheckpointId==null&&(pe.parentCheckpointId=ee.parentCheckpointId),ee.branchLabel&&!pe.branchLabel&&(pe.branchLabel=ee.branchLabel),ee.createdAt!==void 0&&ee.createdAt!==null&&(pe.createdAt=ee.createdAt);return}Q.push({...ee})};for(const Q of _){const ee=Q.editedMessageId??void 0;if(!ee)continue;const Te=Y(ee),pe=Q.parentId??null,Ee=pe?$.get(pe):void 0,Qe=(Ee==null?void 0:Ee.branchLabel)??(Ee==null?void 0:Ee.preview)??"Original",Ur=We(Ee==null?void 0:Ee.createdAt);re(Te,{checkpointId:pe,parentCheckpointId:null,branchLabel:Qe,createdAt:Ur});const Pe=Q.branchLabel??Q.preview??void 0,et=We(Q.createdAt);re(Te,{checkpointId:Q.checkpointId??null,parentCheckpointId:pe,branchLabel:Pe,createdAt:et})}for(const Q of Object.keys(K))K[Q]=ye(K[Q]);return K},[ye]),Se=N.useCallback((_,$)=>{const K={},Y=(re,Q)=>{if(!(Q!=null&&Q.length))return;const ee=K[re]??[],Te=new Map;for(const pe of ee)Te.set(pe.checkpointId??"__root__",pe);for(const pe of Q){const Ee=pe.checkpointId??"__root__",Qe=Te.get(Ee);Qe?(pe.parentCheckpointId!==void 0&&Qe.parentCheckpointId==null&&(Qe.parentCheckpointId=pe.parentCheckpointId),pe.branchLabel&&!Qe.branchLabel&&(Qe.branchLabel=pe.branchLabel),pe.createdAt!==void 0&&pe.createdAt!==null&&(Qe.createdAt=pe.createdAt)):(ee.push({...pe}),Te.set(Ee,ee[ee.length-1]))}K[re]=ee};for(const[re,Q]of Object.entries(_))Y(re,Q);for(const[re,Q]of Object.entries($))Y(re,Q);for(const re of Object.keys(K))K[re]=ye(K[re]);return K},[ye]),fe=N.useCallback(async()=>{if(!P||T)return;const _=le.current;if(!_)return;const $=_.scrollHeight,K=_.scrollTop;he.current=!0;try{await F()}catch(Y){console.warn("loadOlderMessages failed",Y)}finally{requestAnimationFrame(()=>{const Y=le.current;if(!Y){he.current=!1;return}const re=Y.scrollHeight;Y.scrollTop=K+(re-$);const Q=re-Y.scrollTop-Y.clientHeight;de.current=Q<=32,he.current=!1})}},[P,T,F]);N.useEffect(()=>{const _=le.current;if(!_)return;const $=()=>{_.scrollTop<=80&&fe();const re=_.scrollHeight-_.scrollTop-_.clientHeight;de.current=re<=80};return _.addEventListener("scroll",$),()=>_.removeEventListener("scroll",$)},[fe]),N.useEffect(()=>{p.length<be.current&&(de.current=!0),be.current=p.length},[p.length]),N.useEffect(()=>{const _=le.current;_&&(he.current||de.current&&(_.scrollTop=_.scrollHeight,de.current=!0))},[p]),N.useEffect(()=>{var _;n&&((_=ie.current)==null||_.focus())},[n]),N.useEffect(()=>{g&&!z&&(f==null||f(g))},[g,z,f]),N.useEffect(()=>{let _=!0;if(!u){Z([]),te(null),W({});return}return x(u).then($=>{var Q;if(!_)return;const K=$.checkpoints||[];Z(K);const Y=se(K);W(ee=>Se(Y,ee));const re=((Q=K.slice().sort((ee,Te)=>(We(Te.createdAt)??-1/0)-(We(ee.createdAt)??-1/0))[0])==null?void 0:Q.checkpointId)||null;te(ee=>ee??re)}).catch(()=>{}),()=>{_=!1}},[u,x,se,Se]),N.useEffect(()=>{w&&te(w)},[w]);const ve=_=>{if(_.length>Bt)return`Message too long (${_.length}/${Bt} characters)`;try{return mp(_),null}catch($){return($==null?void 0:$.message)||"Invalid message"}},_e=_=>{const $=_.content||[],K=$.filter(Y=>Y.type==="text").map(Y=>Y.text).join("");if(K)return K;try{return JSON.stringify($,null,2)}catch{return String($)}},Fe=N.useMemo(()=>{const _=new Map;for(const $ of I)$!=null&&$.checkpointId&&_.set($.checkpointId,$);return _},[I]);N.useEffect(()=>{if(!y)return;const _=[y.editedMessageId??"",y.parentCheckpointId??"",y.checkpointId??""].join("::");if(ge.current===_)return;ge.current=_;const $=y.editedMessageId;$&&W(K=>{const Y=K[$]??[],re=new Map;for(const Pe of Y){const et=Pe.checkpointId??"__root__";re.set(et,Pe)}const Q=(Pe,et,Hr,zr)=>{if(Pe===void 0)return;const Wr=Pe??"__root__",tt=re.get(Wr);re.set(Wr,{checkpointId:Pe,parentCheckpointId:et??(tt==null?void 0:tt.parentCheckpointId)??null,branchLabel:Hr??(tt==null?void 0:tt.branchLabel)??null,createdAt:zr??(tt==null?void 0:tt.createdAt)??null})},ee=y.parentCheckpointId?Fe.get(y.parentCheckpointId):void 0,Te=We(ee==null?void 0:ee.createdAt);if(y.parentCheckpointId){const Pe=re.get(y.parentCheckpointId),et=(Pe==null?void 0:Pe.branchLabel)??(ee==null?void 0:ee.preview)??"Original";Q(y.parentCheckpointId,null,et,Te)}const pe=y.checkpointId?Fe.get(y.checkpointId):void 0,Ee=We(pe==null?void 0:pe.createdAt)??Date.now();Q(y.checkpointId??null,y.parentCheckpointId??null,y.branchLabel??(pe==null?void 0:pe.preview)??null,Ee);const Qe=Array.from(re.values()),Ur=y.parentCheckpointId??null;return Qe.sort((Pe,et)=>{if(Pe.checkpointId===Ur)return-1;if(et.checkpointId===Ur)return 1;const Hr=Pe.checkpointId?Fe.get(Pe.checkpointId):void 0,zr=et.checkpointId?Fe.get(et.checkpointId):void 0,Wr=Hr?We(Hr.createdAt)??Number.MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,tt=zr?We(zr.createdAt)??Number.MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER;return Wr-tt}),{...K,[$]:ye(Qe)}})},[y,Fe,ye]);const ht=_=>{const $=p[_],K=$==null?void 0:$.id;if(!K)return[];const Y=D[K];return Y!=null&&Y.length?Y.map((re,Q)=>{const ee=re.checkpointId?Fe.get(re.checkpointId):void 0,Te=ee?We(ee.createdAt)??void 0:void 0,pe=re.checkpointId?re.checkpointId===j:!j,Ee=Q===0?"Original":`Branch ${Q}`;return{checkpoint_id:re.checkpointId,checkpoint_ns:ee==null?void 0:ee.checkpointNs,message_count:(ee==null?void 0:ee.messagesLen)??0,last_message_preview:(ee==null?void 0:ee.preview)??void 0,ts:Te,isCurrent:pe,label:re.branchLabel??(ee==null?void 0:ee.preview)??Ee}}):[]},Es=_=>{var Q;if(_===void 0)return{canGoBack:!1,canGoForward:!1,currentIndex:0,totalBranches:0,currentLabel:null};const $=ht(_);if($.length<=1)return{canGoBack:!1,canGoForward:!1,currentIndex:0,totalBranches:$.length,currentLabel:((Q=$[0])==null?void 0:Q.label)??null};const K=$.findIndex(ee=>ee.isCurrent),Y=K>=0?K:0,re=$[Y]??null;return{canGoBack:Y>0,canGoForward:Y<$.length-1,currentIndex:Y,totalBranches:$.length,currentLabel:(re==null?void 0:re.label)??null}},En=async()=>{const _=M.trim();if(!_&&ne.length===0)return;const $=ve(_);if($){O($);return}try{const K=window.__editingCheckpointId||j||void 0;await h(_,{checkpointId:K,payloadExtras:V?{edit:!0,originalMessageId:V}:void 0,attachments:ne}),d==null||d(_),B(""),O(null),L([]),delete window.__editingCheckpointId,J(null),ie.current&&(ie.current.style.height="auto")}catch(K){const Y=(K==null?void 0:K.message)||"Failed to send message";O(Y),f==null||f(Y)}},Ns=(_,$)=>{a&&(J(_),B($),O(null),setTimeout(()=>{ie.current&&(ie.current.focus(),ie.current.style.height="auto",ie.current.style.height=ie.current.scrollHeight+"px")},0))},Fr=async(_,$)=>{const K=p.find(re=>re.id===_);if(!K){O("Message not found");return}const Y=_e(K);J(_),B(Y),window.__editingCheckpointId=$,setTimeout(()=>{var re;return(re=ie.current)==null?void 0:re.focus()},0)},Nn=()=>{J(null),B(""),O(null),delete window.__editingCheckpointId,ie.current&&(ie.current.style.height="auto")},Ts=_=>{_.key==="Enter"&&!_.shiftKey?(_.preventDefault(),En()):_.key==="Escape"&&V&&(_.preventDefault(),Nn())},$r=_=>{const $=Array.from(_.target.files||[]);L(K=>[...K,...$])},me=_=>L($=>$.filter((K,Y)=>_!==Y)),Ie=async _=>{if(u){if(!_){await E(),te(null);return}await C(_),te(_)}},$e=async()=>{await E(),te(null)},Ze=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${c.container||""}`,gt=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-y-auto overflow-x-auto overscroll-contain break-words break-anywhere p-4 space-y-4 bg-transparent ${c.messagesArea||""}`,Br=`flex-shrink-0 w-full border-t p-4 bg-transparent ${c.inputArea||""}`;return i.jsxs("div",{className:Ze,children:[!!g&&!z&&i.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[i.jsx("span",{children:g}),i.jsx(we,{variant:"ghost",size:"sm",onClick:()=>k(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:i.jsx(q.X,{size:16})})]}),u&&I.length>0&&i.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[i.jsx(q.GitBranch,{className:"h-4 w-4 opacity-70"}),i.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),i.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:j??"",onChange:_=>{const $=_.target.value||null;Ie($)},children:[i.jsx("option",{value:"",children:"Latest"}),I.slice().sort((_,$)=>(We($.createdAt)??-1/0)-(We(_.createdAt)??-1/0)).map(_=>i.jsxs("option",{value:_.checkpointId,children:[fb(_.createdAt),_.preview?` — ${_.preview.slice(0,30)}`:""]},_.checkpointId))]})]}),i.jsxs("div",{ref:le,className:gt,style:r?{maxHeight:r}:void 0,children:[p.length===0?i.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:"No messages yet. Start a conversation!"}):i.jsxs(i.Fragment,{children:[(T||!P)&&i.jsx("div",{className:"flex justify-center py-2 text-xs text-muted-foreground",children:T?i.jsx(q.Loader2,{className:"h-4 w-4 animate-spin"}):"You've reached the beginning"}),p.map((_,$)=>i.jsx(Oa,{message:_,messageIndex:$,isStreamingMessage:m&&v===_.id,streamingDebounceMs:o,isEditing:V===_.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:G,truncateToolMessages:!1,toolMessagePreviewLength:200,checkpointBranches:ht($),currentCheckpointId:j??void 0,temporalNavigation:Es($),onSwitchToCheckpoint:Ie,onReturnToMainThread:$e,onNavigateToPreviousBranch:()=>{var re;const K=ht($),Y=Math.max(0,K.findIndex(Q=>Q.isCurrent));if(Y>0){const Q=((re=K[Y-1])==null?void 0:re.checkpoint_id)??null;Ie(Q??null)}},onNavigateToNextBranch:()=>{var re;const K=ht($),Y=Math.max(0,K.findIndex(Q=>Q.isCurrent));if(Y>=0&&Y<K.length-1){const Q=((re=K[Y+1])==null?void 0:re.checkpoint_id)??null;Ie(Q??null)}},onEdit:(K,Y)=>Ns(K,Y),onEditFromCheckpoint:Fr,onRegenerate:()=>{const K=[...p].reverse().find(re=>re.role==="user"),Y=K?_e(K):"";Y&&h(Y,{checkpointId:j??void 0})},onCancelEdit:Nn},_.id||$))]}),i.jsx("div",{ref:xe})]}),i.jsxs("div",{className:Br,children:[V&&i.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(q.Edit3,{size:16,className:"text-blue-600"}),i.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),i.jsx(we,{variant:"ghost",size:"sm",onClick:Nn,className:"text-blue-600 hover:bg-blue-100",children:i.jsx(q.X,{size:16})})]})}),s&&i.jsxs("div",{className:"mb-3",children:[i.jsx("input",{ref:R,type:"file",multiple:!0,onChange:_=>$r(_),className:"hidden"}),ne.length>0&&i.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:ne.map((_,$)=>i.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 rounded-lg px-3 py-2 text-sm",children:[i.jsx(q.Paperclip,{size:14}),i.jsx("span",{className:"truncate max-w-[150px]",children:_.name}),i.jsx(we,{variant:"ghost",size:"sm",onClick:()=>me($),className:"h-4 w-4 p-0 text-gray-500 hover:text-red-500","aria-label":`Remove ${_.name}`,children:i.jsx(q.X,{size:12})})]},$))})]}),H&&i.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:H}),i.jsxs("div",{className:"flex items-end gap-2",children:[s&&i.jsxs(ob,{children:[i.jsx(sb,{asChild:!0,children:i.jsx(we,{type:"button",size:"icon",variant:"outline",disabled:m,title:"More input actions",className:c.moreButton||"",children:i.jsx(q.Plus,{size:16})})}),i.jsx($c,{align:"start",sideOffset:6,className:"w-52",children:i.jsxs(Bc,{onClick:()=>{var _;return(_=R.current)==null?void 0:_.click()},className:"cursor-pointer",children:[i.jsx(q.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]})})]}),i.jsx("div",{className:"flex-1",children:i.jsx(Ca,{ref:ie,value:M,onChange:_=>{B(_.target.value),O(null),ie.current&&(ie.current.style.height="auto",ie.current.style.height=`${ie.current.scrollHeight}px`)},onKeyDown:Ts,placeholder:V?"Edit your message...":t,className:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${V?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${H?"border-red-400":""} ${c.textarea||""}`,disabled:!1,maxLength:Bt,rows:1})}),i.jsx("div",{children:m?i.jsx(we,{type:"button",onClick:b,size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",children:i.jsx(q.Square,{size:16})}):i.jsx(we,{type:"button",onClick:En,size:"icon",disabled:!M.trim()&&ne.length===0,className:`shrink-0 ${c.sendButton||""}`,title:V?"Save changes":"Send message",children:i.jsx(q.Send,{size:16})})})]}),M.length>Bt*.8&&i.jsxs("div",{className:"mt-2 text-xs text-gray-500 text-right",children:[M.length,"/",Bt]})]})]})}const wn=l.forwardRef(({className:e,type:t,...n},r)=>i.jsx("input",{type:t,className:A("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));wn.displayName="Input";function es(e,[t,n]){return Math.min(n,Math.max(t,e))}function pb(e,t){return l.useReducer((n,r)=>t[n][r]??n,e)}var ts="ScrollArea",[Uc,cy]=Ke(ts),[hb,Ve]=Uc(ts),Hc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...a}=e,[c,d]=l.useState(null),[f,u]=l.useState(null),[p,m]=l.useState(null),[v,g]=l.useState(null),[h,b]=l.useState(null),[w,y]=l.useState(0),[x,C]=l.useState(0),[E,P]=l.useState(!1),[T,F]=l.useState(!1),M=ue(t,V=>d(V)),B=Wn(o);return i.jsx(hb,{scope:n,type:r,dir:B,scrollHideDelay:s,scrollArea:c,viewport:f,onViewportChange:u,content:p,onContentChange:m,scrollbarX:v,onScrollbarXChange:g,scrollbarXEnabled:E,onScrollbarXEnabledChange:P,scrollbarY:h,onScrollbarYChange:b,scrollbarYEnabled:T,onScrollbarYEnabledChange:F,onCornerWidthChange:y,onCornerHeightChange:C,children:i.jsx(oe.div,{dir:B,...a,ref:M,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":x+"px",...e.style}})})});Hc.displayName=ts;var zc="ScrollAreaViewport",Wc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,a=Ve(zc,n),c=l.useRef(null),d=ue(t,c,a.onViewportChange);return i.jsxs(i.Fragment,{children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),i.jsx(oe.div,{"data-radix-scroll-area-viewport":"",...s,ref:d,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...e.style},children:i.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Wc.displayName=zc;var dt="ScrollAreaScrollbar",ns=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ve(dt,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:a}=o,c=e.orientation==="horizontal";return l.useEffect(()=>(c?s(!0):a(!0),()=>{c?s(!1):a(!1)}),[c,s,a]),o.type==="hover"?i.jsx(gb,{...r,ref:t,forceMount:n}):o.type==="scroll"?i.jsx(mb,{...r,ref:t,forceMount:n}):o.type==="auto"?i.jsx(Vc,{...r,ref:t,forceMount:n}):o.type==="always"?i.jsx(rs,{...r,ref:t}):null});ns.displayName=dt;var gb=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ve(dt,e.__scopeScrollArea),[s,a]=l.useState(!1);return l.useEffect(()=>{const c=o.scrollArea;let d=0;if(c){const f=()=>{window.clearTimeout(d),a(!0)},u=()=>{d=window.setTimeout(()=>a(!1),o.scrollHideDelay)};return c.addEventListener("pointerenter",f),c.addEventListener("pointerleave",u),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",f),c.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),i.jsx(Le,{present:n||s,children:i.jsx(Vc,{"data-state":s?"visible":"hidden",...r,ref:t})})}),mb=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ve(dt,e.__scopeScrollArea),s=e.orientation==="horizontal",a=br(()=>d("SCROLL_END"),100),[c,d]=pb("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return l.useEffect(()=>{if(c==="idle"){const f=window.setTimeout(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(f)}},[c,o.scrollHideDelay,d]),l.useEffect(()=>{const f=o.viewport,u=s?"scrollLeft":"scrollTop";if(f){let p=f[u];const m=()=>{const v=f[u];p!==v&&(d("SCROLL"),a()),p=v};return f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[o.viewport,s,d,a]),i.jsx(Le,{present:n||c!=="hidden",children:i.jsx(rs,{"data-state":c==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:U(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:U(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),Vc=l.forwardRef((e,t)=>{const n=Ve(dt,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,a]=l.useState(!1),c=e.orientation==="horizontal",d=br(()=>{if(n.viewport){const f=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;a(c?f:u)}},10);return qt(n.viewport,d),qt(n.content,d),i.jsx(Le,{present:r||s,children:i.jsx(rs,{"data-state":s?"visible":"hidden",...o,ref:t})})}),rs=l.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Ve(dt,e.__scopeScrollArea),s=l.useRef(null),a=l.useRef(0),[c,d]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=qc(c.viewport,c.content),u={...r,sizes:c,onSizesChange:d,hasThumb:f>0&&f<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:m=>a.current=m};function p(m,v){return Sb(m,a.current,c,v)}return n==="horizontal"?i.jsx(bb,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,v=Xc(m,c,o.dir);s.current.style.transform=`translate3d(${v}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?i.jsx(vb,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,v=Xc(m,c);s.current.style.transform=`translate3d(0, ${v}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),bb=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Ve(dt,e.__scopeScrollArea),[a,c]=l.useState(),d=l.useRef(null),f=ue(t,d,s.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),i.jsx(Rc,{"data-orientation":"horizontal",...o,ref:f,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":mr(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+u.deltaX;e.onWheelScroll(m),Jc(m,p)&&u.preventDefault()}},onResize:()=>{d.current&&s.viewport&&a&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:gr(a.paddingLeft),paddingEnd:gr(a.paddingRight)}})}})}),vb=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Ve(dt,e.__scopeScrollArea),[a,c]=l.useState(),d=l.useRef(null),f=ue(t,d,s.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),i.jsx(Rc,{"data-orientation":"vertical",...o,ref:f,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":mr(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,p)=>{if(s.viewport){const m=s.viewport.scrollTop+u.deltaY;e.onWheelScroll(m),Jc(m,p)&&u.preventDefault()}},onResize:()=>{d.current&&s.viewport&&a&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:gr(a.paddingTop),paddingEnd:gr(a.paddingBottom)}})}})}),[wb,jc]=Uc(dt),Rc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:a,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:f,onWheelScroll:u,onResize:p,...m}=e,v=Ve(dt,n),[g,h]=l.useState(null),b=ue(t,M=>h(M)),w=l.useRef(null),y=l.useRef(""),x=v.viewport,C=r.content-r.viewport,E=Ae(u),P=Ae(d),T=br(p,10);function F(M){if(w.current){const B=M.clientX-w.current.left,V=M.clientY-w.current.top;f({x:B,y:V})}}return l.useEffect(()=>{const M=B=>{const V=B.target;(g==null?void 0:g.contains(V))&&E(B,C)};return document.addEventListener("wheel",M,{passive:!1}),()=>document.removeEventListener("wheel",M,{passive:!1})},[x,g,C,E]),l.useEffect(P,[r,P]),qt(g,T),qt(v.content,T),i.jsx(wb,{scope:n,scrollbar:g,hasThumb:o,onThumbChange:Ae(s),onThumbPointerUp:Ae(a),onThumbPositionChange:P,onThumbPointerDown:Ae(c),children:i.jsx(oe.div,{...m,ref:b,style:{position:"absolute",...m.style},onPointerDown:U(e.onPointerDown,M=>{M.button===0&&(M.target.setPointerCapture(M.pointerId),w.current=g.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",v.viewport&&(v.viewport.style.scrollBehavior="auto"),F(M))}),onPointerMove:U(e.onPointerMove,F),onPointerUp:U(e.onPointerUp,M=>{const B=M.target;B.hasPointerCapture(M.pointerId)&&B.releasePointerCapture(M.pointerId),document.body.style.webkitUserSelect=y.current,v.viewport&&(v.viewport.style.scrollBehavior=""),w.current=null})})})}),hr="ScrollAreaThumb",Kc=l.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=jc(hr,e.__scopeScrollArea);return i.jsx(Le,{present:n||o.hasThumb,children:i.jsx(yb,{ref:t,...r})})}),yb=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Ve(hr,n),a=jc(hr,n),{onThumbPositionChange:c}=a,d=ue(t,p=>a.onThumbChange(p)),f=l.useRef(void 0),u=br(()=>{f.current&&(f.current(),f.current=void 0)},100);return l.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(u(),!f.current){const v=Cb(p,c);f.current=v,c()}};return c(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,u,c]),i.jsx(oe.div,{"data-state":a.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:U(e.onPointerDownCapture,p=>{const v=p.target.getBoundingClientRect(),g=p.clientX-v.left,h=p.clientY-v.top;a.onThumbPointerDown({x:g,y:h})}),onPointerUp:U(e.onPointerUp,a.onThumbPointerUp)})});Kc.displayName=hr;var os="ScrollAreaCorner",Gc=l.forwardRef((e,t)=>{const n=Ve(os,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?i.jsx(xb,{...e,ref:t}):null});Gc.displayName=os;var xb=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Ve(os,n),[s,a]=l.useState(0),[c,d]=l.useState(0),f=!!(s&&c);return qt(o.scrollbarX,()=>{var p;const u=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(u),d(u)}),qt(o.scrollbarY,()=>{var p;const u=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(u),a(u)}),f?i.jsx(oe.div,{...r,ref:t,style:{width:s,height:c,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function gr(e){return e?parseInt(e,10):0}function qc(e,t){const n=e/t;return isNaN(n)?0:n}function mr(e){const t=qc(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Sb(e,t,n,r="ltr"){const o=mr(n),s=o/2,a=t||s,c=o-a,d=n.scrollbar.paddingStart+a,f=n.scrollbar.size-n.scrollbar.paddingEnd-c,u=n.content-n.viewport,p=r==="ltr"?[0,u]:[u*-1,0];return Yc([d,f],p)(e)}function Xc(e,t,n="ltr"){const r=mr(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,a=t.content-t.viewport,c=s-r,d=n==="ltr"?[0,a]:[a*-1,0],f=es(e,d);return Yc([0,a],[0,c])(f)}function Yc(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Jc(e,t){return e>0&&e<t}var Cb=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},a=n.left!==s.left,c=n.top!==s.top;(a||c)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function br(e,t){const n=Ae(e),r=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(r.current),[]),l.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function qt(e,t){const n=Ae(t);Ne(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var Zc=Hc,Eb=Wc,Nb=Gc;const Qc=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(Zc,{ref:r,className:A("relative overflow-hidden",e),...n,children:[i.jsx(Eb,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),i.jsx(el,{}),i.jsx(Nb,{})]}));Qc.displayName=Zc.displayName;const el=l.forwardRef(({className:e,orientation:t="vertical",...n},r)=>i.jsx(ns,{ref:r,orientation:t,className:A("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:i.jsx(Kc,{className:"relative flex-1 rounded-full bg-border"})}));el.displayName=ns.displayName;function vr({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:a=null,navigateToThread:c,onThreadSelect:d,onThreadCreate:f,onThreadDelete:u}){const{loadThread:p,threads:m,refreshThreads:v,currentThreadId:g,createThread:h,deleteThread:b,renameThread:w}=co(),[y,x]=N.useState(m??[]),[C,E]=N.useState(!1),[P,T]=N.useState(null),[F,M]=N.useState(null),[B,V]=N.useState(""),[J,H]=N.useState(!1);N.useEffect(()=>{x(m??[])},[m]);const O=async D=>{try{await p(D),c==null||c(D),d==null||d(D)}catch(W){console.error("Failed to select thread:",W)}},ne=async()=>{try{H(!0);const D=await h();f==null||f(D),c==null||c(D)}catch(D){console.error("Failed to create thread:",D)}finally{H(!1)}},L=async(D,W)=>{if(W.stopPropagation(),!!confirm("Delete this thread?"))try{await b(D),u==null||u(D)}catch(xe){console.error("Failed to delete thread:",xe)}},z=(D,W)=>{W.stopPropagation(),M(D.threadId),V(D.title||`Thread ${D.threadId.slice(0,8)}`)},k=async D=>{if(B.trim())try{await w(D,B.trim()),M(null),V("")}catch(W){console.error("Failed to update title:",W)}},I=()=>{M(null),V("")},Z=(D,W)=>{D.key==="Enter"?k(W):D.key==="Escape"&&I()},j=D=>{if(!D)return"";try{const W=new Date(D),ie=new Date().getTime()-W.getTime(),R=Math.floor(ie/(1e3*60*60*24));return R===0?W.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):R===1?"Yesterday":R<7?`${R} days ago`:W.toLocaleDateString()}catch{return""}},te=D=>D.title||`Thread ${D.threadId.slice(0,8)}`;return i.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&i.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:i.jsx(we,{onClick:ne,disabled:J||C,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:J?"Creating...":"New Chat",children:i.jsx(q.MessageSquarePlus,{size:20})})}),i.jsx(Qc,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:i.jsx("div",{className:"p-2 space-y-1 pb-4",children:C?i.jsx("div",{className:"text-center py-8 text-slate-400",children:"Loading…"}):y.length===0?i.jsxs("div",{className:"text-center py-8 text-slate-400",children:[i.jsx(q.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),i.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):y.slice().sort((D,W)=>new Date(W.updatedAt||W.createdAt||"").getTime()-new Date(D.updatedAt||D.createdAt||"").getTime()).map(D=>i.jsxs("div",{onClick:()=>O(D.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(a??g)===D.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{className:"flex-1 min-w-0",children:F===D.threadId?i.jsxs("div",{className:"flex items-center gap-2",onClick:W=>W.stopPropagation(),children:[i.jsx(wn,{value:B,onChange:W=>V(W.target.value),onKeyDown:W=>Z(W,D.threadId),className:"h-6 text-sm",autoFocus:!0}),i.jsx(we,{variant:"ghost",size:"sm",onClick:()=>k(D.threadId),className:"h-6 w-6 p-0",children:i.jsx(q.Check,{size:12})}),i.jsx(we,{variant:"ghost",size:"sm",onClick:I,className:"h-6 w-6 p-0",children:i.jsx(q.X,{size:12})})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:te(D)}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[i.jsx(q.Calendar,{size:10}),i.jsx("span",{children:j(D.updatedAt||D.createdAt)})]})]})}),i.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&F!==D.threadId&&i.jsx(we,{variant:"ghost",size:"sm",onClick:W=>z(D,W),className:"h-6 w-6 p-0",title:"Edit title",children:i.jsx(q.Edit3,{size:12})}),n&&i.jsx(we,{variant:"ghost",size:"sm",onClick:W=>L(D.threadId,W),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:i.jsx(q.Trash2,{size:12})})]})]}),a===D.threadId&&i.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},D.threadId))})})]})}const tl=N.createContext(null);function Tb({children:e,basePath:t="/chat"}){const n=N.useMemo(()=>t?t==="/"?"":t.endsWith("/")?t.slice(0,-1):t:"/chat",[t]),r={basePath:n,buildThreadPath:o=>`${n}/${o}`,buildBasePath:()=>n};return i.jsx(tl.Provider,{value:r,children:e})}function Ab(){const e=N.useContext(tl);return e||{basePath:"/chat",buildThreadPath:t=>`/chat/${t}`,buildBasePath:()=>"/chat"}}const nl={BASE_URL:"/",DEV:!1,MODE:"library",PROD:!0,SSR:!1};function yn(e){var o;const t=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Vr&&Vr.tagName.toUpperCase()==="SCRIPT"&&Vr.src||new URL("index.umd.js",document.baseURI).href}<"u"&&nl?nl[e]:void 0,n=(o=globalThis==null?void 0:globalThis.process)==null?void 0:o.env,r=n?n[e]:void 0;return(t??r)||void 0}function Ib(){return yn("VITE_API_BASE_URL")||yn("NEXT_PUBLIC_API_BASE_URL")||void 0}function kb(){return yn("VITE_API_KEY")||yn("NEXT_PUBLIC_API_KEY")||yn("VITE_AUTH_TOKEN")||void 0}function rl(){const e=Ib(),t=kb(),n={};return e&&(n.baseUrl=e),t&&(n.apiKey=t),n}function ol(){const e=rl(),t=ut.getAuthToken();return{apiBaseUrl:e.baseUrl||ut.baseUrl||"http://localhost:8000",apiKey:t||e.apiKey||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const sl="chat-settings";function _b(){try{const e=localStorage.getItem(sl);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Pb(e){try{localStorage.setItem(sl,JSON.stringify(e)),e.apiKey&&ut.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Ob(){const e=ol(),t=_b(),n=ut.getAuthToken();return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:ut.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function Mb(e){e.apiKey&&ut.setAuthToken(e.apiKey),Pb(e)}const ss=768;function Db(){const[e,t]=l.useState(void 0);return l.useEffect(()=>{const n=window.matchMedia(`(max-width: ${ss-1}px)`),r=()=>{t(window.innerWidth<ss)};return n.addEventListener("change",r),t(window.innerWidth<ss),()=>n.removeEventListener("change",r)},[]),!!e}var Lb="Separator",al="horizontal",Fb=["horizontal","vertical"],il=l.forwardRef((e,t)=>{const{decorative:n,orientation:r=al,...o}=e,s=$b(r)?r:al,c=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return i.jsx(oe.div,{"data-orientation":s,...c,...o,ref:t})});il.displayName=Lb;function $b(e){return Fb.includes(e)}var cl=il;const as=l.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>i.jsx(cl,{ref:o,decorative:n,orientation:t,className:A("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));as.displayName=cl.displayName;var wr="Dialog",[ll,ly]=Ke(wr),[Bb,Ye]=ll(wr),dl=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:a=!0}=e,c=l.useRef(null),d=l.useRef(null),[f,u]=mt({prop:r,defaultProp:o??!1,onChange:s,caller:wr});return i.jsx(Bb,{scope:t,triggerRef:c,contentRef:d,contentId:Ge(),titleId:Ge(),descriptionId:Ge(),open:f,onOpenChange:u,onOpenToggle:l.useCallback(()=>u(p=>!p),[u]),modal:a,children:n})};dl.displayName=wr;var ul="DialogTrigger",fl=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ye(ul,n),s=ue(t,o.triggerRef);return i.jsx(oe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":ls(o.open),...r,ref:s,onClick:U(e.onClick,o.onOpenToggle)})});fl.displayName=ul;var is="DialogPortal",[Ub,pl]=ll(is,{forceMount:void 0}),hl=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Ye(is,t);return i.jsx(Ub,{scope:t,forceMount:n,children:l.Children.map(r,a=>i.jsx(Le,{present:n||s.open,children:i.jsx(er,{asChild:!0,container:o,children:a})}))})};hl.displayName=is;var yr="DialogOverlay",gl=l.forwardRef((e,t)=>{const n=pl(yr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Ye(yr,e.__scopeDialog);return s.modal?i.jsx(Le,{present:r||s.open,children:i.jsx(zb,{...o,ref:t})}):null});gl.displayName=yr;var Hb=Be.createSlot("DialogOverlay.RemoveScroll"),zb=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ye(yr,n);return i.jsx(cr,{as:Hb,allowPinchZoom:!0,shards:[o.contentRef],children:i.jsx(oe.div,{"data-state":ls(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),_t="DialogContent",ml=l.forwardRef((e,t)=>{const n=pl(_t,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Ye(_t,e.__scopeDialog);return i.jsx(Le,{present:r||s.open,children:s.modal?i.jsx(Wb,{...o,ref:t}):i.jsx(Vb,{...o,ref:t})})});ml.displayName=_t;var Wb=l.forwardRef((e,t)=>{const n=Ye(_t,e.__scopeDialog),r=l.useRef(null),o=ue(t,n.contentRef,r);return l.useEffect(()=>{const s=r.current;if(s)return zo(s)},[]),i.jsx(bl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:U(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:U(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0;(a.button===2||c)&&s.preventDefault()}),onFocusOutside:U(e.onFocusOutside,s=>s.preventDefault())})}),Vb=l.forwardRef((e,t)=>{const n=Ye(_t,e.__scopeDialog),r=l.useRef(!1),o=l.useRef(!1);return i.jsx(bl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,c;(a=e.onCloseAutoFocus)==null||a.call(e,s),s.defaultPrevented||(r.current||(c=n.triggerRef.current)==null||c.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var d,f;(d=e.onInteractOutside)==null||d.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=s.target;((f=n.triggerRef.current)==null?void 0:f.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),bl=l.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...a}=e,c=Ye(_t,n),d=l.useRef(null),f=ue(t,d);return vo(),i.jsxs(i.Fragment,{children:[i.jsx(Vn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:i.jsx(cn,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":ls(c.open),...a,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(jb,{titleId:c.titleId}),i.jsx(Kb,{contentRef:d,descriptionId:c.descriptionId})]})]})}),cs="DialogTitle",vl=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ye(cs,n);return i.jsx(oe.h2,{id:o.titleId,...r,ref:t})});vl.displayName=cs;var wl="DialogDescription",yl=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ye(wl,n);return i.jsx(oe.p,{id:o.descriptionId,...r,ref:t})});yl.displayName=wl;var xl="DialogClose",Sl=l.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Ye(xl,n);return i.jsx(oe.button,{type:"button",...r,ref:t,onClick:U(e.onClick,()=>o.onOpenChange(!1))})});Sl.displayName=xl;function ls(e){return e?"open":"closed"}var Cl="DialogTitleWarning",[dy,El]=Uf(Cl,{contentName:_t,titleName:cs,docsSlug:"dialog"}),jb=({titleId:e})=>{const t=El(Cl),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
58
+ `)},yg=0,It=[];function xg(e){var t=l.useRef([]),r=l.useRef([0,0]),n=l.useRef(),o=l.useState(yg++)[0],s=l.useState(ci)[0],a=l.useRef(e);l.useEffect(function(){a.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=Wh([e.lockRef.current],(e.shards||[]).map(gi),!0).filter(Boolean);return h.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),h.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(h,b){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!a.current.allowPinchZoom;var w=zr(h),y=r.current,x="deltaX"in h?h.deltaX:y[0]-w[0],C="deltaY"in h?h.deltaY:y[1]-w[1],E,O=h.target,N=Math.abs(x)>Math.abs(C)?"h":"v";if("touches"in h&&N==="h"&&O.type==="range")return!1;var F=ui(N,O);if(!F)return!0;if(F?E=N:(E=N==="v"?"h":"v",F=ui(N,O)),!F)return!1;if(!n.current&&"changedTouches"in h&&(x||C)&&(n.current=E),!E)return!0;var B=n.current||E;return bg(B,b,h,B==="h"?x:C)},[]),d=l.useCallback(function(h){var b=h;if(!(!It.length||It[It.length-1]!==s)){var w="deltaY"in b?hi(b):zr(b),y=t.current.filter(function(E){return E.name===b.type&&(E.target===b.target||b.target===E.shadowParent)&&vg(E.delta,w)})[0];if(y&&y.should){b.cancelable&&b.preventDefault();return}if(!y){var x=(a.current.shards||[]).map(gi).filter(Boolean).filter(function(E){return E.contains(b.target)}),C=x.length>0?c(b,x[0]):!a.current.noIsolation;C&&b.cancelable&&b.preventDefault()}}},[]),f=l.useCallback(function(h,b,w,y){var x={name:h,delta:b,target:w,should:y,shadowParent:Sg(w)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(C){return C!==x})},1)},[]),u=l.useCallback(function(h){r.current=zr(h),n.current=void 0},[]),p=l.useCallback(function(h){f(h.type,hi(h),h.target,c(h,e.lockRef.current))},[]),m=l.useCallback(function(h){f(h.type,zr(h),h.target,c(h,e.lockRef.current))},[]);l.useEffect(function(){return It.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",d,_t),document.addEventListener("touchmove",d,_t),document.addEventListener("touchstart",u,_t),function(){It=It.filter(function(h){return h!==s}),document.removeEventListener("wheel",d,_t),document.removeEventListener("touchmove",d,_t),document.removeEventListener("touchstart",u,_t)}},[]);var v=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(s,{styles:wg(o)}):null,v?l.createElement(dg,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Sg(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Cg=Jh(ii,xg);var Wr=l.forwardRef(function(e,t){return l.createElement(Ur,Ve({},e,{ref:t,sideCar:Cg}))});Wr.classNames=Ur.classNames;var xo=["Enter"," "],Eg=["ArrowDown","PageUp","Home"],mi=["ArrowUp","PageDown","End"],Ng=[...Eg,...mi],Tg={ltr:[...xo,"ArrowRight"],rtl:[...xo,"ArrowLeft"]},Ag={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Xt="Menu",[Yt,Pg,_g]=Rn(Xt),[dt,bi]=Oe(Xt,[_g,Tt,Za]),Rr=Tt(),vi=Za(),[Ig,ut]=dt(Xt),[Og,Jt]=dt(Xt),wi=e=>{const{__scopeMenu:t,open:r=!1,children:n,dir:o,onOpenChange:s,modal:a=!0}=e,c=Rr(t),[d,f]=l.useState(null),u=l.useRef(!1),p=ge(s),m=Sr(o);return l.useEffect(()=>{const v=()=>{u.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>u.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),i.jsx(co,{...c,children:i.jsx(Ig,{scope:t,open:r,onOpenChange:p,content:d,onContentChange:f,children:i.jsx(Og,{scope:t,onClose:l.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:u,dir:m,modal:a,children:n})})})};wi.displayName=Xt;var Mg="MenuAnchor",So=l.forwardRef((e,t)=>{const{__scopeMenu:r,...n}=e,o=Rr(r);return i.jsx(lo,{...o,...n,ref:t})});So.displayName=Mg;var Co="MenuPortal",[kg,yi]=dt(Co,{forceMount:void 0}),xi=e=>{const{__scopeMenu:t,forceMount:r,children:n,container:o}=e,s=ut(Co,t);return i.jsx(kg,{scope:t,forceMount:r,children:i.jsx(xe,{present:r||s.open,children:i.jsx(Dr,{asChild:!0,container:o,children:n})})})};xi.displayName=Co;var Ne="MenuContent",[Dg,Eo]=dt(Ne),Si=l.forwardRef((e,t)=>{const r=yi(Ne,e.__scopeMenu),{forceMount:n=r.forceMount,...o}=e,s=ut(Ne,e.__scopeMenu),a=Jt(Ne,e.__scopeMenu);return i.jsx(Yt.Provider,{scope:e.__scopeMenu,children:i.jsx(xe,{present:n||s.open,children:i.jsx(Yt.Slot,{scope:e.__scopeMenu,children:a.modal?i.jsx(Lg,{...o,ref:t}):i.jsx(Fg,{...o,ref:t})})})})}),Lg=l.forwardRef((e,t)=>{const r=ut(Ne,e.__scopeMenu),n=l.useRef(null),o=se(t,n);return l.useEffect(()=>{const s=n.current;if(s)return mo(s)},[]),i.jsx(No,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:z(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),Fg=l.forwardRef((e,t)=>{const r=ut(Ne,e.__scopeMenu);return i.jsx(No,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),$g=Se.createSlot("MenuContent.ScrollLock"),No=l.forwardRef((e,t)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:m,onDismiss:v,disableOutsideScroll:g,...h}=e,b=ut(Ne,r),w=Jt(Ne,r),y=Rr(r),x=vi(r),C=Pg(r),[E,O]=l.useState(null),N=l.useRef(null),F=se(t,N,b.onContentChange),B=l.useRef(0),_=l.useRef(""),U=l.useRef(0),G=l.useRef(null),L=l.useRef("right"),$=l.useRef(0),q=g?Wr:l.Fragment,k=g?{as:$g,allowPinchZoom:!0}:void 0,V=I=>{var j,K;const J=_.current+I,Q=C().filter(oe=>!oe.disabled),re=document.activeElement,H=(j=Q.find(oe=>oe.ref.current===re))==null?void 0:j.textValue,R=Q.map(oe=>oe.textValue),ue=Xg(R,J,H),de=(K=Q.find(oe=>oe.textValue===ue))==null?void 0:K.ref.current;(function oe(P){_.current=P,window.clearTimeout(B.current),P!==""&&(B.current=window.setTimeout(()=>oe(""),1e3))})(J),de&&setTimeout(()=>de.focus())};l.useEffect(()=>()=>window.clearTimeout(B.current),[]),Kn();const D=l.useCallback(I=>{var Q,re;return L.current===((Q=G.current)==null?void 0:Q.side)&&Jg(I,(re=G.current)==null?void 0:re.area)},[]);return i.jsx(Dg,{scope:r,searchRef:_,onItemEnter:l.useCallback(I=>{D(I)&&I.preventDefault()},[D]),onItemLeave:l.useCallback(I=>{var J;D(I)||((J=N.current)==null||J.focus(),O(null))},[D]),onTriggerLeave:l.useCallback(I=>{D(I)&&I.preventDefault()},[D]),pointerGraceTimerRef:U,onPointerGraceIntentChange:l.useCallback(I=>{G.current=I},[]),children:i.jsx(q,{...k,children:i.jsx(Cr,{asChild:!0,trapped:o,onMountAutoFocus:z(s,I=>{var J;I.preventDefault(),(J=N.current)==null||J.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:i.jsx(Vt,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:u,onFocusOutside:p,onInteractOutside:m,onDismiss:v,children:i.jsx($h,{asChild:!0,...x,dir:w.dir,orientation:"vertical",loop:n,currentTabStopId:E,onCurrentTabStopIdChange:O,onEntryFocus:z(d,I=>{w.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:i.jsx(uo,{role:"menu","aria-orientation":"vertical","data-state":Ui(b.open),"data-radix-menu-content":"",dir:w.dir,...y,...h,ref:F,style:{outline:"none",...h.style},onKeyDown:z(h.onKeyDown,I=>{const Q=I.target.closest("[data-radix-menu-content]")===I.currentTarget,re=I.ctrlKey||I.altKey||I.metaKey,H=I.key.length===1;Q&&(I.key==="Tab"&&I.preventDefault(),!re&&H&&V(I.key));const R=N.current;if(I.target!==R||!Ng.includes(I.key))return;I.preventDefault();const de=C().filter(j=>!j.disabled).map(j=>j.ref.current);mi.includes(I.key)&&de.reverse(),Gg(de)}),onBlur:z(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(B.current),_.current="")}),onPointerMove:z(e.onPointerMove,Qt(I=>{const J=I.target,Q=$.current!==I.clientX;if(I.currentTarget.contains(J)&&Q){const re=I.clientX>$.current?"right":"left";L.current=re,$.current=I.clientX}}))})})})})})})});Si.displayName=Ne;var Bg="MenuGroup",To=l.forwardRef((e,t)=>{const{__scopeMenu:r,...n}=e;return i.jsx(Z.div,{role:"group",...n,ref:t})});To.displayName=Bg;var Ug="MenuLabel",Ci=l.forwardRef((e,t)=>{const{__scopeMenu:r,...n}=e;return i.jsx(Z.div,{...n,ref:t})});Ci.displayName=Ug;var Vr="MenuItem",Ei="menu.itemSelect",jr=l.forwardRef((e,t)=>{const{disabled:r=!1,onSelect:n,...o}=e,s=l.useRef(null),a=Jt(Vr,e.__scopeMenu),c=Eo(Vr,e.__scopeMenu),d=se(t,s),f=l.useRef(!1),u=()=>{const p=s.current;if(!r&&p){const m=new CustomEvent(Ei,{bubbles:!0,cancelable:!0});p.addEventListener(Ei,v=>n==null?void 0:n(v),{once:!0}),Qs(p,m),m.defaultPrevented?f.current=!1:a.onClose()}};return i.jsx(Ni,{...o,ref:d,disabled:r,onClick:z(e.onClick,u),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),f.current=!0},onPointerUp:z(e.onPointerUp,p=>{var m;f.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:z(e.onKeyDown,p=>{const m=c.searchRef.current!=="";r||m&&p.key===" "||xo.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});jr.displayName=Vr;var Ni=l.forwardRef((e,t)=>{const{__scopeMenu:r,disabled:n=!1,textValue:o,...s}=e,a=Eo(Vr,r),c=vi(r),d=l.useRef(null),f=se(t,d),[u,p]=l.useState(!1),[m,v]=l.useState("");return l.useEffect(()=>{const g=d.current;g&&v((g.textContent??"").trim())},[s.children]),i.jsx(Yt.ItemSlot,{scope:r,disabled:n,textValue:o??m,children:i.jsx(Bh,{asChild:!0,...c,focusable:!n,children:i.jsx(Z.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...s,ref:f,onPointerMove:z(e.onPointerMove,Qt(g=>{n?a.onItemLeave(g):(a.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:z(e.onPointerLeave,Qt(g=>a.onItemLeave(g))),onFocus:z(e.onFocus,()=>p(!0)),onBlur:z(e.onBlur,()=>p(!1))})})})}),Hg="MenuCheckboxItem",Ti=l.forwardRef((e,t)=>{const{checked:r=!1,onCheckedChange:n,...o}=e;return i.jsx(Oi,{scope:e.__scopeMenu,checked:r,children:i.jsx(jr,{role:"menuitemcheckbox","aria-checked":Kr(r)?"mixed":r,...o,ref:t,"data-state":Po(r),onSelect:z(o.onSelect,()=>n==null?void 0:n(Kr(r)?!0:!r),{checkForDefaultPrevented:!1})})})});Ti.displayName=Hg;var Ai="MenuRadioGroup",[zg,Wg]=dt(Ai,{value:void 0,onValueChange:()=>{}}),Pi=l.forwardRef((e,t)=>{const{value:r,onValueChange:n,...o}=e,s=ge(n);return i.jsx(zg,{scope:e.__scopeMenu,value:r,onValueChange:s,children:i.jsx(To,{...o,ref:t})})});Pi.displayName=Ai;var _i="MenuRadioItem",Ii=l.forwardRef((e,t)=>{const{value:r,...n}=e,o=Wg(_i,e.__scopeMenu),s=r===o.value;return i.jsx(Oi,{scope:e.__scopeMenu,checked:s,children:i.jsx(jr,{role:"menuitemradio","aria-checked":s,...n,ref:t,"data-state":Po(s),onSelect:z(n.onSelect,()=>{var a;return(a=o.onValueChange)==null?void 0:a.call(o,r)},{checkForDefaultPrevented:!1})})})});Ii.displayName=_i;var Ao="MenuItemIndicator",[Oi,Rg]=dt(Ao,{checked:!1}),Mi=l.forwardRef((e,t)=>{const{__scopeMenu:r,forceMount:n,...o}=e,s=Rg(Ao,r);return i.jsx(xe,{present:n||Kr(s.checked)||s.checked===!0,children:i.jsx(Z.span,{...o,ref:t,"data-state":Po(s.checked)})})});Mi.displayName=Ao;var Vg="MenuSeparator",ki=l.forwardRef((e,t)=>{const{__scopeMenu:r,...n}=e;return i.jsx(Z.div,{role:"separator","aria-orientation":"horizontal",...n,ref:t})});ki.displayName=Vg;var jg="MenuArrow",Di=l.forwardRef((e,t)=>{const{__scopeMenu:r,...n}=e,o=Rr(r);return i.jsx(fo,{...o,...n,ref:t})});Di.displayName=jg;var Kg="MenuSub",[$w,Li]=dt(Kg),Zt="MenuSubTrigger",Fi=l.forwardRef((e,t)=>{const r=ut(Zt,e.__scopeMenu),n=Jt(Zt,e.__scopeMenu),o=Li(Zt,e.__scopeMenu),s=Eo(Zt,e.__scopeMenu),a=l.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=s,f={__scopeMenu:e.__scopeMenu},u=l.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return l.useEffect(()=>u,[u]),l.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),d(null)}},[c,d]),i.jsx(So,{asChild:!0,...f,children:i.jsx(Ni,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":o.contentId,"data-state":Ui(r.open),...e,ref:Bn(t,o.onTriggerChange),onClick:p=>{var m;(m=e.onClick)==null||m.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:z(e.onPointerMove,Qt(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!r.open&&!a.current&&(s.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{r.onOpenChange(!0),u()},100))})),onPointerLeave:z(e.onPointerLeave,Qt(p=>{var v,g;u();const m=(v=r.content)==null?void 0:v.getBoundingClientRect();if(m){const h=(g=r.content)==null?void 0:g.dataset.side,b=h==="right",w=b?-5:5,y=m[b?"left":"right"],x=m[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+w,y:p.clientY},{x:y,y:m.top},{x,y:m.top},{x,y:m.bottom},{x:y,y:m.bottom}],side:h}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:z(e.onKeyDown,p=>{var v;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||Tg[n.dir].includes(p.key)&&(r.onOpenChange(!0),(v=r.content)==null||v.focus(),p.preventDefault())})})})});Fi.displayName=Zt;var $i="MenuSubContent",Bi=l.forwardRef((e,t)=>{const r=yi(Ne,e.__scopeMenu),{forceMount:n=r.forceMount,...o}=e,s=ut(Ne,e.__scopeMenu),a=Jt(Ne,e.__scopeMenu),c=Li($i,e.__scopeMenu),d=l.useRef(null),f=se(t,d);return i.jsx(Yt.Provider,{scope:e.__scopeMenu,children:i.jsx(xe,{present:n||s.open,children:i.jsx(Yt.Slot,{scope:e.__scopeMenu,children:i.jsx(No,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:f,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var p;a.isUsingKeyboardRef.current&&((p=d.current)==null||p.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:z(e.onFocusOutside,u=>{u.target!==c.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:z(e.onEscapeKeyDown,u=>{a.onClose(),u.preventDefault()}),onKeyDown:z(e.onKeyDown,u=>{var v;const p=u.currentTarget.contains(u.target),m=Ag[a.dir].includes(u.key);p&&m&&(s.onOpenChange(!1),(v=c.trigger)==null||v.focus(),u.preventDefault())})})})})})});Bi.displayName=$i;function Ui(e){return e?"open":"closed"}function Kr(e){return e==="indeterminate"}function Po(e){return Kr(e)?"indeterminate":e?"checked":"unchecked"}function Gg(e){const t=document.activeElement;for(const r of e)if(r===t||(r.focus(),document.activeElement!==t))return}function qg(e,t){return e.map((r,n)=>e[(t+n)%e.length])}function Xg(e,t,r){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=r?e.indexOf(r):-1;let a=qg(e,Math.max(s,0));o.length===1&&(a=a.filter(f=>f!==r));const d=a.find(f=>f.toLowerCase().startsWith(o.toLowerCase()));return d!==r?d:void 0}function Yg(e,t){const{x:r,y:n}=e;let o=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const c=t[s],d=t[a],f=c.x,u=c.y,p=d.x,m=d.y;u>n!=m>n&&r<(p-f)*(n-u)/(m-u)+f&&(o=!o)}return o}function Jg(e,t){if(!t)return!1;const r={x:e.clientX,y:e.clientY};return Yg(r,t)}function Qt(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Zg=wi,Qg=So,em=xi,tm=Si,rm=To,nm=Ci,om=jr,sm=Ti,am=Pi,im=Ii,cm=Mi,lm=ki,dm=Di,um=Fi,fm=Bi,Gr="DropdownMenu",[pm,Bw]=Oe(Gr,[bi]),ve=bi(),[hm,Hi]=pm(Gr),zi=e=>{const{__scopeDropdownMenu:t,children:r,dir:n,open:o,defaultOpen:s,onOpenChange:a,modal:c=!0}=e,d=ve(t),f=l.useRef(null),[u,p]=Je({prop:o,defaultProp:s??!1,onChange:a,caller:Gr});return i.jsx(hm,{scope:t,triggerId:Me(),triggerRef:f,contentId:Me(),open:u,onOpenChange:p,onOpenToggle:l.useCallback(()=>p(m=>!m),[p]),modal:c,children:i.jsx(Zg,{...d,open:u,onOpenChange:p,dir:n,modal:c,children:r})})};zi.displayName=Gr;var Wi="DropdownMenuTrigger",Ri=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...o}=e,s=Hi(Wi,r),a=ve(r);return i.jsx(Qg,{asChild:!0,...a,children:i.jsx(Z.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...o,ref:Bn(t,s.triggerRef),onPointerDown:z(e.onPointerDown,c=>{!n&&c.button===0&&c.ctrlKey===!1&&(s.onOpenToggle(),s.open||c.preventDefault())}),onKeyDown:z(e.onKeyDown,c=>{n||(["Enter"," "].includes(c.key)&&s.onOpenToggle(),c.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});Ri.displayName=Wi;var gm="DropdownMenuPortal",Vi=e=>{const{__scopeDropdownMenu:t,...r}=e,n=ve(t);return i.jsx(em,{...n,...r})};Vi.displayName=gm;var ji="DropdownMenuContent",Ki=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=Hi(ji,r),s=ve(r),a=l.useRef(!1);return i.jsx(tm,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...n,ref:t,onCloseAutoFocus:z(e.onCloseAutoFocus,c=>{var d;a.current||(d=o.triggerRef.current)==null||d.focus(),a.current=!1,c.preventDefault()}),onInteractOutside:z(e.onInteractOutside,c=>{const d=c.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0,u=d.button===2||f;(!o.modal||u)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Ki.displayName=ji;var mm="DropdownMenuGroup",bm=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=ve(r);return i.jsx(rm,{...o,...n,ref:t})});bm.displayName=mm;var vm="DropdownMenuLabel",Gi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=ve(r);return i.jsx(nm,{...o,...n,ref:t})});Gi.displayName=vm;var wm="DropdownMenuItem",qi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=ve(r);return i.jsx(om,{...o,...n,ref:t})});qi.displayName=wm;var ym="DropdownMenuCheckboxItem",Xi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=ve(r);return i.jsx(sm,{...o,...n,ref:t})});Xi.displayName=ym;var xm="DropdownMenuRadioGroup",Sm=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=ve(r);return i.jsx(am,{...o,...n,ref:t})});Sm.displayName=xm;var Cm="DropdownMenuRadioItem",Yi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=ve(r);return i.jsx(im,{...o,...n,ref:t})});Yi.displayName=Cm;var Em="DropdownMenuItemIndicator",Ji=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=ve(r);return i.jsx(cm,{...o,...n,ref:t})});Ji.displayName=Em;var Nm="DropdownMenuSeparator",Zi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=ve(r);return i.jsx(lm,{...o,...n,ref:t})});Zi.displayName=Nm;var Tm="DropdownMenuArrow",Am=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=ve(r);return i.jsx(dm,{...o,...n,ref:t})});Am.displayName=Tm;var Pm="DropdownMenuSubTrigger",Qi=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=ve(r);return i.jsx(um,{...o,...n,ref:t})});Qi.displayName=Pm;var _m="DropdownMenuSubContent",ec=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...n}=e,o=ve(r);return i.jsx(fm,{...o,...n,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ec.displayName=_m;var Im=zi,Om=Ri,Mm=Vi,tc=Ki,rc=Gi,nc=qi,oc=Xi,sc=Yi,ac=Ji,ic=Zi,cc=Qi,lc=ec;const km=Im,Dm=Om,Lm=l.forwardRef(({className:e,inset:t,children:r,...n},o)=>i.jsxs(cc,{ref:o,className:T("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...n,children:[r,i.jsx(X.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Lm.displayName=cc.displayName;const Fm=l.forwardRef(({className:e,...t},r)=>i.jsx(lc,{ref:r,className:T("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",e),...t}));Fm.displayName=lc.displayName;const dc=l.forwardRef(({className:e,sideOffset:t=4,...r},n)=>i.jsx(Mm,{children:i.jsx(tc,{ref:n,sideOffset:t,className:T("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",e),...r})}));dc.displayName=tc.displayName;const uc=l.forwardRef(({className:e,inset:t,...r},n)=>i.jsx(nc,{ref:n,className:T("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...r}));uc.displayName=nc.displayName;const $m=l.forwardRef(({className:e,children:t,checked:r,...n},o)=>i.jsxs(oc,{ref:o,className:T("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:r,...n,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(ac,{children:i.jsx(X.Check,{className:"h-4 w-4"})})}),t]}));$m.displayName=oc.displayName;const Bm=l.forwardRef(({className:e,children:t,...r},n)=>i.jsxs(sc,{ref:n,className:T("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(ac,{children:i.jsx(X.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Bm.displayName=sc.displayName;const Um=l.forwardRef(({className:e,inset:t,...r},n)=>i.jsx(rc,{ref:n,className:T("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...r}));Um.displayName=rc.displayName;const Hm=l.forwardRef(({className:e,...t},r)=>i.jsx(ic,{ref:r,className:T("-mx-1 my-1 h-px bg-muted",e),...t}));Hm.displayName=ic.displayName;function er({className:e="",placeholder:t="Type your message...",autoFocus:r=!0,maxHeight:n=void 0,streamingDebounceMs:o=40,enableFileUpload:s=!0,enableMessageEditing:a=!0,customStyles:c={},onMessageSent:d,onError:f}){const{currentThreadId:u,messages:p,isStreaming:m,streamingAssistantId:v,error:g,send:h,stop:b,lastCheckpointId:w,hasMoreHistory:y,isLoadingHistory:x,loadOlderMessages:C}=$n(),[E,O]=A.useState(""),[N,F]=A.useState(null),[B,_]=A.useState(null),[U,G]=A.useState([]),[L,$]=A.useState(!1),q=A.useRef(null),k=A.useRef(null),V=A.useRef(null),D=A.useRef(null),I=A.useRef(!1),J=A.useRef(!0),Q=A.useRef(0),[re,H]=A.useState("desktop");A.useEffect(()=>{const W=()=>{const ne=window.innerWidth;H(ne<640?"phone":ne<1024?"tablet":"desktop")};return W(),window.addEventListener("resize",W),()=>window.removeEventListener("resize",W)},[]);const R=A.useCallback(async()=>{if(!y||x)return;const W=D.current;if(!W)return;const ne=W.scrollHeight,fe=W.scrollTop;I.current=!0;try{await C()}catch(ie){console.warn("loadOlderMessages failed",ie)}finally{requestAnimationFrame(()=>{const ie=D.current;if(!ie){I.current=!1;return}const ot=ie.scrollHeight;ie.scrollTop=fe+(ot-ne);const bn=ot-ie.scrollTop-ie.clientHeight;J.current=bn<=32,I.current=!1})}},[y,x,C]);A.useEffect(()=>{const W=D.current;if(!W)return;const ne=()=>{W.scrollTop<=80&&R();const ot=W.scrollHeight-W.scrollTop-W.clientHeight;J.current=ot<=80};return W.addEventListener("scroll",ne),()=>W.removeEventListener("scroll",ne)},[R]),A.useEffect(()=>{p.length<Q.current&&(J.current=!0),Q.current=p.length},[p.length]),A.useEffect(()=>{const W=D.current;W&&(I.current||J.current&&(W.scrollTop=W.scrollHeight,J.current=!0))},[p]),A.useEffect(()=>{var W;r&&((W=k.current)==null||W.focus())},[r]),A.useEffect(()=>{g&&!L&&(f==null||f(g))},[g,L,f]);const ue=W=>{if(W.length>xt)return`Message too long (${W.length}/${xt} characters)`;try{return jf(W),null}catch(ne){return(ne==null?void 0:ne.message)||"Invalid message"}},de=W=>{const ne=W.content||[],fe=ne.filter(ie=>ie.type==="text").map(ie=>ie.text).join("");if(fe)return fe;try{return JSON.stringify(ne,null,2)}catch{return String(ne)}},j=async()=>{const W=E.trim();if(!W&&U.length===0)return;const ne=ue(W);if(ne){_(ne);return}try{await h(W,{checkpointId:w||void 0,payloadExtras:N?{edit:!0,originalMessageId:N}:void 0,attachments:U}),d==null||d(W),O(""),_(null),G([]),F(null),k.current&&(k.current.style.height="auto")}catch(fe){const ie=(fe==null?void 0:fe.message)||"Failed to send message";_(ie),f==null||f(ie)}},K=(W,ne)=>{a&&(F(W),O(ne),_(null),setTimeout(()=>{k.current&&(k.current.focus(),k.current.style.height="auto",k.current.style.height=k.current.scrollHeight+"px")},0))},oe=()=>{F(null),O(""),_(null),k.current&&(k.current.style.height="auto")},P=W=>{W.key==="Enter"&&!W.shiftKey?(W.preventDefault(),j()):W.key==="Escape"&&N&&(W.preventDefault(),oe())},M=W=>{const ne=Array.from(W.target.files||[]);G(fe=>[...fe,...ne])},Y=W=>G(ne=>ne.filter((fe,ie)=>W!==ie)),le=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${c.container||""}`,me=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-y-auto overflow-x-auto overscroll-contain break-words break-anywhere p-4 space-y-4 bg-transparent ${c.messagesArea||""}`,Ke=`flex-shrink-0 w-full border-t p-4 bg-transparent ${c.inputArea||""}`;return i.jsxs("div",{className:le,children:[!!g&&!L&&i.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[i.jsx("span",{children:g}),i.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>$(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:i.jsx(X.X,{size:16})})]}),i.jsxs("div",{ref:D,className:me,style:n?{maxHeight:n}:void 0,children:[p.length===0?i.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:"No messages yet. Start a conversation!"}):i.jsxs(i.Fragment,{children:[(x||!y)&&i.jsx("div",{className:"flex justify-center py-2 text-xs text-muted-foreground",children:x?i.jsx(X.Loader2,{className:"h-4 w-4 animate-spin"}):"You've reached the beginning"}),p.map((W,ne)=>i.jsx(sa,{message:W,messageIndex:ne,isStreamingMessage:m&&v===W.id,streamingDebounceMs:o,isEditing:N===W.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:re,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:(fe,ie)=>K(fe,ie),onRegenerate:()=>{const fe=[...p].reverse().find(ot=>ot.role==="user"),ie=fe?de(fe):"";ie&&h(ie,{checkpointId:w??void 0})},onCancelEdit:oe},W.id||ne))]}),i.jsx("div",{ref:q})]}),i.jsxs("div",{className:Ke,children:[N&&i.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(X.Edit3,{size:16,className:"text-blue-600"}),i.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),i.jsx(ce,{variant:"ghost",size:"sm",onClick:oe,className:"text-blue-600 hover:bg-blue-100",children:i.jsx(X.X,{size:16})})]})}),s&&i.jsxs("div",{className:"mb-3",children:[i.jsx("input",{ref:V,type:"file",multiple:!0,onChange:W=>M(W),className:"hidden"}),U.length>0&&i.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:U.map((W,ne)=>i.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 rounded-lg px-3 py-2 text-sm",children:[i.jsx(X.Paperclip,{size:14}),i.jsx("span",{className:"truncate max-w-[150px]",children:W.name}),i.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>Y(ne),className:"h-4 w-4 p-0 text-gray-500 hover:text-red-500","aria-label":`Remove ${W.name}`,children:i.jsx(X.X,{size:12})})]},ne))})]}),B&&i.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:B}),i.jsxs("div",{className:"flex items-end gap-2",children:[s&&i.jsxs(km,{children:[i.jsx(Dm,{asChild:!0,children:i.jsx(ce,{type:"button",size:"icon",variant:"outline",disabled:m,title:"More input actions",className:c.moreButton||"",children:i.jsx(X.Plus,{size:16})})}),i.jsx(dc,{align:"start",sideOffset:6,className:"w-52",children:i.jsxs(uc,{onClick:()=>{var W;return(W=V.current)==null?void 0:W.click()},className:"cursor-pointer",children:[i.jsx(X.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]})})]}),i.jsx("div",{className:"flex-1",children:i.jsx(Ys,{ref:k,value:E,onChange:W=>{O(W.target.value),_(null),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`)},onKeyDown:P,placeholder:N?"Edit your message...":t,className:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${N?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${B?"border-red-400":""} ${c.textarea||""}`,disabled:!1,maxLength:xt,rows:1})}),i.jsx("div",{children:m?i.jsx(ce,{type:"button",onClick:b,size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",children:i.jsx(X.Square,{size:16})}):i.jsx(ce,{type:"button",onClick:j,size:"icon",disabled:!E.trim()&&U.length===0,className:`shrink-0 ${c.sendButton||""}`,title:N?"Save changes":"Send message",children:i.jsx(X.Send,{size:16})})})]}),E.length>xt*.8&&i.jsxs("div",{className:"mt-2 text-xs text-gray-500 text-right",children:[E.length,"/",xt]})]})]})}const tr=l.forwardRef(({className:e,type:t,...r},n)=>i.jsx("input",{type:t,className:T("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...r}));tr.displayName="Input";function _o(e,[t,r]){return Math.min(r,Math.max(t,e))}function zm(e,t){return l.useReducer((r,n)=>t[r][n]??r,e)}var Io="ScrollArea",[fc,Uw]=Oe(Io),[Wm,Te]=fc(Io),pc=l.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:o,scrollHideDelay:s=600,...a}=e,[c,d]=l.useState(null),[f,u]=l.useState(null),[p,m]=l.useState(null),[v,g]=l.useState(null),[h,b]=l.useState(null),[w,y]=l.useState(0),[x,C]=l.useState(0),[E,O]=l.useState(!1),[N,F]=l.useState(!1),B=se(t,U=>d(U)),_=Sr(o);return i.jsx(Wm,{scope:r,type:n,dir:_,scrollHideDelay:s,scrollArea:c,viewport:f,onViewportChange:u,content:p,onContentChange:m,scrollbarX:v,onScrollbarXChange:g,scrollbarXEnabled:E,onScrollbarXEnabledChange:O,scrollbarY:h,onScrollbarYChange:b,scrollbarYEnabled:N,onScrollbarYEnabledChange:F,onCornerWidthChange:y,onCornerHeightChange:C,children:i.jsx(Z.div,{dir:_,...a,ref:B,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":x+"px",...e.style}})})});pc.displayName=Io;var hc="ScrollAreaViewport",gc=l.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:o,...s}=e,a=Te(hc,r),c=l.useRef(null),d=se(t,c,a.onViewportChange);return i.jsxs(i.Fragment,{children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),i.jsx(Z.div,{"data-radix-scroll-area-viewport":"",...s,ref:d,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...e.style},children:i.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});gc.displayName=hc;var je="ScrollAreaScrollbar",Oo=l.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Te(je,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:a}=o,c=e.orientation==="horizontal";return l.useEffect(()=>(c?s(!0):a(!0),()=>{c?s(!1):a(!1)}),[c,s,a]),o.type==="hover"?i.jsx(Rm,{...n,ref:t,forceMount:r}):o.type==="scroll"?i.jsx(Vm,{...n,ref:t,forceMount:r}):o.type==="auto"?i.jsx(mc,{...n,ref:t,forceMount:r}):o.type==="always"?i.jsx(Mo,{...n,ref:t}):null});Oo.displayName=je;var Rm=l.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Te(je,e.__scopeScrollArea),[s,a]=l.useState(!1);return l.useEffect(()=>{const c=o.scrollArea;let d=0;if(c){const f=()=>{window.clearTimeout(d),a(!0)},u=()=>{d=window.setTimeout(()=>a(!1),o.scrollHideDelay)};return c.addEventListener("pointerenter",f),c.addEventListener("pointerleave",u),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",f),c.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),i.jsx(xe,{present:r||s,children:i.jsx(mc,{"data-state":s?"visible":"hidden",...n,ref:t})})}),Vm=l.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=Te(je,e.__scopeScrollArea),s=e.orientation==="horizontal",a=Jr(()=>d("SCROLL_END"),100),[c,d]=zm("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return l.useEffect(()=>{if(c==="idle"){const f=window.setTimeout(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(f)}},[c,o.scrollHideDelay,d]),l.useEffect(()=>{const f=o.viewport,u=s?"scrollLeft":"scrollTop";if(f){let p=f[u];const m=()=>{const v=f[u];p!==v&&(d("SCROLL"),a()),p=v};return f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[o.viewport,s,d,a]),i.jsx(xe,{present:r||c!=="hidden",children:i.jsx(Mo,{"data-state":c==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:z(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:z(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),mc=l.forwardRef((e,t)=>{const r=Te(je,e.__scopeScrollArea),{forceMount:n,...o}=e,[s,a]=l.useState(!1),c=e.orientation==="horizontal",d=Jr(()=>{if(r.viewport){const f=r.viewport.offsetWidth<r.viewport.scrollWidth,u=r.viewport.offsetHeight<r.viewport.scrollHeight;a(c?f:u)}},10);return Ot(r.viewport,d),Ot(r.content,d),i.jsx(xe,{present:n||s,children:i.jsx(Mo,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Mo=l.forwardRef((e,t)=>{const{orientation:r="vertical",...n}=e,o=Te(je,e.__scopeScrollArea),s=l.useRef(null),a=l.useRef(0),[c,d]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=xc(c.viewport,c.content),u={...n,sizes:c,onSizesChange:d,hasThumb:f>0&&f<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:m=>a.current=m};function p(m,v){return Ym(m,a.current,c,v)}return r==="horizontal"?i.jsx(jm,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,v=Sc(m,c,o.dir);s.current.style.transform=`translate3d(${v}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):r==="vertical"?i.jsx(Km,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,v=Sc(m,c);s.current.style.transform=`translate3d(0, ${v}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),jm=l.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=Te(je,e.__scopeScrollArea),[a,c]=l.useState(),d=l.useRef(null),f=se(t,d,s.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),i.jsx(vc,{"data-orientation":"horizontal",...o,ref:f,sizes:r,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Yr(r)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+u.deltaX;e.onWheelScroll(m),Ec(m,p)&&u.preventDefault()}},onResize:()=>{d.current&&s.viewport&&a&&n({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:Xr(a.paddingLeft),paddingEnd:Xr(a.paddingRight)}})}})}),Km=l.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...o}=e,s=Te(je,e.__scopeScrollArea),[a,c]=l.useState(),d=l.useRef(null),f=se(t,d,s.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),i.jsx(vc,{"data-orientation":"vertical",...o,ref:f,sizes:r,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Yr(r)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,p)=>{if(s.viewport){const m=s.viewport.scrollTop+u.deltaY;e.onWheelScroll(m),Ec(m,p)&&u.preventDefault()}},onResize:()=>{d.current&&s.viewport&&a&&n({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:Xr(a.paddingTop),paddingEnd:Xr(a.paddingBottom)}})}})}),[Gm,bc]=fc(je),vc=l.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:o,onThumbChange:s,onThumbPointerUp:a,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:f,onWheelScroll:u,onResize:p,...m}=e,v=Te(je,r),[g,h]=l.useState(null),b=se(t,B=>h(B)),w=l.useRef(null),y=l.useRef(""),x=v.viewport,C=n.content-n.viewport,E=ge(u),O=ge(d),N=Jr(p,10);function F(B){if(w.current){const _=B.clientX-w.current.left,U=B.clientY-w.current.top;f({x:_,y:U})}}return l.useEffect(()=>{const B=_=>{const U=_.target;(g==null?void 0:g.contains(U))&&E(_,C)};return document.addEventListener("wheel",B,{passive:!1}),()=>document.removeEventListener("wheel",B,{passive:!1})},[x,g,C,E]),l.useEffect(O,[n,O]),Ot(g,N),Ot(v.content,N),i.jsx(Gm,{scope:r,scrollbar:g,hasThumb:o,onThumbChange:ge(s),onThumbPointerUp:ge(a),onThumbPositionChange:O,onThumbPointerDown:ge(c),children:i.jsx(Z.div,{...m,ref:b,style:{position:"absolute",...m.style},onPointerDown:z(e.onPointerDown,B=>{B.button===0&&(B.target.setPointerCapture(B.pointerId),w.current=g.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",v.viewport&&(v.viewport.style.scrollBehavior="auto"),F(B))}),onPointerMove:z(e.onPointerMove,F),onPointerUp:z(e.onPointerUp,B=>{const _=B.target;_.hasPointerCapture(B.pointerId)&&_.releasePointerCapture(B.pointerId),document.body.style.webkitUserSelect=y.current,v.viewport&&(v.viewport.style.scrollBehavior=""),w.current=null})})})}),qr="ScrollAreaThumb",wc=l.forwardRef((e,t)=>{const{forceMount:r,...n}=e,o=bc(qr,e.__scopeScrollArea);return i.jsx(xe,{present:r||o.hasThumb,children:i.jsx(qm,{ref:t,...n})})}),qm=l.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...o}=e,s=Te(qr,r),a=bc(qr,r),{onThumbPositionChange:c}=a,d=se(t,p=>a.onThumbChange(p)),f=l.useRef(void 0),u=Jr(()=>{f.current&&(f.current(),f.current=void 0)},100);return l.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(u(),!f.current){const v=Jm(p,c);f.current=v,c()}};return c(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,u,c]),i.jsx(Z.div,{"data-state":a.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:z(e.onPointerDownCapture,p=>{const v=p.target.getBoundingClientRect(),g=p.clientX-v.left,h=p.clientY-v.top;a.onThumbPointerDown({x:g,y:h})}),onPointerUp:z(e.onPointerUp,a.onThumbPointerUp)})});wc.displayName=qr;var ko="ScrollAreaCorner",yc=l.forwardRef((e,t)=>{const r=Te(ko,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?i.jsx(Xm,{...e,ref:t}):null});yc.displayName=ko;var Xm=l.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,o=Te(ko,r),[s,a]=l.useState(0),[c,d]=l.useState(0),f=!!(s&&c);return Ot(o.scrollbarX,()=>{var p;const u=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(u),d(u)}),Ot(o.scrollbarY,()=>{var p;const u=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(u),a(u)}),f?i.jsx(Z.div,{...n,ref:t,style:{width:s,height:c,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Xr(e){return e?parseInt(e,10):0}function xc(e,t){const r=e/t;return isNaN(r)?0:r}function Yr(e){const t=xc(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function Ym(e,t,r,n="ltr"){const o=Yr(r),s=o/2,a=t||s,c=o-a,d=r.scrollbar.paddingStart+a,f=r.scrollbar.size-r.scrollbar.paddingEnd-c,u=r.content-r.viewport,p=n==="ltr"?[0,u]:[u*-1,0];return Cc([d,f],p)(e)}function Sc(e,t,r="ltr"){const n=Yr(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,a=t.content-t.viewport,c=s-n,d=r==="ltr"?[0,a]:[a*-1,0],f=_o(e,d);return Cc([0,a],[0,c])(f)}function Cc(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function Ec(e,t){return e>0&&e<t}var Jm=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},a=r.left!==s.left,c=r.top!==s.top;(a||c)&&t(),r=s,n=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(n)};function Jr(e,t){const r=ge(e),n=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(n.current),[]),l.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function Ot(e,t){const r=ge(t);he(()=>{let n=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return o.observe(e),()=>{window.cancelAnimationFrame(n),o.unobserve(e)}}},[e,r])}var Nc=pc,Zm=gc,Qm=yc;const Tc=l.forwardRef(({className:e,children:t,...r},n)=>i.jsxs(Nc,{ref:n,className:T("relative overflow-hidden",e),...r,children:[i.jsx(Zm,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),i.jsx(Ac,{}),i.jsx(Qm,{})]}));Tc.displayName=Nc.displayName;const Ac=l.forwardRef(({className:e,orientation:t="vertical",...r},n)=>i.jsx(Oo,{ref:n,orientation:t,className:T("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...r,children:i.jsx(wc,{className:"relative flex-1 rounded-full bg-border"})}));Ac.displayName=Oo.displayName;function Zr({className:e="",showCreateButton:t=!0,showDeleteButton:r=!0,showEditTitle:n=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:a=null,navigateToThread:c,onThreadSelect:d,onThreadCreate:f,onThreadDelete:u}){const{loadThread:p,threads:m,refreshThreads:v,currentThreadId:g,createThread:h,deleteThread:b,renameThread:w}=$n(),[y,x]=A.useState(m??[]),[C,E]=A.useState(!1),[O,N]=A.useState(null),[F,B]=A.useState(null),[_,U]=A.useState(""),[G,L]=A.useState(!1);A.useEffect(()=>{x(m??[])},[m]);const $=async H=>{try{await p(H),c==null||c(H),d==null||d(H)}catch(R){console.error("Failed to select thread:",R)}},q=async()=>{try{L(!0);const H=await h();f==null||f(H),c==null||c(H)}catch(H){console.error("Failed to create thread:",H)}finally{L(!1)}},k=async(H,R)=>{if(R.stopPropagation(),!!confirm("Delete this thread?"))try{await b(H),u==null||u(H)}catch(ue){console.error("Failed to delete thread:",ue)}},V=(H,R)=>{R.stopPropagation(),B(H.threadId),U(H.title||`Thread ${H.threadId.slice(0,8)}`)},D=async H=>{if(_.trim())try{await w(H,_.trim()),B(null),U("")}catch(R){console.error("Failed to update title:",R)}},I=()=>{B(null),U("")},J=(H,R)=>{H.key==="Enter"?D(R):H.key==="Escape"&&I()},Q=H=>{if(!H)return"";try{const R=new Date(H),de=new Date().getTime()-R.getTime(),j=Math.floor(de/(1e3*60*60*24));return j===0?R.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):j===1?"Yesterday":j<7?`${j} days ago`:R.toLocaleDateString()}catch{return""}},re=H=>H.title||`Thread ${H.threadId.slice(0,8)}`;return i.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&i.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:i.jsx(ce,{onClick:q,disabled:G||C,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:G?"Creating...":"New Chat",children:i.jsx(X.MessageSquarePlus,{size:20})})}),i.jsx(Tc,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:i.jsx("div",{className:"p-2 space-y-1 pb-4",children:C?i.jsx("div",{className:"text-center py-8 text-slate-400",children:"Loading…"}):y.length===0?i.jsxs("div",{className:"text-center py-8 text-slate-400",children:[i.jsx(X.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),i.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):y.slice().sort((H,R)=>new Date(R.updatedAt||R.createdAt||"").getTime()-new Date(H.updatedAt||H.createdAt||"").getTime()).map(H=>i.jsxs("div",{onClick:()=>$(H.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(a??g)===H.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{className:"flex-1 min-w-0",children:F===H.threadId?i.jsxs("div",{className:"flex items-center gap-2",onClick:R=>R.stopPropagation(),children:[i.jsx(tr,{value:_,onChange:R=>U(R.target.value),onKeyDown:R=>J(R,H.threadId),className:"h-6 text-sm",autoFocus:!0}),i.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>D(H.threadId),className:"h-6 w-6 p-0",children:i.jsx(X.Check,{size:12})}),i.jsx(ce,{variant:"ghost",size:"sm",onClick:I,className:"h-6 w-6 p-0",children:i.jsx(X.X,{size:12})})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:re(H)}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[i.jsx(X.Calendar,{size:10}),i.jsx("span",{children:Q(H.updatedAt||H.createdAt)})]})]})}),i.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[n&&F!==H.threadId&&i.jsx(ce,{variant:"ghost",size:"sm",onClick:R=>V(H,R),className:"h-6 w-6 p-0",title:"Edit title",children:i.jsx(X.Edit3,{size:12})}),r&&i.jsx(ce,{variant:"ghost",size:"sm",onClick:R=>k(H.threadId,R),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:i.jsx(X.Trash2,{size:12})})]})]}),a===H.threadId&&i.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},H.threadId))})})]})}const Pc=A.createContext(null);function eb({children:e,basePath:t="/chat"}){const r=A.useMemo(()=>t?t==="/"?"":t.endsWith("/")?t.slice(0,-1):t:"/chat",[t]),n={basePath:r,buildThreadPath:o=>`${r}/${o}`,buildBasePath:()=>r};return i.jsx(Pc.Provider,{value:n,children:e})}function tb(){const e=A.useContext(Pc);return e||{basePath:"/chat",buildThreadPath:t=>`/chat/${t}`,buildBasePath:()=>"/chat"}}const _c={BASE_URL:"/",DEV:!1,MODE:"library",PROD:!0,SSR:!1};function rr(e){var o;const t=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:vn&&vn.tagName.toUpperCase()==="SCRIPT"&&vn.src||new URL("index.umd.js",document.baseURI).href}<"u"&&_c?_c[e]:void 0,r=(o=globalThis==null?void 0:globalThis.process)==null?void 0:o.env,n=r?r[e]:void 0;return(t??n)||void 0}function rb(){return rr("VITE_API_BASE_URL")||rr("NEXT_PUBLIC_API_BASE_URL")||void 0}function nb(){return rr("VITE_API_KEY")||rr("NEXT_PUBLIC_API_KEY")||rr("VITE_AUTH_TOKEN")||void 0}function Ic(){const e=rb(),t=nb(),r={};return e&&(r.baseUrl=e),t&&(r.apiKey=t),r}function Oc(){const e=Ic(),t=Ge.getAuthToken();return{apiBaseUrl:e.baseUrl||Ge.baseUrl||"http://localhost:8000",apiKey:t||e.apiKey||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const Mc="chat-settings";function ob(){try{const e=localStorage.getItem(Mc);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function sb(e){try{localStorage.setItem(Mc,JSON.stringify(e)),e.apiKey&&Ge.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function ab(){const e=Oc(),t=ob(),r=Ge.getAuthToken();return{...e,...t,apiKey:r||t.apiKey||e.apiKey,apiBaseUrl:Ge.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function ib(e){e.apiKey&&Ge.setAuthToken(e.apiKey),sb(e)}const Do=768;function cb(){const[e,t]=l.useState(void 0);return l.useEffect(()=>{const r=window.matchMedia(`(max-width: ${Do-1}px)`),n=()=>{t(window.innerWidth<Do)};return r.addEventListener("change",n),t(window.innerWidth<Do),()=>r.removeEventListener("change",n)},[]),!!e}var lb="Separator",kc="horizontal",db=["horizontal","vertical"],Dc=l.forwardRef((e,t)=>{const{decorative:r,orientation:n=kc,...o}=e,s=ub(n)?n:kc,c=r?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return i.jsx(Z.div,{"data-orientation":s,...c,...o,ref:t})});Dc.displayName=lb;function ub(e){return db.includes(e)}var Lc=Dc;const Lo=l.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...n},o)=>i.jsx(Lc,{ref:o,decorative:r,orientation:t,className:T("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));Lo.displayName=Lc.displayName;var Qr="Dialog",[Fc,Hw]=Oe(Qr),[fb,Le]=Fc(Qr),$c=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:o,onOpenChange:s,modal:a=!0}=e,c=l.useRef(null),d=l.useRef(null),[f,u]=Je({prop:n,defaultProp:o??!1,onChange:s,caller:Qr});return i.jsx(fb,{scope:t,triggerRef:c,contentRef:d,contentId:Me(),titleId:Me(),descriptionId:Me(),open:f,onOpenChange:u,onOpenToggle:l.useCallback(()=>u(p=>!p),[u]),modal:a,children:r})};$c.displayName=Qr;var Bc="DialogTrigger",Uc=l.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Le(Bc,r),s=se(t,o.triggerRef);return i.jsx(Z.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Bo(o.open),...n,ref:s,onClick:z(e.onClick,o.onOpenToggle)})});Uc.displayName=Bc;var Fo="DialogPortal",[pb,Hc]=Fc(Fo,{forceMount:void 0}),zc=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:o}=e,s=Le(Fo,t);return i.jsx(pb,{scope:t,forceMount:r,children:l.Children.map(n,a=>i.jsx(xe,{present:r||s.open,children:i.jsx(Dr,{asChild:!0,container:o,children:a})}))})};zc.displayName=Fo;var en="DialogOverlay",Wc=l.forwardRef((e,t)=>{const r=Hc(en,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=Le(en,e.__scopeDialog);return s.modal?i.jsx(xe,{present:n||s.open,children:i.jsx(gb,{...o,ref:t})}):null});Wc.displayName=en;var hb=Se.createSlot("DialogOverlay.RemoveScroll"),gb=l.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Le(en,r);return i.jsx(Wr,{as:hb,allowPinchZoom:!0,shards:[o.contentRef],children:i.jsx(Z.div,{"data-state":Bo(o.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),ft="DialogContent",Rc=l.forwardRef((e,t)=>{const r=Hc(ft,e.__scopeDialog),{forceMount:n=r.forceMount,...o}=e,s=Le(ft,e.__scopeDialog);return i.jsx(xe,{present:n||s.open,children:s.modal?i.jsx(mb,{...o,ref:t}):i.jsx(bb,{...o,ref:t})})});Rc.displayName=ft;var mb=l.forwardRef((e,t)=>{const r=Le(ft,e.__scopeDialog),n=l.useRef(null),o=se(t,r.contentRef,n);return l.useEffect(()=>{const s=n.current;if(s)return mo(s)},[]),i.jsx(Vc,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:z(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),(a=r.triggerRef.current)==null||a.focus()}),onPointerDownOutside:z(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0;(a.button===2||c)&&s.preventDefault()}),onFocusOutside:z(e.onFocusOutside,s=>s.preventDefault())})}),bb=l.forwardRef((e,t)=>{const r=Le(ft,e.__scopeDialog),n=l.useRef(!1),o=l.useRef(!1);return i.jsx(Vc,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,c;(a=e.onCloseAutoFocus)==null||a.call(e,s),s.defaultPrevented||(n.current||(c=r.triggerRef.current)==null||c.focus(),s.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:s=>{var d,f;(d=e.onInteractOutside)==null||d.call(e,s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=s.target;((f=r.triggerRef.current)==null?void 0:f.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Vc=l.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:s,...a}=e,c=Le(ft,r),d=l.useRef(null),f=se(t,d);return Kn(),i.jsxs(i.Fragment,{children:[i.jsx(Cr,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:s,children:i.jsx(Vt,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Bo(c.open),...a,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(vb,{titleId:c.titleId}),i.jsx(yb,{contentRef:d,descriptionId:c.descriptionId})]})]})}),$o="DialogTitle",jc=l.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Le($o,r);return i.jsx(Z.h2,{id:o.titleId,...n,ref:t})});jc.displayName=$o;var Kc="DialogDescription",Gc=l.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Le(Kc,r);return i.jsx(Z.p,{id:o.descriptionId,...n,ref:t})});Gc.displayName=Kc;var qc="DialogClose",Xc=l.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,o=Le(qc,r);return i.jsx(Z.button,{type:"button",...n,ref:t,onClick:z(e.onClick,()=>o.onOpenChange(!1))})});Xc.displayName=qc;function Bo(e){return e?"open":"closed"}var Yc="DialogTitleWarning",[zw,Jc]=gf(Yc,{contentName:ft,titleName:$o,docsSlug:"dialog"}),vb=({titleId:e})=>{const t=Jc(Yc),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
59
59
 
60
60
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
61
61
 
62
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return l.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Rb="DialogDescriptionWarning",Kb=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${El(Rb).contentName}}.`;return l.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Gb=dl,qb=fl,Xb=hl,Nl=gl,Tl=ml,Al=vl,Il=yl,Yb=Sl;const kl=Gb,Jb=qb,Zb=Xb,_l=l.forwardRef(({className:e,...t},n)=>i.jsx(Nl,{className:A("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));_l.displayName=Nl.displayName;const Qb=Jt.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),ds=l.forwardRef(({side:e="right",className:t,children:n,...r},o)=>i.jsxs(Zb,{children:[i.jsx(_l,{}),i.jsxs(Tl,{ref:o,className:A(Qb({side:e}),t),...r,children:[n,i.jsxs(Yb,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[i.jsx(q.X,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ds.displayName=Tl.displayName;const Pl=({className:e,...t})=>i.jsx("div",{className:A("flex flex-col space-y-2 text-center sm:text-left",e),...t});Pl.displayName="SheetHeader";const Ol=l.forwardRef(({className:e,...t},n)=>i.jsx(Al,{ref:n,className:A("text-lg font-semibold text-foreground",e),...t}));Ol.displayName=Al.displayName;const Ml=l.forwardRef(({className:e,...t},n)=>i.jsx(Il,{ref:n,className:A("text-sm text-muted-foreground",e),...t}));Ml.displayName=Il.displayName;function Dl({className:e,...t}){return i.jsx("div",{className:A("animate-pulse rounded-md bg-muted",e),...t})}var Ll=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),ev="VisuallyHidden",Fl=l.forwardRef((e,t)=>i.jsx(oe.span,{...e,ref:t,style:{...Ll,...e.style}}));Fl.displayName=ev;var tv=Fl,[xr,uy]=Ke("Tooltip",[Vt]),Sr=Vt(),$l="TooltipProvider",nv=700,us="tooltip.open",[rv,fs]=xr($l),Bl=e=>{const{__scopeTooltip:t,delayDuration:n=nv,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,a=l.useRef(!0),c=l.useRef(!1),d=l.useRef(0);return l.useEffect(()=>{const f=d.current;return()=>window.clearTimeout(f)},[]),i.jsx(rv,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:l.useCallback(()=>{window.clearTimeout(d.current),a.current=!1},[]),onClose:l.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>a.current=!0,r)},[r]),isPointerInTransitRef:c,onPointerInTransitChange:l.useCallback(f=>{c.current=f},[]),disableHoverableContent:o,children:s})};Bl.displayName=$l;var xn="Tooltip",[ov,Cr]=xr(xn),Ul=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:a,delayDuration:c}=e,d=fs(xn,e.__scopeTooltip),f=Sr(t),[u,p]=l.useState(null),m=Ge(),v=l.useRef(0),g=a??d.disableHoverableContent,h=c??d.delayDuration,b=l.useRef(!1),[w,y]=mt({prop:r,defaultProp:o??!1,onChange:T=>{T?(d.onOpen(),document.dispatchEvent(new CustomEvent(us))):d.onClose(),s==null||s(T)},caller:xn}),x=l.useMemo(()=>w?b.current?"delayed-open":"instant-open":"closed",[w]),C=l.useCallback(()=>{window.clearTimeout(v.current),v.current=0,b.current=!1,y(!0)},[y]),E=l.useCallback(()=>{window.clearTimeout(v.current),v.current=0,y(!1)},[y]),P=l.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{b.current=!0,y(!0),v.current=0},h)},[h,y]);return l.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),i.jsx(Do,{...f,children:i.jsx(ov,{scope:t,contentId:m,open:w,stateAttribute:x,trigger:u,onTriggerChange:p,onTriggerEnter:l.useCallback(()=>{d.isOpenDelayedRef.current?P():C()},[d.isOpenDelayedRef,P,C]),onTriggerLeave:l.useCallback(()=>{g?E():(window.clearTimeout(v.current),v.current=0)},[E,g]),onOpen:C,onClose:E,disableHoverableContent:g,children:n})})};Ul.displayName=xn;var ps="TooltipTrigger",Hl=l.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Cr(ps,n),s=fs(ps,n),a=Sr(n),c=l.useRef(null),d=ue(t,c,o.onTriggerChange),f=l.useRef(!1),u=l.useRef(!1),p=l.useCallback(()=>f.current=!1,[]);return l.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),i.jsx(Lo,{asChild:!0,...a,children:i.jsx(oe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:d,onPointerMove:U(e.onPointerMove,m=>{m.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),u.current=!0)}),onPointerLeave:U(e.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:U(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:U(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:U(e.onBlur,o.onClose),onClick:U(e.onClick,o.onClose)})})});Hl.displayName=ps;var sv="TooltipPortal",[fy,av]=xr(sv,{forceMount:void 0}),Xt="TooltipContent",zl=l.forwardRef((e,t)=>{const n=av(Xt,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,a=Cr(Xt,e.__scopeTooltip);return i.jsx(Le,{present:r||a.open,children:a.disableHoverableContent?i.jsx(Wl,{side:o,...s,ref:t}):i.jsx(iv,{side:o,...s,ref:t})})}),iv=l.forwardRef((e,t)=>{const n=Cr(Xt,e.__scopeTooltip),r=fs(Xt,e.__scopeTooltip),o=l.useRef(null),s=ue(t,o),[a,c]=l.useState(null),{trigger:d,onClose:f}=n,u=o.current,{onPointerInTransitChange:p}=r,m=l.useCallback(()=>{c(null),p(!1)},[p]),v=l.useCallback((g,h)=>{const b=g.currentTarget,w={x:g.clientX,y:g.clientY},y=fv(w,b.getBoundingClientRect()),x=pv(w,y),C=hv(h.getBoundingClientRect()),E=mv([...x,...C]);c(E),p(!0)},[p]);return l.useEffect(()=>()=>m(),[m]),l.useEffect(()=>{if(d&&u){const g=b=>v(b,u),h=b=>v(b,d);return d.addEventListener("pointerleave",g),u.addEventListener("pointerleave",h),()=>{d.removeEventListener("pointerleave",g),u.removeEventListener("pointerleave",h)}}},[d,u,v,m]),l.useEffect(()=>{if(a){const g=h=>{const b=h.target,w={x:h.clientX,y:h.clientY},y=(d==null?void 0:d.contains(b))||(u==null?void 0:u.contains(b)),x=!gv(w,a);y?m():x&&(m(),f())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[d,u,a,f,m]),i.jsx(Wl,{...e,ref:s})}),[cv,lv]=xr(xn,{isInside:!1}),dv=Be.createSlottable("TooltipContent"),Wl=l.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:a,...c}=e,d=Cr(Xt,n),f=Sr(n),{onClose:u}=d;return l.useEffect(()=>(document.addEventListener(us,u),()=>document.removeEventListener(us,u)),[u]),l.useEffect(()=>{if(d.trigger){const p=m=>{const v=m.target;v!=null&&v.contains(d.trigger)&&u()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[d.trigger,u]),i.jsx(cn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:p=>p.preventDefault(),onDismiss:u,children:i.jsxs(Fo,{"data-state":d.stateAttribute,...f,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[i.jsx(dv,{children:r}),i.jsx(cv,{scope:n,isInside:!0,children:i.jsx(tv,{id:d.contentId,role:"tooltip",children:o||r})})]})})});zl.displayName=Xt;var Vl="TooltipArrow",uv=l.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Sr(n);return lv(Vl,n).isInside?null:i.jsx($o,{...o,...r,ref:t})});uv.displayName=Vl;function fv(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function pv(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function hv(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function gv(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const c=t[s],d=t[a],f=c.x,u=c.y,p=d.x,m=d.y;u>r!=m>r&&n<(p-f)*(r-u)/(m-u)+f&&(o=!o)}return o}function mv(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),bv(t)}function bv(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(o.y-a.y)>=(s.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(o.y-a.y)>=(s.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var vv=Bl,wv=Ul,yv=Hl,jl=zl;const xv=vv,Sv=wv,Cv=yv,Rl=l.forwardRef(({className:e,sideOffset:t=4,...n},r)=>i.jsx(jl,{ref:r,sideOffset:t,className:A("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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",e),...n}));Rl.displayName=jl.displayName;const Ev="sidebar:state",Nv=60*60*24*7,Tv="16rem",Av="18rem",Iv="3rem",kv="b",Kl=l.createContext(null);function Er(){const e=l.useContext(Kl);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const Gl=l.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:o,children:s,...a},c)=>{const d=Db(),[f,u]=l.useState(!1),[p,m]=l.useState(e),v=t??p,g=l.useCallback(y=>{const x=typeof y=="function"?y(v):y;n?n(x):m(x),document.cookie=`${Ev}=${x}; path=/; max-age=${Nv}`},[n,v]),h=l.useCallback(()=>d?u(y=>!y):g(y=>!y),[d,g,u]);l.useEffect(()=>{const y=x=>{x.key===kv&&(x.metaKey||x.ctrlKey)&&(x.preventDefault(),h())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[h]);const b=v?"expanded":"collapsed",w=l.useMemo(()=>({state:b,open:v,setOpen:g,isMobile:d,openMobile:f,setOpenMobile:u,toggleSidebar:h}),[b,v,g,d,f,u,h]);return i.jsx(Kl.Provider,{value:w,children:i.jsx(xv,{delayDuration:0,children:i.jsx("div",{style:{"--sidebar-width":Tv,"--sidebar-width-icon":Iv,...o},className:A("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",r),ref:c,...a,children:s})})})});Gl.displayName="SidebarProvider";const ql=l.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:o,...s},a)=>{const{isMobile:c,state:d,openMobile:f,setOpenMobile:u}=Er();return n==="none"?i.jsx("div",{className:A("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:a,...s,children:o}):c?i.jsx(kl,{open:f,onOpenChange:u,...s,children:i.jsx(ds,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":Av},side:e,children:i.jsx("div",{className:"flex h-full w-full flex-col",children:o})})}):i.jsxs("div",{ref:a,className:"group peer hidden md:block text-sidebar-foreground","data-state":d,"data-collapsible":d==="collapsed"?n:"","data-variant":t,"data-side":e,children:[i.jsx("div",{className:A("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),i.jsx("div",{className:A("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:i.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:o})})]})});ql.displayName="Sidebar";const Xl=l.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:o}=Er();return i.jsxs(we,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:A("h-7 w-7",e),onClick:s=>{t==null||t(s),o()},...n,children:[i.jsx(q.PanelLeft,{}),i.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Xl.displayName="SidebarTrigger";const _v=l.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Er();return i.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:A("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});_v.displayName="SidebarRail";const Yl=l.forwardRef(({className:e,...t},n)=>i.jsx("main",{ref:n,className:A("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...t}));Yl.displayName="SidebarInset";const Pv=l.forwardRef(({className:e,...t},n)=>i.jsx(wn,{ref:n,"data-sidebar":"input",className:A("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));Pv.displayName="SidebarInput";const Jl=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"header",className:A("flex flex-col gap-2 p-2",e),...t}));Jl.displayName="SidebarHeader";const Ov=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"footer",className:A("flex flex-col gap-2 p-2",e),...t}));Ov.displayName="SidebarFooter";const Mv=l.forwardRef(({className:e,...t},n)=>i.jsx(as,{ref:n,"data-sidebar":"separator",className:A("mx-2 w-auto bg-sidebar-border",e),...t}));Mv.displayName="SidebarSeparator";const Zl=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"content",className:A("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Zl.displayName="SidebarContent";const Ql=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"group",className:A("relative flex w-full min-w-0 flex-col p-2",e),...t}));Ql.displayName="SidebarGroup";const ed=l.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Be.Slot:"div";return i.jsx(o,{ref:r,"data-sidebar":"group-label",className:A("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...n})});ed.displayName="SidebarGroupLabel";const Dv=l.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const o=t?Be.Slot:"button";return i.jsx(o,{ref:r,"data-sidebar":"group-action",className:A("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...n})});Dv.displayName="SidebarGroupAction";const td=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"group-content",className:A("w-full text-sm",e),...t}));td.displayName="SidebarGroupContent";const nd=l.forwardRef(({className:e,...t},n)=>i.jsx("ul",{ref:n,"data-sidebar":"menu",className:A("flex w-full min-w-0 flex-col gap-1",e),...t}));nd.displayName="SidebarMenu";const rd=l.forwardRef(({className:e,...t},n)=>i.jsx("li",{ref:n,"data-sidebar":"menu-item",className:A("group/menu-item relative",e),...t}));rd.displayName="SidebarMenuItem";const Lv=Jt.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),od=l.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:o,className:s,...a},c)=>{const d=e?Be.Slot:"button",{isMobile:f,state:u}=Er(),p=i.jsx(d,{ref:c,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:A(Lv({variant:n,size:r}),s),...a});return o?(typeof o=="string"&&(o={children:o}),i.jsxs(Sv,{children:[i.jsx(Cv,{asChild:!0,children:p}),i.jsx(Rl,{side:"right",align:"center",hidden:u!=="collapsed"||f,...o})]})):p});od.displayName="SidebarMenuButton";const Fv=l.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},o)=>{const s=t?Be.Slot:"button";return i.jsx(s,{ref:o,"data-sidebar":"menu-action",className:A("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),...r})});Fv.displayName="SidebarMenuAction";const $v=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:A("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));$v.displayName="SidebarMenuBadge";const Bv=l.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const o=l.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return i.jsxs("div",{ref:r,"data-sidebar":"menu-skeleton",className:A("rounded-md h-8 flex gap-2 px-2 items-center",e),...n,children:[t&&i.jsx(Dl,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),i.jsx(Dl,{className:"h-4 flex-1 max-w-[--skeleton-width]","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});Bv.displayName="SidebarMenuSkeleton";const Uv=l.forwardRef(({className:e,...t},n)=>i.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:A("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));Uv.displayName="SidebarMenuSub";const Hv=l.forwardRef(({...e},t)=>i.jsx("li",{ref:t,...e}));Hv.displayName="SidebarMenuSubItem";const zv=l.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...o},s)=>{const a=e?Be.Slot:"a";return i.jsx(a,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:A("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),...o})});zv.displayName="SidebarMenuSubButton";function Wv({header:e,sidebarTitle:t="Threads",showThreads:n=!0,className:r="",sidebarClassName:o="",chatClassName:s="",...a}){return i.jsx(on,{...a,children:i.jsxs(Gl,{className:`w-full ${r}`,children:[i.jsxs(ql,{className:`border-r ${o}`,children:[i.jsx(Jl,{children:i.jsx(nd,{children:i.jsx(rd,{children:i.jsx(od,{size:"lg",children:i.jsx("span",{className:"font-semibold",children:t})})})})}),i.jsx(Zl,{children:n&&i.jsxs(Ql,{children:[i.jsx(ed,{children:"Conversations"}),i.jsx(td,{children:i.jsx("div",{className:"px-2 py-1",children:i.jsx(vr,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-[calc(100vh-12rem)]"})})})]})})]}),i.jsxs(Yl,{children:[i.jsxs("header",{className:"h-14 border-b bg-background/60 backdrop-blur flex items-center gap-2 px-4",children:[i.jsx(Xl,{}),i.jsx("div",{className:"flex-1"}),e]}),i.jsx("main",{className:`flex-1 min-h-0 overflow-hidden ${s}`,children:i.jsx(vn,{})})]})]})})}var Vv="Label",sd=l.forwardRef((e,t)=>i.jsx(oe.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));sd.displayName=Vv;var ad=sd;const jv=Jt.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),je=l.forwardRef(({className:e,...t},n)=>i.jsx(ad,{ref:n,className:A(jv(),e),...t}));je.displayName=ad.displayName;function id(e){const t=l.useRef({value:e,previous:e});return l.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Nr="Switch",[Rv,py]=Ke(Nr),[Kv,Gv]=Rv(Nr),cd=l.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:a,disabled:c,value:d="on",onCheckedChange:f,form:u,...p}=e,[m,v]=l.useState(null),g=ue(t,x=>v(x)),h=l.useRef(!1),b=m?u||!!m.closest("form"):!0,[w,y]=mt({prop:o,defaultProp:s??!1,onChange:f,caller:Nr});return i.jsxs(Kv,{scope:n,checked:w,disabled:c,children:[i.jsx(oe.button,{type:"button",role:"switch","aria-checked":w,"aria-required":a,"data-state":fd(w),"data-disabled":c?"":void 0,disabled:c,value:d,...p,ref:g,onClick:U(e.onClick,x=>{y(C=>!C),b&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})}),b&&i.jsx(ud,{control:m,bubbles:!h.current,name:r,value:d,checked:w,required:a,disabled:c,form:u,style:{transform:"translateX(-100%)"}})]})});cd.displayName=Nr;var ld="SwitchThumb",dd=l.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Gv(ld,n);return i.jsx(oe.span,{"data-state":fd(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});dd.displayName=ld;var qv="SwitchBubbleInput",ud=l.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const a=l.useRef(null),c=ue(a,s),d=id(n),f=hi(t);return l.useEffect(()=>{const u=a.current;if(!u)return;const p=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(p,"checked").set;if(d!==n&&v){const g=new Event("click",{bubbles:r});v.call(u,n),u.dispatchEvent(g)}},[d,n,r]),i.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:c,style:{...o.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});ud.displayName=qv;function fd(e){return e?"checked":"unchecked"}var pd=cd,Xv=dd;const yt=l.forwardRef(({className:e,...t},n)=>i.jsx(pd,{className:A("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:i.jsx(Xv,{className:A("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));yt.displayName=pd.displayName;var Yv=[" ","Enter","ArrowUp","ArrowDown"],Jv=[" ","Enter"],Pt="Select",[Tr,Ar,Zv]=go(Pt),[Yt,hy]=Ke(Pt,[Zv,Vt]),Ir=Vt(),[Qv,xt]=Yt(Pt),[ew,tw]=Yt(Pt),hd=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:a,defaultValue:c,onValueChange:d,dir:f,name:u,autoComplete:p,disabled:m,required:v,form:g}=e,h=Ir(t),[b,w]=l.useState(null),[y,x]=l.useState(null),[C,E]=l.useState(!1),P=Wn(f),[T,F]=mt({prop:r,defaultProp:o??!1,onChange:s,caller:Pt}),[M,B]=mt({prop:a,defaultProp:c,onChange:d,caller:Pt}),V=l.useRef(null),J=b?g||!!b.closest("form"):!0,[H,O]=l.useState(new Set),ne=Array.from(H).map(L=>L.props.value).join(";");return i.jsx(Do,{...h,children:i.jsxs(Qv,{required:v,scope:t,trigger:b,onTriggerChange:w,valueNode:y,onValueNodeChange:x,valueNodeHasChildren:C,onValueNodeHasChildrenChange:E,contentId:Ge(),value:M,onValueChange:B,open:T,onOpenChange:F,dir:P,triggerPointerDownPosRef:V,disabled:m,children:[i.jsx(Tr.Provider,{scope:t,children:i.jsx(ew,{scope:e.__scopeSelect,onNativeOptionAdd:l.useCallback(L=>{O(z=>new Set(z).add(L))},[]),onNativeOptionRemove:l.useCallback(L=>{O(z=>{const k=new Set(z);return k.delete(L),k})},[]),children:n})}),J?i.jsxs(Bd,{"aria-hidden":!0,required:v,tabIndex:-1,name:u,autoComplete:p,value:M,onChange:L=>B(L.target.value),disabled:m,form:g,children:[M===void 0?i.jsx("option",{value:""}):null,Array.from(H)]},ne):null]})})};hd.displayName=Pt;var gd="SelectTrigger",md=l.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Ir(n),a=xt(gd,n),c=a.disabled||r,d=ue(t,a.onTriggerChange),f=Ar(n),u=l.useRef("touch"),[p,m,v]=Hd(h=>{const b=f().filter(x=>!x.disabled),w=b.find(x=>x.value===a.value),y=zd(b,h,w);y!==void 0&&a.onValueChange(y.value)}),g=h=>{c||(a.onOpenChange(!0),v()),h&&(a.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return i.jsx(Lo,{asChild:!0,...s,children:i.jsx(oe.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":Ud(a.value)?"":void 0,...o,ref:d,onClick:U(o.onClick,h=>{h.currentTarget.focus(),u.current!=="mouse"&&g(h)}),onPointerDown:U(o.onPointerDown,h=>{u.current=h.pointerType;const b=h.target;b.hasPointerCapture(h.pointerId)&&b.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(g(h),h.preventDefault())}),onKeyDown:U(o.onKeyDown,h=>{const b=p.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&m(h.key),!(b&&h.key===" ")&&Yv.includes(h.key)&&(g(),h.preventDefault())})})})});md.displayName=gd;var bd="SelectValue",vd=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:a="",...c}=e,d=xt(bd,n),{onValueNodeHasChildrenChange:f}=d,u=s!==void 0,p=ue(t,d.onValueNodeChange);return Ne(()=>{f(u)},[f,u]),i.jsx(oe.span,{...c,ref:p,style:{pointerEvents:"none"},children:Ud(d.value)?i.jsx(i.Fragment,{children:a}):s})});vd.displayName=bd;var nw="SelectIcon",wd=l.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return i.jsx(oe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});wd.displayName=nw;var rw="SelectPortal",yd=e=>i.jsx(er,{asChild:!0,...e});yd.displayName=rw;var Ot="SelectContent",xd=l.forwardRef((e,t)=>{const n=xt(Ot,e.__scopeSelect),[r,o]=l.useState();if(Ne(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Tn.createPortal(i.jsx(Sd,{scope:e.__scopeSelect,children:i.jsx(Tr.Slot,{scope:e.__scopeSelect,children:i.jsx("div",{children:e.children})})}),s):null}return i.jsx(Cd,{...e,ref:t})});xd.displayName=Ot;var Je=10,[Sd,St]=Yt(Ot),ow="SelectContentImpl",sw=Be.createSlot("SelectContent.RemoveScroll"),Cd=l.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:a,side:c,sideOffset:d,align:f,alignOffset:u,arrowPadding:p,collisionBoundary:m,collisionPadding:v,sticky:g,hideWhenDetached:h,avoidCollisions:b,...w}=e,y=xt(Ot,n),[x,C]=l.useState(null),[E,P]=l.useState(null),T=ue(t,R=>C(R)),[F,M]=l.useState(null),[B,V]=l.useState(null),J=Ar(n),[H,O]=l.useState(!1),ne=l.useRef(!1);l.useEffect(()=>{if(x)return zo(x)},[x]),vo();const L=l.useCallback(R=>{const[le,...he]=J().map(ge=>ge.ref.current),[de]=he.slice(-1),be=document.activeElement;for(const ge of R)if(ge===be||(ge==null||ge.scrollIntoView({block:"nearest"}),ge===le&&E&&(E.scrollTop=0),ge===de&&E&&(E.scrollTop=E.scrollHeight),ge==null||ge.focus(),document.activeElement!==be))return},[J,E]),z=l.useCallback(()=>L([F,x]),[L,F,x]);l.useEffect(()=>{H&&z()},[H,z]);const{onOpenChange:k,triggerPointerDownPosRef:I}=y;l.useEffect(()=>{if(x){let R={x:0,y:0};const le=de=>{var be,ge;R={x:Math.abs(Math.round(de.pageX)-(((be=I.current)==null?void 0:be.x)??0)),y:Math.abs(Math.round(de.pageY)-(((ge=I.current)==null?void 0:ge.y)??0))}},he=de=>{R.x<=10&&R.y<=10?de.preventDefault():x.contains(de.target)||k(!1),document.removeEventListener("pointermove",le),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",le),document.addEventListener("pointerup",he,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",le),document.removeEventListener("pointerup",he,{capture:!0})}}},[x,k,I]),l.useEffect(()=>{const R=()=>k(!1);return window.addEventListener("blur",R),window.addEventListener("resize",R),()=>{window.removeEventListener("blur",R),window.removeEventListener("resize",R)}},[k]);const[Z,j]=Hd(R=>{const le=J().filter(be=>!be.disabled),he=le.find(be=>be.ref.current===document.activeElement),de=zd(le,R,he);de&&setTimeout(()=>de.ref.current.focus())}),te=l.useCallback((R,le,he)=>{const de=!ne.current&&!he;(y.value!==void 0&&y.value===le||de)&&(M(R),de&&(ne.current=!0))},[y.value]),D=l.useCallback(()=>x==null?void 0:x.focus(),[x]),W=l.useCallback((R,le,he)=>{const de=!ne.current&&!he;(y.value!==void 0&&y.value===le||de)&&V(R)},[y.value]),xe=r==="popper"?hs:Ed,ie=xe===hs?{side:c,sideOffset:d,align:f,alignOffset:u,arrowPadding:p,collisionBoundary:m,collisionPadding:v,sticky:g,hideWhenDetached:h,avoidCollisions:b}:{};return i.jsx(Sd,{scope:n,content:x,viewport:E,onViewportChange:P,itemRefCallback:te,selectedItem:F,onItemLeave:D,itemTextRefCallback:W,focusSelectedItem:z,selectedItemText:B,position:r,isPositioned:H,searchRef:Z,children:i.jsx(cr,{as:sw,allowPinchZoom:!0,children:i.jsx(Vn,{asChild:!0,trapped:y.open,onMountAutoFocus:R=>{R.preventDefault()},onUnmountAutoFocus:U(o,R=>{var le;(le=y.trigger)==null||le.focus({preventScroll:!0}),R.preventDefault()}),children:i.jsx(cn,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:R=>R.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:i.jsx(xe,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:R=>R.preventDefault(),...w,...ie,onPlaced:()=>O(!0),ref:T,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:U(w.onKeyDown,R=>{const le=R.ctrlKey||R.altKey||R.metaKey;if(R.key==="Tab"&&R.preventDefault(),!le&&R.key.length===1&&j(R.key),["ArrowUp","ArrowDown","Home","End"].includes(R.key)){let de=J().filter(be=>!be.disabled).map(be=>be.ref.current);if(["ArrowUp","End"].includes(R.key)&&(de=de.slice().reverse()),["ArrowUp","ArrowDown"].includes(R.key)){const be=R.target,ge=de.indexOf(be);de=de.slice(ge+1)}setTimeout(()=>L(de)),R.preventDefault()}})})})})})})});Cd.displayName=ow;var aw="SelectItemAlignedPosition",Ed=l.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=xt(Ot,n),a=St(Ot,n),[c,d]=l.useState(null),[f,u]=l.useState(null),p=ue(t,T=>u(T)),m=Ar(n),v=l.useRef(!1),g=l.useRef(!0),{viewport:h,selectedItem:b,selectedItemText:w,focusSelectedItem:y}=a,x=l.useCallback(()=>{if(s.trigger&&s.valueNode&&c&&f&&h&&b&&w){const T=s.trigger.getBoundingClientRect(),F=f.getBoundingClientRect(),M=s.valueNode.getBoundingClientRect(),B=w.getBoundingClientRect();if(s.dir!=="rtl"){const be=B.left-F.left,ge=M.left-be,G=T.left-ge,X=T.width+G,ye=Math.max(X,F.width),se=window.innerWidth-Je,Se=es(ge,[Je,Math.max(Je,se-ye)]);c.style.minWidth=X+"px",c.style.left=Se+"px"}else{const be=F.right-B.right,ge=window.innerWidth-M.right-be,G=window.innerWidth-T.right-ge,X=T.width+G,ye=Math.max(X,F.width),se=window.innerWidth-Je,Se=es(ge,[Je,Math.max(Je,se-ye)]);c.style.minWidth=X+"px",c.style.right=Se+"px"}const V=m(),J=window.innerHeight-Je*2,H=h.scrollHeight,O=window.getComputedStyle(f),ne=parseInt(O.borderTopWidth,10),L=parseInt(O.paddingTop,10),z=parseInt(O.borderBottomWidth,10),k=parseInt(O.paddingBottom,10),I=ne+L+H+k+z,Z=Math.min(b.offsetHeight*5,I),j=window.getComputedStyle(h),te=parseInt(j.paddingTop,10),D=parseInt(j.paddingBottom,10),W=T.top+T.height/2-Je,xe=J-W,ie=b.offsetHeight/2,R=b.offsetTop+ie,le=ne+L+R,he=I-le;if(le<=W){const be=V.length>0&&b===V[V.length-1].ref.current;c.style.bottom="0px";const ge=f.clientHeight-h.offsetTop-h.offsetHeight,G=Math.max(xe,ie+(be?D:0)+ge+z),X=le+G;c.style.height=X+"px"}else{const be=V.length>0&&b===V[0].ref.current;c.style.top="0px";const G=Math.max(W,ne+h.offsetTop+(be?te:0)+ie)+he;c.style.height=G+"px",h.scrollTop=le-W+h.offsetTop}c.style.margin=`${Je}px 0`,c.style.minHeight=Z+"px",c.style.maxHeight=J+"px",r==null||r(),requestAnimationFrame(()=>v.current=!0)}},[m,s.trigger,s.valueNode,c,f,h,b,w,s.dir,r]);Ne(()=>x(),[x]);const[C,E]=l.useState();Ne(()=>{f&&E(window.getComputedStyle(f).zIndex)},[f]);const P=l.useCallback(T=>{T&&g.current===!0&&(x(),y==null||y(),g.current=!1)},[x,y]);return i.jsx(cw,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:v,onScrollButtonChange:P,children:i.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:C},children:i.jsx(oe.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ed.displayName=aw;var iw="SelectPopperPosition",hs=l.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Je,...s}=e,a=Ir(n);return i.jsx(Fo,{...a,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});hs.displayName=iw;var[cw,gs]=Yt(Ot,{}),ms="SelectViewport",Nd=l.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=St(ms,n),a=gs(ms,n),c=ue(t,s.onViewportChange),d=l.useRef(0);return i.jsxs(i.Fragment,{children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),i.jsx(Tr.Slot,{scope:n,children:i.jsx(oe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:U(o.onScroll,f=>{const u=f.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=a;if(m!=null&&m.current&&p){const v=Math.abs(d.current-u.scrollTop);if(v>0){const g=window.innerHeight-Je*2,h=parseFloat(p.style.minHeight),b=parseFloat(p.style.height),w=Math.max(h,b);if(w<g){const y=w+v,x=Math.min(g,y),C=y-x;p.style.height=x+"px",p.style.bottom==="0px"&&(u.scrollTop=C>0?C:0,p.style.justifyContent="flex-end")}}}d.current=u.scrollTop})})})]})});Nd.displayName=ms;var Td="SelectGroup",[lw,dw]=Yt(Td),uw=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ge();return i.jsx(lw,{scope:n,id:o,children:i.jsx(oe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});uw.displayName=Td;var Ad="SelectLabel",Id=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=dw(Ad,n);return i.jsx(oe.div,{id:o.id,...r,ref:t})});Id.displayName=Ad;var kr="SelectItem",[fw,kd]=Yt(kr),_d=l.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...a}=e,c=xt(kr,n),d=St(kr,n),f=c.value===r,[u,p]=l.useState(s??""),[m,v]=l.useState(!1),g=ue(t,y=>{var x;return(x=d.itemRefCallback)==null?void 0:x.call(d,y,r,o)}),h=Ge(),b=l.useRef("touch"),w=()=>{o||(c.onValueChange(r),c.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return i.jsx(fw,{scope:n,value:r,disabled:o,textId:h,isSelected:f,onItemTextChange:l.useCallback(y=>{p(x=>x||((y==null?void 0:y.textContent)??"").trim())},[]),children:i.jsx(Tr.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:i.jsx(oe.div,{role:"option","aria-labelledby":h,"data-highlighted":m?"":void 0,"aria-selected":f&&m,"data-state":f?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...a,ref:g,onFocus:U(a.onFocus,()=>v(!0)),onBlur:U(a.onBlur,()=>v(!1)),onClick:U(a.onClick,()=>{b.current!=="mouse"&&w()}),onPointerUp:U(a.onPointerUp,()=>{b.current==="mouse"&&w()}),onPointerDown:U(a.onPointerDown,y=>{b.current=y.pointerType}),onPointerMove:U(a.onPointerMove,y=>{var x;b.current=y.pointerType,o?(x=d.onItemLeave)==null||x.call(d):b.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:U(a.onPointerLeave,y=>{var x;y.currentTarget===document.activeElement&&((x=d.onItemLeave)==null||x.call(d))}),onKeyDown:U(a.onKeyDown,y=>{var C;((C=d.searchRef)==null?void 0:C.current)!==""&&y.key===" "||(Jv.includes(y.key)&&w(),y.key===" "&&y.preventDefault())})})})})});_d.displayName=kr;var Sn="SelectItemText",Pd=l.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,a=xt(Sn,n),c=St(Sn,n),d=kd(Sn,n),f=tw(Sn,n),[u,p]=l.useState(null),m=ue(t,w=>p(w),d.onItemTextChange,w=>{var y;return(y=c.itemTextRefCallback)==null?void 0:y.call(c,w,d.value,d.disabled)}),v=u==null?void 0:u.textContent,g=l.useMemo(()=>i.jsx("option",{value:d.value,disabled:d.disabled,children:v},d.value),[d.disabled,d.value,v]),{onNativeOptionAdd:h,onNativeOptionRemove:b}=f;return Ne(()=>(h(g),()=>b(g)),[h,b,g]),i.jsxs(i.Fragment,{children:[i.jsx(oe.span,{id:d.textId,...s,ref:m}),d.isSelected&&a.valueNode&&!a.valueNodeHasChildren?Tn.createPortal(s.children,a.valueNode):null]})});Pd.displayName=Sn;var Od="SelectItemIndicator",Md=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return kd(Od,n).isSelected?i.jsx(oe.span,{"aria-hidden":!0,...r,ref:t}):null});Md.displayName=Od;var bs="SelectScrollUpButton",Dd=l.forwardRef((e,t)=>{const n=St(bs,e.__scopeSelect),r=gs(bs,e.__scopeSelect),[o,s]=l.useState(!1),a=ue(t,r.onScrollButtonChange);return Ne(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollTop>0;s(f)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?i.jsx(Fd,{...e,ref:a,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});Dd.displayName=bs;var vs="SelectScrollDownButton",Ld=l.forwardRef((e,t)=>{const n=St(vs,e.__scopeSelect),r=gs(vs,e.__scopeSelect),[o,s]=l.useState(!1),a=ue(t,r.onScrollButtonChange);return Ne(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollHeight-d.clientHeight,u=Math.ceil(d.scrollTop)<f;s(u)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?i.jsx(Fd,{...e,ref:a,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});Ld.displayName=vs;var Fd=l.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=St("SelectScrollButton",n),a=l.useRef(null),c=Ar(n),d=l.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return l.useEffect(()=>()=>d(),[d]),Ne(()=>{var u;const f=c().find(p=>p.ref.current===document.activeElement);(u=f==null?void 0:f.ref.current)==null||u.scrollIntoView({block:"nearest"})},[c]),i.jsx(oe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:U(o.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(r,50))}),onPointerMove:U(o.onPointerMove,()=>{var f;(f=s.onItemLeave)==null||f.call(s),a.current===null&&(a.current=window.setInterval(r,50))}),onPointerLeave:U(o.onPointerLeave,()=>{d()})})}),pw="SelectSeparator",$d=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return i.jsx(oe.div,{"aria-hidden":!0,...r,ref:t})});$d.displayName=pw;var ws="SelectArrow",hw=l.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ir(n),s=xt(ws,n),a=St(ws,n);return s.open&&a.position==="popper"?i.jsx($o,{...o,...r,ref:t}):null});hw.displayName=ws;var gw="SelectBubbleInput",Bd=l.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=l.useRef(null),s=ue(r,o),a=id(t);return l.useEffect(()=>{const c=o.current;if(!c)return;const d=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(d,"value").set;if(a!==t&&u){const p=new Event("change",{bubbles:!0});u.call(c,t),c.dispatchEvent(p)}},[a,t]),i.jsx(oe.select,{...n,style:{...Ll,...n.style},ref:s,defaultValue:t})});Bd.displayName=gw;function Ud(e){return e===""||e===void 0}function Hd(e){const t=Ae(e),n=l.useRef(""),r=l.useRef(0),o=l.useCallback(a=>{const c=n.current+a;t(c),function d(f){n.current=f,window.clearTimeout(r.current),f!==""&&(r.current=window.setTimeout(()=>d(""),1e3))}(c)},[t]),s=l.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return l.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function zd(e,t,n){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let a=mw(e,Math.max(s,0));o.length===1&&(a=a.filter(f=>f!==n));const d=a.find(f=>f.textValue.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function mw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var bw=hd,Wd=md,vw=vd,ww=wd,yw=yd,Vd=xd,xw=Nd,jd=Id,Rd=_d,Sw=Pd,Cw=Md,Kd=Dd,Gd=Ld,qd=$d;const Xd=bw,Yd=vw,ys=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(Wd,{ref:r,className:A("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,i.jsx(ww,{asChild:!0,children:i.jsx(q.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ys.displayName=Wd.displayName;const Jd=l.forwardRef(({className:e,...t},n)=>i.jsx(Kd,{ref:n,className:A("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(q.ChevronUp,{className:"h-4 w-4"})}));Jd.displayName=Kd.displayName;const Zd=l.forwardRef(({className:e,...t},n)=>i.jsx(Gd,{ref:n,className:A("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(q.ChevronDown,{className:"h-4 w-4"})}));Zd.displayName=Gd.displayName;const xs=l.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>i.jsx(yw,{children:i.jsxs(Vd,{ref:o,className:A("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[i.jsx(Jd,{}),i.jsx(xw,{className:A("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),i.jsx(Zd,{})]})}));xs.displayName=Vd.displayName;const Ew=l.forwardRef(({className:e,...t},n)=>i.jsx(jd,{ref:n,className:A("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Ew.displayName=jd.displayName;const Mt=l.forwardRef(({className:e,children:t,...n},r)=>i.jsxs(Rd,{ref:r,className:A("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Cw,{children:i.jsx(q.Check,{className:"h-4 w-4"})})}),i.jsx(Sw,{children:t})]}));Mt.displayName=Rd.displayName;const Nw=l.forwardRef(({className:e,...t},n)=>i.jsx(qd,{ref:n,className:A("-mx-1 my-1 h-px bg-muted",e),...t}));Nw.displayName=qd.displayName;const _r=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));_r.displayName="Card";const Pr=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("flex flex-col space-y-1.5 p-6",e),...t}));Pr.displayName="CardHeader";const Or=l.forwardRef(({className:e,...t},n)=>i.jsx("h3",{ref:n,className:A("text-2xl font-semibold leading-none tracking-tight",e),...t}));Or.displayName="CardTitle";const Tw=l.forwardRef(({className:e,...t},n)=>i.jsx("p",{ref:n,className:A("text-sm text-muted-foreground",e),...t}));Tw.displayName="CardDescription";const Mr=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("p-6 pt-0",e),...t}));Mr.displayName="CardContent";const Aw=l.forwardRef(({className:e,...t},n)=>i.jsx("div",{ref:n,className:A("flex items-center p-6 pt-0",e),...t}));Aw.displayName="CardFooter";const Iw=1,kw=1e6;let Ss=0;function _w(){return Ss=(Ss+1)%Number.MAX_SAFE_INTEGER,Ss.toString()}const Cs=new Map,Qd=e=>{if(Cs.has(e))return;const t=setTimeout(()=>{Cs.delete(e),Cn({type:"REMOVE_TOAST",toastId:e})},kw);Cs.set(e,t)},Pw=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Iw)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?Qd(n):e.toasts.forEach(r=>{Qd(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},Dr=[];let Lr={toasts:[]};function Cn(e){Lr=Pw(Lr,e),Dr.forEach(t=>{t(Lr)})}function Ow({...e}){const t=_w(),n=o=>Cn({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Cn({type:"DISMISS_TOAST",toastId:t});return Cn({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Mw(){const[e,t]=l.useState(Lr);return l.useEffect(()=>(Dr.push(t),()=>{const n=Dr.indexOf(t);n>-1&&Dr.splice(n,1)}),[e]),{...e,toast:Ow,dismiss:n=>Cn({type:"DISMISS_TOAST",toastId:n})}}const Dw={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function Lw({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=N.useState(!1),[s,a]=N.useState(!1),[c,d]=N.useState(e),[f,u]=N.useState(!1),{toast:p}=Mw();N.useEffect(()=>{const b=JSON.stringify(c)!==JSON.stringify(e);u(b)},[c,e]),N.useEffect(()=>{d(e)},[e]);const m=()=>{t(c),u(!1),p({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},v=()=>{d(Dw),u(!0),p({title:"Settings reset",description:"Configuration has been reset to defaults."})},g=()=>{d(e),u(!1),o(!1)},h=async()=>{try{const w=await(await fetch(`${c.api.baseUrl}/health`)).json();p({title:"Connection successful",description:`API is ${w.status||"healthy"}`})}catch{p({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return i.jsxs(kl,{open:r,onOpenChange:o,children:[i.jsx(Jb,{asChild:!0,children:i.jsxs(we,{variant:"outline",size:"sm",className:n,children:[i.jsx(q.Settings,{className:"h-4 w-4 mr-2"}),"Settings",f&&i.jsx(Ea,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),i.jsxs(ds,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[i.jsxs(Pl,{children:[i.jsx(Ol,{children:"Chat Settings"}),i.jsx(Ml,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),i.jsxs("div",{className:"space-y-6 py-6",children:[i.jsxs(_r,{children:[i.jsx(Pr,{className:"pb-3",children:i.jsxs(Or,{className:"text-lg flex items-center gap-2",children:[i.jsx(q.Server,{className:"h-5 w-5"}),"API Configuration"]})}),i.jsxs(Mr,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(je,{htmlFor:"api-url",children:"API Base URL"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(wn,{id:"api-url",value:c.api.baseUrl,onChange:b=>d(w=>({...w,api:{...w.api,baseUrl:b.target.value}})),placeholder:"http://localhost:8000/api"}),i.jsx(we,{variant:"outline",onClick:h,children:"Test"})]})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(je,{htmlFor:"enable-auth",children:"Enable Authentication"}),i.jsx(yt,{id:"enable-auth",checked:c.api.enableAuth,onCheckedChange:b=>d(w=>({...w,api:{...w.api,enableAuth:b}}))})]}),c.api.enableAuth&&i.jsxs("div",{className:"space-y-2",children:[i.jsx(je,{htmlFor:"auth-token",children:"Authentication Token"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(wn,{id:"auth-token",type:s?"text":"password",value:c.api.authToken,onChange:b=>d(w=>({...w,api:{...w.api,authToken:b.target.value}})),placeholder:"Enter your Bearer token"}),i.jsx(we,{variant:"outline",size:"icon",onClick:()=>a(!s),children:s?i.jsx(q.EyeOff,{className:"h-4 w-4"}):i.jsx(q.Eye,{className:"h-4 w-4"})})]})]})]})]}),i.jsxs(_r,{children:[i.jsx(Pr,{className:"pb-3",children:i.jsxs(Or,{className:"text-lg flex items-center gap-2",children:[i.jsx(q.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),i.jsxs(Mr,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(je,{htmlFor:"layout",children:"Layout Style"}),i.jsxs(Xd,{value:c.ui.layout,onValueChange:b=>d(w=>({...w,ui:{...w.ui,layout:b}})),children:[i.jsx(ys,{children:i.jsx(Yd,{})}),i.jsxs(xs,{children:[i.jsx(Mt,{value:"sidebar",children:"Sidebar Layout"}),i.jsx(Mt,{value:"fullscreen",children:"Fullscreen"}),i.jsx(Mt,{value:"tabs",children:"Tabbed Interface"})]})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(je,{htmlFor:"theme",children:"Theme"}),i.jsxs(Xd,{value:c.ui.theme,onValueChange:b=>d(w=>({...w,ui:{...w.ui,theme:b}})),children:[i.jsx(ys,{children:i.jsx(Yd,{})}),i.jsxs(xs,{children:[i.jsx(Mt,{value:"light",children:"Light"}),i.jsx(Mt,{value:"dark",children:"Dark"}),i.jsx(Mt,{value:"system",children:"System"})]})]})]}),i.jsx(as,{}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(je,{htmlFor:"show-timestamps",children:"Show Timestamps"}),i.jsx(yt,{id:"show-timestamps",checked:c.ui.showTimestamps,onCheckedChange:b=>d(w=>({...w,ui:{...w.ui,showTimestamps:b}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(je,{htmlFor:"show-agent-names",children:"Show Agent Names"}),i.jsx(yt,{id:"show-agent-names",checked:c.ui.showAgentNames,onCheckedChange:b=>d(w=>({...w,ui:{...w.ui,showAgentNames:b}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(je,{htmlFor:"compact-messages",children:"Compact Messages"}),i.jsx(yt,{id:"compact-messages",checked:c.ui.compactMessages,onCheckedChange:b=>d(w=>({...w,ui:{...w.ui,compactMessages:b}}))})]})]})]})]}),i.jsxs(_r,{children:[i.jsx(Pr,{className:"pb-3",children:i.jsxs(Or,{className:"text-lg flex items-center gap-2",children:[i.jsx(q.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),i.jsxs(Mr,{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx(je,{htmlFor:"auto-save",children:"Auto-save Conversations"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),i.jsx(yt,{id:"auto-save",checked:c.behavior.autoSave,onCheckedChange:b=>d(w=>({...w,behavior:{...w.behavior,autoSave:b}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx(je,{htmlFor:"enable-streaming",children:"Enable Streaming"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),i.jsx(yt,{id:"enable-streaming",checked:c.behavior.enableStreaming,onCheckedChange:b=>d(w=>({...w,behavior:{...w.behavior,enableStreaming:b}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx(je,{htmlFor:"typing-indicator",children:"Typing Indicator"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),i.jsx(yt,{id:"typing-indicator",checked:c.behavior.showTypingIndicator,onCheckedChange:b=>d(w=>({...w,behavior:{...w.behavior,showTypingIndicator:b}}))})]})]})]})]}),i.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[i.jsxs(we,{variant:"outline",onClick:v,children:[i.jsx(q.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(we,{variant:"outline",onClick:g,children:"Cancel"}),i.jsxs(we,{onClick:m,disabled:!f,children:[i.jsx(q.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function Fw({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const a=f=>{const u="h-full";switch(f){case"phone":return`${u} max-w-none`;case"tablet":return`${u} max-w-4xl mx-auto`;case"half-screen":return`${u} max-w-2xl`;case"desktop":default:return`${u} max-w-7xl mx-auto`}},c=f=>({"--chat-sidebar-width":f==="phone"?"100%":f==="tablet"?"280px":f==="half-screen"?"240px":"320px","--chat-message-max-width":f==="phone"?"95%":f==="tablet"?"90%":f==="half-screen"?"85%":"80%","--chat-input-height":f==="phone"?"120px":"100px"}),d=N.useCallback(f=>{var u;(u=s.onThreadChange)==null||u.call(s,f)},[s.onThreadChange]);return e==="fullscreen"?i.jsx(on,{...s,onThreadChange:d,children:i.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:c(t),children:i.jsx(vn,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?i.jsx(on,{...s,onThreadChange:d,children:i.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:c(t),children:i.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&i.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:i.jsx(vr,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),i.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:i.jsx(vn,{onError:s.onError,enableFileUpload:!0})})]})})}):i.jsx(on,{...s,onThreadChange:d,children:i.jsxs("div",{className:`${a(t)} flex overflow-hidden ${r} ${o.container||""}`,style:c(t),children:[n&&i.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:i.jsx(vr,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),i.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:i.jsx(vn,{onError:s.onError,enableFileUpload:!0})})]})})}ae.Api=Bn,ae.ApiClient=Bn,ae.ChatApi=Bn,ae.ChatInterface=vn,ae.ChatMainLayout=Wv,ae.ChatProvider=on,ae.ChatRoutingProvider=Tb,ae.ChatSettings=Lw,ae.MarkdownContent=sn,ae.MessageComponent=Oa,ae.ThreadManager=vr,ae.apiClient=ut,ae.applySettings=Mb,ae.chatApiClient=ut,ae.default=Fw,ae.del=va,ae.get=Tt,ae.getChatToken=ro,ae.getCurrentSettings=Ob,ae.getDefaultApiConfig=rl,ae.getDefaultChatSettings=ol,ae.onChatTokenChanged=ma,ae.post=so,ae.put=ba,ae.setChatToken=oo,ae.stream=If,ae.useChat=co,ae.useChatRouting=Ab,ae.useChatStream=wa,ae.useMessagesReducer=ya,Object.defineProperties(ae,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
62
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return l.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},wb="DialogDescriptionWarning",yb=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Jc(wb).contentName}}.`;return l.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},xb=$c,Sb=Uc,Cb=zc,Zc=Wc,Qc=Rc,el=jc,tl=Gc,Eb=Xc;const rl=xb,Nb=Sb,Tb=Cb,nl=l.forwardRef(({className:e,...t},r)=>i.jsx(Zc,{className:T("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:r}));nl.displayName=Zc.displayName;const Ab=Dt.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Uo=l.forwardRef(({side:e="right",className:t,children:r,...n},o)=>i.jsxs(Tb,{children:[i.jsx(nl,{}),i.jsxs(Qc,{ref:o,className:T(Ab({side:e}),t),...n,children:[r,i.jsxs(Eb,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[i.jsx(X.X,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Uo.displayName=Qc.displayName;const ol=({className:e,...t})=>i.jsx("div",{className:T("flex flex-col space-y-2 text-center sm:text-left",e),...t});ol.displayName="SheetHeader";const sl=l.forwardRef(({className:e,...t},r)=>i.jsx(el,{ref:r,className:T("text-lg font-semibold text-foreground",e),...t}));sl.displayName=el.displayName;const al=l.forwardRef(({className:e,...t},r)=>i.jsx(tl,{ref:r,className:T("text-sm text-muted-foreground",e),...t}));al.displayName=tl.displayName;function il({className:e,...t}){return i.jsx("div",{className:T("animate-pulse rounded-md bg-muted",e),...t})}var cl=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Pb="VisuallyHidden",ll=l.forwardRef((e,t)=>i.jsx(Z.span,{...e,ref:t,style:{...cl,...e.style}}));ll.displayName=Pb;var _b=ll,[tn,Ww]=Oe("Tooltip",[Tt]),rn=Tt(),dl="TooltipProvider",Ib=700,Ho="tooltip.open",[Ob,zo]=tn(dl),ul=e=>{const{__scopeTooltip:t,delayDuration:r=Ib,skipDelayDuration:n=300,disableHoverableContent:o=!1,children:s}=e,a=l.useRef(!0),c=l.useRef(!1),d=l.useRef(0);return l.useEffect(()=>{const f=d.current;return()=>window.clearTimeout(f)},[]),i.jsx(Ob,{scope:t,isOpenDelayedRef:a,delayDuration:r,onOpen:l.useCallback(()=>{window.clearTimeout(d.current),a.current=!1},[]),onClose:l.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>a.current=!0,n)},[n]),isPointerInTransitRef:c,onPointerInTransitChange:l.useCallback(f=>{c.current=f},[]),disableHoverableContent:o,children:s})};ul.displayName=dl;var nr="Tooltip",[Mb,nn]=tn(nr),fl=e=>{const{__scopeTooltip:t,children:r,open:n,defaultOpen:o,onOpenChange:s,disableHoverableContent:a,delayDuration:c}=e,d=zo(nr,e.__scopeTooltip),f=rn(t),[u,p]=l.useState(null),m=Me(),v=l.useRef(0),g=a??d.disableHoverableContent,h=c??d.delayDuration,b=l.useRef(!1),[w,y]=Je({prop:n,defaultProp:o??!1,onChange:N=>{N?(d.onOpen(),document.dispatchEvent(new CustomEvent(Ho))):d.onClose(),s==null||s(N)},caller:nr}),x=l.useMemo(()=>w?b.current?"delayed-open":"instant-open":"closed",[w]),C=l.useCallback(()=>{window.clearTimeout(v.current),v.current=0,b.current=!1,y(!0)},[y]),E=l.useCallback(()=>{window.clearTimeout(v.current),v.current=0,y(!1)},[y]),O=l.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{b.current=!0,y(!0),v.current=0},h)},[h,y]);return l.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),i.jsx(co,{...f,children:i.jsx(Mb,{scope:t,contentId:m,open:w,stateAttribute:x,trigger:u,onTriggerChange:p,onTriggerEnter:l.useCallback(()=>{d.isOpenDelayedRef.current?O():C()},[d.isOpenDelayedRef,O,C]),onTriggerLeave:l.useCallback(()=>{g?E():(window.clearTimeout(v.current),v.current=0)},[E,g]),onOpen:C,onClose:E,disableHoverableContent:g,children:r})})};fl.displayName=nr;var Wo="TooltipTrigger",pl=l.forwardRef((e,t)=>{const{__scopeTooltip:r,...n}=e,o=nn(Wo,r),s=zo(Wo,r),a=rn(r),c=l.useRef(null),d=se(t,c,o.onTriggerChange),f=l.useRef(!1),u=l.useRef(!1),p=l.useCallback(()=>f.current=!1,[]);return l.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),i.jsx(lo,{asChild:!0,...a,children:i.jsx(Z.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...n,ref:d,onPointerMove:z(e.onPointerMove,m=>{m.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),u.current=!0)}),onPointerLeave:z(e.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:z(e.onPointerDown,()=>{o.open&&o.onClose(),f.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:z(e.onFocus,()=>{f.current||o.onOpen()}),onBlur:z(e.onBlur,o.onClose),onClick:z(e.onClick,o.onClose)})})});pl.displayName=Wo;var kb="TooltipPortal",[Rw,Db]=tn(kb,{forceMount:void 0}),Mt="TooltipContent",hl=l.forwardRef((e,t)=>{const r=Db(Mt,e.__scopeTooltip),{forceMount:n=r.forceMount,side:o="top",...s}=e,a=nn(Mt,e.__scopeTooltip);return i.jsx(xe,{present:n||a.open,children:a.disableHoverableContent?i.jsx(gl,{side:o,...s,ref:t}):i.jsx(Lb,{side:o,...s,ref:t})})}),Lb=l.forwardRef((e,t)=>{const r=nn(Mt,e.__scopeTooltip),n=zo(Mt,e.__scopeTooltip),o=l.useRef(null),s=se(t,o),[a,c]=l.useState(null),{trigger:d,onClose:f}=r,u=o.current,{onPointerInTransitChange:p}=n,m=l.useCallback(()=>{c(null),p(!1)},[p]),v=l.useCallback((g,h)=>{const b=g.currentTarget,w={x:g.clientX,y:g.clientY},y=Hb(w,b.getBoundingClientRect()),x=zb(w,y),C=Wb(h.getBoundingClientRect()),E=Vb([...x,...C]);c(E),p(!0)},[p]);return l.useEffect(()=>()=>m(),[m]),l.useEffect(()=>{if(d&&u){const g=b=>v(b,u),h=b=>v(b,d);return d.addEventListener("pointerleave",g),u.addEventListener("pointerleave",h),()=>{d.removeEventListener("pointerleave",g),u.removeEventListener("pointerleave",h)}}},[d,u,v,m]),l.useEffect(()=>{if(a){const g=h=>{const b=h.target,w={x:h.clientX,y:h.clientY},y=(d==null?void 0:d.contains(b))||(u==null?void 0:u.contains(b)),x=!Rb(w,a);y?m():x&&(m(),f())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[d,u,a,f,m]),i.jsx(gl,{...e,ref:s})}),[Fb,$b]=tn(nr,{isInside:!1}),Bb=Se.createSlottable("TooltipContent"),gl=l.forwardRef((e,t)=>{const{__scopeTooltip:r,children:n,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:a,...c}=e,d=nn(Mt,r),f=rn(r),{onClose:u}=d;return l.useEffect(()=>(document.addEventListener(Ho,u),()=>document.removeEventListener(Ho,u)),[u]),l.useEffect(()=>{if(d.trigger){const p=m=>{const v=m.target;v!=null&&v.contains(d.trigger)&&u()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[d.trigger,u]),i.jsx(Vt,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:p=>p.preventDefault(),onDismiss:u,children:i.jsxs(uo,{"data-state":d.stateAttribute,...f,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[i.jsx(Bb,{children:n}),i.jsx(Fb,{scope:r,isInside:!0,children:i.jsx(_b,{id:d.contentId,role:"tooltip",children:o||n})})]})})});hl.displayName=Mt;var ml="TooltipArrow",Ub=l.forwardRef((e,t)=>{const{__scopeTooltip:r,...n}=e,o=rn(r);return $b(ml,r).isInside?null:i.jsx(fo,{...o,...n,ref:t})});Ub.displayName=ml;function Hb(e,t){const r=Math.abs(t.top-e.y),n=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(r,n,o,s)){case s:return"left";case o:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function zb(e,t,r=5){const n=[];switch(t){case"top":n.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":n.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":n.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":n.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return n}function Wb(e){const{top:t,right:r,bottom:n,left:o}=e;return[{x:o,y:t},{x:r,y:t},{x:r,y:n},{x:o,y:n}]}function Rb(e,t){const{x:r,y:n}=e;let o=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const c=t[s],d=t[a],f=c.x,u=c.y,p=d.x,m=d.y;u>n!=m>n&&r<(p-f)*(n-u)/(m-u)+f&&(o=!o)}return o}function Vb(e){const t=e.slice();return t.sort((r,n)=>r.x<n.x?-1:r.x>n.x?1:r.y<n.y?-1:r.y>n.y?1:0),jb(t)}function jb(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const o=e[n];for(;t.length>=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(o.y-a.y)>=(s.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const r=[];for(let n=e.length-1;n>=0;n--){const o=e[n];for(;r.length>=2;){const s=r[r.length-1],a=r[r.length-2];if((s.x-a.x)*(o.y-a.y)>=(s.y-a.y)*(o.x-a.x))r.pop();else break}r.push(o)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}var Kb=ul,Gb=fl,qb=pl,bl=hl;const Xb=Kb,Yb=Gb,Jb=qb,vl=l.forwardRef(({className:e,sideOffset:t=4,...r},n)=>i.jsx(bl,{ref:n,sideOffset:t,className:T("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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",e),...r}));vl.displayName=bl.displayName;const Zb="sidebar:state",Qb=60*60*24*7,ev="16rem",tv="18rem",rv="3rem",nv="b",wl=l.createContext(null);function on(){const e=l.useContext(wl);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const yl=l.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:r,className:n,style:o,children:s,...a},c)=>{const d=cb(),[f,u]=l.useState(!1),[p,m]=l.useState(e),v=t??p,g=l.useCallback(y=>{const x=typeof y=="function"?y(v):y;r?r(x):m(x),document.cookie=`${Zb}=${x}; path=/; max-age=${Qb}`},[r,v]),h=l.useCallback(()=>d?u(y=>!y):g(y=>!y),[d,g,u]);l.useEffect(()=>{const y=x=>{x.key===nv&&(x.metaKey||x.ctrlKey)&&(x.preventDefault(),h())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[h]);const b=v?"expanded":"collapsed",w=l.useMemo(()=>({state:b,open:v,setOpen:g,isMobile:d,openMobile:f,setOpenMobile:u,toggleSidebar:h}),[b,v,g,d,f,u,h]);return i.jsx(wl.Provider,{value:w,children:i.jsx(Xb,{delayDuration:0,children:i.jsx("div",{style:{"--sidebar-width":ev,"--sidebar-width-icon":rv,...o},className:T("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",n),ref:c,...a,children:s})})})});yl.displayName="SidebarProvider";const xl=l.forwardRef(({side:e="left",variant:t="sidebar",collapsible:r="offcanvas",className:n,children:o,...s},a)=>{const{isMobile:c,state:d,openMobile:f,setOpenMobile:u}=on();return r==="none"?i.jsx("div",{className:T("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",n),ref:a,...s,children:o}):c?i.jsx(rl,{open:f,onOpenChange:u,...s,children:i.jsx(Uo,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":tv},side:e,children:i.jsx("div",{className:"flex h-full w-full flex-col",children:o})})}):i.jsxs("div",{ref:a,className:"group peer hidden md:block text-sidebar-foreground","data-state":d,"data-collapsible":d==="collapsed"?r:"","data-variant":t,"data-side":e,children:[i.jsx("div",{className:T("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),i.jsx("div",{className:T("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",n),...s,children:i.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:o})})]})});xl.displayName="Sidebar";const Sl=l.forwardRef(({className:e,onClick:t,...r},n)=>{const{toggleSidebar:o}=on();return i.jsxs(ce,{ref:n,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:T("h-7 w-7",e),onClick:s=>{t==null||t(s),o()},...r,children:[i.jsx(X.PanelLeft,{}),i.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Sl.displayName="SidebarTrigger";const ov=l.forwardRef(({className:e,...t},r)=>{const{toggleSidebar:n}=on();return i.jsx("button",{ref:r,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:n,title:"Toggle Sidebar",className:T("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});ov.displayName="SidebarRail";const Cl=l.forwardRef(({className:e,...t},r)=>i.jsx("main",{ref:r,className:T("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...t}));Cl.displayName="SidebarInset";const sv=l.forwardRef(({className:e,...t},r)=>i.jsx(tr,{ref:r,"data-sidebar":"input",className:T("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));sv.displayName="SidebarInput";const El=l.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-sidebar":"header",className:T("flex flex-col gap-2 p-2",e),...t}));El.displayName="SidebarHeader";const av=l.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-sidebar":"footer",className:T("flex flex-col gap-2 p-2",e),...t}));av.displayName="SidebarFooter";const iv=l.forwardRef(({className:e,...t},r)=>i.jsx(Lo,{ref:r,"data-sidebar":"separator",className:T("mx-2 w-auto bg-sidebar-border",e),...t}));iv.displayName="SidebarSeparator";const Nl=l.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-sidebar":"content",className:T("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Nl.displayName="SidebarContent";const Tl=l.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-sidebar":"group",className:T("relative flex w-full min-w-0 flex-col p-2",e),...t}));Tl.displayName="SidebarGroup";const Al=l.forwardRef(({className:e,asChild:t=!1,...r},n)=>{const o=t?Se.Slot:"div";return i.jsx(o,{ref:n,"data-sidebar":"group-label",className:T("duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...r})});Al.displayName="SidebarGroupLabel";const cv=l.forwardRef(({className:e,asChild:t=!1,...r},n)=>{const o=t?Se.Slot:"button";return i.jsx(o,{ref:n,"data-sidebar":"group-action",className:T("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...r})});cv.displayName="SidebarGroupAction";const Pl=l.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-sidebar":"group-content",className:T("w-full text-sm",e),...t}));Pl.displayName="SidebarGroupContent";const _l=l.forwardRef(({className:e,...t},r)=>i.jsx("ul",{ref:r,"data-sidebar":"menu",className:T("flex w-full min-w-0 flex-col gap-1",e),...t}));_l.displayName="SidebarMenu";const Il=l.forwardRef(({className:e,...t},r)=>i.jsx("li",{ref:r,"data-sidebar":"menu-item",className:T("group/menu-item relative",e),...t}));Il.displayName="SidebarMenuItem";const lv=Dt.cva("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),Ol=l.forwardRef(({asChild:e=!1,isActive:t=!1,variant:r="default",size:n="default",tooltip:o,className:s,...a},c)=>{const d=e?Se.Slot:"button",{isMobile:f,state:u}=on(),p=i.jsx(d,{ref:c,"data-sidebar":"menu-button","data-size":n,"data-active":t,className:T(lv({variant:r,size:n}),s),...a});return o?(typeof o=="string"&&(o={children:o}),i.jsxs(Yb,{children:[i.jsx(Jb,{asChild:!0,children:p}),i.jsx(vl,{side:"right",align:"center",hidden:u!=="collapsed"||f,...o})]})):p});Ol.displayName="SidebarMenuButton";const dv=l.forwardRef(({className:e,asChild:t=!1,showOnHover:r=!1,...n},o)=>{const s=t?Se.Slot:"button";return i.jsx(s,{ref:o,"data-sidebar":"menu-action",className:T("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",r&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),...n})});dv.displayName="SidebarMenuAction";const uv=l.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,"data-sidebar":"menu-badge",className:T("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));uv.displayName="SidebarMenuBadge";const fv=l.forwardRef(({className:e,showIcon:t=!1,...r},n)=>{const o=l.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return i.jsxs("div",{ref:n,"data-sidebar":"menu-skeleton",className:T("rounded-md h-8 flex gap-2 px-2 items-center",e),...r,children:[t&&i.jsx(il,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),i.jsx(il,{className:"h-4 flex-1 max-w-[--skeleton-width]","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":o}})]})});fv.displayName="SidebarMenuSkeleton";const pv=l.forwardRef(({className:e,...t},r)=>i.jsx("ul",{ref:r,"data-sidebar":"menu-sub",className:T("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));pv.displayName="SidebarMenuSub";const hv=l.forwardRef(({...e},t)=>i.jsx("li",{ref:t,...e}));hv.displayName="SidebarMenuSubItem";const gv=l.forwardRef(({asChild:e=!1,size:t="md",isActive:r,className:n,...o},s)=>{const a=e?Se.Slot:"a";return i.jsx(a,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":r,className:T("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",n),...o})});gv.displayName="SidebarMenuSubButton";function mv({header:e,sidebarTitle:t="Threads",showThreads:r=!0,className:n="",sidebarClassName:o="",chatClassName:s="",...a}){return i.jsx(zt,{...a,children:i.jsxs(yl,{className:`w-full ${n}`,children:[i.jsxs(xl,{className:`border-r ${o}`,children:[i.jsx(El,{children:i.jsx(_l,{children:i.jsx(Il,{children:i.jsx(Ol,{size:"lg",children:i.jsx("span",{className:"font-semibold",children:t})})})})}),i.jsx(Nl,{children:r&&i.jsxs(Tl,{children:[i.jsx(Al,{children:"Conversations"}),i.jsx(Pl,{children:i.jsx("div",{className:"px-2 py-1",children:i.jsx(Zr,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-[calc(100vh-12rem)]"})})})]})})]}),i.jsxs(Cl,{children:[i.jsxs("header",{className:"h-14 border-b bg-background/60 backdrop-blur flex items-center gap-2 px-4",children:[i.jsx(Sl,{}),i.jsx("div",{className:"flex-1"}),e]}),i.jsx("main",{className:`flex-1 min-h-0 overflow-hidden ${s}`,children:i.jsx(er,{})})]})]})})}var bv="Label",Ml=l.forwardRef((e,t)=>i.jsx(Z.label,{...e,ref:t,onMouseDown:r=>{var o;r.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));Ml.displayName=bv;var kl=Ml;const vv=Dt.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ae=l.forwardRef(({className:e,...t},r)=>i.jsx(kl,{ref:r,className:T(vv(),e),...t}));Ae.displayName=kl.displayName;function Dl(e){const t=l.useRef({value:e,previous:e});return l.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var sn="Switch",[wv,Vw]=Oe(sn),[yv,xv]=wv(sn),Ll=l.forwardRef((e,t)=>{const{__scopeSwitch:r,name:n,checked:o,defaultChecked:s,required:a,disabled:c,value:d="on",onCheckedChange:f,form:u,...p}=e,[m,v]=l.useState(null),g=se(t,x=>v(x)),h=l.useRef(!1),b=m?u||!!m.closest("form"):!0,[w,y]=Je({prop:o,defaultProp:s??!1,onChange:f,caller:sn});return i.jsxs(yv,{scope:r,checked:w,disabled:c,children:[i.jsx(Z.button,{type:"button",role:"switch","aria-checked":w,"aria-required":a,"data-state":Ul(w),"data-disabled":c?"":void 0,disabled:c,value:d,...p,ref:g,onClick:z(e.onClick,x=>{y(C=>!C),b&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})}),b&&i.jsx(Bl,{control:m,bubbles:!h.current,name:n,value:d,checked:w,required:a,disabled:c,form:u,style:{transform:"translateX(-100%)"}})]})});Ll.displayName=sn;var Fl="SwitchThumb",$l=l.forwardRef((e,t)=>{const{__scopeSwitch:r,...n}=e,o=xv(Fl,r);return i.jsx(Z.span,{"data-state":Ul(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:t})});$l.displayName=Fl;var Sv="SwitchBubbleInput",Bl=l.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:n=!0,...o},s)=>{const a=l.useRef(null),c=se(a,s),d=Dl(r),f=za(t);return l.useEffect(()=>{const u=a.current;if(!u)return;const p=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(p,"checked").set;if(d!==r&&v){const g=new Event("click",{bubbles:n});v.call(u,r),u.dispatchEvent(g)}},[d,r,n]),i.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:c,style:{...o.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Bl.displayName=Sv;function Ul(e){return e?"checked":"unchecked"}var Hl=Ll,Cv=$l;const tt=l.forwardRef(({className:e,...t},r)=>i.jsx(Hl,{className:T("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:r,children:i.jsx(Cv,{className:T("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));tt.displayName=Hl.displayName;var Ev=[" ","Enter","ArrowUp","ArrowDown"],Nv=[" ","Enter"],pt="Select",[an,cn,Tv]=Rn(pt),[kt,jw]=Oe(pt,[Tv,Tt]),ln=Tt(),[Av,rt]=kt(pt),[Pv,_v]=kt(pt),zl=e=>{const{__scopeSelect:t,children:r,open:n,defaultOpen:o,onOpenChange:s,value:a,defaultValue:c,onValueChange:d,dir:f,name:u,autoComplete:p,disabled:m,required:v,form:g}=e,h=ln(t),[b,w]=l.useState(null),[y,x]=l.useState(null),[C,E]=l.useState(!1),O=Sr(f),[N,F]=Je({prop:n,defaultProp:o??!1,onChange:s,caller:pt}),[B,_]=Je({prop:a,defaultProp:c,onChange:d,caller:pt}),U=l.useRef(null),G=b?g||!!b.closest("form"):!0,[L,$]=l.useState(new Set),q=Array.from(L).map(k=>k.props.value).join(";");return i.jsx(co,{...h,children:i.jsxs(Av,{required:v,scope:t,trigger:b,onTriggerChange:w,valueNode:y,onValueNodeChange:x,valueNodeHasChildren:C,onValueNodeHasChildrenChange:E,contentId:Me(),value:B,onValueChange:_,open:N,onOpenChange:F,dir:O,triggerPointerDownPosRef:U,disabled:m,children:[i.jsx(an.Provider,{scope:t,children:i.jsx(Pv,{scope:e.__scopeSelect,onNativeOptionAdd:l.useCallback(k=>{$(V=>new Set(V).add(k))},[]),onNativeOptionRemove:l.useCallback(k=>{$(V=>{const D=new Set(V);return D.delete(k),D})},[]),children:r})}),G?i.jsxs(ud,{"aria-hidden":!0,required:v,tabIndex:-1,name:u,autoComplete:p,value:B,onChange:k=>_(k.target.value),disabled:m,form:g,children:[B===void 0?i.jsx("option",{value:""}):null,Array.from(L)]},q):null]})})};zl.displayName=pt;var Wl="SelectTrigger",Rl=l.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:n=!1,...o}=e,s=ln(r),a=rt(Wl,r),c=a.disabled||n,d=se(t,a.onTriggerChange),f=cn(r),u=l.useRef("touch"),[p,m,v]=pd(h=>{const b=f().filter(x=>!x.disabled),w=b.find(x=>x.value===a.value),y=hd(b,h,w);y!==void 0&&a.onValueChange(y.value)}),g=h=>{c||(a.onOpenChange(!0),v()),h&&(a.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return i.jsx(lo,{asChild:!0,...s,children:i.jsx(Z.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":fd(a.value)?"":void 0,...o,ref:d,onClick:z(o.onClick,h=>{h.currentTarget.focus(),u.current!=="mouse"&&g(h)}),onPointerDown:z(o.onPointerDown,h=>{u.current=h.pointerType;const b=h.target;b.hasPointerCapture(h.pointerId)&&b.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(g(h),h.preventDefault())}),onKeyDown:z(o.onKeyDown,h=>{const b=p.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&m(h.key),!(b&&h.key===" ")&&Ev.includes(h.key)&&(g(),h.preventDefault())})})})});Rl.displayName=Wl;var Vl="SelectValue",jl=l.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,children:s,placeholder:a="",...c}=e,d=rt(Vl,r),{onValueNodeHasChildrenChange:f}=d,u=s!==void 0,p=se(t,d.onValueNodeChange);return he(()=>{f(u)},[f,u]),i.jsx(Z.span,{...c,ref:p,style:{pointerEvents:"none"},children:fd(d.value)?i.jsx(i.Fragment,{children:a}):s})});jl.displayName=Vl;var Iv="SelectIcon",Kl=l.forwardRef((e,t)=>{const{__scopeSelect:r,children:n,...o}=e;return i.jsx(Z.span,{"aria-hidden":!0,...o,ref:t,children:n||"▼"})});Kl.displayName=Iv;var Ov="SelectPortal",Gl=e=>i.jsx(Dr,{asChild:!0,...e});Gl.displayName=Ov;var ht="SelectContent",ql=l.forwardRef((e,t)=>{const r=rt(ht,e.__scopeSelect),[n,o]=l.useState();if(he(()=>{o(new DocumentFragment)},[]),!r.open){const s=n;return s?ar.createPortal(i.jsx(Xl,{scope:e.__scopeSelect,children:i.jsx(an.Slot,{scope:e.__scopeSelect,children:i.jsx("div",{children:e.children})})}),s):null}return i.jsx(Yl,{...e,ref:t})});ql.displayName=ht;var Fe=10,[Xl,nt]=kt(ht),Mv="SelectContentImpl",kv=Se.createSlot("SelectContent.RemoveScroll"),Yl=l.forwardRef((e,t)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:a,side:c,sideOffset:d,align:f,alignOffset:u,arrowPadding:p,collisionBoundary:m,collisionPadding:v,sticky:g,hideWhenDetached:h,avoidCollisions:b,...w}=e,y=rt(ht,r),[x,C]=l.useState(null),[E,O]=l.useState(null),N=se(t,j=>C(j)),[F,B]=l.useState(null),[_,U]=l.useState(null),G=cn(r),[L,$]=l.useState(!1),q=l.useRef(!1);l.useEffect(()=>{if(x)return mo(x)},[x]),Kn();const k=l.useCallback(j=>{const[K,...oe]=G().map(Y=>Y.ref.current),[P]=oe.slice(-1),M=document.activeElement;for(const Y of j)if(Y===M||(Y==null||Y.scrollIntoView({block:"nearest"}),Y===K&&E&&(E.scrollTop=0),Y===P&&E&&(E.scrollTop=E.scrollHeight),Y==null||Y.focus(),document.activeElement!==M))return},[G,E]),V=l.useCallback(()=>k([F,x]),[k,F,x]);l.useEffect(()=>{L&&V()},[L,V]);const{onOpenChange:D,triggerPointerDownPosRef:I}=y;l.useEffect(()=>{if(x){let j={x:0,y:0};const K=P=>{var M,Y;j={x:Math.abs(Math.round(P.pageX)-(((M=I.current)==null?void 0:M.x)??0)),y:Math.abs(Math.round(P.pageY)-(((Y=I.current)==null?void 0:Y.y)??0))}},oe=P=>{j.x<=10&&j.y<=10?P.preventDefault():x.contains(P.target)||D(!1),document.removeEventListener("pointermove",K),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",K),document.addEventListener("pointerup",oe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",K),document.removeEventListener("pointerup",oe,{capture:!0})}}},[x,D,I]),l.useEffect(()=>{const j=()=>D(!1);return window.addEventListener("blur",j),window.addEventListener("resize",j),()=>{window.removeEventListener("blur",j),window.removeEventListener("resize",j)}},[D]);const[J,Q]=pd(j=>{const K=G().filter(M=>!M.disabled),oe=K.find(M=>M.ref.current===document.activeElement),P=hd(K,j,oe);P&&setTimeout(()=>P.ref.current.focus())}),re=l.useCallback((j,K,oe)=>{const P=!q.current&&!oe;(y.value!==void 0&&y.value===K||P)&&(B(j),P&&(q.current=!0))},[y.value]),H=l.useCallback(()=>x==null?void 0:x.focus(),[x]),R=l.useCallback((j,K,oe)=>{const P=!q.current&&!oe;(y.value!==void 0&&y.value===K||P)&&U(j)},[y.value]),ue=n==="popper"?Ro:Jl,de=ue===Ro?{side:c,sideOffset:d,align:f,alignOffset:u,arrowPadding:p,collisionBoundary:m,collisionPadding:v,sticky:g,hideWhenDetached:h,avoidCollisions:b}:{};return i.jsx(Xl,{scope:r,content:x,viewport:E,onViewportChange:O,itemRefCallback:re,selectedItem:F,onItemLeave:H,itemTextRefCallback:R,focusSelectedItem:V,selectedItemText:_,position:n,isPositioned:L,searchRef:J,children:i.jsx(Wr,{as:kv,allowPinchZoom:!0,children:i.jsx(Cr,{asChild:!0,trapped:y.open,onMountAutoFocus:j=>{j.preventDefault()},onUnmountAutoFocus:z(o,j=>{var K;(K=y.trigger)==null||K.focus({preventScroll:!0}),j.preventDefault()}),children:i.jsx(Vt,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:j=>j.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:i.jsx(ue,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:j=>j.preventDefault(),...w,...de,onPlaced:()=>$(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:z(w.onKeyDown,j=>{const K=j.ctrlKey||j.altKey||j.metaKey;if(j.key==="Tab"&&j.preventDefault(),!K&&j.key.length===1&&Q(j.key),["ArrowUp","ArrowDown","Home","End"].includes(j.key)){let P=G().filter(M=>!M.disabled).map(M=>M.ref.current);if(["ArrowUp","End"].includes(j.key)&&(P=P.slice().reverse()),["ArrowUp","ArrowDown"].includes(j.key)){const M=j.target,Y=P.indexOf(M);P=P.slice(Y+1)}setTimeout(()=>k(P)),j.preventDefault()}})})})})})})});Yl.displayName=Mv;var Dv="SelectItemAlignedPosition",Jl=l.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:n,...o}=e,s=rt(ht,r),a=nt(ht,r),[c,d]=l.useState(null),[f,u]=l.useState(null),p=se(t,N=>u(N)),m=cn(r),v=l.useRef(!1),g=l.useRef(!0),{viewport:h,selectedItem:b,selectedItemText:w,focusSelectedItem:y}=a,x=l.useCallback(()=>{if(s.trigger&&s.valueNode&&c&&f&&h&&b&&w){const N=s.trigger.getBoundingClientRect(),F=f.getBoundingClientRect(),B=s.valueNode.getBoundingClientRect(),_=w.getBoundingClientRect();if(s.dir!=="rtl"){const M=_.left-F.left,Y=B.left-M,le=N.left-Y,me=N.width+le,Ke=Math.max(me,F.width),W=window.innerWidth-Fe,ne=_o(Y,[Fe,Math.max(Fe,W-Ke)]);c.style.minWidth=me+"px",c.style.left=ne+"px"}else{const M=F.right-_.right,Y=window.innerWidth-B.right-M,le=window.innerWidth-N.right-Y,me=N.width+le,Ke=Math.max(me,F.width),W=window.innerWidth-Fe,ne=_o(Y,[Fe,Math.max(Fe,W-Ke)]);c.style.minWidth=me+"px",c.style.right=ne+"px"}const U=m(),G=window.innerHeight-Fe*2,L=h.scrollHeight,$=window.getComputedStyle(f),q=parseInt($.borderTopWidth,10),k=parseInt($.paddingTop,10),V=parseInt($.borderBottomWidth,10),D=parseInt($.paddingBottom,10),I=q+k+L+D+V,J=Math.min(b.offsetHeight*5,I),Q=window.getComputedStyle(h),re=parseInt(Q.paddingTop,10),H=parseInt(Q.paddingBottom,10),R=N.top+N.height/2-Fe,ue=G-R,de=b.offsetHeight/2,j=b.offsetTop+de,K=q+k+j,oe=I-K;if(K<=R){const M=U.length>0&&b===U[U.length-1].ref.current;c.style.bottom="0px";const Y=f.clientHeight-h.offsetTop-h.offsetHeight,le=Math.max(ue,de+(M?H:0)+Y+V),me=K+le;c.style.height=me+"px"}else{const M=U.length>0&&b===U[0].ref.current;c.style.top="0px";const le=Math.max(R,q+h.offsetTop+(M?re:0)+de)+oe;c.style.height=le+"px",h.scrollTop=K-R+h.offsetTop}c.style.margin=`${Fe}px 0`,c.style.minHeight=J+"px",c.style.maxHeight=G+"px",n==null||n(),requestAnimationFrame(()=>v.current=!0)}},[m,s.trigger,s.valueNode,c,f,h,b,w,s.dir,n]);he(()=>x(),[x]);const[C,E]=l.useState();he(()=>{f&&E(window.getComputedStyle(f).zIndex)},[f]);const O=l.useCallback(N=>{N&&g.current===!0&&(x(),y==null||y(),g.current=!1)},[x,y]);return i.jsx(Fv,{scope:r,contentWrapper:c,shouldExpandOnScrollRef:v,onScrollButtonChange:O,children:i.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:C},children:i.jsx(Z.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Jl.displayName=Dv;var Lv="SelectPopperPosition",Ro=l.forwardRef((e,t)=>{const{__scopeSelect:r,align:n="start",collisionPadding:o=Fe,...s}=e,a=ln(r);return i.jsx(uo,{...a,...s,ref:t,align:n,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ro.displayName=Lv;var[Fv,Vo]=kt(ht,{}),jo="SelectViewport",Zl=l.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:n,...o}=e,s=nt(jo,r),a=Vo(jo,r),c=se(t,s.onViewportChange),d=l.useRef(0);return i.jsxs(i.Fragment,{children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),i.jsx(an.Slot,{scope:r,children:i.jsx(Z.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:z(o.onScroll,f=>{const u=f.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=a;if(m!=null&&m.current&&p){const v=Math.abs(d.current-u.scrollTop);if(v>0){const g=window.innerHeight-Fe*2,h=parseFloat(p.style.minHeight),b=parseFloat(p.style.height),w=Math.max(h,b);if(w<g){const y=w+v,x=Math.min(g,y),C=y-x;p.style.height=x+"px",p.style.bottom==="0px"&&(u.scrollTop=C>0?C:0,p.style.justifyContent="flex-end")}}}d.current=u.scrollTop})})})]})});Zl.displayName=jo;var Ql="SelectGroup",[$v,Bv]=kt(Ql),Uv=l.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=Me();return i.jsx($v,{scope:r,id:o,children:i.jsx(Z.div,{role:"group","aria-labelledby":o,...n,ref:t})})});Uv.displayName=Ql;var ed="SelectLabel",td=l.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=Bv(ed,r);return i.jsx(Z.div,{id:o.id,...n,ref:t})});td.displayName=ed;var dn="SelectItem",[Hv,rd]=kt(dn),nd=l.forwardRef((e,t)=>{const{__scopeSelect:r,value:n,disabled:o=!1,textValue:s,...a}=e,c=rt(dn,r),d=nt(dn,r),f=c.value===n,[u,p]=l.useState(s??""),[m,v]=l.useState(!1),g=se(t,y=>{var x;return(x=d.itemRefCallback)==null?void 0:x.call(d,y,n,o)}),h=Me(),b=l.useRef("touch"),w=()=>{o||(c.onValueChange(n),c.onOpenChange(!1))};if(n==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return i.jsx(Hv,{scope:r,value:n,disabled:o,textId:h,isSelected:f,onItemTextChange:l.useCallback(y=>{p(x=>x||((y==null?void 0:y.textContent)??"").trim())},[]),children:i.jsx(an.ItemSlot,{scope:r,value:n,disabled:o,textValue:u,children:i.jsx(Z.div,{role:"option","aria-labelledby":h,"data-highlighted":m?"":void 0,"aria-selected":f&&m,"data-state":f?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...a,ref:g,onFocus:z(a.onFocus,()=>v(!0)),onBlur:z(a.onBlur,()=>v(!1)),onClick:z(a.onClick,()=>{b.current!=="mouse"&&w()}),onPointerUp:z(a.onPointerUp,()=>{b.current==="mouse"&&w()}),onPointerDown:z(a.onPointerDown,y=>{b.current=y.pointerType}),onPointerMove:z(a.onPointerMove,y=>{var x;b.current=y.pointerType,o?(x=d.onItemLeave)==null||x.call(d):b.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:z(a.onPointerLeave,y=>{var x;y.currentTarget===document.activeElement&&((x=d.onItemLeave)==null||x.call(d))}),onKeyDown:z(a.onKeyDown,y=>{var C;((C=d.searchRef)==null?void 0:C.current)!==""&&y.key===" "||(Nv.includes(y.key)&&w(),y.key===" "&&y.preventDefault())})})})})});nd.displayName=dn;var or="SelectItemText",od=l.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:o,...s}=e,a=rt(or,r),c=nt(or,r),d=rd(or,r),f=_v(or,r),[u,p]=l.useState(null),m=se(t,w=>p(w),d.onItemTextChange,w=>{var y;return(y=c.itemTextRefCallback)==null?void 0:y.call(c,w,d.value,d.disabled)}),v=u==null?void 0:u.textContent,g=l.useMemo(()=>i.jsx("option",{value:d.value,disabled:d.disabled,children:v},d.value),[d.disabled,d.value,v]),{onNativeOptionAdd:h,onNativeOptionRemove:b}=f;return he(()=>(h(g),()=>b(g)),[h,b,g]),i.jsxs(i.Fragment,{children:[i.jsx(Z.span,{id:d.textId,...s,ref:m}),d.isSelected&&a.valueNode&&!a.valueNodeHasChildren?ar.createPortal(s.children,a.valueNode):null]})});od.displayName=or;var sd="SelectItemIndicator",ad=l.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return rd(sd,r).isSelected?i.jsx(Z.span,{"aria-hidden":!0,...n,ref:t}):null});ad.displayName=sd;var Ko="SelectScrollUpButton",id=l.forwardRef((e,t)=>{const r=nt(Ko,e.__scopeSelect),n=Vo(Ko,e.__scopeSelect),[o,s]=l.useState(!1),a=se(t,n.onScrollButtonChange);return he(()=>{if(r.viewport&&r.isPositioned){let c=function(){const f=d.scrollTop>0;s(f)};const d=r.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[r.viewport,r.isPositioned]),o?i.jsx(ld,{...e,ref:a,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=r;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});id.displayName=Ko;var Go="SelectScrollDownButton",cd=l.forwardRef((e,t)=>{const r=nt(Go,e.__scopeSelect),n=Vo(Go,e.__scopeSelect),[o,s]=l.useState(!1),a=se(t,n.onScrollButtonChange);return he(()=>{if(r.viewport&&r.isPositioned){let c=function(){const f=d.scrollHeight-d.clientHeight,u=Math.ceil(d.scrollTop)<f;s(u)};const d=r.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[r.viewport,r.isPositioned]),o?i.jsx(ld,{...e,ref:a,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=r;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});cd.displayName=Go;var ld=l.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:n,...o}=e,s=nt("SelectScrollButton",r),a=l.useRef(null),c=cn(r),d=l.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return l.useEffect(()=>()=>d(),[d]),he(()=>{var u;const f=c().find(p=>p.ref.current===document.activeElement);(u=f==null?void 0:f.ref.current)==null||u.scrollIntoView({block:"nearest"})},[c]),i.jsx(Z.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:z(o.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(n,50))}),onPointerMove:z(o.onPointerMove,()=>{var f;(f=s.onItemLeave)==null||f.call(s),a.current===null&&(a.current=window.setInterval(n,50))}),onPointerLeave:z(o.onPointerLeave,()=>{d()})})}),zv="SelectSeparator",dd=l.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return i.jsx(Z.div,{"aria-hidden":!0,...n,ref:t})});dd.displayName=zv;var qo="SelectArrow",Wv=l.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,o=ln(r),s=rt(qo,r),a=nt(qo,r);return s.open&&a.position==="popper"?i.jsx(fo,{...o,...n,ref:t}):null});Wv.displayName=qo;var Rv="SelectBubbleInput",ud=l.forwardRef(({__scopeSelect:e,value:t,...r},n)=>{const o=l.useRef(null),s=se(n,o),a=Dl(t);return l.useEffect(()=>{const c=o.current;if(!c)return;const d=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(d,"value").set;if(a!==t&&u){const p=new Event("change",{bubbles:!0});u.call(c,t),c.dispatchEvent(p)}},[a,t]),i.jsx(Z.select,{...r,style:{...cl,...r.style},ref:s,defaultValue:t})});ud.displayName=Rv;function fd(e){return e===""||e===void 0}function pd(e){const t=ge(e),r=l.useRef(""),n=l.useRef(0),o=l.useCallback(a=>{const c=r.current+a;t(c),function d(f){r.current=f,window.clearTimeout(n.current),f!==""&&(n.current=window.setTimeout(()=>d(""),1e3))}(c)},[t]),s=l.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return l.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,o,s]}function hd(e,t,r){const o=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,s=r?e.indexOf(r):-1;let a=Vv(e,Math.max(s,0));o.length===1&&(a=a.filter(f=>f!==r));const d=a.find(f=>f.textValue.toLowerCase().startsWith(o.toLowerCase()));return d!==r?d:void 0}function Vv(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var jv=zl,gd=Rl,Kv=jl,Gv=Kl,qv=Gl,md=ql,Xv=Zl,bd=td,vd=nd,Yv=od,Jv=ad,wd=id,yd=cd,xd=dd;const Sd=jv,Cd=Kv,Xo=l.forwardRef(({className:e,children:t,...r},n)=>i.jsxs(gd,{ref:n,className:T("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...r,children:[t,i.jsx(Gv,{asChild:!0,children:i.jsx(X.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Xo.displayName=gd.displayName;const Ed=l.forwardRef(({className:e,...t},r)=>i.jsx(wd,{ref:r,className:T("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(X.ChevronUp,{className:"h-4 w-4"})}));Ed.displayName=wd.displayName;const Nd=l.forwardRef(({className:e,...t},r)=>i.jsx(yd,{ref:r,className:T("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(X.ChevronDown,{className:"h-4 w-4"})}));Nd.displayName=yd.displayName;const Yo=l.forwardRef(({className:e,children:t,position:r="popper",...n},o)=>i.jsx(qv,{children:i.jsxs(md,{ref:o,className:T("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...n,children:[i.jsx(Ed,{}),i.jsx(Xv,{className:T("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),i.jsx(Nd,{})]})}));Yo.displayName=md.displayName;const Zv=l.forwardRef(({className:e,...t},r)=>i.jsx(bd,{ref:r,className:T("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Zv.displayName=bd.displayName;const gt=l.forwardRef(({className:e,children:t,...r},n)=>i.jsxs(vd,{ref:n,className:T("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[i.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i.jsx(Jv,{children:i.jsx(X.Check,{className:"h-4 w-4"})})}),i.jsx(Yv,{children:t})]}));gt.displayName=vd.displayName;const Qv=l.forwardRef(({className:e,...t},r)=>i.jsx(xd,{ref:r,className:T("-mx-1 my-1 h-px bg-muted",e),...t}));Qv.displayName=xd.displayName;const un=l.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:T("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));un.displayName="Card";const fn=l.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:T("flex flex-col space-y-1.5 p-6",e),...t}));fn.displayName="CardHeader";const pn=l.forwardRef(({className:e,...t},r)=>i.jsx("h3",{ref:r,className:T("text-2xl font-semibold leading-none tracking-tight",e),...t}));pn.displayName="CardTitle";const ew=l.forwardRef(({className:e,...t},r)=>i.jsx("p",{ref:r,className:T("text-sm text-muted-foreground",e),...t}));ew.displayName="CardDescription";const hn=l.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:T("p-6 pt-0",e),...t}));hn.displayName="CardContent";const tw=l.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:T("flex items-center p-6 pt-0",e),...t}));tw.displayName="CardFooter";const rw=1,nw=1e6;let Jo=0;function ow(){return Jo=(Jo+1)%Number.MAX_SAFE_INTEGER,Jo.toString()}const Zo=new Map,Td=e=>{if(Zo.has(e))return;const t=setTimeout(()=>{Zo.delete(e),sr({type:"REMOVE_TOAST",toastId:e})},nw);Zo.set(e,t)},sw=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,rw)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(r=>r.id===t.toast.id?{...r,...t.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=t;return r?Td(r):e.toasts.forEach(n=>{Td(n.id)}),{...e,toasts:e.toasts.map(n=>n.id===r||r===void 0?{...n,open:!1}:n)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(r=>r.id!==t.toastId)}}},gn=[];let mn={toasts:[]};function sr(e){mn=sw(mn,e),gn.forEach(t=>{t(mn)})}function aw({...e}){const t=ow(),r=o=>sr({type:"UPDATE_TOAST",toast:{...o,id:t}}),n=()=>sr({type:"DISMISS_TOAST",toastId:t});return sr({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||n()}}}),{id:t,dismiss:n,update:r}}function iw(){const[e,t]=l.useState(mn);return l.useEffect(()=>(gn.push(t),()=>{const r=gn.indexOf(t);r>-1&&gn.splice(r,1)}),[e]),{...e,toast:aw,dismiss:r=>sr({type:"DISMISS_TOAST",toastId:r})}}const cw={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function lw({settings:e,onSettingsChange:t,className:r=""}){const[n,o]=A.useState(!1),[s,a]=A.useState(!1),[c,d]=A.useState(e),[f,u]=A.useState(!1),{toast:p}=iw();A.useEffect(()=>{const b=JSON.stringify(c)!==JSON.stringify(e);u(b)},[c,e]),A.useEffect(()=>{d(e)},[e]);const m=()=>{t(c),u(!1),p({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},v=()=>{d(cw),u(!0),p({title:"Settings reset",description:"Configuration has been reset to defaults."})},g=()=>{d(e),u(!1),o(!1)},h=async()=>{try{const w=await(await fetch(`${c.api.baseUrl}/health`)).json();p({title:"Connection successful",description:`API is ${w.status||"healthy"}`})}catch{p({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return i.jsxs(rl,{open:n,onOpenChange:o,children:[i.jsx(Nb,{asChild:!0,children:i.jsxs(ce,{variant:"outline",size:"sm",className:r,children:[i.jsx(X.Settings,{className:"h-4 w-4 mr-2"}),"Settings",f&&i.jsx(Js,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),i.jsxs(Uo,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[i.jsxs(ol,{children:[i.jsx(sl,{children:"Chat Settings"}),i.jsx(al,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),i.jsxs("div",{className:"space-y-6 py-6",children:[i.jsxs(un,{children:[i.jsx(fn,{className:"pb-3",children:i.jsxs(pn,{className:"text-lg flex items-center gap-2",children:[i.jsx(X.Server,{className:"h-5 w-5"}),"API Configuration"]})}),i.jsxs(hn,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Ae,{htmlFor:"api-url",children:"API Base URL"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(tr,{id:"api-url",value:c.api.baseUrl,onChange:b=>d(w=>({...w,api:{...w.api,baseUrl:b.target.value}})),placeholder:"http://localhost:8000/api"}),i.jsx(ce,{variant:"outline",onClick:h,children:"Test"})]})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(Ae,{htmlFor:"enable-auth",children:"Enable Authentication"}),i.jsx(tt,{id:"enable-auth",checked:c.api.enableAuth,onCheckedChange:b=>d(w=>({...w,api:{...w.api,enableAuth:b}}))})]}),c.api.enableAuth&&i.jsxs("div",{className:"space-y-2",children:[i.jsx(Ae,{htmlFor:"auth-token",children:"Authentication Token"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(tr,{id:"auth-token",type:s?"text":"password",value:c.api.authToken,onChange:b=>d(w=>({...w,api:{...w.api,authToken:b.target.value}})),placeholder:"Enter your Bearer token"}),i.jsx(ce,{variant:"outline",size:"icon",onClick:()=>a(!s),children:s?i.jsx(X.EyeOff,{className:"h-4 w-4"}):i.jsx(X.Eye,{className:"h-4 w-4"})})]})]})]})]}),i.jsxs(un,{children:[i.jsx(fn,{className:"pb-3",children:i.jsxs(pn,{className:"text-lg flex items-center gap-2",children:[i.jsx(X.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),i.jsxs(hn,{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(Ae,{htmlFor:"layout",children:"Layout Style"}),i.jsxs(Sd,{value:c.ui.layout,onValueChange:b=>d(w=>({...w,ui:{...w.ui,layout:b}})),children:[i.jsx(Xo,{children:i.jsx(Cd,{})}),i.jsxs(Yo,{children:[i.jsx(gt,{value:"sidebar",children:"Sidebar Layout"}),i.jsx(gt,{value:"fullscreen",children:"Fullscreen"}),i.jsx(gt,{value:"tabs",children:"Tabbed Interface"})]})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(Ae,{htmlFor:"theme",children:"Theme"}),i.jsxs(Sd,{value:c.ui.theme,onValueChange:b=>d(w=>({...w,ui:{...w.ui,theme:b}})),children:[i.jsx(Xo,{children:i.jsx(Cd,{})}),i.jsxs(Yo,{children:[i.jsx(gt,{value:"light",children:"Light"}),i.jsx(gt,{value:"dark",children:"Dark"}),i.jsx(gt,{value:"system",children:"System"})]})]})]}),i.jsx(Lo,{}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(Ae,{htmlFor:"show-timestamps",children:"Show Timestamps"}),i.jsx(tt,{id:"show-timestamps",checked:c.ui.showTimestamps,onCheckedChange:b=>d(w=>({...w,ui:{...w.ui,showTimestamps:b}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(Ae,{htmlFor:"show-agent-names",children:"Show Agent Names"}),i.jsx(tt,{id:"show-agent-names",checked:c.ui.showAgentNames,onCheckedChange:b=>d(w=>({...w,ui:{...w.ui,showAgentNames:b}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(Ae,{htmlFor:"compact-messages",children:"Compact Messages"}),i.jsx(tt,{id:"compact-messages",checked:c.ui.compactMessages,onCheckedChange:b=>d(w=>({...w,ui:{...w.ui,compactMessages:b}}))})]})]})]})]}),i.jsxs(un,{children:[i.jsx(fn,{className:"pb-3",children:i.jsxs(pn,{className:"text-lg flex items-center gap-2",children:[i.jsx(X.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),i.jsxs(hn,{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx(Ae,{htmlFor:"auto-save",children:"Auto-save Conversations"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),i.jsx(tt,{id:"auto-save",checked:c.behavior.autoSave,onCheckedChange:b=>d(w=>({...w,behavior:{...w.behavior,autoSave:b}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx(Ae,{htmlFor:"enable-streaming",children:"Enable Streaming"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),i.jsx(tt,{id:"enable-streaming",checked:c.behavior.enableStreaming,onCheckedChange:b=>d(w=>({...w,behavior:{...w.behavior,enableStreaming:b}}))})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx(Ae,{htmlFor:"typing-indicator",children:"Typing Indicator"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),i.jsx(tt,{id:"typing-indicator",checked:c.behavior.showTypingIndicator,onCheckedChange:b=>d(w=>({...w,behavior:{...w.behavior,showTypingIndicator:b}}))})]})]})]})]}),i.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[i.jsxs(ce,{variant:"outline",onClick:v,children:[i.jsx(X.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(ce,{variant:"outline",onClick:g,children:"Cancel"}),i.jsxs(ce,{onClick:m,disabled:!f,children:[i.jsx(X.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function dw({layout:e="sidebar",layoutSize:t="desktop",showThreads:r=!0,className:n="",customStyles:o={},...s}){const a=f=>{const u="h-full";switch(f){case"phone":return`${u} max-w-none`;case"tablet":return`${u} max-w-4xl mx-auto`;case"half-screen":return`${u} max-w-2xl`;case"desktop":default:return`${u} max-w-7xl mx-auto`}},c=f=>({"--chat-sidebar-width":f==="phone"?"100%":f==="tablet"?"280px":f==="half-screen"?"240px":"320px","--chat-message-max-width":f==="phone"?"95%":f==="tablet"?"90%":f==="half-screen"?"85%":"80%","--chat-input-height":f==="phone"?"120px":"100px"}),d=A.useCallback(f=>{var u;(u=s.onThreadChange)==null||u.call(s,f)},[s.onThreadChange]);return e==="fullscreen"?i.jsx(zt,{...s,onThreadChange:d,children:i.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${n} ${o.container||""}`,style:c(t),children:i.jsx(er,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?i.jsx(zt,{...s,onThreadChange:d,children:i.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${n} ${o.container||""}`,style:c(t),children:i.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[r&&i.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:i.jsx(Zr,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),i.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:i.jsx(er,{onError:s.onError,enableFileUpload:!0})})]})})}):i.jsx(zt,{...s,onThreadChange:d,children:i.jsxs("div",{className:`${a(t)} flex overflow-hidden ${n} ${o.container||""}`,style:c(t),children:[r&&i.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:i.jsx(Zr,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),i.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:i.jsx(er,{onError:s.onError,enableFileUpload:!0})})]})})}ee.Api=vr,ee.ApiClient=vr,ee.ChatApi=vr,ee.ChatInterface=er,ee.ChatMainLayout=mv,ee.ChatProvider=zt,ee.ChatRoutingProvider=eb,ee.ChatSettings=lw,ee.MarkdownContent=Wt,ee.MessageComponent=sa,ee.ThreadManager=Zr,ee.apiClient=Ge,ee.applySettings=ib,ee.chatApiClient=Ge,ee.default=dw,ee.del=js,ee.get=ct,ee.getChatToken=Mn,ee.getCurrentSettings=ab,ee.getDefaultApiConfig=Ic,ee.getDefaultChatSettings=Oc,ee.onChatTokenChanged=Rs,ee.post=Dn,ee.put=Vs,ee.setChatToken=kn,ee.stream=nf,ee.useChat=$n,ee.useChatRouting=tb,ee.useChatStream=Ks,ee.useMessagesReducer=Gs,Object.defineProperties(ee,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});