teodor-new-chat-ui 4.3.520 → 4.3.521
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.esm.js +1033 -1026
- package/dist/index.umd.js +20 -20
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(z,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("lucide-react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","lucide-react","react-dom"],w):(z=typeof globalThis<"u"?globalThis:z||self,w(z.NewChatUI={},z.React,z.reactSlot,z.classVarianceAuthority,z.clsx,z.tailwindMerge,z.LucideReact,z.ReactDOM))})(this,function(z,w,Yt,Vr,px,hx,ce,Oo){"use strict";var
|
|
1
|
+
(function(z,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("lucide-react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","lucide-react","react-dom"],w):(z=typeof globalThis<"u"?globalThis:z||self,w(z.NewChatUI={},z.React,z.reactSlot,z.classVarianceAuthority,z.clsx,z.tailwindMerge,z.LucideReact,z.ReactDOM))})(this,function(z,w,Yt,Vr,px,hx,ce,Oo){"use strict";var uN=Object.defineProperty;var dN=(z,w,Yt)=>w in z?uN(z,w,{enumerable:!0,configurable:!0,writable:!0,value:Yt}):z[w]=Yt;var dx=(z,w,Yt)=>dN(z,typeof w!="symbol"?w+"":w,Yt);function rc(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 h=rc(w),Kr=rc(Oo),oc=120;function mx(e){if(!Array.isArray(e))return"";const t=e.filter(r=>!!(r&&r.type==="text")).map(r=>(r.text??"").trim()).filter(Boolean);if(!t.length)return"";const n=t.join(" ").replace(/\s+/g," ").trim();return n?n.length>oc?`${n.slice(0,oc-3)}…`:n:""}function wi(e){return mx(e.content)||""}function gx(e){var n;const t=new Map;for(const r of e){if(!r.checkpointId)continue;const o=(n=r.messages)==null?void 0:n.find(s=>s.role==="user");if(o){const s=wi(o);s&&t.set(r.checkpointId,s)}}return t}function sc(e){const t=new Map,n=[],r=new Map,o=[];for(let c=0;c<e.length;c++){const d=e[c],p=d.checkpointId,m=p??`cp-${c}`,f=d.metadata??{},v=typeof f.step=="number"?f.step:null,g=typeof f.source=="string"?f.source:null;let x=null,y=null;const b=Array.isArray(d.messages)?d.messages:[];for(const T of b)T.role==="user"&&(y||(y=T),T.id&&(x=T.id));const C=d.next&&d.next.length>0?String(d.next[0]):null,k=d.parentConfig??null,S={id:m,step:v,source:g,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,next:C,parentConfig:k,userMessageId:x};if(o.push(S),p&&t.set(p,S),p&&y){const T=wi(y);T&&r.set(p,T)}n.push({id:m,messageId:x,step:v,source:g,createdAt:d.createdAt??null,next:C,parentConfig:k})}const s=new Map;for(const c of o){if(!c.userMessageId)continue;const d=s.get(c.userMessageId)??[];d.push(c),s.set(c.userMessageId,d)}for(const c of s.values()){if(!c.length)continue;c.sort((p,m)=>{const f=p.createdAt?Date.parse(p.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-f});const d=c.length;for(let p=0;p<c.length;p++){const m=c[p];m.attemptCount=d,m.attemptIndex=p,m.isLatestAttempt=p===0}}return{checkpoints:e,checkpointMetaByCheckpointId:t,timeline:n,messagePreviews:r,getLatest:()=>{const c=n[0];if(c)return t.get(c.id)},getCheckpoint:c=>t.get(c),getMessageAttempts:c=>{const d=[];for(const p of t.values())p.userMessageId===c&&d.push(p);return d.length?(d.sort((p,m)=>{const f=typeof p.attemptIndex=="number"?p.attemptIndex:Number.MAX_SAFE_INTEGER,v=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return f-v}),d):[]}}}function ic(e,t,n){if(!e)return{attemptCount:1,attemptIndex:0,attempts:[]};const r=n.getMessageAttempts(e);if(!r.length)return{attemptCount:1,attemptIndex:0,attempts:[]};let o=0;if(t){const s=r.findIndex(i=>i.id===t);s>=0&&(o=s)}return{attemptCount:r.length,attemptIndex:o,attempts:r}}function xx(e,t){return e?t.getCheckpoint(e)??null:null}function ac(e){return w.useMemo(()=>sc(e),[e])}function _n(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Rn(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function lc(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function bi(e){const t=_n(e);if(t)return _n(t.configurable)??t}function Yn(e){const r=[...(Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[]).map((s,i)=>vx(s,i)).filter(s=>!!s)].sort((s,i)=>cc(i.createdAt)-cc(s.createdAt)),o=r[0]??null;return{threadId:(e==null?void 0:e.threadId)??"",latest:o,checkpoints:r,interrupt:(o==null?void 0:o.interrupt)??null}}function vx(e,t){var S,T;if(!e)return null;const r=(Array.isArray((S=e.values)==null?void 0:S.messages)?e.values.messages:[]).map(E=>wx(E)).filter(E=>!!E),o=_n(e.metadata)??{},s=bi(e.config),i=_n(e.parent_config??e.parentConfig),a=bi(i),l=Rn(s,["checkpoint_id","checkpointId"]),c=Rn(s,["checkpoint_ns","checkpointNs"]),d=Rn(a,["checkpoint_id","checkpointId"]),p=Rn(a,["checkpoint_id","checkpointId"])??null,m=Rn(a,["checkpoint_ns","checkpointNs"])??null,f=_n(e.config),v=Array.isArray(e.tasks)?e.tasks.map(E=>({...E})):e.tasks??null,g=Array.isArray(e.next)?[...e.next]:e.next??null,x=typeof e.created_at=="string"&&e.created_at.trim()?e.created_at:typeof e.createdAt=="string"&&e.createdAt.trim()?e.createdAt:new Date(Date.now()-t).toISOString(),y={...o,step:lc(o,["step"])??0,source:Rn(o,["source"])??null},b=r.map(E=>({...E,checkpointId:l??null})),C=(T=e.values)==null?void 0:T.interrupts,k=Array.isArray(e.interrupts)?e.interrupts:Array.isArray(C)?C:[];return{checkpointId:l??null,checkpointNs:c??null,createdAt:x,parentId:d??null,messages:b,nextCursor:p,nextCursorNs:m,interrupt:Cx(r,k,t,l??null),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:v}}function wx(e){var s,i,a;if(!e||typeof e!="object")return null;const t=bx(e);if(!t)return null;const n=Sx(e==null?void 0:e.content);if(!n.length)return null;const r=typeof e.createdAt=="string"?e.createdAt:typeof((s=e.additional_kwargs)==null?void 0:s.created_at)=="string"?(i=e.additional_kwargs)==null?void 0:i.created_at:new Date().toISOString();return{id:typeof e.id=="string"&&e.id.trim()?e.id:`msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`,role:t,name:typeof e.name=="string"?e.name:void 0,model:typeof e.model=="string"?e.model:((a=e.additional_kwargs)==null?void 0:a.model)??void 0,createdAt:r,content:n,additionalKwargs:e.additional_kwargs??void 0,responseMetadata:e.response_metadata??void 0,artifact:e.artifact??void 0,threadId:e.threadId??e.thread_id}}function bx(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&yx(t))return t;const n=typeof e.type=="string"?e.type:void 0;if(!n)return null;switch(n){case"human":return"user";case"ai":return"assistant";case"tool":return"tool";case"system":return"system";default:return null}}function yx(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"||e==="default_message"}function Sx(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function Cx(e,t,n,r,o){const s=t.length,i=Tx(e,n);if(i)return i;for(let a=s-1;a>=0;a-=1){const l=t[a];if(!l||typeof l!="object")continue;const c=l,d=c.value??l;if(d==null)continue;return{id:typeof c.id=="string"&&c.id.trim()?c.id:`interrupt-${r??n}-${a}`,value:d}}return null}function Tx(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function cc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var yi={exports:{}},qr={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -22,22 +22,22 @@
|
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+A+"`."}return""}}function tt(A){return""}var me={};function Oe(A){{var ee=he();if(!ee){var Q=typeof A=="string"?A:A.displayName||A.name;Q&&(ee=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+Q+">.")}return ee}}function qe(A,ee){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var Q=Oe(ee);if(me[Q])return;me[Q]=!0;var le="";A&&A._owner&&A._owner!==qt.current&&(le=" It was passed a child from "+G(A._owner.type)+"."),$e(A),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',Q,le),$e(null)}}function ut(A,ee){{if(typeof A!="object")return;if(dt(A))for(var Q=0;Q<A.length;Q++){var le=A[Q];ne(le)&&qe(le,ee)}else if(ne(A))A._store&&(A._store.validated=!0);else if(A){var xe=x(A);if(typeof xe=="function"&&xe!==A.entries)for(var Ie=xe.call(A),Re;!(Re=Ie.next()).done;)ne(Re.value)&&qe(Re.value,ee)}}}function at(A){{var ee=A.type;if(ee==null||typeof ee=="string")return;var Q;if(typeof ee=="function")Q=ee.propTypes;else if(typeof ee=="object"&&(ee.$$typeof===l||ee.$$typeof===p))Q=ee.propTypes;else return;if(Q){var le=G(ee);vt(Q,A.props,"prop",le,A)}else if(ee.PropTypes!==void 0&&!ct){ct=!0;var xe=G(ee);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",xe||"Unknown")}typeof ee.getDefaultProps=="function"&&!ee.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function lt(A){{for(var ee=Object.keys(A.props),Q=0;Q<ee.length;Q++){var le=ee[Q];if(le!=="children"&&le!=="key"){$e(A),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",le),$e(null);break}}A.ref!==null&&($e(A),b("Invalid attribute `ref` supplied to `React.Fragment`."),$e(null))}}var Et={};function ke(A,ee,Q,le,xe,Ie){{var Re=$(A);if(!Re){var Te="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(Te+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Bt=tt();Bt?Te+=Bt:Te+=he();var gt;A===null?gt="null":dt(A)?gt="array":A!==void 0&&A.$$typeof===t?(gt="<"+(G(A.type)||"Unknown")+" />",Te=" Did you accidentally export a JSX literal instead of a component?"):gt=typeof A,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",gt,Te)}var yt=kt(A,ee,Q,xe,Ie);if(yt==null)return yt;if(Re){var an=ee.children;if(an!==void 0)if(le)if(dt(an)){for(var Wr=0;Wr<an.length;Wr++)ut(an[Wr],A);Object.freeze&&Object.freeze(an)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ut(an,A)}if(We.call(ee,"key")){var gr=G(A),Gt=Object.keys(ee).filter(function(
|
|
25
|
+
Check the top-level render call using <`+Q+">.")}return ee}}function qe(A,ee){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var Q=Oe(ee);if(me[Q])return;me[Q]=!0;var le="";A&&A._owner&&A._owner!==qt.current&&(le=" It was passed a child from "+G(A._owner.type)+"."),$e(A),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',Q,le),$e(null)}}function ut(A,ee){{if(typeof A!="object")return;if(dt(A))for(var Q=0;Q<A.length;Q++){var le=A[Q];ne(le)&&qe(le,ee)}else if(ne(A))A._store&&(A._store.validated=!0);else if(A){var xe=x(A);if(typeof xe=="function"&&xe!==A.entries)for(var Ie=xe.call(A),Re;!(Re=Ie.next()).done;)ne(Re.value)&&qe(Re.value,ee)}}}function at(A){{var ee=A.type;if(ee==null||typeof ee=="string")return;var Q;if(typeof ee=="function")Q=ee.propTypes;else if(typeof ee=="object"&&(ee.$$typeof===l||ee.$$typeof===p))Q=ee.propTypes;else return;if(Q){var le=G(ee);vt(Q,A.props,"prop",le,A)}else if(ee.PropTypes!==void 0&&!ct){ct=!0;var xe=G(ee);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",xe||"Unknown")}typeof ee.getDefaultProps=="function"&&!ee.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function lt(A){{for(var ee=Object.keys(A.props),Q=0;Q<ee.length;Q++){var le=ee[Q];if(le!=="children"&&le!=="key"){$e(A),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",le),$e(null);break}}A.ref!==null&&($e(A),b("Invalid attribute `ref` supplied to `React.Fragment`."),$e(null))}}var Et={};function ke(A,ee,Q,le,xe,Ie){{var Re=$(A);if(!Re){var Te="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(Te+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Bt=tt();Bt?Te+=Bt:Te+=he();var gt;A===null?gt="null":dt(A)?gt="array":A!==void 0&&A.$$typeof===t?(gt="<"+(G(A.type)||"Unknown")+" />",Te=" Did you accidentally export a JSX literal instead of a component?"):gt=typeof A,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",gt,Te)}var yt=kt(A,ee,Q,xe,Ie);if(yt==null)return yt;if(Re){var an=ee.children;if(an!==void 0)if(le)if(dt(an)){for(var Wr=0;Wr<an.length;Wr++)ut(an[Wr],A);Object.freeze&&Object.freeze(an)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ut(an,A)}if(We.call(ee,"key")){var gr=G(A),Gt=Object.keys(ee).filter(function(cN){return cN!=="key"}),nc=Gt.length>0?"{key: someKey, "+Gt.join(": ..., ")+": ...}":"{key: someKey}";if(!Et[gr+nc]){var lN=Gt.length>0?"{"+Gt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,nc,gr,aN,gr),Et[gr+nc]=!0}}return A===r?lt(yt):at(yt),yt}}function Ee(A,ee,Q){return ke(A,ee,Q,!0)}function be(A,ee,Q){return ke(A,ee,Q,!1)}var Xe=be,At=Ee;Gr.Fragment=r,Gr.jsx=Xe,Gr.jsxs=At}()),Gr}process.env.NODE_ENV==="production"?yi.exports=kx():yi.exports=Ex();var u=yi.exports;const Ix=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=w.useMemo(()=>l?[...a].reverse():[],[a,l]),d=t??(a.length?a[a.length-1].id:null);if(!l)return null;const m=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return u.jsxs("div",{className:m,onMouseEnter:s,onMouseLeave:i,children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:u.jsx("span",{children:"Timeline"})}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:c.map(f=>{const v=d===f.id,g=(r==null?void 0:r.get(f.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(f.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:f.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[f.step!==null?`STEP ${f.step}`:"STEP —",f.next?` - ${f.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},f.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function fc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Nx}=Object.prototype,{getPrototypeOf:Si}=Object,{iterator:Do,toStringTag:pc}=Symbol,Lo=(e=>t=>{const n=Nx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ln=e=>(e=e.toLowerCase(),t=>Lo(t)===e),$o=e=>t=>typeof t===e,{isArray:xr}=Array,vr=$o("undefined");function Yr(e){return e!==null&&!vr(e)&&e.constructor!==null&&!vr(e.constructor)&&zt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const hc=ln("ArrayBuffer");function Ax(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&hc(e.buffer),t}const Px=$o("string"),zt=$o("function"),mc=$o("number"),Xr=e=>e!==null&&typeof e=="object",jx=e=>e===!0||e===!1,Fo=e=>{if(Lo(e)!=="object")return!1;const t=Si(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(pc in e)&&!(Do in e)},_x=e=>{if(!Xr(e)||Yr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Rx=ln("Date"),Mx=ln("File"),Ox=ln("Blob"),Dx=ln("FileList"),Lx=e=>Xr(e)&&zt(e.pipe),$x=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||zt(e.append)&&((t=Lo(e))==="formdata"||t==="object"&&zt(e.toString)&&e.toString()==="[object FormData]"))},Fx=ln("URLSearchParams"),[Bx,zx,Hx,Ux]=["ReadableStream","Request","Response","Headers"].map(ln),Wx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Jr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),xr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Yr(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(r=0;r<i;r++)a=s[r],t.call(null,e[a],a,e)}}function gc(e,t){if(Yr(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 Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,xc=e=>!vr(e)&&e!==Xn;function Ci(){const{caseless:e,skipUndefined:t}=xc(this)&&this||{},n={},r=(o,s)=>{const i=e&&gc(n,s)||s;Fo(n[i])&&Fo(o)?n[i]=Ci(n[i],o):Fo(o)?n[i]=Ci({},o):xr(o)?n[i]=o.slice():(!t||!vr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Jr(arguments[o],r);return n}const Vx=(e,t,n,{allOwnKeys:r}={})=>(Jr(t,(o,s)=>{n&&zt(o)?e[s]=fc(o,n):e[s]=o},{allOwnKeys:r}),e),Kx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),qx=(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)},Gx=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&Si(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Yx=(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},Xx=e=>{if(!e)return null;if(xr(e))return e;let t=e.length;if(!mc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Jx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Si(Uint8Array)),Zx=(e,t)=>{const r=(e&&e[Do]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Qx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},ev=ln("HTMLFormElement"),tv=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),vc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),nv=ln("RegExp"),wc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Jr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},rv=e=>{wc(e,(t,n)=>{if(zt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(zt(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+"'")})}})},ov=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return xr(e)?r(e):r(String(e).split(t)),n},sv=()=>{},iv=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function av(e){return!!(e&&zt(e.append)&&e[pc]==="FormData"&&e[Do])}const lv=e=>{const t=new Array(10),n=(r,o)=>{if(Xr(r)){if(t.indexOf(r)>=0)return;if(Yr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=xr(r)?[]:{};return Jr(r,(i,a)=>{const l=n(i,o+1);!vr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},cv=ln("AsyncFunction"),uv=e=>e&&(Xr(e)||zt(e))&&zt(e.then)&&zt(e.catch),bc=((e,t)=>e?setImmediate:t?((n,r)=>(Xn.addEventListener("message",({source:o,data:s})=>{o===Xn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Xn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",zt(Xn.postMessage)),dv=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||bc,W={isArray:xr,isArrayBuffer:hc,isBuffer:Yr,isFormData:$x,isArrayBufferView:Ax,isString:Px,isNumber:mc,isBoolean:jx,isObject:Xr,isPlainObject:Fo,isEmptyObject:_x,isReadableStream:Bx,isRequest:zx,isResponse:Hx,isHeaders:Ux,isUndefined:vr,isDate:Rx,isFile:Mx,isBlob:Ox,isRegExp:nv,isFunction:zt,isStream:Lx,isURLSearchParams:Fx,isTypedArray:Jx,isFileList:Dx,forEach:Jr,merge:Ci,extend:Vx,trim:Wx,stripBOM:Kx,inherits:qx,toFlatObject:Gx,kindOf:Lo,kindOfTest:ln,endsWith:Yx,toArray:Xx,forEachEntry:Zx,matchAll:Qx,isHTMLForm:ev,hasOwnProperty:vc,hasOwnProp:vc,reduceDescriptors:wc,freezeMethods:rv,toObjectSet:ov,toCamelCase:tv,noop:sv,toFiniteNumber:iv,findKey:gc,global:Xn,isContextDefined:xc,isSpecCompliantForm:av,toJSONObject:lv,isAsyncFn:cv,isThenable:uv,setImmediate:bc,asap:dv,isIterable:e=>e!=null&&zt(e[Do])};function Pe(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)}W.inherits(Pe,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:W.toJSONObject(this.config),code:this.code,status:this.status}}});const yc=Pe.prototype,Sc={};["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=>{Sc[e]={value:e}}),Object.defineProperties(Pe,Sc),Object.defineProperty(yc,"isAxiosError",{value:!0}),Pe.from=(e,t,n,r,o,s)=>{const i=Object.create(yc);W.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Pe.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const fv=null;function Ti(e){return W.isPlainObject(e)||W.isArray(e)}function Cc(e){return W.endsWith(e,"[]")?e.slice(0,-2):e}function Tc(e,t,n){return e?e.concat(t).map(function(o,s){return o=Cc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function pv(e){return W.isArray(e)&&!e.some(Ti)}const hv=W.toFlatObject(W,{},null,function(t){return/^is[A-Z]/.test(t)});function Bo(e,t,n){if(!W.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=W.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!W.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&W.isSpecCompliantForm(t);if(!W.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(W.isDate(v))return v.toISOString();if(W.isBoolean(v))return v.toString();if(!l&&W.isBlob(v))throw new Pe("Blob is not supported. Use a Buffer instead.");return W.isArrayBuffer(v)||W.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,x){let y=v;if(v&&!x&&typeof v=="object"){if(W.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(W.isArray(v)&&pv(v)||(W.isFileList(v)||W.endsWith(g,"[]"))&&(y=W.toArray(v)))return g=Cc(g),y.forEach(function(C,k){!(W.isUndefined(C)||C===null)&&t.append(i===!0?Tc([g],k,s):i===null?g:g+"[]",c(C))}),!1}return Ti(v)?!0:(t.append(Tc(x,g,s),c(v)),!1)}const p=[],m=Object.assign(hv,{defaultVisitor:d,convertValue:c,isVisitable:Ti});function f(v,g){if(!W.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(v),W.forEach(v,function(y,b){(!(W.isUndefined(y)||y===null)&&o.call(t,y,W.isString(b)?b.trim():b,g,m))===!0&&f(y,g?g.concat(b):[b])}),p.pop()}}if(!W.isObject(e))throw new TypeError("data must be an object");return f(e),t}function kc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ki(e,t){this._pairs=[],e&&Bo(e,this,t)}const Ec=ki.prototype;Ec.append=function(t,n){this._pairs.push([t,n])},Ec.toString=function(t){const n=t?function(r){return t.call(this,r,kc)}:kc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function mv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Ic(e,t,n){if(!t)return e;const r=n&&n.encode||mv;W.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=W.isURLSearchParams(t)?t.toString():new ki(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Nc{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){W.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ac={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},gv={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ki,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ei=typeof window<"u"&&typeof document<"u",Ii=typeof navigator=="object"&&navigator||void 0,xv=Ei&&(!Ii||["ReactNative","NativeScript","NS"].indexOf(Ii.product)<0),vv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",wv=Ei&&window.location.href||"http://localhost",jt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ei,hasStandardBrowserEnv:xv,hasStandardBrowserWebWorkerEnv:vv,navigator:Ii,origin:wv},Symbol.toStringTag,{value:"Module"})),...gv};function bv(e,t){return Bo(e,new jt.classes.URLSearchParams,{visitor:function(n,r,o,s){return jt.isNode&&W.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function yv(e){return W.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Sv(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 Pc(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&W.isArray(o)?o.length:i,l?(W.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!W.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&W.isArray(o[i])&&(o[i]=Sv(o[i])),!a)}if(W.isFormData(e)&&W.isFunction(e.entries)){const n={};return W.forEachEntry(e,(r,o)=>{t(yv(r),o,n,0)}),n}return null}function Cv(e,t,n){if(W.isString(e))try{return(t||JSON.parse)(e),W.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Zr={transitional:Ac,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=W.isObject(t);if(s&&W.isHTMLForm(t)&&(t=new FormData(t)),W.isFormData(t))return o?JSON.stringify(Pc(t)):t;if(W.isArrayBuffer(t)||W.isBuffer(t)||W.isStream(t)||W.isFile(t)||W.isBlob(t)||W.isReadableStream(t))return t;if(W.isArrayBufferView(t))return t.buffer;if(W.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return bv(t,this.formSerializer).toString();if((a=W.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Bo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Cv(t)):t}],transformResponse:[function(t){const n=this.transitional||Zr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(W.isResponse(t)||W.isReadableStream(t))return t;if(t&&W.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Pe.from(a,Pe.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:jt.classes.FormData,Blob:jt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};W.forEach(["delete","get","head","post","put","patch"],e=>{Zr.headers[e]={}});const Tv=W.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"]),kv=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
30
|
+
<%s key={someKey} {...props} />`,nc,gr,lN,gr),Et[gr+nc]=!0}}return A===r?lt(yt):at(yt),yt}}function Ee(A,ee,Q){return ke(A,ee,Q,!0)}function be(A,ee,Q){return ke(A,ee,Q,!1)}var Xe=be,At=Ee;Gr.Fragment=r,Gr.jsx=Xe,Gr.jsxs=At}()),Gr}process.env.NODE_ENV==="production"?yi.exports=kx():yi.exports=Ex();var u=yi.exports;const Ix=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=w.useMemo(()=>l?[...a].reverse():[],[a,l]),d=t??(a.length?a[a.length-1].id:null);if(!l)return null;const m=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return u.jsxs("div",{className:m,onMouseEnter:s,onMouseLeave:i,children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:u.jsx("span",{children:"Timeline"})}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:c.map(f=>{const v=d===f.id,g=(r==null?void 0:r.get(f.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(f.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:f.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[f.step!==null?`STEP ${f.step}`:"STEP —",f.next?` - ${f.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},f.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function fc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Nx}=Object.prototype,{getPrototypeOf:Si}=Object,{iterator:Do,toStringTag:pc}=Symbol,Lo=(e=>t=>{const n=Nx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ln=e=>(e=e.toLowerCase(),t=>Lo(t)===e),$o=e=>t=>typeof t===e,{isArray:xr}=Array,vr=$o("undefined");function Yr(e){return e!==null&&!vr(e)&&e.constructor!==null&&!vr(e.constructor)&&zt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const hc=ln("ArrayBuffer");function Ax(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&hc(e.buffer),t}const Px=$o("string"),zt=$o("function"),mc=$o("number"),Xr=e=>e!==null&&typeof e=="object",jx=e=>e===!0||e===!1,Fo=e=>{if(Lo(e)!=="object")return!1;const t=Si(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(pc in e)&&!(Do in e)},_x=e=>{if(!Xr(e)||Yr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Rx=ln("Date"),Mx=ln("File"),Ox=ln("Blob"),Dx=ln("FileList"),Lx=e=>Xr(e)&&zt(e.pipe),$x=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||zt(e.append)&&((t=Lo(e))==="formdata"||t==="object"&&zt(e.toString)&&e.toString()==="[object FormData]"))},Fx=ln("URLSearchParams"),[Bx,zx,Hx,Ux]=["ReadableStream","Request","Response","Headers"].map(ln),Wx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Jr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),xr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Yr(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(r=0;r<i;r++)a=s[r],t.call(null,e[a],a,e)}}function gc(e,t){if(Yr(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 Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,xc=e=>!vr(e)&&e!==Xn;function Ci(){const{caseless:e,skipUndefined:t}=xc(this)&&this||{},n={},r=(o,s)=>{const i=e&&gc(n,s)||s;Fo(n[i])&&Fo(o)?n[i]=Ci(n[i],o):Fo(o)?n[i]=Ci({},o):xr(o)?n[i]=o.slice():(!t||!vr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Jr(arguments[o],r);return n}const Vx=(e,t,n,{allOwnKeys:r}={})=>(Jr(t,(o,s)=>{n&&zt(o)?e[s]=fc(o,n):e[s]=o},{allOwnKeys:r}),e),Kx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),qx=(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)},Gx=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&Si(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Yx=(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},Xx=e=>{if(!e)return null;if(xr(e))return e;let t=e.length;if(!mc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Jx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Si(Uint8Array)),Zx=(e,t)=>{const r=(e&&e[Do]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Qx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},ev=ln("HTMLFormElement"),tv=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),vc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),nv=ln("RegExp"),wc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Jr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},rv=e=>{wc(e,(t,n)=>{if(zt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(zt(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+"'")})}})},ov=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return xr(e)?r(e):r(String(e).split(t)),n},sv=()=>{},iv=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function av(e){return!!(e&&zt(e.append)&&e[pc]==="FormData"&&e[Do])}const lv=e=>{const t=new Array(10),n=(r,o)=>{if(Xr(r)){if(t.indexOf(r)>=0)return;if(Yr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=xr(r)?[]:{};return Jr(r,(i,a)=>{const l=n(i,o+1);!vr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},cv=ln("AsyncFunction"),uv=e=>e&&(Xr(e)||zt(e))&&zt(e.then)&&zt(e.catch),bc=((e,t)=>e?setImmediate:t?((n,r)=>(Xn.addEventListener("message",({source:o,data:s})=>{o===Xn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Xn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",zt(Xn.postMessage)),dv=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||bc,W={isArray:xr,isArrayBuffer:hc,isBuffer:Yr,isFormData:$x,isArrayBufferView:Ax,isString:Px,isNumber:mc,isBoolean:jx,isObject:Xr,isPlainObject:Fo,isEmptyObject:_x,isReadableStream:Bx,isRequest:zx,isResponse:Hx,isHeaders:Ux,isUndefined:vr,isDate:Rx,isFile:Mx,isBlob:Ox,isRegExp:nv,isFunction:zt,isStream:Lx,isURLSearchParams:Fx,isTypedArray:Jx,isFileList:Dx,forEach:Jr,merge:Ci,extend:Vx,trim:Wx,stripBOM:Kx,inherits:qx,toFlatObject:Gx,kindOf:Lo,kindOfTest:ln,endsWith:Yx,toArray:Xx,forEachEntry:Zx,matchAll:Qx,isHTMLForm:ev,hasOwnProperty:vc,hasOwnProp:vc,reduceDescriptors:wc,freezeMethods:rv,toObjectSet:ov,toCamelCase:tv,noop:sv,toFiniteNumber:iv,findKey:gc,global:Xn,isContextDefined:xc,isSpecCompliantForm:av,toJSONObject:lv,isAsyncFn:cv,isThenable:uv,setImmediate:bc,asap:dv,isIterable:e=>e!=null&&zt(e[Do])};function Pe(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)}W.inherits(Pe,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:W.toJSONObject(this.config),code:this.code,status:this.status}}});const yc=Pe.prototype,Sc={};["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=>{Sc[e]={value:e}}),Object.defineProperties(Pe,Sc),Object.defineProperty(yc,"isAxiosError",{value:!0}),Pe.from=(e,t,n,r,o,s)=>{const i=Object.create(yc);W.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Pe.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const fv=null;function Ti(e){return W.isPlainObject(e)||W.isArray(e)}function Cc(e){return W.endsWith(e,"[]")?e.slice(0,-2):e}function Tc(e,t,n){return e?e.concat(t).map(function(o,s){return o=Cc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function pv(e){return W.isArray(e)&&!e.some(Ti)}const hv=W.toFlatObject(W,{},null,function(t){return/^is[A-Z]/.test(t)});function Bo(e,t,n){if(!W.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=W.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!W.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&W.isSpecCompliantForm(t);if(!W.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(W.isDate(v))return v.toISOString();if(W.isBoolean(v))return v.toString();if(!l&&W.isBlob(v))throw new Pe("Blob is not supported. Use a Buffer instead.");return W.isArrayBuffer(v)||W.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,x){let y=v;if(v&&!x&&typeof v=="object"){if(W.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(W.isArray(v)&&pv(v)||(W.isFileList(v)||W.endsWith(g,"[]"))&&(y=W.toArray(v)))return g=Cc(g),y.forEach(function(C,k){!(W.isUndefined(C)||C===null)&&t.append(i===!0?Tc([g],k,s):i===null?g:g+"[]",c(C))}),!1}return Ti(v)?!0:(t.append(Tc(x,g,s),c(v)),!1)}const p=[],m=Object.assign(hv,{defaultVisitor:d,convertValue:c,isVisitable:Ti});function f(v,g){if(!W.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(v),W.forEach(v,function(y,b){(!(W.isUndefined(y)||y===null)&&o.call(t,y,W.isString(b)?b.trim():b,g,m))===!0&&f(y,g?g.concat(b):[b])}),p.pop()}}if(!W.isObject(e))throw new TypeError("data must be an object");return f(e),t}function kc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ki(e,t){this._pairs=[],e&&Bo(e,this,t)}const Ec=ki.prototype;Ec.append=function(t,n){this._pairs.push([t,n])},Ec.toString=function(t){const n=t?function(r){return t.call(this,r,kc)}:kc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function mv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Ic(e,t,n){if(!t)return e;const r=n&&n.encode||mv;W.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=W.isURLSearchParams(t)?t.toString():new ki(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Nc{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){W.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ac={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},gv={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ki,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ei=typeof window<"u"&&typeof document<"u",Ii=typeof navigator=="object"&&navigator||void 0,xv=Ei&&(!Ii||["ReactNative","NativeScript","NS"].indexOf(Ii.product)<0),vv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",wv=Ei&&window.location.href||"http://localhost",jt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ei,hasStandardBrowserEnv:xv,hasStandardBrowserWebWorkerEnv:vv,navigator:Ii,origin:wv},Symbol.toStringTag,{value:"Module"})),...gv};function bv(e,t){return Bo(e,new jt.classes.URLSearchParams,{visitor:function(n,r,o,s){return jt.isNode&&W.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function yv(e){return W.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Sv(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 Pc(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&W.isArray(o)?o.length:i,l?(W.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!W.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&W.isArray(o[i])&&(o[i]=Sv(o[i])),!a)}if(W.isFormData(e)&&W.isFunction(e.entries)){const n={};return W.forEachEntry(e,(r,o)=>{t(yv(r),o,n,0)}),n}return null}function Cv(e,t,n){if(W.isString(e))try{return(t||JSON.parse)(e),W.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Zr={transitional:Ac,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=W.isObject(t);if(s&&W.isHTMLForm(t)&&(t=new FormData(t)),W.isFormData(t))return o?JSON.stringify(Pc(t)):t;if(W.isArrayBuffer(t)||W.isBuffer(t)||W.isStream(t)||W.isFile(t)||W.isBlob(t)||W.isReadableStream(t))return t;if(W.isArrayBufferView(t))return t.buffer;if(W.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return bv(t,this.formSerializer).toString();if((a=W.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Bo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Cv(t)):t}],transformResponse:[function(t){const n=this.transitional||Zr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(W.isResponse(t)||W.isReadableStream(t))return t;if(t&&W.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Pe.from(a,Pe.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:jt.classes.FormData,Blob:jt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};W.forEach(["delete","get","head","post","put","patch"],e=>{Zr.headers[e]={}});const Tv=W.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"]),kv=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
31
31
|
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&Tv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},jc=Symbol("internals");function Qr(e){return e&&String(e).trim().toLowerCase()}function zo(e){return e===!1||e==null?e:W.isArray(e)?e.map(zo):String(e)}function Ev(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 Iv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ni(e,t,n,r,o){if(W.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!W.isString(t)){if(W.isString(r))return t.indexOf(r)!==-1;if(W.isRegExp(r))return r.test(t)}}function Nv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Av(e,t){const n=W.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let Ht=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Qr(l);if(!d)throw new Error("header name must be a non-empty string");const p=W.findKey(o,d);(!p||o[p]===void 0||c===!0||c===void 0&&o[p]!==!1)&&(o[p||l]=zo(a))}const i=(a,l)=>W.forEach(a,(c,d)=>s(c,d,l));if(W.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(W.isString(t)&&(t=t.trim())&&!Iv(t))i(kv(t),n);else if(W.isObject(t)&&W.isIterable(t)){let a={},l,c;for(const d of t){if(!W.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?W.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Qr(t),t){const r=W.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Ev(o);if(W.isFunction(n))return n.call(this,o,r);if(W.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Qr(t),t){const r=W.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Ni(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Qr(i),i){const a=W.findKey(r,i);a&&(!n||Ni(r,r[a],a,n))&&(delete r[a],o=!0)}}return W.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||Ni(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return W.forEach(this,(o,s)=>{const i=W.findKey(r,s);if(i){n[i]=zo(o),delete n[s];return}const a=t?Nv(s):String(s).trim();a!==s&&delete n[s],n[a]=zo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return W.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&W.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(`
|
|
32
32
|
`)}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[jc]=this[jc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Qr(i);r[a]||(Av(o,i),r[a]=!0)}return W.isArray(t)?t.forEach(s):s(t),this}};Ht.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),W.reduceDescriptors(Ht.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),W.freezeMethods(Ht);function Ai(e,t){const n=this||Zr,r=t||n,o=Ht.from(r.headers);let s=r.data;return W.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function _c(e){return!!(e&&e.__CANCEL__)}function wr(e,t,n){Pe.call(this,e??"canceled",Pe.ERR_CANCELED,t,n),this.name="CanceledError"}W.inherits(wr,Pe,{__CANCEL__:!0});function Rc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Pe("Request failed with status code "+n.status,[Pe.ERR_BAD_REQUEST,Pe.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Pv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function jv(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;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),c-i<t)return;const f=d&&c-d;return f?Math.round(m*1e3/f):void 0}}function _v(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),p=d-n;p>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-p)))},()=>o&&i(o)]}const Ho=(e,t,n=3)=>{let r=0;const o=jv(50,250);return _v(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const p={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(p)},n)},Mc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Oc=e=>(...t)=>W.asap(()=>e(...t)),Rv=jt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,jt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(jt.origin),jt.navigator&&/(msie|trident)/i.test(jt.navigator.userAgent)):()=>!0,Mv=jt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];W.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),W.isString(r)&&i.push("path="+r),W.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.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 Ov(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Dv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Dc(e,t,n){let r=!Ov(t);return e&&(r||n==!1)?Dv(e,t):t}const Lc=e=>e instanceof Ht?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(c,d,p,m){return W.isPlainObject(c)&&W.isPlainObject(d)?W.merge.call({caseless:m},c,d):W.isPlainObject(d)?W.merge({},d):W.isArray(d)?d.slice():d}function o(c,d,p,m){if(W.isUndefined(d)){if(!W.isUndefined(c))return r(void 0,c,p,m)}else return r(c,d,p,m)}function s(c,d){if(!W.isUndefined(d))return r(void 0,d)}function i(c,d){if(W.isUndefined(d)){if(!W.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,p){if(p in t)return r(c,d);if(p in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,p)=>o(Lc(c),Lc(d),p,!0)};return W.forEach(Object.keys({...e,...t}),function(d){const p=l[d]||o,m=p(e[d],t[d],d);W.isUndefined(m)&&p!==a||(n[d]=m)}),n}const $c=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ht.from(i),t.url=Ic(Dc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),W.isFormData(n)){if(jt.hasStandardBrowserEnv||jt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(W.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,p])=>{c.includes(d.toLowerCase())&&i.set(d,p)})}}if(jt.hasStandardBrowserEnv&&(r&&W.isFunction(r)&&(r=r(t)),r||r!==!1&&Rv(t.url))){const l=o&&s&&Mv.read(s);l&&i.set(o,l)}return t},Lv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=$c(e);let s=o.data;const i=Ht.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,p,m,f,v;function g(){f&&f(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const C=Ht.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),S={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:C,config:e,request:x};Rc(function(E){n(E),g()},function(E){r(E),g()},S),x=null}"onloadend"in x?x.onloadend=y:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(y)},x.onabort=function(){x&&(r(new Pe("Request aborted",Pe.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const S=k&&k.message?k.message:"Network Error",T=new Pe(S,Pe.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const S=o.transitional||Ac;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Pe(k,S.clarifyTimeoutError?Pe.ETIMEDOUT:Pe.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&W.forEach(i.toJSON(),function(k,S){x.setRequestHeader(S,k)}),W.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Ho(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([p,f]=Ho(l),x.upload.addEventListener("progress",p),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=C=>{x&&(r(!C||C.type?new wr(null,e,x):C),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Pv(o.url);if(b&&jt.protocols.indexOf(b)===-1){r(new Pe("Unsupported protocol "+b+":",Pe.ERR_BAD_REQUEST,e));return}x.send(s||null)})},$v=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof Pe?d:new wr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Pe(`timeout ${t} of ms exceeded`,Pe.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>W.asap(a),l}},Fv=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},Bv=async function*(e,t){for await(const n of zv(e))yield*Fv(n,t)},zv=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()}},Fc=(e,t,n,r)=>{const o=Bv(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let p=d.byteLength;if(n){let m=s+=p;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Bc=64*1024,{isFunction:Uo}=W,Hv=(({Request:e,Response:t})=>({Request:e,Response:t}))(W.global),{ReadableStream:zc,TextEncoder:Hc}=W.global,Uc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Uv=e=>{e=W.merge.call({skipUndefined:!0},Hv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Uo(t):typeof fetch=="function",s=Uo(n),i=Uo(r);if(!o)return!1;const a=o&&Uo(zc),l=o&&(typeof Hc=="function"?(v=>g=>v.encode(g))(new Hc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&Uc(()=>{let v=!1;const g=new n(jt.origin,{body:new zc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Uc(()=>W.isReadableStream(new r("").body)),p={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!p[v]&&(p[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Pe(`Response type '${v}' is not supported`,Pe.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(W.isBlob(v))return v.size;if(W.isSpecCompliantForm(v))return(await new n(jt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(W.isArrayBufferView(v)||W.isArrayBuffer(v))return v.byteLength;if(W.isURLSearchParams(v)&&(v=v+""),W.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=W.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:b,cancelToken:C,timeout:k,onDownloadProgress:S,onUploadProgress:T,responseType:E,headers:P,withCredentials:_="same-origin",fetchOptions:$}=$c(v),L=t||fetch;E=E?(E+"").toLowerCase():"text";let F=$v([b,C&&C.toAbortSignal()],k),G=null;const O=F&&F.unsubscribe&&(()=>{F.unsubscribe()});let K;try{if(T&&c&&x!=="get"&&x!=="head"&&(K=await f(P,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),D;if(W.isFormData(y)&&(D=J.headers.get("content-type"))&&P.setContentType(D),J.body){const[V,R]=Mc(K,Ho(Oc(T)));y=Fc(J.body,Bc,V,R)}}W.isString(_)||(_=_?"include":"omit");const q=s&&"credentials"in n.prototype,H={...$,signal:F,method:x.toUpperCase(),headers:P.normalize().toJSON(),body:y,duplex:"half",credentials:q?_:void 0};G=s&&new n(g,H);let j=await(s?L(G,$):L(g,H));const I=d&&(E==="stream"||E==="response");if(d&&(S||I&&O)){const J={};["status","statusText","headers"].forEach(B=>{J[B]=j[B]});const D=W.toFiniteNumber(j.headers.get("content-length")),[V,R]=S&&Mc(D,Ho(Oc(S),!0))||[];j=new r(Fc(j.body,Bc,V,()=>{R&&R(),O&&O()}),J)}E=E||"text";let Y=await p[W.findKey(p,E)||"text"](j,v);return!I&&O&&O(),await new Promise((J,D)=>{Rc(J,D,{data:Y,headers:Ht.from(j.headers),status:j.status,statusText:j.statusText,config:v,request:G})})}catch(q){throw O&&O(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new Pe("Network Error",Pe.ERR_NETWORK,v,G),{cause:q.cause||q}):Pe.from(q,q&&q.code,v,G)}}},Wv=new Map,Wc=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,c,d=Wv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Uv(t)),d=c;return c};Wc();const Pi={http:fv,xhr:Lv,fetch:{get:Wc}};W.forEach(Pi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Vc=e=>`- ${e}`,Vv=e=>W.isFunction(e)||e===null||e===!1,Kc={getAdapter:(e,t)=>{e=W.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!Vv(r)&&(o=Pi[(a=String(r)).toLowerCase()],o===void 0))throw new Pe(`Unknown adapter '${a}'`);if(o&&(W.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
33
|
`+i.map(Vc).join(`
|
|
34
34
|
`):" "+Vc(i[0]):"as no adapter specified";throw new Pe("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Pi};function ji(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new wr(null,e)}function qc(e){return ji(e),e.headers=Ht.from(e.headers),e.data=Ai.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Kc.getAdapter(e.adapter||Zr.adapter,e)(e).then(function(r){return ji(e),r.data=Ai.call(e,e.transformResponse,r),r.headers=Ht.from(r.headers),r},function(r){return _c(r)||(ji(e),r&&r.response&&(r.response.data=Ai.call(e,e.transformResponse,r.response),r.response.headers=Ht.from(r.response.headers))),Promise.reject(r)})}const Gc="1.12.2",Wo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Wo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Yc={};Wo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Gc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Pe(o(i," has been removed"+(n?" in "+n:"")),Pe.ERR_DEPRECATED);return n&&!Yc[i]&&(Yc[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,i,a):!0}},Wo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Kv(e,t,n){if(typeof e!="object")throw new Pe("options must be an object",Pe.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],l=a===void 0||i(a,s,e);if(l!==!0)throw new Pe("option "+s+" must be "+l,Pe.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Pe("Unknown option "+s,Pe.ERR_BAD_OPTION)}}const Vo={assertOptions:Kv,validators:Wo},xn=Vo.validators;let Zn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Nc,response:new Nc}}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+=`
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Vo.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(W.isFunction(o)?n.paramsSerializer={serialize:o}:Vo.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Vo.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&W.merge(s.common,s[n.method]);s&&W.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Ht.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,p=0,m;if(!l){const v=[qc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);p<m;)d=d.then(v[p++],v[p++]);return d}m=a.length;let f=n;for(;p<m;){const v=a[p++],g=a[p++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=qc.call(this,f)}catch(v){return Promise.reject(v)}for(p=0,m=c.length;p<m;)d=d.then(c[p++],c[p++]);return d}getUri(t){t=Jn(this.defaults,t);const n=Dc(t.baseURL,t.url,t.allowAbsoluteUrls);return Ic(n,t.params,t.paramsSerializer)}};W.forEach(["delete","get","head","options"],function(t){Zn.prototype[t]=function(n,r){return this.request(Jn(r||{},{method:t,url:n,data:(r||{}).data}))}}),W.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.prototype[t+"Form"]=n(!0)});let qv=class fx{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 i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new wr(s,i,a),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 fx(function(o){t=o}),cancel:t}}};function Gv(e){return function(n){return e.apply(null,n)}}function Yv(e){return W.isObject(e)&&e.isAxiosError===!0}const _i={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(_i).forEach(([e,t])=>{_i[t]=e});function Xc(e){const t=new Zn(e),n=fc(Zn.prototype.request,t);return W.extend(n,Zn.prototype,t,{allOwnKeys:!0}),W.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Xc(Jn(e,o))},n}const ft=Xc(Zr);ft.Axios=Zn,ft.CanceledError=wr,ft.CancelToken=qv,ft.isCancel=_c,ft.VERSION=Gc,ft.toFormData=Bo,ft.AxiosError=Pe,ft.Cancel=ft.CanceledError,ft.all=function(t){return Promise.all(t)},ft.spread=Gv,ft.isAxiosError=Yv,ft.mergeConfig=Jn,ft.AxiosHeaders=Ht,ft.formToJSON=e=>Pc(W.isHTMLForm(e)?new FormData(e):e),ft.getAdapter=Kc.getAdapter,ft.HttpStatusCode=_i,ft.default=ft;const{Axios:xN,AxiosError:vN,CanceledError:wN,isCancel:Jc,CancelToken:bN,VERSION:yN,all:SN,Cancel:CN,isAxiosError:TN,spread:kN,toFormData:EN,AxiosHeaders:IN,HttpStatusCode:NN,formToJSON:AN,getAdapter:PN,mergeConfig:jN}=ft,Zc=typeof window<"u"?window.__API_BASE_URL__:void 0,Qc=Zc?vn(Zc):void 0;function vn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Ko=null;const Ri=new Set;function eu(){return Ko}function qo(e){Ko=e,Ri.forEach(t=>t(e))}function tu(e){return Ri.add(e),()=>Ri.delete(e)}const nu=3e4,ru=9e4,Xt=ft.create({...Qc?{baseURL:Qc}:{},timeout:nu,withCredentials:!0});Xt.interceptors.request.use(e=>(Ko&&(e.headers.Authorization=`Bearer ${Ko}`),e)),Xt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),qo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Jt(e,t){return Xt.defaults.baseURL?(await Xt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Go(e,t,n){return Xt.defaults.baseURL?(await Xt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ou(e,t,n){return Xt.defaults.baseURL?(await Xt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Mi(e,t){return Xt.defaults.baseURL?(await Xt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Lt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Yo{get baseUrl(){const t=Xt.defaults.baseURL;return t?vn(String(t)):""}updateConfig(t){t.baseUrl&&(Xt.defaults.baseURL=vn(String(t.baseUrl))),t.authToken!==void 0&&qo(t.authToken)}getAuthToken(){return eu()}setAuthToken(t){qo(t)}onTokenChange(t){return tu(t)}async listThreads(){const t=await Jt("/threads"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Jt("/threads/shared"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Go("/threads",t?{title:t}:void 0);return Lt(r)}async updateThread(t,n){const r=await ou(`/threads/${t}`,{title:n});return Lt(r)}async deleteThread(t){const n=await Mi(`/threads/${t}`);return Lt(n)}async shareThread(t,n){const r=await Go(`/threads/${t}/share`,{shared_with_user_id:n});return Lt(r)}async threadInfo(t){const n=await Jt(`/threads/${t}/info`);return Lt(n)}async listAgents(){const t=await Jt("/agents"),n=Lt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Jt(`/agents/${t}`);return Lt(n)}async getAgentSchema(t){const n=await Jt(`/agents/${t}/schema`);return Lt(n)}async getState(t){const n=await Jt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Lt(n)}async getStateHistory(t){const n=await Jt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:ru,signal:t.signal});return Lt(n)}async cancelRun(t){const n=await Go("/runs/cancel",{threadId:t});return Lt(n)}async unshareThread(t,n){const r=await Mi(`/threads/${t}/share/${n}`);return Lt(r)}}const Nn=new Yo,Xv=Yo,Jv=Yo;async function Oi(e,t){return await Jt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function Zv(e,t){const n=await Oi(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Di(e,t){return await(await Oi(`/files/${e}/view`,t)).text()}async function su(e,t){const n=await Oi(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Jt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Qv(e){return await Jt(`/files/${e}`)}async function iu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Jt("/files",{params:r})}const au=w.createContext(null);function lu({children:e,apiConfig:t}){const n=Nn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return u.jsx(au.Provider,{value:r,children:e})}async function cu(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function uu(e=[]){const t=[],n=[];for(const r of e)try{const o=await cu(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function eo(){const e=w.useContext(au);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function du(e){return!!e&&typeof e=="object"&&"data"in e}function Li(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var l;return a&&a.type==="text"&&((l=a.text)==null?void 0:l.trim())}),r=(t.content??[]).some(a=>a&&a.type==="image_url"),o=(i=t.artifact)==null?void 0:i.plots,s=Array.isArray(o)&&o.length>0;return!!(n||r||s)})}function to(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function ew(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function fu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function pu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function hu(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(p=>p.type==="text").map(p=>p.text??"").join(""),i=t.filter(p=>p.type!=="text"),a=o.lastText??pu(e);let l="",c=e.slice();if(s){const p=tw(a,s);if(p===""?l="":p===s?l=s:l=p,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const f=m.text??"",v={...m,text:f+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function tw(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return t.slice(r);return t}function nw(e,t,n){for(let r=e.length-1;r>=0;r--)if(e[r].role==="assistant"){const s={...e[r],checkpointId:t,checkpointNs:n??void 0};return to(e,r,s)}return e}function mu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function rw(e={}){const t=w.useMemo(()=>vn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[c,d]=w.useState(null),[p,m]=w.useState(""),[f,v]=w.useState(null),[g,x]=w.useState(0),[y,b]=w.useState(!1),[C,k]=w.useState(null),S=w.useRef(null),T=w.useRef(!0),E=w.useRef(0),P=w.useRef(null),_=w.useRef(null),$=w.useRef(null),L=w.useRef(null),F=w.useRef({messageId:null,lastSeq:null,lastText:""}),G=w.useCallback(H=>{o(H)},[]),O=w.useCallback(()=>{m(""),v(null),d(null),_.current=null,$.current=null,L.current=null,k(null),F.current={messageId:null,lastSeq:null,lastText:""}},[]),K=w.useCallback(()=>{var Y;console.debug("[use-chat] stop() invoked - aborting stream");const H=(Y=P.current)==null?void 0:Y.threadId,j=()=>{var J;(J=S.current)==null||J.abort(),S.current=null,P.current=null,l(!1),b(!1),E.current=0,x(0)};(H?Nn.cancelRun(H).catch(J=>{console.warn("[use-chat] cancel run failed:",J)}):Promise.resolve()).finally(j)},[]),q=w.useCallback((H,j,I)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),_.current=null,$.current=null,L.current=null,k(null),F.current={messageId:null,lastSeq:null,lastText:""};const Y=new AbortController;S.current=Y;let J=null,D=null,V=!1;return P.current={threadId:H.threadId??null,headers:{}},(async()=>{var B,X,N,M,U,Z,se,ae,Ce,we,je,We,Fe,Ye,He,vt,wt,dt;const R=Ve=>{var Ae;try{const Ke=JSON.parse(JSON.stringify(Ve));return(Ae=Ke==null?void 0:Ke.payload)!=null&&Ae.files_info&&Array.isArray(Ke.payload.files_info)&&(Ke.payload.files_info=Ke.payload.files_info.map(_e=>({..._e,data:_e!=null&&_e.data?`<base64 ${String(_e.data).length} chars>`:_e==null?void 0:_e.data}))),Ke}catch{return Ve}};try{let Ve={};try{if(r)Ve={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const $e=window.__AUTH_TOKEN__,ct=((B=window.localStorage)==null?void 0:B.getItem("authToken"))||null;let ne=null;try{const tt=(X=window.localStorage)==null?void 0:X.getItem("chat-settings");tt&&(ne=((N=JSON.parse(tt))==null?void 0:N.apiKey)||null)}catch{}const he=$e||ct||ne||null;he&&(Ve={Authorization:`Bearer ${he}`})}}catch{}console.debug("[use-chat] POST",t+n,R(H));let Ae={};if(typeof window<"u")try{const Ue=(M=window.localStorage)==null?void 0:M.getItem("authSessionId");Ue&&(Ae={"X-Session-Id":Ue})}catch{}const Ke={...Ve,...Ae,...s.current},_e={"Content-Type":"application/json",Accept:"text/event-stream",...Ke},Be=await fetch(t+n,{method:"POST",headers:_e,body:JSON.stringify(H),signal:Y.signal,credentials:i});if(P.current&&(P.current.headers=Ke),!Be.ok||!Be.body){const Ue=await Be.text().catch(()=>"");console.debug("[use-chat] non-OK response",Be.status,Ue==null?void 0:Ue.slice(0,500));const $e=`stream ${Be.status}${Ue?": "+Ue:""}`;throw(U=I==null?void 0:I.onConnectionError)==null||U.call(I,$e),V=!0,J="error",D=$e,new Error($e)}b(!0);const Qe=Be.body.getReader(),Nt=new TextDecoder;let et="",bt=[];E.current=0,x(0);let mt=0,Ct=null;const Tt=()=>{if(bt.length){const Ue=bt.join("");bt=[],T.current&&m($e=>$e+Ue)}Ct=null},Dt=()=>{typeof window<"u"&&Ct==null&&(Ct=requestAnimationFrame(Tt))};let Pt=Date.now();const kt=setInterval(()=>{var Ue;if(Date.now()-Pt>18e5){const $e="Stream idle timeout";d($e),J="error",D=$e,Y.abort(),(Ue=I==null?void 0:I.onError)==null||Ue.call(I,$e)}},5e3),qt=1024*1024;try{const Ue=Be.headers.get("X-Thread-Id")||Be.headers.get("x-thread-id"),$e=Be.headers.get("X-Thread-Created")||Be.headers.get("x-thread-created"),ct=Ue??null,ne=String($e??"").toLowerCase()==="true";for(P.current&&!P.current.threadId&&(P.current={...P.current,threadId:ct}),(Z=I==null?void 0:I.onOpen)==null||Z.call(I,{threadId:ct,created:ne});;){const{value:he,done:tt}=await Qe.read();if(tt)break;et+=Nt.decode(he,{stream:!0}),et.length>qt&&(et="",console.warn("Stream buffer reset: exceeded 1MB"));let me;for(;(me=et.indexOf(`
|
|
35
|
+
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Vo.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(W.isFunction(o)?n.paramsSerializer={serialize:o}:Vo.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Vo.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&W.merge(s.common,s[n.method]);s&&W.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Ht.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,p=0,m;if(!l){const v=[qc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);p<m;)d=d.then(v[p++],v[p++]);return d}m=a.length;let f=n;for(;p<m;){const v=a[p++],g=a[p++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=qc.call(this,f)}catch(v){return Promise.reject(v)}for(p=0,m=c.length;p<m;)d=d.then(c[p++],c[p++]);return d}getUri(t){t=Jn(this.defaults,t);const n=Dc(t.baseURL,t.url,t.allowAbsoluteUrls);return Ic(n,t.params,t.paramsSerializer)}};W.forEach(["delete","get","head","options"],function(t){Zn.prototype[t]=function(n,r){return this.request(Jn(r||{},{method:t,url:n,data:(r||{}).data}))}}),W.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.prototype[t+"Form"]=n(!0)});let qv=class fx{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 i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new wr(s,i,a),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 fx(function(o){t=o}),cancel:t}}};function Gv(e){return function(n){return e.apply(null,n)}}function Yv(e){return W.isObject(e)&&e.isAxiosError===!0}const _i={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(_i).forEach(([e,t])=>{_i[t]=e});function Xc(e){const t=new Zn(e),n=fc(Zn.prototype.request,t);return W.extend(n,Zn.prototype,t,{allOwnKeys:!0}),W.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Xc(Jn(e,o))},n}const ft=Xc(Zr);ft.Axios=Zn,ft.CanceledError=wr,ft.CancelToken=qv,ft.isCancel=_c,ft.VERSION=Gc,ft.toFormData=Bo,ft.AxiosError=Pe,ft.Cancel=ft.CanceledError,ft.all=function(t){return Promise.all(t)},ft.spread=Gv,ft.isAxiosError=Yv,ft.mergeConfig=Jn,ft.AxiosHeaders=Ht,ft.formToJSON=e=>Pc(W.isHTMLForm(e)?new FormData(e):e),ft.getAdapter=Kc.getAdapter,ft.HttpStatusCode=_i,ft.default=ft;const{Axios:vN,AxiosError:wN,CanceledError:bN,isCancel:Jc,CancelToken:yN,VERSION:SN,all:CN,Cancel:TN,isAxiosError:kN,spread:EN,toFormData:IN,AxiosHeaders:NN,HttpStatusCode:AN,formToJSON:PN,getAdapter:jN,mergeConfig:_N}=ft,Zc=typeof window<"u"?window.__API_BASE_URL__:void 0,Qc=Zc?vn(Zc):void 0;function vn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Ko=null;const Ri=new Set;function eu(){return Ko}function qo(e){Ko=e,Ri.forEach(t=>t(e))}function tu(e){return Ri.add(e),()=>Ri.delete(e)}const nu=3e4,ru=9e4,Xt=ft.create({...Qc?{baseURL:Qc}:{},timeout:nu,withCredentials:!0});Xt.interceptors.request.use(e=>(Ko&&(e.headers.Authorization=`Bearer ${Ko}`),e)),Xt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),qo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Jt(e,t){return Xt.defaults.baseURL?(await Xt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Go(e,t,n){return Xt.defaults.baseURL?(await Xt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ou(e,t,n){return Xt.defaults.baseURL?(await Xt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Mi(e,t){return Xt.defaults.baseURL?(await Xt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Lt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Yo{get baseUrl(){const t=Xt.defaults.baseURL;return t?vn(String(t)):""}updateConfig(t){t.baseUrl&&(Xt.defaults.baseURL=vn(String(t.baseUrl))),t.authToken!==void 0&&qo(t.authToken)}getAuthToken(){return eu()}setAuthToken(t){qo(t)}onTokenChange(t){return tu(t)}async listThreads(){const t=await Jt("/threads"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Jt("/threads/shared"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Go("/threads",t?{title:t}:void 0);return Lt(r)}async updateThread(t,n){const r=await ou(`/threads/${t}`,{title:n});return Lt(r)}async deleteThread(t){const n=await Mi(`/threads/${t}`);return Lt(n)}async shareThread(t,n){const r=await Go(`/threads/${t}/share`,{shared_with_user_id:n});return Lt(r)}async threadInfo(t){const n=await Jt(`/threads/${t}/info`);return Lt(n)}async listAgents(){const t=await Jt("/agents"),n=Lt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Jt(`/agents/${t}`);return Lt(n)}async getAgentSchema(t){const n=await Jt(`/agents/${t}/schema`);return Lt(n)}async getState(t){const n=await Jt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Lt(n)}async getStateHistory(t){const n=await Jt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:ru,signal:t.signal});return Lt(n)}async cancelRun(t){const n=await Go("/runs/cancel",{threadId:t});return Lt(n)}async unshareThread(t,n){const r=await Mi(`/threads/${t}/share/${n}`);return Lt(r)}}const Nn=new Yo,Xv=Yo,Jv=Yo;async function Oi(e,t){return await Jt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function Zv(e,t){const n=await Oi(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Di(e,t){return await(await Oi(`/files/${e}/view`,t)).text()}async function su(e,t){const n=await Oi(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Jt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Qv(e){return await Jt(`/files/${e}`)}async function iu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Jt("/files",{params:r})}const au=w.createContext(null);function lu({children:e,apiConfig:t}){const n=Nn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return u.jsx(au.Provider,{value:r,children:e})}async function cu(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function uu(e=[]){const t=[],n=[];for(const r of e)try{const o=await cu(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function eo(){const e=w.useContext(au);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function du(e){return!!e&&typeof e=="object"&&"data"in e}function Li(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var l;return a&&a.type==="text"&&((l=a.text)==null?void 0:l.trim())}),r=(t.content??[]).some(a=>a&&a.type==="image_url"),o=(i=t.artifact)==null?void 0:i.plots,s=Array.isArray(o)&&o.length>0;return!!(n||r||s)})}function to(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function ew(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function fu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function pu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function hu(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(p=>p.type==="text").map(p=>p.text??"").join(""),i=t.filter(p=>p.type!=="text"),a=o.lastText??pu(e);let l="",c=e.slice();if(s){const p=tw(a,s);if(p===""?l="":p===s?l=s:l=p,nw(a,l)&&(l=` ${l}`),l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const f=m.text??"",v={...m,text:f+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function tw(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return t.slice(r);return t}function nw(e,t){if(!e||!t)return!1;const n=e.slice(-1),r=t[0];if(!n||!r||/\s/.test(n)||/\s/.test(r))return!1;const o=s=>/[A-Za-z0-9]/.test(s);return o(n)&&o(r)}function rw(e,t,n){for(let r=e.length-1;r>=0;r--)if(e[r].role==="assistant"){const s={...e[r],checkpointId:t,checkpointNs:n??void 0};return to(e,r,s)}return e}function mu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function ow(e={}){const t=w.useMemo(()=>vn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[c,d]=w.useState(null),[p,m]=w.useState(""),[f,v]=w.useState(null),[g,x]=w.useState(0),[y,b]=w.useState(!1),[C,k]=w.useState(null),S=w.useRef(null),T=w.useRef(!0),E=w.useRef(0),P=w.useRef(null),_=w.useRef(null),$=w.useRef(null),L=w.useRef(null),F=w.useRef({messageId:null,lastSeq:null,lastText:""}),G=w.useCallback(H=>{o(H)},[]),O=w.useCallback(()=>{m(""),v(null),d(null),_.current=null,$.current=null,L.current=null,k(null),F.current={messageId:null,lastSeq:null,lastText:""}},[]),K=w.useCallback(()=>{var Y;console.debug("[use-chat] stop() invoked - aborting stream");const H=(Y=P.current)==null?void 0:Y.threadId,j=()=>{var J;(J=S.current)==null||J.abort(),S.current=null,P.current=null,l(!1),b(!1),E.current=0,x(0)};(H?Nn.cancelRun(H).catch(J=>{console.warn("[use-chat] cancel run failed:",J)}):Promise.resolve()).finally(j)},[]),q=w.useCallback((H,j,I)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),_.current=null,$.current=null,L.current=null,k(null),F.current={messageId:null,lastSeq:null,lastText:""};const Y=new AbortController;S.current=Y;let J=null,D=null,V=!1;return P.current={threadId:H.threadId??null,headers:{}},(async()=>{var B,X,N,M,U,Z,se,ae,Ce,we,je,We,Fe,Ye,He,vt,wt,dt;const R=Ve=>{var Ae;try{const Ke=JSON.parse(JSON.stringify(Ve));return(Ae=Ke==null?void 0:Ke.payload)!=null&&Ae.files_info&&Array.isArray(Ke.payload.files_info)&&(Ke.payload.files_info=Ke.payload.files_info.map(_e=>({..._e,data:_e!=null&&_e.data?`<base64 ${String(_e.data).length} chars>`:_e==null?void 0:_e.data}))),Ke}catch{return Ve}};try{let Ve={};try{if(r)Ve={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const $e=window.__AUTH_TOKEN__,ct=((B=window.localStorage)==null?void 0:B.getItem("authToken"))||null;let ne=null;try{const tt=(X=window.localStorage)==null?void 0:X.getItem("chat-settings");tt&&(ne=((N=JSON.parse(tt))==null?void 0:N.apiKey)||null)}catch{}const he=$e||ct||ne||null;he&&(Ve={Authorization:`Bearer ${he}`})}}catch{}console.debug("[use-chat] POST",t+n,R(H));let Ae={};if(typeof window<"u")try{const Ue=(M=window.localStorage)==null?void 0:M.getItem("authSessionId");Ue&&(Ae={"X-Session-Id":Ue})}catch{}const Ke={...Ve,...Ae,...s.current},_e={"Content-Type":"application/json",Accept:"text/event-stream",...Ke},Be=await fetch(t+n,{method:"POST",headers:_e,body:JSON.stringify(H),signal:Y.signal,credentials:i});if(P.current&&(P.current.headers=Ke),!Be.ok||!Be.body){const Ue=await Be.text().catch(()=>"");console.debug("[use-chat] non-OK response",Be.status,Ue==null?void 0:Ue.slice(0,500));const $e=`stream ${Be.status}${Ue?": "+Ue:""}`;throw(U=I==null?void 0:I.onConnectionError)==null||U.call(I,$e),V=!0,J="error",D=$e,new Error($e)}b(!0);const Qe=Be.body.getReader(),Nt=new TextDecoder;let et="",bt=[];E.current=0,x(0);let mt=0,Ct=null;const Tt=()=>{if(bt.length){const Ue=bt.join("");bt=[],T.current&&m($e=>$e+Ue)}Ct=null},Dt=()=>{typeof window<"u"&&Ct==null&&(Ct=requestAnimationFrame(Tt))};let Pt=Date.now();const kt=setInterval(()=>{var Ue;if(Date.now()-Pt>18e5){const $e="Stream idle timeout";d($e),J="error",D=$e,Y.abort(),(Ue=I==null?void 0:I.onError)==null||Ue.call(I,$e)}},5e3),qt=1024*1024;try{const Ue=Be.headers.get("X-Thread-Id")||Be.headers.get("x-thread-id"),$e=Be.headers.get("X-Thread-Created")||Be.headers.get("x-thread-created"),ct=Ue??null,ne=String($e??"").toLowerCase()==="true";for(P.current&&!P.current.threadId&&(P.current={...P.current,threadId:ct}),(Z=I==null?void 0:I.onOpen)==null||Z.call(I,{threadId:ct,created:ne});;){const{value:he,done:tt}=await Qe.read();if(tt)break;et+=Nt.decode(he,{stream:!0}),et.length>qt&&(et="",console.warn("Stream buffer reset: exceeded 1MB"));let me;for(;(me=et.indexOf(`
|
|
36
36
|
|
|
37
37
|
`))>=0;){const Oe=et.slice(0,me);et=et.slice(me+2);const qe=Oe.split(/\r?\n/),ut=[];for(const be of qe)if(!(!be||be.startsWith(":"))&&be.startsWith("data:")){const Xe=be.slice(5);ut.push(Xe.startsWith(" ")?Xe.slice(1):Xe)}const at=ut.join(`
|
|
38
|
-
`);if(!at)continue;let lt;try{lt=JSON.parse(at)}catch{console.debug("[use-chat] malformed SSE:",at.slice(0,200));continue}const Et=du(lt)?lt.data:lt;if(!Et){console.warn("[use-chat] dropped envelope event without payload",lt);continue}const ke=Et;Pt=Date.now();const Ee=ke.seq;if(Ee!==void 0){if(Ee<=mt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Ee,lastProcessedSeq:mt,type:ke.type});continue}mt>0&&Ee>mt+1&&((se=I==null?void 0:I.onGap)==null||se.call(I,{from:mt,to:Ee})),mt=Ee,E.current=Ee,x(Ee)}if(ke.type==="message.start"&&ke.role==="assistant"){const be=mu(ke.model);F.current={messageId:ke.id,lastSeq:Ee??null,lastText:""},k({id:ke.id,role:"assistant",name:be??void 0,model:ke.model,createdAt:new Date().toISOString(),content:[]})}if(ke.type==="checkpoint")_.current=ke.checkpointId??null,$.current=ke.checkpointNs??null,v(ke.checkpointId??null);else if(ke.type==="state_history"){L.current=ke;try{const Xe=Yn(ke).latest;Xe&&(_.current=Xe.checkpointId??null,$.current=Xe.checkpointNs??null,v(Xe.checkpointId??null))}catch(be){console.warn("[use-chat] Failed to hydrate state_history payload",be)}}try{j==null||j(ke)}catch(be){console.error("[use-chat] Error in onEvent callback:",be,"for event:",ke.type)}if(ke.type==="message.delta"){k(Xe=>{const At=F.current;if(!Xe||At.messageId!==Xe.id)return Xe;const{newParts:A,newMeta:ee,changed:Q}=hu(Xe.content??[],ke.delta,{lastSeq:At.lastSeq,lastText:At.lastText},Ee??null);return Q?(F.current={...At,lastSeq:ee.lastSeq??At.lastSeq,lastText:ee.lastText??At.lastText},{...Xe,content:A}):Xe});const be=ke.delta.filter(Xe=>Xe.type==="text").map(Xe=>Xe.text).join("");be&&e.autoAppendAssistant!==!1&&(bt.push(be),Dt())}else if(ke.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(ae=I==null?void 0:I.onHeartbeat)==null||ae.call(I,ke)}catch(be){console.warn("[use-chat] heartbeat callback failed",be)}}else if(Ct!==null&&cancelAnimationFrame(Ct),Tt(),ke.type==="checkpoint")v(ke.checkpointId);else if(ke.type==="error"){const be=ke;if(d(be.message),J="error",D=be.message,be.error_type==="auth_error"||be.code==="TOKEN_EXPIRED"||((Ce=be.message)==null?void 0:Ce.includes("token"))||((we=be.message)==null?void 0:we.includes("401"))||((je=be.message)==null?void 0:je.includes("unauthorized"))||((We=be.message)==null?void 0:We.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",be.message);try{(Fe=I==null?void 0:I.onAuthError)==null||Fe.call(I,be.message)}catch(At){console.warn("[use-chat] onAuthError handler failed",At)}Y.abort()}}}}Tt(),J===null&&!Y.signal.aborted&&(J="complete")}catch(Ue){if(Ue.name==="AbortError")J=J??"aborted";else{const $e=Ue.message||String(Ue);J="error",D=$e,d($e),(Ye=I==null?void 0:I.onError)==null||Ye.call(I,$e)}}finally{try{await Qe.cancel()}catch{}finally{(He=Qe.releaseLock)==null||He.call(Qe)}Ct!==null&&typeof window<"u"&&window.cancelAnimationFrame(Ct),clearInterval(kt)}}catch(Ve){if(Ve.name==="AbortError")J=J??"aborted";else{const Ae=Ve.message||String(Ve);J="error",D=Ae,d(Ae),(vt=I==null?void 0:I.onError)==null||vt.call(I,Ae),V||((wt=I==null?void 0:I.onConnectionError)==null||wt.call(I,Ae),V=!0)}}finally{const Ve=E.current,Ae=_.current,Ke=$.current,_e=L.current,Be=J??(Y.signal.aborted?"aborted":D?"error":"complete");try{(dt=I==null?void 0:I.onClosed)==null||dt.call(I,{reason:Be,lastSeq:Ve,lastCheckpointId:Ae,lastCheckpointNs:Ke,lastStateHistory:_e,error:D})}catch(Qe){console.warn("[use-chat] onClosed callback failed",Qe)}l(!1),b(!1),S.current=null,E.current=0,x(0),P.current=null}})(),{close:()=>Y.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var H;T.current=!1,(H=S.current)==null||H.abort()},[]),{isStreaming:a,error:c,assistantText:p,assistantMessage:C,lastCheckpointId:f,lastSeq:g,connected:y,stream:q,stop:K,clear:O,setToken:G}}const ow=["detail","message","error","description","title"];function Xo(e){if(!e)return null;if(typeof e=="string"){const t=e.trim();return t.length?t:null}if(Array.isArray(e)){for(const t of e){const n=Xo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of ow){const r=Xo(t[n]);if(r)return r}if("errors"in t){const n=Xo(t.errors);if(n)return n}}return null}function sw(e){if(!e)return"Request failed";const t=e.response,n=Xo(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function gu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=w.useState([]),[a,l]=w.useState(t),[c,d]=w.useState(!1),[p,m]=w.useState(null),[f,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,C]=w.useState(null),[k,S]=w.useState(!1),T=w.useRef(a),E=w.useRef(new Map);w.useEffect(()=>{T.current=a},[a]);const P=w.useCallback(async()=>{d(!0),m(null);try{const j=await e.listThreads();i(j??[])}catch(j){const I=String(j);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),_=w.useCallback(async()=>{x(!0),y(null);try{const j=await e.listSharedThreads();v(j??[])}catch(j){const I=String(j);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);w.useEffect(()=>{P()},[P]),w.useEffect(()=>{_()},[_]),w.useEffect(()=>{r==null||r(a)},[a,r]);const $=w.useCallback(async j=>{try{const I=await e.createThread(j);return l(I.threadId),await P(),I.threadId}catch(I){const Y=String(I);return n==null||n(Y),null}},[e,n,P]),L=w.useCallback(async j=>{const I=s;i(J=>J.filter(D=>D.threadId!==j));const Y=new AbortController;E.current.set(j,Y);try{await e.deleteThread(j),T.current===j&&(l(null),o==null||o())}catch(J){i(I);const D=String(J);n==null||n(D)}finally{E.current.delete(j)}},[e,o,n,s]),F=w.useCallback(async(j,I)=>{try{await e.updateThread(j,I),await P()}catch(Y){n==null||n(String(Y))}},[e,n,P]),G=w.useCallback(async(j,I)=>{S(!0),C("Sharing thread…");try{await e.shareThread(j,I),await _(),C("Shared successfully")}catch(Y){const J=sw(Y);throw n==null||n(J),C(`Failed to share: ${J}`),new Error(J)}finally{S(!1)}},[e,n,_]),O=w.useCallback(async(j,I)=>{try{await e.unshareThread(j,I),await _()}catch(Y){const J=String(Y);throw n==null||n(J),Y}},[e,n,_]),K=w.useMemo(()=>({createThread:$,deleteThread:L,renameThread:F,refreshThreads:P,refreshSharedThreads:_,shareThread:G,unshareThread:O}),[$,L,F,P,_,G,O]),q=w.useCallback(j=>{if(!(j!=null&&j.threadId))return;const I={threadId:j.threadId,title:j.title||`Thread ${j.threadId.slice(0,8)}`,createdAt:j.createdAt||new Date().toISOString(),updatedAt:j.updatedAt||new Date().toISOString(),messageCount:j.messageCount??1};i(Y=>{let J=!1;const D=Y.map(V=>V.threadId===I.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...V,title:I.title??V.title,updatedAt:I.updatedAt??V.updatedAt,messageCount:I.messageCount??V.messageCount}):V);return J?D:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...Y])})},[]),H=w.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:p,sharedThreads:f,isLoadingSharedThreads:g,actions:K,addThreadFromEvent:q,shareInFlight:k,shareStatus:b,clearShareStatus:H}}const xu=w.createContext(null);function vu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=eo(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=gu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),b=w.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,p,m,f,g,x,y,v]);return u.jsx(xu.Provider,{value:b,children:e})}function br(){const e=w.useContext(xu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Qn(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{const n=iw(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function iw(e){let t=!1,n="";for(const o of e){if(o==="\\"){n+=o,t=!t;continue}if(o==="'"&&!t){n+='"';continue}n+=o,t=!1}return n.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null")}function $i(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function yr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(yr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if($i(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=yr(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function er(e){if(typeof e=="string")return e;if($i(e))return"";try{const t=yr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function wu(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function bu(e){const t=er(e);return typeof e=="string"&&wu(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function tr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Qn(t);if(n!==null)return tr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?tr(e.content):e}function yu(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Jo(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function Fi(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Su(e){const t=r=>{try{const o=yr(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
39
|
-
`)):t(e)}function Cu(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Bi(e){if(e.role==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(i=>{switch(i.type){case"text":return`t:${i.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"",r="checkpointId"in e&&e.checkpointId?`cp:${e.checkpointId}`:"",o="checkpointNs"in e&&e.checkpointNs?`ns:${e.checkpointNs}`:"",s=[r,o].filter(Boolean).join("|");return`${e.id}:${t}:${n}${s?`:${s}`:""}`}function Tu(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function ku(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Eu({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Tu(n),i=o?`data:${s};base64,${e}`:t,a=ku(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function Iu(e){var o,s;const t=((o=e.content_base64)==null?void 0:o.trim())||void 0,n=((s=e.url)==null?void 0:s.trim())||void 0,r=e.format||e.mimeType||e.mime_type;return Eu({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function zi(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}function Sr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim(),n=Qn(t);return n!==null?Sr(n):t}if(Array.isArray(e))return e.map(t=>Sr(t));if(typeof e=="object"){const t=e.value;if(t!==void 0)return Sr(t)}return e}function Nu(e){const t=Sr(e.value);return t===e.value?e:{...e,value:t}}const aw={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function lw(e,t){var n;switch(t.type){case"reset":return{messages:Li(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=Li(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=Li(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return Au(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Au(o,s),e):e}default:return e}}function cw(e=[]){const[t,n]=w.useReducer(lw,{...aw,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=w.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=w.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,p)=>n({type:"seed",payload:{messages:d,...p??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,p)=>n({type:"user_message",payload:{message:d,editingMessageId:p}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function Au(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=mu(t.model);if(e.messages.some(c=>c.id===s)){const c=e.messagesStreamMeta??{},d={...c,[s]:c[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const l={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,l]}}if(t.type==="tool.start")return dw(e,t);if(t.type==="tool.progress")return fw(e,t);if(t.type==="tool.end")return pw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??fu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(S=>S.id===s&&S.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},p=d[s],m=p??{lastSeq:null,lastText:pu(l.content)},f=t.seq??null;if(f!==null&&typeof f=="number"&&typeof m.lastSeq=="number"&&f<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:f,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=hu(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},b=to(i,a,y),C=!p||p.lastSeq!==g.lastSeq||p.lastText!==g.lastText,k=C?{...d,[s]:g}:c;return C?{...e,messages:b,messagesStreamMeta:k}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??fu(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var p;return(d==null?void 0:d.type)==="text"&&((p=d.text)==null?void 0:p.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(p=>p==null?void 0:p.type),contentPreview:(o=l.content)==null?void 0:o.map(p=>(p==null?void 0:p.type)==="text"?String(p.text).slice(0,100):p==null?void 0:p.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=nw(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Yn(t),i=s.interrupt,a=s.latest,l=i===null?ew(e.messages):e.messages;return{...e,messages:l,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function Hi(e){return e.call_id??e.id??null}function Pu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function ju(e,t,n,r){const o=t??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:e,role:"tool",name:n??void 0,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:o,toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function Ui(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||Jo(r).toolCallId===t)return n}return-1}function uw(e){if(e==null)return[];const t=tr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=er(t??e);return n?[{type:"text",text:n}]:[]}function _u(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function dw(e,t){const n=Hi(t),r=Ui(e.messages,n),o=t.name??t.tool??void 0,s=Pu(t);if(r>=0){const a=e.messages[r],c={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:c};return{...e,messages:to(e.messages,r,d)}}const i=ju(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function fw(e,t){const n=Hi(t);if(!n)return e;const r=Ui(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=_u(e.messages[r],o);return{...e,messages:to(e.messages,r,a)}}function pw(e,t){const n=Hi(t),r=Pu(t);let o=e.messages,s=Ui(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,ju(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=uw(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const p=_u(i,d),m=t.artifact??i.artifact,f={...p,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...p.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:to(o,s,f)}}function Ru({api:e,seed:t,onError:n,currentThreadId:r,initialThreadId:o=null,initialCheckpointId:s=null,initialCheckpointNs:i=null,autoLoadInitial:a=!0,isStreaming:l,getMessages:c}){const[d,p]=w.useState(null),f=w.useMemo(()=>Yn(d),[d]).checkpoints,v=ac(f),g=v.timeline,[x,y]=w.useState(!1),[b,C]=w.useState(!1),[k,S]=w.useState(null),T=w.useRef(r),E=w.useRef(null),P=w.useRef(null),_=w.useRef(null),$=w.useRef(null),L=w.useRef(null),F=w.useRef(new Map),G=w.useRef(null);w.useEffect(()=>{T.current=r},[r]);const O=w.useCallback(async R=>{var X,N;if(!R.threadId)return;const B=R.threadId;(X=R.onStart)==null||X.call(R),R.setLoading(!0);try{await R.action(B)}catch(M){if(!Jc(M)&&T.current===B){const Z=String(M);(N=R.handleError)==null||N.call(R,Z),n==null||n(Z)}throw M}finally{R.setLoading(!1)}},[n]),K=w.useCallback(async(R,B)=>{var Z;if(!R)return;const X=`${R}:${B??"latest"}`,N=F.current.get(X);if(N)return N;(Z=G.current)==null||Z.abort();const M=new AbortController;G.current=M;const U=O({threadId:R,setLoading:y,onStart:()=>S(null),handleError:se=>S(se),action:async se=>{const ae=await e.getStateHistory({threadId:se,checkpointId:B??void 0,signal:M.signal});if(T.current!==se){console.log(`[useThreadHistoryState] Thread changed during load (was ${se}, now ${T.current}), discarding stale data`);return}const{checkpoints:Ce}=Yn(ae),we=Ce.find(je=>je.messages&&je.messages.length>0)??(B?Ce.find(je=>je.checkpointId===B):null)??Ce[0];t((we==null?void 0:we.messages)??[],{checkpointId:(we==null?void 0:we.checkpointId)??null,checkpointNs:(we==null?void 0:we.checkpointNs)??null,pendingInterrupt:(we==null?void 0:we.interrupt)??null}),p(ae)}});F.current.set(X,U);try{await U}finally{F.current.delete(X),G.current===M&&(G.current=null)}return T.current===R&&(L.current=X),U},[e,t,O]),q=w.useCallback(async(R,B)=>{$.current=R;try{await K(R,B)}catch(X){if(!Jc(X))throw X}finally{$.current===R&&($.current=null)}},[K]),H=w.useCallback(R=>{P.current=R},[]),j=w.useCallback(R=>{_.current=R},[]),I=w.useCallback(R=>{const B=R.threadId??T.current;if(!B||T.current&&T.current!==B)return;const{checkpoints:X}=Yn(R);if(!X.length)return;const N=X.find(U=>U.messages&&U.messages.length>0)??X.find(U=>!!U.checkpointId)??X[0],M=_.current===B;!l&&!M&&t((N==null?void 0:N.messages)??[],{checkpointId:(N==null?void 0:N.checkpointId)??null,checkpointNs:(N==null?void 0:N.checkpointNs)??null,pendingInterrupt:(N==null?void 0:N.interrupt)??null}),p(R),L.current=`${B}:latest`,P.current=null,_.current===B&&(_.current=null)},[t,l]),Y=w.useCallback(async(R,B)=>{const X=T.current;await O({threadId:X,setLoading:C,action:async N=>{const M=await e.getStateHistory({threadId:N,checkpointId:R,checkpointNs:B??void 0});if(T.current!==N)return;const{checkpoints:U}=Yn(M),Z=U.find(se=>se.checkpointId===R&&(B?se.checkpointNs===B:!0));if(!Z){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:R,checkpointNs:B});return}p(M),t(Z.messages??[],{checkpointId:Z.checkpointId??null,checkpointNs:Z.checkpointNs??null})}}).catch(()=>{})},[e,t,O]),J=w.useCallback((R,B)=>{t(c(),{checkpointId:R??null,checkpointNs:B??null})},[c,t]),D=w.useCallback(async()=>{T.current&&await q(T.current)},[q]);w.useEffect(()=>{if(!a||!r||x||l)return;if(P.current===r){P.current=null,E.current=r;return}if(_.current===r){E.current=r;return}if($.current===r){$.current=null,E.current=r;return}if(E.current===r)return;E.current=r;let R;const B=`${r}:latest`;L.current!==B&&q(r,R)},[a,r,s,i,o,x,l,q]);const V=w.useCallback(()=>{p(null),y(!1),C(!1),S(null),P.current=null,_.current=null,E.current=null,L.current=null,$.current=null},[]);return{threadCheckpoints:f,threadTimeline:g,checkpointIndex:v,isLoadingThread:x,isLoadingCheckpoint:b,threadStateError:k,loadThread:q,navigateToCheckpoint:Y,setCurrentCheckpointId:J,returnToLatest:D,handleStateHistoryEvent:I,markSkipNextLoad:H,markStreamPendingThread:j,resetHistoryState:V}}const Mu=w.createContext(null),Ou=w.createContext(null);function no(){const e=w.useContext(Mu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Du(){const e=w.useContext(Ou);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Lu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=eo(),{currentThreadId:l}=br(),{state:c,seed:d,pushUser:p,onEvent:m}=cw(),{threadCheckpoints:f,threadTimeline:v,checkpointIndex:g,isLoadingThread:x,isLoadingCheckpoint:y,threadStateError:b,loadThread:C,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,handleStateHistoryEvent:E,markSkipNextLoad:P,markStreamPendingThread:_,resetHistoryState:$}=Ru({api:a,seed:d,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:w.useCallback(()=>c.messages,[c.messages])}),[L,F]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[G,O]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),$())},[l,d,$]);const K=w.useCallback(Y=>F(()=>Y),[]),q=w.useCallback(Y=>O(()=>Y),[]),H=w.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),j=w.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:f,checkpointIndex:g,timelineCheckpoints:v,metadata:H,isLoading:x,isLoadingCheckpoint:y,error:b,clearState:L,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,loadThread:C,clearThread:L,respondToInterrupt:G,messagePreviews:g.messagePreviews,handleStateHistoryEvent:E,markSkipNextLoad:P,markStreamPendingThread:_,resetHistoryState:$,pushUser:p,onEvent:m}),[l,c,f,v,g,H,x,y,b,L,k,S,T,C,G,g.messagePreviews,E,P,_,$,p,m]),I=w.useMemo(()=>({registerClearThread:K,registerRespondToInterrupt:q}),[K,q]);return u.jsx(Ou.Provider,{value:I,children:u.jsx(Mu.Provider,{value:j,children:e})})}function $u(e,t){if(!e)return null;const n=_n(e);if(!n)return null;const r=_n(n.configurable)??n;return Rn(r,t)??null}function hw(e){const t=$u(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=$u(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function mw(e,t){const n=typeof e.step=="number"?e.step:Number.POSITIVE_INFINITY,r=typeof t.step=="number"?t.step:Number.POSITIVE_INFINITY;if(n!==r)return n-r;const o=e.createdAt?Date.parse(e.createdAt):0,s=t.createdAt?Date.parse(t.createdAt):0;return o-s}function gw(e,t){const n=[...e].sort(mw);for(const r of n){if(r.messageId!==t)continue;const o=hw(r.parentConfig);if(!o)throw new Error(`Parent checkpoint info missing for message ${t}`);return o}throw new Error(`Message ${t} not found in timeline`)}const Fu=w.createContext(null),Bu=w.createContext(!1);function xw({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:p}=eo(),m=w.useMemo(()=>vn(p),[p]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=rw({baseUrl:m}),[b,C]=w.useState(!1);return w.useEffect(()=>{C(g)},[g]),u.jsx(vu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Lu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(Bu.Provider,{value:!0,children:u.jsx(vw,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function vw({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:p}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=br(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:C,resetHistoryState:k,pushUser:S,onEvent:T}=no(),{registerClearThread:E,registerRespondToInterrupt:P}=Du(),_=w.useCallback(H=>{v(H),f.current!==H.threadId&&((H.created??!f.current)&&b(H.threadId),C(H.threadId),m(H.threadId))},[v,b,C,m,f]),$=w.useCallback(H=>{H.type==="thread_info"?_(H):H.type==="state_history"?y(H):H.type==="tool.end"?i==null||i(H):T(H)},[_,y,T,i]),L=w.useCallback(H=>{a(H,$,{onError:j=>{console.error("[StreamingProvider] Stream error:",j),r==null||r(j)},onAuthError:j=>{console.error("[StreamingProvider] Auth error:",j),o==null||o(j)},onConnectionError:j=>{console.error("[StreamingProvider] Connection error:",j),s==null||s(j)}})},[a,$,r,o,s]),F=w.useRef(g);w.useEffect(()=>{F.current=g},[g]);const G=w.useCallback(async(H,j,I)=>{const Y=f.current;if(!Y)throw new Error("No active thread to handle interrupt");const J=H?j??!0:!1,D=F.current,V={threadId:Y,checkpointId:D.id??void 0,checkpointNs:D.namespace??void 0,command:{kind:"resume",value:J},payload:I==null?void 0:I.payload,config:I==null?void 0:I.config,nodeFilter:I==null?void 0:I.nodeFilter,branchLabel:I==null?void 0:I.branchLabel,active_agent:I==null?void 0:I.active_agent,timelineCheckpoints:I==null?void 0:I.timelineCheckpoints};L(V)},[f,L]);w.useEffect(()=>{P(G)},[G,P]);const O=w.useCallback(async()=>{l(),k(),m(null)},[k,m,l]);w.useEffect(()=>{E(O)},[O,E]);const K=w.useCallback(async(H,j)=>{let I=f.current;const Y=(H==null?void 0:H.text)??"",J=(H==null?void 0:H.attachments)??[],D=(Y==null?void 0:Y.trim())??"",V={...(H==null?void 0:H.payload)??{}},R=Array.isArray(V.messages)?V.messages:void 0;R&&delete V.messages;const B=!!(R&&R.length);if(!I&&!D&&J.length===0&&!B)return;if(!I){const Ye=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),He=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Ye}${He}`,b(I),m(I)}const{contentParts:X,filesInfo:N}=await uu(J),M=[...X];D&&M.push({type:"text",text:Y});const U=j==null?void 0:j.originalMessageId,Z=!!(j!=null&&j.edit&&U),se=!B&&M.length>0;let ae=null;se&&(ae={id:Z?U:`msg-${Date.now()}`,role:"user",content:M,createdAt:new Date().toISOString()},Z?S(ae,U):S(ae));const Ce=B?R:ae?[ae]:[],we={...V,...N.length?{files_info:N}:{}};Ce.length?we.messages=Ce:"messages"in we||(we.messages=[]);let je=(j==null?void 0:j.checkpointId)??g.id??void 0,We=(j==null?void 0:j.checkpointNs)??g.namespace??void 0;if(Z&&U){const Ye=gw(x,U);je=Ye.checkpointId,We=Ye.checkpointNs??void 0}const Fe={threadId:I,payload:we,checkpointId:je,checkpointNs:We,edit:!!(j!=null&&j.edit)};L(Fe)},[g,f,b,S,L,x]),q=w.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:K,send:K,stop:l,setAuthToken:p}),[c,d,K,l,p]);return u.jsx(Fu.Provider,{value:q,children:e})}function Wi(){const e=w.useContext(Fu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function ww(){return w.useContext(Bu)}function zu(e){return typeof e=="object"&&e!==null}function bw(e,t){if(Object.is(e,t))return!0;if(!zu(e)||!zu(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function Hu(e){const t=w.useRef(e),n=w.useRef(e);return bw(t.current,e)||(t.current=e,n.current=e),n.current}function Cr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const p=Hu(t),m=ro(a),f=ro(l),v=ro(i),g=ro(c),x=ro(d),y=w.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:f,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,f,v,g,x]);return u.jsx(lu,{apiConfig:p,children:u.jsx(xw,{...y,children:e})})}function ro(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e},[e]),w.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function Tr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function yw(e){if(typeof e!="string")return;const t=e.trim();if(t)return vn(t)}function Uu(){const e=[Tr("__API_BASE_URL__"),Tr("__CHAT_API_BASE_URL__"),Tr("__CHAT_API_URL__")];for(const t of e){const n=yw(t);if(n)return n}}function Wu(){const e=[Tr("__API_AUTH_TOKEN__"),Tr("__CHAT_API_KEY__"),Tr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Vu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return vn(t);return vn()}function Ku(){const e={},t=Uu(),n=Wu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function qu(){const e=Ku(),t=Nn.getAuthToken(),n=Uu();return{apiBaseUrl:Vu(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||Wu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Vi="chat-settings";function Gu(){try{const e=localStorage.getItem(Vi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Yu(e){try{const t={...e,apiBaseUrl:vn(e.apiBaseUrl)};localStorage.setItem(Vi,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Sw(){const e=qu(),t=Gu(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Vu(Nn.baseUrl,r,e.apiBaseUrl)}}function Cw(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Yu(e)}function re(...e){return hx.twMerge(px.clsx(e))}const Tw=Vr.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"}}),Je=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yt.Slot:"button";return u.jsx(i,{className:re(Tw({variant:t,size:n,className:e})),ref:s,...o})});Je.displayName="Button";function ie(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 Xu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Mn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Xu(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():Xu(e[o],null)}}}}function De(...e){return h.useCallback(Mn(...e),e)}function kw(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=h.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function cn(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),l=n.length;n=[...n,i];const c=p=>{var y;const{scope:m,children:f,...v}=p,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=h.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(p,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=h.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Ew(o,...t)]}function Ew(...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 i=r.reduce((a,{useScope:l,scopeName:c})=>{const p=l(s)[`__scope${c}`];return{...a,...p}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var It=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},Iw=h[" useInsertionEffect ".trim().toString()]||It;function On({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Nw({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const p=d.current;p!==a&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${a?"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.`),d.current=a},[a,r])}const c=h.useCallback(d=>{var p;if(a){const m=Aw(d)?d(e):d;m!==e&&((p=i.current)==null||p.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Nw({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return Iw(()=>{s.current=t},[t]),h.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Aw(e){return typeof e=="function"}var Pw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],fe=Pw.reduce((e,t)=>{const n=Yt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ki(e,t){e&&Kr.flushSync(()=>e.dispatchEvent(t))}function Zo(e){const t=e+"CollectionProvider",[n,r]=cn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,b=w.useRef(null),C=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:C,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Yt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,C=s(a,y),k=De(x,C.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",p="data-radix-collection-item",m=Yt.createSlot(d),f=w.forwardRef((g,x)=>{const{scope:y,children:b,...C}=g,k=w.useRef(null),S=De(x,k),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...C}),()=>void T.itemMap.delete(k))),u.jsx(m,{[p]:"",ref:S,children:b})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return w.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const C=Array.from(b.querySelectorAll(`[${p}]`));return Array.from(x.itemMap.values()).sort((T,E)=>C.indexOf(T.ref.current)-C.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var jw=h.createContext(void 0);function Qo(e){const t=h.useContext(jw);return e||t||"ltr"}function pt(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function _w(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e);h.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 Rw="DismissableLayer",qi="dismissableLayer.update",Mw="dismissableLayer.pointerDownOutside",Ow="dismissableLayer.focusOutside",Ju,Zu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),kr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Zu),[d,p]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=h.useState({}),v=De(t,E=>p(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,C=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=y,S=Lw(E=>{const P=E.target,_=[...c.branches].some($=>$.contains(P));!k||_||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=$w(E=>{const P=E.target;[...c.branches].some($=>$.contains(P))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return _w(E=>{b===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Ju=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),ed(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Ju)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),ed())},[d,c]),h.useEffect(()=>{const E=()=>f({});return document.addEventListener(qi,E),()=>document.removeEventListener(qi,E)},[]),u.jsx(fe.div,{...l,ref:v,style:{pointerEvents:C?k?"auto":"none":void 0,...e.style},onFocusCapture:ie(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ie(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ie(e.onPointerDownCapture,S.onPointerDownCapture)})});kr.displayName=Rw;var Dw="DismissableLayerBranch",Qu=h.forwardRef((e,t)=>{const n=h.useContext(Zu),r=h.useRef(null),o=De(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(fe.div,{...e,ref:o})});Qu.displayName=Dw;function Lw(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){td(Mw,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function $w(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&td(Ow,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 ed(){const e=new CustomEvent(qi);document.dispatchEvent(e)}function td(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?Ki(o,s):o.dispatchEvent(s)}var Fw=kr,Bw=Qu,Gi=0;function Yi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??nd()),document.body.insertAdjacentElement("beforeend",e[1]??nd()),Gi++,()=>{Gi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Gi--}},[])}function nd(){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 Xi="focusScope.autoFocusOnMount",Ji="focusScope.autoFocusOnUnmount",rd={bubbles:!1,cancelable:!0},zw="FocusScope",es=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=pt(o),d=pt(s),p=h.useRef(null),m=De(t,g=>l(g)),f=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(C){if(f.paused||!a)return;const k=C.target;a.contains(k)?p.current=k:Dn(p.current,{select:!0})},x=function(C){if(f.paused||!a)return;const k=C.relatedTarget;k!==null&&(a.contains(k)||Dn(p.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const S of C)S.removedNodes.length>0&&Dn(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),b.disconnect()}}},[r,a,f.paused]),h.useEffect(()=>{if(a){id.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Xi,rd);a.addEventListener(Xi,c),a.dispatchEvent(y),y.defaultPrevented||(Hw(qw(od(a)),{select:!0}),document.activeElement===g&&Dn(a))}return()=>{a.removeEventListener(Xi,c),setTimeout(()=>{const y=new CustomEvent(Ji,rd);a.addEventListener(Ji,d),a.dispatchEvent(y),y.defaultPrevented||Dn(g??document.body,{select:!0}),a.removeEventListener(Ji,d),id.remove(f)},0)}}},[a,c,d,f]);const v=h.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const b=g.currentTarget,[C,k]=Uw(b);C&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Dn(C,{select:!0})):g.shiftKey&&y===C&&(g.preventDefault(),n&&Dn(k,{select:!0})):y===b&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(fe.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});es.displayName=zw;function Hw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Dn(r,{select:t}),document.activeElement!==n)return}function Uw(e){const t=od(e),n=sd(t,e),r=sd(t.reverse(),e);return[n,r]}function od(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 sd(e,t){for(const n of e)if(!Ww(n,{upTo:t}))return n}function Ww(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 Vw(e){return e instanceof HTMLInputElement&&"select"in e}function Dn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Vw(e)&&t&&e.select()}}var id=Kw();function Kw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ad(e,t),e.unshift(t)},remove(t){var n;e=ad(e,t),(n=e[0])==null||n.resume()}}}function ad(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function qw(e){return e.filter(t=>t.tagName!=="A")}var Gw=h[" useId ".trim().toString()]||(()=>{}),Yw=0;function _t(e){const[t,n]=h.useState(Gw());return It(()=>{n(r=>r??String(Yw++))},[e]),t?`radix-${t}`:""}const Xw=["top","right","bottom","left"],Ln=Math.min,Zt=Math.max,ts=Math.round,ns=Math.floor,wn=e=>({x:e,y:e}),Jw={left:"right",right:"left",bottom:"top",top:"bottom"},Zw={start:"end",end:"start"};function Zi(e,t,n){return Zt(e,Ln(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function Pn(e){return e.split("-")[0]}function Er(e){return e.split("-")[1]}function Qi(e){return e==="x"?"y":"x"}function ea(e){return e==="y"?"height":"width"}const Qw=new Set(["top","bottom"]);function bn(e){return Qw.has(Pn(e))?"y":"x"}function ta(e){return Qi(bn(e))}function eb(e,t,n){n===void 0&&(n=!1);const r=Er(e),o=ta(e),s=ea(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=rs(i)),[i,rs(i)]}function tb(e){const t=rs(e);return[na(e),t,na(t)]}function na(e){return e.replace(/start|end/g,t=>Zw[t])}const ld=["left","right"],cd=["right","left"],nb=["top","bottom"],rb=["bottom","top"];function ob(e,t,n){switch(e){case"top":case"bottom":return n?t?cd:ld:t?ld:cd;case"left":case"right":return t?nb:rb;default:return[]}}function sb(e,t,n,r){const o=Er(e);let s=ob(Pn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(na)))),s}function rs(e){return e.replace(/left|right|bottom|top/g,t=>Jw[t])}function ib(e){return{top:0,right:0,bottom:0,left:0,...e}}function ud(e){return typeof e!="number"?ib(e):{top:e,right:e,bottom:e,left:e}}function os(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 dd(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=ta(t),a=ea(i),l=Pn(t),c=s==="y",d=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:p};break;case"left":f={x:r.x-o.width,y:p};break;default:f={x:r.x,y:r.y}}switch(Er(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const ab=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:p}=dd(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:b,y:C,data:k,reset:S}=await y({x:d,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=b??d,p=C??p,f={...f,[x]:{...f[x],...k}},S&&v<=50&&(v++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(c=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:p}=dd(c,m,l)),g=-1)}return{x:d,y:p,placement:m,strategy:o,middlewareData:f}};async function oo(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:p="floating",altBoundary:m=!1,padding:f=0}=An(t,e),v=ud(f),x=a[m?p==="floating"?"reference":"floating":p],y=os(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),b=p==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},S=os(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:C,strategy:l}):b);return{top:(y.top-S.top+v.top)/k.y,bottom:(S.bottom-y.bottom+v.bottom)/k.y,left:(y.left-S.left+v.left)/k.x,right:(S.right-y.right+v.right)/k.x}}const lb=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=An(e,t)||{};if(c==null)return{};const p=ud(d),m={x:n,y:r},f=ta(o),v=ea(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",b=x?"bottom":"right",C=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],S=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[C]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[C]||s.floating[v]);const P=k/2-S/2,_=E/2-g[v]/2-1,$=Ln(p[y],_),L=Ln(p[b],_),F=$,G=E-g[v]-L,O=E/2-g[v]/2+P,K=Zi(F,O,G),q=!l.arrow&&Er(o)!=null&&O!==K&&s.reference[v]/2-(O<F?$:L)-g[v]/2<0,H=q?O<F?O-F:O-G:0;return{[f]:m[f]+H,data:{[f]:K,centerOffset:O-K-H,...q&&{alignmentOffset:H}},reset:q}}}),cb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Pn(o),b=bn(a),C=Pn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=m||(C||!g?[rs(a)]:tb(a)),T=v!=="none";!m&&T&&S.push(...sb(a,g,v,k));const E=[a,...S],P=await oo(t,x),_=[];let $=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&_.push(P[y]),p){const O=eb(o,i,k);_.push(P[O[0]],P[O[1]])}if($=[...$,{placement:o,overflows:_}],!_.every(O=>O<=0)){var L,F;const O=(((L=s.flip)==null?void 0:L.index)||0)+1,K=E[O];if(K&&(!(p==="alignment"?b!==bn(K):!1)||$.every(j=>bn(j.placement)===b?j.overflows[0]>0:!0)))return{data:{index:O,overflows:$},reset:{placement:K}};let q=(F=$.filter(H=>H.overflows[0]<=0).sort((H,j)=>H.overflows[1]-j.overflows[1])[0])==null?void 0:F.placement;if(!q)switch(f){case"bestFit":{var G;const H=(G=$.filter(j=>{if(T){const I=bn(j.placement);return I===b||I==="y"}return!0}).map(j=>[j.placement,j.overflows.filter(I=>I>0).reduce((I,Y)=>I+Y,0)]).sort((j,I)=>j[1]-I[1])[0])==null?void 0:G[0];H&&(q=H);break}case"initialPlacement":q=a;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function fd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function pd(e){return Xw.some(t=>e[t]>=0)}const ub=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=An(e,t);switch(r){case"referenceHidden":{const s=await oo(t,{...o,elementContext:"reference"}),i=fd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:pd(i)}}}case"escaped":{const s=await oo(t,{...o,altBoundary:!0}),i=fd(s,n.floating);return{data:{escapedOffsets:i,escaped:pd(i)}}}default:return{}}}}},hd=new Set(["left","top"]);async function db(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Pn(n),a=Er(n),l=bn(n)==="y",c=hd.has(i)?-1:1,d=s&&l?-1:1,p=An(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const fb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await db(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},pb=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:i=!1,limiter:a={fn:x=>{let{x:y,y:b}=x;return{x:y,y:b}}},...l}=An(e,t),c={x:n,y:r},d=await oo(t,l),p=bn(Pn(o)),m=Qi(p);let f=c[m],v=c[p];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=f+d[x],C=f-d[y];f=Zi(b,f,C)}if(i){const x=p==="y"?"top":"left",y=p==="y"?"bottom":"right",b=v+d[x],C=v-d[y];v=Zi(b,v,C)}const g=a.fn({...t,[m]:f,[p]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[p]:i}}}}}},hb=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=An(e,t),d={x:n,y:r},p=bn(o),m=Qi(p);let f=d[m],v=d[p];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const C=m==="y"?"height":"width",k=s.reference[m]-s.floating[C]+x.mainAxis,S=s.reference[m]+s.reference[C]-x.mainAxis;f<k?f=k:f>S&&(f=S)}if(c){var y,b;const C=m==="y"?"width":"height",k=hd.has(Pn(o)),S=s.reference[p]-s.floating[C]+(k&&((y=i.offset)==null?void 0:y[p])||0)+(k?0:x.crossAxis),T=s.reference[p]+s.reference[C]+(k?0:((b=i.offset)==null?void 0:b[p])||0)-(k?x.crossAxis:0);v<S?v=S:v>T&&(v=T)}return{[m]:f,[p]:v}}}},mb=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=An(e,t),d=await oo(t,c),p=Pn(o),m=Er(o),f=bn(o)==="y",{width:v,height:g}=s.floating;let x,y;p==="top"||p==="bottom"?(x=p,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=p,x=m==="end"?"top":"bottom");const b=g-d.top-d.bottom,C=v-d.left-d.right,k=Ln(g-d[x],b),S=Ln(v-d[y],C),T=!t.middlewareData.shift;let E=k,P=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(P=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!m){const $=Zt(d.left,0),L=Zt(d.right,0),F=Zt(d.top,0),G=Zt(d.bottom,0);f?P=v-2*($!==0||L!==0?$+L:Zt(d.left,d.right)):E=g-2*(F!==0||G!==0?F+G:Zt(d.top,d.bottom))}await l({...t,availableWidth:P,availableHeight:E});const _=await i.getDimensions(a.floating);return v!==_.width||g!==_.height?{reset:{rects:!0}}:{}}}};function ss(){return typeof window<"u"}function Ir(e){return md(e)?(e.nodeName||"").toLowerCase():"#document"}function Qt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yn(e){var t;return(t=(md(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function md(e){return ss()?e instanceof Node||e instanceof Qt(e).Node:!1}function un(e){return ss()?e instanceof Element||e instanceof Qt(e).Element:!1}function Sn(e){return ss()?e instanceof HTMLElement||e instanceof Qt(e).HTMLElement:!1}function gd(e){return!ss()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qt(e).ShadowRoot}const gb=new Set(["inline","contents"]);function so(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!gb.has(o)}const xb=new Set(["table","td","th"]);function vb(e){return xb.has(Ir(e))}const wb=[":popover-open",":modal"];function is(e){return wb.some(t=>{try{return e.matches(t)}catch{return!1}})}const bb=["transform","translate","scale","rotate","perspective"],yb=["transform","translate","scale","rotate","perspective","filter"],Sb=["paint","layout","strict","content"];function ra(e){const t=oa(),n=un(e)?dn(e):e;return bb.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)||yb.some(r=>(n.willChange||"").includes(r))||Sb.some(r=>(n.contain||"").includes(r))}function Cb(e){let t=$n(e);for(;Sn(t)&&!Nr(t);){if(ra(t))return t;if(is(t))return null;t=$n(t)}return null}function oa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Tb=new Set(["html","body","#document"]);function Nr(e){return Tb.has(Ir(e))}function dn(e){return Qt(e).getComputedStyle(e)}function as(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $n(e){if(Ir(e)==="html")return e;const t=e.assignedSlot||e.parentNode||gd(e)&&e.host||yn(e);return gd(t)?t.host:t}function xd(e){const t=$n(e);return Nr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(t)&&so(t)?t:xd(t)}function io(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=xd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Qt(o);if(s){const a=sa(i);return t.concat(i,i.visualViewport||[],so(o)?o:[],a&&n?io(a):[])}return t.concat(o,io(o,[],n))}function sa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function vd(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ts(n)!==s||ts(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ia(e){return un(e)?e:e.contextElement}function Ar(e){const t=ia(e);if(!Sn(t))return wn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=vd(t);let i=(s?ts(n.width):n.width)/r,a=(s?ts(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const kb=wn(0);function wd(e){const t=Qt(e);return!oa()||!t.visualViewport?kb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Eb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qt(e)?!1:t}function nr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ia(e);let i=wn(1);t&&(r?un(r)&&(i=Ar(r)):i=Ar(e));const a=Eb(s,n,r)?wd(s):wn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,p=o.height/i.y;if(s){const m=Qt(s),f=r&&un(r)?Qt(r):r;let v=m,g=sa(v);for(;g&&r&&f!==v;){const x=Ar(g),y=g.getBoundingClientRect(),b=dn(g),C=y.left+(g.clientLeft+parseFloat(b.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(b.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,p*=x.y,l+=C,c+=k,v=Qt(g),g=sa(v)}}return os({width:d,height:p,x:l,y:c})}function ls(e,t){const n=as(e).scrollLeft;return t?t.left+n:nr(yn(e)).left+n}function bd(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ls(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Ib(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=yn(r),a=t?is(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=wn(1);const d=wn(0),p=Sn(r);if((p||!p&&!s)&&((Ir(r)!=="body"||so(i))&&(l=as(r)),Sn(r))){const f=nr(r);c=Ar(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!p&&!s?bd(i,l):wn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+m.x,y:n.y*c.y-l.scrollTop*c.y+d.y+m.y}}function Nb(e){return Array.from(e.getClientRects())}function Ab(e){const t=yn(e),n=as(e),r=e.ownerDocument.body,o=Zt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Zt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ls(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=Zt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const yd=25;function Pb(e,t){const n=Qt(e),r=yn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=oa();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ls(r);if(c<=0){const d=r.ownerDocument,p=d.body,m=getComputedStyle(p),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-p.clientWidth-f);v<=yd&&(s-=v)}else c<=yd&&(s+=c);return{width:s,height:i,x:a,y:l}}const jb=new Set(["absolute","fixed"]);function _b(e,t){const n=nr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Sn(e)?Ar(e):wn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function Sd(e,t,n){let r;if(t==="viewport")r=Pb(e,n);else if(t==="document")r=Ab(yn(e));else if(un(t))r=_b(t,n);else{const o=wd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return os(r)}function Cd(e,t){const n=$n(e);return n===t||!un(n)||Nr(n)?!1:dn(n).position==="fixed"||Cd(n,t)}function Rb(e,t){const n=t.get(e);if(n)return n;let r=io(e,[],!1).filter(a=>un(a)&&Ir(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?$n(e):e;for(;un(i)&&!Nr(i);){const a=dn(i),l=ra(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&jb.has(o.position)||so(i)&&!l&&Cd(e,i))?r=r.filter(d=>d!==i):o=a,i=$n(i)}return t.set(e,r),r}function Mb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?is(t)?[]:Rb(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const p=Sd(t,d,o);return c.top=Zt(p.top,c.top),c.right=Ln(p.right,c.right),c.bottom=Ln(p.bottom,c.bottom),c.left=Zt(p.left,c.left),c},Sd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Ob(e){const{width:t,height:n}=vd(e);return{width:t,height:n}}function Db(e,t,n){const r=Sn(t),o=yn(t),s=n==="fixed",i=nr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=wn(0);function c(){l.x=ls(o)}if(r||!r&&!s)if((Ir(t)!=="body"||so(o))&&(a=as(t)),r){const f=nr(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?bd(o,a):wn(0),p=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:p,y:m,width:i.width,height:i.height}}function aa(e){return dn(e).position==="static"}function Td(e,t){if(!Sn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yn(e)===n&&(n=n.ownerDocument.body),n}function kd(e,t){const n=Qt(e);if(is(e))return n;if(!Sn(e)){let o=$n(e);for(;o&&!Nr(o);){if(un(o)&&!aa(o))return o;o=$n(o)}return n}let r=Td(e,t);for(;r&&vb(r)&&aa(r);)r=Td(r,t);return r&&Nr(r)&&aa(r)&&!ra(r)?n:r||Cb(e)||n}const Lb=async function(e){const t=this.getOffsetParent||kd,n=this.getDimensions,r=await n(e.floating);return{reference:Db(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function $b(e){return dn(e).direction==="rtl"}const Fb={convertOffsetParentRelativeRectToViewportRelativeRect:Ib,getDocumentElement:yn,getClippingRect:Mb,getOffsetParent:kd,getElementRects:Lb,getClientRects:Nb,getDimensions:Ob,getScale:Ar,isElement:un,isRTL:$b};function Ed(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Bb(e,t){let n=null,r;const o=yn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:p,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=ns(p),g=ns(o.clientWidth-(d+m)),x=ns(o.clientHeight-(p+f)),y=ns(d),C={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Zt(0,Ln(1,l))||1};let k=!0;function S(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Ed(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(S,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,C)}n.observe(e)}return i(!0),s}function zb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=ia(e),d=o||s?[...c?io(c):[],...io(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const p=c&&a?Bb(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[b]=y;b&&b.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var C;(C=f)==null||C.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?nr(e):null;l&&x();function x(){const y=nr(e);g&&!Ed(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),p==null||p(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const Hb=fb,Ub=pb,Wb=cb,Vb=mb,Kb=ub,Id=lb,qb=hb,Gb=(e,t,n)=>{const r=new Map,o={platform:Fb,...n},s={...o.platform,_c:r};return ab(e,t,{...o,platform:s})};var Yb=typeof document<"u",Xb=function(){},cs=Yb?w.useLayoutEffect:Xb;function us(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(!us(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)&&!us(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Nd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ad(e,t){const n=Nd(e);return Math.round(t*n)/n}function la(e){const t=h.useRef(e);return cs(()=>{t.current=e}),t}function Jb(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,p]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=h.useState(r);us(m,r)||f(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),b=h.useCallback(j=>{j!==T.current&&(T.current=j,g(j))},[]),C=h.useCallback(j=>{j!==E.current&&(E.current=j,y(j))},[]),k=s||v,S=i||x,T=h.useRef(null),E=h.useRef(null),P=h.useRef(d),_=l!=null,$=la(l),L=la(o),F=la(c),G=h.useCallback(()=>{if(!T.current||!E.current)return;const j={placement:t,strategy:n,middleware:m};L.current&&(j.platform=L.current),Gb(T.current,E.current,j).then(I=>{const Y={...I,isPositioned:F.current!==!1};O.current&&!us(P.current,Y)&&(P.current=Y,Kr.flushSync(()=>{p(Y)}))})},[m,t,n,L,F]);cs(()=>{c===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,p(j=>({...j,isPositioned:!1})))},[c]);const O=h.useRef(!1);cs(()=>(O.current=!0,()=>{O.current=!1}),[]),cs(()=>{if(k&&(T.current=k),S&&(E.current=S),k&&S){if($.current)return $.current(k,S,G);G()}},[k,S,G,$,_]);const K=h.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:C}),[b,C]),q=h.useMemo(()=>({reference:k,floating:S}),[k,S]),H=h.useMemo(()=>{const j={position:n,left:0,top:0};if(!q.floating)return j;const I=Ad(q.floating,d.x),Y=Ad(q.floating,d.y);return a?{...j,transform:"translate("+I+"px, "+Y+"px)",...Nd(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:Y}},[n,a,q.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:G,refs:K,elements:q,floatingStyles:H}),[d,G,K,q,H])}const Zb=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?Id({element:r.current,padding:o}).fn(n):{}:r?Id({element:r,padding:o}).fn(n):{}}}},Qb=(e,t)=>({...Hb(e),options:[e,t]}),ey=(e,t)=>({...Ub(e),options:[e,t]}),ty=(e,t)=>({...qb(e),options:[e,t]}),ny=(e,t)=>({...Wb(e),options:[e,t]}),ry=(e,t)=>({...Vb(e),options:[e,t]}),oy=(e,t)=>({...Kb(e),options:[e,t]}),sy=(e,t)=>({...Zb(e),options:[e,t]});var iy="Arrow",Pd=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(fe.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});Pd.displayName=iy;var ay=Pd;function jd(e){const[t,n]=h.useState(void 0);return It(()=>{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 i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ca="Popper",[_d,Pr]=cn(ca),[ly,Rd]=_d(ca),Md=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(ly,{scope:t,anchor:r,onAnchorChange:o,children:n})};Md.displayName=ca;var Od="PopperAnchor",Dd=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Rd(Od,n),i=h.useRef(null),a=De(t,i),l=h.useRef(null);return h.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(fe.div,{...o,ref:a})});Dd.displayName=Od;var ua="PopperContent",[cy,uy]=_d(ua),Ld=h.forwardRef((e,t)=>{var N,M,U,Z,se,ae;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=Rd(ua,n),[y,b]=h.useState(null),C=De(t,Ce=>b(Ce)),[k,S]=h.useState(null),T=jd(k),E=(T==null?void 0:T.width)??0,P=(T==null?void 0:T.height)??0,_=r+(s!=="center"?"-"+s:""),$=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},L=Array.isArray(c)?c:[c],F=L.length>0,G={padding:$,boundary:L.filter(fy),altBoundary:F},{refs:O,floatingStyles:K,placement:q,isPositioned:H,middlewareData:j}=Jb({strategy:"fixed",placement:_,whileElementsMounted:(...Ce)=>zb(...Ce,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Qb({mainAxis:o+P,alignmentAxis:i}),l&&ey({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?ty():void 0,...G}),l&&ny({...G}),ry({...G,apply:({elements:Ce,rects:we,availableWidth:je,availableHeight:We})=>{const{width:Fe,height:Ye}=we.reference,He=Ce.floating.style;He.setProperty("--radix-popper-available-width",`${je}px`),He.setProperty("--radix-popper-available-height",`${We}px`),He.setProperty("--radix-popper-anchor-width",`${Fe}px`),He.setProperty("--radix-popper-anchor-height",`${Ye}px`)}}),k&&sy({element:k,padding:a}),py({arrowWidth:E,arrowHeight:P}),m&&oy({strategy:"referenceHidden",...G})]}),[I,Y]=Bd(q),J=pt(v);It(()=>{H&&(J==null||J())},[H,J]);const D=(N=j.arrow)==null?void 0:N.x,V=(M=j.arrow)==null?void 0:M.y,R=((U=j.arrow)==null?void 0:U.centerOffset)!==0,[B,X]=h.useState();return It(()=>{y&&X(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:H?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:B,"--radix-popper-transform-origin":[(Z=j.transformOrigin)==null?void 0:Z.x,(se=j.transformOrigin)==null?void 0:se.y].join(" "),...((ae=j.hide)==null?void 0:ae.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(cy,{scope:n,placedSide:I,onArrowChange:S,arrowX:D,arrowY:V,shouldHideArrow:R,children:u.jsx(fe.div,{"data-side":I,"data-align":Y,...g,ref:C,style:{...g.style,animation:H?void 0:"none"}})})})});Ld.displayName=ua;var $d="PopperArrow",dy={top:"bottom",right:"left",bottom:"top",left:"right"},Fd=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=uy($d,r),i=dy[s.placedSide];return u.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]: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:u.jsx(ay,{...o,ref:n,style:{...o.style,display:"block"}})})});Fd.displayName=$d;function fy(e){return e!==null}var py=e=>({name:"transformOrigin",options:e,fn(t){var x,y,b;const{placement:n,rects:r,middlewareData:o}=t,i=((x=o.arrow)==null?void 0:x.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=Bd(n),p={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?p:`${m}px`,g=`${-l}px`):c==="top"?(v=i?p:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?p:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?p:`${f}px`),{data:{x:v,y:g}}}});function Bd(e){const[t,n="center"]=e.split("-");return[t,n]}var da=Md,fa=Dd,pa=Ld,ha=Fd,hy="Portal",ao=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Oo.createPortal(u.jsx(fe.div,{...r,ref:t}),i):null});ao.displayName=hy;function my(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ut=e=>{const{present:t,children:n}=e,r=gy(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=De(r.ref,xy(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Ut.displayName="Presence";function gy(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=my(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=ds(r.current);s.current=a==="mounted"?c:"none"},[a]),It(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=ds(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,p=f=>{const g=ds(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=f=>{f.target===t&&(s.current=ds(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function ds(e){return(e==null?void 0:e.animationName)||"none"}function xy(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 ma="rovingFocusGroup.onEntryFocus",vy={bubbles:!1,cancelable:!0},lo="RovingFocusGroup",[ga,zd,wy]=Zo(lo),[by,Hd]=cn(lo,[wy]),[yy,Sy]=by(lo),Ud=h.forwardRef((e,t)=>u.jsx(ga.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ga.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Cy,{...e,ref:t})})}));Ud.displayName=lo;var Cy=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...p}=e,m=h.useRef(null),f=De(t,m),v=Qo(s),[g,x]=On({prop:i,defaultProp:a??null,onChange:l,caller:lo}),[y,b]=h.useState(!1),C=pt(c),k=zd(n),S=h.useRef(!1),[T,E]=h.useState(0);return h.useEffect(()=>{const P=m.current;if(P)return P.addEventListener(ma,C),()=>P.removeEventListener(ma,C)},[C]),u.jsx(yy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(P=>x(P),[x]),onItemShiftTab:h.useCallback(()=>b(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(P=>P+1),[]),onFocusableItemRemove:h.useCallback(()=>E(P=>P-1),[]),children:u.jsx(fe.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:ie(e.onMouseDown,()=>{S.current=!0}),onFocus:ie(e.onFocus,P=>{const _=!S.current;if(P.target===P.currentTarget&&_&&!y){const $=new CustomEvent(ma,vy);if(P.currentTarget.dispatchEvent($),!$.defaultPrevented){const L=k().filter(q=>q.focusable),F=L.find(q=>q.active),G=L.find(q=>q.id===g),K=[F,G,...L].filter(Boolean).map(q=>q.ref.current);Kd(K,d)}}S.current=!1}),onBlur:ie(e.onBlur,()=>b(!1))})})}),Wd="RovingFocusGroupItem",Vd=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=_t(),c=s||l,d=Sy(Wd,n),p=d.currentTabStopId===c,m=zd(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(ga.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(fe.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ie(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ie(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ie(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Ey(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let C=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")C.reverse();else if(y==="prev"||y==="next"){y==="prev"&&C.reverse();const k=C.indexOf(x.currentTarget);C=d.loop?Iy(C,k+1):C.slice(k+1)}setTimeout(()=>Kd(C))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});Vd.displayName=Wd;var Ty={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ky(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ey(e,t,n){const r=ky(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ty[r]}function Kd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Iy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ny=Ud,Ay=Vd,Py=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},jr=new WeakMap,fs=new WeakMap,ps={},xa=0,qd=function(e){return e&&(e.host||qd(e.parentNode))},jy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=qd(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})},_y=function(e,t,n,r){var o=jy(t,Array.isArray(e)?e:[e]);ps[n]||(ps[n]=new WeakMap);var s=ps[n],i=[],a=new Set,l=new Set(o),c=function(p){!p||a.has(p)||(a.add(p),c(p.parentNode))};o.forEach(c);var d=function(p){!p||l.has(p)||Array.prototype.forEach.call(p.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(jr.get(m)||0)+1,x=(s.get(m)||0)+1;jr.set(m,g),s.set(m,x),i.push(m),g===1&&v&&fs.set(m,!0),x===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),a.clear(),xa++,function(){i.forEach(function(p){var m=jr.get(p)-1,f=s.get(p)-1;jr.set(p,m),s.set(p,f),m||(fs.has(p)||p.removeAttribute(r),fs.delete(p)),f||p.removeAttribute(n)}),xa--,xa||(jr=new WeakMap,jr=new WeakMap,fs=new WeakMap,ps={})}},va=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Py(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),_y(r,o,n,"aria-hidden")):function(){return null}},Cn=function(){return Cn=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},Cn.apply(this,arguments)};function Gd(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 Ry(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 hs="right-scroll-bar-position",ms="width-before-scroll-bar",My="with-scroll-bars-hidden",Oy="--removed-body-scroll-bar-size";function wa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Dy(e,t){var n=w.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 Ly=typeof window<"u"?h.useLayoutEffect:h.useEffect,Yd=new WeakMap;function $y(e,t){var n=Dy(null,function(r){return e.forEach(function(o){return wa(o,r)})});return Ly(function(){var r=Yd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||wa(a,null)}),s.forEach(function(a){o.has(a)||wa(a,i)})}Yd.set(n,e)},[e]),n}function Fy(e){return e}function By(e,t){t===void 0&&(t=Fy);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 i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function zy(e){e===void 0&&(e={});var t=By(null);return t.options=Cn({async:!0,ssr:!1},e),t}var Xd=function(e){var t=e.sideCar,n=Gd(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 h.createElement(r,Cn({},n))};Xd.isSideCarExport=!0;function Hy(e,t){return e.useMedium(t),Xd}var Jd=zy(),ba=function(){},gs=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:ba,onWheelCapture:ba,onTouchMoveCapture:ba}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,p=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,C=e.gapMode,k=Gd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,T=$y([n,t]),E=Cn(Cn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(S,{sideCar:Jd,removeScrollBar:c,shards:p,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:C}),i?h.cloneElement(h.Children.only(a),Cn(Cn({},E),{ref:T})):h.createElement(b,Cn({},E,{className:l,ref:T}),a))});gs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},gs.classNames={fullWidth:ms,zeroRight:hs};var Uy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Wy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Uy();return t&&e.setAttribute("nonce",t),e}function Vy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ky(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var qy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Wy())&&(Vy(t,n),Ky(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Gy=function(){var e=qy();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Zd=function(){var e=Gy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Yy={left:0,top:0,right:0,gap:0},ya=function(e){return parseInt(e||"",10)||0},Xy=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[ya(n),ya(r),ya(o)]},Jy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Yy;var t=Xy(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])}},Zy=Zd(),_r="data-scroll-locked",Qy=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
40
|
-
.`.concat(
|
|
38
|
+
`);if(!at)continue;let lt;try{lt=JSON.parse(at)}catch{console.debug("[use-chat] malformed SSE:",at.slice(0,200));continue}const Et=du(lt)?lt.data:lt;if(!Et){console.warn("[use-chat] dropped envelope event without payload",lt);continue}const ke=Et;Pt=Date.now();const Ee=ke.seq;if(Ee!==void 0){if(Ee<=mt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Ee,lastProcessedSeq:mt,type:ke.type});continue}mt>0&&Ee>mt+1&&((se=I==null?void 0:I.onGap)==null||se.call(I,{from:mt,to:Ee})),mt=Ee,E.current=Ee,x(Ee)}if(ke.type==="message.start"&&ke.role==="assistant"){const be=mu(ke.model);F.current={messageId:ke.id,lastSeq:Ee??null,lastText:""},k({id:ke.id,role:"assistant",name:be??void 0,model:ke.model,createdAt:new Date().toISOString(),content:[]})}if(ke.type==="checkpoint")_.current=ke.checkpointId??null,$.current=ke.checkpointNs??null,v(ke.checkpointId??null);else if(ke.type==="state_history"){L.current=ke;try{const Xe=Yn(ke).latest;Xe&&(_.current=Xe.checkpointId??null,$.current=Xe.checkpointNs??null,v(Xe.checkpointId??null))}catch(be){console.warn("[use-chat] Failed to hydrate state_history payload",be)}}try{j==null||j(ke)}catch(be){console.error("[use-chat] Error in onEvent callback:",be,"for event:",ke.type)}if(ke.type==="message.delta"){k(Xe=>{const At=F.current;if(!Xe||At.messageId!==Xe.id)return Xe;const{newParts:A,newMeta:ee,changed:Q}=hu(Xe.content??[],ke.delta,{lastSeq:At.lastSeq,lastText:At.lastText},Ee??null);return Q?(F.current={...At,lastSeq:ee.lastSeq??At.lastSeq,lastText:ee.lastText??At.lastText},{...Xe,content:A}):Xe});const be=ke.delta.filter(Xe=>Xe.type==="text").map(Xe=>Xe.text).join("");be&&e.autoAppendAssistant!==!1&&(bt.push(be),Dt())}else if(ke.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(ae=I==null?void 0:I.onHeartbeat)==null||ae.call(I,ke)}catch(be){console.warn("[use-chat] heartbeat callback failed",be)}}else if(Ct!==null&&cancelAnimationFrame(Ct),Tt(),ke.type==="checkpoint")v(ke.checkpointId);else if(ke.type==="error"){const be=ke;if(d(be.message),J="error",D=be.message,be.error_type==="auth_error"||be.code==="TOKEN_EXPIRED"||((Ce=be.message)==null?void 0:Ce.includes("token"))||((we=be.message)==null?void 0:we.includes("401"))||((je=be.message)==null?void 0:je.includes("unauthorized"))||((We=be.message)==null?void 0:We.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",be.message);try{(Fe=I==null?void 0:I.onAuthError)==null||Fe.call(I,be.message)}catch(At){console.warn("[use-chat] onAuthError handler failed",At)}Y.abort()}}}}Tt(),J===null&&!Y.signal.aborted&&(J="complete")}catch(Ue){if(Ue.name==="AbortError")J=J??"aborted";else{const $e=Ue.message||String(Ue);J="error",D=$e,d($e),(Ye=I==null?void 0:I.onError)==null||Ye.call(I,$e)}}finally{try{await Qe.cancel()}catch{}finally{(He=Qe.releaseLock)==null||He.call(Qe)}Ct!==null&&typeof window<"u"&&window.cancelAnimationFrame(Ct),clearInterval(kt)}}catch(Ve){if(Ve.name==="AbortError")J=J??"aborted";else{const Ae=Ve.message||String(Ve);J="error",D=Ae,d(Ae),(vt=I==null?void 0:I.onError)==null||vt.call(I,Ae),V||((wt=I==null?void 0:I.onConnectionError)==null||wt.call(I,Ae),V=!0)}}finally{const Ve=E.current,Ae=_.current,Ke=$.current,_e=L.current,Be=J??(Y.signal.aborted?"aborted":D?"error":"complete");try{(dt=I==null?void 0:I.onClosed)==null||dt.call(I,{reason:Be,lastSeq:Ve,lastCheckpointId:Ae,lastCheckpointNs:Ke,lastStateHistory:_e,error:D})}catch(Qe){console.warn("[use-chat] onClosed callback failed",Qe)}l(!1),b(!1),S.current=null,E.current=0,x(0),P.current=null}})(),{close:()=>Y.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var H;T.current=!1,(H=S.current)==null||H.abort()},[]),{isStreaming:a,error:c,assistantText:p,assistantMessage:C,lastCheckpointId:f,lastSeq:g,connected:y,stream:q,stop:K,clear:O,setToken:G}}const sw=["detail","message","error","description","title"];function Xo(e){if(!e)return null;if(typeof e=="string"){const t=e.trim();return t.length?t:null}if(Array.isArray(e)){for(const t of e){const n=Xo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of sw){const r=Xo(t[n]);if(r)return r}if("errors"in t){const n=Xo(t.errors);if(n)return n}}return null}function iw(e){if(!e)return"Request failed";const t=e.response,n=Xo(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function gu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=w.useState([]),[a,l]=w.useState(t),[c,d]=w.useState(!1),[p,m]=w.useState(null),[f,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,C]=w.useState(null),[k,S]=w.useState(!1),T=w.useRef(a),E=w.useRef(new Map);w.useEffect(()=>{T.current=a},[a]);const P=w.useCallback(async()=>{d(!0),m(null);try{const j=await e.listThreads();i(j??[])}catch(j){const I=String(j);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),_=w.useCallback(async()=>{x(!0),y(null);try{const j=await e.listSharedThreads();v(j??[])}catch(j){const I=String(j);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);w.useEffect(()=>{P()},[P]),w.useEffect(()=>{_()},[_]),w.useEffect(()=>{r==null||r(a)},[a,r]);const $=w.useCallback(async j=>{try{const I=await e.createThread(j);return l(I.threadId),await P(),I.threadId}catch(I){const Y=String(I);return n==null||n(Y),null}},[e,n,P]),L=w.useCallback(async j=>{const I=s;i(J=>J.filter(D=>D.threadId!==j));const Y=new AbortController;E.current.set(j,Y);try{await e.deleteThread(j),T.current===j&&(l(null),o==null||o())}catch(J){i(I);const D=String(J);n==null||n(D)}finally{E.current.delete(j)}},[e,o,n,s]),F=w.useCallback(async(j,I)=>{try{await e.updateThread(j,I),await P()}catch(Y){n==null||n(String(Y))}},[e,n,P]),G=w.useCallback(async(j,I)=>{S(!0),C("Sharing thread…");try{await e.shareThread(j,I),await _(),C("Shared successfully")}catch(Y){const J=iw(Y);throw n==null||n(J),C(`Failed to share: ${J}`),new Error(J)}finally{S(!1)}},[e,n,_]),O=w.useCallback(async(j,I)=>{try{await e.unshareThread(j,I),await _()}catch(Y){const J=String(Y);throw n==null||n(J),Y}},[e,n,_]),K=w.useMemo(()=>({createThread:$,deleteThread:L,renameThread:F,refreshThreads:P,refreshSharedThreads:_,shareThread:G,unshareThread:O}),[$,L,F,P,_,G,O]),q=w.useCallback(j=>{if(!(j!=null&&j.threadId))return;const I={threadId:j.threadId,title:j.title||`Thread ${j.threadId.slice(0,8)}`,createdAt:j.createdAt||new Date().toISOString(),updatedAt:j.updatedAt||new Date().toISOString(),messageCount:j.messageCount??1};i(Y=>{let J=!1;const D=Y.map(V=>V.threadId===I.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...V,title:I.title??V.title,updatedAt:I.updatedAt??V.updatedAt,messageCount:I.messageCount??V.messageCount}):V);return J?D:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...Y])})},[]),H=w.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:p,sharedThreads:f,isLoadingSharedThreads:g,actions:K,addThreadFromEvent:q,shareInFlight:k,shareStatus:b,clearShareStatus:H}}const xu=w.createContext(null);function vu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=eo(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=gu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),b=w.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,p,m,f,g,x,y,v]);return u.jsx(xu.Provider,{value:b,children:e})}function br(){const e=w.useContext(xu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Qn(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{const n=aw(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function aw(e){let t=!1,n="";for(const o of e){if(o==="\\"){n+=o,t=!t;continue}if(o==="'"&&!t){n+='"';continue}n+=o,t=!1}return n.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null")}function $i(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function yr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(yr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if($i(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=yr(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function er(e){if(typeof e=="string")return e;if($i(e))return"";try{const t=yr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function wu(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function bu(e){const t=er(e);return typeof e=="string"&&wu(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function tr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Qn(t);if(n!==null)return tr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?tr(e.content):e}function yu(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Jo(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function Fi(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Su(e){const t=r=>{try{const o=yr(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
39
|
+
`)):t(e)}function Cu(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Bi(e){if(e.role==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(i=>{switch(i.type){case"text":return`t:${i.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"",r="checkpointId"in e&&e.checkpointId?`cp:${e.checkpointId}`:"",o="checkpointNs"in e&&e.checkpointNs?`ns:${e.checkpointNs}`:"",s=[r,o].filter(Boolean).join("|");return`${e.id}:${t}:${n}${s?`:${s}`:""}`}function Tu(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function ku(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Eu({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Tu(n),i=o?`data:${s};base64,${e}`:t,a=ku(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function Iu(e){var o,s;const t=((o=e.content_base64)==null?void 0:o.trim())||void 0,n=((s=e.url)==null?void 0:s.trim())||void 0,r=e.format||e.mimeType||e.mime_type;return Eu({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function zi(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}function Sr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim(),n=Qn(t);return n!==null?Sr(n):t}if(Array.isArray(e))return e.map(t=>Sr(t));if(typeof e=="object"){const t=e.value;if(t!==void 0)return Sr(t)}return e}function Nu(e){const t=Sr(e.value);return t===e.value?e:{...e,value:t}}const lw={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function cw(e,t){var n;switch(t.type){case"reset":return{messages:Li(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=Li(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=Li(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return Au(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Au(o,s),e):e}default:return e}}function uw(e=[]){const[t,n]=w.useReducer(cw,{...lw,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=w.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=w.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,p)=>n({type:"seed",payload:{messages:d,...p??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,p)=>n({type:"user_message",payload:{message:d,editingMessageId:p}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function Au(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=mu(t.model);if(e.messages.some(c=>c.id===s)){const c=e.messagesStreamMeta??{},d={...c,[s]:c[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const l={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,l]}}if(t.type==="tool.start")return fw(e,t);if(t.type==="tool.progress")return pw(e,t);if(t.type==="tool.end")return hw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??fu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(S=>S.id===s&&S.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},p=d[s],m=p??{lastSeq:null,lastText:pu(l.content)},f=t.seq??null;if(f!==null&&typeof f=="number"&&typeof m.lastSeq=="number"&&f<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:f,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=hu(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},b=to(i,a,y),C=!p||p.lastSeq!==g.lastSeq||p.lastText!==g.lastText,k=C?{...d,[s]:g}:c;return C?{...e,messages:b,messagesStreamMeta:k}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??fu(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var p;return(d==null?void 0:d.type)==="text"&&((p=d.text)==null?void 0:p.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(p=>p==null?void 0:p.type),contentPreview:(o=l.content)==null?void 0:o.map(p=>(p==null?void 0:p.type)==="text"?String(p.text).slice(0,100):p==null?void 0:p.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=rw(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Yn(t),i=s.interrupt,a=s.latest,l=i===null?ew(e.messages):e.messages;return{...e,messages:l,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function Hi(e){return e.call_id??e.id??null}function Pu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function ju(e,t,n,r){const o=t??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:e,role:"tool",name:n??void 0,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:o,toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function Ui(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||Jo(r).toolCallId===t)return n}return-1}function dw(e){if(e==null)return[];const t=tr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=er(t??e);return n?[{type:"text",text:n}]:[]}function _u(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function fw(e,t){const n=Hi(t),r=Ui(e.messages,n),o=t.name??t.tool??void 0,s=Pu(t);if(r>=0){const a=e.messages[r],c={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:c};return{...e,messages:to(e.messages,r,d)}}const i=ju(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function pw(e,t){const n=Hi(t);if(!n)return e;const r=Ui(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=_u(e.messages[r],o);return{...e,messages:to(e.messages,r,a)}}function hw(e,t){const n=Hi(t),r=Pu(t);let o=e.messages,s=Ui(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,ju(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=dw(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const p=_u(i,d),m=t.artifact??i.artifact,f={...p,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...p.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:to(o,s,f)}}function Ru({api:e,seed:t,onError:n,currentThreadId:r,initialThreadId:o=null,initialCheckpointId:s=null,initialCheckpointNs:i=null,autoLoadInitial:a=!0,isStreaming:l,getMessages:c}){const[d,p]=w.useState(null),f=w.useMemo(()=>Yn(d),[d]).checkpoints,v=ac(f),g=v.timeline,[x,y]=w.useState(!1),[b,C]=w.useState(!1),[k,S]=w.useState(null),T=w.useRef(r),E=w.useRef(null),P=w.useRef(null),_=w.useRef(null),$=w.useRef(null),L=w.useRef(null),F=w.useRef(new Map),G=w.useRef(null);w.useEffect(()=>{T.current=r},[r]);const O=w.useCallback(async R=>{var X,N;if(!R.threadId)return;const B=R.threadId;(X=R.onStart)==null||X.call(R),R.setLoading(!0);try{await R.action(B)}catch(M){if(!Jc(M)&&T.current===B){const Z=String(M);(N=R.handleError)==null||N.call(R,Z),n==null||n(Z)}throw M}finally{R.setLoading(!1)}},[n]),K=w.useCallback(async(R,B)=>{var Z;if(!R)return;const X=`${R}:${B??"latest"}`,N=F.current.get(X);if(N)return N;(Z=G.current)==null||Z.abort();const M=new AbortController;G.current=M;const U=O({threadId:R,setLoading:y,onStart:()=>S(null),handleError:se=>S(se),action:async se=>{const ae=await e.getStateHistory({threadId:se,checkpointId:B??void 0,signal:M.signal});if(T.current!==se){console.log(`[useThreadHistoryState] Thread changed during load (was ${se}, now ${T.current}), discarding stale data`);return}const{checkpoints:Ce}=Yn(ae),we=Ce.find(je=>je.messages&&je.messages.length>0)??(B?Ce.find(je=>je.checkpointId===B):null)??Ce[0];t((we==null?void 0:we.messages)??[],{checkpointId:(we==null?void 0:we.checkpointId)??null,checkpointNs:(we==null?void 0:we.checkpointNs)??null,pendingInterrupt:(we==null?void 0:we.interrupt)??null}),p(ae)}});F.current.set(X,U);try{await U}finally{F.current.delete(X),G.current===M&&(G.current=null)}return T.current===R&&(L.current=X),U},[e,t,O]),q=w.useCallback(async(R,B)=>{$.current=R;try{await K(R,B)}catch(X){if(!Jc(X))throw X}finally{$.current===R&&($.current=null)}},[K]),H=w.useCallback(R=>{P.current=R},[]),j=w.useCallback(R=>{_.current=R},[]),I=w.useCallback(R=>{const B=R.threadId??T.current;if(!B||T.current&&T.current!==B)return;const{checkpoints:X}=Yn(R);if(!X.length)return;const N=X.find(U=>U.messages&&U.messages.length>0)??X.find(U=>!!U.checkpointId)??X[0],M=_.current===B;!l&&!M&&t((N==null?void 0:N.messages)??[],{checkpointId:(N==null?void 0:N.checkpointId)??null,checkpointNs:(N==null?void 0:N.checkpointNs)??null,pendingInterrupt:(N==null?void 0:N.interrupt)??null}),p(R),L.current=`${B}:latest`,P.current=null,_.current===B&&(_.current=null)},[t,l]),Y=w.useCallback(async(R,B)=>{const X=T.current;await O({threadId:X,setLoading:C,action:async N=>{const M=await e.getStateHistory({threadId:N,checkpointId:R,checkpointNs:B??void 0});if(T.current!==N)return;const{checkpoints:U}=Yn(M),Z=U.find(se=>se.checkpointId===R&&(B?se.checkpointNs===B:!0));if(!Z){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:R,checkpointNs:B});return}p(M),t(Z.messages??[],{checkpointId:Z.checkpointId??null,checkpointNs:Z.checkpointNs??null})}}).catch(()=>{})},[e,t,O]),J=w.useCallback((R,B)=>{t(c(),{checkpointId:R??null,checkpointNs:B??null})},[c,t]),D=w.useCallback(async()=>{T.current&&await q(T.current)},[q]);w.useEffect(()=>{if(!a||!r||x||l)return;if(P.current===r){P.current=null,E.current=r;return}if(_.current===r){E.current=r;return}if($.current===r){$.current=null,E.current=r;return}if(E.current===r)return;E.current=r;let R;const B=`${r}:latest`;L.current!==B&&q(r,R)},[a,r,s,i,o,x,l,q]);const V=w.useCallback(()=>{p(null),y(!1),C(!1),S(null),P.current=null,_.current=null,E.current=null,L.current=null,$.current=null},[]);return{threadCheckpoints:f,threadTimeline:g,checkpointIndex:v,isLoadingThread:x,isLoadingCheckpoint:b,threadStateError:k,loadThread:q,navigateToCheckpoint:Y,setCurrentCheckpointId:J,returnToLatest:D,handleStateHistoryEvent:I,markSkipNextLoad:H,markStreamPendingThread:j,resetHistoryState:V}}const Mu=w.createContext(null),Ou=w.createContext(null);function no(){const e=w.useContext(Mu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Du(){const e=w.useContext(Ou);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Lu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=eo(),{currentThreadId:l}=br(),{state:c,seed:d,pushUser:p,onEvent:m}=uw(),{threadCheckpoints:f,threadTimeline:v,checkpointIndex:g,isLoadingThread:x,isLoadingCheckpoint:y,threadStateError:b,loadThread:C,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,handleStateHistoryEvent:E,markSkipNextLoad:P,markStreamPendingThread:_,resetHistoryState:$}=Ru({api:a,seed:d,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:w.useCallback(()=>c.messages,[c.messages])}),[L,F]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[G,O]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),$())},[l,d,$]);const K=w.useCallback(Y=>F(()=>Y),[]),q=w.useCallback(Y=>O(()=>Y),[]),H=w.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),j=w.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:f,checkpointIndex:g,timelineCheckpoints:v,metadata:H,isLoading:x,isLoadingCheckpoint:y,error:b,clearState:L,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,loadThread:C,clearThread:L,respondToInterrupt:G,messagePreviews:g.messagePreviews,handleStateHistoryEvent:E,markSkipNextLoad:P,markStreamPendingThread:_,resetHistoryState:$,pushUser:p,onEvent:m}),[l,c,f,v,g,H,x,y,b,L,k,S,T,C,G,g.messagePreviews,E,P,_,$,p,m]),I=w.useMemo(()=>({registerClearThread:K,registerRespondToInterrupt:q}),[K,q]);return u.jsx(Ou.Provider,{value:I,children:u.jsx(Mu.Provider,{value:j,children:e})})}function $u(e,t){if(!e)return null;const n=_n(e);if(!n)return null;const r=_n(n.configurable)??n;return Rn(r,t)??null}function mw(e){const t=$u(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=$u(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function gw(e,t){const n=typeof e.step=="number"?e.step:Number.POSITIVE_INFINITY,r=typeof t.step=="number"?t.step:Number.POSITIVE_INFINITY;if(n!==r)return n-r;const o=e.createdAt?Date.parse(e.createdAt):0,s=t.createdAt?Date.parse(t.createdAt):0;return o-s}function xw(e,t){const n=[...e].sort(gw);for(const r of n){if(r.messageId!==t)continue;const o=mw(r.parentConfig);if(!o)throw new Error(`Parent checkpoint info missing for message ${t}`);return o}throw new Error(`Message ${t} not found in timeline`)}const Fu=w.createContext(null),Bu=w.createContext(!1);function vw({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:p}=eo(),m=w.useMemo(()=>vn(p),[p]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=ow({baseUrl:m}),[b,C]=w.useState(!1);return w.useEffect(()=>{C(g)},[g]),u.jsx(vu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Lu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(Bu.Provider,{value:!0,children:u.jsx(ww,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function ww({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:p}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=br(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:C,resetHistoryState:k,pushUser:S,onEvent:T}=no(),{registerClearThread:E,registerRespondToInterrupt:P}=Du(),_=w.useCallback(H=>{v(H),f.current!==H.threadId&&((H.created??!f.current)&&b(H.threadId),C(H.threadId),m(H.threadId))},[v,b,C,m,f]),$=w.useCallback(H=>{H.type==="thread_info"?_(H):H.type==="state_history"?y(H):H.type==="tool.end"?i==null||i(H):T(H)},[_,y,T,i]),L=w.useCallback(H=>{a(H,$,{onError:j=>{console.error("[StreamingProvider] Stream error:",j),r==null||r(j)},onAuthError:j=>{console.error("[StreamingProvider] Auth error:",j),o==null||o(j)},onConnectionError:j=>{console.error("[StreamingProvider] Connection error:",j),s==null||s(j)}})},[a,$,r,o,s]),F=w.useRef(g);w.useEffect(()=>{F.current=g},[g]);const G=w.useCallback(async(H,j,I)=>{const Y=f.current;if(!Y)throw new Error("No active thread to handle interrupt");const J=H?j??!0:!1,D=F.current,V={threadId:Y,checkpointId:D.id??void 0,checkpointNs:D.namespace??void 0,command:{kind:"resume",value:J},payload:I==null?void 0:I.payload,config:I==null?void 0:I.config,nodeFilter:I==null?void 0:I.nodeFilter,branchLabel:I==null?void 0:I.branchLabel,active_agent:I==null?void 0:I.active_agent,timelineCheckpoints:I==null?void 0:I.timelineCheckpoints};L(V)},[f,L]);w.useEffect(()=>{P(G)},[G,P]);const O=w.useCallback(async()=>{l(),k(),m(null)},[k,m,l]);w.useEffect(()=>{E(O)},[O,E]);const K=w.useCallback(async(H,j)=>{let I=f.current;const Y=(H==null?void 0:H.text)??"",J=(H==null?void 0:H.attachments)??[],D=(Y==null?void 0:Y.trim())??"",V={...(H==null?void 0:H.payload)??{}},R=Array.isArray(V.messages)?V.messages:void 0;R&&delete V.messages;const B=!!(R&&R.length);if(!I&&!D&&J.length===0&&!B)return;if(!I){const Ye=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),He=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Ye}${He}`,b(I),m(I)}const{contentParts:X,filesInfo:N}=await uu(J),M=[...X];D&&M.push({type:"text",text:Y});const U=j==null?void 0:j.originalMessageId,Z=!!(j!=null&&j.edit&&U),se=!B&&M.length>0;let ae=null;se&&(ae={id:Z?U:`msg-${Date.now()}`,role:"user",content:M,createdAt:new Date().toISOString()},Z?S(ae,U):S(ae));const Ce=B?R:ae?[ae]:[],we={...V,...N.length?{files_info:N}:{}};Ce.length?we.messages=Ce:"messages"in we||(we.messages=[]);let je=(j==null?void 0:j.checkpointId)??g.id??void 0,We=(j==null?void 0:j.checkpointNs)??g.namespace??void 0;if(Z&&U){const Ye=xw(x,U);je=Ye.checkpointId,We=Ye.checkpointNs??void 0}const Fe={threadId:I,payload:we,checkpointId:je,checkpointNs:We,edit:!!(j!=null&&j.edit)};L(Fe)},[g,f,b,S,L,x]),q=w.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:K,send:K,stop:l,setAuthToken:p}),[c,d,K,l,p]);return u.jsx(Fu.Provider,{value:q,children:e})}function Wi(){const e=w.useContext(Fu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function bw(){return w.useContext(Bu)}function zu(e){return typeof e=="object"&&e!==null}function yw(e,t){if(Object.is(e,t))return!0;if(!zu(e)||!zu(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function Hu(e){const t=w.useRef(e),n=w.useRef(e);return yw(t.current,e)||(t.current=e,n.current=e),n.current}function Cr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const p=Hu(t),m=ro(a),f=ro(l),v=ro(i),g=ro(c),x=ro(d),y=w.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:f,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,f,v,g,x]);return u.jsx(lu,{apiConfig:p,children:u.jsx(vw,{...y,children:e})})}function ro(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e},[e]),w.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function Tr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function Sw(e){if(typeof e!="string")return;const t=e.trim();if(t)return vn(t)}function Uu(){const e=[Tr("__API_BASE_URL__"),Tr("__CHAT_API_BASE_URL__"),Tr("__CHAT_API_URL__")];for(const t of e){const n=Sw(t);if(n)return n}}function Wu(){const e=[Tr("__API_AUTH_TOKEN__"),Tr("__CHAT_API_KEY__"),Tr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Vu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return vn(t);return vn()}function Ku(){const e={},t=Uu(),n=Wu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function qu(){const e=Ku(),t=Nn.getAuthToken(),n=Uu();return{apiBaseUrl:Vu(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||Wu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Vi="chat-settings";function Gu(){try{const e=localStorage.getItem(Vi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Yu(e){try{const t={...e,apiBaseUrl:vn(e.apiBaseUrl)};localStorage.setItem(Vi,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Cw(){const e=qu(),t=Gu(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Vu(Nn.baseUrl,r,e.apiBaseUrl)}}function Tw(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Yu(e)}function re(...e){return hx.twMerge(px.clsx(e))}const kw=Vr.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"}}),Je=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yt.Slot:"button";return u.jsx(i,{className:re(kw({variant:t,size:n,className:e})),ref:s,...o})});Je.displayName="Button";function ie(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 Xu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Mn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Xu(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():Xu(e[o],null)}}}}function De(...e){return h.useCallback(Mn(...e),e)}function Ew(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=h.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function cn(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),l=n.length;n=[...n,i];const c=p=>{var y;const{scope:m,children:f,...v}=p,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=h.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(p,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=h.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Iw(o,...t)]}function Iw(...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 i=r.reduce((a,{useScope:l,scopeName:c})=>{const p=l(s)[`__scope${c}`];return{...a,...p}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var It=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},Nw=h[" useInsertionEffect ".trim().toString()]||It;function On({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Aw({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const p=d.current;p!==a&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${a?"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.`),d.current=a},[a,r])}const c=h.useCallback(d=>{var p;if(a){const m=Pw(d)?d(e):d;m!==e&&((p=i.current)==null||p.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Aw({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return Nw(()=>{s.current=t},[t]),h.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Pw(e){return typeof e=="function"}var jw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],fe=jw.reduce((e,t)=>{const n=Yt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ki(e,t){e&&Kr.flushSync(()=>e.dispatchEvent(t))}function Zo(e){const t=e+"CollectionProvider",[n,r]=cn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,b=w.useRef(null),C=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:C,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Yt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,C=s(a,y),k=De(x,C.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",p="data-radix-collection-item",m=Yt.createSlot(d),f=w.forwardRef((g,x)=>{const{scope:y,children:b,...C}=g,k=w.useRef(null),S=De(x,k),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...C}),()=>void T.itemMap.delete(k))),u.jsx(m,{[p]:"",ref:S,children:b})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return w.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const C=Array.from(b.querySelectorAll(`[${p}]`));return Array.from(x.itemMap.values()).sort((T,E)=>C.indexOf(T.ref.current)-C.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var _w=h.createContext(void 0);function Qo(e){const t=h.useContext(_w);return e||t||"ltr"}function pt(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Rw(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e);h.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 Mw="DismissableLayer",qi="dismissableLayer.update",Ow="dismissableLayer.pointerDownOutside",Dw="dismissableLayer.focusOutside",Ju,Zu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),kr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Zu),[d,p]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=h.useState({}),v=De(t,E=>p(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,C=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=y,S=$w(E=>{const P=E.target,_=[...c.branches].some($=>$.contains(P));!k||_||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Fw(E=>{const P=E.target;[...c.branches].some($=>$.contains(P))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Rw(E=>{b===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Ju=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),ed(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Ju)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),ed())},[d,c]),h.useEffect(()=>{const E=()=>f({});return document.addEventListener(qi,E),()=>document.removeEventListener(qi,E)},[]),u.jsx(fe.div,{...l,ref:v,style:{pointerEvents:C?k?"auto":"none":void 0,...e.style},onFocusCapture:ie(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ie(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ie(e.onPointerDownCapture,S.onPointerDownCapture)})});kr.displayName=Mw;var Lw="DismissableLayerBranch",Qu=h.forwardRef((e,t)=>{const n=h.useContext(Zu),r=h.useRef(null),o=De(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(fe.div,{...e,ref:o})});Qu.displayName=Lw;function $w(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){td(Ow,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Fw(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&td(Dw,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 ed(){const e=new CustomEvent(qi);document.dispatchEvent(e)}function td(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?Ki(o,s):o.dispatchEvent(s)}var Bw=kr,zw=Qu,Gi=0;function Yi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??nd()),document.body.insertAdjacentElement("beforeend",e[1]??nd()),Gi++,()=>{Gi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Gi--}},[])}function nd(){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 Xi="focusScope.autoFocusOnMount",Ji="focusScope.autoFocusOnUnmount",rd={bubbles:!1,cancelable:!0},Hw="FocusScope",es=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=pt(o),d=pt(s),p=h.useRef(null),m=De(t,g=>l(g)),f=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(C){if(f.paused||!a)return;const k=C.target;a.contains(k)?p.current=k:Dn(p.current,{select:!0})},x=function(C){if(f.paused||!a)return;const k=C.relatedTarget;k!==null&&(a.contains(k)||Dn(p.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const S of C)S.removedNodes.length>0&&Dn(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),b.disconnect()}}},[r,a,f.paused]),h.useEffect(()=>{if(a){id.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Xi,rd);a.addEventListener(Xi,c),a.dispatchEvent(y),y.defaultPrevented||(Uw(Gw(od(a)),{select:!0}),document.activeElement===g&&Dn(a))}return()=>{a.removeEventListener(Xi,c),setTimeout(()=>{const y=new CustomEvent(Ji,rd);a.addEventListener(Ji,d),a.dispatchEvent(y),y.defaultPrevented||Dn(g??document.body,{select:!0}),a.removeEventListener(Ji,d),id.remove(f)},0)}}},[a,c,d,f]);const v=h.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const b=g.currentTarget,[C,k]=Ww(b);C&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Dn(C,{select:!0})):g.shiftKey&&y===C&&(g.preventDefault(),n&&Dn(k,{select:!0})):y===b&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(fe.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});es.displayName=Hw;function Uw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Dn(r,{select:t}),document.activeElement!==n)return}function Ww(e){const t=od(e),n=sd(t,e),r=sd(t.reverse(),e);return[n,r]}function od(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 sd(e,t){for(const n of e)if(!Vw(n,{upTo:t}))return n}function Vw(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 Kw(e){return e instanceof HTMLInputElement&&"select"in e}function Dn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Kw(e)&&t&&e.select()}}var id=qw();function qw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ad(e,t),e.unshift(t)},remove(t){var n;e=ad(e,t),(n=e[0])==null||n.resume()}}}function ad(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Gw(e){return e.filter(t=>t.tagName!=="A")}var Yw=h[" useId ".trim().toString()]||(()=>{}),Xw=0;function _t(e){const[t,n]=h.useState(Yw());return It(()=>{n(r=>r??String(Xw++))},[e]),t?`radix-${t}`:""}const Jw=["top","right","bottom","left"],Ln=Math.min,Zt=Math.max,ts=Math.round,ns=Math.floor,wn=e=>({x:e,y:e}),Zw={left:"right",right:"left",bottom:"top",top:"bottom"},Qw={start:"end",end:"start"};function Zi(e,t,n){return Zt(e,Ln(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function Pn(e){return e.split("-")[0]}function Er(e){return e.split("-")[1]}function Qi(e){return e==="x"?"y":"x"}function ea(e){return e==="y"?"height":"width"}const eb=new Set(["top","bottom"]);function bn(e){return eb.has(Pn(e))?"y":"x"}function ta(e){return Qi(bn(e))}function tb(e,t,n){n===void 0&&(n=!1);const r=Er(e),o=ta(e),s=ea(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=rs(i)),[i,rs(i)]}function nb(e){const t=rs(e);return[na(e),t,na(t)]}function na(e){return e.replace(/start|end/g,t=>Qw[t])}const ld=["left","right"],cd=["right","left"],rb=["top","bottom"],ob=["bottom","top"];function sb(e,t,n){switch(e){case"top":case"bottom":return n?t?cd:ld:t?ld:cd;case"left":case"right":return t?rb:ob;default:return[]}}function ib(e,t,n,r){const o=Er(e);let s=sb(Pn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(na)))),s}function rs(e){return e.replace(/left|right|bottom|top/g,t=>Zw[t])}function ab(e){return{top:0,right:0,bottom:0,left:0,...e}}function ud(e){return typeof e!="number"?ab(e):{top:e,right:e,bottom:e,left:e}}function os(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 dd(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=ta(t),a=ea(i),l=Pn(t),c=s==="y",d=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:p};break;case"left":f={x:r.x-o.width,y:p};break;default:f={x:r.x,y:r.y}}switch(Er(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const lb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:p}=dd(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:b,y:C,data:k,reset:S}=await y({x:d,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=b??d,p=C??p,f={...f,[x]:{...f[x],...k}},S&&v<=50&&(v++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(c=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:p}=dd(c,m,l)),g=-1)}return{x:d,y:p,placement:m,strategy:o,middlewareData:f}};async function oo(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:p="floating",altBoundary:m=!1,padding:f=0}=An(t,e),v=ud(f),x=a[m?p==="floating"?"reference":"floating":p],y=os(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),b=p==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},S=os(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:C,strategy:l}):b);return{top:(y.top-S.top+v.top)/k.y,bottom:(S.bottom-y.bottom+v.bottom)/k.y,left:(y.left-S.left+v.left)/k.x,right:(S.right-y.right+v.right)/k.x}}const cb=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=An(e,t)||{};if(c==null)return{};const p=ud(d),m={x:n,y:r},f=ta(o),v=ea(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",b=x?"bottom":"right",C=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],S=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[C]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[C]||s.floating[v]);const P=k/2-S/2,_=E/2-g[v]/2-1,$=Ln(p[y],_),L=Ln(p[b],_),F=$,G=E-g[v]-L,O=E/2-g[v]/2+P,K=Zi(F,O,G),q=!l.arrow&&Er(o)!=null&&O!==K&&s.reference[v]/2-(O<F?$:L)-g[v]/2<0,H=q?O<F?O-F:O-G:0;return{[f]:m[f]+H,data:{[f]:K,centerOffset:O-K-H,...q&&{alignmentOffset:H}},reset:q}}}),ub=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Pn(o),b=bn(a),C=Pn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=m||(C||!g?[rs(a)]:nb(a)),T=v!=="none";!m&&T&&S.push(...ib(a,g,v,k));const E=[a,...S],P=await oo(t,x),_=[];let $=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&_.push(P[y]),p){const O=tb(o,i,k);_.push(P[O[0]],P[O[1]])}if($=[...$,{placement:o,overflows:_}],!_.every(O=>O<=0)){var L,F;const O=(((L=s.flip)==null?void 0:L.index)||0)+1,K=E[O];if(K&&(!(p==="alignment"?b!==bn(K):!1)||$.every(j=>bn(j.placement)===b?j.overflows[0]>0:!0)))return{data:{index:O,overflows:$},reset:{placement:K}};let q=(F=$.filter(H=>H.overflows[0]<=0).sort((H,j)=>H.overflows[1]-j.overflows[1])[0])==null?void 0:F.placement;if(!q)switch(f){case"bestFit":{var G;const H=(G=$.filter(j=>{if(T){const I=bn(j.placement);return I===b||I==="y"}return!0}).map(j=>[j.placement,j.overflows.filter(I=>I>0).reduce((I,Y)=>I+Y,0)]).sort((j,I)=>j[1]-I[1])[0])==null?void 0:G[0];H&&(q=H);break}case"initialPlacement":q=a;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function fd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function pd(e){return Jw.some(t=>e[t]>=0)}const db=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=An(e,t);switch(r){case"referenceHidden":{const s=await oo(t,{...o,elementContext:"reference"}),i=fd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:pd(i)}}}case"escaped":{const s=await oo(t,{...o,altBoundary:!0}),i=fd(s,n.floating);return{data:{escapedOffsets:i,escaped:pd(i)}}}default:return{}}}}},hd=new Set(["left","top"]);async function fb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Pn(n),a=Er(n),l=bn(n)==="y",c=hd.has(i)?-1:1,d=s&&l?-1:1,p=An(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const pb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await fb(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},hb=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:i=!1,limiter:a={fn:x=>{let{x:y,y:b}=x;return{x:y,y:b}}},...l}=An(e,t),c={x:n,y:r},d=await oo(t,l),p=bn(Pn(o)),m=Qi(p);let f=c[m],v=c[p];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=f+d[x],C=f-d[y];f=Zi(b,f,C)}if(i){const x=p==="y"?"top":"left",y=p==="y"?"bottom":"right",b=v+d[x],C=v-d[y];v=Zi(b,v,C)}const g=a.fn({...t,[m]:f,[p]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[p]:i}}}}}},mb=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=An(e,t),d={x:n,y:r},p=bn(o),m=Qi(p);let f=d[m],v=d[p];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const C=m==="y"?"height":"width",k=s.reference[m]-s.floating[C]+x.mainAxis,S=s.reference[m]+s.reference[C]-x.mainAxis;f<k?f=k:f>S&&(f=S)}if(c){var y,b;const C=m==="y"?"width":"height",k=hd.has(Pn(o)),S=s.reference[p]-s.floating[C]+(k&&((y=i.offset)==null?void 0:y[p])||0)+(k?0:x.crossAxis),T=s.reference[p]+s.reference[C]+(k?0:((b=i.offset)==null?void 0:b[p])||0)-(k?x.crossAxis:0);v<S?v=S:v>T&&(v=T)}return{[m]:f,[p]:v}}}},gb=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=An(e,t),d=await oo(t,c),p=Pn(o),m=Er(o),f=bn(o)==="y",{width:v,height:g}=s.floating;let x,y;p==="top"||p==="bottom"?(x=p,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=p,x=m==="end"?"top":"bottom");const b=g-d.top-d.bottom,C=v-d.left-d.right,k=Ln(g-d[x],b),S=Ln(v-d[y],C),T=!t.middlewareData.shift;let E=k,P=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(P=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!m){const $=Zt(d.left,0),L=Zt(d.right,0),F=Zt(d.top,0),G=Zt(d.bottom,0);f?P=v-2*($!==0||L!==0?$+L:Zt(d.left,d.right)):E=g-2*(F!==0||G!==0?F+G:Zt(d.top,d.bottom))}await l({...t,availableWidth:P,availableHeight:E});const _=await i.getDimensions(a.floating);return v!==_.width||g!==_.height?{reset:{rects:!0}}:{}}}};function ss(){return typeof window<"u"}function Ir(e){return md(e)?(e.nodeName||"").toLowerCase():"#document"}function Qt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yn(e){var t;return(t=(md(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function md(e){return ss()?e instanceof Node||e instanceof Qt(e).Node:!1}function un(e){return ss()?e instanceof Element||e instanceof Qt(e).Element:!1}function Sn(e){return ss()?e instanceof HTMLElement||e instanceof Qt(e).HTMLElement:!1}function gd(e){return!ss()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qt(e).ShadowRoot}const xb=new Set(["inline","contents"]);function so(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!xb.has(o)}const vb=new Set(["table","td","th"]);function wb(e){return vb.has(Ir(e))}const bb=[":popover-open",":modal"];function is(e){return bb.some(t=>{try{return e.matches(t)}catch{return!1}})}const yb=["transform","translate","scale","rotate","perspective"],Sb=["transform","translate","scale","rotate","perspective","filter"],Cb=["paint","layout","strict","content"];function ra(e){const t=oa(),n=un(e)?dn(e):e;return yb.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)||Sb.some(r=>(n.willChange||"").includes(r))||Cb.some(r=>(n.contain||"").includes(r))}function Tb(e){let t=$n(e);for(;Sn(t)&&!Nr(t);){if(ra(t))return t;if(is(t))return null;t=$n(t)}return null}function oa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const kb=new Set(["html","body","#document"]);function Nr(e){return kb.has(Ir(e))}function dn(e){return Qt(e).getComputedStyle(e)}function as(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $n(e){if(Ir(e)==="html")return e;const t=e.assignedSlot||e.parentNode||gd(e)&&e.host||yn(e);return gd(t)?t.host:t}function xd(e){const t=$n(e);return Nr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(t)&&so(t)?t:xd(t)}function io(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=xd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Qt(o);if(s){const a=sa(i);return t.concat(i,i.visualViewport||[],so(o)?o:[],a&&n?io(a):[])}return t.concat(o,io(o,[],n))}function sa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function vd(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ts(n)!==s||ts(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ia(e){return un(e)?e:e.contextElement}function Ar(e){const t=ia(e);if(!Sn(t))return wn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=vd(t);let i=(s?ts(n.width):n.width)/r,a=(s?ts(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Eb=wn(0);function wd(e){const t=Qt(e);return!oa()||!t.visualViewport?Eb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ib(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qt(e)?!1:t}function nr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ia(e);let i=wn(1);t&&(r?un(r)&&(i=Ar(r)):i=Ar(e));const a=Ib(s,n,r)?wd(s):wn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,p=o.height/i.y;if(s){const m=Qt(s),f=r&&un(r)?Qt(r):r;let v=m,g=sa(v);for(;g&&r&&f!==v;){const x=Ar(g),y=g.getBoundingClientRect(),b=dn(g),C=y.left+(g.clientLeft+parseFloat(b.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(b.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,p*=x.y,l+=C,c+=k,v=Qt(g),g=sa(v)}}return os({width:d,height:p,x:l,y:c})}function ls(e,t){const n=as(e).scrollLeft;return t?t.left+n:nr(yn(e)).left+n}function bd(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ls(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Nb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=yn(r),a=t?is(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=wn(1);const d=wn(0),p=Sn(r);if((p||!p&&!s)&&((Ir(r)!=="body"||so(i))&&(l=as(r)),Sn(r))){const f=nr(r);c=Ar(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!p&&!s?bd(i,l):wn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+m.x,y:n.y*c.y-l.scrollTop*c.y+d.y+m.y}}function Ab(e){return Array.from(e.getClientRects())}function Pb(e){const t=yn(e),n=as(e),r=e.ownerDocument.body,o=Zt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Zt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ls(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=Zt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const yd=25;function jb(e,t){const n=Qt(e),r=yn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=oa();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ls(r);if(c<=0){const d=r.ownerDocument,p=d.body,m=getComputedStyle(p),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-p.clientWidth-f);v<=yd&&(s-=v)}else c<=yd&&(s+=c);return{width:s,height:i,x:a,y:l}}const _b=new Set(["absolute","fixed"]);function Rb(e,t){const n=nr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Sn(e)?Ar(e):wn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function Sd(e,t,n){let r;if(t==="viewport")r=jb(e,n);else if(t==="document")r=Pb(yn(e));else if(un(t))r=Rb(t,n);else{const o=wd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return os(r)}function Cd(e,t){const n=$n(e);return n===t||!un(n)||Nr(n)?!1:dn(n).position==="fixed"||Cd(n,t)}function Mb(e,t){const n=t.get(e);if(n)return n;let r=io(e,[],!1).filter(a=>un(a)&&Ir(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?$n(e):e;for(;un(i)&&!Nr(i);){const a=dn(i),l=ra(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&_b.has(o.position)||so(i)&&!l&&Cd(e,i))?r=r.filter(d=>d!==i):o=a,i=$n(i)}return t.set(e,r),r}function Ob(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?is(t)?[]:Mb(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const p=Sd(t,d,o);return c.top=Zt(p.top,c.top),c.right=Ln(p.right,c.right),c.bottom=Ln(p.bottom,c.bottom),c.left=Zt(p.left,c.left),c},Sd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Db(e){const{width:t,height:n}=vd(e);return{width:t,height:n}}function Lb(e,t,n){const r=Sn(t),o=yn(t),s=n==="fixed",i=nr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=wn(0);function c(){l.x=ls(o)}if(r||!r&&!s)if((Ir(t)!=="body"||so(o))&&(a=as(t)),r){const f=nr(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?bd(o,a):wn(0),p=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:p,y:m,width:i.width,height:i.height}}function aa(e){return dn(e).position==="static"}function Td(e,t){if(!Sn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yn(e)===n&&(n=n.ownerDocument.body),n}function kd(e,t){const n=Qt(e);if(is(e))return n;if(!Sn(e)){let o=$n(e);for(;o&&!Nr(o);){if(un(o)&&!aa(o))return o;o=$n(o)}return n}let r=Td(e,t);for(;r&&wb(r)&&aa(r);)r=Td(r,t);return r&&Nr(r)&&aa(r)&&!ra(r)?n:r||Tb(e)||n}const $b=async function(e){const t=this.getOffsetParent||kd,n=this.getDimensions,r=await n(e.floating);return{reference:Lb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Fb(e){return dn(e).direction==="rtl"}const Bb={convertOffsetParentRelativeRectToViewportRelativeRect:Nb,getDocumentElement:yn,getClippingRect:Ob,getOffsetParent:kd,getElementRects:$b,getClientRects:Ab,getDimensions:Db,getScale:Ar,isElement:un,isRTL:Fb};function Ed(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function zb(e,t){let n=null,r;const o=yn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:p,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=ns(p),g=ns(o.clientWidth-(d+m)),x=ns(o.clientHeight-(p+f)),y=ns(d),C={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Zt(0,Ln(1,l))||1};let k=!0;function S(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Ed(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(S,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,C)}n.observe(e)}return i(!0),s}function Hb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=ia(e),d=o||s?[...c?io(c):[],...io(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const p=c&&a?zb(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[b]=y;b&&b.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var C;(C=f)==null||C.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?nr(e):null;l&&x();function x(){const y=nr(e);g&&!Ed(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),p==null||p(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const Ub=pb,Wb=hb,Vb=ub,Kb=gb,qb=db,Id=cb,Gb=mb,Yb=(e,t,n)=>{const r=new Map,o={platform:Bb,...n},s={...o.platform,_c:r};return lb(e,t,{...o,platform:s})};var Xb=typeof document<"u",Jb=function(){},cs=Xb?w.useLayoutEffect:Jb;function us(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(!us(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)&&!us(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Nd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ad(e,t){const n=Nd(e);return Math.round(t*n)/n}function la(e){const t=h.useRef(e);return cs(()=>{t.current=e}),t}function Zb(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,p]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=h.useState(r);us(m,r)||f(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),b=h.useCallback(j=>{j!==T.current&&(T.current=j,g(j))},[]),C=h.useCallback(j=>{j!==E.current&&(E.current=j,y(j))},[]),k=s||v,S=i||x,T=h.useRef(null),E=h.useRef(null),P=h.useRef(d),_=l!=null,$=la(l),L=la(o),F=la(c),G=h.useCallback(()=>{if(!T.current||!E.current)return;const j={placement:t,strategy:n,middleware:m};L.current&&(j.platform=L.current),Yb(T.current,E.current,j).then(I=>{const Y={...I,isPositioned:F.current!==!1};O.current&&!us(P.current,Y)&&(P.current=Y,Kr.flushSync(()=>{p(Y)}))})},[m,t,n,L,F]);cs(()=>{c===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,p(j=>({...j,isPositioned:!1})))},[c]);const O=h.useRef(!1);cs(()=>(O.current=!0,()=>{O.current=!1}),[]),cs(()=>{if(k&&(T.current=k),S&&(E.current=S),k&&S){if($.current)return $.current(k,S,G);G()}},[k,S,G,$,_]);const K=h.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:C}),[b,C]),q=h.useMemo(()=>({reference:k,floating:S}),[k,S]),H=h.useMemo(()=>{const j={position:n,left:0,top:0};if(!q.floating)return j;const I=Ad(q.floating,d.x),Y=Ad(q.floating,d.y);return a?{...j,transform:"translate("+I+"px, "+Y+"px)",...Nd(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:Y}},[n,a,q.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:G,refs:K,elements:q,floatingStyles:H}),[d,G,K,q,H])}const Qb=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?Id({element:r.current,padding:o}).fn(n):{}:r?Id({element:r,padding:o}).fn(n):{}}}},ey=(e,t)=>({...Ub(e),options:[e,t]}),ty=(e,t)=>({...Wb(e),options:[e,t]}),ny=(e,t)=>({...Gb(e),options:[e,t]}),ry=(e,t)=>({...Vb(e),options:[e,t]}),oy=(e,t)=>({...Kb(e),options:[e,t]}),sy=(e,t)=>({...qb(e),options:[e,t]}),iy=(e,t)=>({...Qb(e),options:[e,t]});var ay="Arrow",Pd=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(fe.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});Pd.displayName=ay;var ly=Pd;function jd(e){const[t,n]=h.useState(void 0);return It(()=>{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 i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ca="Popper",[_d,Pr]=cn(ca),[cy,Rd]=_d(ca),Md=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(cy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Md.displayName=ca;var Od="PopperAnchor",Dd=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Rd(Od,n),i=h.useRef(null),a=De(t,i),l=h.useRef(null);return h.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(fe.div,{...o,ref:a})});Dd.displayName=Od;var ua="PopperContent",[uy,dy]=_d(ua),Ld=h.forwardRef((e,t)=>{var N,M,U,Z,se,ae;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=Rd(ua,n),[y,b]=h.useState(null),C=De(t,Ce=>b(Ce)),[k,S]=h.useState(null),T=jd(k),E=(T==null?void 0:T.width)??0,P=(T==null?void 0:T.height)??0,_=r+(s!=="center"?"-"+s:""),$=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},L=Array.isArray(c)?c:[c],F=L.length>0,G={padding:$,boundary:L.filter(py),altBoundary:F},{refs:O,floatingStyles:K,placement:q,isPositioned:H,middlewareData:j}=Zb({strategy:"fixed",placement:_,whileElementsMounted:(...Ce)=>Hb(...Ce,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[ey({mainAxis:o+P,alignmentAxis:i}),l&&ty({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?ny():void 0,...G}),l&&ry({...G}),oy({...G,apply:({elements:Ce,rects:we,availableWidth:je,availableHeight:We})=>{const{width:Fe,height:Ye}=we.reference,He=Ce.floating.style;He.setProperty("--radix-popper-available-width",`${je}px`),He.setProperty("--radix-popper-available-height",`${We}px`),He.setProperty("--radix-popper-anchor-width",`${Fe}px`),He.setProperty("--radix-popper-anchor-height",`${Ye}px`)}}),k&&iy({element:k,padding:a}),hy({arrowWidth:E,arrowHeight:P}),m&&sy({strategy:"referenceHidden",...G})]}),[I,Y]=Bd(q),J=pt(v);It(()=>{H&&(J==null||J())},[H,J]);const D=(N=j.arrow)==null?void 0:N.x,V=(M=j.arrow)==null?void 0:M.y,R=((U=j.arrow)==null?void 0:U.centerOffset)!==0,[B,X]=h.useState();return It(()=>{y&&X(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:H?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:B,"--radix-popper-transform-origin":[(Z=j.transformOrigin)==null?void 0:Z.x,(se=j.transformOrigin)==null?void 0:se.y].join(" "),...((ae=j.hide)==null?void 0:ae.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(uy,{scope:n,placedSide:I,onArrowChange:S,arrowX:D,arrowY:V,shouldHideArrow:R,children:u.jsx(fe.div,{"data-side":I,"data-align":Y,...g,ref:C,style:{...g.style,animation:H?void 0:"none"}})})})});Ld.displayName=ua;var $d="PopperArrow",fy={top:"bottom",right:"left",bottom:"top",left:"right"},Fd=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=dy($d,r),i=fy[s.placedSide];return u.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]: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:u.jsx(ly,{...o,ref:n,style:{...o.style,display:"block"}})})});Fd.displayName=$d;function py(e){return e!==null}var hy=e=>({name:"transformOrigin",options:e,fn(t){var x,y,b;const{placement:n,rects:r,middlewareData:o}=t,i=((x=o.arrow)==null?void 0:x.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=Bd(n),p={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?p:`${m}px`,g=`${-l}px`):c==="top"?(v=i?p:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?p:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?p:`${f}px`),{data:{x:v,y:g}}}});function Bd(e){const[t,n="center"]=e.split("-");return[t,n]}var da=Md,fa=Dd,pa=Ld,ha=Fd,my="Portal",ao=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Oo.createPortal(u.jsx(fe.div,{...r,ref:t}),i):null});ao.displayName=my;function gy(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ut=e=>{const{present:t,children:n}=e,r=xy(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=De(r.ref,vy(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Ut.displayName="Presence";function xy(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=gy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=ds(r.current);s.current=a==="mounted"?c:"none"},[a]),It(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=ds(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,p=f=>{const g=ds(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=f=>{f.target===t&&(s.current=ds(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function ds(e){return(e==null?void 0:e.animationName)||"none"}function vy(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 ma="rovingFocusGroup.onEntryFocus",wy={bubbles:!1,cancelable:!0},lo="RovingFocusGroup",[ga,zd,by]=Zo(lo),[yy,Hd]=cn(lo,[by]),[Sy,Cy]=yy(lo),Ud=h.forwardRef((e,t)=>u.jsx(ga.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ga.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Ty,{...e,ref:t})})}));Ud.displayName=lo;var Ty=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...p}=e,m=h.useRef(null),f=De(t,m),v=Qo(s),[g,x]=On({prop:i,defaultProp:a??null,onChange:l,caller:lo}),[y,b]=h.useState(!1),C=pt(c),k=zd(n),S=h.useRef(!1),[T,E]=h.useState(0);return h.useEffect(()=>{const P=m.current;if(P)return P.addEventListener(ma,C),()=>P.removeEventListener(ma,C)},[C]),u.jsx(Sy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(P=>x(P),[x]),onItemShiftTab:h.useCallback(()=>b(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(P=>P+1),[]),onFocusableItemRemove:h.useCallback(()=>E(P=>P-1),[]),children:u.jsx(fe.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:ie(e.onMouseDown,()=>{S.current=!0}),onFocus:ie(e.onFocus,P=>{const _=!S.current;if(P.target===P.currentTarget&&_&&!y){const $=new CustomEvent(ma,wy);if(P.currentTarget.dispatchEvent($),!$.defaultPrevented){const L=k().filter(q=>q.focusable),F=L.find(q=>q.active),G=L.find(q=>q.id===g),K=[F,G,...L].filter(Boolean).map(q=>q.ref.current);Kd(K,d)}}S.current=!1}),onBlur:ie(e.onBlur,()=>b(!1))})})}),Wd="RovingFocusGroupItem",Vd=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=_t(),c=s||l,d=Cy(Wd,n),p=d.currentTabStopId===c,m=zd(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(ga.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(fe.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ie(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ie(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ie(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Iy(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let C=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")C.reverse();else if(y==="prev"||y==="next"){y==="prev"&&C.reverse();const k=C.indexOf(x.currentTarget);C=d.loop?Ny(C,k+1):C.slice(k+1)}setTimeout(()=>Kd(C))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});Vd.displayName=Wd;var ky={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ey(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Iy(e,t,n){const r=Ey(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return ky[r]}function Kd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ny(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ay=Ud,Py=Vd,jy=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},jr=new WeakMap,fs=new WeakMap,ps={},xa=0,qd=function(e){return e&&(e.host||qd(e.parentNode))},_y=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=qd(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})},Ry=function(e,t,n,r){var o=_y(t,Array.isArray(e)?e:[e]);ps[n]||(ps[n]=new WeakMap);var s=ps[n],i=[],a=new Set,l=new Set(o),c=function(p){!p||a.has(p)||(a.add(p),c(p.parentNode))};o.forEach(c);var d=function(p){!p||l.has(p)||Array.prototype.forEach.call(p.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(jr.get(m)||0)+1,x=(s.get(m)||0)+1;jr.set(m,g),s.set(m,x),i.push(m),g===1&&v&&fs.set(m,!0),x===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),a.clear(),xa++,function(){i.forEach(function(p){var m=jr.get(p)-1,f=s.get(p)-1;jr.set(p,m),s.set(p,f),m||(fs.has(p)||p.removeAttribute(r),fs.delete(p)),f||p.removeAttribute(n)}),xa--,xa||(jr=new WeakMap,jr=new WeakMap,fs=new WeakMap,ps={})}},va=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=jy(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Ry(r,o,n,"aria-hidden")):function(){return null}},Cn=function(){return Cn=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},Cn.apply(this,arguments)};function Gd(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 My(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 hs="right-scroll-bar-position",ms="width-before-scroll-bar",Oy="with-scroll-bars-hidden",Dy="--removed-body-scroll-bar-size";function wa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Ly(e,t){var n=w.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 $y=typeof window<"u"?h.useLayoutEffect:h.useEffect,Yd=new WeakMap;function Fy(e,t){var n=Ly(null,function(r){return e.forEach(function(o){return wa(o,r)})});return $y(function(){var r=Yd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||wa(a,null)}),s.forEach(function(a){o.has(a)||wa(a,i)})}Yd.set(n,e)},[e]),n}function By(e){return e}function zy(e,t){t===void 0&&(t=By);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 i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function Hy(e){e===void 0&&(e={});var t=zy(null);return t.options=Cn({async:!0,ssr:!1},e),t}var Xd=function(e){var t=e.sideCar,n=Gd(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 h.createElement(r,Cn({},n))};Xd.isSideCarExport=!0;function Uy(e,t){return e.useMedium(t),Xd}var Jd=Hy(),ba=function(){},gs=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:ba,onWheelCapture:ba,onTouchMoveCapture:ba}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,p=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,C=e.gapMode,k=Gd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,T=Fy([n,t]),E=Cn(Cn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(S,{sideCar:Jd,removeScrollBar:c,shards:p,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:C}),i?h.cloneElement(h.Children.only(a),Cn(Cn({},E),{ref:T})):h.createElement(b,Cn({},E,{className:l,ref:T}),a))});gs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},gs.classNames={fullWidth:ms,zeroRight:hs};var Wy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Vy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Wy();return t&&e.setAttribute("nonce",t),e}function Ky(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function qy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Gy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Vy())&&(Ky(t,n),qy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Yy=function(){var e=Gy();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Zd=function(){var e=Yy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Xy={left:0,top:0,right:0,gap:0},ya=function(e){return parseInt(e||"",10)||0},Jy=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[ya(n),ya(r),ya(o)]},Zy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Xy;var t=Jy(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])}},Qy=Zd(),_r="data-scroll-locked",e0=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
40
|
+
.`.concat(Oy,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
43
43
|
}
|
|
@@ -71,19 +71,19 @@ React keys must be passed directly to JSX without using spread:
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
body[`).concat(_r,`] {
|
|
74
|
-
`).concat(
|
|
74
|
+
`).concat(Dy,": ").concat(a,`px;
|
|
75
75
|
}
|
|
76
|
-
`)},Qd=function(){var e=parseInt(document.body.getAttribute(_r)||"0",10);return isFinite(e)?e:0},
|
|
76
|
+
`)},Qd=function(){var e=parseInt(document.body.getAttribute(_r)||"0",10);return isFinite(e)?e:0},t0=function(){h.useEffect(function(){return document.body.setAttribute(_r,(Qd()+1).toString()),function(){var e=Qd()-1;e<=0?document.body.removeAttribute(_r):document.body.setAttribute(_r,e.toString())}},[])},n0=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;t0();var s=h.useMemo(function(){return Zy(o)},[o]);return h.createElement(Qy,{styles:e0(s,!t,o,n?"":"!important")})},Sa=!1;if(typeof window<"u")try{var xs=Object.defineProperty({},"passive",{get:function(){return Sa=!0,!0}});window.addEventListener("test",xs,xs),window.removeEventListener("test",xs,xs)}catch{Sa=!1}var Rr=Sa?{passive:!1}:!1,r0=function(e){return e.tagName==="TEXTAREA"},ef=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!r0(e)&&n[t]==="visible")},o0=function(e){return ef(e,"overflowY")},s0=function(e){return ef(e,"overflowX")},tf=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=nf(e,r);if(o){var s=rf(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},i0=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},a0=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},nf=function(e,t){return e==="v"?o0(t):s0(t)},rf=function(e,t){return e==="v"?i0(t):a0(t)},l0=function(e,t){return e==="h"&&t==="rtl"?-1:1},c0=function(e,t,n,r,o){var s=l0(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,p=0,m=0;do{if(!a)break;var f=rf(e,a),v=f[0],g=f[1],x=f[2],y=g-x-s*v;(v||y)&&nf(e,a)&&(p+=y,m+=v);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(p)<1||!d&&Math.abs(m)<1)&&(c=!0),c},vs=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},of=function(e){return[e.deltaX,e.deltaY]},sf=function(e){return e&&"current"in e?e.current:e},u0=function(e,t){return e[0]===t[0]&&e[1]===t[1]},d0=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},d0=0,Mr=[];function f0(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(d0++)[0],s=h.useState(Zd)[0],i=h.useRef(e);h.useEffect(function(){i.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=Ry([e.lockRef.current],(e.shards||[]).map(sf),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=h.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=vs(g),b=n.current,C="deltaX"in g?g.deltaX:b[0]-y[0],k="deltaY"in g?g.deltaY:b[1]-y[1],S,T=g.target,E=Math.abs(C)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var P=tf(E,T);if(!P)return!0;if(P?S=E:(S=E==="v"?"h":"v",P=tf(E,T)),!P)return!1;if(!r.current&&"changedTouches"in g&&(C||k)&&(r.current=S),!S)return!0;var _=r.current||S;return l0(_,x,g,_==="h"?C:k)},[]),l=h.useCallback(function(g){var x=g;if(!(!Mr.length||Mr[Mr.length-1]!==s)){var y="deltaY"in x?of(x):vs(x),b=t.current.filter(function(S){return S.name===x.type&&(S.target===x.target||x.target===S.shadowParent)&&c0(S.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var C=(i.current.shards||[]).map(sf).filter(Boolean).filter(function(S){return S.contains(x.target)}),k=C.length>0?a(x,C[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=h.useCallback(function(g,x,y,b){var C={name:g,delta:x,target:y,should:b,shadowParent:p0(y)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(k){return k!==C})},1)},[]),d=h.useCallback(function(g){n.current=vs(g),r.current=void 0},[]),p=h.useCallback(function(g){c(g.type,of(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){c(g.type,vs(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return Mr.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Rr),document.addEventListener("touchmove",l,Rr),document.addEventListener("touchstart",d,Rr),function(){Mr=Mr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Rr),document.removeEventListener("touchmove",l,Rr),document.removeEventListener("touchstart",d,Rr)}},[]);var f=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:u0(o)}):null,f?h.createElement(t0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function p0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const h0=Hy(Jd,f0);var ws=h.forwardRef(function(e,t){return h.createElement(gs,Cn({},e,{ref:t,sideCar:h0}))});ws.classNames=gs.classNames;var Ca=["Enter"," "],m0=["ArrowDown","PageUp","Home"],af=["ArrowUp","PageDown","End"],g0=[...m0,...af],x0={ltr:[...Ca,"ArrowRight"],rtl:[...Ca,"ArrowLeft"]},v0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},co="Menu",[uo,w0,b0]=Zo(co),[rr,lf]=cn(co,[b0,Pr,Hd]),bs=Pr(),cf=Hd(),[y0,or]=rr(co),[S0,fo]=rr(co),uf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=bs(t),[l,c]=h.useState(null),d=h.useRef(!1),p=pt(s),m=Qo(o);return h.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(da,{...a,children:u.jsx(y0,{scope:t,open:n,onOpenChange:p,content:l,onContentChange:c,children:u.jsx(S0,{scope:t,onClose:h.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};uf.displayName=co;var C0="MenuAnchor",Ta=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(fa,{...o,...r,ref:t})});Ta.displayName=C0;var ka="MenuPortal",[T0,df]=rr(ka,{forceMount:void 0}),ff=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=or(ka,t);return u.jsx(T0,{scope:t,forceMount:n,children:u.jsx(Ut,{present:n||s.open,children:u.jsx(ao,{asChild:!0,container:o,children:r})})})};ff.displayName=ka;var nn="MenuContent",[k0,Ea]=rr(nn),pf=h.forwardRef((e,t)=>{const n=df(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=or(nn,e.__scopeMenu),i=fo(nn,e.__scopeMenu);return u.jsx(uo.Provider,{scope:e.__scopeMenu,children:u.jsx(Ut,{present:r||s.open,children:u.jsx(uo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(E0,{...o,ref:t}):u.jsx(I0,{...o,ref:t})})})})}),E0=h.forwardRef((e,t)=>{const n=or(nn,e.__scopeMenu),r=h.useRef(null),o=De(t,r);return h.useEffect(()=>{const s=r.current;if(s)return va(s)},[]),u.jsx(Ia,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),I0=h.forwardRef((e,t)=>{const n=or(nn,e.__scopeMenu);return u.jsx(Ia,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),N0=Yt.createSlot("MenuContent.ScrollLock"),Ia=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...g}=e,x=or(nn,n),y=fo(nn,n),b=bs(n),C=cf(n),k=w0(n),[S,T]=h.useState(null),E=h.useRef(null),P=De(t,E,x.onContentChange),_=h.useRef(0),$=h.useRef(""),L=h.useRef(0),F=h.useRef(null),G=h.useRef("right"),O=h.useRef(0),K=v?ws:h.Fragment,q=v?{as:N0,allowPinchZoom:!0}:void 0,H=I=>{var N,M;const Y=$.current+I,J=k().filter(U=>!U.disabled),D=document.activeElement,V=(N=J.find(U=>U.ref.current===D))==null?void 0:N.textValue,R=J.map(U=>U.textValue),B=B0(R,Y,V),X=(M=J.find(U=>U.textValue===B))==null?void 0:M.ref.current;(function U(Z){$.current=Z,window.clearTimeout(_.current),Z!==""&&(_.current=window.setTimeout(()=>U(""),1e3))})(Y),X&&setTimeout(()=>X.focus())};h.useEffect(()=>()=>window.clearTimeout(_.current),[]),Yi();const j=h.useCallback(I=>{var J,D;return G.current===((J=F.current)==null?void 0:J.side)&&H0(I,(D=F.current)==null?void 0:D.area)},[]);return u.jsx(k0,{scope:n,searchRef:$,onItemEnter:h.useCallback(I=>{j(I)&&I.preventDefault()},[j]),onItemLeave:h.useCallback(I=>{var Y;j(I)||((Y=E.current)==null||Y.focus(),T(null))},[j]),onTriggerLeave:h.useCallback(I=>{j(I)&&I.preventDefault()},[j]),pointerGraceTimerRef:L,onPointerGraceIntentChange:h.useCallback(I=>{F.current=I},[]),children:u.jsx(K,{...q,children:u.jsx(es,{asChild:!0,trapped:o,onMountAutoFocus:ie(s,I=>{var Y;I.preventDefault(),(Y=E.current)==null||Y.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(kr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,children:u.jsx(Ny,{asChild:!0,...C,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:T,onEntryFocus:ie(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(pa,{role:"menu","aria-orientation":"vertical","data-state":Pf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:P,style:{outline:"none",...g.style},onKeyDown:ie(g.onKeyDown,I=>{const J=I.target.closest("[data-radix-menu-content]")===I.currentTarget,D=I.ctrlKey||I.altKey||I.metaKey,V=I.key.length===1;J&&(I.key==="Tab"&&I.preventDefault(),!D&&V&&H(I.key));const R=E.current;if(I.target!==R||!g0.includes(I.key))return;I.preventDefault();const X=k().filter(N=>!N.disabled).map(N=>N.ref.current);af.includes(I.key)&&X.reverse(),$0(X)}),onBlur:ie(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(_.current),$.current="")}),onPointerMove:ie(e.onPointerMove,ho(I=>{const Y=I.target,J=O.current!==I.clientX;if(I.currentTarget.contains(Y)&&J){const D=I.clientX>O.current?"right":"left";G.current=D,O.current=I.clientX}}))})})})})})})});pf.displayName=nn;var A0="MenuGroup",Na=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(fe.div,{role:"group",...r,ref:t})});Na.displayName=A0;var P0="MenuLabel",hf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(fe.div,{...r,ref:t})});hf.displayName=P0;var ys="MenuItem",mf="menu.itemSelect",Ss=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=fo(ys,e.__scopeMenu),a=Ea(ys,e.__scopeMenu),l=De(t,s),c=h.useRef(!1),d=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(mf,{bubbles:!0,cancelable:!0});p.addEventListener(mf,f=>r==null?void 0:r(f),{once:!0}),Ki(p,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(gf,{...o,ref:l,disabled:n,onClick:ie(e.onClick,d),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),c.current=!0},onPointerUp:ie(e.onPointerUp,p=>{var m;c.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:ie(e.onKeyDown,p=>{const m=a.searchRef.current!=="";n||m&&p.key===" "||Ca.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Ss.displayName=ys;var gf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Ea(ys,n),a=cf(n),l=h.useRef(null),c=De(t,l),[d,p]=h.useState(!1),[m,f]=h.useState("");return h.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(uo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(Ay,{asChild:!0,...a,focusable:!r,children:u.jsx(fe.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ie(e.onPointerMove,ho(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ie(e.onPointerLeave,ho(v=>i.onItemLeave(v))),onFocus:ie(e.onFocus,()=>p(!0)),onBlur:ie(e.onBlur,()=>p(!1))})})})}),j0="MenuCheckboxItem",xf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(Sf,{scope:e.__scopeMenu,checked:n,children:u.jsx(Ss,{role:"menuitemcheckbox","aria-checked":Cs(n)?"mixed":n,...o,ref:t,"data-state":Pa(n),onSelect:ie(o.onSelect,()=>r==null?void 0:r(Cs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});xf.displayName=j0;var vf="MenuRadioGroup",[_0,R0]=rr(vf,{value:void 0,onValueChange:()=>{}}),wf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=pt(r);return u.jsx(_0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Na,{...o,ref:t})})});wf.displayName=vf;var bf="MenuRadioItem",yf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=R0(bf,e.__scopeMenu),s=n===o.value;return u.jsx(Sf,{scope:e.__scopeMenu,checked:s,children:u.jsx(Ss,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Pa(s),onSelect:ie(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});yf.displayName=bf;var Aa="MenuItemIndicator",[Sf,M0]=rr(Aa,{checked:!1}),Cf=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=M0(Aa,n);return u.jsx(Ut,{present:r||Cs(s.checked)||s.checked===!0,children:u.jsx(fe.span,{...o,ref:t,"data-state":Pa(s.checked)})})});Cf.displayName=Aa;var O0="MenuSeparator",Tf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(fe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Tf.displayName=O0;var D0="MenuArrow",kf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(ha,{...o,...r,ref:t})});kf.displayName=D0;var L0="MenuSub",[_N,Ef]=rr(L0),po="MenuSubTrigger",If=h.forwardRef((e,t)=>{const n=or(po,e.__scopeMenu),r=fo(po,e.__scopeMenu),o=Ef(po,e.__scopeMenu),s=Ea(po,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const p=a.current;return()=>{window.clearTimeout(p),l(null)}},[a,l]),u.jsx(Ta,{asChild:!0,...c,children:u.jsx(gf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Pf(n.open),...e,ref:Mn(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:ie(e.onPointerMove,ho(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ie(e.onPointerLeave,ho(p=>{var f,v;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,b=m[x?"left":"right"],C=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+y,y:p.clientY},{x:b,y:m.top},{x:C,y:m.top},{x:C,y:m.bottom},{x:b,y:m.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ie(e.onKeyDown,p=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||x0[r.dir].includes(p.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),p.preventDefault())})})})});If.displayName=po;var Nf="MenuSubContent",Af=h.forwardRef((e,t)=>{const n=df(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=or(nn,e.__scopeMenu),i=fo(nn,e.__scopeMenu),a=Ef(Nf,e.__scopeMenu),l=h.useRef(null),c=De(t,l);return u.jsx(uo.Provider,{scope:e.__scopeMenu,children:u.jsx(Ut,{present:r||s.open,children:u.jsx(uo.Slot,{scope:e.__scopeMenu,children:u.jsx(Ia,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var p;i.isUsingKeyboardRef.current&&((p=l.current)==null||p.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ie(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ie(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ie(e.onKeyDown,d=>{var f;const p=d.currentTarget.contains(d.target),m=v0[i.dir].includes(d.key);p&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});Af.displayName=Nf;function Pf(e){return e?"open":"closed"}function Cs(e){return e==="indeterminate"}function Pa(e){return Cs(e)?"indeterminate":e?"checked":"unchecked"}function $0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function F0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function B0(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=F0(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function z0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function H0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return z0(n,t)}function ho(e){return t=>t.pointerType==="mouse"?e(t):void 0}var U0=uf,W0=Ta,V0=ff,K0=pf,q0=Na,G0=hf,Y0=Ss,X0=xf,J0=wf,Z0=yf,Q0=Cf,eS=Tf,tS=kf,nS=If,rS=Af,Ts="DropdownMenu",[oS,RN]=cn(Ts,[lf]),$t=lf(),[sS,jf]=oS(Ts),_f=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=$t(t),c=h.useRef(null),[d,p]=On({prop:o,defaultProp:s??!1,onChange:i,caller:Ts});return u.jsx(sS,{scope:t,triggerId:_t(),triggerRef:c,contentId:_t(),open:d,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(m=>!m),[p]),modal:a,children:u.jsx(U0,{...l,open:d,onOpenChange:p,dir:r,modal:a,children:n})})};_f.displayName=Ts;var Rf="DropdownMenuTrigger",Mf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=jf(Rf,n),i=$t(n);return u.jsx(W0,{asChild:!0,...i,children:u.jsx(fe.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:Mn(t,s.triggerRef),onPointerDown:ie(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ie(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Mf.displayName=Rf;var iS="DropdownMenuPortal",Of=e=>{const{__scopeDropdownMenu:t,...n}=e,r=$t(t);return u.jsx(V0,{...r,...n})};Of.displayName=iS;var Df="DropdownMenuContent",Lf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jf(Df,n),s=$t(n),i=h.useRef(!1);return u.jsx(K0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ie(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ie(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.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)"}})});Lf.displayName=Df;var aS="DropdownMenuGroup",lS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(q0,{...o,...r,ref:t})});lS.displayName=aS;var cS="DropdownMenuLabel",$f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(G0,{...o,...r,ref:t})});$f.displayName=cS;var uS="DropdownMenuItem",Ff=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Y0,{...o,...r,ref:t})});Ff.displayName=uS;var dS="DropdownMenuCheckboxItem",Bf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(X0,{...o,...r,ref:t})});Bf.displayName=dS;var fS="DropdownMenuRadioGroup",pS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(J0,{...o,...r,ref:t})});pS.displayName=fS;var hS="DropdownMenuRadioItem",zf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Z0,{...o,...r,ref:t})});zf.displayName=hS;var mS="DropdownMenuItemIndicator",Hf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Q0,{...o,...r,ref:t})});Hf.displayName=mS;var gS="DropdownMenuSeparator",Uf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(eS,{...o,...r,ref:t})});Uf.displayName=gS;var xS="DropdownMenuArrow",vS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(tS,{...o,...r,ref:t})});vS.displayName=xS;var wS="DropdownMenuSubTrigger",Wf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(nS,{...o,...r,ref:t})});Wf.displayName=wS;var bS="DropdownMenuSubContent",Vf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(rS,{...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)"}})});Vf.displayName=bS;var yS=_f,SS=Mf,CS=Of,Kf=Lf,qf=$f,Gf=Ff,Yf=Bf,Xf=zf,Jf=Hf,Zf=Uf,Qf=Wf,ep=Vf;const ks=yS,Es=SS,TS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Qf,{ref:o,className:re("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,u.jsx(ce.ChevronRight,{className:"ml-auto h-4 w-4"})]}));TS.displayName=Qf.displayName;const kS=h.forwardRef(({className:e,...t},n)=>u.jsx(ep,{ref:n,className:re("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}));kS.displayName=ep.displayName;const mo=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(CS,{children:u.jsx(Kf,{ref:r,sideOffset:t,className:re("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})}));mo.displayName=Kf.displayName;const Fn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Gf,{ref:r,className:re("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}));Fn.displayName=Gf.displayName;const ES=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Yf,{ref:o,className:re("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:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Jf,{children:u.jsx(ce.Check,{className:"h-4 w-4"})})}),t]}));ES.displayName=Yf.displayName;const IS=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Xf,{ref:r,className:re("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:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Jf,{children:u.jsx(ce.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));IS.displayName=Xf.displayName;const NS=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(qf,{ref:r,className:re("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));NS.displayName=qf.displayName;const AS=h.forwardRef(({className:e,...t},n)=>u.jsx(Zf,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));AS.displayName=Zf.displayName;const ja=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:re("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}));ja.displayName="Textarea";const PS=1e4;function tp({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=PS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:p="",textareaClassName:m="",allowEmptySend:f=!1,sendButtonClassName:v,validate:g,onValidationError:x}){const y=i!==void 0,[b,C]=w.useState(e),k=(y?i:b)??"",[S,T]=w.useTransition(),E=w.useRef(null),P=w.useRef(0),_=w.useRef(null),$=w.useRef("");w.useEffect(()=>{y||(C(e??""),_.current=null,E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`))},[e,t,y]);const[L,F]=w.useState(null),G=w.useCallback(R=>R.length>s?`Message too long (${R.length}/${s} characters)`:null,[s]),O=w.useMemo(()=>g??G,[g,G]),K=w.useCallback(R=>{const B=O(R);return F(B),x==null||x(B),$.current=R,B},[O,x]),q=w.useCallback(()=>{const R=E.current;R&&(R.style.height="auto",R.style.height=`${R.scrollHeight}px`)},[]);w.useEffect(()=>{q()},[q,k]),w.useEffect(()=>{if(!L)return;const R=(k??"").trim();$.current!==R&&K(R)},[k,L,K]);const H=w.useCallback((R,{fromUser:B})=>{y||C(R),B&&(a==null||a(R))},[y,a]),j=w.useCallback(async R=>{R&&R.preventDefault();const B=(k??"").trim();if(!B&&!f||K(B))return;const X=++P.current;_.current={id:X,shouldClear:!0},T(()=>{var N,M,U;try{const Z=l(B);Z&&typeof Z.then=="function"?Z.then(()=>{var se,ae;((se=_.current)==null?void 0:se.id)===X&&_.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((ae=_.current)==null?void 0:ae.id)===X&&(_.current=null)}).catch(()=>{var se;((se=_.current)==null?void 0:se.id)===X&&(_.current=null)}):(((N=_.current)==null?void 0:N.id)===X&&_.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((M=_.current)==null?void 0:M.id)===X&&(_.current=null))}catch{((U=_.current)==null?void 0:U.id)===X&&(_.current=null)}})},[k,l,f,y,a,K]),I=w.useCallback(R=>{const B=R.target.value;H(B,{fromUser:!0}),_.current&&(_.current.shouldClear=!1),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`),L&&K(B.trim())},[H,K,L]),Y=w.useCallback(R=>{R.key==="Enter"&&!R.shiftKey?(R.preventDefault(),j()):R.key==="Escape"&&t&&(R.preventDefault(),c==null||c())},[j,t,c]),V=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${m}`;return u.jsx("form",{onSubmit:R=>void j(R),className:`w-full ${p}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(ja,{ref:E,value:k,onChange:I,onKeyDown:Y,placeholder:t?"Edit your message...":n,className:V,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),L&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:L})]}),u.jsx("div",{children:r?u.jsx(Je,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ce.Square,{size:16})}):u.jsx(Je,{type:"submit",size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!k.trim()&&!f||S,children:u.jsx(ce.Send,{size:16})})})]})})}const jS=w.memo(tp);function np({composerValue:e,onComposerChange:t,onSend:n,onCancelEdit:r,onStop:o,editingMessageId:s=null,editingInitialValue:i="",placeholder:a="Type your message...",isStreaming:l=!1,disabled:c=!1,textareaClassName:d="",customStyles:p={},enableFileUpload:m=!1,enableExcelUpload:f=!1,onExcelUpload:v,onError:g,allowEmptySend:x=!1,inputError:y=null}){const[b,C]=w.useState([]),k=w.useRef(null),S=w.useRef(null),[T,E]=w.useState(0),[P,_]=w.useState(0),[$,L]=w.useState(!1),[F,G]=w.useState(null),[O,K]=w.useState(null),q=w.useCallback(()=>{k.current&&(k.current.value=""),S.current&&(S.current.value=""),E(R=>R+1),_(R=>R+1)},[]),H=w.useCallback(R=>{C(B=>[...B,...R])},[]),j=w.useCallback(R=>{const B=Array.from(R.target.files||[]);H(B),R.target.value=""},[H]),I=w.useCallback(R=>{C(B=>{const X=B.filter((N,M)=>M!==R);return X.length===0&&q(),X})},[q]),Y=w.useCallback(async R=>{const B=(R.target.files||[])[0];if(B&&(G(null),K(null),!!v)){L(!0);try{await v(B),G(`Uploaded ${B.name} - processing through chat stream`)}catch(X){const N=X instanceof Error?X.message:"Failed to upload Excel file";K(N),g==null||g(N)}finally{L(!1),R.target.value="",q()}}},[v,g,q]),J=w.useMemo(()=>x||b.length>0,[x,b]),D=w.useCallback(async R=>{const X=await n(R,b);return b.length>0&&(C([]),q()),X},[n,q,b]),V=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${s?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${y?"border-red-400":""} ${p.textarea||""} ${d}`;return u.jsxs(u.Fragment,{children:[(m||f)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[m&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:k,type:"file",multiple:!0,onChange:j,className:"hidden"},T),b.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:b.map((R,B)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(ce.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:R.name}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>I(B),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${R.name}`,children:u.jsx(ce.X,{size:12})})]},B))})]}),f&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Y,className:"hidden"},P),$&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ce.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),F&&!$&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:F}),O&&!$&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:O})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||f)&&u.jsxs(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Je,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:p.moreButton||"",children:u.jsx(ce.Plus,{size:16})})}),u.jsxs(mo,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Fn,{onClick:()=>{var R;return(R=k.current)==null?void 0:R.click()},className:"cursor-pointer",children:[u.jsx(ce.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),f&&u.jsxs(Fn,{onClick:()=>{var R;$||(R=S.current)==null||R.click()},className:`cursor-pointer ${$?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ce.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(jS,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:D,onCancelEdit:r,onStop:o,allowEmptySend:J,textareaClassName:V,sendButtonClassName:p.sendButton})})]})]})}const _S=w.memo(np),Is=0,Bn=1,Or=2,rp=4;function op(e){return()=>e}function RS(e){e()}function sp(e,t){return n=>e(t(n))}function ip(e,t){return()=>e(t)}function MS(e,t){return n=>e(t,n)}function _a(e){return e!==void 0}function OS(...e){return()=>{e.map(RS)}}function Dr(){}function Ns(e,t){return t(e),e}function DS(e,t){return t(e)}function ot(...e){return e}function Ze(e,t){return e(Bn,t)}function Me(e,t){e(Is,t)}function Ra(e){e(Or)}function ht(e){return e(rp)}function pe(e,t){return Ze(e,MS(t,Is))}function fn(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function ap(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function lp(e,t){return e===t}function st(e=lp){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Se(e){return t=>n=>{e(n)&&t(n)}}function ue(e){return t=>sp(t,e)}function Tn(e){return t=>()=>{t(e)}}function te(e,...t){const n=LS(...t);return(r,o)=>{switch(r){case Or:Ra(e);return;case Bn:return Ze(e,n(o))}}}function kn(e,t){return n=>r=>{n(t=e(t,r))}}function sr(e){return t=>n=>{e>0?e--:t(n)}}function jn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Le(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function LS(...e){return t=>e.reduceRight(DS,t)}function $S(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Bn:return s?n===s?void 0:(r(),n=s,t=Ze(e,s),t):(r(),Dr);case Or:r(),n=null;return}}}function oe(e){let t=e;const n=ze();return(r,o)=>{switch(r){case Is:t=o;break;case Bn:{o(t);break}case rp:return t}return n(r,o)}}function Rt(e,t){return Ns(oe(t),n=>pe(e,n))}function ze(){const e=[];return(t,n)=>{switch(t){case Is:e.slice().forEach(r=>{r(n)});return;case Or:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function en(e){return Ns(ze(),t=>pe(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:FS(),singleton:n}}const FS=()=>Symbol();function BS(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function xt(...e){const t=ze(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,l=>{n[i]=l,r=r|a,r===o&&Me(t,n)})}),function(s,i){switch(s){case Or:{Ra(t);return}case Bn:return r===o&&i(n),Ze(t,i)}}}function ye(e,t=lp){return te(e,st(t))}function Ma(...e){return function(t,n){switch(t){case Or:return;case Bn:return OS(...e.map(r=>Ze(r,n)))}}}var Wt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Wt||{});const zS={0:"debug",3:"error",1:"log",2:"warn"},HS=()=>typeof globalThis>"u"?window:globalThis,zn=Ge(()=>{const e=oe(3);return{log:oe((t,n,r=1)=>{var o;const s=(o=HS().VIRTUOSO_LOG_LEVEL)!=null?o:ht(e);r>=s&&console[zS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function ir(e,t,n){return Oa(e,t,n).callbackRef}function Oa(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function US(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const p=WS(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const f=m.lastElementChild.dataset.viewportType==="window";let v;f&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:f?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:f?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:f?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?cp("column-gap",getComputedStyle(d).columnGap,o):cp("row-gap",getComputedStyle(d).rowGap,o)),p!==null&&e(p)},[e,t,o,s,i,r,a]);return Oa(c,n,l)}function WS(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Wt.ERROR),d===c)continue;const p=s[s.length-1];s.length===0||p.size!==d||p.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function cp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Wt.WARN),t==="normal"?0:parseInt(t??"0",10)}function up(e,t,n){const r=w.useRef(null),o=w.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let p,m;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;m=f.height-Math.max(0,v),p=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),p=c.top+f.scrollY}r.current={offsetTop:p,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Oa(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Ft=Ge(()=>{const e=ze(),t=ze(),n=oe(0),r=ze(),o=oe(0),s=ze(),i=ze(),a=oe(0),l=oe(0),c=oe(0),d=oe(0),p=ze(),m=ze(),f=oe(!1),v=oe(!1),g=oe(!1);return pe(te(e,ue(({scrollTop:x})=>x)),t),pe(te(e,ue(({scrollHeight:x})=>x)),i),pe(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:p,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),go={lvl:0};function dp(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function nt(e){return e===go}function xo(e,t){if(!nt(e))return t===e.k?e.v:t<e.k?xo(e.l,t):xo(e.r,t)}function pn(e,t,n="k"){if(nt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=pn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return pn(e.l,t,n)}function tn(e,t,n){return nt(e)?hp(t,n,1):t===e.k?St(e,{k:t,v:n}):t<e.k?mp(St(e,{l:tn(e.l,t,n)})):mp(St(e,{r:tn(e.r,t,n)}))}function Lr(){return go}function As(e,t,n){if(nt(e))return[];const r=pn(e,t)[0];return VS(La(e,r,n))}function Da(e,t){if(nt(e))return go;const{k:n,l:r,r:o}=e;if(t===n){if(nt(r))return o;if(nt(o))return r;{const[s,i]=pp(r);return Ps(St(e,{k:s,l:fp(r),v:i}))}}else return t<n?Ps(St(e,{l:Da(r,t)})):Ps(St(e,{r:Da(o,t)}))}function ar(e){return nt(e)?[]:[...ar(e.l),{k:e.k,v:e.v},...ar(e.r)]}function La(e,t,n){if(nt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(La(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(La(s,t,n))),a}function Ps(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if($a(t))return gp(St(e,{lvl:n-1}));if(!nt(t)&&!nt(t.r))return St(t.r,{l:St(t,{r:t.r.l}),lvl:n,r:St(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if($a(e))return Fa(St(e,{lvl:n-1}));if(!nt(r)&&!nt(r.l)){const o=r.l,s=$a(o)?r.lvl-1:r.lvl;return St(o,{l:St(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Fa(St(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function St(e,t){return hp(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function fp(e){return nt(e.r)?e.l:Ps(St(e,{r:fp(e.r)}))}function $a(e){return nt(e)||e.lvl>e.r.lvl}function pp(e){return nt(e.r)?[e.k,e.v]:pp(e.r)}function hp(e,t,n,r=go,o=go){return{k:e,l:r,lvl:n,r:o,v:t}}function mp(e){return Fa(gp(e))}function gp(e){const{l:t}=e;return!nt(t)&&t.lvl===e.lvl?St(t,{r:St(e,{l:t.r})}):e}function Fa(e){const{lvl:t,r:n}=e;return!nt(n)&&!nt(n.r)&&n.lvl===t&&n.r.lvl===t?St(n,{l:St(e,{r:n.l}),lvl:t+1}):e}function VS(e){return dp(e,({k:t,v:n})=>({index:t,value:n}))}function xp(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function vo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ba=Ge(()=>({recalcInProgress:oe(!1)}),[],{singleton:!0});function vp(e,t,n){return e[js(e,t,n)]}function js(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function KS(e,t,n,r){const o=js(e,t,r),s=js(e,n,r,o);return e.slice(o,s+1)}function Hn(e,t){return Math.round(e.getBoundingClientRect()[t])}function _s(e){return!nt(e.groupOffsetTree)}function za({index:e},t){return t===e?0:t<e?-1:1}function qS(){return{groupIndices:[],groupOffsetTree:Lr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Lr()}}function GS(e,t){let n=nt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),nt(e)){e=tn(e,0,s);continue}const a=As(e,i-1,o+1);if(a.some(tC(r)))continue;let l=!1,c=!1;for(const{end:d,start:p,value:m}of a)l?(o>=p||s===m)&&(e=Da(e,p)):(c=m!==s,l=!0),d>o&&o>=p&&m!==s&&(e=tn(e,o+1,m));c&&(e=tn(e,i,s))}return[e,n]}function YS(e){return typeof e.groupIndex<"u"}function XS({offset:e},t){return t===e?0:t<e?-1:1}function wo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=vp(t,e,za),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function wp(e,t){if(!_s(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function bp(e,t,n){if(YS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=wp(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function JS(e,t,n,r=0){return r>0&&(t=Math.max(t,vp(e,r,za).offset)),dp(KS(e,t,n,XS),eC)}function ZS(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Wt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&nt(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>tn(tn(v,g,m),g+1,f),i)}else[i,a]=GS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p}=Ha(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>tn(m,f,wo(f,p,o)),Lr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p,sizeTree:i}}function QS(e){return ar(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function yp(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function Ha(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=js(o,t-1,za),a=o[l].offset;const c=pn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===pn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of As(n,t,1/0)){const p=c-s,m=p*i+a+p*r;o.push({index:c,offset:m,size:d}),s=c,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function eC(e){return{index:e.index,value:e}}function tC(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const nC={offsetHeight:"height",offsetWidth:"width"},En=Ge(([{log:e},{recalcInProgress:t}])=>{const n=ze(),r=ze(),o=Rt(r,0),s=ze(),i=ze(),a=oe(0),l=oe([]),c=oe(void 0),d=oe(void 0),p=oe((S,T)=>Hn(S,nC[T])),m=oe(void 0),f=oe(0),v=qS(),g=Rt(te(n,Le(l,e,f),kn(ZS,v),st()),v),x=Rt(te(l,st(),kn((S,T)=>({current:T,prev:S.current}),{current:[],prev:[]}),ue(({prev:S})=>S)),[]);pe(te(l,Se(S=>S.length>0),Le(g,f),ue(([S,T,E])=>{const P=S.reduce((_,$,L)=>tn(_,$,wo($,T.offsetTree,E)||L),Lr());return{...T,groupIndices:S,groupOffsetTree:P}})),g),pe(te(r,Le(g),Se(([S,{lastIndex:T}])=>S<T),ue(([S,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:S}])),n),pe(c,d);const y=Rt(te(c,ue(S=>S===void 0)),!0);pe(te(d,Se(S=>S!==void 0&&nt(ht(g).sizeTree)),ue(S=>[{endIndex:0,size:S,startIndex:0}])),n);const b=en(te(n,Le(g),kn(({sizes:S},[T,E])=>({changed:E!==S,sizes:E}),{changed:!1,sizes:v}),ue(S=>S.changed)));Ze(te(a,kn((S,T)=>({diff:S.prev-T,prev:T}),{diff:0,prev:0}),ue(S=>S.diff)),S=>{const{groupIndices:T}=ht(g);if(S>0)Me(t,!0),Me(s,S+yp(S,T));else if(S<0){const E=ht(x);E.length>0&&(S-=yp(-S,E)),Me(i,S)}}),Ze(te(a,Le(e)),([S,T])=>{S<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Wt.ERROR)});const C=en(s);pe(te(s,Le(g),ue(([S,T])=>{const E=T.groupIndices.length>0,P=[],_=T.lastSize;if(E){const $=xo(T.sizeTree,0);let L=0,F=0;for(;L<S;){const O=T.groupIndices[F],K=T.groupIndices.length===F+1?1/0:T.groupIndices[F+1]-O-1;P.push({endIndex:O,size:$,startIndex:O}),P.push({endIndex:O+1+K-1,size:_,startIndex:O+1}),F++,L+=K+1}const G=ar(T.sizeTree);return L!==S&&G.shift(),G.reduce((O,{k:K,v:q})=>{let H=O.ranges;return O.prevSize!==0&&(H=[...O.ranges,{endIndex:K+S-1,size:O.prevSize,startIndex:O.prevIndex}]),{prevIndex:K+S,prevSize:q,ranges:H}},{prevIndex:S,prevSize:0,ranges:P}).ranges}return ar(T.sizeTree).reduce(($,{k:L,v:F})=>({prevIndex:L+S,prevSize:F,ranges:[...$.ranges,{endIndex:L+S-1,size:$.prevSize,startIndex:$.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const k=en(te(i,Le(g,f),ue(([S,{offsetTree:T},E])=>{const P=-S;return wo(P,T,E)})));return pe(te(i,Le(g,f),ue(([S,T,E])=>{if(T.groupIndices.length>0){if(nt(T.sizeTree))return T;let P=Lr();const _=ht(x);let $=0,L=0,F=0;for(;$<-S;){F=_[L];const G=_[L+1]-F-1;L++,$+=G+1}if(P=ar(T.sizeTree).reduce((G,{k:O,v:K})=>tn(G,Math.max(0,O+S),K),P),$!==-S){const G=xo(T.sizeTree,F);P=tn(P,0,G);const O=pn(T.sizeTree,-S+1)[1];P=tn(P,1,O)}return{...T,sizeTree:P,...Ha(T.offsetTree,0,P,E)}}else{const P=ar(T.sizeTree).reduce((_,{k:$,v:L})=>tn(_,Math.max(0,$+S),L),Lr());return{...T,sizeTree:P,...Ha(T.offsetTree,0,P,E)}}})),g),{beforeUnshiftWith:C,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:p,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},ot(zn,Ba),{singleton:!0});function rC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Sp=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=ze(),i=ze(),a=en(te(s,ue(rC)));return pe(te(a,ue(l=>l.totalCount)),n),pe(te(a,ue(l=>l.groupIndices)),e),pe(te(xt(o,t,r),Se(([l,c])=>_s(c)),ue(([l,c,d])=>pn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),st(),ue(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ot(En,Ft)),Un=Ge(([{log:e}])=>{const t=oe(!1),n=en(te(t,Se(r=>r),st()));return Ze(t,r=>{r&&ht(e)("props updated",{},Wt.DEBUG)}),{didMount:n,propsReady:t}},ot(zn),{singleton:!0}),oC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Cp(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!oC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const bo=Ge(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:p},{log:m}])=>{const f=ze(),v=ze(),g=oe(0);let x=null,y=null,b=null;function C(){x&&(x(),x=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Me(l,!1)}return pe(te(f,Le(n,p,r,g,a,i,m),Le(e,s,o),ue(([[k,S,T,E,P,_,$,L],F,G,O])=>{const K=Cp(k),{align:q,behavior:H,offset:j}=K,I=E-1,Y=bp(K,S,I);let J=wo(Y,S.offsetTree,F)+_;q==="end"?(J+=G+pn(S.sizeTree,Y)[1]-T+O,Y===I&&(J+=$)):q==="center"?J+=(G+pn(S.sizeTree,Y)[1]-T+O)/2:J-=P,j&&(J+=j);const D=V=>{C(),V?(L("retrying to scroll to",{location:k},Wt.DEBUG),Me(f,k)):(Me(v,!0),L("list did not change, scroll successful",{},Wt.DEBUG))};if(C(),H==="smooth"){let V=!1;b=Ze(t,R=>{V=V||R}),x=fn(d,()=>{D(V)})}else x=fn(te(t,sC(150)),D);return y=setTimeout(()=>{C()},1200),Me(l,!0),L("scrolling from index to",{behavior:H,index:Y,top:J},Wt.DEBUG),{behavior:H,top:J}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},ot(En,Ft,zn),{singleton:!0});function sC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Ua(e,t){e==0?t():requestAnimationFrame(()=>{Ua(e-1,t)})}function Wa(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const yo=Ge(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=oe(!0),l=oe(0),c=oe(!0);return pe(te(i,Le(l),Se(([d,p])=>!!p),Tn(!1)),a),pe(te(i,Le(l),Se(([d,p])=>!!p),Tn(!1)),c),Ze(te(xt(t,i),Le(a,n,e,c),Se(([[,d],p,{sizeTree:m},f,v])=>d&&(!nt(m)||_a(f))&&!p&&!v),Le(l)),([,d])=>{fn(o,()=>{Me(c,!0)}),Ua(4,()=>{fn(r,()=>{Me(a,!0)}),Me(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ot(En,Ft,bo,Un),{singleton:!0});function Tp(e,t){return Math.abs(e-t)<1.01}const So="up",Co="down",iC="none",aC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},lC=0,To=Ge(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=oe(!1),a=oe(!0),l=ze(),c=ze(),d=oe(4),p=oe(lC),m=Rt(te(Ma(te(ye(o),sr(1),Tn(!0)),te(ye(o),sr(1),Tn(!1),ap(100))),st()),!1),f=Rt(te(Ma(te(n,Tn(!0)),te(n,Tn(!1),ap(200))),st()),!1);pe(te(xt(ye(o),ye(p)),ue(([b,C])=>b<=C),st()),a),pe(te(a,jn(50)),c);const v=en(te(xt(r,ye(s),ye(t),ye(e),ye(d)),kn((b,[{scrollHeight:C,scrollTop:k},S,T,E,P])=>{const _=k+S-C>-P,$={scrollHeight:C,scrollTop:k,viewportHeight:S};if(_){let F,G;return k>b.state.scrollTop?(F="SCROLLED_DOWN",G=b.state.scrollTop-k):(F="SIZE_DECREASED",G=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:F,scrollTopDelta:G,state:$}}let L;return $.scrollHeight>b.state.scrollHeight?L="SIZE_INCREASED":S<b.state.viewportHeight?L="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?L="SCROLLING_UPWARDS":L="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:L,state:$}},aC),st((b,C)=>b&&b.atBottom===C.atBottom))),g=Rt(te(r,kn((b,{scrollHeight:C,scrollTop:k,viewportHeight:S})=>{if(Tp(b.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:k};{const T=C-(k+S)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:C,scrollTop:k}:{changed:!0,jump:0,scrollHeight:C,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Se(b=>b.changed),ue(b=>b.jump)),0);pe(te(v,ue(b=>b.atBottom)),i),pe(te(i,jn(50)),l);const x=oe(Co);pe(te(r,ue(({scrollTop:b})=>b),st(),kn((b,C)=>ht(f)?{direction:b.direction,prevScrollTop:C}:{direction:C<b.prevScrollTop?So:Co,prevScrollTop:C},{direction:Co,prevScrollTop:0}),ue(b=>b.direction)),x),pe(te(r,jn(50),Tn(iC)),x);const y=oe(0);return pe(te(m,Se(b=>!b),Tn(0)),y),pe(te(o,jn(100),Le(m),Se(([b,C])=>!!C),kn(([b,C],[k])=>[C,k],[0,0]),ue(([b,C])=>C-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:p,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},ot(Ft)),Rs="top",Ms="bottom",kp="none";function Ep(e,t,n){return typeof e=="number"?n===So&&t===Rs||n===Co&&t===Ms?e:0:n===So?t===Rs?e.main:e.reverse:t===Ms?e.main:e.reverse}function Ip(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Va=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=ze(),i=oe(0),a=oe(0),l=oe(0),c=Rt(te(xt(ye(r),ye(o),ye(n),ye(s,vo),ye(l),ye(i),ye(t),ye(e),ye(a)),ue(([d,p,m,[f,v],g,x,y,b,C])=>{const k=d-b,S=x+y,T=Math.max(m-k,0);let E=kp;const P=Ip(C,Rs),_=Ip(C,Ms);return f-=b,f+=m+y,v+=m+y,v-=b,f>d+S-P&&(E=So),v<d-T+p+_&&(E=Co),E!==kp?[Math.max(k-m-Ep(g,Rs,E)-P,0),k-T-y+p+Ep(g,Ms,E)+_]:null}),Se(d=>d!=null),st(vo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},ot(Ft),{singleton:!0});function cC(e,t,n){if(_s(t)){const r=wp(e,t);return[{index:pn(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Ka={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Os(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const p=n-i,m=a+p*l+(p-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:Ap(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:Ap(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function Np(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=Wa(t,a),c=Array.from({length:a}).map((d,p)=>({data:s[p+l],index:p+l,offset:0,size:0}));return Os(c,[],a,o,n,r)}function Ap(e,t,n){if(e.length===0)return[];if(!_s(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=As(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const lr=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:p},m,{didMount:f},{recalcInProgress:v}])=>{const g=oe([]),x=oe(0),y=ze();pe(s.topItemsIndexes,g);const b=Rt(te(xt(f,v,ye(l,vo),ye(o),ye(r),ye(c),d,ye(g),ye(t),ye(n),e),Se(([T,E,,P,,,,,,,_])=>{const $=_&&_.length!==P;return T&&!E&&!$}),ue(([,,[T,E],P,_,$,L,F,G,O,K])=>{const q=_,{offsetTree:H,sizeTree:j}=q,I=ht(x);if(P===0)return{...Ka,totalCount:P};if(T===0&&E===0)return I===0?{...Ka,totalCount:P}:Np(I,$,_,G,O,K||[]);if(nt(j))return I>0?null:Os(cC(Wa($,P),q,K),[],P,O,q,G);const Y=[];if(F.length>0){const B=F[0],X=F[F.length-1];let N=0;for(const M of As(j,B,X)){const U=M.value,Z=Math.max(M.start,B),se=Math.min(M.end,X);for(let ae=Z;ae<=se;ae++)Y.push({data:K==null?void 0:K[ae],index:ae,offset:N,size:U}),N+=U}}if(!L)return Os([],Y,P,O,q,G);const J=F.length>0?F[F.length-1]+1:0,D=JS(H,T,E,J);if(D.length===0)return null;const V=P-1,R=Ns([],B=>{for(const X of D){const N=X.value;let M=N.offset,U=X.start;const Z=N.size;if(N.offset<T){U+=Math.floor((T-N.offset+O)/(Z+O));const ae=U-X.start;M+=ae*Z+ae*O}U<J&&(M+=(J-U)*Z,U=J);const se=Math.min(X.end,V);for(let ae=U;ae<=se&&!(M>=E);ae++)B.push({data:K==null?void 0:K[ae],index:ae,offset:M,size:Z}),M+=Z+O}});return Os(R,Y,P,O,q,G)}),Se(T=>T!==null),st()),Ka);pe(te(e,Se(_a),ue(T=>T==null?void 0:T.length)),o),pe(te(b,ue(T=>T.topListHeight)),p),pe(p,a),pe(te(b,ue(T=>[T.top,T.bottom])),i),pe(te(b,ue(T=>T.items)),y);const C=en(te(b,Se(({items:T})=>T.length>0),Le(o,e),Se(([{items:T},E])=>T[T.length-1].originalIndex===E-1),ue(([,T,E])=>[T-1,E]),st(vo),ue(([T])=>T))),k=en(te(b,jn(200),Se(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),ue(({items:T})=>T[0].index),st())),S=en(te(b,Se(({items:T})=>T.length>0),ue(({items:T})=>{let E=0,P=T.length-1;for(;T[E].type==="group"&&E<P;)E++;for(;T[P].type==="group"&&P>E;)P--;return{endIndex:T[P].index,startIndex:T[E].index}}),st(xp)));return{endReached:C,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:S,startReached:k,topItemsIndexes:g,...m}},ot(En,Sp,Va,yo,bo,To,Un,Ba),{singleton:!0}),Pp=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=ze(),i=Rt(te(xt(n,e,r,t,o),ue(([a,l,c,d,p])=>a+l+c+d+p.offsetBottom+p.bottom)),0);return pe(ye(i),s),{totalListHeight:i,totalListHeightChanged:s}},ot(Ft,lr),{singleton:!0}),uC=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=oe(!1),r=Rt(te(xt(n,e,t),Se(([o])=>o),ue(([,o,s])=>Math.max(0,o-s)),jn(0),st()),0);return{alignToBottom:n,paddingTopAddition:r}},ot(Ft,Pp),{singleton:!0}),jp=Ge(()=>({context:oe(null)})),dC=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,_p=Ge(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=ze();return pe(te(d,Le(t,l,n,s,o,r,a),Le(e),ue(([[p,m,f,v,g,x,y,b],C])=>{const{align:k,behavior:S,calculateViewLocation:T=dC,done:E,...P}=p,_=bp(p,m,v-1),$=wo(_,m.offsetTree,C)+g+x,L=$+pn(m.sizeTree,_)[1],F=b+x,G=b+f-y,O=T({itemBottom:L,itemTop:$,locationParams:{align:k,behavior:S,...P},viewportBottom:G,viewportTop:F});return O?E&&fn(te(i,Se(K=>!K),sr(ht(i)?1:2)),E):E&&E(),O}),Se(p=>p!==null)),c),{scrollIntoView:d}},ot(En,Ft,bo,lr,zn),{singleton:!0});function Rp(e){return e?e==="smooth"?"smooth":"auto":!1}const fC=(e,t)=>typeof e=="function"?Rp(e(t)):t&&Rp(e),pC=Ge(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:p},{context:m},{scrollIntoView:f}])=>{const v=oe(!1),g=ze();let x=null;function y(S){Me(i,{align:"end",behavior:S,index:"LAST"})}Ze(te(xt(te(ye(t),sr(1)),l),Le(ye(v),s,a,p),ue(([[S,T],E,P,_,$])=>{let L=T&&_,F="auto";return L&&(F=fC(E,P||$),L=L&&!!F),{followOutputBehavior:F,shouldFollow:L,totalCount:S}}),Se(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:T})=>{x&&(x(),x=null),ht(n)?requestAnimationFrame(()=>{ht(d)("following output to ",{totalCount:T},Wt.DEBUG),y(S)}):x=fn(e,()=>{ht(d)("following output to ",{totalCount:T},Wt.DEBUG),y(S),x=null})});function b(S){const T=fn(o,E=>{S&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(ht(d)("scrolling to bottom due to increased size",{},Wt.DEBUG),y("auto"))});setTimeout(T,100)}Ze(te(xt(ye(v),t,c),Se(([S,,T])=>S&&T),kn(({value:S},[,T])=>({refreshed:S===T,value:T}),{refreshed:!1,value:0}),Se(({refreshed:S})=>S),Le(v,t)),([,S])=>{ht(a)&&b(S!==!1)}),Ze(g,()=>{b(ht(v)!==!1)}),Ze(xt(ye(v),o),([S,T])=>{S&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=oe(null),k=ze();return pe(Ma(te(ye(r),ue(S=>{var T;return(T=S==null?void 0:S.length)!=null?T:0})),te(ye(t))),k),Ze(te(xt(te(k,sr(1)),l),Le(ye(C),a,p,m),ue(([[S,T],E,P,_,$])=>T&&P&&(E==null?void 0:E({context:$,totalCount:S,scrollingInProgress:_}))),Se(S=>!!S),jn(0)),S=>{x&&(x(),x=null),ht(n)?requestAnimationFrame(()=>{ht(d)("scrolling into view",{}),Me(f,S)}):x=fn(e,()=>{ht(d)("scrolling into view",{}),Me(f,S),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:C}},ot(En,To,bo,yo,Un,zn,Ft,jp,_p)),hC=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(pe(te(a,Le(s),Se(([,l])=>l!==0),Le(o,r,t,n,e),ue(([[,l],c,d,p,m,f=[]])=>Np(l,c,d,p,m,f))),i),{}),ot(En,yo,lr,Un),{singleton:!0}),mC=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=oe(0);return Ze(te(e,Le(r),Se(([,o])=>o!==0),ue(([,o])=>({top:o}))),o=>{fn(te(n,sr(1),Se(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Me(t,o)})})}),{initialScrollTop:r}},ot(Un,Ft,lr),{singleton:!0}),Mp=Ge(([{scrollVelocity:e}])=>{const t=oe(!1),n=ze(),r=oe(!1);return pe(te(e,Le(r,t,n),Se(([o,s])=>!!s),ue(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),st()),t),Ze(te(xt(t,e,n),Le(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ot(To),{singleton:!0}),qa=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=ze(),r=ze(),o=ze(),s=oe(!1),i=oe(void 0);return pe(te(xt(n,r),ue(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),pe(te(t,Le(r),ue(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ot(Ft)),gC=Ge(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=ze(),d=oe(void 0),p=oe(null),m=oe(null);return pe(a,p),pe(l,m),Ze(te(c,Le(t,r,i,p,m,n)),([f,v,g,x,y,b,C])=>{const k=QS(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=C,f({ranges:k,scrollTop:g})}),pe(te(d,Se(_a),ue(xC)),o),pe(te(s,Le(d),Se(([,f])=>f!==void 0),st(),ue(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},ot(En,Ft,yo,Un,qa));function xC(e){return{align:"start",index:0,offset:e.scrollTop}}const vC=Ge(([{topItemsIndexes:e}])=>{const t=oe(0);return pe(te(t,Se(n=>n>=0),ue(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ot(lr));function Op(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const wC=Op(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),bC=Ge(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:p,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=en(te(l,Le(i),kn(([,y,b,C],[{bottom:k,items:S,offsetBottom:T,totalCount:E},P])=>{const _=k+T;let $=0;return b===E&&y.length>0&&S.length>0&&(S[0].originalIndex===0&&y[0].originalIndex===0||($=_-C,$!==0&&($+=P))),[$,S,E,_]},[0,[],0,0]),Se(([y])=>y!==0),Le(r,a,n,o,f,v),Se(([,y,b,C,,,k])=>!k&&!C&&y!==0&&b===So),ue(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Wt.DEBUG),y))));function x(y){y>0?(Me(t,{behavior:"auto",top:-y}),Me(e,0)):(Me(e,0),Me(t,{behavior:"auto",top:-y}))}return Ze(te(g,Le(e,s)),([y,b,C])=>{C&&wC()?Me(e,b-y):x(-y)}),Ze(te(xt(Rt(s,!1),e,v),Se(([y,b,C])=>!y&&!C&&b!==0),ue(([y,b])=>b),jn(1)),x),pe(te(p,ue(y=>({top:-y}))),t),Ze(te(c,Le(m,d),ue(([y,{groupIndices:b,lastSize:C,sizeTree:k},S])=>{function T(E){return E*(C+S)}if(b.length===0)return T(y);{let E=0;const P=xo(k,0);let _=0,$=0;for(;_<y;){_++,E+=P;let L=b.length===$+1?1/0:b[$+1]-b[$]-1;_+L>y&&(E-=P,L=y-_+1),_+=L,E+=T(L),$++}return E}})),y=>{Me(e,y),requestAnimationFrame(()=>{Me(t,{top:y}),requestAnimationFrame(()=>{Me(e,0),Me(v,!1)})})}),{deviation:e}},ot(Ft,To,lr,En,zn,Ba)),yC=Ge(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),ot(Va,hC,Un,Mp,Pp,mC,uC,qa,_p,zn,jp)),Dp=Ge(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:b,topItemsIndexes:C,...k},{scrollToIndex:S},T,{topItemCount:E},{groupCounts:P},_])=>(pe(k.rangeChanged,_.scrollSeekRangeChanged),pe(te(_.windowViewportRect,ue($=>$.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:P,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:C,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:S,statefulTotalCount:c,trackItemSizes:p,...k,..._,...g,sizes:l,...x}),ot(En,yo,Ft,gC,pC,lr,bo,bC,vC,Sp,yC));function SC(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const Ds=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Lp(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=w.createContext({});function l(x,y){x.propsReady&&Me(x.propsReady,!1);for(const b of r){const C=x[t.required[b]];Me(C,y[b])}for(const b of o)if(b in y){const C=x[t.optional[b]];Me(C,y[b])}x.propsReady&&Me(x.propsReady,!0)}function c(x){return s.reduce((y,b)=>(y[b]=C=>{const k=x[t.methods[b]];Me(k,C)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=$S(x[t.events[b]]),y),{})}const p=w.forwardRef((x,y)=>{const{children:b,...C}=x,[k]=w.useState(()=>Ns(BS(e),E=>{l(E,C)})),[S]=w.useState(ip(d,k));Ds(()=>{for(const E of i)E in C&&Ze(S[E],C[E]);return()=>{Object.values(S).map(Ra)}},[C,S,k]),Ds(()=>{l(k,C)}),w.useImperativeHandle(y,op(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...SC([...r,...o,...i],C),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{Me(y[x],b)},[y,x])},f=x=>{const y=w.useContext(a)[x],b=w.useCallback(C=>Ze(y,C),[y]);return w.useSyncExternalStore(b,()=>ht(y),()=>ht(y))},v=x=>{const y=w.useContext(a)[x],[b,C]=w.useState(ip(ht,y));return Ds(()=>Ze(y,k=>{k!==b&&C(op(k))}),[y,b]),b},g=w.version.startsWith("18")?f:v;return{Component:p,useEmitter:(x,y)=>{const b=w.useContext(a)[x];Ds(()=>Ze(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const $p=w.createContext(void 0),Fp=w.createContext(void 0),Bp=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Ga(e){return"self"in e}function CC(e){return"body"in e}function zp(e,t,n,r=Dr,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),c=w.useCallback(m=>{let f,v,g;const x=m.target;if(CC(x)||Ga(x)){const b=Ga(x)?x:x.defaultView;g=s?b.scrollX:b.scrollY,f=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else g=s?x.scrollLeft:x.scrollTop,f=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Oo.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.useEffect(()=>{const m=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",c,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(m){const f=i.current;if(!f||(s?"offsetWidth"in f&&f.offsetWidth===0:"offsetHeight"in f&&f.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;Ga(f)?(x=Math.max(Hn(f.document.documentElement,s?"width":"height"),s?f.document.documentElement.scrollWidth:f.document.documentElement.scrollHeight),g=s?f.innerWidth:f.innerHeight,y=s?window.scrollX:window.scrollY):(x=f[s?"scrollWidth":"scrollHeight"],g=Hn(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const b=x-g;if(m.top=Math.ceil(Math.max(Math.min(b,m.top),0)),Tp(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),f.scrollTo(m)}function p(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:p,scrollerRef:i,scrollToCallback:d}}const Ya="-webkit-sticky",Hp="sticky",Xa=Op(()=>{if(typeof document>"u")return Hp;const e=document.createElement("div");return e.style.position=Ya,e.style.position===Ya?Ya:Hp});function Ja(e){return e}const TC=Ge(()=>{const e=oe(a=>`Item ${a}`),t=oe(a=>`Group ${a}`),n=oe({}),r=oe(Ja),o=oe("div"),s=oe(Dr),i=(a,l=null)=>Rt(te(n,ue(c=>c[a]),st()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),kC=Ge(([e,t])=>({...e,...t}),ot(Dp,TC)),EC=({height:e})=>u.jsx("div",{style:{height:e}}),IC={overflowAnchor:"none",position:Xa(),zIndex:1},Up={overflowAnchor:"none"},NC={...Up,display:"inline-block",height:"100%"},Wp=w.memo(function({showTopList:e=!1}){const t=Ne("listState"),n=rn("sizeRanges"),r=Ne("useWindowScroll"),o=Ne("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=Ne("itemContent"),c=Ne("context"),d=Ne("groupContent"),p=Ne("trackItemSizes"),m=Ne("itemSize"),f=Ne("log"),v=rn("gap"),g=Ne("horizontalDirection"),{callbackRef:x}=US(n,m,p,e?Dr:a,f,v,o,g,Ne("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);Za("deviation",O=>{y!==O&&b(O)});const C=Ne("EmptyPlaceholder"),k=Ne("ScrollSeekPlaceholder")||EC,S=Ne("ListComponent"),T=Ne("ItemComponent"),E=Ne("GroupComponent"),P=Ne("computeItemKey"),_=Ne("isSeeking"),$=Ne("groupIndices").length>0,L=Ne("alignToBottom"),F=Ne("initialItemFinalLocationReached"),G=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:L?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:L?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...F?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?u.jsx(C,{...Mt(C,c)}):u.jsx(S,{...Mt(S,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:G,children:(e?t.topItems:t.items).map(O=>{const K=O.originalIndex,q=P(K+t.firstItemIndex,O.data,c);return _?w.createElement(k,{...Mt(k,c),height:O.size,index:O.index,key:q,type:O.type||"item",...O.type==="group"?{}:{groupIndex:O.groupIndex}}):O.type==="group"?w.createElement(E,{...Mt(E,c),"data-index":K,"data-item-index":O.index,"data-known-size":O.size,key:q,style:IC},d(O.index,c)):w.createElement(T,{...Mt(T,c),..._C(T,O.data),"data-index":K,"data-item-group-index":O.groupIndex,"data-item-index":O.index,"data-known-size":O.size,key:q,style:g?NC:Up},$?l(O.index,O.groupIndex,O.data,c):l(O.index,O.data,c))})})}),AC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},PC={outline:"none",overflowX:"auto",position:"relative"},Ls=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),jC={position:Xa(),top:0,width:"100%",zIndex:1};function Mt(e,t){if(typeof e!="string")return{context:t}}function _C(e,t){return{item:typeof e=="string"?void 0:t}}const RC=w.memo(function(){const e=Ne("HeaderComponent"),t=rn("headerHeight"),n=Ne("HeaderFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),MC=w.memo(function(){const e=Ne("FooterComponent"),t=rn("footerHeight"),n=Ne("HeaderFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null});function Vp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),p=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=zp(a,c,l,d,void 0,p);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...p?PC:AC,...o},tabIndex:0,...i,...Mt(l,s),children:r})})}function Kp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),p=t("deviation"),m=t("customScrollParent"),f=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=zp(a,c,l,v,m);return Bp(()=>{var b;return x.current=m||((b=f.current)==null?void 0:b.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+p}:{}},...i,...Mt(l,s),children:r})})}const OC=({children:e})=>{const t=w.useContext($p),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=Ne("alignToBottom"),s=Ne("horizontalDirection"),i=w.useMemo(()=>sp(n,l=>Hn(l,s?"width":"height")),[n,s]),a=ir(i,!0,Ne("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Ls(o),children:e})},DC=({children:e})=>{const t=w.useContext($p),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=Ne("customScrollParent"),s=up(n,o,Ne("skipAnimationFrameInResizeObserver")),i=Ne("alignToBottom");return w.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:Ls(i),children:e})},LC=({children:e})=>{const t=Ne("TopItemListComponent")||"div",n=Ne("headerHeight"),r={...jC,marginTop:`${n}px`},o=Ne("context");return u.jsx(t,{style:r,...Mt(t,o),children:e})},$C=w.memo(function(e){const t=Ne("useWindowScroll"),n=Ne("topItemsIndexes").length>0,r=Ne("customScrollParent"),o=Ne("context");return u.jsxs(r||t?zC:BC,{...e,context:o,children:[n&&u.jsx(LC,{children:u.jsx(Wp,{showTopList:!0})}),u.jsxs(r||t?DC:OC,{children:[u.jsx(RC,{}),u.jsx(Wp,{}),u.jsx(MC,{})]})]})}),{Component:FC,useEmitter:Za,useEmitterValue:Ne,usePublisher:rn}=Lp(kC,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},$C),BC=Vp({useEmitter:Za,useEmitterValue:Ne,usePublisher:rn}),zC=Kp({useEmitter:Za,useEmitterValue:Ne,usePublisher:rn}),HC=FC;ot(Dp,Ge(()=>{const e=oe(c=>u.jsxs("td",{children:["Item $",c]})),t=oe(null),n=oe(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=oe(null),o=oe(null),s=oe({}),i=oe(Ja),a=oe(Dr),l=(c,d=null)=>Rt(te(s,ue(p=>p[c]),st()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Xa();const qp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},UC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Gp,floor:$s,max:ko,min:Qa,round:Yp}=Math;function Xp(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function WC(e){return{...UC,items:e}}function Fs(e,t){return e&&e.width===t.width&&e.height===t.height}function VC(e,t){return e&&e.column===t.column&&e.row===t.row}const KC=Ge(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:p},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:k},S])=>{const T=oe(0),E=oe(0),P=oe(qp),_=oe({height:0,width:0}),$=oe({height:0,width:0}),L=ze(),F=ze(),G=oe(0),O=oe(null),K=oe({column:0,row:0}),q=ze(),H=ze(),j=oe(!1),I=oe(0),Y=oe(!0),J=oe(!1),D=oe(!1);Ze(te(v,Le(I),Se(([M,U])=>!!U)),()=>{Me(Y,!1)}),Ze(te(xt(v,Y,$,_,I,J),Se(([M,U,Z,se,,ae])=>M&&!U&&Z.height!==0&&se.height!==0&&!ae)),([,,,,M])=>{Me(J,!0),Ua(1,()=>{Me(L,M)}),fn(te(c),()=>{Me(t,[0,0]),Me(Y,!0)})}),pe(te(H,Se(M=>M!=null&&M.scrollTop>0),Tn(0)),E),Ze(te(v,Le(H),Se(([,M])=>M!=null)),([,M])=>{M&&(Me(_,M.viewport),Me($,M.item),Me(K,M.gap),M.scrollTop>0&&(Me(j,!0),fn(te(c,sr(1)),U=>{Me(j,!1)}),Me(l,{top:M.scrollTop})))}),pe(te(_,ue(({height:M})=>M)),p),pe(te(xt(ye(_,Fs),ye($,Fs),ye(K,(M,U)=>M&&M.column===U.column&&M.row===U.row),ye(c)),ue(([M,U,Z,se])=>({gap:Z,item:U,scrollTop:se,viewport:M}))),q),pe(te(xt(ye(T),r,ye(K,VC),ye($,Fs),ye(_,Fs),ye(O),ye(E),ye(j),ye(Y),ye(I)),Se(([,,,,,,,M])=>!M),ue(([M,[U,Z],se,ae,Ce,we,je,,We,Fe])=>{const{column:Ye,row:He}=se,{height:vt,width:wt}=ae,{width:dt}=Ce;if(je===0&&(M===0||dt===0))return qp;if(wt===0){const bt=Wa(Fe,M),mt=bt+Math.max(je-1,0);return WC(Xp(bt,mt,we))}const Ve=Jp(dt,wt,Ye);let Ae,Ke;We?U===0&&Z===0&&je>0?(Ae=0,Ke=je-1):(Ae=Ve*$s((U+He)/(vt+He)),Ke=Ve*Gp((Z+He)/(vt+He))-1,Ke=Qa(M-1,ko(Ke,Ve-1)),Ae=Qa(Ke,ko(0,Ae))):(Ae=0,Ke=-1);const _e=Xp(Ae,Ke,we),{bottom:Be,top:Qe}=Zp(Ce,se,ae,_e),Nt=Gp(M/Ve),et=Nt*vt+(Nt-1)*He-Be;return{bottom:Be,itemHeight:vt,items:_e,itemWidth:wt,offsetBottom:et,offsetTop:Qe,top:Qe}})),P),pe(te(O,Se(M=>M!==null),ue(M=>M.length)),T),pe(te(xt(_,$,P,K),Se(([M,U,{items:Z}])=>Z.length>0&&U.height!==0&&M.height!==0),ue(([M,U,{items:Z},se])=>{const{bottom:ae,top:Ce}=Zp(M,se,U,Z);return[Ce,ae]}),st(vo)),t);const V=oe(!1);pe(te(c,Le(V),ue(([M,U])=>U||M!==0)),V);const R=en(te(xt(P,T),Se(([{items:M}])=>M.length>0),Le(V),Se(([[M,U],Z])=>{const se=M.items[M.items.length-1].index===U-1;return(Z||M.bottom>0&&M.itemHeight>0&&M.offsetBottom===0&&M.items.length===U)&&se}),ue(([[,M]])=>M-1),st())),B=en(te(ye(P),Se(({items:M})=>M.length>0&&M[0].index===0),Tn(0),st())),X=en(te(ye(P),Le(j),Se(([{items:M},U])=>M.length>0&&!U),ue(([{items:M}])=>({endIndex:M[M.length-1].index,startIndex:M[0].index})),st(xp),jn(0)));pe(X,f.scrollSeekRangeChanged),pe(te(L,Le(_,$,T,K),ue(([M,U,Z,se,ae])=>{const Ce=Cp(M),{align:we,behavior:je,offset:We}=Ce;let Fe=Ce.index;Fe==="LAST"&&(Fe=se-1),Fe=ko(0,Fe,Qa(se-1,Fe));let Ye=el(U,ae,Z,Fe);return we==="end"?Ye=Yp(Ye-U.height+Z.height):we==="center"&&(Ye=Yp(Ye-U.height/2+Z.height/2)),We&&(Ye+=We),{behavior:je,top:Ye}})),l);const N=Rt(te(P,ue(M=>M.offsetBottom+M.bottom)),0);return pe(te(k,ue(M=>({height:M.visibleHeight,width:M.visibleWidth}))),_),{customScrollParent:x,data:O,deviation:G,footerHeight:o,gap:K,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:$,overscan:n,restoreStateFrom:H,scrollBy:i,scrollContainerState:a,scrollHeight:F,scrollTo:l,scrollToIndex:L,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:_,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:k,...f,gridState:P,horizontalDirection:D,initialTopMostItemIndex:I,totalListHeight:N,...m,endReached:R,propsReady:g,rangeChanged:X,startReached:B,stateChanged:q,stateRestoreInProgress:j,...S}},ot(Va,Ft,To,Mp,Un,qa,zn));function Jp(e,t,n){return ko(1,$s((e+n)/($s(t)+n)))}function Zp(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=el(e,t,n,r[0].index);return{bottom:el(e,t,n,r[r.length-1].index)+o,top:s}}function el(e,t,n,r){const o=Jp(e.width,n.width,t.column),s=$s(r/o),i=s*n.height+ko(0,s-1)*t.row;return i>0?i+t.row:i}const qC=Ge(()=>{const e=oe(p=>`Item ${p}`),t=oe({}),n=oe(null),r=oe("virtuoso-grid-item"),o=oe("virtuoso-grid-list"),s=oe(Ja),i=oe("div"),a=oe(Dr),l=(p,m=null)=>Rt(te(t,ue(f=>f[p]),st()),m),c=oe(!1),d=oe(!1);return pe(ye(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),GC=Ge(([e,t])=>({...e,...t}),ot(KC,qC)),YC=w.memo(function(){const e=it("gridState"),t=it("listClassName"),n=it("itemClassName"),r=it("itemContent"),o=it("computeItemKey"),s=it("isSeeking"),i=on("scrollHeight"),a=it("ItemComponent"),l=it("ListComponent"),c=it("ScrollSeekPlaceholder"),d=it("context"),p=on("itemDimensions"),m=on("gap"),f=it("log"),v=it("stateRestoreInProgress"),g=on("reportReadyState"),x=ir(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const C=y.firstChild;if(C){const{height:k,width:S}=C.getBoundingClientRect();p({height:k,width:S})}m({column:eh("column-gap",getComputedStyle(y).columnGap,f),row:eh("row-gap",getComputedStyle(y).rowGap,f)})},[i,p,m,f]),!0,!1);return Bp(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Mt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const b=o(y.index,y.data,d);return s?u.jsx(c,{...Mt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Mt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),XC=w.memo(function(){const e=it("HeaderComponent"),t=on("headerHeight"),n=it("headerFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=it("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),JC=w.memo(function(){const e=it("FooterComponent"),t=on("footerHeight"),n=it("headerFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=it("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),ZC=({children:e})=>{const t=w.useContext(Fp),n=on("itemDimensions"),r=on("viewportDimensions"),o=ir(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:Ls(!1),children:e})},QC=({children:e})=>{const t=w.useContext(Fp),n=on("windowViewportRect"),r=on("itemDimensions"),o=it("customScrollParent"),s=up(n,o,!1);return w.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:Ls(!1),children:e})},eT=w.memo(function({...e}){const t=it("useWindowScroll"),n=it("customScrollParent"),r=n||t?nT:tT,o=n||t?QC:ZC,s=it("context");return u.jsx(r,{...e,...Mt(r,s),children:u.jsxs(o,{children:[u.jsx(XC,{}),u.jsx(YC,{}),u.jsx(JC,{})]})})}),{useEmitter:Qp,useEmitterValue:it,usePublisher:on}=Lp(GC,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},eT),tT=Vp({useEmitter:Qp,useEmitterValue:it,usePublisher:on}),nT=Kp({useEmitter:Qp,useEmitterValue:it,usePublisher:on});function eh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Wt.WARN),t==="normal"?0:parseInt(t??"0",10)}var Bs="Dialog",[th,ON]=cn(Bs),[rT,hn]=th(Bs),nh=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),l=h.useRef(null),[c,d]=On({prop:r,defaultProp:o??!1,onChange:s,caller:Bs});return u.jsx(rT,{scope:t,triggerRef:a,contentRef:l,contentId:_t(),titleId:_t(),descriptionId:_t(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(p=>!p),[d]),modal:i,children:n})};nh.displayName=Bs;var rh="DialogTrigger",oh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(rh,n),s=De(t,o.triggerRef);return u.jsx(fe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":rl(o.open),...r,ref:s,onClick:ie(e.onClick,o.onOpenToggle)})});oh.displayName=rh;var tl="DialogPortal",[oT,sh]=th(tl,{forceMount:void 0}),ih=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=hn(tl,t);return u.jsx(oT,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(Ut,{present:n||s.open,children:u.jsx(ao,{asChild:!0,container:o,children:i})}))})};ih.displayName=tl;var zs="DialogOverlay",ah=h.forwardRef((e,t)=>{const n=sh(zs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(zs,e.__scopeDialog);return s.modal?u.jsx(Ut,{present:r||s.open,children:u.jsx(iT,{...o,ref:t})}):null});ah.displayName=zs;var sT=Yt.createSlot("DialogOverlay.RemoveScroll"),iT=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(zs,n);return u.jsx(ws,{as:sT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(fe.div,{"data-state":rl(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),cr="DialogContent",lh=h.forwardRef((e,t)=>{const n=sh(cr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(cr,e.__scopeDialog);return u.jsx(Ut,{present:r||s.open,children:s.modal?u.jsx(aT,{...o,ref:t}):u.jsx(lT,{...o,ref:t})})});lh.displayName=cr;var aT=h.forwardRef((e,t)=>{const n=hn(cr,e.__scopeDialog),r=h.useRef(null),o=De(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return va(s)},[]),u.jsx(ch,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ie(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ie(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault())})}),lT=h.forwardRef((e,t)=>{const n=hn(cr,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(ch,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),ch=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=hn(cr,n),l=h.useRef(null),c=De(t,l);return Yi(),u.jsxs(u.Fragment,{children:[u.jsx(es,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(kr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":rl(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(cT,{titleId:a.titleId}),u.jsx(dT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),nl="DialogTitle",uh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(nl,n);return u.jsx(fe.h2,{id:o.titleId,...r,ref:t})});uh.displayName=nl;var dh="DialogDescription",fh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(dh,n);return u.jsx(fe.p,{id:o.descriptionId,...r,ref:t})});fh.displayName=dh;var ph="DialogClose",hh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(ph,n);return u.jsx(fe.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,()=>o.onOpenChange(!1))})});hh.displayName=ph;function rl(e){return e?"open":"closed"}var mh="DialogTitleWarning",[DN,gh]=kw(mh,{contentName:cr,titleName:nl,docsSlug:"dialog"}),cT=({titleId:e})=>{const t=gh(mh),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
79
|
+
`)},f0=0,Mr=[];function p0(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(f0++)[0],s=h.useState(Zd)[0],i=h.useRef(e);h.useEffect(function(){i.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=My([e.lockRef.current],(e.shards||[]).map(sf),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=h.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=vs(g),b=n.current,C="deltaX"in g?g.deltaX:b[0]-y[0],k="deltaY"in g?g.deltaY:b[1]-y[1],S,T=g.target,E=Math.abs(C)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var P=tf(E,T);if(!P)return!0;if(P?S=E:(S=E==="v"?"h":"v",P=tf(E,T)),!P)return!1;if(!r.current&&"changedTouches"in g&&(C||k)&&(r.current=S),!S)return!0;var _=r.current||S;return c0(_,x,g,_==="h"?C:k)},[]),l=h.useCallback(function(g){var x=g;if(!(!Mr.length||Mr[Mr.length-1]!==s)){var y="deltaY"in x?of(x):vs(x),b=t.current.filter(function(S){return S.name===x.type&&(S.target===x.target||x.target===S.shadowParent)&&u0(S.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var C=(i.current.shards||[]).map(sf).filter(Boolean).filter(function(S){return S.contains(x.target)}),k=C.length>0?a(x,C[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=h.useCallback(function(g,x,y,b){var C={name:g,delta:x,target:y,should:b,shadowParent:h0(y)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(k){return k!==C})},1)},[]),d=h.useCallback(function(g){n.current=vs(g),r.current=void 0},[]),p=h.useCallback(function(g){c(g.type,of(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){c(g.type,vs(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return Mr.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Rr),document.addEventListener("touchmove",l,Rr),document.addEventListener("touchstart",d,Rr),function(){Mr=Mr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Rr),document.removeEventListener("touchmove",l,Rr),document.removeEventListener("touchstart",d,Rr)}},[]);var f=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:d0(o)}):null,f?h.createElement(n0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function h0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const m0=Uy(Jd,p0);var ws=h.forwardRef(function(e,t){return h.createElement(gs,Cn({},e,{ref:t,sideCar:m0}))});ws.classNames=gs.classNames;var Ca=["Enter"," "],g0=["ArrowDown","PageUp","Home"],af=["ArrowUp","PageDown","End"],x0=[...g0,...af],v0={ltr:[...Ca,"ArrowRight"],rtl:[...Ca,"ArrowLeft"]},w0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},co="Menu",[uo,b0,y0]=Zo(co),[rr,lf]=cn(co,[y0,Pr,Hd]),bs=Pr(),cf=Hd(),[S0,or]=rr(co),[C0,fo]=rr(co),uf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=bs(t),[l,c]=h.useState(null),d=h.useRef(!1),p=pt(s),m=Qo(o);return h.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(da,{...a,children:u.jsx(S0,{scope:t,open:n,onOpenChange:p,content:l,onContentChange:c,children:u.jsx(C0,{scope:t,onClose:h.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};uf.displayName=co;var T0="MenuAnchor",Ta=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(fa,{...o,...r,ref:t})});Ta.displayName=T0;var ka="MenuPortal",[k0,df]=rr(ka,{forceMount:void 0}),ff=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=or(ka,t);return u.jsx(k0,{scope:t,forceMount:n,children:u.jsx(Ut,{present:n||s.open,children:u.jsx(ao,{asChild:!0,container:o,children:r})})})};ff.displayName=ka;var nn="MenuContent",[E0,Ea]=rr(nn),pf=h.forwardRef((e,t)=>{const n=df(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=or(nn,e.__scopeMenu),i=fo(nn,e.__scopeMenu);return u.jsx(uo.Provider,{scope:e.__scopeMenu,children:u.jsx(Ut,{present:r||s.open,children:u.jsx(uo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(I0,{...o,ref:t}):u.jsx(N0,{...o,ref:t})})})})}),I0=h.forwardRef((e,t)=>{const n=or(nn,e.__scopeMenu),r=h.useRef(null),o=De(t,r);return h.useEffect(()=>{const s=r.current;if(s)return va(s)},[]),u.jsx(Ia,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),N0=h.forwardRef((e,t)=>{const n=or(nn,e.__scopeMenu);return u.jsx(Ia,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),A0=Yt.createSlot("MenuContent.ScrollLock"),Ia=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...g}=e,x=or(nn,n),y=fo(nn,n),b=bs(n),C=cf(n),k=b0(n),[S,T]=h.useState(null),E=h.useRef(null),P=De(t,E,x.onContentChange),_=h.useRef(0),$=h.useRef(""),L=h.useRef(0),F=h.useRef(null),G=h.useRef("right"),O=h.useRef(0),K=v?ws:h.Fragment,q=v?{as:A0,allowPinchZoom:!0}:void 0,H=I=>{var N,M;const Y=$.current+I,J=k().filter(U=>!U.disabled),D=document.activeElement,V=(N=J.find(U=>U.ref.current===D))==null?void 0:N.textValue,R=J.map(U=>U.textValue),B=z0(R,Y,V),X=(M=J.find(U=>U.textValue===B))==null?void 0:M.ref.current;(function U(Z){$.current=Z,window.clearTimeout(_.current),Z!==""&&(_.current=window.setTimeout(()=>U(""),1e3))})(Y),X&&setTimeout(()=>X.focus())};h.useEffect(()=>()=>window.clearTimeout(_.current),[]),Yi();const j=h.useCallback(I=>{var J,D;return G.current===((J=F.current)==null?void 0:J.side)&&U0(I,(D=F.current)==null?void 0:D.area)},[]);return u.jsx(E0,{scope:n,searchRef:$,onItemEnter:h.useCallback(I=>{j(I)&&I.preventDefault()},[j]),onItemLeave:h.useCallback(I=>{var Y;j(I)||((Y=E.current)==null||Y.focus(),T(null))},[j]),onTriggerLeave:h.useCallback(I=>{j(I)&&I.preventDefault()},[j]),pointerGraceTimerRef:L,onPointerGraceIntentChange:h.useCallback(I=>{F.current=I},[]),children:u.jsx(K,{...q,children:u.jsx(es,{asChild:!0,trapped:o,onMountAutoFocus:ie(s,I=>{var Y;I.preventDefault(),(Y=E.current)==null||Y.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(kr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,children:u.jsx(Ay,{asChild:!0,...C,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:T,onEntryFocus:ie(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(pa,{role:"menu","aria-orientation":"vertical","data-state":Pf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:P,style:{outline:"none",...g.style},onKeyDown:ie(g.onKeyDown,I=>{const J=I.target.closest("[data-radix-menu-content]")===I.currentTarget,D=I.ctrlKey||I.altKey||I.metaKey,V=I.key.length===1;J&&(I.key==="Tab"&&I.preventDefault(),!D&&V&&H(I.key));const R=E.current;if(I.target!==R||!x0.includes(I.key))return;I.preventDefault();const X=k().filter(N=>!N.disabled).map(N=>N.ref.current);af.includes(I.key)&&X.reverse(),F0(X)}),onBlur:ie(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(_.current),$.current="")}),onPointerMove:ie(e.onPointerMove,ho(I=>{const Y=I.target,J=O.current!==I.clientX;if(I.currentTarget.contains(Y)&&J){const D=I.clientX>O.current?"right":"left";G.current=D,O.current=I.clientX}}))})})})})})})});pf.displayName=nn;var P0="MenuGroup",Na=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(fe.div,{role:"group",...r,ref:t})});Na.displayName=P0;var j0="MenuLabel",hf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(fe.div,{...r,ref:t})});hf.displayName=j0;var ys="MenuItem",mf="menu.itemSelect",Ss=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=fo(ys,e.__scopeMenu),a=Ea(ys,e.__scopeMenu),l=De(t,s),c=h.useRef(!1),d=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(mf,{bubbles:!0,cancelable:!0});p.addEventListener(mf,f=>r==null?void 0:r(f),{once:!0}),Ki(p,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(gf,{...o,ref:l,disabled:n,onClick:ie(e.onClick,d),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),c.current=!0},onPointerUp:ie(e.onPointerUp,p=>{var m;c.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:ie(e.onKeyDown,p=>{const m=a.searchRef.current!=="";n||m&&p.key===" "||Ca.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Ss.displayName=ys;var gf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Ea(ys,n),a=cf(n),l=h.useRef(null),c=De(t,l),[d,p]=h.useState(!1),[m,f]=h.useState("");return h.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(uo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(Py,{asChild:!0,...a,focusable:!r,children:u.jsx(fe.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ie(e.onPointerMove,ho(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ie(e.onPointerLeave,ho(v=>i.onItemLeave(v))),onFocus:ie(e.onFocus,()=>p(!0)),onBlur:ie(e.onBlur,()=>p(!1))})})})}),_0="MenuCheckboxItem",xf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(Sf,{scope:e.__scopeMenu,checked:n,children:u.jsx(Ss,{role:"menuitemcheckbox","aria-checked":Cs(n)?"mixed":n,...o,ref:t,"data-state":Pa(n),onSelect:ie(o.onSelect,()=>r==null?void 0:r(Cs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});xf.displayName=_0;var vf="MenuRadioGroup",[R0,M0]=rr(vf,{value:void 0,onValueChange:()=>{}}),wf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=pt(r);return u.jsx(R0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Na,{...o,ref:t})})});wf.displayName=vf;var bf="MenuRadioItem",yf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=M0(bf,e.__scopeMenu),s=n===o.value;return u.jsx(Sf,{scope:e.__scopeMenu,checked:s,children:u.jsx(Ss,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Pa(s),onSelect:ie(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});yf.displayName=bf;var Aa="MenuItemIndicator",[Sf,O0]=rr(Aa,{checked:!1}),Cf=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=O0(Aa,n);return u.jsx(Ut,{present:r||Cs(s.checked)||s.checked===!0,children:u.jsx(fe.span,{...o,ref:t,"data-state":Pa(s.checked)})})});Cf.displayName=Aa;var D0="MenuSeparator",Tf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(fe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Tf.displayName=D0;var L0="MenuArrow",kf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(ha,{...o,...r,ref:t})});kf.displayName=L0;var $0="MenuSub",[RN,Ef]=rr($0),po="MenuSubTrigger",If=h.forwardRef((e,t)=>{const n=or(po,e.__scopeMenu),r=fo(po,e.__scopeMenu),o=Ef(po,e.__scopeMenu),s=Ea(po,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const p=a.current;return()=>{window.clearTimeout(p),l(null)}},[a,l]),u.jsx(Ta,{asChild:!0,...c,children:u.jsx(gf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Pf(n.open),...e,ref:Mn(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:ie(e.onPointerMove,ho(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ie(e.onPointerLeave,ho(p=>{var f,v;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,b=m[x?"left":"right"],C=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+y,y:p.clientY},{x:b,y:m.top},{x:C,y:m.top},{x:C,y:m.bottom},{x:b,y:m.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ie(e.onKeyDown,p=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||v0[r.dir].includes(p.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),p.preventDefault())})})})});If.displayName=po;var Nf="MenuSubContent",Af=h.forwardRef((e,t)=>{const n=df(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=or(nn,e.__scopeMenu),i=fo(nn,e.__scopeMenu),a=Ef(Nf,e.__scopeMenu),l=h.useRef(null),c=De(t,l);return u.jsx(uo.Provider,{scope:e.__scopeMenu,children:u.jsx(Ut,{present:r||s.open,children:u.jsx(uo.Slot,{scope:e.__scopeMenu,children:u.jsx(Ia,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var p;i.isUsingKeyboardRef.current&&((p=l.current)==null||p.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ie(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ie(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ie(e.onKeyDown,d=>{var f;const p=d.currentTarget.contains(d.target),m=w0[i.dir].includes(d.key);p&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});Af.displayName=Nf;function Pf(e){return e?"open":"closed"}function Cs(e){return e==="indeterminate"}function Pa(e){return Cs(e)?"indeterminate":e?"checked":"unchecked"}function F0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function B0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function z0(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=B0(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function H0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function U0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return H0(n,t)}function ho(e){return t=>t.pointerType==="mouse"?e(t):void 0}var W0=uf,V0=Ta,K0=ff,q0=pf,G0=Na,Y0=hf,X0=Ss,J0=xf,Z0=wf,Q0=yf,eS=Cf,tS=Tf,nS=kf,rS=If,oS=Af,Ts="DropdownMenu",[sS,MN]=cn(Ts,[lf]),$t=lf(),[iS,jf]=sS(Ts),_f=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=$t(t),c=h.useRef(null),[d,p]=On({prop:o,defaultProp:s??!1,onChange:i,caller:Ts});return u.jsx(iS,{scope:t,triggerId:_t(),triggerRef:c,contentId:_t(),open:d,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(m=>!m),[p]),modal:a,children:u.jsx(W0,{...l,open:d,onOpenChange:p,dir:r,modal:a,children:n})})};_f.displayName=Ts;var Rf="DropdownMenuTrigger",Mf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=jf(Rf,n),i=$t(n);return u.jsx(V0,{asChild:!0,...i,children:u.jsx(fe.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:Mn(t,s.triggerRef),onPointerDown:ie(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ie(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Mf.displayName=Rf;var aS="DropdownMenuPortal",Of=e=>{const{__scopeDropdownMenu:t,...n}=e,r=$t(t);return u.jsx(K0,{...r,...n})};Of.displayName=aS;var Df="DropdownMenuContent",Lf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jf(Df,n),s=$t(n),i=h.useRef(!1);return u.jsx(q0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ie(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ie(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.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)"}})});Lf.displayName=Df;var lS="DropdownMenuGroup",cS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(G0,{...o,...r,ref:t})});cS.displayName=lS;var uS="DropdownMenuLabel",$f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Y0,{...o,...r,ref:t})});$f.displayName=uS;var dS="DropdownMenuItem",Ff=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(X0,{...o,...r,ref:t})});Ff.displayName=dS;var fS="DropdownMenuCheckboxItem",Bf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(J0,{...o,...r,ref:t})});Bf.displayName=fS;var pS="DropdownMenuRadioGroup",hS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Z0,{...o,...r,ref:t})});hS.displayName=pS;var mS="DropdownMenuRadioItem",zf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Q0,{...o,...r,ref:t})});zf.displayName=mS;var gS="DropdownMenuItemIndicator",Hf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(eS,{...o,...r,ref:t})});Hf.displayName=gS;var xS="DropdownMenuSeparator",Uf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(tS,{...o,...r,ref:t})});Uf.displayName=xS;var vS="DropdownMenuArrow",wS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(nS,{...o,...r,ref:t})});wS.displayName=vS;var bS="DropdownMenuSubTrigger",Wf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(rS,{...o,...r,ref:t})});Wf.displayName=bS;var yS="DropdownMenuSubContent",Vf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(oS,{...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)"}})});Vf.displayName=yS;var SS=_f,CS=Mf,TS=Of,Kf=Lf,qf=$f,Gf=Ff,Yf=Bf,Xf=zf,Jf=Hf,Zf=Uf,Qf=Wf,ep=Vf;const ks=SS,Es=CS,kS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Qf,{ref:o,className:re("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,u.jsx(ce.ChevronRight,{className:"ml-auto h-4 w-4"})]}));kS.displayName=Qf.displayName;const ES=h.forwardRef(({className:e,...t},n)=>u.jsx(ep,{ref:n,className:re("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}));ES.displayName=ep.displayName;const mo=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(TS,{children:u.jsx(Kf,{ref:r,sideOffset:t,className:re("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})}));mo.displayName=Kf.displayName;const Fn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Gf,{ref:r,className:re("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}));Fn.displayName=Gf.displayName;const IS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Yf,{ref:o,className:re("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:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Jf,{children:u.jsx(ce.Check,{className:"h-4 w-4"})})}),t]}));IS.displayName=Yf.displayName;const NS=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Xf,{ref:r,className:re("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:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Jf,{children:u.jsx(ce.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));NS.displayName=Xf.displayName;const AS=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(qf,{ref:r,className:re("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));AS.displayName=qf.displayName;const PS=h.forwardRef(({className:e,...t},n)=>u.jsx(Zf,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));PS.displayName=Zf.displayName;const ja=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:re("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}));ja.displayName="Textarea";const jS=1e4;function tp({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=jS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:p="",textareaClassName:m="",allowEmptySend:f=!1,sendButtonClassName:v,validate:g,onValidationError:x}){const y=i!==void 0,[b,C]=w.useState(e),k=(y?i:b)??"",[S,T]=w.useTransition(),E=w.useRef(null),P=w.useRef(0),_=w.useRef(null),$=w.useRef("");w.useEffect(()=>{y||(C(e??""),_.current=null,E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`))},[e,t,y]);const[L,F]=w.useState(null),G=w.useCallback(R=>R.length>s?`Message too long (${R.length}/${s} characters)`:null,[s]),O=w.useMemo(()=>g??G,[g,G]),K=w.useCallback(R=>{const B=O(R);return F(B),x==null||x(B),$.current=R,B},[O,x]),q=w.useCallback(()=>{const R=E.current;R&&(R.style.height="auto",R.style.height=`${R.scrollHeight}px`)},[]);w.useEffect(()=>{q()},[q,k]),w.useEffect(()=>{if(!L)return;const R=(k??"").trim();$.current!==R&&K(R)},[k,L,K]);const H=w.useCallback((R,{fromUser:B})=>{y||C(R),B&&(a==null||a(R))},[y,a]),j=w.useCallback(async R=>{R&&R.preventDefault();const B=(k??"").trim();if(!B&&!f||K(B))return;const X=++P.current;_.current={id:X,shouldClear:!0},T(()=>{var N,M,U;try{const Z=l(B);Z&&typeof Z.then=="function"?Z.then(()=>{var se,ae;((se=_.current)==null?void 0:se.id)===X&&_.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((ae=_.current)==null?void 0:ae.id)===X&&(_.current=null)}).catch(()=>{var se;((se=_.current)==null?void 0:se.id)===X&&(_.current=null)}):(((N=_.current)==null?void 0:N.id)===X&&_.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((M=_.current)==null?void 0:M.id)===X&&(_.current=null))}catch{((U=_.current)==null?void 0:U.id)===X&&(_.current=null)}})},[k,l,f,y,a,K]),I=w.useCallback(R=>{const B=R.target.value;H(B,{fromUser:!0}),_.current&&(_.current.shouldClear=!1),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`),L&&K(B.trim())},[H,K,L]),Y=w.useCallback(R=>{R.key==="Enter"&&!R.shiftKey?(R.preventDefault(),j()):R.key==="Escape"&&t&&(R.preventDefault(),c==null||c())},[j,t,c]),V=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${m}`;return u.jsx("form",{onSubmit:R=>void j(R),className:`w-full ${p}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(ja,{ref:E,value:k,onChange:I,onKeyDown:Y,placeholder:t?"Edit your message...":n,className:V,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),L&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:L})]}),u.jsx("div",{children:r?u.jsx(Je,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ce.Square,{size:16})}):u.jsx(Je,{type:"submit",size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!k.trim()&&!f||S,children:u.jsx(ce.Send,{size:16})})})]})})}const _S=w.memo(tp);function np({composerValue:e,onComposerChange:t,onSend:n,onCancelEdit:r,onStop:o,editingMessageId:s=null,editingInitialValue:i="",placeholder:a="Type your message...",isStreaming:l=!1,disabled:c=!1,textareaClassName:d="",customStyles:p={},enableFileUpload:m=!1,enableExcelUpload:f=!1,onExcelUpload:v,onError:g,allowEmptySend:x=!1,inputError:y=null}){const[b,C]=w.useState([]),k=w.useRef(null),S=w.useRef(null),[T,E]=w.useState(0),[P,_]=w.useState(0),[$,L]=w.useState(!1),[F,G]=w.useState(null),[O,K]=w.useState(null),q=w.useCallback(()=>{k.current&&(k.current.value=""),S.current&&(S.current.value=""),E(R=>R+1),_(R=>R+1)},[]),H=w.useCallback(R=>{C(B=>[...B,...R])},[]),j=w.useCallback(R=>{const B=Array.from(R.target.files||[]);H(B),R.target.value=""},[H]),I=w.useCallback(R=>{C(B=>{const X=B.filter((N,M)=>M!==R);return X.length===0&&q(),X})},[q]),Y=w.useCallback(async R=>{const B=(R.target.files||[])[0];if(B&&(G(null),K(null),!!v)){L(!0);try{await v(B),G(`Uploaded ${B.name} - processing through chat stream`)}catch(X){const N=X instanceof Error?X.message:"Failed to upload Excel file";K(N),g==null||g(N)}finally{L(!1),R.target.value="",q()}}},[v,g,q]),J=w.useMemo(()=>x||b.length>0,[x,b]),D=w.useCallback(async R=>{const X=await n(R,b);return b.length>0&&(C([]),q()),X},[n,q,b]),V=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${s?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${y?"border-red-400":""} ${p.textarea||""} ${d}`;return u.jsxs(u.Fragment,{children:[(m||f)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[m&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:k,type:"file",multiple:!0,onChange:j,className:"hidden"},T),b.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:b.map((R,B)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(ce.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:R.name}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>I(B),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${R.name}`,children:u.jsx(ce.X,{size:12})})]},B))})]}),f&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Y,className:"hidden"},P),$&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ce.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),F&&!$&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:F}),O&&!$&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:O})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||f)&&u.jsxs(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Je,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:p.moreButton||"",children:u.jsx(ce.Plus,{size:16})})}),u.jsxs(mo,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Fn,{onClick:()=>{var R;return(R=k.current)==null?void 0:R.click()},className:"cursor-pointer",children:[u.jsx(ce.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),f&&u.jsxs(Fn,{onClick:()=>{var R;$||(R=S.current)==null||R.click()},className:`cursor-pointer ${$?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ce.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(_S,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:D,onCancelEdit:r,onStop:o,allowEmptySend:J,textareaClassName:V,sendButtonClassName:p.sendButton})})]})]})}const RS=w.memo(np),Is=0,Bn=1,Or=2,rp=4;function op(e){return()=>e}function MS(e){e()}function sp(e,t){return n=>e(t(n))}function ip(e,t){return()=>e(t)}function OS(e,t){return n=>e(t,n)}function _a(e){return e!==void 0}function DS(...e){return()=>{e.map(MS)}}function Dr(){}function Ns(e,t){return t(e),e}function LS(e,t){return t(e)}function ot(...e){return e}function Ze(e,t){return e(Bn,t)}function Me(e,t){e(Is,t)}function Ra(e){e(Or)}function ht(e){return e(rp)}function pe(e,t){return Ze(e,OS(t,Is))}function fn(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function ap(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function lp(e,t){return e===t}function st(e=lp){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Se(e){return t=>n=>{e(n)&&t(n)}}function ue(e){return t=>sp(t,e)}function Tn(e){return t=>()=>{t(e)}}function te(e,...t){const n=$S(...t);return(r,o)=>{switch(r){case Or:Ra(e);return;case Bn:return Ze(e,n(o))}}}function kn(e,t){return n=>r=>{n(t=e(t,r))}}function sr(e){return t=>n=>{e>0?e--:t(n)}}function jn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Le(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function $S(...e){return t=>e.reduceRight(LS,t)}function FS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Bn:return s?n===s?void 0:(r(),n=s,t=Ze(e,s),t):(r(),Dr);case Or:r(),n=null;return}}}function oe(e){let t=e;const n=ze();return(r,o)=>{switch(r){case Is:t=o;break;case Bn:{o(t);break}case rp:return t}return n(r,o)}}function Rt(e,t){return Ns(oe(t),n=>pe(e,n))}function ze(){const e=[];return(t,n)=>{switch(t){case Is:e.slice().forEach(r=>{r(n)});return;case Or:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function en(e){return Ns(ze(),t=>pe(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:BS(),singleton:n}}const BS=()=>Symbol();function zS(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function xt(...e){const t=ze(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,l=>{n[i]=l,r=r|a,r===o&&Me(t,n)})}),function(s,i){switch(s){case Or:{Ra(t);return}case Bn:return r===o&&i(n),Ze(t,i)}}}function ye(e,t=lp){return te(e,st(t))}function Ma(...e){return function(t,n){switch(t){case Or:return;case Bn:return DS(...e.map(r=>Ze(r,n)))}}}var Wt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Wt||{});const HS={0:"debug",3:"error",1:"log",2:"warn"},US=()=>typeof globalThis>"u"?window:globalThis,zn=Ge(()=>{const e=oe(3);return{log:oe((t,n,r=1)=>{var o;const s=(o=US().VIRTUOSO_LOG_LEVEL)!=null?o:ht(e);r>=s&&console[HS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function ir(e,t,n){return Oa(e,t,n).callbackRef}function Oa(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function WS(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const p=VS(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const f=m.lastElementChild.dataset.viewportType==="window";let v;f&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:f?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:f?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:f?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?cp("column-gap",getComputedStyle(d).columnGap,o):cp("row-gap",getComputedStyle(d).rowGap,o)),p!==null&&e(p)},[e,t,o,s,i,r,a]);return Oa(c,n,l)}function VS(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Wt.ERROR),d===c)continue;const p=s[s.length-1];s.length===0||p.size!==d||p.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function cp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Wt.WARN),t==="normal"?0:parseInt(t??"0",10)}function up(e,t,n){const r=w.useRef(null),o=w.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let p,m;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;m=f.height-Math.max(0,v),p=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),p=c.top+f.scrollY}r.current={offsetTop:p,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Oa(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Ft=Ge(()=>{const e=ze(),t=ze(),n=oe(0),r=ze(),o=oe(0),s=ze(),i=ze(),a=oe(0),l=oe(0),c=oe(0),d=oe(0),p=ze(),m=ze(),f=oe(!1),v=oe(!1),g=oe(!1);return pe(te(e,ue(({scrollTop:x})=>x)),t),pe(te(e,ue(({scrollHeight:x})=>x)),i),pe(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:p,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),go={lvl:0};function dp(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function nt(e){return e===go}function xo(e,t){if(!nt(e))return t===e.k?e.v:t<e.k?xo(e.l,t):xo(e.r,t)}function pn(e,t,n="k"){if(nt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=pn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return pn(e.l,t,n)}function tn(e,t,n){return nt(e)?hp(t,n,1):t===e.k?St(e,{k:t,v:n}):t<e.k?mp(St(e,{l:tn(e.l,t,n)})):mp(St(e,{r:tn(e.r,t,n)}))}function Lr(){return go}function As(e,t,n){if(nt(e))return[];const r=pn(e,t)[0];return KS(La(e,r,n))}function Da(e,t){if(nt(e))return go;const{k:n,l:r,r:o}=e;if(t===n){if(nt(r))return o;if(nt(o))return r;{const[s,i]=pp(r);return Ps(St(e,{k:s,l:fp(r),v:i}))}}else return t<n?Ps(St(e,{l:Da(r,t)})):Ps(St(e,{r:Da(o,t)}))}function ar(e){return nt(e)?[]:[...ar(e.l),{k:e.k,v:e.v},...ar(e.r)]}function La(e,t,n){if(nt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(La(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(La(s,t,n))),a}function Ps(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if($a(t))return gp(St(e,{lvl:n-1}));if(!nt(t)&&!nt(t.r))return St(t.r,{l:St(t,{r:t.r.l}),lvl:n,r:St(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if($a(e))return Fa(St(e,{lvl:n-1}));if(!nt(r)&&!nt(r.l)){const o=r.l,s=$a(o)?r.lvl-1:r.lvl;return St(o,{l:St(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Fa(St(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function St(e,t){return hp(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function fp(e){return nt(e.r)?e.l:Ps(St(e,{r:fp(e.r)}))}function $a(e){return nt(e)||e.lvl>e.r.lvl}function pp(e){return nt(e.r)?[e.k,e.v]:pp(e.r)}function hp(e,t,n,r=go,o=go){return{k:e,l:r,lvl:n,r:o,v:t}}function mp(e){return Fa(gp(e))}function gp(e){const{l:t}=e;return!nt(t)&&t.lvl===e.lvl?St(t,{r:St(e,{l:t.r})}):e}function Fa(e){const{lvl:t,r:n}=e;return!nt(n)&&!nt(n.r)&&n.lvl===t&&n.r.lvl===t?St(n,{l:St(e,{r:n.l}),lvl:t+1}):e}function KS(e){return dp(e,({k:t,v:n})=>({index:t,value:n}))}function xp(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function vo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ba=Ge(()=>({recalcInProgress:oe(!1)}),[],{singleton:!0});function vp(e,t,n){return e[js(e,t,n)]}function js(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function qS(e,t,n,r){const o=js(e,t,r),s=js(e,n,r,o);return e.slice(o,s+1)}function Hn(e,t){return Math.round(e.getBoundingClientRect()[t])}function _s(e){return!nt(e.groupOffsetTree)}function za({index:e},t){return t===e?0:t<e?-1:1}function GS(){return{groupIndices:[],groupOffsetTree:Lr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Lr()}}function YS(e,t){let n=nt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),nt(e)){e=tn(e,0,s);continue}const a=As(e,i-1,o+1);if(a.some(nC(r)))continue;let l=!1,c=!1;for(const{end:d,start:p,value:m}of a)l?(o>=p||s===m)&&(e=Da(e,p)):(c=m!==s,l=!0),d>o&&o>=p&&m!==s&&(e=tn(e,o+1,m));c&&(e=tn(e,i,s))}return[e,n]}function XS(e){return typeof e.groupIndex<"u"}function JS({offset:e},t){return t===e?0:t<e?-1:1}function wo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=vp(t,e,za),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function wp(e,t){if(!_s(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function bp(e,t,n){if(XS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=wp(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function ZS(e,t,n,r=0){return r>0&&(t=Math.max(t,vp(e,r,za).offset)),dp(qS(e,t,n,JS),tC)}function QS(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Wt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&nt(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>tn(tn(v,g,m),g+1,f),i)}else[i,a]=YS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p}=Ha(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>tn(m,f,wo(f,p,o)),Lr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p,sizeTree:i}}function eC(e){return ar(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function yp(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function Ha(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=js(o,t-1,za),a=o[l].offset;const c=pn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===pn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of As(n,t,1/0)){const p=c-s,m=p*i+a+p*r;o.push({index:c,offset:m,size:d}),s=c,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function tC(e){return{index:e.index,value:e}}function nC(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const rC={offsetHeight:"height",offsetWidth:"width"},En=Ge(([{log:e},{recalcInProgress:t}])=>{const n=ze(),r=ze(),o=Rt(r,0),s=ze(),i=ze(),a=oe(0),l=oe([]),c=oe(void 0),d=oe(void 0),p=oe((S,T)=>Hn(S,rC[T])),m=oe(void 0),f=oe(0),v=GS(),g=Rt(te(n,Le(l,e,f),kn(QS,v),st()),v),x=Rt(te(l,st(),kn((S,T)=>({current:T,prev:S.current}),{current:[],prev:[]}),ue(({prev:S})=>S)),[]);pe(te(l,Se(S=>S.length>0),Le(g,f),ue(([S,T,E])=>{const P=S.reduce((_,$,L)=>tn(_,$,wo($,T.offsetTree,E)||L),Lr());return{...T,groupIndices:S,groupOffsetTree:P}})),g),pe(te(r,Le(g),Se(([S,{lastIndex:T}])=>S<T),ue(([S,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:S}])),n),pe(c,d);const y=Rt(te(c,ue(S=>S===void 0)),!0);pe(te(d,Se(S=>S!==void 0&&nt(ht(g).sizeTree)),ue(S=>[{endIndex:0,size:S,startIndex:0}])),n);const b=en(te(n,Le(g),kn(({sizes:S},[T,E])=>({changed:E!==S,sizes:E}),{changed:!1,sizes:v}),ue(S=>S.changed)));Ze(te(a,kn((S,T)=>({diff:S.prev-T,prev:T}),{diff:0,prev:0}),ue(S=>S.diff)),S=>{const{groupIndices:T}=ht(g);if(S>0)Me(t,!0),Me(s,S+yp(S,T));else if(S<0){const E=ht(x);E.length>0&&(S-=yp(-S,E)),Me(i,S)}}),Ze(te(a,Le(e)),([S,T])=>{S<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Wt.ERROR)});const C=en(s);pe(te(s,Le(g),ue(([S,T])=>{const E=T.groupIndices.length>0,P=[],_=T.lastSize;if(E){const $=xo(T.sizeTree,0);let L=0,F=0;for(;L<S;){const O=T.groupIndices[F],K=T.groupIndices.length===F+1?1/0:T.groupIndices[F+1]-O-1;P.push({endIndex:O,size:$,startIndex:O}),P.push({endIndex:O+1+K-1,size:_,startIndex:O+1}),F++,L+=K+1}const G=ar(T.sizeTree);return L!==S&&G.shift(),G.reduce((O,{k:K,v:q})=>{let H=O.ranges;return O.prevSize!==0&&(H=[...O.ranges,{endIndex:K+S-1,size:O.prevSize,startIndex:O.prevIndex}]),{prevIndex:K+S,prevSize:q,ranges:H}},{prevIndex:S,prevSize:0,ranges:P}).ranges}return ar(T.sizeTree).reduce(($,{k:L,v:F})=>({prevIndex:L+S,prevSize:F,ranges:[...$.ranges,{endIndex:L+S-1,size:$.prevSize,startIndex:$.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const k=en(te(i,Le(g,f),ue(([S,{offsetTree:T},E])=>{const P=-S;return wo(P,T,E)})));return pe(te(i,Le(g,f),ue(([S,T,E])=>{if(T.groupIndices.length>0){if(nt(T.sizeTree))return T;let P=Lr();const _=ht(x);let $=0,L=0,F=0;for(;$<-S;){F=_[L];const G=_[L+1]-F-1;L++,$+=G+1}if(P=ar(T.sizeTree).reduce((G,{k:O,v:K})=>tn(G,Math.max(0,O+S),K),P),$!==-S){const G=xo(T.sizeTree,F);P=tn(P,0,G);const O=pn(T.sizeTree,-S+1)[1];P=tn(P,1,O)}return{...T,sizeTree:P,...Ha(T.offsetTree,0,P,E)}}else{const P=ar(T.sizeTree).reduce((_,{k:$,v:L})=>tn(_,Math.max(0,$+S),L),Lr());return{...T,sizeTree:P,...Ha(T.offsetTree,0,P,E)}}})),g),{beforeUnshiftWith:C,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:p,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},ot(zn,Ba),{singleton:!0});function oC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Sp=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=ze(),i=ze(),a=en(te(s,ue(oC)));return pe(te(a,ue(l=>l.totalCount)),n),pe(te(a,ue(l=>l.groupIndices)),e),pe(te(xt(o,t,r),Se(([l,c])=>_s(c)),ue(([l,c,d])=>pn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),st(),ue(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ot(En,Ft)),Un=Ge(([{log:e}])=>{const t=oe(!1),n=en(te(t,Se(r=>r),st()));return Ze(t,r=>{r&&ht(e)("props updated",{},Wt.DEBUG)}),{didMount:n,propsReady:t}},ot(zn),{singleton:!0}),sC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Cp(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!sC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const bo=Ge(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:p},{log:m}])=>{const f=ze(),v=ze(),g=oe(0);let x=null,y=null,b=null;function C(){x&&(x(),x=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Me(l,!1)}return pe(te(f,Le(n,p,r,g,a,i,m),Le(e,s,o),ue(([[k,S,T,E,P,_,$,L],F,G,O])=>{const K=Cp(k),{align:q,behavior:H,offset:j}=K,I=E-1,Y=bp(K,S,I);let J=wo(Y,S.offsetTree,F)+_;q==="end"?(J+=G+pn(S.sizeTree,Y)[1]-T+O,Y===I&&(J+=$)):q==="center"?J+=(G+pn(S.sizeTree,Y)[1]-T+O)/2:J-=P,j&&(J+=j);const D=V=>{C(),V?(L("retrying to scroll to",{location:k},Wt.DEBUG),Me(f,k)):(Me(v,!0),L("list did not change, scroll successful",{},Wt.DEBUG))};if(C(),H==="smooth"){let V=!1;b=Ze(t,R=>{V=V||R}),x=fn(d,()=>{D(V)})}else x=fn(te(t,iC(150)),D);return y=setTimeout(()=>{C()},1200),Me(l,!0),L("scrolling from index to",{behavior:H,index:Y,top:J},Wt.DEBUG),{behavior:H,top:J}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},ot(En,Ft,zn),{singleton:!0});function iC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Ua(e,t){e==0?t():requestAnimationFrame(()=>{Ua(e-1,t)})}function Wa(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const yo=Ge(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=oe(!0),l=oe(0),c=oe(!0);return pe(te(i,Le(l),Se(([d,p])=>!!p),Tn(!1)),a),pe(te(i,Le(l),Se(([d,p])=>!!p),Tn(!1)),c),Ze(te(xt(t,i),Le(a,n,e,c),Se(([[,d],p,{sizeTree:m},f,v])=>d&&(!nt(m)||_a(f))&&!p&&!v),Le(l)),([,d])=>{fn(o,()=>{Me(c,!0)}),Ua(4,()=>{fn(r,()=>{Me(a,!0)}),Me(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ot(En,Ft,bo,Un),{singleton:!0});function Tp(e,t){return Math.abs(e-t)<1.01}const So="up",Co="down",aC="none",lC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},cC=0,To=Ge(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=oe(!1),a=oe(!0),l=ze(),c=ze(),d=oe(4),p=oe(cC),m=Rt(te(Ma(te(ye(o),sr(1),Tn(!0)),te(ye(o),sr(1),Tn(!1),ap(100))),st()),!1),f=Rt(te(Ma(te(n,Tn(!0)),te(n,Tn(!1),ap(200))),st()),!1);pe(te(xt(ye(o),ye(p)),ue(([b,C])=>b<=C),st()),a),pe(te(a,jn(50)),c);const v=en(te(xt(r,ye(s),ye(t),ye(e),ye(d)),kn((b,[{scrollHeight:C,scrollTop:k},S,T,E,P])=>{const _=k+S-C>-P,$={scrollHeight:C,scrollTop:k,viewportHeight:S};if(_){let F,G;return k>b.state.scrollTop?(F="SCROLLED_DOWN",G=b.state.scrollTop-k):(F="SIZE_DECREASED",G=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:F,scrollTopDelta:G,state:$}}let L;return $.scrollHeight>b.state.scrollHeight?L="SIZE_INCREASED":S<b.state.viewportHeight?L="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?L="SCROLLING_UPWARDS":L="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:L,state:$}},lC),st((b,C)=>b&&b.atBottom===C.atBottom))),g=Rt(te(r,kn((b,{scrollHeight:C,scrollTop:k,viewportHeight:S})=>{if(Tp(b.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:k};{const T=C-(k+S)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:C,scrollTop:k}:{changed:!0,jump:0,scrollHeight:C,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Se(b=>b.changed),ue(b=>b.jump)),0);pe(te(v,ue(b=>b.atBottom)),i),pe(te(i,jn(50)),l);const x=oe(Co);pe(te(r,ue(({scrollTop:b})=>b),st(),kn((b,C)=>ht(f)?{direction:b.direction,prevScrollTop:C}:{direction:C<b.prevScrollTop?So:Co,prevScrollTop:C},{direction:Co,prevScrollTop:0}),ue(b=>b.direction)),x),pe(te(r,jn(50),Tn(aC)),x);const y=oe(0);return pe(te(m,Se(b=>!b),Tn(0)),y),pe(te(o,jn(100),Le(m),Se(([b,C])=>!!C),kn(([b,C],[k])=>[C,k],[0,0]),ue(([b,C])=>C-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:p,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},ot(Ft)),Rs="top",Ms="bottom",kp="none";function Ep(e,t,n){return typeof e=="number"?n===So&&t===Rs||n===Co&&t===Ms?e:0:n===So?t===Rs?e.main:e.reverse:t===Ms?e.main:e.reverse}function Ip(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Va=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=ze(),i=oe(0),a=oe(0),l=oe(0),c=Rt(te(xt(ye(r),ye(o),ye(n),ye(s,vo),ye(l),ye(i),ye(t),ye(e),ye(a)),ue(([d,p,m,[f,v],g,x,y,b,C])=>{const k=d-b,S=x+y,T=Math.max(m-k,0);let E=kp;const P=Ip(C,Rs),_=Ip(C,Ms);return f-=b,f+=m+y,v+=m+y,v-=b,f>d+S-P&&(E=So),v<d-T+p+_&&(E=Co),E!==kp?[Math.max(k-m-Ep(g,Rs,E)-P,0),k-T-y+p+Ep(g,Ms,E)+_]:null}),Se(d=>d!=null),st(vo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},ot(Ft),{singleton:!0});function uC(e,t,n){if(_s(t)){const r=wp(e,t);return[{index:pn(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Ka={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Os(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const p=n-i,m=a+p*l+(p-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:Ap(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:Ap(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function Np(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=Wa(t,a),c=Array.from({length:a}).map((d,p)=>({data:s[p+l],index:p+l,offset:0,size:0}));return Os(c,[],a,o,n,r)}function Ap(e,t,n){if(e.length===0)return[];if(!_s(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=As(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const lr=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:p},m,{didMount:f},{recalcInProgress:v}])=>{const g=oe([]),x=oe(0),y=ze();pe(s.topItemsIndexes,g);const b=Rt(te(xt(f,v,ye(l,vo),ye(o),ye(r),ye(c),d,ye(g),ye(t),ye(n),e),Se(([T,E,,P,,,,,,,_])=>{const $=_&&_.length!==P;return T&&!E&&!$}),ue(([,,[T,E],P,_,$,L,F,G,O,K])=>{const q=_,{offsetTree:H,sizeTree:j}=q,I=ht(x);if(P===0)return{...Ka,totalCount:P};if(T===0&&E===0)return I===0?{...Ka,totalCount:P}:Np(I,$,_,G,O,K||[]);if(nt(j))return I>0?null:Os(uC(Wa($,P),q,K),[],P,O,q,G);const Y=[];if(F.length>0){const B=F[0],X=F[F.length-1];let N=0;for(const M of As(j,B,X)){const U=M.value,Z=Math.max(M.start,B),se=Math.min(M.end,X);for(let ae=Z;ae<=se;ae++)Y.push({data:K==null?void 0:K[ae],index:ae,offset:N,size:U}),N+=U}}if(!L)return Os([],Y,P,O,q,G);const J=F.length>0?F[F.length-1]+1:0,D=ZS(H,T,E,J);if(D.length===0)return null;const V=P-1,R=Ns([],B=>{for(const X of D){const N=X.value;let M=N.offset,U=X.start;const Z=N.size;if(N.offset<T){U+=Math.floor((T-N.offset+O)/(Z+O));const ae=U-X.start;M+=ae*Z+ae*O}U<J&&(M+=(J-U)*Z,U=J);const se=Math.min(X.end,V);for(let ae=U;ae<=se&&!(M>=E);ae++)B.push({data:K==null?void 0:K[ae],index:ae,offset:M,size:Z}),M+=Z+O}});return Os(R,Y,P,O,q,G)}),Se(T=>T!==null),st()),Ka);pe(te(e,Se(_a),ue(T=>T==null?void 0:T.length)),o),pe(te(b,ue(T=>T.topListHeight)),p),pe(p,a),pe(te(b,ue(T=>[T.top,T.bottom])),i),pe(te(b,ue(T=>T.items)),y);const C=en(te(b,Se(({items:T})=>T.length>0),Le(o,e),Se(([{items:T},E])=>T[T.length-1].originalIndex===E-1),ue(([,T,E])=>[T-1,E]),st(vo),ue(([T])=>T))),k=en(te(b,jn(200),Se(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),ue(({items:T})=>T[0].index),st())),S=en(te(b,Se(({items:T})=>T.length>0),ue(({items:T})=>{let E=0,P=T.length-1;for(;T[E].type==="group"&&E<P;)E++;for(;T[P].type==="group"&&P>E;)P--;return{endIndex:T[P].index,startIndex:T[E].index}}),st(xp)));return{endReached:C,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:S,startReached:k,topItemsIndexes:g,...m}},ot(En,Sp,Va,yo,bo,To,Un,Ba),{singleton:!0}),Pp=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=ze(),i=Rt(te(xt(n,e,r,t,o),ue(([a,l,c,d,p])=>a+l+c+d+p.offsetBottom+p.bottom)),0);return pe(ye(i),s),{totalListHeight:i,totalListHeightChanged:s}},ot(Ft,lr),{singleton:!0}),dC=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=oe(!1),r=Rt(te(xt(n,e,t),Se(([o])=>o),ue(([,o,s])=>Math.max(0,o-s)),jn(0),st()),0);return{alignToBottom:n,paddingTopAddition:r}},ot(Ft,Pp),{singleton:!0}),jp=Ge(()=>({context:oe(null)})),fC=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,_p=Ge(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=ze();return pe(te(d,Le(t,l,n,s,o,r,a),Le(e),ue(([[p,m,f,v,g,x,y,b],C])=>{const{align:k,behavior:S,calculateViewLocation:T=fC,done:E,...P}=p,_=bp(p,m,v-1),$=wo(_,m.offsetTree,C)+g+x,L=$+pn(m.sizeTree,_)[1],F=b+x,G=b+f-y,O=T({itemBottom:L,itemTop:$,locationParams:{align:k,behavior:S,...P},viewportBottom:G,viewportTop:F});return O?E&&fn(te(i,Se(K=>!K),sr(ht(i)?1:2)),E):E&&E(),O}),Se(p=>p!==null)),c),{scrollIntoView:d}},ot(En,Ft,bo,lr,zn),{singleton:!0});function Rp(e){return e?e==="smooth"?"smooth":"auto":!1}const pC=(e,t)=>typeof e=="function"?Rp(e(t)):t&&Rp(e),hC=Ge(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:p},{context:m},{scrollIntoView:f}])=>{const v=oe(!1),g=ze();let x=null;function y(S){Me(i,{align:"end",behavior:S,index:"LAST"})}Ze(te(xt(te(ye(t),sr(1)),l),Le(ye(v),s,a,p),ue(([[S,T],E,P,_,$])=>{let L=T&&_,F="auto";return L&&(F=pC(E,P||$),L=L&&!!F),{followOutputBehavior:F,shouldFollow:L,totalCount:S}}),Se(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:T})=>{x&&(x(),x=null),ht(n)?requestAnimationFrame(()=>{ht(d)("following output to ",{totalCount:T},Wt.DEBUG),y(S)}):x=fn(e,()=>{ht(d)("following output to ",{totalCount:T},Wt.DEBUG),y(S),x=null})});function b(S){const T=fn(o,E=>{S&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(ht(d)("scrolling to bottom due to increased size",{},Wt.DEBUG),y("auto"))});setTimeout(T,100)}Ze(te(xt(ye(v),t,c),Se(([S,,T])=>S&&T),kn(({value:S},[,T])=>({refreshed:S===T,value:T}),{refreshed:!1,value:0}),Se(({refreshed:S})=>S),Le(v,t)),([,S])=>{ht(a)&&b(S!==!1)}),Ze(g,()=>{b(ht(v)!==!1)}),Ze(xt(ye(v),o),([S,T])=>{S&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=oe(null),k=ze();return pe(Ma(te(ye(r),ue(S=>{var T;return(T=S==null?void 0:S.length)!=null?T:0})),te(ye(t))),k),Ze(te(xt(te(k,sr(1)),l),Le(ye(C),a,p,m),ue(([[S,T],E,P,_,$])=>T&&P&&(E==null?void 0:E({context:$,totalCount:S,scrollingInProgress:_}))),Se(S=>!!S),jn(0)),S=>{x&&(x(),x=null),ht(n)?requestAnimationFrame(()=>{ht(d)("scrolling into view",{}),Me(f,S)}):x=fn(e,()=>{ht(d)("scrolling into view",{}),Me(f,S),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:C}},ot(En,To,bo,yo,Un,zn,Ft,jp,_p)),mC=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(pe(te(a,Le(s),Se(([,l])=>l!==0),Le(o,r,t,n,e),ue(([[,l],c,d,p,m,f=[]])=>Np(l,c,d,p,m,f))),i),{}),ot(En,yo,lr,Un),{singleton:!0}),gC=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=oe(0);return Ze(te(e,Le(r),Se(([,o])=>o!==0),ue(([,o])=>({top:o}))),o=>{fn(te(n,sr(1),Se(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Me(t,o)})})}),{initialScrollTop:r}},ot(Un,Ft,lr),{singleton:!0}),Mp=Ge(([{scrollVelocity:e}])=>{const t=oe(!1),n=ze(),r=oe(!1);return pe(te(e,Le(r,t,n),Se(([o,s])=>!!s),ue(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),st()),t),Ze(te(xt(t,e,n),Le(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ot(To),{singleton:!0}),qa=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=ze(),r=ze(),o=ze(),s=oe(!1),i=oe(void 0);return pe(te(xt(n,r),ue(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),pe(te(t,Le(r),ue(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ot(Ft)),xC=Ge(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=ze(),d=oe(void 0),p=oe(null),m=oe(null);return pe(a,p),pe(l,m),Ze(te(c,Le(t,r,i,p,m,n)),([f,v,g,x,y,b,C])=>{const k=eC(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=C,f({ranges:k,scrollTop:g})}),pe(te(d,Se(_a),ue(vC)),o),pe(te(s,Le(d),Se(([,f])=>f!==void 0),st(),ue(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},ot(En,Ft,yo,Un,qa));function vC(e){return{align:"start",index:0,offset:e.scrollTop}}const wC=Ge(([{topItemsIndexes:e}])=>{const t=oe(0);return pe(te(t,Se(n=>n>=0),ue(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ot(lr));function Op(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const bC=Op(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),yC=Ge(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:p,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=en(te(l,Le(i),kn(([,y,b,C],[{bottom:k,items:S,offsetBottom:T,totalCount:E},P])=>{const _=k+T;let $=0;return b===E&&y.length>0&&S.length>0&&(S[0].originalIndex===0&&y[0].originalIndex===0||($=_-C,$!==0&&($+=P))),[$,S,E,_]},[0,[],0,0]),Se(([y])=>y!==0),Le(r,a,n,o,f,v),Se(([,y,b,C,,,k])=>!k&&!C&&y!==0&&b===So),ue(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Wt.DEBUG),y))));function x(y){y>0?(Me(t,{behavior:"auto",top:-y}),Me(e,0)):(Me(e,0),Me(t,{behavior:"auto",top:-y}))}return Ze(te(g,Le(e,s)),([y,b,C])=>{C&&bC()?Me(e,b-y):x(-y)}),Ze(te(xt(Rt(s,!1),e,v),Se(([y,b,C])=>!y&&!C&&b!==0),ue(([y,b])=>b),jn(1)),x),pe(te(p,ue(y=>({top:-y}))),t),Ze(te(c,Le(m,d),ue(([y,{groupIndices:b,lastSize:C,sizeTree:k},S])=>{function T(E){return E*(C+S)}if(b.length===0)return T(y);{let E=0;const P=xo(k,0);let _=0,$=0;for(;_<y;){_++,E+=P;let L=b.length===$+1?1/0:b[$+1]-b[$]-1;_+L>y&&(E-=P,L=y-_+1),_+=L,E+=T(L),$++}return E}})),y=>{Me(e,y),requestAnimationFrame(()=>{Me(t,{top:y}),requestAnimationFrame(()=>{Me(e,0),Me(v,!1)})})}),{deviation:e}},ot(Ft,To,lr,En,zn,Ba)),SC=Ge(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),ot(Va,mC,Un,Mp,Pp,gC,dC,qa,_p,zn,jp)),Dp=Ge(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:b,topItemsIndexes:C,...k},{scrollToIndex:S},T,{topItemCount:E},{groupCounts:P},_])=>(pe(k.rangeChanged,_.scrollSeekRangeChanged),pe(te(_.windowViewportRect,ue($=>$.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:P,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:C,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:S,statefulTotalCount:c,trackItemSizes:p,...k,..._,...g,sizes:l,...x}),ot(En,yo,Ft,xC,hC,lr,bo,yC,wC,Sp,SC));function CC(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const Ds=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Lp(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=w.createContext({});function l(x,y){x.propsReady&&Me(x.propsReady,!1);for(const b of r){const C=x[t.required[b]];Me(C,y[b])}for(const b of o)if(b in y){const C=x[t.optional[b]];Me(C,y[b])}x.propsReady&&Me(x.propsReady,!0)}function c(x){return s.reduce((y,b)=>(y[b]=C=>{const k=x[t.methods[b]];Me(k,C)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=FS(x[t.events[b]]),y),{})}const p=w.forwardRef((x,y)=>{const{children:b,...C}=x,[k]=w.useState(()=>Ns(zS(e),E=>{l(E,C)})),[S]=w.useState(ip(d,k));Ds(()=>{for(const E of i)E in C&&Ze(S[E],C[E]);return()=>{Object.values(S).map(Ra)}},[C,S,k]),Ds(()=>{l(k,C)}),w.useImperativeHandle(y,op(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...CC([...r,...o,...i],C),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{Me(y[x],b)},[y,x])},f=x=>{const y=w.useContext(a)[x],b=w.useCallback(C=>Ze(y,C),[y]);return w.useSyncExternalStore(b,()=>ht(y),()=>ht(y))},v=x=>{const y=w.useContext(a)[x],[b,C]=w.useState(ip(ht,y));return Ds(()=>Ze(y,k=>{k!==b&&C(op(k))}),[y,b]),b},g=w.version.startsWith("18")?f:v;return{Component:p,useEmitter:(x,y)=>{const b=w.useContext(a)[x];Ds(()=>Ze(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const $p=w.createContext(void 0),Fp=w.createContext(void 0),Bp=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Ga(e){return"self"in e}function TC(e){return"body"in e}function zp(e,t,n,r=Dr,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),c=w.useCallback(m=>{let f,v,g;const x=m.target;if(TC(x)||Ga(x)){const b=Ga(x)?x:x.defaultView;g=s?b.scrollX:b.scrollY,f=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else g=s?x.scrollLeft:x.scrollTop,f=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Oo.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.useEffect(()=>{const m=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",c,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(m){const f=i.current;if(!f||(s?"offsetWidth"in f&&f.offsetWidth===0:"offsetHeight"in f&&f.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;Ga(f)?(x=Math.max(Hn(f.document.documentElement,s?"width":"height"),s?f.document.documentElement.scrollWidth:f.document.documentElement.scrollHeight),g=s?f.innerWidth:f.innerHeight,y=s?window.scrollX:window.scrollY):(x=f[s?"scrollWidth":"scrollHeight"],g=Hn(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const b=x-g;if(m.top=Math.ceil(Math.max(Math.min(b,m.top),0)),Tp(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),f.scrollTo(m)}function p(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:p,scrollerRef:i,scrollToCallback:d}}const Ya="-webkit-sticky",Hp="sticky",Xa=Op(()=>{if(typeof document>"u")return Hp;const e=document.createElement("div");return e.style.position=Ya,e.style.position===Ya?Ya:Hp});function Ja(e){return e}const kC=Ge(()=>{const e=oe(a=>`Item ${a}`),t=oe(a=>`Group ${a}`),n=oe({}),r=oe(Ja),o=oe("div"),s=oe(Dr),i=(a,l=null)=>Rt(te(n,ue(c=>c[a]),st()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),EC=Ge(([e,t])=>({...e,...t}),ot(Dp,kC)),IC=({height:e})=>u.jsx("div",{style:{height:e}}),NC={overflowAnchor:"none",position:Xa(),zIndex:1},Up={overflowAnchor:"none"},AC={...Up,display:"inline-block",height:"100%"},Wp=w.memo(function({showTopList:e=!1}){const t=Ne("listState"),n=rn("sizeRanges"),r=Ne("useWindowScroll"),o=Ne("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=Ne("itemContent"),c=Ne("context"),d=Ne("groupContent"),p=Ne("trackItemSizes"),m=Ne("itemSize"),f=Ne("log"),v=rn("gap"),g=Ne("horizontalDirection"),{callbackRef:x}=WS(n,m,p,e?Dr:a,f,v,o,g,Ne("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);Za("deviation",O=>{y!==O&&b(O)});const C=Ne("EmptyPlaceholder"),k=Ne("ScrollSeekPlaceholder")||IC,S=Ne("ListComponent"),T=Ne("ItemComponent"),E=Ne("GroupComponent"),P=Ne("computeItemKey"),_=Ne("isSeeking"),$=Ne("groupIndices").length>0,L=Ne("alignToBottom"),F=Ne("initialItemFinalLocationReached"),G=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:L?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:L?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...F?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?u.jsx(C,{...Mt(C,c)}):u.jsx(S,{...Mt(S,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:G,children:(e?t.topItems:t.items).map(O=>{const K=O.originalIndex,q=P(K+t.firstItemIndex,O.data,c);return _?w.createElement(k,{...Mt(k,c),height:O.size,index:O.index,key:q,type:O.type||"item",...O.type==="group"?{}:{groupIndex:O.groupIndex}}):O.type==="group"?w.createElement(E,{...Mt(E,c),"data-index":K,"data-item-index":O.index,"data-known-size":O.size,key:q,style:NC},d(O.index,c)):w.createElement(T,{...Mt(T,c),...RC(T,O.data),"data-index":K,"data-item-group-index":O.groupIndex,"data-item-index":O.index,"data-known-size":O.size,key:q,style:g?AC:Up},$?l(O.index,O.groupIndex,O.data,c):l(O.index,O.data,c))})})}),PC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},jC={outline:"none",overflowX:"auto",position:"relative"},Ls=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),_C={position:Xa(),top:0,width:"100%",zIndex:1};function Mt(e,t){if(typeof e!="string")return{context:t}}function RC(e,t){return{item:typeof e=="string"?void 0:t}}const MC=w.memo(function(){const e=Ne("HeaderComponent"),t=rn("headerHeight"),n=Ne("HeaderFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),OC=w.memo(function(){const e=Ne("FooterComponent"),t=rn("footerHeight"),n=Ne("HeaderFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null});function Vp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),p=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=zp(a,c,l,d,void 0,p);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...p?jC:PC,...o},tabIndex:0,...i,...Mt(l,s),children:r})})}function Kp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),p=t("deviation"),m=t("customScrollParent"),f=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=zp(a,c,l,v,m);return Bp(()=>{var b;return x.current=m||((b=f.current)==null?void 0:b.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+p}:{}},...i,...Mt(l,s),children:r})})}const DC=({children:e})=>{const t=w.useContext($p),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=Ne("alignToBottom"),s=Ne("horizontalDirection"),i=w.useMemo(()=>sp(n,l=>Hn(l,s?"width":"height")),[n,s]),a=ir(i,!0,Ne("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Ls(o),children:e})},LC=({children:e})=>{const t=w.useContext($p),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=Ne("customScrollParent"),s=up(n,o,Ne("skipAnimationFrameInResizeObserver")),i=Ne("alignToBottom");return w.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:Ls(i),children:e})},$C=({children:e})=>{const t=Ne("TopItemListComponent")||"div",n=Ne("headerHeight"),r={..._C,marginTop:`${n}px`},o=Ne("context");return u.jsx(t,{style:r,...Mt(t,o),children:e})},FC=w.memo(function(e){const t=Ne("useWindowScroll"),n=Ne("topItemsIndexes").length>0,r=Ne("customScrollParent"),o=Ne("context");return u.jsxs(r||t?HC:zC,{...e,context:o,children:[n&&u.jsx($C,{children:u.jsx(Wp,{showTopList:!0})}),u.jsxs(r||t?LC:DC,{children:[u.jsx(MC,{}),u.jsx(Wp,{}),u.jsx(OC,{})]})]})}),{Component:BC,useEmitter:Za,useEmitterValue:Ne,usePublisher:rn}=Lp(EC,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},FC),zC=Vp({useEmitter:Za,useEmitterValue:Ne,usePublisher:rn}),HC=Kp({useEmitter:Za,useEmitterValue:Ne,usePublisher:rn}),UC=BC;ot(Dp,Ge(()=>{const e=oe(c=>u.jsxs("td",{children:["Item $",c]})),t=oe(null),n=oe(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=oe(null),o=oe(null),s=oe({}),i=oe(Ja),a=oe(Dr),l=(c,d=null)=>Rt(te(s,ue(p=>p[c]),st()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Xa();const qp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},WC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Gp,floor:$s,max:ko,min:Qa,round:Yp}=Math;function Xp(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function VC(e){return{...WC,items:e}}function Fs(e,t){return e&&e.width===t.width&&e.height===t.height}function KC(e,t){return e&&e.column===t.column&&e.row===t.row}const qC=Ge(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:p},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:k},S])=>{const T=oe(0),E=oe(0),P=oe(qp),_=oe({height:0,width:0}),$=oe({height:0,width:0}),L=ze(),F=ze(),G=oe(0),O=oe(null),K=oe({column:0,row:0}),q=ze(),H=ze(),j=oe(!1),I=oe(0),Y=oe(!0),J=oe(!1),D=oe(!1);Ze(te(v,Le(I),Se(([M,U])=>!!U)),()=>{Me(Y,!1)}),Ze(te(xt(v,Y,$,_,I,J),Se(([M,U,Z,se,,ae])=>M&&!U&&Z.height!==0&&se.height!==0&&!ae)),([,,,,M])=>{Me(J,!0),Ua(1,()=>{Me(L,M)}),fn(te(c),()=>{Me(t,[0,0]),Me(Y,!0)})}),pe(te(H,Se(M=>M!=null&&M.scrollTop>0),Tn(0)),E),Ze(te(v,Le(H),Se(([,M])=>M!=null)),([,M])=>{M&&(Me(_,M.viewport),Me($,M.item),Me(K,M.gap),M.scrollTop>0&&(Me(j,!0),fn(te(c,sr(1)),U=>{Me(j,!1)}),Me(l,{top:M.scrollTop})))}),pe(te(_,ue(({height:M})=>M)),p),pe(te(xt(ye(_,Fs),ye($,Fs),ye(K,(M,U)=>M&&M.column===U.column&&M.row===U.row),ye(c)),ue(([M,U,Z,se])=>({gap:Z,item:U,scrollTop:se,viewport:M}))),q),pe(te(xt(ye(T),r,ye(K,KC),ye($,Fs),ye(_,Fs),ye(O),ye(E),ye(j),ye(Y),ye(I)),Se(([,,,,,,,M])=>!M),ue(([M,[U,Z],se,ae,Ce,we,je,,We,Fe])=>{const{column:Ye,row:He}=se,{height:vt,width:wt}=ae,{width:dt}=Ce;if(je===0&&(M===0||dt===0))return qp;if(wt===0){const bt=Wa(Fe,M),mt=bt+Math.max(je-1,0);return VC(Xp(bt,mt,we))}const Ve=Jp(dt,wt,Ye);let Ae,Ke;We?U===0&&Z===0&&je>0?(Ae=0,Ke=je-1):(Ae=Ve*$s((U+He)/(vt+He)),Ke=Ve*Gp((Z+He)/(vt+He))-1,Ke=Qa(M-1,ko(Ke,Ve-1)),Ae=Qa(Ke,ko(0,Ae))):(Ae=0,Ke=-1);const _e=Xp(Ae,Ke,we),{bottom:Be,top:Qe}=Zp(Ce,se,ae,_e),Nt=Gp(M/Ve),et=Nt*vt+(Nt-1)*He-Be;return{bottom:Be,itemHeight:vt,items:_e,itemWidth:wt,offsetBottom:et,offsetTop:Qe,top:Qe}})),P),pe(te(O,Se(M=>M!==null),ue(M=>M.length)),T),pe(te(xt(_,$,P,K),Se(([M,U,{items:Z}])=>Z.length>0&&U.height!==0&&M.height!==0),ue(([M,U,{items:Z},se])=>{const{bottom:ae,top:Ce}=Zp(M,se,U,Z);return[Ce,ae]}),st(vo)),t);const V=oe(!1);pe(te(c,Le(V),ue(([M,U])=>U||M!==0)),V);const R=en(te(xt(P,T),Se(([{items:M}])=>M.length>0),Le(V),Se(([[M,U],Z])=>{const se=M.items[M.items.length-1].index===U-1;return(Z||M.bottom>0&&M.itemHeight>0&&M.offsetBottom===0&&M.items.length===U)&&se}),ue(([[,M]])=>M-1),st())),B=en(te(ye(P),Se(({items:M})=>M.length>0&&M[0].index===0),Tn(0),st())),X=en(te(ye(P),Le(j),Se(([{items:M},U])=>M.length>0&&!U),ue(([{items:M}])=>({endIndex:M[M.length-1].index,startIndex:M[0].index})),st(xp),jn(0)));pe(X,f.scrollSeekRangeChanged),pe(te(L,Le(_,$,T,K),ue(([M,U,Z,se,ae])=>{const Ce=Cp(M),{align:we,behavior:je,offset:We}=Ce;let Fe=Ce.index;Fe==="LAST"&&(Fe=se-1),Fe=ko(0,Fe,Qa(se-1,Fe));let Ye=el(U,ae,Z,Fe);return we==="end"?Ye=Yp(Ye-U.height+Z.height):we==="center"&&(Ye=Yp(Ye-U.height/2+Z.height/2)),We&&(Ye+=We),{behavior:je,top:Ye}})),l);const N=Rt(te(P,ue(M=>M.offsetBottom+M.bottom)),0);return pe(te(k,ue(M=>({height:M.visibleHeight,width:M.visibleWidth}))),_),{customScrollParent:x,data:O,deviation:G,footerHeight:o,gap:K,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:$,overscan:n,restoreStateFrom:H,scrollBy:i,scrollContainerState:a,scrollHeight:F,scrollTo:l,scrollToIndex:L,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:_,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:k,...f,gridState:P,horizontalDirection:D,initialTopMostItemIndex:I,totalListHeight:N,...m,endReached:R,propsReady:g,rangeChanged:X,startReached:B,stateChanged:q,stateRestoreInProgress:j,...S}},ot(Va,Ft,To,Mp,Un,qa,zn));function Jp(e,t,n){return ko(1,$s((e+n)/($s(t)+n)))}function Zp(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=el(e,t,n,r[0].index);return{bottom:el(e,t,n,r[r.length-1].index)+o,top:s}}function el(e,t,n,r){const o=Jp(e.width,n.width,t.column),s=$s(r/o),i=s*n.height+ko(0,s-1)*t.row;return i>0?i+t.row:i}const GC=Ge(()=>{const e=oe(p=>`Item ${p}`),t=oe({}),n=oe(null),r=oe("virtuoso-grid-item"),o=oe("virtuoso-grid-list"),s=oe(Ja),i=oe("div"),a=oe(Dr),l=(p,m=null)=>Rt(te(t,ue(f=>f[p]),st()),m),c=oe(!1),d=oe(!1);return pe(ye(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),YC=Ge(([e,t])=>({...e,...t}),ot(qC,GC)),XC=w.memo(function(){const e=it("gridState"),t=it("listClassName"),n=it("itemClassName"),r=it("itemContent"),o=it("computeItemKey"),s=it("isSeeking"),i=on("scrollHeight"),a=it("ItemComponent"),l=it("ListComponent"),c=it("ScrollSeekPlaceholder"),d=it("context"),p=on("itemDimensions"),m=on("gap"),f=it("log"),v=it("stateRestoreInProgress"),g=on("reportReadyState"),x=ir(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const C=y.firstChild;if(C){const{height:k,width:S}=C.getBoundingClientRect();p({height:k,width:S})}m({column:eh("column-gap",getComputedStyle(y).columnGap,f),row:eh("row-gap",getComputedStyle(y).rowGap,f)})},[i,p,m,f]),!0,!1);return Bp(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Mt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const b=o(y.index,y.data,d);return s?u.jsx(c,{...Mt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Mt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),JC=w.memo(function(){const e=it("HeaderComponent"),t=on("headerHeight"),n=it("headerFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=it("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),ZC=w.memo(function(){const e=it("FooterComponent"),t=on("footerHeight"),n=it("headerFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=it("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),QC=({children:e})=>{const t=w.useContext(Fp),n=on("itemDimensions"),r=on("viewportDimensions"),o=ir(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:Ls(!1),children:e})},eT=({children:e})=>{const t=w.useContext(Fp),n=on("windowViewportRect"),r=on("itemDimensions"),o=it("customScrollParent"),s=up(n,o,!1);return w.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:Ls(!1),children:e})},tT=w.memo(function({...e}){const t=it("useWindowScroll"),n=it("customScrollParent"),r=n||t?rT:nT,o=n||t?eT:QC,s=it("context");return u.jsx(r,{...e,...Mt(r,s),children:u.jsxs(o,{children:[u.jsx(JC,{}),u.jsx(XC,{}),u.jsx(ZC,{})]})})}),{useEmitter:Qp,useEmitterValue:it,usePublisher:on}=Lp(YC,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},tT),nT=Vp({useEmitter:Qp,useEmitterValue:it,usePublisher:on}),rT=Kp({useEmitter:Qp,useEmitterValue:it,usePublisher:on});function eh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Wt.WARN),t==="normal"?0:parseInt(t??"0",10)}var Bs="Dialog",[th,DN]=cn(Bs),[oT,hn]=th(Bs),nh=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),l=h.useRef(null),[c,d]=On({prop:r,defaultProp:o??!1,onChange:s,caller:Bs});return u.jsx(oT,{scope:t,triggerRef:a,contentRef:l,contentId:_t(),titleId:_t(),descriptionId:_t(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(p=>!p),[d]),modal:i,children:n})};nh.displayName=Bs;var rh="DialogTrigger",oh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(rh,n),s=De(t,o.triggerRef);return u.jsx(fe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":rl(o.open),...r,ref:s,onClick:ie(e.onClick,o.onOpenToggle)})});oh.displayName=rh;var tl="DialogPortal",[sT,sh]=th(tl,{forceMount:void 0}),ih=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=hn(tl,t);return u.jsx(sT,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(Ut,{present:n||s.open,children:u.jsx(ao,{asChild:!0,container:o,children:i})}))})};ih.displayName=tl;var zs="DialogOverlay",ah=h.forwardRef((e,t)=>{const n=sh(zs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(zs,e.__scopeDialog);return s.modal?u.jsx(Ut,{present:r||s.open,children:u.jsx(aT,{...o,ref:t})}):null});ah.displayName=zs;var iT=Yt.createSlot("DialogOverlay.RemoveScroll"),aT=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(zs,n);return u.jsx(ws,{as:iT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(fe.div,{"data-state":rl(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),cr="DialogContent",lh=h.forwardRef((e,t)=>{const n=sh(cr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(cr,e.__scopeDialog);return u.jsx(Ut,{present:r||s.open,children:s.modal?u.jsx(lT,{...o,ref:t}):u.jsx(cT,{...o,ref:t})})});lh.displayName=cr;var lT=h.forwardRef((e,t)=>{const n=hn(cr,e.__scopeDialog),r=h.useRef(null),o=De(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return va(s)},[]),u.jsx(ch,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ie(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ie(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault())})}),cT=h.forwardRef((e,t)=>{const n=hn(cr,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(ch,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),ch=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=hn(cr,n),l=h.useRef(null),c=De(t,l);return Yi(),u.jsxs(u.Fragment,{children:[u.jsx(es,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(kr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":rl(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(uT,{titleId:a.titleId}),u.jsx(fT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),nl="DialogTitle",uh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(nl,n);return u.jsx(fe.h2,{id:o.titleId,...r,ref:t})});uh.displayName=nl;var dh="DialogDescription",fh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(dh,n);return u.jsx(fe.p,{id:o.descriptionId,...r,ref:t})});fh.displayName=dh;var ph="DialogClose",hh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(ph,n);return u.jsx(fe.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,()=>o.onOpenChange(!1))})});hh.displayName=ph;function rl(e){return e?"open":"closed"}var mh="DialogTitleWarning",[LN,gh]=Ew(mh,{contentName:cr,titleName:nl,docsSlug:"dialog"}),uT=({titleId:e})=>{const t=gh(mh),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
80
80
|
|
|
81
81
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
82
82
|
|
|
83
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},uT="DialogDescriptionWarning",dT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${gh(uT).contentName}}.`;return h.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},ol=nh,fT=oh,sl=ih,Eo=ah,Io=lh,ur=uh,Hs=fh,xh=hh;const il=ol,pT=sl,vh=h.forwardRef(({className:e,...t},n)=>u.jsx(Eo,{ref:n,className:re("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}));vh.displayName=Eo.displayName;const Us=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,l=>{if(s||!h.isValidElement(l))return;const c=l.type;if(c===ur||(c==null?void 0:c.displayName)===ur.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(pT,{children:[u.jsx(vh,{}),u.jsxs(Io,{ref:r,className:re("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(ur,{className:"sr-only",children:"Dialog"}),t,u.jsxs(xh,{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-accent data-[state=open]:text-muted-foreground",children:[u.jsx(ce.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Us.displayName=Io.displayName;const Ws=({className:e,...t})=>u.jsx("div",{className:re("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ws.displayName="DialogHeader";const Vs=h.forwardRef(({className:e,...t},n)=>u.jsx(ur,{ref:n,className:re("text-lg font-semibold leading-none tracking-tight",e),...t}));Vs.displayName=ur.displayName;const hT=h.forwardRef(({className:e,...t},n)=>u.jsx(Hs,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));hT.displayName=Hs.displayName;const mT=1,gT=1e6;let al=0;function xT(){return al=(al+1)%Number.MAX_SAFE_INTEGER,al.toString()}const ll=new Map,wh=e=>{if(ll.has(e))return;const t=setTimeout(()=>{ll.delete(e),No({type:"REMOVE_TOAST",toastId:e})},gT);ll.set(e,t)},vT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,mT)};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?wh(n):e.toasts.forEach(r=>{wh(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)}}},Ks=[];let qs={toasts:[]};function No(e){qs=vT(qs,e),Ks.forEach(t=>{t(qs)})}function wT({...e}){const t=xT(),n=o=>No({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>No({type:"DISMISS_TOAST",toastId:t});return No({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function cl(){const[e,t]=h.useState(qs);return h.useEffect(()=>(Ks.push(t),()=>{const n=Ks.indexOf(t);n>-1&&Ks.splice(n,1)}),[e]),{...e,toast:wT,dismiss:n=>No({type:"DISMISS_TOAST",toastId:n})}}function bh({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,l]=w.useState(null),[c,d]=w.useState(null),{toast:p}=cl(),m=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Di(n);l(y)}catch(y){console.error("Failed to load file:",y),d(y instanceof Error?y.message:"Failed to load file")}finally{i(!1)}}},[n]);w.useEffect(()=>{e&&n&&m()},[e,n,m]);const f=async()=>{if(n)try{await su(n),p({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),p({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await Di(n),b=new Blob([y],{type:o}),C=URL.createObjectURL(b);window.open(C,"_blank"),URL.revokeObjectURL(C)}catch(y){console.error("Failed to open file externally:",y),p({title:"Failed to open file",description:String(y),variant:"destructive"})}},g=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(ce.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx(Je,{onClick:m,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(ce.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),x=()=>o.startsWith("image/")?u.jsx(ce.Image,{className:"h-5 w-5"}):u.jsx(ce.FileText,{className:"h-5 w-5"});return u.jsx(il,{open:e,onOpenChange:t,children:u.jsxs(Us,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(Ws,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[x(),u.jsxs("div",{children:[u.jsx(Vs,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Je,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(ce.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Je,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(ce.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function yh(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let dr=yh();function bT(e){dr=e}const Sh=/[&<>"']/,yT=new RegExp(Sh.source,"g"),Ch=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,ST=new RegExp(Ch.source,"g"),CT={"&":"&","<":"<",">":">",'"':""","'":"'"},Th=e=>CT[e];function Ot(e,t){if(t){if(Sh.test(e))return e.replace(yT,Th)}else if(Ch.test(e))return e.replace(ST,Th);return e}const TT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function kh(e){return e.replace(TT,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const kT=/(^|[^\[])\^/g;function rt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(kT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const ET=/[^\w:]/g,IT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Eh(e,t,n){if(e){let r;try{r=decodeURIComponent(kh(n)).replace(ET,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!IT.test(n)&&(n=jT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Gs={},NT=/^[^:]+:\/*[^/]*$/,AT=/^([^:]+:)[\s\S]*$/,PT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function jT(e,t){Gs[" "+e]||(NT.test(e)?Gs[" "+e]=e+"/":Gs[" "+e]=Xs(e,"/",!0)),e=Gs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(AT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(PT,"$1")+t:e+t}const Ys={exec:function(){}};function Ih(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,c=i;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Xs(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function _T(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function RT(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function Nh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Ah(e,t,n,r){const o=t.href,s=t.title?Ot(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:Ot(i)}}function MT(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
83
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},dT="DialogDescriptionWarning",fT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${gh(dT).contentName}}.`;return h.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},ol=nh,pT=oh,sl=ih,Eo=ah,Io=lh,ur=uh,Hs=fh,xh=hh;const il=ol,hT=sl,vh=h.forwardRef(({className:e,...t},n)=>u.jsx(Eo,{ref:n,className:re("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}));vh.displayName=Eo.displayName;const Us=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,l=>{if(s||!h.isValidElement(l))return;const c=l.type;if(c===ur||(c==null?void 0:c.displayName)===ur.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(hT,{children:[u.jsx(vh,{}),u.jsxs(Io,{ref:r,className:re("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(ur,{className:"sr-only",children:"Dialog"}),t,u.jsxs(xh,{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-accent data-[state=open]:text-muted-foreground",children:[u.jsx(ce.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Us.displayName=Io.displayName;const Ws=({className:e,...t})=>u.jsx("div",{className:re("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ws.displayName="DialogHeader";const Vs=h.forwardRef(({className:e,...t},n)=>u.jsx(ur,{ref:n,className:re("text-lg font-semibold leading-none tracking-tight",e),...t}));Vs.displayName=ur.displayName;const mT=h.forwardRef(({className:e,...t},n)=>u.jsx(Hs,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));mT.displayName=Hs.displayName;const gT=1,xT=1e6;let al=0;function vT(){return al=(al+1)%Number.MAX_SAFE_INTEGER,al.toString()}const ll=new Map,wh=e=>{if(ll.has(e))return;const t=setTimeout(()=>{ll.delete(e),No({type:"REMOVE_TOAST",toastId:e})},xT);ll.set(e,t)},wT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,gT)};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?wh(n):e.toasts.forEach(r=>{wh(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)}}},Ks=[];let qs={toasts:[]};function No(e){qs=wT(qs,e),Ks.forEach(t=>{t(qs)})}function bT({...e}){const t=vT(),n=o=>No({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>No({type:"DISMISS_TOAST",toastId:t});return No({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function cl(){const[e,t]=h.useState(qs);return h.useEffect(()=>(Ks.push(t),()=>{const n=Ks.indexOf(t);n>-1&&Ks.splice(n,1)}),[e]),{...e,toast:bT,dismiss:n=>No({type:"DISMISS_TOAST",toastId:n})}}function bh({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,l]=w.useState(null),[c,d]=w.useState(null),{toast:p}=cl(),m=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Di(n);l(y)}catch(y){console.error("Failed to load file:",y),d(y instanceof Error?y.message:"Failed to load file")}finally{i(!1)}}},[n]);w.useEffect(()=>{e&&n&&m()},[e,n,m]);const f=async()=>{if(n)try{await su(n),p({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),p({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await Di(n),b=new Blob([y],{type:o}),C=URL.createObjectURL(b);window.open(C,"_blank"),URL.revokeObjectURL(C)}catch(y){console.error("Failed to open file externally:",y),p({title:"Failed to open file",description:String(y),variant:"destructive"})}},g=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(ce.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx(Je,{onClick:m,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(ce.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),x=()=>o.startsWith("image/")?u.jsx(ce.Image,{className:"h-5 w-5"}):u.jsx(ce.FileText,{className:"h-5 w-5"});return u.jsx(il,{open:e,onOpenChange:t,children:u.jsxs(Us,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(Ws,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[x(),u.jsxs("div",{children:[u.jsx(Vs,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Je,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(ce.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Je,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(ce.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function yh(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let dr=yh();function yT(e){dr=e}const Sh=/[&<>"']/,ST=new RegExp(Sh.source,"g"),Ch=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,CT=new RegExp(Ch.source,"g"),TT={"&":"&","<":"<",">":">",'"':""","'":"'"},Th=e=>TT[e];function Ot(e,t){if(t){if(Sh.test(e))return e.replace(ST,Th)}else if(Ch.test(e))return e.replace(CT,Th);return e}const kT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function kh(e){return e.replace(kT,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const ET=/(^|[^\[])\^/g;function rt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(ET,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const IT=/[^\w:]/g,NT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Eh(e,t,n){if(e){let r;try{r=decodeURIComponent(kh(n)).replace(IT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!NT.test(n)&&(n=_T(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Gs={},AT=/^[^:]+:\/*[^/]*$/,PT=/^([^:]+:)[\s\S]*$/,jT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function _T(e,t){Gs[" "+e]||(AT.test(e)?Gs[" "+e]=e+"/":Gs[" "+e]=Xs(e,"/",!0)),e=Gs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(PT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(jT,"$1")+t:e+t}const Ys={exec:function(){}};function Ih(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,c=i;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Xs(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function RT(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function MT(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function Nh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Ah(e,t,n,r){const o=t.href,s=t.title?Ot(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:Ot(i)}}function OT(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
84
84
|
`).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
|
|
85
85
|
`)}class ul{constructor(t){this.options=t||dr}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Xs(r,`
|
|
86
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=
|
|
86
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=OT(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=Xs(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,c,d,p,m,f,v,g=n[1].trim();const x=g.length>1,y={type:"list",raw:"",ordered:x,start:x?+g.slice(0,-1):"",loose:!1,items:[]};g=x?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=x?g:"[*+-]");const b=new RegExp(`^( {0,3}${g})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(v=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
|
|
87
87
|
`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),p=t.split(`
|
|
88
88
|
`,1)[0],this.options.pedantic?(i=2,f=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,f=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(p)&&(r+=p+`
|
|
89
89
|
`,t=t.substring(p.length+1),v=!0),!v){const k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),S=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(m=t.split(`
|
|
@@ -92,8 +92,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
92
92
|
`+p}!l&&!p.trim()&&(l=!0),r+=m+`
|
|
93
93
|
`,t=t.substring(m.length+1),d=p.slice(i)}}y.loose||(c?y.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(f),o&&(s=o[0]!=="[ ] ",f=f.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:f}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=f.trimRight(),y.raw=y.raw.trimRight();const C=y.items.length;for(a=0;a<C;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const k=y.items[a].tokens.filter(T=>T.type==="space"),S=k.length>0&&k.some(T=>/\n.*\n/.test(T.raw));y.loose=S}if(y.loose)for(a=0;a<C;a++)y.items[a].loose=!0;return y}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):Ot(n[0]);r.type="paragraph",r.text=o,r.tokens=this.lexer.inline(o)}return r}}def(t){const n=this.rules.block.def.exec(t);if(n){const r=n[1].toLowerCase().replace(/\s+/g," "),o=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:o,title:s}}}table(t){const n=this.rules.block.table.exec(t);if(n){const r={type:"table",header:Ih(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
|
|
94
94
|
`):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,l;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=Ih(r.rows[s],r.header.length).map(c=>({text:c}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
|
|
95
|
-
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:Ot(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):Ot(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=Xs(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=
|
|
96
|
-
]`).replace("lheading",ve.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const de={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ys,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Ys,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};de._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",de.punctuation=rt(de.punctuation).replace(/punctuation/g,de._punctuation).getRegex(),de.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,de.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,de._comment=rt(ve._comment).replace("(?:-->|$)","-->").getRegex(),de.emStrong.lDelim=rt(de.emStrong.lDelim).replace(/punct/g,de._punctuation).getRegex(),de.emStrong.rDelimAst=rt(de.emStrong.rDelimAst,"g").replace(/punct/g,de._punctuation).getRegex(),de.emStrong.rDelimUnd=rt(de.emStrong.rDelimUnd,"g").replace(/punct/g,de._punctuation).getRegex(),de._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,de._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,de._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,de.autolink=rt(de.autolink).replace("scheme",de._scheme).replace("email",de._email).getRegex(),de._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,de.tag=rt(de.tag).replace("comment",de._comment).replace("attribute",de._attribute).getRegex(),de._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,de._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,de._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,de.link=rt(de.link).replace("label",de._label).replace("href",de._href).replace("title",de._title).getRegex(),de.reflink=rt(de.reflink).replace("label",de._label).replace("ref",ve._label).getRegex(),de.nolink=rt(de.nolink).replace("ref",ve._label).getRegex(),de.reflinkSearch=rt(de.reflinkSearch,"g").replace("reflink",de.reflink).replace("nolink",de.nolink).getRegex(),de.normal={...de},de.pedantic={...de.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:rt(/^!?\[(label)\]\((.*?)\)/).replace("label",de._label).getRegex(),reflink:rt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",de._label).getRegex()},de.gfm={...de.normal,escape:rt(de.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},de.gfm.url=rt(de.gfm.url,"i").replace("email",de.gfm._extended_email).getRegex(),de.breaks={...de.gfm,br:rt(de.br).replace("{2,}","*").getRegex(),text:rt(de.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function
|
|
95
|
+
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:Ot(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):Ot(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=Xs(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=RT(n[2],"()");if(i>-1){const l=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,l).trim(),n[3]=""}}let o=n[2],s="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);i&&(o=i[1],s=i[3])}else s=n[3]?n[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(r)?o=o.slice(1):o=o.slice(1,-1)),Ah(n,{href:o&&o.replace(this.rules.inline._escapes,"$1"),title:s&&s.replace(this.rules.inline._escapes,"$1")},n[0],this.lexer)}}reflink(t,n){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){let o=(r[2]||r[1]).replace(/\s+/g," ");if(o=n[o.toLowerCase()],!o){const s=r[0].charAt(0);return{type:"text",raw:s,text:s}}return Ah(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,c=i,d=0;const p=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(p.lastIndex=0,n=n.slice(-1*t.length+i);(o=p.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){c+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);const m=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=m.slice(1,-1);return{type:"em",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}const f=m.slice(2,-2);return{type:"strong",raw:m,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=Ot(r,!0),{type:"codespan",raw:n[0],text:r}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t,n){const r=this.rules.inline.autolink.exec(t);if(r){let o,s;return r[2]==="@"?(o=Ot(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Ot(r[1]),s=o),{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t,n){let r;if(r=this.rules.inline.url.exec(t)){let o,s;if(r[2]==="@")o=Ot(this.options.mangle?n(r[0]):r[0]),s="mailto:"+o;else{let i;do i=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(i!==r[0]);o=Ot(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t,n){const r=this.rules.inline.text.exec(t);if(r){let o;return this.lexer.state.inRawBlock?o=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):Ot(r[0]):r[0]:o=Ot(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const ve={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Ys,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};ve._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ve._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ve.def=rt(ve.def).replace("label",ve._label).replace("title",ve._title).getRegex(),ve.bullet=/(?:[*+-]|\d{1,9}[.)])/,ve.listItemStart=rt(/^( *)(bull) */).replace("bull",ve.bullet).getRegex(),ve.list=rt(ve.list).replace(/bull/g,ve.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ve.def.source+")").getRegex(),ve._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ve._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,ve.html=rt(ve.html,"i").replace("comment",ve._comment).replace("tag",ve._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ve.paragraph=rt(ve._paragraph).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ve._tag).getRegex(),ve.blockquote=rt(ve.blockquote).replace("paragraph",ve.paragraph).getRegex(),ve.normal={...ve},ve.gfm={...ve.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},ve.gfm.table=rt(ve.gfm.table).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ve._tag).getRegex(),ve.gfm.paragraph=rt(ve._paragraph).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",ve.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ve._tag).getRegex(),ve.pedantic={...ve.normal,html:rt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ve._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ys,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:rt(ve.normal._paragraph).replace("hr",ve.hr).replace("heading",` *#{1,6} *[^
|
|
96
|
+
]`).replace("lheading",ve.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const de={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ys,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Ys,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};de._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",de.punctuation=rt(de.punctuation).replace(/punctuation/g,de._punctuation).getRegex(),de.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,de.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,de._comment=rt(ve._comment).replace("(?:-->|$)","-->").getRegex(),de.emStrong.lDelim=rt(de.emStrong.lDelim).replace(/punct/g,de._punctuation).getRegex(),de.emStrong.rDelimAst=rt(de.emStrong.rDelimAst,"g").replace(/punct/g,de._punctuation).getRegex(),de.emStrong.rDelimUnd=rt(de.emStrong.rDelimUnd,"g").replace(/punct/g,de._punctuation).getRegex(),de._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,de._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,de._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,de.autolink=rt(de.autolink).replace("scheme",de._scheme).replace("email",de._email).getRegex(),de._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,de.tag=rt(de.tag).replace("comment",de._comment).replace("attribute",de._attribute).getRegex(),de._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,de._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,de._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,de.link=rt(de.link).replace("label",de._label).replace("href",de._href).replace("title",de._title).getRegex(),de.reflink=rt(de.reflink).replace("label",de._label).replace("ref",ve._label).getRegex(),de.nolink=rt(de.nolink).replace("ref",ve._label).getRegex(),de.reflinkSearch=rt(de.reflinkSearch,"g").replace("reflink",de.reflink).replace("nolink",de.nolink).getRegex(),de.normal={...de},de.pedantic={...de.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:rt(/^!?\[(label)\]\((.*?)\)/).replace("label",de._label).getRegex(),reflink:rt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",de._label).getRegex()},de.gfm={...de.normal,escape:rt(de.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},de.gfm.url=rt(de.gfm.url,"i").replace("email",de.gfm._extended_email).getRegex(),de.breaks={...de.gfm,br:rt(de.br).replace("{2,}","*").getRegex(),text:rt(de.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function DT(e){return e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function Ph(e){let t="",n,r;const o=e.length;for(n=0;n<o;n++)r=e.charCodeAt(n),Math.random()>.5&&(r="x"+r.toString(16)),t+="&#"+r+";";return t}class Wn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||dr,this.options.tokenizer=this.options.tokenizer||new ul,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:ve.normal,inline:de.normal};this.options.pedantic?(n.block=ve.pedantic,n.inline=de.pedantic):this.options.gfm&&(n.block=ve.gfm,this.options.breaks?n.inline=de.breaks:n.inline=de.gfm),this.tokenizer.rules=n}static get rules(){return{block:ve,inline:de}}static lex(t,n){return new Wn(n).lex(t)}static lexInline(t,n){return new Wn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
97
97
|
`),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,l,c)=>l+" ".repeat(c.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
|
|
98
98
|
`:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
|
|
99
99
|
`+r.raw,o.text+=`
|
|
@@ -103,7 +103,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
103
103
|
`+r.raw,o.text+=`
|
|
104
104
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r),i=s.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&o.type==="text"?(o.raw+=`
|
|
105
105
|
`+r.raw,o.text+=`
|
|
106
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+Nh("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,a.index)+"["+Nh("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(l||(c=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,c)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,Ph)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,Ph))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const p=t.slice(1);let m;this.options.extensions.startInline.forEach(function(f){m=f.call({lexer:this},p),typeof m=="number"&&m>=0&&(d=Math.min(d,m))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,
|
|
106
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+Nh("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,a.index)+"["+Nh("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(l||(c=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,c)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,Ph)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,Ph))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const p=t.slice(1);let m;this.options.extensions.startInline.forEach(function(f){m=f.call({lexer:this},p),typeof m=="number"&&m>=0&&(d=Math.min(d,m))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,DT)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(c=r.raw.slice(-1)),l=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class dl{constructor(t){this.options=t||dr}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
|
|
107
107
|
`,o?'<pre><code class="'+this.options.langPrefix+Ot(o)+'">'+(r?t:Ot(t,!0))+`</code></pre>
|
|
108
108
|
`:"<pre><code>"+(r?t:Ot(t,!0))+`</code></pre>
|
|
109
109
|
`}blockquote(t){return`<blockquote>
|
|
@@ -124,8 +124,8 @@ ${t}</blockquote>
|
|
|
124
124
|
${t}</tr>
|
|
125
125
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
126
126
|
`}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=Eh(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o='<a href="'+t+'"';return n&&(o+=' title="'+n+'"'),o+=">"+r+"</a>",o}image(t,n,r){if(t=Eh(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o=`<img src="${t}" alt="${r}"`;return n&&(o+=` title="${n}"`),o+=this.options.xhtml?"/>":">",o}text(t){return t}}class jh{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,n,r){return""+r}image(t,n,r){return""+r}br(){return""}}class _h{constructor(){this.seen={}}serialize(t){return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(t,n){let r=t,o=0;if(this.seen.hasOwnProperty(r)){o=this.seen[t];do o++,r=t+"-"+o;while(this.seen.hasOwnProperty(r))}return n||(this.seen[t]=o,this.seen[r]=0),r}slug(t,n={}){const r=this.serialize(t);return this.getNextSafeSlug(r,n.dryrun)}}class Vn{constructor(t){this.options=t||dr,this.options.renderer=this.options.renderer||new dl,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new jh,this.slugger=new _h}static parse(t,n){return new Vn(n).parse(t)}static parseInline(t,n){return new Vn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,p,m,f,v,g,x,y,b,C,k,S,T;const E=t.length;for(o=0;o<E;o++){if(f=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[f.type]&&(T=this.options.extensions.renderers[f.type].call({parser:this},f),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type))){r+=T||"";continue}switch(f.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(f.tokens),f.depth,kh(this.parseInline(f.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(f.text,f.lang,f.escaped);continue}case"table":{for(p="",d="",a=f.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(f.header[s].tokens),{header:!0,align:f.align[s]});for(p+=this.renderer.tablerow(d),m="",a=f.rows.length,s=0;s<a;s++){for(c=f.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:f.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(p,m);continue}case"blockquote":{m=this.parse(f.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=f.ordered,g=f.start,x=f.loose,a=f.items.length,m="",s=0;s<a;s++)b=f.items[s],C=b.checked,k=b.task,y="",b.task&&(S=this.renderer.checkbox(C),x?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=S+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=S+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:S}):y+=S),y+=this.parse(b.tokens,x),m+=this.renderer.listitem(y,k,C);r+=this.renderer.list(m,v,g);continue}case"html":{r+=this.renderer.html(f.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(f.tokens));continue}case"text":{for(m=f.tokens?this.parseInline(f.tokens):f.text;o+1<E&&t[o+1].type==="text";)f=t[++o],m+=`
|
|
127
|
-
`+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const P='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(P);return}else throw new Error(P)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Js{constructor(t){this.options=t||dr}preprocess(t){return t}postprocess(t){return t}}dx(Js,"passThroughHooks",new Set(["preprocess","postprocess"]));function
|
|
128
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Ot(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function Rh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ge.defaults,...s};const i=DT(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(RT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(p){return i(p)}const c=function(p){let m;if(!p)try{r.walkTokens&&ge.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){p=f}return r.highlight=a,p?i(p):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ge.walkTokens(l,function(p){p.type==="code"&&(d++,setTimeout(()=>{a(p.text,p.lang,function(m,f){if(m)return c(m);f!=null&&f!==p.text&&(p.text=f,p.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(ge.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&ge.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ge(e,t,n){return Rh(Wn.lex,Vn.parse)(e,t,n)}ge.options=ge.setOptions=function(e){return ge.defaults={...ge.defaults,...e},bT(ge.defaults),ge},ge.getDefaults=yh,ge.defaults=dr,ge.use=function(...e){const t=ge.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ge.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=ge.defaults.renderer||new dl;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=ge.defaults.tokenizer||new ul;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=ge.defaults.hooks||new Js;for(const s in n.hooks){const i=o[s];Js.passThroughHooks.has(s)?o[s]=a=>{if(ge.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=ge.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}ge.setOptions(r)})},ge.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ge,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ge.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ge.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ge.walkTokens(r.items,t));break}default:ge.defaults.extensions&&ge.defaults.extensions.childTokens&&ge.defaults.extensions.childTokens[r.type]?ge.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ge.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ge.walkTokens(r.tokens,t)))}return n},ge.parseInline=Rh(Wn.lexInline,Vn.parseInline),ge.Parser=Vn,ge.parser=Vn.parse,ge.Renderer=dl,ge.TextRenderer=jh,ge.Lexer=Wn,ge.lexer=Wn.lex,ge.Tokenizer=ul,ge.Slugger=_h,ge.Hooks=Js,ge.parse=ge,ge.options,ge.setOptions,ge.use,ge.walkTokens,ge.parseInline,Vn.parse,Wn.lex;function fr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof ge.parse=="function"?ge.parse(i):ge(i)}return typeof ge.parse=="function"?ge.parse(e):ge(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=w.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:re("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function Mh({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}function Oh({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>Iu(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Mh,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?u.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:u.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",u.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const LT="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 Zs({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:LT,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:er(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:er(e)})}function Dh({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=w.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(ce.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}const fl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));fl.displayName="Card";const pl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex flex-col space-y-1.5 p-6",e),...t}));pl.displayName="CardHeader";const hl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:re("text-2xl font-semibold leading-none tracking-tight",e),...t}));hl.displayName="CardTitle";const ml=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:re("text-sm text-muted-foreground",e),...t}));ml.displayName="CardDescription";const Qs=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("p-6 pt-0",e),...t}));Qs.displayName="CardContent";const Lh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex items-center p-6 pt-0",e),...t}));Lh.displayName="CardFooter";const $T=e=>!!e&&typeof e=="object"&&e.type==="user_choice"&&typeof e.question=="string"&&Array.isArray(e.alternatives);function gl({interruptPart:e,onApprove:t,onReject:n,onSelectAlternative:r,disabled:o,isActive:s,payload:i}){const a=$T(i)?i:null,l=(a==null?void 0:a.question)??e.title??"Approve the result?",c=a?s?"Select one of the alternatives to continue.":"Waiting for approval from another participant.":s?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";let d=null;if(!a&&i!==void 0&&i!==null)if(typeof i=="string")d=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:i});else{const p=er(i);d=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:p})}return u.jsxs(fl,{className:re("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",s?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(pl,{className:"pb-3",children:[u.jsx(hl,{className:"text-blue-900 dark:text-blue-100 text-base",children:l}),u.jsx(ml,{className:"text-blue-700 dark:text-blue-300 text-sm",children:c})]}),a?u.jsx(Qs,{className:"pt-0 pb-3",children:u.jsx("div",{className:"space-y-2",children:a.alternatives.map(p=>u.jsx(Je,{size:"sm",variant:"outline",onClick:()=>r==null?void 0:r(e,p),className:"w-full justify-start text-left",disabled:o||!s,children:u.jsxs("div",{className:"flex flex-col items-start gap-1",children:[u.jsx("span",{className:"font-semibold",children:p.label}),p.description?u.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:p.description}):null]})},p.id))})}):d&&u.jsx(Qs,{className:"pt-0 pb-3",children:d}),!a&&u.jsx(Lh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Je,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:o||!s,children:"Reject"}),u.jsx(Je,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:o||!s,children:"Approve"})]})})]})}function $h({className:e}){const t=w.useRef(null);return w.useEffect(()=>{let n=0;const r=()=>{if(n=(n+1)%4,t.current){const s=".".repeat(n);t.current.textContent=`Is thinking${s}`}};r();const o=setInterval(r,500);return()=>clearInterval(o)},[]),u.jsx("span",{ref:t,"aria-live":"polite",className:re("inline-block text-xs opacity-70 ml-1",e),children:"Is thinking"})}function Fh({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:re("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(fr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:re("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Je,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(ce.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ce.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Bh(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=cl(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),p=w.useCallback(f=>{a(f),c(!0)},[]),m=w.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const b=String(v.url??""),C=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(C){f.preventDefault();const k=C[1],S=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";p({id:k,name:S,mimeType:T});return}if(b.startsWith("data:")){f.preventDefault(),s(S=>({...S,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const S=await iu(n??void 0);if(!S||!Array.isArray(S))throw new Error("Invalid file list response");const T=S.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");p({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(S){console.error("Failed to fetch server file:",S);const T=S instanceof Error?S.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(S=>({...S,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(C=>({...C,[g]:!1}))}},[t,o,r,n,p]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function zh(e,t){return w.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:yu(r),toolMeta:Jo(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Su(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Hh="data:";function FT(e){if(!e)return[];const t=[],n=e.split(/\r?\n/);for(const r of n){const o=r.trim();if(!o||!o.startsWith(Hh))continue;const s=o.slice(Hh.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=Qn(s);i&&typeof i=="object"&&t.push(i)}return t}function BT(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n&&typeof n=="object"&&n.type==="tool.end")return n}return null}function zT(e){return w.useMemo(()=>{const t=e.content.filter(c=>c.type==="text");if(!t.length)return null;let r=t.flatMap(c=>FT(c.text??""));if(!r.length){const c=t.map(p=>p.text??"").join(`
|
|
129
|
-
`),d=Qn(c);d&&typeof d=="object"&&(r=[d])}if(!r.length)return null;const s=
|
|
130
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[y[M]?u.jsx(ce.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[Z,y[M]?" (processing)":""]})]},M)}return null},[x,E,S,b,C,y,k,v,T]),X=a.trim().length>0||l.length>0||c.length>0||R.length>0;if(!t&&c.length>0&&!p)return K();if(!t&&!X&&!p)return null;if(t){if(!n)return null;if(O&&d){const N=d.value,M=!G,U=$??(()=>{}),Z=L??(()=>{});return u.jsx(gl,{interruptPart:d,payload:N,onApprove:U,onReject:Z,onSelectAlternative:F,disabled:G,isActive:M})}return u.jsx(Uh,{message:e,viewMode:r,expandable:o,isStreaming:s,toolConfig:_},e.id)}if(!g){const N=u.jsx("div",{className:"space-y-2",children:R.map((M,U)=>v&&qT(M)?J?u.jsx("div",{className:"space-y-2",children:J},`streaming-md-${U}`):null:u.jsx(B,{part:M,i:U},U))});return p?u.jsxs("div",{"aria-busy":"true",role:"status",children:[N,u.jsx($h,{className:P})]}):N}return null}function VT(e){return e?!(Ao(e,/```/g)||Ao(e,/`/g)||Ao(e,/\*\*/g)||Ao(e,/__/g)||Ao(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function Ao(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function KT(e){if(!e)return 0;for(let t=e.length;t>=0;t-=1)if(VT(e.slice(0,t)))return t;return 0}function qT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const GT=Vr.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 Wh({className:e,variant:t,...n}){return u.jsx("div",{className:re(GT({variant:t}),e),...n})}function YT({showTimestamp:e,showAgentName:t,isToolMessage:n,isInterruptMessage:r=!1,iconForeground:o,agentName:s,messageIcon:i,customHeaderClass:a,customActionsClass:l,isCompactLayout:c,showActions:d,isEditing:p,messageRole:m,toolViewMode:f,toolExpandable:v=!1,toolMeta:g,onToggleToolView:x,onCopy:y,onEdit:b,onRegenerate:C,showCheckpointControls:k,attemptCount:S,attemptIndex:T,handleOlderAttemptSelect:E,handleNewerAttemptSelect:P,messageCreatedAt:_,copied:$}){return!e&&!t&&!n&&!r?null:u.jsxs("div",{className:re("flex items-center justify-between mb-2 pb-2 border-b border-current/10",c&&"mb-1 pb-1",o,a),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[i,t&&s&&u.jsx("span",{className:re("font-medium",c?"text-xs":"text-sm"),children:s}),n&&!r&&u.jsxs(Wh,{variant:"outline",className:re("text-xs flex items-center gap-1",o,"border border-current/40",c&&"text-xs h-4",v&&"cursor-pointer select-none"),role:v?"button":void 0,tabIndex:v?0:void 0,"aria-expanded":v?f==="expanded":void 0,onClick:v?x:void 0,onKeyDown:L=>{v&&(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),x())},children:[u.jsx("span",{children:g.name??"Tool Output"}),g.toolCallId&&u.jsx("span",{className:"opacity-70",children:g.toolCallId.slice(0,8)}),v&&(f==="expanded"?u.jsx(ce.ChevronUp,{className:"h-3 w-3"}):u.jsx(ce.ChevronDown,{className:"h-3 w-3"}))]}),r&&u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g.name??"Interrupt"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[k&&S>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T<S-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T>=S-1||E()},"aria-label":"Older attempt (back in time)",disabled:T>=S-1,children:u.jsx(ce.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[S-T," / ",S]})}),u.jsx("button",{type:"button",className:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T<=0||P()},"aria-label":"Newer attempt (forward in time)",disabled:T<=0,children:u.jsx(ce.ChevronRight,{className:"h-3 w-3"})})]}),e&&_&&u.jsx("time",{className:re("text-xs opacity-60",o,c&&"text-xs"),dateTime:new Date(_).toISOString(),title:new Date(_).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(_))}),d&&!p&&u.jsxs("div",{className:re("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",l),children:[u.jsx("div",{className:"relative",children:u.jsx(Je,{variant:"ghost",size:"sm",onClick:y,className:re("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ce.Copy,{className:re($?"text-success":o,c?"h-3 w-3":"h-4 w-4")})})}),m==="user"&&b&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:b,className:re("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ce.Edit,{className:re(o,c?"h-3 w-3":"h-4 w-4")})}),m==="assistant"&&C&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:C,className:re("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ce.RotateCcw,{className:re(o,c?"h-3 w-3":"h-4 w-4")})})]})]})]})}const ei=w.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:p=!0,toolConfig:m,customStyles:f={},streamingDebounceMs:v=300,renderStreamingMarkdown:g=!1,enableStreamingMarkdownBuffer:x,onEdit:y,onRegenerate:b,onCopy:C,getInterruptOptions:k,attemptCount:S=1,attemptIndex:T=0,onSelectCheckpoint:E,attemptMetas:P=[]}){const[_,$]=w.useState(!1),[L,F]=w.useState(!1),{currentThreadId:G}=br(),{respondToInterrupt:O}=no(),[K,q]=w.useState(!1),H=l==="phone"||l==="half-screen",j=t.role,I=j==="interrupt",Y=j==="tool"||I,D=!(t.role==="default_message")&&t.expandable!==void 0?t.expandable!==!1:!0,{toolRenderers:V,toolArtifactRenderers:R,getToolExpandable:B}=m??{},X=w.useMemo(()=>!B||t.role!=="tool"?!1:B(t),[B,t.id,t.role]),[N,M]=w.useState(X?"preview":"expanded");w.useEffect(()=>{M(X?"preview":"expanded")},[X,t.id]);const U=w.useMemo(()=>t.role==="default_message"?t:null,[t]),Z=!!U,se=!(r&&j!=="user"),{uploadingFiles:ae,handleFileClick:Ce,fileViewerOpen:we,currentFileInfo:je,closeFileViewer:We}=Bh({allowFileOpen:se,currentThreadId:G}),Fe=w.useMemo(()=>{switch(j){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"interrupt":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[j]),Ye=zh(t,U),{contentParts:He,imageParts:vt,fileParts:wt,textContent:dt,toolMeta:Ve,toolRaw:Ae,isToolStreaming:Ke,interruptParts:_e}=Ye,Be=x??v!==0,Qe=w.useMemo(()=>_e.length?_e[0]:null,[_e]),Nt=w.useCallback(async()=>{const Ee=Y?Ae:dt;async function be(Xe){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Xe);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const At=new Blob([Xe],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":At})]);return}throw new Error("Clipboard API not supported in this context.")}try{await be(Ee),$(!0),setTimeout(()=>$(!1),2e3),C==null||C(Ee)}catch(Xe){console.error("Failed to copy:",Xe)}},[Y,Ae,dt,C]),et=w.useCallback(async(Ee,be)=>{if(!Qe)return;if(!Fi(Qe.id)){console.warn("Interrupt part missing id",Qe);return}q(!0);try{const At=k==null?void 0:k(t);await O(Ee,be,At)}catch(At){console.error("Failed to respond to interrupt:",At)}finally{q(!1)}},[Qe,O]),bt=w.useCallback(()=>et(!0),[et]),mt=w.useCallback(()=>et(!1),[et]),Ct=w.useCallback((Ee,be)=>{if(!be)return;const Xe={alternativeId:be.id??be.label??void 0,alternativeLabel:be.label};et(!0,Xe)},[et]),Tt=w.useCallback(()=>{if(!y||!t.id)return;const Ee=(Y?Ae:dt)??"",be="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};y(t.id,Ee,be)},[y,Y,Ae,dt,t]),Dt=w.useCallback(()=>{b==null||b(n)},[b,n]),Pt=w.useCallback(()=>{const be=re(H?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Fe);switch(j){case"user":return u.jsx(ce.User,{className:be});case"assistant":return u.jsx(ce.Bot,{className:be});case"tool":return u.jsx(ce.Wrench,{className:be});case"interrupt":return u.jsx(ce.Bot,{className:be});default:return u.jsx(ce.Bot,{className:be})}},[H,Fe,j]),kt=w.useCallback(()=>{const Ee="group relative mb-4 flex w-full";switch(j){case"user":return re(Ee,"justify-end");case"assistant":case"tool":case"system":case"interrupt":return re(Ee,"justify-start");default:return Ee}},[j]),qt=w.useCallback(()=>{const Ee=re("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",H&&"px-3 py-2 text-sm");if(Z)return re(Ee,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(j){case"user":return re(Ee,"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 re(Ee,"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":case"interrupt":return re(Ee,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return re(Ee,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return re(Ee,"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")}},[H,Z,j]),Ue=X&&!I&&D,$e=w.useCallback(()=>{Ue&&M(Ee=>Ee==="expanded"?"preview":"expanded")},[Ue]),ne=I?"expanded":N,he=(p||I)&&D,tt=u.jsx(WT,{message:t,isToolMessage:Y,showToolMessages:he,toolViewMode:ne,toolExpandable:X,toolConfig:{toolRenderers:V,toolArtifactRenderers:R,getToolExpandable:B},isToolStreaming:Ke,contentParts:He,textContent:dt,imageParts:vt,fileParts:wt,isStreamingMessage:r,defaultMessage:U,enableStreamingMarkdownBuffer:Be,renderStreamingMarkdown:g,streamingDebounceMs:v,handleFileClick:Ce,uploadingFiles:ae,messageRole:j,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:L,setIsUserExpanded:F,isCompactLayout:H,iconForeground:Fe,interruptPart:Qe,handleInterruptApprove:bt,handleInterruptReject:mt,handleInterruptAlternative:Ct,disableInterruptActions:K,isInterruptMessage:I}),me=w.useMemo(()=>U?"Assistant":Cu(t),[U,t]),Oe=Pt(),qe=j==="user"&&(S??1)>1&&typeof E=="function",ut=(P==null?void 0:P.length)??0,at=ut>0&&T<ut-1?P[T+1]:void 0,lt=ut>0&&T>0?P[T-1]:void 0,Et=w.useCallback(()=>{!at||!E||E(at.id,void 0,!!at.isLatestAttempt)},[at,E]),ke=w.useCallback(()=>{!lt||!E||E(lt.id,void 0,!!lt.isLatestAttempt)},[lt,E]);return Y&&!p?null:Z&&U?u.jsx("div",{className:re(kt(),f.container),children:u.jsxs("div",{className:re(qt(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ce.Bot,{className:re("h-4 w-4",Fe)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(fr,{content:U.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:re(kt(),f.container),children:u.jsxs("div",{className:re(qt(),f.content),children:[u.jsx(YT,{showTimestamp:i,showAgentName:a,isToolMessage:Y,iconForeground:Fe,agentName:me,messageIcon:Oe,customHeaderClass:f.header,customActionsClass:f.actions,isCompactLayout:H,showActions:s,isEditing:o,messageRole:j,toolViewMode:ne,toolExpandable:X,isInterruptMessage:I,toolMeta:Ve,onToggleToolView:$e,onCopy:Nt,onEdit:Tt,onRegenerate:Dt,showCheckpointControls:qe,attemptCount:S,attemptIndex:T,handleOlderAttemptSelect:Et,handleNewerAttemptSelect:ke,messageCreatedAt:t.createdAt,copied:_}),u.jsx("div",{className:"relative",children:tt}),!(i||a||Y)&&s&&!o&&u.jsxs("div",{className:re("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>Nt(),className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",H&&"h-5 w-5"),children:u.jsx(ce.Copy,{className:re(_?"text-success":"text-current",H?"h-3 w-3":"h-4 w-4")})}),j==="user"&&y&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:Tt,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",H&&"h-5 w-5"),children:u.jsx(ce.Edit,{className:re("text-current",H?"h-3 w-3":"h-4 w-4")})}),j==="assistant"&&b&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:Dt,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",H&&"h-5 w-5"),children:u.jsx(ce.RotateCcw,{className:re("text-current",H?"h-3 w-3":"h-4 w-4")})})]})]})}),je&&u.jsx(bh,{isOpen:we,onClose:We,fileId:je.id,fileName:je.name,mimeType:je.mimeType})]})},(e,t)=>{var l,c,d,p,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Bi(e.message)===Bi(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolConfig"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((p=t.customStyles)==null?void 0:p.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=zi(e.message),a=zi(t.message);return i.length===a.length});ei.displayName="MessageComponent";const wl=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r=0,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:p,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,showToolMessages:b=!0,toolConfig:C,checkpointIndex:k,activeCheckpointId:S,onSelectCheckpoint:T,createSyntheticThinkingMessage:E=!0,forceSyntheticThinking:P=!1,getMessageCustomStyles:_,getInterruptOptions:$},L)=>{const F=w.useRef(null),G=w.useRef(null),O=w.useRef(!1),K=w.useRef(!1),q=e,H=w.useMemo(()=>{const N=n&&q.some(U=>U.id===n);return E&&(t||P)&&!N&&q.length>0?[...q,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:q},[q,t,n,E,P]),j=w.useMemo(()=>b?H:H.filter(N=>(N==null?void 0:N.role)!=="tool"),[H,b]),I=w.useCallback(N=>{x&&x(!N),y&&y(N)},[x,y]),Y=w.useMemo(()=>{if(a)return async()=>{if(!O.current){O.current=!0;try{await a()}finally{O.current=!1}}}},[a]),J=w.useMemo(()=>!v||g?!1:"auto",[v,g]),D=w.useMemo(()=>{if(typeof f!="string")return null;const N=f.trim();return!N||j&&j.length>0?null:{id:"default-message",role:"default_message",content:N,createdAt:new Date().toISOString()}},[f,j]),V=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),R=()=>{if(D){const N=_==null?void 0:_(D);return u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(ei,{message:D,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:N,getInterruptOptions:$})})})}return u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"})},B=j.length,X=B>0;return w.useEffect(()=>{var N,M;if(B===0){K.current=!1;return}if(!K.current)if(K.current=!0,F.current&&j.length>0){const U=j.length-1;(M=(N=F.current).scrollToIndex)==null||M.call(N,{index:U,align:"end",behavior:"auto"})}else G.current&&(G.current.scrollTop=G.current.scrollHeight)},[B,j.length]),w.useImperativeHandle(L,()=>({scrollToLatest:()=>{var N,M;if(F.current&&j.length>0){const U=j.length-1;(M=(N=F.current).scrollToIndex)==null||M.call(N,{index:U,align:"end",behavior:"auto"})}else G.current&&(G.current.scrollTop=G.current.scrollHeight)},scrollToTop:()=>{var N,M;F.current&&j.length>0?(M=(N=F.current).scrollToIndex)==null||M.call(N,{index:0,align:"start",behavior:"auto"}):G.current&&(G.current.scrollTop=0)}}),[j]),u.jsx("div",{className:V,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:X?u.jsx(HC,{ref:N=>{F.current=N},scrollerRef:N=>{G.current=N instanceof HTMLDivElement?N:null},data:j,followOutput:J,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{Y&&Y()},atBottomStateChange:I,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(N,M)=>xl(M,N),itemContent:(N,M)=>u.jsx(vl,{message:M,index:N,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,showToolMessages:b,toolConfig:C,checkpointIndex:k,activeCheckpointId:S,onSelectCheckpoint:T,getMessageCustomStyles:_,getInterruptOptions:$})}):R()})})});wl.displayName="MessageList";const Vh={value:""};function $r({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,followNewMessages:s=!0,enableFileUpload:i=!0,enableExcelUpload:a=!1,enableMessageEditing:l=!0,showToolMessages:c=!0,toolConfig:d,toolRenderers:p,toolArtifactRenderers:m,payloadExtras:f={},customStyles:v={},messageCustomStyles:g,onMessageSent:x,onExcelUploadSuccess:y,onError:b,defaultMessage:C}){const{api:k}=eo(),S=k.baseUrl,{currentThreadId:T}=br(),{threadId:E,messages:P,isLoading:_,navigateToCheckpoint:$,returnToLatest:L,checkpoint:F,checkpoints:G,interrupt:O,metadata:K,checkpointIndex:q,respondToInterrupt:H}=no(),{isStreaming:j,error:I,connectionState:Y,submit:J,stop:D}=Wi(),V=E??T??null,R=(F==null?void 0:F.id)??null,B=(F==null?void 0:F.namespace)??null,X=(K==null?void 0:K.assemblingMessageId)??null,N=O,M=N?Fi(N.id):null,U=M!==null?{type:"interrupt",id:M}:null,[Z,se]=w.useState(!1),[ae,Ce]=w.useState(!1);w.useEffect(()=>{N||se(!1)},[N]);const we=w.useCallback(()=>{se(!0)},[]),je=w.useCallback(()=>{se(!1)},[]),We=w.useCallback(Q=>{},[]),Fe=w.useCallback(Q=>Q.name!=="ask_user_choice",[]),Ye=d??{toolRenderers:p,toolArtifactRenderers:m,getToolExpandable:Fe},He=w.useCallback(async(Q,le,xe)=>{try{we(),await H(Q,le,xe)}catch(Ie){console.error("Failed to respond to interrupt:",Ie)}finally{je()}},[je,we,H]),vt=w.useCallback(()=>He(!0),[He]),wt=w.useCallback(()=>He(!1),[He]),dt=w.useCallback((Q,le)=>He(!0,le),[He]),Ve=!!N||Z,[Ae,Ke]=w.useState(null),[_e,Be]=w.useState(""),[Qe,Nt]=w.useState(null),[et,bt]=w.useState(null),[mt,Ct]=w.useState(!1),[Tt,Dt]=w.useState(null),Pt=w.useRef(!1),[kt,qt]=w.useState(()=>Vh.value),Ue=w.useRef(kt),$e=w.useRef(null),ct=w.useCallback(Q=>{Vh.value=Q,qt(Q)},[]),[ne,he]=w.useState(!1),tt=w.useRef(null),me=w.useCallback(Q=>{ct(Q)},[ct]);w.useEffect(()=>{j||Ce(!1)},[j]),w.useEffect(()=>{K!=null&&K.assemblingMessageId&&Ce(!1)},[K==null?void 0:K.assemblingMessageId]);const[Oe,qe]=w.useState("desktop");w.useEffect(()=>{const Q=()=>{const le=window.innerWidth;qe(le<640?"phone":le<1024?"tablet":"desktop")};return Q(),window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[]),w.useEffect(()=>{Pt.current=!1},[V]),w.useEffect(()=>{Ue.current=kt},[kt]),w.useEffect(()=>{if(!Ae){$e.current=null;return}$e.current===null&&($e.current=Ue.current),ct(_e??"")},[_e,Ae,ct]),w.useEffect(()=>{if(C!==void 0){Dt(C);return}(async()=>{if(!S){Dt(null);return}try{const xe=(await k.getAgent("default")).uiDefaultMessage||"";Dt(xe||null)}catch(le){console.warn("Failed to fetch default message:",le),Dt(null)}})()},[k,S,C]),w.useEffect(()=>{I&&!mt&&(b==null||b(I))},[I,mt,b]);const ut=async(Q,le)=>{const xe=Q.trim();if(!(!xe&&le.length===0))try{const Ie=Ae?(Qe==null?void 0:Qe.checkpointId)??R??void 0:R??void 0,Re=Ae?(Qe==null?void 0:Qe.checkpointNs)??B??void 0:B??void 0;await J({text:xe||"",attachments:le,payload:f},{checkpointId:Ie,checkpointNs:Re,edit:!!Ae,originalMessageId:Ae??void 0}),x==null||x(xe),Ce(!0),ct(""),bt(null),Ke(null),Be(""),Nt(null)}catch(Ie){const Re=(Ie==null?void 0:Ie.message)||"Failed to send message";bt(Re),b==null||b(Re),Ce(!1)}},at=w.useCallback(async Q=>{await J({attachments:[Q],payload:f},{checkpointId:R??void 0,checkpointNs:B??void 0}),y==null||y({file:Q})},[R,B,f,y,J]),lt=w.useCallback((Q,le,xe)=>{l&&($e.current=kt,Ke(Q),Be(le),ct(le),bt(null),Nt({checkpointId:(xe==null?void 0:xe.checkpointId)??null,checkpointNs:(xe==null?void 0:xe.checkpointNs)??null}))},[kt,l,ct]),Et=w.useCallback(()=>{Ke(null),Be(""),Nt(null),bt(null),ct($e.current??kt),$e.current=null},[kt,ct]),ke=w.useCallback((Q,le,xe)=>{lt(Q,le,xe)},[lt]),Ee=w.useCallback(Q=>{let le=null;for(let Te=Q-1;Te>=0;Te--)if(P[Te].role==="user"){le=P[Te];break}if(!le)return;const xe=Array.isArray(le.content)?le.content:[],Re=xe.filter(Te=>(Te==null?void 0:Te.type)==="text").map(Te=>Te.text).join("")||(()=>{try{return JSON.stringify(xe,null,2)}catch{return String(xe)}})();Re&&J({text:Re,payload:f},{checkpointId:R??void 0,checkpointNs:B??void 0,edit:!0,originalMessageId:le.id})},[P,J,R,B,f]),be=w.useCallback(async Q=>{if(T){he(!0);try{if(!Q){await L(),requestAnimationFrame(()=>{var Ie;(Ie=tt.current)==null||Ie.scrollToLatest()});return}const le=G.find(Ie=>Ie.checkpointId===Q),xe=(le==null?void 0:le.checkpointNs)??null;await $(Q,xe),requestAnimationFrame(()=>{var Ie;(Ie=tt.current)==null||Ie.scrollToTop()})}finally{he(!1)}}},[G,T,tt,$,L]),Xe=w.useCallback(async(Q,le,xe)=>{await be(xe?null:Q)},[be]),At=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.container||""}`,A=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 ${N?"pb-32":""} bg-transparent ${v.messagesArea||""}`,ee=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:At,children:[!!I&&!mt&&u.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:[u.jsx("span",{children:I}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>Ct(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ce.X,{size:16})})]}),u.jsxs("div",{className:`relative ${A}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(wl,{ref:tt,className:"h-full",style:{height:"100%"},messages:P,isStreaming:j,streamingAssistantId:X,streamingDebounceMs:o,followNewMessages:s,layoutSize:Oe,enableMessageEditing:l,editingMessageId:Ae,onEdit:ke,onRegenerate:Ee,onCancelEdit:Et,emptyMessage:Tt??void 0,isNavigatingCheckpoint:ne,showToolMessages:c,toolConfig:Ye,checkpointIndex:q,activeCheckpointId:R,onSelectCheckpoint:Xe,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ae,getMessageCustomStyles:g,getInterruptOptions:We}),(Y==="reconnecting"||Y==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(ce.Loader2,{className:"h-3 w-3 animate-spin"}),Y==="reconnecting"?"Reconnecting…":"Connecting…"]})}),Y==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),_&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ce.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),ne&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ce.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]}),N&&U&&u.jsx("div",{className:"pointer-events-auto absolute inset-x-0 bottom-6 z-30 flex justify-center px-4",children:u.jsx("div",{className:"w-full max-w-3xl",children:u.jsx(gl,{interruptPart:U,onApprove:vt,onReject:wt,onSelectAlternative:dt,disabled:Z,isActive:!0,payload:N.value})})})]}),u.jsxs("div",{className:ee,children:[Ae&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ce.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:Et,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ce.X,{size:16})})]})}),et&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:et}),u.jsx(_S,{composerValue:kt,onComposerChange:me,onSend:ut,onCancelEdit:Et,onStop:D,editingMessageId:Ae,editingInitialValue:_e,placeholder:Ae?"Edit your message...":t,isStreaming:j,disabled:Ve,enableFileUpload:i,enableExcelUpload:a,onExcelUpload:at,onError:b,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:et})]})]})}var Kh=1,XT=.9,JT=.8,ZT=.17,bl=.1,yl=.999,QT=.9999,ek=.99,tk=/[\\\/_+.#"@\[\(\{&]/,nk=/[\\\/_+.#"@\[\(\{&]/g,rk=/[\s-]/,qh=/[\s-]/g;function Sl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Kh:ek;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,p,m,f,v;c>=0;)p=Sl(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=Kh:tk.test(e.charAt(c-1))?(p*=JT,f=e.slice(o,c-1).match(nk),f&&o>0&&(p*=Math.pow(yl,f.length))):rk.test(e.charAt(c-1))?(p*=XT,v=e.slice(o,c-1).match(qh),v&&o>0&&(p*=Math.pow(yl,v.length))):(p*=ZT,o>0&&(p*=Math.pow(yl,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=QT)),(p<bl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=Sl(e,t,n,r,c+1,s+2,i),m*bl>p&&(p=m*bl)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function Gh(e){return e.toLowerCase().replace(qh," ")}function ok(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Sl(e,t,Gh(e),Gh(t),0,0,{})}var Po='[cmdk-group=""]',Cl='[cmdk-group-items=""]',sk='[cmdk-group-heading=""]',Yh='[cmdk-item=""]',Xh=`${Yh}:not([aria-disabled="true"])`,Tl="cmdk-item-select",Fr="data-value",ik=(e,t,n)=>ok(e,t,n),Jh=h.createContext(void 0),jo=()=>h.useContext(Jh),Zh=h.createContext(void 0),kl=()=>h.useContext(Zh),Qh=h.createContext(void 0),em=h.forwardRef((e,t)=>{let n=Br(()=>{var D,V;return{search:"",value:(V=(D=e.value)!=null?D:e.defaultValue)!=null?V:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Br(()=>new Set),o=Br(()=>new Map),s=Br(()=>new Map),i=Br(()=>new Set),a=tm(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=_t(),C=_t(),k=_t(),S=h.useRef(null),T=xk();pr(()=>{if(d!==void 0){let D=d.trim();n.current.value=D,E.emit()}},[d]),pr(()=>{T(6,G)},[]);let E=h.useMemo(()=>({subscribe:D=>(i.current.add(D),()=>i.current.delete(D)),snapshot:()=>n.current,setState:(D,V,R)=>{var B,X,N,M;if(!Object.is(n.current[D],V)){if(n.current[D]=V,D==="search")F(),$(),T(1,L);else if(D==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let U=document.getElementById(k);U?U.focus():(B=document.getElementById(b))==null||B.focus()}if(T(7,()=>{var U;n.current.selectedItemId=(U=O())==null?void 0:U.id,E.emit()}),R||T(5,G),((X=a.current)==null?void 0:X.value)!==void 0){let U=V??"";(M=(N=a.current).onValueChange)==null||M.call(N,U);return}}E.emit()}},emit:()=>{i.current.forEach(D=>D())}}),[]),P=h.useMemo(()=>({value:(D,V,R)=>{var B;V!==((B=s.current.get(D))==null?void 0:B.value)&&(s.current.set(D,{value:V,keywords:R}),n.current.filtered.items.set(D,_(V,R)),T(2,()=>{$(),E.emit()}))},item:(D,V)=>(r.current.add(D),V&&(o.current.has(V)?o.current.get(V).add(D):o.current.set(V,new Set([D]))),T(3,()=>{F(),$(),n.current.value||L(),E.emit()}),()=>{s.current.delete(D),r.current.delete(D),n.current.filtered.items.delete(D);let R=O();T(4,()=>{F(),(R==null?void 0:R.getAttribute("id"))===D&&L(),E.emit()})}),group:D=>(o.current.has(D)||o.current.set(D,new Set),()=>{s.current.delete(D),o.current.delete(D)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:C,listInnerRef:S}),[]);function _(D,V){var R,B;let X=(B=(R=a.current)==null?void 0:R.filter)!=null?B:ik;return D?X(D,n.current.search,V):0}function $(){if(!n.current.search||a.current.shouldFilter===!1)return;let D=n.current.filtered.items,V=[];n.current.filtered.groups.forEach(B=>{let X=o.current.get(B),N=0;X.forEach(M=>{let U=D.get(M);N=Math.max(U,N)}),V.push([B,N])});let R=S.current;K().sort((B,X)=>{var N,M;let U=B.getAttribute("id"),Z=X.getAttribute("id");return((N=D.get(Z))!=null?N:0)-((M=D.get(U))!=null?M:0)}).forEach(B=>{let X=B.closest(Cl);X?X.appendChild(B.parentElement===X?B:B.closest(`${Cl} > *`)):R.appendChild(B.parentElement===R?B:B.closest(`${Cl} > *`))}),V.sort((B,X)=>X[1]-B[1]).forEach(B=>{var X;let N=(X=S.current)==null?void 0:X.querySelector(`${Po}[${Fr}="${encodeURIComponent(B[0])}"]`);N==null||N.parentElement.appendChild(N)})}function L(){let D=K().find(R=>R.getAttribute("aria-disabled")!=="true"),V=D==null?void 0:D.getAttribute(Fr);E.setState("value",V||void 0)}function F(){var D,V,R,B;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let X=0;for(let N of r.current){let M=(V=(D=s.current.get(N))==null?void 0:D.value)!=null?V:"",U=(B=(R=s.current.get(N))==null?void 0:R.keywords)!=null?B:[],Z=_(M,U);n.current.filtered.items.set(N,Z),Z>0&&X++}for(let[N,M]of o.current)for(let U of M)if(n.current.filtered.items.get(U)>0){n.current.filtered.groups.add(N);break}n.current.filtered.count=X}function G(){var D,V,R;let B=O();B&&(((D=B.parentElement)==null?void 0:D.firstChild)===B&&((R=(V=B.closest(Po))==null?void 0:V.querySelector(sk))==null||R.scrollIntoView({block:"nearest"})),B.scrollIntoView({block:"nearest"}))}function O(){var D;return(D=S.current)==null?void 0:D.querySelector(`${Yh}[aria-selected="true"]`)}function K(){var D;return Array.from(((D=S.current)==null?void 0:D.querySelectorAll(Xh))||[])}function q(D){let V=K()[D];V&&E.setState("value",V.getAttribute(Fr))}function H(D){var V;let R=O(),B=K(),X=B.findIndex(M=>M===R),N=B[X+D];(V=a.current)!=null&&V.loop&&(N=X+D<0?B[B.length-1]:X+D===B.length?B[0]:B[X+D]),N&&E.setState("value",N.getAttribute(Fr))}function j(D){let V=O(),R=V==null?void 0:V.closest(Po),B;for(;R&&!B;)R=D>0?mk(R,Po):gk(R,Po),B=R==null?void 0:R.querySelector(Xh);B?E.setState("value",B.getAttribute(Fr)):H(D)}let I=()=>q(K().length-1),Y=D=>{D.preventDefault(),D.metaKey?I():D.altKey?j(1):H(1)},J=D=>{D.preventDefault(),D.metaKey?q(0):D.altKey?j(-1):H(-1)};return h.createElement(fe.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:D=>{var V;(V=y.onKeyDown)==null||V.call(y,D);let R=D.nativeEvent.isComposing||D.keyCode===229;if(!(D.defaultPrevented||R))switch(D.key){case"n":case"j":{x&&D.ctrlKey&&Y(D);break}case"ArrowDown":{Y(D);break}case"p":case"k":{x&&D.ctrlKey&&J(D);break}case"ArrowUp":{J(D);break}case"Home":{D.preventDefault(),q(0);break}case"End":{D.preventDefault(),I();break}case"Enter":{D.preventDefault();let B=O();if(B){let X=new Event(Tl);B.dispatchEvent(X)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:P.inputId,id:P.labelId,style:wk},l),ti(e,D=>h.createElement(Zh.Provider,{value:E},h.createElement(Jh.Provider,{value:P},D))))}),ak=h.forwardRef((e,t)=>{var n,r;let o=_t(),s=h.useRef(null),i=h.useContext(Qh),a=jo(),l=tm(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;pr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=nm(o,s,[e.value,e.children,s],e.keywords),p=kl(),m=Kn(T=>T.value&&T.value===d.current),f=Kn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);h.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(Tl,v),()=>T.removeEventListener(Tl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){p.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:b,forceMount:C,keywords:k,...S}=e;return h.createElement(fe.div,{ref:Mn(s,t),...S,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),lk=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=_t(),a=h.useRef(null),l=h.useRef(null),c=_t(),d=jo(),p=Kn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);pr(()=>d.group(i),[]),nm(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(fe.div,{ref:Mn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),ti(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(Qh.Provider,{value:m},f))))}),ck=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Kn(i=>!i.search);return!n&&!s?null:h.createElement(fe.div,{ref:Mn(o,t),...r,"cmdk-separator":"",role:"separator"})}),uk=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=kl(),i=Kn(c=>c.search),a=Kn(c=>c.selectedItemId),l=jo();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(fe.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),dk=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Kn(c=>c.selectedItemId),l=jo();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,p,m=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(p),m.unobserve(c)}}},[]),h.createElement(fe.div,{ref:Mn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},ti(e,c=>h.createElement("div",{ref:Mn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),fk=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(ol,{open:n,onOpenChange:r},h.createElement(sl,{container:i},h.createElement(Eo,{"cmdk-overlay":"",className:o}),h.createElement(Io,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(em,{ref:t,...a}))))}),pk=h.forwardRef((e,t)=>Kn(n=>n.filtered.count===0)?h.createElement(fe.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),hk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(fe.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ti(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Vt=Object.assign(em,{List:dk,Item:ak,Input:uk,Group:lk,Separator:ck,Dialog:fk,Empty:pk,Loading:hk});function mk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function gk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function tm(e){let t=h.useRef(e);return pr(()=>{t.current=e}),t}var pr=typeof window>"u"?h.useEffect:h.useLayoutEffect;function Br(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Kn(e){let t=kl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function nm(e,t,n,r=[]){let o=h.useRef(),s=jo();return pr(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Fr,a),o.current=a}),o}var xk=()=>{let[e,t]=h.useState(),n=Br(()=>new Map);return pr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function vk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function ti({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(vk(t),{ref:t.ref},n(t.props.children)):n(t)}var wk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const El=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt,{ref:n,className:re("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));El.displayName=Vt.displayName;const Il=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(ce.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Vt.Input,{ref:n,className:re("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));Il.displayName=Vt.Input.displayName;const Nl=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt.List,{ref:n,className:re("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Nl.displayName=Vt.List.displayName;const Al=h.forwardRef((e,t)=>u.jsx(Vt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Al.displayName=Vt.Empty.displayName;const Pl=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt.Group,{ref:n,className:re("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Pl.displayName=Vt.Group.displayName;const bk=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt.Separator,{ref:n,className:re("-mx-1 h-px bg-border",e),...t}));bk.displayName=Vt.Separator.displayName;const jl=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt.Item,{ref:n,className:re("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));jl.displayName=Vt.Item.displayName;function _l(e,[t,n]){return Math.min(n,Math.max(t,e))}function yk(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Rl="ScrollArea",[rm,LN]=cn(Rl),[Sk,sn]=rm(Rl),om=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[p,m]=h.useState(null),[f,v]=h.useState(null),[g,x]=h.useState(null),[y,b]=h.useState(0),[C,k]=h.useState(0),[S,T]=h.useState(!1),[E,P]=h.useState(!1),_=De(t,L=>l(L)),$=Qo(o);return u.jsx(Sk,{scope:n,type:r,dir:$,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:p,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:P,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(fe.div,{dir:$,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});om.displayName=Rl;var sm="ScrollAreaViewport",im=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(sm,n),a=h.useRef(null),l=De(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.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}),u.jsx(fe.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});im.displayName=sm;var In="ScrollAreaScrollbar",Ml=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(Ck,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(Tk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(am,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Ol,{...r,ref:t}):null});Ml.displayName=In;var Ck=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ut,{present:n||s,children:u.jsx(am,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Tk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=si(()=>l("SCROLL_END"),100),[a,l]=yk("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 h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let p=c[d];const m=()=>{const f=c[d];p!==f&&(l("SCROLL"),i()),p=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Ut,{present:n||a!=="hidden",children:u.jsx(Ol,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ie(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ie(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),am=h.forwardRef((e,t)=>{const n=sn(In,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=si(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return zr(n.viewport,l),zr(n.content,l),u.jsx(Ut,{present:r||s,children:u.jsx(Ol,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ol=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(In,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=fm(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function p(m,f){return Pk(m,i.current,a,f)}return n==="horizontal"?u.jsx(kk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=pm(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?u.jsx(Ek,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=pm(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),kk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=De(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(cm,{"data-orientation":"horizontal",...o,ref:c,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":oi(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),mm(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:ri(i.paddingLeft),paddingEnd:ri(i.paddingRight)}})}})}),Ek=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=De(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(cm,{"data-orientation":"vertical",...o,ref:c,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":oi(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),mm(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:ri(i.paddingTop),paddingEnd:ri(i.paddingBottom)}})}})}),[Ik,lm]=rm(In),cm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:p,...m}=e,f=sn(In,n),[v,g]=h.useState(null),x=De(t,_=>g(_)),y=h.useRef(null),b=h.useRef(""),C=f.viewport,k=r.content-r.viewport,S=pt(d),T=pt(l),E=si(p,10);function P(_){if(y.current){const $=_.clientX-y.current.left,L=_.clientY-y.current.top;c({x:$,y:L})}}return h.useEffect(()=>{const _=$=>{const L=$.target;(v==null?void 0:v.contains(L))&&S($,k)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[C,v,k,S]),h.useEffect(T,[r,T]),zr(v,E),zr(f.content,E),u.jsx(Ik,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:pt(s),onThumbPointerUp:pt(i),onThumbPositionChange:T,onThumbPointerDown:pt(a),children:u.jsx(fe.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ie(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),P(_))}),onPointerMove:ie(e.onPointerMove,P),onPointerUp:ie(e.onPointerUp,_=>{const $=_.target;$.hasPointerCapture(_.pointerId)&&$.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),ni="ScrollAreaThumb",um=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=lm(ni,e.__scopeScrollArea);return u.jsx(Ut,{present:n||o.hasThumb,children:u.jsx(Nk,{ref:t,...r})})}),Nk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(ni,n),i=lm(ni,n),{onThumbPositionChange:a}=i,l=De(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=si(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(d(),!c.current){const f=jk(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(fe.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ie(e.onPointerDownCapture,p=>{const f=p.target.getBoundingClientRect(),v=p.clientX-f.left,g=p.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ie(e.onPointerUp,i.onThumbPointerUp)})});um.displayName=ni;var Dl="ScrollAreaCorner",dm=h.forwardRef((e,t)=>{const n=sn(Dl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Ak,{...e,ref:t}):null});dm.displayName=Dl;var Ak=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn(Dl,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return zr(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),zr(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(fe.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ri(e){return e?parseInt(e,10):0}function fm(e,t){const n=e/t;return isNaN(n)?0:n}function oi(e){const t=fm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Pk(e,t,n,r="ltr"){const o=oi(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,p=r==="ltr"?[0,d]:[d*-1,0];return hm([l,c],p)(e)}function pm(e,t,n="ltr"){const r=oi(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=_l(e,l);return hm([0,i],[0,a])(c)}function hm(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 mm(e,t){return e>0&&e<t}var jk=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function si(e,t){const n=pt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function zr(e,t){const n=pt(t);It(()=>{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 gm=om,_k=im,Rk=dm;const Ll=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(gm,{ref:r,className:re("relative overflow-hidden",e),...n,children:[u.jsx(_k,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(xm,{}),u.jsx(Rk,{})]}));Ll.displayName=gm.displayName;const xm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Ml,{ref:r,orientation:t,className:re("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:u.jsx(um,{className:"relative flex-1 rounded-full bg-border"})}));xm.displayName=Ml.displayName;const $l=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:re("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}));$l.displayName="Input";const Mk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Ok="bg-slate-700 border-slate-600 hover:bg-slate-600",Dk="bg-slate-600 border-slate-500";function vm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:p,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const b=n===e.threadId,C=t?`${y??Dk}`:`${x??Ok}`,k=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Mk} ${C}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:b?u.jsxs("div",{className:"flex items-center gap-2",onClick:S=>S.stopPropagation(),children:[u.jsx($l,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ce.Check,{size:12})}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ce.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(ce.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Je,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ce.MoreHorizontal,{size:12})})}),u.jsxs(mo,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Fn,{onClick:S=>{S.preventDefault(),c(e.threadId)},children:[u.jsx(ce.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(Fn,{onClick:S=>{S.preventDefault(),s(e,S)},children:[u.jsx(ce.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Fn,{className:"text-red-400 hover:text-red-300",onClick:S=>{S.preventDefault(),d(e.threadId,S)},children:[u.jsx(ce.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const wm=25,bm="thread-manager-view",Lk=e=>e==="default"||e==="shared",$k=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(bm);if(Lk(e))return e}catch{}return null};function ym({defaultView:e}={}){const[t,n]=w.useState(()=>$k()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(bm,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Fk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ii({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:p,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:b,shareTargetFilter:C}){const{threads:k,sharedThreads:S,currentThreadId:T,setCurrentThreadId:E,isLoading:P,isLoadingSharedThreads:_,actions:$,shareInFlight:L,shareStatus:F,clearShareStatus:G}=br(),{createThread:O,deleteThread:K,renameThread:q,shareThread:H}=$,{loadThread:j}=no(),I=i??T,[Y,J]=w.useState(Array.isArray(k)?k:[]),D=w.useRef(Y.length>0),V=w.useRef(null),R=w.useRef(0),[B,X]=w.useState(null),[N,M]=w.useState(""),[U,Z]=w.useState(!1),[se,ae]=w.useState(!1),[Ce,we]=w.useState(null),[je,We]=w.useState(""),Fe=v&&v.length>0?v:Fk,Ye=ym({defaultView:m}),He=g??Ye,vt=p??He.view,wt=w.useCallback(ne=>{p||He.setView(ne),f==null||f(ne)},[p,f,He]),dt=Fe.find(ne=>ne.key===vt)??Fe[0],Ve=ne=>{we(ne),We(""),ae(!0)},Ae=()=>{ae(!1),we(null),We(""),G()},Ke=w.useCallback(async ne=>{if(!(!Ce||L)&&ne.id)try{await H(Ce,ne.id),setTimeout(()=>Ae(),600)}catch(he){console.error("Failed to share thread:",he)}},[Ae,L,Ce,H]),_e=w.useMemo(()=>{const ne=y??[],he=je.trim().toLowerCase();return he?C?ne.filter(tt=>C(tt,he)):ne.filter(tt=>`${tt.label} ${tt.secondaryLabel??""}`.toLowerCase().includes(he)):ne},[y,je,C]),Be=vt==="shared",Qe=Be?S:Y,Nt=Be?_:P,et=Be?"No shared conversations yet":"No conversations yet",bt=ne=>{const he=ne.sharedAt?` • ${Ue(ne.sharedAt)}`:"";return`Shared by ${ne.sharedByUserId}${he}`},mt=ne=>"sharedByUserId"in ne;w.useEffect(()=>{const ne=Array.isArray(k)?k:[];if(ne.length>0){D.current=!0,J(ne);return}P||(D.current=!1,J(ne))},[k,P]),w.useEffect(()=>{if(!V.current)return;const ne=V.current.querySelector("[data-radix-scroll-area-viewport]");if(!ne)return;let he=null,tt=null;return he=requestAnimationFrame(()=>{tt=requestAnimationFrame(()=>{ne.scrollTop=R.current})}),()=>{he!==null&&cancelAnimationFrame(he),tt!==null&&cancelAnimationFrame(tt)}},[Y]);const Ct=async ne=>{try{E(ne),await j(ne),a==null||a(ne),l==null||l(ne)}catch(he){console.error("Failed to select thread:",he)}},Tt=async()=>{try{Z(!0);const ne=await O();ne&&(c==null||c(ne),a==null||a(ne))}catch(ne){console.error("Failed to create thread:",ne)}finally{Z(!1)}},Dt=async(ne,he)=>{if(he.stopPropagation(),!!confirm("Delete this thread?")){if(V.current){const tt=V.current.querySelector("[data-radix-scroll-area-viewport]");tt&&(R.current=tt.scrollTop)}try{await K(ne),d==null||d(ne)}catch(tt){console.error("Failed to delete thread:",tt)}}},Pt=(ne,he)=>{he.stopPropagation(),X(ne.threadId),M(ne.title||`Thread ${ne.threadId.slice(0,8)}`)},kt=async ne=>{if(N.trim())try{await q(ne,N.trim()),X(null),M("")}catch(he){console.error("Failed to update title:",he)}},qt=()=>{X(null),M("")},Ue=ne=>{if(!ne)return"";try{const he=new Date(ne),me=new Date().getTime()-he.getTime(),Oe=Math.floor(me/(1e3*60*60*24));return Oe===0?he.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Oe===1?"Yesterday":Oe<7?`${Oe} days ago`:he.toLocaleDateString()}catch{return""}},$e=ne=>ne.title||`Thread ${ne.threadId.slice(0,8)}`,ct=ne=>{const he=$e(ne);return he.length<=wm?he:`${he.slice(0,wm)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(Je,{onClick:Tt,disabled:U||P,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:U?"Creating...":"New Chat",children:[u.jsx(ce.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Je,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:dt.label})}),u.jsx(mo,{align:"start",sideOffset:6,className:"w-40",children:Fe.map(ne=>u.jsxs(Fn,{className:"justify-between text-[12px]",onClick:he=>{he.preventDefault(),wt(ne.key)},children:[u.jsx("span",{children:ne.label}),vt===ne.key&&u.jsx(ce.Check,{className:"h-3 w-3"})]},ne.key))})]})]})]}),u.jsx(Ll,{ref:V,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:Nt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ce.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):Qe.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ce.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:et})]}):Qe.slice().sort((ne,he)=>new Date(he.updatedAt||he.createdAt||"").getTime()-new Date(ne.updatedAt||ne.createdAt||"").getTime()).map(ne=>u.jsx(vm,{thread:ne,isActive:I===ne.threadId,editingThreadId:B,editingTitle:N,onSelect:Ct,onStartEditing:Pt,onEditingTitleChange:he=>M(he),onSaveEditing:kt,onCancelEditing:qt,onShare:()=>Ve(ne.threadId),onDelete:Dt,showEditTitle:r,showDeleteButton:n,formatDate:Ue,getDisplayThreadTitle:ct,secondaryLine:Be&&mt(ne)?bt(ne):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},ne.threadId))})}),u.jsx(il,{open:se,onOpenChange:ne=>!ne&&Ae(),children:u.jsxs(Us,{className:"max-w-md p-0",children:[u.jsx(Ws,{children:u.jsx(Vs,{children:"Share thread"})}),u.jsxs(El,{children:[u.jsx(Il,{autoFocus:!0,value:je,onValueChange:ne=>We(ne),placeholder:"Search for recipients..."}),u.jsxs(Nl,{children:[F&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[L&&u.jsx(ce.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:F.startsWith("Failed")?"text-red-500":F.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:F})]}),u.jsx(Al,{children:b?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ce.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),_e.length>0&&u.jsx(Pl,{heading:"Recipients",children:_e.map(ne=>u.jsx(jl,{onSelect:()=>Ke(ne),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:ne.label}),ne.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:ne.secondaryLabel})]})},ne.id))})]})]})]})})]})}function Bk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=w.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(Cr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx($r,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Cr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ii,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx($r,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Cr,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ii,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx($r,{onError:s.onError,enableFileUpload:!0})})]})})}function zk({apiConfig:e,className:t="",onError:n}){return u.jsx(Cr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx($r,{})})})}function Hk({placeholder:e,onMessageSent:t}){const[n,r]=w.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ce.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ce.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx($r,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ii,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Uk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=w.useState(!1);return n?u.jsx(Cr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Je,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(ce.MoreHorizontal,{size:16})}),u.jsx(Je,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(ce.Edit3,{size:16})}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(ce.Maximize2,{size:14}):u.jsx(ce.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(Hk,{placeholder:t,onMessageSent:r})})]})})}):null}function Wk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Je,{variant:r,size:o,className:re("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(ce.Edit3,{size:16}),t??e]})}var Vk="Label",Sm=h.forwardRef((e,t)=>u.jsx(fe.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())}}));Sm.displayName=Vk;var Cm=Sm;const Kk=Vr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Tm=h.forwardRef(({className:e,...t},n)=>u.jsx(Cm,{ref:n,className:re(Kk(),e),...t}));Tm.displayName=Cm.displayName;function km(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Em=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"}),qk="VisuallyHidden",ai=h.forwardRef((e,t)=>u.jsx(fe.span,{...e,ref:t,style:{...Em,...e.style}}));ai.displayName=qk;var Gk=ai,Yk=[" ","Enter","ArrowUp","ArrowDown"],Xk=[" ","Enter"],hr="Select",[li,ci,Jk]=Zo(hr),[Hr,$N]=cn(hr,[Jk,Pr]),ui=Pr(),[Zk,qn]=Hr(hr),[Qk,eE]=Hr(hr),Im=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:p,disabled:m,required:f,form:v}=e,g=ui(t),[x,y]=h.useState(null),[b,C]=h.useState(null),[k,S]=h.useState(!1),T=Qo(c),[E,P]=On({prop:r,defaultProp:o??!1,onChange:s,caller:hr}),[_,$]=On({prop:i,defaultProp:a,onChange:l,caller:hr}),L=h.useRef(null),F=x?v||!!x.closest("form"):!0,[G,O]=h.useState(new Set),K=Array.from(G).map(q=>q.props.value).join(";");return u.jsx(da,{...g,children:u.jsxs(Zk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:_t(),value:_,onValueChange:$,open:E,onOpenChange:P,dir:T,triggerPointerDownPosRef:L,disabled:m,children:[u.jsx(li.Provider,{scope:t,children:u.jsx(Qk,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(q=>{O(H=>new Set(H).add(q))},[]),onNativeOptionRemove:h.useCallback(q=>{O(H=>{const j=new Set(H);return j.delete(q),j})},[]),children:n})}),F?u.jsxs(Jm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:_,onChange:q=>$(q.target.value),disabled:m,form:v,children:[_===void 0?u.jsx("option",{value:""}):null,Array.from(G)]},K):null]})})};Im.displayName=hr;var Nm="SelectTrigger",Am=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ui(n),i=qn(Nm,n),a=i.disabled||r,l=De(t,i.onTriggerChange),c=ci(n),d=h.useRef("touch"),[p,m,f]=Qm(g=>{const x=c().filter(C=>!C.disabled),y=x.find(C=>C.value===i.value),b=eg(x,g,y);b!==void 0&&i.onValueChange(b.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(fa,{asChild:!0,...s,children:u.jsx(fe.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Zm(i.value)?"":void 0,...o,ref:l,onClick:ie(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ie(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:ie(o.onKeyDown,g=>{const x=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Yk.includes(g.key)&&(v(),g.preventDefault())})})})});Am.displayName=Nm;var Pm="SelectValue",jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=qn(Pm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=De(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(fe.span,{...a,ref:p,style:{pointerEvents:"none"},children:Zm(l.value)?u.jsx(u.Fragment,{children:i}):s})});jm.displayName=Pm;var tE="SelectIcon",_m=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(fe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});_m.displayName=tE;var nE="SelectPortal",Rm=e=>u.jsx(ao,{asChild:!0,...e});Rm.displayName=nE;var mr="SelectContent",Mm=h.forwardRef((e,t)=>{const n=qn(mr,e.__scopeSelect),[r,o]=h.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Kr.createPortal(u.jsx(Om,{scope:e.__scopeSelect,children:u.jsx(li.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Dm,{...e,ref:t})});Mm.displayName=mr;var mn=10,[Om,Gn]=Hr(mr),rE="SelectContentImpl",oE=Yt.createSlot("SelectContent.RemoveScroll"),Dm=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,b=qn(mr,n),[C,k]=h.useState(null),[S,T]=h.useState(null),E=De(t,N=>k(N)),[P,_]=h.useState(null),[$,L]=h.useState(null),F=ci(n),[G,O]=h.useState(!1),K=h.useRef(!1);h.useEffect(()=>{if(C)return va(C)},[C]),Yi();const q=h.useCallback(N=>{const[M,...U]=F().map(ae=>ae.ref.current),[Z]=U.slice(-1),se=document.activeElement;for(const ae of N)if(ae===se||(ae==null||ae.scrollIntoView({block:"nearest"}),ae===M&&S&&(S.scrollTop=0),ae===Z&&S&&(S.scrollTop=S.scrollHeight),ae==null||ae.focus(),document.activeElement!==se))return},[F,S]),H=h.useCallback(()=>q([P,C]),[q,P,C]);h.useEffect(()=>{G&&H()},[G,H]);const{onOpenChange:j,triggerPointerDownPosRef:I}=b;h.useEffect(()=>{if(C){let N={x:0,y:0};const M=Z=>{var se,ae;N={x:Math.abs(Math.round(Z.pageX)-(((se=I.current)==null?void 0:se.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((ae=I.current)==null?void 0:ae.y)??0))}},U=Z=>{N.x<=10&&N.y<=10?Z.preventDefault():C.contains(Z.target)||j(!1),document.removeEventListener("pointermove",M),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",M),document.addEventListener("pointerup",U,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",U,{capture:!0})}}},[C,j,I]),h.useEffect(()=>{const N=()=>j(!1);return window.addEventListener("blur",N),window.addEventListener("resize",N),()=>{window.removeEventListener("blur",N),window.removeEventListener("resize",N)}},[j]);const[Y,J]=Qm(N=>{const M=F().filter(se=>!se.disabled),U=M.find(se=>se.ref.current===document.activeElement),Z=eg(M,N,U);Z&&setTimeout(()=>Z.ref.current.focus())}),D=h.useCallback((N,M,U)=>{const Z=!K.current&&!U;(b.value!==void 0&&b.value===M||Z)&&(_(N),Z&&(K.current=!0))},[b.value]),V=h.useCallback(()=>C==null?void 0:C.focus(),[C]),R=h.useCallback((N,M,U)=>{const Z=!K.current&&!U;(b.value!==void 0&&b.value===M||Z)&&L(N)},[b.value]),B=r==="popper"?Fl:Lm,X=B===Fl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Om,{scope:n,content:C,viewport:S,onViewportChange:T,itemRefCallback:D,selectedItem:P,onItemLeave:V,itemTextRefCallback:R,focusSelectedItem:H,selectedItemText:$,position:r,isPositioned:G,searchRef:Y,children:u.jsx(ws,{as:oE,allowPinchZoom:!0,children:u.jsx(es,{asChild:!0,trapped:b.open,onMountAutoFocus:N=>{N.preventDefault()},onUnmountAutoFocus:ie(o,N=>{var M;(M=b.trigger)==null||M.focus({preventScroll:!0}),N.preventDefault()}),children:u.jsx(kr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:N=>N.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(B,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:N=>N.preventDefault(),...y,...X,onPlaced:()=>O(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ie(y.onKeyDown,N=>{const M=N.ctrlKey||N.altKey||N.metaKey;if(N.key==="Tab"&&N.preventDefault(),!M&&N.key.length===1&&J(N.key),["ArrowUp","ArrowDown","Home","End"].includes(N.key)){let Z=F().filter(se=>!se.disabled).map(se=>se.ref.current);if(["ArrowUp","End"].includes(N.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(N.key)){const se=N.target,ae=Z.indexOf(se);Z=Z.slice(ae+1)}setTimeout(()=>q(Z)),N.preventDefault()}})})})})})})});Dm.displayName=rE;var sE="SelectItemAlignedPosition",Lm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=qn(mr,n),i=Gn(mr,n),[a,l]=h.useState(null),[c,d]=h.useState(null),p=De(t,E=>d(E)),m=ci(n),f=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,C=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),P=c.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),$=y.getBoundingClientRect();if(s.dir!=="rtl"){const se=$.left-P.left,ae=_.left-se,Ce=E.left-ae,we=E.width+Ce,je=Math.max(we,P.width),We=window.innerWidth-mn,Fe=_l(ae,[mn,Math.max(mn,We-je)]);a.style.minWidth=we+"px",a.style.left=Fe+"px"}else{const se=P.right-$.right,ae=window.innerWidth-_.right-se,Ce=window.innerWidth-E.right-ae,we=E.width+Ce,je=Math.max(we,P.width),We=window.innerWidth-mn,Fe=_l(ae,[mn,Math.max(mn,We-je)]);a.style.minWidth=we+"px",a.style.right=Fe+"px"}const L=m(),F=window.innerHeight-mn*2,G=g.scrollHeight,O=window.getComputedStyle(c),K=parseInt(O.borderTopWidth,10),q=parseInt(O.paddingTop,10),H=parseInt(O.borderBottomWidth,10),j=parseInt(O.paddingBottom,10),I=K+q+G+j+H,Y=Math.min(x.offsetHeight*5,I),J=window.getComputedStyle(g),D=parseInt(J.paddingTop,10),V=parseInt(J.paddingBottom,10),R=E.top+E.height/2-mn,B=F-R,X=x.offsetHeight/2,N=x.offsetTop+X,M=K+q+N,U=I-M;if(M<=R){const se=L.length>0&&x===L[L.length-1].ref.current;a.style.bottom="0px";const ae=c.clientHeight-g.offsetTop-g.offsetHeight,Ce=Math.max(B,X+(se?V:0)+ae+H),we=M+Ce;a.style.height=we+"px"}else{const se=L.length>0&&x===L[0].ref.current;a.style.top="0px";const Ce=Math.max(R,K+g.offsetTop+(se?D:0)+X)+U;a.style.height=Ce+"px",g.scrollTop=M-R+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=Y+"px",a.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);It(()=>C(),[C]);const[k,S]=h.useState();It(()=>{c&&S(window.getComputedStyle(c).zIndex)},[c]);const T=h.useCallback(E=>{E&&v.current===!0&&(C(),b==null||b(),v.current=!1)},[C,b]);return u.jsx(aE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(fe.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Lm.displayName=sE;var iE="SelectPopperPosition",Fl=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=ui(n);return u.jsx(pa,{...i,...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)"}})});Fl.displayName=iE;var[aE,Bl]=Hr(mr,{}),zl="SelectViewport",$m=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Gn(zl,n),i=Bl(zl,n),a=De(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.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}),u.jsx(li.Slot,{scope:n,children:u.jsx(fe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ie(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-mn*2,g=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),y=Math.max(g,x);if(y<v){const b=y+f,C=Math.min(v,b),k=b-C;p.style.height=C+"px",p.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,p.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});$m.displayName=zl;var Fm="SelectGroup",[lE,cE]=Hr(Fm),uE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_t();return u.jsx(lE,{scope:n,id:o,children:u.jsx(fe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});uE.displayName=Fm;var Bm="SelectLabel",zm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=cE(Bm,n);return u.jsx(fe.div,{id:o.id,...r,ref:t})});zm.displayName=Bm;var di="SelectItem",[dE,Hm]=Hr(di),Um=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=qn(di,n),l=Gn(di,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),v=De(t,b=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,b,r,o)}),g=_t(),x=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.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 u.jsx(dE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(b=>{p(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(li.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(fe.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ie(i.onFocus,()=>f(!0)),onBlur:ie(i.onBlur,()=>f(!1)),onClick:ie(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ie(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ie(i.onPointerDown,b=>{x.current=b.pointerType}),onPointerMove:ie(i.onPointerMove,b=>{var C;x.current=b.pointerType,o?(C=l.onItemLeave)==null||C.call(l):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ie(i.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:ie(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(Xk.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Um.displayName=di;var _o="SelectItemText",Wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=qn(_o,n),a=Gn(_o,n),l=Hm(_o,n),c=eE(_o,n),[d,p]=h.useState(null),m=De(t,y=>p(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return It(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(fe.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Kr.createPortal(s.children,i.valueNode):null]})});Wm.displayName=_o;var Vm="SelectItemIndicator",Km=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Hm(Vm,n).isSelected?u.jsx(fe.span,{"aria-hidden":!0,...r,ref:t}):null});Km.displayName=Vm;var Hl="SelectScrollUpButton",qm=h.forwardRef((e,t)=>{const n=Gn(Hl,e.__scopeSelect),r=Bl(Hl,e.__scopeSelect),[o,s]=h.useState(!1),i=De(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Ym,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});qm.displayName=Hl;var Ul="SelectScrollDownButton",Gm=h.forwardRef((e,t)=>{const n=Gn(Ul,e.__scopeSelect),r=Bl(Ul,e.__scopeSelect),[o,s]=h.useState(!1),i=De(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Ym,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Gm.displayName=Ul;var Ym=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Gn("SelectScrollButton",n),i=h.useRef(null),a=ci(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=a().find(p=>p.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(fe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ie(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ie(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ie(o.onPointerLeave,()=>{l()})})}),fE="SelectSeparator",Xm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(fe.div,{"aria-hidden":!0,...r,ref:t})});Xm.displayName=fE;var Wl="SelectArrow",pE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ui(n),s=qn(Wl,n),i=Gn(Wl,n);return s.open&&i.position==="popper"?u.jsx(ha,{...o,...r,ref:t}):null});pE.displayName=Wl;var hE="SelectBubbleInput",Jm=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=De(r,o),i=km(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const p=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(p)}},[i,t]),u.jsx(fe.select,{...n,style:{...Em,...n.style},ref:s,defaultValue:t})});Jm.displayName=hE;function Zm(e){return e===""||e===void 0}function Qm(e){const t=pt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function eg(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=mE(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function mE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var gE=Im,tg=Am,xE=jm,vE=_m,wE=Rm,ng=Mm,bE=$m,rg=zm,og=Um,yE=Wm,SE=Km,sg=qm,ig=Gm,ag=Xm;const CE=gE,TE=xE,lg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(tg,{ref:r,className:re("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,u.jsx(vE,{asChild:!0,children:u.jsx(ce.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));lg.displayName=tg.displayName;const cg=h.forwardRef(({className:e,...t},n)=>u.jsx(sg,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ce.ChevronUp,{className:"h-4 w-4"})}));cg.displayName=sg.displayName;const ug=h.forwardRef(({className:e,...t},n)=>u.jsx(ig,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ce.ChevronDown,{className:"h-4 w-4"})}));ug.displayName=ig.displayName;const dg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(wE,{children:u.jsxs(ng,{ref:o,className:re("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:[u.jsx(cg,{}),u.jsx(bE,{className:re("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(ug,{})]})}));dg.displayName=ng.displayName;const kE=h.forwardRef(({className:e,...t},n)=>u.jsx(rg,{ref:n,className:re("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));kE.displayName=rg.displayName;const fg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(og,{ref:r,className:re("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:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(SE,{children:u.jsx(ce.Check,{className:"h-4 w-4"})})}),u.jsx(yE,{children:t})]}));fg.displayName=og.displayName;const EE=h.forwardRef(({className:e,...t},n)=>u.jsx(ag,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));EE.displayName=ag.displayName;var IE="Separator",pg="horizontal",NE=["horizontal","vertical"],hg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=pg,...o}=e,s=AE(r)?r:pg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(fe.div,{"data-orientation":s,...a,...o,ref:t})});hg.displayName=IE;function AE(e){return NE.includes(e)}var mg=hg;const gg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(mg,{ref:o,decorative:n,orientation:t,className:re("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));gg.displayName=mg.displayName;var fi="Switch",[PE,FN]=cn(fi),[jE,_E]=PE(fi),xg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...p}=e,[m,f]=h.useState(null),v=De(t,C=>f(C)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=On({prop:o,defaultProp:s??!1,onChange:c,caller:fi});return u.jsxs(jE,{scope:n,checked:y,disabled:a,children:[u.jsx(fe.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":yg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:v,onClick:ie(e.onClick,C=>{b(k=>!k),x&&(g.current=C.isPropagationStopped(),g.current||C.stopPropagation())})}),x&&u.jsx(bg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});xg.displayName=fi;var vg="SwitchThumb",wg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=_E(vg,n);return u.jsx(fe.span,{"data-state":yg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});wg.displayName=vg;var RE="SwitchBubbleInput",bg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=De(i,s),l=km(n),c=jd(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});bg.displayName=RE;function yg(e){return e?"checked":"unchecked"}var Sg=xg,ME=wg;const Cg=h.forwardRef(({className:e,...t},n)=>u.jsx(Sg,{className:re("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:u.jsx(ME,{className:re("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")})}));Cg.displayName=Sg.displayName;const OE=ol,DE=fT,LE=sl,Tg=h.forwardRef(({className:e,...t},n)=>u.jsx(Eo,{className:re("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}));Tg.displayName=Eo.displayName;const $E=Vr.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"}}),kg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(LE,{children:[u.jsx(Tg,{}),u.jsxs(Io,{ref:o,className:re($E({side:e}),t),...r,children:[n,u.jsxs(xh,{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:[u.jsx(ce.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));kg.displayName=Io.displayName;const Eg=({className:e,...t})=>u.jsx("div",{className:re("flex flex-col space-y-2 text-center sm:text-left",e),...t});Eg.displayName="SheetHeader";const Ig=h.forwardRef(({className:e,...t},n)=>u.jsx(ur,{ref:n,className:re("text-lg font-semibold text-foreground",e),...t}));Ig.displayName=ur.displayName;const Ng=h.forwardRef(({className:e,...t},n)=>u.jsx(Hs,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Ng.displayName=Hs.displayName;var[pi,BN]=cn("Tooltip",[Pr]),hi=Pr(),Ag="TooltipProvider",FE=700,Vl="tooltip.open",[BE,Kl]=pi(Ag),Pg=e=>{const{__scopeTooltip:t,delayDuration:n=FE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(BE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};Pg.displayName=Ag;var Ro="Tooltip",[zE,mi]=pi(Ro),jg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Kl(Ro,e.__scopeTooltip),c=hi(t),[d,p]=h.useState(null),m=_t(),f=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,b]=On({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Vl))):l.onClose(),s==null||s(E)},caller:Ro}),C=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,b(!0)},[b]),S=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b(!1)},[b]),T=h.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,b(!0),f.current=0},g)},[g,b]);return h.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(da,{...c,children:u.jsx(zE,{scope:t,contentId:m,open:y,stateAttribute:C,trigger:d,onTriggerChange:p,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:h.useCallback(()=>{v?S():(window.clearTimeout(f.current),f.current=0)},[S,v]),onOpen:k,onClose:S,disableHoverableContent:v,children:n})})};jg.displayName=Ro;var ql="TooltipTrigger",_g=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=mi(ql,n),s=Kl(ql,n),i=hi(n),a=h.useRef(null),l=De(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),p=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),u.jsx(fa,{asChild:!0,...i,children:u.jsx(fe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ie(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ie(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ie(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ie(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ie(e.onBlur,o.onClose),onClick:ie(e.onClick,o.onClose)})})});_g.displayName=ql;var HE="TooltipPortal",[zN,UE]=pi(HE,{forceMount:void 0}),Ur="TooltipContent",Rg=h.forwardRef((e,t)=>{const n=UE(Ur,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=mi(Ur,e.__scopeTooltip);return u.jsx(Ut,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Mg,{side:o,...s,ref:t}):u.jsx(WE,{side:o,...s,ref:t})})}),WE=h.forwardRef((e,t)=>{const n=mi(Ur,e.__scopeTooltip),r=Kl(Ur,e.__scopeTooltip),o=h.useRef(null),s=De(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:p}=r,m=h.useCallback(()=>{a(null),p(!1)},[p]),f=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},b=YE(y,x.getBoundingClientRect()),C=XE(y,b),k=JE(g.getBoundingClientRect()),S=QE([...C,...k]);a(S),p(!0)},[p]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},b=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),C=!ZE(y,i);b?m():C&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Mg,{...e,ref:s})}),[VE,KE]=pi(Ro,{isInside:!1}),qE=Yt.createSlottable("TooltipContent"),Mg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=mi(Ur,n),c=hi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Vl,d),()=>document.removeEventListener(Vl,d)),[d]),h.useEffect(()=>{if(l.trigger){const p=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[l.trigger,d]),u.jsx(kr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(pa,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.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:[u.jsx(qE,{children:r}),u.jsx(VE,{scope:n,isInside:!0,children:u.jsx(Gk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Rg.displayName=Ur;var Og="TooltipArrow",GE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hi(n);return KE(Og,n).isInside?null:u.jsx(ha,{...o,...r,ref:t})});GE.displayName=Og;function YE(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 XE(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 JE(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 ZE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function QE(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),eI(t)}function eI(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],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.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],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.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 tI=Pg,nI=jg,rI=_g,Dg=Rg;const oI=tI,sI=nI,iI=rI,Lg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Dg,{ref:r,sideOffset:t,className:re("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}));Lg.displayName=Dg.displayName;var Gl="ToastProvider",[Yl,aI,lI]=Zo("Toast"),[$g,HN]=cn("Toast",[lI]),[cI,gi]=$g(Gl),Fg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),p=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Gl}\`. Expected non-empty \`string\`.`),u.jsx(Yl.Provider,{scope:t,children:u.jsx(cI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(f=>f+1),[]),onToastRemove:h.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:m,children:i})})};Fg.displayName=Gl;var Bg="ToastViewport",uI=["F8"],Xl="toast.viewportPause",Jl="toast.viewportResume",zg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=uI,label:o="Notifications ({hotkey})",...s}=e,i=gi(Bg,n),a=aI(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=De(t,p,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var C;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((C=p.current)==null||C.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=p.current;if(v&&x&&y){const b=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Xl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},C=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Jl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&C()},S=()=>{x.contains(document.activeElement)||C()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",S),window.addEventListener("blur",b),window.addEventListener("focus",C),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",S),window.removeEventListener("blur",b),window.removeEventListener("focus",C)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const b=a().map(C=>{const k=C.ref.current,S=[k,...CI(k)];return x==="forwards"?S:S.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return h.useEffect(()=>{const x=p.current;if(x){const y=b=>{var S,T,E;const C=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!C){const P=document.activeElement,_=b.shiftKey;if(b.target===x&&_){(S=c.current)==null||S.focus();return}const F=g({tabbingDirection:_?"backwards":"forwards"}),G=F.findIndex(O=>O===P);ec(F.slice(G+1))?b.preventDefault():_?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Bw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Zl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});ec(x)}}),u.jsx(Yl.Slot,{scope:n,children:u.jsx(fe.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Zl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});ec(x)}})]})});zg.displayName=Bg;var Hg="ToastFocusProxy",Zl=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=gi(Hg,n);return u.jsx(ai,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Zl.displayName=Hg;var Mo="Toast",dI="toast.swipeStart",fI="toast.swipeMove",pI="toast.swipeCancel",hI="toast.swipeEnd",Ug=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=On({prop:r,defaultProp:o??!0,onChange:s,caller:Mo});return u.jsx(Ut,{present:n||a,children:u.jsx(xI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:pt(e.onPause),onResume:pt(e.onResume),onSwipeStart:ie(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ie(e.onSwipeMove,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${p}px`)}),onSwipeCancel:ie(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ie(e.onSwipeEnd,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${p}px`),l(!1)})})})});Ug.displayName=Mo;var[mI,gI]=$g(Mo,{onClose(){}}),xI=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:p,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=gi(Mo,n),[x,y]=h.useState(null),b=De(t,O=>y(O)),C=h.useRef(null),k=h.useRef(null),S=o||g.duration,T=h.useRef(0),E=h.useRef(S),P=h.useRef(0),{onToastAdd:_,onToastRemove:$}=g,L=pt(()=>{var K;(x==null?void 0:x.contains(document.activeElement))&&((K=g.viewport)==null||K.focus()),i()}),F=h.useCallback(O=>{!O||O===1/0||(window.clearTimeout(P.current),T.current=new Date().getTime(),P.current=window.setTimeout(L,O))},[L]);h.useEffect(()=>{const O=g.viewport;if(O){const K=()=>{F(E.current),c==null||c()},q=()=>{const H=new Date().getTime()-T.current;E.current=E.current-H,window.clearTimeout(P.current),l==null||l()};return O.addEventListener(Xl,q),O.addEventListener(Jl,K),()=>{O.removeEventListener(Xl,q),O.removeEventListener(Jl,K)}}},[g.viewport,S,l,c,F]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&F(S)},[s,S,g.isClosePausedRef,F]),h.useEffect(()=>(_(),()=>$()),[_,$]);const G=h.useMemo(()=>x?Xg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[G&&u.jsx(vI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:G}),u.jsx(mI,{scope:n,onClose:L,children:Kr.createPortal(u.jsx(Yl.ItemSlot,{scope:n,children:u.jsx(Fw,{asChild:!0,onEscapeKeyDown:ie(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||L(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(fe.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ie(e.onKeyDown,O=>{O.key==="Escape"&&(a==null||a(O.nativeEvent),O.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,L()))}),onPointerDown:ie(e.onPointerDown,O=>{O.button===0&&(C.current={x:O.clientX,y:O.clientY})}),onPointerMove:ie(e.onPointerMove,O=>{if(!C.current)return;const K=O.clientX-C.current.x,q=O.clientY-C.current.y,H=!!k.current,j=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,Y=j?I(0,K):0,J=j?0:I(0,q),D=O.pointerType==="touch"?10:2,V={x:Y,y:J},R={originalEvent:O,delta:V};H?(k.current=V,xi(fI,p,R,{discrete:!1})):Jg(V,g.swipeDirection,D)?(k.current=V,xi(dI,d,R,{discrete:!1}),O.target.setPointerCapture(O.pointerId)):(Math.abs(K)>D||Math.abs(q)>D)&&(C.current=null)}),onPointerUp:ie(e.onPointerUp,O=>{const K=k.current,q=O.target;if(q.hasPointerCapture(O.pointerId)&&q.releasePointerCapture(O.pointerId),k.current=null,C.current=null,K){const H=O.currentTarget,j={originalEvent:O,delta:K};Jg(K,g.swipeDirection,g.swipeThreshold)?xi(hI,f,j,{discrete:!0}):xi(pI,m,j,{discrete:!0}),H.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),vI=e=>{const{__scopeToast:t,children:n,...r}=e,o=gi(Mo,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return yI(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(ao,{asChild:!0,children:u.jsx(ai,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},wI="ToastTitle",Wg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(fe.div,{...r,ref:t})});Wg.displayName=wI;var bI="ToastDescription",Vg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(fe.div,{...r,ref:t})});Vg.displayName=bI;var Kg="ToastAction",qg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Yg,{altText:n,asChild:!0,children:u.jsx(Ql,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Kg}\`. Expected non-empty \`string\`.`),null)});qg.displayName=Kg;var Gg="ToastClose",Ql=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=gI(Gg,n);return u.jsx(Yg,{asChild:!0,children:u.jsx(fe.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,o.onClose)})})});Ql.displayName=Gg;var Yg=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(fe.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Xg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),SI(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...Xg(r))}}),t}function xi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Ki(o,s):o.dispatchEvent(s)}var Jg=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function yI(e=()=>{}){const t=pt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function SI(e){return e.nodeType===e.ELEMENT_NODE}function CI(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 ec(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var TI=Fg,Zg=zg,Qg=Ug,ex=Wg,tx=Vg,nx=qg,rx=Ql;const kI=TI,ox=h.forwardRef(({className:e,...t},n)=>u.jsx(Zg,{ref:n,className:re("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));ox.displayName=Zg.displayName;const EI=Vr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),sx=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Qg,{ref:r,className:re(EI({variant:t}),e),...n}));sx.displayName=Qg.displayName;const II=h.forwardRef(({className:e,...t},n)=>u.jsx(nx,{ref:n,className:re("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));II.displayName=nx.displayName;const ix=h.forwardRef(({className:e,...t},n)=>u.jsx(rx,{ref:n,className:re("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(ce.X,{className:"h-4 w-4"})}));ix.displayName=rx.displayName;const ax=h.forwardRef(({className:e,...t},n)=>u.jsx(ex,{ref:n,className:re("text-sm font-semibold",e),...t}));ax.displayName=ex.displayName;const lx=h.forwardRef(({className:e,...t},n)=>u.jsx(tx,{ref:n,className:re("text-sm opacity-90",e),...t}));lx.displayName=tx.displayName;function NI(){const{toasts:e}=cl();return u.jsxs(kI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(sx,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(ax,{children:n}),r&&u.jsx(lx,{children:r})]}),o,u.jsx(ix,{})]},t)}),u.jsx(ox,{})]})}var AI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),p(f)}function p(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},PI=h.createContext(void 0),jI={setTheme:e=>{},themes:[]},_I=()=>{var e;return(e=h.useContext(PI))!=null?e:jI};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${AI.toString()})(${d})`}})});var RI=e=>{switch(e){case"success":return DI;case"info":return $I;case"warning":return LI;case"error":return FI;default:return null}},MI=Array(12).fill(0),OI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},MI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),DI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),LI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),$I=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),FI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),BI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},w.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),w.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),zI=()=>{let[e,t]=w.useState(document.hidden);return w.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},tc=1,HI=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:tc++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],w.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(WI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||tc++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Kt=new HI,UI=(e,t)=>{let n=(t==null?void 0:t.id)||tc++;return Kt.addToast({title:e,...t,id:n}),n},WI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",VI=UI,KI=()=>Kt.toasts,qI=()=>Kt.getActiveToasts();Object.assign(VI,{success:Kt.success,info:Kt.info,warning:Kt.warning,error:Kt.error,custom:Kt.custom,message:Kt.message,promise:Kt.promise,dismiss:Kt.dismiss,loading:Kt.loading},{getHistory:KI,getToasts:qI});function GI(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}GI(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
131
|
-
`);function vi(e){return e.label!==void 0}var YI=3,XI="32px",JI="16px",cx=4e3,ZI=356,QI=14,eN=20,tN=200;function gn(...e){return e.filter(Boolean).join(" ")}function nN(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var rN=e=>{var t,n,r,o,s,i,a,l,c,d,p;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:b,index:C,toasts:k,expanded:S,removeToast:T,defaultRichColors:E,closeButton:P,style:_,cancelButtonStyle:$,actionButtonStyle:L,className:F="",descriptionClassName:G="",duration:O,position:K,gap:q,loadingIcon:H,expandByDefault:j,classNames:I,icons:Y,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:D}=e,[V,R]=w.useState(null),[B,X]=w.useState(null),[N,M]=w.useState(!1),[U,Z]=w.useState(!1),[se,ae]=w.useState(!1),[Ce,we]=w.useState(!1),[je,We]=w.useState(!1),[Fe,Ye]=w.useState(0),[He,vt]=w.useState(0),wt=w.useRef(f.duration||O||cx),dt=w.useRef(null),Ve=w.useRef(null),Ae=C===0,Ke=C+1<=y,_e=f.type,Be=f.dismissible!==!1,Qe=f.className||"",Nt=f.descriptionClassName||"",et=w.useMemo(()=>b.findIndex(me=>me.toastId===f.id)||0,[b,f.id]),bt=w.useMemo(()=>{var me;return(me=f.closeButton)!=null?me:P},[f.closeButton,P]),mt=w.useMemo(()=>f.duration||O||cx,[f.duration,O]),Ct=w.useRef(0),Tt=w.useRef(0),Dt=w.useRef(0),Pt=w.useRef(null),[kt,qt]=K.split("-"),Ue=w.useMemo(()=>b.reduce((me,Oe,qe)=>qe>=et?me:me+Oe.height,0),[b,et]),$e=zI(),ct=f.invert||m,ne=_e==="loading";Tt.current=w.useMemo(()=>et*q+Ue,[et,Ue]),w.useEffect(()=>{wt.current=mt},[mt]),w.useEffect(()=>{M(!0)},[]),w.useEffect(()=>{let me=Ve.current;if(me){let Oe=me.getBoundingClientRect().height;return vt(Oe),x(qe=>[{toastId:f.id,height:Oe,position:f.position},...qe]),()=>x(qe=>qe.filter(ut=>ut.toastId!==f.id))}},[x,f.id]),w.useLayoutEffect(()=>{if(!N)return;let me=Ve.current,Oe=me.style.height;me.style.height="auto";let qe=me.getBoundingClientRect().height;me.style.height=Oe,vt(qe),x(ut=>ut.find(at=>at.toastId===f.id)?ut.map(at=>at.toastId===f.id?{...at,height:qe}:at):[{toastId:f.id,height:qe,position:f.position},...ut])},[N,f.title,f.description,x,f.id]);let he=w.useCallback(()=>{Z(!0),Ye(Tt.current),x(me=>me.filter(Oe=>Oe.toastId!==f.id)),setTimeout(()=>{T(f)},tN)},[f,T,x,Tt]);w.useEffect(()=>{if(f.promise&&_e==="loading"||f.duration===1/0||f.type==="loading")return;let me;return S||g||D&&$e?(()=>{if(Dt.current<Ct.current){let Oe=new Date().getTime()-Ct.current;wt.current=wt.current-Oe}Dt.current=new Date().getTime()})():wt.current!==1/0&&(Ct.current=new Date().getTime(),me=setTimeout(()=>{var Oe;(Oe=f.onAutoClose)==null||Oe.call(f,f),he()},wt.current)),()=>clearTimeout(me)},[S,g,f,_e,D,$e,he]),w.useEffect(()=>{f.delete&&he()},[he,f.delete]);function tt(){var me,Oe,qe;return Y!=null&&Y.loading?w.createElement("div",{className:gn(I==null?void 0:I.loader,(me=f==null?void 0:f.classNames)==null?void 0:me.loader,"sonner-loader"),"data-visible":_e==="loading"},Y.loading):H?w.createElement("div",{className:gn(I==null?void 0:I.loader,(Oe=f==null?void 0:f.classNames)==null?void 0:Oe.loader,"sonner-loader"),"data-visible":_e==="loading"},H):w.createElement(OI,{className:gn(I==null?void 0:I.loader,(qe=f==null?void 0:f.classNames)==null?void 0:qe.loader),visible:_e==="loading"})}return w.createElement("li",{tabIndex:0,ref:Ve,className:gn(F,Qe,I==null?void 0:I.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[_e],(n=f==null?void 0:f.classNames)==null?void 0:n[_e]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":N,"data-promise":!!f.promise,"data-swiped":je,"data-removed":U,"data-visible":Ke,"data-y-position":kt,"data-x-position":qt,"data-index":C,"data-front":Ae,"data-swiping":se,"data-dismissible":Be,"data-type":_e,"data-invert":ct,"data-swipe-out":Ce,"data-swipe-direction":B,"data-expanded":!!(S||j&&N),style:{"--index":C,"--toasts-before":C,"--z-index":k.length-C,"--offset":`${U?Fe:Tt.current}px`,"--initial-height":j?"auto":`${He}px`,..._,...f.style},onDragEnd:()=>{ae(!1),R(null),Pt.current=null},onPointerDown:me=>{ne||!Be||(dt.current=new Date,Ye(Tt.current),me.target.setPointerCapture(me.pointerId),me.target.tagName!=="BUTTON"&&(ae(!0),Pt.current={x:me.clientX,y:me.clientY}))},onPointerUp:()=>{var me,Oe,qe,ut;if(Ce||!Be)return;Pt.current=null;let at=Number(((me=Ve.current)==null?void 0:me.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),lt=Number(((Oe=Ve.current)==null?void 0:Oe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Et=new Date().getTime()-((qe=dt.current)==null?void 0:qe.getTime()),ke=V==="x"?at:lt,Ee=Math.abs(ke)/Et;if(Math.abs(ke)>=eN||Ee>.11){Ye(Tt.current),(ut=f.onDismiss)==null||ut.call(f,f),X(V==="x"?at>0?"right":"left":lt>0?"down":"up"),he(),we(!0),We(!1);return}ae(!1),R(null)},onPointerMove:me=>{var Oe,qe,ut,at;if(!Pt.current||!Be||((Oe=window.getSelection())==null?void 0:Oe.toString().length)>0)return;let lt=me.clientY-Pt.current.y,Et=me.clientX-Pt.current.x,ke=(qe=e.swipeDirections)!=null?qe:nN(K);!V&&(Math.abs(Et)>1||Math.abs(lt)>1)&&R(Math.abs(Et)>Math.abs(lt)?"x":"y");let Ee={x:0,y:0};V==="y"?(ke.includes("top")||ke.includes("bottom"))&&(ke.includes("top")&<<0||ke.includes("bottom")&<>0)&&(Ee.y=lt):V==="x"&&(ke.includes("left")||ke.includes("right"))&&(ke.includes("left")&&Et<0||ke.includes("right")&&Et>0)&&(Ee.x=Et),(Math.abs(Ee.x)>0||Math.abs(Ee.y)>0)&&We(!0),(ut=Ve.current)==null||ut.style.setProperty("--swipe-amount-x",`${Ee.x}px`),(at=Ve.current)==null||at.style.setProperty("--swipe-amount-y",`${Ee.y}px`)}},bt&&!f.jsx?w.createElement("button",{"aria-label":J,"data-disabled":ne,"data-close-button":!0,onClick:ne||!Be?()=>{}:()=>{var me;he(),(me=f.onDismiss)==null||me.call(f,f)},className:gn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=Y==null?void 0:Y.close)!=null?s:BI):null,f.jsx||w.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:w.createElement(w.Fragment,null,_e||f.icon||f.promise?w.createElement("div",{"data-icon":"",className:gn(I==null?void 0:I.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||tt():null,f.type!=="loading"?f.icon||(Y==null?void 0:Y[_e])||RI(_e):null):null,w.createElement("div",{"data-content":"",className:gn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:gn(I==null?void 0:I.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?w.createElement("div",{"data-description":"",className:gn(G,Nt,I==null?void 0:I.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),w.isValidElement(f.cancel)?f.cancel:f.cancel&&vi(f.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||$,onClick:me=>{var Oe,qe;vi(f.cancel)&&Be&&((qe=(Oe=f.cancel).onClick)==null||qe.call(Oe,me),he())},className:gn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,w.isValidElement(f.action)?f.action:f.action&&vi(f.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||L,onClick:me=>{var Oe,qe;vi(f.action)&&((qe=(Oe=f.action).onClick)==null||qe.call(Oe,me),!me.defaultPrevented&&he())},className:gn(I==null?void 0:I.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function ux(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function oN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?JI:XI;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var sN=w.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:p,duration:m,style:f,visibleToasts:v=YI,toastOptions:g,dir:x=ux(),gap:y=QI,loadingIcon:b,icons:C,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:S}=e,[T,E]=w.useState([]),P=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(D=>D.position).map(D=>D.position)))),[T,r]),[_,$]=w.useState([]),[L,F]=w.useState(!1),[G,O]=w.useState(!1),[K,q]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),H=w.useRef(null),j=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),Y=w.useRef(!1),J=w.useCallback(D=>{E(V=>{var R;return(R=V.find(B=>B.id===D.id))!=null&&R.delete||Kt.dismiss(D.id),V.filter(({id:B})=>B!==D.id)})},[]);return w.useEffect(()=>Kt.subscribe(D=>{if(D.dismiss){E(V=>V.map(R=>R.id===D.id?{...R,delete:!0}:R));return}setTimeout(()=>{Oo.flushSync(()=>{E(V=>{let R=V.findIndex(B=>B.id===D.id);return R!==-1?[...V.slice(0,R),{...V[R],...D},...V.slice(R+1)]:[D,...V]})})})}),[]),w.useEffect(()=>{if(d!=="system"){q(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;let D=window.matchMedia("(prefers-color-scheme: dark)");try{D.addEventListener("change",({matches:V})=>{q(V?"dark":"light")})}catch{D.addListener(({matches:R})=>{try{q(R?"dark":"light")}catch(B){console.error(B)}})}},[d]),w.useEffect(()=>{T.length<=1&&F(!1)},[T]),w.useEffect(()=>{let D=V=>{var R,B;o.every(X=>V[X]||V.code===X)&&(F(!0),(R=H.current)==null||R.focus()),V.code==="Escape"&&(document.activeElement===H.current||(B=H.current)!=null&&B.contains(document.activeElement))&&F(!1)};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[o]),w.useEffect(()=>{if(H.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,Y.current=!1)}},[H.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${j}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},P.map((D,V)=>{var R;let[B,X]=D.split("-");return T.length?w.createElement("ol",{key:D,dir:x==="auto"?ux():x,tabIndex:-1,ref:H,className:a,"data-sonner-toaster":!0,"data-theme":K,"data-y-position":B,"data-lifted":L&&T.length>1&&!s,"data-x-position":X,style:{"--front-toast-height":`${((R=_[0])==null?void 0:R.height)||0}px`,"--width":`${ZI}px`,"--gap":`${y}px`,...f,...oN(l,c)},onBlur:N=>{Y.current&&!N.currentTarget.contains(N.relatedTarget)&&(Y.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:N=>{N.target instanceof HTMLElement&&N.target.dataset.dismissible==="false"||Y.current||(Y.current=!0,I.current=N.relatedTarget)},onMouseEnter:()=>F(!0),onMouseMove:()=>F(!0),onMouseLeave:()=>{G||F(!1)},onDragEnd:()=>F(!1),onPointerDown:N=>{N.target instanceof HTMLElement&&N.target.dataset.dismissible==="false"||O(!0)},onPointerUp:()=>O(!1)},T.filter(N=>!N.position&&V===0||N.position===D).map((N,M)=>{var U,Z;return w.createElement(rN,{key:N.id,icons:C,index:M,toast:N,defaultRichColors:p,duration:(U=g==null?void 0:g.duration)!=null?U:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Z=g==null?void 0:g.closeButton)!=null?Z:i,interacting:G,position:D,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:T.filter(se=>se.position==N.position),heights:_.filter(se=>se.position==N.position),setHeights:$,expandByDefault:s,gap:y,loadingIcon:b,expanded:L,pauseWhenPageIsHidden:S,swipeDirections:e.swipeDirections})})):null}))});const iN=({...e})=>{const{theme:t="system"}=_I();return u.jsx(sN,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};z.Api=Jv,z.ApiClient=Xv,z.ApiProvider=lu,z.ArtifactRenderer=Oh,z.Badge=Wh,z.Button=Je,z.Card=fl,z.CardContent=Qs,z.CardDescription=ml,z.CardHeader=pl,z.CardTitle=hl,z.ChatApi=Yo,z.ChatApp=Bk,z.ChatInput=tp,z.ChatInputRow=np,z.ChatInterface=$r,z.ChatProviders=Cr,z.ChatWidget=Uk,z.Command=El,z.CommandEmpty=Al,z.CommandGroup=Pl,z.CommandInput=Il,z.CommandItem=jl,z.CommandList=Nl,z.DEFAULT_TIMEOUT_MS=nu,z.Dialog=il,z.DialogContent=Us,z.DialogHeader=Ws,z.DialogTitle=Vs,z.DropdownMenu=ks,z.DropdownMenuContent=mo,z.DropdownMenuItem=Fn,z.DropdownMenuTrigger=Es,z.FileViewerModal=bh,z.HISTORY_TIMEOUT_MS=ru,z.Input=$l,z.InterruptPartRenderer=gl,z.Label=Tm,z.MarkdownContent=fr,z.MessageComponent=ei,z.MessageList=wl,z.MessageRow=vl,z.NewChatButton=Wk,z.PlotArtifact=Mh,z.SETTINGS_STORAGE_KEY=Vi,z.ScrollArea=Ll,z.Select=CE,z.SelectContent=dg,z.SelectItem=fg,z.SelectTrigger=lg,z.SelectValue=TE,z.Separator=gg,z.Sheet=OE,z.SheetContent=kg,z.SheetDescription=Ng,z.SheetHeader=Eg,z.SheetTitle=Ig,z.SheetTrigger=DE,z.SimpleChat=zk,z.SimpleJsonView=Zs,z.Sonner=iN,z.StreamProgress=Dh,z.Switch=Cg,z.Textarea=ja,z.ThinkingIndicator=$h,z.ThreadListItem=vm,z.ThreadManager=ii,z.ThreadStateProvider=Lu,z.ThreadsProvider=vu,z.TimelineColumn=Ix,z.Toaster=NI,z.ToolContent=Uh,z.Tooltip=sI,z.TooltipContent=Lg,z.TooltipProvider=oI,z.TooltipTrigger=iI,z.UserTextContent=Fh,z.applySettings=Cw,z.buildCheckpointIndex=sc,z.buildCheckpointPreviewMap=gx,z.buildLabelParts=ku,z.chatApiClient=Nn,z.collectText=yu,z.createArtifactPreviewFromPlot=Iu,z.createArtifactPreviewFromSource=Eu,z.del=Mi,z.downloadFileById=su,z.extractConfigFields=bi,z.extractToolContent=tr,z.extractToolMeta=Jo,z.fileToBase64=cu,z.formatToolOutput=bu,z.get=Jt,z.getAgentNameFromMessage=Cu,z.getChatToken=eu,z.getCheckpointForMessage=xx,z.getCurrentSettings=Sw,z.getDefaultApiConfig=Ku,z.getDefaultChatSettings=qu,z.getFileContent=Di,z.getFileInfo=Qv,z.getMessageAttemptInfo=ic,z.getMessageDomKey=xl,z.getPreviewForMessage=wi,z.getToolProgress=zi,z.httpClient=Xt,z.hydrateHistorySnapshots=Yn,z.isEnvelope=du,z.isFileLike=$i,z.listFiles=iu,z.loadStoredSettings=Gu,z.looksLikeMarkdown=wu,z.messageSignature=Bi,z.normalizeInterruptId=Fi,z.normalizeMimeType=Tu,z.normalizeToolPayload=Nu,z.normalizeToolPayloadValue=Sr,z.onChatTokenChanged=tu,z.parseJsonSafe=Qn,z.post=Go,z.pretty=er,z.processAttachments=uu,z.put=ou,z.readNumber=lc,z.readString=Rn,z.resolveChatBaseUrl=vn,z.sanitizeForDisplay=yr,z.saveSettings=Yu,z.setChatToken=qo,z.stringifyTool=Su,z.toPlainObject=_n,z.unwrap=Lt,z.useApi=eo,z.useCheckpointIndex=ac,z.useFilePreview=Bh,z.useHasChatSession=ww,z.useParsedMessageContent=zh,z.useShallowStableValue=Hu,z.useStream=Wi,z.useStreamingHook=Wi,z.useThreadHistoryState=Ru,z.useThreadManagerViewState=ym,z.useThreadState=no,z.useThreadStateUpdater=Du,z.useThreads=br,z.useThreadsState=gu,z.viewFileById=Zv,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
|
|
127
|
+
`+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const P='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(P);return}else throw new Error(P)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Js{constructor(t){this.options=t||dr}preprocess(t){return t}postprocess(t){return t}}dx(Js,"passThroughHooks",new Set(["preprocess","postprocess"]));function LT(e,t,n){return r=>{if(r.message+=`
|
|
128
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Ot(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function Rh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ge.defaults,...s};const i=LT(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(MT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(p){return i(p)}const c=function(p){let m;if(!p)try{r.walkTokens&&ge.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){p=f}return r.highlight=a,p?i(p):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ge.walkTokens(l,function(p){p.type==="code"&&(d++,setTimeout(()=>{a(p.text,p.lang,function(m,f){if(m)return c(m);f!=null&&f!==p.text&&(p.text=f,p.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(ge.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&ge.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ge(e,t,n){return Rh(Wn.lex,Vn.parse)(e,t,n)}ge.options=ge.setOptions=function(e){return ge.defaults={...ge.defaults,...e},yT(ge.defaults),ge},ge.getDefaults=yh,ge.defaults=dr,ge.use=function(...e){const t=ge.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ge.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=ge.defaults.renderer||new dl;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=ge.defaults.tokenizer||new ul;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=ge.defaults.hooks||new Js;for(const s in n.hooks){const i=o[s];Js.passThroughHooks.has(s)?o[s]=a=>{if(ge.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=ge.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}ge.setOptions(r)})},ge.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ge,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ge.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ge.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ge.walkTokens(r.items,t));break}default:ge.defaults.extensions&&ge.defaults.extensions.childTokens&&ge.defaults.extensions.childTokens[r.type]?ge.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ge.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ge.walkTokens(r.tokens,t)))}return n},ge.parseInline=Rh(Wn.lexInline,Vn.parseInline),ge.Parser=Vn,ge.parser=Vn.parse,ge.Renderer=dl,ge.TextRenderer=jh,ge.Lexer=Wn,ge.lexer=Wn.lex,ge.Tokenizer=ul,ge.Slugger=_h,ge.Hooks=Js,ge.parse=ge,ge.options,ge.setOptions,ge.use,ge.walkTokens,ge.parseInline,Vn.parse,Wn.lex;function fr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof ge.parse=="function"?ge.parse(i):ge(i)}return typeof ge.parse=="function"?ge.parse(e):ge(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=w.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:re("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function Mh({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}function Oh({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>Iu(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Mh,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?u.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:u.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",u.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const $T="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 Zs({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:$T,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:er(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:er(e)})}function Dh({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=w.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(ce.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}const fl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));fl.displayName="Card";const pl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex flex-col space-y-1.5 p-6",e),...t}));pl.displayName="CardHeader";const hl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:re("text-2xl font-semibold leading-none tracking-tight",e),...t}));hl.displayName="CardTitle";const ml=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:re("text-sm text-muted-foreground",e),...t}));ml.displayName="CardDescription";const Qs=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("p-6 pt-0",e),...t}));Qs.displayName="CardContent";const Lh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex items-center p-6 pt-0",e),...t}));Lh.displayName="CardFooter";const FT=e=>!!e&&typeof e=="object"&&e.type==="user_choice"&&typeof e.question=="string"&&Array.isArray(e.alternatives);function gl({interruptPart:e,onApprove:t,onReject:n,onSelectAlternative:r,disabled:o,isActive:s,payload:i}){const a=FT(i)?i:null,l=(a==null?void 0:a.question)??e.title??"Approve the result?",c=a?s?"Select one of the alternatives to continue.":"Waiting for approval from another participant.":s?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";let d=null;if(!a&&i!==void 0&&i!==null)if(typeof i=="string")d=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:i});else{const p=er(i);d=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:p})}return u.jsxs(fl,{className:re("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",s?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(pl,{className:"pb-3",children:[u.jsx(hl,{className:"text-blue-900 dark:text-blue-100 text-base",children:l}),u.jsx(ml,{className:"text-blue-700 dark:text-blue-300 text-sm",children:c})]}),a?u.jsx(Qs,{className:"pt-0 pb-3",children:u.jsx("div",{className:"space-y-2",children:a.alternatives.map(p=>u.jsx(Je,{size:"sm",variant:"outline",onClick:()=>r==null?void 0:r(e,p),className:"w-full justify-start text-left",disabled:o||!s,children:u.jsxs("div",{className:"flex flex-col items-start gap-1",children:[u.jsx("span",{className:"font-semibold",children:p.label}),p.description?u.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:p.description}):null]})},p.id))})}):d&&u.jsx(Qs,{className:"pt-0 pb-3",children:d}),!a&&u.jsx(Lh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Je,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:o||!s,children:"Reject"}),u.jsx(Je,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:o||!s,children:"Approve"})]})})]})}function $h({className:e}){const t=w.useRef(null);return w.useEffect(()=>{let n=0;const r=()=>{if(n=(n+1)%4,t.current){const s=".".repeat(n);t.current.textContent=`Is thinking${s}`}};r();const o=setInterval(r,500);return()=>clearInterval(o)},[]),u.jsx("span",{ref:t,"aria-live":"polite",className:re("inline-block text-xs opacity-70 ml-1",e),children:"Is thinking"})}function Fh({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:re("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(fr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:re("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Je,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(ce.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ce.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Bh(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=cl(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),p=w.useCallback(f=>{a(f),c(!0)},[]),m=w.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const b=String(v.url??""),C=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(C){f.preventDefault();const k=C[1],S=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";p({id:k,name:S,mimeType:T});return}if(b.startsWith("data:")){f.preventDefault(),s(S=>({...S,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const S=await iu(n??void 0);if(!S||!Array.isArray(S))throw new Error("Invalid file list response");const T=S.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");p({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(S){console.error("Failed to fetch server file:",S);const T=S instanceof Error?S.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(S=>({...S,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(C=>({...C,[g]:!1}))}},[t,o,r,n,p]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function zh(e,t){return w.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:yu(r),toolMeta:Jo(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Su(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Hh="data:";function BT(e){if(!e)return[];const t=[],n=e.split(/\r?\n/);for(const r of n){const o=r.trim();if(!o||!o.startsWith(Hh))continue;const s=o.slice(Hh.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=Qn(s);i&&typeof i=="object"&&t.push(i)}return t}function zT(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n&&typeof n=="object"&&n.type==="tool.end")return n}return null}function HT(e){return w.useMemo(()=>{const t=e.content.filter(c=>c.type==="text");if(!t.length)return null;let r=t.flatMap(c=>BT(c.text??""));if(!r.length){const c=t.map(p=>p.text??"").join(`
|
|
129
|
+
`),d=Qn(c);d&&typeof d=="object"&&(r=[d])}if(!r.length)return null;const s=zT(r)??r[r.length-1];if(!s)return null;const i=s.output??s.payload??s,a=Sr(i),l=tr(a);return l&&typeof l=="object"&&!Array.isArray(l)?{kind:"dict",value:l,data:l,event:s}:{kind:"generic",value:l,event:s}},[e])}function Uh({message:e,viewMode:t,isStreaming:n=!1,toolConfig:r,expandable:o=!1}){var $;const s=Jo(e),i=e.artifact??null,a=HT(e),c=(a?Nu(a):null)??a,d=e.content.find(L=>L.type!=="tool_call"),p=L=>{if(L==null)return null;const F=typeof L=="string"?Qn(L)??L:L;if(F&&typeof F=="object")return u.jsx(Zs,{data:F});const G=typeof F=="string"?F:(()=>{try{return er(F)}catch{return String(F??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:G})},m=L=>{if(L==null)return null;const{content:F,isMarkdown:G}=bu(L);return G?u.jsx(fr,{content:F,className:"text-current"}):p(L)},f=L=>u.jsxs("div",{className:"space-y-2 rounded-2xl border border-muted-foreground/30 bg-white/80 p-4 shadow-sm shadow-slate-900/10",children:[u.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:"Structured dictionary"}),u.jsx(Zs,{data:L})]}),v=()=>{if((c==null?void 0:c.kind)==="generic")return m(c.value);if(!d)return null;if(d.type==="text"){const O=(d.text??"").trim();if(!O)return null;const K=tr(O);return m(K)}const L=yr(d),F=tr(L);return m(F)},g=()=>(c==null?void 0:c.kind)==="dict"?f(c.data):v(),x=()=>{if(!y)return;if(s.name){const F=y[s.name];if(F)return F}const L=(c==null?void 0:c.kind)??(a==null?void 0:a.kind);if(L){const F=y[L];if(F)return F}return y.default},{toolRenderers:y,toolArtifactRenderers:b}=r??{},C=x(),k=g(),S=!o||t==="expanded",T=(S?C==null?void 0:C({message:e,toolMeta:s,toolPayload:c,viewMode:t,isStreaming:n}):null)??null,P=(($=(()=>{if(!b)return;const L=i==null?void 0:i.type;if(typeof L=="string"){const F=b[L];if(F)return F}return b.default})())==null?void 0:$({artifact:i,message:e,toolPayload:c,isStreaming:n}))??null,_=T??k;return u.jsxs("div",{className:"space-y-2",children:[i&&(P??u.jsx(Oh,{artifact:i,idx:0})),u.jsx(Dh,{message:e,isStreaming:n}),S?_:null]})}const UT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},xl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,vl=w.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s=0,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:p,showToolMessages:m,checkpointIndex:f,onSelectCheckpoint:v,getMessageCustomStyles:g,getInterruptOptions:x,toolConfig:y}){const b=xl(t,n),C=t.role==="default_message",T=!!t.__syntheticStreaming||o===t.id&&t.role==="assistant",E=f??UT,P=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:_,attemptIndex:$,attempts:L}=w.useMemo(()=>ic(t.id,P,E),[t.id,P,E]),F=g==null?void 0:g(t);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":b,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(ei,{message:t,messageIndex:n,isStreamingMessage:T,renderStreamingMarkdown:T,streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:p,getInterruptOptions:x,showToolMessages:m,attemptCount:_,attemptIndex:$,attemptMetas:L,onSelectCheckpoint:v,customStyles:F,toolConfig:y})})});vl.displayName="MessageRow";function WT(e,t,n){const[r,o]=w.useState(e),s=w.useRef(e),i=w.useRef(null);return w.useEffect(()=>{s.current=e;const a=()=>{o(s.current),i.current&&(clearTimeout(i.current),i.current=null)};if(!t||n<=0){a();return}return i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{a()},n),()=>{i.current&&(clearTimeout(i.current),i.current=null)}},[e,t,n]),r}function VT({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,toolExpandable:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptPart:d,isStreamingMessage:p,streamingDebounceMs:m,enableStreamingMarkdownBuffer:f,renderStreamingMarkdown:v,defaultMessage:g,handleFileClick:x,uploadingFiles:y,messageRole:b,truncateUserMessages:C,userMessagePreviewLength:k,isUserExpanded:S,setIsUserExpanded:T,isCompactLayout:E,iconForeground:P,toolConfig:_,handleInterruptApprove:$,handleInterruptReject:L,handleInterruptAlternative:F,disableInterruptActions:G,isInterruptMessage:O}){const K=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ce.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),H=WT(i,(f??!0)&&p,m??0),j=w.useMemo(()=>H.filter(N=>N.type==="text"),[H]),I=w.useMemo(()=>j.map(N=>N.text??"").join(""),[j]),Y=w.useMemo(()=>{if(!v)return null;const N=qT(I);return{stablePart:I.slice(0,N),tailPart:I.slice(N)}},[I,v]),J=w.useMemo(()=>{if(!Y)return null;const{stablePart:N,tailPart:M}=Y;return!N&&!M?null:u.jsxs("div",{className:"space-y-2",children:[N?u.jsx(fr,{content:N,allowHtml:!1}):null,M?u.jsx(fr,{content:M,allowHtml:!1}):null]})},[Y]),D=w.useMemo(()=>{if(!v)return H;const N=[];let M=!1;for(const U of H){if(U.type==="text"){M||(N.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),M=!0);continue}N.push(U)}return N},[H,v]),R=(v?D:H).filter(N=>N.type!=="interrupt"),B=w.useCallback(({part:N,i:M})=>{if(N.type==="text"){if(v)return null;const U=N.text??"",Z=U.trim(),se=Qn(Z);return se&&b!=="tool"?u.jsx(Zs,{data:se},M):b==="user"&&C&&Z.length>k?u.jsx(Fh,{text:Z,expanded:S,onExpandedChange:T,previewLength:k,isCompact:E},M):u.jsx(fr,{content:U,allowHtml:!1},M)}if(N.type==="image_url"){const U=N;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:U.url,alt:U.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},M)}if(N.type==="file"){const U=N,Z=U.name||"file";return u.jsxs("a",{href:U.url,onClick:se=>x(se,U,M),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
130
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[y[M]?u.jsx(ce.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[Z,y[M]?" (processing)":""]})]},M)}return null},[x,E,S,b,C,y,k,v,T]),X=a.trim().length>0||l.length>0||c.length>0||R.length>0;if(!t&&c.length>0&&!p)return K();if(!t&&!X&&!p)return null;if(t){if(!n)return null;if(O&&d){const N=d.value,M=!G,U=$??(()=>{}),Z=L??(()=>{});return u.jsx(gl,{interruptPart:d,payload:N,onApprove:U,onReject:Z,onSelectAlternative:F,disabled:G,isActive:M})}return u.jsx(Uh,{message:e,viewMode:r,expandable:o,isStreaming:s,toolConfig:_},e.id)}if(!g){const N=u.jsx("div",{className:"space-y-2",children:R.map((M,U)=>v&>(M)?J?u.jsx("div",{className:"space-y-2",children:J},`streaming-md-${U}`):null:u.jsx(B,{part:M,i:U},U))});return p?u.jsxs("div",{"aria-busy":"true",role:"status",children:[N,u.jsx($h,{className:P})]}):N}return null}function KT(e){return e?!(Ao(e,/```/g)||Ao(e,/`/g)||Ao(e,/\*\*/g)||Ao(e,/__/g)||Ao(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function Ao(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function qT(e){if(!e)return 0;for(let t=e.length;t>=0;t-=1)if(KT(e.slice(0,t)))return t;return 0}function GT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const YT=Vr.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 Wh({className:e,variant:t,...n}){return u.jsx("div",{className:re(YT({variant:t}),e),...n})}function XT({showTimestamp:e,showAgentName:t,isToolMessage:n,isInterruptMessage:r=!1,iconForeground:o,agentName:s,messageIcon:i,customHeaderClass:a,customActionsClass:l,isCompactLayout:c,showActions:d,isEditing:p,messageRole:m,toolViewMode:f,toolExpandable:v=!1,toolMeta:g,onToggleToolView:x,onCopy:y,onEdit:b,onRegenerate:C,showCheckpointControls:k,attemptCount:S,attemptIndex:T,handleOlderAttemptSelect:E,handleNewerAttemptSelect:P,messageCreatedAt:_,copied:$}){return!e&&!t&&!n&&!r?null:u.jsxs("div",{className:re("flex items-center justify-between mb-2 pb-2 border-b border-current/10",c&&"mb-1 pb-1",o,a),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[i,t&&s&&u.jsx("span",{className:re("font-medium",c?"text-xs":"text-sm"),children:s}),n&&!r&&u.jsxs(Wh,{variant:"outline",className:re("text-xs flex items-center gap-1",o,"border border-current/40",c&&"text-xs h-4",v&&"cursor-pointer select-none"),role:v?"button":void 0,tabIndex:v?0:void 0,"aria-expanded":v?f==="expanded":void 0,onClick:v?x:void 0,onKeyDown:L=>{v&&(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),x())},children:[u.jsx("span",{children:g.name??"Tool Output"}),g.toolCallId&&u.jsx("span",{className:"opacity-70",children:g.toolCallId.slice(0,8)}),v&&(f==="expanded"?u.jsx(ce.ChevronUp,{className:"h-3 w-3"}):u.jsx(ce.ChevronDown,{className:"h-3 w-3"}))]}),r&&u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g.name??"Interrupt"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[k&&S>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T<S-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T>=S-1||E()},"aria-label":"Older attempt (back in time)",disabled:T>=S-1,children:u.jsx(ce.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[S-T," / ",S]})}),u.jsx("button",{type:"button",className:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T<=0||P()},"aria-label":"Newer attempt (forward in time)",disabled:T<=0,children:u.jsx(ce.ChevronRight,{className:"h-3 w-3"})})]}),e&&_&&u.jsx("time",{className:re("text-xs opacity-60",o,c&&"text-xs"),dateTime:new Date(_).toISOString(),title:new Date(_).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(_))}),d&&!p&&u.jsxs("div",{className:re("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",l),children:[u.jsx("div",{className:"relative",children:u.jsx(Je,{variant:"ghost",size:"sm",onClick:y,className:re("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ce.Copy,{className:re($?"text-success":o,c?"h-3 w-3":"h-4 w-4")})})}),m==="user"&&b&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:b,className:re("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ce.Edit,{className:re(o,c?"h-3 w-3":"h-4 w-4")})}),m==="assistant"&&C&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:C,className:re("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ce.RotateCcw,{className:re(o,c?"h-3 w-3":"h-4 w-4")})})]})]})]})}const ei=w.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:p=!0,toolConfig:m,customStyles:f={},streamingDebounceMs:v=300,renderStreamingMarkdown:g=!1,enableStreamingMarkdownBuffer:x,onEdit:y,onRegenerate:b,onCopy:C,getInterruptOptions:k,attemptCount:S=1,attemptIndex:T=0,onSelectCheckpoint:E,attemptMetas:P=[]}){const[_,$]=w.useState(!1),[L,F]=w.useState(!1),{currentThreadId:G}=br(),{respondToInterrupt:O}=no(),[K,q]=w.useState(!1),H=l==="phone"||l==="half-screen",j=t.role,I=j==="interrupt",Y=j==="tool"||I,D=!(t.role==="default_message")&&t.expandable!==void 0?t.expandable!==!1:!0,{toolRenderers:V,toolArtifactRenderers:R,getToolExpandable:B}=m??{},X=w.useMemo(()=>!B||t.role!=="tool"?!1:B(t),[B,t.id,t.role]),[N,M]=w.useState(X?"preview":"expanded");w.useEffect(()=>{M(X?"preview":"expanded")},[X,t.id]);const U=w.useMemo(()=>t.role==="default_message"?t:null,[t]),Z=!!U,se=!(r&&j!=="user"),{uploadingFiles:ae,handleFileClick:Ce,fileViewerOpen:we,currentFileInfo:je,closeFileViewer:We}=Bh({allowFileOpen:se,currentThreadId:G}),Fe=w.useMemo(()=>{switch(j){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"interrupt":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[j]),Ye=zh(t,U),{contentParts:He,imageParts:vt,fileParts:wt,textContent:dt,toolMeta:Ve,toolRaw:Ae,isToolStreaming:Ke,interruptParts:_e}=Ye,Be=x??v!==0,Qe=w.useMemo(()=>_e.length?_e[0]:null,[_e]),Nt=w.useCallback(async()=>{const Ee=Y?Ae:dt;async function be(Xe){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Xe);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const At=new Blob([Xe],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":At})]);return}throw new Error("Clipboard API not supported in this context.")}try{await be(Ee),$(!0),setTimeout(()=>$(!1),2e3),C==null||C(Ee)}catch(Xe){console.error("Failed to copy:",Xe)}},[Y,Ae,dt,C]),et=w.useCallback(async(Ee,be)=>{if(!Qe)return;if(!Fi(Qe.id)){console.warn("Interrupt part missing id",Qe);return}q(!0);try{const At=k==null?void 0:k(t);await O(Ee,be,At)}catch(At){console.error("Failed to respond to interrupt:",At)}finally{q(!1)}},[Qe,O]),bt=w.useCallback(()=>et(!0),[et]),mt=w.useCallback(()=>et(!1),[et]),Ct=w.useCallback((Ee,be)=>{if(!be)return;const Xe={alternativeId:be.id??be.label??void 0,alternativeLabel:be.label};et(!0,Xe)},[et]),Tt=w.useCallback(()=>{if(!y||!t.id)return;const Ee=(Y?Ae:dt)??"",be="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};y(t.id,Ee,be)},[y,Y,Ae,dt,t]),Dt=w.useCallback(()=>{b==null||b(n)},[b,n]),Pt=w.useCallback(()=>{const be=re(H?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Fe);switch(j){case"user":return u.jsx(ce.User,{className:be});case"assistant":return u.jsx(ce.Bot,{className:be});case"tool":return u.jsx(ce.Wrench,{className:be});case"interrupt":return u.jsx(ce.Bot,{className:be});default:return u.jsx(ce.Bot,{className:be})}},[H,Fe,j]),kt=w.useCallback(()=>{const Ee="group relative mb-4 flex w-full";switch(j){case"user":return re(Ee,"justify-end");case"assistant":case"tool":case"system":case"interrupt":return re(Ee,"justify-start");default:return Ee}},[j]),qt=w.useCallback(()=>{const Ee=re("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",H&&"px-3 py-2 text-sm");if(Z)return re(Ee,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(j){case"user":return re(Ee,"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 re(Ee,"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":case"interrupt":return re(Ee,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return re(Ee,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return re(Ee,"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")}},[H,Z,j]),Ue=X&&!I&&D,$e=w.useCallback(()=>{Ue&&M(Ee=>Ee==="expanded"?"preview":"expanded")},[Ue]),ne=I?"expanded":N,he=(p||I)&&D,tt=u.jsx(VT,{message:t,isToolMessage:Y,showToolMessages:he,toolViewMode:ne,toolExpandable:X,toolConfig:{toolRenderers:V,toolArtifactRenderers:R,getToolExpandable:B},isToolStreaming:Ke,contentParts:He,textContent:dt,imageParts:vt,fileParts:wt,isStreamingMessage:r,defaultMessage:U,enableStreamingMarkdownBuffer:Be,renderStreamingMarkdown:g,streamingDebounceMs:v,handleFileClick:Ce,uploadingFiles:ae,messageRole:j,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:L,setIsUserExpanded:F,isCompactLayout:H,iconForeground:Fe,interruptPart:Qe,handleInterruptApprove:bt,handleInterruptReject:mt,handleInterruptAlternative:Ct,disableInterruptActions:K,isInterruptMessage:I}),me=w.useMemo(()=>U?"Assistant":Cu(t),[U,t]),Oe=Pt(),qe=j==="user"&&(S??1)>1&&typeof E=="function",ut=(P==null?void 0:P.length)??0,at=ut>0&&T<ut-1?P[T+1]:void 0,lt=ut>0&&T>0?P[T-1]:void 0,Et=w.useCallback(()=>{!at||!E||E(at.id,void 0,!!at.isLatestAttempt)},[at,E]),ke=w.useCallback(()=>{!lt||!E||E(lt.id,void 0,!!lt.isLatestAttempt)},[lt,E]);return Y&&!p?null:Z&&U?u.jsx("div",{className:re(kt(),f.container),children:u.jsxs("div",{className:re(qt(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ce.Bot,{className:re("h-4 w-4",Fe)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(fr,{content:U.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:re(kt(),f.container),children:u.jsxs("div",{className:re(qt(),f.content),children:[u.jsx(XT,{showTimestamp:i,showAgentName:a,isToolMessage:Y,iconForeground:Fe,agentName:me,messageIcon:Oe,customHeaderClass:f.header,customActionsClass:f.actions,isCompactLayout:H,showActions:s,isEditing:o,messageRole:j,toolViewMode:ne,toolExpandable:X,isInterruptMessage:I,toolMeta:Ve,onToggleToolView:$e,onCopy:Nt,onEdit:Tt,onRegenerate:Dt,showCheckpointControls:qe,attemptCount:S,attemptIndex:T,handleOlderAttemptSelect:Et,handleNewerAttemptSelect:ke,messageCreatedAt:t.createdAt,copied:_}),u.jsx("div",{className:"relative",children:tt}),!(i||a||Y)&&s&&!o&&u.jsxs("div",{className:re("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>Nt(),className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",H&&"h-5 w-5"),children:u.jsx(ce.Copy,{className:re(_?"text-success":"text-current",H?"h-3 w-3":"h-4 w-4")})}),j==="user"&&y&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:Tt,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",H&&"h-5 w-5"),children:u.jsx(ce.Edit,{className:re("text-current",H?"h-3 w-3":"h-4 w-4")})}),j==="assistant"&&b&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:Dt,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",H&&"h-5 w-5"),children:u.jsx(ce.RotateCcw,{className:re("text-current",H?"h-3 w-3":"h-4 w-4")})})]})]})}),je&&u.jsx(bh,{isOpen:we,onClose:We,fileId:je.id,fileName:je.name,mimeType:je.mimeType})]})},(e,t)=>{var l,c,d,p,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Bi(e.message)===Bi(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolConfig"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((p=t.customStyles)==null?void 0:p.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=zi(e.message),a=zi(t.message);return i.length===a.length});ei.displayName="MessageComponent";const wl=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r=0,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:p,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,showToolMessages:b=!0,toolConfig:C,checkpointIndex:k,activeCheckpointId:S,onSelectCheckpoint:T,createSyntheticThinkingMessage:E=!0,forceSyntheticThinking:P=!1,getMessageCustomStyles:_,getInterruptOptions:$},L)=>{const F=w.useRef(null),G=w.useRef(null),O=w.useRef(!1),K=w.useRef(!1),q=e,H=w.useMemo(()=>{const N=n&&q.some(U=>U.id===n);return E&&(t||P)&&!N&&q.length>0?[...q,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:q},[q,t,n,E,P]),j=w.useMemo(()=>b?H:H.filter(N=>(N==null?void 0:N.role)!=="tool"),[H,b]),I=w.useCallback(N=>{x&&x(!N),y&&y(N)},[x,y]),Y=w.useMemo(()=>{if(a)return async()=>{if(!O.current){O.current=!0;try{await a()}finally{O.current=!1}}}},[a]),J=w.useMemo(()=>!v||g?!1:"auto",[v,g]),D=w.useMemo(()=>{if(typeof f!="string")return null;const N=f.trim();return!N||j&&j.length>0?null:{id:"default-message",role:"default_message",content:N,createdAt:new Date().toISOString()}},[f,j]),V=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),R=()=>{if(D){const N=_==null?void 0:_(D);return u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(ei,{message:D,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:N,getInterruptOptions:$})})})}return u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"})},B=j.length,X=B>0;return w.useEffect(()=>{var N,M;if(B===0){K.current=!1;return}if(!K.current)if(K.current=!0,F.current&&j.length>0){const U=j.length-1;(M=(N=F.current).scrollToIndex)==null||M.call(N,{index:U,align:"end",behavior:"auto"})}else G.current&&(G.current.scrollTop=G.current.scrollHeight)},[B,j.length]),w.useImperativeHandle(L,()=>({scrollToLatest:()=>{var N,M;if(F.current&&j.length>0){const U=j.length-1;(M=(N=F.current).scrollToIndex)==null||M.call(N,{index:U,align:"end",behavior:"auto"})}else G.current&&(G.current.scrollTop=G.current.scrollHeight)},scrollToTop:()=>{var N,M;F.current&&j.length>0?(M=(N=F.current).scrollToIndex)==null||M.call(N,{index:0,align:"start",behavior:"auto"}):G.current&&(G.current.scrollTop=0)}}),[j]),u.jsx("div",{className:V,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:X?u.jsx(UC,{ref:N=>{F.current=N},scrollerRef:N=>{G.current=N instanceof HTMLDivElement?N:null},data:j,followOutput:J,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{Y&&Y()},atBottomStateChange:I,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(N,M)=>xl(M,N),itemContent:(N,M)=>u.jsx(vl,{message:M,index:N,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,showToolMessages:b,toolConfig:C,checkpointIndex:k,activeCheckpointId:S,onSelectCheckpoint:T,getMessageCustomStyles:_,getInterruptOptions:$})}):R()})})});wl.displayName="MessageList";const Vh={value:""};function $r({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,followNewMessages:s=!0,enableFileUpload:i=!0,enableExcelUpload:a=!1,enableMessageEditing:l=!0,showToolMessages:c=!0,toolConfig:d,toolRenderers:p,toolArtifactRenderers:m,payloadExtras:f={},customStyles:v={},messageCustomStyles:g,onMessageSent:x,onExcelUploadSuccess:y,onError:b,defaultMessage:C}){const{api:k}=eo(),S=k.baseUrl,{currentThreadId:T}=br(),{threadId:E,messages:P,isLoading:_,navigateToCheckpoint:$,returnToLatest:L,checkpoint:F,checkpoints:G,interrupt:O,metadata:K,checkpointIndex:q,respondToInterrupt:H}=no(),{isStreaming:j,error:I,connectionState:Y,submit:J,stop:D}=Wi(),V=E??T??null,R=(F==null?void 0:F.id)??null,B=(F==null?void 0:F.namespace)??null,X=(K==null?void 0:K.assemblingMessageId)??null,N=O,M=N?Fi(N.id):null,U=M!==null?{type:"interrupt",id:M}:null,[Z,se]=w.useState(!1),[ae,Ce]=w.useState(!1);w.useEffect(()=>{N||se(!1)},[N]);const we=w.useCallback(()=>{se(!0)},[]),je=w.useCallback(()=>{se(!1)},[]),We=w.useCallback(Q=>{},[]),Fe=w.useCallback(Q=>Q.name!=="ask_user_choice",[]),Ye=d??{toolRenderers:p,toolArtifactRenderers:m,getToolExpandable:Fe},He=w.useCallback(async(Q,le,xe)=>{try{we(),await H(Q,le,xe)}catch(Ie){console.error("Failed to respond to interrupt:",Ie)}finally{je()}},[je,we,H]),vt=w.useCallback(()=>He(!0),[He]),wt=w.useCallback(()=>He(!1),[He]),dt=w.useCallback((Q,le)=>He(!0,le),[He]),Ve=!!N||Z,[Ae,Ke]=w.useState(null),[_e,Be]=w.useState(""),[Qe,Nt]=w.useState(null),[et,bt]=w.useState(null),[mt,Ct]=w.useState(!1),[Tt,Dt]=w.useState(null),Pt=w.useRef(!1),[kt,qt]=w.useState(()=>Vh.value),Ue=w.useRef(kt),$e=w.useRef(null),ct=w.useCallback(Q=>{Vh.value=Q,qt(Q)},[]),[ne,he]=w.useState(!1),tt=w.useRef(null),me=w.useCallback(Q=>{ct(Q)},[ct]);w.useEffect(()=>{j||Ce(!1)},[j]),w.useEffect(()=>{K!=null&&K.assemblingMessageId&&Ce(!1)},[K==null?void 0:K.assemblingMessageId]);const[Oe,qe]=w.useState("desktop");w.useEffect(()=>{const Q=()=>{const le=window.innerWidth;qe(le<640?"phone":le<1024?"tablet":"desktop")};return Q(),window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[]),w.useEffect(()=>{Pt.current=!1},[V]),w.useEffect(()=>{Ue.current=kt},[kt]),w.useEffect(()=>{if(!Ae){$e.current=null;return}$e.current===null&&($e.current=Ue.current),ct(_e??"")},[_e,Ae,ct]),w.useEffect(()=>{if(C!==void 0){Dt(C);return}(async()=>{if(!S){Dt(null);return}try{const xe=(await k.getAgent("default")).uiDefaultMessage||"";Dt(xe||null)}catch(le){console.warn("Failed to fetch default message:",le),Dt(null)}})()},[k,S,C]),w.useEffect(()=>{I&&!mt&&(b==null||b(I))},[I,mt,b]);const ut=async(Q,le)=>{const xe=Q.trim();if(!(!xe&&le.length===0))try{const Ie=Ae?(Qe==null?void 0:Qe.checkpointId)??R??void 0:R??void 0,Re=Ae?(Qe==null?void 0:Qe.checkpointNs)??B??void 0:B??void 0;await J({text:xe||"",attachments:le,payload:f},{checkpointId:Ie,checkpointNs:Re,edit:!!Ae,originalMessageId:Ae??void 0}),x==null||x(xe),Ce(!0),ct(""),bt(null),Ke(null),Be(""),Nt(null)}catch(Ie){const Re=(Ie==null?void 0:Ie.message)||"Failed to send message";bt(Re),b==null||b(Re),Ce(!1)}},at=w.useCallback(async Q=>{await J({attachments:[Q],payload:f},{checkpointId:R??void 0,checkpointNs:B??void 0}),y==null||y({file:Q})},[R,B,f,y,J]),lt=w.useCallback((Q,le,xe)=>{l&&($e.current=kt,Ke(Q),Be(le),ct(le),bt(null),Nt({checkpointId:(xe==null?void 0:xe.checkpointId)??null,checkpointNs:(xe==null?void 0:xe.checkpointNs)??null}))},[kt,l,ct]),Et=w.useCallback(()=>{Ke(null),Be(""),Nt(null),bt(null),ct($e.current??kt),$e.current=null},[kt,ct]),ke=w.useCallback((Q,le,xe)=>{lt(Q,le,xe)},[lt]),Ee=w.useCallback(Q=>{let le=null;for(let Te=Q-1;Te>=0;Te--)if(P[Te].role==="user"){le=P[Te];break}if(!le)return;const xe=Array.isArray(le.content)?le.content:[],Re=xe.filter(Te=>(Te==null?void 0:Te.type)==="text").map(Te=>Te.text).join("")||(()=>{try{return JSON.stringify(xe,null,2)}catch{return String(xe)}})();Re&&J({text:Re,payload:f},{checkpointId:R??void 0,checkpointNs:B??void 0,edit:!0,originalMessageId:le.id})},[P,J,R,B,f]),be=w.useCallback(async Q=>{if(T){he(!0);try{if(!Q){await L(),requestAnimationFrame(()=>{var Ie;(Ie=tt.current)==null||Ie.scrollToLatest()});return}const le=G.find(Ie=>Ie.checkpointId===Q),xe=(le==null?void 0:le.checkpointNs)??null;await $(Q,xe),requestAnimationFrame(()=>{var Ie;(Ie=tt.current)==null||Ie.scrollToTop()})}finally{he(!1)}}},[G,T,tt,$,L]),Xe=w.useCallback(async(Q,le,xe)=>{await be(xe?null:Q)},[be]),At=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.container||""}`,A=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 ${N?"pb-32":""} bg-transparent ${v.messagesArea||""}`,ee=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:At,children:[!!I&&!mt&&u.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:[u.jsx("span",{children:I}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>Ct(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ce.X,{size:16})})]}),u.jsxs("div",{className:`relative ${A}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(wl,{ref:tt,className:"h-full",style:{height:"100%"},messages:P,isStreaming:j,streamingAssistantId:X,streamingDebounceMs:o,followNewMessages:s,layoutSize:Oe,enableMessageEditing:l,editingMessageId:Ae,onEdit:ke,onRegenerate:Ee,onCancelEdit:Et,emptyMessage:Tt??void 0,isNavigatingCheckpoint:ne,showToolMessages:c,toolConfig:Ye,checkpointIndex:q,activeCheckpointId:R,onSelectCheckpoint:Xe,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ae,getMessageCustomStyles:g,getInterruptOptions:We}),(Y==="reconnecting"||Y==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(ce.Loader2,{className:"h-3 w-3 animate-spin"}),Y==="reconnecting"?"Reconnecting…":"Connecting…"]})}),Y==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),_&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ce.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),ne&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ce.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]}),N&&U&&u.jsx("div",{className:"pointer-events-auto absolute inset-x-0 bottom-6 z-30 flex justify-center px-4",children:u.jsx("div",{className:"w-full max-w-3xl",children:u.jsx(gl,{interruptPart:U,onApprove:vt,onReject:wt,onSelectAlternative:dt,disabled:Z,isActive:!0,payload:N.value})})})]}),u.jsxs("div",{className:ee,children:[Ae&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ce.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:Et,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ce.X,{size:16})})]})}),et&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:et}),u.jsx(RS,{composerValue:kt,onComposerChange:me,onSend:ut,onCancelEdit:Et,onStop:D,editingMessageId:Ae,editingInitialValue:_e,placeholder:Ae?"Edit your message...":t,isStreaming:j,disabled:Ve,enableFileUpload:i,enableExcelUpload:a,onExcelUpload:at,onError:b,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:et})]})]})}var Kh=1,JT=.9,ZT=.8,QT=.17,bl=.1,yl=.999,ek=.9999,tk=.99,nk=/[\\\/_+.#"@\[\(\{&]/,rk=/[\\\/_+.#"@\[\(\{&]/g,ok=/[\s-]/,qh=/[\s-]/g;function Sl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Kh:tk;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,p,m,f,v;c>=0;)p=Sl(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=Kh:nk.test(e.charAt(c-1))?(p*=ZT,f=e.slice(o,c-1).match(rk),f&&o>0&&(p*=Math.pow(yl,f.length))):ok.test(e.charAt(c-1))?(p*=JT,v=e.slice(o,c-1).match(qh),v&&o>0&&(p*=Math.pow(yl,v.length))):(p*=QT,o>0&&(p*=Math.pow(yl,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=ek)),(p<bl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=Sl(e,t,n,r,c+1,s+2,i),m*bl>p&&(p=m*bl)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function Gh(e){return e.toLowerCase().replace(qh," ")}function sk(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Sl(e,t,Gh(e),Gh(t),0,0,{})}var Po='[cmdk-group=""]',Cl='[cmdk-group-items=""]',ik='[cmdk-group-heading=""]',Yh='[cmdk-item=""]',Xh=`${Yh}:not([aria-disabled="true"])`,Tl="cmdk-item-select",Fr="data-value",ak=(e,t,n)=>sk(e,t,n),Jh=h.createContext(void 0),jo=()=>h.useContext(Jh),Zh=h.createContext(void 0),kl=()=>h.useContext(Zh),Qh=h.createContext(void 0),em=h.forwardRef((e,t)=>{let n=Br(()=>{var D,V;return{search:"",value:(V=(D=e.value)!=null?D:e.defaultValue)!=null?V:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Br(()=>new Set),o=Br(()=>new Map),s=Br(()=>new Map),i=Br(()=>new Set),a=tm(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=_t(),C=_t(),k=_t(),S=h.useRef(null),T=vk();pr(()=>{if(d!==void 0){let D=d.trim();n.current.value=D,E.emit()}},[d]),pr(()=>{T(6,G)},[]);let E=h.useMemo(()=>({subscribe:D=>(i.current.add(D),()=>i.current.delete(D)),snapshot:()=>n.current,setState:(D,V,R)=>{var B,X,N,M;if(!Object.is(n.current[D],V)){if(n.current[D]=V,D==="search")F(),$(),T(1,L);else if(D==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let U=document.getElementById(k);U?U.focus():(B=document.getElementById(b))==null||B.focus()}if(T(7,()=>{var U;n.current.selectedItemId=(U=O())==null?void 0:U.id,E.emit()}),R||T(5,G),((X=a.current)==null?void 0:X.value)!==void 0){let U=V??"";(M=(N=a.current).onValueChange)==null||M.call(N,U);return}}E.emit()}},emit:()=>{i.current.forEach(D=>D())}}),[]),P=h.useMemo(()=>({value:(D,V,R)=>{var B;V!==((B=s.current.get(D))==null?void 0:B.value)&&(s.current.set(D,{value:V,keywords:R}),n.current.filtered.items.set(D,_(V,R)),T(2,()=>{$(),E.emit()}))},item:(D,V)=>(r.current.add(D),V&&(o.current.has(V)?o.current.get(V).add(D):o.current.set(V,new Set([D]))),T(3,()=>{F(),$(),n.current.value||L(),E.emit()}),()=>{s.current.delete(D),r.current.delete(D),n.current.filtered.items.delete(D);let R=O();T(4,()=>{F(),(R==null?void 0:R.getAttribute("id"))===D&&L(),E.emit()})}),group:D=>(o.current.has(D)||o.current.set(D,new Set),()=>{s.current.delete(D),o.current.delete(D)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:C,listInnerRef:S}),[]);function _(D,V){var R,B;let X=(B=(R=a.current)==null?void 0:R.filter)!=null?B:ak;return D?X(D,n.current.search,V):0}function $(){if(!n.current.search||a.current.shouldFilter===!1)return;let D=n.current.filtered.items,V=[];n.current.filtered.groups.forEach(B=>{let X=o.current.get(B),N=0;X.forEach(M=>{let U=D.get(M);N=Math.max(U,N)}),V.push([B,N])});let R=S.current;K().sort((B,X)=>{var N,M;let U=B.getAttribute("id"),Z=X.getAttribute("id");return((N=D.get(Z))!=null?N:0)-((M=D.get(U))!=null?M:0)}).forEach(B=>{let X=B.closest(Cl);X?X.appendChild(B.parentElement===X?B:B.closest(`${Cl} > *`)):R.appendChild(B.parentElement===R?B:B.closest(`${Cl} > *`))}),V.sort((B,X)=>X[1]-B[1]).forEach(B=>{var X;let N=(X=S.current)==null?void 0:X.querySelector(`${Po}[${Fr}="${encodeURIComponent(B[0])}"]`);N==null||N.parentElement.appendChild(N)})}function L(){let D=K().find(R=>R.getAttribute("aria-disabled")!=="true"),V=D==null?void 0:D.getAttribute(Fr);E.setState("value",V||void 0)}function F(){var D,V,R,B;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let X=0;for(let N of r.current){let M=(V=(D=s.current.get(N))==null?void 0:D.value)!=null?V:"",U=(B=(R=s.current.get(N))==null?void 0:R.keywords)!=null?B:[],Z=_(M,U);n.current.filtered.items.set(N,Z),Z>0&&X++}for(let[N,M]of o.current)for(let U of M)if(n.current.filtered.items.get(U)>0){n.current.filtered.groups.add(N);break}n.current.filtered.count=X}function G(){var D,V,R;let B=O();B&&(((D=B.parentElement)==null?void 0:D.firstChild)===B&&((R=(V=B.closest(Po))==null?void 0:V.querySelector(ik))==null||R.scrollIntoView({block:"nearest"})),B.scrollIntoView({block:"nearest"}))}function O(){var D;return(D=S.current)==null?void 0:D.querySelector(`${Yh}[aria-selected="true"]`)}function K(){var D;return Array.from(((D=S.current)==null?void 0:D.querySelectorAll(Xh))||[])}function q(D){let V=K()[D];V&&E.setState("value",V.getAttribute(Fr))}function H(D){var V;let R=O(),B=K(),X=B.findIndex(M=>M===R),N=B[X+D];(V=a.current)!=null&&V.loop&&(N=X+D<0?B[B.length-1]:X+D===B.length?B[0]:B[X+D]),N&&E.setState("value",N.getAttribute(Fr))}function j(D){let V=O(),R=V==null?void 0:V.closest(Po),B;for(;R&&!B;)R=D>0?gk(R,Po):xk(R,Po),B=R==null?void 0:R.querySelector(Xh);B?E.setState("value",B.getAttribute(Fr)):H(D)}let I=()=>q(K().length-1),Y=D=>{D.preventDefault(),D.metaKey?I():D.altKey?j(1):H(1)},J=D=>{D.preventDefault(),D.metaKey?q(0):D.altKey?j(-1):H(-1)};return h.createElement(fe.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:D=>{var V;(V=y.onKeyDown)==null||V.call(y,D);let R=D.nativeEvent.isComposing||D.keyCode===229;if(!(D.defaultPrevented||R))switch(D.key){case"n":case"j":{x&&D.ctrlKey&&Y(D);break}case"ArrowDown":{Y(D);break}case"p":case"k":{x&&D.ctrlKey&&J(D);break}case"ArrowUp":{J(D);break}case"Home":{D.preventDefault(),q(0);break}case"End":{D.preventDefault(),I();break}case"Enter":{D.preventDefault();let B=O();if(B){let X=new Event(Tl);B.dispatchEvent(X)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:P.inputId,id:P.labelId,style:bk},l),ti(e,D=>h.createElement(Zh.Provider,{value:E},h.createElement(Jh.Provider,{value:P},D))))}),lk=h.forwardRef((e,t)=>{var n,r;let o=_t(),s=h.useRef(null),i=h.useContext(Qh),a=jo(),l=tm(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;pr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=nm(o,s,[e.value,e.children,s],e.keywords),p=kl(),m=Kn(T=>T.value&&T.value===d.current),f=Kn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);h.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(Tl,v),()=>T.removeEventListener(Tl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){p.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:b,forceMount:C,keywords:k,...S}=e;return h.createElement(fe.div,{ref:Mn(s,t),...S,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),ck=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=_t(),a=h.useRef(null),l=h.useRef(null),c=_t(),d=jo(),p=Kn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);pr(()=>d.group(i),[]),nm(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(fe.div,{ref:Mn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),ti(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(Qh.Provider,{value:m},f))))}),uk=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Kn(i=>!i.search);return!n&&!s?null:h.createElement(fe.div,{ref:Mn(o,t),...r,"cmdk-separator":"",role:"separator"})}),dk=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=kl(),i=Kn(c=>c.search),a=Kn(c=>c.selectedItemId),l=jo();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(fe.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),fk=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Kn(c=>c.selectedItemId),l=jo();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,p,m=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(p),m.unobserve(c)}}},[]),h.createElement(fe.div,{ref:Mn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},ti(e,c=>h.createElement("div",{ref:Mn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),pk=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(ol,{open:n,onOpenChange:r},h.createElement(sl,{container:i},h.createElement(Eo,{"cmdk-overlay":"",className:o}),h.createElement(Io,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(em,{ref:t,...a}))))}),hk=h.forwardRef((e,t)=>Kn(n=>n.filtered.count===0)?h.createElement(fe.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),mk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(fe.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ti(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Vt=Object.assign(em,{List:fk,Item:lk,Input:dk,Group:ck,Separator:uk,Dialog:pk,Empty:hk,Loading:mk});function gk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function xk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function tm(e){let t=h.useRef(e);return pr(()=>{t.current=e}),t}var pr=typeof window>"u"?h.useEffect:h.useLayoutEffect;function Br(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Kn(e){let t=kl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function nm(e,t,n,r=[]){let o=h.useRef(),s=jo();return pr(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Fr,a),o.current=a}),o}var vk=()=>{let[e,t]=h.useState(),n=Br(()=>new Map);return pr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function wk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function ti({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(wk(t),{ref:t.ref},n(t.props.children)):n(t)}var bk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const El=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt,{ref:n,className:re("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));El.displayName=Vt.displayName;const Il=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(ce.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Vt.Input,{ref:n,className:re("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));Il.displayName=Vt.Input.displayName;const Nl=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt.List,{ref:n,className:re("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Nl.displayName=Vt.List.displayName;const Al=h.forwardRef((e,t)=>u.jsx(Vt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Al.displayName=Vt.Empty.displayName;const Pl=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt.Group,{ref:n,className:re("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Pl.displayName=Vt.Group.displayName;const yk=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt.Separator,{ref:n,className:re("-mx-1 h-px bg-border",e),...t}));yk.displayName=Vt.Separator.displayName;const jl=h.forwardRef(({className:e,...t},n)=>u.jsx(Vt.Item,{ref:n,className:re("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));jl.displayName=Vt.Item.displayName;function _l(e,[t,n]){return Math.min(n,Math.max(t,e))}function Sk(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Rl="ScrollArea",[rm,$N]=cn(Rl),[Ck,sn]=rm(Rl),om=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[p,m]=h.useState(null),[f,v]=h.useState(null),[g,x]=h.useState(null),[y,b]=h.useState(0),[C,k]=h.useState(0),[S,T]=h.useState(!1),[E,P]=h.useState(!1),_=De(t,L=>l(L)),$=Qo(o);return u.jsx(Ck,{scope:n,type:r,dir:$,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:p,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:P,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(fe.div,{dir:$,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});om.displayName=Rl;var sm="ScrollAreaViewport",im=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(sm,n),a=h.useRef(null),l=De(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.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}),u.jsx(fe.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});im.displayName=sm;var In="ScrollAreaScrollbar",Ml=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(Tk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(kk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(am,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Ol,{...r,ref:t}):null});Ml.displayName=In;var Tk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ut,{present:n||s,children:u.jsx(am,{"data-state":s?"visible":"hidden",...r,ref:t})})}),kk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=si(()=>l("SCROLL_END"),100),[a,l]=Sk("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 h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let p=c[d];const m=()=>{const f=c[d];p!==f&&(l("SCROLL"),i()),p=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Ut,{present:n||a!=="hidden",children:u.jsx(Ol,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ie(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ie(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),am=h.forwardRef((e,t)=>{const n=sn(In,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=si(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return zr(n.viewport,l),zr(n.content,l),u.jsx(Ut,{present:r||s,children:u.jsx(Ol,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ol=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(In,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=fm(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function p(m,f){return jk(m,i.current,a,f)}return n==="horizontal"?u.jsx(Ek,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=pm(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?u.jsx(Ik,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=pm(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),Ek=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=De(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(cm,{"data-orientation":"horizontal",...o,ref:c,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":oi(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),mm(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:ri(i.paddingLeft),paddingEnd:ri(i.paddingRight)}})}})}),Ik=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=De(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(cm,{"data-orientation":"vertical",...o,ref:c,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":oi(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),mm(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:ri(i.paddingTop),paddingEnd:ri(i.paddingBottom)}})}})}),[Nk,lm]=rm(In),cm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:p,...m}=e,f=sn(In,n),[v,g]=h.useState(null),x=De(t,_=>g(_)),y=h.useRef(null),b=h.useRef(""),C=f.viewport,k=r.content-r.viewport,S=pt(d),T=pt(l),E=si(p,10);function P(_){if(y.current){const $=_.clientX-y.current.left,L=_.clientY-y.current.top;c({x:$,y:L})}}return h.useEffect(()=>{const _=$=>{const L=$.target;(v==null?void 0:v.contains(L))&&S($,k)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[C,v,k,S]),h.useEffect(T,[r,T]),zr(v,E),zr(f.content,E),u.jsx(Nk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:pt(s),onThumbPointerUp:pt(i),onThumbPositionChange:T,onThumbPointerDown:pt(a),children:u.jsx(fe.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ie(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),P(_))}),onPointerMove:ie(e.onPointerMove,P),onPointerUp:ie(e.onPointerUp,_=>{const $=_.target;$.hasPointerCapture(_.pointerId)&&$.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),ni="ScrollAreaThumb",um=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=lm(ni,e.__scopeScrollArea);return u.jsx(Ut,{present:n||o.hasThumb,children:u.jsx(Ak,{ref:t,...r})})}),Ak=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(ni,n),i=lm(ni,n),{onThumbPositionChange:a}=i,l=De(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=si(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(d(),!c.current){const f=_k(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(fe.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ie(e.onPointerDownCapture,p=>{const f=p.target.getBoundingClientRect(),v=p.clientX-f.left,g=p.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ie(e.onPointerUp,i.onThumbPointerUp)})});um.displayName=ni;var Dl="ScrollAreaCorner",dm=h.forwardRef((e,t)=>{const n=sn(Dl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Pk,{...e,ref:t}):null});dm.displayName=Dl;var Pk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn(Dl,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return zr(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),zr(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(fe.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ri(e){return e?parseInt(e,10):0}function fm(e,t){const n=e/t;return isNaN(n)?0:n}function oi(e){const t=fm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function jk(e,t,n,r="ltr"){const o=oi(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,p=r==="ltr"?[0,d]:[d*-1,0];return hm([l,c],p)(e)}function pm(e,t,n="ltr"){const r=oi(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=_l(e,l);return hm([0,i],[0,a])(c)}function hm(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 mm(e,t){return e>0&&e<t}var _k=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function si(e,t){const n=pt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function zr(e,t){const n=pt(t);It(()=>{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 gm=om,Rk=im,Mk=dm;const Ll=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(gm,{ref:r,className:re("relative overflow-hidden",e),...n,children:[u.jsx(Rk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(xm,{}),u.jsx(Mk,{})]}));Ll.displayName=gm.displayName;const xm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Ml,{ref:r,orientation:t,className:re("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:u.jsx(um,{className:"relative flex-1 rounded-full bg-border"})}));xm.displayName=Ml.displayName;const $l=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:re("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}));$l.displayName="Input";const Ok="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Dk="bg-slate-700 border-slate-600 hover:bg-slate-600",Lk="bg-slate-600 border-slate-500";function vm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:p,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const b=n===e.threadId,C=t?`${y??Lk}`:`${x??Dk}`,k=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Ok} ${C}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:b?u.jsxs("div",{className:"flex items-center gap-2",onClick:S=>S.stopPropagation(),children:[u.jsx($l,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ce.Check,{size:12})}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ce.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(ce.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Je,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ce.MoreHorizontal,{size:12})})}),u.jsxs(mo,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Fn,{onClick:S=>{S.preventDefault(),c(e.threadId)},children:[u.jsx(ce.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(Fn,{onClick:S=>{S.preventDefault(),s(e,S)},children:[u.jsx(ce.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Fn,{className:"text-red-400 hover:text-red-300",onClick:S=>{S.preventDefault(),d(e.threadId,S)},children:[u.jsx(ce.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const wm=25,bm="thread-manager-view",$k=e=>e==="default"||e==="shared",Fk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(bm);if($k(e))return e}catch{}return null};function ym({defaultView:e}={}){const[t,n]=w.useState(()=>Fk()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(bm,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Bk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ii({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:p,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:b,shareTargetFilter:C}){const{threads:k,sharedThreads:S,currentThreadId:T,setCurrentThreadId:E,isLoading:P,isLoadingSharedThreads:_,actions:$,shareInFlight:L,shareStatus:F,clearShareStatus:G}=br(),{createThread:O,deleteThread:K,renameThread:q,shareThread:H}=$,{loadThread:j}=no(),I=i??T,[Y,J]=w.useState(Array.isArray(k)?k:[]),D=w.useRef(Y.length>0),V=w.useRef(null),R=w.useRef(0),[B,X]=w.useState(null),[N,M]=w.useState(""),[U,Z]=w.useState(!1),[se,ae]=w.useState(!1),[Ce,we]=w.useState(null),[je,We]=w.useState(""),Fe=v&&v.length>0?v:Bk,Ye=ym({defaultView:m}),He=g??Ye,vt=p??He.view,wt=w.useCallback(ne=>{p||He.setView(ne),f==null||f(ne)},[p,f,He]),dt=Fe.find(ne=>ne.key===vt)??Fe[0],Ve=ne=>{we(ne),We(""),ae(!0)},Ae=()=>{ae(!1),we(null),We(""),G()},Ke=w.useCallback(async ne=>{if(!(!Ce||L)&&ne.id)try{await H(Ce,ne.id),setTimeout(()=>Ae(),600)}catch(he){console.error("Failed to share thread:",he)}},[Ae,L,Ce,H]),_e=w.useMemo(()=>{const ne=y??[],he=je.trim().toLowerCase();return he?C?ne.filter(tt=>C(tt,he)):ne.filter(tt=>`${tt.label} ${tt.secondaryLabel??""}`.toLowerCase().includes(he)):ne},[y,je,C]),Be=vt==="shared",Qe=Be?S:Y,Nt=Be?_:P,et=Be?"No shared conversations yet":"No conversations yet",bt=ne=>{const he=ne.sharedAt?` • ${Ue(ne.sharedAt)}`:"";return`Shared by ${ne.sharedByUserId}${he}`},mt=ne=>"sharedByUserId"in ne;w.useEffect(()=>{const ne=Array.isArray(k)?k:[];if(ne.length>0){D.current=!0,J(ne);return}P||(D.current=!1,J(ne))},[k,P]),w.useEffect(()=>{if(!V.current)return;const ne=V.current.querySelector("[data-radix-scroll-area-viewport]");if(!ne)return;let he=null,tt=null;return he=requestAnimationFrame(()=>{tt=requestAnimationFrame(()=>{ne.scrollTop=R.current})}),()=>{he!==null&&cancelAnimationFrame(he),tt!==null&&cancelAnimationFrame(tt)}},[Y]);const Ct=async ne=>{try{E(ne),await j(ne),a==null||a(ne),l==null||l(ne)}catch(he){console.error("Failed to select thread:",he)}},Tt=async()=>{try{Z(!0);const ne=await O();ne&&(c==null||c(ne),a==null||a(ne))}catch(ne){console.error("Failed to create thread:",ne)}finally{Z(!1)}},Dt=async(ne,he)=>{if(he.stopPropagation(),!!confirm("Delete this thread?")){if(V.current){const tt=V.current.querySelector("[data-radix-scroll-area-viewport]");tt&&(R.current=tt.scrollTop)}try{await K(ne),d==null||d(ne)}catch(tt){console.error("Failed to delete thread:",tt)}}},Pt=(ne,he)=>{he.stopPropagation(),X(ne.threadId),M(ne.title||`Thread ${ne.threadId.slice(0,8)}`)},kt=async ne=>{if(N.trim())try{await q(ne,N.trim()),X(null),M("")}catch(he){console.error("Failed to update title:",he)}},qt=()=>{X(null),M("")},Ue=ne=>{if(!ne)return"";try{const he=new Date(ne),me=new Date().getTime()-he.getTime(),Oe=Math.floor(me/(1e3*60*60*24));return Oe===0?he.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Oe===1?"Yesterday":Oe<7?`${Oe} days ago`:he.toLocaleDateString()}catch{return""}},$e=ne=>ne.title||`Thread ${ne.threadId.slice(0,8)}`,ct=ne=>{const he=$e(ne);return he.length<=wm?he:`${he.slice(0,wm)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(Je,{onClick:Tt,disabled:U||P,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:U?"Creating...":"New Chat",children:[u.jsx(ce.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(ks,{children:[u.jsx(Es,{asChild:!0,children:u.jsx(Je,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:dt.label})}),u.jsx(mo,{align:"start",sideOffset:6,className:"w-40",children:Fe.map(ne=>u.jsxs(Fn,{className:"justify-between text-[12px]",onClick:he=>{he.preventDefault(),wt(ne.key)},children:[u.jsx("span",{children:ne.label}),vt===ne.key&&u.jsx(ce.Check,{className:"h-3 w-3"})]},ne.key))})]})]})]}),u.jsx(Ll,{ref:V,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:Nt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ce.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):Qe.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ce.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:et})]}):Qe.slice().sort((ne,he)=>new Date(he.updatedAt||he.createdAt||"").getTime()-new Date(ne.updatedAt||ne.createdAt||"").getTime()).map(ne=>u.jsx(vm,{thread:ne,isActive:I===ne.threadId,editingThreadId:B,editingTitle:N,onSelect:Ct,onStartEditing:Pt,onEditingTitleChange:he=>M(he),onSaveEditing:kt,onCancelEditing:qt,onShare:()=>Ve(ne.threadId),onDelete:Dt,showEditTitle:r,showDeleteButton:n,formatDate:Ue,getDisplayThreadTitle:ct,secondaryLine:Be&&mt(ne)?bt(ne):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},ne.threadId))})}),u.jsx(il,{open:se,onOpenChange:ne=>!ne&&Ae(),children:u.jsxs(Us,{className:"max-w-md p-0",children:[u.jsx(Ws,{children:u.jsx(Vs,{children:"Share thread"})}),u.jsxs(El,{children:[u.jsx(Il,{autoFocus:!0,value:je,onValueChange:ne=>We(ne),placeholder:"Search for recipients..."}),u.jsxs(Nl,{children:[F&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[L&&u.jsx(ce.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:F.startsWith("Failed")?"text-red-500":F.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:F})]}),u.jsx(Al,{children:b?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ce.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),_e.length>0&&u.jsx(Pl,{heading:"Recipients",children:_e.map(ne=>u.jsx(jl,{onSelect:()=>Ke(ne),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:ne.label}),ne.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:ne.secondaryLabel})]})},ne.id))})]})]})]})})]})}function zk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=w.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(Cr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx($r,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Cr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ii,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx($r,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Cr,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ii,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx($r,{onError:s.onError,enableFileUpload:!0})})]})})}function Hk({apiConfig:e,className:t="",onError:n}){return u.jsx(Cr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx($r,{})})})}function Uk({placeholder:e,onMessageSent:t}){const[n,r]=w.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ce.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ce.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx($r,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ii,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Wk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=w.useState(!1);return n?u.jsx(Cr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Je,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(ce.MoreHorizontal,{size:16})}),u.jsx(Je,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(ce.Edit3,{size:16})}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(ce.Maximize2,{size:14}):u.jsx(ce.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(Uk,{placeholder:t,onMessageSent:r})})]})})}):null}function Vk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Je,{variant:r,size:o,className:re("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(ce.Edit3,{size:16}),t??e]})}var Kk="Label",Sm=h.forwardRef((e,t)=>u.jsx(fe.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())}}));Sm.displayName=Kk;var Cm=Sm;const qk=Vr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Tm=h.forwardRef(({className:e,...t},n)=>u.jsx(Cm,{ref:n,className:re(qk(),e),...t}));Tm.displayName=Cm.displayName;function km(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Em=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"}),Gk="VisuallyHidden",ai=h.forwardRef((e,t)=>u.jsx(fe.span,{...e,ref:t,style:{...Em,...e.style}}));ai.displayName=Gk;var Yk=ai,Xk=[" ","Enter","ArrowUp","ArrowDown"],Jk=[" ","Enter"],hr="Select",[li,ci,Zk]=Zo(hr),[Hr,FN]=cn(hr,[Zk,Pr]),ui=Pr(),[Qk,qn]=Hr(hr),[eE,tE]=Hr(hr),Im=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:p,disabled:m,required:f,form:v}=e,g=ui(t),[x,y]=h.useState(null),[b,C]=h.useState(null),[k,S]=h.useState(!1),T=Qo(c),[E,P]=On({prop:r,defaultProp:o??!1,onChange:s,caller:hr}),[_,$]=On({prop:i,defaultProp:a,onChange:l,caller:hr}),L=h.useRef(null),F=x?v||!!x.closest("form"):!0,[G,O]=h.useState(new Set),K=Array.from(G).map(q=>q.props.value).join(";");return u.jsx(da,{...g,children:u.jsxs(Qk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:_t(),value:_,onValueChange:$,open:E,onOpenChange:P,dir:T,triggerPointerDownPosRef:L,disabled:m,children:[u.jsx(li.Provider,{scope:t,children:u.jsx(eE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(q=>{O(H=>new Set(H).add(q))},[]),onNativeOptionRemove:h.useCallback(q=>{O(H=>{const j=new Set(H);return j.delete(q),j})},[]),children:n})}),F?u.jsxs(Jm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:_,onChange:q=>$(q.target.value),disabled:m,form:v,children:[_===void 0?u.jsx("option",{value:""}):null,Array.from(G)]},K):null]})})};Im.displayName=hr;var Nm="SelectTrigger",Am=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ui(n),i=qn(Nm,n),a=i.disabled||r,l=De(t,i.onTriggerChange),c=ci(n),d=h.useRef("touch"),[p,m,f]=Qm(g=>{const x=c().filter(C=>!C.disabled),y=x.find(C=>C.value===i.value),b=eg(x,g,y);b!==void 0&&i.onValueChange(b.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(fa,{asChild:!0,...s,children:u.jsx(fe.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Zm(i.value)?"":void 0,...o,ref:l,onClick:ie(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ie(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:ie(o.onKeyDown,g=>{const x=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Xk.includes(g.key)&&(v(),g.preventDefault())})})})});Am.displayName=Nm;var Pm="SelectValue",jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=qn(Pm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=De(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(fe.span,{...a,ref:p,style:{pointerEvents:"none"},children:Zm(l.value)?u.jsx(u.Fragment,{children:i}):s})});jm.displayName=Pm;var nE="SelectIcon",_m=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(fe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});_m.displayName=nE;var rE="SelectPortal",Rm=e=>u.jsx(ao,{asChild:!0,...e});Rm.displayName=rE;var mr="SelectContent",Mm=h.forwardRef((e,t)=>{const n=qn(mr,e.__scopeSelect),[r,o]=h.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Kr.createPortal(u.jsx(Om,{scope:e.__scopeSelect,children:u.jsx(li.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Dm,{...e,ref:t})});Mm.displayName=mr;var mn=10,[Om,Gn]=Hr(mr),oE="SelectContentImpl",sE=Yt.createSlot("SelectContent.RemoveScroll"),Dm=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,b=qn(mr,n),[C,k]=h.useState(null),[S,T]=h.useState(null),E=De(t,N=>k(N)),[P,_]=h.useState(null),[$,L]=h.useState(null),F=ci(n),[G,O]=h.useState(!1),K=h.useRef(!1);h.useEffect(()=>{if(C)return va(C)},[C]),Yi();const q=h.useCallback(N=>{const[M,...U]=F().map(ae=>ae.ref.current),[Z]=U.slice(-1),se=document.activeElement;for(const ae of N)if(ae===se||(ae==null||ae.scrollIntoView({block:"nearest"}),ae===M&&S&&(S.scrollTop=0),ae===Z&&S&&(S.scrollTop=S.scrollHeight),ae==null||ae.focus(),document.activeElement!==se))return},[F,S]),H=h.useCallback(()=>q([P,C]),[q,P,C]);h.useEffect(()=>{G&&H()},[G,H]);const{onOpenChange:j,triggerPointerDownPosRef:I}=b;h.useEffect(()=>{if(C){let N={x:0,y:0};const M=Z=>{var se,ae;N={x:Math.abs(Math.round(Z.pageX)-(((se=I.current)==null?void 0:se.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((ae=I.current)==null?void 0:ae.y)??0))}},U=Z=>{N.x<=10&&N.y<=10?Z.preventDefault():C.contains(Z.target)||j(!1),document.removeEventListener("pointermove",M),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",M),document.addEventListener("pointerup",U,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",U,{capture:!0})}}},[C,j,I]),h.useEffect(()=>{const N=()=>j(!1);return window.addEventListener("blur",N),window.addEventListener("resize",N),()=>{window.removeEventListener("blur",N),window.removeEventListener("resize",N)}},[j]);const[Y,J]=Qm(N=>{const M=F().filter(se=>!se.disabled),U=M.find(se=>se.ref.current===document.activeElement),Z=eg(M,N,U);Z&&setTimeout(()=>Z.ref.current.focus())}),D=h.useCallback((N,M,U)=>{const Z=!K.current&&!U;(b.value!==void 0&&b.value===M||Z)&&(_(N),Z&&(K.current=!0))},[b.value]),V=h.useCallback(()=>C==null?void 0:C.focus(),[C]),R=h.useCallback((N,M,U)=>{const Z=!K.current&&!U;(b.value!==void 0&&b.value===M||Z)&&L(N)},[b.value]),B=r==="popper"?Fl:Lm,X=B===Fl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Om,{scope:n,content:C,viewport:S,onViewportChange:T,itemRefCallback:D,selectedItem:P,onItemLeave:V,itemTextRefCallback:R,focusSelectedItem:H,selectedItemText:$,position:r,isPositioned:G,searchRef:Y,children:u.jsx(ws,{as:sE,allowPinchZoom:!0,children:u.jsx(es,{asChild:!0,trapped:b.open,onMountAutoFocus:N=>{N.preventDefault()},onUnmountAutoFocus:ie(o,N=>{var M;(M=b.trigger)==null||M.focus({preventScroll:!0}),N.preventDefault()}),children:u.jsx(kr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:N=>N.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(B,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:N=>N.preventDefault(),...y,...X,onPlaced:()=>O(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ie(y.onKeyDown,N=>{const M=N.ctrlKey||N.altKey||N.metaKey;if(N.key==="Tab"&&N.preventDefault(),!M&&N.key.length===1&&J(N.key),["ArrowUp","ArrowDown","Home","End"].includes(N.key)){let Z=F().filter(se=>!se.disabled).map(se=>se.ref.current);if(["ArrowUp","End"].includes(N.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(N.key)){const se=N.target,ae=Z.indexOf(se);Z=Z.slice(ae+1)}setTimeout(()=>q(Z)),N.preventDefault()}})})})})})})});Dm.displayName=oE;var iE="SelectItemAlignedPosition",Lm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=qn(mr,n),i=Gn(mr,n),[a,l]=h.useState(null),[c,d]=h.useState(null),p=De(t,E=>d(E)),m=ci(n),f=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,C=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),P=c.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),$=y.getBoundingClientRect();if(s.dir!=="rtl"){const se=$.left-P.left,ae=_.left-se,Ce=E.left-ae,we=E.width+Ce,je=Math.max(we,P.width),We=window.innerWidth-mn,Fe=_l(ae,[mn,Math.max(mn,We-je)]);a.style.minWidth=we+"px",a.style.left=Fe+"px"}else{const se=P.right-$.right,ae=window.innerWidth-_.right-se,Ce=window.innerWidth-E.right-ae,we=E.width+Ce,je=Math.max(we,P.width),We=window.innerWidth-mn,Fe=_l(ae,[mn,Math.max(mn,We-je)]);a.style.minWidth=we+"px",a.style.right=Fe+"px"}const L=m(),F=window.innerHeight-mn*2,G=g.scrollHeight,O=window.getComputedStyle(c),K=parseInt(O.borderTopWidth,10),q=parseInt(O.paddingTop,10),H=parseInt(O.borderBottomWidth,10),j=parseInt(O.paddingBottom,10),I=K+q+G+j+H,Y=Math.min(x.offsetHeight*5,I),J=window.getComputedStyle(g),D=parseInt(J.paddingTop,10),V=parseInt(J.paddingBottom,10),R=E.top+E.height/2-mn,B=F-R,X=x.offsetHeight/2,N=x.offsetTop+X,M=K+q+N,U=I-M;if(M<=R){const se=L.length>0&&x===L[L.length-1].ref.current;a.style.bottom="0px";const ae=c.clientHeight-g.offsetTop-g.offsetHeight,Ce=Math.max(B,X+(se?V:0)+ae+H),we=M+Ce;a.style.height=we+"px"}else{const se=L.length>0&&x===L[0].ref.current;a.style.top="0px";const Ce=Math.max(R,K+g.offsetTop+(se?D:0)+X)+U;a.style.height=Ce+"px",g.scrollTop=M-R+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=Y+"px",a.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);It(()=>C(),[C]);const[k,S]=h.useState();It(()=>{c&&S(window.getComputedStyle(c).zIndex)},[c]);const T=h.useCallback(E=>{E&&v.current===!0&&(C(),b==null||b(),v.current=!1)},[C,b]);return u.jsx(lE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(fe.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Lm.displayName=iE;var aE="SelectPopperPosition",Fl=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=ui(n);return u.jsx(pa,{...i,...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)"}})});Fl.displayName=aE;var[lE,Bl]=Hr(mr,{}),zl="SelectViewport",$m=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Gn(zl,n),i=Bl(zl,n),a=De(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.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}),u.jsx(li.Slot,{scope:n,children:u.jsx(fe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ie(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-mn*2,g=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),y=Math.max(g,x);if(y<v){const b=y+f,C=Math.min(v,b),k=b-C;p.style.height=C+"px",p.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,p.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});$m.displayName=zl;var Fm="SelectGroup",[cE,uE]=Hr(Fm),dE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_t();return u.jsx(cE,{scope:n,id:o,children:u.jsx(fe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});dE.displayName=Fm;var Bm="SelectLabel",zm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=uE(Bm,n);return u.jsx(fe.div,{id:o.id,...r,ref:t})});zm.displayName=Bm;var di="SelectItem",[fE,Hm]=Hr(di),Um=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=qn(di,n),l=Gn(di,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),v=De(t,b=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,b,r,o)}),g=_t(),x=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.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 u.jsx(fE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(b=>{p(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(li.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(fe.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ie(i.onFocus,()=>f(!0)),onBlur:ie(i.onBlur,()=>f(!1)),onClick:ie(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ie(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ie(i.onPointerDown,b=>{x.current=b.pointerType}),onPointerMove:ie(i.onPointerMove,b=>{var C;x.current=b.pointerType,o?(C=l.onItemLeave)==null||C.call(l):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ie(i.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:ie(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(Jk.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Um.displayName=di;var _o="SelectItemText",Wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=qn(_o,n),a=Gn(_o,n),l=Hm(_o,n),c=tE(_o,n),[d,p]=h.useState(null),m=De(t,y=>p(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return It(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(fe.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Kr.createPortal(s.children,i.valueNode):null]})});Wm.displayName=_o;var Vm="SelectItemIndicator",Km=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Hm(Vm,n).isSelected?u.jsx(fe.span,{"aria-hidden":!0,...r,ref:t}):null});Km.displayName=Vm;var Hl="SelectScrollUpButton",qm=h.forwardRef((e,t)=>{const n=Gn(Hl,e.__scopeSelect),r=Bl(Hl,e.__scopeSelect),[o,s]=h.useState(!1),i=De(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Ym,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});qm.displayName=Hl;var Ul="SelectScrollDownButton",Gm=h.forwardRef((e,t)=>{const n=Gn(Ul,e.__scopeSelect),r=Bl(Ul,e.__scopeSelect),[o,s]=h.useState(!1),i=De(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Ym,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Gm.displayName=Ul;var Ym=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Gn("SelectScrollButton",n),i=h.useRef(null),a=ci(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=a().find(p=>p.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(fe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ie(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ie(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ie(o.onPointerLeave,()=>{l()})})}),pE="SelectSeparator",Xm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(fe.div,{"aria-hidden":!0,...r,ref:t})});Xm.displayName=pE;var Wl="SelectArrow",hE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ui(n),s=qn(Wl,n),i=Gn(Wl,n);return s.open&&i.position==="popper"?u.jsx(ha,{...o,...r,ref:t}):null});hE.displayName=Wl;var mE="SelectBubbleInput",Jm=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=De(r,o),i=km(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const p=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(p)}},[i,t]),u.jsx(fe.select,{...n,style:{...Em,...n.style},ref:s,defaultValue:t})});Jm.displayName=mE;function Zm(e){return e===""||e===void 0}function Qm(e){const t=pt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function eg(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=gE(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function gE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var xE=Im,tg=Am,vE=jm,wE=_m,bE=Rm,ng=Mm,yE=$m,rg=zm,og=Um,SE=Wm,CE=Km,sg=qm,ig=Gm,ag=Xm;const TE=xE,kE=vE,lg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(tg,{ref:r,className:re("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,u.jsx(wE,{asChild:!0,children:u.jsx(ce.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));lg.displayName=tg.displayName;const cg=h.forwardRef(({className:e,...t},n)=>u.jsx(sg,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ce.ChevronUp,{className:"h-4 w-4"})}));cg.displayName=sg.displayName;const ug=h.forwardRef(({className:e,...t},n)=>u.jsx(ig,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ce.ChevronDown,{className:"h-4 w-4"})}));ug.displayName=ig.displayName;const dg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(bE,{children:u.jsxs(ng,{ref:o,className:re("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:[u.jsx(cg,{}),u.jsx(yE,{className:re("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(ug,{})]})}));dg.displayName=ng.displayName;const EE=h.forwardRef(({className:e,...t},n)=>u.jsx(rg,{ref:n,className:re("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));EE.displayName=rg.displayName;const fg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(og,{ref:r,className:re("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:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(CE,{children:u.jsx(ce.Check,{className:"h-4 w-4"})})}),u.jsx(SE,{children:t})]}));fg.displayName=og.displayName;const IE=h.forwardRef(({className:e,...t},n)=>u.jsx(ag,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));IE.displayName=ag.displayName;var NE="Separator",pg="horizontal",AE=["horizontal","vertical"],hg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=pg,...o}=e,s=PE(r)?r:pg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(fe.div,{"data-orientation":s,...a,...o,ref:t})});hg.displayName=NE;function PE(e){return AE.includes(e)}var mg=hg;const gg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(mg,{ref:o,decorative:n,orientation:t,className:re("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));gg.displayName=mg.displayName;var fi="Switch",[jE,BN]=cn(fi),[_E,RE]=jE(fi),xg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...p}=e,[m,f]=h.useState(null),v=De(t,C=>f(C)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=On({prop:o,defaultProp:s??!1,onChange:c,caller:fi});return u.jsxs(_E,{scope:n,checked:y,disabled:a,children:[u.jsx(fe.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":yg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:v,onClick:ie(e.onClick,C=>{b(k=>!k),x&&(g.current=C.isPropagationStopped(),g.current||C.stopPropagation())})}),x&&u.jsx(bg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});xg.displayName=fi;var vg="SwitchThumb",wg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=RE(vg,n);return u.jsx(fe.span,{"data-state":yg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});wg.displayName=vg;var ME="SwitchBubbleInput",bg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=De(i,s),l=km(n),c=jd(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});bg.displayName=ME;function yg(e){return e?"checked":"unchecked"}var Sg=xg,OE=wg;const Cg=h.forwardRef(({className:e,...t},n)=>u.jsx(Sg,{className:re("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:u.jsx(OE,{className:re("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")})}));Cg.displayName=Sg.displayName;const DE=ol,LE=pT,$E=sl,Tg=h.forwardRef(({className:e,...t},n)=>u.jsx(Eo,{className:re("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}));Tg.displayName=Eo.displayName;const FE=Vr.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"}}),kg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs($E,{children:[u.jsx(Tg,{}),u.jsxs(Io,{ref:o,className:re(FE({side:e}),t),...r,children:[n,u.jsxs(xh,{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:[u.jsx(ce.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));kg.displayName=Io.displayName;const Eg=({className:e,...t})=>u.jsx("div",{className:re("flex flex-col space-y-2 text-center sm:text-left",e),...t});Eg.displayName="SheetHeader";const Ig=h.forwardRef(({className:e,...t},n)=>u.jsx(ur,{ref:n,className:re("text-lg font-semibold text-foreground",e),...t}));Ig.displayName=ur.displayName;const Ng=h.forwardRef(({className:e,...t},n)=>u.jsx(Hs,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Ng.displayName=Hs.displayName;var[pi,zN]=cn("Tooltip",[Pr]),hi=Pr(),Ag="TooltipProvider",BE=700,Vl="tooltip.open",[zE,Kl]=pi(Ag),Pg=e=>{const{__scopeTooltip:t,delayDuration:n=BE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(zE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};Pg.displayName=Ag;var Ro="Tooltip",[HE,mi]=pi(Ro),jg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Kl(Ro,e.__scopeTooltip),c=hi(t),[d,p]=h.useState(null),m=_t(),f=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,b]=On({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Vl))):l.onClose(),s==null||s(E)},caller:Ro}),C=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,b(!0)},[b]),S=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b(!1)},[b]),T=h.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,b(!0),f.current=0},g)},[g,b]);return h.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(da,{...c,children:u.jsx(HE,{scope:t,contentId:m,open:y,stateAttribute:C,trigger:d,onTriggerChange:p,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:h.useCallback(()=>{v?S():(window.clearTimeout(f.current),f.current=0)},[S,v]),onOpen:k,onClose:S,disableHoverableContent:v,children:n})})};jg.displayName=Ro;var ql="TooltipTrigger",_g=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=mi(ql,n),s=Kl(ql,n),i=hi(n),a=h.useRef(null),l=De(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),p=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),u.jsx(fa,{asChild:!0,...i,children:u.jsx(fe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ie(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ie(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ie(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ie(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ie(e.onBlur,o.onClose),onClick:ie(e.onClick,o.onClose)})})});_g.displayName=ql;var UE="TooltipPortal",[HN,WE]=pi(UE,{forceMount:void 0}),Ur="TooltipContent",Rg=h.forwardRef((e,t)=>{const n=WE(Ur,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=mi(Ur,e.__scopeTooltip);return u.jsx(Ut,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Mg,{side:o,...s,ref:t}):u.jsx(VE,{side:o,...s,ref:t})})}),VE=h.forwardRef((e,t)=>{const n=mi(Ur,e.__scopeTooltip),r=Kl(Ur,e.__scopeTooltip),o=h.useRef(null),s=De(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:p}=r,m=h.useCallback(()=>{a(null),p(!1)},[p]),f=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},b=XE(y,x.getBoundingClientRect()),C=JE(y,b),k=ZE(g.getBoundingClientRect()),S=eI([...C,...k]);a(S),p(!0)},[p]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},b=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),C=!QE(y,i);b?m():C&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Mg,{...e,ref:s})}),[KE,qE]=pi(Ro,{isInside:!1}),GE=Yt.createSlottable("TooltipContent"),Mg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=mi(Ur,n),c=hi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Vl,d),()=>document.removeEventListener(Vl,d)),[d]),h.useEffect(()=>{if(l.trigger){const p=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[l.trigger,d]),u.jsx(kr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(pa,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.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:[u.jsx(GE,{children:r}),u.jsx(KE,{scope:n,isInside:!0,children:u.jsx(Yk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Rg.displayName=Ur;var Og="TooltipArrow",YE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hi(n);return qE(Og,n).isInside?null:u.jsx(ha,{...o,...r,ref:t})});YE.displayName=Og;function XE(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 JE(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 ZE(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 QE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function eI(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),tI(t)}function tI(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],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.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],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.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 nI=Pg,rI=jg,oI=_g,Dg=Rg;const sI=nI,iI=rI,aI=oI,Lg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Dg,{ref:r,sideOffset:t,className:re("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}));Lg.displayName=Dg.displayName;var Gl="ToastProvider",[Yl,lI,cI]=Zo("Toast"),[$g,UN]=cn("Toast",[cI]),[uI,gi]=$g(Gl),Fg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),p=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Gl}\`. Expected non-empty \`string\`.`),u.jsx(Yl.Provider,{scope:t,children:u.jsx(uI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(f=>f+1),[]),onToastRemove:h.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:m,children:i})})};Fg.displayName=Gl;var Bg="ToastViewport",dI=["F8"],Xl="toast.viewportPause",Jl="toast.viewportResume",zg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=dI,label:o="Notifications ({hotkey})",...s}=e,i=gi(Bg,n),a=lI(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=De(t,p,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var C;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((C=p.current)==null||C.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=p.current;if(v&&x&&y){const b=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Xl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},C=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Jl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&C()},S=()=>{x.contains(document.activeElement)||C()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",S),window.addEventListener("blur",b),window.addEventListener("focus",C),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",S),window.removeEventListener("blur",b),window.removeEventListener("focus",C)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const b=a().map(C=>{const k=C.ref.current,S=[k,...TI(k)];return x==="forwards"?S:S.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return h.useEffect(()=>{const x=p.current;if(x){const y=b=>{var S,T,E;const C=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!C){const P=document.activeElement,_=b.shiftKey;if(b.target===x&&_){(S=c.current)==null||S.focus();return}const F=g({tabbingDirection:_?"backwards":"forwards"}),G=F.findIndex(O=>O===P);ec(F.slice(G+1))?b.preventDefault():_?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(zw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Zl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});ec(x)}}),u.jsx(Yl.Slot,{scope:n,children:u.jsx(fe.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Zl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});ec(x)}})]})});zg.displayName=Bg;var Hg="ToastFocusProxy",Zl=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=gi(Hg,n);return u.jsx(ai,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Zl.displayName=Hg;var Mo="Toast",fI="toast.swipeStart",pI="toast.swipeMove",hI="toast.swipeCancel",mI="toast.swipeEnd",Ug=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=On({prop:r,defaultProp:o??!0,onChange:s,caller:Mo});return u.jsx(Ut,{present:n||a,children:u.jsx(vI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:pt(e.onPause),onResume:pt(e.onResume),onSwipeStart:ie(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ie(e.onSwipeMove,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${p}px`)}),onSwipeCancel:ie(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ie(e.onSwipeEnd,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${p}px`),l(!1)})})})});Ug.displayName=Mo;var[gI,xI]=$g(Mo,{onClose(){}}),vI=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:p,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=gi(Mo,n),[x,y]=h.useState(null),b=De(t,O=>y(O)),C=h.useRef(null),k=h.useRef(null),S=o||g.duration,T=h.useRef(0),E=h.useRef(S),P=h.useRef(0),{onToastAdd:_,onToastRemove:$}=g,L=pt(()=>{var K;(x==null?void 0:x.contains(document.activeElement))&&((K=g.viewport)==null||K.focus()),i()}),F=h.useCallback(O=>{!O||O===1/0||(window.clearTimeout(P.current),T.current=new Date().getTime(),P.current=window.setTimeout(L,O))},[L]);h.useEffect(()=>{const O=g.viewport;if(O){const K=()=>{F(E.current),c==null||c()},q=()=>{const H=new Date().getTime()-T.current;E.current=E.current-H,window.clearTimeout(P.current),l==null||l()};return O.addEventListener(Xl,q),O.addEventListener(Jl,K),()=>{O.removeEventListener(Xl,q),O.removeEventListener(Jl,K)}}},[g.viewport,S,l,c,F]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&F(S)},[s,S,g.isClosePausedRef,F]),h.useEffect(()=>(_(),()=>$()),[_,$]);const G=h.useMemo(()=>x?Xg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[G&&u.jsx(wI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:G}),u.jsx(gI,{scope:n,onClose:L,children:Kr.createPortal(u.jsx(Yl.ItemSlot,{scope:n,children:u.jsx(Bw,{asChild:!0,onEscapeKeyDown:ie(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||L(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(fe.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ie(e.onKeyDown,O=>{O.key==="Escape"&&(a==null||a(O.nativeEvent),O.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,L()))}),onPointerDown:ie(e.onPointerDown,O=>{O.button===0&&(C.current={x:O.clientX,y:O.clientY})}),onPointerMove:ie(e.onPointerMove,O=>{if(!C.current)return;const K=O.clientX-C.current.x,q=O.clientY-C.current.y,H=!!k.current,j=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,Y=j?I(0,K):0,J=j?0:I(0,q),D=O.pointerType==="touch"?10:2,V={x:Y,y:J},R={originalEvent:O,delta:V};H?(k.current=V,xi(pI,p,R,{discrete:!1})):Jg(V,g.swipeDirection,D)?(k.current=V,xi(fI,d,R,{discrete:!1}),O.target.setPointerCapture(O.pointerId)):(Math.abs(K)>D||Math.abs(q)>D)&&(C.current=null)}),onPointerUp:ie(e.onPointerUp,O=>{const K=k.current,q=O.target;if(q.hasPointerCapture(O.pointerId)&&q.releasePointerCapture(O.pointerId),k.current=null,C.current=null,K){const H=O.currentTarget,j={originalEvent:O,delta:K};Jg(K,g.swipeDirection,g.swipeThreshold)?xi(mI,f,j,{discrete:!0}):xi(hI,m,j,{discrete:!0}),H.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),wI=e=>{const{__scopeToast:t,children:n,...r}=e,o=gi(Mo,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return SI(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(ao,{asChild:!0,children:u.jsx(ai,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},bI="ToastTitle",Wg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(fe.div,{...r,ref:t})});Wg.displayName=bI;var yI="ToastDescription",Vg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(fe.div,{...r,ref:t})});Vg.displayName=yI;var Kg="ToastAction",qg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Yg,{altText:n,asChild:!0,children:u.jsx(Ql,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Kg}\`. Expected non-empty \`string\`.`),null)});qg.displayName=Kg;var Gg="ToastClose",Ql=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=xI(Gg,n);return u.jsx(Yg,{asChild:!0,children:u.jsx(fe.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,o.onClose)})})});Ql.displayName=Gg;var Yg=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(fe.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Xg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),CI(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...Xg(r))}}),t}function xi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Ki(o,s):o.dispatchEvent(s)}var Jg=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function SI(e=()=>{}){const t=pt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function CI(e){return e.nodeType===e.ELEMENT_NODE}function TI(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 ec(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var kI=Fg,Zg=zg,Qg=Ug,ex=Wg,tx=Vg,nx=qg,rx=Ql;const EI=kI,ox=h.forwardRef(({className:e,...t},n)=>u.jsx(Zg,{ref:n,className:re("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));ox.displayName=Zg.displayName;const II=Vr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),sx=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Qg,{ref:r,className:re(II({variant:t}),e),...n}));sx.displayName=Qg.displayName;const NI=h.forwardRef(({className:e,...t},n)=>u.jsx(nx,{ref:n,className:re("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));NI.displayName=nx.displayName;const ix=h.forwardRef(({className:e,...t},n)=>u.jsx(rx,{ref:n,className:re("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(ce.X,{className:"h-4 w-4"})}));ix.displayName=rx.displayName;const ax=h.forwardRef(({className:e,...t},n)=>u.jsx(ex,{ref:n,className:re("text-sm font-semibold",e),...t}));ax.displayName=ex.displayName;const lx=h.forwardRef(({className:e,...t},n)=>u.jsx(tx,{ref:n,className:re("text-sm opacity-90",e),...t}));lx.displayName=tx.displayName;function AI(){const{toasts:e}=cl();return u.jsxs(EI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(sx,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(ax,{children:n}),r&&u.jsx(lx,{children:r})]}),o,u.jsx(ix,{})]},t)}),u.jsx(ox,{})]})}var PI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),p(f)}function p(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},jI=h.createContext(void 0),_I={setTheme:e=>{},themes:[]},RI=()=>{var e;return(e=h.useContext(jI))!=null?e:_I};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${PI.toString()})(${d})`}})});var MI=e=>{switch(e){case"success":return LI;case"info":return FI;case"warning":return $I;case"error":return BI;default:return null}},OI=Array(12).fill(0),DI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},OI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),LI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),$I=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),FI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),BI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),zI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},w.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),w.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),HI=()=>{let[e,t]=w.useState(document.hidden);return w.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},tc=1,UI=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:tc++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],w.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(VI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||tc++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Kt=new UI,WI=(e,t)=>{let n=(t==null?void 0:t.id)||tc++;return Kt.addToast({title:e,...t,id:n}),n},VI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",KI=WI,qI=()=>Kt.toasts,GI=()=>Kt.getActiveToasts();Object.assign(KI,{success:Kt.success,info:Kt.info,warning:Kt.warning,error:Kt.error,custom:Kt.custom,message:Kt.message,promise:Kt.promise,dismiss:Kt.dismiss,loading:Kt.loading},{getHistory:qI,getToasts:GI});function YI(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}YI(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
131
|
+
`);function vi(e){return e.label!==void 0}var XI=3,JI="32px",ZI="16px",cx=4e3,QI=356,eN=14,tN=20,nN=200;function gn(...e){return e.filter(Boolean).join(" ")}function rN(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var oN=e=>{var t,n,r,o,s,i,a,l,c,d,p;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:b,index:C,toasts:k,expanded:S,removeToast:T,defaultRichColors:E,closeButton:P,style:_,cancelButtonStyle:$,actionButtonStyle:L,className:F="",descriptionClassName:G="",duration:O,position:K,gap:q,loadingIcon:H,expandByDefault:j,classNames:I,icons:Y,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:D}=e,[V,R]=w.useState(null),[B,X]=w.useState(null),[N,M]=w.useState(!1),[U,Z]=w.useState(!1),[se,ae]=w.useState(!1),[Ce,we]=w.useState(!1),[je,We]=w.useState(!1),[Fe,Ye]=w.useState(0),[He,vt]=w.useState(0),wt=w.useRef(f.duration||O||cx),dt=w.useRef(null),Ve=w.useRef(null),Ae=C===0,Ke=C+1<=y,_e=f.type,Be=f.dismissible!==!1,Qe=f.className||"",Nt=f.descriptionClassName||"",et=w.useMemo(()=>b.findIndex(me=>me.toastId===f.id)||0,[b,f.id]),bt=w.useMemo(()=>{var me;return(me=f.closeButton)!=null?me:P},[f.closeButton,P]),mt=w.useMemo(()=>f.duration||O||cx,[f.duration,O]),Ct=w.useRef(0),Tt=w.useRef(0),Dt=w.useRef(0),Pt=w.useRef(null),[kt,qt]=K.split("-"),Ue=w.useMemo(()=>b.reduce((me,Oe,qe)=>qe>=et?me:me+Oe.height,0),[b,et]),$e=HI(),ct=f.invert||m,ne=_e==="loading";Tt.current=w.useMemo(()=>et*q+Ue,[et,Ue]),w.useEffect(()=>{wt.current=mt},[mt]),w.useEffect(()=>{M(!0)},[]),w.useEffect(()=>{let me=Ve.current;if(me){let Oe=me.getBoundingClientRect().height;return vt(Oe),x(qe=>[{toastId:f.id,height:Oe,position:f.position},...qe]),()=>x(qe=>qe.filter(ut=>ut.toastId!==f.id))}},[x,f.id]),w.useLayoutEffect(()=>{if(!N)return;let me=Ve.current,Oe=me.style.height;me.style.height="auto";let qe=me.getBoundingClientRect().height;me.style.height=Oe,vt(qe),x(ut=>ut.find(at=>at.toastId===f.id)?ut.map(at=>at.toastId===f.id?{...at,height:qe}:at):[{toastId:f.id,height:qe,position:f.position},...ut])},[N,f.title,f.description,x,f.id]);let he=w.useCallback(()=>{Z(!0),Ye(Tt.current),x(me=>me.filter(Oe=>Oe.toastId!==f.id)),setTimeout(()=>{T(f)},nN)},[f,T,x,Tt]);w.useEffect(()=>{if(f.promise&&_e==="loading"||f.duration===1/0||f.type==="loading")return;let me;return S||g||D&&$e?(()=>{if(Dt.current<Ct.current){let Oe=new Date().getTime()-Ct.current;wt.current=wt.current-Oe}Dt.current=new Date().getTime()})():wt.current!==1/0&&(Ct.current=new Date().getTime(),me=setTimeout(()=>{var Oe;(Oe=f.onAutoClose)==null||Oe.call(f,f),he()},wt.current)),()=>clearTimeout(me)},[S,g,f,_e,D,$e,he]),w.useEffect(()=>{f.delete&&he()},[he,f.delete]);function tt(){var me,Oe,qe;return Y!=null&&Y.loading?w.createElement("div",{className:gn(I==null?void 0:I.loader,(me=f==null?void 0:f.classNames)==null?void 0:me.loader,"sonner-loader"),"data-visible":_e==="loading"},Y.loading):H?w.createElement("div",{className:gn(I==null?void 0:I.loader,(Oe=f==null?void 0:f.classNames)==null?void 0:Oe.loader,"sonner-loader"),"data-visible":_e==="loading"},H):w.createElement(DI,{className:gn(I==null?void 0:I.loader,(qe=f==null?void 0:f.classNames)==null?void 0:qe.loader),visible:_e==="loading"})}return w.createElement("li",{tabIndex:0,ref:Ve,className:gn(F,Qe,I==null?void 0:I.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[_e],(n=f==null?void 0:f.classNames)==null?void 0:n[_e]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":N,"data-promise":!!f.promise,"data-swiped":je,"data-removed":U,"data-visible":Ke,"data-y-position":kt,"data-x-position":qt,"data-index":C,"data-front":Ae,"data-swiping":se,"data-dismissible":Be,"data-type":_e,"data-invert":ct,"data-swipe-out":Ce,"data-swipe-direction":B,"data-expanded":!!(S||j&&N),style:{"--index":C,"--toasts-before":C,"--z-index":k.length-C,"--offset":`${U?Fe:Tt.current}px`,"--initial-height":j?"auto":`${He}px`,..._,...f.style},onDragEnd:()=>{ae(!1),R(null),Pt.current=null},onPointerDown:me=>{ne||!Be||(dt.current=new Date,Ye(Tt.current),me.target.setPointerCapture(me.pointerId),me.target.tagName!=="BUTTON"&&(ae(!0),Pt.current={x:me.clientX,y:me.clientY}))},onPointerUp:()=>{var me,Oe,qe,ut;if(Ce||!Be)return;Pt.current=null;let at=Number(((me=Ve.current)==null?void 0:me.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),lt=Number(((Oe=Ve.current)==null?void 0:Oe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Et=new Date().getTime()-((qe=dt.current)==null?void 0:qe.getTime()),ke=V==="x"?at:lt,Ee=Math.abs(ke)/Et;if(Math.abs(ke)>=tN||Ee>.11){Ye(Tt.current),(ut=f.onDismiss)==null||ut.call(f,f),X(V==="x"?at>0?"right":"left":lt>0?"down":"up"),he(),we(!0),We(!1);return}ae(!1),R(null)},onPointerMove:me=>{var Oe,qe,ut,at;if(!Pt.current||!Be||((Oe=window.getSelection())==null?void 0:Oe.toString().length)>0)return;let lt=me.clientY-Pt.current.y,Et=me.clientX-Pt.current.x,ke=(qe=e.swipeDirections)!=null?qe:rN(K);!V&&(Math.abs(Et)>1||Math.abs(lt)>1)&&R(Math.abs(Et)>Math.abs(lt)?"x":"y");let Ee={x:0,y:0};V==="y"?(ke.includes("top")||ke.includes("bottom"))&&(ke.includes("top")&<<0||ke.includes("bottom")&<>0)&&(Ee.y=lt):V==="x"&&(ke.includes("left")||ke.includes("right"))&&(ke.includes("left")&&Et<0||ke.includes("right")&&Et>0)&&(Ee.x=Et),(Math.abs(Ee.x)>0||Math.abs(Ee.y)>0)&&We(!0),(ut=Ve.current)==null||ut.style.setProperty("--swipe-amount-x",`${Ee.x}px`),(at=Ve.current)==null||at.style.setProperty("--swipe-amount-y",`${Ee.y}px`)}},bt&&!f.jsx?w.createElement("button",{"aria-label":J,"data-disabled":ne,"data-close-button":!0,onClick:ne||!Be?()=>{}:()=>{var me;he(),(me=f.onDismiss)==null||me.call(f,f)},className:gn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=Y==null?void 0:Y.close)!=null?s:zI):null,f.jsx||w.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:w.createElement(w.Fragment,null,_e||f.icon||f.promise?w.createElement("div",{"data-icon":"",className:gn(I==null?void 0:I.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||tt():null,f.type!=="loading"?f.icon||(Y==null?void 0:Y[_e])||MI(_e):null):null,w.createElement("div",{"data-content":"",className:gn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:gn(I==null?void 0:I.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?w.createElement("div",{"data-description":"",className:gn(G,Nt,I==null?void 0:I.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),w.isValidElement(f.cancel)?f.cancel:f.cancel&&vi(f.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||$,onClick:me=>{var Oe,qe;vi(f.cancel)&&Be&&((qe=(Oe=f.cancel).onClick)==null||qe.call(Oe,me),he())},className:gn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,w.isValidElement(f.action)?f.action:f.action&&vi(f.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||L,onClick:me=>{var Oe,qe;vi(f.action)&&((qe=(Oe=f.action).onClick)==null||qe.call(Oe,me),!me.defaultPrevented&&he())},className:gn(I==null?void 0:I.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function ux(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function sN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?ZI:JI;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var iN=w.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:p,duration:m,style:f,visibleToasts:v=XI,toastOptions:g,dir:x=ux(),gap:y=eN,loadingIcon:b,icons:C,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:S}=e,[T,E]=w.useState([]),P=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(D=>D.position).map(D=>D.position)))),[T,r]),[_,$]=w.useState([]),[L,F]=w.useState(!1),[G,O]=w.useState(!1),[K,q]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),H=w.useRef(null),j=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),Y=w.useRef(!1),J=w.useCallback(D=>{E(V=>{var R;return(R=V.find(B=>B.id===D.id))!=null&&R.delete||Kt.dismiss(D.id),V.filter(({id:B})=>B!==D.id)})},[]);return w.useEffect(()=>Kt.subscribe(D=>{if(D.dismiss){E(V=>V.map(R=>R.id===D.id?{...R,delete:!0}:R));return}setTimeout(()=>{Oo.flushSync(()=>{E(V=>{let R=V.findIndex(B=>B.id===D.id);return R!==-1?[...V.slice(0,R),{...V[R],...D},...V.slice(R+1)]:[D,...V]})})})}),[]),w.useEffect(()=>{if(d!=="system"){q(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;let D=window.matchMedia("(prefers-color-scheme: dark)");try{D.addEventListener("change",({matches:V})=>{q(V?"dark":"light")})}catch{D.addListener(({matches:R})=>{try{q(R?"dark":"light")}catch(B){console.error(B)}})}},[d]),w.useEffect(()=>{T.length<=1&&F(!1)},[T]),w.useEffect(()=>{let D=V=>{var R,B;o.every(X=>V[X]||V.code===X)&&(F(!0),(R=H.current)==null||R.focus()),V.code==="Escape"&&(document.activeElement===H.current||(B=H.current)!=null&&B.contains(document.activeElement))&&F(!1)};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[o]),w.useEffect(()=>{if(H.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,Y.current=!1)}},[H.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${j}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},P.map((D,V)=>{var R;let[B,X]=D.split("-");return T.length?w.createElement("ol",{key:D,dir:x==="auto"?ux():x,tabIndex:-1,ref:H,className:a,"data-sonner-toaster":!0,"data-theme":K,"data-y-position":B,"data-lifted":L&&T.length>1&&!s,"data-x-position":X,style:{"--front-toast-height":`${((R=_[0])==null?void 0:R.height)||0}px`,"--width":`${QI}px`,"--gap":`${y}px`,...f,...sN(l,c)},onBlur:N=>{Y.current&&!N.currentTarget.contains(N.relatedTarget)&&(Y.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:N=>{N.target instanceof HTMLElement&&N.target.dataset.dismissible==="false"||Y.current||(Y.current=!0,I.current=N.relatedTarget)},onMouseEnter:()=>F(!0),onMouseMove:()=>F(!0),onMouseLeave:()=>{G||F(!1)},onDragEnd:()=>F(!1),onPointerDown:N=>{N.target instanceof HTMLElement&&N.target.dataset.dismissible==="false"||O(!0)},onPointerUp:()=>O(!1)},T.filter(N=>!N.position&&V===0||N.position===D).map((N,M)=>{var U,Z;return w.createElement(oN,{key:N.id,icons:C,index:M,toast:N,defaultRichColors:p,duration:(U=g==null?void 0:g.duration)!=null?U:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Z=g==null?void 0:g.closeButton)!=null?Z:i,interacting:G,position:D,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:T.filter(se=>se.position==N.position),heights:_.filter(se=>se.position==N.position),setHeights:$,expandByDefault:s,gap:y,loadingIcon:b,expanded:L,pauseWhenPageIsHidden:S,swipeDirections:e.swipeDirections})})):null}))});const aN=({...e})=>{const{theme:t="system"}=RI();return u.jsx(iN,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};z.Api=Jv,z.ApiClient=Xv,z.ApiProvider=lu,z.ArtifactRenderer=Oh,z.Badge=Wh,z.Button=Je,z.Card=fl,z.CardContent=Qs,z.CardDescription=ml,z.CardHeader=pl,z.CardTitle=hl,z.ChatApi=Yo,z.ChatApp=zk,z.ChatInput=tp,z.ChatInputRow=np,z.ChatInterface=$r,z.ChatProviders=Cr,z.ChatWidget=Wk,z.Command=El,z.CommandEmpty=Al,z.CommandGroup=Pl,z.CommandInput=Il,z.CommandItem=jl,z.CommandList=Nl,z.DEFAULT_TIMEOUT_MS=nu,z.Dialog=il,z.DialogContent=Us,z.DialogHeader=Ws,z.DialogTitle=Vs,z.DropdownMenu=ks,z.DropdownMenuContent=mo,z.DropdownMenuItem=Fn,z.DropdownMenuTrigger=Es,z.FileViewerModal=bh,z.HISTORY_TIMEOUT_MS=ru,z.Input=$l,z.InterruptPartRenderer=gl,z.Label=Tm,z.MarkdownContent=fr,z.MessageComponent=ei,z.MessageList=wl,z.MessageRow=vl,z.NewChatButton=Vk,z.PlotArtifact=Mh,z.SETTINGS_STORAGE_KEY=Vi,z.ScrollArea=Ll,z.Select=TE,z.SelectContent=dg,z.SelectItem=fg,z.SelectTrigger=lg,z.SelectValue=kE,z.Separator=gg,z.Sheet=DE,z.SheetContent=kg,z.SheetDescription=Ng,z.SheetHeader=Eg,z.SheetTitle=Ig,z.SheetTrigger=LE,z.SimpleChat=Hk,z.SimpleJsonView=Zs,z.Sonner=aN,z.StreamProgress=Dh,z.Switch=Cg,z.Textarea=ja,z.ThinkingIndicator=$h,z.ThreadListItem=vm,z.ThreadManager=ii,z.ThreadStateProvider=Lu,z.ThreadsProvider=vu,z.TimelineColumn=Ix,z.Toaster=AI,z.ToolContent=Uh,z.Tooltip=iI,z.TooltipContent=Lg,z.TooltipProvider=sI,z.TooltipTrigger=aI,z.UserTextContent=Fh,z.applySettings=Tw,z.buildCheckpointIndex=sc,z.buildCheckpointPreviewMap=gx,z.buildLabelParts=ku,z.chatApiClient=Nn,z.collectText=yu,z.createArtifactPreviewFromPlot=Iu,z.createArtifactPreviewFromSource=Eu,z.del=Mi,z.downloadFileById=su,z.extractConfigFields=bi,z.extractToolContent=tr,z.extractToolMeta=Jo,z.fileToBase64=cu,z.formatToolOutput=bu,z.get=Jt,z.getAgentNameFromMessage=Cu,z.getChatToken=eu,z.getCheckpointForMessage=xx,z.getCurrentSettings=Cw,z.getDefaultApiConfig=Ku,z.getDefaultChatSettings=qu,z.getFileContent=Di,z.getFileInfo=Qv,z.getMessageAttemptInfo=ic,z.getMessageDomKey=xl,z.getPreviewForMessage=wi,z.getToolProgress=zi,z.httpClient=Xt,z.hydrateHistorySnapshots=Yn,z.isEnvelope=du,z.isFileLike=$i,z.listFiles=iu,z.loadStoredSettings=Gu,z.looksLikeMarkdown=wu,z.messageSignature=Bi,z.normalizeInterruptId=Fi,z.normalizeMimeType=Tu,z.normalizeToolPayload=Nu,z.normalizeToolPayloadValue=Sr,z.onChatTokenChanged=tu,z.parseJsonSafe=Qn,z.post=Go,z.pretty=er,z.processAttachments=uu,z.put=ou,z.readNumber=lc,z.readString=Rn,z.resolveChatBaseUrl=vn,z.sanitizeForDisplay=yr,z.saveSettings=Yu,z.setChatToken=qo,z.stringifyTool=Su,z.toPlainObject=_n,z.unwrap=Lt,z.useApi=eo,z.useCheckpointIndex=ac,z.useFilePreview=Bh,z.useHasChatSession=bw,z.useParsedMessageContent=zh,z.useShallowStableValue=Hu,z.useStream=Wi,z.useStreamingHook=Wi,z.useThreadHistoryState=Ru,z.useThreadManagerViewState=ym,z.useThreadState=no,z.useThreadStateUpdater=Du,z.useThreads=br,z.useThreadsState=gu,z.viewFileById=Zv,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
|