teodor-new-chat-ui 4.3.398 → 4.3.399

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/dist/features/checkpoint/components/TimelineColumn.d.ts +12 -0
  2. package/dist/features/checkpoint/components/index.d.ts +1 -0
  3. package/dist/{hooks/checkpoints → features/checkpoint/hooks}/index.d.ts +0 -1
  4. package/dist/{hooks/checkpoints → features/checkpoint/hooks}/useCheckpointIndex.d.ts +1 -1
  5. package/dist/{hooks/checkpoints → features/checkpoint/hooks}/useMessageMetadata.d.ts +2 -2
  6. package/dist/features/checkpoint/index.d.ts +4 -0
  7. package/dist/{types/checkpoints.d.ts → features/checkpoint/types.d.ts} +1 -0
  8. package/dist/{lib → features/checkpoint/utils}/attemptDetection.d.ts +1 -1
  9. package/dist/{lib → features/checkpoint/utils}/checkpointIndex.d.ts +1 -1
  10. package/dist/features/checkpoint/utils/index.d.ts +7 -0
  11. package/dist/{lib → features/checkpoint/utils}/messageMetadataResolver.d.ts +2 -2
  12. package/dist/{api/chat-api.d.ts → features/core/api/clients/chatClient.d.ts} +2 -3
  13. package/dist/features/core/api/clients/index.d.ts +2 -0
  14. package/dist/features/core/api/index.d.ts +2 -0
  15. package/dist/features/core/api/utils/index.d.ts +1 -0
  16. package/dist/{config → features/core/constants}/env.d.ts +1 -1
  17. package/dist/features/core/constants/index.d.ts +1 -0
  18. package/dist/{context → features/core/contexts}/ChatProviders.d.ts +2 -3
  19. package/dist/features/core/contexts/index.d.ts +6 -0
  20. package/dist/{context → features/core/contexts}/providers/ApiProvider.d.ts +1 -1
  21. package/dist/features/core/contexts/providers/ChatSessionProvider.d.ts +1 -0
  22. package/dist/features/core/hooks/index.d.ts +2 -0
  23. package/dist/features/core/index.d.ts +6 -0
  24. package/dist/{types → features/core/types}/context.d.ts +3 -3
  25. package/dist/features/core/types/index.d.ts +7 -0
  26. package/dist/features/core/utils/index.d.ts +1 -0
  27. package/dist/{components → features/messaging/components}/chat/ChatApp.d.ts +1 -2
  28. package/dist/{components → features/messaging/components}/chat/MessageComponent.d.ts +1 -1
  29. package/dist/{components → features/messaging/components}/chat/MessageList.d.ts +2 -2
  30. package/dist/{components → features/messaging/components}/chat/MessageRow.d.ts +2 -2
  31. package/dist/features/messaging/index.d.ts +12 -0
  32. package/dist/{context/providers/ChatSessionProvider.d.ts → features/streaming/contexts/StreamingProvider.d.ts} +9 -9
  33. package/dist/features/streaming/contexts/index.d.ts +3 -0
  34. package/dist/{context → features/streaming/contexts}/services/use-streaming-service.d.ts +3 -12
  35. package/dist/features/streaming/index.d.ts +3 -0
  36. package/dist/features/streaming/utils/index.d.ts +1 -0
  37. package/dist/features/streaming/utils/types.d.ts +109 -0
  38. package/dist/{hooks → features/thread/hooks}/useThreadHistoryState.d.ts +4 -4
  39. package/dist/{hooks → features/thread/hooks}/useThreadsState.d.ts +2 -2
  40. package/dist/features/thread/index.d.ts +2 -0
  41. package/dist/{hooks → features/ui/hooks}/use-toast.d.ts +3 -3
  42. package/dist/features/ui/index.d.ts +17 -0
  43. package/dist/features/ui/utils/index.d.ts +1 -0
  44. package/dist/index.esm.js +13985 -12997
  45. package/dist/index.umd.js +49 -48
  46. package/dist/lib/index.d.ts +8 -27
  47. package/dist/types/events.d.ts +1 -90
  48. package/dist/types/index.d.ts +1 -3
  49. package/dist/types/marked.d.ts +11 -0
  50. package/dist/types/models.d.ts +80 -104
  51. package/dist/types/requests.d.ts +1 -1
  52. package/package.json +1 -1
  53. package/dist/components/chat/message-components/artifacts/ResearchTaskArtifact.d.ts +0 -20
  54. package/dist/components/settings/ChatSettings.d.ts +0 -30
  55. package/dist/components/ui/accordion.d.ts +0 -7
  56. package/dist/components/ui/alert-dialog.d.ts +0 -20
  57. package/dist/components/ui/alert.d.ts +0 -8
  58. package/dist/components/ui/aspect-ratio.d.ts +0 -3
  59. package/dist/components/ui/avatar.d.ts +0 -6
  60. package/dist/components/ui/breadcrumb.d.ts +0 -19
  61. package/dist/components/ui/calendar.d.ts +0 -8
  62. package/dist/components/ui/carousel.d.ts +0 -18
  63. package/dist/components/ui/chart.d.ts +0 -62
  64. package/dist/components/ui/checkbox.d.ts +0 -4
  65. package/dist/components/ui/collapsible.d.ts +0 -5
  66. package/dist/components/ui/context-menu.d.ts +0 -27
  67. package/dist/components/ui/drawer.d.ts +0 -22
  68. package/dist/components/ui/form.d.ts +0 -23
  69. package/dist/components/ui/hover-card.d.ts +0 -6
  70. package/dist/components/ui/input-otp.d.ts +0 -34
  71. package/dist/components/ui/menubar.d.ts +0 -28
  72. package/dist/components/ui/navigation-menu.d.ts +0 -12
  73. package/dist/components/ui/pagination.d.ts +0 -28
  74. package/dist/components/ui/popover.d.ts +0 -6
  75. package/dist/components/ui/progress.d.ts +0 -4
  76. package/dist/components/ui/radio-group.d.ts +0 -5
  77. package/dist/components/ui/resizable.d.ts +0 -23
  78. package/dist/components/ui/sidebar.d.ts +0 -66
  79. package/dist/components/ui/skeleton.d.ts +0 -2
  80. package/dist/components/ui/slider.d.ts +0 -4
  81. package/dist/components/ui/table.d.ts +0 -10
  82. package/dist/components/ui/tabs.d.ts +0 -7
  83. package/dist/components/ui/toggle-group.d.ts +0 -12
  84. package/dist/components/ui/toggle.d.ts +0 -12
  85. package/dist/components/ui/use-toast.d.ts +0 -2
  86. package/dist/context/index.d.ts +0 -14
  87. package/dist/context/types.d.ts +0 -1
  88. package/dist/hooks/checkpoints/types.d.ts +0 -1
  89. package/dist/hooks/use-mobile.d.ts +0 -1
  90. package/dist/lib/markdown.d.ts +0 -46
  91. package/dist/types/toolStream.d.ts +0 -11
  92. package/dist/utils/env.d.ts +0 -12
  93. /package/dist/{lib → features/checkpoint/utils}/historyUtils.d.ts +0 -0
  94. /package/dist/{lib → features/checkpoint/utils}/messagePreviews.d.ts +0 -0
  95. /package/dist/{lib → features/checkpoint/utils}/schemaUtils.d.ts +0 -0
  96. /package/dist/{api/file-api.d.ts → features/core/api/clients/fileClient.d.ts} +0 -0
  97. /package/dist/{api/utils.d.ts → features/core/api/utils/http.d.ts} +0 -0
  98. /package/dist/{lib → features/core/utils}/chatUtils.d.ts +0 -0
  99. /package/dist/{components → features/messaging/components}/chat/ChatInput.d.ts +0 -0
  100. /package/dist/{components → features/messaging/components}/chat/ChatInterface.d.ts +0 -0
  101. /package/dist/{components → features/messaging/components}/chat/FileViewerModal.d.ts +0 -0
  102. /package/dist/{components → features/messaging/components}/chat/MarkdownContent.d.ts +0 -0
  103. /package/dist/{components → features/messaging/components}/chat/ThreadManager.d.ts +0 -0
  104. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/ArtifactRenderer.d.ts +0 -0
  105. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/InterruptPartRenderer.d.ts +0 -0
  106. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/SimpleJsonView.d.ts +0 -0
  107. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/StreamProgress.d.ts +0 -0
  108. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/ToolComponent.d.ts +0 -0
  109. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/UserTextContent.d.ts +0 -0
  110. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/artifacts/PlotArtifact.d.ts +0 -0
  111. /package/dist/{components/chat/message-components → features/messaging/components/chat/message/artifacts}/ResearchTaskArtifact.d.ts +0 -0
  112. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/index.d.ts +0 -0
  113. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/useFilePreview.d.ts +0 -0
  114. /package/dist/{components → features/messaging/components}/chat/threads/ThreadListItem.d.ts +0 -0
  115. /package/dist/{lib → features/messaging/utils}/messageHelpers.d.ts +0 -0
  116. /package/dist/{lib → features/messaging/utils}/messageUtils.d.ts +0 -0
  117. /package/dist/{context → features/streaming/contexts}/reducers/MessageReducer.d.ts +0 -0
  118. /package/dist/{context → features/streaming/contexts}/reducers/utils/reducerUtils.d.ts +0 -0
  119. /package/dist/{hooks → features/streaming/hooks}/use-stream.d.ts +0 -0
  120. /package/dist/{components → features/ui/components}/ui/badge.d.ts +0 -0
  121. /package/dist/{components → features/ui/components}/ui/button.d.ts +0 -0
  122. /package/dist/{components → features/ui/components}/ui/card.d.ts +0 -0
  123. /package/dist/{components → features/ui/components}/ui/command.d.ts +0 -0
  124. /package/dist/{components → features/ui/components}/ui/dialog.d.ts +0 -0
  125. /package/dist/{components → features/ui/components}/ui/dropdown-menu.d.ts +0 -0
  126. /package/dist/{components → features/ui/components}/ui/input.d.ts +0 -0
  127. /package/dist/{components → features/ui/components}/ui/label.d.ts +0 -0
  128. /package/dist/{components → features/ui/components}/ui/scroll-area.d.ts +0 -0
  129. /package/dist/{components → features/ui/components}/ui/select.d.ts +0 -0
  130. /package/dist/{components → features/ui/components}/ui/separator.d.ts +0 -0
  131. /package/dist/{components → features/ui/components}/ui/sheet.d.ts +0 -0
  132. /package/dist/{components → features/ui/components}/ui/sonner.d.ts +0 -0
  133. /package/dist/{components → features/ui/components}/ui/switch.d.ts +0 -0
  134. /package/dist/{components → features/ui/components}/ui/textarea.d.ts +0 -0
  135. /package/dist/{components → features/ui/components}/ui/toast.d.ts +0 -0
  136. /package/dist/{components → features/ui/components}/ui/toaster.d.ts +0 -0
  137. /package/dist/{components → features/ui/components}/ui/tooltip.d.ts +0 -0
  138. /package/dist/{lib/utils.d.ts → features/ui/utils/cn.d.ts} +0 -0
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(Ee,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],y):(Ee=typeof globalThis<"u"?globalThis:Ee||self,y(Ee.NewChatUI={},Ee.React,Ee.LucideReact,Ee.reactSlot,Ee.classVarianceAuthority,Ee.clsx,Ee.tailwindMerge,Ee.ReactDOM))})(this,function(Ee,y,se,Ln,go,mm,gm,Xs){"use strict";var aT=Object.defineProperty;var lT=(Ee,y,se)=>y in Ee?aT(Ee,y,{enumerable:!0,configurable:!0,writable:!0,value:se}):Ee[y]=se;var hm=(Ee,y,se)=>lT(Ee,typeof y!="symbol"?y+"":y,se);var Js=typeof document<"u"?document.currentScript:null;function ll(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 m=ll(y),xo=ll(Xs);var Zs={exports:{}},Ar={};/**
1
+ (function(G,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("react-dom"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","lucide-react"],w):(G=typeof globalThis<"u"?globalThis:G||self,w(G.NewChatUI={},G.React,G.reactSlot,G.classVarianceAuthority,G.clsx,G.tailwindMerge,G.ReactDOM,G.LucideReact))})(this,function(G,w,Vt,Or,Og,Dg,Eo,de){"use strict";var jI=Object.defineProperty;var PI=(G,w,Vt)=>w in G?jI(G,w,{enumerable:!0,configurable:!0,writable:!0,value:Vt}):G[w]=Vt;var Mg=(G,w,Vt)=>PI(G,typeof w!="symbol"?w+"":w,Vt);function Kl(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=Kl(w),Dr=Kl(Eo);function ql(e,t){var d;let n=[],r=null,o={},s={},i=null,a=null,l=null;if(!(e&&"type"in e&&e.type==="default_message")&&e){const p=e,m=p.checkpointId??null;o=p.additionalKwargs??{},s=p.responseMetadata??{};const f=m?t.checkpointMetaById.get(m)??null:null;i=typeof o.step=="number"?o.step:typeof s.step=="number"?s.step:(f==null?void 0:f.step)??null;const v=typeof o.source=="string"?o.source:typeof s.source=="string"?s.source:(f==null?void 0:f.source)??null;a=v?String(v):null;const g=i!==null&&a?`${i}:${a}`:null;if(g&&t.checkpointIndexByKey.has(g)?n=t.checkpointIndexByKey.get(g)??[]:m&&f&&(n=[f]),r=m??((d=n[0])==null?void 0:d.id)??null,l=m?t.attemptMetaById.get(m)??null:null,!l&&p.role==="user"&&p.id&&t.userMessageIdToAttempts.has(p.id)){const x=t.userMessageIdToAttempts.get(p.id);if(x&&x.length>0){const y=x[0].checkpointId;l=t.attemptMetaById.get(y)??null}}if(!l&&n.length>0){const x=t.attemptMetaById.get(n[0].id);x&&(l=x)}if(l&&l.attemptCount>1){const x=l.baseUserMessageId;if(x){const y=[];for(const[b,S]of t.attemptMetaById.entries())if(S.baseUserMessageId===x){const E=t.checkpointMetaById.get(b);E&&y.push(E)}y.length>0&&(y.sort((b,S)=>{const E=b.createdAt?Date.parse(b.createdAt):0;return(S.createdAt?Date.parse(S.createdAt):0)-E}),n=y)}}}return{checkpointCandidates:n,defaultCheckpointId:r,resolvedStep:i,resolvedSource:a}}function Gl(e,t){return w.useMemo(()=>ql(e,t),[e,t])}function Yl(e){const t=new Map;for(const o of e){const s=o.messages??[];if(!o.checkpointId)continue;let i;for(let l=s.length-1;l>=0;l--){const c=s[l];if(c.role==="user"&&c.id){i=c.id;break}}if(!i)continue;const a=t.get(i)??[];a.push({checkpoint:o,timestamp:Date.parse(o.createdAt??"0")}),t.set(i,a)}const n=new Map,r=new Map;for(const[o,s]of t.entries()){if(!s.length)continue;const i=s.length;i>1&&s.sort((l,c)=>c.timestamp-l.timestamp);const a=[];for(let l=0;l<s.length;l++){const{checkpoint:c}=s[l],d=c.checkpointId;if(!d)continue;const p={attemptIndex:l,attemptCount:i,isLatestAttempt:l===0,baseUserMessageId:o};n.set(d,p),i>1&&a.push({checkpointId:d,attemptIndex:p.attemptIndex,attemptCount:p.attemptCount,isLatestAttempt:p.isLatestAttempt})}a.length&&r.set(o,a)}return{attemptMetaById:n,userMessageIdToAttempts:r}}const Xl=120;function Lg(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>Xl?`${n.slice(0,Xl-3)}…`:n:""}function ko(e){return Lg(e.content)||""}function $g(e){const t=new Map;for(const n of e){if(!n.id||n.role!=="user")continue;const r=ko(n);r&&t.set(n.id,r)}return t}function Fg(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=ko(o);s&&t.set(r.checkpointId,s)}}return t}function Jl(e){const t=new Map,n=new Map,r=[],o=new Map;for(let p=0;p<e.length;p++){const m=e[p],f=m.checkpointId,v=f??`cp-${p}`,g=m.metadata??{},x=typeof g.step=="number"?g.step:null,y=typeof g.source=="string"?g.source:null,b={id:v,step:x,source:y,createdAt:m.createdAt??null,namespace:m.checkpointNs??null,parentId:m.parentId??null};if(f&&(t.set(f,b),x!==null&&y)){const T=`${x}:${y}`,k=n.get(T);k?k.push(b):n.set(T,[b])}let S=null,E=null;const C=Array.isArray(m.messages)?m.messages:[];for(const T of C)T.role==="user"&&(E||(E=T),T.id&&(S=T.id));if(f&&E){const T=ko(E);T&&o.set(f,T)}r.push({id:v,messageId:S,step:x,source:y,createdAt:m.createdAt??null,next:m.next&&m.next.length>0?String(m.next[0]):null,parentConfig:m.parentConfig??null})}const{attemptMetaById:s,userMessageIdToAttempts:i}=Yl(e),a=new Map;for(const[p,m]of t.entries()){const f=s.get(p);f?a.set(p,{...m,attemptIndex:f.attemptIndex,attemptCount:f.attemptCount,isLatestAttempt:f.isLatestAttempt,baseUserMessageId:f.baseUserMessageId??null}):a.set(p,{...m,attemptIndex:0,attemptCount:1,isLatestAttempt:!0,baseUserMessageId:null})}return{checkpoints:e,checkpointMetaById:t,checkpointIndexByKey:n,attemptMetaById:a,userMessageIdToAttempts:i,timeline:r,messagePreviews:o,getLatest:()=>{const p=r[0];if(p)return t.get(p.id)},getCheckpoint:p=>t.get(p),getAttempts:p=>i.get(p)??[]}}function Zl(e){return w.useMemo(()=>Jl(e),[e])}function cr(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Vn(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function Ql(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 ui(e){const t=cr(e);if(t)return cr(t.configurable)??t}function Nn(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)=>Bg(s,i)).filter(s=>!!s)].sort((s,i)=>ec(i.createdAt)-ec(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 Bg(e,t){var b;if(!e)return null;const r=(Array.isArray((b=e.values)==null?void 0:b.messages)?e.values.messages:[]).filter(S=>!!(S&&typeof S=="object"&&typeof S.role=="string")),o=cr(e.metadata)??{},s=ui(e.config),i=cr(e.parent_config??e.parentConfig),a=ui(i),l=Vn(s,["checkpoint_id","checkpointId"]),c=Vn(s,["checkpoint_ns","checkpointNs"]),d=Vn(a,["checkpoint_id","checkpointId"]),p=Vn(a,["checkpoint_id","checkpointId"])??null,m=Vn(a,["checkpoint_ns","checkpointNs"])??null,f=cr(e.config),v=Array.isArray(e.tasks)?e.tasks.map(S=>({...S})):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:Ql(o,["step"])??0,source:Vn(o,["source"])??null};return{checkpointId:l??null,checkpointNs:c??null,createdAt:x,parentId:d??null,messages:r,nextCursor:p,nextCursorNs:m,interrupt:zg(r,t),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:v}}function zg(e,t){return Hg(e,t)}function Hg(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 ec(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var di={exports:{}},Lr={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var cl;function xm(){if(cl)return Ar;cl=1;var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,u){var d,f={},h=null,p=null;u!==void 0&&(h=""+u),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(p=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:t,type:a,key:h,ref:p,props:f,_owner:o.current}}return Ar.Fragment=n,Ar.jsx=i,Ar.jsxs=i,Ar}var jr={};/**
9
+ */var tc;function Ug(){if(tc)return Lr;tc=1;var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,c){var d,p={},m=null,f=null;c!==void 0&&(m=""+c),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(f=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(p[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)p[d]===void 0&&(p[d]=l[d]);return{$$typeof:t,type:a,key:m,ref:f,props:p,_owner:o.current}}return Lr.Fragment=n,Lr.jsx=i,Lr.jsxs=i,Lr}var $r={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,30 +14,30 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var ul;function wm(){return ul||(ul=1,process.env.NODE_ENV!=="production"&&function(){var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),v=Symbol.iterator,x="@@iterator";function g(I){if(I===null||typeof I!="object")return null;var Q=v&&I[v]||I[x];return typeof Q=="function"?Q:null}var w=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(I){{for(var Q=arguments.length,ce=new Array(Q>1?Q-1:0),Ne=1;Ne<Q;Ne++)ce[Ne-1]=arguments[Ne];S("error",I,ce)}}function S(I,Q,ce){{var Ne=w.ReactDebugCurrentFrame,ae=Ne.getStackAddendum();ae!==""&&(Q+="%s",ce=ce.concat([ae]));var ge=ce.map(function(ue){return String(ue)});ge.unshift("Warning: "+Q),Function.prototype.apply.call(console[I],console,ge)}}var T=!1,C=!1,k=!1,E=!1,A=!1,L;L=Symbol.for("react.module.reference");function B(I){return!!(typeof I=="string"||typeof I=="function"||I===r||I===s||A||I===o||I===u||I===d||E||I===p||T||C||k||typeof I=="object"&&I!==null&&(I.$$typeof===h||I.$$typeof===f||I.$$typeof===i||I.$$typeof===a||I.$$typeof===l||I.$$typeof===L||I.getModuleId!==void 0))}function W(I,Q,ce){var Ne=I.displayName;if(Ne)return Ne;var ae=Q.displayName||Q.name||"";return ae!==""?ce+"("+ae+")":ce}function K(I){return I.displayName||"Context"}function H(I){if(I==null)return null;if(typeof I.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof I=="function")return I.displayName||I.name||null;if(typeof I=="string")return I;switch(I){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof I=="object")switch(I.$$typeof){case a:var Q=I;return K(Q)+".Consumer";case i:var ce=I;return K(ce._context)+".Provider";case l:return W(I,I.render,"ForwardRef");case f:var Ne=I.displayName||null;return Ne!==null?Ne:H(I.type)||"Memo";case h:{var ae=I,ge=ae._payload,ue=ae._init;try{return H(ue(ge))}catch{return null}}}return null}var R=Object.assign,G=0,N,$,P,j,U,V,M;function F(){}F.__reactDisabledLog=!0;function ee(){{if(G===0){N=console.log,$=console.info,P=console.warn,j=console.error,U=console.group,V=console.groupCollapsed,M=console.groupEnd;var I={configurable:!0,enumerable:!0,value:F,writable:!0};Object.defineProperties(console,{info:I,log:I,warn:I,error:I,group:I,groupCollapsed:I,groupEnd:I})}G++}}function J(){{if(G--,G===0){var I={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:R({},I,{value:N}),info:R({},I,{value:$}),warn:R({},I,{value:P}),error:R({},I,{value:j}),group:R({},I,{value:U}),groupCollapsed:R({},I,{value:V}),groupEnd:R({},I,{value:M})})}G<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ie=w.ReactCurrentDispatcher,q;function O(I,Q,ce){{if(q===void 0)try{throw Error()}catch(ae){var Ne=ae.stack.trim().match(/\n( *(at )?)/);q=Ne&&Ne[1]||""}return`
18
- `+q+I}}var Y=!1,X;{var le=typeof WeakMap=="function"?WeakMap:Map;X=new le}function D(I,Q){if(!I||Y)return"";{var ce=X.get(I);if(ce!==void 0)return ce}var Ne;Y=!0;var ae=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ge;ge=ie.current,ie.current=null,ee();try{if(Q){var ue=function(){throw Error()};if(Object.defineProperty(ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ue,[])}catch(Ft){Ne=Ft}Reflect.construct(I,[],ue)}else{try{ue.call()}catch(Ft){Ne=Ft}I.call(ue.prototype)}}else{try{throw Error()}catch(Ft){Ne=Ft}I()}}catch(Ft){if(Ft&&Ne&&typeof Ft.stack=="string"){for(var ye=Ft.stack.split(`
19
- `),gt=Ne.stack.split(`
20
- `),Xe=ye.length-1,xt=gt.length-1;Xe>=1&&xt>=0&&ye[Xe]!==gt[xt];)xt--;for(;Xe>=1&&xt>=0;Xe--,xt--)if(ye[Xe]!==gt[xt]){if(Xe!==1||xt!==1)do if(Xe--,xt--,xt<0||ye[Xe]!==gt[xt]){var Zt=`
21
- `+ye[Xe].replace(" at new "," at ");return I.displayName&&Zt.includes("<anonymous>")&&(Zt=Zt.replace("<anonymous>",I.displayName)),typeof I=="function"&&X.set(I,Zt),Zt}while(Xe>=1&&xt>=0);break}}}finally{Y=!1,ie.current=ge,J(),Error.prepareStackTrace=ae}var Nr=I?I.displayName||I.name:"",or=Nr?O(Nr):"";return typeof I=="function"&&X.set(I,or),or}function te(I,Q,ce){return D(I,!1)}function xe(I){var Q=I.prototype;return!!(Q&&Q.isReactComponent)}function de(I,Q,ce){if(I==null)return"";if(typeof I=="function")return D(I,xe(I));if(typeof I=="string")return O(I);switch(I){case u:return O("Suspense");case d:return O("SuspenseList")}if(typeof I=="object")switch(I.$$typeof){case l:return te(I.render);case f:return de(I.type,Q,ce);case h:{var Ne=I,ae=Ne._payload,ge=Ne._init;try{return de(ge(ae),Q,ce)}catch{}}}return""}var we=Object.prototype.hasOwnProperty,je={},De=w.ReactDebugCurrentFrame;function $e(I){if(I){var Q=I._owner,ce=de(I.type,I._source,Q?Q.type:null);De.setExtraStackFrame(ce)}else De.setExtraStackFrame(null)}function ke(I,Q,ce,Ne,ae){{var ge=Function.call.bind(we);for(var ue in I)if(ge(I,ue)){var ye=void 0;try{if(typeof I[ue]!="function"){var gt=Error((Ne||"React class")+": "+ce+" type `"+ue+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof I[ue]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw gt.name="Invariant Violation",gt}ye=I[ue](Q,ue,Ne,ce,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Xe){ye=Xe}ye&&!(ye instanceof Error)&&($e(ae),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ne||"React class",ce,ue,typeof ye),$e(null)),ye instanceof Error&&!(ye.message in je)&&(je[ye.message]=!0,$e(ae),b("Failed %s type: %s",ce,ye.message),$e(null))}}}var Fe=Array.isArray;function Ke(I){return Fe(I)}function Je(I){{var Q=typeof Symbol=="function"&&Symbol.toStringTag,ce=Q&&I[Symbol.toStringTag]||I.constructor.name||"Object";return ce}}function qe(I){try{return tt(I),!1}catch{return!0}}function tt(I){return""+I}function bt(I){if(qe(I))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Je(I)),tt(I)}var st=w.ReactCurrentOwner,Te={key:!0,ref:!0,__self:!0,__source:!0},Le,ot;function ct(I){if(we.call(I,"ref")){var Q=Object.getOwnPropertyDescriptor(I,"ref").get;if(Q&&Q.isReactWarning)return!1}return I.ref!==void 0}function Nt(I){if(we.call(I,"key")){var Q=Object.getOwnPropertyDescriptor(I,"key").get;if(Q&&Q.isReactWarning)return!1}return I.key!==void 0}function it(I,Q){typeof I.ref=="string"&&st.current}function Ye(I,Q){{var ce=function(){Le||(Le=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",Q))};ce.isReactWarning=!0,Object.defineProperty(I,"key",{get:ce,configurable:!0})}}function Mt(I,Q){{var ce=function(){ot||(ot=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",Q))};ce.isReactWarning=!0,Object.defineProperty(I,"ref",{get:ce,configurable:!0})}}var ze=function(I,Q,ce,Ne,ae,ge,ue){var ye={$$typeof:t,type:I,key:Q,ref:ce,props:ue,_owner:ge};return ye._store={},Object.defineProperty(ye._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ye,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ne}),Object.defineProperty(ye,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ae}),Object.freeze&&(Object.freeze(ye.props),Object.freeze(ye)),ye};function Be(I,Q,ce,Ne,ae){{var ge,ue={},ye=null,gt=null;ce!==void 0&&(bt(ce),ye=""+ce),Nt(Q)&&(bt(Q.key),ye=""+Q.key),ct(Q)&&(gt=Q.ref,it(Q,ae));for(ge in Q)we.call(Q,ge)&&!Te.hasOwnProperty(ge)&&(ue[ge]=Q[ge]);if(I&&I.defaultProps){var Xe=I.defaultProps;for(ge in Xe)ue[ge]===void 0&&(ue[ge]=Xe[ge])}if(ye||gt){var xt=typeof I=="function"?I.displayName||I.name||"Unknown":I;ye&&Ye(ue,xt),gt&&Mt(ue,xt)}return ze(I,ye,gt,ae,Ne,st.current,ue)}}var yt=w.ReactCurrentOwner,ht=w.ReactDebugCurrentFrame;function He(I){if(I){var Q=I._owner,ce=de(I.type,I._source,Q?Q.type:null);ht.setExtraStackFrame(ce)}else ht.setExtraStackFrame(null)}var mt;mt=!1;function _(I){return typeof I=="object"&&I!==null&&I.$$typeof===t}function ne(){{if(yt.current){var I=H(yt.current.type);if(I)return`
17
+ */var nc;function Wg(){return nc||(nc=1,process.env.NODE_ENV!=="production"&&function(){var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(A){if(A===null||typeof A!="object")return null;var ne=v&&A[v]||A[g];return typeof ne=="function"?ne:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(A){{for(var ne=arguments.length,pe=new Array(ne>1?ne-1:0),Pe=1;Pe<ne;Pe++)pe[Pe-1]=arguments[Pe];S("error",A,pe)}}function S(A,ne,pe){{var Pe=y.ReactDebugCurrentFrame,ue=Pe.getStackAddendum();ue!==""&&(ne+="%s",pe=pe.concat([ue]));var be=pe.map(function(he){return String(he)});be.unshift("Warning: "+ne),Function.prototype.apply.call(console[A],console,be)}}var E=!1,C=!1,T=!1,k=!1,j=!1,D;D=Symbol.for("react.module.reference");function B(A){return!!(typeof A=="string"||typeof A=="function"||A===r||A===s||j||A===o||A===c||A===d||k||A===f||E||C||T||typeof A=="object"&&A!==null&&(A.$$typeof===m||A.$$typeof===p||A.$$typeof===i||A.$$typeof===a||A.$$typeof===l||A.$$typeof===D||A.getModuleId!==void 0))}function W(A,ne,pe){var Pe=A.displayName;if(Pe)return Pe;var ue=ne.displayName||ne.name||"";return ue!==""?pe+"("+ue+")":pe}function K(A){return A.displayName||"Context"}function z(A){if(A==null)return null;if(typeof A.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof A=="object")switch(A.$$typeof){case a:var ne=A;return K(ne)+".Consumer";case i:var pe=A;return K(pe._context)+".Provider";case l:return W(A,A.render,"ForwardRef");case p:var Pe=A.displayName||null;return Pe!==null?Pe:z(A.type)||"Memo";case m:{var ue=A,be=ue._payload,he=ue._init;try{return z(he(be))}catch{return null}}}return null}var _=Object.assign,Y=0,N,$,R,I,H,q,P;function O(){}O.__reactDisabledLog=!0;function X(){{if(Y===0){N=console.log,$=console.info,R=console.warn,I=console.error,H=console.group,q=console.groupCollapsed,P=console.groupEnd;var A={configurable:!0,enumerable:!0,value:O,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}Y++}}function J(){{if(Y--,Y===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:_({},A,{value:N}),info:_({},A,{value:$}),warn:_({},A,{value:R}),error:_({},A,{value:I}),group:_({},A,{value:H}),groupCollapsed:_({},A,{value:q}),groupEnd:_({},A,{value:P})})}Y<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var se=y.ReactCurrentDispatcher,V;function L(A,ne,pe){{if(V===void 0)try{throw Error()}catch(ue){var Pe=ue.stack.trim().match(/\n( *(at )?)/);V=Pe&&Pe[1]||""}return`
18
+ `+V+A}}var Z=!1,Q;{var ce=typeof WeakMap=="function"?WeakMap:Map;Q=new ce}function F(A,ne){if(!A||Z)return"";{var pe=Q.get(A);if(pe!==void 0)return pe}var Pe;Z=!0;var ue=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var be;be=se.current,se.current=null,X();try{if(ne){var he=function(){throw Error()};if(Object.defineProperty(he.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(he,[])}catch(Wt){Pe=Wt}Reflect.construct(A,[],he)}else{try{he.call()}catch(Wt){Pe=Wt}A.call(he.prototype)}}else{try{throw Error()}catch(Wt){Pe=Wt}A()}}catch(Wt){if(Wt&&Pe&&typeof Wt.stack=="string"){for(var Ee=Wt.stack.split(`
19
+ `),St=Pe.stack.split(`
20
+ `),tt=Ee.length-1,Ct=St.length-1;tt>=1&&Ct>=0&&Ee[tt]!==St[Ct];)Ct--;for(;tt>=1&&Ct>=0;tt--,Ct--)if(Ee[tt]!==St[Ct]){if(tt!==1||Ct!==1)do if(tt--,Ct--,Ct<0||Ee[tt]!==St[Ct]){var rn=`
21
+ `+Ee[tt].replace(" at new "," at ");return A.displayName&&rn.includes("<anonymous>")&&(rn=rn.replace("<anonymous>",A.displayName)),typeof A=="function"&&Q.set(A,rn),rn}while(tt>=1&&Ct>=0);break}}}finally{Z=!1,se.current=be,J(),Error.prepareStackTrace=ue}var Rr=A?A.displayName||A.name:"",lr=Rr?L(Rr):"";return typeof A=="function"&&Q.set(A,lr),lr}function oe(A,ne,pe){return F(A,!1)}function we(A){var ne=A.prototype;return!!(ne&&ne.isReactComponent)}function fe(A,ne,pe){if(A==null)return"";if(typeof A=="function")return F(A,we(A));if(typeof A=="string")return L(A);switch(A){case c:return L("Suspense");case d:return L("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case l:return oe(A.render);case p:return fe(A.type,ne,pe);case m:{var Pe=A,ue=Pe._payload,be=Pe._init;try{return fe(be(ue),ne,pe)}catch{}}}return""}var xe=Object.prototype.hasOwnProperty,_e={},$e=y.ReactDebugCurrentFrame;function Ue(A){if(A){var ne=A._owner,pe=fe(A.type,A._source,ne?ne.type:null);$e.setExtraStackFrame(pe)}else $e.setExtraStackFrame(null)}function Ne(A,ne,pe,Pe,ue){{var be=Function.call.bind(xe);for(var he in A)if(be(A,he)){var Ee=void 0;try{if(typeof A[he]!="function"){var St=Error((Pe||"React class")+": "+pe+" type `"+he+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[he]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw St.name="Invariant Violation",St}Ee=A[he](ne,he,Pe,pe,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(tt){Ee=tt}Ee&&!(Ee instanceof Error)&&(Ue(ue),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Pe||"React class",pe,he,typeof Ee),Ue(null)),Ee instanceof Error&&!(Ee.message in _e)&&(_e[Ee.message]=!0,Ue(ue),b("Failed %s type: %s",pe,Ee.message),Ue(null))}}}var Oe=Array.isArray;function Ye(A){return Oe(A)}function We(A){{var ne=typeof Symbol=="function"&&Symbol.toStringTag,pe=ne&&A[Symbol.toStringTag]||A.constructor.name||"Object";return pe}}function Je(A){try{return ot(A),!1}catch{return!0}}function ot(A){return""+A}function nt(A){if(Je(A))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",We(A)),ot(A)}var Ze=y.ReactCurrentOwner,Ae={key:!0,ref:!0,__self:!0,__source:!0},Be,et;function ct(A){if(xe.call(A,"ref")){var ne=Object.getOwnPropertyDescriptor(A,"ref").get;if(ne&&ne.isReactWarning)return!1}return A.ref!==void 0}function Et(A){if(xe.call(A,"key")){var ne=Object.getOwnPropertyDescriptor(A,"key").get;if(ne&&ne.isReactWarning)return!1}return A.key!==void 0}function st(A,ne){typeof A.ref=="string"&&Ze.current}function Ve(A,ne){{var pe=function(){Be||(Be=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",ne))};pe.isReactWarning=!0,Object.defineProperty(A,"key",{get:pe,configurable:!0})}}function It(A,ne){{var pe=function(){et||(et=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",ne))};pe.isReactWarning=!0,Object.defineProperty(A,"ref",{get:pe,configurable:!0})}}var De=function(A,ne,pe,Pe,ue,be,he){var Ee={$$typeof:t,type:A,key:ne,ref:pe,props:he,_owner:be};return Ee._store={},Object.defineProperty(Ee._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Ee,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Pe}),Object.defineProperty(Ee,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ue}),Object.freeze&&(Object.freeze(Ee.props),Object.freeze(Ee)),Ee};function Ke(A,ne,pe,Pe,ue){{var be,he={},Ee=null,St=null;pe!==void 0&&(nt(pe),Ee=""+pe),Et(ne)&&(nt(ne.key),Ee=""+ne.key),ct(ne)&&(St=ne.ref,st(ne,ue));for(be in ne)xe.call(ne,be)&&!Ae.hasOwnProperty(be)&&(he[be]=ne[be]);if(A&&A.defaultProps){var tt=A.defaultProps;for(be in tt)he[be]===void 0&&(he[be]=tt[be])}if(Ee||St){var Ct=typeof A=="function"?A.displayName||A.name||"Unknown":A;Ee&&Ve(he,Ct),St&&It(he,Ct)}return De(A,Ee,St,ue,Pe,Ze.current,he)}}var yt=y.ReactCurrentOwner,ht=y.ReactDebugCurrentFrame;function qe(A){if(A){var ne=A._owner,pe=fe(A.type,A._source,ne?ne.type:null);ht.setExtraStackFrame(pe)}else ht.setExtraStackFrame(null)}var gt;gt=!1;function M(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function ee(){{if(yt.current){var A=z(yt.current.type);if(A)return`
22
22
 
23
- Check the render method of \``+I+"`."}return""}}function me(I){return""}var Ue={};function Pe(I){{var Q=ne();if(!Q){var ce=typeof I=="string"?I:I.displayName||I.name;ce&&(Q=`
23
+ Check the render method of \``+A+"`."}return""}}function ve(A){return""}var ae={};function ke(A){{var ne=ee();if(!ne){var pe=typeof A=="string"?A:A.displayName||A.name;pe&&(ne=`
24
24
 
25
- Check the top-level render call using <`+ce+">.")}return Q}}function vt(I,Q){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var ce=Pe(Q);if(Ue[ce])return;Ue[ce]=!0;var Ne="";I&&I._owner&&I._owner!==yt.current&&(Ne=" It was passed a child from "+H(I._owner.type)+"."),He(I),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ce,Ne),He(null)}}function et(I,Q){{if(typeof I!="object")return;if(Ke(I))for(var ce=0;ce<I.length;ce++){var Ne=I[ce];_(Ne)&&vt(Ne,Q)}else if(_(I))I._store&&(I._store.validated=!0);else if(I){var ae=g(I);if(typeof ae=="function"&&ae!==I.entries)for(var ge=ae.call(I),ue;!(ue=ge.next()).done;)_(ue.value)&&vt(ue.value,Q)}}}function $t(I){{var Q=I.type;if(Q==null||typeof Q=="string")return;var ce;if(typeof Q=="function")ce=Q.propTypes;else if(typeof Q=="object"&&(Q.$$typeof===l||Q.$$typeof===f))ce=Q.propTypes;else return;if(ce){var Ne=H(Q);ke(ce,I.props,"prop",Ne,I)}else if(Q.PropTypes!==void 0&&!mt){mt=!0;var ae=H(Q);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ae||"Unknown")}typeof Q.getDefaultProps=="function"&&!Q.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function rr(I){{for(var Q=Object.keys(I.props),ce=0;ce<Q.length;ce++){var Ne=Q[ce];if(Ne!=="children"&&Ne!=="key"){He(I),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ne),He(null);break}}I.ref!==null&&(He(I),b("Invalid attribute `ref` supplied to `React.Fragment`."),He(null))}}var qs={};function Gs(I,Q,ce,Ne,ae,ge){{var ue=B(I);if(!ue){var ye="";(I===void 0||typeof I=="object"&&I!==null&&Object.keys(I).length===0)&&(ye+=" 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 gt=me();gt?ye+=gt:ye+=ne();var Xe;I===null?Xe="null":Ke(I)?Xe="array":I!==void 0&&I.$$typeof===t?(Xe="<"+(H(I.type)||"Unknown")+" />",ye=" Did you accidentally export a JSX literal instead of a component?"):Xe=typeof I,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Xe,ye)}var xt=Be(I,Q,ce,ae,ge);if(xt==null)return xt;if(ue){var Zt=Q.children;if(Zt!==void 0)if(Ne)if(Ke(Zt)){for(var Nr=0;Nr<Zt.length;Nr++)et(Zt[Nr],I);Object.freeze&&Object.freeze(Zt)}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 et(Zt,I)}if(we.call(Q,"key")){var or=H(I),Ft=Object.keys(Q).filter(function(iT){return iT!=="key"}),al=Ft.length>0?"{key: someKey, "+Ft.join(": ..., ")+": ...}":"{key: someKey}";if(!qs[or+al]){var sT=Ft.length>0?"{"+Ft.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+pe+">.")}return ne}}function Te(A,ne){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var pe=ke(ne);if(ae[pe])return;ae[pe]=!0;var Pe="";A&&A._owner&&A._owner!==yt.current&&(Pe=" It was passed a child from "+z(A._owner.type)+"."),qe(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.',pe,Pe),qe(null)}}function it(A,ne){{if(typeof A!="object")return;if(Ye(A))for(var pe=0;pe<A.length;pe++){var Pe=A[pe];M(Pe)&&Te(Pe,ne)}else if(M(A))A._store&&(A._store.validated=!0);else if(A){var ue=x(A);if(typeof ue=="function"&&ue!==A.entries)for(var be=ue.call(A),he;!(he=be.next()).done;)M(he.value)&&Te(he.value,ne)}}}function Ge(A){{var ne=A.type;if(ne==null||typeof ne=="string")return;var pe;if(typeof ne=="function")pe=ne.propTypes;else if(typeof ne=="object"&&(ne.$$typeof===l||ne.$$typeof===p))pe=ne.propTypes;else return;if(pe){var Pe=z(ne);Ne(pe,A.props,"prop",Pe,A)}else if(ne.PropTypes!==void 0&&!gt){gt=!0;var ue=z(ne);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ue||"Unknown")}typeof ne.getDefaultProps=="function"&&!ne.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function mt(A){{for(var ne=Object.keys(A.props),pe=0;pe<ne.length;pe++){var Pe=ne[pe];if(Pe!=="children"&&Pe!=="key"){qe(A),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Pe),qe(null);break}}A.ref!==null&&(qe(A),b("Invalid attribute `ref` supplied to `React.Fragment`."),qe(null))}}var Ut={};function Mt(A,ne,pe,Pe,ue,be){{var he=B(A);if(!he){var Ee="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(Ee+=" 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 St=ve();St?Ee+=St:Ee+=ee();var tt;A===null?tt="null":Ye(A)?tt="array":A!==void 0&&A.$$typeof===t?(tt="<"+(z(A.type)||"Unknown")+" />",Ee=" Did you accidentally export a JSX literal instead of a component?"):tt=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",tt,Ee)}var Ct=Ke(A,ne,pe,ue,be);if(Ct==null)return Ct;if(he){var rn=ne.children;if(rn!==void 0)if(Pe)if(Ye(rn)){for(var Rr=0;Rr<rn.length;Rr++)it(rn[Rr],A);Object.freeze&&Object.freeze(rn)}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 it(rn,A)}if(xe.call(ne,"key")){var lr=z(A),Wt=Object.keys(ne).filter(function(_I){return _I!=="key"}),Vl=Wt.length>0?"{key: someKey, "+Wt.join(": ..., ")+": ...}":"{key: someKey}";if(!Ut[lr+Vl]){var AI=Wt.length>0?"{"+Wt.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} />`,al,or,sT,or),qs[or+al]=!0}}return I===r?rr(xt):$t(xt),xt}}function ol(I,Q,ce){return Gs(I,Q,ce,!0)}function sl(I,Q,ce){return Gs(I,Q,ce,!1)}var il=sl,Ys=ol;jr.Fragment=r,jr.jsx=il,jr.jsxs=Ys}()),jr}process.env.NODE_ENV==="production"?Zs.exports=xm():Zs.exports=wm();var c=Zs.exports;function dl(e,t){return function(){return e.apply(t,arguments)}}const{toString:vm}=Object.prototype,{getPrototypeOf:Qs}=Object,{iterator:wo,toStringTag:fl}=Symbol,vo=(e=>t=>{const n=vm.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Qt=e=>(e=e.toLowerCase(),t=>vo(t)===e),bo=e=>t=>typeof t===e,{isArray:sr}=Array,ir=bo("undefined");function _r(e){return e!==null&&!ir(e)&&e.constructor!==null&&!ir(e.constructor)&&Rt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const hl=Qt("ArrayBuffer");function bm(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&hl(e.buffer),t}const ym=bo("string"),Rt=bo("function"),pl=bo("number"),Mr=e=>e!==null&&typeof e=="object",Sm=e=>e===!0||e===!1,yo=e=>{if(vo(e)!=="object")return!1;const t=Qs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(fl in e)&&!(wo in e)},Cm=e=>{if(!Mr(e)||_r(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},km=Qt("Date"),Tm=Qt("File"),Em=Qt("Blob"),Im=Qt("FileList"),Nm=e=>Mr(e)&&Rt(e.pipe),Am=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Rt(e.append)&&((t=vo(e))==="formdata"||t==="object"&&Rt(e.toString)&&e.toString()==="[object FormData]"))},jm=Qt("URLSearchParams"),[_m,Mm,Rm,Pm]=["ReadableStream","Request","Response","Headers"].map(Qt),Om=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Rr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),sr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(_r(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 ml(e,t){if(_r(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 $n=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,gl=e=>!ir(e)&&e!==$n;function ei(){const{caseless:e,skipUndefined:t}=gl(this)&&this||{},n={},r=(o,s)=>{const i=e&&ml(n,s)||s;yo(n[i])&&yo(o)?n[i]=ei(n[i],o):yo(o)?n[i]=ei({},o):sr(o)?n[i]=o.slice():(!t||!ir(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Rr(arguments[o],r);return n}const Dm=(e,t,n,{allOwnKeys:r}={})=>(Rr(t,(o,s)=>{n&&Rt(o)?e[s]=dl(o,n):e[s]=o},{allOwnKeys:r}),e),Lm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),$m=(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)},Fm=(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&&Qs(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Bm=(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},zm=e=>{if(!e)return null;if(sr(e))return e;let t=e.length;if(!pl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Hm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Qs(Uint8Array)),Um=(e,t)=>{const r=(e&&e[wo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Wm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Vm=Qt("HTMLFormElement"),Km=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),xl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),qm=Qt("RegExp"),wl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Rr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Gm=e=>{wl(e,(t,n)=>{if(Rt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Rt(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+"'")})}})},Ym=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return sr(e)?r(e):r(String(e).split(t)),n},Xm=()=>{},Jm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Zm(e){return!!(e&&Rt(e.append)&&e[fl]==="FormData"&&e[wo])}const Qm=e=>{const t=new Array(10),n=(r,o)=>{if(Mr(r)){if(t.indexOf(r)>=0)return;if(_r(r))return r;if(!("toJSON"in r)){t[o]=r;const s=sr(r)?[]:{};return Rr(r,(i,a)=>{const l=n(i,o+1);!ir(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},eg=Qt("AsyncFunction"),tg=e=>e&&(Mr(e)||Rt(e))&&Rt(e.then)&&Rt(e.catch),vl=((e,t)=>e?setImmediate:t?((n,r)=>($n.addEventListener("message",({source:o,data:s})=>{o===$n&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),$n.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Rt($n.postMessage)),ng=typeof queueMicrotask<"u"?queueMicrotask.bind($n):typeof process<"u"&&process.nextTick||vl,z={isArray:sr,isArrayBuffer:hl,isBuffer:_r,isFormData:Am,isArrayBufferView:bm,isString:ym,isNumber:pl,isBoolean:Sm,isObject:Mr,isPlainObject:yo,isEmptyObject:Cm,isReadableStream:_m,isRequest:Mm,isResponse:Rm,isHeaders:Pm,isUndefined:ir,isDate:km,isFile:Tm,isBlob:Em,isRegExp:qm,isFunction:Rt,isStream:Nm,isURLSearchParams:jm,isTypedArray:Hm,isFileList:Im,forEach:Rr,merge:ei,extend:Dm,trim:Om,stripBOM:Lm,inherits:$m,toFlatObject:Fm,kindOf:vo,kindOfTest:Qt,endsWith:Bm,toArray:zm,forEachEntry:Um,matchAll:Wm,isHTMLForm:Vm,hasOwnProperty:xl,hasOwnProp:xl,reduceDescriptors:wl,freezeMethods:Gm,toObjectSet:Ym,toCamelCase:Km,noop:Xm,toFiniteNumber:Jm,findKey:ml,global:$n,isContextDefined:gl,isSpecCompliantForm:Zm,toJSONObject:Qm,isAsyncFn:eg,isThenable:tg,setImmediate:vl,asap:ng,isIterable:e=>e!=null&&Rt(e[wo])};function Me(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)}z.inherits(Me,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:z.toJSONObject(this.config),code:this.code,status:this.status}}});const bl=Me.prototype,yl={};["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=>{yl[e]={value:e}}),Object.defineProperties(Me,yl),Object.defineProperty(bl,"isAxiosError",{value:!0}),Me.from=(e,t,n,r,o,s)=>{const i=Object.create(bl);z.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Me.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 rg=null;function ti(e){return z.isPlainObject(e)||z.isArray(e)}function Sl(e){return z.endsWith(e,"[]")?e.slice(0,-2):e}function Cl(e,t,n){return e?e.concat(t).map(function(o,s){return o=Sl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function og(e){return z.isArray(e)&&!e.some(ti)}const sg=z.toFlatObject(z,{},null,function(t){return/^is[A-Z]/.test(t)});function So(e,t,n){if(!z.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=z.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,g){return!z.isUndefined(g[x])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&z.isSpecCompliantForm(t);if(!z.isFunction(o))throw new TypeError("visitor must be a function");function u(v){if(v===null)return"";if(z.isDate(v))return v.toISOString();if(z.isBoolean(v))return v.toString();if(!l&&z.isBlob(v))throw new Me("Blob is not supported. Use a Buffer instead.");return z.isArrayBuffer(v)||z.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,x,g){let w=v;if(v&&!g&&typeof v=="object"){if(z.endsWith(x,"{}"))x=r?x:x.slice(0,-2),v=JSON.stringify(v);else if(z.isArray(v)&&og(v)||(z.isFileList(v)||z.endsWith(x,"[]"))&&(w=z.toArray(v)))return x=Sl(x),w.forEach(function(S,T){!(z.isUndefined(S)||S===null)&&t.append(i===!0?Cl([x],T,s):i===null?x:x+"[]",u(S))}),!1}return ti(v)?!0:(t.append(Cl(g,x,s),u(v)),!1)}const f=[],h=Object.assign(sg,{defaultVisitor:d,convertValue:u,isVisitable:ti});function p(v,x){if(!z.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+x.join("."));f.push(v),z.forEach(v,function(w,b){(!(z.isUndefined(w)||w===null)&&o.call(t,w,z.isString(b)?b.trim():b,x,h))===!0&&p(w,x?x.concat(b):[b])}),f.pop()}}if(!z.isObject(e))throw new TypeError("data must be an object");return p(e),t}function kl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ni(e,t){this._pairs=[],e&&So(e,this,t)}const Tl=ni.prototype;Tl.append=function(t,n){this._pairs.push([t,n])},Tl.toString=function(t){const n=t?function(r){return t.call(this,r,kl)}:kl;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function ig(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function El(e,t,n){if(!t)return e;const r=n&&n.encode||ig;z.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=z.isURLSearchParams(t)?t.toString():new ni(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Il{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){z.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Nl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ag={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ni,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ri=typeof window<"u"&&typeof document<"u",oi=typeof navigator=="object"&&navigator||void 0,lg=ri&&(!oi||["ReactNative","NativeScript","NS"].indexOf(oi.product)<0),cg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ug=ri&&window.location.href||"http://localhost",kt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ri,hasStandardBrowserEnv:lg,hasStandardBrowserWebWorkerEnv:cg,navigator:oi,origin:ug},Symbol.toStringTag,{value:"Module"})),...ag};function dg(e,t){return So(e,new kt.classes.URLSearchParams,{visitor:function(n,r,o,s){return kt.isNode&&z.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function fg(e){return z.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function hg(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 Al(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&&z.isArray(o)?o.length:i,l?(z.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!z.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&z.isArray(o[i])&&(o[i]=hg(o[i])),!a)}if(z.isFormData(e)&&z.isFunction(e.entries)){const n={};return z.forEachEntry(e,(r,o)=>{t(fg(r),o,n,0)}),n}return null}function pg(e,t,n){if(z.isString(e))try{return(t||JSON.parse)(e),z.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Pr={transitional:Nl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=z.isObject(t);if(s&&z.isHTMLForm(t)&&(t=new FormData(t)),z.isFormData(t))return o?JSON.stringify(Al(t)):t;if(z.isArrayBuffer(t)||z.isBuffer(t)||z.isStream(t)||z.isFile(t)||z.isBlob(t)||z.isReadableStream(t))return t;if(z.isArrayBufferView(t))return t.buffer;if(z.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 dg(t,this.formSerializer).toString();if((a=z.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return So(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),pg(t)):t}],transformResponse:[function(t){const n=this.transitional||Pr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(z.isResponse(t)||z.isReadableStream(t))return t;if(t&&z.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"?Me.from(a,Me.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:kt.classes.FormData,Blob:kt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};z.forEach(["delete","get","head","post","put","patch"],e=>{Pr.headers[e]={}});const mg=z.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"]),gg=e=>{const t={};let n,r,o;return e&&e.split(`
31
- `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&mg[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},jl=Symbol("internals");function Or(e){return e&&String(e).trim().toLowerCase()}function Co(e){return e===!1||e==null?e:z.isArray(e)?e.map(Co):String(e)}function xg(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 wg=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function si(e,t,n,r,o){if(z.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!z.isString(t)){if(z.isString(r))return t.indexOf(r)!==-1;if(z.isRegExp(r))return r.test(t)}}function vg(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function bg(e,t){const n=z.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 Pt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=Or(l);if(!d)throw new Error("header name must be a non-empty string");const f=z.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=Co(a))}const i=(a,l)=>z.forEach(a,(u,d)=>s(u,d,l));if(z.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(z.isString(t)&&(t=t.trim())&&!wg(t))i(gg(t),n);else if(z.isObject(t)&&z.isIterable(t)){let a={},l,u;for(const d of t){if(!z.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?z.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=Or(t),t){const r=z.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return xg(o);if(z.isFunction(n))return n.call(this,o,r);if(z.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Or(t),t){const r=z.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||si(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Or(i),i){const a=z.findKey(r,i);a&&(!n||si(r,r[a],a,n))&&(delete r[a],o=!0)}}return z.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||si(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return z.forEach(this,(o,s)=>{const i=z.findKey(r,s);if(i){n[i]=Co(o),delete n[s];return}const a=t?vg(s):String(s).trim();a!==s&&delete n[s],n[a]=Co(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return z.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&z.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
- `)}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[jl]=this[jl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Or(i);r[a]||(bg(o,i),r[a]=!0)}return z.isArray(t)?t.forEach(s):s(t),this}};Pt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),z.reduceDescriptors(Pt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),z.freezeMethods(Pt);function ii(e,t){const n=this||Pr,r=t||n,o=Pt.from(r.headers);let s=r.data;return z.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function _l(e){return!!(e&&e.__CANCEL__)}function ar(e,t,n){Me.call(this,e??"canceled",Me.ERR_CANCELED,t,n),this.name="CanceledError"}z.inherits(ar,Me,{__CANCEL__:!0});function Ml(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Me("Request failed with status code "+n.status,[Me.ERR_BAD_REQUEST,Me.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function yg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Sg(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 u=Date.now(),d=r[s];i||(i=u),n[o]=l,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const p=d&&u-d;return p?Math.round(h*1e3/p):void 0}}function Cg(e,t){let n=0,r=1e3/t,o,s;const i=(u,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?i(u,d):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const ko=(e,t,n=3)=>{let r=0;const o=Sg(50,250);return Cg(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,u=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},Rl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Pl=e=>(...t)=>z.asap(()=>e(...t)),kg=kt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,kt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(kt.origin),kt.navigator&&/(msie|trident)/i.test(kt.navigator.userAgent)):()=>!0,Tg=kt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];z.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),z.isString(r)&&i.push("path="+r),z.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 Eg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Ig(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Ol(e,t,n){let r=!Eg(t);return e&&(r||n==!1)?Ig(e,t):t}const Dl=e=>e instanceof Pt?{...e}:e;function Fn(e,t){t=t||{};const n={};function r(u,d,f,h){return z.isPlainObject(u)&&z.isPlainObject(d)?z.merge.call({caseless:h},u,d):z.isPlainObject(d)?z.merge({},d):z.isArray(d)?d.slice():d}function o(u,d,f,h){if(z.isUndefined(d)){if(!z.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!z.isUndefined(d))return r(void 0,d)}function i(u,d){if(z.isUndefined(d)){if(!z.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}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:(u,d,f)=>o(Dl(u),Dl(d),f,!0)};return z.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);z.isUndefined(h)&&f!==a||(n[d]=h)}),n}const Ll=e=>{const t=Fn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Pt.from(i),t.url=El(Ol(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),z.isFormData(n)){if(kt.hasStandardBrowserEnv||kt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(z.isFunction(n.getHeaders)){const l=n.getHeaders(),u=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(kt.hasStandardBrowserEnv&&(r&&z.isFunction(r)&&(r=r(t)),r||r!==!1&&kg(t.url))){const l=o&&s&&Tg.read(s);l&&i.set(o,l)}return t},Ng=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Ll(e);let s=o.data;const i=Pt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,v;function x(){p&&p(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function w(){if(!g)return;const S=Pt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:S,config:e,request:g};Ml(function(E){n(E),x()},function(E){r(E),x()},C),g=null}"onloadend"in g?g.onloadend=w:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(w)},g.onabort=function(){g&&(r(new Me("Request aborted",Me.ECONNABORTED,e,g)),g=null)},g.onerror=function(T){const C=T&&T.message?T.message:"Network Error",k=new Me(C,Me.ERR_NETWORK,e,g);k.event=T||null,r(k),g=null},g.ontimeout=function(){let T=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Nl;o.timeoutErrorMessage&&(T=o.timeoutErrorMessage),r(new Me(T,C.clarifyTimeoutError?Me.ETIMEDOUT:Me.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&z.forEach(i.toJSON(),function(T,C){g.setRequestHeader(C,T)}),z.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,v]=ko(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=ko(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new ar(null,e,g):S),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=yg(o.url);if(b&&kt.protocols.indexOf(b)===-1){r(new Me("Unsupported protocol "+b+":",Me.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Ag=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof Me?d:new ar(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Me(`timeout ${t} of ms exceeded`,Me.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>z.asap(a),l}},jg=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},_g=async function*(e,t){for await(const n of Mg(e))yield*jg(n,t)},Mg=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()}},$l=(e,t,n,r)=>{const o=_g(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:u,value:d}=await o.next();if(u){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Fl=64*1024,{isFunction:To}=z,Rg=(({Request:e,Response:t})=>({Request:e,Response:t}))(z.global),{ReadableStream:Bl,TextEncoder:zl}=z.global,Hl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Pg=e=>{e=z.merge.call({skipUndefined:!0},Rg,e);const{fetch:t,Request:n,Response:r}=e,o=t?To(t):typeof fetch=="function",s=To(n),i=To(r);if(!o)return!1;const a=o&&To(Bl),l=o&&(typeof zl=="function"?(v=>x=>v.encode(x))(new zl):async v=>new Uint8Array(await new n(v).arrayBuffer())),u=s&&a&&Hl(()=>{let v=!1;const x=new n(kt.origin,{body:new Bl,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!x}),d=i&&a&&Hl(()=>z.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(x,g)=>{let w=x&&x[v];if(w)return w.call(x);throw new Me(`Response type '${v}' is not supported`,Me.ERR_NOT_SUPPORT,g)})});const h=async v=>{if(v==null)return 0;if(z.isBlob(v))return v.size;if(z.isSpecCompliantForm(v))return(await new n(kt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(z.isArrayBufferView(v)||z.isArrayBuffer(v))return v.byteLength;if(z.isURLSearchParams(v)&&(v=v+""),z.isString(v))return(await l(v)).byteLength},p=async(v,x)=>{const g=z.toFiniteNumber(v.getContentLength());return g??h(x)};return async v=>{let{url:x,method:g,data:w,signal:b,cancelToken:S,timeout:T,onDownloadProgress:C,onUploadProgress:k,responseType:E,headers:A,withCredentials:L="same-origin",fetchOptions:B}=Ll(v),W=t||fetch;E=E?(E+"").toLowerCase():"text";let K=Ag([b,S&&S.toAbortSignal()],T),H=null;const R=K&&K.unsubscribe&&(()=>{K.unsubscribe()});let G;try{if(k&&u&&g!=="get"&&g!=="head"&&(G=await p(A,w))!==0){let V=new n(x,{method:"POST",body:w,duplex:"half"}),M;if(z.isFormData(w)&&(M=V.headers.get("content-type"))&&A.setContentType(M),V.body){const[F,ee]=Rl(G,ko(Pl(k)));w=$l(V.body,Fl,F,ee)}}z.isString(L)||(L=L?"include":"omit");const N=s&&"credentials"in n.prototype,$={...B,signal:K,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:w,duplex:"half",credentials:N?L:void 0};H=s&&new n(x,$);let P=await(s?W(H,B):W(x,$));const j=d&&(E==="stream"||E==="response");if(d&&(C||j&&R)){const V={};["status","statusText","headers"].forEach(J=>{V[J]=P[J]});const M=z.toFiniteNumber(P.headers.get("content-length")),[F,ee]=C&&Rl(M,ko(Pl(C),!0))||[];P=new r($l(P.body,Fl,F,()=>{ee&&ee(),R&&R()}),V)}E=E||"text";let U=await f[z.findKey(f,E)||"text"](P,v);return!j&&R&&R(),await new Promise((V,M)=>{Ml(V,M,{data:U,headers:Pt.from(P.headers),status:P.status,statusText:P.statusText,config:v,request:H})})}catch(N){throw R&&R(),N&&N.name==="TypeError"&&/Load failed|fetch/i.test(N.message)?Object.assign(new Me("Network Error",Me.ERR_NETWORK,v,H),{cause:N.cause||N}):Me.from(N,N&&N.code,v,H)}}},Og=new Map,Ul=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,u,d=Og;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Pg(t)),d=u;return u};Ul();const ai={http:rg,xhr:Ng,fetch:{get:Ul}};z.forEach(ai,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Wl=e=>`- ${e}`,Dg=e=>z.isFunction(e)||e===null||e===!1,Vl={getAdapter:(e,t)=>{e=z.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,!Dg(r)&&(o=ai[(a=String(r)).toLowerCase()],o===void 0))throw new Me(`Unknown adapter '${a}'`);if(o&&(z.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
33
- `+i.map(Wl).join(`
34
- `):" "+Wl(i[0]):"as no adapter specified";throw new Me("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:ai};function li(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ar(null,e)}function Kl(e){return li(e),e.headers=Pt.from(e.headers),e.data=ii.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Vl.getAdapter(e.adapter||Pr.adapter,e)(e).then(function(r){return li(e),r.data=ii.call(e,e.transformResponse,r),r.headers=Pt.from(r.headers),r},function(r){return _l(r)||(li(e),r&&r.response&&(r.response.data=ii.call(e,e.transformResponse,r.response),r.response.headers=Pt.from(r.response.headers))),Promise.reject(r)})}const ql="1.12.2",Eo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Eo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Gl={};Eo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+ql+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Me(o(i," has been removed"+(n?" in "+n:"")),Me.ERR_DEPRECATED);return n&&!Gl[i]&&(Gl[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}},Eo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Lg(e,t,n){if(typeof e!="object")throw new Me("options must be an object",Me.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 Me("option "+s+" must be "+l,Me.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Me("Unknown option "+s,Me.ERR_BAD_OPTION)}}const Io={assertOptions:Lg,validators:Eo},an=Io.validators;let Bn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Il,response:new Il}}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=Fn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Io.assertOptions(r,{silentJSONParsing:an.transitional(an.boolean),forcedJSONParsing:an.transitional(an.boolean),clarifyTimeoutError:an.transitional(an.boolean)},!1),o!=null&&(z.isFunction(o)?n.paramsSerializer={serialize:o}:Io.assertOptions(o,{encode:an.function,serialize:an.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Io.assertOptions(n,{baseUrl:an.spelling("baseURL"),withXsrfToken:an.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&z.merge(s.common,s[n.method]);s&&z.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Pt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(n)===!1||(l=l&&x.synchronous,a.unshift(x.fulfilled,x.rejected))});const u=[];this.interceptors.response.forEach(function(x){u.push(x.fulfilled,x.rejected)});let d,f=0,h;if(!l){const v=[Kl.bind(this),void 0];for(v.unshift(...a),v.push(...u),h=v.length,d=Promise.resolve(n);f<h;)d=d.then(v[f++],v[f++]);return d}h=a.length;let p=n;for(;f<h;){const v=a[f++],x=a[f++];try{p=v(p)}catch(g){x.call(this,g);break}}try{d=Kl.call(this,p)}catch(v){return Promise.reject(v)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=Fn(this.defaults,t);const n=Ol(t.baseURL,t.url,t.allowAbsoluteUrls);return El(n,t.params,t.paramsSerializer)}};z.forEach(["delete","get","head","options"],function(t){Bn.prototype[t]=function(n,r){return this.request(Fn(r||{},{method:t,url:n,data:(r||{}).data}))}}),z.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Fn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Bn.prototype[t]=n(),Bn.prototype[t+"Form"]=n(!0)});let $g=class pm{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 ar(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 pm(function(o){t=o}),cancel:t}}};function Fg(e){return function(n){return e.apply(null,n)}}function Bg(e){return z.isObject(e)&&e.isAxiosError===!0}const ci={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(ci).forEach(([e,t])=>{ci[t]=e});function Yl(e){const t=new Bn(e),n=dl(Bn.prototype.request,t);return z.extend(n,Bn.prototype,t,{allOwnKeys:!0}),z.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Yl(Fn(e,o))},n}const dt=Yl(Pr);dt.Axios=Bn,dt.CanceledError=ar,dt.CancelToken=$g,dt.isCancel=_l,dt.VERSION=ql,dt.toFormData=So,dt.AxiosError=Me,dt.Cancel=dt.CanceledError,dt.all=function(t){return Promise.all(t)},dt.spread=Fg,dt.isAxiosError=Bg,dt.mergeConfig=Fn,dt.AxiosHeaders=Pt,dt.formToJSON=e=>Al(z.isHTMLForm(e)?new FormData(e):e),dt.getAdapter=Vl.getAdapter,dt.HttpStatusCode=ci,dt.default=dt;const{Axios:mT,AxiosError:gT,CanceledError:xT,isCancel:wT,CancelToken:vT,VERSION:bT,all:yT,Cancel:ST,isAxiosError:CT,spread:kT,toFormData:TT,AxiosHeaders:ET,HttpStatusCode:IT,formToJSON:NT,getAdapter:AT,mergeConfig:jT}=dt,Xl=typeof window<"u"?window.__API_BASE_URL__:void 0,Jl=Xl?xn(Xl):void 0;function xn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let No=null;const ui=new Set;function Zl(){return No}function Ao(e){No=e,ui.forEach(t=>t(e))}function Ql(e){return ui.add(e),()=>ui.delete(e)}const zg=3e4,Hg=9e4,Wt=dt.create({...Jl?{baseURL:Jl}:{},timeout:zg,withCredentials:!0});Wt.interceptors.request.use(e=>(No&&(e.headers.Authorization=`Bearer ${No}`),e)),Wt.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),Ao(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 Vt(e,t){return Wt.defaults.baseURL?(await Wt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function jo(e,t,n){return Wt.defaults.baseURL?(await Wt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ec(e,t,n){return Wt.defaults.baseURL?(await Wt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function di(e,t){return Wt.defaults.baseURL?(await Wt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Ot(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class tc{get baseUrl(){const t=Wt.defaults.baseURL;return t?xn(String(t)):""}updateConfig(t){t.baseUrl&&(Wt.defaults.baseURL=xn(String(t.baseUrl))),t.authToken!==void 0&&Ao(t.authToken)}getAuthToken(){return Zl()}setAuthToken(t){Ao(t)}onTokenChange(t){return Ql(t)}async listThreads(){const t=await Vt("/threads"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Vt("/threads/shared"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await jo("/threads",t?{title:t}:void 0);return Ot(r)}async updateThread(t,n){const r=await ec(`/threads/${t}`,{title:n});return Ot(r)}async deleteThread(t){const n=await di(`/threads/${t}`);return Ot(n)}async shareThread(t,n){const r=await jo(`/threads/${t}/share`,{shared_with_user_id:n});return Ot(r)}async threadInfo(t){const n=await Vt(`/threads/${t}/info`);return Ot(n)}async listAgents(){const t=await Vt("/agents"),n=Ot(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Vt(`/agents/${t}`);return Ot(n)}async getAgentSchema(t){const n=await Vt(`/agents/${t}/schema`);return Ot(n)}async getState(t){const n=await Vt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ot(n)}async getStateHistory(t){const n=await Vt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Hg});return Ot(n)}async cancelRun(t){const n=await jo("/runs/cancel",{threadId:t});return Ot(n)}async unshareThread(t,n){const r=await di(`/threads/${t}/share/${n}`);return Ot(r)}}const Sn=new tc,nc=y.createContext(null);function Ug({children:e,apiConfig:t}){const n=Sn;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 c.jsx(nc.Provider,{value:r,children:e})}function fi(){const e=y.useContext(nc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Wg(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 Vg(e=[]){const t=[],n=[];for(const r of e)try{const o=await Wg(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Dr(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function lr(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function Kg(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 rc(e){const t=Dr(e);if(t)return Dr(t.configurable)??t}function zn(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)=>qg(s,i)).filter(s=>!!s)].sort((s,i)=>oc(i.createdAt)-oc(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 qg(e,t){var b;if(!e)return null;const r=(Array.isArray((b=e.values)==null?void 0:b.messages)?e.values.messages:[]).filter(S=>!!(S&&typeof S=="object"&&typeof S.role=="string")),o=Dr(e.metadata)??{},s=rc(e.config),i=Dr(e.parent_config??e.parentConfig),a=rc(i),l=lr(s,["checkpoint_id","checkpointId"]),u=lr(s,["checkpoint_ns","checkpointNs"]),d=lr(a,["checkpoint_id","checkpointId"]),f=lr(a,["checkpoint_id","checkpointId"])??null,h=lr(a,["checkpoint_ns","checkpointNs"])??null,p=Dr(e.config),v=Array.isArray(e.tasks)?e.tasks.map(S=>({...S})):e.tasks??null,x=Array.isArray(e.next)?[...e.next]:e.next??null,g=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(),w={...o,step:Kg(o,["step"])??0,source:lr(o,["source"])??null};return{checkpointId:l??null,checkpointNs:u??null,createdAt:g,parentId:d??null,messages:r,nextCursor:f,nextCursorNs:h,interrupt:Gg(r,t),metadata:w,config:p??null,parentConfig:i??null,next:x,tasks:v}}function Gg(e,t){return Yg(e,t)}function Yg(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 oc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function Xg(e,t){var d;let n=[],r=null,o={},s={},i=null,a=null,l=null;if(!(e&&"type"in e&&e.type==="default_message")&&e){const f=e,h=f.checkpointId??null;o=f.additionalKwargs??{},s=f.responseMetadata??{};const p=h?t.checkpointMetaById.get(h)??null:null;i=typeof o.step=="number"?o.step:typeof s.step=="number"?s.step:(p==null?void 0:p.step)??null;const v=typeof o.source=="string"?o.source:typeof s.source=="string"?s.source:(p==null?void 0:p.source)??null;a=v?String(v):null;const x=i!==null&&a?`${i}:${a}`:null;if(x&&t.checkpointIndexByKey.has(x)?n=t.checkpointIndexByKey.get(x)??[]:h&&p&&(n=[p]),r=h??((d=n[0])==null?void 0:d.id)??null,l=h?t.attemptMetaById.get(h)??null:null,!l&&f.role==="user"&&f.id&&t.userMessageIdToAttempts.has(f.id)){const g=t.userMessageIdToAttempts.get(f.id);if(g&&g.length>0){const w=g[0].checkpointId;l=t.attemptMetaById.get(w)??null}}if(!l&&n.length>0){const g=t.attemptMetaById.get(n[0].id);g&&(l=g)}if(l&&l.attemptCount>1){const g=l.baseUserMessageId;if(g){const w=[];for(const[b,S]of t.attemptMetaById.entries())if(S.baseUserMessageId===g){const T=t.checkpointMetaById.get(b);T&&w.push(T)}w.length>0&&(w.sort((b,S)=>{const T=b.createdAt?Date.parse(b.createdAt):0;return(S.createdAt?Date.parse(S.createdAt):0)-T}),n=w)}}}return{checkpointCandidates:n,defaultCheckpointId:r,resolvedStep:i,resolvedSource:a}}function Jg(e,t){return y.useMemo(()=>Xg(e,t),[e,t])}function Zg(e){const t=new Map;for(const o of e){const s=o.messages??[];if(!o.checkpointId)continue;let i;for(let l=s.length-1;l>=0;l--){const u=s[l];if(u.role==="user"&&u.id){i=u.id;break}}if(!i)continue;const a=t.get(i)??[];a.push({checkpoint:o,timestamp:Date.parse(o.createdAt??"0")}),t.set(i,a)}const n=new Map,r=new Map;for(const[o,s]of t.entries()){if(!s.length)continue;const i=s.length;i>1&&s.sort((l,u)=>u.timestamp-l.timestamp);const a=[];for(let l=0;l<s.length;l++){const{checkpoint:u}=s[l],d=u.checkpointId;if(!d)continue;const f={attemptIndex:l,attemptCount:i,isLatestAttempt:l===0,baseUserMessageId:o};n.set(d,f),i>1&&a.push({checkpointId:d,attemptIndex:f.attemptIndex,attemptCount:f.attemptCount,isLatestAttempt:f.isLatestAttempt})}a.length&&r.set(o,a)}return{attemptMetaById:n,userMessageIdToAttempts:r}}const sc=120;function Qg(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>sc?`${n.slice(0,sc-3)}…`:n:""}function ic(e){return Qg(e.content)||""}function ex(e){const t=new Map;for(const n of e){if(!n.id||n.role!=="user")continue;const r=ic(n);r&&t.set(n.id,r)}return t}function ac(e){const t=new Map,n=new Map,r=[],o=new Map;for(let f=0;f<e.length;f++){const h=e[f],p=h.checkpointId,v=p??`cp-${f}`,x=h.metadata??{},g=typeof x.step=="number"?x.step:null,w=typeof x.source=="string"?x.source:null,b={id:v,step:g,source:w,createdAt:h.createdAt??null,namespace:h.checkpointNs??null,parentId:h.parentId??null};if(p&&(t.set(p,b),g!==null&&w)){const k=`${g}:${w}`,E=n.get(k);E?E.push(b):n.set(k,[b])}let S=null,T=null;const C=Array.isArray(h.messages)?h.messages:[];for(const k of C)k.role==="user"&&(T||(T=k),k.id&&(S=k.id));if(p&&T){const k=ic(T);k&&o.set(p,k)}r.push({id:v,messageId:S,step:g,source:w,createdAt:h.createdAt??null,next:h.next&&h.next.length>0?String(h.next[0]):null,parentConfig:h.parentConfig??null})}const{attemptMetaById:s,userMessageIdToAttempts:i}=Zg(e),a=new Map;for(const[f,h]of t.entries()){const p=s.get(f);p?a.set(f,{...h,attemptIndex:p.attemptIndex,attemptCount:p.attemptCount,isLatestAttempt:p.isLatestAttempt,baseUserMessageId:p.baseUserMessageId??null}):a.set(f,{...h,attemptIndex:0,attemptCount:1,isLatestAttempt:!0,baseUserMessageId:null})}return{checkpoints:e,checkpointMetaById:t,checkpointIndexByKey:n,attemptMetaById:a,userMessageIdToAttempts:i,timeline:r,messagePreviews:o,getLatest:()=>{const f=r[0];if(f)return t.get(f.id)},getCheckpoint:f=>t.get(f),getAttempts:f=>i.get(f)??[]}}function tx(e){return y.useMemo(()=>ac(e),[e])}function nx({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:u,getMessages:d}){const[f,h]=y.useState(null),v=y.useMemo(()=>zn(f),[f]).checkpoints,x=tx(v),g=x.timeline,[w,b]=y.useState(!1),[S,T]=y.useState(null),[C,k]=y.useState(!1),[E,A]=y.useState(!1),[L,B]=y.useState(!1),[W,K]=y.useState(null),H=y.useRef(o),R=y.useRef(null),G=y.useRef(null),N=y.useRef(null),$=y.useRef(null),P=y.useRef(!1),j=y.useRef(null),U=y.useRef(new Map);y.useEffect(()=>{H.current=o},[o]);const V=y.useCallback(async D=>{var xe,de;if(!D.threadId)return;const te=D.threadId;(xe=D.onStart)==null||xe.call(D),D.setLoading(!0);try{await D.action(te)}catch(we){if(H.current===te){const je=String(we);(de=D.handleError)==null||de.call(D,je),r==null||r(je)}throw we}finally{D.setLoading(!1)}},[r]),M=y.useCallback(async(D,te)=>{if(!D)return;const xe=`${D}:${te??"latest"}`,de=U.current.get(xe);if(de)return de;const we=V({threadId:D,setLoading:k,onStart:()=>K(null),handleError:je=>K(je),action:async je=>{const De=await e.getStateHistory({threadId:je,checkpointId:te??void 0});if(H.current!==je){console.log(`[useThreadHistoryState] Thread changed during load (was ${je}, now ${H.current}), discarding stale data`);return}const{checkpoints:$e}=zn(De),ke=$e.find(Fe=>Fe.messages&&Fe.messages.length>0)??(te?$e.find(Fe=>Fe.checkpointId===te):null)??$e[0];t((ke==null?void 0:ke.messages)??[],{checkpointId:(ke==null?void 0:ke.checkpointId)??null,checkpointNs:(ke==null?void 0:ke.checkpointNs)??null}),h(De),b(!!(ke!=null&&ke.nextCursor)),T((ke==null?void 0:ke.nextCursor)??null)}});U.current.set(xe,we);try{await we}finally{U.current.delete(xe)}return H.current===D&&(j.current=xe),we},[e,t,V]),F=y.useCallback(async(D,te)=>{$.current=D;try{await M(D,te)}finally{$.current===D&&($.current=null)}},[M]),ee=y.useCallback(D=>{G.current=D},[]),J=y.useCallback(D=>{N.current=D},[]),ie=y.useCallback(D=>{const te=D.threadId??H.current;if(!te||H.current&&H.current!==te)return;const{checkpoints:xe}=zn(D);if(!xe.length)return;const de=xe.find(we=>we.messages&&we.messages.length>0)??xe.find(we=>!!we.checkpointId)??xe[0];t((de==null?void 0:de.messages)??[],{checkpointId:(de==null?void 0:de.checkpointId)??null,checkpointNs:(de==null?void 0:de.checkpointNs)??null}),h(D),b(!!(de!=null&&de.nextCursor)),T((de==null?void 0:de.nextCursor)??null),j.current=`${te}:latest`,G.current=null,N.current=null},[t]),q=y.useCallback(async(D,te)=>{const xe=H.current;await V({threadId:xe,setLoading:B,action:async de=>{const we=await e.getStateHistory({threadId:de,checkpointId:D,checkpointNs:te??void 0});if(H.current!==de){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${de}, now ${H.current}), discarding stale data`);return}const{checkpoints:je}=zn(we),De=je.find($e=>$e.checkpointId===D&&(te?$e.checkpointNs===te:!0));if(!De){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:D,checkpointNs:te});return}h(we),t(De.messages??[],{checkpointId:De.checkpointId??null,checkpointNs:De.checkpointNs??null})}}).catch(()=>{})},[e,t,V]),O=y.useCallback((D,te)=>{t(d(),{checkpointId:D??null,checkpointNs:te??null})},[d,t]),Y=y.useCallback(async()=>{H.current&&await F(H.current)},[F]),X=y.useCallback(async()=>{const D=H.current;!D||!S||await V({threadId:D,setLoading:A,action:async te=>{const xe=await e.getStateHistory({threadId:te,checkpointId:S});if(H.current!==te)return;const{checkpoints:de}=zn(xe);if(de.length>0){const we=de[de.length-1];n((we==null?void 0:we.messages)??[]),b(!!(we!=null&&we.nextCursor)),T((we==null?void 0:we.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,V]);y.useEffect(()=>{if(!l||!o||C||u)return;if(G.current===o){G.current=null,R.current=o;return}if(N.current===o){R.current=o;return}if($.current===o){$.current=null,R.current=o;return}if(R.current===o)return;R.current=o;const D=!P.current&&!!i&&o===s;let te;D&&i?(te=i,P.current=!0,console.log("[useThreadHistoryState] Loading thread with checkpoint:",te,a?`(ns: ${a})`:"")):console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const xe=`${o}:${te??"latest"}`;j.current!==xe&&F(o,te)},[l,o,i,a,s,C,u,F]);const le=y.useCallback(()=>{h(null),b(!1),T(null),k(!1),A(!1),B(!1),K(null),G.current=null,N.current=null,R.current=null,j.current=null,$.current=null},[]);return{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:L,threadStateError:W,hasMoreHistory:w,loadThread:F,navigateToCheckpoint:q,loadOlderMessages:X,setCurrentCheckpointId:O,returnToLatest:Y,handleStateHistoryEvent:ie,markSkipNextLoad:ee,markStreamPendingThread:J,resetHistoryState:le}}const rx=["detail","message","error","description","title"];function _o(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=_o(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of rx){const r=_o(t[n]);if(r)return r}if("errors"in t){const n=_o(t.errors);if(n)return n}}return null}function ox(e){if(!e)return"Request failed";const t=e.response,n=_o(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 sx({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=y.useState([]),[a,l]=y.useState(t),[u,d]=y.useState(!1),[f,h]=y.useState(null),[p,v]=y.useState([]),[x,g]=y.useState(!1),[,w]=y.useState(null),[b,S]=y.useState(null),[T,C]=y.useState(!1),k=y.useRef(a),E=y.useRef(new Map);y.useEffect(()=>{k.current=a},[a]);const A=y.useCallback(async()=>{d(!0),h(null);try{const P=await e.listThreads();i(P??[])}catch(P){const j=String(P);h(j),n==null||n(j)}finally{d(!1)}},[e,n]),L=y.useCallback(async()=>{g(!0),w(null);try{const P=await e.listSharedThreads();v(P??[])}catch(P){const j=String(P);w(j),n==null||n(j)}finally{g(!1)}},[e,n]);y.useEffect(()=>{A()},[A]),y.useEffect(()=>{L()},[L]),y.useEffect(()=>{r==null||r(a)},[a,r]);const B=y.useCallback(async P=>{try{const j=await e.createThread(P);return l(j.threadId),await A(),j.threadId}catch(j){const U=String(j);return n==null||n(U),null}},[e,n,A]),W=y.useCallback(async P=>{const j=s;i(V=>V.filter(M=>M.threadId!==P));const U=new AbortController;E.current.set(P,U);try{await e.deleteThread(P),k.current===P&&(l(null),o==null||o())}catch(V){i(j);const M=String(V);n==null||n(M)}finally{E.current.delete(P)}},[e,o,n,s]),K=y.useCallback(async(P,j)=>{try{await e.updateThread(P,j),await A()}catch(U){n==null||n(String(U))}},[e,n,A]),H=y.useCallback(async(P,j)=>{C(!0),S("Sharing thread…");try{await e.shareThread(P,j),await L(),S("Shared successfully")}catch(U){const V=ox(U);throw n==null||n(V),S(`Failed to share: ${V}`),new Error(V)}finally{C(!1)}},[e,n,L]),R=y.useCallback(async(P,j)=>{try{await e.unshareThread(P,j),await L()}catch(U){const V=String(U);throw n==null||n(V),U}},[e,n,L]),G=y.useMemo(()=>({createThread:B,deleteThread:W,renameThread:K,refreshThreads:A,refreshSharedThreads:L,shareThread:H,unshareThread:R}),[B,W,K,A,L,H,R]),N=y.useCallback(P=>{if(!(P!=null&&P.threadId))return;const j={threadId:P.threadId,title:P.title||`Thread ${P.threadId.slice(0,8)}`,createdAt:P.createdAt||new Date().toISOString(),updatedAt:P.updatedAt||new Date().toISOString(),messageCount:P.messageCount??1};i(U=>{let V=!1;const M=U.map(F=>F.threadId===j.threadId?(V=!0,console.debug("[useThreadsState] thread_info: updating existing thread",j.threadId),{...F,title:j.title??F.title,updatedAt:j.updatedAt??F.updatedAt,messageCount:j.messageCount??F.messageCount}):F);return V?M:(console.debug("[useThreadsState] thread_info: adding thread to list",j.threadId),[j,...U])})},[]),$=y.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:k,setCurrentThreadId:l,isLoadingThreads:u,threadsError:f,sharedThreads:p,isLoadingSharedThreads:x,actions:G,addThreadFromEvent:N,shareInFlight:T,shareStatus:b,clearShareStatus:$}}function hi(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function lc(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Lr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Lr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(lc(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=Lr(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 cr(e){if(typeof e=="string")return e;if(lc(e))return"";try{const t=Lr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function ix(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function ax(e){const t=cr(e);return typeof e=="string"&&ix(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function $r(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=hi(t);if(n!==null)return $r(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?$r(e.content):e}function lx(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function pi(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 Mo(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function cx(e){const t=r=>{try{const o=Lr(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(`
36
- `)):t(e)}function ux(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function cc(e){if("type"in e&&e.type==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function dx(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function fx(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function hx({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=dx(n),i=o?`data:${s};base64,${e}`:t,a=fx(r),l=a.length?a.join(" / "):void 0,u=l?`${l} artifact`:"artifact image";return{src:i,alt:u,label:l}}function px(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 hx({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function mi(e){return e.filter(t=>{var s;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(i=>{var a;return i&&i.type==="text"&&((a=i.text)==null?void 0:a.trim())}),r=(t.content??[]).some(i=>i&&i.type==="image_url"),o=!!((s=t.artifact)!=null&&s.plots&&t.artifact.plots.length>0);return!!(n||r||o)})}function Fr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function mx(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 uc(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function dc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function gx(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(f=>f.type==="text").map(f=>f.text??"").join(""),i=t.filter(f=>f.type!=="text"),a=o.lastText??dc(e);let l="",u=e.slice();if(s){const f=xx(a,s);if(f===""?l="":f===s?l=s:l=f,l){const h=u[u.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",v={...h,text:p+l};u=[...u.slice(0,u.length-1),v]}else u=[...u,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(u=[...u,...i]);const d=!!(l||i.length);return{newParts:u,newMeta:o,changed:d}}function fc(e){return e.replace(/\s+/g," ").trim()}function xx(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=fc(e),o=fc(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function wx(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 Fr(e,r,s)}return e}function vx(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const bx={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function yx(e,t){var n;switch(t.type){case"reset":return{messages:mi(((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=mi(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=mi(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 pc(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>pc(o,s),e):e}default:return e}}function hc(e=[]){const[t,n]=y.useReducer(yx,{...bx,messages:e}),r=y.useRef([]),o=y.useRef(null),s=y.useRef(null),i=y.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=y.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=y.useCallback(d=>{r.current.push(d),a()},[a]);y.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=y.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,f)=>n({type:"user_message",payload:{message:d,editingMessageId:f}}),onEvent:l}),[l]);return{state:t,dispatch:n,...u}}function pc(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=vx(t.model);if(e.messages.some(u=>u.id===s)){const u=e.messagesStreamMeta??{},d={...u,[s]:u[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 Cx(e,t);if(t.type==="tool.progress")return kx(e,t);if(t.type==="tool.end")return Tx(e,t);if(t.type==="message.delta"){const s=e.assemblingId??uc(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],u=e.messagesStreamMeta,d=u??{},f=d[s],h=f??{lastSeq:null,lastText:dc(l.content)},p=t.seq??null;if(p!==null&&typeof p=="number"&&typeof h.lastSeq=="number"&&p<=h.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:p,lastSeq:h.lastSeq}),e;const{newParts:v,newMeta:x,changed:g}=gx(l.content,t.delta,h,p);if(!g)return e;const w={...l,content:v},b=Fr(i,a,w),S=!f||f.lastSeq!==x.lastSeq||f.lastText!==x.lastText,T=S?{...d,[s]:x}:u;return S?{...e,messages:b,messagesStreamMeta:T}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??uc(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 f;return(d==null?void 0:d.type)==="text"&&((f=d.text)==null?void 0:f.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(f=>f==null?void 0:f.type),contentPreview:(o=l.content)==null?void 0:o.map(f=>(f==null?void 0:f.type)==="text"?String(f.text).slice(0,100):f==null?void 0:f.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=wx(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=zn(t),i=s.interrupt,a=s.latest,l=i===null?mx(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 gi(e){return e.call_id??e.id??null}function mc(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function gc(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 xi(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||pi(r).toolCallId===t)return n}return-1}function Sx(e){if(e==null)return[];const t=$r(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=cr(t??e);return n?[{type:"text",text:n}]:[]}function xc(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function Cx(e,t){const n=gi(t),r=xi(e.messages,n),o=t.name??t.tool??void 0,s=mc(t);if(r>=0){const a=e.messages[r],u={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:u};return{...e,messages:Fr(e.messages,r,d)}}const i=gc(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function kx(e,t){const n=gi(t);if(!n)return e;const r=xi(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=xc(e.messages[r],o);return{...e,messages:Fr(e.messages,r,a)}}function Tx(e,t){const n=gi(t),r=mc(t);let o=e.messages,s=xi(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,gc(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=Sx(a),u=[...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 f=xc(i,d),h=t.artifact??i.artifact,p={...f,name:t.name??t.tool??i.name,content:u,artifact:h,additionalKwargs:{...f.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Fr(o,s,p)}}function wc(e={}){const t=y.useMemo(()=>xn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=y.useState(e.token??null),s=y.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=y.useState(!1),[u,d]=y.useState(null),[f,h]=y.useState(""),[p,v]=y.useState(null),[x,g]=y.useState(0),[w,b]=y.useState(!1),S=y.useRef(null),T=y.useRef(!0),C=y.useRef(0),k=y.useRef(null),E=y.useRef(null),A=y.useRef(null),L=y.useRef(null),B=y.useCallback(R=>{o(R)},[]),W=y.useCallback(()=>{h(""),v(null),d(null),E.current=null,A.current=null,L.current=null},[]),K=y.useCallback(()=>{var R;console.debug("[use-chat] stop() invoked - aborting stream"),(R=S.current)==null||R.abort(),S.current=null,k.current=null,l(!1),b(!1),C.current=0,g(0)},[]),H=y.useCallback((R,G,N)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h(""),v(null),E.current=null,A.current=null,L.current=null;const $=new AbortController;S.current=$;let P=null,j=null,U=!1;return k.current={threadId:R.threadId??null,headers:{}},(async()=>{var M,F,ee,J,ie,q,O,Y,X,le,D,te,xe,de,we,je,De,$e;const V=ke=>{var Fe;try{const Ke=JSON.parse(JSON.stringify(ke));return(Fe=Ke==null?void 0:Ke.payload)!=null&&Fe.files_info&&Array.isArray(Ke.payload.files_info)&&(Ke.payload.files_info=Ke.payload.files_info.map(Je=>({...Je,data:Je!=null&&Je.data?`<base64 ${String(Je.data).length} chars>`:Je==null?void 0:Je.data}))),Ke}catch{return ke}};try{let ke={};try{if(r)ke={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Be=window.__AUTH_TOKEN__,yt=((M=window.localStorage)==null?void 0:M.getItem("authToken"))||null;let ht=null;try{const mt=(F=window.localStorage)==null?void 0:F.getItem("chat-settings");mt&&(ht=((ee=JSON.parse(mt))==null?void 0:ee.apiKey)||null)}catch{}const He=Be||yt||ht||null;He&&(ke={Authorization:`Bearer ${He}`})}}catch{}console.debug("[use-chat] POST",t+n,V(R));let Fe={};if(typeof window<"u")try{const ze=(J=window.localStorage)==null?void 0:J.getItem("authSessionId");ze&&(Fe={"X-Session-Id":ze})}catch{}const Ke={...ke,...Fe,...s.current},Je={"Content-Type":"application/json",Accept:"text/event-stream",...Ke},qe=await fetch(t+n,{method:"POST",headers:Je,body:JSON.stringify(R),signal:$.signal,credentials:i});if(k.current&&(k.current.headers=Ke),!qe.ok||!qe.body){const ze=await qe.text().catch(()=>"");console.debug("[use-chat] non-OK response",qe.status,ze==null?void 0:ze.slice(0,500));const Be=`stream ${qe.status}${ze?": "+ze:""}`;throw(ie=N==null?void 0:N.onConnectionError)==null||ie.call(N,Be),U=!0,P="error",j=Be,new Error(Be)}b(!0);const tt=qe.body.getReader(),bt=new TextDecoder;let st="",Te=[];C.current=0,g(0);let Le=0,ot=null;const ct=()=>{if(Te.length){const ze=Te.join("");Te=[],T.current&&h(Be=>Be+ze)}ot=null},Nt=()=>{typeof window<"u"&&ot==null&&(ot=requestAnimationFrame(ct))};let it=Date.now();const Ye=setInterval(()=>{var ze;if(Date.now()-it>18e5){const Be="Stream idle timeout";d(Be),P="error",j=Be,$.abort(),(ze=N==null?void 0:N.onError)==null||ze.call(N,Be)}},5e3),Mt=1024*1024;try{const ze=qe.headers.get("X-Thread-Id")||qe.headers.get("x-thread-id"),Be=qe.headers.get("X-Thread-Created")||qe.headers.get("x-thread-created"),yt=ze??null,ht=String(Be??"").toLowerCase()==="true";for(k.current&&!k.current.threadId&&(k.current={...k.current,threadId:yt}),(q=N==null?void 0:N.onOpen)==null||q.call(N,{threadId:yt,created:ht});;){const{value:He,done:mt}=await tt.read();if(mt)break;st+=bt.decode(He,{stream:!0}),st.length>Mt&&(st="",console.warn("Stream buffer reset: exceeded 1MB"));let _;for(;(_=st.indexOf(`
30
+ <%s key={someKey} {...props} />`,Vl,lr,AI,lr),Ut[lr+Vl]=!0}}return A===r?mt(Ct):Ge(Ct),Ct}}function nn(A,ne,pe){return Mt(A,ne,pe,!0)}function Ul(A,ne,pe){return Mt(A,ne,pe,!1)}var Wl=Ul,ci=nn;$r.Fragment=r,$r.jsx=Wl,$r.jsxs=ci}()),$r}process.env.NODE_ENV==="production"?di.exports=Ug():di.exports=Wg();var u=di.exports;const Vg=({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 rc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Kg}=Object.prototype,{getPrototypeOf:fi}=Object,{iterator:Io,toStringTag:oc}=Symbol,No=(e=>t=>{const n=Kg.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),on=e=>(e=e.toLowerCase(),t=>No(t)===e),Ao=e=>t=>typeof t===e,{isArray:ur}=Array,dr=Ao("undefined");function Fr(e){return e!==null&&!dr(e)&&e.constructor!==null&&!dr(e.constructor)&&Lt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const sc=on("ArrayBuffer");function qg(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&sc(e.buffer),t}const Gg=Ao("string"),Lt=Ao("function"),ic=Ao("number"),Br=e=>e!==null&&typeof e=="object",Yg=e=>e===!0||e===!1,_o=e=>{if(No(e)!=="object")return!1;const t=fi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(oc in e)&&!(Io in e)},Xg=e=>{if(!Br(e)||Fr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Jg=on("Date"),Zg=on("File"),Qg=on("Blob"),ex=on("FileList"),tx=e=>Br(e)&&Lt(e.pipe),nx=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Lt(e.append)&&((t=No(e))==="formdata"||t==="object"&&Lt(e.toString)&&e.toString()==="[object FormData]"))},rx=on("URLSearchParams"),[ox,sx,ix,ax]=["ReadableStream","Request","Response","Headers"].map(on),lx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function zr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),ur(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Fr(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 ac(e,t){if(Fr(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 Kn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,lc=e=>!dr(e)&&e!==Kn;function pi(){const{caseless:e,skipUndefined:t}=lc(this)&&this||{},n={},r=(o,s)=>{const i=e&&ac(n,s)||s;_o(n[i])&&_o(o)?n[i]=pi(n[i],o):_o(o)?n[i]=pi({},o):ur(o)?n[i]=o.slice():(!t||!dr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&zr(arguments[o],r);return n}const cx=(e,t,n,{allOwnKeys:r}={})=>(zr(t,(o,s)=>{n&&Lt(o)?e[s]=rc(o,n):e[s]=o},{allOwnKeys:r}),e),ux=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),dx=(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)},fx=(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&&fi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},px=(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},hx=e=>{if(!e)return null;if(ur(e))return e;let t=e.length;if(!ic(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},mx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&fi(Uint8Array)),gx=(e,t)=>{const r=(e&&e[Io]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},xx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},vx=on("HTMLFormElement"),wx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),cc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),bx=on("RegExp"),uc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};zr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},yx=e=>{uc(e,(t,n)=>{if(Lt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Lt(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+"'")})}})},Sx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return ur(e)?r(e):r(String(e).split(t)),n},Cx=()=>{},Tx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Ex(e){return!!(e&&Lt(e.append)&&e[oc]==="FormData"&&e[Io])}const kx=e=>{const t=new Array(10),n=(r,o)=>{if(Br(r)){if(t.indexOf(r)>=0)return;if(Fr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=ur(r)?[]:{};return zr(r,(i,a)=>{const l=n(i,o+1);!dr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Ix=on("AsyncFunction"),Nx=e=>e&&(Br(e)||Lt(e))&&Lt(e.then)&&Lt(e.catch),dc=((e,t)=>e?setImmediate:t?((n,r)=>(Kn.addEventListener("message",({source:o,data:s})=>{o===Kn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Kn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Lt(Kn.postMessage)),Ax=typeof queueMicrotask<"u"?queueMicrotask.bind(Kn):typeof process<"u"&&process.nextTick||dc,U={isArray:ur,isArrayBuffer:sc,isBuffer:Fr,isFormData:nx,isArrayBufferView:qg,isString:Gg,isNumber:ic,isBoolean:Yg,isObject:Br,isPlainObject:_o,isEmptyObject:Xg,isReadableStream:ox,isRequest:sx,isResponse:ix,isHeaders:ax,isUndefined:dr,isDate:Jg,isFile:Zg,isBlob:Qg,isRegExp:bx,isFunction:Lt,isStream:tx,isURLSearchParams:rx,isTypedArray:mx,isFileList:ex,forEach:zr,merge:pi,extend:cx,trim:lx,stripBOM:ux,inherits:dx,toFlatObject:fx,kindOf:No,kindOfTest:on,endsWith:px,toArray:hx,forEachEntry:gx,matchAll:xx,isHTMLForm:vx,hasOwnProperty:cc,hasOwnProp:cc,reduceDescriptors:uc,freezeMethods:yx,toObjectSet:Sx,toCamelCase:wx,noop:Cx,toFiniteNumber:Tx,findKey:ac,global:Kn,isContextDefined:lc,isSpecCompliantForm:Ex,toJSONObject:kx,isAsyncFn:Ix,isThenable:Nx,setImmediate:dc,asap:Ax,isIterable:e=>e!=null&&Lt(e[Io])};function Le(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)}U.inherits(Le,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:U.toJSONObject(this.config),code:this.code,status:this.status}}});const fc=Le.prototype,pc={};["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=>{pc[e]={value:e}}),Object.defineProperties(Le,pc),Object.defineProperty(fc,"isAxiosError",{value:!0}),Le.from=(e,t,n,r,o,s)=>{const i=Object.create(fc);U.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 Le.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 _x=null;function hi(e){return U.isPlainObject(e)||U.isArray(e)}function hc(e){return U.endsWith(e,"[]")?e.slice(0,-2):e}function mc(e,t,n){return e?e.concat(t).map(function(o,s){return o=hc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function jx(e){return U.isArray(e)&&!e.some(hi)}const Px=U.toFlatObject(U,{},null,function(t){return/^is[A-Z]/.test(t)});function jo(e,t,n){if(!U.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=U.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!U.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&U.isSpecCompliantForm(t);if(!U.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(U.isDate(v))return v.toISOString();if(U.isBoolean(v))return v.toString();if(!l&&U.isBlob(v))throw new Le("Blob is not supported. Use a Buffer instead.");return U.isArrayBuffer(v)||U.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(U.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(U.isArray(v)&&jx(v)||(U.isFileList(v)||U.endsWith(g,"[]"))&&(y=U.toArray(v)))return g=hc(g),y.forEach(function(S,E){!(U.isUndefined(S)||S===null)&&t.append(i===!0?mc([g],E,s):i===null?g:g+"[]",c(S))}),!1}return hi(v)?!0:(t.append(mc(x,g,s),c(v)),!1)}const p=[],m=Object.assign(Px,{defaultVisitor:d,convertValue:c,isVisitable:hi});function f(v,g){if(!U.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(v),U.forEach(v,function(y,b){(!(U.isUndefined(y)||y===null)&&o.call(t,y,U.isString(b)?b.trim():b,g,m))===!0&&f(y,g?g.concat(b):[b])}),p.pop()}}if(!U.isObject(e))throw new TypeError("data must be an object");return f(e),t}function gc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function mi(e,t){this._pairs=[],e&&jo(e,this,t)}const xc=mi.prototype;xc.append=function(t,n){this._pairs.push([t,n])},xc.toString=function(t){const n=t?function(r){return t.call(this,r,gc)}:gc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Mx(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function vc(e,t,n){if(!t)return e;const r=n&&n.encode||Mx;U.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=U.isURLSearchParams(t)?t.toString():new mi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class wc{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){U.forEach(this.handlers,function(r){r!==null&&t(r)})}}const bc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Rx={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:mi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},gi=typeof window<"u"&&typeof document<"u",xi=typeof navigator=="object"&&navigator||void 0,Ox=gi&&(!xi||["ReactNative","NativeScript","NS"].indexOf(xi.product)<0),Dx=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Lx=gi&&window.location.href||"http://localhost",Nt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:gi,hasStandardBrowserEnv:Ox,hasStandardBrowserWebWorkerEnv:Dx,navigator:xi,origin:Lx},Symbol.toStringTag,{value:"Module"})),...Rx};function $x(e,t){return jo(e,new Nt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Nt.isNode&&U.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Fx(e){return U.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Bx(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 yc(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&&U.isArray(o)?o.length:i,l?(U.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!U.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&U.isArray(o[i])&&(o[i]=Bx(o[i])),!a)}if(U.isFormData(e)&&U.isFunction(e.entries)){const n={};return U.forEachEntry(e,(r,o)=>{t(Fx(r),o,n,0)}),n}return null}function zx(e,t,n){if(U.isString(e))try{return(t||JSON.parse)(e),U.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Hr={transitional:bc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=U.isObject(t);if(s&&U.isHTMLForm(t)&&(t=new FormData(t)),U.isFormData(t))return o?JSON.stringify(yc(t)):t;if(U.isArrayBuffer(t)||U.isBuffer(t)||U.isStream(t)||U.isFile(t)||U.isBlob(t)||U.isReadableStream(t))return t;if(U.isArrayBufferView(t))return t.buffer;if(U.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 $x(t,this.formSerializer).toString();if((a=U.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return jo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),zx(t)):t}],transformResponse:[function(t){const n=this.transitional||Hr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(U.isResponse(t)||U.isReadableStream(t))return t;if(t&&U.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"?Le.from(a,Le.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:Nt.classes.FormData,Blob:Nt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};U.forEach(["delete","get","head","post","put","patch"],e=>{Hr.headers[e]={}});const Hx=U.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"]),Ux=e=>{const t={};let n,r,o;return e&&e.split(`
31
+ `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&Hx[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Sc=Symbol("internals");function Ur(e){return e&&String(e).trim().toLowerCase()}function Po(e){return e===!1||e==null?e:U.isArray(e)?e.map(Po):String(e)}function Wx(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 Vx=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function vi(e,t,n,r,o){if(U.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!U.isString(t)){if(U.isString(r))return t.indexOf(r)!==-1;if(U.isRegExp(r))return r.test(t)}}function Kx(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function qx(e,t){const n=U.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 $t=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Ur(l);if(!d)throw new Error("header name must be a non-empty string");const p=U.findKey(o,d);(!p||o[p]===void 0||c===!0||c===void 0&&o[p]!==!1)&&(o[p||l]=Po(a))}const i=(a,l)=>U.forEach(a,(c,d)=>s(c,d,l));if(U.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(U.isString(t)&&(t=t.trim())&&!Vx(t))i(Ux(t),n);else if(U.isObject(t)&&U.isIterable(t)){let a={},l,c;for(const d of t){if(!U.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?U.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=Ur(t),t){const r=U.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Wx(o);if(U.isFunction(n))return n.call(this,o,r);if(U.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Ur(t),t){const r=U.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||vi(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Ur(i),i){const a=U.findKey(r,i);a&&(!n||vi(r,r[a],a,n))&&(delete r[a],o=!0)}}return U.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||vi(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return U.forEach(this,(o,s)=>{const i=U.findKey(r,s);if(i){n[i]=Po(o),delete n[s];return}const a=t?Kx(s):String(s).trim();a!==s&&delete n[s],n[a]=Po(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return U.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&U.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
+ `)}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[Sc]=this[Sc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Ur(i);r[a]||(qx(o,i),r[a]=!0)}return U.isArray(t)?t.forEach(s):s(t),this}};$t.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),U.reduceDescriptors($t.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),U.freezeMethods($t);function wi(e,t){const n=this||Hr,r=t||n,o=$t.from(r.headers);let s=r.data;return U.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Cc(e){return!!(e&&e.__CANCEL__)}function fr(e,t,n){Le.call(this,e??"canceled",Le.ERR_CANCELED,t,n),this.name="CanceledError"}U.inherits(fr,Le,{__CANCEL__:!0});function Tc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Le("Request failed with status code "+n.status,[Le.ERR_BAD_REQUEST,Le.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Gx(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Yx(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 Xx(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 Mo=(e,t,n=3)=>{let r=0;const o=Yx(50,250);return Xx(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)},Ec=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},kc=e=>(...t)=>U.asap(()=>e(...t)),Jx=Nt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Nt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Nt.origin),Nt.navigator&&/(msie|trident)/i.test(Nt.navigator.userAgent)):()=>!0,Zx=Nt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];U.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),U.isString(r)&&i.push("path="+r),U.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 Qx(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function ev(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Ic(e,t,n){let r=!Qx(t);return e&&(r||n==!1)?ev(e,t):t}const Nc=e=>e instanceof $t?{...e}:e;function qn(e,t){t=t||{};const n={};function r(c,d,p,m){return U.isPlainObject(c)&&U.isPlainObject(d)?U.merge.call({caseless:m},c,d):U.isPlainObject(d)?U.merge({},d):U.isArray(d)?d.slice():d}function o(c,d,p,m){if(U.isUndefined(d)){if(!U.isUndefined(c))return r(void 0,c,p,m)}else return r(c,d,p,m)}function s(c,d){if(!U.isUndefined(d))return r(void 0,d)}function i(c,d){if(U.isUndefined(d)){if(!U.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(Nc(c),Nc(d),p,!0)};return U.forEach(Object.keys({...e,...t}),function(d){const p=l[d]||o,m=p(e[d],t[d],d);U.isUndefined(m)&&p!==a||(n[d]=m)}),n}const Ac=e=>{const t=qn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=$t.from(i),t.url=vc(Ic(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),U.isFormData(n)){if(Nt.hasStandardBrowserEnv||Nt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(U.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(Nt.hasStandardBrowserEnv&&(r&&U.isFunction(r)&&(r=r(t)),r||r!==!1&&Jx(t.url))){const l=o&&s&&Zx.read(s);l&&i.set(o,l)}return t},tv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Ac(e);let s=o.data;const i=$t.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 S=$t.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:S,config:e,request:x};Tc(function(k){n(k),g()},function(k){r(k),g()},C),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 Le("Request aborted",Le.ECONNABORTED,e,x)),x=null)},x.onerror=function(E){const C=E&&E.message?E.message:"Network Error",T=new Le(C,Le.ERR_NETWORK,e,x);T.event=E||null,r(T),x=null},x.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||bc;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new Le(E,C.clarifyTimeoutError?Le.ETIMEDOUT:Le.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&U.forEach(i.toJSON(),function(E,C){x.setRequestHeader(C,E)}),U.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Mo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([p,f]=Mo(l),x.upload.addEventListener("progress",p),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new fr(null,e,x):S),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Gx(o.url);if(b&&Nt.protocols.indexOf(b)===-1){r(new Le("Unsupported protocol "+b+":",Le.ERR_BAD_REQUEST,e));return}x.send(s||null)})},nv=(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 Le?d:new fr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Le(`timeout ${t} of ms exceeded`,Le.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=()=>U.asap(a),l}},rv=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},ov=async function*(e,t){for await(const n of sv(e))yield*rv(n,t)},sv=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()}},_c=(e,t,n,r)=>{const o=ov(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})},jc=64*1024,{isFunction:Ro}=U,iv=(({Request:e,Response:t})=>({Request:e,Response:t}))(U.global),{ReadableStream:Pc,TextEncoder:Mc}=U.global,Rc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},av=e=>{e=U.merge.call({skipUndefined:!0},iv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Ro(t):typeof fetch=="function",s=Ro(n),i=Ro(r);if(!o)return!1;const a=o&&Ro(Pc),l=o&&(typeof Mc=="function"?(v=>g=>v.encode(g))(new Mc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&Rc(()=>{let v=!1;const g=new n(Nt.origin,{body:new Pc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Rc(()=>U.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 Le(`Response type '${v}' is not supported`,Le.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(U.isBlob(v))return v.size;if(U.isSpecCompliantForm(v))return(await new n(Nt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(U.isArrayBufferView(v)||U.isArrayBuffer(v))return v.byteLength;if(U.isURLSearchParams(v)&&(v=v+""),U.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=U.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:b,cancelToken:S,timeout:E,onDownloadProgress:C,onUploadProgress:T,responseType:k,headers:j,withCredentials:D="same-origin",fetchOptions:B}=Ac(v),W=t||fetch;k=k?(k+"").toLowerCase():"text";let K=nv([b,S&&S.toAbortSignal()],E),z=null;const _=K&&K.unsubscribe&&(()=>{K.unsubscribe()});let Y;try{if(T&&c&&x!=="get"&&x!=="head"&&(Y=await f(j,y))!==0){let q=new n(g,{method:"POST",body:y,duplex:"half"}),P;if(U.isFormData(y)&&(P=q.headers.get("content-type"))&&j.setContentType(P),q.body){const[O,X]=Ec(Y,Mo(kc(T)));y=_c(q.body,jc,O,X)}}U.isString(D)||(D=D?"include":"omit");const N=s&&"credentials"in n.prototype,$={...B,signal:K,method:x.toUpperCase(),headers:j.normalize().toJSON(),body:y,duplex:"half",credentials:N?D:void 0};z=s&&new n(g,$);let R=await(s?W(z,B):W(g,$));const I=d&&(k==="stream"||k==="response");if(d&&(C||I&&_)){const q={};["status","statusText","headers"].forEach(J=>{q[J]=R[J]});const P=U.toFiniteNumber(R.headers.get("content-length")),[O,X]=C&&Ec(P,Mo(kc(C),!0))||[];R=new r(_c(R.body,jc,O,()=>{X&&X(),_&&_()}),q)}k=k||"text";let H=await p[U.findKey(p,k)||"text"](R,v);return!I&&_&&_(),await new Promise((q,P)=>{Tc(q,P,{data:H,headers:$t.from(R.headers),status:R.status,statusText:R.statusText,config:v,request:z})})}catch(N){throw _&&_(),N&&N.name==="TypeError"&&/Load failed|fetch/i.test(N.message)?Object.assign(new Le("Network Error",Le.ERR_NETWORK,v,z),{cause:N.cause||N}):Le.from(N,N&&N.code,v,z)}}},lv=new Map,Oc=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=lv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:av(t)),d=c;return c};Oc();const bi={http:_x,xhr:tv,fetch:{get:Oc}};U.forEach(bi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Dc=e=>`- ${e}`,cv=e=>U.isFunction(e)||e===null||e===!1,Lc={getAdapter:(e,t)=>{e=U.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,!cv(r)&&(o=bi[(a=String(r)).toLowerCase()],o===void 0))throw new Le(`Unknown adapter '${a}'`);if(o&&(U.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
+ `+i.map(Dc).join(`
34
+ `):" "+Dc(i[0]):"as no adapter specified";throw new Le("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:bi};function yi(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new fr(null,e)}function $c(e){return yi(e),e.headers=$t.from(e.headers),e.data=wi.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Lc.getAdapter(e.adapter||Hr.adapter,e)(e).then(function(r){return yi(e),r.data=wi.call(e,e.transformResponse,r),r.headers=$t.from(r.headers),r},function(r){return Cc(r)||(yi(e),r&&r.response&&(r.response.data=wi.call(e,e.transformResponse,r.response),r.response.headers=$t.from(r.response.headers))),Promise.reject(r)})}const Fc="1.12.2",Oo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Oo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Bc={};Oo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Fc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Le(o(i," has been removed"+(n?" in "+n:"")),Le.ERR_DEPRECATED);return n&&!Bc[i]&&(Bc[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}},Oo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function uv(e,t,n){if(typeof e!="object")throw new Le("options must be an object",Le.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 Le("option "+s+" must be "+l,Le.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Le("Unknown option "+s,Le.ERR_BAD_OPTION)}}const Do={assertOptions:uv,validators:Oo},hn=Do.validators;let Gn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new wc,response:new wc}}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=qn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Do.assertOptions(r,{silentJSONParsing:hn.transitional(hn.boolean),forcedJSONParsing:hn.transitional(hn.boolean),clarifyTimeoutError:hn.transitional(hn.boolean)},!1),o!=null&&(U.isFunction(o)?n.paramsSerializer={serialize:o}:Do.assertOptions(o,{encode:hn.function,serialize:hn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Do.assertOptions(n,{baseUrl:hn.spelling("baseURL"),withXsrfToken:hn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&U.merge(s.common,s[n.method]);s&&U.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=$t.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=[$c.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=$c.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=qn(this.defaults,t);const n=Ic(t.baseURL,t.url,t.allowAbsoluteUrls);return vc(n,t.params,t.paramsSerializer)}};U.forEach(["delete","get","head","options"],function(t){Gn.prototype[t]=function(n,r){return this.request(qn(r||{},{method:t,url:n,data:(r||{}).data}))}}),U.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(qn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Gn.prototype[t]=n(),Gn.prototype[t+"Form"]=n(!0)});let dv=class Rg{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 fr(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 Rg(function(o){t=o}),cancel:t}}};function fv(e){return function(n){return e.apply(null,n)}}function pv(e){return U.isObject(e)&&e.isAxiosError===!0}const Si={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(Si).forEach(([e,t])=>{Si[t]=e});function zc(e){const t=new Gn(e),n=rc(Gn.prototype.request,t);return U.extend(n,Gn.prototype,t,{allOwnKeys:!0}),U.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return zc(qn(e,o))},n}const xt=zc(Hr);xt.Axios=Gn,xt.CanceledError=fr,xt.CancelToken=dv,xt.isCancel=Cc,xt.VERSION=Fc,xt.toFormData=jo,xt.AxiosError=Le,xt.Cancel=xt.CanceledError,xt.all=function(t){return Promise.all(t)},xt.spread=fv,xt.isAxiosError=pv,xt.mergeConfig=qn,xt.AxiosHeaders=$t,xt.formToJSON=e=>yc(U.isHTMLForm(e)?new FormData(e):e),xt.getAdapter=Lc.getAdapter,xt.HttpStatusCode=Si,xt.default=xt;const{Axios:FI,AxiosError:BI,CanceledError:zI,isCancel:HI,CancelToken:UI,VERSION:WI,all:VI,Cancel:KI,isAxiosError:qI,spread:GI,toFormData:YI,AxiosHeaders:XI,HttpStatusCode:JI,formToJSON:ZI,getAdapter:QI,mergeConfig:e1}=xt,Hc=typeof window<"u"?window.__API_BASE_URL__:void 0,Uc=Hc?mn(Hc):void 0;function mn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Lo=null;const Ci=new Set;function Wc(){return Lo}function $o(e){Lo=e,Ci.forEach(t=>t(e))}function Vc(e){return Ci.add(e),()=>Ci.delete(e)}const Kc=3e4,qc=9e4,Kt=xt.create({...Uc?{baseURL:Uc}:{},timeout:Kc,withCredentials:!0});Kt.interceptors.request.use(e=>(Lo&&(e.headers.Authorization=`Bearer ${Lo}`),e)),Kt.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),$o(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 qt(e,t){return Kt.defaults.baseURL?(await Kt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Fo(e,t,n){return Kt.defaults.baseURL?(await Kt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Gc(e,t,n){return Kt.defaults.baseURL?(await Kt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ti(e,t){return Kt.defaults.baseURL?(await Kt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Rt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Bo{get baseUrl(){const t=Kt.defaults.baseURL;return t?mn(String(t)):""}updateConfig(t){t.baseUrl&&(Kt.defaults.baseURL=mn(String(t.baseUrl))),t.authToken!==void 0&&$o(t.authToken)}getAuthToken(){return Wc()}setAuthToken(t){$o(t)}onTokenChange(t){return Vc(t)}async listThreads(){const t=await qt("/threads"),n=Rt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await qt("/threads/shared"),n=Rt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Fo("/threads",t?{title:t}:void 0);return Rt(r)}async updateThread(t,n){const r=await Gc(`/threads/${t}`,{title:n});return Rt(r)}async deleteThread(t){const n=await Ti(`/threads/${t}`);return Rt(n)}async shareThread(t,n){const r=await Fo(`/threads/${t}/share`,{shared_with_user_id:n});return Rt(r)}async threadInfo(t){const n=await qt(`/threads/${t}/info`);return Rt(n)}async listAgents(){const t=await qt("/agents"),n=Rt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await qt(`/agents/${t}`);return Rt(n)}async getAgentSchema(t){const n=await qt(`/agents/${t}/schema`);return Rt(n)}async getState(t){const n=await qt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Rt(n)}async getStateHistory(t){const n=await qt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:qc});return Rt(n)}async cancelRun(t){const n=await Fo("/runs/cancel",{threadId:t});return Rt(n)}async unshareThread(t,n){const r=await Ti(`/threads/${t}/share/${n}`);return Rt(r)}}const An=new Bo,hv=Bo,mv=Bo;async function Ei(e,t){return await qt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function gv(e,t){const n=await Ei(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function ki(e,t){return await(await Ei(`/files/${e}/view`,t)).text()}async function Yc(e,t){const n=await Ei(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await qt(`/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 xv(e){return await qt(`/files/${e}`)}async function Xc(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await qt("/files",{params:r})}const Jc=w.createContext(null);function vv({children:e,apiConfig:t}){const n=An;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(Jc.Provider,{value:r,children:e})}function Ii(){const e=w.useContext(Jc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Zc(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 Qc(e=[]){const t=[],n=[];for(const r of e)try{const o=await Zc(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function eu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[p,m]=w.useState(null),v=w.useMemo(()=>Nn(p),[p]).checkpoints,g=Zl(v),x=g.timeline,[y,b]=w.useState(!1),[S,E]=w.useState(null),[C,T]=w.useState(!1),[k,j]=w.useState(!1),[D,B]=w.useState(!1),[W,K]=w.useState(null),z=w.useRef(o),_=w.useRef(null),Y=w.useRef(null),N=w.useRef(null),$=w.useRef(null),R=w.useRef(!1),I=w.useRef(null),H=w.useRef(new Map);w.useEffect(()=>{z.current=o},[o]);const q=w.useCallback(async F=>{var we,fe;if(!F.threadId)return;const oe=F.threadId;(we=F.onStart)==null||we.call(F),F.setLoading(!0);try{await F.action(oe)}catch(xe){if(z.current===oe){const _e=String(xe);(fe=F.handleError)==null||fe.call(F,_e),r==null||r(_e)}throw xe}finally{F.setLoading(!1)}},[r]),P=w.useCallback(async(F,oe)=>{if(!F)return;const we=`${F}:${oe??"latest"}`,fe=H.current.get(we);if(fe)return fe;const xe=q({threadId:F,setLoading:T,onStart:()=>K(null),handleError:_e=>K(_e),action:async _e=>{const $e=await e.getStateHistory({threadId:_e,checkpointId:oe??void 0});if(z.current!==_e){console.log(`[useThreadHistoryState] Thread changed during load (was ${_e}, now ${z.current}), discarding stale data`);return}const{checkpoints:Ue}=Nn($e),Ne=Ue.find(Oe=>Oe.messages&&Oe.messages.length>0)??(oe?Ue.find(Oe=>Oe.checkpointId===oe):null)??Ue[0];t((Ne==null?void 0:Ne.messages)??[],{checkpointId:(Ne==null?void 0:Ne.checkpointId)??null,checkpointNs:(Ne==null?void 0:Ne.checkpointNs)??null}),m($e),b(!!(Ne!=null&&Ne.nextCursor)),E((Ne==null?void 0:Ne.nextCursor)??null)}});H.current.set(we,xe);try{await xe}finally{H.current.delete(we)}return z.current===F&&(I.current=we),xe},[e,t,q]),O=w.useCallback(async(F,oe)=>{$.current=F;try{await P(F,oe)}finally{$.current===F&&($.current=null)}},[P]),X=w.useCallback(F=>{Y.current=F},[]),J=w.useCallback(F=>{N.current=F},[]),se=w.useCallback(F=>{const oe=F.threadId??z.current;if(!oe||z.current&&z.current!==oe)return;const{checkpoints:we}=Nn(F);if(!we.length)return;const fe=we.find(xe=>xe.messages&&xe.messages.length>0)??we.find(xe=>!!xe.checkpointId)??we[0];t((fe==null?void 0:fe.messages)??[],{checkpointId:(fe==null?void 0:fe.checkpointId)??null,checkpointNs:(fe==null?void 0:fe.checkpointNs)??null}),m(F),b(!!(fe!=null&&fe.nextCursor)),E((fe==null?void 0:fe.nextCursor)??null),I.current=`${oe}:latest`,Y.current=null,N.current=null},[t]),V=w.useCallback(async(F,oe)=>{const we=z.current;await q({threadId:we,setLoading:B,action:async fe=>{const xe=await e.getStateHistory({threadId:fe,checkpointId:F,checkpointNs:oe??void 0});if(z.current!==fe){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${fe}, now ${z.current}), discarding stale data`);return}const{checkpoints:_e}=Nn(xe),$e=_e.find(Ue=>Ue.checkpointId===F&&(oe?Ue.checkpointNs===oe:!0));if(!$e){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:F,checkpointNs:oe});return}m(xe),t($e.messages??[],{checkpointId:$e.checkpointId??null,checkpointNs:$e.checkpointNs??null})}}).catch(()=>{})},[e,t,q]),L=w.useCallback((F,oe)=>{t(d(),{checkpointId:F??null,checkpointNs:oe??null})},[d,t]),Z=w.useCallback(async()=>{z.current&&await O(z.current)},[O]),Q=w.useCallback(async()=>{const F=z.current;!F||!S||await q({threadId:F,setLoading:j,action:async oe=>{const we=await e.getStateHistory({threadId:oe,checkpointId:S});if(z.current!==oe)return;const{checkpoints:fe}=Nn(we);if(fe.length>0){const xe=fe[fe.length-1];n((xe==null?void 0:xe.messages)??[]),b(!!(xe!=null&&xe.nextCursor)),E((xe==null?void 0:xe.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,q]);w.useEffect(()=>{if(!l||!o||C||c)return;if(Y.current===o){Y.current=null,_.current=o;return}if(N.current===o){_.current=o;return}if($.current===o){$.current=null,_.current=o;return}if(_.current===o)return;_.current=o;const F=!R.current&&!!i&&o===s;let oe;F&&i?(oe=i,R.current=!0,console.log("[useThreadHistoryState] Loading thread with checkpoint:",oe,a?`(ns: ${a})`:"")):console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const we=`${o}:${oe??"latest"}`;I.current!==we&&O(o,oe)},[l,o,i,a,s,C,c,O]);const ce=w.useCallback(()=>{m(null),b(!1),E(null),T(!1),j(!1),B(!1),K(null),Y.current=null,N.current=null,_.current=null,I.current=null,$.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:k,isLoadingCheckpoint:D,threadStateError:W,hasMoreHistory:y,loadThread:O,navigateToCheckpoint:V,loadOlderMessages:Q,setCurrentCheckpointId:L,returnToLatest:Z,handleStateHistoryEvent:se,markSkipNextLoad:X,markStreamPendingThread:J,resetHistoryState:ce}}const wv=["detail","message","error","description","title"];function zo(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=zo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of wv){const r=zo(t[n]);if(r)return r}if("errors"in t){const n=zo(t.errors);if(n)return n}}return null}function bv(e){if(!e)return"Request failed";const t=e.response,n=zo(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 tu({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,S]=w.useState(null),[E,C]=w.useState(!1),T=w.useRef(a),k=w.useRef(new Map);w.useEffect(()=>{T.current=a},[a]);const j=w.useCallback(async()=>{d(!0),m(null);try{const R=await e.listThreads();i(R??[])}catch(R){const I=String(R);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),D=w.useCallback(async()=>{x(!0),y(null);try{const R=await e.listSharedThreads();v(R??[])}catch(R){const I=String(R);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);w.useEffect(()=>{j()},[j]),w.useEffect(()=>{D()},[D]),w.useEffect(()=>{r==null||r(a)},[a,r]);const B=w.useCallback(async R=>{try{const I=await e.createThread(R);return l(I.threadId),await j(),I.threadId}catch(I){const H=String(I);return n==null||n(H),null}},[e,n,j]),W=w.useCallback(async R=>{const I=s;i(q=>q.filter(P=>P.threadId!==R));const H=new AbortController;k.current.set(R,H);try{await e.deleteThread(R),T.current===R&&(l(null),o==null||o())}catch(q){i(I);const P=String(q);n==null||n(P)}finally{k.current.delete(R)}},[e,o,n,s]),K=w.useCallback(async(R,I)=>{try{await e.updateThread(R,I),await j()}catch(H){n==null||n(String(H))}},[e,n,j]),z=w.useCallback(async(R,I)=>{C(!0),S("Sharing thread…");try{await e.shareThread(R,I),await D(),S("Shared successfully")}catch(H){const q=bv(H);throw n==null||n(q),S(`Failed to share: ${q}`),new Error(q)}finally{C(!1)}},[e,n,D]),_=w.useCallback(async(R,I)=>{try{await e.unshareThread(R,I),await D()}catch(H){const q=String(H);throw n==null||n(q),H}},[e,n,D]),Y=w.useMemo(()=>({createThread:B,deleteThread:W,renameThread:K,refreshThreads:j,refreshSharedThreads:D,shareThread:z,unshareThread:_}),[B,W,K,j,D,z,_]),N=w.useCallback(R=>{if(!(R!=null&&R.threadId))return;const I={threadId:R.threadId,title:R.title||`Thread ${R.threadId.slice(0,8)}`,createdAt:R.createdAt||new Date().toISOString(),updatedAt:R.updatedAt||new Date().toISOString(),messageCount:R.messageCount??1};i(H=>{let q=!1;const P=H.map(O=>O.threadId===I.threadId?(q=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...O,title:I.title??O.title,updatedAt:I.updatedAt??O.updatedAt,messageCount:I.messageCount??O.messageCount}):O);return q?P:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...H])})},[]),$=w.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:p,sharedThreads:f,isLoadingSharedThreads:g,actions:Y,addThreadFromEvent:N,shareInFlight:E,shareStatus:b,clearShareStatus:$}}function Ni(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function nu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Wr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Wr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(nu(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=Wr(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 pr(e){if(typeof e=="string")return e;if(nu(e))return"";try{const t=Wr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function yv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Sv(e){const t=pr(e);return typeof e=="string"&&yv(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Vr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Ni(t);if(n!==null)return Vr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Vr(e.content):e}function Cv(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Ai(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 Ho(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Tv(e){const t=r=>{try{const o=Wr(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(`
36
+ `)):t(e)}function Ev(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function ru(e){if("type"in e&&e.type==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function kv(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function Iv(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Nv({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=kv(n),i=o?`data:${s};base64,${e}`:t,a=Iv(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function Av(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 Nv({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function _i(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 Kr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function _v(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 ou(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function su(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function jv(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??su(e);let l="",c=e.slice();if(s){const p=Pv(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 iu(e){return e.replace(/\s+/g," ").trim()}function Pv(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=iu(e),o=iu(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function Mv(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 Kr(e,r,s)}return e}function Rv(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const Ov={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function Dv(e,t){var n;switch(t.type){case"reset":return{messages:_i(((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=_i(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=_i(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 Lv(e=[]){const[t,n]=w.useReducer(Dv,{...Ov,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=Rv(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 Fv(e,t);if(t.type==="tool.progress")return Bv(e,t);if(t.type==="tool.end")return zv(e,t);if(t.type==="message.delta"){const s=e.assemblingId??ou(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},p=d[s],m=p??{lastSeq:null,lastText:su(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}=jv(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},b=Kr(i,a,y),S=!p||p.lastSeq!==g.lastSeq||p.lastText!==g.lastText,E=S?{...d,[s]:g}:c;return S?{...e,messages:b,messagesStreamMeta:E}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??ou(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=Mv(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=Nn(t),i=s.interrupt,a=s.latest,l=i===null?_v(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 ji(e){return e.call_id??e.id??null}function lu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function cu(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 Pi(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||Ai(r).toolCallId===t)return n}return-1}function $v(e){if(e==null)return[];const t=Vr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=pr(t??e);return n?[{type:"text",text:n}]:[]}function uu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function Fv(e,t){const n=ji(t),r=Pi(e.messages,n),o=t.name??t.tool??void 0,s=lu(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:Kr(e.messages,r,d)}}const i=cu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function Bv(e,t){const n=ji(t);if(!n)return e;const r=Pi(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=uu(e.messages[r],o);return{...e,messages:Kr(e.messages,r,a)}}function zv(e,t){const n=ji(t),r=lu(t);let o=e.messages,s=Pi(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,cu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=$v(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=uu(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:Kr(o,s,f)}}function du(e={}){const t=w.useMemo(()=>mn(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),S=w.useRef(null),E=w.useRef(!0),C=w.useRef(0),T=w.useRef(null),k=w.useRef(null),j=w.useRef(null),D=w.useRef(null),B=w.useCallback(_=>{o(_)},[]),W=w.useCallback(()=>{m(""),v(null),d(null),k.current=null,j.current=null,D.current=null},[]),K=w.useCallback(()=>{var _;console.debug("[use-chat] stop() invoked - aborting stream"),(_=S.current)==null||_.abort(),S.current=null,T.current=null,l(!1),b(!1),C.current=0,x(0)},[]),z=w.useCallback((_,Y,N)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),k.current=null,j.current=null,D.current=null;const $=new AbortController;S.current=$;let R=null,I=null,H=!1;return T.current={threadId:_.threadId??null,headers:{}},(async()=>{var P,O,X,J,se,V,L,Z,Q,ce,F,oe,we,fe,xe,_e,$e,Ue;const q=Ne=>{var Oe;try{const Ye=JSON.parse(JSON.stringify(Ne));return(Oe=Ye==null?void 0:Ye.payload)!=null&&Oe.files_info&&Array.isArray(Ye.payload.files_info)&&(Ye.payload.files_info=Ye.payload.files_info.map(We=>({...We,data:We!=null&&We.data?`<base64 ${String(We.data).length} chars>`:We==null?void 0:We.data}))),Ye}catch{return Ne}};try{let Ne={};try{if(r)Ne={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ke=window.__AUTH_TOKEN__,yt=((P=window.localStorage)==null?void 0:P.getItem("authToken"))||null;let ht=null;try{const gt=(O=window.localStorage)==null?void 0:O.getItem("chat-settings");gt&&(ht=((X=JSON.parse(gt))==null?void 0:X.apiKey)||null)}catch{}const qe=Ke||yt||ht||null;qe&&(Ne={Authorization:`Bearer ${qe}`})}}catch{}console.debug("[use-chat] POST",t+n,q(_));let Oe={};if(typeof window<"u")try{const De=(J=window.localStorage)==null?void 0:J.getItem("authSessionId");De&&(Oe={"X-Session-Id":De})}catch{}const Ye={...Ne,...Oe,...s.current},We={"Content-Type":"application/json",Accept:"text/event-stream",...Ye},Je=await fetch(t+n,{method:"POST",headers:We,body:JSON.stringify(_),signal:$.signal,credentials:i});if(T.current&&(T.current.headers=Ye),!Je.ok||!Je.body){const De=await Je.text().catch(()=>"");console.debug("[use-chat] non-OK response",Je.status,De==null?void 0:De.slice(0,500));const Ke=`stream ${Je.status}${De?": "+De:""}`;throw(se=N==null?void 0:N.onConnectionError)==null||se.call(N,Ke),H=!0,R="error",I=Ke,new Error(Ke)}b(!0);const ot=Je.body.getReader(),nt=new TextDecoder;let Ze="",Ae=[];C.current=0,x(0);let Be=0,et=null;const ct=()=>{if(Ae.length){const De=Ae.join("");Ae=[],E.current&&m(Ke=>Ke+De)}et=null},Et=()=>{typeof window<"u"&&et==null&&(et=requestAnimationFrame(ct))};let st=Date.now();const Ve=setInterval(()=>{var De;if(Date.now()-st>18e5){const Ke="Stream idle timeout";d(Ke),R="error",I=Ke,$.abort(),(De=N==null?void 0:N.onError)==null||De.call(N,Ke)}},5e3),It=1024*1024;try{const De=Je.headers.get("X-Thread-Id")||Je.headers.get("x-thread-id"),Ke=Je.headers.get("X-Thread-Created")||Je.headers.get("x-thread-created"),yt=De??null,ht=String(Ke??"").toLowerCase()==="true";for(T.current&&!T.current.threadId&&(T.current={...T.current,threadId:yt}),(V=N==null?void 0:N.onOpen)==null||V.call(N,{threadId:yt,created:ht});;){const{value:qe,done:gt}=await ot.read();if(gt)break;Ze+=nt.decode(qe,{stream:!0}),Ze.length>It&&(Ze="",console.warn("Stream buffer reset: exceeded 1MB"));let M;for(;(M=Ze.indexOf(`
37
37
 
38
- `))>=0;){const ne=st.slice(0,_);st=st.slice(_+2);const me=Ix(ne);if(!me)continue;let Ue;try{Ue=JSON.parse(me)}catch{console.debug("[use-chat] malformed SSE:",me.slice(0,200));continue}const Pe=Ex(Ue)?Ue.data:Ue;it=Date.now();const vt=Pe.seq;if(vt!==void 0){if(vt<=Le){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:vt,lastProcessedSeq:Le,type:Pe.type});continue}Le>0&&vt>Le+1&&((O=N==null?void 0:N.onGap)==null||O.call(N,{from:Le,to:vt})),Le=vt,C.current=vt,g(vt)}if(Pe.type==="checkpoint")E.current=Pe.checkpointId??null,A.current=Pe.checkpointNs??null,v(Pe.checkpointId??null);else if(Pe.type==="state_history"){L.current=Pe;try{const $t=zn(Pe).latest;$t&&(E.current=$t.checkpointId??null,A.current=$t.checkpointNs??null,v($t.checkpointId??null))}catch(et){console.warn("[use-chat] Failed to hydrate state_history payload",et)}}try{G==null||G(Pe)}catch(et){console.error("[use-chat] Error in onEvent callback:",et,"for event:",Pe.type)}if(Pe.type==="message.delta"){const et=Pe.delta.filter($t=>$t.type==="text").map($t=>$t.text).join("");et&&e.autoAppendAssistant!==!1&&(Te.push(et),Nt())}else if(Pe.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(Y=N==null?void 0:N.onHeartbeat)==null||Y.call(N,Pe)}catch(et){console.warn("[use-chat] heartbeat callback failed",et)}}else if(ot!==null&&cancelAnimationFrame(ot),ct(),Pe.type==="checkpoint")v(Pe.checkpointId);else if(Pe.type==="error"){const et=Pe;if(d(et.message),P="error",j=et.message,et.error_type==="auth_error"||et.code==="TOKEN_EXPIRED"||((X=et.message)==null?void 0:X.includes("token"))||((le=et.message)==null?void 0:le.includes("401"))||((D=et.message)==null?void 0:D.includes("unauthorized"))||((te=et.message)==null?void 0:te.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",et.message);try{(xe=N==null?void 0:N.onAuthError)==null||xe.call(N,et.message)}catch(rr){console.warn("[use-chat] onAuthError handler failed",rr)}$.abort()}}}}ct(),P===null&&!$.signal.aborted&&(P="complete")}catch(ze){if(ze.name==="AbortError")P=P??"aborted";else{const Be=ze.message||String(ze);P="error",j=Be,d(Be),(de=N==null?void 0:N.onError)==null||de.call(N,Be)}}finally{try{await tt.cancel()}catch{}finally{(we=tt.releaseLock)==null||we.call(tt)}ot!==null&&typeof window<"u"&&window.cancelAnimationFrame(ot),clearInterval(Ye)}}catch(ke){if(ke.name==="AbortError")P=P??"aborted";else{const Fe=ke.message||String(ke);P="error",j=Fe,d(Fe),(je=N==null?void 0:N.onError)==null||je.call(N,Fe),U||((De=N==null?void 0:N.onConnectionError)==null||De.call(N,Fe),U=!0)}}finally{const ke=C.current,Fe=E.current,Ke=A.current,Je=L.current,qe=P??($.signal.aborted?"aborted":j?"error":"complete");try{($e=N==null?void 0:N.onClosed)==null||$e.call(N,{reason:qe,lastSeq:ke,lastCheckpointId:Fe,lastCheckpointNs:Ke,lastStateHistory:Je,error:j})}catch(tt){console.warn("[use-chat] onClosed callback failed",tt)}l(!1),b(!1),S.current=null,C.current=0,g(0),k.current=null}})(),{close:()=>$.abort()}},[t,n,r,e.autoAppendAssistant]);return y.useEffect(()=>()=>{var R;T.current=!1,(R=S.current)==null||R.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:x,connected:w,stream:H,stop:K,clear:W,setToken:B}}function Ex(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Ix(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
39
- `)}const Nx=["message.start","message.delta","message.end"],Ax=["tool.start","tool.end","tool.progress"],jx=["thread_info","checkpoint"],_x=["error","interrupt","heartbeat","state_history","cancelled"],Mx=[...Nx,...Ax,...jx,..._x],Rx=new Set(Mx);function Px(e){if(typeof e!="object"||e===null||typeof e.type!="string")return!1;const t=e.type;return Rx.has(t)}const vc=200;function Ox({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onStateHistory:r,onUnhandledEvent:o,onSequenceGap:s,onStreamClosed:i,onConnectionError:a,onAuthError:l,onHeartbeat:u,onToolEvent:d}){const f=y.useRef(null),h=y.useRef(null),p=y.useRef(new Map),v=y.useRef(null),x=y.useRef(null),g=y.useCallback(N=>{try{const $=globalThis.structuredClone;if(typeof $=="function")return $(N)}catch{}try{return JSON.parse(JSON.stringify(N))}catch{return N}},[]),w=y.useCallback((N,$)=>{if(!N)return;const P=p.current.get(N)??[],j=g($),U=P.length>=vc?[...P.slice(P.length-vc+1),j]:[...P,j];p.current.set(N,U)},[g]),b=y.useCallback(N=>{N&&p.current.set(N,[])},[]),S=y.useCallback(N=>{const $=N??h.current;if(!$)return;const P=p.current.get($);P!=null&&P.length&&P.forEach(j=>{try{n(j)}catch(U){console.error("[useChatStreamingService] Failed to replay buffered event",U)}})},[n]),T=y.useCallback(N=>{h.current=N.threadId,v.current&&(v.current.threadIdGuess=N.threadId),x.current=N,b(N.threadId),console.log("[useChatStreamingService] 🎯 Received thread_info event:",N);try{t(N)}catch($){console.error("[useChatStreamingService] Error in onThreadInfo handler:",$)}},[b,t]),C=y.useCallback(N=>{try{u==null||u(N)}catch($){console.error("[useChatStreamingService] Error in onHeartbeat handler:",$)}},[u]),k=y.useCallback(N=>{var j,U,V,M;const $=N;if($.error_type==="auth_error"||$.code==="TOKEN_EXPIRED"||((j=$.message)==null?void 0:j.includes("token"))||((U=$.message)==null?void 0:U.includes("401"))||((V=$.message)==null?void 0:V.includes("unauthorized"))||((M=$.message)==null?void 0:M.includes("Unauthorized"))){console.error("[useChatStreamingService] Auth error event detected:",$.message);try{l==null||l($.message)}catch(F){console.warn("[useChatStreamingService] onAuthError handler failed",F)}}},[l]),E=y.useMemo(()=>({thread_info:N=>(T(N),!0),heartbeat:N=>(C(N),!0),error:N=>(k(N),!1)}),[T,C,k]),A=y.useCallback(N=>{var U;const $=N.seq??null;if($!==null){const V=f.current;if(V!==null){if($<=V)return;$>V+1&&(s==null||s({from:V,to:$}))}f.current=$}const P=E[N.type];if(P&&P(N))return;const j=N.threadId??(N.type==="state_history"?N.threadId:void 0)??h.current??((U=v.current)==null?void 0:U.threadIdGuess)??null;if(N.type==="state_history"){h.current=j??h.current;try{r==null||r(N)}catch(V){console.error("[useChatStreamingService] onStateHistory handler failed",V)}}if(Px(N)){(N.type==="tool.start"||N.type==="tool.end")&&(d==null||d(N)),N.type==="checkpoint"||N.type==="state_history"?b(j??null):w(j??null,N);try{n(N)}catch(V){console.error("[useChatStreamingService] Error in onMessageEvent handler:",V)}return}try{o==null||o(N)}catch(V){console.error("[useChatStreamingService] Error in onUnhandledEvent handler:",V)}},[w,b,n,s,r,o,E]),{stream:L,stop:B,isStreaming:W,error:K,setToken:H}=wc({baseUrl:e,token:void 0}),R=y.useCallback((N,$)=>{f.current=null,x.current=null,h.current=N.threadId??null,v.current={request:N,callbacks:$,manualStop:!1,threadIdGuess:N.threadId??null},L(N,A,{onOpen:$==null?void 0:$.onOpen,onError:P=>{var j;(j=$==null?void 0:$.onError)==null||j.call($,P)},onGap:($==null?void 0:$.onGap)??s,onConnectionError:P=>{var j;a==null||a(P),(j=$==null?void 0:$.onConnectionError)==null||j.call($,P)},onAuthError:P=>{var j;l==null||l(P),(j=$==null?void 0:$.onAuthError)==null||j.call($,P)},onHeartbeat:P=>{var j;try{u==null||u(P)}catch(U){console.warn("[useChatStreamingService] onHeartbeat handler failed",U)}try{(j=$==null?void 0:$.onHeartbeat)==null||j.call($,P)}catch(U){console.warn("[useChatStreamingService] downstream onHeartbeat handler failed",U)}},onClosed:P=>{var M,F,ee,J;const j=((M=v.current)==null?void 0:M.manualStop)??!1,U=h.current??((F=v.current)==null?void 0:F.threadIdGuess)??((ee=P.lastStateHistory)==null?void 0:ee.threadId)??null;(P.reason==="complete"||P.reason==="aborted"&&j)&&b(U);const V={...P,threadId:U,threadInfo:x.current,manualStop:j};try{i==null||i(V)}catch(ie){console.warn("[useChatStreamingService] onStreamClosed handler failed",ie)}try{(J=$==null?void 0:$.onClosed)==null||J.call($,V)}catch(ie){console.warn("[useChatStreamingService] downstream onClosed handler failed",ie)}v.current&&(v.current=null)}})},[b,A,l,a,u,s,i,L]),G=y.useCallback(()=>{v.current&&(v.current.manualStop=!0),B()},[B]);return y.useMemo(()=>({startStream:R,stop:G,isStreaming:W,error:K,setAuthToken:H,replayBufferedEvents:S}),[R,G,W,K,H,S])}const bc=y.createContext(null),yc=y.createContext(null),Sc=y.createContext(null);y.createContext(!1);function Dx({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:u}){const{api:d,baseUrl:f}=fi(),h=y.useMemo(()=>xn(f),[f]),{state:p,seed:v,prepend:x,pushUser:g,onEvent:w}=hc(),{threads:b,currentThreadId:S,setCurrentThreadId:T,currentThreadIdRef:C,isLoadingThreads:k,threadsError:E,sharedThreads:A,isLoadingSharedThreads:L,actions:B,addThreadFromEvent:W,shareInFlight:K,shareStatus:H,clearShareStatus:R}=sx({api:d,initialThreadId:t,onError:s,onThreadChange:a,onCurrentThreadDeleted:()=>v([],{})}),[G,N]=y.useState(!1),$=y.useCallback(()=>p.messages,[p.messages]),{threadCheckpoints:P,threadTimeline:j,checkpointIndex:U,isLoadingThread:V,isHistoryLoading:M,isLoadingCheckpoint:F,threadStateError:ee,hasMoreHistory:J,loadThread:ie,navigateToCheckpoint:q,loadOlderMessages:O,setCurrentCheckpointId:Y,returnToLatest:X,handleStateHistoryEvent:le,markSkipNextLoad:D,markStreamPendingThread:te,resetHistoryState:xe}=nx({api:d,seed:v,prepend:x,onError:s,currentThreadId:S,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:G,getMessages:$}),de=y.useCallback(Te=>{console.log("[ChatSessionProvider] 🎯 Received thread_info:",Te.threadId),W(Te),C.current!==Te.threadId&&((Te.created??!C.current)&&D(Te.threadId),te(Te.threadId),console.log("[ChatSessionProvider] thread_info: marking to skip auto-load for new thread"),T(Te.threadId))},[W,D,te]),{startStream:we,stop:je,isStreaming:De,error:$e,setAuthToken:ke}=Ox({baseUrl:h,onThreadInfo:de,onMessageEvent:w,onStateHistory:le,onUnhandledEvent:Te=>{console.warn("[ChatSessionProvider] Unhandled event:",Te.type)},onAuthError:i,onConnectionError:l,onToolEvent:Te=>{Te.type==="tool.end"&&(u==null||u(Te))}});y.useEffect(()=>{N(De)},[De]);const Fe=y.useCallback(async()=>{v([],{}),T(null),je(),xe();try{await d.getAgent("default")}catch(Te){console.warn("[ChatSessionProvider] Failed to refetch agent after clearing thread:",Te)}},[v,je,d,xe]),Ke=y.useCallback(async(Te,Le,ot)=>{const ct=C.current;if(!ct)throw new Error("No active thread to handle interrupt");const Nt=Le?ot??!0:!1;try{const it={threadId:ct,checkpointId:p.lastCheckpointId??void 0,checkpointNs:p.lastCheckpointNs??void 0,command:{kind:"resume",value:Nt}};we(it)}catch(it){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${Te}:`,it),it}},[p.lastCheckpointId,p.lastCheckpointNs,we]),Je=y.useCallback(async(Te,Le)=>{let ot=C.current;const ct=(Te==null?void 0:Te.text)??"",Nt=(Te==null?void 0:Te.attachments)??[],it=(ct==null?void 0:ct.trim())??"",Ye={...(Te==null?void 0:Te.payload)??{}},Mt=Array.isArray(Ye.messages)?Ye.messages:void 0;Mt&&delete Ye.messages;const ze=!!(Mt&&Mt.length);if(!ot&&!it&&Nt.length===0&&!ze)return;if(!ot){const vt=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),et=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);ot=`${vt}${et}`,D(ot),T(ot)}const{contentParts:Be,filesInfo:yt}=await Vg(Nt),ht=[...Be];it&&ht.push({type:"text",text:ct});const He=Le==null?void 0:Le.originalMessageId,mt=!!(Le!=null&&Le.edit&&He),_=!ze&&ht.length>0;let ne=null;_&&(ne={id:mt?He:`msg-${Date.now()}`,role:"user",content:ht,createdAt:new Date().toISOString()},mt?g(ne,He):g(ne));const me=ze?Mt:ne?[ne]:[],Ue={...Ye,...yt.length?{files_info:yt}:{}};me.length?Ue.messages=me:"messages"in Ue||(Ue.messages=[]);const Pe={threadId:ot,payload:Ue,checkpointId:(Le==null?void 0:Le.checkpointId)??p.lastCheckpointId??void 0,checkpointNs:(Le==null?void 0:Le.checkpointNs)??p.lastCheckpointNs??void 0,edit:!!(Le!=null&&Le.edit),timelineCheckpoints:j};we(Pe)},[d,g,p,we,j]),qe=y.useMemo(()=>({threads:b,currentThreadId:S,setCurrentThreadId:T,isLoading:k,error:E,sharedThreads:A,isLoadingSharedThreads:L,actions:B,shareInFlight:K,shareStatus:H,clearShareStatus:R}),[b,S,T,k,E,A,L,B,K,H,R]),tt=y.useMemo(()=>{const Te=p.assemblingId??null;return Te?{assemblingMessageId:Te}:null},[p.assemblingId]),bt=y.useMemo(()=>({threadId:S,messages:p.messages,interrupt:null,checkpoint:{id:p.lastCheckpointId??null,namespace:p.lastCheckpointNs??null},checkpoints:P,checkpointIndex:U,timelineCheckpoints:j,metadata:tt,isLoading:V,isHistoryLoading:M,isLoadingCheckpoint:F,error:ee,hasMore:J,loadOlder:O,clearState:Fe,navigateToCheckpoint:q,setCurrentCheckpointId:Y,returnToLatest:X,loadThread:ie,clearThread:Fe,respondToInterrupt:Ke,messagePreviews:U.messagePreviews}),[S,p,P,j,U,V,M,F,ee,J,O,Fe,q,Y,X,ie,Ke,tt]),st=y.useMemo(()=>({isStreaming:De,error:$e,connectionState:De?"connected":"idle",submit:Je,send:Je,stop:je,setAuthToken:ke}),[De,$e,Je,je,ke]);return c.jsx(bc.Provider,{value:qe,children:c.jsx(yc.Provider,{value:bt,children:c.jsx(Sc.Provider,{value:st,children:e})})})}function Ro(){const e=y.useContext(bc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Po(){const e=y.useContext(yc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function Cc(){const e=y.useContext(Sc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Oo({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:u,onToolEnd:d}){return c.jsx(Ug,{apiConfig:t,children:c.jsx(Dx,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:a,onAuthError:l,onConnectionError:i,onThreadChange:u,onToolEnd:d,children:e})})}function re(...e){return gm.twMerge(mm.clsx(e))}const Lx=go.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"}}),Ze=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Ln.Slot:"button";return c.jsx(i,{className:re(Lx({variant:t,size:n,className:e})),ref:s,...o})});Ze.displayName="Button";const kc=m.forwardRef(({className:e,...t},n)=>c.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}));kc.displayName="Textarea";const $x=1e4;function Tc({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=$x,value:i,onValueChange:a,onSend:l,onCancelEdit:u,onStop:d,className:f="",textareaClassName:h="",allowEmptySend:p=!1,validate:v,onValidationError:x}){const g=i!==void 0,[w,b]=y.useState(e),S=(g?i:w)??"",[T,C]=y.useTransition(),k=y.useRef(null),E=y.useRef(0),A=y.useRef(null),L=y.useRef("");y.useEffect(()=>{g||(b(e??""),A.current=null,k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`))},[e,t,g]);const[B,W]=y.useState(null),K=y.useCallback(F=>F.length>s?`Message too long (${F.length}/${s} characters)`:null,[s]),H=y.useMemo(()=>v??K,[v,K]),R=y.useCallback(F=>{const ee=H(F);return W(ee),x==null||x(ee),L.current=F,ee},[H,x]),G=y.useCallback(()=>{const F=k.current;F&&(F.style.height="auto",F.style.height=`${F.scrollHeight}px`)},[]);y.useEffect(()=>{G()},[G,S]),y.useEffect(()=>{if(!B)return;const F=(S??"").trim();L.current!==F&&R(F)},[S,B,R]);const N=y.useCallback((F,{fromUser:ee})=>{g||b(F),ee&&(a==null||a(F))},[g,a]),$=y.useCallback(async F=>{F&&F.preventDefault();const ee=(S??"").trim();if(!ee&&!p||R(ee))return;const J=++E.current;A.current={id:J,shouldClear:!0},C(()=>{var ie,q,O;try{const Y=l(ee);Y&&typeof Y.then=="function"?Y.then(()=>{var X,le;((X=A.current)==null?void 0:X.id)===J&&A.current.shouldClear&&(g||(b(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((le=A.current)==null?void 0:le.id)===J&&(A.current=null)}).catch(()=>{var X;((X=A.current)==null?void 0:X.id)===J&&(A.current=null)}):(((ie=A.current)==null?void 0:ie.id)===J&&A.current.shouldClear&&(g||(b(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((q=A.current)==null?void 0:q.id)===J&&(A.current=null))}catch{((O=A.current)==null?void 0:O.id)===J&&(A.current=null)}})},[S,l,p,g,a,R]),P=y.useCallback(F=>{const ee=F.target.value;N(ee,{fromUser:!0}),A.current&&(A.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`),B&&R(ee.trim())},[N,R,B]),j=y.useCallback(F=>{F.key==="Enter"&&!F.shiftKey?(F.preventDefault(),$()):F.key==="Escape"&&t&&(F.preventDefault(),u==null||u())},[$,t,u]),M=`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))]":""} ${h}`;return c.jsx("form",{onSubmit:F=>void $(F),className:`w-full ${f}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx(kc,{ref:k,value:S,onChange:P,onKeyDown:j,placeholder:t?"Edit your message...":n,className:M,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),B&&c.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:B})]}),c.jsx("div",{children:r?c.jsx(Ze,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:c.jsx(se.Square,{size:16})}):c.jsx(Ze,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!p||T,children:c.jsx(se.Send,{size:16})})})]})})}const Fx=y.memo(Tc);function pe(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 Ec(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Cn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Ec(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():Ec(e[o],null)}}}}function We(...e){return m.useCallback(Cn(...e),e)}function Bx(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.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 wn(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var w;const{scope:h,children:p,...v}=f,x=((w=h==null?void 0:h[e])==null?void 0:w[l])||a,g=m.useMemo(()=>v,Object.values(v));return c.jsx(x.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var x;const p=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,v=m.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,zx(o,...t)]}function zx(...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:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var St=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},Hx=m[" useInsertionEffect ".trim().toString()]||St;function ur({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Ux({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"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 u=m.useCallback(d=>{var f;if(a){const h=Wx(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,u]}function Ux({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return Hx(()=>{s.current=t},[t]),m.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Wx(e){return typeof e=="function"}var Vx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ce=Vx.reduce((e,t)=>{const n=Ln.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ic(e,t){e&&xo.flushSync(()=>e.dispatchEvent(t))}function wi(e){const t=e+"CollectionProvider",[n,r]=wn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:g,children:w}=x,b=y.useRef(null),S=y.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:w})};i.displayName=t;const a=e+"CollectionSlot",l=Ln.createSlot(a),u=y.forwardRef((x,g)=>{const{scope:w,children:b}=x,S=s(a,w),T=We(g,S.collectionRef);return c.jsx(l,{ref:T,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Ln.createSlot(d),p=y.forwardRef((x,g)=>{const{scope:w,children:b,...S}=x,T=y.useRef(null),C=We(g,T),k=s(d,w);return y.useEffect(()=>(k.itemMap.set(T,{ref:T,...S}),()=>void k.itemMap.delete(T))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function v(x){const g=s(e+"CollectionConsumer",x);return y.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((k,E)=>S.indexOf(k.ref.current)-S.indexOf(E.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},v,r]}var Kx=m.createContext(void 0);function Do(e){const t=m.useContext(Kx);return e||t||"ltr"}function Ct(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function qx(e,t=globalThis==null?void 0:globalThis.document){const n=Ct(e);m.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 Gx="DismissableLayer",vi="dismissableLayer.update",Yx="dismissableLayer.pointerDownOutside",Xx="dismissableLayer.focusOutside",Nc,Ac=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Lo=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(Ac),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),v=We(t,E=>f(E)),x=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),w=x.indexOf(g),b=d?x.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,T=b>=w,C=Qx(E=>{const A=E.target,L=[...u.branches].some(B=>B.contains(A));!T||L||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),k=ew(E=>{const A=E.target;[...u.branches].some(B=>B.contains(A))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return qx(E=>{b===u.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Nc=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),jc(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Nc)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),jc())},[d,u]),m.useEffect(()=>{const E=()=>p({});return document.addEventListener(vi,E),()=>document.removeEventListener(vi,E)},[]),c.jsx(Ce.div,{...l,ref:v,style:{pointerEvents:S?T?"auto":"none":void 0,...e.style},onFocusCapture:pe(e.onFocusCapture,k.onFocusCapture),onBlurCapture:pe(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:pe(e.onPointerDownCapture,C.onPointerDownCapture)})});Lo.displayName=Gx;var Jx="DismissableLayerBranch",Zx=m.forwardRef((e,t)=>{const n=m.useContext(Ac),r=m.useRef(null),o=We(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(Ce.div,{...e,ref:o})});Zx.displayName=Jx;function Qx(e,t=globalThis==null?void 0:globalThis.document){const n=Ct(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){_c(Yx,n,u,{discrete:!0})};const u={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 ew(e,t=globalThis==null?void 0:globalThis.document){const n=Ct(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&_c(Xx,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 jc(){const e=new CustomEvent(vi);document.dispatchEvent(e)}function _c(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?Ic(o,s):o.dispatchEvent(s)}var bi=0;function yi(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Mc()),document.body.insertAdjacentElement("beforeend",e[1]??Mc()),bi++,()=>{bi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),bi--}},[])}function Mc(){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 Si="focusScope.autoFocusOnMount",Ci="focusScope.autoFocusOnUnmount",Rc={bubbles:!1,cancelable:!0},tw="FocusScope",$o=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=Ct(o),d=Ct(s),f=m.useRef(null),h=We(t,x=>l(x)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let x=function(S){if(p.paused||!a)return;const T=S.target;a.contains(T)?f.current=T:kn(f.current,{select:!0})},g=function(S){if(p.paused||!a)return;const T=S.relatedTarget;T!==null&&(a.contains(T)||kn(f.current,{select:!0}))},w=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&kn(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",g);const b=new MutationObserver(w);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){Dc.add(p);const x=document.activeElement;if(!a.contains(x)){const w=new CustomEvent(Si,Rc);a.addEventListener(Si,u),a.dispatchEvent(w),w.defaultPrevented||(nw(aw(Pc(a)),{select:!0}),document.activeElement===x&&kn(a))}return()=>{a.removeEventListener(Si,u),setTimeout(()=>{const w=new CustomEvent(Ci,Rc);a.addEventListener(Ci,d),a.dispatchEvent(w),w.defaultPrevented||kn(x??document.body,{select:!0}),a.removeEventListener(Ci,d),Dc.remove(p)},0)}}},[a,u,d,p]);const v=m.useCallback(x=>{if(!n&&!r||p.paused)return;const g=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,w=document.activeElement;if(g&&w){const b=x.currentTarget,[S,T]=rw(b);S&&T?!x.shiftKey&&w===T?(x.preventDefault(),n&&kn(S,{select:!0})):x.shiftKey&&w===S&&(x.preventDefault(),n&&kn(T,{select:!0})):w===b&&x.preventDefault()}},[n,r,p.paused]);return c.jsx(Ce.div,{tabIndex:-1,...i,ref:h,onKeyDown:v})});$o.displayName=tw;function nw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(kn(r,{select:t}),document.activeElement!==n)return}function rw(e){const t=Pc(e),n=Oc(t,e),r=Oc(t.reverse(),e);return[n,r]}function Pc(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 Oc(e,t){for(const n of e)if(!ow(n,{upTo:t}))return n}function ow(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 sw(e){return e instanceof HTMLInputElement&&"select"in e}function kn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&sw(e)&&t&&e.select()}}var Dc=iw();function iw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Lc(e,t),e.unshift(t)},remove(t){var n;e=Lc(e,t),(n=e[0])==null||n.resume()}}}function Lc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function aw(e){return e.filter(t=>t.tagName!=="A")}var lw=m[" useId ".trim().toString()]||(()=>{}),cw=0;function At(e){const[t,n]=m.useState(lw());return St(()=>{n(r=>r??String(cw++))},[e]),t?`radix-${t}`:""}const uw=["top","right","bottom","left"],Tn=Math.min,Bt=Math.max,Fo=Math.round,Bo=Math.floor,ln=e=>({x:e,y:e}),dw={left:"right",right:"left",bottom:"top",top:"bottom"},fw={start:"end",end:"start"};function ki(e,t,n){return Bt(e,Tn(t,n))}function vn(e,t){return typeof e=="function"?e(t):e}function bn(e){return e.split("-")[0]}function dr(e){return e.split("-")[1]}function Ti(e){return e==="x"?"y":"x"}function Ei(e){return e==="y"?"height":"width"}const hw=new Set(["top","bottom"]);function cn(e){return hw.has(bn(e))?"y":"x"}function Ii(e){return Ti(cn(e))}function pw(e,t,n){n===void 0&&(n=!1);const r=dr(e),o=Ii(e),s=Ei(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=zo(i)),[i,zo(i)]}function mw(e){const t=zo(e);return[Ni(e),t,Ni(t)]}function Ni(e){return e.replace(/start|end/g,t=>fw[t])}const $c=["left","right"],Fc=["right","left"],gw=["top","bottom"],xw=["bottom","top"];function ww(e,t,n){switch(e){case"top":case"bottom":return n?t?Fc:$c:t?$c:Fc;case"left":case"right":return t?gw:xw;default:return[]}}function vw(e,t,n,r){const o=dr(e);let s=ww(bn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ni)))),s}function zo(e){return e.replace(/left|right|bottom|top/g,t=>dw[t])}function bw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Bc(e){return typeof e!="number"?bw(e):{top:e,right:e,bottom:e,left:e}}function Ho(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 zc(e,t,n){let{reference:r,floating:o}=e;const s=cn(t),i=Ii(t),a=Ei(i),l=bn(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(dr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const yw=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 u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=zc(u,r,l),h=r,p={},v=0;for(let x=0;x<a.length;x++){const{name:g,fn:w}=a[x],{x:b,y:S,data:T,reset:C}=await w({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,p={...p,[g]:{...p[g],...T}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=zc(u,h,l)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function Br(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=vn(t,e),v=Bc(p),g=a[h?f==="floating"?"reference":"floating":f],w=Ho(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),T=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=Ho(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(w.top-C.top+v.top)/T.y,bottom:(C.bottom-w.bottom+v.bottom)/T.y,left:(w.left-C.left+v.left)/T.x,right:(C.right-w.right+v.right)/T.x}}const Sw=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:u,padding:d=0}=vn(e,t)||{};if(u==null)return{};const f=Bc(d),h={x:n,y:r},p=Ii(o),v=Ei(p),x=await i.getDimensions(u),g=p==="y",w=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",T=s.reference[v]+s.reference[p]-h[p]-s.floating[v],C=h[p]-s.reference[p],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let E=k?k[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(k)))&&(E=a.floating[S]||s.floating[v]);const A=T/2-C/2,L=E/2-x[v]/2-1,B=Tn(f[w],L),W=Tn(f[b],L),K=B,H=E-x[v]-W,R=E/2-x[v]/2+A,G=ki(K,R,H),N=!l.arrow&&dr(o)!=null&&R!==G&&s.reference[v]/2-(R<K?B:W)-x[v]/2<0,$=N?R<K?R-K:R-H:0;return{[p]:h[p]+$,data:{[p]:G,centerOffset:R-G-$,...N&&{alignmentOffset:$}},reset:N}}}),Cw=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:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:x=!0,...g}=vn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=bn(o),b=cn(a),S=bn(a)===a,T=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(S||!x?[zo(a)]:mw(a)),k=v!=="none";!h&&k&&C.push(...vw(a,x,v,T));const E=[a,...C],A=await Br(t,g),L=[];let B=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&L.push(A[w]),f){const R=pw(o,i,T);L.push(A[R[0]],A[R[1]])}if(B=[...B,{placement:o,overflows:L}],!L.every(R=>R<=0)){var W,K;const R=(((W=s.flip)==null?void 0:W.index)||0)+1,G=E[R];if(G&&(!(f==="alignment"?b!==cn(G):!1)||B.every(P=>cn(P.placement)===b?P.overflows[0]>0:!0)))return{data:{index:R,overflows:B},reset:{placement:G}};let N=(K=B.filter($=>$.overflows[0]<=0).sort(($,P)=>$.overflows[1]-P.overflows[1])[0])==null?void 0:K.placement;if(!N)switch(p){case"bestFit":{var H;const $=(H=B.filter(P=>{if(k){const j=cn(P.placement);return j===b||j==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(j=>j>0).reduce((j,U)=>j+U,0)]).sort((P,j)=>P[1]-j[1])[0])==null?void 0:H[0];$&&(N=$);break}case"initialPlacement":N=a;break}if(o!==N)return{reset:{placement:N}}}return{}}}};function Hc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Uc(e){return uw.some(t=>e[t]>=0)}const kw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=vn(e,t);switch(r){case"referenceHidden":{const s=await Br(t,{...o,elementContext:"reference"}),i=Hc(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Uc(i)}}}case"escaped":{const s=await Br(t,{...o,altBoundary:!0}),i=Hc(s,n.floating);return{data:{escapedOffsets:i,escaped:Uc(i)}}}default:return{}}}}},Wc=new Set(["left","top"]);async function Tw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=bn(n),a=dr(n),l=cn(n)==="y",u=Wc.has(i)?-1:1,d=s&&l?-1:1,f=vn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const Ew=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 Tw(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}}}}},Iw=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:g=>{let{x:w,y:b}=g;return{x:w,y:b}}},...l}=vn(e,t),u={x:n,y:r},d=await Br(t,l),f=cn(bn(o)),h=Ti(f);let p=u[h],v=u[f];if(s){const g=h==="y"?"top":"left",w=h==="y"?"bottom":"right",b=p+d[g],S=p-d[w];p=ki(b,p,S)}if(i){const g=f==="y"?"top":"left",w=f==="y"?"bottom":"right",b=v+d[g],S=v-d[w];v=ki(b,v,S)}const x=a.fn({...t,[h]:p,[f]:v});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:s,[f]:i}}}}}},Nw=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:u=!0}=vn(e,t),d={x:n,y:r},f=cn(o),h=Ti(f);let p=d[h],v=d[f];const x=vn(a,t),g=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const S=h==="y"?"height":"width",T=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;p<T?p=T:p>C&&(p=C)}if(u){var w,b;const S=h==="y"?"width":"height",T=Wc.has(bn(o)),C=s.reference[f]-s.floating[S]+(T&&((w=i.offset)==null?void 0:w[f])||0)+(T?0:g.crossAxis),k=s.reference[f]+s.reference[S]+(T?0:((b=i.offset)==null?void 0:b[f])||0)-(T?g.crossAxis:0);v<C?v=C:v>k&&(v=k)}return{[h]:p,[f]:v}}}},Aw=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=()=>{},...u}=vn(e,t),d=await Br(t,u),f=bn(o),h=dr(o),p=cn(o)==="y",{width:v,height:x}=s.floating;let g,w;f==="top"||f==="bottom"?(g=f,w=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(w=f,g=h==="end"?"top":"bottom");const b=x-d.top-d.bottom,S=v-d.left-d.right,T=Tn(x-d[g],b),C=Tn(v-d[w],S),k=!t.middlewareData.shift;let E=T,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),k&&!h){const B=Bt(d.left,0),W=Bt(d.right,0),K=Bt(d.top,0),H=Bt(d.bottom,0);p?A=v-2*(B!==0||W!==0?B+W:Bt(d.left,d.right)):E=x-2*(K!==0||H!==0?K+H:Bt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:E});const L=await i.getDimensions(a.floating);return v!==L.width||x!==L.height?{reset:{rects:!0}}:{}}}};function Uo(){return typeof window<"u"}function fr(e){return Vc(e)?(e.nodeName||"").toLowerCase():"#document"}function zt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function un(e){var t;return(t=(Vc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Vc(e){return Uo()?e instanceof Node||e instanceof zt(e).Node:!1}function en(e){return Uo()?e instanceof Element||e instanceof zt(e).Element:!1}function dn(e){return Uo()?e instanceof HTMLElement||e instanceof zt(e).HTMLElement:!1}function Kc(e){return!Uo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof zt(e).ShadowRoot}const jw=new Set(["inline","contents"]);function zr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=tn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!jw.has(o)}const _w=new Set(["table","td","th"]);function Mw(e){return _w.has(fr(e))}const Rw=[":popover-open",":modal"];function Wo(e){return Rw.some(t=>{try{return e.matches(t)}catch{return!1}})}const Pw=["transform","translate","scale","rotate","perspective"],Ow=["transform","translate","scale","rotate","perspective","filter"],Dw=["paint","layout","strict","content"];function Ai(e){const t=ji(),n=en(e)?tn(e):e;return Pw.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)||Ow.some(r=>(n.willChange||"").includes(r))||Dw.some(r=>(n.contain||"").includes(r))}function Lw(e){let t=En(e);for(;dn(t)&&!hr(t);){if(Ai(t))return t;if(Wo(t))return null;t=En(t)}return null}function ji(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const $w=new Set(["html","body","#document"]);function hr(e){return $w.has(fr(e))}function tn(e){return zt(e).getComputedStyle(e)}function Vo(e){return en(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function En(e){if(fr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Kc(e)&&e.host||un(e);return Kc(t)?t.host:t}function qc(e){const t=En(e);return hr(t)?e.ownerDocument?e.ownerDocument.body:e.body:dn(t)&&zr(t)?t:qc(t)}function Hr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=qc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=zt(o);if(s){const a=_i(i);return t.concat(i,i.visualViewport||[],zr(o)?o:[],a&&n?Hr(a):[])}return t.concat(o,Hr(o,[],n))}function _i(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Gc(e){const t=tn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=dn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Fo(n)!==s||Fo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Mi(e){return en(e)?e:e.contextElement}function pr(e){const t=Mi(e);if(!dn(t))return ln(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Gc(t);let i=(s?Fo(n.width):n.width)/r,a=(s?Fo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Fw=ln(0);function Yc(e){const t=zt(e);return!ji()||!t.visualViewport?Fw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Bw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==zt(e)?!1:t}function Hn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Mi(e);let i=ln(1);t&&(r?en(r)&&(i=pr(r)):i=pr(e));const a=Bw(s,n,r)?Yc(s):ln(0);let l=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=zt(s),p=r&&en(r)?zt(r):r;let v=h,x=_i(v);for(;x&&r&&p!==v;){const g=pr(x),w=x.getBoundingClientRect(),b=tn(x),S=w.left+(x.clientLeft+parseFloat(b.paddingLeft))*g.x,T=w.top+(x.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=T,v=zt(x),x=_i(v)}}return Ho({width:d,height:f,x:l,y:u})}function Ko(e,t){const n=Vo(e).scrollLeft;return t?t.left+n:Hn(un(e)).left+n}function Xc(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Ko(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function zw(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=un(r),a=t?Wo(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=ln(1);const d=ln(0),f=dn(r);if((f||!f&&!s)&&((fr(r)!=="body"||zr(i))&&(l=Vo(r)),dn(r))){const p=Hn(r);u=pr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?Xc(i,l):ln(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function Hw(e){return Array.from(e.getClientRects())}function Uw(e){const t=un(e),n=Vo(e),r=e.ownerDocument.body,o=Bt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Bt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Ko(e);const a=-n.scrollTop;return tn(r).direction==="rtl"&&(i+=Bt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Jc=25;function Ww(e,t){const n=zt(e),r=un(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=ji();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=Ko(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=Jc&&(s-=v)}else u<=Jc&&(s+=u);return{width:s,height:i,x:a,y:l}}const Vw=new Set(["absolute","fixed"]);function Kw(e,t){const n=Hn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=dn(e)?pr(e):ln(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function Zc(e,t,n){let r;if(t==="viewport")r=Ww(e,n);else if(t==="document")r=Uw(un(e));else if(en(t))r=Kw(t,n);else{const o=Yc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ho(r)}function Qc(e,t){const n=En(e);return n===t||!en(n)||hr(n)?!1:tn(n).position==="fixed"||Qc(n,t)}function qw(e,t){const n=t.get(e);if(n)return n;let r=Hr(e,[],!1).filter(a=>en(a)&&fr(a)!=="body"),o=null;const s=tn(e).position==="fixed";let i=s?En(e):e;for(;en(i)&&!hr(i);){const a=tn(i),l=Ai(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Vw.has(o.position)||zr(i)&&!l&&Qc(e,i))?r=r.filter(d=>d!==i):o=a,i=En(i)}return t.set(e,r),r}function Gw(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Wo(t)?[]:qw(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=Zc(t,d,o);return u.top=Bt(f.top,u.top),u.right=Tn(f.right,u.right),u.bottom=Tn(f.bottom,u.bottom),u.left=Bt(f.left,u.left),u},Zc(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Yw(e){const{width:t,height:n}=Gc(e);return{width:t,height:n}}function Xw(e,t,n){const r=dn(t),o=un(t),s=n==="fixed",i=Hn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=ln(0);function u(){l.x=Ko(o)}if(r||!r&&!s)if((fr(t)!=="body"||zr(o))&&(a=Vo(t)),r){const p=Hn(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?Xc(o,a):ln(0),f=i.left+a.scrollLeft-l.x-d.x,h=i.top+a.scrollTop-l.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function Ri(e){return tn(e).position==="static"}function eu(e,t){if(!dn(e)||tn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return un(e)===n&&(n=n.ownerDocument.body),n}function tu(e,t){const n=zt(e);if(Wo(e))return n;if(!dn(e)){let o=En(e);for(;o&&!hr(o);){if(en(o)&&!Ri(o))return o;o=En(o)}return n}let r=eu(e,t);for(;r&&Mw(r)&&Ri(r);)r=eu(r,t);return r&&hr(r)&&Ri(r)&&!Ai(r)?n:r||Lw(e)||n}const Jw=async function(e){const t=this.getOffsetParent||tu,n=this.getDimensions,r=await n(e.floating);return{reference:Xw(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Zw(e){return tn(e).direction==="rtl"}const Qw={convertOffsetParentRelativeRectToViewportRelativeRect:zw,getDocumentElement:un,getClippingRect:Gw,getOffsetParent:tu,getElementRects:Jw,getClientRects:Hw,getDimensions:Yw,getScale:pr,isElement:en,isRTL:Zw};function nu(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ev(e,t){let n=null,r;const o=un(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 u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const v=Bo(f),x=Bo(o.clientWidth-(d+h)),g=Bo(o.clientHeight-(f+p)),w=Bo(d),S={rootMargin:-v+"px "+-x+"px "+-g+"px "+-w+"px",threshold:Bt(0,Tn(1,l))||1};let T=!0;function C(k){const E=k[0].intersectionRatio;if(E!==l){if(!T)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!nu(u,e.getBoundingClientRect())&&i(),T=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function tv(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,u=Mi(e),d=o||s?[...u?Hr(u):[],...Hr(t)]:[];d.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const f=u&&a?ev(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(w=>{let[b]=w;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let v,x=l?Hn(e):null;l&&g();function g(){const w=Hn(e);x&&!nu(x,w)&&n(),x=w,v=requestAnimationFrame(g)}return n(),()=>{var w;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(w=p)==null||w.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const nv=Ew,rv=Iw,ov=Cw,sv=Aw,iv=kw,ru=Sw,av=Nw,lv=(e,t,n)=>{const r=new Map,o={platform:Qw,...n},s={...o.platform,_c:r};return yw(e,t,{...o,platform:s})};var cv=typeof document<"u",uv=function(){},qo=cv?y.useLayoutEffect:uv;function Go(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(!Go(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)&&!Go(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function ou(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function su(e,t){const n=ou(e);return Math.round(t*n)/n}function Pi(e){const t=m.useRef(e);return qo(()=>{t.current=e}),t}function dv(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:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);Go(h,r)||p(r);const[v,x]=m.useState(null),[g,w]=m.useState(null),b=m.useCallback(P=>{P!==k.current&&(k.current=P,x(P))},[]),S=m.useCallback(P=>{P!==E.current&&(E.current=P,w(P))},[]),T=s||v,C=i||g,k=m.useRef(null),E=m.useRef(null),A=m.useRef(d),L=l!=null,B=Pi(l),W=Pi(o),K=Pi(u),H=m.useCallback(()=>{if(!k.current||!E.current)return;const P={placement:t,strategy:n,middleware:h};W.current&&(P.platform=W.current),lv(k.current,E.current,P).then(j=>{const U={...j,isPositioned:K.current!==!1};R.current&&!Go(A.current,U)&&(A.current=U,xo.flushSync(()=>{f(U)}))})},[h,t,n,W,K]);qo(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(P=>({...P,isPositioned:!1})))},[u]);const R=m.useRef(!1);qo(()=>(R.current=!0,()=>{R.current=!1}),[]),qo(()=>{if(T&&(k.current=T),C&&(E.current=C),T&&C){if(B.current)return B.current(T,C,H);H()}},[T,C,H,B,L]);const G=m.useMemo(()=>({reference:k,floating:E,setReference:b,setFloating:S}),[b,S]),N=m.useMemo(()=>({reference:T,floating:C}),[T,C]),$=m.useMemo(()=>{const P={position:n,left:0,top:0};if(!N.floating)return P;const j=su(N.floating,d.x),U=su(N.floating,d.y);return a?{...P,transform:"translate("+j+"px, "+U+"px)",...ou(N.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:j,top:U}},[n,a,N.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:H,refs:G,elements:N,floatingStyles:$}),[d,H,G,N,$])}const fv=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?ru({element:r.current,padding:o}).fn(n):{}:r?ru({element:r,padding:o}).fn(n):{}}}},hv=(e,t)=>({...nv(e),options:[e,t]}),pv=(e,t)=>({...rv(e),options:[e,t]}),mv=(e,t)=>({...av(e),options:[e,t]}),gv=(e,t)=>({...ov(e),options:[e,t]}),xv=(e,t)=>({...sv(e),options:[e,t]}),wv=(e,t)=>({...iv(e),options:[e,t]}),vv=(e,t)=>({...fv(e),options:[e,t]});var bv="Arrow",iu=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(Ce.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});iu.displayName=bv;var yv=iu;function au(e){const[t,n]=m.useState(void 0);return St(()=>{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,u=Array.isArray(l)?l[0]:l;i=u.inlineSize,a=u.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 Oi="Popper",[lu,Yo]=wn(Oi),[Sv,cu]=lu(Oi),uu=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(Sv,{scope:t,anchor:r,onAnchorChange:o,children:n})};uu.displayName=Oi;var du="PopperAnchor",fu=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=cu(du,n),i=m.useRef(null),a=We(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(Ce.div,{...o,ref:a})});fu.displayName=du;var Di="PopperContent",[Cv,kv]=lu(Di),hu=m.forwardRef((e,t)=>{var q,O,Y,X,le,D;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:v,...x}=e,g=cu(Di,n),[w,b]=m.useState(null),S=We(t,te=>b(te)),[T,C]=m.useState(null),k=au(T),E=(k==null?void 0:k.width)??0,A=(k==null?void 0:k.height)??0,L=r+(s!=="center"?"-"+s:""),B=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},W=Array.isArray(u)?u:[u],K=W.length>0,H={padding:B,boundary:W.filter(Ev),altBoundary:K},{refs:R,floatingStyles:G,placement:N,isPositioned:$,middlewareData:P}=dv({strategy:"fixed",placement:L,whileElementsMounted:(...te)=>tv(...te,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[hv({mainAxis:o+A,alignmentAxis:i}),l&&pv({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?mv():void 0,...H}),l&&gv({...H}),xv({...H,apply:({elements:te,rects:xe,availableWidth:de,availableHeight:we})=>{const{width:je,height:De}=xe.reference,$e=te.floating.style;$e.setProperty("--radix-popper-available-width",`${de}px`),$e.setProperty("--radix-popper-available-height",`${we}px`),$e.setProperty("--radix-popper-anchor-width",`${je}px`),$e.setProperty("--radix-popper-anchor-height",`${De}px`)}}),T&&vv({element:T,padding:a}),Iv({arrowWidth:E,arrowHeight:A}),h&&wv({strategy:"referenceHidden",...H})]}),[j,U]=gu(N),V=Ct(v);St(()=>{$&&(V==null||V())},[$,V]);const M=(q=P.arrow)==null?void 0:q.x,F=(O=P.arrow)==null?void 0:O.y,ee=((Y=P.arrow)==null?void 0:Y.centerOffset)!==0,[J,ie]=m.useState();return St(()=>{w&&ie(window.getComputedStyle(w).zIndex)},[w]),c.jsx("div",{ref:R.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:$?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(X=P.transformOrigin)==null?void 0:X.x,(le=P.transformOrigin)==null?void 0:le.y].join(" "),...((D=P.hide)==null?void 0:D.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(Cv,{scope:n,placedSide:j,onArrowChange:C,arrowX:M,arrowY:F,shouldHideArrow:ee,children:c.jsx(Ce.div,{"data-side":j,"data-align":U,...x,ref:S,style:{...x.style,animation:$?void 0:"none"}})})})});hu.displayName=Di;var pu="PopperArrow",Tv={top:"bottom",right:"left",bottom:"top",left:"right"},mu=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=kv(pu,r),i=Tv[s.placedSide];return c.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:c.jsx(yv,{...o,ref:n,style:{...o.style,display:"block"}})})});mu.displayName=pu;function Ev(e){return e!==null}var Iv=e=>({name:"transformOrigin",options:e,fn(t){var g,w,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=gu(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((w=o.arrow)==null?void 0:w.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",x="";return u==="bottom"?(v=i?f:`${h}px`,x=`${-l}px`):u==="top"?(v=i?f:`${h}px`,x=`${r.floating.height+l}px`):u==="right"?(v=`${-l}px`,x=i?f:`${p}px`):u==="left"&&(v=`${r.floating.width+l}px`,x=i?f:`${p}px`),{data:{x:v,y:x}}}});function gu(e){const[t,n="center"]=e.split("-");return[t,n]}var xu=uu,wu=fu,vu=hu,bu=mu,Nv="Portal",Xo=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);St(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Xs.createPortal(c.jsx(Ce.div,{...r,ref:t}),i):null});Xo.displayName=Nv;function Av(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Kt=e=>{const{present:t,children:n}=e,r=jv(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=We(r.ref,_v(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Kt.displayName="Presence";function jv(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Av(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=Jo(r.current);s.current=a==="mounted"?u:"none"},[a]),St(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=Jo(u);e?l("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),St(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const x=Jo(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&x&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=Jo(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function Jo(e){return(e==null?void 0:e.animationName)||"none"}function _v(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 Li="rovingFocusGroup.onEntryFocus",Mv={bubbles:!1,cancelable:!0},Ur="RovingFocusGroup",[$i,yu,Rv]=wi(Ur),[Pv,Su]=wn(Ur,[Rv]),[Ov,Dv]=Pv(Ur),Cu=m.forwardRef((e,t)=>c.jsx($i.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx($i.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Lv,{...e,ref:t})})}));Cu.displayName=Ur;var Lv=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=We(t,h),v=Do(s),[x,g]=ur({prop:i,defaultProp:a??null,onChange:l,caller:Ur}),[w,b]=m.useState(!1),S=Ct(u),T=yu(n),C=m.useRef(!1),[k,E]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(Li,S),()=>A.removeEventListener(Li,S)},[S]),c.jsx(Ov,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:x,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>E(A=>A-1),[]),children:c.jsx(Ce.div,{tabIndex:w||k===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:pe(e.onMouseDown,()=>{C.current=!0}),onFocus:pe(e.onFocus,A=>{const L=!C.current;if(A.target===A.currentTarget&&L&&!w){const B=new CustomEvent(Li,Mv);if(A.currentTarget.dispatchEvent(B),!B.defaultPrevented){const W=T().filter(N=>N.focusable),K=W.find(N=>N.active),H=W.find(N=>N.id===x),G=[K,H,...W].filter(Boolean).map(N=>N.ref.current);Eu(G,d)}}C.current=!1}),onBlur:pe(e.onBlur,()=>b(!1))})})}),ku="RovingFocusGroupItem",Tu=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=At(),u=s||l,d=Dv(ku,n),f=d.currentTabStopId===u,h=yu(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:x}=d;return m.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),c.jsx($i.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(Ce.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:pe(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:pe(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:pe(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const w=Bv(g,d.orientation,d.dir);if(w!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(T=>T.focusable).map(T=>T.ref.current);if(w==="last")S.reverse();else if(w==="prev"||w==="next"){w==="prev"&&S.reverse();const T=S.indexOf(g.currentTarget);S=d.loop?zv(S,T+1):S.slice(T+1)}setTimeout(()=>Eu(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});Tu.displayName=ku;var $v={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Fv(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Bv(e,t,n){const r=Fv(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return $v[r]}function Eu(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function zv(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Hv=Cu,Uv=Tu,Wv=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},mr=new WeakMap,Zo=new WeakMap,Qo={},Fi=0,Iu=function(e){return e&&(e.host||Iu(e.parentNode))},Vv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Iu(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})},Kv=function(e,t,n,r){var o=Vv(t,Array.isArray(e)?e:[e]);Qo[n]||(Qo[n]=new WeakMap);var s=Qo[n],i=[],a=new Set,l=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var p=h.getAttribute(r),v=p!==null&&p!=="false",x=(mr.get(h)||0)+1,g=(s.get(h)||0)+1;mr.set(h,x),s.set(h,g),i.push(h),x===1&&v&&Zo.set(h,!0),g===1&&h.setAttribute(n,"true"),v||h.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",h,w)}})};return d(t),a.clear(),Fi++,function(){i.forEach(function(f){var h=mr.get(f)-1,p=s.get(f)-1;mr.set(f,h),s.set(f,p),h||(Zo.has(f)||f.removeAttribute(r),Zo.delete(f)),p||f.removeAttribute(n)}),Fi--,Fi||(mr=new WeakMap,mr=new WeakMap,Zo=new WeakMap,Qo={})}},Bi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Wv(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Kv(r,o,n,"aria-hidden")):function(){return null}},fn=function(){return fn=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},fn.apply(this,arguments)};function Nu(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 qv(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 es="right-scroll-bar-position",ts="width-before-scroll-bar",Gv="with-scroll-bars-hidden",Yv="--removed-body-scroll-bar-size";function zi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Xv(e,t){var n=y.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 Jv=typeof window<"u"?m.useLayoutEffect:m.useEffect,Au=new WeakMap;function Zv(e,t){var n=Xv(null,function(r){return e.forEach(function(o){return zi(o,r)})});return Jv(function(){var r=Au.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||zi(a,null)}),s.forEach(function(a){o.has(a)||zi(a,i)})}Au.set(n,e)},[e]),n}function Qv(e){return e}function eb(e,t){t===void 0&&(t=Qv);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)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function tb(e){e===void 0&&(e={});var t=eb(null);return t.options=fn({async:!0,ssr:!1},e),t}var ju=function(e){var t=e.sideCar,n=Nu(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 m.createElement(r,fn({},n))};ju.isSideCarExport=!0;function nb(e,t){return e.useMedium(t),ju}var _u=tb(),Hi=function(){},ns=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Hi,onWheelCapture:Hi,onTouchMoveCapture:Hi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,v=e.noIsolation,x=e.inert,g=e.allowPinchZoom,w=e.as,b=w===void 0?"div":w,S=e.gapMode,T=Nu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,k=Zv([n,t]),E=fn(fn({},T),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:_u,removeScrollBar:u,shards:f,noRelative:p,noIsolation:v,inert:x,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?m.cloneElement(m.Children.only(a),fn(fn({},E),{ref:k})):m.createElement(b,fn({},E,{className:l,ref:k}),a))});ns.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ns.classNames={fullWidth:ts,zeroRight:es};var rb=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function ob(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=rb();return t&&e.setAttribute("nonce",t),e}function sb(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function ib(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ab=function(){var e=0,t=null;return{add:function(n){e==0&&(t=ob())&&(sb(t,n),ib(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},lb=function(){var e=ab();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Mu=function(){var e=lb(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},cb={left:0,top:0,right:0,gap:0},Ui=function(e){return parseInt(e||"",10)||0},ub=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[Ui(n),Ui(r),Ui(o)]},db=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return cb;var t=ub(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])}},fb=Mu(),gr="data-scroll-locked",hb=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(Gv,` {
38
+ `))>=0;){const ee=Ze.slice(0,M);Ze=Ze.slice(M+2);const ve=Uv(ee);if(!ve)continue;let ae;try{ae=JSON.parse(ve)}catch{console.debug("[use-chat] malformed SSE:",ve.slice(0,200));continue}const ke=Hv(ae)?ae.data:ae;if(!ke){console.warn("[use-chat] dropped envelope event without payload",ae);continue}const Te=ke;st=Date.now();const it=Te.seq;if(it!==void 0){if(it<=Be){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:it,lastProcessedSeq:Be,type:Te.type});continue}Be>0&&it>Be+1&&((L=N==null?void 0:N.onGap)==null||L.call(N,{from:Be,to:it})),Be=it,C.current=it,x(it)}if(Te.type==="checkpoint")k.current=Te.checkpointId??null,j.current=Te.checkpointNs??null,v(Te.checkpointId??null);else if(Te.type==="state_history"){D.current=Te;try{const mt=Nn(Te).latest;mt&&(k.current=mt.checkpointId??null,j.current=mt.checkpointNs??null,v(mt.checkpointId??null))}catch(Ge){console.warn("[use-chat] Failed to hydrate state_history payload",Ge)}}try{Y==null||Y(Te)}catch(Ge){console.error("[use-chat] Error in onEvent callback:",Ge,"for event:",Te.type)}if(Te.type==="message.delta"){const Ge=Te.delta.filter(mt=>mt.type==="text").map(mt=>mt.text).join("");Ge&&e.autoAppendAssistant!==!1&&(Ae.push(Ge),Et())}else if(Te.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(Z=N==null?void 0:N.onHeartbeat)==null||Z.call(N,Te)}catch(Ge){console.warn("[use-chat] heartbeat callback failed",Ge)}}else if(et!==null&&cancelAnimationFrame(et),ct(),Te.type==="checkpoint")v(Te.checkpointId);else if(Te.type==="error"){const Ge=Te;if(d(Ge.message),R="error",I=Ge.message,Ge.error_type==="auth_error"||Ge.code==="TOKEN_EXPIRED"||((Q=Ge.message)==null?void 0:Q.includes("token"))||((ce=Ge.message)==null?void 0:ce.includes("401"))||((F=Ge.message)==null?void 0:F.includes("unauthorized"))||((oe=Ge.message)==null?void 0:oe.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Ge.message);try{(we=N==null?void 0:N.onAuthError)==null||we.call(N,Ge.message)}catch(Ut){console.warn("[use-chat] onAuthError handler failed",Ut)}$.abort()}}}}ct(),R===null&&!$.signal.aborted&&(R="complete")}catch(De){if(De.name==="AbortError")R=R??"aborted";else{const Ke=De.message||String(De);R="error",I=Ke,d(Ke),(fe=N==null?void 0:N.onError)==null||fe.call(N,Ke)}}finally{try{await ot.cancel()}catch{}finally{(xe=ot.releaseLock)==null||xe.call(ot)}et!==null&&typeof window<"u"&&window.cancelAnimationFrame(et),clearInterval(Ve)}}catch(Ne){if(Ne.name==="AbortError")R=R??"aborted";else{const Oe=Ne.message||String(Ne);R="error",I=Oe,d(Oe),(_e=N==null?void 0:N.onError)==null||_e.call(N,Oe),H||(($e=N==null?void 0:N.onConnectionError)==null||$e.call(N,Oe),H=!0)}}finally{const Ne=C.current,Oe=k.current,Ye=j.current,We=D.current,Je=R??($.signal.aborted?"aborted":I?"error":"complete");try{(Ue=N==null?void 0:N.onClosed)==null||Ue.call(N,{reason:Je,lastSeq:Ne,lastCheckpointId:Oe,lastCheckpointNs:Ye,lastStateHistory:We,error:I})}catch(ot){console.warn("[use-chat] onClosed callback failed",ot)}l(!1),b(!1),S.current=null,C.current=0,x(0),T.current=null}})(),{close:()=>$.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var _;E.current=!1,(_=S.current)==null||_.abort()},[]),{isStreaming:a,error:c,assistantText:p,lastCheckpointId:f,lastSeq:g,connected:y,stream:z,stop:K,clear:W,setToken:B}}function Hv(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Uv(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
39
+ `)}function Wv(e){if(!e||typeof e!="object")return!1;const t=e.type;return t==="message.start"||t==="message.delta"||t==="message.end"||t==="tool.start"||t==="tool.end"||t==="tool.progress"||t==="tool.call"||t==="thread_info"||t==="checkpoint"||t==="error"||t==="interrupt"||t==="heartbeat"||t==="cancelled"||t==="state_history"}const fu=200;function Vv({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onStateHistory:r,onUnhandledEvent:o,onSequenceGap:s,onStreamClosed:i,onConnectionError:a,onAuthError:l,onHeartbeat:c,onToolEvent:d}){const p=w.useRef(null),m=w.useRef(null),f=w.useRef(new Map),v=w.useRef(null),g=w.useRef(null),x=w.useCallback(N=>{try{const $=globalThis.structuredClone;if(typeof $=="function")return $(N)}catch{}try{return JSON.parse(JSON.stringify(N))}catch{return N}},[]),y=w.useCallback((N,$)=>{if(!N)return;const R=f.current.get(N)??[],I=x($),H=R.length>=fu?[...R.slice(R.length-fu+1),I]:[...R,I];f.current.set(N,H)},[x]),b=w.useCallback(N=>{N&&f.current.set(N,[])},[]),S=w.useCallback(N=>{const $=N??m.current;if(!$)return;const R=f.current.get($);R!=null&&R.length&&R.forEach(I=>{try{n(I)}catch(H){console.error("[useChatStreamingService] Failed to replay buffered event",H)}})},[n]),E=w.useCallback(N=>{m.current=N.threadId,v.current&&(v.current.threadIdGuess=N.threadId),g.current=N,b(N.threadId),console.log("[useChatStreamingService] 🎯 Received thread_info event:",N);try{t(N)}catch($){console.error("[useChatStreamingService] Error in onThreadInfo handler:",$)}},[b,t]),C=w.useCallback(N=>{try{c==null||c(N)}catch($){console.error("[useChatStreamingService] Error in onHeartbeat handler:",$)}},[c]),T=w.useCallback(N=>{var I,H,q,P;const $=N;if($.error_type==="auth_error"||$.code==="TOKEN_EXPIRED"||((I=$.message)==null?void 0:I.includes("token"))||((H=$.message)==null?void 0:H.includes("401"))||((q=$.message)==null?void 0:q.includes("unauthorized"))||((P=$.message)==null?void 0:P.includes("Unauthorized"))){console.error("[useChatStreamingService] Auth error event detected:",$.message);try{l==null||l($.message)}catch(O){console.warn("[useChatStreamingService] onAuthError handler failed",O)}}},[l]),k=w.useMemo(()=>({thread_info:N=>(E(N),!0),heartbeat:N=>(C(N),!0),error:N=>(T(N),!1)}),[E,C,T]),j=w.useCallback(N=>{var H;const $=N.seq??null;if($!==null){const q=p.current;if(q!==null){if($<=q)return;$>q+1&&(s==null||s({from:q,to:$}))}p.current=$}const R=k[N.type];if(R&&R(N))return;const I=N.threadId??(N.type==="state_history"?N.threadId:void 0)??m.current??((H=v.current)==null?void 0:H.threadIdGuess)??null;if(N.type==="state_history"){m.current=I??m.current;try{r==null||r(N)}catch(q){console.error("[useChatStreamingService] onStateHistory handler failed",q)}}if(Wv(N)){(N.type==="tool.start"||N.type==="tool.end")&&(d==null||d(N)),N.type==="checkpoint"||N.type==="state_history"?b(I??null):y(I??null,N);try{n(N)}catch(q){console.error("[useChatStreamingService] Error in onMessageEvent handler:",q)}return}try{o==null||o(N)}catch(q){console.error("[useChatStreamingService] Error in onUnhandledEvent handler:",q)}},[y,b,n,s,r,o,k]),{stream:D,stop:B,isStreaming:W,error:K,setToken:z}=du({baseUrl:e,token:void 0}),_=w.useCallback((N,$)=>{p.current=null,g.current=null,m.current=N.threadId??null,v.current={request:N,callbacks:$,manualStop:!1,threadIdGuess:N.threadId??null},D(N,j,{onOpen:$==null?void 0:$.onOpen,onError:R=>{var I;(I=$==null?void 0:$.onError)==null||I.call($,R)},onGap:($==null?void 0:$.onGap)??s,onConnectionError:R=>{var I;a==null||a(R),(I=$==null?void 0:$.onConnectionError)==null||I.call($,R)},onAuthError:R=>{var I;l==null||l(R),(I=$==null?void 0:$.onAuthError)==null||I.call($,R)},onHeartbeat:R=>{var I;try{c==null||c(R)}catch(H){console.warn("[useChatStreamingService] onHeartbeat handler failed",H)}try{(I=$==null?void 0:$.onHeartbeat)==null||I.call($,R)}catch(H){console.warn("[useChatStreamingService] downstream onHeartbeat handler failed",H)}},onClosed:R=>{var P,O,X,J;const I=((P=v.current)==null?void 0:P.manualStop)??!1,H=m.current??((O=v.current)==null?void 0:O.threadIdGuess)??((X=R.lastStateHistory)==null?void 0:X.threadId)??null;(R.reason==="complete"||R.reason==="aborted"&&I)&&b(H);const q={...R,threadId:H,threadInfo:g.current,manualStop:I};try{i==null||i(q)}catch(se){console.warn("[useChatStreamingService] onStreamClosed handler failed",se)}try{(J=$==null?void 0:$.onClosed)==null||J.call($,q)}catch(se){console.warn("[useChatStreamingService] downstream onClosed handler failed",se)}v.current&&(v.current=null)}})},[b,j,l,a,c,s,i,D]),Y=w.useCallback(()=>{v.current&&(v.current.manualStop=!0),B()},[B]);return w.useMemo(()=>({startStream:_,stop:Y,isStreaming:W,error:K,setAuthToken:z,replayBufferedEvents:S}),[_,Y,W,K,z,S])}const pu=w.createContext(null),hu=w.createContext(null),mu=w.createContext(null),Kv=w.createContext(!1);function qv({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}=Ii(),m=w.useMemo(()=>mn(p),[p]),{state:f,seed:v,prepend:g,pushUser:x,onEvent:y}=Lv(),{threads:b,currentThreadId:S,setCurrentThreadId:E,currentThreadIdRef:C,isLoadingThreads:T,threadsError:k,sharedThreads:j,isLoadingSharedThreads:D,actions:B,addThreadFromEvent:W,shareInFlight:K,shareStatus:z,clearShareStatus:_}=tu({api:d,initialThreadId:t,onError:s,onThreadChange:a,onCurrentThreadDeleted:()=>v([],{})}),[Y,N]=w.useState(!1),$=w.useCallback(()=>f.messages,[f.messages]),{threadCheckpoints:R,threadTimeline:I,checkpointIndex:H,isLoadingThread:q,isHistoryLoading:P,isLoadingCheckpoint:O,threadStateError:X,hasMoreHistory:J,loadThread:se,navigateToCheckpoint:V,loadOlderMessages:L,setCurrentCheckpointId:Z,returnToLatest:Q,handleStateHistoryEvent:ce,markSkipNextLoad:F,markStreamPendingThread:oe,resetHistoryState:we}=eu({api:d,seed:v,prepend:g,onError:s,currentThreadId:S,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:Y,getMessages:$}),fe=w.useCallback(Ae=>{console.log("[StreamingProvider] 🎯 Received thread_info:",Ae.threadId),W(Ae),C.current!==Ae.threadId&&((Ae.created??!C.current)&&F(Ae.threadId),oe(Ae.threadId),console.log("[StreamingProvider] thread_info: marking to skip auto-load for new thread"),E(Ae.threadId))},[W,F,oe]),{startStream:xe,stop:_e,isStreaming:$e,error:Ue,setAuthToken:Ne}=Vv({baseUrl:m,onThreadInfo:fe,onMessageEvent:y,onStateHistory:ce,onUnhandledEvent:Ae=>{console.warn("[StreamingProvider] Unhandled event:",Ae.type)},onAuthError:i,onConnectionError:l,onToolEvent:Ae=>{Ae.type==="tool.end"&&(c==null||c(Ae))}});w.useEffect(()=>{N($e)},[$e]);const Oe=w.useCallback(async()=>{v([],{}),E(null),_e(),we();try{await d.getAgent("default")}catch(Ae){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",Ae)}},[v,_e,d,we]),Ye=w.useCallback(async(Ae,Be,et)=>{const ct=C.current;if(!ct)throw new Error("No active thread to handle interrupt");const Et=Be?et??!0:!1;try{const st={threadId:ct,checkpointId:f.lastCheckpointId??void 0,checkpointNs:f.lastCheckpointNs??void 0,command:{kind:"resume",value:Et}};xe(st)}catch(st){throw console.error(`[StreamingProvider] Failed to handle interrupt ${Ae}:`,st),st}},[f.lastCheckpointId,f.lastCheckpointNs,xe]),We=w.useCallback(async(Ae,Be)=>{let et=C.current;const ct=(Ae==null?void 0:Ae.text)??"",Et=(Ae==null?void 0:Ae.attachments)??[],st=(ct==null?void 0:ct.trim())??"",Ve={...(Ae==null?void 0:Ae.payload)??{}},It=Array.isArray(Ve.messages)?Ve.messages:void 0;It&&delete Ve.messages;const De=!!(It&&It.length);if(!et&&!st&&Et.length===0&&!De)return;if(!et){const Te=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),it=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);et=`${Te}${it}`,F(et),E(et)}const{contentParts:Ke,filesInfo:yt}=await Qc(Et),ht=[...Ke];st&&ht.push({type:"text",text:ct});const qe=Be==null?void 0:Be.originalMessageId,gt=!!(Be!=null&&Be.edit&&qe),M=!De&&ht.length>0;let ee=null;M&&(ee={id:gt?qe:`msg-${Date.now()}`,role:"user",content:ht,createdAt:new Date().toISOString()},gt?x(ee,qe):x(ee));const ve=De?It:ee?[ee]:[],ae={...Ve,...yt.length?{files_info:yt}:{}};ve.length?ae.messages=ve:"messages"in ae||(ae.messages=[]);const ke={threadId:et,payload:ae,checkpointId:(Be==null?void 0:Be.checkpointId)??f.lastCheckpointId??void 0,checkpointNs:(Be==null?void 0:Be.checkpointNs)??f.lastCheckpointNs??void 0,edit:!!(Be!=null&&Be.edit),timelineCheckpoints:I};xe(ke)},[d,x,f,xe,I]),Je=w.useMemo(()=>({threads:b,currentThreadId:S,setCurrentThreadId:E,isLoading:T,error:k,sharedThreads:j,isLoadingSharedThreads:D,actions:B,shareInFlight:K,shareStatus:z,clearShareStatus:_}),[b,S,E,T,k,j,D,B,K,z,_]),ot=w.useMemo(()=>{const Ae=f.assemblingId??null;return Ae?{assemblingMessageId:Ae}:null},[f.assemblingId]),nt=w.useMemo(()=>({threadId:S,messages:f.messages,interrupt:null,checkpoint:{id:f.lastCheckpointId??null,namespace:f.lastCheckpointNs??null},checkpoints:R,checkpointIndex:H,timelineCheckpoints:I,metadata:ot,isLoading:q,isHistoryLoading:P,isLoadingCheckpoint:O,error:X,hasMore:J,loadOlder:L,clearState:Oe,navigateToCheckpoint:V,setCurrentCheckpointId:Z,returnToLatest:Q,loadThread:se,clearThread:Oe,respondToInterrupt:Ye,messagePreviews:H.messagePreviews}),[S,f,R,I,H,q,P,O,X,J,L,Oe,V,Z,Q,se,Ye,ot]),Ze=w.useMemo(()=>({isStreaming:$e,error:Ue,connectionState:$e?"connected":"idle",submit:We,send:We,stop:_e,setAuthToken:Ne}),[$e,Ue,We,_e,Ne]);return u.jsx(pu.Provider,{value:Je,children:u.jsx(hu.Provider,{value:nt,children:u.jsx(mu.Provider,{value:Ze,children:e})})})}function Gv(){return w.useContext(Kv)}function Uo(){const e=w.useContext(pu);if(!e)throw new Error("useThreads must be used within StreamingProvider");return e}function Wo(){const e=w.useContext(hu);if(!e)throw new Error("useThreadState must be used within StreamingProvider");return e}function gu(){const e=w.useContext(mu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function qr({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}){return u.jsx(vv,{apiConfig:t,children:u.jsx(qv,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:a,onAuthError:l,onConnectionError:i,onThreadChange:c,onToolEnd:d,children:e})})}function hr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function Yv(e){if(typeof e!="string")return;const t=e.trim();if(t)return mn(t)}function xu(){const e=[hr("__API_BASE_URL__"),hr("__CHAT_API_BASE_URL__"),hr("__CHAT_API_URL__")];for(const t of e){const n=Yv(t);if(n)return n}}function vu(){const e=[hr("__API_AUTH_TOKEN__"),hr("__CHAT_API_KEY__"),hr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function wu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return mn(t);return mn()}function bu(){const e={},t=xu(),n=vu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function yu(){const e=bu(),t=An.getAuthToken(),n=xu();return{apiBaseUrl:wu(e.baseUrl,An.baseUrl,n),apiKey:t||e.apiKey||vu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Mi="chat-settings";function Su(){try{const e=localStorage.getItem(Mi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Cu(e){try{const t={...e,apiBaseUrl:mn(e.apiBaseUrl)};localStorage.setItem(Mi,JSON.stringify(t)),t.apiKey&&An.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Xv(){const e=yu(),t=Su(),n=An.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:wu(An.baseUrl,r,e.apiBaseUrl)}}function Jv(e){An.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Cu(e)}function re(...e){return Dg.twMerge(Og.clsx(e))}const Zv=Or.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"}}),ut=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Vt.Slot:"button";return u.jsx(i,{className:re(Zv({variant:t,size:n,className:e})),ref:s,...o})});ut.displayName="Button";var Tu=1,Qv=.9,ew=.8,tw=.17,Ri=.1,Oi=.999,nw=.9999,rw=.99,ow=/[\\\/_+.#"@\[\(\{&]/,sw=/[\\\/_+.#"@\[\(\{&]/g,iw=/[\s-]/,Eu=/[\s-]/g;function Di(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Tu:rw;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=Di(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=Tu:ow.test(e.charAt(c-1))?(p*=ew,f=e.slice(o,c-1).match(sw),f&&o>0&&(p*=Math.pow(Oi,f.length))):iw.test(e.charAt(c-1))?(p*=Qv,v=e.slice(o,c-1).match(Eu),v&&o>0&&(p*=Math.pow(Oi,v.length))):(p*=tw,o>0&&(p*=Math.pow(Oi,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=nw)),(p<Ri&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=Di(e,t,n,r,c+1,s+2,i),m*Ri>p&&(p=m*Ri)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function ku(e){return e.toLowerCase().replace(Eu," ")}function aw(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Di(e,t,ku(e),ku(t),0,0,{})}function le(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 Iu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function _n(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Iu(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():Iu(e[o],null)}}}}function ze(...e){return h.useCallback(_n(...e),e)}function lw(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 sn(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,cw(o,...t)]}function cw(...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 kt=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},uw=h[" useId ".trim().toString()]||(()=>{}),dw=0;function At(e){const[t,n]=h.useState(uw());return kt(()=>{n(r=>r??String(dw++))},[e]),t?`radix-${t}`:""}var fw=h[" useInsertionEffect ".trim().toString()]||kt;function jn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=pw({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=hw(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 pw({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return fw(()=>{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 hw(e){return typeof e=="function"}var mw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ye=mw.reduce((e,t)=>{const n=Vt.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 Li(e,t){e&&Dr.flushSync(()=>e.dispatchEvent(t))}function vt(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 gw(e,t=globalThis==null?void 0:globalThis.document){const n=vt(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 xw="DismissableLayer",$i="dismissableLayer.update",vw="dismissableLayer.pointerDownOutside",ww="dismissableLayer.focusOutside",Nu,Au=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),mr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Au),[d,p]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=h.useState({}),v=ze(t,k=>p(k)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,E=b>=y,C=yw(k=>{const j=k.target,D=[...c.branches].some(B=>B.contains(j));!E||D||(o==null||o(k),i==null||i(k),k.defaultPrevented||a==null||a())},m),T=Sw(k=>{const j=k.target;[...c.branches].some(B=>B.contains(j))||(s==null||s(k),i==null||i(k),k.defaultPrevented||a==null||a())},m);return gw(k=>{b===c.layers.size-1&&(r==null||r(k),!k.defaultPrevented&&a&&(k.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Nu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),ju(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Nu)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),ju())},[d,c]),h.useEffect(()=>{const k=()=>f({});return document.addEventListener($i,k),()=>document.removeEventListener($i,k)},[]),u.jsx(ye.div,{...l,ref:v,style:{pointerEvents:S?E?"auto":"none":void 0,...e.style},onFocusCapture:le(e.onFocusCapture,T.onFocusCapture),onBlurCapture:le(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:le(e.onPointerDownCapture,C.onPointerDownCapture)})});mr.displayName=xw;var bw="DismissableLayerBranch",_u=h.forwardRef((e,t)=>{const n=h.useContext(Au),r=h.useRef(null),o=ze(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(ye.div,{...e,ref:o})});_u.displayName=bw;function yw(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Pu(vw,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 Sw(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&Pu(ww,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 ju(){const e=new CustomEvent($i);document.dispatchEvent(e)}function Pu(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?Li(o,s):o.dispatchEvent(s)}var Cw=mr,Tw=_u,Fi="focusScope.autoFocusOnMount",Bi="focusScope.autoFocusOnUnmount",Mu={bubbles:!1,cancelable:!0},Ew="FocusScope",Vo=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=vt(o),d=vt(s),p=h.useRef(null),m=ze(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(S){if(f.paused||!a)return;const E=S.target;a.contains(E)?p.current=E:Pn(p.current,{select:!0})},x=function(S){if(f.paused||!a)return;const E=S.relatedTarget;E!==null&&(a.contains(E)||Pn(p.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Pn(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){Du.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Fi,Mu);a.addEventListener(Fi,c),a.dispatchEvent(y),y.defaultPrevented||(kw(jw(Ru(a)),{select:!0}),document.activeElement===g&&Pn(a))}return()=>{a.removeEventListener(Fi,c),setTimeout(()=>{const y=new CustomEvent(Bi,Mu);a.addEventListener(Bi,d),a.dispatchEvent(y),y.defaultPrevented||Pn(g??document.body,{select:!0}),a.removeEventListener(Bi,d),Du.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,[S,E]=Iw(b);S&&E?!g.shiftKey&&y===E?(g.preventDefault(),n&&Pn(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&Pn(E,{select:!0})):y===b&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(ye.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Vo.displayName=Ew;function kw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Pn(r,{select:t}),document.activeElement!==n)return}function Iw(e){const t=Ru(e),n=Ou(t,e),r=Ou(t.reverse(),e);return[n,r]}function Ru(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 Ou(e,t){for(const n of e)if(!Nw(n,{upTo:t}))return n}function Nw(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 Aw(e){return e instanceof HTMLInputElement&&"select"in e}function Pn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Aw(e)&&t&&e.select()}}var Du=_w();function _w(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Lu(e,t),e.unshift(t)},remove(t){var n;e=Lu(e,t),(n=e[0])==null||n.resume()}}}function Lu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function jw(e){return e.filter(t=>t.tagName!=="A")}var Pw="Portal",Gr=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);kt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Eo.createPortal(u.jsx(ye.div,{...r,ref:t}),i):null});Gr.displayName=Pw;function Mw(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ft=e=>{const{present:t,children:n}=e,r=Rw(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=ze(r.ref,Ow(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Ft.displayName="Presence";function Rw(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Mw(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=Ko(r.current);s.current=a==="mounted"?c:"none"},[a]),kt(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=Ko(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]),kt(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,p=f=>{const g=Ko(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=Ko(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 Ko(e){return(e==null?void 0:e.animationName)||"none"}function Ow(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 zi=0;function Hi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??$u()),document.body.insertAdjacentElement("beforeend",e[1]??$u()),zi++,()=>{zi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),zi--}},[])}function $u(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var gn=function(){return gn=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},gn.apply(this,arguments)};function Fu(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 Dw(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 qo="right-scroll-bar-position",Go="width-before-scroll-bar",Lw="with-scroll-bars-hidden",$w="--removed-body-scroll-bar-size";function Ui(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Fw(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 Bw=typeof window<"u"?h.useLayoutEffect:h.useEffect,Bu=new WeakMap;function zw(e,t){var n=Fw(null,function(r){return e.forEach(function(o){return Ui(o,r)})});return Bw(function(){var r=Bu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Ui(a,null)}),s.forEach(function(a){o.has(a)||Ui(a,i)})}Bu.set(n,e)},[e]),n}function Hw(e){return e}function Uw(e,t){t===void 0&&(t=Hw);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 Ww(e){e===void 0&&(e={});var t=Uw(null);return t.options=gn({async:!0,ssr:!1},e),t}var zu=function(e){var t=e.sideCar,n=Fu(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,gn({},n))};zu.isSideCarExport=!0;function Vw(e,t){return e.useMedium(t),zu}var Hu=Ww(),Wi=function(){},Yo=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:Wi,onWheelCapture:Wi,onTouchMoveCapture:Wi}),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,S=e.gapMode,E=Fu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=zw([n,t]),k=gn(gn({},E),o);return h.createElement(h.Fragment,null,d&&h.createElement(C,{sideCar:Hu,removeScrollBar:c,shards:p,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?h.cloneElement(h.Children.only(a),gn(gn({},k),{ref:T})):h.createElement(b,gn({},k,{className:l,ref:T}),a))});Yo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Yo.classNames={fullWidth:Go,zeroRight:qo};var Kw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function qw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Kw();return t&&e.setAttribute("nonce",t),e}function Gw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Yw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Xw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=qw())&&(Gw(t,n),Yw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Jw=function(){var e=Xw();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Uu=function(){var e=Jw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Zw={left:0,top:0,right:0,gap:0},Vi=function(e){return parseInt(e||"",10)||0},Qw=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[Vi(n),Vi(r),Vi(o)]},eb=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Zw;var t=Qw(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])}},tb=Uu(),gr="data-scroll-locked",nb=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(Lw,` {
41
41
  overflow: hidden `).concat(r,`;
42
42
  padding-right: `).concat(a,"px ").concat(r,`;
43
43
  }
@@ -54,58 +54,58 @@ React keys must be passed directly to JSX without using spread:
54
54
  `),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
55
55
  }
56
56
 
57
- .`).concat(es,` {
57
+ .`).concat(qo,` {
58
58
  right: `).concat(a,"px ").concat(r,`;
59
59
  }
60
60
 
61
- .`).concat(ts,` {
61
+ .`).concat(Go,` {
62
62
  margin-right: `).concat(a,"px ").concat(r,`;
63
63
  }
64
64
 
65
- .`).concat(es," .").concat(es,` {
65
+ .`).concat(qo," .").concat(qo,` {
66
66
  right: 0 `).concat(r,`;
67
67
  }
68
68
 
69
- .`).concat(ts," .").concat(ts,` {
69
+ .`).concat(Go," .").concat(Go,` {
70
70
  margin-right: 0 `).concat(r,`;
71
71
  }
72
72
 
73
73
  body[`).concat(gr,`] {
74
- `).concat(Yv,": ").concat(a,`px;
74
+ `).concat($w,": ").concat(a,`px;
75
75
  }
76
- `)},Ru=function(){var e=parseInt(document.body.getAttribute(gr)||"0",10);return isFinite(e)?e:0},pb=function(){m.useEffect(function(){return document.body.setAttribute(gr,(Ru()+1).toString()),function(){var e=Ru()-1;e<=0?document.body.removeAttribute(gr):document.body.setAttribute(gr,e.toString())}},[])},mb=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;pb();var s=m.useMemo(function(){return db(o)},[o]);return m.createElement(fb,{styles:hb(s,!t,o,n?"":"!important")})},Wi=!1;if(typeof window<"u")try{var rs=Object.defineProperty({},"passive",{get:function(){return Wi=!0,!0}});window.addEventListener("test",rs,rs),window.removeEventListener("test",rs,rs)}catch{Wi=!1}var xr=Wi?{passive:!1}:!1,gb=function(e){return e.tagName==="TEXTAREA"},Pu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!gb(e)&&n[t]==="visible")},xb=function(e){return Pu(e,"overflowY")},wb=function(e){return Pu(e,"overflowX")},Ou=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Du(e,r);if(o){var s=Lu(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},vb=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},bb=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Du=function(e,t){return e==="v"?xb(t):wb(t)},Lu=function(e,t){return e==="v"?vb(t):bb(t)},yb=function(e,t){return e==="h"&&t==="rtl"?-1:1},Sb=function(e,t,n,r,o){var s=yb(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var p=Lu(e,a),v=p[0],x=p[1],g=p[2],w=x-g-s*v;(v||w)&&Du(e,a)&&(f+=w,h+=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(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},os=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},$u=function(e){return[e.deltaX,e.deltaY]},Fu=function(e){return e&&"current"in e?e.current:e},Cb=function(e,t){return e[0]===t[0]&&e[1]===t[1]},kb=function(e){return`
76
+ `)},Wu=function(){var e=parseInt(document.body.getAttribute(gr)||"0",10);return isFinite(e)?e:0},rb=function(){h.useEffect(function(){return document.body.setAttribute(gr,(Wu()+1).toString()),function(){var e=Wu()-1;e<=0?document.body.removeAttribute(gr):document.body.setAttribute(gr,e.toString())}},[])},ob=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;rb();var s=h.useMemo(function(){return eb(o)},[o]);return h.createElement(tb,{styles:nb(s,!t,o,n?"":"!important")})},Ki=!1;if(typeof window<"u")try{var Xo=Object.defineProperty({},"passive",{get:function(){return Ki=!0,!0}});window.addEventListener("test",Xo,Xo),window.removeEventListener("test",Xo,Xo)}catch{Ki=!1}var xr=Ki?{passive:!1}:!1,sb=function(e){return e.tagName==="TEXTAREA"},Vu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!sb(e)&&n[t]==="visible")},ib=function(e){return Vu(e,"overflowY")},ab=function(e){return Vu(e,"overflowX")},Ku=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=qu(e,r);if(o){var s=Gu(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},lb=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},cb=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},qu=function(e,t){return e==="v"?ib(t):ab(t)},Gu=function(e,t){return e==="v"?lb(t):cb(t)},ub=function(e,t){return e==="h"&&t==="rtl"?-1:1},db=function(e,t,n,r,o){var s=ub(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=Gu(e,a),v=f[0],g=f[1],x=f[2],y=g-x-s*v;(v||y)&&qu(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},Jo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Yu=function(e){return[e.deltaX,e.deltaY]},Xu=function(e){return e&&"current"in e?e.current:e},fb=function(e,t){return e[0]===t[0]&&e[1]===t[1]},pb=function(e){return`
77
77
  .block-interactivity-`.concat(e,` {pointer-events: none;}
78
78
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
79
- `)},Tb=0,wr=[];function Eb(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Tb++)[0],s=m.useState(Mu)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=qv([e.lockRef.current],(e.shards||[]).map(Fu),!0).filter(Boolean);return x.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(x,g){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var w=os(x),b=n.current,S="deltaX"in x?x.deltaX:b[0]-w[0],T="deltaY"in x?x.deltaY:b[1]-w[1],C,k=x.target,E=Math.abs(S)>Math.abs(T)?"h":"v";if("touches"in x&&E==="h"&&k.type==="range")return!1;var A=Ou(E,k);if(!A)return!0;if(A?C=E:(C=E==="v"?"h":"v",A=Ou(E,k)),!A)return!1;if(!r.current&&"changedTouches"in x&&(S||T)&&(r.current=C),!C)return!0;var L=r.current||C;return Sb(L,g,x,L==="h"?S:T)},[]),l=m.useCallback(function(x){var g=x;if(!(!wr.length||wr[wr.length-1]!==s)){var w="deltaY"in g?$u(g):os(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&Cb(C.delta,w)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Fu).filter(Boolean).filter(function(C){return C.contains(g.target)}),T=S.length>0?a(g,S[0]):!i.current.noIsolation;T&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(x,g,w,b){var S={name:x,delta:g,target:w,should:b,shadowParent:Ib(w)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(T){return T!==S})},1)},[]),d=m.useCallback(function(x){n.current=os(x),r.current=void 0},[]),f=m.useCallback(function(x){u(x.type,$u(x),x.target,a(x,e.lockRef.current))},[]),h=m.useCallback(function(x){u(x.type,os(x),x.target,a(x,e.lockRef.current))},[]);m.useEffect(function(){return wr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,xr),document.addEventListener("touchmove",l,xr),document.addEventListener("touchstart",d,xr),function(){wr=wr.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,xr),document.removeEventListener("touchmove",l,xr),document.removeEventListener("touchstart",d,xr)}},[]);var p=e.removeScrollBar,v=e.inert;return m.createElement(m.Fragment,null,v?m.createElement(s,{styles:kb(o)}):null,p?m.createElement(mb,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Ib(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Nb=nb(_u,Eb);var ss=m.forwardRef(function(e,t){return m.createElement(ns,fn({},e,{ref:t,sideCar:Nb}))});ss.classNames=ns.classNames;var Vi=["Enter"," "],Ab=["ArrowDown","PageUp","Home"],Bu=["ArrowUp","PageDown","End"],jb=[...Ab,...Bu],_b={ltr:[...Vi,"ArrowRight"],rtl:[...Vi,"ArrowLeft"]},Mb={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Wr="Menu",[Vr,Rb,Pb]=wi(Wr),[Un,zu]=wn(Wr,[Pb,Yo,Su]),is=Yo(),Hu=Su(),[Ob,Wn]=Un(Wr),[Db,Kr]=Un(Wr),Uu=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=is(t),[l,u]=m.useState(null),d=m.useRef(!1),f=Ct(s),h=Do(o);return m.useEffect(()=>{const p=()=>{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",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),c.jsx(xu,{...a,children:c.jsx(Ob,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(Db,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Uu.displayName=Wr;var Lb="MenuAnchor",Ki=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=is(n);return c.jsx(wu,{...o,...r,ref:t})});Ki.displayName=Lb;var qi="MenuPortal",[$b,Wu]=Un(qi,{forceMount:void 0}),Vu=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Wn(qi,t);return c.jsx($b,{scope:t,forceMount:n,children:c.jsx(Kt,{present:n||s.open,children:c.jsx(Xo,{asChild:!0,container:o,children:r})})})};Vu.displayName=qi;var qt="MenuContent",[Fb,Gi]=Un(qt),Ku=m.forwardRef((e,t)=>{const n=Wu(qt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Wn(qt,e.__scopeMenu),i=Kr(qt,e.__scopeMenu);return c.jsx(Vr.Provider,{scope:e.__scopeMenu,children:c.jsx(Kt,{present:r||s.open,children:c.jsx(Vr.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(Bb,{...o,ref:t}):c.jsx(zb,{...o,ref:t})})})})}),Bb=m.forwardRef((e,t)=>{const n=Wn(qt,e.__scopeMenu),r=m.useRef(null),o=We(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Bi(s)},[]),c.jsx(Yi,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),zb=m.forwardRef((e,t)=>{const n=Wn(qt,e.__scopeMenu);return c.jsx(Yi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Hb=Ln.createSlot("MenuContent.ScrollLock"),Yi=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:v,...x}=e,g=Wn(qt,n),w=Kr(qt,n),b=is(n),S=Hu(n),T=Rb(n),[C,k]=m.useState(null),E=m.useRef(null),A=We(t,E,g.onContentChange),L=m.useRef(0),B=m.useRef(""),W=m.useRef(0),K=m.useRef(null),H=m.useRef("right"),R=m.useRef(0),G=v?ss:m.Fragment,N=v?{as:Hb,allowPinchZoom:!0}:void 0,$=j=>{var q,O;const U=B.current+j,V=T().filter(Y=>!Y.disabled),M=document.activeElement,F=(q=V.find(Y=>Y.ref.current===M))==null?void 0:q.textValue,ee=V.map(Y=>Y.textValue),J=ey(ee,U,F),ie=(O=V.find(Y=>Y.textValue===J))==null?void 0:O.ref.current;(function Y(X){B.current=X,window.clearTimeout(L.current),X!==""&&(L.current=window.setTimeout(()=>Y(""),1e3))})(U),ie&&setTimeout(()=>ie.focus())};m.useEffect(()=>()=>window.clearTimeout(L.current),[]),yi();const P=m.useCallback(j=>{var V,M;return H.current===((V=K.current)==null?void 0:V.side)&&ny(j,(M=K.current)==null?void 0:M.area)},[]);return c.jsx(Fb,{scope:n,searchRef:B,onItemEnter:m.useCallback(j=>{P(j)&&j.preventDefault()},[P]),onItemLeave:m.useCallback(j=>{var U;P(j)||((U=E.current)==null||U.focus(),k(null))},[P]),onTriggerLeave:m.useCallback(j=>{P(j)&&j.preventDefault()},[P]),pointerGraceTimerRef:W,onPointerGraceIntentChange:m.useCallback(j=>{K.current=j},[]),children:c.jsx(G,{...N,children:c.jsx($o,{asChild:!0,trapped:o,onMountAutoFocus:pe(s,j=>{var U;j.preventDefault(),(U=E.current)==null||U.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(Lo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(Hv,{asChild:!0,...S,dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:pe(l,j=>{w.isUsingKeyboardRef.current||j.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(vu,{role:"menu","aria-orientation":"vertical","data-state":cd(g.open),"data-radix-menu-content":"",dir:w.dir,...b,...x,ref:A,style:{outline:"none",...x.style},onKeyDown:pe(x.onKeyDown,j=>{const V=j.target.closest("[data-radix-menu-content]")===j.currentTarget,M=j.ctrlKey||j.altKey||j.metaKey,F=j.key.length===1;V&&(j.key==="Tab"&&j.preventDefault(),!M&&F&&$(j.key));const ee=E.current;if(j.target!==ee||!jb.includes(j.key))return;j.preventDefault();const ie=T().filter(q=>!q.disabled).map(q=>q.ref.current);Bu.includes(j.key)&&ie.reverse(),Zb(ie)}),onBlur:pe(e.onBlur,j=>{j.currentTarget.contains(j.target)||(window.clearTimeout(L.current),B.current="")}),onPointerMove:pe(e.onPointerMove,Gr(j=>{const U=j.target,V=R.current!==j.clientX;if(j.currentTarget.contains(U)&&V){const M=j.clientX>R.current?"right":"left";H.current=M,R.current=j.clientX}}))})})})})})})});Ku.displayName=qt;var Ub="MenuGroup",Xi=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ce.div,{role:"group",...r,ref:t})});Xi.displayName=Ub;var Wb="MenuLabel",qu=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ce.div,{...r,ref:t})});qu.displayName=Wb;var as="MenuItem",Gu="menu.itemSelect",ls=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=Kr(as,e.__scopeMenu),a=Gi(as,e.__scopeMenu),l=We(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(Gu,{bubbles:!0,cancelable:!0});f.addEventListener(Gu,p=>r==null?void 0:r(p),{once:!0}),Ic(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(Yu,{...o,ref:l,disabled:n,onClick:pe(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:pe(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:pe(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||Vi.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});ls.displayName=as;var Yu=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Gi(as,n),a=Hu(n),l=m.useRef(null),u=We(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[s.children]),c.jsx(Vr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(Uv,{asChild:!0,...a,focusable:!r,children:c.jsx(Ce.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:pe(e.onPointerMove,Gr(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:pe(e.onPointerLeave,Gr(v=>i.onItemLeave(v))),onFocus:pe(e.onFocus,()=>f(!0)),onBlur:pe(e.onBlur,()=>f(!1))})})})}),Vb="MenuCheckboxItem",Xu=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(td,{scope:e.__scopeMenu,checked:n,children:c.jsx(ls,{role:"menuitemcheckbox","aria-checked":cs(n)?"mixed":n,...o,ref:t,"data-state":Zi(n),onSelect:pe(o.onSelect,()=>r==null?void 0:r(cs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Xu.displayName=Vb;var Ju="MenuRadioGroup",[Kb,qb]=Un(Ju,{value:void 0,onValueChange:()=>{}}),Zu=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Ct(r);return c.jsx(Kb,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(Xi,{...o,ref:t})})});Zu.displayName=Ju;var Qu="MenuRadioItem",ed=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=qb(Qu,e.__scopeMenu),s=n===o.value;return c.jsx(td,{scope:e.__scopeMenu,checked:s,children:c.jsx(ls,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Zi(s),onSelect:pe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});ed.displayName=Qu;var Ji="MenuItemIndicator",[td,Gb]=Un(Ji,{checked:!1}),nd=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=Gb(Ji,n);return c.jsx(Kt,{present:r||cs(s.checked)||s.checked===!0,children:c.jsx(Ce.span,{...o,ref:t,"data-state":Zi(s.checked)})})});nd.displayName=Ji;var Yb="MenuSeparator",rd=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ce.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});rd.displayName=Yb;var Xb="MenuArrow",od=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=is(n);return c.jsx(bu,{...o,...r,ref:t})});od.displayName=Xb;var Jb="MenuSub",[_T,sd]=Un(Jb),qr="MenuSubTrigger",id=m.forwardRef((e,t)=>{const n=Wn(qr,e.__scopeMenu),r=Kr(qr,e.__scopeMenu),o=sd(qr,e.__scopeMenu),s=Gi(qr,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(Ki,{asChild:!0,...u,children:c.jsx(Yu,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":cd(n.open),...e,ref:Cn(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:pe(e.onPointerMove,Gr(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:pe(e.onPointerLeave,Gr(f=>{var p,v;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const x=(v=n.content)==null?void 0:v.dataset.side,g=x==="right",w=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+w,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:pe(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||_b[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});id.displayName=qr;var ad="MenuSubContent",ld=m.forwardRef((e,t)=>{const n=Wu(qt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Wn(qt,e.__scopeMenu),i=Kr(qt,e.__scopeMenu),a=sd(ad,e.__scopeMenu),l=m.useRef(null),u=We(t,l);return c.jsx(Vr.Provider,{scope:e.__scopeMenu,children:c.jsx(Kt,{present:r||s.open,children:c.jsx(Vr.Slot,{scope:e.__scopeMenu,children:c.jsx(Yi,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:pe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:pe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:pe(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=Mb[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});ld.displayName=ad;function cd(e){return e?"open":"closed"}function cs(e){return e==="indeterminate"}function Zi(e){return cs(e)?"indeterminate":e?"checked":"unchecked"}function Zb(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Qb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function ey(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=Qb(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function ty(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],u=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function ny(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return ty(n,t)}function Gr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var ry=Uu,oy=Ki,sy=Vu,iy=Ku,ay=Xi,ly=qu,cy=ls,uy=Xu,dy=Zu,fy=ed,hy=nd,py=rd,my=od,gy=id,xy=ld,us="DropdownMenu",[wy,MT]=wn(us,[zu]),jt=zu(),[vy,ud]=wy(us),dd=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=jt(t),u=m.useRef(null),[d,f]=ur({prop:o,defaultProp:s??!1,onChange:i,caller:us});return c.jsx(vy,{scope:t,triggerId:At(),triggerRef:u,contentId:At(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(ry,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};dd.displayName=us;var fd="DropdownMenuTrigger",hd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=ud(fd,n),i=jt(n);return c.jsx(oy,{asChild:!0,...i,children:c.jsx(Ce.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:Cn(t,s.triggerRef),onPointerDown:pe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:pe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});hd.displayName=fd;var by="DropdownMenuPortal",pd=e=>{const{__scopeDropdownMenu:t,...n}=e,r=jt(t);return c.jsx(sy,{...r,...n})};pd.displayName=by;var md="DropdownMenuContent",gd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ud(md,n),s=jt(n),i=m.useRef(!1);return c.jsx(iy,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:pe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:pe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!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)"}})});gd.displayName=md;var yy="DropdownMenuGroup",Sy=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(ay,{...o,...r,ref:t})});Sy.displayName=yy;var Cy="DropdownMenuLabel",xd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(ly,{...o,...r,ref:t})});xd.displayName=Cy;var ky="DropdownMenuItem",wd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(cy,{...o,...r,ref:t})});wd.displayName=ky;var Ty="DropdownMenuCheckboxItem",vd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(uy,{...o,...r,ref:t})});vd.displayName=Ty;var Ey="DropdownMenuRadioGroup",Iy=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(dy,{...o,...r,ref:t})});Iy.displayName=Ey;var Ny="DropdownMenuRadioItem",bd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(fy,{...o,...r,ref:t})});bd.displayName=Ny;var Ay="DropdownMenuItemIndicator",yd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(hy,{...o,...r,ref:t})});yd.displayName=Ay;var jy="DropdownMenuSeparator",Sd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(py,{...o,...r,ref:t})});Sd.displayName=jy;var _y="DropdownMenuArrow",My=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(my,{...o,...r,ref:t})});My.displayName=_y;var Ry="DropdownMenuSubTrigger",Cd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(gy,{...o,...r,ref:t})});Cd.displayName=Ry;var Py="DropdownMenuSubContent",kd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=jt(n);return c.jsx(xy,{...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)"}})});kd.displayName=Py;var Oy=dd,Dy=hd,Ly=pd,Td=gd,Ed=xd,Id=wd,Nd=vd,Ad=bd,jd=yd,_d=Sd,Md=Cd,Rd=kd;const Qi=Oy,ea=Dy,$y=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Md,{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,c.jsx(se.ChevronRight,{className:"ml-auto h-4 w-4"})]}));$y.displayName=Md.displayName;const Fy=m.forwardRef(({className:e,...t},n)=>c.jsx(Rd,{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}));Fy.displayName=Rd.displayName;const ds=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(Ly,{children:c.jsx(Td,{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})}));ds.displayName=Td.displayName;const Vn=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Id,{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}));Vn.displayName=Id.displayName;const By=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Nd,{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:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(jd,{children:c.jsx(se.Check,{className:"h-4 w-4"})})}),t]}));By.displayName=Nd.displayName;const zy=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Ad,{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:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(jd,{children:c.jsx(se.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));zy.displayName=Ad.displayName;const Hy=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Ed,{ref:r,className:re("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Hy.displayName=Ed.displayName;const Uy=m.forwardRef(({className:e,...t},n)=>c.jsx(_d,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));Uy.displayName=_d.displayName;const fs=0,In=1,vr=2,Pd=4;function Od(e){return()=>e}function Wy(e){e()}function Dd(e,t){return n=>e(t(n))}function Ld(e,t){return()=>e(t)}function Vy(e,t){return n=>e(t,n)}function ta(e){return e!==void 0}function Ky(...e){return()=>{e.map(Wy)}}function br(){}function hs(e,t){return t(e),e}function qy(e,t){return t(e)}function at(...e){return e}function Qe(e,t){return e(In,t)}function Re(e,t){e(fs,t)}function na(e){e(vr)}function ft(e){return e(Pd)}function ve(e,t){return Qe(e,Vy(t,fs))}function nn(e,t){const n=e(In,r=>{n(),t(r)});return n}function $d(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Fd(e,t){return e===t}function lt(e=Fd){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ae(e){return t=>n=>{e(n)&&t(n)}}function fe(e){return t=>Dd(t,e)}function hn(e){return t=>()=>{t(e)}}function Z(e,...t){const n=Gy(...t);return(r,o)=>{switch(r){case vr:na(e);return;case In:return Qe(e,n(o))}}}function pn(e,t){return n=>r=>{n(t=e(t,r))}}function Kn(e){return t=>n=>{e>0?e--:t(n)}}function yn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Oe(...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);Qe(s,l=>{const u=n;n=n|a,t[i]=l,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function Gy(...e){return t=>e.reduceRight(qy,t)}function Yy(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case In:return s?n===s?void 0:(r(),n=s,t=Qe(e,s),t):(r(),br);case vr:r(),n=null;return}}}function oe(e){let t=e;const n=Ve();return(r,o)=>{switch(r){case fs:t=o;break;case In:{o(t);break}case Pd:return t}return n(r,o)}}function Tt(e,t){return hs(oe(t),n=>ve(e,n))}function Ve(){const e=[];return(t,n)=>{switch(t){case fs:e.slice().forEach(r=>{r(n)});return;case vr:e.splice(0,e.length);return;case In:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Ht(e){return hs(Ve(),t=>ve(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Xy(),singleton:n}}const Xy=()=>Symbol();function Jy(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 pt(...e){const t=Ve(),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);Qe(s,l=>{n[i]=l,r=r|a,r===o&&Re(t,n)})}),function(s,i){switch(s){case vr:{na(t);return}case In:return r===o&&i(n),Qe(t,i)}}}function Ie(e,t=Fd){return Z(e,lt(t))}function ra(...e){return function(t,n){switch(t){case vr:return;case In:return Ky(...e.map(r=>Qe(r,n)))}}}var Dt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Dt||{});const Zy={0:"debug",3:"error",1:"log",2:"warn"},Qy=()=>typeof globalThis>"u"?window:globalThis,Nn=Ge(()=>{const e=oe(3);return{log:oe((t,n,r=1)=>{var o;const s=(o=Qy().VIRTUOSO_LOG_LEVEL)!=null?o:ft(e);r>=s&&console[Zy[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function qn(e,t,n){return oa(e,t,n).callbackRef}function oa(e,t,n){const r=y.useRef(null);let o=i=>{};const s=y.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 e0(e,t,n,r,o,s,i,a,l){const u=y.useCallback(d=>{const f=t0(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let v;p&&(v=h.ownerDocument.defaultView);const x=i?a?i.scrollLeft:i.scrollTop:p?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,w=i?a?i.offsetWidth:i.offsetHeight:p?a?v.innerWidth:v.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(x,0),viewportHeight:w}),s==null||s(a?Bd("column-gap",getComputedStyle(d).columnGap,o):Bd("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return oa(u,n,l)}function t0(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),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Dt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Bd(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Dt.WARN),t==="normal"?0:parseInt(t??"0",10)}function zd(e,t,n){const r=y.useRef(null),o=y.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),v=u.top-p.top;h=p.height-Math.max(0,v),f=v+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=oa(o,!0,n),a=y.useCallback(()=>{o(i.current)},[o,i]);return y.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const _t=Ge(()=>{const e=Ve(),t=Ve(),n=oe(0),r=Ve(),o=oe(0),s=Ve(),i=Ve(),a=oe(0),l=oe(0),u=oe(0),d=oe(0),f=Ve(),h=Ve(),p=oe(!1),v=oe(!1),x=oe(!1);return ve(Z(e,fe(({scrollTop:g})=>g)),t),ve(Z(e,fe(({scrollHeight:g})=>g)),i),ve(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Yr={lvl:0};function Hd(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===Yr}function Xr(e,t){if(!nt(e))return t===e.k?e.v:t<e.k?Xr(e.l,t):Xr(e.r,t)}function rn(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=rn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return rn(e.l,t,n)}function Ut(e,t,n){return nt(e)?Vd(t,n,1):t===e.k?wt(e,{k:t,v:n}):t<e.k?Kd(wt(e,{l:Ut(e.l,t,n)})):Kd(wt(e,{r:Ut(e.r,t,n)}))}function yr(){return Yr}function ps(e,t,n){if(nt(e))return[];const r=rn(e,t)[0];return n0(ia(e,r,n))}function sa(e,t){if(nt(e))return Yr;const{k:n,l:r,r:o}=e;if(t===n){if(nt(r))return o;if(nt(o))return r;{const[s,i]=Wd(r);return ms(wt(e,{k:s,l:Ud(r),v:i}))}}else return t<n?ms(wt(e,{l:sa(r,t)})):ms(wt(e,{r:sa(o,t)}))}function Gn(e){return nt(e)?[]:[...Gn(e.l),{k:e.k,v:e.v},...Gn(e.r)]}function ia(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(ia(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ia(s,t,n))),a}function ms(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(aa(t))return qd(wt(e,{lvl:n-1}));if(!nt(t)&&!nt(t.r))return wt(t.r,{l:wt(t,{r:t.r.l}),lvl:n,r:wt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(aa(e))return la(wt(e,{lvl:n-1}));if(!nt(r)&&!nt(r.l)){const o=r.l,s=aa(o)?r.lvl-1:r.lvl;return wt(o,{l:wt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:la(wt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function wt(e,t){return Vd(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 Ud(e){return nt(e.r)?e.l:ms(wt(e,{r:Ud(e.r)}))}function aa(e){return nt(e)||e.lvl>e.r.lvl}function Wd(e){return nt(e.r)?[e.k,e.v]:Wd(e.r)}function Vd(e,t,n,r=Yr,o=Yr){return{k:e,l:r,lvl:n,r:o,v:t}}function Kd(e){return la(qd(e))}function qd(e){const{l:t}=e;return!nt(t)&&t.lvl===e.lvl?wt(t,{r:wt(e,{l:t.r})}):e}function la(e){const{lvl:t,r:n}=e;return!nt(n)&&!nt(n.r)&&n.lvl===t&&n.r.lvl===t?wt(n,{l:wt(e,{r:n.l}),lvl:t+1}):e}function n0(e){return Hd(e,({k:t,v:n})=>({index:t,value:n}))}function Gd(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Jr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const ca=Ge(()=>({recalcInProgress:oe(!1)}),[],{singleton:!0});function Yd(e,t,n){return e[gs(e,t,n)]}function gs(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 r0(e,t,n,r){const o=gs(e,t,r),s=gs(e,n,r,o);return e.slice(o,s+1)}function An(e,t){return Math.round(e.getBoundingClientRect()[t])}function xs(e){return!nt(e.groupOffsetTree)}function ua({index:e},t){return t===e?0:t<e?-1:1}function o0(){return{groupIndices:[],groupOffsetTree:yr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:yr()}}function s0(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=Ut(e,0,s);continue}const a=ps(e,i-1,o+1);if(a.some(f0(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=sa(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=Ut(e,o+1,h));u&&(e=Ut(e,i,s))}return[e,n]}function i0(e){return typeof e.groupIndex<"u"}function a0({offset:e},t){return t===e?0:t<e?-1:1}function Zr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Yd(t,e,ua),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Xd(e,t){if(!xs(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Jd(e,t,n){if(i0(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Xd(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function l0(e,t,n,r=0){return r>0&&(t=Math.max(t,Yd(e,r,ua).offset)),Hd(r0(e,t,n,a0),d0)}function c0(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Dt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&nt(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((v,x)=>Ut(Ut(v,x,h),x+1,p),i)}else[i,a]=s0(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=da(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Ut(h,p,Zr(p,f,o)),yr()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function u0(e){return Gn(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 Zd(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 da(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=gs(o,t-1,ua),a=o[l].offset;const u=rn(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===rn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of ps(n,t,1/0)){const f=u-s,h=f*i+a+f*r;o.push({index:u,offset:h,size:d}),s=u,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function d0(e){return{index:e.index,value:e}}function f0(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 h0={offsetHeight:"height",offsetWidth:"width"},mn=Ge(([{log:e},{recalcInProgress:t}])=>{const n=Ve(),r=Ve(),o=Tt(r,0),s=Ve(),i=Ve(),a=oe(0),l=oe([]),u=oe(void 0),d=oe(void 0),f=oe((C,k)=>An(C,h0[k])),h=oe(void 0),p=oe(0),v=o0(),x=Tt(Z(n,Oe(l,e,p),pn(c0,v),lt()),v),g=Tt(Z(l,lt(),pn((C,k)=>({current:k,prev:C.current}),{current:[],prev:[]}),fe(({prev:C})=>C)),[]);ve(Z(l,Ae(C=>C.length>0),Oe(x,p),fe(([C,k,E])=>{const A=C.reduce((L,B,W)=>Ut(L,B,Zr(B,k.offsetTree,E)||W),yr());return{...k,groupIndices:C,groupOffsetTree:A}})),x),ve(Z(r,Oe(x),Ae(([C,{lastIndex:k}])=>C<k),fe(([C,{lastIndex:k,lastSize:E}])=>[{endIndex:k,size:E,startIndex:C}])),n),ve(u,d);const w=Tt(Z(u,fe(C=>C===void 0)),!0);ve(Z(d,Ae(C=>C!==void 0&&nt(ft(x).sizeTree)),fe(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=Ht(Z(n,Oe(x),pn(({sizes:C},[k,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),fe(C=>C.changed)));Qe(Z(a,pn((C,k)=>({diff:C.prev-k,prev:k}),{diff:0,prev:0}),fe(C=>C.diff)),C=>{const{groupIndices:k}=ft(x);if(C>0)Re(t,!0),Re(s,C+Zd(C,k));else if(C<0){const E=ft(g);E.length>0&&(C-=Zd(-C,E)),Re(i,C)}}),Qe(Z(a,Oe(e)),([C,k])=>{C<0&&k("`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},Dt.ERROR)});const S=Ht(s);ve(Z(s,Oe(x),fe(([C,k])=>{const E=k.groupIndices.length>0,A=[],L=k.lastSize;if(E){const B=Xr(k.sizeTree,0);let W=0,K=0;for(;W<C;){const R=k.groupIndices[K],G=k.groupIndices.length===K+1?1/0:k.groupIndices[K+1]-R-1;A.push({endIndex:R,size:B,startIndex:R}),A.push({endIndex:R+1+G-1,size:L,startIndex:R+1}),K++,W+=G+1}const H=Gn(k.sizeTree);return W!==C&&H.shift(),H.reduce((R,{k:G,v:N})=>{let $=R.ranges;return R.prevSize!==0&&($=[...R.ranges,{endIndex:G+C-1,size:R.prevSize,startIndex:R.prevIndex}]),{prevIndex:G+C,prevSize:N,ranges:$}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return Gn(k.sizeTree).reduce((B,{k:W,v:K})=>({prevIndex:W+C,prevSize:K,ranges:[...B.ranges,{endIndex:W+C-1,size:B.prevSize,startIndex:B.prevIndex}]}),{prevIndex:0,prevSize:L,ranges:[]}).ranges})),n);const T=Ht(Z(i,Oe(x,p),fe(([C,{offsetTree:k},E])=>{const A=-C;return Zr(A,k,E)})));return ve(Z(i,Oe(x,p),fe(([C,k,E])=>{if(k.groupIndices.length>0){if(nt(k.sizeTree))return k;let A=yr();const L=ft(g);let B=0,W=0,K=0;for(;B<-C;){K=L[W];const H=L[W+1]-K-1;W++,B+=H+1}if(A=Gn(k.sizeTree).reduce((H,{k:R,v:G})=>Ut(H,Math.max(0,R+C),G),A),B!==-C){const H=Xr(k.sizeTree,K);A=Ut(A,0,H);const R=rn(k.sizeTree,-C+1)[1];A=Ut(A,1,R)}return{...k,sizeTree:A,...da(k.offsetTree,0,A,E)}}else{const A=Gn(k.sizeTree).reduce((L,{k:B,v:W})=>Ut(L,Math.max(0,B+C),W),yr());return{...k,sizeTree:A,...da(k.offsetTree,0,A,E)}}})),x),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:T,sizeRanges:n,sizes:x,statefulTotalCount:o,totalCount:r,trackItemSizes:w,unshiftWith:s}},at(Nn,ca),{singleton:!0});function p0(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Qd=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ve(),i=Ve(),a=Ht(Z(s,fe(p0)));return ve(Z(a,fe(l=>l.totalCount)),n),ve(Z(a,fe(l=>l.groupIndices)),e),ve(Z(pt(o,t,r),Ae(([l,u])=>xs(u)),fe(([l,u,d])=>rn(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),lt(),fe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},at(mn,_t)),jn=Ge(([{log:e}])=>{const t=oe(!1),n=Ht(Z(t,Ae(r=>r),lt()));return Qe(t,r=>{r&&ft(e)("props updated",{},Dt.DEBUG)}),{didMount:n,propsReady:t}},at(Nn),{singleton:!0}),m0=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ef(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!m0)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Qr=Ge(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=Ve(),v=Ve(),x=oe(0);let g=null,w=null,b=null;function S(){g&&(g(),g=null),b&&(b(),b=null),w&&(clearTimeout(w),w=null),Re(l,!1)}return ve(Z(p,Oe(n,f,r,x,a,i,h),Oe(e,s,o),fe(([[T,C,k,E,A,L,B,W],K,H,R])=>{const G=ef(T),{align:N,behavior:$,offset:P}=G,j=E-1,U=Jd(G,C,j);let V=Zr(U,C.offsetTree,K)+L;N==="end"?(V+=H+rn(C.sizeTree,U)[1]-k+R,U===j&&(V+=B)):N==="center"?V+=(H+rn(C.sizeTree,U)[1]-k+R)/2:V-=A,P&&(V+=P);const M=F=>{S(),F?(W("retrying to scroll to",{location:T},Dt.DEBUG),Re(p,T)):(Re(v,!0),W("list did not change, scroll successful",{},Dt.DEBUG))};if(S(),$==="smooth"){let F=!1;b=Qe(t,ee=>{F=F||ee}),g=nn(d,()=>{M(F)})}else g=nn(Z(t,g0(150)),M);return w=setTimeout(()=>{S()},1200),Re(l,!0),W("scrolling from index to",{behavior:$,index:U,top:V},Dt.DEBUG),{behavior:$,top:V}})),u),{scrollTargetReached:v,scrollToIndex:p,topListHeight:x}},at(mn,_t,Nn),{singleton:!0});function g0(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function fa(e,t){e==0?t():requestAnimationFrame(()=>{fa(e-1,t)})}function ha(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const eo=Ge(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=oe(!0),l=oe(0),u=oe(!0);return ve(Z(i,Oe(l),Ae(([d,f])=>!!f),hn(!1)),a),ve(Z(i,Oe(l),Ae(([d,f])=>!!f),hn(!1)),u),Qe(Z(pt(t,i),Oe(a,n,e,u),Ae(([[,d],f,{sizeTree:h},p,v])=>d&&(!nt(h)||ta(p))&&!f&&!v),Oe(l)),([,d])=>{nn(o,()=>{Re(u,!0)}),fa(4,()=>{nn(r,()=>{Re(a,!0)}),Re(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},at(mn,_t,Qr,jn),{singleton:!0});function tf(e,t){return Math.abs(e-t)<1.01}const to="up",no="down",x0="none",w0={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},v0=0,ro=Ge(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=oe(!1),a=oe(!0),l=Ve(),u=Ve(),d=oe(4),f=oe(v0),h=Tt(Z(ra(Z(Ie(o),Kn(1),hn(!0)),Z(Ie(o),Kn(1),hn(!1),$d(100))),lt()),!1),p=Tt(Z(ra(Z(n,hn(!0)),Z(n,hn(!1),$d(200))),lt()),!1);ve(Z(pt(Ie(o),Ie(f)),fe(([b,S])=>b<=S),lt()),a),ve(Z(a,yn(50)),u);const v=Ht(Z(pt(r,Ie(s),Ie(t),Ie(e),Ie(d)),pn((b,[{scrollHeight:S,scrollTop:T},C,k,E,A])=>{const L=T+C-S>-A,B={scrollHeight:S,scrollTop:T,viewportHeight:C};if(L){let K,H;return T>b.state.scrollTop?(K="SCROLLED_DOWN",H=b.state.scrollTop-T):(K="SIZE_DECREASED",H=b.state.scrollTop-T||b.scrollTopDelta),{atBottom:!0,atBottomBecause:K,scrollTopDelta:H,state:B}}let W;return B.scrollHeight>b.state.scrollHeight?W="SIZE_INCREASED":C<b.state.viewportHeight?W="VIEWPORT_HEIGHT_DECREASING":T<b.state.scrollTop?W="SCROLLING_UPWARDS":W="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:W,state:B}},w0),lt((b,S)=>b&&b.atBottom===S.atBottom))),x=Tt(Z(r,pn((b,{scrollHeight:S,scrollTop:T,viewportHeight:C})=>{if(tf(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:T};{const k=S-(T+C)<1;return b.scrollTop!==T&&k?{changed:!0,jump:b.scrollTop-T,scrollHeight:S,scrollTop:T}:{changed:!0,jump:0,scrollHeight:S,scrollTop:T}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ae(b=>b.changed),fe(b=>b.jump)),0);ve(Z(v,fe(b=>b.atBottom)),i),ve(Z(i,yn(50)),l);const g=oe(no);ve(Z(r,fe(({scrollTop:b})=>b),lt(),pn((b,S)=>ft(p)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?to:no,prevScrollTop:S},{direction:no,prevScrollTop:0}),fe(b=>b.direction)),g),ve(Z(r,yn(50),hn(x0)),g);const w=oe(0);return ve(Z(h,Ae(b=>!b),hn(0)),w),ve(Z(o,yn(100),Oe(h),Ae(([b,S])=>!!S),pn(([b,S],[T])=>[S,T],[0,0]),fe(([b,S])=>S-b)),w),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:x,scrollDirection:g,scrollVelocity:w}},at(_t)),ws="top",vs="bottom",nf="none";function rf(e,t,n){return typeof e=="number"?n===to&&t===ws||n===no&&t===vs?e:0:n===to?t===ws?e.main:e.reverse:t===vs?e.main:e.reverse}function of(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const pa=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ve(),i=oe(0),a=oe(0),l=oe(0),u=Tt(Z(pt(Ie(r),Ie(o),Ie(n),Ie(s,Jr),Ie(l),Ie(i),Ie(t),Ie(e),Ie(a)),fe(([d,f,h,[p,v],x,g,w,b,S])=>{const T=d-b,C=g+w,k=Math.max(h-T,0);let E=nf;const A=of(S,ws),L=of(S,vs);return p-=b,p+=h+w,v+=h+w,v-=b,p>d+C-A&&(E=to),v<d-k+f+L&&(E=no),E!==nf?[Math.max(T-h-rf(x,ws,E)-A,0),T-k-w+f+rf(x,vs,E)+L]:null}),Ae(d=>d!=null),lt(Jr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},at(_t),{singleton:!0});function b0(e,t,n){if(xs(t)){const r=Xd(e,t);return[{index:rn(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 ma={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function bs(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const x=e[e.length-1];d=x.offset+x.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,v=h-d;return{bottom:d,firstItemIndex:s,items:af(e,o,s),offsetBottom:v,offsetTop:u,top:p,topItems:af(t,o,s),topListHeight:t.reduce((x,g)=>g.size+x,0),totalCount:n}}function sf(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=ha(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return bs(u,[],a,o,n,r)}function af(e,t,n){if(e.length===0)return[];if(!xs(t))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=ps(t.groupOffsetTree,r,o);let a,l=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:u.index-(l+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const Yn=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:v}])=>{const x=oe([]),g=oe(0),w=Ve();ve(s.topItemsIndexes,x);const b=Tt(Z(pt(p,v,Ie(l,Jr),Ie(o),Ie(r),Ie(u),d,Ie(x),Ie(t),Ie(n),e),Ae(([k,E,,A,,,,,,,L])=>{const B=L&&L.length!==A;return k&&!E&&!B}),fe(([,,[k,E],A,L,B,W,K,H,R,G])=>{const N=L,{offsetTree:$,sizeTree:P}=N,j=ft(g);if(A===0)return{...ma,totalCount:A};if(k===0&&E===0)return j===0?{...ma,totalCount:A}:sf(j,B,L,H,R,G||[]);if(nt(P))return j>0?null:bs(b0(ha(B,A),N,G),[],A,R,N,H);const U=[];if(K.length>0){const J=K[0],ie=K[K.length-1];let q=0;for(const O of ps(P,J,ie)){const Y=O.value,X=Math.max(O.start,J),le=Math.min(O.end,ie);for(let D=X;D<=le;D++)U.push({data:G==null?void 0:G[D],index:D,offset:q,size:Y}),q+=Y}}if(!W)return bs([],U,A,R,N,H);const V=K.length>0?K[K.length-1]+1:0,M=l0($,k,E,V);if(M.length===0)return null;const F=A-1,ee=hs([],J=>{for(const ie of M){const q=ie.value;let O=q.offset,Y=ie.start;const X=q.size;if(q.offset<k){Y+=Math.floor((k-q.offset+R)/(X+R));const D=Y-ie.start;O+=D*X+D*R}Y<V&&(O+=(V-Y)*X,Y=V);const le=Math.min(ie.end,F);for(let D=Y;D<=le&&!(O>=E);D++)J.push({data:G==null?void 0:G[D],index:D,offset:O,size:X}),O+=X+R}});return bs(ee,U,A,R,N,H)}),Ae(k=>k!==null),lt()),ma);ve(Z(e,Ae(ta),fe(k=>k==null?void 0:k.length)),o),ve(Z(b,fe(k=>k.topListHeight)),f),ve(f,a),ve(Z(b,fe(k=>[k.top,k.bottom])),i),ve(Z(b,fe(k=>k.items)),w);const S=Ht(Z(b,Ae(({items:k})=>k.length>0),Oe(o,e),Ae(([{items:k},E])=>k[k.length-1].originalIndex===E-1),fe(([,k,E])=>[k-1,E]),lt(Jr),fe(([k])=>k))),T=Ht(Z(b,yn(200),Ae(({items:k,topItems:E})=>k.length>0&&k[0].originalIndex===E.length),fe(({items:k})=>k[0].index),lt())),C=Ht(Z(b,Ae(({items:k})=>k.length>0),fe(({items:k})=>{let E=0,A=k.length-1;for(;k[E].type==="group"&&E<A;)E++;for(;k[A].type==="group"&&A>E;)A--;return{endIndex:k[A].index,startIndex:k[E].index}}),lt(Gd)));return{endReached:S,initialItemCount:g,itemsRendered:w,listState:b,rangeChanged:C,startReached:T,topItemsIndexes:x,...h}},at(mn,Qd,pa,eo,Qr,ro,jn,ca),{singleton:!0}),lf=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ve(),i=Tt(Z(pt(n,e,r,t,o),fe(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return ve(Ie(i),s),{totalListHeight:i,totalListHeightChanged:s}},at(_t,Yn),{singleton:!0}),y0=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=oe(!1),r=Tt(Z(pt(n,e,t),Ae(([o])=>o),fe(([,o,s])=>Math.max(0,o-s)),yn(0),lt()),0);return{alignToBottom:n,paddingTopAddition:r}},at(_t,lf),{singleton:!0}),cf=Ge(()=>({context:oe(null)})),S0=({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,uf=Ge(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=Ve();return ve(Z(d,Oe(t,l,n,s,o,r,a),Oe(e),fe(([[f,h,p,v,x,g,w,b],S])=>{const{align:T,behavior:C,calculateViewLocation:k=S0,done:E,...A}=f,L=Jd(f,h,v-1),B=Zr(L,h.offsetTree,S)+x+g,W=B+rn(h.sizeTree,L)[1],K=b+g,H=b+p-w,R=k({itemBottom:W,itemTop:B,locationParams:{align:T,behavior:C,...A},viewportBottom:H,viewportTop:K});return R?E&&nn(Z(i,Ae(G=>!G),Kn(ft(i)?1:2)),E):E&&E(),R}),Ae(f=>f!==null)),u),{scrollIntoView:d}},at(mn,_t,Qr,Yn,Nn),{singleton:!0});function df(e){return e?e==="smooth"?"smooth":"auto":!1}const C0=(e,t)=>typeof e=="function"?df(e(t)):t&&df(e),k0=Ge(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const v=oe(!1),x=Ve();let g=null;function w(C){Re(i,{align:"end",behavior:C,index:"LAST"})}Qe(Z(pt(Z(Ie(t),Kn(1)),l),Oe(Ie(v),s,a,f),fe(([[C,k],E,A,L,B])=>{let W=k&&L,K="auto";return W&&(K=C0(E,A||B),W=W&&!!K),{followOutputBehavior:K,shouldFollow:W,totalCount:C}}),Ae(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:k})=>{g&&(g(),g=null),ft(n)?requestAnimationFrame(()=>{ft(d)("following output to ",{totalCount:k},Dt.DEBUG),w(C)}):g=nn(e,()=>{ft(d)("following output to ",{totalCount:k},Dt.DEBUG),w(C),g=null})});function b(C){const k=nn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(ft(d)("scrolling to bottom due to increased size",{},Dt.DEBUG),w("auto"))});setTimeout(k,100)}Qe(Z(pt(Ie(v),t,u),Ae(([C,,k])=>C&&k),pn(({value:C},[,k])=>({refreshed:C===k,value:k}),{refreshed:!1,value:0}),Ae(({refreshed:C})=>C),Oe(v,t)),([,C])=>{ft(a)&&b(C!==!1)}),Qe(x,()=>{b(ft(v)!==!1)}),Qe(pt(Ie(v),o),([C,k])=>{C&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&w("auto")});const S=oe(null),T=Ve();return ve(ra(Z(Ie(r),fe(C=>{var k;return(k=C==null?void 0:C.length)!=null?k:0})),Z(Ie(t))),T),Qe(Z(pt(Z(T,Kn(1)),l),Oe(Ie(S),a,f,h),fe(([[C,k],E,A,L,B])=>k&&A&&(E==null?void 0:E({context:B,totalCount:C,scrollingInProgress:L}))),Ae(C=>!!C),yn(0)),C=>{g&&(g(),g=null),ft(n)?requestAnimationFrame(()=>{ft(d)("scrolling into view",{}),Re(p,C)}):g=nn(e,()=>{ft(d)("scrolling into view",{}),Re(p,C),g=null})}),{autoscrollToBottom:x,followOutput:v,scrollIntoViewOnChange:S}},at(mn,ro,Qr,eo,jn,Nn,_t,cf,uf)),T0=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ve(Z(a,Oe(s),Ae(([,l])=>l!==0),Oe(o,r,t,n,e),fe(([[,l],u,d,f,h,p=[]])=>sf(l,u,d,f,h,p))),i),{}),at(mn,eo,Yn,jn),{singleton:!0}),E0=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=oe(0);return Qe(Z(e,Oe(r),Ae(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{nn(Z(n,Kn(1),Ae(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Re(t,o)})})}),{initialScrollTop:r}},at(jn,_t,Yn),{singleton:!0}),ff=Ge(([{scrollVelocity:e}])=>{const t=oe(!1),n=Ve(),r=oe(!1);return ve(Z(e,Oe(r,t,n),Ae(([o,s])=>!!s),fe(([o,s,i,a])=>{const{enter:l,exit:u}=s;if(i){if(u(o,a))return!1}else if(l(o,a))return!0;return i}),lt()),t),Qe(Z(pt(t,e,n),Oe(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},at(ro),{singleton:!0}),ga=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ve(),r=Ve(),o=Ve(),s=oe(!1),i=oe(void 0);return ve(Z(pt(n,r),fe(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),ve(Z(t,Oe(r),fe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},at(_t)),I0=Ge(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=Ve(),d=oe(void 0),f=oe(null),h=oe(null);return ve(a,f),ve(l,h),Qe(Z(u,Oe(t,r,i,f,h,n)),([p,v,x,g,w,b,S])=>{const T=u0(v.sizeTree);g&&w!==null&&b!==null&&(x=w.scrollTop-b.offsetTop),x-=S,p({ranges:T,scrollTop:x})}),ve(Z(d,Ae(ta),fe(N0)),o),ve(Z(s,Oe(d),Ae(([,p])=>p!==void 0),lt(),fe(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},at(mn,_t,eo,jn,ga));function N0(e){return{align:"start",index:0,offset:e.scrollTop}}const A0=Ge(([{topItemsIndexes:e}])=>{const t=oe(0);return ve(Z(t,Ae(n=>n>=0),fe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},at(Yn));function hf(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const j0=hf(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),_0=Ge(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:v}])=>{const x=Ht(Z(l,Oe(i),pn(([,w,b,S],[{bottom:T,items:C,offsetBottom:k,totalCount:E},A])=>{const L=T+k;let B=0;return b===E&&w.length>0&&C.length>0&&(C[0].originalIndex===0&&w[0].originalIndex===0||(B=L-S,B!==0&&(B+=A))),[B,C,E,L]},[0,[],0,0]),Ae(([w])=>w!==0),Oe(r,a,n,o,p,v),Ae(([,w,b,S,,,T])=>!T&&!S&&w!==0&&b===to),fe(([[w],,,,,b])=>(b("Upward scrolling compensation",{amount:w},Dt.DEBUG),w))));function g(w){w>0?(Re(t,{behavior:"auto",top:-w}),Re(e,0)):(Re(e,0),Re(t,{behavior:"auto",top:-w}))}return Qe(Z(x,Oe(e,s)),([w,b,S])=>{S&&j0()?Re(e,b-w):g(-w)}),Qe(Z(pt(Tt(s,!1),e,v),Ae(([w,b,S])=>!w&&!S&&b!==0),fe(([w,b])=>b),yn(1)),g),ve(Z(f,fe(w=>({top:-w}))),t),Qe(Z(u,Oe(h,d),fe(([w,{groupIndices:b,lastSize:S,sizeTree:T},C])=>{function k(E){return E*(S+C)}if(b.length===0)return k(w);{let E=0;const A=Xr(T,0);let L=0,B=0;for(;L<w;){L++,E+=A;let W=b.length===B+1?1/0:b[B+1]-b[B]-1;L+W>w&&(E-=A,W=w-L+1),L+=W,E+=k(W),B++}return E}})),w=>{Re(e,w),requestAnimationFrame(()=>{Re(t,{top:w}),requestAnimationFrame(()=>{Re(e,0),Re(v,!1)})})}),{deviation:e}},at(_t,ro,Yn,mn,Nn,ca)),M0=Ge(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),at(pa,T0,jn,ff,lf,E0,y0,ga,uf,Nn,cf)),pf=Ge(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v},x,g,w,{listState:b,topItemsIndexes:S,...T},{scrollToIndex:C},k,{topItemCount:E},{groupCounts:A},L])=>(ve(T.rangeChanged,L.scrollSeekRangeChanged),ve(Z(L.windowViewportRect,fe(B=>B.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...w,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...T,...L,...x,sizes:l,...g}),at(mn,eo,_t,I0,k0,Yn,Qr,_0,A0,Qd,M0));function R0(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 ys=typeof document<"u"?y.useLayoutEffect:y.useEffect;function mf(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=y.createContext({});function l(g,w){g.propsReady&&Re(g.propsReady,!1);for(const b of r){const S=g[t.required[b]];Re(S,w[b])}for(const b of o)if(b in w){const S=g[t.optional[b]];Re(S,w[b])}g.propsReady&&Re(g.propsReady,!0)}function u(g){return s.reduce((w,b)=>(w[b]=S=>{const T=g[t.methods[b]];Re(T,S)},w),{})}function d(g){return i.reduce((w,b)=>(w[b]=Yy(g[t.events[b]]),w),{})}const f=y.forwardRef((g,w)=>{const{children:b,...S}=g,[T]=y.useState(()=>hs(Jy(e),E=>{l(E,S)})),[C]=y.useState(Ld(d,T));ys(()=>{for(const E of i)E in S&&Qe(C[E],S[E]);return()=>{Object.values(C).map(na)}},[S,C,T]),ys(()=>{l(T,S)}),y.useImperativeHandle(w,Od(u(T)));const k=n;return c.jsx(a.Provider,{value:T,children:n?c.jsx(k,{...R0([...r,...o,...i],S),children:b}):b})}),h=g=>{const w=y.useContext(a);return y.useCallback(b=>{Re(w[g],b)},[w,g])},p=g=>{const w=y.useContext(a)[g],b=y.useCallback(S=>Qe(w,S),[w]);return y.useSyncExternalStore(b,()=>ft(w),()=>ft(w))},v=g=>{const w=y.useContext(a)[g],[b,S]=y.useState(Ld(ft,w));return ys(()=>Qe(w,T=>{T!==b&&S(Od(T))}),[w,b]),b},x=y.version.startsWith("18")?p:v;return{Component:f,useEmitter:(g,w)=>{const b=y.useContext(a)[g];ys(()=>Qe(b,w),[w,b])},useEmitterValue:x,usePublisher:h}}const gf=y.createContext(void 0),xf=y.createContext(void 0),wf=typeof document<"u"?y.useLayoutEffect:y.useEffect;function xa(e){return"self"in e}function P0(e){return"body"in e}function vf(e,t,n,r=br,o,s){const i=y.useRef(null),a=y.useRef(null),l=y.useRef(null),u=y.useCallback(h=>{let p,v,x;const g=h.target;if(P0(g)||xa(g)){const b=xa(g)?g:g.defaultView;x=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else x=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,v=s?g.offsetWidth:g.offsetHeight;const w=()=>{e({scrollHeight:p,scrollTop:Math.max(x,0),viewportHeight:v})};h.suppressFlushSync?w():Xs.flushSync(w),a.current!==null&&(x===a.current||x<=0||x===p-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);y.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=h.behavior==="smooth";let x,g,w;xa(p)?(g=Math.max(An(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),x=s?p.innerWidth:p.innerHeight,w=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],x=An(p,s?"width":"height"),w=p[s?"scrollLeft":"scrollTop"]);const b=g-x;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),tf(x,g)||h.top===w){e({scrollHeight:g,scrollTop:w,viewportHeight:x}),v&&t(!0);return}v?(a.current=h.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const wa="-webkit-sticky",bf="sticky",va=hf(()=>{if(typeof document>"u")return bf;const e=document.createElement("div");return e.style.position=wa,e.style.position===wa?wa:bf});function ba(e){return e}const O0=Ge(()=>{const e=oe(a=>`Item ${a}`),t=oe(a=>`Group ${a}`),n=oe({}),r=oe(ba),o=oe("div"),s=oe(br),i=(a,l=null)=>Tt(Z(n,fe(u=>u[a]),lt()),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")}}),D0=Ge(([e,t])=>({...e,...t}),at(pf,O0)),L0=({height:e})=>c.jsx("div",{style:{height:e}}),$0={overflowAnchor:"none",position:va(),zIndex:1},yf={overflowAnchor:"none"},F0={...yf,display:"inline-block",height:"100%"},Sf=y.memo(function({showTopList:e=!1}){const t=_e("listState"),n=Gt("sizeRanges"),r=_e("useWindowScroll"),o=_e("customScrollParent"),s=Gt("windowScrollContainerState"),i=Gt("scrollContainerState"),a=o||r?s:i,l=_e("itemContent"),u=_e("context"),d=_e("groupContent"),f=_e("trackItemSizes"),h=_e("itemSize"),p=_e("log"),v=Gt("gap"),x=_e("horizontalDirection"),{callbackRef:g}=e0(n,h,f,e?br:a,p,v,o,x,_e("skipAnimationFrameInResizeObserver")),[w,b]=y.useState(0);ya("deviation",R=>{w!==R&&b(R)});const S=_e("EmptyPlaceholder"),T=_e("ScrollSeekPlaceholder")||L0,C=_e("ListComponent"),k=_e("ItemComponent"),E=_e("GroupComponent"),A=_e("computeItemKey"),L=_e("isSeeking"),B=_e("groupIndices").length>0,W=_e("alignToBottom"),K=_e("initialItemFinalLocationReached"),H=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:w!==0?w:W?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:w!==0?w:W?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...K?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{...Et(S,u)}):c.jsx(C,{...Et(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:H,children:(e?t.topItems:t.items).map(R=>{const G=R.originalIndex,N=A(G+t.firstItemIndex,R.data,u);return L?y.createElement(T,{...Et(T,u),height:R.size,index:R.index,key:N,type:R.type||"item",...R.type==="group"?{}:{groupIndex:R.groupIndex}}):R.type==="group"?y.createElement(E,{...Et(E,u),"data-index":G,"data-item-index":R.index,"data-known-size":R.size,key:N,style:$0},d(R.index,u)):y.createElement(k,{...Et(k,u),...U0(k,R.data),"data-index":G,"data-item-group-index":R.groupIndex,"data-item-index":R.index,"data-known-size":R.size,key:N,style:x?F0:yf},B?l(R.index,R.groupIndex,R.data,u):l(R.index,R.data,u))})})}),B0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},z0={outline:"none",overflowX:"auto",position:"relative"},Ss=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),H0={position:va(),top:0,width:"100%",zIndex:1};function Et(e,t){if(typeof e!="string")return{context:t}}function U0(e,t){return{item:typeof e=="string"?void 0:t}}const W0=y.memo(function(){const e=_e("HeaderComponent"),t=Gt("headerHeight"),n=_e("HeaderFooterTag"),r=qn(y.useMemo(()=>s=>{t(An(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Et(e,o)})}):null}),V0=y.memo(function(){const e=_e("FooterComponent"),t=Gt("footerHeight"),n=_e("HeaderFooterTag"),r=qn(y.useMemo(()=>s=>{t(An(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Et(e,o)})}):null});function Cf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:v}=vf(a,u,l,d,void 0,f);return e("scrollTo",v),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?z0:B0,...o},tabIndex:0,...i,...Et(l,s),children:r})})}function kf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=y.useRef(null),v=t("scrollerRef"),{scrollByCallback:x,scrollerRef:g,scrollToCallback:w}=vf(a,u,l,v,h);return wf(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",w),e("scrollBy",x),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Et(l,s),children:r})})}const K0=({children:e})=>{const t=y.useContext(gf),n=Gt("viewportHeight"),r=Gt("fixedItemHeight"),o=_e("alignToBottom"),s=_e("horizontalDirection"),i=y.useMemo(()=>Dd(n,l=>An(l,s?"width":"height")),[n,s]),a=qn(i,!0,_e("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:Ss(o),children:e})},q0=({children:e})=>{const t=y.useContext(gf),n=Gt("windowViewportRect"),r=Gt("fixedItemHeight"),o=_e("customScrollParent"),s=zd(n,o,_e("skipAnimationFrameInResizeObserver")),i=_e("alignToBottom");return y.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:Ss(i),children:e})},G0=({children:e})=>{const t=_e("TopItemListComponent")||"div",n=_e("headerHeight"),r={...H0,marginTop:`${n}px`},o=_e("context");return c.jsx(t,{style:r,...Et(t,o),children:e})},Y0=y.memo(function(e){const t=_e("useWindowScroll"),n=_e("topItemsIndexes").length>0,r=_e("customScrollParent"),o=_e("context");return c.jsxs(r||t?Z0:J0,{...e,context:o,children:[n&&c.jsx(G0,{children:c.jsx(Sf,{showTopList:!0})}),c.jsxs(r||t?q0:K0,{children:[c.jsx(W0,{}),c.jsx(Sf,{}),c.jsx(V0,{})]})]})}),{Component:X0,useEmitter:ya,useEmitterValue:_e,usePublisher:Gt}=mf(D0,{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"}},Y0),J0=Cf({useEmitter:ya,useEmitterValue:_e,usePublisher:Gt}),Z0=kf({useEmitter:ya,useEmitterValue:_e,usePublisher:Gt}),Q0=X0;at(pf,Ge(()=>{const e=oe(u=>c.jsxs("td",{children:["Item $",u]})),t=oe(null),n=oe(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=oe(null),o=oe(null),s=oe({}),i=oe(ba),a=oe(br),l=(u,d=null)=>Tt(Z(s,fe(f=>f[u]),lt()),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")}})),va();const Tf={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},eS={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ef,floor:Cs,max:oo,min:Sa,round:If}=Math;function Nf(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function tS(e){return{...eS,items:e}}function ks(e,t){return e&&e.width===t.width&&e.height===t.height}function nS(e,t){return e&&e.column===t.column&&e.row===t.row}const rS=Ge(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:v,propsReady:x},{customScrollParent:g,useWindowScroll:w,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:T},C])=>{const k=oe(0),E=oe(0),A=oe(Tf),L=oe({height:0,width:0}),B=oe({height:0,width:0}),W=Ve(),K=Ve(),H=oe(0),R=oe(null),G=oe({column:0,row:0}),N=Ve(),$=Ve(),P=oe(!1),j=oe(0),U=oe(!0),V=oe(!1),M=oe(!1);Qe(Z(v,Oe(j),Ae(([O,Y])=>!!Y)),()=>{Re(U,!1)}),Qe(Z(pt(v,U,B,L,j,V),Ae(([O,Y,X,le,,D])=>O&&!Y&&X.height!==0&&le.height!==0&&!D)),([,,,,O])=>{Re(V,!0),fa(1,()=>{Re(W,O)}),nn(Z(u),()=>{Re(t,[0,0]),Re(U,!0)})}),ve(Z($,Ae(O=>O!=null&&O.scrollTop>0),hn(0)),E),Qe(Z(v,Oe($),Ae(([,O])=>O!=null)),([,O])=>{O&&(Re(L,O.viewport),Re(B,O.item),Re(G,O.gap),O.scrollTop>0&&(Re(P,!0),nn(Z(u,Kn(1)),Y=>{Re(P,!1)}),Re(l,{top:O.scrollTop})))}),ve(Z(L,fe(({height:O})=>O)),f),ve(Z(pt(Ie(L,ks),Ie(B,ks),Ie(G,(O,Y)=>O&&O.column===Y.column&&O.row===Y.row),Ie(u)),fe(([O,Y,X,le])=>({gap:X,item:Y,scrollTop:le,viewport:O}))),N),ve(Z(pt(Ie(k),r,Ie(G,nS),Ie(B,ks),Ie(L,ks),Ie(R),Ie(E),Ie(P),Ie(U),Ie(j)),Ae(([,,,,,,,O])=>!O),fe(([O,[Y,X],le,D,te,xe,de,,we,je])=>{const{column:De,row:$e}=le,{height:ke,width:Fe}=D,{width:Ke}=te;if(de===0&&(O===0||Ke===0))return Tf;if(Fe===0){const ct=ha(je,O),Nt=ct+Math.max(de-1,0);return tS(Nf(ct,Nt,xe))}const Je=Af(Ke,Fe,De);let qe,tt;we?Y===0&&X===0&&de>0?(qe=0,tt=de-1):(qe=Je*Cs((Y+$e)/(ke+$e)),tt=Je*Ef((X+$e)/(ke+$e))-1,tt=Sa(O-1,oo(tt,Je-1)),qe=Sa(tt,oo(0,qe))):(qe=0,tt=-1);const bt=Nf(qe,tt,xe),{bottom:st,top:Te}=jf(te,le,D,bt),Le=Ef(O/Je),ot=Le*ke+(Le-1)*$e-st;return{bottom:st,itemHeight:ke,items:bt,itemWidth:Fe,offsetBottom:ot,offsetTop:Te,top:Te}})),A),ve(Z(R,Ae(O=>O!==null),fe(O=>O.length)),k),ve(Z(pt(L,B,A,G),Ae(([O,Y,{items:X}])=>X.length>0&&Y.height!==0&&O.height!==0),fe(([O,Y,{items:X},le])=>{const{bottom:D,top:te}=jf(O,le,Y,X);return[te,D]}),lt(Jr)),t);const F=oe(!1);ve(Z(u,Oe(F),fe(([O,Y])=>Y||O!==0)),F);const ee=Ht(Z(pt(A,k),Ae(([{items:O}])=>O.length>0),Oe(F),Ae(([[O,Y],X])=>{const le=O.items[O.items.length-1].index===Y-1;return(X||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===Y)&&le}),fe(([[,O]])=>O-1),lt())),J=Ht(Z(Ie(A),Ae(({items:O})=>O.length>0&&O[0].index===0),hn(0),lt())),ie=Ht(Z(Ie(A),Oe(P),Ae(([{items:O},Y])=>O.length>0&&!Y),fe(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),lt(Gd),yn(0)));ve(ie,p.scrollSeekRangeChanged),ve(Z(W,Oe(L,B,k,G),fe(([O,Y,X,le,D])=>{const te=ef(O),{align:xe,behavior:de,offset:we}=te;let je=te.index;je==="LAST"&&(je=le-1),je=oo(0,je,Sa(le-1,je));let De=Ca(Y,D,X,je);return xe==="end"?De=If(De-Y.height+X.height):xe==="center"&&(De=If(De-Y.height/2+X.height/2)),we&&(De+=we),{behavior:de,top:De}})),l);const q=Tt(Z(A,fe(O=>O.offsetBottom+O.bottom)),0);return ve(Z(T,fe(O=>({height:O.visibleHeight,width:O.visibleWidth}))),L),{customScrollParent:g,data:R,deviation:H,footerHeight:o,gap:G,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:B,overscan:n,restoreStateFrom:$,scrollBy:i,scrollContainerState:a,scrollHeight:K,scrollTo:l,scrollToIndex:W,scrollTop:u,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:w,viewportDimensions:L,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:T,...p,gridState:A,horizontalDirection:M,initialTopMostItemIndex:j,totalListHeight:q,...h,endReached:ee,propsReady:x,rangeChanged:ie,startReached:J,stateChanged:N,stateRestoreInProgress:P,...C}},at(pa,_t,ro,ff,jn,ga,Nn));function Af(e,t,n){return oo(1,Cs((e+n)/(Cs(t)+n)))}function jf(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ca(e,t,n,r[0].index);return{bottom:Ca(e,t,n,r[r.length-1].index)+o,top:s}}function Ca(e,t,n,r){const o=Af(e.width,n.width,t.column),s=Cs(r/o),i=s*n.height+oo(0,s-1)*t.row;return i>0?i+t.row:i}const oS=Ge(()=>{const e=oe(f=>`Item ${f}`),t=oe({}),n=oe(null),r=oe("virtuoso-grid-item"),o=oe("virtuoso-grid-list"),s=oe(ba),i=oe("div"),a=oe(br),l=(f,h=null)=>Tt(Z(t,fe(p=>p[f]),lt()),h),u=oe(!1),d=oe(!1);return ve(Ie(d),u),{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:u,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),sS=Ge(([e,t])=>({...e,...t}),at(rS,oS)),iS=y.memo(function(){const e=ut("gridState"),t=ut("listClassName"),n=ut("itemClassName"),r=ut("itemContent"),o=ut("computeItemKey"),s=ut("isSeeking"),i=Yt("scrollHeight"),a=ut("ItemComponent"),l=ut("ListComponent"),u=ut("ScrollSeekPlaceholder"),d=ut("context"),f=Yt("itemDimensions"),h=Yt("gap"),p=ut("log"),v=ut("stateRestoreInProgress"),x=Yt("reportReadyState"),g=qn(y.useMemo(()=>w=>{const b=w.parentElement.parentElement.scrollHeight;i(b);const S=w.firstChild;if(S){const{height:T,width:C}=S.getBoundingClientRect();f({height:T,width:C})}h({column:Mf("column-gap",getComputedStyle(w).columnGap,p),row:Mf("row-gap",getComputedStyle(w).rowGap,p)})},[i,f,h,p]),!0,!1);return wf(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),v?null:c.jsx(l,{className:t,ref:g,...Et(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(w=>{const b=o(w.index,w.data,d);return s?c.jsx(u,{...Et(u,d),height:e.itemHeight,index:w.index,width:e.itemWidth},b):y.createElement(a,{...Et(a,d),className:n,"data-index":w.index,key:b},r(w.index,w.data,d))})})}),aS=y.memo(function(){const e=ut("HeaderComponent"),t=Yt("headerHeight"),n=ut("headerFooterTag"),r=qn(y.useMemo(()=>s=>{t(An(s,"height"))},[t]),!0,!1),o=ut("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Et(e,o)})}):null}),lS=y.memo(function(){const e=ut("FooterComponent"),t=Yt("footerHeight"),n=ut("headerFooterTag"),r=qn(y.useMemo(()=>s=>{t(An(s,"height"))},[t]),!0,!1),o=ut("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Et(e,o)})}):null}),cS=({children:e})=>{const t=y.useContext(xf),n=Yt("itemDimensions"),r=Yt("viewportDimensions"),o=qn(y.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return y.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),c.jsx("div",{ref:o,style:Ss(!1),children:e})},uS=({children:e})=>{const t=y.useContext(xf),n=Yt("windowViewportRect"),r=Yt("itemDimensions"),o=ut("customScrollParent"),s=zd(n,o,!1);return y.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),c.jsx("div",{ref:s,style:Ss(!1),children:e})},dS=y.memo(function({...e}){const t=ut("useWindowScroll"),n=ut("customScrollParent"),r=n||t?hS:fS,o=n||t?uS:cS,s=ut("context");return c.jsx(r,{...e,...Et(r,s),children:c.jsxs(o,{children:[c.jsx(aS,{}),c.jsx(iS,{}),c.jsx(lS,{})]})})}),{useEmitter:_f,useEmitterValue:ut,usePublisher:Yt}=mf(sS,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},dS),fS=Cf({useEmitter:_f,useEmitterValue:ut,usePublisher:Yt}),hS=kf({useEmitter:_f,useEmitterValue:ut,usePublisher:Yt});function Mf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Dt.WARN),t==="normal"?0:parseInt(t??"0",10)}const pS=go.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 Rf({className:e,variant:t,...n}){return c.jsx("div",{className:re(pS({variant:t}),e),...n})}async function Pf(e,t){return await Vt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function Of(e,t){return await(await Pf(`/files/${e}/view`,t)).text()}async function mS(e,t){const n=await Pf(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Vt(`/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 gS(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Vt("/files",{params:r})}var Ts="Dialog",[Df,PT]=wn(Ts),[xS,on]=Df(Ts),Lf=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=m.useRef(null),l=m.useRef(null),[u,d]=ur({prop:r,defaultProp:o??!1,onChange:s,caller:Ts});return c.jsx(xS,{scope:t,triggerRef:a,contentRef:l,contentId:At(),titleId:At(),descriptionId:At(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Lf.displayName=Ts;var $f="DialogTrigger",Ff=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=on($f,n),s=We(t,o.triggerRef);return c.jsx(Ce.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ea(o.open),...r,ref:s,onClick:pe(e.onClick,o.onOpenToggle)})});Ff.displayName=$f;var ka="DialogPortal",[wS,Bf]=Df(ka,{forceMount:void 0}),zf=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=on(ka,t);return c.jsx(wS,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(Kt,{present:n||s.open,children:c.jsx(Xo,{asChild:!0,container:o,children:i})}))})};zf.displayName=ka;var Es="DialogOverlay",Hf=m.forwardRef((e,t)=>{const n=Bf(Es,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=on(Es,e.__scopeDialog);return s.modal?c.jsx(Kt,{present:r||s.open,children:c.jsx(bS,{...o,ref:t})}):null});Hf.displayName=Es;var vS=Ln.createSlot("DialogOverlay.RemoveScroll"),bS=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=on(Es,n);return c.jsx(ss,{as:vS,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Ce.div,{"data-state":Ea(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Xn="DialogContent",Uf=m.forwardRef((e,t)=>{const n=Bf(Xn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=on(Xn,e.__scopeDialog);return c.jsx(Kt,{present:r||s.open,children:s.modal?c.jsx(yS,{...o,ref:t}):c.jsx(SS,{...o,ref:t})})});Uf.displayName=Xn;var yS=m.forwardRef((e,t)=>{const n=on(Xn,e.__scopeDialog),r=m.useRef(null),o=We(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return Bi(s)},[]),c.jsx(Wf,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pe(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:pe(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault())})}),SS=m.forwardRef((e,t)=>{const n=on(Xn,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(Wf,{...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,u;(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;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Wf=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=on(Xn,n),l=m.useRef(null),u=We(t,l);return yi(),c.jsxs(c.Fragment,{children:[c.jsx($o,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Lo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ea(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(CS,{titleId:a.titleId}),c.jsx(TS,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ta="DialogTitle",Vf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=on(Ta,n);return c.jsx(Ce.h2,{id:o.titleId,...r,ref:t})});Vf.displayName=Ta;var Kf="DialogDescription",qf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=on(Kf,n);return c.jsx(Ce.p,{id:o.descriptionId,...r,ref:t})});qf.displayName=Kf;var Gf="DialogClose",Yf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=on(Gf,n);return c.jsx(Ce.button,{type:"button",...r,ref:t,onClick:pe(e.onClick,()=>o.onOpenChange(!1))})});Yf.displayName=Gf;function Ea(e){return e?"open":"closed"}var Xf="DialogTitleWarning",[OT,Jf]=Bx(Xf,{contentName:Xn,titleName:Ta,docsSlug:"dialog"}),CS=({titleId:e})=>{const t=Jf(Xf),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
79
+ `)},hb=0,vr=[];function mb(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(hb++)[0],s=h.useState(Uu)[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=Dw([e.lockRef.current],(e.shards||[]).map(Xu),!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=Jo(g),b=n.current,S="deltaX"in g?g.deltaX:b[0]-y[0],E="deltaY"in g?g.deltaY:b[1]-y[1],C,T=g.target,k=Math.abs(S)>Math.abs(E)?"h":"v";if("touches"in g&&k==="h"&&T.type==="range")return!1;var j=Ku(k,T);if(!j)return!0;if(j?C=k:(C=k==="v"?"h":"v",j=Ku(k,T)),!j)return!1;if(!r.current&&"changedTouches"in g&&(S||E)&&(r.current=C),!C)return!0;var D=r.current||C;return db(D,x,g,D==="h"?S:E)},[]),l=h.useCallback(function(g){var x=g;if(!(!vr.length||vr[vr.length-1]!==s)){var y="deltaY"in x?Yu(x):Jo(x),b=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&fb(C.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Xu).filter(Boolean).filter(function(C){return C.contains(x.target)}),E=S.length>0?a(x,S[0]):!i.current.noIsolation;E&&x.cancelable&&x.preventDefault()}}},[]),c=h.useCallback(function(g,x,y,b){var S={name:g,delta:x,target:y,should:b,shadowParent:gb(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(E){return E!==S})},1)},[]),d=h.useCallback(function(g){n.current=Jo(g),r.current=void 0},[]),p=h.useCallback(function(g){c(g.type,Yu(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){c(g.type,Jo(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return vr.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",l,xr),document.addEventListener("touchmove",l,xr),document.addEventListener("touchstart",d,xr),function(){vr=vr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,xr),document.removeEventListener("touchmove",l,xr),document.removeEventListener("touchstart",d,xr)}},[]);var f=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:pb(o)}):null,f?h.createElement(ob,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function gb(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const xb=Vw(Hu,mb);var Zo=h.forwardRef(function(e,t){return h.createElement(Yo,gn({},e,{ref:t,sideCar:xb}))});Zo.classNames=Yo.classNames;var vb=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},wr=new WeakMap,Qo=new WeakMap,es={},qi=0,Ju=function(e){return e&&(e.host||Ju(e.parentNode))},wb=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Ju(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})},bb=function(e,t,n,r){var o=wb(t,Array.isArray(e)?e:[e]);es[n]||(es[n]=new WeakMap);var s=es[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=(wr.get(m)||0)+1,x=(s.get(m)||0)+1;wr.set(m,g),s.set(m,x),i.push(m),g===1&&v&&Qo.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(),qi++,function(){i.forEach(function(p){var m=wr.get(p)-1,f=s.get(p)-1;wr.set(p,m),s.set(p,f),m||(Qo.has(p)||p.removeAttribute(r),Qo.delete(p)),f||p.removeAttribute(n)}),qi--,qi||(wr=new WeakMap,wr=new WeakMap,Qo=new WeakMap,es={})}},Gi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=vb(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),bb(r,o,n,"aria-hidden")):function(){return null}},ts="Dialog",[Zu,t1]=sn(ts),[yb,an]=Zu(ts),Qu=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]=jn({prop:r,defaultProp:o??!1,onChange:s,caller:ts});return u.jsx(yb,{scope:t,triggerRef:a,contentRef:l,contentId:At(),titleId:At(),descriptionId:At(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(p=>!p),[d]),modal:i,children:n})};Qu.displayName=ts;var ed="DialogTrigger",td=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(ed,n),s=ze(t,o.triggerRef);return u.jsx(ye.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ji(o.open),...r,ref:s,onClick:le(e.onClick,o.onOpenToggle)})});td.displayName=ed;var Yi="DialogPortal",[Sb,nd]=Zu(Yi,{forceMount:void 0}),rd=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=an(Yi,t);return u.jsx(Sb,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(Ft,{present:n||s.open,children:u.jsx(Gr,{asChild:!0,container:o,children:i})}))})};rd.displayName=Yi;var ns="DialogOverlay",od=h.forwardRef((e,t)=>{const n=nd(ns,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=an(ns,e.__scopeDialog);return s.modal?u.jsx(Ft,{present:r||s.open,children:u.jsx(Tb,{...o,ref:t})}):null});od.displayName=ns;var Cb=Vt.createSlot("DialogOverlay.RemoveScroll"),Tb=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(ns,n);return u.jsx(Zo,{as:Cb,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(ye.div,{"data-state":Ji(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Yn="DialogContent",sd=h.forwardRef((e,t)=>{const n=nd(Yn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=an(Yn,e.__scopeDialog);return u.jsx(Ft,{present:r||s.open,children:s.modal?u.jsx(Eb,{...o,ref:t}):u.jsx(kb,{...o,ref:t})})});sd.displayName=Yn;var Eb=h.forwardRef((e,t)=>{const n=an(Yn,e.__scopeDialog),r=h.useRef(null),o=ze(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return Gi(s)},[]),u.jsx(id,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:le(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:le(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:le(e.onFocusOutside,s=>s.preventDefault())})}),kb=h.forwardRef((e,t)=>{const n=an(Yn,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(id,{...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()}})}),id=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=an(Yn,n),l=h.useRef(null),c=ze(t,l);return Hi(),u.jsxs(u.Fragment,{children:[u.jsx(Vo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(mr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ji(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(Ib,{titleId:a.titleId}),u.jsx(Ab,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Xi="DialogTitle",ad=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(Xi,n);return u.jsx(ye.h2,{id:o.titleId,...r,ref:t})});ad.displayName=Xi;var ld="DialogDescription",cd=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(ld,n);return u.jsx(ye.p,{id:o.descriptionId,...r,ref:t})});cd.displayName=ld;var ud="DialogClose",dd=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(ud,n);return u.jsx(ye.button,{type:"button",...r,ref:t,onClick:le(e.onClick,()=>o.onOpenChange(!1))})});dd.displayName=ud;function Ji(e){return e?"open":"closed"}var fd="DialogTitleWarning",[n1,pd]=lw(fd,{contentName:Yn,titleName:Xi,docsSlug:"dialog"}),Ib=({titleId:e})=>{const t=pd(fd),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 m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},kS="DialogDescriptionWarning",TS=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Jf(kS).contentName}}.`;return m.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},Ia=Lf,ES=Ff,Na=zf,so=Hf,io=Uf,Jn=Vf,Is=qf,Zf=Yf;const Qf=Ia,IS=Na,eh=m.forwardRef(({className:e,...t},n)=>c.jsx(so,{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}));eh.displayName=so.displayName;const Aa=m.forwardRef(({className:e,children:t,...n},r)=>{const o=m.useMemo(()=>{let s=!1;function i(a){m.Children.forEach(a,l=>{if(s||!m.isValidElement(l))return;const u=l.type;if(u===Jn||(u==null?void 0:u.displayName)===Jn.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return c.jsxs(IS,{children:[c.jsx(eh,{}),c.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&&c.jsx(Jn,{className:"sr-only",children:"Dialog"}),t,c.jsxs(Zf,{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:[c.jsx(se.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Aa.displayName=io.displayName;const ja=({className:e,...t})=>c.jsx("div",{className:re("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});ja.displayName="DialogHeader";const _a=m.forwardRef(({className:e,...t},n)=>c.jsx(Jn,{ref:n,className:re("text-lg font-semibold leading-none tracking-tight",e),...t}));_a.displayName=Jn.displayName;const NS=m.forwardRef(({className:e,...t},n)=>c.jsx(Is,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));NS.displayName=Is.displayName;const AS=1,jS=1e6;let Ma=0;function _S(){return Ma=(Ma+1)%Number.MAX_SAFE_INTEGER,Ma.toString()}const Ra=new Map,th=e=>{if(Ra.has(e))return;const t=setTimeout(()=>{Ra.delete(e),ao({type:"REMOVE_TOAST",toastId:e})},jS);Ra.set(e,t)},MS=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,AS)};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?th(n):e.toasts.forEach(r=>{th(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)}}},Ns=[];let As={toasts:[]};function ao(e){As=MS(As,e),Ns.forEach(t=>{t(As)})}function RS({...e}){const t=_S(),n=o=>ao({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>ao({type:"DISMISS_TOAST",toastId:t});return ao({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Pa(){const[e,t]=m.useState(As);return m.useEffect(()=>(Ns.push(t),()=>{const n=Ns.indexOf(t);n>-1&&Ns.splice(n,1)}),[e]),{...e,toast:RS,dismiss:n=>ao({type:"DISMISS_TOAST",toastId:n})}}function PS({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=y.useState(!1),[a,l]=y.useState(null),[u,d]=y.useState(null),{toast:f}=Pa(),h=y.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const w=await Of(n);l(w)}catch(w){console.error("Failed to load file:",w),d(w instanceof Error?w.message:"Failed to load file")}finally{i(!1)}}},[n]);y.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await mS(n),f({title:"Download started",description:`Downloading ${r}`})}catch(w){console.error("Failed to download file:",w),f({title:"Download failed",description:String(w),variant:"destructive"})}},v=async()=>{if(n)try{const w=await Of(n),b=new Blob([w],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(w){console.error("Failed to open file externally:",w),f({title:"Failed to open file",description:String(w),variant:"destructive"})}},x=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(se.Loader,{className:"h-8 w-8 animate-spin mr-3"}),c.jsx("span",{children:"Loading file..."})]}):u?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),c.jsx("p",{className:"text-red-600 mb-4",children:u}),c.jsx(Ze,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?c.jsx("div",{className:"flex justify-center",children:c.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?c.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:c.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?c.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx(se.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),c.jsx("p",{className:"text-lg font-medium mb-2",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?c.jsx(se.Image,{className:"h-5 w-5"}):c.jsx(se.FileText,{className:"h-5 w-5"});return c.jsx(Qf,{open:e,onOpenChange:t,children:c.jsxs(Aa,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(ja,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[g(),c.jsxs("div",{children:[c.jsx(_a,{className:"text-left",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ze,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[c.jsx(se.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(Ze,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(se.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:x()})]})})}function nh(){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 Zn=nh();function OS(e){Zn=e}const rh=/[&<>"']/,DS=new RegExp(rh.source,"g"),oh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,LS=new RegExp(oh.source,"g"),$S={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},sh=e=>$S[e];function It(e,t){if(t){if(rh.test(e))return e.replace(DS,sh)}else if(oh.test(e))return e.replace(LS,sh);return e}const FS=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function ih(e){return e.replace(FS,(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 BS=/(^|[^\[])\^/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(BS,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const zS=/[^\w:]/g,HS=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function ah(e,t,n){if(e){let r;try{r=decodeURIComponent(ih(n)).replace(zS,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!HS.test(n)&&(n=KS(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const js={},US=/^[^:]+:\/*[^/]*$/,WS=/^([^:]+:)[\s\S]*$/,VS=/^([^:]+:\/*[^/]*)[\s\S]*$/;function KS(e,t){js[" "+e]||(US.test(e)?js[" "+e]=e+"/":js[" "+e]=Ms(e,"/",!0)),e=js[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(WS,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(VS,"$1")+t:e+t}const _s={exec:function(){}};function lh(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,u=i;for(;--u>=0&&a[u]==="\\";)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 Ms(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 qS(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 GS(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 ch(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function uh(e,t,n,r){const o=t.href,s=t.title?It(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:It(i)}}function YS(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},Nb="DialogDescriptionWarning",Ab=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${pd(Nb).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},Zi=Qu,_b=td,Qi=rd,Yr=od,Xr=sd,Xn=ad,rs=cd,hd=dd,Jr='[cmdk-group=""]',ea='[cmdk-group-items=""]',jb='[cmdk-group-heading=""]',md='[cmdk-item=""]',gd=`${md}:not([aria-disabled="true"])`,ta="cmdk-item-select",br="data-value",Pb=(e,t,n)=>aw(e,t,n),xd=h.createContext(void 0),Zr=()=>h.useContext(xd),vd=h.createContext(void 0),na=()=>h.useContext(vd),wd=h.createContext(void 0),bd=h.forwardRef((e,t)=>{let n=yr(()=>{var P,O;return{search:"",value:(O=(P=e.value)!=null?P:e.defaultValue)!=null?O:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=yr(()=>new Set),o=yr(()=>new Map),s=yr(()=>new Map),i=yr(()=>new Set),a=yd(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=At(),S=At(),E=At(),C=h.useRef(null),T=Ub();Jn(()=>{if(d!==void 0){let P=d.trim();n.current.value=P,k.emit()}},[d]),Jn(()=>{T(6,z)},[]);let k=h.useMemo(()=>({subscribe:P=>(i.current.add(P),()=>i.current.delete(P)),snapshot:()=>n.current,setState:(P,O,X)=>{var J,se,V,L;if(!Object.is(n.current[P],O)){if(n.current[P]=O,P==="search")K(),B(),T(1,W);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Z=document.getElementById(E);Z?Z.focus():(J=document.getElementById(b))==null||J.focus()}if(T(7,()=>{var Z;n.current.selectedItemId=(Z=_())==null?void 0:Z.id,k.emit()}),X||T(5,z),((se=a.current)==null?void 0:se.value)!==void 0){let Z=O??"";(L=(V=a.current).onValueChange)==null||L.call(V,Z);return}}k.emit()}},emit:()=>{i.current.forEach(P=>P())}}),[]),j=h.useMemo(()=>({value:(P,O,X)=>{var J;O!==((J=s.current.get(P))==null?void 0:J.value)&&(s.current.set(P,{value:O,keywords:X}),n.current.filtered.items.set(P,D(O,X)),T(2,()=>{B(),k.emit()}))},item:(P,O)=>(r.current.add(P),O&&(o.current.has(O)?o.current.get(O).add(P):o.current.set(O,new Set([P]))),T(3,()=>{K(),B(),n.current.value||W(),k.emit()}),()=>{s.current.delete(P),r.current.delete(P),n.current.filtered.items.delete(P);let X=_();T(4,()=>{K(),(X==null?void 0:X.getAttribute("id"))===P&&W(),k.emit()})}),group:P=>(o.current.has(P)||o.current.set(P,new Set),()=>{s.current.delete(P),o.current.delete(P)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:E,labelId:S,listInnerRef:C}),[]);function D(P,O){var X,J;let se=(J=(X=a.current)==null?void 0:X.filter)!=null?J:Pb;return P?se(P,n.current.search,O):0}function B(){if(!n.current.search||a.current.shouldFilter===!1)return;let P=n.current.filtered.items,O=[];n.current.filtered.groups.forEach(J=>{let se=o.current.get(J),V=0;se.forEach(L=>{let Z=P.get(L);V=Math.max(Z,V)}),O.push([J,V])});let X=C.current;Y().sort((J,se)=>{var V,L;let Z=J.getAttribute("id"),Q=se.getAttribute("id");return((V=P.get(Q))!=null?V:0)-((L=P.get(Z))!=null?L:0)}).forEach(J=>{let se=J.closest(ea);se?se.appendChild(J.parentElement===se?J:J.closest(`${ea} > *`)):X.appendChild(J.parentElement===X?J:J.closest(`${ea} > *`))}),O.sort((J,se)=>se[1]-J[1]).forEach(J=>{var se;let V=(se=C.current)==null?void 0:se.querySelector(`${Jr}[${br}="${encodeURIComponent(J[0])}"]`);V==null||V.parentElement.appendChild(V)})}function W(){let P=Y().find(X=>X.getAttribute("aria-disabled")!=="true"),O=P==null?void 0:P.getAttribute(br);k.setState("value",O||void 0)}function K(){var P,O,X,J;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let se=0;for(let V of r.current){let L=(O=(P=s.current.get(V))==null?void 0:P.value)!=null?O:"",Z=(J=(X=s.current.get(V))==null?void 0:X.keywords)!=null?J:[],Q=D(L,Z);n.current.filtered.items.set(V,Q),Q>0&&se++}for(let[V,L]of o.current)for(let Z of L)if(n.current.filtered.items.get(Z)>0){n.current.filtered.groups.add(V);break}n.current.filtered.count=se}function z(){var P,O,X;let J=_();J&&(((P=J.parentElement)==null?void 0:P.firstChild)===J&&((X=(O=J.closest(Jr))==null?void 0:O.querySelector(jb))==null||X.scrollIntoView({block:"nearest"})),J.scrollIntoView({block:"nearest"}))}function _(){var P;return(P=C.current)==null?void 0:P.querySelector(`${md}[aria-selected="true"]`)}function Y(){var P;return Array.from(((P=C.current)==null?void 0:P.querySelectorAll(gd))||[])}function N(P){let O=Y()[P];O&&k.setState("value",O.getAttribute(br))}function $(P){var O;let X=_(),J=Y(),se=J.findIndex(L=>L===X),V=J[se+P];(O=a.current)!=null&&O.loop&&(V=se+P<0?J[J.length-1]:se+P===J.length?J[0]:J[se+P]),V&&k.setState("value",V.getAttribute(br))}function R(P){let O=_(),X=O==null?void 0:O.closest(Jr),J;for(;X&&!J;)X=P>0?zb(X,Jr):Hb(X,Jr),J=X==null?void 0:X.querySelector(gd);J?k.setState("value",J.getAttribute(br)):$(P)}let I=()=>N(Y().length-1),H=P=>{P.preventDefault(),P.metaKey?I():P.altKey?R(1):$(1)},q=P=>{P.preventDefault(),P.metaKey?N(0):P.altKey?R(-1):$(-1)};return h.createElement(ye.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:P=>{var O;(O=y.onKeyDown)==null||O.call(y,P);let X=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||X))switch(P.key){case"n":case"j":{x&&P.ctrlKey&&H(P);break}case"ArrowDown":{H(P);break}case"p":case"k":{x&&P.ctrlKey&&q(P);break}case"ArrowUp":{q(P);break}case"Home":{P.preventDefault(),N(0);break}case"End":{P.preventDefault(),I();break}case"Enter":{P.preventDefault();let J=_();if(J){let se=new Event(ta);J.dispatchEvent(se)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:Vb},l),os(e,P=>h.createElement(vd.Provider,{value:k},h.createElement(xd.Provider,{value:j},P))))}),Mb=h.forwardRef((e,t)=>{var n,r;let o=At(),s=h.useRef(null),i=h.useContext(wd),a=Zr(),l=yd(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;Jn(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Sd(o,s,[e.value,e.children,s],e.keywords),p=na(),m=Mn(T=>T.value&&T.value===d.current),f=Mn(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(ta,v),()=>T.removeEventListener(ta,v)},[f,e.onSelect,e.disabled]);function v(){var T,k;g(),(k=(T=l.current).onSelect)==null||k.call(T,d.current)}function g(){p.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:b,forceMount:S,keywords:E,...C}=e;return h.createElement(ye.div,{ref:_n(s,t),...C,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)}),Rb=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=At(),a=h.useRef(null),l=h.useRef(null),c=At(),d=Zr(),p=Mn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);Jn(()=>d.group(i),[]),Sd(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(ye.div,{ref:_n(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),os(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(wd.Provider,{value:m},f))))}),Ob=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Mn(i=>!i.search);return!n&&!s?null:h.createElement(ye.div,{ref:_n(o,t),...r,"cmdk-separator":"",role:"separator"})}),Db=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=na(),i=Mn(c=>c.search),a=Mn(c=>c.selectedItemId),l=Zr();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(ye.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)}})}),Lb=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Mn(c=>c.selectedItemId),l=Zr();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(ye.div,{ref:_n(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},os(e,c=>h.createElement("div",{ref:_n(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),$b=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(Zi,{open:n,onOpenChange:r},h.createElement(Qi,{container:i},h.createElement(Yr,{"cmdk-overlay":"",className:o}),h.createElement(Xr,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(bd,{ref:t,...a}))))}),Fb=h.forwardRef((e,t)=>Mn(n=>n.filtered.count===0)?h.createElement(ye.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Bb=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(ye.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},os(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Bt=Object.assign(bd,{List:Lb,Item:Mb,Input:Db,Group:Rb,Separator:Ob,Dialog:$b,Empty:Fb,Loading:Bb});function zb(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Hb(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function yd(e){let t=h.useRef(e);return Jn(()=>{t.current=e}),t}var Jn=typeof window>"u"?h.useEffect:h.useLayoutEffect;function yr(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Mn(e){let t=na(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Sd(e,t,n,r=[]){let o=h.useRef(),s=Zr();return Jn(()=>{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(br,a),o.current=a}),o}var Ub=()=>{let[e,t]=h.useState(),n=yr(()=>new Map);return Jn(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function Wb(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function os({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(Wb(t),{ref:t.ref},n(t.props.children)):n(t)}var Vb={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const ra=Zi,Kb=Qi,Cd=h.forwardRef(({className:e,...t},n)=>u.jsx(Yr,{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}));Cd.displayName=Yr.displayName;const ss=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===Xn||(c==null?void 0:c.displayName)===Xn.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(Kb,{children:[u.jsx(Cd,{}),u.jsxs(Xr,{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(Xn,{className:"sr-only",children:"Dialog"}),t,u.jsxs(hd,{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(de.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});ss.displayName=Xr.displayName;const is=({className:e,...t})=>u.jsx("div",{className:re("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});is.displayName="DialogHeader";const as=h.forwardRef(({className:e,...t},n)=>u.jsx(Xn,{ref:n,className:re("text-lg font-semibold leading-none tracking-tight",e),...t}));as.displayName=Xn.displayName;const qb=h.forwardRef(({className:e,...t},n)=>u.jsx(rs,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));qb.displayName=rs.displayName;const oa=h.forwardRef(({className:e,...t},n)=>u.jsx(Bt,{ref:n,className:re("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));oa.displayName=Bt.displayName;const sa=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(de.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Bt.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})]}));sa.displayName=Bt.Input.displayName;const ia=h.forwardRef(({className:e,...t},n)=>u.jsx(Bt.List,{ref:n,className:re("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));ia.displayName=Bt.List.displayName;const aa=h.forwardRef((e,t)=>u.jsx(Bt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));aa.displayName=Bt.Empty.displayName;const la=h.forwardRef(({className:e,...t},n)=>u.jsx(Bt.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}));la.displayName=Bt.Group.displayName;const Gb=h.forwardRef(({className:e,...t},n)=>u.jsx(Bt.Separator,{ref:n,className:re("-mx-1 h-px bg-border",e),...t}));Gb.displayName=Bt.Separator.displayName;const ca=h.forwardRef(({className:e,...t},n)=>u.jsx(Bt.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}));ca.displayName=Bt.Item.displayName;function ls(e){const t=e+"CollectionProvider",[n,r]=sn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,b=w.useRef(null),S=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:S,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Vt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,S=s(a,y),E=ze(x,S.collectionRef);return u.jsx(l,{ref:E,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",p="data-radix-collection-item",m=Vt.createSlot(d),f=w.forwardRef((g,x)=>{const{scope:y,children:b,...S}=g,E=w.useRef(null),C=ze(x,E),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(E,{ref:E,...S}),()=>void T.itemMap.delete(E))),u.jsx(m,{[p]:"",ref:C,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 S=Array.from(b.querySelectorAll(`[${p}]`));return Array.from(x.itemMap.values()).sort((T,k)=>S.indexOf(T.ref.current)-S.indexOf(k.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var Yb=h.createContext(void 0);function cs(e){const t=h.useContext(Yb);return e||t||"ltr"}const Xb=["top","right","bottom","left"],Rn=Math.min,Gt=Math.max,us=Math.round,ds=Math.floor,xn=e=>({x:e,y:e}),Jb={left:"right",right:"left",bottom:"top",top:"bottom"},Zb={start:"end",end:"start"};function ua(e,t,n){return Gt(e,Rn(t,n))}function En(e,t){return typeof e=="function"?e(t):e}function kn(e){return e.split("-")[0]}function Sr(e){return e.split("-")[1]}function da(e){return e==="x"?"y":"x"}function fa(e){return e==="y"?"height":"width"}const Qb=new Set(["top","bottom"]);function vn(e){return Qb.has(kn(e))?"y":"x"}function pa(e){return da(vn(e))}function ey(e,t,n){n===void 0&&(n=!1);const r=Sr(e),o=pa(e),s=fa(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=fs(i)),[i,fs(i)]}function ty(e){const t=fs(e);return[ha(e),t,ha(t)]}function ha(e){return e.replace(/start|end/g,t=>Zb[t])}const Td=["left","right"],Ed=["right","left"],ny=["top","bottom"],ry=["bottom","top"];function oy(e,t,n){switch(e){case"top":case"bottom":return n?t?Ed:Td:t?Td:Ed;case"left":case"right":return t?ny:ry;default:return[]}}function sy(e,t,n,r){const o=Sr(e);let s=oy(kn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(ha)))),s}function fs(e){return e.replace(/left|right|bottom|top/g,t=>Jb[t])}function iy(e){return{top:0,right:0,bottom:0,left:0,...e}}function kd(e){return typeof e!="number"?iy(e):{top:e,right:e,bottom:e,left:e}}function ps(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 Id(e,t,n){let{reference:r,floating:o}=e;const s=vn(t),i=pa(t),a=fa(i),l=kn(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(Sr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const ay=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}=Id(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:S,data:E,reset:C}=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=S??p,f={...f,[x]:{...f[x],...E}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:p}=Id(c,m,l)),g=-1)}return{x:d,y:p,placement:m,strategy:o,middlewareData:f}};async function Qr(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}=En(t,e),v=kd(f),x=a[m?p==="floating"?"reference":"floating":p],y=ps(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,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=ps(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(y.top-C.top+v.top)/E.y,bottom:(C.bottom-y.bottom+v.bottom)/E.y,left:(y.left-C.left+v.left)/E.x,right:(C.right-y.right+v.right)/E.x}}const ly=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}=En(e,t)||{};if(c==null)return{};const p=kd(d),m={x:n,y:r},f=pa(o),v=fa(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",b=x?"bottom":"right",S=x?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[f]-m[f]-s.floating[v],C=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let k=T?T[S]:0;(!k||!await(i.isElement==null?void 0:i.isElement(T)))&&(k=a.floating[S]||s.floating[v]);const j=E/2-C/2,D=k/2-g[v]/2-1,B=Rn(p[y],D),W=Rn(p[b],D),K=B,z=k-g[v]-W,_=k/2-g[v]/2+j,Y=ua(K,_,z),N=!l.arrow&&Sr(o)!=null&&_!==Y&&s.reference[v]/2-(_<K?B:W)-g[v]/2<0,$=N?_<K?_-K:_-z:0;return{[f]:m[f]+$,data:{[f]:Y,centerOffset:_-Y-$,...N&&{alignmentOffset:$}},reset:N}}}),cy=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}=En(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=kn(o),b=vn(a),S=kn(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[fs(a)]:ty(a)),T=v!=="none";!m&&T&&C.push(...sy(a,g,v,E));const k=[a,...C],j=await Qr(t,x),D=[];let B=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&D.push(j[y]),p){const _=ey(o,i,E);D.push(j[_[0]],j[_[1]])}if(B=[...B,{placement:o,overflows:D}],!D.every(_=>_<=0)){var W,K;const _=(((W=s.flip)==null?void 0:W.index)||0)+1,Y=k[_];if(Y&&(!(p==="alignment"?b!==vn(Y):!1)||B.every(R=>vn(R.placement)===b?R.overflows[0]>0:!0)))return{data:{index:_,overflows:B},reset:{placement:Y}};let N=(K=B.filter($=>$.overflows[0]<=0).sort(($,R)=>$.overflows[1]-R.overflows[1])[0])==null?void 0:K.placement;if(!N)switch(f){case"bestFit":{var z;const $=(z=B.filter(R=>{if(T){const I=vn(R.placement);return I===b||I==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(I=>I>0).reduce((I,H)=>I+H,0)]).sort((R,I)=>R[1]-I[1])[0])==null?void 0:z[0];$&&(N=$);break}case"initialPlacement":N=a;break}if(o!==N)return{reset:{placement:N}}}return{}}}};function Nd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ad(e){return Xb.some(t=>e[t]>=0)}const uy=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=En(e,t);switch(r){case"referenceHidden":{const s=await Qr(t,{...o,elementContext:"reference"}),i=Nd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Ad(i)}}}case"escaped":{const s=await Qr(t,{...o,altBoundary:!0}),i=Nd(s,n.floating);return{data:{escapedOffsets:i,escaped:Ad(i)}}}default:return{}}}}},_d=new Set(["left","top"]);async function dy(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=kn(n),a=Sr(n),l=vn(n)==="y",c=_d.has(i)?-1:1,d=s&&l?-1:1,p=En(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 fy=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 dy(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}}}}},py=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}=En(e,t),c={x:n,y:r},d=await Qr(t,l),p=vn(kn(o)),m=da(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],S=f-d[y];f=ua(b,f,S)}if(i){const x=p==="y"?"top":"left",y=p==="y"?"bottom":"right",b=v+d[x],S=v-d[y];v=ua(b,v,S)}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}}}}}},hy=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}=En(e,t),d={x:n,y:r},p=vn(o),m=da(p);let f=d[m],v=d[p];const g=En(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const S=m==="y"?"height":"width",E=s.reference[m]-s.floating[S]+x.mainAxis,C=s.reference[m]+s.reference[S]-x.mainAxis;f<E?f=E:f>C&&(f=C)}if(c){var y,b;const S=m==="y"?"width":"height",E=_d.has(kn(o)),C=s.reference[p]-s.floating[S]+(E&&((y=i.offset)==null?void 0:y[p])||0)+(E?0:x.crossAxis),T=s.reference[p]+s.reference[S]+(E?0:((b=i.offset)==null?void 0:b[p])||0)-(E?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:f,[p]:v}}}},my=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}=En(e,t),d=await Qr(t,c),p=kn(o),m=Sr(o),f=vn(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,S=v-d.left-d.right,E=Rn(g-d[x],b),C=Rn(v-d[y],S),T=!t.middlewareData.shift;let k=E,j=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=b),T&&!m){const B=Gt(d.left,0),W=Gt(d.right,0),K=Gt(d.top,0),z=Gt(d.bottom,0);f?j=v-2*(B!==0||W!==0?B+W:Gt(d.left,d.right)):k=g-2*(K!==0||z!==0?K+z:Gt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:k});const D=await i.getDimensions(a.floating);return v!==D.width||g!==D.height?{reset:{rects:!0}}:{}}}};function hs(){return typeof window<"u"}function Cr(e){return jd(e)?(e.nodeName||"").toLowerCase():"#document"}function Yt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function wn(e){var t;return(t=(jd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function jd(e){return hs()?e instanceof Node||e instanceof Yt(e).Node:!1}function ln(e){return hs()?e instanceof Element||e instanceof Yt(e).Element:!1}function bn(e){return hs()?e instanceof HTMLElement||e instanceof Yt(e).HTMLElement:!1}function Pd(e){return!hs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Yt(e).ShadowRoot}const gy=new Set(["inline","contents"]);function eo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=cn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!gy.has(o)}const xy=new Set(["table","td","th"]);function vy(e){return xy.has(Cr(e))}const wy=[":popover-open",":modal"];function ms(e){return wy.some(t=>{try{return e.matches(t)}catch{return!1}})}const by=["transform","translate","scale","rotate","perspective"],yy=["transform","translate","scale","rotate","perspective","filter"],Sy=["paint","layout","strict","content"];function ma(e){const t=ga(),n=ln(e)?cn(e):e;return by.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)||yy.some(r=>(n.willChange||"").includes(r))||Sy.some(r=>(n.contain||"").includes(r))}function Cy(e){let t=On(e);for(;bn(t)&&!Tr(t);){if(ma(t))return t;if(ms(t))return null;t=On(t)}return null}function ga(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ty=new Set(["html","body","#document"]);function Tr(e){return Ty.has(Cr(e))}function cn(e){return Yt(e).getComputedStyle(e)}function gs(e){return ln(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function On(e){if(Cr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Pd(e)&&e.host||wn(e);return Pd(t)?t.host:t}function Md(e){const t=On(e);return Tr(t)?e.ownerDocument?e.ownerDocument.body:e.body:bn(t)&&eo(t)?t:Md(t)}function to(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Md(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Yt(o);if(s){const a=xa(i);return t.concat(i,i.visualViewport||[],eo(o)?o:[],a&&n?to(a):[])}return t.concat(o,to(o,[],n))}function xa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Rd(e){const t=cn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=bn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=us(n)!==s||us(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function va(e){return ln(e)?e:e.contextElement}function Er(e){const t=va(e);if(!bn(t))return xn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Rd(t);let i=(s?us(n.width):n.width)/r,a=(s?us(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Ey=xn(0);function Od(e){const t=Yt(e);return!ga()||!t.visualViewport?Ey:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ky(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Yt(e)?!1:t}function Zn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=va(e);let i=xn(1);t&&(r?ln(r)&&(i=Er(r)):i=Er(e));const a=ky(s,n,r)?Od(s):xn(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=Yt(s),f=r&&ln(r)?Yt(r):r;let v=m,g=xa(v);for(;g&&r&&f!==v;){const x=Er(g),y=g.getBoundingClientRect(),b=cn(g),S=y.left+(g.clientLeft+parseFloat(b.paddingLeft))*x.x,E=y.top+(g.clientTop+parseFloat(b.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,p*=x.y,l+=S,c+=E,v=Yt(g),g=xa(v)}}return ps({width:d,height:p,x:l,y:c})}function xs(e,t){const n=gs(e).scrollLeft;return t?t.left+n:Zn(wn(e)).left+n}function Dd(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-xs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Iy(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=wn(r),a=t?ms(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=xn(1);const d=xn(0),p=bn(r);if((p||!p&&!s)&&((Cr(r)!=="body"||eo(i))&&(l=gs(r)),bn(r))){const f=Zn(r);c=Er(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!p&&!s?Dd(i,l):xn(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 Ny(e){return Array.from(e.getClientRects())}function Ay(e){const t=wn(e),n=gs(e),r=e.ownerDocument.body,o=Gt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Gt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+xs(e);const a=-n.scrollTop;return cn(r).direction==="rtl"&&(i+=Gt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Ld=25;function _y(e,t){const n=Yt(e),r=wn(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=ga();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=xs(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<=Ld&&(s-=v)}else c<=Ld&&(s+=c);return{width:s,height:i,x:a,y:l}}const jy=new Set(["absolute","fixed"]);function Py(e,t){const n=Zn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=bn(e)?Er(e):xn(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 $d(e,t,n){let r;if(t==="viewport")r=_y(e,n);else if(t==="document")r=Ay(wn(e));else if(ln(t))r=Py(t,n);else{const o=Od(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ps(r)}function Fd(e,t){const n=On(e);return n===t||!ln(n)||Tr(n)?!1:cn(n).position==="fixed"||Fd(n,t)}function My(e,t){const n=t.get(e);if(n)return n;let r=to(e,[],!1).filter(a=>ln(a)&&Cr(a)!=="body"),o=null;const s=cn(e).position==="fixed";let i=s?On(e):e;for(;ln(i)&&!Tr(i);){const a=cn(i),l=ma(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&jy.has(o.position)||eo(i)&&!l&&Fd(e,i))?r=r.filter(d=>d!==i):o=a,i=On(i)}return t.set(e,r),r}function Ry(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ms(t)?[]:My(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const p=$d(t,d,o);return c.top=Gt(p.top,c.top),c.right=Rn(p.right,c.right),c.bottom=Rn(p.bottom,c.bottom),c.left=Gt(p.left,c.left),c},$d(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Oy(e){const{width:t,height:n}=Rd(e);return{width:t,height:n}}function Dy(e,t,n){const r=bn(t),o=wn(t),s=n==="fixed",i=Zn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=xn(0);function c(){l.x=xs(o)}if(r||!r&&!s)if((Cr(t)!=="body"||eo(o))&&(a=gs(t)),r){const f=Zn(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?Dd(o,a):xn(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 wa(e){return cn(e).position==="static"}function Bd(e,t){if(!bn(e)||cn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return wn(e)===n&&(n=n.ownerDocument.body),n}function zd(e,t){const n=Yt(e);if(ms(e))return n;if(!bn(e)){let o=On(e);for(;o&&!Tr(o);){if(ln(o)&&!wa(o))return o;o=On(o)}return n}let r=Bd(e,t);for(;r&&vy(r)&&wa(r);)r=Bd(r,t);return r&&Tr(r)&&wa(r)&&!ma(r)?n:r||Cy(e)||n}const Ly=async function(e){const t=this.getOffsetParent||zd,n=this.getDimensions,r=await n(e.floating);return{reference:Dy(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function $y(e){return cn(e).direction==="rtl"}const Fy={convertOffsetParentRelativeRectToViewportRelativeRect:Iy,getDocumentElement:wn,getClippingRect:Ry,getOffsetParent:zd,getElementRects:Ly,getClientRects:Ny,getDimensions:Oy,getScale:Er,isElement:ln,isRTL:$y};function Hd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function By(e,t){let n=null,r;const o=wn(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=ds(p),g=ds(o.clientWidth-(d+m)),x=ds(o.clientHeight-(p+f)),y=ds(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Gt(0,Rn(1,l))||1};let E=!0;function C(T){const k=T[0].intersectionRatio;if(k!==l){if(!E)return i();k?i(!1,k):r=setTimeout(()=>{i(!1,1e-7)},1e3)}k===1&&!Hd(c,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function zy(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=va(e),d=o||s?[...c?to(c):[],...to(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const p=c&&a?By(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 S;(S=f)==null||S.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?Zn(e):null;l&&x();function x(){const y=Zn(e);g&&!Hd(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 Hy=fy,Uy=py,Wy=cy,Vy=my,Ky=uy,Ud=ly,qy=hy,Gy=(e,t,n)=>{const r=new Map,o={platform:Fy,...n},s={...o.platform,_c:r};return ay(e,t,{...o,platform:s})};var Yy=typeof document<"u",Xy=function(){},vs=Yy?w.useLayoutEffect:Xy;function ws(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(!ws(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)&&!ws(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Wd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Vd(e,t){const n=Wd(e);return Math.round(t*n)/n}function ba(e){const t=h.useRef(e);return vs(()=>{t.current=e}),t}function Jy(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);ws(m,r)||f(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),b=h.useCallback(R=>{R!==T.current&&(T.current=R,g(R))},[]),S=h.useCallback(R=>{R!==k.current&&(k.current=R,y(R))},[]),E=s||v,C=i||x,T=h.useRef(null),k=h.useRef(null),j=h.useRef(d),D=l!=null,B=ba(l),W=ba(o),K=ba(c),z=h.useCallback(()=>{if(!T.current||!k.current)return;const R={placement:t,strategy:n,middleware:m};W.current&&(R.platform=W.current),Gy(T.current,k.current,R).then(I=>{const H={...I,isPositioned:K.current!==!1};_.current&&!ws(j.current,H)&&(j.current=H,Dr.flushSync(()=>{p(H)}))})},[m,t,n,W,K]);vs(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,p(R=>({...R,isPositioned:!1})))},[c]);const _=h.useRef(!1);vs(()=>(_.current=!0,()=>{_.current=!1}),[]),vs(()=>{if(E&&(T.current=E),C&&(k.current=C),E&&C){if(B.current)return B.current(E,C,z);z()}},[E,C,z,B,D]);const Y=h.useMemo(()=>({reference:T,floating:k,setReference:b,setFloating:S}),[b,S]),N=h.useMemo(()=>({reference:E,floating:C}),[E,C]),$=h.useMemo(()=>{const R={position:n,left:0,top:0};if(!N.floating)return R;const I=Vd(N.floating,d.x),H=Vd(N.floating,d.y);return a?{...R,transform:"translate("+I+"px, "+H+"px)",...Wd(N.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:H}},[n,a,N.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:z,refs:Y,elements:N,floatingStyles:$}),[d,z,Y,N,$])}const Zy=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?Ud({element:r.current,padding:o}).fn(n):{}:r?Ud({element:r,padding:o}).fn(n):{}}}},Qy=(e,t)=>({...Hy(e),options:[e,t]}),e0=(e,t)=>({...Uy(e),options:[e,t]}),t0=(e,t)=>({...qy(e),options:[e,t]}),n0=(e,t)=>({...Wy(e),options:[e,t]}),r0=(e,t)=>({...Vy(e),options:[e,t]}),o0=(e,t)=>({...Ky(e),options:[e,t]}),s0=(e,t)=>({...Zy(e),options:[e,t]});var i0="Arrow",Kd=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(ye.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"})})});Kd.displayName=i0;var a0=Kd;function qd(e){const[t,n]=h.useState(void 0);return kt(()=>{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 ya="Popper",[Gd,kr]=sn(ya),[l0,Yd]=Gd(ya),Xd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(l0,{scope:t,anchor:r,onAnchorChange:o,children:n})};Xd.displayName=ya;var Jd="PopperAnchor",Zd=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Yd(Jd,n),i=h.useRef(null),a=ze(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(ye.div,{...o,ref:a})});Zd.displayName=Jd;var Sa="PopperContent",[c0,u0]=Gd(Sa),Qd=h.forwardRef((e,t)=>{var V,L,Z,Q,ce,F;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=Yd(Sa,n),[y,b]=h.useState(null),S=ze(t,oe=>b(oe)),[E,C]=h.useState(null),T=qd(E),k=(T==null?void 0:T.width)??0,j=(T==null?void 0:T.height)??0,D=r+(s!=="center"?"-"+s:""),B=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},W=Array.isArray(c)?c:[c],K=W.length>0,z={padding:B,boundary:W.filter(f0),altBoundary:K},{refs:_,floatingStyles:Y,placement:N,isPositioned:$,middlewareData:R}=Jy({strategy:"fixed",placement:D,whileElementsMounted:(...oe)=>zy(...oe,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Qy({mainAxis:o+j,alignmentAxis:i}),l&&e0({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?t0():void 0,...z}),l&&n0({...z}),r0({...z,apply:({elements:oe,rects:we,availableWidth:fe,availableHeight:xe})=>{const{width:_e,height:$e}=we.reference,Ue=oe.floating.style;Ue.setProperty("--radix-popper-available-width",`${fe}px`),Ue.setProperty("--radix-popper-available-height",`${xe}px`),Ue.setProperty("--radix-popper-anchor-width",`${_e}px`),Ue.setProperty("--radix-popper-anchor-height",`${$e}px`)}}),E&&s0({element:E,padding:a}),p0({arrowWidth:k,arrowHeight:j}),m&&o0({strategy:"referenceHidden",...z})]}),[I,H]=nf(N),q=vt(v);kt(()=>{$&&(q==null||q())},[$,q]);const P=(V=R.arrow)==null?void 0:V.x,O=(L=R.arrow)==null?void 0:L.y,X=((Z=R.arrow)==null?void 0:Z.centerOffset)!==0,[J,se]=h.useState();return kt(()=>{y&&se(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:_.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:$?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(Q=R.transformOrigin)==null?void 0:Q.x,(ce=R.transformOrigin)==null?void 0:ce.y].join(" "),...((F=R.hide)==null?void 0:F.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(c0,{scope:n,placedSide:I,onArrowChange:C,arrowX:P,arrowY:O,shouldHideArrow:X,children:u.jsx(ye.div,{"data-side":I,"data-align":H,...g,ref:S,style:{...g.style,animation:$?void 0:"none"}})})})});Qd.displayName=Sa;var ef="PopperArrow",d0={top:"bottom",right:"left",bottom:"top",left:"right"},tf=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=u0(ef,r),i=d0[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(a0,{...o,ref:n,style:{...o.style,display:"block"}})})});tf.displayName=ef;function f0(e){return e!==null}var p0=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]=nf(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 nf(e){const[t,n="center"]=e.split("-");return[t,n]}var Ca=Xd,Ta=Zd,Ea=Qd,ka=tf,Ia="rovingFocusGroup.onEntryFocus",h0={bubbles:!1,cancelable:!0},no="RovingFocusGroup",[Na,rf,m0]=ls(no),[g0,of]=sn(no,[m0]),[x0,v0]=g0(no),sf=h.forwardRef((e,t)=>u.jsx(Na.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Na.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(w0,{...e,ref:t})})}));sf.displayName=no;var w0=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=ze(t,m),v=cs(s),[g,x]=jn({prop:i,defaultProp:a??null,onChange:l,caller:no}),[y,b]=h.useState(!1),S=vt(c),E=rf(n),C=h.useRef(!1),[T,k]=h.useState(0);return h.useEffect(()=>{const j=m.current;if(j)return j.addEventListener(Ia,S),()=>j.removeEventListener(Ia,S)},[S]),u.jsx(x0,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(j=>x(j),[x]),onItemShiftTab:h.useCallback(()=>b(!0),[]),onFocusableItemAdd:h.useCallback(()=>k(j=>j+1),[]),onFocusableItemRemove:h.useCallback(()=>k(j=>j-1),[]),children:u.jsx(ye.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:le(e.onMouseDown,()=>{C.current=!0}),onFocus:le(e.onFocus,j=>{const D=!C.current;if(j.target===j.currentTarget&&D&&!y){const B=new CustomEvent(Ia,h0);if(j.currentTarget.dispatchEvent(B),!B.defaultPrevented){const W=E().filter(N=>N.focusable),K=W.find(N=>N.active),z=W.find(N=>N.id===g),Y=[K,z,...W].filter(Boolean).map(N=>N.ref.current);cf(Y,d)}}C.current=!1}),onBlur:le(e.onBlur,()=>b(!1))})})}),af="RovingFocusGroupItem",lf=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=At(),c=s||l,d=v0(af,n),p=d.currentTabStopId===c,m=rf(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(Na.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(ye.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:le(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:le(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:le(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=S0(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=m().filter(E=>E.focusable).map(E=>E.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const E=S.indexOf(x.currentTarget);S=d.loop?C0(S,E+1):S.slice(E+1)}setTimeout(()=>cf(S))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});lf.displayName=af;var b0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function y0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function S0(e,t,n){const r=y0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return b0[r]}function cf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function C0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var T0=sf,E0=lf,Aa=["Enter"," "],k0=["ArrowDown","PageUp","Home"],uf=["ArrowUp","PageDown","End"],I0=[...k0,...uf],N0={ltr:[...Aa,"ArrowRight"],rtl:[...Aa,"ArrowLeft"]},A0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ro="Menu",[oo,_0,j0]=ls(ro),[Qn,df]=sn(ro,[j0,kr,of]),bs=kr(),ff=of(),[P0,er]=Qn(ro),[M0,so]=Qn(ro),pf=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=vt(s),m=cs(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(Ca,{...a,children:u.jsx(P0,{scope:t,open:n,onOpenChange:p,content:l,onContentChange:c,children:u.jsx(M0,{scope:t,onClose:h.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};pf.displayName=ro;var R0="MenuAnchor",_a=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(Ta,{...o,...r,ref:t})});_a.displayName=R0;var ja="MenuPortal",[O0,hf]=Qn(ja,{forceMount:void 0}),mf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=er(ja,t);return u.jsx(O0,{scope:t,forceMount:n,children:u.jsx(Ft,{present:n||s.open,children:u.jsx(Gr,{asChild:!0,container:o,children:r})})})};mf.displayName=ja;var Zt="MenuContent",[D0,Pa]=Qn(Zt),gf=h.forwardRef((e,t)=>{const n=hf(Zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=er(Zt,e.__scopeMenu),i=so(Zt,e.__scopeMenu);return u.jsx(oo.Provider,{scope:e.__scopeMenu,children:u.jsx(Ft,{present:r||s.open,children:u.jsx(oo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(L0,{...o,ref:t}):u.jsx($0,{...o,ref:t})})})})}),L0=h.forwardRef((e,t)=>{const n=er(Zt,e.__scopeMenu),r=h.useRef(null),o=ze(t,r);return h.useEffect(()=>{const s=r.current;if(s)return Gi(s)},[]),u.jsx(Ma,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:le(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),$0=h.forwardRef((e,t)=>{const n=er(Zt,e.__scopeMenu);return u.jsx(Ma,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),F0=Vt.createSlot("MenuContent.ScrollLock"),Ma=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=er(Zt,n),y=so(Zt,n),b=bs(n),S=ff(n),E=_0(n),[C,T]=h.useState(null),k=h.useRef(null),j=ze(t,k,x.onContentChange),D=h.useRef(0),B=h.useRef(""),W=h.useRef(0),K=h.useRef(null),z=h.useRef("right"),_=h.useRef(0),Y=v?Zo:h.Fragment,N=v?{as:F0,allowPinchZoom:!0}:void 0,$=I=>{var V,L;const H=B.current+I,q=E().filter(Z=>!Z.disabled),P=document.activeElement,O=(V=q.find(Z=>Z.ref.current===P))==null?void 0:V.textValue,X=q.map(Z=>Z.textValue),J=J0(X,H,O),se=(L=q.find(Z=>Z.textValue===J))==null?void 0:L.ref.current;(function Z(Q){B.current=Q,window.clearTimeout(D.current),Q!==""&&(D.current=window.setTimeout(()=>Z(""),1e3))})(H),se&&setTimeout(()=>se.focus())};h.useEffect(()=>()=>window.clearTimeout(D.current),[]),Hi();const R=h.useCallback(I=>{var q,P;return z.current===((q=K.current)==null?void 0:q.side)&&Q0(I,(P=K.current)==null?void 0:P.area)},[]);return u.jsx(D0,{scope:n,searchRef:B,onItemEnter:h.useCallback(I=>{R(I)&&I.preventDefault()},[R]),onItemLeave:h.useCallback(I=>{var H;R(I)||((H=k.current)==null||H.focus(),T(null))},[R]),onTriggerLeave:h.useCallback(I=>{R(I)&&I.preventDefault()},[R]),pointerGraceTimerRef:W,onPointerGraceIntentChange:h.useCallback(I=>{K.current=I},[]),children:u.jsx(Y,{...N,children:u.jsx(Vo,{asChild:!0,trapped:o,onMountAutoFocus:le(s,I=>{var H;I.preventDefault(),(H=k.current)==null||H.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(mr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,children:u.jsx(T0,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:le(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(Ea,{role:"menu","aria-orientation":"vertical","data-state":Mf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:j,style:{outline:"none",...g.style},onKeyDown:le(g.onKeyDown,I=>{const q=I.target.closest("[data-radix-menu-content]")===I.currentTarget,P=I.ctrlKey||I.altKey||I.metaKey,O=I.key.length===1;q&&(I.key==="Tab"&&I.preventDefault(),!P&&O&&$(I.key));const X=k.current;if(I.target!==X||!I0.includes(I.key))return;I.preventDefault();const se=E().filter(V=>!V.disabled).map(V=>V.ref.current);uf.includes(I.key)&&se.reverse(),Y0(se)}),onBlur:le(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(D.current),B.current="")}),onPointerMove:le(e.onPointerMove,ao(I=>{const H=I.target,q=_.current!==I.clientX;if(I.currentTarget.contains(H)&&q){const P=I.clientX>_.current?"right":"left";z.current=P,_.current=I.clientX}}))})})})})})})});gf.displayName=Zt;var B0="MenuGroup",Ra=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ye.div,{role:"group",...r,ref:t})});Ra.displayName=B0;var z0="MenuLabel",xf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ye.div,{...r,ref:t})});xf.displayName=z0;var ys="MenuItem",vf="menu.itemSelect",Ss=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=so(ys,e.__scopeMenu),a=Pa(ys,e.__scopeMenu),l=ze(t,s),c=h.useRef(!1),d=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(vf,{bubbles:!0,cancelable:!0});p.addEventListener(vf,f=>r==null?void 0:r(f),{once:!0}),Li(p,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(wf,{...o,ref:l,disabled:n,onClick:le(e.onClick,d),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),c.current=!0},onPointerUp:le(e.onPointerUp,p=>{var m;c.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:le(e.onKeyDown,p=>{const m=a.searchRef.current!=="";n||m&&p.key===" "||Aa.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Ss.displayName=ys;var wf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Pa(ys,n),a=ff(n),l=h.useRef(null),c=ze(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(oo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(E0,{asChild:!0,...a,focusable:!r,children:u.jsx(ye.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:le(e.onPointerMove,ao(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:le(e.onPointerLeave,ao(v=>i.onItemLeave(v))),onFocus:le(e.onFocus,()=>p(!0)),onBlur:le(e.onBlur,()=>p(!1))})})})}),H0="MenuCheckboxItem",bf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(Ef,{scope:e.__scopeMenu,checked:n,children:u.jsx(Ss,{role:"menuitemcheckbox","aria-checked":Cs(n)?"mixed":n,...o,ref:t,"data-state":Da(n),onSelect:le(o.onSelect,()=>r==null?void 0:r(Cs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});bf.displayName=H0;var yf="MenuRadioGroup",[U0,W0]=Qn(yf,{value:void 0,onValueChange:()=>{}}),Sf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=vt(r);return u.jsx(U0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ra,{...o,ref:t})})});Sf.displayName=yf;var Cf="MenuRadioItem",Tf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=W0(Cf,e.__scopeMenu),s=n===o.value;return u.jsx(Ef,{scope:e.__scopeMenu,checked:s,children:u.jsx(Ss,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Da(s),onSelect:le(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Tf.displayName=Cf;var Oa="MenuItemIndicator",[Ef,V0]=Qn(Oa,{checked:!1}),kf=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=V0(Oa,n);return u.jsx(Ft,{present:r||Cs(s.checked)||s.checked===!0,children:u.jsx(ye.span,{...o,ref:t,"data-state":Da(s.checked)})})});kf.displayName=Oa;var K0="MenuSeparator",If=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ye.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});If.displayName=K0;var q0="MenuArrow",Nf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(ka,{...o,...r,ref:t})});Nf.displayName=q0;var G0="MenuSub",[r1,Af]=Qn(G0),io="MenuSubTrigger",_f=h.forwardRef((e,t)=>{const n=er(io,e.__scopeMenu),r=so(io,e.__scopeMenu),o=Af(io,e.__scopeMenu),s=Pa(io,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(_a,{asChild:!0,...c,children:u.jsx(wf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Mf(n.open),...e,ref:_n(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:le(e.onPointerMove,ao(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:le(e.onPointerLeave,ao(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"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+y,y:p.clientY},{x:b,y:m.top},{x:S,y:m.top},{x:S,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:le(e.onKeyDown,p=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||N0[r.dir].includes(p.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),p.preventDefault())})})})});_f.displayName=io;var jf="MenuSubContent",Pf=h.forwardRef((e,t)=>{const n=hf(Zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=er(Zt,e.__scopeMenu),i=so(Zt,e.__scopeMenu),a=Af(jf,e.__scopeMenu),l=h.useRef(null),c=ze(t,l);return u.jsx(oo.Provider,{scope:e.__scopeMenu,children:u.jsx(Ft,{present:r||s.open,children:u.jsx(oo.Slot,{scope:e.__scopeMenu,children:u.jsx(Ma,{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:le(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:le(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:le(e.onKeyDown,d=>{var f;const p=d.currentTarget.contains(d.target),m=A0[i.dir].includes(d.key);p&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});Pf.displayName=jf;function Mf(e){return e?"open":"closed"}function Cs(e){return e==="indeterminate"}function Da(e){return Cs(e)?"indeterminate":e?"checked":"unchecked"}function Y0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function X0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function J0(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=X0(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 Q0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Z0(n,t)}function ao(e){return t=>t.pointerType==="mouse"?e(t):void 0}var eS=pf,tS=_a,nS=mf,rS=gf,oS=Ra,sS=xf,iS=Ss,aS=bf,lS=Sf,cS=Tf,uS=kf,dS=If,fS=Nf,pS=_f,hS=Pf,Ts="DropdownMenu",[mS,o1]=sn(Ts,[df]),Ot=df(),[gS,Rf]=mS(Ts),Of=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ot(t),c=h.useRef(null),[d,p]=jn({prop:o,defaultProp:s??!1,onChange:i,caller:Ts});return u.jsx(gS,{scope:t,triggerId:At(),triggerRef:c,contentId:At(),open:d,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(m=>!m),[p]),modal:a,children:u.jsx(eS,{...l,open:d,onOpenChange:p,dir:r,modal:a,children:n})})};Of.displayName=Ts;var Df="DropdownMenuTrigger",Lf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Rf(Df,n),i=Ot(n);return u.jsx(tS,{asChild:!0,...i,children:u.jsx(ye.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:_n(t,s.triggerRef),onPointerDown:le(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:le(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Lf.displayName=Df;var xS="DropdownMenuPortal",$f=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return u.jsx(nS,{...r,...n})};$f.displayName=xS;var Ff="DropdownMenuContent",Bf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rf(Ff,n),s=Ot(n),i=h.useRef(!1);return u.jsx(rS,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:le(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:le(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)"}})});Bf.displayName=Ff;var vS="DropdownMenuGroup",wS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(oS,{...o,...r,ref:t})});wS.displayName=vS;var bS="DropdownMenuLabel",zf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(sS,{...o,...r,ref:t})});zf.displayName=bS;var yS="DropdownMenuItem",Hf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(iS,{...o,...r,ref:t})});Hf.displayName=yS;var SS="DropdownMenuCheckboxItem",Uf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(aS,{...o,...r,ref:t})});Uf.displayName=SS;var CS="DropdownMenuRadioGroup",TS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(lS,{...o,...r,ref:t})});TS.displayName=CS;var ES="DropdownMenuRadioItem",Wf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(cS,{...o,...r,ref:t})});Wf.displayName=ES;var kS="DropdownMenuItemIndicator",Vf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(uS,{...o,...r,ref:t})});Vf.displayName=kS;var IS="DropdownMenuSeparator",Kf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(dS,{...o,...r,ref:t})});Kf.displayName=IS;var NS="DropdownMenuArrow",AS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(fS,{...o,...r,ref:t})});AS.displayName=NS;var _S="DropdownMenuSubTrigger",qf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(pS,{...o,...r,ref:t})});qf.displayName=_S;var jS="DropdownMenuSubContent",Gf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(hS,{...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)"}})});Gf.displayName=jS;var PS=Of,MS=Lf,RS=$f,Yf=Bf,Xf=zf,Jf=Hf,Zf=Uf,Qf=Wf,ep=Vf,tp=Kf,np=qf,rp=Gf;const Es=PS,ks=MS,OS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(np,{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(de.ChevronRight,{className:"ml-auto h-4 w-4"})]}));OS.displayName=np.displayName;const DS=h.forwardRef(({className:e,...t},n)=>u.jsx(rp,{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}));DS.displayName=rp.displayName;const lo=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(RS,{children:u.jsx(Yf,{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})}));lo.displayName=Yf.displayName;const Dn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Jf,{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}));Dn.displayName=Jf.displayName;const LS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Zf,{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(ep,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),t]}));LS.displayName=Zf.displayName;const $S=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Qf,{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(ep,{children:u.jsx(de.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));$S.displayName=Qf.displayName;const FS=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Xf,{ref:r,className:re("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));FS.displayName=Xf.displayName;const BS=h.forwardRef(({className:e,...t},n)=>u.jsx(tp,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));BS.displayName=tp.displayName;function La(e,[t,n]){return Math.min(n,Math.max(t,e))}function zS(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var $a="ScrollArea",[op,s1]=sn($a),[HS,Qt]=op($a),sp=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),[S,E]=h.useState(0),[C,T]=h.useState(!1),[k,j]=h.useState(!1),D=ze(t,W=>l(W)),B=cs(o);return u.jsx(HS,{scope:n,type:r,dir:B,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:p,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:k,onScrollbarYEnabledChange:j,onCornerWidthChange:b,onCornerHeightChange:E,children:u.jsx(ye.div,{dir:B,...i,ref:D,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});sp.displayName=$a;var ip="ScrollAreaViewport",ap=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Qt(ip,n),a=h.useRef(null),l=ze(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(ye.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})})]})});ap.displayName=ip;var yn="ScrollAreaScrollbar",Fa=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(yn,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(US,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(WS,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(lp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Ba,{...r,ref:t}):null});Fa.displayName=yn;var US=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(yn,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(Ft,{present:n||s,children:u.jsx(lp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),WS=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(yn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=_s(()=>l("SCROLL_END"),100),[a,l]=zS("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(Ft,{present:n||a!=="hidden",children:u.jsx(Ba,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:le(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:le(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),lp=h.forwardRef((e,t)=>{const n=Qt(yn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=_s(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Ir(n.viewport,l),Ir(n.content,l),u.jsx(Ft,{present:r||s,children:u.jsx(Ba,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ba=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Qt(yn,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=pp(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 XS(m,i.current,a,f)}return n==="horizontal"?u.jsx(VS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=hp(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(KS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=hp(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}),VS=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Qt(yn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=ze(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(up,{"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":As(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),gp(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:Ns(i.paddingLeft),paddingEnd:Ns(i.paddingRight)}})}})}),KS=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Qt(yn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=ze(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(up,{"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":As(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),gp(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:Ns(i.paddingTop),paddingEnd:Ns(i.paddingBottom)}})}})}),[qS,cp]=op(yn),up=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=Qt(yn,n),[v,g]=h.useState(null),x=ze(t,D=>g(D)),y=h.useRef(null),b=h.useRef(""),S=f.viewport,E=r.content-r.viewport,C=vt(d),T=vt(l),k=_s(p,10);function j(D){if(y.current){const B=D.clientX-y.current.left,W=D.clientY-y.current.top;c({x:B,y:W})}}return h.useEffect(()=>{const D=B=>{const W=B.target;(v==null?void 0:v.contains(W))&&C(B,E)};return document.addEventListener("wheel",D,{passive:!1}),()=>document.removeEventListener("wheel",D,{passive:!1})},[S,v,E,C]),h.useEffect(T,[r,T]),Ir(v,k),Ir(f.content,k),u.jsx(qS,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:vt(s),onThumbPointerUp:vt(i),onThumbPositionChange:T,onThumbPointerDown:vt(a),children:u.jsx(ye.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:le(e.onPointerDown,D=>{D.button===0&&(D.target.setPointerCapture(D.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),j(D))}),onPointerMove:le(e.onPointerMove,j),onPointerUp:le(e.onPointerUp,D=>{const B=D.target;B.hasPointerCapture(D.pointerId)&&B.releasePointerCapture(D.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Is="ScrollAreaThumb",dp=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=cp(Is,e.__scopeScrollArea);return u.jsx(Ft,{present:n||o.hasThumb,children:u.jsx(GS,{ref:t,...r})})}),GS=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Qt(Is,n),i=cp(Is,n),{onThumbPositionChange:a}=i,l=ze(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=_s(()=>{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=JS(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(ye.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:le(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:le(e.onPointerUp,i.onThumbPointerUp)})});dp.displayName=Is;var za="ScrollAreaCorner",fp=h.forwardRef((e,t)=>{const n=Qt(za,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(YS,{...e,ref:t}):null});fp.displayName=za;var YS=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Qt(za,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Ir(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Ir(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(ye.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 Ns(e){return e?parseInt(e,10):0}function pp(e,t){const n=e/t;return isNaN(n)?0:n}function As(e){const t=pp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function XS(e,t,n,r="ltr"){const o=As(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 mp([l,c],p)(e)}function hp(e,t,n="ltr"){const r=As(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=La(e,l);return mp([0,i],[0,a])(c)}function mp(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 gp(e,t){return e>0&&e<t}var JS=(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 _s(e,t){const n=vt(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 Ir(e,t){const n=vt(t);kt(()=>{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 xp=sp,ZS=ap,QS=fp;const Ha=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(xp,{ref:r,className:re("relative overflow-hidden",e),...n,children:[u.jsx(ZS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(vp,{}),u.jsx(QS,{})]}));Ha.displayName=xp.displayName;const vp=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Fa,{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(dp,{className:"relative flex-1 rounded-full bg-border"})}));vp.displayName=Fa.displayName;const Ua=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}));Ua.displayName="Input";const eC="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",tC="bg-slate-700 border-slate-600 hover:bg-slate-600",nC="bg-slate-600 border-slate-500";function rC({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,S=t?`${y??nC}`:`${x??tC}`,E=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:E,className:`${eC} ${S}`,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:C=>C.stopPropagation(),children:[u.jsx(Ua,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(de.Check,{size:12})}),u.jsx(ut,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(de.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(de.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(Es,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(ut,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(de.MoreHorizontal,{size:12})})}),u.jsxs(lo,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Dn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(de.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(Dn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(de.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Dn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(de.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 wp=25,bp="thread-manager-view",oC=e=>e==="default"||e==="shared",sC=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(bp);if(oC(e))return e}catch{}return null};function yp({defaultView:e}={}){const[t,n]=w.useState(()=>sC()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(bp,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const iC=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function Wa({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:S}){const{threads:E,sharedThreads:C,currentThreadId:T,setCurrentThreadId:k,isLoading:j,isLoadingSharedThreads:D,actions:B,shareInFlight:W,shareStatus:K,clearShareStatus:z}=Uo(),{createThread:_,deleteThread:Y,renameThread:N,shareThread:$}=B,{loadThread:R}=Wo(),I=i??T,[H,q]=w.useState(Array.isArray(E)?E:[]),P=w.useRef(H.length>0),O=w.useRef(null),X=w.useRef(0),[J,se]=w.useState(null),[V,L]=w.useState(""),[Z,Q]=w.useState(!1),[ce,F]=w.useState(!1),[oe,we]=w.useState(null),[fe,xe]=w.useState(""),_e=v&&v.length>0?v:iC,$e=yp({defaultView:m}),Ue=g??$e,Ne=p??Ue.view,Oe=w.useCallback(M=>{p||Ue.setView(M),f==null||f(M)},[p,f,Ue]),Ye=_e.find(M=>M.key===Ne)??_e[0],We=M=>{we(M),xe(""),F(!0)},Je=()=>{F(!1),we(null),xe(""),z()},ot=w.useCallback(async M=>{if(!(!oe||W)&&M.id)try{await $(oe,M.id),setTimeout(()=>Je(),600)}catch(ee){console.error("Failed to share thread:",ee)}},[Je,W,oe,$]),nt=w.useMemo(()=>{const M=y??[],ee=fe.trim().toLowerCase();return ee?S?M.filter(ve=>S(ve,ee)):M.filter(ve=>`${ve.label} ${ve.secondaryLabel??""}`.toLowerCase().includes(ee)):M},[y,fe,S]),Ze=Ne==="shared",Ae=Ze?C:H,Be=Ze?D:j,et=Ze?"No shared conversations yet":"No conversations yet",ct=M=>{const ee=M.sharedAt?` • ${ht(M.sharedAt)}`:"";return`Shared by ${M.sharedByUserId}${ee}`},Et=M=>"sharedByUserId"in M;w.useEffect(()=>{const M=Array.isArray(E)?E:[];if(M.length>0){P.current=!0,q(M);return}j||(P.current=!1,q(M))},[E,j]),w.useEffect(()=>{if(!O.current)return;const M=O.current.querySelector("[data-radix-scroll-area-viewport]");if(!M)return;let ee=null,ve=null;return ee=requestAnimationFrame(()=>{ve=requestAnimationFrame(()=>{M.scrollTop=X.current})}),()=>{ee!==null&&cancelAnimationFrame(ee),ve!==null&&cancelAnimationFrame(ve)}},[H]);const st=async M=>{try{k(M),await R(M),a==null||a(M),l==null||l(M)}catch(ee){console.error("Failed to select thread:",ee)}},Ve=async()=>{try{Q(!0);const M=await _();M&&(c==null||c(M),a==null||a(M))}catch(M){console.error("Failed to create thread:",M)}finally{Q(!1)}},It=async(M,ee)=>{if(ee.stopPropagation(),!!confirm("Delete this thread?")){if(O.current){const ve=O.current.querySelector("[data-radix-scroll-area-viewport]");ve&&(X.current=ve.scrollTop)}try{await Y(M),d==null||d(M)}catch(ve){console.error("Failed to delete thread:",ve)}}},De=(M,ee)=>{ee.stopPropagation(),se(M.threadId),L(M.title||`Thread ${M.threadId.slice(0,8)}`)},Ke=async M=>{if(V.trim())try{await N(M,V.trim()),se(null),L("")}catch(ee){console.error("Failed to update title:",ee)}},yt=()=>{se(null),L("")},ht=M=>{if(!M)return"";try{const ee=new Date(M),ae=new Date().getTime()-ee.getTime(),ke=Math.floor(ae/(1e3*60*60*24));return ke===0?ee.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ke===1?"Yesterday":ke<7?`${ke} days ago`:ee.toLocaleDateString()}catch{return""}},qe=M=>M.title||`Thread ${M.threadId.slice(0,8)}`,gt=M=>{const ee=qe(M);return ee.length<=wp?ee:`${ee.slice(0,wp)}...`};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(ut,{onClick:Ve,disabled:Z||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:Z?"Creating...":"New Chat",children:[u.jsx(de.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(Es,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(ut,{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:Ye.label})}),u.jsx(lo,{align:"start",sideOffset:6,className:"w-40",children:_e.map(M=>u.jsxs(Dn,{className:"justify-between text-[12px]",onClick:ee=>{ee.preventDefault(),Oe(M.key)},children:[u.jsx("span",{children:M.label}),Ne===M.key&&u.jsx(de.Check,{className:"h-3 w-3"})]},M.key))})]})]})]}),u.jsx(Ha,{ref:O,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:Be?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(de.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):Ae.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(de.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})]}):Ae.slice().sort((M,ee)=>new Date(ee.updatedAt||ee.createdAt||"").getTime()-new Date(M.updatedAt||M.createdAt||"").getTime()).map(M=>u.jsx(rC,{thread:M,isActive:I===M.threadId,editingThreadId:J,editingTitle:V,onSelect:st,onStartEditing:De,onEditingTitleChange:ee=>L(ee),onSaveEditing:Ke,onCancelEditing:yt,onShare:()=>We(M.threadId),onDelete:It,showEditTitle:r,showDeleteButton:n,formatDate:ht,getDisplayThreadTitle:gt,secondaryLine:Ze&&Et(M)?ct(M):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},M.threadId))})}),u.jsx(ra,{open:ce,onOpenChange:M=>!M&&Je(),children:u.jsxs(ss,{className:"max-w-md p-0",children:[u.jsx(is,{children:u.jsx(as,{children:"Share thread"})}),u.jsxs(oa,{children:[u.jsx(sa,{autoFocus:!0,value:fe,onValueChange:M=>xe(M),placeholder:"Search for recipients..."}),u.jsxs(ia,{children:[K&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[W&&u.jsx(de.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:K.startsWith("Failed")?"text-red-500":K.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:K})]}),u.jsx(aa,{children:b?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),nt.length>0&&u.jsx(la,{heading:"Recipients",children:nt.map(M=>u.jsx(ca,{onSelect:()=>ot(M),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:M.label}),M.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:M.secondaryLabel})]})},M.id))})]})]})]})})]})}const Va=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}));Va.displayName="Textarea";const aC=1e4;function Sp({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=aC,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:p="",textareaClassName:m="",allowEmptySend:f=!1,validate:v,onValidationError:g}){const x=i!==void 0,[y,b]=w.useState(e),S=(x?i:y)??"",[E,C]=w.useTransition(),T=w.useRef(null),k=w.useRef(0),j=w.useRef(null),D=w.useRef("");w.useEffect(()=>{x||(b(e??""),j.current=null,T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`))},[e,t,x]);const[B,W]=w.useState(null),K=w.useCallback(O=>O.length>s?`Message too long (${O.length}/${s} characters)`:null,[s]),z=w.useMemo(()=>v??K,[v,K]),_=w.useCallback(O=>{const X=z(O);return W(X),g==null||g(X),D.current=O,X},[z,g]),Y=w.useCallback(()=>{const O=T.current;O&&(O.style.height="auto",O.style.height=`${O.scrollHeight}px`)},[]);w.useEffect(()=>{Y()},[Y,S]),w.useEffect(()=>{if(!B)return;const O=(S??"").trim();D.current!==O&&_(O)},[S,B,_]);const N=w.useCallback((O,{fromUser:X})=>{x||b(O),X&&(a==null||a(O))},[x,a]),$=w.useCallback(async O=>{O&&O.preventDefault();const X=(S??"").trim();if(!X&&!f||_(X))return;const J=++k.current;j.current={id:J,shouldClear:!0},C(()=>{var se,V,L;try{const Z=l(X);Z&&typeof Z.then=="function"?Z.then(()=>{var Q,ce;((Q=j.current)==null?void 0:Q.id)===J&&j.current.shouldClear&&(x||(b(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((ce=j.current)==null?void 0:ce.id)===J&&(j.current=null)}).catch(()=>{var Q;((Q=j.current)==null?void 0:Q.id)===J&&(j.current=null)}):(((se=j.current)==null?void 0:se.id)===J&&j.current.shouldClear&&(x||(b(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((V=j.current)==null?void 0:V.id)===J&&(j.current=null))}catch{((L=j.current)==null?void 0:L.id)===J&&(j.current=null)}})},[S,l,f,x,a,_]),R=w.useCallback(O=>{const X=O.target.value;N(X,{fromUser:!0}),j.current&&(j.current.shouldClear=!1),T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`),B&&_(X.trim())},[N,_,B]),I=w.useCallback(O=>{O.key==="Enter"&&!O.shiftKey?(O.preventDefault(),$()):O.key==="Escape"&&t&&(O.preventDefault(),c==null||c())},[$,t,c]),P=`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:O=>void $(O),className:`w-full ${p}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Va,{ref:T,value:S,onChange:R,onKeyDown:I,placeholder:t?"Edit your message...":n,className:P,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),B&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:B})]}),u.jsx("div",{children:r?u.jsx(ut,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(de.Square,{size:16})}):u.jsx(ut,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!f||E,children:u.jsx(de.Send,{size:16})})})]})})}const lC=w.memo(Sp),js=0,Ln=1,Nr=2,Cp=4;function Tp(e){return()=>e}function cC(e){e()}function Ep(e,t){return n=>e(t(n))}function kp(e,t){return()=>e(t)}function uC(e,t){return n=>e(t,n)}function Ka(e){return e!==void 0}function dC(...e){return()=>{e.map(cC)}}function Ar(){}function Ps(e,t){return t(e),e}function fC(e,t){return t(e)}function dt(...e){return e}function rt(e,t){return e(Ln,t)}function Fe(e,t){e(js,t)}function qa(e){e(Nr)}function wt(e){return e(Cp)}function Se(e,t){return rt(e,uC(t,js))}function un(e,t){const n=e(Ln,r=>{n(),t(r)});return n}function Ip(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Np(e,t){return e===t}function ft(e=Np){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Me(e){return t=>n=>{e(n)&&t(n)}}function me(e){return t=>Ep(t,e)}function Sn(e){return t=>()=>{t(e)}}function te(e,...t){const n=pC(...t);return(r,o)=>{switch(r){case Nr:qa(e);return;case Ln:return rt(e,n(o))}}}function Cn(e,t){return n=>r=>{n(t=e(t,r))}}function tr(e){return t=>n=>{e>0?e--:t(n)}}function In(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function He(...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);rt(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 pC(...e){return t=>e.reduceRight(fC,t)}function hC(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Ln:return s?n===s?void 0:(r(),n=s,t=rt(e,s),t):(r(),Ar);case Nr:r(),n=null;return}}}function ie(e){let t=e;const n=Xe();return(r,o)=>{switch(r){case js:t=o;break;case Ln:{o(t);break}case Cp:return t}return n(r,o)}}function _t(e,t){return Ps(ie(t),n=>Se(e,n))}function Xe(){const e=[];return(t,n)=>{switch(t){case js:e.slice().forEach(r=>{r(n)});return;case Nr:e.splice(0,e.length);return;case Ln:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Xt(e){return Ps(Xe(),t=>Se(e,t))}function Qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:mC(),singleton:n}}const mC=()=>Symbol();function gC(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 bt(...e){const t=Xe(),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);rt(s,l=>{n[i]=l,r=r|a,r===o&&Fe(t,n)})}),function(s,i){switch(s){case Nr:{qa(t);return}case Ln:return r===o&&i(n),rt(t,i)}}}function je(e,t=Np){return te(e,ft(t))}function Ga(...e){return function(t,n){switch(t){case Nr:return;case Ln:return dC(...e.map(r=>rt(r,n)))}}}var zt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(zt||{});const xC={0:"debug",3:"error",1:"log",2:"warn"},vC=()=>typeof globalThis>"u"?window:globalThis,$n=Qe(()=>{const e=ie(3);return{log:ie((t,n,r=1)=>{var o;const s=(o=vC().VIRTUOSO_LOG_LEVEL)!=null?o:wt(e);r>=s&&console[xC[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function nr(e,t,n){return Ya(e,t,n).callbackRef}function Ya(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 wC(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const p=bC(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?Ap("column-gap",getComputedStyle(d).columnGap,o):Ap("row-gap",getComputedStyle(d).rowGap,o)),p!==null&&e(p)},[e,t,o,s,i,r,a]);return Ya(c,n,l)}function bC(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},zt.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 Ap(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,zt.WARN),t==="normal"?0:parseInt(t??"0",10)}function _p(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}=Ya(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 Dt=Qe(()=>{const e=Xe(),t=Xe(),n=ie(0),r=Xe(),o=ie(0),s=Xe(),i=Xe(),a=ie(0),l=ie(0),c=ie(0),d=ie(0),p=Xe(),m=Xe(),f=ie(!1),v=ie(!1),g=ie(!1);return Se(te(e,me(({scrollTop:x})=>x)),t),Se(te(e,me(({scrollHeight:x})=>x)),i),Se(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}),co={lvl:0};function jp(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 at(e){return e===co}function uo(e,t){if(!at(e))return t===e.k?e.v:t<e.k?uo(e.l,t):uo(e.r,t)}function dn(e,t,n="k"){if(at(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=dn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return dn(e.l,t,n)}function Jt(e,t,n){return at(e)?Rp(t,n,1):t===e.k?Tt(e,{k:t,v:n}):t<e.k?Op(Tt(e,{l:Jt(e.l,t,n)})):Op(Tt(e,{r:Jt(e.r,t,n)}))}function _r(){return co}function Ms(e,t,n){if(at(e))return[];const r=dn(e,t)[0];return yC(Ja(e,r,n))}function Xa(e,t){if(at(e))return co;const{k:n,l:r,r:o}=e;if(t===n){if(at(r))return o;if(at(o))return r;{const[s,i]=Mp(r);return Rs(Tt(e,{k:s,l:Pp(r),v:i}))}}else return t<n?Rs(Tt(e,{l:Xa(r,t)})):Rs(Tt(e,{r:Xa(o,t)}))}function rr(e){return at(e)?[]:[...rr(e.l),{k:e.k,v:e.v},...rr(e.r)]}function Ja(e,t,n){if(at(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Ja(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Ja(s,t,n))),a}function Rs(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(Za(t))return Dp(Tt(e,{lvl:n-1}));if(!at(t)&&!at(t.r))return Tt(t.r,{l:Tt(t,{r:t.r.l}),lvl:n,r:Tt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Za(e))return Qa(Tt(e,{lvl:n-1}));if(!at(r)&&!at(r.l)){const o=r.l,s=Za(o)?r.lvl-1:r.lvl;return Tt(o,{l:Tt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Qa(Tt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Tt(e,t){return Rp(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 Pp(e){return at(e.r)?e.l:Rs(Tt(e,{r:Pp(e.r)}))}function Za(e){return at(e)||e.lvl>e.r.lvl}function Mp(e){return at(e.r)?[e.k,e.v]:Mp(e.r)}function Rp(e,t,n,r=co,o=co){return{k:e,l:r,lvl:n,r:o,v:t}}function Op(e){return Qa(Dp(e))}function Dp(e){const{l:t}=e;return!at(t)&&t.lvl===e.lvl?Tt(t,{r:Tt(e,{l:t.r})}):e}function Qa(e){const{lvl:t,r:n}=e;return!at(n)&&!at(n.r)&&n.lvl===t&&n.r.lvl===t?Tt(n,{l:Tt(e,{r:n.l}),lvl:t+1}):e}function yC(e){return jp(e,({k:t,v:n})=>({index:t,value:n}))}function Lp(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function fo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const el=Qe(()=>({recalcInProgress:ie(!1)}),[],{singleton:!0});function $p(e,t,n){return e[Os(e,t,n)]}function Os(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 SC(e,t,n,r){const o=Os(e,t,r),s=Os(e,n,r,o);return e.slice(o,s+1)}function Fn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Ds(e){return!at(e.groupOffsetTree)}function tl({index:e},t){return t===e?0:t<e?-1:1}function CC(){return{groupIndices:[],groupOffsetTree:_r(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:_r()}}function TC(e,t){let n=at(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),at(e)){e=Jt(e,0,s);continue}const a=Ms(e,i-1,o+1);if(a.some(jC(r)))continue;let l=!1,c=!1;for(const{end:d,start:p,value:m}of a)l?(o>=p||s===m)&&(e=Xa(e,p)):(c=m!==s,l=!0),d>o&&o>=p&&m!==s&&(e=Jt(e,o+1,m));c&&(e=Jt(e,i,s))}return[e,n]}function EC(e){return typeof e.groupIndex<"u"}function kC({offset:e},t){return t===e?0:t<e?-1:1}function po(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=$p(t,e,tl),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Fp(e,t){if(!Ds(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Bp(e,t,n){if(EC(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Fp(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function IC(e,t,n,r=0){return r>0&&(t=Math.max(t,$p(e,r,tl).offset)),jp(SC(e,t,n,kC),_C)}function NC(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,zt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&at(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>Jt(Jt(v,g,m),g+1,f),i)}else[i,a]=TC(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p}=nl(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Jt(m,f,po(f,p,o)),_r()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p,sizeTree:i}}function AC(e){return rr(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 zp(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 nl(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Os(o,t-1,tl),a=o[l].offset;const c=dn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===dn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Ms(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 _C(e){return{index:e.index,value:e}}function jC(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 PC={offsetHeight:"height",offsetWidth:"width"},Tn=Qe(([{log:e},{recalcInProgress:t}])=>{const n=Xe(),r=Xe(),o=_t(r,0),s=Xe(),i=Xe(),a=ie(0),l=ie([]),c=ie(void 0),d=ie(void 0),p=ie((C,T)=>Fn(C,PC[T])),m=ie(void 0),f=ie(0),v=CC(),g=_t(te(n,He(l,e,f),Cn(NC,v),ft()),v),x=_t(te(l,ft(),Cn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),me(({prev:C})=>C)),[]);Se(te(l,Me(C=>C.length>0),He(g,f),me(([C,T,k])=>{const j=C.reduce((D,B,W)=>Jt(D,B,po(B,T.offsetTree,k)||W),_r());return{...T,groupIndices:C,groupOffsetTree:j}})),g),Se(te(r,He(g),Me(([C,{lastIndex:T}])=>C<T),me(([C,{lastIndex:T,lastSize:k}])=>[{endIndex:T,size:k,startIndex:C}])),n),Se(c,d);const y=_t(te(c,me(C=>C===void 0)),!0);Se(te(d,Me(C=>C!==void 0&&at(wt(g).sizeTree)),me(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=Xt(te(n,He(g),Cn(({sizes:C},[T,k])=>({changed:k!==C,sizes:k}),{changed:!1,sizes:v}),me(C=>C.changed)));rt(te(a,Cn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),me(C=>C.diff)),C=>{const{groupIndices:T}=wt(g);if(C>0)Fe(t,!0),Fe(s,C+zp(C,T));else if(C<0){const k=wt(x);k.length>0&&(C-=zp(-C,k)),Fe(i,C)}}),rt(te(a,He(e)),([C,T])=>{C<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},zt.ERROR)});const S=Xt(s);Se(te(s,He(g),me(([C,T])=>{const k=T.groupIndices.length>0,j=[],D=T.lastSize;if(k){const B=uo(T.sizeTree,0);let W=0,K=0;for(;W<C;){const _=T.groupIndices[K],Y=T.groupIndices.length===K+1?1/0:T.groupIndices[K+1]-_-1;j.push({endIndex:_,size:B,startIndex:_}),j.push({endIndex:_+1+Y-1,size:D,startIndex:_+1}),K++,W+=Y+1}const z=rr(T.sizeTree);return W!==C&&z.shift(),z.reduce((_,{k:Y,v:N})=>{let $=_.ranges;return _.prevSize!==0&&($=[..._.ranges,{endIndex:Y+C-1,size:_.prevSize,startIndex:_.prevIndex}]),{prevIndex:Y+C,prevSize:N,ranges:$}},{prevIndex:C,prevSize:0,ranges:j}).ranges}return rr(T.sizeTree).reduce((B,{k:W,v:K})=>({prevIndex:W+C,prevSize:K,ranges:[...B.ranges,{endIndex:W+C-1,size:B.prevSize,startIndex:B.prevIndex}]}),{prevIndex:0,prevSize:D,ranges:[]}).ranges})),n);const E=Xt(te(i,He(g,f),me(([C,{offsetTree:T},k])=>{const j=-C;return po(j,T,k)})));return Se(te(i,He(g,f),me(([C,T,k])=>{if(T.groupIndices.length>0){if(at(T.sizeTree))return T;let j=_r();const D=wt(x);let B=0,W=0,K=0;for(;B<-C;){K=D[W];const z=D[W+1]-K-1;W++,B+=z+1}if(j=rr(T.sizeTree).reduce((z,{k:_,v:Y})=>Jt(z,Math.max(0,_+C),Y),j),B!==-C){const z=uo(T.sizeTree,K);j=Jt(j,0,z);const _=dn(T.sizeTree,-C+1)[1];j=Jt(j,1,_)}return{...T,sizeTree:j,...nl(T.offsetTree,0,j,k)}}else{const j=rr(T.sizeTree).reduce((D,{k:B,v:W})=>Jt(D,Math.max(0,B+C),W),_r());return{...T,sizeTree:j,...nl(T.offsetTree,0,j,k)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:p,listRefresh:b,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},dt($n,el),{singleton:!0});function MC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Hp=Qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Xe(),i=Xe(),a=Xt(te(s,me(MC)));return Se(te(a,me(l=>l.totalCount)),n),Se(te(a,me(l=>l.groupIndices)),e),Se(te(bt(o,t,r),Me(([l,c])=>Ds(c)),me(([l,c,d])=>dn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ft(),me(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},dt(Tn,Dt)),Bn=Qe(([{log:e}])=>{const t=ie(!1),n=Xt(te(t,Me(r=>r),ft()));return rt(t,r=>{r&&wt(e)("props updated",{},zt.DEBUG)}),{didMount:n,propsReady:t}},dt($n),{singleton:!0}),RC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Up(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!RC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const ho=Qe(([{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=Xe(),v=Xe(),g=ie(0);let x=null,y=null,b=null;function S(){x&&(x(),x=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Fe(l,!1)}return Se(te(f,He(n,p,r,g,a,i,m),He(e,s,o),me(([[E,C,T,k,j,D,B,W],K,z,_])=>{const Y=Up(E),{align:N,behavior:$,offset:R}=Y,I=k-1,H=Bp(Y,C,I);let q=po(H,C.offsetTree,K)+D;N==="end"?(q+=z+dn(C.sizeTree,H)[1]-T+_,H===I&&(q+=B)):N==="center"?q+=(z+dn(C.sizeTree,H)[1]-T+_)/2:q-=j,R&&(q+=R);const P=O=>{S(),O?(W("retrying to scroll to",{location:E},zt.DEBUG),Fe(f,E)):(Fe(v,!0),W("list did not change, scroll successful",{},zt.DEBUG))};if(S(),$==="smooth"){let O=!1;b=rt(t,X=>{O=O||X}),x=un(d,()=>{P(O)})}else x=un(te(t,OC(150)),P);return y=setTimeout(()=>{S()},1200),Fe(l,!0),W("scrolling from index to",{behavior:$,index:H,top:q},zt.DEBUG),{behavior:$,top:q}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},dt(Tn,Dt,$n),{singleton:!0});function OC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function rl(e,t){e==0?t():requestAnimationFrame(()=>{rl(e-1,t)})}function ol(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const mo=Qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=ie(!0),l=ie(0),c=ie(!0);return Se(te(i,He(l),Me(([d,p])=>!!p),Sn(!1)),a),Se(te(i,He(l),Me(([d,p])=>!!p),Sn(!1)),c),rt(te(bt(t,i),He(a,n,e,c),Me(([[,d],p,{sizeTree:m},f,v])=>d&&(!at(m)||Ka(f))&&!p&&!v),He(l)),([,d])=>{un(o,()=>{Fe(c,!0)}),rl(4,()=>{un(r,()=>{Fe(a,!0)}),Fe(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},dt(Tn,Dt,ho,Bn),{singleton:!0});function Wp(e,t){return Math.abs(e-t)<1.01}const go="up",xo="down",DC="none",LC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},$C=0,vo=Qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=ie(!1),a=ie(!0),l=Xe(),c=Xe(),d=ie(4),p=ie($C),m=_t(te(Ga(te(je(o),tr(1),Sn(!0)),te(je(o),tr(1),Sn(!1),Ip(100))),ft()),!1),f=_t(te(Ga(te(n,Sn(!0)),te(n,Sn(!1),Ip(200))),ft()),!1);Se(te(bt(je(o),je(p)),me(([b,S])=>b<=S),ft()),a),Se(te(a,In(50)),c);const v=Xt(te(bt(r,je(s),je(t),je(e),je(d)),Cn((b,[{scrollHeight:S,scrollTop:E},C,T,k,j])=>{const D=E+C-S>-j,B={scrollHeight:S,scrollTop:E,viewportHeight:C};if(D){let K,z;return E>b.state.scrollTop?(K="SCROLLED_DOWN",z=b.state.scrollTop-E):(K="SIZE_DECREASED",z=b.state.scrollTop-E||b.scrollTopDelta),{atBottom:!0,atBottomBecause:K,scrollTopDelta:z,state:B}}let W;return B.scrollHeight>b.state.scrollHeight?W="SIZE_INCREASED":C<b.state.viewportHeight?W="VIEWPORT_HEIGHT_DECREASING":E<b.state.scrollTop?W="SCROLLING_UPWARDS":W="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:W,state:B}},LC),ft((b,S)=>b&&b.atBottom===S.atBottom))),g=_t(te(r,Cn((b,{scrollHeight:S,scrollTop:E,viewportHeight:C})=>{if(Wp(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:E};{const T=S-(E+C)<1;return b.scrollTop!==E&&T?{changed:!0,jump:b.scrollTop-E,scrollHeight:S,scrollTop:E}:{changed:!0,jump:0,scrollHeight:S,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Me(b=>b.changed),me(b=>b.jump)),0);Se(te(v,me(b=>b.atBottom)),i),Se(te(i,In(50)),l);const x=ie(xo);Se(te(r,me(({scrollTop:b})=>b),ft(),Cn((b,S)=>wt(f)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?go:xo,prevScrollTop:S},{direction:xo,prevScrollTop:0}),me(b=>b.direction)),x),Se(te(r,In(50),Sn(DC)),x);const y=ie(0);return Se(te(m,Me(b=>!b),Sn(0)),y),Se(te(o,In(100),He(m),Me(([b,S])=>!!S),Cn(([b,S],[E])=>[S,E],[0,0]),me(([b,S])=>S-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:p,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},dt(Dt)),Ls="top",$s="bottom",Vp="none";function Kp(e,t,n){return typeof e=="number"?n===go&&t===Ls||n===xo&&t===$s?e:0:n===go?t===Ls?e.main:e.reverse:t===$s?e.main:e.reverse}function qp(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const sl=Qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Xe(),i=ie(0),a=ie(0),l=ie(0),c=_t(te(bt(je(r),je(o),je(n),je(s,fo),je(l),je(i),je(t),je(e),je(a)),me(([d,p,m,[f,v],g,x,y,b,S])=>{const E=d-b,C=x+y,T=Math.max(m-E,0);let k=Vp;const j=qp(S,Ls),D=qp(S,$s);return f-=b,f+=m+y,v+=m+y,v-=b,f>d+C-j&&(k=go),v<d-T+p+D&&(k=xo),k!==Vp?[Math.max(E-m-Kp(g,Ls,k)-j,0),E-T-y+p+Kp(g,$s,k)+D]:null}),Me(d=>d!=null),ft(fo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},dt(Dt),{singleton:!0});function FC(e,t,n){if(Ds(t)){const r=Fp(e,t);return[{index:dn(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 il={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Fs(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:Yp(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:Yp(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function Gp(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=ol(t,a),c=Array.from({length:a}).map((d,p)=>({data:s[p+l],index:p+l,offset:0,size:0}));return Fs(c,[],a,o,n,r)}function Yp(e,t,n){if(e.length===0)return[];if(!Ds(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=Ms(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 or=Qe(([{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=ie([]),x=ie(0),y=Xe();Se(s.topItemsIndexes,g);const b=_t(te(bt(f,v,je(l,fo),je(o),je(r),je(c),d,je(g),je(t),je(n),e),Me(([T,k,,j,,,,,,,D])=>{const B=D&&D.length!==j;return T&&!k&&!B}),me(([,,[T,k],j,D,B,W,K,z,_,Y])=>{const N=D,{offsetTree:$,sizeTree:R}=N,I=wt(x);if(j===0)return{...il,totalCount:j};if(T===0&&k===0)return I===0?{...il,totalCount:j}:Gp(I,B,D,z,_,Y||[]);if(at(R))return I>0?null:Fs(FC(ol(B,j),N,Y),[],j,_,N,z);const H=[];if(K.length>0){const J=K[0],se=K[K.length-1];let V=0;for(const L of Ms(R,J,se)){const Z=L.value,Q=Math.max(L.start,J),ce=Math.min(L.end,se);for(let F=Q;F<=ce;F++)H.push({data:Y==null?void 0:Y[F],index:F,offset:V,size:Z}),V+=Z}}if(!W)return Fs([],H,j,_,N,z);const q=K.length>0?K[K.length-1]+1:0,P=IC($,T,k,q);if(P.length===0)return null;const O=j-1,X=Ps([],J=>{for(const se of P){const V=se.value;let L=V.offset,Z=se.start;const Q=V.size;if(V.offset<T){Z+=Math.floor((T-V.offset+_)/(Q+_));const F=Z-se.start;L+=F*Q+F*_}Z<q&&(L+=(q-Z)*Q,Z=q);const ce=Math.min(se.end,O);for(let F=Z;F<=ce&&!(L>=k);F++)J.push({data:Y==null?void 0:Y[F],index:F,offset:L,size:Q}),L+=Q+_}});return Fs(X,H,j,_,N,z)}),Me(T=>T!==null),ft()),il);Se(te(e,Me(Ka),me(T=>T==null?void 0:T.length)),o),Se(te(b,me(T=>T.topListHeight)),p),Se(p,a),Se(te(b,me(T=>[T.top,T.bottom])),i),Se(te(b,me(T=>T.items)),y);const S=Xt(te(b,Me(({items:T})=>T.length>0),He(o,e),Me(([{items:T},k])=>T[T.length-1].originalIndex===k-1),me(([,T,k])=>[T-1,k]),ft(fo),me(([T])=>T))),E=Xt(te(b,In(200),Me(({items:T,topItems:k})=>T.length>0&&T[0].originalIndex===k.length),me(({items:T})=>T[0].index),ft())),C=Xt(te(b,Me(({items:T})=>T.length>0),me(({items:T})=>{let k=0,j=T.length-1;for(;T[k].type==="group"&&k<j;)k++;for(;T[j].type==="group"&&j>k;)j--;return{endIndex:T[j].index,startIndex:T[k].index}}),ft(Lp)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:C,startReached:E,topItemsIndexes:g,...m}},dt(Tn,Hp,sl,mo,ho,vo,Bn,el),{singleton:!0}),Xp=Qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Xe(),i=_t(te(bt(n,e,r,t,o),me(([a,l,c,d,p])=>a+l+c+d+p.offsetBottom+p.bottom)),0);return Se(je(i),s),{totalListHeight:i,totalListHeightChanged:s}},dt(Dt,or),{singleton:!0}),BC=Qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=ie(!1),r=_t(te(bt(n,e,t),Me(([o])=>o),me(([,o,s])=>Math.max(0,o-s)),In(0),ft()),0);return{alignToBottom:n,paddingTopAddition:r}},dt(Dt,Xp),{singleton:!0}),Jp=Qe(()=>({context:ie(null)})),zC=({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,Zp=Qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Xe();return Se(te(d,He(t,l,n,s,o,r,a),He(e),me(([[p,m,f,v,g,x,y,b],S])=>{const{align:E,behavior:C,calculateViewLocation:T=zC,done:k,...j}=p,D=Bp(p,m,v-1),B=po(D,m.offsetTree,S)+g+x,W=B+dn(m.sizeTree,D)[1],K=b+x,z=b+f-y,_=T({itemBottom:W,itemTop:B,locationParams:{align:E,behavior:C,...j},viewportBottom:z,viewportTop:K});return _?k&&un(te(i,Me(Y=>!Y),tr(wt(i)?1:2)),k):k&&k(),_}),Me(p=>p!==null)),c),{scrollIntoView:d}},dt(Tn,Dt,ho,or,$n),{singleton:!0});function Qp(e){return e?e==="smooth"?"smooth":"auto":!1}const HC=(e,t)=>typeof e=="function"?Qp(e(t)):t&&Qp(e),UC=Qe(([{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=ie(!1),g=Xe();let x=null;function y(C){Fe(i,{align:"end",behavior:C,index:"LAST"})}rt(te(bt(te(je(t),tr(1)),l),He(je(v),s,a,p),me(([[C,T],k,j,D,B])=>{let W=T&&D,K="auto";return W&&(K=HC(k,j||B),W=W&&!!K),{followOutputBehavior:K,shouldFollow:W,totalCount:C}}),Me(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),wt(n)?requestAnimationFrame(()=>{wt(d)("following output to ",{totalCount:T},zt.DEBUG),y(C)}):x=un(e,()=>{wt(d)("following output to ",{totalCount:T},zt.DEBUG),y(C),x=null})});function b(C){const T=un(o,k=>{C&&!k.atBottom&&k.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(wt(d)("scrolling to bottom due to increased size",{},zt.DEBUG),y("auto"))});setTimeout(T,100)}rt(te(bt(je(v),t,c),Me(([C,,T])=>C&&T),Cn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Me(({refreshed:C})=>C),He(v,t)),([,C])=>{wt(a)&&b(C!==!1)}),rt(g,()=>{b(wt(v)!==!1)}),rt(bt(je(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=ie(null),E=Xe();return Se(Ga(te(je(r),me(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),te(je(t))),E),rt(te(bt(te(E,tr(1)),l),He(je(S),a,p,m),me(([[C,T],k,j,D,B])=>T&&j&&(k==null?void 0:k({context:B,totalCount:C,scrollingInProgress:D}))),Me(C=>!!C),In(0)),C=>{x&&(x(),x=null),wt(n)?requestAnimationFrame(()=>{wt(d)("scrolling into view",{}),Fe(f,C)}):x=un(e,()=>{wt(d)("scrolling into view",{}),Fe(f,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},dt(Tn,vo,ho,mo,Bn,$n,Dt,Jp,Zp)),WC=Qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(Se(te(a,He(s),Me(([,l])=>l!==0),He(o,r,t,n,e),me(([[,l],c,d,p,m,f=[]])=>Gp(l,c,d,p,m,f))),i),{}),dt(Tn,mo,or,Bn),{singleton:!0}),VC=Qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=ie(0);return rt(te(e,He(r),Me(([,o])=>o!==0),me(([,o])=>({top:o}))),o=>{un(te(n,tr(1),Me(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Fe(t,o)})})}),{initialScrollTop:r}},dt(Bn,Dt,or),{singleton:!0}),eh=Qe(([{scrollVelocity:e}])=>{const t=ie(!1),n=Xe(),r=ie(!1);return Se(te(e,He(r,t,n),Me(([o,s])=>!!s),me(([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}),ft()),t),rt(te(bt(t,e,n),He(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},dt(vo),{singleton:!0}),al=Qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=Xe(),r=Xe(),o=Xe(),s=ie(!1),i=ie(void 0);return Se(te(bt(n,r),me(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),Se(te(t,He(r),me(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},dt(Dt)),KC=Qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Xe(),d=ie(void 0),p=ie(null),m=ie(null);return Se(a,p),Se(l,m),rt(te(c,He(t,r,i,p,m,n)),([f,v,g,x,y,b,S])=>{const E=AC(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=S,f({ranges:E,scrollTop:g})}),Se(te(d,Me(Ka),me(qC)),o),Se(te(s,He(d),Me(([,f])=>f!==void 0),ft(),me(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},dt(Tn,Dt,mo,Bn,al));function qC(e){return{align:"start",index:0,offset:e.scrollTop}}const GC=Qe(([{topItemsIndexes:e}])=>{const t=ie(0);return Se(te(t,Me(n=>n>=0),me(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},dt(or));function th(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const YC=th(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),XC=Qe(([{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=Xt(te(l,He(i),Cn(([,y,b,S],[{bottom:E,items:C,offsetBottom:T,totalCount:k},j])=>{const D=E+T;let B=0;return b===k&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(B=D-S,B!==0&&(B+=j))),[B,C,k,D]},[0,[],0,0]),Me(([y])=>y!==0),He(r,a,n,o,f,v),Me(([,y,b,S,,,E])=>!E&&!S&&y!==0&&b===go),me(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},zt.DEBUG),y))));function x(y){y>0?(Fe(t,{behavior:"auto",top:-y}),Fe(e,0)):(Fe(e,0),Fe(t,{behavior:"auto",top:-y}))}return rt(te(g,He(e,s)),([y,b,S])=>{S&&YC()?Fe(e,b-y):x(-y)}),rt(te(bt(_t(s,!1),e,v),Me(([y,b,S])=>!y&&!S&&b!==0),me(([y,b])=>b),In(1)),x),Se(te(p,me(y=>({top:-y}))),t),rt(te(c,He(m,d),me(([y,{groupIndices:b,lastSize:S,sizeTree:E},C])=>{function T(k){return k*(S+C)}if(b.length===0)return T(y);{let k=0;const j=uo(E,0);let D=0,B=0;for(;D<y;){D++,k+=j;let W=b.length===B+1?1/0:b[B+1]-b[B]-1;D+W>y&&(k-=j,W=y-D+1),D+=W,k+=T(W),B++}return k}})),y=>{Fe(e,y),requestAnimationFrame(()=>{Fe(t,{top:y}),requestAnimationFrame(()=>{Fe(e,0),Fe(v,!1)})})}),{deviation:e}},dt(Dt,vo,or,Tn,$n,el)),JC=Qe(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),dt(sl,WC,Bn,eh,Xp,VC,BC,al,Zp,$n,Jp)),nh=Qe(([{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:S,...E},{scrollToIndex:C},T,{topItemCount:k},{groupCounts:j},D])=>(Se(E.rangeChanged,D.scrollSeekRangeChanged),Se(te(D.windowViewportRect,me(B=>B.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:k,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:p,...E,...D,...g,sizes:l,...x}),dt(Tn,mo,Dt,KC,UC,or,ho,XC,GC,Hp,JC));function ZC(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 Bs=typeof document<"u"?w.useLayoutEffect:w.useEffect;function rh(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&&Fe(x.propsReady,!1);for(const b of r){const S=x[t.required[b]];Fe(S,y[b])}for(const b of o)if(b in y){const S=x[t.optional[b]];Fe(S,y[b])}x.propsReady&&Fe(x.propsReady,!0)}function c(x){return s.reduce((y,b)=>(y[b]=S=>{const E=x[t.methods[b]];Fe(E,S)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=hC(x[t.events[b]]),y),{})}const p=w.forwardRef((x,y)=>{const{children:b,...S}=x,[E]=w.useState(()=>Ps(gC(e),k=>{l(k,S)})),[C]=w.useState(kp(d,E));Bs(()=>{for(const k of i)k in S&&rt(C[k],S[k]);return()=>{Object.values(C).map(qa)}},[S,C,E]),Bs(()=>{l(E,S)}),w.useImperativeHandle(y,Tp(c(E)));const T=n;return u.jsx(a.Provider,{value:E,children:n?u.jsx(T,{...ZC([...r,...o,...i],S),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{Fe(y[x],b)},[y,x])},f=x=>{const y=w.useContext(a)[x],b=w.useCallback(S=>rt(y,S),[y]);return w.useSyncExternalStore(b,()=>wt(y),()=>wt(y))},v=x=>{const y=w.useContext(a)[x],[b,S]=w.useState(kp(wt,y));return Bs(()=>rt(y,E=>{E!==b&&S(Tp(E))}),[y,b]),b},g=w.version.startsWith("18")?f:v;return{Component:p,useEmitter:(x,y)=>{const b=w.useContext(a)[x];Bs(()=>rt(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const oh=w.createContext(void 0),sh=w.createContext(void 0),ih=typeof document<"u"?w.useLayoutEffect:w.useEffect;function ll(e){return"self"in e}function QC(e){return"body"in e}function ah(e,t,n,r=Ar,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(QC(x)||ll(x)){const b=ll(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():Eo.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;ll(f)?(x=Math.max(Fn(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=Fn(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)),Wp(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 cl="-webkit-sticky",lh="sticky",ul=th(()=>{if(typeof document>"u")return lh;const e=document.createElement("div");return e.style.position=cl,e.style.position===cl?cl:lh});function dl(e){return e}const eT=Qe(()=>{const e=ie(a=>`Item ${a}`),t=ie(a=>`Group ${a}`),n=ie({}),r=ie(dl),o=ie("div"),s=ie(Ar),i=(a,l=null)=>_t(te(n,me(c=>c[a]),ft()),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")}}),tT=Qe(([e,t])=>({...e,...t}),dt(nh,eT)),nT=({height:e})=>u.jsx("div",{style:{height:e}}),rT={overflowAnchor:"none",position:ul(),zIndex:1},ch={overflowAnchor:"none"},oT={...ch,display:"inline-block",height:"100%"},uh=w.memo(function({showTopList:e=!1}){const t=Re("listState"),n=en("sizeRanges"),r=Re("useWindowScroll"),o=Re("customScrollParent"),s=en("windowScrollContainerState"),i=en("scrollContainerState"),a=o||r?s:i,l=Re("itemContent"),c=Re("context"),d=Re("groupContent"),p=Re("trackItemSizes"),m=Re("itemSize"),f=Re("log"),v=en("gap"),g=Re("horizontalDirection"),{callbackRef:x}=wC(n,m,p,e?Ar:a,f,v,o,g,Re("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);fl("deviation",_=>{y!==_&&b(_)});const S=Re("EmptyPlaceholder"),E=Re("ScrollSeekPlaceholder")||nT,C=Re("ListComponent"),T=Re("ItemComponent"),k=Re("GroupComponent"),j=Re("computeItemKey"),D=Re("isSeeking"),B=Re("groupIndices").length>0,W=Re("alignToBottom"),K=Re("initialItemFinalLocationReached"),z=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:W?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:W?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...K?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...jt(S,c)}):u.jsx(C,{...jt(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:z,children:(e?t.topItems:t.items).map(_=>{const Y=_.originalIndex,N=j(Y+t.firstItemIndex,_.data,c);return D?w.createElement(E,{...jt(E,c),height:_.size,index:_.index,key:N,type:_.type||"item",..._.type==="group"?{}:{groupIndex:_.groupIndex}}):_.type==="group"?w.createElement(k,{...jt(k,c),"data-index":Y,"data-item-index":_.index,"data-known-size":_.size,key:N,style:rT},d(_.index,c)):w.createElement(T,{...jt(T,c),...lT(T,_.data),"data-index":Y,"data-item-group-index":_.groupIndex,"data-item-index":_.index,"data-known-size":_.size,key:N,style:g?oT:ch},B?l(_.index,_.groupIndex,_.data,c):l(_.index,_.data,c))})})}),sT={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},iT={outline:"none",overflowX:"auto",position:"relative"},zs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),aT={position:ul(),top:0,width:"100%",zIndex:1};function jt(e,t){if(typeof e!="string")return{context:t}}function lT(e,t){return{item:typeof e=="string"?void 0:t}}const cT=w.memo(function(){const e=Re("HeaderComponent"),t=en("headerHeight"),n=Re("HeaderFooterTag"),r=nr(w.useMemo(()=>s=>{t(Fn(s,"height"))},[t]),!0,Re("skipAnimationFrameInResizeObserver")),o=Re("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),uT=w.memo(function(){const e=Re("FooterComponent"),t=en("footerHeight"),n=Re("HeaderFooterTag"),r=nr(w.useMemo(()=>s=>{t(Fn(s,"height"))},[t]),!0,Re("skipAnimationFrameInResizeObserver")),o=Re("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null});function dh({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}=ah(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?iT:sT,...o},tabIndex:0,...i,...jt(l,s),children:r})})}function fh({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}=ah(a,c,l,v,m);return ih(()=>{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,...jt(l,s),children:r})})}const dT=({children:e})=>{const t=w.useContext(oh),n=en("viewportHeight"),r=en("fixedItemHeight"),o=Re("alignToBottom"),s=Re("horizontalDirection"),i=w.useMemo(()=>Ep(n,l=>Fn(l,s?"width":"height")),[n,s]),a=nr(i,!0,Re("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:zs(o),children:e})},fT=({children:e})=>{const t=w.useContext(oh),n=en("windowViewportRect"),r=en("fixedItemHeight"),o=Re("customScrollParent"),s=_p(n,o,Re("skipAnimationFrameInResizeObserver")),i=Re("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:zs(i),children:e})},pT=({children:e})=>{const t=Re("TopItemListComponent")||"div",n=Re("headerHeight"),r={...aT,marginTop:`${n}px`},o=Re("context");return u.jsx(t,{style:r,...jt(t,o),children:e})},hT=w.memo(function(e){const t=Re("useWindowScroll"),n=Re("topItemsIndexes").length>0,r=Re("customScrollParent"),o=Re("context");return u.jsxs(r||t?xT:gT,{...e,context:o,children:[n&&u.jsx(pT,{children:u.jsx(uh,{showTopList:!0})}),u.jsxs(r||t?fT:dT,{children:[u.jsx(cT,{}),u.jsx(uh,{}),u.jsx(uT,{})]})]})}),{Component:mT,useEmitter:fl,useEmitterValue:Re,usePublisher:en}=rh(tT,{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"}},hT),gT=dh({useEmitter:fl,useEmitterValue:Re,usePublisher:en}),xT=fh({useEmitter:fl,useEmitterValue:Re,usePublisher:en}),vT=mT;dt(nh,Qe(()=>{const e=ie(c=>u.jsxs("td",{children:["Item $",c]})),t=ie(null),n=ie(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=ie(null),o=ie(null),s=ie({}),i=ie(dl),a=ie(Ar),l=(c,d=null)=>_t(te(s,me(p=>p[c]),ft()),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")}})),ul();const ph={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},wT={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:hh,floor:Hs,max:wo,min:pl,round:mh}=Math;function gh(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function bT(e){return{...wT,items:e}}function Us(e,t){return e&&e.width===t.width&&e.height===t.height}function yT(e,t){return e&&e.column===t.column&&e.row===t.row}const ST=Qe(([{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:S,windowViewportRect:E},C])=>{const T=ie(0),k=ie(0),j=ie(ph),D=ie({height:0,width:0}),B=ie({height:0,width:0}),W=Xe(),K=Xe(),z=ie(0),_=ie(null),Y=ie({column:0,row:0}),N=Xe(),$=Xe(),R=ie(!1),I=ie(0),H=ie(!0),q=ie(!1),P=ie(!1);rt(te(v,He(I),Me(([L,Z])=>!!Z)),()=>{Fe(H,!1)}),rt(te(bt(v,H,B,D,I,q),Me(([L,Z,Q,ce,,F])=>L&&!Z&&Q.height!==0&&ce.height!==0&&!F)),([,,,,L])=>{Fe(q,!0),rl(1,()=>{Fe(W,L)}),un(te(c),()=>{Fe(t,[0,0]),Fe(H,!0)})}),Se(te($,Me(L=>L!=null&&L.scrollTop>0),Sn(0)),k),rt(te(v,He($),Me(([,L])=>L!=null)),([,L])=>{L&&(Fe(D,L.viewport),Fe(B,L.item),Fe(Y,L.gap),L.scrollTop>0&&(Fe(R,!0),un(te(c,tr(1)),Z=>{Fe(R,!1)}),Fe(l,{top:L.scrollTop})))}),Se(te(D,me(({height:L})=>L)),p),Se(te(bt(je(D,Us),je(B,Us),je(Y,(L,Z)=>L&&L.column===Z.column&&L.row===Z.row),je(c)),me(([L,Z,Q,ce])=>({gap:Q,item:Z,scrollTop:ce,viewport:L}))),N),Se(te(bt(je(T),r,je(Y,yT),je(B,Us),je(D,Us),je(_),je(k),je(R),je(H),je(I)),Me(([,,,,,,,L])=>!L),me(([L,[Z,Q],ce,F,oe,we,fe,,xe,_e])=>{const{column:$e,row:Ue}=ce,{height:Ne,width:Oe}=F,{width:Ye}=oe;if(fe===0&&(L===0||Ye===0))return ph;if(Oe===0){const ct=ol(_e,L),Et=ct+Math.max(fe-1,0);return bT(gh(ct,Et,we))}const We=xh(Ye,Oe,$e);let Je,ot;xe?Z===0&&Q===0&&fe>0?(Je=0,ot=fe-1):(Je=We*Hs((Z+Ue)/(Ne+Ue)),ot=We*hh((Q+Ue)/(Ne+Ue))-1,ot=pl(L-1,wo(ot,We-1)),Je=pl(ot,wo(0,Je))):(Je=0,ot=-1);const nt=gh(Je,ot,we),{bottom:Ze,top:Ae}=vh(oe,ce,F,nt),Be=hh(L/We),et=Be*Ne+(Be-1)*Ue-Ze;return{bottom:Ze,itemHeight:Ne,items:nt,itemWidth:Oe,offsetBottom:et,offsetTop:Ae,top:Ae}})),j),Se(te(_,Me(L=>L!==null),me(L=>L.length)),T),Se(te(bt(D,B,j,Y),Me(([L,Z,{items:Q}])=>Q.length>0&&Z.height!==0&&L.height!==0),me(([L,Z,{items:Q},ce])=>{const{bottom:F,top:oe}=vh(L,ce,Z,Q);return[oe,F]}),ft(fo)),t);const O=ie(!1);Se(te(c,He(O),me(([L,Z])=>Z||L!==0)),O);const X=Xt(te(bt(j,T),Me(([{items:L}])=>L.length>0),He(O),Me(([[L,Z],Q])=>{const ce=L.items[L.items.length-1].index===Z-1;return(Q||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===Z)&&ce}),me(([[,L]])=>L-1),ft())),J=Xt(te(je(j),Me(({items:L})=>L.length>0&&L[0].index===0),Sn(0),ft())),se=Xt(te(je(j),He(R),Me(([{items:L},Z])=>L.length>0&&!Z),me(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),ft(Lp),In(0)));Se(se,f.scrollSeekRangeChanged),Se(te(W,He(D,B,T,Y),me(([L,Z,Q,ce,F])=>{const oe=Up(L),{align:we,behavior:fe,offset:xe}=oe;let _e=oe.index;_e==="LAST"&&(_e=ce-1),_e=wo(0,_e,pl(ce-1,_e));let $e=hl(Z,F,Q,_e);return we==="end"?$e=mh($e-Z.height+Q.height):we==="center"&&($e=mh($e-Z.height/2+Q.height/2)),xe&&($e+=xe),{behavior:fe,top:$e}})),l);const V=_t(te(j,me(L=>L.offsetBottom+L.bottom)),0);return Se(te(E,me(L=>({height:L.visibleHeight,width:L.visibleWidth}))),D),{customScrollParent:x,data:_,deviation:z,footerHeight:o,gap:Y,headerHeight:s,increaseViewportBy:e,initialItemCount:k,itemDimensions:B,overscan:n,restoreStateFrom:$,scrollBy:i,scrollContainerState:a,scrollHeight:K,scrollTo:l,scrollToIndex:W,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:D,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:E,...f,gridState:j,horizontalDirection:P,initialTopMostItemIndex:I,totalListHeight:V,...m,endReached:X,propsReady:g,rangeChanged:se,startReached:J,stateChanged:N,stateRestoreInProgress:R,...C}},dt(sl,Dt,vo,eh,Bn,al,$n));function xh(e,t,n){return wo(1,Hs((e+n)/(Hs(t)+n)))}function vh(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=hl(e,t,n,r[0].index);return{bottom:hl(e,t,n,r[r.length-1].index)+o,top:s}}function hl(e,t,n,r){const o=xh(e.width,n.width,t.column),s=Hs(r/o),i=s*n.height+wo(0,s-1)*t.row;return i>0?i+t.row:i}const CT=Qe(()=>{const e=ie(p=>`Item ${p}`),t=ie({}),n=ie(null),r=ie("virtuoso-grid-item"),o=ie("virtuoso-grid-list"),s=ie(dl),i=ie("div"),a=ie(Ar),l=(p,m=null)=>_t(te(t,me(f=>f[p]),ft()),m),c=ie(!1),d=ie(!1);return Se(je(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")}}),TT=Qe(([e,t])=>({...e,...t}),dt(ST,CT)),ET=w.memo(function(){const e=pt("gridState"),t=pt("listClassName"),n=pt("itemClassName"),r=pt("itemContent"),o=pt("computeItemKey"),s=pt("isSeeking"),i=tn("scrollHeight"),a=pt("ItemComponent"),l=pt("ListComponent"),c=pt("ScrollSeekPlaceholder"),d=pt("context"),p=tn("itemDimensions"),m=tn("gap"),f=pt("log"),v=pt("stateRestoreInProgress"),g=tn("reportReadyState"),x=nr(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const S=y.firstChild;if(S){const{height:E,width:C}=S.getBoundingClientRect();p({height:E,width:C})}m({column:bh("column-gap",getComputedStyle(y).columnGap,f),row:bh("row-gap",getComputedStyle(y).rowGap,f)})},[i,p,m,f]),!0,!1);return ih(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...jt(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,{...jt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...jt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),kT=w.memo(function(){const e=pt("HeaderComponent"),t=tn("headerHeight"),n=pt("headerFooterTag"),r=nr(w.useMemo(()=>s=>{t(Fn(s,"height"))},[t]),!0,!1),o=pt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),IT=w.memo(function(){const e=pt("FooterComponent"),t=tn("footerHeight"),n=pt("headerFooterTag"),r=nr(w.useMemo(()=>s=>{t(Fn(s,"height"))},[t]),!0,!1),o=pt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),NT=({children:e})=>{const t=w.useContext(sh),n=tn("itemDimensions"),r=tn("viewportDimensions"),o=nr(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:zs(!1),children:e})},AT=({children:e})=>{const t=w.useContext(sh),n=tn("windowViewportRect"),r=tn("itemDimensions"),o=pt("customScrollParent"),s=_p(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:zs(!1),children:e})},_T=w.memo(function({...e}){const t=pt("useWindowScroll"),n=pt("customScrollParent"),r=n||t?PT:jT,o=n||t?AT:NT,s=pt("context");return u.jsx(r,{...e,...jt(r,s),children:u.jsxs(o,{children:[u.jsx(kT,{}),u.jsx(ET,{}),u.jsx(IT,{})]})})}),{useEmitter:wh,useEmitterValue:pt,usePublisher:tn}=rh(TT,{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"}},_T),jT=dh({useEmitter:wh,useEmitterValue:pt,usePublisher:tn}),PT=fh({useEmitter:wh,useEmitterValue:pt,usePublisher:tn});function bh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,zt.WARN),t==="normal"?0:parseInt(t??"0",10)}const MT=Or.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 yh({className:e,variant:t,...n}){return u.jsx("div",{className:re(MT({variant:t}),e),...n})}const RT=1,OT=1e6;let ml=0;function DT(){return ml=(ml+1)%Number.MAX_SAFE_INTEGER,ml.toString()}const gl=new Map,Sh=e=>{if(gl.has(e))return;const t=setTimeout(()=>{gl.delete(e),bo({type:"REMOVE_TOAST",toastId:e})},OT);gl.set(e,t)},LT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,RT)};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?Sh(n):e.toasts.forEach(r=>{Sh(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)}}},Ws=[];let Vs={toasts:[]};function bo(e){Vs=LT(Vs,e),Ws.forEach(t=>{t(Vs)})}function $T({...e}){const t=DT(),n=o=>bo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>bo({type:"DISMISS_TOAST",toastId:t});return bo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function xl(){const[e,t]=h.useState(Vs);return h.useEffect(()=>(Ws.push(t),()=>{const n=Ws.indexOf(t);n>-1&&Ws.splice(n,1)}),[e]),{...e,toast:$T,dismiss:n=>bo({type:"DISMISS_TOAST",toastId:n})}}function Ch({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}=xl(),m=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await ki(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 Yc(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 ki(n),b=new Blob([y],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}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(de.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(ut,{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(de.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(de.Image,{className:"h-5 w-5"}):u.jsx(de.FileText,{className:"h-5 w-5"});return u.jsx(ra,{open:e,onOpenChange:t,children:u.jsxs(ss,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(is,{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(as,{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(ut,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(de.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(ut,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(de.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function Th(){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 sr=Th();function FT(e){sr=e}const Eh=/[&<>"']/,BT=new RegExp(Eh.source,"g"),kh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,zT=new RegExp(kh.source,"g"),HT={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ih=e=>HT[e];function Pt(e,t){if(t){if(Eh.test(e))return e.replace(BT,Ih)}else if(kh.test(e))return e.replace(zT,Ih);return e}const UT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Nh(e){return e.replace(UT,(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 WT=/(^|[^\[])\^/g;function lt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(WT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const VT=/[^\w:]/g,KT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Ah(e,t,n){if(e){let r;try{r=decodeURIComponent(Nh(n)).replace(VT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!KT.test(n)&&(n=XT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Ks={},qT=/^[^:]+:\/*[^/]*$/,GT=/^([^:]+:)[\s\S]*$/,YT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function XT(e,t){Ks[" "+e]||(qT.test(e)?Ks[" "+e]=e+"/":Ks[" "+e]=Gs(e,"/",!0)),e=Ks[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(GT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(YT,"$1")+t:e+t}const qs={exec:function(){}};function _h(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 Gs(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 JT(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 ZT(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 jh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Ph(e,t,n,r){const o=t.href,s=t.title?Pt(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:Pt(i)}}function QT(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
- `)}class Oa{constructor(t){this.options=t||Zn}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:Ms(r,`
86
- `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=YS(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=Ms(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,u,d,f,h,p,v,x=n[1].trim();const g=x.length>1,w={type:"list",raw:"",ordered:g,start:g?+x.slice(0,-1):"",loose:!1,items:[]};x=g?`\\d{1,9}\\${x.slice(-1)}`:`\\${x}`,this.options.pedantic&&(x=g?x:"[*+-]");const b=new RegExp(`^( {0,3}${x})((?:[ ][^\\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
- `,1)[0].replace(/^\t+/,T=>" ".repeat(3*T.length)),f=t.split(`
88
- `,1)[0],this.options.pedantic?(i=2,p=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,p=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(f)&&(r+=f+`
89
- `,t=t.substring(f.length+1),v=!0),!v){const T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
90
- `,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(k.test(f)||E.test(f)||T.test(f)||C.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
91
- `+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||k.test(d)||E.test(d)||C.test(d))break;p+=`
92
- `+f}!l&&!f.trim()&&(l=!0),r+=h+`
93
- `,t=t.substring(h.length+1),d=f.slice(i)}}w.loose||(u?w.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),w.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),w.raw+=r}w.items[w.items.length-1].raw=r.trimRight(),w.items[w.items.length-1].text=p.trimRight(),w.raw=w.raw.trimRight();const S=w.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,w.items[a].tokens=this.lexer.blockTokens(w.items[a].text,[]),!w.loose){const T=w.items[a].tokens.filter(k=>k.type==="space"),C=T.length>0&&T.some(k=>/\n.*\n/.test(k.raw));w.loose=C}if(w.loose)for(a=0;a<S;a++)w.items[a].loose=!0;return w}}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]):It(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:lh(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
- `):[]};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]=lh(r.rows[s],r.header.length).map(u=>({text:u}));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:It(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]):It(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=Ms(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=qS(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)),uh(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 uh(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,u=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.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]){u+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=h.slice(1,-1);return{type:"em",raw:h,text:v,tokens:this.lexer.inlineTokens(v)}}const p=h.slice(2,-2);return{type:"strong",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}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=It(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=It(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=It(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=It(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=It(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]):It(r[0]):r[0]:o=It(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const Se={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:_s,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Se._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Se._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Se.def=rt(Se.def).replace("label",Se._label).replace("title",Se._title).getRegex(),Se.bullet=/(?:[*+-]|\d{1,9}[.)])/,Se.listItemStart=rt(/^( *)(bull) */).replace("bull",Se.bullet).getRegex(),Se.list=rt(Se.list).replace(/bull/g,Se.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Se.def.source+")").getRegex(),Se._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",Se._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Se.html=rt(Se.html,"i").replace("comment",Se._comment).replace("tag",Se._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Se.paragraph=rt(Se._paragraph).replace("hr",Se.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",Se._tag).getRegex(),Se.blockquote=rt(Se.blockquote).replace("paragraph",Se.paragraph).getRegex(),Se.normal={...Se},Se.gfm={...Se.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},Se.gfm.table=rt(Se.gfm.table).replace("hr",Se.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",Se._tag).getRegex(),Se.gfm.paragraph=rt(Se._paragraph).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Se.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",Se._tag).getRegex(),Se.pedantic={...Se.normal,html:rt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Se._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:_s,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:rt(Se.normal._paragraph).replace("hr",Se.hr).replace("heading",` *#{1,6} *[^
96
- ]`).replace("lheading",Se.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const he={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:_s,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:_s,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};he._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",he.punctuation=rt(he.punctuation).replace(/punctuation/g,he._punctuation).getRegex(),he.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,he.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,he._comment=rt(Se._comment).replace("(?:-->|$)","-->").getRegex(),he.emStrong.lDelim=rt(he.emStrong.lDelim).replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimAst=rt(he.emStrong.rDelimAst,"g").replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimUnd=rt(he.emStrong.rDelimUnd,"g").replace(/punct/g,he._punctuation).getRegex(),he._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,he._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,he._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])?)+(?![-_])/,he.autolink=rt(he.autolink).replace("scheme",he._scheme).replace("email",he._email).getRegex(),he._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,he.tag=rt(he.tag).replace("comment",he._comment).replace("attribute",he._attribute).getRegex(),he._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,he._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,he._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,he.link=rt(he.link).replace("label",he._label).replace("href",he._href).replace("title",he._title).getRegex(),he.reflink=rt(he.reflink).replace("label",he._label).replace("ref",Se._label).getRegex(),he.nolink=rt(he.nolink).replace("ref",Se._label).getRegex(),he.reflinkSearch=rt(he.reflinkSearch,"g").replace("reflink",he.reflink).replace("nolink",he.nolink).getRegex(),he.normal={...he},he.pedantic={...he.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",he._label).getRegex(),reflink:rt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",he._label).getRegex()},he.gfm={...he.normal,escape:rt(he.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},he.gfm.url=rt(he.gfm.url,"i").replace("email",he.gfm._extended_email).getRegex(),he.breaks={...he.gfm,br:rt(he.br).replace("{2,}","*").getRegex(),text:rt(he.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function XS(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 dh(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 _n{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Zn,this.options.tokenizer=this.options.tokenizer||new Oa,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:Se.normal,inline:he.normal};this.options.pedantic?(n.block=Se.pedantic,n.inline=he.pedantic):this.options.gfm&&(n.block=Se.gfm,this.options.breaks?n.inline=he.breaks:n.inline=he.gfm),this.tokenizer.rules=n}static get rules(){return{block:Se,inline:he}}static lex(t,n){return new _n(n).lex(t)}static lexInline(t,n){return new _n(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
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,u)=>l+" ".repeat(u.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+=`
85
+ `)}class vl{constructor(t){this.options=t||sr}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:Gs(r,`
86
+ `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=QT(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=Gs(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
+ `,1)[0].replace(/^\t+/,E=>" ".repeat(3*E.length)),p=t.split(`
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
+ `,t=t.substring(p.length+1),v=!0),!v){const E=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),k=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(m=t.split(`
90
+ `,1)[0],p=m,this.options.pedantic&&(p=p.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(p)||k.test(p)||E.test(p)||C.test(t)));){if(p.search(/[^ ]/)>=i||!p.trim())f+=`
91
+ `+p.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||k.test(d)||C.test(d))break;f+=`
92
+ `+p}!l&&!p.trim()&&(l=!0),r+=m+`
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 S=y.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const E=y.items[a].tokens.filter(T=>T.type==="space"),C=E.length>0&&E.some(T=>/\n.*\n/.test(T.raw));y.loose=C}if(y.loose)for(a=0;a<S;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]):Pt(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:_h(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
+ `):[]};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]=_h(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:Pt(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]):Pt(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=Gs(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=JT(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)),Ph(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 Ph(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=Pt(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=Pt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Pt(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=Pt(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=Pt(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]):Pt(r[0]):r[0]:o=Pt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const Ie={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:qs,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Ie._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ie._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Ie.def=lt(Ie.def).replace("label",Ie._label).replace("title",Ie._title).getRegex(),Ie.bullet=/(?:[*+-]|\d{1,9}[.)])/,Ie.listItemStart=lt(/^( *)(bull) */).replace("bull",Ie.bullet).getRegex(),Ie.list=lt(Ie.list).replace(/bull/g,Ie.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Ie.def.source+")").getRegex(),Ie._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",Ie._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Ie.html=lt(Ie.html,"i").replace("comment",Ie._comment).replace("tag",Ie._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ie.paragraph=lt(Ie._paragraph).replace("hr",Ie.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",Ie._tag).getRegex(),Ie.blockquote=lt(Ie.blockquote).replace("paragraph",Ie.paragraph).getRegex(),Ie.normal={...Ie},Ie.gfm={...Ie.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},Ie.gfm.table=lt(Ie.gfm.table).replace("hr",Ie.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",Ie._tag).getRegex(),Ie.gfm.paragraph=lt(Ie._paragraph).replace("hr",Ie.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Ie.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",Ie._tag).getRegex(),Ie.pedantic={...Ie.normal,html:lt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ie._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:qs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:lt(Ie.normal._paragraph).replace("hr",Ie.hr).replace("heading",` *#{1,6} *[^
96
+ ]`).replace("lheading",Ie.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ge={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:qs,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:qs,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ge._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ge.punctuation=lt(ge.punctuation).replace(/punctuation/g,ge._punctuation).getRegex(),ge.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ge.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ge._comment=lt(Ie._comment).replace("(?:-->|$)","-->").getRegex(),ge.emStrong.lDelim=lt(ge.emStrong.lDelim).replace(/punct/g,ge._punctuation).getRegex(),ge.emStrong.rDelimAst=lt(ge.emStrong.rDelimAst,"g").replace(/punct/g,ge._punctuation).getRegex(),ge.emStrong.rDelimUnd=lt(ge.emStrong.rDelimUnd,"g").replace(/punct/g,ge._punctuation).getRegex(),ge._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ge._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ge._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])?)+(?![-_])/,ge.autolink=lt(ge.autolink).replace("scheme",ge._scheme).replace("email",ge._email).getRegex(),ge._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ge.tag=lt(ge.tag).replace("comment",ge._comment).replace("attribute",ge._attribute).getRegex(),ge._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ge._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ge._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ge.link=lt(ge.link).replace("label",ge._label).replace("href",ge._href).replace("title",ge._title).getRegex(),ge.reflink=lt(ge.reflink).replace("label",ge._label).replace("ref",Ie._label).getRegex(),ge.nolink=lt(ge.nolink).replace("ref",Ie._label).getRegex(),ge.reflinkSearch=lt(ge.reflinkSearch,"g").replace("reflink",ge.reflink).replace("nolink",ge.nolink).getRegex(),ge.normal={...ge},ge.pedantic={...ge.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:lt(/^!?\[(label)\]\((.*?)\)/).replace("label",ge._label).getRegex(),reflink:lt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ge._label).getRegex()},ge.gfm={...ge.normal,escape:lt(ge.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ge.gfm.url=lt(ge.gfm.url,"i").replace("email",ge.gfm._extended_email).getRegex(),ge.breaks={...ge.gfm,br:lt(ge.br).replace("{2,}","*").getRegex(),text:lt(ge.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function eE(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 Mh(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 zn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||sr,this.options.tokenizer=this.options.tokenizer||new vl,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:Ie.normal,inline:ge.normal};this.options.pedantic?(n.block=Ie.pedantic,n.inline=ge.pedantic):this.options.gfm&&(n.block=Ie.gfm,this.options.breaks?n.inline=ge.breaks:n.inline=ge.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ie,inline:ge}}static lex(t,n){return new zn(n).lex(t)}static lexInline(t,n){return new zn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
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+=`
100
100
  `+r.text,this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(r=this.tokenizer.fences(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
101
101
  `+r.raw,o.text+=`
102
- `+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=o.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startBlock){let a=1/0;const l=t.slice(1);let u;this.options.extensions.startBlock.forEach(function(d){u=d.call({lexer:this},l),typeof u=="number"&&u>=0&&(a=Math.min(a,u))}),a<1/0&&a>=0&&(s=t.substring(0,a+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){o=n[n.length-1],i&&o.type==="paragraph"?(o.raw+=`
102
+ `+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=o.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startBlock){let a=1/0;const l=t.slice(1);let c;this.options.extensions.startBlock.forEach(function(d){c=d.call({lexer:this},l),typeof c=="number"&&c>=0&&(a=Math.min(a,c))}),a<1/0&&a>=0&&(s=t.substring(0,a+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){o=n[n.length-1],i&&o.type==="paragraph"?(o.raw+=`
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,u;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)+"["+ch("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)+"["+ch("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||(u=""),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,u)){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,dh)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,dh))){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 f=t.slice(1);let h;this.options.extensions.startInline.forEach(function(p){h=p.call({lexer:this},f),typeof h=="number"&&h>=0&&(d=Math.min(d,h))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,XS)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=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 Da{constructor(t){this.options=t||Zn}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
- `,o?'<pre><code class="'+this.options.langPrefix+It(o)+'">'+(r?t:It(t,!0))+`</code></pre>
108
- `:"<pre><code>"+(r?t:It(t,!0))+`</code></pre>
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)+"["+jh("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)+"["+jh("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,Mh)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,Mh))){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,eE)){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 wl{constructor(t){this.options=t||sr}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
+ `,o?'<pre><code class="'+this.options.langPrefix+Pt(o)+'">'+(r?t:Pt(t,!0))+`</code></pre>
108
+ `:"<pre><code>"+(r?t:Pt(t,!0))+`</code></pre>
109
109
  `}blockquote(t){return`<blockquote>
110
110
  ${t}</blockquote>
111
111
  `}html(t){return t}heading(t,n,r,o){if(this.options.headerIds){const s=this.options.headerPrefix+o.slug(r);return`<h${n} id="${s}">${t}</h${n}>
@@ -123,7 +123,8 @@ ${t}</blockquote>
123
123
  `}tablerow(t){return`<tr>
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
- `}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=ah(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=ah(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 fh{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 hh{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 Mn{constructor(t){this.options=t||Zn,this.options.renderer=this.options.renderer||new Da,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new fh,this.slugger=new hh}static parse(t,n){return new Mn(n).parse(t)}static parseInline(t,n){return new Mn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,p,v,x,g,w,b,S,T,C,k;const E=t.length;for(o=0;o<E;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(k=this.options.extensions.renderers[p.type].call({parser:this},p),k!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=k||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,ih(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),h="",a=p.rows.length,s=0;s<a;s++){for(u=p.rows[s],d="",l=u.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:p.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(p.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(v=p.ordered,x=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)b=p.items[s],S=b.checked,T=b.task,w="",b.task&&(C=this.renderer.checkbox(S),g?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+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=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):w+=C),w+=this.parse(b.tokens,g),h+=this.renderer.listitem(w,T,S);r+=this.renderer.list(h,v,x);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(h=p.tokens?this.parseInline(p.tokens):p.text;o+1<E&&t[o+1].type==="text";)p=t[++o],h+=`
127
- `+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}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 Rs{constructor(t){this.options=t||Zn}preprocess(t){return t}postprocess(t){return t}}hm(Rs,"passThroughHooks",new Set(["preprocess","postprocess"]));function JS(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>"+It(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 ph(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...be.defaults,...s};const i=JS(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(GS(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(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&be.walkTokens(l,r.walkTokens),h=t(l,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!l.length))return u();let d=0;be.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return u(h);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&u()})},0))}),d===0&&u();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(be.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&&be.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function be(e,t,n){return ph(_n.lex,Mn.parse)(e,t,n)}be.options=be.setOptions=function(e){return be.defaults={...be.defaults,...e},OS(be.defaults),be},be.getDefaults=nh,be.defaults=Zn,be.use=function(...e){const t=be.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=be.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=be.defaults.renderer||new Da;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=be.defaults.tokenizer||new Oa;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=be.defaults.hooks||new Rs;for(const s in n.hooks){const i=o[s];Rs.passThroughHooks.has(s)?o[s]=a=>{if(be.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));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=be.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}}be.setOptions(r)})},be.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(be,r)),r.type){case"table":{for(const o of r.header)n=n.concat(be.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(be.walkTokens(s.tokens,t));break}case"list":{n=n.concat(be.walkTokens(r.items,t));break}default:be.defaults.extensions&&be.defaults.extensions.childTokens&&be.defaults.extensions.childTokens[r.type]?be.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(be.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(be.walkTokens(r.tokens,t)))}return n},be.parseInline=ph(_n.lexInline,Mn.parseInline),be.Parser=Mn,be.parser=Mn.parse,be.Renderer=Da,be.TextRenderer=fh,be.Lexer=_n,be.lexer=_n.lex,be.Tokenizer=Oa,be.Slugger=hh,be.Hooks=Rs,be.parse=be,be.options,be.setOptions,be.use,be.walkTokens,be.parseInline,Mn.parse,_n.lex;function Sr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=y.useMemo(()=>{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 be.parse=="function"?be.parse(i):be(i)}return typeof be.parse=="function"?be.parse(e):be(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=y.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 c.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}})}const ZS={MODE:"library"};function QS(){var i;const e=typeof globalThis<"u"?globalThis.process:void 0,t=typeof((i=e==null?void 0:e.env)==null?void 0:i.NODE_ENV)=="string"?e.env.NODE_ENV:void 0;if(t)return t==="production";const n=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Js&&Js.tagName.toUpperCase()==="SCRIPT"&&Js.src||new URL("index.umd.js",document.baseURI).href}<"u"?ZS:void 0,r=typeof(n==null?void 0:n.MODE)=="string"?n.MODE:void 0,o=typeof(n==null?void 0:n.NODE_ENV)=="string"?n.NODE_ENV:void 0;return(r??o)==="production"}function eC(){return!QS()}function tC(){return typeof window>"u"?!1:window.__ARTIFACT_DEBUG__===!0}function nC(){return eC()||tC()}function rC({preview:e,idx:t}){return y.useEffect(()=>{nC()&&console.debug(`[MessageComponent] Preview ${t} mounted:`,{src:e.src.substring(0,100),alt:e.alt,label:e.label})},[t,e]),c.jsxs("div",{className:"space-y-2",children:[e.label&&c.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),c.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:c.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 oC({artifact:e}){const[t,n]=y.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=y.useState(c.jsx(se.Clock,{className:"w-4 h-4"})),[s,i]=y.useState("Processing");return y.useEffect(()=>{switch(e.status||"processing"){case"completed":n("bg-green-500/20 text-green-700 dark:text-green-300"),o(c.jsx(se.CheckCircle,{className:"w-4 h-4"})),i("Completed");break;case"failed":n("bg-red-500/20 text-red-700 dark:text-red-300"),o(c.jsx(se.ExternalLink,{className:"w-4 h-4 rotate-45"})),i("Failed");break;case"pending":n("bg-blue-500/20 text-blue-700 dark:text-blue-300"),o(c.jsx(se.Clock,{className:"w-4 h-4"})),i("Pending");break;default:n("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),o(c.jsx(se.Clock,{className:"w-4 h-4"})),i("Processing")}},[e.status]),c.jsxs("div",{className:"rounded-lg border border-blue-200 dark:border-blue-900/50 bg-blue-50 dark:bg-blue-950/20 p-4 space-y-3",children:[c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"mt-1 flex-shrink-0",children:c.jsx(se.Search,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100",children:"Research Task"}),c.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300 mt-1",children:["Task ID: ",c.jsxs("code",{className:"font-mono text-xs bg-blue-100 dark:bg-blue-900/30 px-2 py-1 rounded",children:[e.task_id.slice(0,8),"..."]})]})]})]}),c.jsxs("div",{className:`inline-flex items-center gap-2 px-3 py-1 rounded-full text-sm font-medium ${t}`,children:[r,c.jsx("span",{children:s})]}),e.query&&c.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200 bg-white dark:bg-blue-900/30 rounded px-3 py-2",children:[c.jsx("p",{className:"font-medium text-xs text-blue-600 dark:text-blue-400 mb-1",children:"Query:"}),c.jsx("p",{className:"line-clamp-2",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&c.jsxs("div",{className:"text-sm text-blue-900 dark:text-blue-100 bg-white dark:bg-blue-900/30 rounded px-3 py-2 space-y-2",children:[c.jsx("p",{className:"font-semibold text-xs text-blue-600 dark:text-blue-400",children:"Results:"}),c.jsx(Sr,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),e.progress_url&&c.jsx("div",{className:"pt-2",children:c.jsxs("a",{href:e.progress_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white dark:bg-blue-700 dark:hover:bg-blue-600 rounded-md text-sm font-medium transition-colors",children:[c.jsx("span",{children:"Monitor Progress"}),c.jsx(se.ExternalLink,{className:"w-3.5 h-3.5"})]})}),e.createdAt&&c.jsxs("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})}function sC({artifact:e,idx:t=0}){if((e==null?void 0:e.type)==="research_task_info")return c.jsx(oC,{artifact:{type:"research_task_info",task_id:e.task_id,progress_url:e.progress_url,query:e.query,status:e.status,createdAt:e.createdAt}});const n=y.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>px(o)).filter(o=>o!==null):[],[e]);return n.length>0?c.jsx("div",{className:"space-y-2",children:n.map((r,o)=>c.jsx(rC,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?c.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:c.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",c.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const lo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:re("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));lo.displayName="Card";const co=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:re("flex flex-col space-y-1.5 p-6",e),...t}));co.displayName="CardHeader";const uo=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:re("text-2xl font-semibold leading-none tracking-tight",e),...t}));uo.displayName="CardTitle";const mh=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:re("text-sm text-muted-foreground",e),...t}));mh.displayName="CardDescription";const fo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:re("p-6 pt-0",e),...t}));fo.displayName="CardContent";const gh=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:re("flex items-center p-6 pt-0",e),...t}));gh.displayName="CardFooter";function iC({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=c.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const u=cr(s);a=c.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:u})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return c.jsxs(lo,{className:re("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[c.jsxs(co,{className:"pb-3",children:[c.jsx(uo,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),c.jsx(mh,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&c.jsx(fo,{className:"pt-0 pb-3",children:a}),c.jsx(gh,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(Ze,{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:r||!o,children:"Reject"}),c.jsx(Ze,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const aC="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 xh({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:aC,children:c.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>c.jsx("li",{children:String(n)},r))})}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:cr(e)}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:cr(e)})}function lC({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=y.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?c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&c.jsx(se.Loader,{className:"h-3 w-3 animate-spin"}),c.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&c.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var u;return c.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[c.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[c.jsx("span",{children:((u=a.type)==null?void 0:u.replace(/\./g," "))??"progress"}),c.jsx("span",{children:a.idx??l+1})]}),a.content&&c.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),c.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&c.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&c.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}function cC({message:e,viewMode:t,isStreaming:n=!1}){const o=pi(e).name||"tool",s=l=>{if(l==null)return null;const u=typeof l=="string"?hi(l)??l:l;if(u&&typeof u=="object")return c.jsx(xh,{data:u});const d=typeof u=="string"?u:(()=>{try{return cr(u)}catch{return String(u??"")}})();return c.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:d})},i=l=>{if(l==null)return null;const{content:u,isMarkdown:d}=ax(l);return d?c.jsx(Sr,{content:u,className:"text-current"}):s(l)},a=()=>{const l=e.content.find(f=>f.type!=="tool_call");if(!l)return c.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:c.jsxs("span",{children:["Running ",o,"…"]})});if(l.type==="text"){const h=(l.text??"").trim();if(!h)return null;const p=$r(h);return i(p)}const u=Lr(l),d=$r(u);return i(d)};return c.jsxs("div",{className:"space-y-2",children:[c.jsx(lC,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function uC(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Pa(),[o,s]=y.useState({}),[i,a]=y.useState(null),[l,u]=y.useState(!1),d=y.useCallback(()=>{u(!1),a(null)},[]),f=y.useCallback(p=>{a(p),u(!0)},[]),h=y.useCallback(async(p,v,x)=>{var g,w;if(!t){p.preventDefault();return}if(o[x]){p.preventDefault();return}try{const b=String(v.url??""),S=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){p.preventDefault();const T=S[1],C=v.name||`file_${T}`,k=v.mimeType||"application/octet-stream";f({id:T,name:C,mimeType:k});return}if(b.startsWith("data:")){p.preventDefault(),s(C=>({...C,[x]:!0}));const T=r({title:"Fetching file...",description:"",open:!0});try{const C=await gS(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const k=C.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(!(k!=null&&k.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!k.id||!k.filename)throw new Error("Invalid file data received from server");f({id:k.id,name:v.name||k.filename||`file_${k.id}`,mimeType:v.mimeType||k.mime_type||"application/octet-stream"}),(g=T.update)==null||g.call(T,{id:T.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const k=C instanceof Error?C.message:"Unknown error occurred";(w=T.update)==null||w.call(T,{id:T.id,title:"Failed",description:k}),r({title:"Failed to fetch file",description:k,open:!0})}finally{s(C=>({...C,[x]:!1}))}}}catch(b){console.error("File click error:",b),s(S=>({...S,[x]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:h,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function dC({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("div",{className:re("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?c.jsx(Sr,{content:e,allowHtml:!1}):c.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,"..."]})}),c.jsx(Ze,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?c.jsxs(c.Fragment,{children:[c.jsx(se.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function fC({className:e}){const[t,n]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:re("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function wh(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const Ps=y.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:u=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,showArtifactPreviews:h=!0,customStyles:p={},onEdit:v,onRegenerate:x,onCancelEdit:g,onCopy:w,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:T,onInterruptActionEnd:C,checkpointCandidates:k=[],activeCheckpointId:E=null,onSelectCheckpoint:A,defaultCheckpointId:L=null,messageParentCheckpointId:B=null}){const[W,K]=y.useState(!1),[H,R]=y.useState("preview"),[G,N]=y.useState(!1),{currentThreadId:$}=Ro(),{respondToInterrupt:P}=Po(),j=l==="phone"||l==="half-screen",U=t.role,V=U==="tool",M=y.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),F=!!M,ee=!(r&&U!=="user"),{uploadingFiles:J,handleFileClick:ie,fileViewerOpen:q,currentFileInfo:O,closeFileViewer:Y}=uC({allowFileOpen:ee,currentThreadId:$}),X=y.useMemo(()=>{switch(U){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[U]),le=y.useMemo(()=>{if(M)return"";const _=t.content;return Array.isArray(_)?lx(_):""},[M,t]),D=y.useMemo(()=>{if(M)return{};const _=t.content;return Array.isArray(_)?pi(t):{}},[M,t]),te=y.useMemo(()=>V?!!(t.additionalKwargs??{}).toolStreaming:!1,[V,t]),xe=y.useMemo(()=>{if(M)return[];const _=t.content;return Array.isArray(_)?_.filter(ne=>ne.type==="image_url"):[]},[M,t]),de=y.useMemo(()=>{if(M)return[];const _=t.content;return Array.isArray(_)?_.filter(ne=>ne.type==="file"):[]},[M,t]),we=y.useMemo(()=>{if(M)return[];const _=t.content;return Array.isArray(_)?_.filter(ne=>ne.type==="interrupt"):[]},[M,t]),je=(b==null?void 0:b.id)??(b==null?void 0:b.interrupt_id),De=Mo(je),$e=b==null?void 0:b.value,ke=y.useMemo(()=>{if(M)return"";const _=t.content;return Array.isArray(_)?cx(_):""},[M,t]),Fe=y.useMemo(()=>M||!h?null:t.artifact||null,[M,t,h]),Ke=y.useCallback(async()=>{const _=V?ke:le;async function ne(me){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(me);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Ue=new Blob([me],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Ue})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ne(_),K(!0),setTimeout(()=>K(!1),2e3),w==null||w(_)}catch(me){console.error("Failed to copy:",me)}},[V,ke,le,w]),Je=y.useCallback(()=>{if(!v)return;const _=V?ke:le,ne="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,_,ne)},[v,t.id,V,ke,le,t]),qe=y.useCallback(()=>{x==null||x(n)},[x,n]),tt=y.useCallback(()=>{const ne=re(j?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",X);switch(U){case"user":return c.jsx(se.User,{className:ne});case"assistant":return c.jsx(se.Bot,{className:ne});case"tool":return c.jsx(se.Wrench,{className:ne});default:return c.jsx(se.Bot,{className:ne})}},[j,X,U]),bt=y.useCallback(()=>{const _="group relative mb-4 flex w-full";switch(U){case"user":return re(_,"justify-end");case"assistant":case"tool":case"system":return re(_,"justify-start");default:return _}},[U]),st=y.useCallback(()=>{const _=re("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",j&&"px-3 py-2 text-sm");if(F)return re(_,"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(U){case"user":return re(_,"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(_,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return re(_,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return re(_,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return re(_,"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")}},[j,F,U]),Te=y.useCallback(async _=>{if(S)return;const ne=Mo((_==null?void 0:_.id)??(_==null?void 0:_.interrupt_id));if(!ne){console.warn("Interrupt part missing id",_);return}try{T==null||T(),await P(ne,!0)}catch(me){console.error("Failed to approve interrupt:",me)}finally{C==null||C()}},[S,C,T,P]),Le=y.useCallback(async _=>{if(S)return;const ne=Mo((_==null?void 0:_.id)??(_==null?void 0:_.interrupt_id));if(!ne){console.warn("Interrupt part missing id",_);return}try{T==null||T(),await P(ne,!1)}catch(me){console.error("Failed to reject interrupt:",me)}finally{C==null||C()}},[S,C,T,P]),ot=y.useCallback(({part:_,i:ne})=>{if(_.type==="text"){const me=_.text??"",Ue=me.trim(),Pe=hi(Ue);return Pe&&U!=="tool"?c.jsx(xh,{data:Pe},ne):U==="user"&&u&&Ue.length>d?c.jsx(dC,{text:Ue,expanded:G,onExpandedChange:N,previewLength:d,isCompact:j},ne):c.jsx(Sr,{content:me,allowHtml:!1},ne)}if(_.type==="image_url"){const me=_;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:me.url,alt:me.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},ne)}if(_.type==="file"){const me=_,Ue=me.name||"file";return c.jsxs("a",{href:me.url,onClick:Pe=>ie(Pe.nativeEvent,me,ne),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
129
- dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[J[ne]?c.jsx(se.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[Ue,J[ne]?" (processing)":""]})]},ne)}if(_.type==="interrupt"){const me=_,Ue=Mo((me==null?void 0:me.id)??(me==null?void 0:me.interrupt_id)),Pe=!!(De&&Ue&&Ue===De),vt=Pe?$e??(me==null?void 0:me.value):me==null?void 0:me.value,et=Ue?{...me,id:Ue,interrupt_id:Ue}:me;return c.jsx(iC,{interruptPart:et,onApprove:Te,onReject:Le,disabled:S,isActive:Pe,payload:vt},ne)}return null},[ie,J,Te,Le,U,u,d,G,j,De,$e,b,S,we]),ct=y.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(se.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),Nt=y.useCallback(()=>{const _=le.trim().length>0||xe.length>0||de.length>0||we.length>0;if(!V&&de.length>0&&!r)return ct();if(!V&&!_&&!r)return null;if(V)return!f&&Fe?null:f?c.jsx(cC,{message:t,viewMode:H,isStreaming:te},t.id):null;if(!V&&!M){const ne=t,me=c.jsx("div",{className:"space-y-2",children:ne.content.map((Ue,Pe)=>c.jsx(ot,{part:Ue,i:Pe},Pe))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[me,c.jsx(fC,{className:X})]}):me}},[le,xe.length,de.length,we.length,r,V,H,f,Fe,ct,X]),it=y.useMemo(()=>M?"Assistant":ux(t),[M,t]),Ye=y.useMemo(()=>M?[]:Array.isArray(k)?k:[],[k,M]),Mt=y.useMemo(()=>{var _;return Ye.length?L&&Ye.some(ne=>ne.id===L)?L:((_=Ye[0])==null?void 0:_.id)??null:null},[L,Ye]),Be=y.useMemo(()=>!Ye.length||!E?null:Ye.some(_=>_.id===E)?E:null,[E,Ye])??Mt,yt=U==="user"&&Ye.length>0&&typeof A=="function",ht=y.useCallback((_,ne=!1)=>{if(!A)return;const me=(_==null?void 0:_.id)??null,Ue=(_==null?void 0:_.parentId)??B??null;A(me,Ue,ne)},[B,A]),He=y.useMemo(()=>Be?Ye.findIndex(_=>_.id===Be):-1,[Be,Ye]),mt=y.useMemo(()=>He<0?null:Ye[He]??null,[He,Ye]);return V&&!f&&!Fe?null:F&&M?c.jsx("div",{className:re(bt(),p.container),children:c.jsxs("div",{className:re(st(),p.content),children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[c.jsx(se.Bot,{className:re("h-4 w-4",X)}),a&&c.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),c.jsx(Sr,{content:M.content,className:"text-current"})]})}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:re(bt(),p.container),children:c.jsxs("div",{className:re(st(),p.content),children:[(i||a||V)&&c.jsxs("div",{className:re("flex items-center justify-between mb-2 pb-2 border-b border-current/10",j&&"mb-1 pb-1",X,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[tt(),a&&it&&c.jsx("span",{className:re("font-medium",j?"text-xs":"text-sm"),children:it}),V&&c.jsxs(Rf,{variant:"outline",className:re("text-xs flex items-center gap-1 cursor-pointer select-none",X,"border border-current/40",j&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":H==="expanded",onClick:()=>R(_=>_==="expanded"?"preview":"expanded"),onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),R(ne=>ne==="expanded"?"preview":"expanded"))},children:[c.jsx("span",{children:D.name??"Tool Output"}),D.toolCallId&&c.jsx("span",{className:"opacity-70",children:D.toolCallId.slice(0,8)}),H==="expanded"?c.jsx(se.ChevronUp,{className:"h-3 w-3"}):c.jsx(se.ChevronDown,{className:"h-3 w-3"})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[yt&&mt&&He>=0&&c.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{type:"button",className:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",He<Ye.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(He>=Ye.length-1)return;const _=Ye[He+1];_&&ht(_)},"aria-label":"Older checkpoint (back in time)",disabled:He>=Ye.length-1,children:c.jsx(se.ChevronLeft,{className:"h-3 w-3"})}),c.jsx("div",{className:"flex items-center gap-2",children:c.jsxs("span",{className:"whitespace-nowrap",children:[Ye.length-He," / ",Ye.length]})}),c.jsx("button",{type:"button",className:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",He>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(!(He<=0))if(He===1)ht(null,!0);else{const _=Ye[He-1];_&&ht(_,!1)}},"aria-label":"Newer checkpoint (forward in time)",disabled:He<=0,children:c.jsx(se.ChevronRight,{className:"h-3 w-3"})})]})}),i&&t.createdAt&&c.jsx("time",{className:re("text-xs opacity-60",X,j&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&c.jsxs("div",{className:re("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx("div",{className:"relative",children:c.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>Ke(),className:re("h-6 w-6 p-0 hover:bg-foreground/10",X,j&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:c.jsx(se.Copy,{className:re(W?"text-success":X,j?"h-3 w-3":"h-4 w-4")})})}),U==="user"&&v&&c.jsx(Ze,{variant:"ghost",size:"sm",onClick:Je,className:re("h-6 w-6 p-0 hover:bg-foreground/10",X,j&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(se.Edit,{className:re(X,j?"h-3 w-3":"h-4 w-4")})}),U==="assistant"&&x&&c.jsx(Ze,{variant:"ghost",size:"sm",onClick:qe,className:re("h-6 w-6 p-0 hover:bg-foreground/10",X,j&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(se.RotateCcw,{className:re(X,j?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsxs("div",{className:"relative",children:[Nt(),h&&Fe&&c.jsx("div",{className:"mt-3",children:c.jsx(sC,{artifact:Fe,idx:0})})]}),V&&H==="expanded"&&(D.toolCallId||D.name)&&c.jsxs("div",{className:re("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",j&&"text-xs"),children:[D.name&&c.jsxs("div",{children:["Function: ",D.name]}),D.toolCallId&&c.jsxs("div",{children:["Call ID: ",D.toolCallId]})]}),!(i||a||V)&&s&&!o&&c.jsxs("div",{className:re("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>Ke(),className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:c.jsx(se.Copy,{className:re(W?"text-success":"text-current",j?"h-3 w-3":"h-4 w-4")})}),U==="user"&&v&&c.jsx(Ze,{variant:"ghost",size:"sm",onClick:Je,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:c.jsx(se.Edit,{className:re("text-current",j?"h-3 w-3":"h-4 w-4")})}),U==="assistant"&&x&&c.jsx(Ze,{variant:"ghost",size:"sm",onClick:qe,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:c.jsx(se.RotateCcw,{className:re("text-current",j?"h-3 w-3":"h-4 w-4")})})]})]})}),O&&c.jsx(PS,{isOpen:q,onClose:Y,fileId:O.id,fileName:O.name,mimeType:O.mimeType})]})},(e,t)=>{var l,u,d,f,h,p,v,x;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&cc(e.message)===cc(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(g=>e[g]===t[g]),s=((l=e.customStyles)==null?void 0:l.container)===((u=t.customStyles)==null?void 0:u.container)&&((d=e.customStyles)==null?void 0:d.content)===((f=t.customStyles)==null?void 0:f.content)&&((h=e.customStyles)==null?void 0:h.actions)===((p=t.customStyles)==null?void 0:p.actions)&&((v=e.customStyles)==null?void 0:v.header)===((x=t.customStyles)==null?void 0:x.header);if(!o||!s)return!1;const i=wh(e.message),a=wh(t.message);return i.length===a.length});Ps.displayName="MessageComponent";const vh=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,bh=y.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:u,onRegenerate:d,onCancelEdit:f,activeInterrupt:h,disableInterruptActions:p,onInterruptActionStart:v,onInterruptActionEnd:x,showToolMessages:g,showArtifactPreviews:w,checkpointIndex:b,activeCheckpointId:S,onSelectCheckpoint:T}){const C=vh(t,n),k="type"in t&&t.type==="default_message",A=!!t.__syntheticStreaming,{checkpointCandidates:L,defaultCheckpointId:B}=Jg(t,b??{checkpoints:[],checkpointMetaById:new Map,checkpointIndexByKey:new Map,attemptMetaById:new Map,userMessageIdToAttempts:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getAttempts:()=>[]}),W=t&&!k?t.additionalKwargs??{}:{},K=t&&!k?t.responseMetadata??{}:{},H=(()=>{if(typeof W.parentCheckpointId=="string")return W.parentCheckpointId;if(typeof K.parentCheckpointId=="string")return K.parentCheckpointId})();return c.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":C,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(Ps,{message:t,messageIndex:n,isStreamingMessage:A||r&&o===t.id,streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:u,onRegenerate:()=>d(n),onCancelEdit:f,activeInterrupt:h,disableInterruptActions:p,onInterruptActionStart:v,onInterruptActionEnd:x,showToolMessages:g,showArtifactPreviews:w,checkpointCandidates:L,activeCheckpointId:S??null,onSelectCheckpoint:T,defaultCheckpointId:B,messageParentCheckpointId:H})})});bh.displayName="MessageRow";const La=y.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:x=!1,onScrollAway:g,onAtBottom:w,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:T,onInterruptActionEnd:C,showToolMessages:k=!0,showArtifactPreviews:E=!0,checkpointIndex:A,activeCheckpointId:L,onSelectCheckpoint:B,createSyntheticThinkingMessage:W=!0},K)=>{const H=y.useRef(null),R=y.useRef(null),G=y.useRef(!1),N=y.useRef(!1),[$,P]=y.useState(!0),j=y.useMemo(()=>b?e.some(D=>"type"in D&&D.type==="default_message"?!1:Array.isArray(D==null?void 0:D.content)&&D.content.some(te=>te&&te.type==="interrupt"&&(te.id??te.interrupt_id)===b.id)):!1,[b,e]),U=y.useMemo(()=>{if(!b||j)return null;const D=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let te;const xe=b.value;if(xe&&typeof xe=="object"&&!Array.isArray(xe)){const de=xe.title;typeof de=="string"&&de.trim()&&(te=de.trim())}return{id:`interrupt-${D}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:D,value:xe,title:te}]}},[b,j]),V=y.useMemo(()=>U?[...e,U]:e,[e,U]),M=y.useMemo(()=>!W||!t?V:!V.some(te=>te.role==="assistant")&&V.length>0?[...V,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:V,[V,t,W]),F=y.useMemo(()=>k?M:M.filter(D=>(D==null?void 0:D.role)!=="tool"),[M,k]),ee=y.useCallback(D=>{P(D),g&&g(!D),w&&w(D)},[g,w]),J=y.useMemo(()=>{if(a)return async()=>{if(!G.current){G.current=!0;try{await a()}finally{G.current=!1}}}},[a]),ie=y.useMemo(()=>!v||x?!1:$?"auto":!1,[$,v,x]),q=y.useMemo(()=>{if(typeof p!="string")return null;const D=p.trim();return D?{id:"default-message",role:"assistant",type:"default_message",content:D,createdAt:new Date().toISOString()}:null},[p]),O=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),Y=()=>q?c.jsx("div",{className:"p-6 h-full overflow-y-auto",children:c.jsx("div",{className:"w-full max-w-full",children:c.jsx(Ps,{message:q,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},showArtifactPreviews:E})})}):c.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"}),X=F.length,le=X>0;return y.useEffect(()=>{var D,te;if(X===0){N.current=!1;return}if(!N.current)if(N.current=!0,H.current&&F.length>0){const xe=F.length-1;(te=(D=H.current).scrollToIndex)==null||te.call(D,{index:xe,align:"end",behavior:"auto"})}else R.current&&(R.current.scrollTop=R.current.scrollHeight)},[X,F.length]),y.useImperativeHandle(K,()=>({scrollToLatest:()=>{var D,te;if(H.current&&F.length>0){const xe=F.length-1;(te=(D=H.current).scrollToIndex)==null||te.call(D,{index:xe,align:"end",behavior:"auto"})}else R.current&&(R.current.scrollTop=R.current.scrollHeight)},scrollToTop:()=>{var D,te;H.current&&F.length>0?(te=(D=H.current).scrollToIndex)==null||te.call(D,{index:0,align:"start",behavior:"auto"}):R.current&&(R.current.scrollTop=0)}}),[F]),c.jsx("div",{className:O,style:h,children:c.jsx("div",{className:"relative flex-1 min-h-0",children:le?c.jsx(Q0,{ref:D=>{H.current=D},scrollerRef:D=>{R.current=D instanceof HTMLDivElement?D:null},data:F,followOutput:ie,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{J&&J()},atBottomStateChange:ee,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(D,te)=>vh(te,D),itemContent:(D,te)=>c.jsx(bh,{message:te,index:D,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:u,onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:T,onInterruptActionEnd:C,showToolMessages:k,showArtifactPreviews:E,checkpointIndex:A,activeCheckpointId:L,onSelectCheckpoint:B})}):Y()})})});La.displayName="MessageList";const yh={value:""};function Os({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:u=!0,showToolMessages:d=!0,showArtifactPreviews:f=!0,customStyles:h={},onMessageSent:p,onExcelUploadSuccess:v,onError:x}){const{api:g}=fi(),{currentThreadId:w}=Ro(),{threadId:b,messages:S,isHistoryLoading:T,isLoading:C,navigateToCheckpoint:k,returnToLatest:E,checkpoint:A,checkpoints:L,interrupt:B,metadata:W,checkpointIndex:K}=Po(),{isStreaming:H,error:R,connectionState:G,submit:N,stop:$}=Cc(),P=b??w??null,j=(A==null?void 0:A.id)??null,U=(A==null?void 0:A.namespace)??null,V=(W==null?void 0:W.assemblingMessageId)??null,M=B,[F,ee]=y.useState(!1);y.useEffect(()=>{M||ee(!1)},[M]);const J=y.useCallback(()=>{ee(!0)},[]),ie=y.useCallback(()=>{ee(!1)},[]),q=!!M||F,[O,Y]=y.useState(null),[X,le]=y.useState(""),[D,te]=y.useState(null),[xe,de]=y.useState(null),[we,je]=y.useState([]),[De,$e]=y.useState(0),[ke,Fe]=y.useState(0),[Ke,Je]=y.useState(!1),[qe,tt]=y.useState(null),[bt,st]=y.useState(null),[Te,Le]=y.useState(!1),[ot,ct]=y.useState(null),Nt=y.useRef(!1),[it,Ye]=y.useState(()=>yh.value),Mt=y.useRef(it),ze=y.useRef(null),Be=y.useCallback(ae=>{yh.value=ae,Ye(ae)},[]),[yt,ht]=y.useState(!1),He=y.useRef(null),mt=y.useRef(null),_=y.useRef(null),ne=y.useCallback(()=>{mt.current&&(mt.current.value=""),_.current&&(_.current.value=""),$e(ae=>ae+1),Fe(ae=>ae+1)},[]),me=y.useCallback(ae=>{Be(ae)},[Be]),Ue=y.useRef(!1);y.useEffect(()=>{Ue.current&&!H&&(je([]),ne()),Ue.current=H},[H,ne]);const[Pe,vt]=y.useState("desktop");y.useEffect(()=>{const ae=()=>{const ge=window.innerWidth;vt(ge<640?"phone":ge<1024?"tablet":"desktop")};return ae(),window.addEventListener("resize",ae),()=>window.removeEventListener("resize",ae)},[]),y.useEffect(()=>{Nt.current=!1},[P]),y.useEffect(()=>{Mt.current=it},[it]),y.useEffect(()=>{if(!O){ze.current=null;return}ze.current===null&&(ze.current=Mt.current),Be(X??"")},[X,O,Be]),y.useEffect(()=>{(async()=>{if(!g.baseUrl){ct(null);return}try{const ue=(await g.getAgent("default")).uiDefaultMessage||"";ct(ue||null)}catch(ge){console.warn("Failed to fetch default message:",ge),ct(null)}})()},[g.baseUrl]),y.useEffect(()=>{R&&!Te&&(x==null||x(R))},[R,Te,x]);const et=async ae=>{const ge=ae.trim();if(!(!ge&&we.length===0))try{const ue=O?(D==null?void 0:D.checkpointId)??j??void 0:j??void 0,ye=O?(D==null?void 0:D.checkpointNs)??U??void 0:U??void 0;await N({text:ge||"",attachments:we},{checkpointId:ue,checkpointNs:ye,edit:!!O,originalMessageId:O??void 0}),p==null||p(ge),Be(""),de(null),je([]),ne(),Y(null),le(""),te(null)}catch(ue){const ye=(ue==null?void 0:ue.message)||"Failed to send message";de(ye),x==null||x(ye)}},$t=y.useCallback((ae,ge,ue)=>{u&&(ze.current=it,Y(ae),le(ge),Be(ge),de(null),te({checkpointId:(ue==null?void 0:ue.checkpointId)??null,checkpointNs:(ue==null?void 0:ue.checkpointNs)??null}))},[it,u,Be]),rr=y.useCallback(()=>{Y(null),le(""),te(null),de(null),Be(ze.current??it),ze.current=null},[it,Be]),qs=y.useCallback((ae,ge,ue)=>{$t(ae,ge,ue)},[$t]),Gs=y.useCallback(ae=>{let ge=null;for(let Xe=ae-1;Xe>=0;Xe--)if(S[Xe].role==="user"){ge=S[Xe];break}if(!ge)return;const ue=Array.isArray(ge.content)?ge.content:[],gt=ue.filter(Xe=>(Xe==null?void 0:Xe.type)==="text").map(Xe=>Xe.text).join("")||(()=>{try{return JSON.stringify(ue,null,2)}catch{return String(ue)}})();gt&&N({text:gt},{checkpointId:j??void 0,checkpointNs:U??void 0,edit:!0,originalMessageId:ge.id})},[S,N,j,U]),ol=ae=>{const ge=Array.from(ae.target.files||[]);je(ue=>[...ue,...ge]),ae.target.value=""},sl=ae=>{je(ge=>{const ue=ge.filter((ye,gt)=>ae!==gt);return ue.length===0&&ne(),ue})},il=async ae=>{const ge=(ae.target.files||[])[0];if(ge){tt(null),st(null),Je(!0);try{await N({attachments:[ge]},{checkpointId:j??void 0,checkpointNs:U??void 0});const ue=`Uploaded ${ge.name} - processing through chat stream`;st(ue)}catch(ue){const ye=ue instanceof Error?ue.message:"Failed to upload Excel file";console.error("Excel upload failed",ue),tt(ye),x==null||x(ye)}finally{Je(!1),ae.target.value="",ne()}}},Ys=async ae=>{if(w){ht(!0);try{if(!ae){await E(),requestAnimationFrame(()=>{var ye;(ye=He.current)==null||ye.scrollToLatest()});return}const ge=L.find(ye=>ye.checkpointId===ae),ue=(ge==null?void 0:ge.checkpointNs)??null;await k(ae,ue),requestAnimationFrame(()=>{var ye;(ye=He.current)==null||ye.scrollToTop()})}finally{ht(!1)}}},I=y.useCallback(async(ae,ge,ue)=>{await Ys(ue?null:ae)},[Ys]),Q=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${h.container||""}`,ce=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${h.messagesArea||""}`,Ne=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${h.inputArea||""}`;return c.jsxs("div",{className:Q,children:[!!R&&!Te&&c.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:[c.jsx("span",{children:R}),c.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>Le(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(se.X,{size:16})})]}),c.jsxs("div",{className:`relative ${ce}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(La,{ref:He,className:"h-full",style:{height:"100%"},messages:S,isStreaming:H,streamingAssistantId:V,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Pe,enableMessageEditing:u,editingMessageId:O,onEdit:qs,onRegenerate:Gs,onCancelEdit:rr,emptyMessage:ot??void 0,isNavigatingCheckpoint:yt,activeInterrupt:M,disableInterruptActions:F,onInterruptActionStart:J,onInterruptActionEnd:ie,showToolMessages:d,showArtifactPreviews:f,checkpointIndex:K,activeCheckpointId:j,onSelectCheckpoint:I,createSyntheticThinkingMessage:!0}),(G==="reconnecting"||G==="connecting")&&c.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:c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(se.Loader2,{className:"h-3 w-3 animate-spin"}),G==="reconnecting"?"Reconnecting…":"Connecting…"]})}),G==="error"&&c.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"}),C&&c.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:[c.jsx(se.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(T||yt)&&c.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:[c.jsx(se.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),c.jsxs("div",{className:Ne,children:[O&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(se.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Ze,{variant:"ghost",size:"sm",onClick:rr,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(se.X,{size:16})})]})}),(a||l)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[a&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:mt,type:"file",multiple:!0,onChange:ae=>ol(ae),className:"hidden"},De),we.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:we.map((ae,ge)=>c.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:[c.jsx(se.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:ae.name}),c.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>sl(ge),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 ${ae.name}`,children:c.jsx(se.X,{size:12})})]},ge))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:_,type:"file",accept:".xls,.xlsx,.xlsm",onChange:il,className:"hidden"},ke),Ke&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(se.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),bt&&!Ke&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:bt}),qe&&!Ke&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:qe})]})]}),xe&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:xe}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(Qi,{children:[c.jsx(ea,{asChild:!0,children:c.jsx(Ze,{type:"button",size:"icon",variant:"outline",disabled:H||q,title:"More input actions",className:h.moreButton||"",children:c.jsx(se.Plus,{size:16})})}),c.jsxs(ds,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(Vn,{onClick:()=>{var ae;return(ae=mt.current)==null?void 0:ae.click()},className:"cursor-pointer",children:[c.jsx(se.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(Vn,{onClick:()=>{var ae;Ke||(ae=_.current)==null||ae.click()},className:`cursor-pointer ${Ke?"opacity-60 pointer-events-none":""}`,children:[c.jsx(se.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(Fx,{initialValue:X,editingMessageId:O,value:it,onValueChange:me,placeholder:O?"Edit your message...":t,isStreaming:H,disabled:q,onSend:et,onCancelEdit:rr,onStop:$,allowEmptySend:we.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${O?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${xe?"border-red-400":""} ${h.textarea||""}`})})]})]})]})}var Sh=1,hC=.9,pC=.8,mC=.17,$a=.1,Fa=.999,gC=.9999,xC=.99,wC=/[\\\/_+.#"@\[\(\{&]/,vC=/[\\\/_+.#"@\[\(\{&]/g,bC=/[\s-]/,Ch=/[\s-]/g;function Ba(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Sh:xC;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),u=n.indexOf(l,o),d=0,f,h,p,v;u>=0;)f=Ba(e,t,n,r,u+1,s+1,i),f>d&&(u===o?f*=Sh:wC.test(e.charAt(u-1))?(f*=pC,p=e.slice(o,u-1).match(vC),p&&o>0&&(f*=Math.pow(Fa,p.length))):bC.test(e.charAt(u-1))?(f*=hC,v=e.slice(o,u-1).match(Ch),v&&o>0&&(f*=Math.pow(Fa,v.length))):(f*=mC,o>0&&(f*=Math.pow(Fa,u-o))),e.charAt(u)!==t.charAt(s)&&(f*=gC)),(f<$a&&n.charAt(u-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(u-1)!==r.charAt(s))&&(h=Ba(e,t,n,r,u+1,s+2,i),h*$a>f&&(f=h*$a)),f>d&&(d=f),u=n.indexOf(l,u+1);return i[a]=d,d}function kh(e){return e.toLowerCase().replace(Ch," ")}function yC(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Ba(e,t,kh(e),kh(t),0,0,{})}var ho='[cmdk-group=""]',za='[cmdk-group-items=""]',SC='[cmdk-group-heading=""]',Th='[cmdk-item=""]',Eh=`${Th}:not([aria-disabled="true"])`,Ha="cmdk-item-select",Cr="data-value",CC=(e,t,n)=>yC(e,t,n),Ih=m.createContext(void 0),po=()=>m.useContext(Ih),Nh=m.createContext(void 0),Ua=()=>m.useContext(Nh),Ah=m.createContext(void 0),jh=m.forwardRef((e,t)=>{let n=kr(()=>{var M,F;return{search:"",value:(F=(M=e.value)!=null?M:e.defaultValue)!=null?F:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=kr(()=>new Set),o=kr(()=>new Map),s=kr(()=>new Map),i=kr(()=>new Set),a=_h(e),{label:l,children:u,value:d,onValueChange:f,filter:h,shouldFilter:p,loop:v,disablePointerSelection:x=!1,vimBindings:g=!0,...w}=e,b=At(),S=At(),T=At(),C=m.useRef(null),k=PC();Qn(()=>{if(d!==void 0){let M=d.trim();n.current.value=M,E.emit()}},[d]),Qn(()=>{k(6,H)},[]);let E=m.useMemo(()=>({subscribe:M=>(i.current.add(M),()=>i.current.delete(M)),snapshot:()=>n.current,setState:(M,F,ee)=>{var J,ie,q,O;if(!Object.is(n.current[M],F)){if(n.current[M]=F,M==="search")K(),B(),k(1,W);else if(M==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Y=document.getElementById(T);Y?Y.focus():(J=document.getElementById(b))==null||J.focus()}if(k(7,()=>{var Y;n.current.selectedItemId=(Y=R())==null?void 0:Y.id,E.emit()}),ee||k(5,H),((ie=a.current)==null?void 0:ie.value)!==void 0){let Y=F??"";(O=(q=a.current).onValueChange)==null||O.call(q,Y);return}}E.emit()}},emit:()=>{i.current.forEach(M=>M())}}),[]),A=m.useMemo(()=>({value:(M,F,ee)=>{var J;F!==((J=s.current.get(M))==null?void 0:J.value)&&(s.current.set(M,{value:F,keywords:ee}),n.current.filtered.items.set(M,L(F,ee)),k(2,()=>{B(),E.emit()}))},item:(M,F)=>(r.current.add(M),F&&(o.current.has(F)?o.current.get(F).add(M):o.current.set(F,new Set([M]))),k(3,()=>{K(),B(),n.current.value||W(),E.emit()}),()=>{s.current.delete(M),r.current.delete(M),n.current.filtered.items.delete(M);let ee=R();k(4,()=>{K(),(ee==null?void 0:ee.getAttribute("id"))===M&&W(),E.emit()})}),group:M=>(o.current.has(M)||o.current.set(M,new Set),()=>{s.current.delete(M),o.current.delete(M)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:T,labelId:S,listInnerRef:C}),[]);function L(M,F){var ee,J;let ie=(J=(ee=a.current)==null?void 0:ee.filter)!=null?J:CC;return M?ie(M,n.current.search,F):0}function B(){if(!n.current.search||a.current.shouldFilter===!1)return;let M=n.current.filtered.items,F=[];n.current.filtered.groups.forEach(J=>{let ie=o.current.get(J),q=0;ie.forEach(O=>{let Y=M.get(O);q=Math.max(Y,q)}),F.push([J,q])});let ee=C.current;G().sort((J,ie)=>{var q,O;let Y=J.getAttribute("id"),X=ie.getAttribute("id");return((q=M.get(X))!=null?q:0)-((O=M.get(Y))!=null?O:0)}).forEach(J=>{let ie=J.closest(za);ie?ie.appendChild(J.parentElement===ie?J:J.closest(`${za} > *`)):ee.appendChild(J.parentElement===ee?J:J.closest(`${za} > *`))}),F.sort((J,ie)=>ie[1]-J[1]).forEach(J=>{var ie;let q=(ie=C.current)==null?void 0:ie.querySelector(`${ho}[${Cr}="${encodeURIComponent(J[0])}"]`);q==null||q.parentElement.appendChild(q)})}function W(){let M=G().find(ee=>ee.getAttribute("aria-disabled")!=="true"),F=M==null?void 0:M.getAttribute(Cr);E.setState("value",F||void 0)}function K(){var M,F,ee,J;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ie=0;for(let q of r.current){let O=(F=(M=s.current.get(q))==null?void 0:M.value)!=null?F:"",Y=(J=(ee=s.current.get(q))==null?void 0:ee.keywords)!=null?J:[],X=L(O,Y);n.current.filtered.items.set(q,X),X>0&&ie++}for(let[q,O]of o.current)for(let Y of O)if(n.current.filtered.items.get(Y)>0){n.current.filtered.groups.add(q);break}n.current.filtered.count=ie}function H(){var M,F,ee;let J=R();J&&(((M=J.parentElement)==null?void 0:M.firstChild)===J&&((ee=(F=J.closest(ho))==null?void 0:F.querySelector(SC))==null||ee.scrollIntoView({block:"nearest"})),J.scrollIntoView({block:"nearest"}))}function R(){var M;return(M=C.current)==null?void 0:M.querySelector(`${Th}[aria-selected="true"]`)}function G(){var M;return Array.from(((M=C.current)==null?void 0:M.querySelectorAll(Eh))||[])}function N(M){let F=G()[M];F&&E.setState("value",F.getAttribute(Cr))}function $(M){var F;let ee=R(),J=G(),ie=J.findIndex(O=>O===ee),q=J[ie+M];(F=a.current)!=null&&F.loop&&(q=ie+M<0?J[J.length-1]:ie+M===J.length?J[0]:J[ie+M]),q&&E.setState("value",q.getAttribute(Cr))}function P(M){let F=R(),ee=F==null?void 0:F.closest(ho),J;for(;ee&&!J;)ee=M>0?MC(ee,ho):RC(ee,ho),J=ee==null?void 0:ee.querySelector(Eh);J?E.setState("value",J.getAttribute(Cr)):$(M)}let j=()=>N(G().length-1),U=M=>{M.preventDefault(),M.metaKey?j():M.altKey?P(1):$(1)},V=M=>{M.preventDefault(),M.metaKey?N(0):M.altKey?P(-1):$(-1)};return m.createElement(Ce.div,{ref:t,tabIndex:-1,...w,"cmdk-root":"",onKeyDown:M=>{var F;(F=w.onKeyDown)==null||F.call(w,M);let ee=M.nativeEvent.isComposing||M.keyCode===229;if(!(M.defaultPrevented||ee))switch(M.key){case"n":case"j":{g&&M.ctrlKey&&U(M);break}case"ArrowDown":{U(M);break}case"p":case"k":{g&&M.ctrlKey&&V(M);break}case"ArrowUp":{V(M);break}case"Home":{M.preventDefault(),N(0);break}case"End":{M.preventDefault(),j();break}case"Enter":{M.preventDefault();let J=R();if(J){let ie=new Event(Ha);J.dispatchEvent(ie)}}}}},m.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:DC},l),Ds(e,M=>m.createElement(Nh.Provider,{value:E},m.createElement(Ih.Provider,{value:A},M))))}),kC=m.forwardRef((e,t)=>{var n,r;let o=At(),s=m.useRef(null),i=m.useContext(Ah),a=po(),l=_h(e),u=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;Qn(()=>{if(!u)return a.item(o,i==null?void 0:i.id)},[u]);let d=Mh(o,s,[e.value,e.children,s],e.keywords),f=Ua(),h=Rn(k=>k.value&&k.value===d.current),p=Rn(k=>u||a.filter()===!1?!0:k.search?k.filtered.items.get(o)>0:!0);m.useEffect(()=>{let k=s.current;if(!(!k||e.disabled))return k.addEventListener(Ha,v),()=>k.removeEventListener(Ha,v)},[p,e.onSelect,e.disabled]);function v(){var k,E;x(),(E=(k=l.current).onSelect)==null||E.call(k,d.current)}function x(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:g,value:w,onSelect:b,forceMount:S,keywords:T,...C}=e;return m.createElement(Ce.div,{ref:Cn(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!g,"aria-selected":!!h,"data-disabled":!!g,"data-selected":!!h,onPointerMove:g||a.getDisablePointerSelection()?void 0:x,onClick:g?void 0:v},e.children)}),TC=m.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=At(),a=m.useRef(null),l=m.useRef(null),u=At(),d=po(),f=Rn(p=>o||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);Qn(()=>d.group(i),[]),Mh(i,a,[e.value,e.heading,l]);let h=m.useMemo(()=>({id:i,forceMount:o}),[o]);return m.createElement(Ce.div,{ref:Cn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&m.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:u},n),Ds(e,p=>m.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?u:void 0},m.createElement(Ah.Provider,{value:h},p))))}),EC=m.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=m.useRef(null),s=Rn(i=>!i.search);return!n&&!s?null:m.createElement(Ce.div,{ref:Cn(o,t),...r,"cmdk-separator":"",role:"separator"})}),IC=m.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Ua(),i=Rn(u=>u.search),a=Rn(u=>u.selectedItemId),l=po();return m.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),m.createElement(Ce.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:u=>{o||s.setState("search",u.target.value),n==null||n(u.target.value)}})}),NC=m.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=m.useRef(null),i=m.useRef(null),a=Rn(u=>u.selectedItemId),l=po();return m.useEffect(()=>{if(i.current&&s.current){let u=i.current,d=s.current,f,h=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=u.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return h.observe(u),()=>{cancelAnimationFrame(f),h.unobserve(u)}}},[]),m.createElement(Ce.div,{ref:Cn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Ds(e,u=>m.createElement("div",{ref:Cn(i,l.listInnerRef),"cmdk-list-sizer":""},u)))}),AC=m.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return m.createElement(Ia,{open:n,onOpenChange:r},m.createElement(Na,{container:i},m.createElement(so,{"cmdk-overlay":"",className:o}),m.createElement(io,{"aria-label":e.label,"cmdk-dialog":"",className:s},m.createElement(jh,{ref:t,...a}))))}),jC=m.forwardRef((e,t)=>Rn(n=>n.filtered.count===0)?m.createElement(Ce.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),_C=m.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return m.createElement(Ce.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Ds(e,i=>m.createElement("div",{"aria-hidden":!0},i)))}),Lt=Object.assign(jh,{List:NC,Item:kC,Input:IC,Group:TC,Separator:EC,Dialog:AC,Empty:jC,Loading:_C});function MC(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function RC(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function _h(e){let t=m.useRef(e);return Qn(()=>{t.current=e}),t}var Qn=typeof window>"u"?m.useEffect:m.useLayoutEffect;function kr(e){let t=m.useRef();return t.current===void 0&&(t.current=e()),t}function Rn(e){let t=Ua(),n=()=>e(t.snapshot());return m.useSyncExternalStore(t.subscribe,n,n)}function Mh(e,t,n,r=[]){let o=m.useRef(),s=po();return Qn(()=>{var i;let a=(()=>{var u;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(u=d.current.textContent)==null?void 0:u.trim():o.current}})(),l=r.map(u=>u.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Cr,a),o.current=a}),o}var PC=()=>{let[e,t]=m.useState(),n=kr(()=>new Map);return Qn(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function OC(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Ds({asChild:e,children:t},n){return e&&m.isValidElement(t)?m.cloneElement(OC(t),{ref:t.ref},n(t.props.children)):n(t)}var DC={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Rh=m.forwardRef(({className:e,...t},n)=>c.jsx(Lt,{ref:n,className:re("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Rh.displayName=Lt.displayName;const Ph=m.forwardRef(({className:e,...t},n)=>c.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[c.jsx(se.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),c.jsx(Lt.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})]}));Ph.displayName=Lt.Input.displayName;const Oh=m.forwardRef(({className:e,...t},n)=>c.jsx(Lt.List,{ref:n,className:re("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Oh.displayName=Lt.List.displayName;const Dh=m.forwardRef((e,t)=>c.jsx(Lt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Dh.displayName=Lt.Empty.displayName;const Lh=m.forwardRef(({className:e,...t},n)=>c.jsx(Lt.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}));Lh.displayName=Lt.Group.displayName;const LC=m.forwardRef(({className:e,...t},n)=>c.jsx(Lt.Separator,{ref:n,className:re("-mx-1 h-px bg-border",e),...t}));LC.displayName=Lt.Separator.displayName;const $h=m.forwardRef(({className:e,...t},n)=>c.jsx(Lt.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}));$h.displayName=Lt.Item.displayName;function Wa(e,[t,n]){return Math.min(n,Math.max(t,e))}function $C(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Va="ScrollArea",[Fh,DT]=wn(Va),[FC,Xt]=Fh(Va),Bh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,v]=m.useState(null),[x,g]=m.useState(null),[w,b]=m.useState(0),[S,T]=m.useState(0),[C,k]=m.useState(!1),[E,A]=m.useState(!1),L=We(t,W=>l(W)),B=Do(o);return c.jsx(FC,{scope:n,type:r,dir:B,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:k,scrollbarY:x,onScrollbarYChange:g,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:T,children:c.jsx(Ce.div,{dir:B,...i,ref:L,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Bh.displayName=Va;var zh="ScrollAreaViewport",Hh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Xt(zh,n),a=m.useRef(null),l=We(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(Ce.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Hh.displayName=zh;var gn="ScrollAreaScrollbar",Ka=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xt(gn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(BC,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(zC,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(Uh,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(qa,{...r,ref:t}):null});Ka.displayName=gn;var BC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xt(gn,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(Kt,{present:n||s,children:c.jsx(Uh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),zC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xt(gn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Bs(()=>l("SCROLL_END"),100),[a,l]=$C("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 m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(Kt,{present:n||a!=="hidden",children:c.jsx(qa,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:pe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:pe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Uh=m.forwardRef((e,t)=>{const n=Xt(gn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=Bs(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return Tr(n.viewport,l),Tr(n.content,l),c.jsx(Kt,{present:r||s,children:c.jsx(qa,{"data-state":s?"visible":"hidden",...o,ref:t})})}),qa=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Xt(gn,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Gh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return qC(h,i.current,a,p)}return n==="horizontal"?c.jsx(HC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=Yh(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(UC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=Yh(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),HC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Xt(gn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=We(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Vh,{"data-orientation":"horizontal",...o,ref:u,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":Fs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),Jh(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:$s(i.paddingLeft),paddingEnd:$s(i.paddingRight)}})}})}),UC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Xt(gn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=We(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Vh,{"data-orientation":"vertical",...o,ref:u,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":Fs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),Jh(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:$s(i.paddingTop),paddingEnd:$s(i.paddingBottom)}})}})}),[WC,Wh]=Fh(gn),Vh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=Xt(gn,n),[v,x]=m.useState(null),g=We(t,L=>x(L)),w=m.useRef(null),b=m.useRef(""),S=p.viewport,T=r.content-r.viewport,C=Ct(d),k=Ct(l),E=Bs(f,10);function A(L){if(w.current){const B=L.clientX-w.current.left,W=L.clientY-w.current.top;u({x:B,y:W})}}return m.useEffect(()=>{const L=B=>{const W=B.target;(v==null?void 0:v.contains(W))&&C(B,T)};return document.addEventListener("wheel",L,{passive:!1}),()=>document.removeEventListener("wheel",L,{passive:!1})},[S,v,T,C]),m.useEffect(k,[r,k]),Tr(v,E),Tr(p.content,E),c.jsx(WC,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:Ct(s),onThumbPointerUp:Ct(i),onThumbPositionChange:k,onThumbPointerDown:Ct(a),children:c.jsx(Ce.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:pe(e.onPointerDown,L=>{L.button===0&&(L.target.setPointerCapture(L.pointerId),w.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(L))}),onPointerMove:pe(e.onPointerMove,A),onPointerUp:pe(e.onPointerUp,L=>{const B=L.target;B.hasPointerCapture(L.pointerId)&&B.releasePointerCapture(L.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),w.current=null})})})}),Ls="ScrollAreaThumb",Kh=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Wh(Ls,e.__scopeScrollArea);return c.jsx(Kt,{present:n||o.hasThumb,children:c.jsx(VC,{ref:t,...r})})}),VC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Xt(Ls,n),i=Wh(Ls,n),{onThumbPositionChange:a}=i,l=We(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=Bs(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=GC(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(Ce.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:pe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,x=f.clientY-p.top;i.onThumbPointerDown({x:v,y:x})}),onPointerUp:pe(e.onPointerUp,i.onThumbPointerUp)})});Kh.displayName=Ls;var Ga="ScrollAreaCorner",qh=m.forwardRef((e,t)=>{const n=Xt(Ga,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(KC,{...e,ref:t}):null});qh.displayName=Ga;var KC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Xt(Ga,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return Tr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Tr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(Ce.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 $s(e){return e?parseInt(e,10):0}function Gh(e,t){const n=e/t;return isNaN(n)?0:n}function Fs(e){const t=Gh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function qC(e,t,n,r="ltr"){const o=Fs(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return Xh([l,u],f)(e)}function Yh(e,t,n="ltr"){const r=Fs(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],u=Wa(e,l);return Xh([0,i],[0,a])(u)}function Xh(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 Jh(e,t){return e>0&&e<t}var GC=(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 Bs(e,t){const n=Ct(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Tr(e,t){const n=Ct(t);St(()=>{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 Zh=Bh,YC=Hh,XC=qh;const Qh=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Zh,{ref:r,className:re("relative overflow-hidden",e),...n,children:[c.jsx(YC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(ep,{}),c.jsx(XC,{})]}));Qh.displayName=Zh.displayName;const ep=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Ka,{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:c.jsx(Kh,{className:"relative flex-1 rounded-full bg-border"})}));ep.displayName=Ka.displayName;const zs=m.forwardRef(({className:e,type:t,...n},r)=>c.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}));zs.displayName="Input";const JC="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",ZC="bg-slate-700 border-slate-600 hover:bg-slate-600",QC="bg-slate-600 border-slate-500";function ek({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:u,onDelete:d,showEditTitle:f,showDeleteButton:h,formatDate:p,getDisplayThreadTitle:v,secondaryLine:x,itemClassName:g,activeItemClassName:w}){const b=n===e.threadId,S=t?`${w??QC}`:`${g??ZC}`,T=C=>{C.stopPropagation(),o(e.threadId)};return c.jsxs("div",{onClick:T,className:`${JC} ${S}`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:b?c.jsxs("div",{className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[c.jsx(zs,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),c.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:c.jsx(se.Check,{size:12})}),c.jsx(Ze,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:c.jsx(se.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(se.Calendar,{size:10}),c.jsx("span",{children:p(e.updatedAt||e.createdAt)})]}),x&&c.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:x})]})}),c.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:c.jsxs(Qi,{children:[c.jsx(ea,{asChild:!0,children:c.jsx(Ze,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:c.jsx(se.MoreHorizontal,{size:12})})}),c.jsxs(ds,{align:"end",sideOffset:6,className:"w-44",children:[c.jsxs(Vn,{onClick:C=>{C.preventDefault(),u(e.threadId)},children:[c.jsx(se.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&n!==e.threadId&&c.jsxs(Vn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[c.jsx(se.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),h&&d&&c.jsxs(Vn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[c.jsx(se.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const tp=25,np="thread-manager-view",tk=e=>e==="default"||e==="shared",nk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(np);if(tk(e))return e}catch{}return null};function rk({defaultView:e}={}){const[t,n]=y.useState(()=>nk()??e??"default");y.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(np,t)}catch{}},[t]);const r=y.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const ok=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function Ya({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d,view:f,defaultView:h,onViewChange:p,viewOptions:v,viewState:x,showHeader:g=!0,shareTargets:w,isLoadingShareTargets:b,shareTargetFilter:S}){const{threads:T,sharedThreads:C,currentThreadId:k,setCurrentThreadId:E,isLoading:A,isLoadingSharedThreads:L,actions:B,shareInFlight:W,shareStatus:K,clearShareStatus:H}=Ro(),{createThread:R,deleteThread:G,renameThread:N,shareThread:$}=B,{loadThread:P}=Po(),j=i??k,[U,V]=y.useState(Array.isArray(T)?T:[]),M=y.useRef(U.length>0),F=y.useRef(null),ee=y.useRef(0),[J,ie]=y.useState(null),[q,O]=y.useState(""),[Y,X]=y.useState(!1),[le,D]=y.useState(!1),[te,xe]=y.useState(null),[de,we]=y.useState(""),je=v&&v.length>0?v:ok,De=rk({defaultView:h}),$e=x??De,ke=f??$e.view,Fe=y.useCallback(_=>{f||$e.setView(_),p==null||p(_)},[f,p,$e]),Ke=je.find(_=>_.key===ke)??je[0],Je=_=>{xe(_),we(""),D(!0)},qe=()=>{D(!1),xe(null),we(""),H()},tt=y.useCallback(async _=>{if(!(!te||W)&&_.id)try{await $(te,_.id),setTimeout(()=>qe(),600)}catch(ne){console.error("Failed to share thread:",ne)}},[qe,W,te,$]),bt=y.useMemo(()=>{const _=w??[],ne=de.trim().toLowerCase();return ne?S?_.filter(me=>S(me,ne)):_.filter(me=>`${me.label} ${me.secondaryLabel??""}`.toLowerCase().includes(ne)):_},[w,de,S]),st=ke==="shared",Te=st?C:U,Le=st?L:A,ot=st?"No shared conversations yet":"No conversations yet",ct=_=>{const ne=_.sharedAt?` • ${ht(_.sharedAt)}`:"";return`Shared by ${_.sharedByUserId}${ne}`},Nt=_=>"sharedByUserId"in _;y.useEffect(()=>{const _=Array.isArray(T)?T:[];if(_.length>0){M.current=!0,V(_);return}A||(M.current=!1,V(_))},[T,A]),y.useEffect(()=>{if(!F.current)return;const _=F.current.querySelector("[data-radix-scroll-area-viewport]");if(!_)return;let ne=null,me=null;return ne=requestAnimationFrame(()=>{me=requestAnimationFrame(()=>{_.scrollTop=ee.current})}),()=>{ne!==null&&cancelAnimationFrame(ne),me!==null&&cancelAnimationFrame(me)}},[U]);const it=async _=>{try{E(_),await P(_),a==null||a(_),l==null||l(_)}catch(ne){console.error("Failed to select thread:",ne)}},Ye=async()=>{try{X(!0);const _=await R();_&&(u==null||u(_),a==null||a(_))}catch(_){console.error("Failed to create thread:",_)}finally{X(!1)}},Mt=async(_,ne)=>{if(ne.stopPropagation(),!!confirm("Delete this thread?")){if(F.current){const me=F.current.querySelector("[data-radix-scroll-area-viewport]");me&&(ee.current=me.scrollTop)}try{await G(_),d==null||d(_)}catch(me){console.error("Failed to delete thread:",me)}}},ze=(_,ne)=>{ne.stopPropagation(),ie(_.threadId),O(_.title||`Thread ${_.threadId.slice(0,8)}`)},Be=async _=>{if(q.trim())try{await N(_,q.trim()),ie(null),O("")}catch(ne){console.error("Failed to update title:",ne)}},yt=()=>{ie(null),O("")},ht=_=>{if(!_)return"";try{const ne=new Date(_),Ue=new Date().getTime()-ne.getTime(),Pe=Math.floor(Ue/(1e3*60*60*24));return Pe===0?ne.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Pe===1?"Yesterday":Pe<7?`${Pe} days ago`:ne.toLocaleDateString()}catch{return""}},He=_=>_.title||`Thread ${_.threadId.slice(0,8)}`,mt=_=>{const ne=He(_);return ne.length<=tp?ne:`${ne.slice(0,tp)}...`};return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[g&&c.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&&c.jsx("div",{className:"flex justify-end",children:c.jsxs(Ze,{onClick:Ye,disabled:Y||A,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:Y?"Creating...":"New Chat",children:[c.jsx(se.Edit3,{size:16}),c.jsx("span",{children:"New chat"})]})}),c.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:[c.jsx("span",{children:"Current View"}),c.jsxs(Qi,{children:[c.jsx(ea,{asChild:!0,children:c.jsx(Ze,{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:Ke.label})}),c.jsx(ds,{align:"start",sideOffset:6,className:"w-40",children:je.map(_=>c.jsxs(Vn,{className:"justify-between text-[12px]",onClick:ne=>{ne.preventDefault(),Fe(_.key)},children:[c.jsx("span",{children:_.label}),ke===_.key&&c.jsx(se.Check,{className:"h-3 w-3"})]},_.key))})]})]})]}),c.jsx(Qh,{ref:F,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:Le?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(se.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):Te.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(se.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:ot})]}):Te.slice().sort((_,ne)=>new Date(ne.updatedAt||ne.createdAt||"").getTime()-new Date(_.updatedAt||_.createdAt||"").getTime()).map(_=>c.jsx(ek,{thread:_,isActive:j===_.threadId,editingThreadId:J,editingTitle:q,onSelect:it,onStartEditing:ze,onEditingTitleChange:ne=>O(ne),onSaveEditing:Be,onCancelEditing:yt,onShare:()=>Je(_.threadId),onDelete:Mt,showEditTitle:r,showDeleteButton:n,formatDate:ht,getDisplayThreadTitle:mt,secondaryLine:st&&Nt(_)?ct(_):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},_.threadId))})}),c.jsx(Qf,{open:le,onOpenChange:_=>!_&&qe(),children:c.jsxs(Aa,{className:"max-w-md p-0",children:[c.jsx(ja,{children:c.jsx(_a,{children:"Share thread"})}),c.jsxs(Rh,{children:[c.jsx(Ph,{autoFocus:!0,value:de,onValueChange:_=>we(_),placeholder:"Search for recipients..."}),c.jsxs(Oh,{children:[K&&c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[W&&c.jsx(se.Loader2,{className:"h-3 w-3 animate-spin"}),c.jsx("span",{className:K.startsWith("Failed")?"text-red-500":K.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:K})]}),c.jsx(Dh,{children:b?c.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(se.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),bt.length>0&&c.jsx(Lh,{heading:"Recipients",children:bt.map(_=>c.jsx($h,{onSelect:()=>tt(_),children:c.jsxs("div",{className:"flex flex-col items-start text-sm",children:[c.jsx("span",{className:"font-medium",children:_.label}),_.secondaryLabel&&c.jsx("span",{className:"text-xs text-muted-foreground",children:_.secondaryLabel})]})},_.id))})]})]})]})})]})}function Er(e){if(!(typeof globalThis>"u"))return globalThis[e]}function sk(e){if(typeof e!="string")return;const t=e.trim();if(t)return xn(t)}function rp(){const e=[Er("__API_BASE_URL__"),Er("__CHAT_API_BASE_URL__"),Er("__CHAT_API_URL__")];for(const t of e){const n=sk(t);if(n)return n}}function op(){const e=[Er("__API_AUTH_TOKEN__"),Er("__CHAT_API_KEY__"),Er("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function sp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return xn(t);return xn()}function ip(){const e={},t=rp(),n=op();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function ap(){const e=ip(),t=Sn.getAuthToken(),n=rp();return{apiBaseUrl:sp(e.baseUrl,Sn.baseUrl,n),apiKey:t||e.apiKey||op()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const lp="chat-settings";function ik(){try{const e=localStorage.getItem(lp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function ak(e){try{const t={...e,apiBaseUrl:xn(e.apiBaseUrl)};localStorage.setItem(lp,JSON.stringify(t)),t.apiKey&&Sn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function lk(){const e=ap(),t=ik(),n=Sn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:sp(Sn.baseUrl,r,e.apiBaseUrl)}}function ck(e){Sn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),ak(e)}var uk="Label",cp=m.forwardRef((e,t)=>c.jsx(Ce.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())}}));cp.displayName=uk;var up=cp;const dk=go.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Jt=m.forwardRef(({className:e,...t},n)=>c.jsx(up,{ref:n,className:re(dk(),e),...t}));Jt.displayName=up.displayName;function dp(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var fp=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"}),fk="VisuallyHidden",hk=m.forwardRef((e,t)=>c.jsx(Ce.span,{...e,ref:t,style:{...fp,...e.style}}));hk.displayName=fk;var pk=[" ","Enter","ArrowUp","ArrowDown"],mk=[" ","Enter"],er="Select",[Hs,Us,gk]=wi(er),[Ir,LT]=wn(er,[gk,Yo]),Ws=Yo(),[xk,Pn]=Ir(er),[wk,vk]=Ir(er),hp=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:v}=e,x=Ws(t),[g,w]=m.useState(null),[b,S]=m.useState(null),[T,C]=m.useState(!1),k=Do(u),[E,A]=ur({prop:r,defaultProp:o??!1,onChange:s,caller:er}),[L,B]=ur({prop:i,defaultProp:a,onChange:l,caller:er}),W=m.useRef(null),K=g?v||!!g.closest("form"):!0,[H,R]=m.useState(new Set),G=Array.from(H).map(N=>N.props.value).join(";");return c.jsx(xu,{...x,children:c.jsxs(xk,{required:p,scope:t,trigger:g,onTriggerChange:w,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:T,onValueNodeHasChildrenChange:C,contentId:At(),value:L,onValueChange:B,open:E,onOpenChange:A,dir:k,triggerPointerDownPosRef:W,disabled:h,children:[c.jsx(Hs.Provider,{scope:t,children:c.jsx(wk,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(N=>{R($=>new Set($).add(N))},[]),onNativeOptionRemove:m.useCallback(N=>{R($=>{const P=new Set($);return P.delete(N),P})},[]),children:n})}),K?c.jsxs(Lp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:L,onChange:N=>B(N.target.value),disabled:h,form:v,children:[L===void 0?c.jsx("option",{value:""}):null,Array.from(H)]},G):null]})})};hp.displayName=er;var pp="SelectTrigger",mp=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Ws(n),i=Pn(pp,n),a=i.disabled||r,l=We(t,i.onTriggerChange),u=Us(n),d=m.useRef("touch"),[f,h,p]=Fp(x=>{const g=u().filter(S=>!S.disabled),w=g.find(S=>S.value===i.value),b=Bp(g,x,w);b!==void 0&&i.onValueChange(b.value)}),v=x=>{a||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return c.jsx(wu,{asChild:!0,...s,children:c.jsx(Ce.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":$p(i.value)?"":void 0,...o,ref:l,onClick:pe(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&v(x)}),onPointerDown:pe(o.onPointerDown,x=>{d.current=x.pointerType;const g=x.target;g.hasPointerCapture(x.pointerId)&&g.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(v(x),x.preventDefault())}),onKeyDown:pe(o.onKeyDown,x=>{const g=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(g&&x.key===" ")&&pk.includes(x.key)&&(v(),x.preventDefault())})})})});mp.displayName=pp;var gp="SelectValue",xp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Pn(gp,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=We(t,l.onValueNodeChange);return St(()=>{u(d)},[u,d]),c.jsx(Ce.span,{...a,ref:f,style:{pointerEvents:"none"},children:$p(l.value)?c.jsx(c.Fragment,{children:i}):s})});xp.displayName=gp;var bk="SelectIcon",wp=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(Ce.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});wp.displayName=bk;var yk="SelectPortal",vp=e=>c.jsx(Xo,{asChild:!0,...e});vp.displayName=yk;var tr="SelectContent",bp=m.forwardRef((e,t)=>{const n=Pn(tr,e.__scopeSelect),[r,o]=m.useState();if(St(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?xo.createPortal(c.jsx(yp,{scope:e.__scopeSelect,children:c.jsx(Hs.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Sp,{...e,ref:t})});bp.displayName=tr;var sn=10,[yp,On]=Ir(tr),Sk="SelectContentImpl",Ck=Ln.createSlot("SelectContent.RemoveScroll"),Sp=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g,...w}=e,b=Pn(tr,n),[S,T]=m.useState(null),[C,k]=m.useState(null),E=We(t,q=>T(q)),[A,L]=m.useState(null),[B,W]=m.useState(null),K=Us(n),[H,R]=m.useState(!1),G=m.useRef(!1);m.useEffect(()=>{if(S)return Bi(S)},[S]),yi();const N=m.useCallback(q=>{const[O,...Y]=K().map(D=>D.ref.current),[X]=Y.slice(-1),le=document.activeElement;for(const D of q)if(D===le||(D==null||D.scrollIntoView({block:"nearest"}),D===O&&C&&(C.scrollTop=0),D===X&&C&&(C.scrollTop=C.scrollHeight),D==null||D.focus(),document.activeElement!==le))return},[K,C]),$=m.useCallback(()=>N([A,S]),[N,A,S]);m.useEffect(()=>{H&&$()},[H,$]);const{onOpenChange:P,triggerPointerDownPosRef:j}=b;m.useEffect(()=>{if(S){let q={x:0,y:0};const O=X=>{var le,D;q={x:Math.abs(Math.round(X.pageX)-(((le=j.current)==null?void 0:le.x)??0)),y:Math.abs(Math.round(X.pageY)-(((D=j.current)==null?void 0:D.y)??0))}},Y=X=>{q.x<=10&&q.y<=10?X.preventDefault():S.contains(X.target)||P(!1),document.removeEventListener("pointermove",O),j.current=null};return j.current!==null&&(document.addEventListener("pointermove",O),document.addEventListener("pointerup",Y,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",Y,{capture:!0})}}},[S,P,j]),m.useEffect(()=>{const q=()=>P(!1);return window.addEventListener("blur",q),window.addEventListener("resize",q),()=>{window.removeEventListener("blur",q),window.removeEventListener("resize",q)}},[P]);const[U,V]=Fp(q=>{const O=K().filter(le=>!le.disabled),Y=O.find(le=>le.ref.current===document.activeElement),X=Bp(O,q,Y);X&&setTimeout(()=>X.ref.current.focus())}),M=m.useCallback((q,O,Y)=>{const X=!G.current&&!Y;(b.value!==void 0&&b.value===O||X)&&(L(q),X&&(G.current=!0))},[b.value]),F=m.useCallback(()=>S==null?void 0:S.focus(),[S]),ee=m.useCallback((q,O,Y)=>{const X=!G.current&&!Y;(b.value!==void 0&&b.value===O||X)&&W(q)},[b.value]),J=r==="popper"?Xa:Cp,ie=J===Xa?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g}:{};return c.jsx(yp,{scope:n,content:S,viewport:C,onViewportChange:k,itemRefCallback:M,selectedItem:A,onItemLeave:F,itemTextRefCallback:ee,focusSelectedItem:$,selectedItemText:B,position:r,isPositioned:H,searchRef:U,children:c.jsx(ss,{as:Ck,allowPinchZoom:!0,children:c.jsx($o,{asChild:!0,trapped:b.open,onMountAutoFocus:q=>{q.preventDefault()},onUnmountAutoFocus:pe(o,q=>{var O;(O=b.trigger)==null||O.focus({preventScroll:!0}),q.preventDefault()}),children:c.jsx(Lo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:q=>q.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(J,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:q=>q.preventDefault(),...w,...ie,onPlaced:()=>R(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:pe(w.onKeyDown,q=>{const O=q.ctrlKey||q.altKey||q.metaKey;if(q.key==="Tab"&&q.preventDefault(),!O&&q.key.length===1&&V(q.key),["ArrowUp","ArrowDown","Home","End"].includes(q.key)){let X=K().filter(le=>!le.disabled).map(le=>le.ref.current);if(["ArrowUp","End"].includes(q.key)&&(X=X.slice().reverse()),["ArrowUp","ArrowDown"].includes(q.key)){const le=q.target,D=X.indexOf(le);X=X.slice(D+1)}setTimeout(()=>N(X)),q.preventDefault()}})})})})})})});Sp.displayName=Sk;var kk="SelectItemAlignedPosition",Cp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Pn(tr,n),i=On(tr,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=We(t,E=>d(E)),h=Us(n),p=m.useRef(!1),v=m.useRef(!0),{viewport:x,selectedItem:g,selectedItemText:w,focusSelectedItem:b}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&x&&g&&w){const E=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),L=s.valueNode.getBoundingClientRect(),B=w.getBoundingClientRect();if(s.dir!=="rtl"){const le=B.left-A.left,D=L.left-le,te=E.left-D,xe=E.width+te,de=Math.max(xe,A.width),we=window.innerWidth-sn,je=Wa(D,[sn,Math.max(sn,we-de)]);a.style.minWidth=xe+"px",a.style.left=je+"px"}else{const le=A.right-B.right,D=window.innerWidth-L.right-le,te=window.innerWidth-E.right-D,xe=E.width+te,de=Math.max(xe,A.width),we=window.innerWidth-sn,je=Wa(D,[sn,Math.max(sn,we-de)]);a.style.minWidth=xe+"px",a.style.right=je+"px"}const W=h(),K=window.innerHeight-sn*2,H=x.scrollHeight,R=window.getComputedStyle(u),G=parseInt(R.borderTopWidth,10),N=parseInt(R.paddingTop,10),$=parseInt(R.borderBottomWidth,10),P=parseInt(R.paddingBottom,10),j=G+N+H+P+$,U=Math.min(g.offsetHeight*5,j),V=window.getComputedStyle(x),M=parseInt(V.paddingTop,10),F=parseInt(V.paddingBottom,10),ee=E.top+E.height/2-sn,J=K-ee,ie=g.offsetHeight/2,q=g.offsetTop+ie,O=G+N+q,Y=j-O;if(O<=ee){const le=W.length>0&&g===W[W.length-1].ref.current;a.style.bottom="0px";const D=u.clientHeight-x.offsetTop-x.offsetHeight,te=Math.max(J,ie+(le?F:0)+D+$),xe=O+te;a.style.height=xe+"px"}else{const le=W.length>0&&g===W[0].ref.current;a.style.top="0px";const te=Math.max(ee,G+x.offsetTop+(le?M:0)+ie)+Y;a.style.height=te+"px",x.scrollTop=O-ee+x.offsetTop}a.style.margin=`${sn}px 0`,a.style.minHeight=U+"px",a.style.maxHeight=K+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,x,g,w,s.dir,r]);St(()=>S(),[S]);const[T,C]=m.useState();St(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const k=m.useCallback(E=>{E&&v.current===!0&&(S(),b==null||b(),v.current=!1)},[S,b]);return c.jsx(Ek,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:k,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:T},children:c.jsx(Ce.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Cp.displayName=kk;var Tk="SelectPopperPosition",Xa=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=sn,...s}=e,i=Ws(n);return c.jsx(vu,{...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)"}})});Xa.displayName=Tk;var[Ek,Ja]=Ir(tr,{}),Za="SelectViewport",kp=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=On(Za,n),i=Ja(Za,n),a=We(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(Hs.Slot,{scope:n,children:c.jsx(Ce.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:pe(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-sn*2,x=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),w=Math.max(x,g);if(w<v){const b=w+p,S=Math.min(v,b),T=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=T>0?T:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});kp.displayName=Za;var Tp="SelectGroup",[Ik,Nk]=Ir(Tp),Ak=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=At();return c.jsx(Ik,{scope:n,id:o,children:c.jsx(Ce.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Ak.displayName=Tp;var Ep="SelectLabel",Ip=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Nk(Ep,n);return c.jsx(Ce.div,{id:o.id,...r,ref:t})});Ip.displayName=Ep;var Vs="SelectItem",[jk,Np]=Ir(Vs),Ap=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Pn(Vs,n),l=On(Vs,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),v=We(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),x=At(),g=m.useRef("touch"),w=()=>{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 c.jsx(jk,{scope:n,value:r,disabled:o,textId:x,isSelected:u,onItemTextChange:m.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(Hs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(Ce.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:pe(i.onFocus,()=>p(!0)),onBlur:pe(i.onBlur,()=>p(!1)),onClick:pe(i.onClick,()=>{g.current!=="mouse"&&w()}),onPointerUp:pe(i.onPointerUp,()=>{g.current==="mouse"&&w()}),onPointerDown:pe(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:pe(i.onPointerMove,b=>{var S;g.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:pe(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:pe(i.onKeyDown,b=>{var T;((T=l.searchRef)==null?void 0:T.current)!==""&&b.key===" "||(mk.includes(b.key)&&w(),b.key===" "&&b.preventDefault())})})})})});Ap.displayName=Vs;var mo="SelectItemText",jp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Pn(mo,n),a=On(mo,n),l=Np(mo,n),u=vk(mo,n),[d,f]=m.useState(null),h=We(t,w=>f(w),l.onItemTextChange,w=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,w,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:g}=u;return St(()=>(x(v),()=>g(v)),[x,g,v]),c.jsxs(c.Fragment,{children:[c.jsx(Ce.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?xo.createPortal(s.children,i.valueNode):null]})});jp.displayName=mo;var _p="SelectItemIndicator",Mp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Np(_p,n).isSelected?c.jsx(Ce.span,{"aria-hidden":!0,...r,ref:t}):null});Mp.displayName=_p;var Qa="SelectScrollUpButton",Rp=m.forwardRef((e,t)=>{const n=On(Qa,e.__scopeSelect),r=Ja(Qa,e.__scopeSelect),[o,s]=m.useState(!1),i=We(t,r.onScrollButtonChange);return St(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Op,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Rp.displayName=Qa;var el="SelectScrollDownButton",Pp=m.forwardRef((e,t)=>{const n=On(el,e.__scopeSelect),r=Ja(el,e.__scopeSelect),[o,s]=m.useState(!1),i=We(t,r.onScrollButtonChange);return St(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Op,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Pp.displayName=el;var Op=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=On("SelectScrollButton",n),i=m.useRef(null),a=Us(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),St(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),c.jsx(Ce.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:pe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:pe(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:pe(o.onPointerLeave,()=>{l()})})}),_k="SelectSeparator",Dp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ce.div,{"aria-hidden":!0,...r,ref:t})});Dp.displayName=_k;var tl="SelectArrow",Mk=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ws(n),s=Pn(tl,n),i=On(tl,n);return s.open&&i.position==="popper"?c.jsx(bu,{...o,...r,ref:t}):null});Mk.displayName=tl;var Rk="SelectBubbleInput",Lp=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=We(r,o),i=dp(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(Ce.select,{...n,style:{...fp,...n.style},ref:s,defaultValue:t})});Lp.displayName=Rk;function $p(e){return e===""||e===void 0}function Fp(e){const t=Ct(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Bp(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=Pk(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Pk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ok=hp,zp=mp,Dk=xp,Lk=wp,$k=vp,Hp=bp,Fk=kp,Up=Ip,Wp=Ap,Bk=jp,zk=Mp,Vp=Rp,Kp=Pp,qp=Dp;const Gp=Ok,Yp=Dk,nl=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(zp,{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,c.jsx(Lk,{asChild:!0,children:c.jsx(se.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));nl.displayName=zp.displayName;const Xp=m.forwardRef(({className:e,...t},n)=>c.jsx(Vp,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(se.ChevronUp,{className:"h-4 w-4"})}));Xp.displayName=Vp.displayName;const Jp=m.forwardRef(({className:e,...t},n)=>c.jsx(Kp,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(se.ChevronDown,{className:"h-4 w-4"})}));Jp.displayName=Kp.displayName;const rl=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx($k,{children:c.jsxs(Hp,{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:[c.jsx(Xp,{}),c.jsx(Fk,{className:re("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(Jp,{})]})}));rl.displayName=Hp.displayName;const Hk=m.forwardRef(({className:e,...t},n)=>c.jsx(Up,{ref:n,className:re("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Hk.displayName=Up.displayName;const nr=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Wp,{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:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(zk,{children:c.jsx(se.Check,{className:"h-4 w-4"})})}),c.jsx(Bk,{children:t})]}));nr.displayName=Wp.displayName;const Uk=m.forwardRef(({className:e,...t},n)=>c.jsx(qp,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));Uk.displayName=qp.displayName;var Wk="Separator",Zp="horizontal",Vk=["horizontal","vertical"],Qp=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=Zp,...o}=e,s=Kk(r)?r:Zp,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(Ce.div,{"data-orientation":s,...a,...o,ref:t})});Qp.displayName=Wk;function Kk(e){return Vk.includes(e)}var em=Qp;const tm=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(em,{ref:o,decorative:n,orientation:t,className:re("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));tm.displayName=em.displayName;const qk=Ia,Gk=ES,Yk=Na,nm=m.forwardRef(({className:e,...t},n)=>c.jsx(so,{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}));nm.displayName=so.displayName;const Xk=go.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"}}),rm=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(Yk,{children:[c.jsx(nm,{}),c.jsxs(io,{ref:o,className:re(Xk({side:e}),t),...r,children:[n,c.jsxs(Zf,{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:[c.jsx(se.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));rm.displayName=io.displayName;const om=({className:e,...t})=>c.jsx("div",{className:re("flex flex-col space-y-2 text-center sm:text-left",e),...t});om.displayName="SheetHeader";const sm=m.forwardRef(({className:e,...t},n)=>c.jsx(Jn,{ref:n,className:re("text-lg font-semibold text-foreground",e),...t}));sm.displayName=Jn.displayName;const im=m.forwardRef(({className:e,...t},n)=>c.jsx(Is,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));im.displayName=Is.displayName;var Ks="Switch",[Jk,$T]=wn(Ks),[Zk,Qk]=Jk(Ks),am=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),v=We(t,S=>p(S)),x=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[w,b]=ur({prop:o,defaultProp:s??!1,onChange:u,caller:Ks});return c.jsxs(Zk,{scope:n,checked:w,disabled:a,children:[c.jsx(Ce.button,{type:"button",role:"switch","aria-checked":w,"aria-required":i,"data-state":dm(w),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:pe(e.onClick,S=>{b(T=>!T),g&&(x.current=S.isPropagationStopped(),x.current||S.stopPropagation())})}),g&&c.jsx(um,{control:h,bubbles:!x.current,name:r,value:l,checked:w,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});am.displayName=Ks;var lm="SwitchThumb",cm=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Qk(lm,n);return c.jsx(Ce.span,{"data-state":dm(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});cm.displayName=lm;var eT="SwitchBubbleInput",um=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=We(i,s),l=dp(n),u=au(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});um.displayName=eT;function dm(e){return e?"checked":"unchecked"}var fm=am,tT=cm;const Dn=m.forwardRef(({className:e,...t},n)=>c.jsx(fm,{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:c.jsx(tT,{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")})}));Dn.displayName=fm.displayName;const nT={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function rT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=y.useState(!1),[s,i]=y.useState(!1),[a,l]=y.useState(e),[u,d]=y.useState(!1),{toast:f}=Pa();y.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),y.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(nT),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},v=()=>{l(e),d(!1),o(!1)},x=async()=>{try{const w=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${w.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(qk,{open:r,onOpenChange:o,children:[c.jsx(Gk,{asChild:!0,children:c.jsxs(Ze,{variant:"outline",size:"sm",className:n,children:[c.jsx(se.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(Rf,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(rm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(om,{children:[c.jsx(sm,{children:"Chat Settings"}),c.jsx(im,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(lo,{children:[c.jsx(co,{className:"pb-3",children:c.jsxs(uo,{className:"text-lg flex items-center gap-2",children:[c.jsx(se.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(fo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Jt,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(zs,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(w=>({...w,api:{...w.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(Ze,{variant:"outline",onClick:x,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Jt,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(Dn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(w=>({...w,api:{...w.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(Jt,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(zs,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(w=>({...w,api:{...w.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(Ze,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(se.EyeOff,{className:"h-4 w-4"}):c.jsx(se.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(lo,{children:[c.jsx(co,{className:"pb-3",children:c.jsxs(uo,{className:"text-lg flex items-center gap-2",children:[c.jsx(se.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(fo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Jt,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(Gp,{value:a.ui.layout,onValueChange:g=>l(w=>({...w,ui:{...w.ui,layout:g}})),children:[c.jsx(nl,{children:c.jsx(Yp,{})}),c.jsxs(rl,{children:[c.jsx(nr,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(nr,{value:"fullscreen",children:"Fullscreen"}),c.jsx(nr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Jt,{htmlFor:"theme",children:"Theme"}),c.jsxs(Gp,{value:a.ui.theme,onValueChange:g=>l(w=>({...w,ui:{...w.ui,theme:g}})),children:[c.jsx(nl,{children:c.jsx(Yp,{})}),c.jsxs(rl,{children:[c.jsx(nr,{value:"light",children:"Light"}),c.jsx(nr,{value:"dark",children:"Dark"}),c.jsx(nr,{value:"system",children:"System"})]})]})]}),c.jsx(tm,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Jt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(Dn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(w=>({...w,ui:{...w.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Jt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(Dn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(w=>({...w,ui:{...w.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Jt,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(Dn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(w=>({...w,ui:{...w.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(lo,{children:[c.jsx(co,{className:"pb-3",children:c.jsxs(uo,{className:"text-lg flex items-center gap-2",children:[c.jsx(se.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(fo,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Jt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(Dn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(w=>({...w,behavior:{...w.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Jt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(Dn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(w=>({...w,behavior:{...w.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Jt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(Dn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(w=>({...w,behavior:{...w.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(Ze,{variant:"outline",onClick:p,children:[c.jsx(se.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ze,{variant:"outline",onClick:v,children:"Cancel"}),c.jsxs(Ze,{onClick:h,disabled:!u,children:[c.jsx(se.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function oT({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){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=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=y.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(Oo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(Os,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(Oo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(Ya,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(Os,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(Oo,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(Ya,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(Os,{onError:s.onError,enableFileUpload:!0})})]})})}Ee.ChatApi=tc,Ee.ChatInput=Tc,Ee.ChatInterface=Os,Ee.ChatProviders=Oo,Ee.ChatSettings=rT,Ee.MarkdownContent=Sr,Ee.MessageComponent=Ps,Ee.MessageList=La,Ee.ThreadManager=Ya,Ee.applySettings=ck,Ee.buildCheckpointIndex=ac,Ee.buildMessagePreviewMap=ex,Ee.chatApiClient=Sn,Ee.default=oT,Ee.del=di,Ee.get=Vt,Ee.getChatToken=Zl,Ee.getCurrentSettings=lk,Ee.getDefaultApiConfig=ip,Ee.getDefaultChatSettings=ap,Ee.onChatTokenChanged=Ql,Ee.post=jo,Ee.put=ec,Ee.setChatToken=Ao,Ee.useApi=fi,Ee.useChatStream=wc,Ee.useMessagesReducer=hc,Ee.useStream=Cc,Ee.useThreadState=Po,Ee.useThreads=Ro,Object.defineProperties(Ee,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
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=Ah(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=Ah(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 Rh{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 Oh{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 Hn{constructor(t){this.options=t||sr,this.options.renderer=this.options.renderer||new wl,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Rh,this.slugger=new Oh}static parse(t,n){return new Hn(n).parse(t)}static parseInline(t,n){return new Hn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,p,m,f,v,g,x,y,b,S,E,C,T;const k=t.length;for(o=0;o<k;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,Nh(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],S=b.checked,E=b.task,y="",b.task&&(C=this.renderer.checkbox(S),x?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+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=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):y+=C),y+=this.parse(b.tokens,x),m+=this.renderer.listitem(y,E,S);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<k&&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 j='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}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 Ys{constructor(t){this.options=t||sr}preprocess(t){return t}postprocess(t){return t}}Mg(Ys,"passThroughHooks",new Set(["preprocess","postprocess"]));function tE(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>"+Pt(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 Dh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...Ce.defaults,...s};const i=tE(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(ZT(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&&Ce.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;Ce.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(Ce.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&&Ce.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function Ce(e,t,n){return Dh(zn.lex,Hn.parse)(e,t,n)}Ce.options=Ce.setOptions=function(e){return Ce.defaults={...Ce.defaults,...e},FT(Ce.defaults),Ce},Ce.getDefaults=Th,Ce.defaults=sr,Ce.use=function(...e){const t=Ce.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=Ce.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=Ce.defaults.renderer||new wl;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=Ce.defaults.tokenizer||new vl;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=Ce.defaults.hooks||new Ys;for(const s in n.hooks){const i=o[s];Ys.passThroughHooks.has(s)?o[s]=a=>{if(Ce.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=Ce.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}}Ce.setOptions(r)})},Ce.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(Ce,r)),r.type){case"table":{for(const o of r.header)n=n.concat(Ce.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(Ce.walkTokens(s.tokens,t));break}case"list":{n=n.concat(Ce.walkTokens(r.items,t));break}default:Ce.defaults.extensions&&Ce.defaults.extensions.childTokens&&Ce.defaults.extensions.childTokens[r.type]?Ce.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(Ce.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(Ce.walkTokens(r.tokens,t)))}return n},Ce.parseInline=Dh(zn.lexInline,Hn.parseInline),Ce.Parser=Hn,Ce.parser=Hn.parse,Ce.Renderer=wl,Ce.TextRenderer=Rh,Ce.Lexer=zn,Ce.lexer=zn.lex,Ce.Tokenizer=vl,Ce.Slugger=Oh,Ce.Hooks=Ys,Ce.parse=Ce,Ce.options,Ce.setOptions,Ce.use,Ce.walkTokens,Ce.parseInline,Hn.parse,zn.lex;function jr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{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 Ce.parse=="function"?Ce.parse(i):Ce(i)}return typeof Ce.parse=="function"?Ce.parse(e):Ce(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 nE({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 rE({artifact:e}){const[t,n]=w.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=w.useState(u.jsx(de.Clock,{className:"w-4 h-4"})),[s,i]=w.useState("Processing");return w.useEffect(()=>{switch(e.status||"processing"){case"completed":n("bg-green-500/20 text-green-700 dark:text-green-300"),o(u.jsx(de.CheckCircle,{className:"w-4 h-4"})),i("Completed");break;case"failed":n("bg-red-500/20 text-red-700 dark:text-red-300"),o(u.jsx(de.ExternalLink,{className:"w-4 h-4 rotate-45"})),i("Failed");break;case"pending":n("bg-blue-500/20 text-blue-700 dark:text-blue-300"),o(u.jsx(de.Clock,{className:"w-4 h-4"})),i("Pending");break;default:n("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),o(u.jsx(de.Clock,{className:"w-4 h-4"})),i("Processing")}},[e.status]),u.jsxs("div",{className:"rounded-lg border border-blue-200 dark:border-blue-900/50 bg-blue-50 dark:bg-blue-950/20 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"mt-1 flex-shrink-0",children:u.jsx(de.Search,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100",children:"Research Task"}),u.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300 mt-1",children:["Task ID: ",u.jsxs("code",{className:"font-mono text-xs bg-blue-100 dark:bg-blue-900/30 px-2 py-1 rounded",children:[e.task_id.slice(0,8),"..."]})]})]})]}),u.jsxs("div",{className:`inline-flex items-center gap-2 px-3 py-1 rounded-full text-sm font-medium ${t}`,children:[r,u.jsx("span",{children:s})]}),e.query&&u.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200 bg-white dark:bg-blue-900/30 rounded px-3 py-2",children:[u.jsx("p",{className:"font-medium text-xs text-blue-600 dark:text-blue-400 mb-1",children:"Query:"}),u.jsx("p",{className:"line-clamp-2",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"text-sm text-blue-900 dark:text-blue-100 bg-white dark:bg-blue-900/30 rounded px-3 py-2 space-y-2",children:[u.jsx("p",{className:"font-semibold text-xs text-blue-600 dark:text-blue-400",children:"Results:"}),u.jsx(jr,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),e.progress_url&&u.jsx("div",{className:"pt-2",children:u.jsxs("a",{href:e.progress_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white dark:bg-blue-700 dark:hover:bg-blue-600 rounded-md text-sm font-medium transition-colors",children:[u.jsx("span",{children:"Monitor Progress"}),u.jsx(de.ExternalLink,{className:"w-3.5 h-3.5"})]})}),e.createdAt&&u.jsxs("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})}function oE({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>Av(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(rE,{artifact:{type:"research_task_info",task_id:e.task_id,progress_url:e.progress_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(nE,{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 bl=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}));bl.displayName="Card";const yl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex flex-col space-y-1.5 p-6",e),...t}));yl.displayName="CardHeader";const Sl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:re("text-2xl font-semibold leading-none tracking-tight",e),...t}));Sl.displayName="CardTitle";const Cl=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Cl.displayName="CardDescription";const Tl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("p-6 pt-0",e),...t}));Tl.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";function sE({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=pr(s);a=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:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(bl,{className:re("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(yl,{className:"pb-3",children:[u.jsx(Sl,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(Cl,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(Tl,{className:"pt-0 pb-3",children:a}),u.jsx(Lh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(ut,{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:r||!o,children:"Reject"}),u.jsx(ut,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const iE="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 $h({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:iE,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:pr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:pr(e)})}function aE({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(de.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}function lE({message:e,viewMode:t,isStreaming:n=!1}){const o=Ai(e).name||"tool",s=l=>{if(l==null)return null;const c=typeof l=="string"?Ni(l)??l:l;if(c&&typeof c=="object")return u.jsx($h,{data:c});const d=typeof c=="string"?c:(()=>{try{return pr(c)}catch{return String(c??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:d})},i=l=>{if(l==null)return null;const{content:c,isMarkdown:d}=Sv(l);return d?u.jsx(jr,{content:c,className:"text-current"}):s(l)},a=()=>{const l=e.content.find(p=>p.type!=="tool_call");if(!l)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(l.type==="text"){const m=(l.text??"").trim();if(!m)return null;const f=Vr(m);return i(f)}const c=Wr(l),d=Vr(c);return i(d)};return u.jsxs("div",{className:"space-y-2",children:[u.jsx(aE,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function cE(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=xl(),[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??""),S=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const E=S[1],C=v.name||`file_${E}`,T=v.mimeType||"application/octet-stream";p({id:E,name:C,mimeType:T});return}if(b.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const E=r({title:"Fetching file...",description:"",open:!0});try{const C=await Xc(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(k=>!k||typeof k!="object"||!((k.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof k.size=="number"?k.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=E.update)==null||x.call(E,{id:E.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=E.update)==null||y.call(E,{id:E.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(S=>({...S,[g]:!1}))}},[t,o,r,n,p]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function uE({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(jr,{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(ut,{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(de.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(de.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function dE({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:re("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function Fh(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const Xs=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,showArtifactPreviews:m=!0,customStyles:f={},onEdit:v,onRegenerate:g,onCancelEdit:x,onCopy:y,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:E,onInterruptActionEnd:C,checkpointCandidates:T=[],activeCheckpointId:k=null,onSelectCheckpoint:j,defaultCheckpointId:D=null,messageParentCheckpointId:B=null}){const[W,K]=w.useState(!1),[z,_]=w.useState("preview"),[Y,N]=w.useState(!1),{currentThreadId:$}=Uo(),{respondToInterrupt:R}=Wo(),I=l==="phone"||l==="half-screen",H=t.role,q=H==="tool",P=w.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),O=!!P,X=!(r&&H!=="user"),{uploadingFiles:J,handleFileClick:se,fileViewerOpen:V,currentFileInfo:L,closeFileViewer:Z}=cE({allowFileOpen:X,currentThreadId:$}),Q=w.useMemo(()=>{switch(H){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[H]),ce=w.useMemo(()=>{if(P)return"";const M=t.content;return Array.isArray(M)?Cv(M):""},[P,t]),F=w.useMemo(()=>{if(P)return{};const M=t.content;return Array.isArray(M)?Ai(t):{}},[P,t]),oe=w.useMemo(()=>q?!!(t.additionalKwargs??{}).toolStreaming:!1,[q,t]),we=w.useMemo(()=>{if(P)return[];const M=t.content;return Array.isArray(M)?M.filter(ee=>ee.type==="image_url"):[]},[P,t]),fe=w.useMemo(()=>{if(P)return[];const M=t.content;return Array.isArray(M)?M.filter(ee=>ee.type==="file"):[]},[P,t]),xe=w.useMemo(()=>{if(P)return[];const M=t.content;return Array.isArray(M)?M.filter(ee=>ee.type==="interrupt"):[]},[P,t]),_e=(b==null?void 0:b.id)??(b==null?void 0:b.interrupt_id),$e=Ho(_e),Ue=b==null?void 0:b.value,Ne=w.useMemo(()=>{if(P)return"";const M=t.content;return Array.isArray(M)?Tv(M):""},[P,t]),Oe=w.useMemo(()=>P||!m?null:t.artifact||null,[P,t,m]),Ye=w.useCallback(async()=>{const M=q?Ne:ce;async function ee(ve){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(ve);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const ae=new Blob([ve],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":ae})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ee(M),K(!0),setTimeout(()=>K(!1),2e3),y==null||y(M)}catch(ve){console.error("Failed to copy:",ve)}},[q,Ne,ce,y]),We=w.useCallback(()=>{if(!v||!t.id)return;const M=(q?Ne:ce)??"",ee="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,M,ee)},[v,t.id,q,Ne,ce,t]),Je=w.useCallback(()=>{g==null||g(n)},[g,n]),ot=w.useCallback(()=>{const ee=re(I?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Q);switch(H){case"user":return u.jsx(de.User,{className:ee});case"assistant":return u.jsx(de.Bot,{className:ee});case"tool":return u.jsx(de.Wrench,{className:ee});default:return u.jsx(de.Bot,{className:ee})}},[I,Q,H]),nt=w.useCallback(()=>{const M="group relative mb-4 flex w-full";switch(H){case"user":return re(M,"justify-end");case"assistant":case"tool":case"system":return re(M,"justify-start");default:return M}},[H]),Ze=w.useCallback(()=>{const M=re("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",I&&"px-3 py-2 text-sm");if(O)return re(M,"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(H){case"user":return re(M,"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(M,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return re(M,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return re(M,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return re(M,"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")}},[I,O,H]),Ae=w.useCallback(async M=>{if(S)return;const ee=Ho((M==null?void 0:M.id)??(M==null?void 0:M.interrupt_id));if(!ee){console.warn("Interrupt part missing id",M);return}try{E==null||E(),await R(ee,!0)}catch(ve){console.error("Failed to approve interrupt:",ve)}finally{C==null||C()}},[S,C,E,R]),Be=w.useCallback(async M=>{if(S)return;const ee=Ho((M==null?void 0:M.id)??(M==null?void 0:M.interrupt_id));if(!ee){console.warn("Interrupt part missing id",M);return}try{E==null||E(),await R(ee,!1)}catch(ve){console.error("Failed to reject interrupt:",ve)}finally{C==null||C()}},[S,C,E,R]),et=w.useCallback(({part:M,i:ee})=>{if(M.type==="text"){const ve=M.text??"",ae=ve.trim(),ke=Ni(ae);return ke&&H!=="tool"?u.jsx($h,{data:ke},ee):H==="user"&&c&&ae.length>d?u.jsx(uE,{text:ae,expanded:Y,onExpandedChange:N,previewLength:d,isCompact:I},ee):u.jsx(jr,{content:ve,allowHtml:!1},ee)}if(M.type==="image_url"){const ve=M;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:ve.url,alt:ve.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},ee)}if(M.type==="file"){const ve=M,ae=ve.name||"file";return u.jsxs("a",{href:ve.url,onClick:ke=>se(ke.nativeEvent,ve,ee),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
129
+ dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[J[ee]?u.jsx(de.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[ae,J[ee]?" (processing)":""]})]},ee)}if(M.type==="interrupt"){const ve=M,ae=Ho((ve==null?void 0:ve.id)??(ve==null?void 0:ve.interrupt_id)),ke=!!($e&&ae&&ae===$e),Te=ke?Ue??(ve==null?void 0:ve.value):ve==null?void 0:ve.value,it=ae?{...ve,id:ae,interrupt_id:ae}:ve;return u.jsx(sE,{interruptPart:it,onApprove:Ae,onReject:Be,disabled:S,isActive:ke,payload:Te},ee)}return null},[se,J,Ae,Be,H,c,d,Y,I,$e,Ue,b,S,xe]),ct=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(de.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),Et=w.useCallback(()=>{const M=ce.trim().length>0||we.length>0||fe.length>0||xe.length>0;if(!q&&fe.length>0&&!r)return ct();if(!q&&!M&&!r)return null;if(q)return!p&&Oe?null:p?u.jsx(lE,{message:t,viewMode:z,isStreaming:oe},t.id):null;if(!q&&!P){const ee=t,ve=u.jsx("div",{className:"space-y-2",children:ee.content.map((ae,ke)=>u.jsx(et,{part:ae,i:ke},ke))});return r?u.jsxs("div",{"aria-busy":"true",role:"status",children:[ve,u.jsx(dE,{className:Q})]}):ve}},[ce,we.length,fe.length,xe.length,r,q,z,p,Oe,ct,Q]),st=w.useMemo(()=>P?"Assistant":Ev(t),[P,t]),Ve=w.useMemo(()=>P?[]:Array.isArray(T)?T:[],[T,P]),It=w.useMemo(()=>{var M;return Ve.length?D&&Ve.some(ee=>ee.id===D)?D:((M=Ve[0])==null?void 0:M.id)??null:null},[D,Ve]),Ke=w.useMemo(()=>!Ve.length||!k?null:Ve.some(M=>M.id===k)?k:null,[k,Ve])??It,yt=H==="user"&&Ve.length>0&&typeof j=="function",ht=w.useCallback((M,ee=!1)=>{if(!j)return;const ve=(M==null?void 0:M.id)??null,ae=(M==null?void 0:M.parentId)??B??null;j(ve,ae,ee)},[B,j]),qe=w.useMemo(()=>Ke?Ve.findIndex(M=>M.id===Ke):-1,[Ke,Ve]),gt=w.useMemo(()=>qe<0?null:Ve[qe]??null,[qe,Ve]);return q&&!p&&!Oe?null:O&&P?u.jsx("div",{className:re(nt(),f.container),children:u.jsxs("div",{className:re(Ze(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(de.Bot,{className:re("h-4 w-4",Q)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(jr,{content:P.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:re(nt(),f.container),children:u.jsxs("div",{className:re(Ze(),f.content),children:[(i||a||q)&&u.jsxs("div",{className:re("flex items-center justify-between mb-2 pb-2 border-b border-current/10",I&&"mb-1 pb-1",Q,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[ot(),a&&st&&u.jsx("span",{className:re("font-medium",I?"text-xs":"text-sm"),children:st}),q&&u.jsxs(yh,{variant:"outline",className:re("text-xs flex items-center gap-1 cursor-pointer select-none",Q,"border border-current/40",I&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":z==="expanded",onClick:()=>_(M=>M==="expanded"?"preview":"expanded"),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),_(ee=>ee==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:F.name??"Tool Output"}),F.toolCallId&&u.jsx("span",{className:"opacity-70",children:F.toolCallId.slice(0,8)}),z==="expanded"?u.jsx(de.ChevronUp,{className:"h-3 w-3"}):u.jsx(de.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[yt&&gt&&qe>=0&&u.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{type:"button",className:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",qe<Ve.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(qe>=Ve.length-1)return;const M=Ve[qe+1];M&&ht(M)},"aria-label":"Older checkpoint (back in time)",disabled:qe>=Ve.length-1,children:u.jsx(de.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[Ve.length-qe," / ",Ve.length]})}),u.jsx("button",{type:"button",className:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",qe>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(!(qe<=0))if(qe===1)ht(null,!0);else{const M=Ve[qe-1];M&&ht(M,!1)}},"aria-label":"Newer checkpoint (forward in time)",disabled:qe<=0,children:u.jsx(de.ChevronRight,{className:"h-3 w-3"})})]})}),i&&t.createdAt&&u.jsx("time",{className:re("text-xs opacity-60",Q,I&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:re("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>Ye(),className:re("h-6 w-6 p-0 hover:bg-foreground/10",Q,I&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(de.Copy,{className:re(W?"text-success":Q,I?"h-3 w-3":"h-4 w-4")})})}),H==="user"&&v&&u.jsx(ut,{variant:"ghost",size:"sm",onClick:We,className:re("h-6 w-6 p-0 hover:bg-foreground/10",Q,I&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(de.Edit,{className:re(Q,I?"h-3 w-3":"h-4 w-4")})}),H==="assistant"&&g&&u.jsx(ut,{variant:"ghost",size:"sm",onClick:Je,className:re("h-6 w-6 p-0 hover:bg-foreground/10",Q,I&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(de.RotateCcw,{className:re(Q,I?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[Et(),m&&Oe&&u.jsx("div",{className:"mt-3",children:u.jsx(oE,{artifact:Oe,idx:0})})]}),q&&z==="expanded"&&(F.toolCallId||F.name)&&u.jsxs("div",{className:re("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",I&&"text-xs"),children:[F.name&&u.jsxs("div",{children:["Function: ",F.name]}),F.toolCallId&&u.jsxs("div",{children:["Call ID: ",F.toolCallId]})]}),!(i||a||q)&&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(ut,{variant:"ghost",size:"sm",onClick:()=>Ye(),className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(de.Copy,{className:re(W?"text-success":"text-current",I?"h-3 w-3":"h-4 w-4")})}),H==="user"&&v&&u.jsx(ut,{variant:"ghost",size:"sm",onClick:We,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(de.Edit,{className:re("text-current",I?"h-3 w-3":"h-4 w-4")})}),H==="assistant"&&g&&u.jsx(ut,{variant:"ghost",size:"sm",onClick:Je,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(de.RotateCcw,{className:re("text-current",I?"h-3 w-3":"h-4 w-4")})})]})]})}),L&&u.jsx(Ch,{isOpen:V,onClose:Z,fileId:L.id,fileName:L.name,mimeType:L.mimeType})]})},(e,t)=>{var l,c,d,p,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&ru(e.message)===ru(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].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=Fh(e.message),a=Fh(t.message);return i.length===a.length});Xs.displayName="MessageComponent";const Bh=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,zh=w.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointIndex:b,activeCheckpointId:S,onSelectCheckpoint:E}){const C=Bh(t,n),T="type"in t&&t.type==="default_message",j=!!t.__syntheticStreaming,{checkpointCandidates:D,defaultCheckpointId:B}=Gl(t,b??{checkpoints:[],checkpointMetaById:new Map,checkpointIndexByKey:new Map,attemptMetaById:new Map,userMessageIdToAttempts:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getAttempts:()=>[]}),W=t&&!T?t.additionalKwargs??{}:{},K=t&&!T?t.responseMetadata??{}:{},z=(()=>{if(typeof W.parentCheckpointId=="string")return W.parentCheckpointId;if(typeof K.parentCheckpointId=="string")return K.parentCheckpointId})();return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":C,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Xs,{message:t,messageIndex:n,isStreamingMessage:j||r&&o===t.id,streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointCandidates:D,activeCheckpointId:S??null,onSelectCheckpoint:E,defaultCheckpointId:B,messageParentCheckpointId:z})})});zh.displayName="MessageRow";const El=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,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,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:E,onInterruptActionEnd:C,showToolMessages:T=!0,showArtifactPreviews:k=!0,checkpointIndex:j,activeCheckpointId:D,onSelectCheckpoint:B,createSyntheticThinkingMessage:W=!0},K)=>{const z=w.useRef(null),_=w.useRef(null),Y=w.useRef(!1),N=w.useRef(!1),[$,R]=w.useState(!0),I=w.useMemo(()=>b?e.some(F=>"type"in F&&F.type==="default_message"?!1:Array.isArray(F==null?void 0:F.content)&&F.content.some(oe=>oe&&oe.type==="interrupt"&&(oe.id??oe.interrupt_id)===b.id)):!1,[b,e]),H=w.useMemo(()=>{if(!b||I)return null;const F=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let oe;const we=b.value;if(we&&typeof we=="object"&&!Array.isArray(we)){const fe=we.title;typeof fe=="string"&&fe.trim()&&(oe=fe.trim())}return{id:`interrupt-${F}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:F,value:we,title:oe}]}},[b,I]),q=w.useMemo(()=>H?[...e,H]:e,[e,H]),P=w.useMemo(()=>!W||!t?q:!q.some(oe=>oe.role==="assistant")&&q.length>0?[...q,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:q,[q,t,W]),O=w.useMemo(()=>T?P:P.filter(F=>(F==null?void 0:F.role)!=="tool"),[P,T]),X=w.useCallback(F=>{R(F),x&&x(!F),y&&y(F)},[x,y]),J=w.useMemo(()=>{if(a)return async()=>{if(!Y.current){Y.current=!0;try{await a()}finally{Y.current=!1}}}},[a]),se=w.useMemo(()=>!v||g?!1:$?"auto":!1,[$,v,g]),V=w.useMemo(()=>{if(typeof f!="string")return null;const F=f.trim();return F?{id:"default-message",role:"assistant",type:"default_message",content:F,createdAt:new Date().toISOString()}:null},[f]),L=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),Z=()=>V?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Xs,{message:V,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},showArtifactPreviews:k})})}):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!"}),Q=O.length,ce=Q>0;return w.useEffect(()=>{var F,oe;if(Q===0){N.current=!1;return}if(!N.current)if(N.current=!0,z.current&&O.length>0){const we=O.length-1;(oe=(F=z.current).scrollToIndex)==null||oe.call(F,{index:we,align:"end",behavior:"auto"})}else _.current&&(_.current.scrollTop=_.current.scrollHeight)},[Q,O.length]),w.useImperativeHandle(K,()=>({scrollToLatest:()=>{var F,oe;if(z.current&&O.length>0){const we=O.length-1;(oe=(F=z.current).scrollToIndex)==null||oe.call(F,{index:we,align:"end",behavior:"auto"})}else _.current&&(_.current.scrollTop=_.current.scrollHeight)},scrollToTop:()=>{var F,oe;z.current&&O.length>0?(oe=(F=z.current).scrollToIndex)==null||oe.call(F,{index:0,align:"start",behavior:"auto"}):_.current&&(_.current.scrollTop=0)}}),[O]),u.jsx("div",{className:L,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ce?u.jsx(vT,{ref:F=>{z.current=F},scrollerRef:F=>{_.current=F instanceof HTMLDivElement?F:null},data:O,followOutput:se,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{J&&J()},atBottomStateChange:X,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(F,oe)=>Bh(oe,F),itemContent:(F,oe)=>u.jsx(zh,{message:oe,index:F,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:E,onInterruptActionEnd:C,showToolMessages:T,showArtifactPreviews:k,checkpointIndex:j,activeCheckpointId:D,onSelectCheckpoint:B})}):Z()})})});El.displayName="MessageList";const Hh={value:""};function yo({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,showArtifactPreviews:p=!0,customStyles:m={},onMessageSent:f,onExcelUploadSuccess:v,onError:g}){const{api:x}=Ii(),{currentThreadId:y}=Uo(),{threadId:b,messages:S,isHistoryLoading:E,isLoading:C,navigateToCheckpoint:T,returnToLatest:k,checkpoint:j,checkpoints:D,interrupt:B,metadata:W,checkpointIndex:K}=Wo(),{isStreaming:z,error:_,connectionState:Y,submit:N,stop:$}=gu(),R=b??y??null,I=(j==null?void 0:j.id)??null,H=(j==null?void 0:j.namespace)??null,q=(W==null?void 0:W.assemblingMessageId)??null,P=B,[O,X]=w.useState(!1);w.useEffect(()=>{P||X(!1)},[P]);const J=w.useCallback(()=>{X(!0)},[]),se=w.useCallback(()=>{X(!1)},[]),V=!!P||O,[L,Z]=w.useState(null),[Q,ce]=w.useState(""),[F,oe]=w.useState(null),[we,fe]=w.useState(null),[xe,_e]=w.useState([]),[$e,Ue]=w.useState(0),[Ne,Oe]=w.useState(0),[Ye,We]=w.useState(!1),[Je,ot]=w.useState(null),[nt,Ze]=w.useState(null),[Ae,Be]=w.useState(!1),[et,ct]=w.useState(null),Et=w.useRef(!1),[st,Ve]=w.useState(()=>Hh.value),It=w.useRef(st),De=w.useRef(null),Ke=w.useCallback(ue=>{Hh.value=ue,Ve(ue)},[]),[yt,ht]=w.useState(!1),qe=w.useRef(null),gt=w.useRef(null),M=w.useRef(null),ee=w.useCallback(()=>{gt.current&&(gt.current.value=""),M.current&&(M.current.value=""),Ue(ue=>ue+1),Oe(ue=>ue+1)},[]),ve=w.useCallback(ue=>{Ke(ue)},[Ke]),ae=w.useRef(!1);w.useEffect(()=>{ae.current&&!z&&(_e([]),ee()),ae.current=z},[z,ee]);const[ke,Te]=w.useState("desktop");w.useEffect(()=>{const ue=()=>{const be=window.innerWidth;Te(be<640?"phone":be<1024?"tablet":"desktop")};return ue(),window.addEventListener("resize",ue),()=>window.removeEventListener("resize",ue)},[]),w.useEffect(()=>{Et.current=!1},[R]),w.useEffect(()=>{It.current=st},[st]),w.useEffect(()=>{if(!L){De.current=null;return}De.current===null&&(De.current=It.current),Ke(Q??"")},[Q,L,Ke]),w.useEffect(()=>{(async()=>{if(!x.baseUrl){ct(null);return}try{const he=(await x.getAgent("default")).uiDefaultMessage||"";ct(he||null)}catch(be){console.warn("Failed to fetch default message:",be),ct(null)}})()},[x.baseUrl]),w.useEffect(()=>{_&&!Ae&&(g==null||g(_))},[_,Ae,g]);const it=async ue=>{const be=ue.trim();if(!(!be&&xe.length===0))try{const he=L?(F==null?void 0:F.checkpointId)??I??void 0:I??void 0,Ee=L?(F==null?void 0:F.checkpointNs)??H??void 0:H??void 0;await N({text:be||"",attachments:xe},{checkpointId:he,checkpointNs:Ee,edit:!!L,originalMessageId:L??void 0}),f==null||f(be),Ke(""),fe(null),_e([]),ee(),Z(null),ce(""),oe(null)}catch(he){const Ee=(he==null?void 0:he.message)||"Failed to send message";fe(Ee),g==null||g(Ee)}},Ge=w.useCallback((ue,be,he)=>{c&&(De.current=st,Z(ue),ce(be),Ke(be),fe(null),oe({checkpointId:(he==null?void 0:he.checkpointId)??null,checkpointNs:(he==null?void 0:he.checkpointNs)??null}))},[st,c,Ke]),mt=w.useCallback(()=>{Z(null),ce(""),oe(null),fe(null),Ke(De.current??st),De.current=null},[st,Ke]),Ut=w.useCallback((ue,be,he)=>{Ge(ue,be,he)},[Ge]),Mt=w.useCallback(ue=>{let be=null;for(let tt=ue-1;tt>=0;tt--)if(S[tt].role==="user"){be=S[tt];break}if(!be)return;const he=Array.isArray(be.content)?be.content:[],St=he.filter(tt=>(tt==null?void 0:tt.type)==="text").map(tt=>tt.text).join("")||(()=>{try{return JSON.stringify(he,null,2)}catch{return String(he)}})();St&&N({text:St},{checkpointId:I??void 0,checkpointNs:H??void 0,edit:!0,originalMessageId:be.id})},[S,N,I,H]),nn=ue=>{const be=Array.from(ue.target.files||[]);_e(he=>[...he,...be]),ue.target.value=""},Ul=ue=>{_e(be=>{const he=be.filter((Ee,St)=>ue!==St);return he.length===0&&ee(),he})},Wl=async ue=>{const be=(ue.target.files||[])[0];if(be){ot(null),Ze(null),We(!0);try{await N({attachments:[be]},{checkpointId:I??void 0,checkpointNs:H??void 0});const he=`Uploaded ${be.name} - processing through chat stream`;Ze(he)}catch(he){const Ee=he instanceof Error?he.message:"Failed to upload Excel file";console.error("Excel upload failed",he),ot(Ee),g==null||g(Ee)}finally{We(!1),ue.target.value="",ee()}}},ci=async ue=>{if(y){ht(!0);try{if(!ue){await k(),requestAnimationFrame(()=>{var Ee;(Ee=qe.current)==null||Ee.scrollToLatest()});return}const be=D.find(Ee=>Ee.checkpointId===ue),he=(be==null?void 0:be.checkpointNs)??null;await T(ue,he),requestAnimationFrame(()=>{var Ee;(Ee=qe.current)==null||Ee.scrollToTop()})}finally{ht(!1)}}},A=w.useCallback(async(ue,be,he)=>{await ci(he?null:ue)},[ci]),ne=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,pe=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${m.messagesArea||""}`,Pe=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:ne,children:[!!_&&!Ae&&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:_}),u.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>Be(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(de.X,{size:16})})]}),u.jsxs("div",{className:`relative ${pe}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(El,{ref:qe,className:"h-full",style:{height:"100%"},messages:S,isStreaming:z,streamingAssistantId:q,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:ke,enableMessageEditing:c,editingMessageId:L,onEdit:Ut,onRegenerate:Mt,onCancelEdit:mt,emptyMessage:et??void 0,isNavigatingCheckpoint:yt,activeInterrupt:P,disableInterruptActions:O,onInterruptActionStart:J,onInterruptActionEnd:se,showToolMessages:d,showArtifactPreviews:p,checkpointIndex:K,activeCheckpointId:I,onSelectCheckpoint:A,createSyntheticThinkingMessage:!0}),(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(de.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"}),C&&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(de.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(E||yt)&&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(de.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:Pe,children:[L&&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(de.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(ut,{variant:"ghost",size:"sm",onClick:mt,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(de.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:gt,type:"file",multiple:!0,onChange:ue=>nn(ue),className:"hidden"},$e),xe.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:xe.map((ue,be)=>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(de.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:ue.name}),u.jsx(ut,{variant:"ghost",size:"sm",onClick:()=>Ul(be),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 ${ue.name}`,children:u.jsx(de.X,{size:12})})]},be))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:M,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Wl,className:"hidden"},Ne),Ye&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),nt&&!Ye&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:nt}),Je&&!Ye&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Je})]})]}),we&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:we}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Es,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(ut,{type:"button",size:"icon",variant:"outline",disabled:z||V,title:"More input actions",className:m.moreButton||"",children:u.jsx(de.Plus,{size:16})})}),u.jsxs(lo,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(Dn,{onClick:()=>{var ue;return(ue=gt.current)==null?void 0:ue.click()},className:"cursor-pointer",children:[u.jsx(de.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(Dn,{onClick:()=>{var ue;Ye||(ue=M.current)==null||ue.click()},className:`cursor-pointer ${Ye?"opacity-60 pointer-events-none":""}`,children:[u.jsx(de.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(lC,{initialValue:Q,editingMessageId:L,value:st,onValueChange:ve,placeholder:L?"Edit your message...":t,isStreaming:z,disabled:V,onSend:it,onCancelEdit:mt,onStop:$,allowEmptySend:xe.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${L?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${we?"border-red-400":""} ${m.textarea||""}`})})]})]})]})}function Uh({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(qr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(yo,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(qr,{...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(Wa,{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(yo,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(qr,{...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(Wa,{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(yo,{onError:s.onError,enableFileUpload:!0})})]})})}function fE({apiConfig:e,className:t="",onError:n}){return u.jsx(qr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(yo,{})})})}var pE="Label",Wh=h.forwardRef((e,t)=>u.jsx(ye.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())}}));Wh.displayName=pE;var Vh=Wh;const hE=Or.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Kh=h.forwardRef(({className:e,...t},n)=>u.jsx(Vh,{ref:n,className:re(hE(),e),...t}));Kh.displayName=Vh.displayName;function qh(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 Gh=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"}),mE="VisuallyHidden",Js=h.forwardRef((e,t)=>u.jsx(ye.span,{...e,ref:t,style:{...Gh,...e.style}}));Js.displayName=mE;var gE=Js,xE=[" ","Enter","ArrowUp","ArrowDown"],vE=[" ","Enter"],ir="Select",[Zs,Qs,wE]=ls(ir),[Pr,a1]=sn(ir,[wE,kr]),ei=kr(),[bE,Un]=Pr(ir),[yE,SE]=Pr(ir),Yh=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=ei(t),[x,y]=h.useState(null),[b,S]=h.useState(null),[E,C]=h.useState(!1),T=cs(c),[k,j]=jn({prop:r,defaultProp:o??!1,onChange:s,caller:ir}),[D,B]=jn({prop:i,defaultProp:a,onChange:l,caller:ir}),W=h.useRef(null),K=x?v||!!x.closest("form"):!0,[z,_]=h.useState(new Set),Y=Array.from(z).map(N=>N.props.value).join(";");return u.jsx(Ca,{...g,children:u.jsxs(bE,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:E,onValueNodeHasChildrenChange:C,contentId:At(),value:D,onValueChange:B,open:k,onOpenChange:j,dir:T,triggerPointerDownPosRef:W,disabled:m,children:[u.jsx(Zs.Provider,{scope:t,children:u.jsx(yE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(N=>{_($=>new Set($).add(N))},[]),onNativeOptionRemove:h.useCallback(N=>{_($=>{const R=new Set($);return R.delete(N),R})},[]),children:n})}),K?u.jsxs(wm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:D,onChange:N=>B(N.target.value),disabled:m,form:v,children:[D===void 0?u.jsx("option",{value:""}):null,Array.from(z)]},Y):null]})})};Yh.displayName=ir;var Xh="SelectTrigger",Jh=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ei(n),i=Un(Xh,n),a=i.disabled||r,l=ze(t,i.onTriggerChange),c=Qs(n),d=h.useRef("touch"),[p,m,f]=ym(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),b=Sm(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(Ta,{asChild:!0,...s,children:u.jsx(ye.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":bm(i.value)?"":void 0,...o,ref:l,onClick:le(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:le(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:le(o.onKeyDown,g=>{const x=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&xE.includes(g.key)&&(v(),g.preventDefault())})})})});Jh.displayName=Xh;var Zh="SelectValue",Qh=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Un(Zh,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=ze(t,l.onValueNodeChange);return kt(()=>{c(d)},[c,d]),u.jsx(ye.span,{...a,ref:p,style:{pointerEvents:"none"},children:bm(l.value)?u.jsx(u.Fragment,{children:i}):s})});Qh.displayName=Zh;var CE="SelectIcon",em=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(ye.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});em.displayName=CE;var TE="SelectPortal",tm=e=>u.jsx(Gr,{asChild:!0,...e});tm.displayName=TE;var ar="SelectContent",nm=h.forwardRef((e,t)=>{const n=Un(ar,e.__scopeSelect),[r,o]=h.useState();if(kt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Dr.createPortal(u.jsx(rm,{scope:e.__scopeSelect,children:u.jsx(Zs.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(om,{...e,ref:t})});nm.displayName=ar;var fn=10,[rm,Wn]=Pr(ar),EE="SelectContentImpl",kE=Vt.createSlot("SelectContent.RemoveScroll"),om=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=Un(ar,n),[S,E]=h.useState(null),[C,T]=h.useState(null),k=ze(t,V=>E(V)),[j,D]=h.useState(null),[B,W]=h.useState(null),K=Qs(n),[z,_]=h.useState(!1),Y=h.useRef(!1);h.useEffect(()=>{if(S)return Gi(S)},[S]),Hi();const N=h.useCallback(V=>{const[L,...Z]=K().map(F=>F.ref.current),[Q]=Z.slice(-1),ce=document.activeElement;for(const F of V)if(F===ce||(F==null||F.scrollIntoView({block:"nearest"}),F===L&&C&&(C.scrollTop=0),F===Q&&C&&(C.scrollTop=C.scrollHeight),F==null||F.focus(),document.activeElement!==ce))return},[K,C]),$=h.useCallback(()=>N([j,S]),[N,j,S]);h.useEffect(()=>{z&&$()},[z,$]);const{onOpenChange:R,triggerPointerDownPosRef:I}=b;h.useEffect(()=>{if(S){let V={x:0,y:0};const L=Q=>{var ce,F;V={x:Math.abs(Math.round(Q.pageX)-(((ce=I.current)==null?void 0:ce.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((F=I.current)==null?void 0:F.y)??0))}},Z=Q=>{V.x<=10&&V.y<=10?Q.preventDefault():S.contains(Q.target)||R(!1),document.removeEventListener("pointermove",L),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",Z,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",Z,{capture:!0})}}},[S,R,I]),h.useEffect(()=>{const V=()=>R(!1);return window.addEventListener("blur",V),window.addEventListener("resize",V),()=>{window.removeEventListener("blur",V),window.removeEventListener("resize",V)}},[R]);const[H,q]=ym(V=>{const L=K().filter(ce=>!ce.disabled),Z=L.find(ce=>ce.ref.current===document.activeElement),Q=Sm(L,V,Z);Q&&setTimeout(()=>Q.ref.current.focus())}),P=h.useCallback((V,L,Z)=>{const Q=!Y.current&&!Z;(b.value!==void 0&&b.value===L||Q)&&(D(V),Q&&(Y.current=!0))},[b.value]),O=h.useCallback(()=>S==null?void 0:S.focus(),[S]),X=h.useCallback((V,L,Z)=>{const Q=!Y.current&&!Z;(b.value!==void 0&&b.value===L||Q)&&W(V)},[b.value]),J=r==="popper"?kl:sm,se=J===kl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(rm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:P,selectedItem:j,onItemLeave:O,itemTextRefCallback:X,focusSelectedItem:$,selectedItemText:B,position:r,isPositioned:z,searchRef:H,children:u.jsx(Zo,{as:kE,allowPinchZoom:!0,children:u.jsx(Vo,{asChild:!0,trapped:b.open,onMountAutoFocus:V=>{V.preventDefault()},onUnmountAutoFocus:le(o,V=>{var L;(L=b.trigger)==null||L.focus({preventScroll:!0}),V.preventDefault()}),children:u.jsx(mr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:V=>V.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(J,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:V=>V.preventDefault(),...y,...se,onPlaced:()=>_(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:le(y.onKeyDown,V=>{const L=V.ctrlKey||V.altKey||V.metaKey;if(V.key==="Tab"&&V.preventDefault(),!L&&V.key.length===1&&q(V.key),["ArrowUp","ArrowDown","Home","End"].includes(V.key)){let Q=K().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);if(["ArrowUp","End"].includes(V.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(V.key)){const ce=V.target,F=Q.indexOf(ce);Q=Q.slice(F+1)}setTimeout(()=>N(Q)),V.preventDefault()}})})})})})})});om.displayName=EE;var IE="SelectItemAlignedPosition",sm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Un(ar,n),i=Wn(ar,n),[a,l]=h.useState(null),[c,d]=h.useState(null),p=ze(t,k=>d(k)),m=Qs(n),f=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,S=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const k=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),D=s.valueNode.getBoundingClientRect(),B=y.getBoundingClientRect();if(s.dir!=="rtl"){const ce=B.left-j.left,F=D.left-ce,oe=k.left-F,we=k.width+oe,fe=Math.max(we,j.width),xe=window.innerWidth-fn,_e=La(F,[fn,Math.max(fn,xe-fe)]);a.style.minWidth=we+"px",a.style.left=_e+"px"}else{const ce=j.right-B.right,F=window.innerWidth-D.right-ce,oe=window.innerWidth-k.right-F,we=k.width+oe,fe=Math.max(we,j.width),xe=window.innerWidth-fn,_e=La(F,[fn,Math.max(fn,xe-fe)]);a.style.minWidth=we+"px",a.style.right=_e+"px"}const W=m(),K=window.innerHeight-fn*2,z=g.scrollHeight,_=window.getComputedStyle(c),Y=parseInt(_.borderTopWidth,10),N=parseInt(_.paddingTop,10),$=parseInt(_.borderBottomWidth,10),R=parseInt(_.paddingBottom,10),I=Y+N+z+R+$,H=Math.min(x.offsetHeight*5,I),q=window.getComputedStyle(g),P=parseInt(q.paddingTop,10),O=parseInt(q.paddingBottom,10),X=k.top+k.height/2-fn,J=K-X,se=x.offsetHeight/2,V=x.offsetTop+se,L=Y+N+V,Z=I-L;if(L<=X){const ce=W.length>0&&x===W[W.length-1].ref.current;a.style.bottom="0px";const F=c.clientHeight-g.offsetTop-g.offsetHeight,oe=Math.max(J,se+(ce?O:0)+F+$),we=L+oe;a.style.height=we+"px"}else{const ce=W.length>0&&x===W[0].ref.current;a.style.top="0px";const oe=Math.max(X,Y+g.offsetTop+(ce?P:0)+se)+Z;a.style.height=oe+"px",g.scrollTop=L-X+g.offsetTop}a.style.margin=`${fn}px 0`,a.style.minHeight=H+"px",a.style.maxHeight=K+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);kt(()=>S(),[S]);const[E,C]=h.useState();kt(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=h.useCallback(k=>{k&&v.current===!0&&(S(),b==null||b(),v.current=!1)},[S,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:E},children:u.jsx(ye.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});sm.displayName=IE;var NE="SelectPopperPosition",kl=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=fn,...s}=e,i=ei(n);return u.jsx(Ea,{...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)"}})});kl.displayName=NE;var[AE,Il]=Pr(ar,{}),Nl="SelectViewport",im=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Wn(Nl,n),i=Il(Nl,n),a=ze(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(Zs.Slot,{scope:n,children:u.jsx(ye.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:le(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-fn*2,g=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),y=Math.max(g,x);if(y<v){const b=y+f,S=Math.min(v,b),E=b-S;p.style.height=S+"px",p.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,p.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});im.displayName=Nl;var am="SelectGroup",[_E,jE]=Pr(am),PE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=At();return u.jsx(_E,{scope:n,id:o,children:u.jsx(ye.div,{role:"group","aria-labelledby":o,...r,ref:t})})});PE.displayName=am;var lm="SelectLabel",cm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=jE(lm,n);return u.jsx(ye.div,{id:o.id,...r,ref:t})});cm.displayName=lm;var ti="SelectItem",[ME,um]=Pr(ti),dm=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Un(ti,n),l=Wn(ti,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),v=ze(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),g=At(),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(ME,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(b=>{p(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(Zs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(ye.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:le(i.onFocus,()=>f(!0)),onBlur:le(i.onBlur,()=>f(!1)),onClick:le(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:le(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:le(i.onPointerDown,b=>{x.current=b.pointerType}),onPointerMove:le(i.onPointerMove,b=>{var S;x.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:le(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:le(i.onKeyDown,b=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&b.key===" "||(vE.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});dm.displayName=ti;var So="SelectItemText",fm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Un(So,n),a=Wn(So,n),l=um(So,n),c=SE(So,n),[d,p]=h.useState(null),m=ze(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 kt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(ye.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Dr.createPortal(s.children,i.valueNode):null]})});fm.displayName=So;var pm="SelectItemIndicator",hm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return um(pm,n).isSelected?u.jsx(ye.span,{"aria-hidden":!0,...r,ref:t}):null});hm.displayName=pm;var Al="SelectScrollUpButton",mm=h.forwardRef((e,t)=>{const n=Wn(Al,e.__scopeSelect),r=Il(Al,e.__scopeSelect),[o,s]=h.useState(!1),i=ze(t,r.onScrollButtonChange);return kt(()=>{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(xm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});mm.displayName=Al;var _l="SelectScrollDownButton",gm=h.forwardRef((e,t)=>{const n=Wn(_l,e.__scopeSelect),r=Il(_l,e.__scopeSelect),[o,s]=h.useState(!1),i=ze(t,r.onScrollButtonChange);return kt(()=>{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(xm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});gm.displayName=_l;var xm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Wn("SelectScrollButton",n),i=h.useRef(null),a=Qs(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),kt(()=>{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(ye.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:le(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:le(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:le(o.onPointerLeave,()=>{l()})})}),RE="SelectSeparator",vm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(ye.div,{"aria-hidden":!0,...r,ref:t})});vm.displayName=RE;var jl="SelectArrow",OE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ei(n),s=Un(jl,n),i=Wn(jl,n);return s.open&&i.position==="popper"?u.jsx(ka,{...o,...r,ref:t}):null});OE.displayName=jl;var DE="SelectBubbleInput",wm=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=ze(r,o),i=qh(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(ye.select,{...n,style:{...Gh,...n.style},ref:s,defaultValue:t})});wm.displayName=DE;function bm(e){return e===""||e===void 0}function ym(e){const t=vt(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 Sm(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=LE(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 LE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var $E=Yh,Cm=Jh,FE=Qh,BE=em,zE=tm,Tm=nm,HE=im,Em=cm,km=dm,UE=fm,WE=hm,Im=mm,Nm=gm,Am=vm;const VE=$E,KE=FE,_m=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Cm,{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(BE,{asChild:!0,children:u.jsx(de.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));_m.displayName=Cm.displayName;const jm=h.forwardRef(({className:e,...t},n)=>u.jsx(Im,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(de.ChevronUp,{className:"h-4 w-4"})}));jm.displayName=Im.displayName;const Pm=h.forwardRef(({className:e,...t},n)=>u.jsx(Nm,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(de.ChevronDown,{className:"h-4 w-4"})}));Pm.displayName=Nm.displayName;const Mm=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(zE,{children:u.jsxs(Tm,{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(jm,{}),u.jsx(HE,{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(Pm,{})]})}));Mm.displayName=Tm.displayName;const qE=h.forwardRef(({className:e,...t},n)=>u.jsx(Em,{ref:n,className:re("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));qE.displayName=Em.displayName;const Rm=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(km,{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(WE,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),u.jsx(UE,{children:t})]}));Rm.displayName=km.displayName;const GE=h.forwardRef(({className:e,...t},n)=>u.jsx(Am,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));GE.displayName=Am.displayName;var YE="Separator",Om="horizontal",XE=["horizontal","vertical"],Dm=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=Om,...o}=e,s=JE(r)?r:Om,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(ye.div,{"data-orientation":s,...a,...o,ref:t})});Dm.displayName=YE;function JE(e){return XE.includes(e)}var Lm=Dm;const $m=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(Lm,{ref:o,decorative:n,orientation:t,className:re("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));$m.displayName=Lm.displayName;var ni="Switch",[ZE,l1]=sn(ni),[QE,ek]=ZE(ni),Fm=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=ze(t,S=>f(S)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=jn({prop:o,defaultProp:s??!1,onChange:c,caller:ni});return u.jsxs(QE,{scope:n,checked:y,disabled:a,children:[u.jsx(ye.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Um(y),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:v,onClick:le(e.onClick,S=>{b(E=>!E),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(Hm,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Fm.displayName=ni;var Bm="SwitchThumb",zm=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=ek(Bm,n);return u.jsx(ye.span,{"data-state":Um(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});zm.displayName=Bm;var tk="SwitchBubbleInput",Hm=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=ze(i,s),l=qh(n),c=qd(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}})});Hm.displayName=tk;function Um(e){return e?"checked":"unchecked"}var Wm=Fm,nk=zm;const Vm=h.forwardRef(({className:e,...t},n)=>u.jsx(Wm,{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(nk,{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")})}));Vm.displayName=Wm.displayName;const rk=Zi,ok=_b,sk=Qi,Km=h.forwardRef(({className:e,...t},n)=>u.jsx(Yr,{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}));Km.displayName=Yr.displayName;const ik=Or.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"}}),qm=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(sk,{children:[u.jsx(Km,{}),u.jsxs(Xr,{ref:o,className:re(ik({side:e}),t),...r,children:[n,u.jsxs(hd,{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(de.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));qm.displayName=Xr.displayName;const Gm=({className:e,...t})=>u.jsx("div",{className:re("flex flex-col space-y-2 text-center sm:text-left",e),...t});Gm.displayName="SheetHeader";const Ym=h.forwardRef(({className:e,...t},n)=>u.jsx(Xn,{ref:n,className:re("text-lg font-semibold text-foreground",e),...t}));Ym.displayName=Xn.displayName;const Xm=h.forwardRef(({className:e,...t},n)=>u.jsx(rs,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Xm.displayName=rs.displayName;var[ri,c1]=sn("Tooltip",[kr]),oi=kr(),Jm="TooltipProvider",ak=700,Pl="tooltip.open",[lk,Ml]=ri(Jm),Zm=e=>{const{__scopeTooltip:t,delayDuration:n=ak,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(lk,{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})};Zm.displayName=Jm;var Co="Tooltip",[ck,si]=ri(Co),Qm=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Ml(Co,e.__scopeTooltip),c=oi(t),[d,p]=h.useState(null),m=At(),f=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,b]=jn({prop:r,defaultProp:o??!1,onChange:k=>{k?(l.onOpen(),document.dispatchEvent(new CustomEvent(Pl))):l.onClose(),s==null||s(k)},caller:Co}),S=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),E=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,b(!0)},[b]),C=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(Ca,{...c,children:u.jsx(ck,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:p,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?T():E()},[l.isOpenDelayedRef,T,E]),onTriggerLeave:h.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:E,onClose:C,disableHoverableContent:v,children:n})})};Qm.displayName=Co;var Rl="TooltipTrigger",eg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=si(Rl,n),s=Ml(Rl,n),i=oi(n),a=h.useRef(null),l=ze(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(Ta,{asChild:!0,...i,children:u.jsx(ye.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:le(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:le(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:le(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:le(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:le(e.onBlur,o.onClose),onClick:le(e.onClick,o.onClose)})})});eg.displayName=Rl;var uk="TooltipPortal",[u1,dk]=ri(uk,{forceMount:void 0}),Mr="TooltipContent",tg=h.forwardRef((e,t)=>{const n=dk(Mr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=si(Mr,e.__scopeTooltip);return u.jsx(Ft,{present:r||i.open,children:i.disableHoverableContent?u.jsx(ng,{side:o,...s,ref:t}):u.jsx(fk,{side:o,...s,ref:t})})}),fk=h.forwardRef((e,t)=>{const n=si(Mr,e.__scopeTooltip),r=Ml(Mr,e.__scopeTooltip),o=h.useRef(null),s=ze(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=xk(y,x.getBoundingClientRect()),S=vk(y,b),E=wk(g.getBoundingClientRect()),C=yk([...S,...E]);a(C),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)),S=!bk(y,i);b?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(ng,{...e,ref:s})}),[pk,hk]=ri(Co,{isInside:!1}),mk=Vt.createSlottable("TooltipContent"),ng=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=si(Mr,n),c=oi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Pl,d),()=>document.removeEventListener(Pl,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(mr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(Ea,{"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(mk,{children:r}),u.jsx(pk,{scope:n,isInside:!0,children:u.jsx(gE,{id:l.contentId,role:"tooltip",children:o||r})})]})})});tg.displayName=Mr;var rg="TooltipArrow",gk=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=oi(n);return hk(rg,n).isInside?null:u.jsx(ka,{...o,...r,ref:t})});gk.displayName=rg;function xk(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 vk(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 wk(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 bk(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 yk(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),Sk(t)}function Sk(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 Ck=Zm,Tk=Qm,Ek=eg,og=tg;const kk=Ck,Ik=Tk,Nk=Ek,sg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(og,{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}));sg.displayName=og.displayName;var Ol="ToastProvider",[Dl,Ak,_k]=ls("Toast"),[ig,d1]=sn("Toast",[_k]),[jk,ii]=ig(Ol),ag=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 \`${Ol}\`. Expected non-empty \`string\`.`),u.jsx(Dl.Provider,{scope:t,children:u.jsx(jk,{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})})};ag.displayName=Ol;var lg="ToastViewport",Pk=["F8"],Ll="toast.viewportPause",$l="toast.viewportResume",cg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=Pk,label:o="Notifications ({hotkey})",...s}=e,i=ii(lg,n),a=Ak(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=ze(t,p,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(E=>y[E]||y.code===E)&&((S=p.current)==null||S.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(Ll);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent($l);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},E=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",b),x.addEventListener("focusout",E),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",C),window.addEventListener("blur",b),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",E),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",b),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const b=a().map(S=>{const E=S.ref.current,C=[E,...Vk(E)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return h.useEffect(()=>{const x=p.current;if(x){const y=b=>{var C,T,k;const S=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!S){const j=document.activeElement,D=b.shiftKey;if(b.target===x&&D){(C=c.current)==null||C.focus();return}const K=g({tabbingDirection:D?"backwards":"forwards"}),z=K.findIndex(_=>_===j);zl(K.slice(z+1))?b.preventDefault():D?(T=c.current)==null||T.focus():(k=d.current)==null||k.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Tw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Fl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});zl(x)}}),u.jsx(Dl.Slot,{scope:n,children:u.jsx(ye.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Fl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});zl(x)}})]})});cg.displayName=lg;var ug="ToastFocusProxy",Fl=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=ii(ug,n);return u.jsx(Js,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Fl.displayName=ug;var To="Toast",Mk="toast.swipeStart",Rk="toast.swipeMove",Ok="toast.swipeCancel",Dk="toast.swipeEnd",dg=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=jn({prop:r,defaultProp:o??!0,onChange:s,caller:To});return u.jsx(Ft,{present:n||a,children:u.jsx(Fk,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:vt(e.onPause),onResume:vt(e.onResume),onSwipeStart:le(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:le(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:le(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:le(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)})})})});dg.displayName=To;var[Lk,$k]=ig(To,{onClose(){}}),Fk=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=ii(To,n),[x,y]=h.useState(null),b=ze(t,_=>y(_)),S=h.useRef(null),E=h.useRef(null),C=o||g.duration,T=h.useRef(0),k=h.useRef(C),j=h.useRef(0),{onToastAdd:D,onToastRemove:B}=g,W=vt(()=>{var Y;(x==null?void 0:x.contains(document.activeElement))&&((Y=g.viewport)==null||Y.focus()),i()}),K=h.useCallback(_=>{!_||_===1/0||(window.clearTimeout(j.current),T.current=new Date().getTime(),j.current=window.setTimeout(W,_))},[W]);h.useEffect(()=>{const _=g.viewport;if(_){const Y=()=>{K(k.current),c==null||c()},N=()=>{const $=new Date().getTime()-T.current;k.current=k.current-$,window.clearTimeout(j.current),l==null||l()};return _.addEventListener(Ll,N),_.addEventListener($l,Y),()=>{_.removeEventListener(Ll,N),_.removeEventListener($l,Y)}}},[g.viewport,C,l,c,K]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&K(C)},[s,C,g.isClosePausedRef,K]),h.useEffect(()=>(D(),()=>B()),[D,B]);const z=h.useMemo(()=>x?vg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[z&&u.jsx(Bk,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:z}),u.jsx(Lk,{scope:n,onClose:W,children:Dr.createPortal(u.jsx(Dl.ItemSlot,{scope:n,children:u.jsx(Cw,{asChild:!0,onEscapeKeyDown:le(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||W(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(ye.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:le(e.onKeyDown,_=>{_.key==="Escape"&&(a==null||a(_.nativeEvent),_.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,W()))}),onPointerDown:le(e.onPointerDown,_=>{_.button===0&&(S.current={x:_.clientX,y:_.clientY})}),onPointerMove:le(e.onPointerMove,_=>{if(!S.current)return;const Y=_.clientX-S.current.x,N=_.clientY-S.current.y,$=!!E.current,R=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,H=R?I(0,Y):0,q=R?0:I(0,N),P=_.pointerType==="touch"?10:2,O={x:H,y:q},X={originalEvent:_,delta:O};$?(E.current=O,ai(Rk,p,X,{discrete:!1})):wg(O,g.swipeDirection,P)?(E.current=O,ai(Mk,d,X,{discrete:!1}),_.target.setPointerCapture(_.pointerId)):(Math.abs(Y)>P||Math.abs(N)>P)&&(S.current=null)}),onPointerUp:le(e.onPointerUp,_=>{const Y=E.current,N=_.target;if(N.hasPointerCapture(_.pointerId)&&N.releasePointerCapture(_.pointerId),E.current=null,S.current=null,Y){const $=_.currentTarget,R={originalEvent:_,delta:Y};wg(Y,g.swipeDirection,g.swipeThreshold)?ai(Dk,f,R,{discrete:!0}):ai(Ok,m,R,{discrete:!0}),$.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),Bk=e=>{const{__scopeToast:t,children:n,...r}=e,o=ii(To,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return Uk(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(Gr,{asChild:!0,children:u.jsx(Js,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},zk="ToastTitle",fg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ye.div,{...r,ref:t})});fg.displayName=zk;var Hk="ToastDescription",pg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ye.div,{...r,ref:t})});pg.displayName=Hk;var hg="ToastAction",mg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(xg,{altText:n,asChild:!0,children:u.jsx(Bl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${hg}\`. Expected non-empty \`string\`.`),null)});mg.displayName=hg;var gg="ToastClose",Bl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=$k(gg,n);return u.jsx(xg,{asChild:!0,children:u.jsx(ye.button,{type:"button",...r,ref:t,onClick:le(e.onClick,o.onClose)})})});Bl.displayName=gg;var xg=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(ye.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function vg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),Wk(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(...vg(r))}}),t}function ai(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?Li(o,s):o.dispatchEvent(s)}var wg=(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 Uk(e=()=>{}){const t=vt(e);kt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function Wk(e){return e.nodeType===e.ELEMENT_NODE}function Vk(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 zl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var Kk=ag,bg=cg,yg=dg,Sg=fg,Cg=pg,Tg=mg,Eg=Bl;const qk=Kk,kg=h.forwardRef(({className:e,...t},n)=>u.jsx(bg,{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}));kg.displayName=bg.displayName;const Gk=Or.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"}}),Ig=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(yg,{ref:r,className:re(Gk({variant:t}),e),...n}));Ig.displayName=yg.displayName;const Yk=h.forwardRef(({className:e,...t},n)=>u.jsx(Tg,{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}));Yk.displayName=Tg.displayName;const Ng=h.forwardRef(({className:e,...t},n)=>u.jsx(Eg,{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(de.X,{className:"h-4 w-4"})}));Ng.displayName=Eg.displayName;const Ag=h.forwardRef(({className:e,...t},n)=>u.jsx(Sg,{ref:n,className:re("text-sm font-semibold",e),...t}));Ag.displayName=Sg.displayName;const _g=h.forwardRef(({className:e,...t},n)=>u.jsx(Cg,{ref:n,className:re("text-sm opacity-90",e),...t}));_g.displayName=Cg.displayName;function Xk(){const{toasts:e}=xl();return u.jsxs(qk,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Ig,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Ag,{children:n}),r&&u.jsx(_g,{children:r})]}),o,u.jsx(Ng,{})]},t)}),u.jsx(kg,{})]})}var Jk=(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{}},Zk=h.createContext(void 0),Qk={setTheme:e=>{},themes:[]},eI=()=>{var e;return(e=h.useContext(Zk))!=null?e:Qk};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:`(${Jk.toString()})(${d})`}})});var tI=e=>{switch(e){case"success":return oI;case"info":return iI;case"warning":return sI;case"error":return aI;default:return null}},nI=Array(12).fill(0),rI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},nI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),oI=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"})),sI=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"})),iI=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"})),aI=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"})),lI=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"})),cI=()=>{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},Hl=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:Hl++,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(fI(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)||Hl++;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}},Ht=new uI,dI=(e,t)=>{let n=(t==null?void 0:t.id)||Hl++;return Ht.addToast({title:e,...t,id:n}),n},fI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",pI=dI,hI=()=>Ht.toasts,mI=()=>Ht.getActiveToasts();Object.assign(pI,{success:Ht.success,info:Ht.info,warning:Ht.warning,error:Ht.error,custom:Ht.custom,message:Ht.message,promise:Ht.promise,dismiss:Ht.dismiss,loading:Ht.loading},{getHistory:hI,getToasts:mI});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%)}
130
+ `);function li(e){return e.label!==void 0}var xI=3,vI="32px",wI="16px",jg=4e3,bI=356,yI=14,SI=20,CI=200;function pn(...e){return e.filter(Boolean).join(" ")}function TI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var EI=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:S,toasts:E,expanded:C,removeToast:T,defaultRichColors:k,closeButton:j,style:D,cancelButtonStyle:B,actionButtonStyle:W,className:K="",descriptionClassName:z="",duration:_,position:Y,gap:N,loadingIcon:$,expandByDefault:R,classNames:I,icons:H,closeButtonAriaLabel:q="Close toast",pauseWhenPageIsHidden:P}=e,[O,X]=w.useState(null),[J,se]=w.useState(null),[V,L]=w.useState(!1),[Z,Q]=w.useState(!1),[ce,F]=w.useState(!1),[oe,we]=w.useState(!1),[fe,xe]=w.useState(!1),[_e,$e]=w.useState(0),[Ue,Ne]=w.useState(0),Oe=w.useRef(f.duration||_||jg),Ye=w.useRef(null),We=w.useRef(null),Je=S===0,ot=S+1<=y,nt=f.type,Ze=f.dismissible!==!1,Ae=f.className||"",Be=f.descriptionClassName||"",et=w.useMemo(()=>b.findIndex(ae=>ae.toastId===f.id)||0,[b,f.id]),ct=w.useMemo(()=>{var ae;return(ae=f.closeButton)!=null?ae:j},[f.closeButton,j]),Et=w.useMemo(()=>f.duration||_||jg,[f.duration,_]),st=w.useRef(0),Ve=w.useRef(0),It=w.useRef(0),De=w.useRef(null),[Ke,yt]=Y.split("-"),ht=w.useMemo(()=>b.reduce((ae,ke,Te)=>Te>=et?ae:ae+ke.height,0),[b,et]),qe=cI(),gt=f.invert||m,M=nt==="loading";Ve.current=w.useMemo(()=>et*N+ht,[et,ht]),w.useEffect(()=>{Oe.current=Et},[Et]),w.useEffect(()=>{L(!0)},[]),w.useEffect(()=>{let ae=We.current;if(ae){let ke=ae.getBoundingClientRect().height;return Ne(ke),x(Te=>[{toastId:f.id,height:ke,position:f.position},...Te]),()=>x(Te=>Te.filter(it=>it.toastId!==f.id))}},[x,f.id]),w.useLayoutEffect(()=>{if(!V)return;let ae=We.current,ke=ae.style.height;ae.style.height="auto";let Te=ae.getBoundingClientRect().height;ae.style.height=ke,Ne(Te),x(it=>it.find(Ge=>Ge.toastId===f.id)?it.map(Ge=>Ge.toastId===f.id?{...Ge,height:Te}:Ge):[{toastId:f.id,height:Te,position:f.position},...it])},[V,f.title,f.description,x,f.id]);let ee=w.useCallback(()=>{Q(!0),$e(Ve.current),x(ae=>ae.filter(ke=>ke.toastId!==f.id)),setTimeout(()=>{T(f)},CI)},[f,T,x,Ve]);w.useEffect(()=>{if(f.promise&&nt==="loading"||f.duration===1/0||f.type==="loading")return;let ae;return C||g||P&&qe?(()=>{if(It.current<st.current){let ke=new Date().getTime()-st.current;Oe.current=Oe.current-ke}It.current=new Date().getTime()})():Oe.current!==1/0&&(st.current=new Date().getTime(),ae=setTimeout(()=>{var ke;(ke=f.onAutoClose)==null||ke.call(f,f),ee()},Oe.current)),()=>clearTimeout(ae)},[C,g,f,nt,P,qe,ee]),w.useEffect(()=>{f.delete&&ee()},[ee,f.delete]);function ve(){var ae,ke,Te;return H!=null&&H.loading?w.createElement("div",{className:pn(I==null?void 0:I.loader,(ae=f==null?void 0:f.classNames)==null?void 0:ae.loader,"sonner-loader"),"data-visible":nt==="loading"},H.loading):$?w.createElement("div",{className:pn(I==null?void 0:I.loader,(ke=f==null?void 0:f.classNames)==null?void 0:ke.loader,"sonner-loader"),"data-visible":nt==="loading"},$):w.createElement(rI,{className:pn(I==null?void 0:I.loader,(Te=f==null?void 0:f.classNames)==null?void 0:Te.loader),visible:nt==="loading"})}return w.createElement("li",{tabIndex:0,ref:We,className:pn(K,Ae,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[nt],(n=f==null?void 0:f.classNames)==null?void 0:n[nt]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:k,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":V,"data-promise":!!f.promise,"data-swiped":fe,"data-removed":Z,"data-visible":ot,"data-y-position":Ke,"data-x-position":yt,"data-index":S,"data-front":Je,"data-swiping":ce,"data-dismissible":Ze,"data-type":nt,"data-invert":gt,"data-swipe-out":oe,"data-swipe-direction":J,"data-expanded":!!(C||R&&V),style:{"--index":S,"--toasts-before":S,"--z-index":E.length-S,"--offset":`${Z?_e:Ve.current}px`,"--initial-height":R?"auto":`${Ue}px`,...D,...f.style},onDragEnd:()=>{F(!1),X(null),De.current=null},onPointerDown:ae=>{M||!Ze||(Ye.current=new Date,$e(Ve.current),ae.target.setPointerCapture(ae.pointerId),ae.target.tagName!=="BUTTON"&&(F(!0),De.current={x:ae.clientX,y:ae.clientY}))},onPointerUp:()=>{var ae,ke,Te,it;if(oe||!Ze)return;De.current=null;let Ge=Number(((ae=We.current)==null?void 0:ae.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),mt=Number(((ke=We.current)==null?void 0:ke.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Ut=new Date().getTime()-((Te=Ye.current)==null?void 0:Te.getTime()),Mt=O==="x"?Ge:mt,nn=Math.abs(Mt)/Ut;if(Math.abs(Mt)>=SI||nn>.11){$e(Ve.current),(it=f.onDismiss)==null||it.call(f,f),se(O==="x"?Ge>0?"right":"left":mt>0?"down":"up"),ee(),we(!0),xe(!1);return}F(!1),X(null)},onPointerMove:ae=>{var ke,Te,it,Ge;if(!De.current||!Ze||((ke=window.getSelection())==null?void 0:ke.toString().length)>0)return;let mt=ae.clientY-De.current.y,Ut=ae.clientX-De.current.x,Mt=(Te=e.swipeDirections)!=null?Te:TI(Y);!O&&(Math.abs(Ut)>1||Math.abs(mt)>1)&&X(Math.abs(Ut)>Math.abs(mt)?"x":"y");let nn={x:0,y:0};O==="y"?(Mt.includes("top")||Mt.includes("bottom"))&&(Mt.includes("top")&&mt<0||Mt.includes("bottom")&&mt>0)&&(nn.y=mt):O==="x"&&(Mt.includes("left")||Mt.includes("right"))&&(Mt.includes("left")&&Ut<0||Mt.includes("right")&&Ut>0)&&(nn.x=Ut),(Math.abs(nn.x)>0||Math.abs(nn.y)>0)&&xe(!0),(it=We.current)==null||it.style.setProperty("--swipe-amount-x",`${nn.x}px`),(Ge=We.current)==null||Ge.style.setProperty("--swipe-amount-y",`${nn.y}px`)}},ct&&!f.jsx?w.createElement("button",{"aria-label":q,"data-disabled":M,"data-close-button":!0,onClick:M||!Ze?()=>{}:()=>{var ae;ee(),(ae=f.onDismiss)==null||ae.call(f,f)},className:pn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=H==null?void 0:H.close)!=null?s:lI):null,f.jsx||w.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:w.createElement(w.Fragment,null,nt||f.icon||f.promise?w.createElement("div",{"data-icon":"",className:pn(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||ve():null,f.type!=="loading"?f.icon||(H==null?void 0:H[nt])||tI(nt):null):null,w.createElement("div",{"data-content":"",className:pn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:pn(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:pn(z,Be,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&&li(f.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||B,onClick:ae=>{var ke,Te;li(f.cancel)&&Ze&&((Te=(ke=f.cancel).onClick)==null||Te.call(ke,ae),ee())},className:pn(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&&li(f.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||W,onClick:ae=>{var ke,Te;li(f.action)&&((Te=(ke=f.action).onClick)==null||Te.call(ke,ae),!ae.defaultPrevented&&ee())},className:pn(I==null?void 0:I.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function Pg(){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 kI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?wI:vI;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 II=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=Pg(),gap:y=yI,loadingIcon:b,icons:S,containerAriaLabel:E="Notifications",pauseWhenPageIsHidden:C}=e,[T,k]=w.useState([]),j=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(P=>P.position).map(P=>P.position)))),[T,r]),[D,B]=w.useState([]),[W,K]=w.useState(!1),[z,_]=w.useState(!1),[Y,N]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),$=w.useRef(null),R=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),H=w.useRef(!1),q=w.useCallback(P=>{k(O=>{var X;return(X=O.find(J=>J.id===P.id))!=null&&X.delete||Ht.dismiss(P.id),O.filter(({id:J})=>J!==P.id)})},[]);return w.useEffect(()=>Ht.subscribe(P=>{if(P.dismiss){k(O=>O.map(X=>X.id===P.id?{...X,delete:!0}:X));return}setTimeout(()=>{Eo.flushSync(()=>{k(O=>{let X=O.findIndex(J=>J.id===P.id);return X!==-1?[...O.slice(0,X),{...O[X],...P},...O.slice(X+1)]:[P,...O]})})})}),[]),w.useEffect(()=>{if(d!=="system"){N(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?N("dark"):N("light")),typeof window>"u")return;let P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:O})=>{N(O?"dark":"light")})}catch{P.addListener(({matches:X})=>{try{N(X?"dark":"light")}catch(J){console.error(J)}})}},[d]),w.useEffect(()=>{T.length<=1&&K(!1)},[T]),w.useEffect(()=>{let P=O=>{var X,J;o.every(se=>O[se]||O.code===se)&&(K(!0),(X=$.current)==null||X.focus()),O.code==="Escape"&&(document.activeElement===$.current||(J=$.current)!=null&&J.contains(document.activeElement))&&K(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[o]),w.useEffect(()=>{if($.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,H.current=!1)}},[$.current]),w.createElement("section",{ref:t,"aria-label":`${E} ${R}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((P,O)=>{var X;let[J,se]=P.split("-");return T.length?w.createElement("ol",{key:P,dir:x==="auto"?Pg():x,tabIndex:-1,ref:$,className:a,"data-sonner-toaster":!0,"data-theme":Y,"data-y-position":J,"data-lifted":W&&T.length>1&&!s,"data-x-position":se,style:{"--front-toast-height":`${((X=D[0])==null?void 0:X.height)||0}px`,"--width":`${bI}px`,"--gap":`${y}px`,...f,...kI(l,c)},onBlur:V=>{H.current&&!V.currentTarget.contains(V.relatedTarget)&&(H.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||H.current||(H.current=!0,I.current=V.relatedTarget)},onMouseEnter:()=>K(!0),onMouseMove:()=>K(!0),onMouseLeave:()=>{z||K(!1)},onDragEnd:()=>K(!1),onPointerDown:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||_(!0)},onPointerUp:()=>_(!1)},T.filter(V=>!V.position&&O===0||V.position===P).map((V,L)=>{var Z,Q;return w.createElement(EI,{key:V.id,icons:S,index:L,toast:V,defaultRichColors:p,duration:(Z=g==null?void 0:g.duration)!=null?Z:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Q=g==null?void 0:g.closeButton)!=null?Q:i,interacting:z,position:P,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:q,toasts:T.filter(ce=>ce.position==V.position),heights:D.filter(ce=>ce.position==V.position),setHeights:B,expandByDefault:s,gap:y,loadingIcon:b,expanded:W,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const NI=({...e})=>{const{theme:t="system"}=eI();return u.jsx(II,{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})};G.Api=mv,G.ApiClient=hv,G.Badge=yh,G.Button=ut,G.Card=bl,G.CardContent=Tl,G.CardDescription=Cl,G.CardHeader=yl,G.CardTitle=Sl,G.ChatApi=Bo,G.ChatApp=Uh,G.ChatInput=Sp,G.ChatInterface=yo,G.ChatProviders=qr,G.Command=oa,G.CommandEmpty=aa,G.CommandGroup=la,G.CommandInput=sa,G.CommandItem=ca,G.CommandList=ia,G.DEFAULT_TIMEOUT_MS=Kc,G.Dialog=ra,G.DialogContent=ss,G.DialogHeader=is,G.DialogTitle=as,G.DropdownMenu=Es,G.DropdownMenuContent=lo,G.DropdownMenuItem=Dn,G.DropdownMenuTrigger=ks,G.FileViewerModal=Ch,G.HISTORY_TIMEOUT_MS=qc,G.Input=Ua,G.Label=Kh,G.MarkdownContent=jr,G.MessageComponent=Xs,G.MessageList=El,G.SETTINGS_STORAGE_KEY=Mi,G.ScrollArea=Ha,G.Select=VE,G.SelectContent=Mm,G.SelectItem=Rm,G.SelectTrigger=_m,G.SelectValue=KE,G.Separator=$m,G.Sheet=rk,G.SheetContent=qm,G.SheetDescription=Xm,G.SheetHeader=Gm,G.SheetTitle=Ym,G.SheetTrigger=ok,G.SimpleChat=fE,G.Sonner=NI,G.Switch=Vm,G.Textarea=Va,G.ThreadManager=Wa,G.TimelineColumn=Vg,G.Toaster=Xk,G.Tooltip=Ik,G.TooltipContent=sg,G.TooltipProvider=kk,G.TooltipTrigger=Nk,G.applySettings=Jv,G.buildAttemptMaps=Yl,G.buildCheckpointIndex=Jl,G.buildCheckpointPreviewMap=Fg,G.buildMessagePreviewMap=$g,G.chatApiClient=An,G.default=Uh,G.del=Ti,G.downloadFileById=Yc,G.extractConfigFields=ui,G.fileToBase64=Zc,G.get=qt,G.getChatToken=Wc,G.getCurrentSettings=Xv,G.getDefaultApiConfig=bu,G.getDefaultChatSettings=yu,G.getFileContent=ki,G.getFileInfo=xv,G.getPreviewForMessage=ko,G.httpClient=Kt,G.hydrateHistorySnapshots=Nn,G.listFiles=Xc,G.loadStoredSettings=Su,G.onChatTokenChanged=Vc,G.post=Fo,G.processAttachments=Qc,G.put=Gc,G.readNumber=Ql,G.readString=Vn,G.resolveChatBaseUrl=mn,G.resolveMessageMetadata=ql,G.saveSettings=Cu,G.setChatToken=$o,G.toPlainObject=cr,G.unwrap=Rt,G.useApi=Ii,G.useCheckpointIndex=Zl,G.useHasChatSession=Gv,G.useMessageMetadata=Gl,G.useStream=gu,G.useStreamingHook=du,G.useThreadHistoryState=eu,G.useThreadManagerViewState=yp,G.useThreadState=Wo,G.useThreads=Uo,G.useThreadsState=tu,G.viewFileById=gv,Object.defineProperties(G,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});