teodor-new-chat-ui 4.3.397 → 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 (142) 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/features/checkpoint/hooks/index.d.ts +2 -0
  4. package/dist/features/checkpoint/hooks/useCheckpointIndex.d.ts +2 -0
  5. package/dist/features/checkpoint/hooks/useMessageMetadata.d.ts +18 -0
  6. package/dist/features/checkpoint/index.d.ts +4 -0
  7. package/dist/features/checkpoint/types.d.ts +34 -0
  8. package/dist/{lib → features/checkpoint/utils}/attemptDetection.d.ts +2 -6
  9. package/dist/features/checkpoint/utils/checkpointIndex.d.ts +15 -0
  10. package/dist/features/checkpoint/utils/index.d.ts +7 -0
  11. package/dist/features/checkpoint/utils/messageMetadataResolver.d.ts +32 -0
  12. package/dist/{lib → features/checkpoint/utils}/messagePreviews.d.ts +1 -0
  13. package/dist/{api/chat-api.d.ts → features/core/api/clients/chatClient.d.ts} +2 -3
  14. package/dist/features/core/api/clients/index.d.ts +2 -0
  15. package/dist/features/core/api/index.d.ts +2 -0
  16. package/dist/features/core/api/utils/index.d.ts +1 -0
  17. package/dist/{config → features/core/constants}/env.d.ts +1 -1
  18. package/dist/features/core/constants/index.d.ts +1 -0
  19. package/dist/{context → features/core/contexts}/ChatProviders.d.ts +2 -3
  20. package/dist/features/core/contexts/index.d.ts +6 -0
  21. package/dist/{context → features/core/contexts}/providers/ApiProvider.d.ts +1 -1
  22. package/dist/features/core/contexts/providers/ChatSessionProvider.d.ts +1 -0
  23. package/dist/features/core/hooks/index.d.ts +2 -0
  24. package/dist/features/core/index.d.ts +6 -0
  25. package/dist/{types → features/core/types}/context.d.ts +3 -3
  26. package/dist/features/core/types/index.d.ts +7 -0
  27. package/dist/features/core/utils/index.d.ts +1 -0
  28. package/dist/{components → features/messaging/components}/chat/ChatApp.d.ts +1 -2
  29. package/dist/{components → features/messaging/components}/chat/MessageComponent.d.ts +1 -2
  30. package/dist/{components → features/messaging/components}/chat/MessageList.d.ts +3 -11
  31. package/dist/{components → features/messaging/components}/chat/MessageRow.d.ts +3 -10
  32. package/dist/features/messaging/index.d.ts +12 -0
  33. package/dist/{context/providers/ChatSessionProvider.d.ts → features/streaming/contexts/StreamingProvider.d.ts} +10 -8
  34. package/dist/features/streaming/contexts/index.d.ts +3 -0
  35. package/dist/{context/services/streaming → features/streaming/contexts/services}/use-streaming-service.d.ts +3 -12
  36. package/dist/features/streaming/index.d.ts +3 -0
  37. package/dist/features/streaming/utils/index.d.ts +1 -0
  38. package/dist/features/streaming/utils/types.d.ts +109 -0
  39. package/dist/{hooks → features/thread/hooks}/useThreadHistoryState.d.ts +5 -3
  40. package/dist/{hooks → features/thread/hooks}/useThreadsState.d.ts +2 -2
  41. package/dist/features/thread/index.d.ts +2 -0
  42. package/dist/{hooks → features/ui/hooks}/use-toast.d.ts +3 -3
  43. package/dist/features/ui/index.d.ts +17 -0
  44. package/dist/features/ui/utils/index.d.ts +1 -0
  45. package/dist/index.esm.js +12635 -11688
  46. package/dist/index.umd.js +49 -48
  47. package/dist/lib/index.d.ts +8 -25
  48. package/dist/types/events.d.ts +1 -90
  49. package/dist/types/index.d.ts +1 -3
  50. package/dist/types/marked.d.ts +11 -0
  51. package/dist/types/models.d.ts +80 -104
  52. package/dist/types/requests.d.ts +1 -1
  53. package/package.json +1 -1
  54. package/dist/components/chat/message-components/artifacts/ResearchTaskArtifact.d.ts +0 -20
  55. package/dist/components/settings/ChatSettings.d.ts +0 -30
  56. package/dist/components/ui/accordion.d.ts +0 -7
  57. package/dist/components/ui/alert-dialog.d.ts +0 -20
  58. package/dist/components/ui/alert.d.ts +0 -8
  59. package/dist/components/ui/aspect-ratio.d.ts +0 -3
  60. package/dist/components/ui/avatar.d.ts +0 -6
  61. package/dist/components/ui/breadcrumb.d.ts +0 -19
  62. package/dist/components/ui/calendar.d.ts +0 -8
  63. package/dist/components/ui/carousel.d.ts +0 -18
  64. package/dist/components/ui/chart.d.ts +0 -62
  65. package/dist/components/ui/checkbox.d.ts +0 -4
  66. package/dist/components/ui/collapsible.d.ts +0 -5
  67. package/dist/components/ui/context-menu.d.ts +0 -27
  68. package/dist/components/ui/drawer.d.ts +0 -22
  69. package/dist/components/ui/form.d.ts +0 -23
  70. package/dist/components/ui/hover-card.d.ts +0 -6
  71. package/dist/components/ui/input-otp.d.ts +0 -34
  72. package/dist/components/ui/menubar.d.ts +0 -28
  73. package/dist/components/ui/navigation-menu.d.ts +0 -12
  74. package/dist/components/ui/pagination.d.ts +0 -28
  75. package/dist/components/ui/popover.d.ts +0 -6
  76. package/dist/components/ui/progress.d.ts +0 -4
  77. package/dist/components/ui/radio-group.d.ts +0 -5
  78. package/dist/components/ui/resizable.d.ts +0 -23
  79. package/dist/components/ui/sidebar.d.ts +0 -66
  80. package/dist/components/ui/skeleton.d.ts +0 -2
  81. package/dist/components/ui/slider.d.ts +0 -4
  82. package/dist/components/ui/table.d.ts +0 -10
  83. package/dist/components/ui/tabs.d.ts +0 -7
  84. package/dist/components/ui/toggle-group.d.ts +0 -12
  85. package/dist/components/ui/toggle.d.ts +0 -12
  86. package/dist/components/ui/use-toast.d.ts +0 -2
  87. package/dist/context/index.d.ts +0 -14
  88. package/dist/context/types.d.ts +0 -1
  89. package/dist/hooks/checkpoints/index.d.ts +0 -4
  90. package/dist/hooks/checkpoints/types.d.ts +0 -14
  91. package/dist/hooks/checkpoints/useCheckpointMetadata.d.ts +0 -33
  92. package/dist/hooks/checkpoints/useCheckpointSelectors.d.ts +0 -24
  93. package/dist/hooks/checkpoints/useMessageMetadata.d.ts +0 -39
  94. package/dist/hooks/use-mobile.d.ts +0 -1
  95. package/dist/lib/markdown.d.ts +0 -46
  96. package/dist/types/toolStream.d.ts +0 -11
  97. package/dist/utils/env.d.ts +0 -12
  98. /package/dist/{lib → features/checkpoint/utils}/historyUtils.d.ts +0 -0
  99. /package/dist/{lib → features/checkpoint/utils}/schemaUtils.d.ts +0 -0
  100. /package/dist/{api/file-api.d.ts → features/core/api/clients/fileClient.d.ts} +0 -0
  101. /package/dist/{api/utils.d.ts → features/core/api/utils/http.d.ts} +0 -0
  102. /package/dist/{lib → features/core/utils}/chatUtils.d.ts +0 -0
  103. /package/dist/{components → features/messaging/components}/chat/ChatInput.d.ts +0 -0
  104. /package/dist/{components → features/messaging/components}/chat/ChatInterface.d.ts +0 -0
  105. /package/dist/{components → features/messaging/components}/chat/FileViewerModal.d.ts +0 -0
  106. /package/dist/{components → features/messaging/components}/chat/MarkdownContent.d.ts +0 -0
  107. /package/dist/{components → features/messaging/components}/chat/ThreadManager.d.ts +0 -0
  108. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/ArtifactRenderer.d.ts +0 -0
  109. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/InterruptPartRenderer.d.ts +0 -0
  110. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/SimpleJsonView.d.ts +0 -0
  111. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/StreamProgress.d.ts +0 -0
  112. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/ToolComponent.d.ts +0 -0
  113. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/UserTextContent.d.ts +0 -0
  114. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/artifacts/PlotArtifact.d.ts +0 -0
  115. /package/dist/{components/chat/message-components → features/messaging/components/chat/message/artifacts}/ResearchTaskArtifact.d.ts +0 -0
  116. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/index.d.ts +0 -0
  117. /package/dist/{components/chat/message-components → features/messaging/components/chat/message}/useFilePreview.d.ts +0 -0
  118. /package/dist/{components → features/messaging/components}/chat/threads/ThreadListItem.d.ts +0 -0
  119. /package/dist/{lib → features/messaging/utils}/messageHelpers.d.ts +0 -0
  120. /package/dist/{lib → features/messaging/utils}/messageUtils.d.ts +0 -0
  121. /package/dist/{context → features/streaming/contexts}/reducers/MessageReducer.d.ts +0 -0
  122. /package/dist/{context → features/streaming/contexts}/reducers/utils/reducerUtils.d.ts +0 -0
  123. /package/dist/{hooks → features/streaming/hooks}/use-stream.d.ts +0 -0
  124. /package/dist/{components → features/ui/components}/ui/badge.d.ts +0 -0
  125. /package/dist/{components → features/ui/components}/ui/button.d.ts +0 -0
  126. /package/dist/{components → features/ui/components}/ui/card.d.ts +0 -0
  127. /package/dist/{components → features/ui/components}/ui/command.d.ts +0 -0
  128. /package/dist/{components → features/ui/components}/ui/dialog.d.ts +0 -0
  129. /package/dist/{components → features/ui/components}/ui/dropdown-menu.d.ts +0 -0
  130. /package/dist/{components → features/ui/components}/ui/input.d.ts +0 -0
  131. /package/dist/{components → features/ui/components}/ui/label.d.ts +0 -0
  132. /package/dist/{components → features/ui/components}/ui/scroll-area.d.ts +0 -0
  133. /package/dist/{components → features/ui/components}/ui/select.d.ts +0 -0
  134. /package/dist/{components → features/ui/components}/ui/separator.d.ts +0 -0
  135. /package/dist/{components → features/ui/components}/ui/sheet.d.ts +0 -0
  136. /package/dist/{components → features/ui/components}/ui/sonner.d.ts +0 -0
  137. /package/dist/{components → features/ui/components}/ui/switch.d.ts +0 -0
  138. /package/dist/{components → features/ui/components}/ui/textarea.d.ts +0 -0
  139. /package/dist/{components → features/ui/components}/ui/toast.d.ts +0 -0
  140. /package/dist/{components → features/ui/components}/ui/toaster.d.ts +0 -0
  141. /package/dist/{components → features/ui/components}/ui/tooltip.d.ts +0 -0
  142. /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,ae,Bn,wo,pm,mm,Zs){"use strict";var uT=Object.defineProperty;var dT=(Ee,y,ae)=>y in Ee?uT(Ee,y,{enumerable:!0,configurable:!0,writable:!0,value:ae}):Ee[y]=ae;var fm=(Ee,y,ae)=>dT(Ee,typeof y!="symbol"?y+"":y,ae);var Qs=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 p=ll(y),bo=ll(Zs);var ei={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 gm(){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,m=null;u!==void 0&&(h=""+u),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(m=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:m,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,34 +14,34 @@
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 xm(){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"),m=Symbol.for("react.offscreen"),w=Symbol.iterator,v="@@iterator";function g(I){if(I===null||typeof I!="object")return null;var ne=w&&I[w]||I[v];return typeof ne=="function"?ne:null}var x=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(I){{for(var ne=arguments.length,ce=new Array(ne>1?ne-1:0),Te=1;Te<ne;Te++)ce[Te-1]=arguments[Te];S("error",I,ce)}}function S(I,ne,ce){{var Te=x.ReactDebugCurrentFrame,Ze=Te.getStackAddendum();Ze!==""&&(ne+="%s",ce=ce.concat([Ze]));var tt=ce.map(function(Be){return String(Be)});tt.unshift("Warning: "+ne),Function.prototype.apply.call(console[I],console,tt)}}var T=!1,C=!1,k=!1,E=!1,A=!1,O;O=Symbol.for("react.module.reference");function $(I){return!!(typeof I=="string"||typeof I=="function"||I===r||I===s||A||I===o||I===u||I===d||E||I===m||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===O||I.getModuleId!==void 0))}function H(I,ne,ce){var Te=I.displayName;if(Te)return Te;var Ze=ne.displayName||ne.name||"";return Ze!==""?ce+"("+Ze+")":ce}function U(I){return I.displayName||"Context"}function K(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 ne=I;return U(ne)+".Consumer";case i:var ce=I;return U(ce._context)+".Provider";case l:return H(I,I.render,"ForwardRef");case f:var Te=I.displayName||null;return Te!==null?Te:K(I.type)||"Memo";case h:{var Ze=I,tt=Ze._payload,Be=Ze._init;try{return K(Be(tt))}catch{return null}}}return null}var R=Object.assign,Y=0,N,D,M,j,z,W,P;function B(){}B.__reactDisabledLog=!0;function te(){{if(Y===0){N=console.log,D=console.info,M=console.warn,j=console.error,z=console.group,W=console.groupCollapsed,P=console.groupEnd;var I={configurable:!0,enumerable:!0,value:B,writable:!0};Object.defineProperties(console,{info:I,log:I,warn:I,error:I,group:I,groupCollapsed:I,groupEnd:I})}Y++}}function J(){{if(Y--,Y===0){var I={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:R({},I,{value:N}),info:R({},I,{value:D}),warn:R({},I,{value:M}),error:R({},I,{value:j}),group:R({},I,{value:z}),groupCollapsed:R({},I,{value:W}),groupEnd:R({},I,{value:P})})}Y<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var re=x.ReactCurrentDispatcher,G;function L(I,ne,ce){{if(G===void 0)try{throw Error()}catch(Ze){var Te=Ze.stack.trim().match(/\n( *(at )?)/);G=Te&&Te[1]||""}return`
18
- `+G+I}}var V=!1,Z;{var q=typeof WeakMap=="function"?WeakMap:Map;Z=new q}function X(I,ne){if(!I||V)return"";{var ce=Z.get(I);if(ce!==void 0)return ce}var Te;V=!0;var Ze=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var tt;tt=re.current,re.current=null,te();try{if(ne){var Be=function(){throw Error()};if(Object.defineProperty(Be.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Be,[])}catch(Ct){Te=Ct}Reflect.construct(I,[],Be)}else{try{Be.call()}catch(Ct){Te=Ct}I.call(Be.prototype)}}else{try{throw Error()}catch(Ct){Te=Ct}I()}}catch(Ct){if(Ct&&Te&&typeof Ct.stack=="string"){for(var Fe=Ct.stack.split(`
19
- `),At=Te.stack.split(`
20
- `),pt=Fe.length-1,de=At.length-1;pt>=1&&de>=0&&Fe[pt]!==At[de];)de--;for(;pt>=1&&de>=0;pt--,de--)if(Fe[pt]!==At[de]){if(pt!==1||de!==1)do if(pt--,de--,de<0||Fe[pt]!==At[de]){var Se=`
21
- `+Fe[pt].replace(" at new "," at ");return I.displayName&&Se.includes("<anonymous>")&&(Se=Se.replace("<anonymous>",I.displayName)),typeof I=="function"&&Z.set(I,Se),Se}while(pt>=1&&de>=0);break}}}finally{V=!1,re.current=tt,J(),Error.prepareStackTrace=Ze}var Me=I?I.displayName||I.name:"",lt=Me?L(Me):"";return typeof I=="function"&&Z.set(I,lt),lt}function pe(I,ne,ce){return X(I,!1)}function he(I){var ne=I.prototype;return!!(ne&&ne.isReactComponent)}function ee(I,ne,ce){if(I==null)return"";if(typeof I=="function")return X(I,he(I));if(typeof I=="string")return L(I);switch(I){case u:return L("Suspense");case d:return L("SuspenseList")}if(typeof I=="object")switch(I.$$typeof){case l:return pe(I.render);case f:return ee(I.type,ne,ce);case h:{var Te=I,Ze=Te._payload,tt=Te._init;try{return ee(tt(Ze),ne,ce)}catch{}}}return""}var le=Object.prototype.hasOwnProperty,we={},je=x.ReactDebugCurrentFrame;function Ne(I){if(I){var ne=I._owner,ce=ee(I.type,I._source,ne?ne.type:null);je.setExtraStackFrame(ce)}else je.setExtraStackFrame(null)}function $e(I,ne,ce,Te,Ze){{var tt=Function.call.bind(le);for(var Be in I)if(tt(I,Be)){var Fe=void 0;try{if(typeof I[Be]!="function"){var At=Error((Te||"React class")+": "+ce+" type `"+Be+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof I[Be]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw At.name="Invariant Violation",At}Fe=I[Be](ne,Be,Te,ce,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(pt){Fe=pt}Fe&&!(Fe instanceof Error)&&(Ne(Ze),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).",Te||"React class",ce,Be,typeof Fe),Ne(null)),Fe instanceof Error&&!(Fe.message in we)&&(we[Fe.message]=!0,Ne(Ze),b("Failed %s type: %s",ce,Fe.message),Ne(null))}}}var Ye=Array.isArray;function nt(I){return Ye(I)}function Ve(I){{var ne=typeof Symbol=="function"&&Symbol.toStringTag,ce=ne&&I[Symbol.toStringTag]||I.constructor.name||"Object";return ce}}function qe(I){try{return rt(I),!1}catch{return!0}}function rt(I){return""+I}function kt(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.",Ve(I)),rt(I)}var at=x.ReactCurrentOwner,ke={key:!0,ref:!0,__self:!0,__source:!0},Oe,it;function ht(I){if(le.call(I,"ref")){var ne=Object.getOwnPropertyDescriptor(I,"ref").get;if(ne&&ne.isReactWarning)return!1}return I.ref!==void 0}function Tt(I){if(le.call(I,"key")){var ne=Object.getOwnPropertyDescriptor(I,"key").get;if(ne&&ne.isReactWarning)return!1}return I.key!==void 0}function yt(I,ne){typeof I.ref=="string"&&at.current}function Le(I,ne){{var ce=function(){Oe||(Oe=!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))};ce.isReactWarning=!0,Object.defineProperty(I,"key",{get:ce,configurable:!0})}}function Ht(I,ne){{var ce=function(){it||(it=!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))};ce.isReactWarning=!0,Object.defineProperty(I,"ref",{get:ce,configurable:!0})}}var Xe=function(I,ne,ce,Te,Ze,tt,Be){var Fe={$$typeof:t,type:I,key:ne,ref:ce,props:Be,_owner:tt};return Fe._store={},Object.defineProperty(Fe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Fe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Te}),Object.defineProperty(Fe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ze}),Object.freeze&&(Object.freeze(Fe.props),Object.freeze(Fe)),Fe};function Ke(I,ne,ce,Te,Ze){{var tt,Be={},Fe=null,At=null;ce!==void 0&&(kt(ce),Fe=""+ce),Tt(ne)&&(kt(ne.key),Fe=""+ne.key),ht(ne)&&(At=ne.ref,yt(ne,Ze));for(tt in ne)le.call(ne,tt)&&!ke.hasOwnProperty(tt)&&(Be[tt]=ne[tt]);if(I&&I.defaultProps){var pt=I.defaultProps;for(tt in pt)Be[tt]===void 0&&(Be[tt]=pt[tt])}if(Fe||At){var de=typeof I=="function"?I.displayName||I.name||"Unknown":I;Fe&&Le(Be,de),At&&Ht(Be,de)}return Xe(I,Fe,At,Ze,Te,at.current,Be)}}var dt=x.ReactCurrentOwner,vt=x.ReactDebugCurrentFrame;function Ue(I){if(I){var ne=I._owner,ce=ee(I.type,I._source,ne?ne.type:null);vt.setExtraStackFrame(ce)}else vt.setExtraStackFrame(null)}var St;St=!1;function _(I){return typeof I=="object"&&I!==null&&I.$$typeof===t}function ie(){{if(dt.current){var I=K(dt.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 ge(I){return""}var We={};function Re(I){{var ne=ie();if(!ne){var ce=typeof I=="string"?I:I.displayName||I.name;ce&&(ne=`
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 ne}}function mt(I,ne){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var ce=Re(ne);if(We[ce])return;We[ce]=!0;var Te="";I&&I._owner&&I._owner!==dt.current&&(Te=" It was passed a child from "+K(I._owner.type)+"."),Ue(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,Te),Ue(null)}}function Je(I,ne){{if(typeof I!="object")return;if(nt(I))for(var ce=0;ce<I.length;ce++){var Te=I[ce];_(Te)&&mt(Te,ne)}else if(_(I))I._store&&(I._store.validated=!0);else if(I){var Ze=g(I);if(typeof Ze=="function"&&Ze!==I.entries)for(var tt=Ze.call(I),Be;!(Be=tt.next()).done;)_(Be.value)&&mt(Be.value,ne)}}}function Nt(I){{var ne=I.type;if(ne==null||typeof ne=="string")return;var ce;if(typeof ne=="function")ce=ne.propTypes;else if(typeof ne=="object"&&(ne.$$typeof===l||ne.$$typeof===f))ce=ne.propTypes;else return;if(ce){var Te=K(ne);$e(ce,I.props,"prop",Te,I)}else if(ne.PropTypes!==void 0&&!St){St=!0;var Ze=K(ne);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ze||"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 go(I){{for(var ne=Object.keys(I.props),ce=0;ce<ne.length;ce++){var Te=ne[ce];if(Te!=="children"&&Te!=="key"){Ue(I),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Te),Ue(null);break}}I.ref!==null&&(Ue(I),b("Invalid attribute `ref` supplied to `React.Fragment`."),Ue(null))}}var xo={};function Xs(I,ne,ce,Te,Ze,tt){{var Be=$(I);if(!Be){var Fe="";(I===void 0||typeof I=="object"&&I!==null&&Object.keys(I).length===0)&&(Fe+=" 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 At=ge();At?Fe+=At:Fe+=ie();var pt;I===null?pt="null":nt(I)?pt="array":I!==void 0&&I.$$typeof===t?(pt="<"+(K(I.type)||"Unknown")+" />",Fe=" Did you accidentally export a JSX literal instead of a component?"):pt=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",pt,Fe)}var de=Ke(I,ne,ce,Ze,tt);if(de==null)return de;if(Be){var Se=ne.children;if(Se!==void 0)if(Te)if(nt(Se)){for(var Me=0;Me<Se.length;Me++)Je(Se[Me],I);Object.freeze&&Object.freeze(Se)}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 Je(Se,I)}if(le.call(ne,"key")){var lt=K(I),Ct=Object.keys(ne).filter(function(cT){return cT!=="key"}),Ut=Ct.length>0?"{key: someKey, "+Ct.join(": ..., ")+": ...}":"{key: someKey}";if(!xo[lt+Ut]){var lT=Ct.length>0?"{"+Ct.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} />`,Ut,lt,lT,lt),xo[lt+Ut]=!0}}return I===r?go(de):Nt(de),de}}function il(I,ne,ce){return Xs(I,ne,ce,!0)}function al(I,ne,ce){return Xs(I,ne,ce,!1)}var Js=al,vo=il;jr.Fragment=r,jr.jsx=Js,jr.jsxs=vo}()),jr}process.env.NODE_ENV==="production"?ei.exports=gm():ei.exports=xm();var c=ei.exports;function dl(e,t){return function(){return e.apply(t,arguments)}}const{toString:vm}=Object.prototype,{getPrototypeOf:ti}=Object,{iterator:yo,toStringTag:fl}=Symbol,So=(e=>t=>{const n=vm.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),nn=e=>(e=e.toLowerCase(),t=>So(t)===e),Co=e=>t=>typeof t===e,{isArray:ir}=Array,ar=Co("undefined");function _r(e){return e!==null&&!ar(e)&&e.constructor!==null&&!ar(e.constructor)&&Lt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const hl=nn("ArrayBuffer");function wm(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&hl(e.buffer),t}const bm=Co("string"),Lt=Co("function"),pl=Co("number"),Mr=e=>e!==null&&typeof e=="object",ym=e=>e===!0||e===!1,ko=e=>{if(So(e)!=="object")return!1;const t=ti(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(fl in e)&&!(yo in e)},Sm=e=>{if(!Mr(e)||_r(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Cm=nn("Date"),km=nn("File"),Tm=nn("Blob"),Em=nn("FileList"),Im=e=>Mr(e)&&Lt(e.pipe),Nm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Lt(e.append)&&((t=So(e))==="formdata"||t==="object"&&Lt(e.toString)&&e.toString()==="[object FormData]"))},Am=nn("URLSearchParams"),[jm,_m,Mm,Pm]=["ReadableStream","Request","Response","Headers"].map(nn),Rm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Pr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),ir(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 zn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,gl=e=>!ar(e)&&e!==zn;function ni(){const{caseless:e,skipUndefined:t}=gl(this)&&this||{},n={},r=(o,s)=>{const i=e&&ml(n,s)||s;ko(n[i])&&ko(o)?n[i]=ni(n[i],o):ko(o)?n[i]=ni({},o):ir(o)?n[i]=o.slice():(!t||!ar(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Pr(arguments[o],r);return n}const Om=(e,t,n,{allOwnKeys:r}={})=>(Pr(t,(o,s)=>{n&&Lt(o)?e[s]=dl(o,n):e[s]=o},{allOwnKeys:r}),e),Dm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Lm=(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)},$m=(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&&ti(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Fm=(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},Bm=e=>{if(!e)return null;if(ir(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},zm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ti(Uint8Array)),Hm=(e,t)=>{const r=(e&&e[yo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Um=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Wm=nn("HTMLFormElement"),Vm=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),Km=nn("RegExp"),vl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Pr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},qm=e=>{vl(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+"'")})}})},Gm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return ir(e)?r(e):r(String(e).split(t)),n},Ym=()=>{},Xm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Jm(e){return!!(e&&Lt(e.append)&&e[fl]==="FormData"&&e[yo])}const Zm=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=ir(r)?[]:{};return Pr(r,(i,a)=>{const l=n(i,o+1);!ar(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Qm=nn("AsyncFunction"),eg=e=>e&&(Mr(e)||Lt(e))&&Lt(e.then)&&Lt(e.catch),wl=((e,t)=>e?setImmediate:t?((n,r)=>(zn.addEventListener("message",({source:o,data:s})=>{o===zn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),zn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Lt(zn.postMessage)),tg=typeof queueMicrotask<"u"?queueMicrotask.bind(zn):typeof process<"u"&&process.nextTick||wl,F={isArray:ir,isArrayBuffer:hl,isBuffer:_r,isFormData:Nm,isArrayBufferView:wm,isString:bm,isNumber:pl,isBoolean:ym,isObject:Mr,isPlainObject:ko,isEmptyObject:Sm,isReadableStream:jm,isRequest:_m,isResponse:Mm,isHeaders:Pm,isUndefined:ar,isDate:Cm,isFile:km,isBlob:Tm,isRegExp:Km,isFunction:Lt,isStream:Im,isURLSearchParams:Am,isTypedArray:zm,isFileList:Em,forEach:Pr,merge:ni,extend:Om,trim:Rm,stripBOM:Dm,inherits:Lm,toFlatObject:$m,kindOf:So,kindOfTest:nn,endsWith:Fm,toArray:Bm,forEachEntry:Hm,matchAll:Um,isHTMLForm:Wm,hasOwnProperty:xl,hasOwnProp:xl,reduceDescriptors:vl,freezeMethods:qm,toObjectSet:Gm,toCamelCase:Vm,noop:Ym,toFiniteNumber:Xm,findKey:ml,global:zn,isContextDefined:gl,isSpecCompliantForm:Jm,toJSONObject:Zm,isAsyncFn:Qm,isThenable:eg,setImmediate:wl,asap:tg,isIterable:e=>e!=null&&Lt(e[yo])};function _e(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)}F.inherits(_e,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:F.toJSONObject(this.config),code:this.code,status:this.status}}});const bl=_e.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(_e,yl),Object.defineProperty(bl,"isAxiosError",{value:!0}),_e.from=(e,t,n,r,o,s)=>{const i=Object.create(bl);F.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 _e.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 ng=null;function ri(e){return F.isPlainObject(e)||F.isArray(e)}function Sl(e){return F.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 rg(e){return F.isArray(e)&&!e.some(ri)}const og=F.toFlatObject(F,{},null,function(t){return/^is[A-Z]/.test(t)});function To(e,t,n){if(!F.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=F.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,g){return!F.isUndefined(g[v])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&F.isSpecCompliantForm(t);if(!F.isFunction(o))throw new TypeError("visitor must be a function");function u(w){if(w===null)return"";if(F.isDate(w))return w.toISOString();if(F.isBoolean(w))return w.toString();if(!l&&F.isBlob(w))throw new _e("Blob is not supported. Use a Buffer instead.");return F.isArrayBuffer(w)||F.isTypedArray(w)?l&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function d(w,v,g){let x=w;if(w&&!g&&typeof w=="object"){if(F.endsWith(v,"{}"))v=r?v:v.slice(0,-2),w=JSON.stringify(w);else if(F.isArray(w)&&rg(w)||(F.isFileList(w)||F.endsWith(v,"[]"))&&(x=F.toArray(w)))return v=Sl(v),x.forEach(function(S,T){!(F.isUndefined(S)||S===null)&&t.append(i===!0?Cl([v],T,s):i===null?v:v+"[]",u(S))}),!1}return ri(w)?!0:(t.append(Cl(g,v,s),u(w)),!1)}const f=[],h=Object.assign(og,{defaultVisitor:d,convertValue:u,isVisitable:ri});function m(w,v){if(!F.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+v.join("."));f.push(w),F.forEach(w,function(x,b){(!(F.isUndefined(x)||x===null)&&o.call(t,x,F.isString(b)?b.trim():b,v,h))===!0&&m(x,v?v.concat(b):[b])}),f.pop()}}if(!F.isObject(e))throw new TypeError("data must be an object");return m(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 oi(e,t){this._pairs=[],e&&To(e,this,t)}const Tl=oi.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 sg(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||sg;F.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=F.isURLSearchParams(t)?t.toString():new oi(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){F.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Nl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ig={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:oi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},si=typeof window<"u"&&typeof document<"u",ii=typeof navigator=="object"&&navigator||void 0,ag=si&&(!ii||["ReactNative","NativeScript","NS"].indexOf(ii.product)<0),lg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",cg=si&&window.location.href||"http://localhost",jt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:si,hasStandardBrowserEnv:ag,hasStandardBrowserWebWorkerEnv:lg,navigator:ii,origin:cg},Symbol.toStringTag,{value:"Module"})),...ig};function ug(e,t){return To(e,new jt.classes.URLSearchParams,{visitor:function(n,r,o,s){return jt.isNode&&F.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function dg(e){return F.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function fg(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&&F.isArray(o)?o.length:i,l?(F.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!F.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&F.isArray(o[i])&&(o[i]=fg(o[i])),!a)}if(F.isFormData(e)&&F.isFunction(e.entries)){const n={};return F.forEachEntry(e,(r,o)=>{t(dg(r),o,n,0)}),n}return null}function hg(e,t,n){if(F.isString(e))try{return(t||JSON.parse)(e),F.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Rr={transitional:Nl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=F.isObject(t);if(s&&F.isHTMLForm(t)&&(t=new FormData(t)),F.isFormData(t))return o?JSON.stringify(Al(t)):t;if(F.isArrayBuffer(t)||F.isBuffer(t)||F.isStream(t)||F.isFile(t)||F.isBlob(t)||F.isReadableStream(t))return t;if(F.isArrayBufferView(t))return t.buffer;if(F.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 ug(t,this.formSerializer).toString();if((a=F.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return To(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),hg(t)):t}],transformResponse:[function(t){const n=this.transitional||Rr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(F.isResponse(t)||F.isReadableStream(t))return t;if(t&&F.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"?_e.from(a,_e.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:jt.classes.FormData,Blob:jt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};F.forEach(["delete","get","head","post","put","patch"],e=>{Rr.headers[e]={}});const pg=F.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"]),mg=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]&&pg[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 Eo(e){return e===!1||e==null?e:F.isArray(e)?e.map(Eo):String(e)}function gg(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 xg=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ai(e,t,n,r,o){if(F.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!F.isString(t)){if(F.isString(r))return t.indexOf(r)!==-1;if(F.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 wg(e,t){const n=F.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,u){const d=Or(l);if(!d)throw new Error("header name must be a non-empty string");const f=F.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=Eo(a))}const i=(a,l)=>F.forEach(a,(u,d)=>s(u,d,l));if(F.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(F.isString(t)&&(t=t.trim())&&!xg(t))i(mg(t),n);else if(F.isObject(t)&&F.isIterable(t)){let a={},l,u;for(const d of t){if(!F.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?F.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=F.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return gg(o);if(F.isFunction(n))return n.call(this,o,r);if(F.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=F.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||ai(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=F.findKey(r,i);a&&(!n||ai(r,r[a],a,n))&&(delete r[a],o=!0)}}return F.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||ai(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return F.forEach(this,(o,s)=>{const i=F.findKey(r,s);if(i){n[i]=Eo(o),delete n[s];return}const a=t?vg(s):String(s).trim();a!==s&&delete n[s],n[a]=Eo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return F.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&F.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]||(wg(o,i),r[a]=!0)}return F.isArray(t)?t.forEach(s):s(t),this}};$t.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),F.reduceDescriptors($t.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),F.freezeMethods($t);function li(e,t){const n=this||Rr,r=t||n,o=$t.from(r.headers);let s=r.data;return F.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 lr(e,t,n){_e.call(this,e??"canceled",_e.ERR_CANCELED,t,n),this.name="CanceledError"}F.inherits(lr,_e,{__CANCEL__:!0});function Ml(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new _e("Request failed with status code "+n.status,[_e.ERR_BAD_REQUEST,_e.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function bg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function yg(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 m=d&&u-d;return m?Math.round(h*1e3/m):void 0}}function Sg(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 Io=(e,t,n=3)=>{let r=0;const o=yg(50,250);return Sg(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)},Pl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Rl=e=>(...t)=>F.asap(()=>e(...t)),Cg=jt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,jt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(jt.origin),jt.navigator&&/(msie|trident)/i.test(jt.navigator.userAgent)):()=>!0,kg=jt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];F.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),F.isString(r)&&i.push("path="+r),F.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 Tg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Eg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Ol(e,t,n){let r=!Tg(t);return e&&(r||n==!1)?Eg(e,t):t}const Dl=e=>e instanceof $t?{...e}:e;function Hn(e,t){t=t||{};const n={};function r(u,d,f,h){return F.isPlainObject(u)&&F.isPlainObject(d)?F.merge.call({caseless:h},u,d):F.isPlainObject(d)?F.merge({},d):F.isArray(d)?d.slice():d}function o(u,d,f,h){if(F.isUndefined(d)){if(!F.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!F.isUndefined(d))return r(void 0,d)}function i(u,d){if(F.isUndefined(d)){if(!F.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 F.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);F.isUndefined(h)&&f!==a||(n[d]=h)}),n}const Ll=e=>{const t=Hn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=$t.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)):""))),F.isFormData(n)){if(jt.hasStandardBrowserEnv||jt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(F.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(jt.hasStandardBrowserEnv&&(r&&F.isFunction(r)&&(r=r(t)),r||r!==!1&&Cg(t.url))){const l=o&&s&&kg.read(s);l&&i.set(o,l)}return t},Ig=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Ll(e);let s=o.data;const i=$t.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,m,w;function v(){m&&m(),w&&w(),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 x(){if(!g)return;const S=$t.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),v()},function(E){r(E),v()},C),g=null}"onloadend"in g?g.onloadend=x:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(x)},g.onabort=function(){g&&(r(new _e("Request aborted",_e.ECONNABORTED,e,g)),g=null)},g.onerror=function(T){const C=T&&T.message?T.message:"Network Error",k=new _e(C,_e.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 _e(T,C.clarifyTimeoutError?_e.ETIMEDOUT:_e.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&F.forEach(i.toJSON(),function(T,C){g.setRequestHeader(C,T)}),F.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,w]=Io(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,m]=Io(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new lr(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=bg(o.url);if(b&&jt.protocols.indexOf(b)===-1){r(new _e("Unsupported protocol "+b+":",_e.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Ng=(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 _e?d:new lr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new _e(`timeout ${t} of ms exceeded`,_e.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=()=>F.asap(a),l}},Ag=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},jg=async function*(e,t){for await(const n of _g(e))yield*Ag(n,t)},_g=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=jg(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:No}=F,Mg=(({Request:e,Response:t})=>({Request:e,Response:t}))(F.global),{ReadableStream:Bl,TextEncoder:zl}=F.global,Hl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Pg=e=>{e=F.merge.call({skipUndefined:!0},Mg,e);const{fetch:t,Request:n,Response:r}=e,o=t?No(t):typeof fetch=="function",s=No(n),i=No(r);if(!o)return!1;const a=o&&No(Bl),l=o&&(typeof zl=="function"?(w=>v=>w.encode(v))(new zl):async w=>new Uint8Array(await new n(w).arrayBuffer())),u=s&&a&&Hl(()=>{let w=!1;const v=new n(jt.origin,{body:new Bl,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!v}),d=i&&a&&Hl(()=>F.isReadableStream(new r("").body)),f={stream:d&&(w=>w.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!f[w]&&(f[w]=(v,g)=>{let x=v&&v[w];if(x)return x.call(v);throw new _e(`Response type '${w}' is not supported`,_e.ERR_NOT_SUPPORT,g)})});const h=async w=>{if(w==null)return 0;if(F.isBlob(w))return w.size;if(F.isSpecCompliantForm(w))return(await new n(jt.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(F.isArrayBufferView(w)||F.isArrayBuffer(w))return w.byteLength;if(F.isURLSearchParams(w)&&(w=w+""),F.isString(w))return(await l(w)).byteLength},m=async(w,v)=>{const g=F.toFiniteNumber(w.getContentLength());return g??h(v)};return async w=>{let{url:v,method:g,data:x,signal:b,cancelToken:S,timeout:T,onDownloadProgress:C,onUploadProgress:k,responseType:E,headers:A,withCredentials:O="same-origin",fetchOptions:$}=Ll(w),H=t||fetch;E=E?(E+"").toLowerCase():"text";let U=Ng([b,S&&S.toAbortSignal()],T),K=null;const R=U&&U.unsubscribe&&(()=>{U.unsubscribe()});let Y;try{if(k&&u&&g!=="get"&&g!=="head"&&(Y=await m(A,x))!==0){let W=new n(v,{method:"POST",body:x,duplex:"half"}),P;if(F.isFormData(x)&&(P=W.headers.get("content-type"))&&A.setContentType(P),W.body){const[B,te]=Pl(Y,Io(Rl(k)));x=$l(W.body,Fl,B,te)}}F.isString(O)||(O=O?"include":"omit");const N=s&&"credentials"in n.prototype,D={...$,signal:U,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:x,duplex:"half",credentials:N?O:void 0};K=s&&new n(v,D);let M=await(s?H(K,$):H(v,D));const j=d&&(E==="stream"||E==="response");if(d&&(C||j&&R)){const W={};["status","statusText","headers"].forEach(J=>{W[J]=M[J]});const P=F.toFiniteNumber(M.headers.get("content-length")),[B,te]=C&&Pl(P,Io(Rl(C),!0))||[];M=new r($l(M.body,Fl,B,()=>{te&&te(),R&&R()}),W)}E=E||"text";let z=await f[F.findKey(f,E)||"text"](M,w);return!j&&R&&R(),await new Promise((W,P)=>{Ml(W,P,{data:z,headers:$t.from(M.headers),status:M.status,statusText:M.statusText,config:w,request:K})})}catch(N){throw R&&R(),N&&N.name==="TypeError"&&/Load failed|fetch/i.test(N.message)?Object.assign(new _e("Network Error",_e.ERR_NETWORK,w,K),{cause:N.cause||N}):_e.from(N,N&&N.code,w,K)}}},Rg=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=Rg;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 ci={http:ng,xhr:Ig,fetch:{get:Ul}};F.forEach(ci,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Wl=e=>`- ${e}`,Og=e=>F.isFunction(e)||e===null||e===!1,Vl={getAdapter:(e,t)=>{e=F.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,!Og(r)&&(o=ci[(a=String(r)).toLowerCase()],o===void 0))throw new _e(`Unknown adapter '${a}'`);if(o&&(F.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 _e("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:ci};function ui(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new lr(null,e)}function Kl(e){return ui(e),e.headers=$t.from(e.headers),e.data=li.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Vl.getAdapter(e.adapter||Rr.adapter,e)(e).then(function(r){return ui(e),r.data=li.call(e,e.transformResponse,r),r.headers=$t.from(r.headers),r},function(r){return _l(r)||(ui(e),r&&r.response&&(r.response.data=li.call(e,e.transformResponse,r.response),r.response.headers=$t.from(r.response.headers))),Promise.reject(r)})}const ql="1.12.2",Ao={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ao[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Gl={};Ao.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 _e(o(i," has been removed"+(n?" in "+n:"")),_e.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}},Ao.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Dg(e,t,n){if(typeof e!="object")throw new _e("options must be an object",_e.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 _e("option "+s+" must be "+l,_e.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new _e("Unknown option "+s,_e.ERR_BAD_OPTION)}}const jo={assertOptions:Dg,validators:Ao},un=jo.validators;let Un=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=Hn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&jo.assertOptions(r,{silentJSONParsing:un.transitional(un.boolean),forcedJSONParsing:un.transitional(un.boolean),clarifyTimeoutError:un.transitional(un.boolean)},!1),o!=null&&(F.isFunction(o)?n.paramsSerializer={serialize:o}:jo.assertOptions(o,{encode:un.function,serialize:un.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),jo.assertOptions(n,{baseUrl:un.spelling("baseURL"),withXsrfToken:un.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&F.merge(s.common,s[n.method]);s&&F.forEach(["delete","get","head","post","put","patch","common"],w=>{delete s[w]}),n.headers=$t.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(l=l&&v.synchronous,a.unshift(v.fulfilled,v.rejected))});const u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let d,f=0,h;if(!l){const w=[Kl.bind(this),void 0];for(w.unshift(...a),w.push(...u),h=w.length,d=Promise.resolve(n);f<h;)d=d.then(w[f++],w[f++]);return d}h=a.length;let m=n;for(;f<h;){const w=a[f++],v=a[f++];try{m=w(m)}catch(g){v.call(this,g);break}}try{d=Kl.call(this,m)}catch(w){return Promise.reject(w)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=Hn(this.defaults,t);const n=Ol(t.baseURL,t.url,t.allowAbsoluteUrls);return El(n,t.params,t.paramsSerializer)}};F.forEach(["delete","get","head","options"],function(t){Un.prototype[t]=function(n,r){return this.request(Hn(r||{},{method:t,url:n,data:(r||{}).data}))}}),F.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Hn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Un.prototype[t]=n(),Un.prototype[t+"Form"]=n(!0)});let Lg=class hm{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 lr(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 hm(function(o){t=o}),cancel:t}}};function $g(e){return function(n){return e.apply(null,n)}}function Fg(e){return F.isObject(e)&&e.isAxiosError===!0}const di={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(di).forEach(([e,t])=>{di[t]=e});function Yl(e){const t=new Un(e),n=dl(Un.prototype.request,t);return F.extend(n,Un.prototype,t,{allOwnKeys:!0}),F.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Yl(Hn(e,o))},n}const gt=Yl(Rr);gt.Axios=Un,gt.CanceledError=lr,gt.CancelToken=Lg,gt.isCancel=_l,gt.VERSION=ql,gt.toFormData=To,gt.AxiosError=_e,gt.Cancel=gt.CanceledError,gt.all=function(t){return Promise.all(t)},gt.spread=$g,gt.isAxiosError=Fg,gt.mergeConfig=Hn,gt.AxiosHeaders=$t,gt.formToJSON=e=>Al(F.isHTMLForm(e)?new FormData(e):e),gt.getAdapter=Vl.getAdapter,gt.HttpStatusCode=di,gt.default=gt;const{Axios:vT,AxiosError:wT,CanceledError:bT,isCancel:yT,CancelToken:ST,VERSION:CT,all:kT,Cancel:TT,isAxiosError:ET,spread:IT,toFormData:NT,AxiosHeaders:AT,HttpStatusCode:jT,formToJSON:_T,getAdapter:MT,mergeConfig:PT}=gt,Xl=typeof window<"u"?window.__API_BASE_URL__:void 0,Jl=Xl?bn(Xl):void 0;function bn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let _o=null;const fi=new Set;function Zl(){return _o}function Mo(e){_o=e,fi.forEach(t=>t(e))}function Ql(e){return fi.add(e),()=>fi.delete(e)}const Bg=3e4,zg=9e4,Gt=gt.create({...Jl?{baseURL:Jl}:{},timeout:Bg,withCredentials:!0});Gt.interceptors.request.use(e=>(_o&&(e.headers.Authorization=`Bearer ${_o}`),e)),Gt.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),Mo(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 Yt(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Po(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ec(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function hi(e,t){return Gt.defaults.baseURL?(await Gt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Ft(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class tc{get baseUrl(){const t=Gt.defaults.baseURL;return t?bn(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.defaults.baseURL=bn(String(t.baseUrl))),t.authToken!==void 0&&Mo(t.authToken)}getAuthToken(){return Zl()}setAuthToken(t){Mo(t)}onTokenChange(t){return Ql(t)}async listThreads(){const t=await Yt("/threads"),n=Ft(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Yt("/threads/shared"),n=Ft(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Po("/threads",t?{title:t}:void 0);return Ft(r)}async updateThread(t,n){const r=await ec(`/threads/${t}`,{title:n});return Ft(r)}async deleteThread(t){const n=await hi(`/threads/${t}`);return Ft(n)}async shareThread(t,n){const r=await Po(`/threads/${t}/share`,{shared_with_user_id:n});return Ft(r)}async threadInfo(t){const n=await Yt(`/threads/${t}/info`);return Ft(n)}async listAgents(){const t=await Yt("/agents"),n=Ft(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Yt(`/agents/${t}`);return Ft(n)}async getAgentSchema(t){const n=await Yt(`/agents/${t}/schema`);return Ft(n)}async getState(t){const n=await Yt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ft(n)}async getStateHistory(t){const n=await Yt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:zg});return Ft(n)}async cancelRun(t){const n=await Po("/runs/cancel",{threadId:t});return Ft(n)}async unshareThread(t,n){const r=await hi(`/threads/${t}/share/${n}`);return Ft(r)}}const Tn=new tc,nc=y.createContext(null);function Hg({children:e,apiConfig:t}){const n=Tn;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 pi(){const e=y.useContext(nc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Ug(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 Wg(e=[]){const t=[],n=[];for(const r of e)try{const o=await Ug(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}const rc=120;function Vg(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>rc?`${n.slice(0,rc-3)}…`:n:""}function oc(e){return Vg(e.content)||""}function Kg(e){const t=new Map;for(const n of e){if(!n.id||n.role!=="user")continue;const r=oc(n);r&&t.set(n.id,r)}return t}function qg(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=oc(o);s&&t.set(r.checkpointId,s)}}return t}function Dr(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function cr(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function Gg(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 sc(e){const t=Dr(e);if(t)return Dr(t.configurable)??t}function Wn(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)=>Yg(s,i)).filter(s=>!!s)].sort((s,i)=>ic(i.createdAt)-ic(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 Yg(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=sc(e.config),i=Dr(e.parent_config??e.parentConfig),a=sc(i),l=cr(s,["checkpoint_id","checkpointId"]),u=cr(s,["checkpoint_ns","checkpointNs"]),d=cr(a,["checkpoint_id","checkpointId"]),f=cr(a,["checkpoint_id","checkpointId"])??null,h=cr(a,["checkpoint_ns","checkpointNs"])??null,m=Dr(e.config),w=Array.isArray(e.tasks)?e.tasks.map(S=>({...S})):e.tasks??null,v=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(),x={...o,step:Gg(o,["step"])??0,source:cr(o,["source"])??null};return{checkpointId:l??null,checkpointNs:u??null,createdAt:g,parentId:d??null,messages:r,nextCursor:f,nextCursorNs:h,interrupt:Xg(r,t),metadata:x,config:m??null,parentConfig:i??null,next:v,tasks:w}}function Xg(e,t){return Jg(e,t)}function Jg(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 ic(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function Zg(e){for(let t=e.messages.length-1;t>=0;t--){const n=e.messages[t];if(n.role==="user")return n.id}return null}function Qg(e){return y.useMemo(()=>e.map((t,n)=>({id:t.checkpointId??`cp-${n}`,label:t.metadata.source==="input"?"User Input":`Step ${t.metadata.step}`,messageId:Zg(t)??null,step:t.metadata.step,source:t.metadata.source,createdAt:t.createdAt??null,next:t.next&&t.next.length>0?String(t.next[0]):null,parentConfig:t.parentConfig??null})),[e])}function ex(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}}function tx(e,t){if(!e||typeof e!="object")return null;const n=e[t];return typeof n=="number"?n:null}function nx(e,t){if(!e||typeof e!="object")return null;const n=e[t];return typeof n=="string"&&n.trim()?n:null}function rx(e){const{checkpointMetaById:t,checkpointIndexByKey:n,attemptMetaById:r,userMessageIdToAttempts:o}=y.useMemo(()=>{const s=new Map,i=new Map,a=new Map;for(const d of e){const f=d.checkpointId??null;if(!f)continue;const h=tx(d.metadata,"step"),m=nx(d.metadata,"source"),w={id:f,step:h,source:m,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null};if(s.set(f,w),h!==null&&m){const v=`${h}:${m}`,g=i.get(v)??[];g.push(w),i.set(v,g)}}const{attemptMetaById:l,userMessageIdToAttempts:u}=ex(e);for(const[d,f]of s.entries()){const h=l.get(d);h?a.set(d,{...f,attemptIndex:h.attemptIndex,attemptCount:h.attemptCount,isLatestAttempt:h.isLatestAttempt,baseUserMessageId:h.baseUserMessageId??null}):a.set(d,{...f,attemptIndex:0,attemptCount:1,isLatestAttempt:!0,baseUserMessageId:null})}return{checkpointMetaById:s,checkpointIndexByKey:i,attemptMetaById:a,userMessageIdToAttempts:u}},[e]);return{checkpointMetaById:t,checkpointIndexByKey:n,attemptMetaById:r,userMessageIdToAttempts:o}}function ox(e,t){return y.useMemo(()=>{var d,f,h,m,w;const n=e&&"type"in e&&e.type==="default_message";let r=[],o=null,s={},i={},a=null,l=null,u=null;if(!n&&e){const v=e,g=v.checkpointId??null;s=v.additionalKwargs??{},i=v.responseMetadata??{};const x=g&&t.checkpointMetaById?t.checkpointMetaById.get(g)??null:null;a=typeof s.step=="number"?s.step:typeof i.step=="number"?i.step:(x==null?void 0:x.step)??null;const b=typeof s.source=="string"?s.source:typeof i.source=="string"?i.source:(x==null?void 0:x.source)??null;l=b?String(b):null;const S=a!==null&&l?`${a}:${l}`:null;if(S&&((d=t.checkpointIndexByKey)!=null&&d.has(S))?r=t.checkpointIndexByKey.get(S)??[]:g&&x&&(r=[x]),o=g??((f=r[0])==null?void 0:f.id)??null,u=g?((h=t.attemptMetaById)==null?void 0:h.get(g))??null:null,!u&&(e==null?void 0:e.role)==="user"&&(e!=null&&e.id)&&t.userMessageIdToAttempts){const T=t.userMessageIdToAttempts.get(e.id);if(T&&T.length>0){const C=T[0].checkpointId;u=((m=t.attemptMetaById)==null?void 0:m.get(C))??null,u&&console.log(`[useMessageMetadata] Found attempt by user message ID "${e.id}":`,T.length,"versions")}}if(!u&&r.length>0&&t.attemptMetaById){const T=t.attemptMetaById.get(r[0].id);T&&(u=T)}if(u&&u.attemptCount>1&&t.attemptMetaById){const T=u.baseUserMessageId;if(T){const C=[];for(const[k,E]of t.attemptMetaById.entries())if(E.baseUserMessageId===T){const A=(w=t.checkpointMetaById)==null?void 0:w.get(k);A&&C.push(A)}C.length>0&&(r=C)}}if(u&&u.attemptCount>1&&t.checkpointMetaById&&t.attemptMetaById){const T=[];for(const[C,k]of t.checkpointMetaById.entries()){const E=t.attemptMetaById.get(C);E&&E.attemptCount===u.attemptCount&&E.baseUserMessageId===u.baseUserMessageId&&T.push(k)}T.sort((C,k)=>{const E=C.createdAt?Date.parse(C.createdAt):0;return(k.createdAt?Date.parse(k.createdAt):0)-E}),T.length>0&&(r=T,console.log("[useMessageMetadata] Populated checkpointCandidates with all attempts:",{messageId:e.id,attemptCount:u.attemptCount,candidateIds:r.map(C=>C.id)}))}}return{checkpointCandidates:r,defaultCheckpointId:o,attemptMeta:u,resolvedStep:a,resolvedSource:l}},[e,t.checkpointMetaById,t.checkpointIndexByKey,t.attemptMetaById,t.userMessageIdToAttempts])}function sx({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),w=y.useMemo(()=>Wn(f),[f]).checkpoints,v=Qg(w),[g,x]=y.useState(!1),[b,S]=y.useState(null),[T,C]=y.useState(!1),[k,E]=y.useState(!1),[A,O]=y.useState(!1),[$,H]=y.useState(null),U=y.useRef(o),K=y.useRef(null),R=y.useRef(null),Y=y.useRef(null),N=y.useRef(null),D=y.useRef(!1),M=y.useRef(null),j=y.useRef(new Map);y.useEffect(()=>{U.current=o},[o]);const z=y.useCallback(async q=>{var pe,he;if(!q.threadId)return;const X=q.threadId;(pe=q.onStart)==null||pe.call(q),q.setLoading(!0);try{await q.action(X)}catch(ee){if(U.current===X){const le=String(ee);(he=q.handleError)==null||he.call(q,le),r==null||r(le)}throw ee}finally{q.setLoading(!1)}},[r]),W=y.useCallback(async(q,X)=>{if(!q)return;const pe=`${q}:${X??"latest"}`,he=j.current.get(pe);if(he)return he;const ee=z({threadId:q,setLoading:C,onStart:()=>H(null),handleError:le=>H(le),action:async le=>{const we=await e.getStateHistory({threadId:le,checkpointId:X??void 0});if(U.current!==le){console.log(`[useThreadHistoryState] Thread changed during load (was ${le}, now ${U.current}), discarding stale data`);return}const{checkpoints:je}=Wn(we),Ne=je.find($e=>$e.messages&&$e.messages.length>0)??(X?je.find($e=>$e.checkpointId===X):null)??je[0];t((Ne==null?void 0:Ne.messages)??[],{checkpointId:(Ne==null?void 0:Ne.checkpointId)??null,checkpointNs:(Ne==null?void 0:Ne.checkpointNs)??null}),h(we),x(!!(Ne!=null&&Ne.nextCursor)),S((Ne==null?void 0:Ne.nextCursor)??null)}});j.current.set(pe,ee);try{await ee}finally{j.current.delete(pe)}return U.current===q&&(M.current=pe),ee},[e,t,z]),P=y.useCallback(async(q,X)=>{N.current=q;try{await W(q,X)}finally{N.current===q&&(N.current=null)}},[W]),B=y.useCallback(q=>{R.current=q},[]),te=y.useCallback(q=>{Y.current=q},[]),J=y.useCallback(q=>{const X=q.threadId??U.current;if(!X||U.current&&U.current!==X)return;const{checkpoints:pe}=Wn(q);if(!pe.length)return;const he=pe.find(ee=>ee.messages&&ee.messages.length>0)??pe.find(ee=>!!ee.checkpointId)??pe[0];t((he==null?void 0:he.messages)??[],{checkpointId:(he==null?void 0:he.checkpointId)??null,checkpointNs:(he==null?void 0:he.checkpointNs)??null}),h(q),x(!!(he!=null&&he.nextCursor)),S((he==null?void 0:he.nextCursor)??null),M.current=`${X}:latest`,R.current=null,Y.current=null},[t]),re=y.useCallback(async(q,X)=>{const pe=U.current;await z({threadId:pe,setLoading:O,action:async he=>{const ee=await e.getStateHistory({threadId:he,checkpointId:q,checkpointNs:X??void 0});if(U.current!==he){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${he}, now ${U.current}), discarding stale data`);return}const{checkpoints:le}=Wn(ee),we=le.find(je=>je.checkpointId===q&&(X?je.checkpointNs===X:!0));if(!we){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:q,checkpointNs:X});return}h(ee),t(we.messages??[],{checkpointId:we.checkpointId??null,checkpointNs:we.checkpointNs??null})}}).catch(()=>{})},[e,t,z]),G=y.useCallback((q,X)=>{t(d(),{checkpointId:q??null,checkpointNs:X??null})},[d,t]),L=y.useCallback(async()=>{U.current&&await P(U.current)},[P]),V=y.useCallback(async()=>{const q=U.current;!q||!b||await z({threadId:q,setLoading:E,action:async X=>{const pe=await e.getStateHistory({threadId:X,checkpointId:b});if(U.current!==X)return;const{checkpoints:he}=Wn(pe);if(he.length>0){const ee=he[he.length-1];n((ee==null?void 0:ee.messages)??[]),x(!!(ee!=null&&ee.nextCursor)),S((ee==null?void 0:ee.nextCursor)??null)}}}).catch(()=>{})},[e,b,r,n,z]);y.useEffect(()=>{if(!l||!o||T||u)return;if(R.current===o){R.current=null,K.current=o;return}if(Y.current===o){K.current=o;return}if(N.current===o){N.current=null,K.current=o;return}if(K.current===o)return;K.current=o;const q=!D.current&&!!i&&o===s;let X;q&&i?(X=i,D.current=!0,console.log("[useThreadHistoryState] Loading thread with checkpoint:",X,a?`(ns: ${a})`:"")):console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const pe=`${o}:${X??"latest"}`;M.current!==pe&&P(o,X)},[l,o,i,a,s,T,u,P]);const Z=y.useCallback(()=>{h(null),x(!1),S(null),C(!1),E(!1),O(!1),H(null),R.current=null,Y.current=null,K.current=null,M.current=null,N.current=null},[]);return{threadCheckpoints:w,threadTimeline:v,isLoadingThread:T,isHistoryLoading:k,isLoadingCheckpoint:A,threadStateError:$,hasMoreHistory:g,loadThread:P,navigateToCheckpoint:re,loadOlderMessages:V,setCurrentCheckpointId:G,returnToLatest:L,handleStateHistoryEvent:J,markSkipNextLoad:B,markStreamPendingThread:te,resetHistoryState:Z}}const ix=["detail","message","error","description","title"];function Ro(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=Ro(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of ix){const r=Ro(t[n]);if(r)return r}if("errors"in t){const n=Ro(t.errors);if(n)return n}}return null}function ax(e){if(!e)return"Request failed";const t=e.response,n=Ro(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 lx({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),[m,w]=y.useState([]),[v,g]=y.useState(!1),[,x]=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 M=await e.listThreads();i(M??[])}catch(M){const j=String(M);h(j),n==null||n(j)}finally{d(!1)}},[e,n]),O=y.useCallback(async()=>{g(!0),x(null);try{const M=await e.listSharedThreads();w(M??[])}catch(M){const j=String(M);x(j),n==null||n(j)}finally{g(!1)}},[e,n]);y.useEffect(()=>{A()},[A]),y.useEffect(()=>{O()},[O]),y.useEffect(()=>{r==null||r(a)},[a,r]);const $=y.useCallback(async M=>{try{const j=await e.createThread(M);return l(j.threadId),await A(),j.threadId}catch(j){const z=String(j);return n==null||n(z),null}},[e,n,A]),H=y.useCallback(async M=>{const j=s;i(W=>W.filter(P=>P.threadId!==M));const z=new AbortController;E.current.set(M,z);try{await e.deleteThread(M),k.current===M&&(l(null),o==null||o())}catch(W){i(j);const P=String(W);n==null||n(P)}finally{E.current.delete(M)}},[e,o,n,s]),U=y.useCallback(async(M,j)=>{try{await e.updateThread(M,j),await A()}catch(z){n==null||n(String(z))}},[e,n,A]),K=y.useCallback(async(M,j)=>{C(!0),S("Sharing thread…");try{await e.shareThread(M,j),await O(),S("Shared successfully")}catch(z){const W=ax(z);throw n==null||n(W),S(`Failed to share: ${W}`),new Error(W)}finally{C(!1)}},[e,n,O]),R=y.useCallback(async(M,j)=>{try{await e.unshareThread(M,j),await O()}catch(z){const W=String(z);throw n==null||n(W),z}},[e,n,O]),Y=y.useMemo(()=>({createThread:$,deleteThread:H,renameThread:U,refreshThreads:A,refreshSharedThreads:O,shareThread:K,unshareThread:R}),[$,H,U,A,O,K,R]),N=y.useCallback(M=>{if(!(M!=null&&M.threadId))return;const j={threadId:M.threadId,title:M.title||`Thread ${M.threadId.slice(0,8)}`,createdAt:M.createdAt||new Date().toISOString(),updatedAt:M.updatedAt||new Date().toISOString(),messageCount:M.messageCount??1};i(z=>{let W=!1;const P=z.map(B=>B.threadId===j.threadId?(W=!0,console.debug("[useThreadsState] thread_info: updating existing thread",j.threadId),{...B,title:j.title??B.title,updatedAt:j.updatedAt??B.updatedAt,messageCount:j.messageCount??B.messageCount}):B);return W?P:(console.debug("[useThreadsState] thread_info: adding thread to list",j.threadId),[j,...z])})},[]),D=y.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:k,setCurrentThreadId:l,isLoadingThreads:u,threadsError:f,sharedThreads:m,isLoadingSharedThreads:v,actions:Y,addThreadFromEvent:N,shareInFlight:T,shareStatus:b,clearShareStatus:D}}function mi(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 ac(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(ac(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 ur(e){if(typeof e=="string")return e;if(ac(e))return"";try{const t=Lr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function cx(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function ux(e){const t=ur(e);return typeof e=="string"&&cx(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=mi(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 dx(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function gi(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 Oo(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function fx(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 hx(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function lc(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 px(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function mx(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function gx({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=px(n),i=o?`data:${s};base64,${e}`:t,a=mx(r),l=a.length?a.join(" / "):void 0,u=l?`${l} artifact`:"artifact image";return{src:i,alt:u,label:l}}function xx(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 gx({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function xi(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 vx(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 cc(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function uc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function wx(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??uc(e);let l="",u=e.slice();if(s){const f=bx(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 m=h.text??"",w={...h,text:m+l};u=[...u.slice(0,u.length-1),w]}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 dc(e){return e.replace(/\s+/g," ").trim()}function bx(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=dc(e),o=dc(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 yx(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 Sx(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const Cx={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function kx(e,t){var n;switch(t.type){case"reset":return{messages:xi(((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=xi(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=xi(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 hc(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>hc(o,s),e):e}default:return e}}function fc(e=[]){const[t,n]=y.useReducer(kx,{...Cx,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 hc(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=Sx(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 Ex(e,t);if(t.type==="tool.progress")return Ix(e,t);if(t.type==="tool.end")return Nx(e,t);if(t.type==="message.delta"){const s=e.assemblingId??cc(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:uc(l.content)},m=t.seq??null;if(m!==null&&typeof m=="number"&&typeof h.lastSeq=="number"&&m<=h.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:m,lastSeq:h.lastSeq}),e;const{newParts:w,newMeta:v,changed:g}=wx(l.content,t.delta,h,m);if(!g)return e;const x={...l,content:w},b=Fr(i,a,x),S=!f||f.lastSeq!==v.lastSeq||f.lastText!==v.lastText,T=S?{...d,[s]:v}:u;return S?{...e,messages:b,messagesStreamMeta:T}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??cc(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=yx(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=Wn(t),i=s.interrupt,a=s.latest,l=i===null?vx(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 vi(e){return e.call_id??e.id??null}function pc(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function mc(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 wi(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||gi(r).toolCallId===t)return n}return-1}function Tx(e){if(e==null)return[];const t=$r(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=ur(t??e);return n?[{type:"text",text:n}]:[]}function gc(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function Ex(e,t){const n=vi(t),r=wi(e.messages,n),o=t.name??t.tool??void 0,s=pc(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=mc(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function Ix(e,t){const n=vi(t);if(!n)return e;const r=wi(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=gc(e.messages[r],o);return{...e,messages:Fr(e.messages,r,a)}}function Nx(e,t){const n=vi(t),r=pc(t);let o=e.messages,s=wi(o,n);if(s===-1){const w=t.name??t.tool??void 0;o=[...o,mc(r,n,w,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=Tx(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=gc(i,d),h=t.artifact??i.artifact,m={...f,name:t.name??t.tool??i.name,content:u,artifact:h,additionalKwargs:{...f.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Fr(o,s,m)}}function xc(e={}){const t=y.useMemo(()=>bn(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(""),[m,w]=y.useState(null),[v,g]=y.useState(0),[x,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),O=y.useRef(null),$=y.useCallback(R=>{o(R)},[]),H=y.useCallback(()=>{h(""),w(null),d(null),E.current=null,A.current=null,O.current=null},[]),U=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)},[]),K=y.useCallback((R,Y,N)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h(""),w(null),E.current=null,A.current=null,O.current=null;const D=new AbortController;S.current=D;let M=null,j=null,z=!1;return k.current={threadId:R.threadId??null,headers:{}},(async()=>{var P,B,te,J,re,G,L,V,Z,q,X,pe,he,ee,le,we,je,Ne;const W=$e=>{var Ye;try{const nt=JSON.parse(JSON.stringify($e));return(Ye=nt==null?void 0:nt.payload)!=null&&Ye.files_info&&Array.isArray(nt.payload.files_info)&&(nt.payload.files_info=nt.payload.files_info.map(Ve=>({...Ve,data:Ve!=null&&Ve.data?`<base64 ${String(Ve.data).length} chars>`:Ve==null?void 0:Ve.data}))),nt}catch{return $e}};try{let $e={};try{if(r)$e={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ke=window.__AUTH_TOKEN__,dt=((P=window.localStorage)==null?void 0:P.getItem("authToken"))||null;let vt=null;try{const St=(B=window.localStorage)==null?void 0:B.getItem("chat-settings");St&&(vt=((te=JSON.parse(St))==null?void 0:te.apiKey)||null)}catch{}const Ue=Ke||dt||vt||null;Ue&&($e={Authorization:`Bearer ${Ue}`})}}catch{}console.debug("[use-chat] POST",t+n,W(R));let Ye={};if(typeof window<"u")try{const Xe=(J=window.localStorage)==null?void 0:J.getItem("authSessionId");Xe&&(Ye={"X-Session-Id":Xe})}catch{}const nt={...$e,...Ye,...s.current},Ve={"Content-Type":"application/json",Accept:"text/event-stream",...nt},qe=await fetch(t+n,{method:"POST",headers:Ve,body:JSON.stringify(R),signal:D.signal,credentials:i});if(k.current&&(k.current.headers=nt),!qe.ok||!qe.body){const Xe=await qe.text().catch(()=>"");console.debug("[use-chat] non-OK response",qe.status,Xe==null?void 0:Xe.slice(0,500));const Ke=`stream ${qe.status}${Xe?": "+Xe:""}`;throw(re=N==null?void 0:N.onConnectionError)==null||re.call(N,Ke),z=!0,M="error",j=Ke,new Error(Ke)}b(!0);const rt=qe.body.getReader(),kt=new TextDecoder;let at="",ke=[];C.current=0,g(0);let Oe=0,it=null;const ht=()=>{if(ke.length){const Xe=ke.join("");ke=[],T.current&&h(Ke=>Ke+Xe)}it=null},Tt=()=>{typeof window<"u"&&it==null&&(it=requestAnimationFrame(ht))};let yt=Date.now();const Le=setInterval(()=>{var Xe;if(Date.now()-yt>18e5){const Ke="Stream idle timeout";d(Ke),M="error",j=Ke,D.abort(),(Xe=N==null?void 0:N.onError)==null||Xe.call(N,Ke)}},5e3),Ht=1024*1024;try{const Xe=qe.headers.get("X-Thread-Id")||qe.headers.get("x-thread-id"),Ke=qe.headers.get("X-Thread-Created")||qe.headers.get("x-thread-created"),dt=Xe??null,vt=String(Ke??"").toLowerCase()==="true";for(k.current&&!k.current.threadId&&(k.current={...k.current,threadId:dt}),(G=N==null?void 0:N.onOpen)==null||G.call(N,{threadId:dt,created:vt});;){const{value:Ue,done:St}=await rt.read();if(St)break;at+=kt.decode(Ue,{stream:!0}),at.length>Ht&&(at="",console.warn("Stream buffer reset: exceeded 1MB"));let _;for(;(_=at.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 ie=at.slice(0,_);at=at.slice(_+2);const ge=jx(ie);if(!ge)continue;let We;try{We=JSON.parse(ge)}catch{console.debug("[use-chat] malformed SSE:",ge.slice(0,200));continue}const Re=Ax(We)?We.data:We;yt=Date.now();const mt=Re.seq;if(mt!==void 0){if(mt<=Oe){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:mt,lastProcessedSeq:Oe,type:Re.type});continue}Oe>0&&mt>Oe+1&&((L=N==null?void 0:N.onGap)==null||L.call(N,{from:Oe,to:mt})),Oe=mt,C.current=mt,g(mt)}if(Re.type==="checkpoint")E.current=Re.checkpointId??null,A.current=Re.checkpointNs??null,w(Re.checkpointId??null);else if(Re.type==="state_history"){O.current=Re;try{const Nt=Wn(Re).latest;Nt&&(E.current=Nt.checkpointId??null,A.current=Nt.checkpointNs??null,w(Nt.checkpointId??null))}catch(Je){console.warn("[use-chat] Failed to hydrate state_history payload",Je)}}try{Y==null||Y(Re)}catch(Je){console.error("[use-chat] Error in onEvent callback:",Je,"for event:",Re.type)}if(Re.type==="message.delta"){const Je=Re.delta.filter(Nt=>Nt.type==="text").map(Nt=>Nt.text).join("");Je&&e.autoAppendAssistant!==!1&&(ke.push(Je),Tt())}else if(Re.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(V=N==null?void 0:N.onHeartbeat)==null||V.call(N,Re)}catch(Je){console.warn("[use-chat] heartbeat callback failed",Je)}}else if(it!==null&&cancelAnimationFrame(it),ht(),Re.type==="checkpoint")w(Re.checkpointId);else if(Re.type==="error"){const Je=Re;if(d(Je.message),M="error",j=Je.message,Je.error_type==="auth_error"||Je.code==="TOKEN_EXPIRED"||((Z=Je.message)==null?void 0:Z.includes("token"))||((q=Je.message)==null?void 0:q.includes("401"))||((X=Je.message)==null?void 0:X.includes("unauthorized"))||((pe=Je.message)==null?void 0:pe.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Je.message);try{(he=N==null?void 0:N.onAuthError)==null||he.call(N,Je.message)}catch(go){console.warn("[use-chat] onAuthError handler failed",go)}D.abort()}}}}ht(),M===null&&!D.signal.aborted&&(M="complete")}catch(Xe){if(Xe.name==="AbortError")M=M??"aborted";else{const Ke=Xe.message||String(Xe);M="error",j=Ke,d(Ke),(ee=N==null?void 0:N.onError)==null||ee.call(N,Ke)}}finally{try{await rt.cancel()}catch{}finally{(le=rt.releaseLock)==null||le.call(rt)}it!==null&&typeof window<"u"&&window.cancelAnimationFrame(it),clearInterval(Le)}}catch($e){if($e.name==="AbortError")M=M??"aborted";else{const Ye=$e.message||String($e);M="error",j=Ye,d(Ye),(we=N==null?void 0:N.onError)==null||we.call(N,Ye),z||((je=N==null?void 0:N.onConnectionError)==null||je.call(N,Ye),z=!0)}}finally{const $e=C.current,Ye=E.current,nt=A.current,Ve=O.current,qe=M??(D.signal.aborted?"aborted":j?"error":"complete");try{(Ne=N==null?void 0:N.onClosed)==null||Ne.call(N,{reason:qe,lastSeq:$e,lastCheckpointId:Ye,lastCheckpointNs:nt,lastStateHistory:Ve,error:j})}catch(rt){console.warn("[use-chat] onClosed callback failed",rt)}l(!1),b(!1),S.current=null,C.current=0,g(0),k.current=null}})(),{close:()=>D.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:m,lastSeq:v,connected:x,stream:K,stop:U,clear:H,setToken:$}}function Ax(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function jx(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 _x=["message.start","message.delta","message.end"],Mx=["tool.start","tool.end","tool.progress"],Px=["thread_info","checkpoint"],Rx=["error","interrupt","heartbeat","state_history","cancelled"],Ox=[..._x,...Mx,...Px,...Rx],Dx=new Set(Ox);function Lx(e){if(typeof e!="object"||e===null||typeof e.type!="string")return!1;const t=e.type;return Dx.has(t)}const vc=200;function $x({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),m=y.useRef(new Map),w=y.useRef(null),v=y.useRef(null),g=y.useCallback(N=>{try{const D=globalThis.structuredClone;if(typeof D=="function")return D(N)}catch{}try{return JSON.parse(JSON.stringify(N))}catch{return N}},[]),x=y.useCallback((N,D)=>{if(!N)return;const M=m.current.get(N)??[],j=g(D),z=M.length>=vc?[...M.slice(M.length-vc+1),j]:[...M,j];m.current.set(N,z)},[g]),b=y.useCallback(N=>{N&&m.current.set(N,[])},[]),S=y.useCallback(N=>{const D=N??h.current;if(!D)return;const M=m.current.get(D);M!=null&&M.length&&M.forEach(j=>{try{n(j)}catch(z){console.error("[useChatStreamingService] Failed to replay buffered event",z)}})},[n]),T=y.useCallback(N=>{h.current=N.threadId,w.current&&(w.current.threadIdGuess=N.threadId),v.current=N,b(N.threadId),console.log("[useChatStreamingService] 🎯 Received thread_info event:",N);try{t(N)}catch(D){console.error("[useChatStreamingService] Error in onThreadInfo handler:",D)}},[b,t]),C=y.useCallback(N=>{try{u==null||u(N)}catch(D){console.error("[useChatStreamingService] Error in onHeartbeat handler:",D)}},[u]),k=y.useCallback(N=>{var j,z,W,P;const D=N;if(D.error_type==="auth_error"||D.code==="TOKEN_EXPIRED"||((j=D.message)==null?void 0:j.includes("token"))||((z=D.message)==null?void 0:z.includes("401"))||((W=D.message)==null?void 0:W.includes("unauthorized"))||((P=D.message)==null?void 0:P.includes("Unauthorized"))){console.error("[useChatStreamingService] Auth error event detected:",D.message);try{l==null||l(D.message)}catch(B){console.warn("[useChatStreamingService] onAuthError handler failed",B)}}},[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 z;const D=N.seq??null;if(D!==null){const W=f.current;if(W!==null){if(D<=W)return;D>W+1&&(s==null||s({from:W,to:D}))}f.current=D}const M=E[N.type];if(M&&M(N))return;const j=N.threadId??(N.type==="state_history"?N.threadId:void 0)??h.current??((z=w.current)==null?void 0:z.threadIdGuess)??null;if(N.type==="state_history"){h.current=j??h.current;try{r==null||r(N)}catch(W){console.error("[useChatStreamingService] onStateHistory handler failed",W)}}if(Lx(N)){(N.type==="tool.start"||N.type==="tool.end")&&(d==null||d(N)),N.type==="checkpoint"||N.type==="state_history"?b(j??null):x(j??null,N);try{n(N)}catch(W){console.error("[useChatStreamingService] Error in onMessageEvent handler:",W)}return}try{o==null||o(N)}catch(W){console.error("[useChatStreamingService] Error in onUnhandledEvent handler:",W)}},[x,b,n,s,r,o,E]),{stream:O,stop:$,isStreaming:H,error:U,setToken:K}=xc({baseUrl:e,token:void 0}),R=y.useCallback((N,D)=>{f.current=null,v.current=null,h.current=N.threadId??null,w.current={request:N,callbacks:D,manualStop:!1,threadIdGuess:N.threadId??null},O(N,A,{onOpen:D==null?void 0:D.onOpen,onError:M=>{var j;(j=D==null?void 0:D.onError)==null||j.call(D,M)},onGap:(D==null?void 0:D.onGap)??s,onConnectionError:M=>{var j;a==null||a(M),(j=D==null?void 0:D.onConnectionError)==null||j.call(D,M)},onAuthError:M=>{var j;l==null||l(M),(j=D==null?void 0:D.onAuthError)==null||j.call(D,M)},onHeartbeat:M=>{var j;try{u==null||u(M)}catch(z){console.warn("[useChatStreamingService] onHeartbeat handler failed",z)}try{(j=D==null?void 0:D.onHeartbeat)==null||j.call(D,M)}catch(z){console.warn("[useChatStreamingService] downstream onHeartbeat handler failed",z)}},onClosed:M=>{var P,B,te,J;const j=((P=w.current)==null?void 0:P.manualStop)??!1,z=h.current??((B=w.current)==null?void 0:B.threadIdGuess)??((te=M.lastStateHistory)==null?void 0:te.threadId)??null;(M.reason==="complete"||M.reason==="aborted"&&j)&&b(z);const W={...M,threadId:z,threadInfo:v.current,manualStop:j};try{i==null||i(W)}catch(re){console.warn("[useChatStreamingService] onStreamClosed handler failed",re)}try{(J=D==null?void 0:D.onClosed)==null||J.call(D,W)}catch(re){console.warn("[useChatStreamingService] downstream onClosed handler failed",re)}w.current&&(w.current=null)}})},[b,A,l,a,u,s,i,O]),Y=y.useCallback(()=>{w.current&&(w.current.manualStop=!0),$()},[$]);return y.useMemo(()=>({startStream:R,stop:Y,isStreaming:H,error:U,setAuthToken:K,replayBufferedEvents:S}),[R,Y,H,U,K,S])}const wc=y.createContext(null),bc=y.createContext(null),yc=y.createContext(null);y.createContext(!1);function Fx({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}=pi(),h=y.useMemo(()=>bn(f),[f]),{state:m,seed:w,prepend:v,pushUser:g,onEvent:x}=fc(),{threads:b,currentThreadId:S,setCurrentThreadId:T,currentThreadIdRef:C,isLoadingThreads:k,threadsError:E,sharedThreads:A,isLoadingSharedThreads:O,actions:$,addThreadFromEvent:H,shareInFlight:U,shareStatus:K,clearShareStatus:R}=lx({api:d,initialThreadId:t,onError:s,onThreadChange:a,onCurrentThreadDeleted:()=>w([],{})}),[Y,N]=y.useState(!1),D=y.useCallback(()=>m.messages,[m.messages]),{threadCheckpoints:M,threadTimeline:j,isLoadingThread:z,isHistoryLoading:W,isLoadingCheckpoint:P,threadStateError:B,hasMoreHistory:te,loadThread:J,navigateToCheckpoint:re,loadOlderMessages:G,setCurrentCheckpointId:L,returnToLatest:V,handleStateHistoryEvent:Z,markSkipNextLoad:q,markStreamPendingThread:X,resetHistoryState:pe}=sx({api:d,seed:w,prepend:v,onError:s,currentThreadId:S,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:Y,getMessages:D}),he=y.useMemo(()=>qg(M),[M]),ee=y.useCallback(ke=>{console.log("[ChatSessionProvider] 🎯 Received thread_info:",ke.threadId),H(ke),C.current!==ke.threadId&&((ke.created??!C.current)&&q(ke.threadId),X(ke.threadId),console.log("[ChatSessionProvider] thread_info: marking to skip auto-load for new thread"),T(ke.threadId))},[H,q,X]),{startStream:le,stop:we,isStreaming:je,error:Ne,setAuthToken:$e}=$x({baseUrl:h,onThreadInfo:ee,onMessageEvent:x,onStateHistory:Z,onUnhandledEvent:ke=>{console.warn("[ChatSessionProvider] Unhandled event:",ke.type)},onAuthError:i,onConnectionError:l,onToolEvent:ke=>{ke.type==="tool.end"&&(u==null||u(ke))}});y.useEffect(()=>{N(je)},[je]);const Ye=y.useCallback(async()=>{w([],{}),T(null),we(),pe();try{await d.getAgent("default")}catch(ke){console.warn("[ChatSessionProvider] Failed to refetch agent after clearing thread:",ke)}},[w,we,d,pe]),nt=y.useCallback(async(ke,Oe,it)=>{const ht=C.current;if(!ht)throw new Error("No active thread to handle interrupt");const Tt=Oe?it??!0:!1;try{const yt={threadId:ht,checkpointId:m.lastCheckpointId??void 0,checkpointNs:m.lastCheckpointNs??void 0,command:{kind:"resume",value:Tt}};le(yt)}catch(yt){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${ke}:`,yt),yt}},[m.lastCheckpointId,m.lastCheckpointNs,le]),Ve=y.useCallback(async(ke,Oe)=>{let it=C.current;const ht=(ke==null?void 0:ke.text)??"",Tt=(ke==null?void 0:ke.attachments)??[],yt=(ht==null?void 0:ht.trim())??"",Le={...(ke==null?void 0:ke.payload)??{}},Ht=Array.isArray(Le.messages)?Le.messages:void 0;Ht&&delete Le.messages;const Xe=!!(Ht&&Ht.length);if(!it&&!yt&&Tt.length===0&&!Xe)return;if(!it){const mt=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Je=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);it=`${mt}${Je}`,q(it),T(it)}const{contentParts:Ke,filesInfo:dt}=await Wg(Tt),vt=[...Ke];yt&&vt.push({type:"text",text:ht});const Ue=Oe==null?void 0:Oe.originalMessageId,St=!!(Oe!=null&&Oe.edit&&Ue),_=!Xe&&vt.length>0;let ie=null;_&&(ie={id:St?Ue:`msg-${Date.now()}`,role:"user",content:vt,createdAt:new Date().toISOString()},St?g(ie,Ue):g(ie));const ge=Xe?Ht:ie?[ie]:[],We={...Le,...dt.length?{files_info:dt}:{}};ge.length?We.messages=ge:"messages"in We||(We.messages=[]);const Re={threadId:it,payload:We,checkpointId:(Oe==null?void 0:Oe.checkpointId)??m.lastCheckpointId??void 0,checkpointNs:(Oe==null?void 0:Oe.checkpointNs)??m.lastCheckpointNs??void 0,edit:!!(Oe!=null&&Oe.edit),timelineCheckpoints:j};le(Re)},[d,g,m,le,j]),qe=y.useMemo(()=>({threads:b,currentThreadId:S,setCurrentThreadId:T,isLoading:k,error:E,sharedThreads:A,isLoadingSharedThreads:O,actions:$,shareInFlight:U,shareStatus:K,clearShareStatus:R}),[b,S,T,k,E,A,O,$,U,K,R]),rt=y.useMemo(()=>{const ke=m.assemblingId??null;return ke?{assemblingMessageId:ke}:null},[m.assemblingId]),kt=y.useMemo(()=>({threadId:S,messages:m.messages,interrupt:null,checkpoint:{id:m.lastCheckpointId??null,namespace:m.lastCheckpointNs??null},checkpoints:M,timelineCheckpoints:j,metadata:rt,isLoading:z,isHistoryLoading:W,isLoadingCheckpoint:P,error:B,hasMore:te,loadOlder:G,clearState:Ye,navigateToCheckpoint:re,setCurrentCheckpointId:L,returnToLatest:V,loadThread:J,clearThread:Ye,respondToInterrupt:nt,messagePreviews:he}),[S,m,M,j,z,W,P,B,te,G,Ye,re,L,V,J,nt,he,rt]),at=y.useMemo(()=>({isStreaming:je,error:Ne,connectionState:je?"connected":"idle",submit:Ve,send:Ve,stop:we,setAuthToken:$e}),[je,Ne,Ve,we,$e]);return c.jsx(wc.Provider,{value:qe,children:c.jsx(bc.Provider,{value:kt,children:c.jsx(yc.Provider,{value:at,children:e})})})}function Do(){const e=y.useContext(wc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Lo(){const e=y.useContext(bc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function Sc(){const e=y.useContext(yc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function $o({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(Hg,{apiConfig:t,children:c.jsx(Fx,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:a,onAuthError:l,onConnectionError:i,onThreadChange:u,onToolEnd:d,children:e})})}function oe(...e){return mm.twMerge(pm.clsx(e))}const Bx=wo.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"}}),Qe=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Bn.Slot:"button";return c.jsx(i,{className:oe(Bx({variant:t,size:n,className:e})),ref:s,...o})});Qe.displayName="Button";const Cc=p.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:oe("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}));Cc.displayName="Textarea";const zx=1e4;function kc({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=zx,value:i,onValueChange:a,onSend:l,onCancelEdit:u,onStop:d,className:f="",textareaClassName:h="",allowEmptySend:m=!1,validate:w,onValidationError:v}){const g=i!==void 0,[x,b]=y.useState(e),S=(g?i:x)??"",[T,C]=y.useTransition(),k=y.useRef(null),E=y.useRef(0),A=y.useRef(null),O=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[$,H]=y.useState(null),U=y.useCallback(B=>B.length>s?`Message too long (${B.length}/${s} characters)`:null,[s]),K=y.useMemo(()=>w??U,[w,U]),R=y.useCallback(B=>{const te=K(B);return H(te),v==null||v(te),O.current=B,te},[K,v]),Y=y.useCallback(()=>{const B=k.current;B&&(B.style.height="auto",B.style.height=`${B.scrollHeight}px`)},[]);y.useEffect(()=>{Y()},[Y,S]),y.useEffect(()=>{if(!$)return;const B=(S??"").trim();O.current!==B&&R(B)},[S,$,R]);const N=y.useCallback((B,{fromUser:te})=>{g||b(B),te&&(a==null||a(B))},[g,a]),D=y.useCallback(async B=>{B&&B.preventDefault();const te=(S??"").trim();if(!te&&!m||R(te))return;const J=++E.current;A.current={id:J,shouldClear:!0},C(()=>{var re,G,L;try{const V=l(te);V&&typeof V.then=="function"?V.then(()=>{var Z,q;((Z=A.current)==null?void 0:Z.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(()=>{var Z;((Z=A.current)==null?void 0:Z.id)===J&&(A.current=null)}):(((re=A.current)==null?void 0:re.id)===J&&A.current.shouldClear&&(g||(b(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((G=A.current)==null?void 0:G.id)===J&&(A.current=null))}catch{((L=A.current)==null?void 0:L.id)===J&&(A.current=null)}})},[S,l,m,g,a,R]),M=y.useCallback(B=>{const te=B.target.value;N(te,{fromUser:!0}),A.current&&(A.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`),$&&R(te.trim())},[N,R,$]),j=y.useCallback(B=>{B.key==="Enter"&&!B.shiftKey?(B.preventDefault(),D()):B.key==="Escape"&&t&&(B.preventDefault(),u==null||u())},[D,t,u]),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))]":""} ${h}`;return c.jsx("form",{onSubmit:B=>void D(B),className:`w-full ${f}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx(Cc,{ref:k,value:S,onChange:M,onKeyDown:j,placeholder:t?"Edit your message...":n,className:P,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),$&&c.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:$})]}),c.jsx("div",{children:r?c.jsx(Qe,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:c.jsx(ae.Square,{size:16})}):c.jsx(Qe,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!m||T,children:c.jsx(ae.Send,{size:16})})})]})})}const Hx=y.memo(kc);function me(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 Tc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function En(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Tc(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():Tc(e[o],null)}}}}function ze(...e){return p.useCallback(En(...e),e)}function Ux(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,l=p.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=p.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 yn(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),l=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:m,...w}=f,v=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,g=p.useMemo(()=>w,Object.values(w));return c.jsx(v.Provider,{value:g,children:m})};u.displayName=s+"Provider";function d(f,h){var v;const m=((v=h==null?void 0:h[e])==null?void 0:v[l])||a,w=p.useContext(m);if(w)return w;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=>p.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Wx(o,...t)]}function Wx(...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 p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Et=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Vx=p[" useInsertionEffect ".trim().toString()]||Et;function dr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Kx({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=p.useRef(e!==void 0);p.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=p.useCallback(d=>{var f;if(a){const h=qx(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 Kx({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Vx(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function qx(e){return typeof e=="function"}var Gx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ye=Gx.reduce((e,t)=>{const n=Bn.createSlot(`Primitive.${t}`),r=p.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 Ec(e,t){e&&bo.flushSync(()=>e.dispatchEvent(t))}function bi(e){const t=e+"CollectionProvider",[n,r]=yn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:g,children:x}=v,b=y.useRef(null),S=y.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:x})};i.displayName=t;const a=e+"CollectionSlot",l=Bn.createSlot(a),u=y.forwardRef((v,g)=>{const{scope:x,children:b}=v,S=s(a,x),T=ze(g,S.collectionRef);return c.jsx(l,{ref:T,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Bn.createSlot(d),m=y.forwardRef((v,g)=>{const{scope:x,children:b,...S}=v,T=y.useRef(null),C=ze(g,T),k=s(d,x);return y.useEffect(()=>(k.itemMap.set(T,{ref:T,...S}),()=>void k.itemMap.delete(T))),c.jsx(h,{[f]:"",ref:C,children:b})});m.displayName=d;function w(v){const g=s(e+"CollectionConsumer",v);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:m},w,r]}var Yx=p.createContext(void 0);function Fo(e){const t=p.useContext(Yx);return e||t||"ltr"}function It(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Xx(e,t=globalThis==null?void 0:globalThis.document){const n=It(e);p.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 Jx="DismissableLayer",yi="dismissableLayer.update",Zx="dismissableLayer.pointerDownOutside",Qx="dismissableLayer.focusOutside",Ic,Nc=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Bo=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=p.useContext(Nc),[d,f]=p.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=p.useState({}),w=ze(t,E=>f(E)),v=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=v.indexOf(g),b=d?v.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,T=b>=x,C=nv(E=>{const A=E.target,O=[...u.branches].some($=>$.contains(A));!T||O||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),k=rv(E=>{const A=E.target;[...u.branches].some($=>$.contains(A))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return Xx(E=>{b===u.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),p.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Ic=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Ac(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Ic)}},[d,h,n,u]),p.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Ac())},[d,u]),p.useEffect(()=>{const E=()=>m({});return document.addEventListener(yi,E),()=>document.removeEventListener(yi,E)},[]),c.jsx(ye.div,{...l,ref:w,style:{pointerEvents:S?T?"auto":"none":void 0,...e.style},onFocusCapture:me(e.onFocusCapture,k.onFocusCapture),onBlurCapture:me(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:me(e.onPointerDownCapture,C.onPointerDownCapture)})});Bo.displayName=Jx;var ev="DismissableLayerBranch",tv=p.forwardRef((e,t)=>{const n=p.useContext(Nc),r=p.useRef(null),o=ze(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(ye.div,{...e,ref:o})});tv.displayName=ev;function nv(e,t=globalThis==null?void 0:globalThis.document){const n=It(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){jc(Zx,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 rv(e,t=globalThis==null?void 0:globalThis.document){const n=It(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&jc(Qx,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 Ac(){const e=new CustomEvent(yi);document.dispatchEvent(e)}function jc(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?Ec(o,s):o.dispatchEvent(s)}var Si=0;function Ci(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??_c()),document.body.insertAdjacentElement("beforeend",e[1]??_c()),Si++,()=>{Si===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Si--}},[])}function _c(){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 ki="focusScope.autoFocusOnMount",Ti="focusScope.autoFocusOnUnmount",Mc={bubbles:!1,cancelable:!0},ov="FocusScope",zo=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=p.useState(null),u=It(o),d=It(s),f=p.useRef(null),h=ze(t,v=>l(v)),m=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let v=function(S){if(m.paused||!a)return;const T=S.target;a.contains(T)?f.current=T:In(f.current,{select:!0})},g=function(S){if(m.paused||!a)return;const T=S.relatedTarget;T!==null&&(a.contains(T)||In(f.current,{select:!0}))},x=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&In(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",g);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,m.paused]),p.useEffect(()=>{if(a){Oc.add(m);const v=document.activeElement;if(!a.contains(v)){const x=new CustomEvent(ki,Mc);a.addEventListener(ki,u),a.dispatchEvent(x),x.defaultPrevented||(sv(uv(Pc(a)),{select:!0}),document.activeElement===v&&In(a))}return()=>{a.removeEventListener(ki,u),setTimeout(()=>{const x=new CustomEvent(Ti,Mc);a.addEventListener(Ti,d),a.dispatchEvent(x),x.defaultPrevented||In(v??document.body,{select:!0}),a.removeEventListener(Ti,d),Oc.remove(m)},0)}}},[a,u,d,m]);const w=p.useCallback(v=>{if(!n&&!r||m.paused)return;const g=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,x=document.activeElement;if(g&&x){const b=v.currentTarget,[S,T]=iv(b);S&&T?!v.shiftKey&&x===T?(v.preventDefault(),n&&In(S,{select:!0})):v.shiftKey&&x===S&&(v.preventDefault(),n&&In(T,{select:!0})):x===b&&v.preventDefault()}},[n,r,m.paused]);return c.jsx(ye.div,{tabIndex:-1,...i,ref:h,onKeyDown:w})});zo.displayName=ov;function sv(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(In(r,{select:t}),document.activeElement!==n)return}function iv(e){const t=Pc(e),n=Rc(t,e),r=Rc(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 Rc(e,t){for(const n of e)if(!av(n,{upTo:t}))return n}function av(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 lv(e){return e instanceof HTMLInputElement&&"select"in e}function In(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&lv(e)&&t&&e.select()}}var Oc=cv();function cv(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Dc(e,t),e.unshift(t)},remove(t){var n;e=Dc(e,t),(n=e[0])==null||n.resume()}}}function Dc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function uv(e){return e.filter(t=>t.tagName!=="A")}var dv=p[" useId ".trim().toString()]||(()=>{}),fv=0;function Rt(e){const[t,n]=p.useState(dv());return Et(()=>{n(r=>r??String(fv++))},[e]),t?`radix-${t}`:""}const hv=["top","right","bottom","left"],Nn=Math.min,Wt=Math.max,Ho=Math.round,Uo=Math.floor,dn=e=>({x:e,y:e}),pv={left:"right",right:"left",bottom:"top",top:"bottom"},mv={start:"end",end:"start"};function Ei(e,t,n){return Wt(e,Nn(t,n))}function Sn(e,t){return typeof e=="function"?e(t):e}function Cn(e){return e.split("-")[0]}function fr(e){return e.split("-")[1]}function Ii(e){return e==="x"?"y":"x"}function Ni(e){return e==="y"?"height":"width"}const gv=new Set(["top","bottom"]);function fn(e){return gv.has(Cn(e))?"y":"x"}function Ai(e){return Ii(fn(e))}function xv(e,t,n){n===void 0&&(n=!1);const r=fr(e),o=Ai(e),s=Ni(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Wo(i)),[i,Wo(i)]}function vv(e){const t=Wo(e);return[ji(e),t,ji(t)]}function ji(e){return e.replace(/start|end/g,t=>mv[t])}const Lc=["left","right"],$c=["right","left"],wv=["top","bottom"],bv=["bottom","top"];function yv(e,t,n){switch(e){case"top":case"bottom":return n?t?$c:Lc:t?Lc:$c;case"left":case"right":return t?wv:bv;default:return[]}}function Sv(e,t,n,r){const o=fr(e);let s=yv(Cn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(ji)))),s}function Wo(e){return e.replace(/left|right|bottom|top/g,t=>pv[t])}function Cv(e){return{top:0,right:0,bottom:0,left:0,...e}}function Fc(e){return typeof e!="number"?Cv(e):{top:e,right:e,bottom:e,left:e}}function Vo(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 Bc(e,t,n){let{reference:r,floating:o}=e;const s=fn(t),i=Ai(t),a=Ni(i),l=Cn(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 m;switch(l){case"top":m={x:d,y:r.y-o.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(fr(t)){case"start":m[i]-=h*(n&&u?-1:1);break;case"end":m[i]+=h*(n&&u?-1:1);break}return m}const kv=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}=Bc(u,r,l),h=r,m={},w=0;for(let v=0;v<a.length;v++){const{name:g,fn:x}=a[v],{x:b,y:S,data:T,reset:C}=await x({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:m,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,m={...m,[g]:{...m[g],...T}},C&&w<=50&&(w++,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}=Bc(u,h,l)),v=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:m}};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:m=0}=Sn(t,e),w=Fc(m),g=a[h?f==="floating"?"reference":"floating":f],x=Vo(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=Vo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(x.top-C.top+w.top)/T.y,bottom:(C.bottom-x.bottom+w.bottom)/T.y,left:(x.left-C.left+w.left)/T.x,right:(C.right-x.right+w.right)/T.x}}const Tv=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}=Sn(e,t)||{};if(u==null)return{};const f=Fc(d),h={x:n,y:r},m=Ai(o),w=Ni(m),v=await i.getDimensions(u),g=m==="y",x=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",T=s.reference[w]+s.reference[m]-h[m]-s.floating[w],C=h[m]-s.reference[m],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[w]);const A=T/2-C/2,O=E/2-v[w]/2-1,$=Nn(f[x],O),H=Nn(f[b],O),U=$,K=E-v[w]-H,R=E/2-v[w]/2+A,Y=Ei(U,R,K),N=!l.arrow&&fr(o)!=null&&R!==Y&&s.reference[w]/2-(R<U?$:H)-v[w]/2<0,D=N?R<U?R-U:R-K:0;return{[m]:h[m]+D,data:{[m]:Y,centerOffset:R-Y-D,...N&&{alignmentOffset:D}},reset:N}}}),Ev=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:m="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:v=!0,...g}=Sn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=Cn(o),b=fn(a),S=Cn(a)===a,T=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(S||!v?[Wo(a)]:vv(a)),k=w!=="none";!h&&k&&C.push(...Sv(a,v,w,T));const E=[a,...C],A=await Br(t,g),O=[];let $=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&O.push(A[x]),f){const R=xv(o,i,T);O.push(A[R[0]],A[R[1]])}if($=[...$,{placement:o,overflows:O}],!O.every(R=>R<=0)){var H,U;const R=(((H=s.flip)==null?void 0:H.index)||0)+1,Y=E[R];if(Y&&(!(f==="alignment"?b!==fn(Y):!1)||$.every(M=>fn(M.placement)===b?M.overflows[0]>0:!0)))return{data:{index:R,overflows:$},reset:{placement:Y}};let N=(U=$.filter(D=>D.overflows[0]<=0).sort((D,M)=>D.overflows[1]-M.overflows[1])[0])==null?void 0:U.placement;if(!N)switch(m){case"bestFit":{var K;const D=(K=$.filter(M=>{if(k){const j=fn(M.placement);return j===b||j==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(j=>j>0).reduce((j,z)=>j+z,0)]).sort((M,j)=>M[1]-j[1])[0])==null?void 0:K[0];D&&(N=D);break}case"initialPlacement":N=a;break}if(o!==N)return{reset:{placement:N}}}return{}}}};function zc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Hc(e){return hv.some(t=>e[t]>=0)}const Iv=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Sn(e,t);switch(r){case"referenceHidden":{const s=await Br(t,{...o,elementContext:"reference"}),i=zc(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Hc(i)}}}case"escaped":{const s=await Br(t,{...o,altBoundary:!0}),i=zc(s,n.floating);return{data:{escapedOffsets:i,escaped:Hc(i)}}}default:return{}}}}},Uc=new Set(["left","top"]);async function Nv(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Cn(n),a=fr(n),l=fn(n)==="y",u=Uc.has(i)?-1:1,d=s&&l?-1:1,f=Sn(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(m=a==="end"?w*-1:w),l?{x:m*d,y:h*u}:{x:h*u,y:m*d}}const Av=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 Nv(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}}}}},jv=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,y:b}=g;return{x,y:b}}},...l}=Sn(e,t),u={x:n,y:r},d=await Br(t,l),f=fn(Cn(o)),h=Ii(f);let m=u[h],w=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=m+d[g],S=m-d[x];m=Ei(b,m,S)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",b=w+d[g],S=w-d[x];w=Ei(b,w,S)}const v=a.fn({...t,[h]:m,[f]:w});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[h]:s,[f]:i}}}}}},_v=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}=Sn(e,t),d={x:n,y:r},f=fn(o),h=Ii(f);let m=d[h],w=d[f];const v=Sn(a,t),g=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};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;m<T?m=T:m>C&&(m=C)}if(u){var x,b;const S=h==="y"?"width":"height",T=Uc.has(Cn(o)),C=s.reference[f]-s.floating[S]+(T&&((x=i.offset)==null?void 0:x[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);w<C?w=C:w>k&&(w=k)}return{[h]:m,[f]:w}}}},Mv=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}=Sn(e,t),d=await Br(t,u),f=Cn(o),h=fr(o),m=fn(o)==="y",{width:w,height:v}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=h==="end"?"top":"bottom");const b=v-d.top-d.bottom,S=w-d.left-d.right,T=Nn(v-d[g],b),C=Nn(w-d[x],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 $=Wt(d.left,0),H=Wt(d.right,0),U=Wt(d.top,0),K=Wt(d.bottom,0);m?A=w-2*($!==0||H!==0?$+H:Wt(d.left,d.right)):E=v-2*(U!==0||K!==0?U+K:Wt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:E});const O=await i.getDimensions(a.floating);return w!==O.width||v!==O.height?{reset:{rects:!0}}:{}}}};function Ko(){return typeof window<"u"}function hr(e){return Wc(e)?(e.nodeName||"").toLowerCase():"#document"}function Vt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function hn(e){var t;return(t=(Wc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Wc(e){return Ko()?e instanceof Node||e instanceof Vt(e).Node:!1}function rn(e){return Ko()?e instanceof Element||e instanceof Vt(e).Element:!1}function pn(e){return Ko()?e instanceof HTMLElement||e instanceof Vt(e).HTMLElement:!1}function Vc(e){return!Ko()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Vt(e).ShadowRoot}const Pv=new Set(["inline","contents"]);function zr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=on(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Pv.has(o)}const Rv=new Set(["table","td","th"]);function Ov(e){return Rv.has(hr(e))}const Dv=[":popover-open",":modal"];function qo(e){return Dv.some(t=>{try{return e.matches(t)}catch{return!1}})}const Lv=["transform","translate","scale","rotate","perspective"],$v=["transform","translate","scale","rotate","perspective","filter"],Fv=["paint","layout","strict","content"];function _i(e){const t=Mi(),n=rn(e)?on(e):e;return Lv.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)||$v.some(r=>(n.willChange||"").includes(r))||Fv.some(r=>(n.contain||"").includes(r))}function Bv(e){let t=An(e);for(;pn(t)&&!pr(t);){if(_i(t))return t;if(qo(t))return null;t=An(t)}return null}function Mi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const zv=new Set(["html","body","#document"]);function pr(e){return zv.has(hr(e))}function on(e){return Vt(e).getComputedStyle(e)}function Go(e){return rn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function An(e){if(hr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Vc(e)&&e.host||hn(e);return Vc(t)?t.host:t}function Kc(e){const t=An(e);return pr(t)?e.ownerDocument?e.ownerDocument.body:e.body:pn(t)&&zr(t)?t:Kc(t)}function Hr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Kc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Vt(o);if(s){const a=Pi(i);return t.concat(i,i.visualViewport||[],zr(o)?o:[],a&&n?Hr(a):[])}return t.concat(o,Hr(o,[],n))}function Pi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function qc(e){const t=on(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=pn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Ho(n)!==s||Ho(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Ri(e){return rn(e)?e:e.contextElement}function mr(e){const t=Ri(e);if(!pn(t))return dn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=qc(t);let i=(s?Ho(n.width):n.width)/r,a=(s?Ho(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Hv=dn(0);function Gc(e){const t=Vt(e);return!Mi()||!t.visualViewport?Hv:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Uv(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Vt(e)?!1:t}function Vn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Ri(e);let i=dn(1);t&&(r?rn(r)&&(i=mr(r)):i=mr(e));const a=Uv(s,n,r)?Gc(s):dn(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=Vt(s),m=r&&rn(r)?Vt(r):r;let w=h,v=Pi(w);for(;v&&r&&m!==w;){const g=mr(v),x=v.getBoundingClientRect(),b=on(v),S=x.left+(v.clientLeft+parseFloat(b.paddingLeft))*g.x,T=x.top+(v.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=T,w=Vt(v),v=Pi(w)}}return Vo({width:d,height:f,x:l,y:u})}function Yo(e,t){const n=Go(e).scrollLeft;return t?t.left+n:Vn(hn(e)).left+n}function Yc(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Yo(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Wv(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=hn(r),a=t?qo(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=dn(1);const d=dn(0),f=pn(r);if((f||!f&&!s)&&((hr(r)!=="body"||zr(i))&&(l=Go(r)),pn(r))){const m=Vn(r);u=mr(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const h=i&&!f&&!s?Yc(i,l):dn(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 Vv(e){return Array.from(e.getClientRects())}function Kv(e){const t=hn(e),n=Go(e),r=e.ownerDocument.body,o=Wt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Wt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Yo(e);const a=-n.scrollTop;return on(r).direction==="rtl"&&(i+=Wt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Xc=25;function qv(e,t){const n=Vt(e),r=hn(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=Mi();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=Yo(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),m=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,w=Math.abs(r.clientWidth-f.clientWidth-m);w<=Xc&&(s-=w)}else u<=Xc&&(s+=u);return{width:s,height:i,x:a,y:l}}const Gv=new Set(["absolute","fixed"]);function Yv(e,t){const n=Vn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=pn(e)?mr(e):dn(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 Jc(e,t,n){let r;if(t==="viewport")r=qv(e,n);else if(t==="document")r=Kv(hn(e));else if(rn(t))r=Yv(t,n);else{const o=Gc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Vo(r)}function Zc(e,t){const n=An(e);return n===t||!rn(n)||pr(n)?!1:on(n).position==="fixed"||Zc(n,t)}function Xv(e,t){const n=t.get(e);if(n)return n;let r=Hr(e,[],!1).filter(a=>rn(a)&&hr(a)!=="body"),o=null;const s=on(e).position==="fixed";let i=s?An(e):e;for(;rn(i)&&!pr(i);){const a=on(i),l=_i(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Gv.has(o.position)||zr(i)&&!l&&Zc(e,i))?r=r.filter(d=>d!==i):o=a,i=An(i)}return t.set(e,r),r}function Jv(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?qo(t)?[]:Xv(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=Jc(t,d,o);return u.top=Wt(f.top,u.top),u.right=Nn(f.right,u.right),u.bottom=Nn(f.bottom,u.bottom),u.left=Wt(f.left,u.left),u},Jc(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Zv(e){const{width:t,height:n}=qc(e);return{width:t,height:n}}function Qv(e,t,n){const r=pn(t),o=hn(t),s=n==="fixed",i=Vn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=dn(0);function u(){l.x=Yo(o)}if(r||!r&&!s)if((hr(t)!=="body"||zr(o))&&(a=Go(t)),r){const m=Vn(t,!0,s,t);l.x=m.x+t.clientLeft,l.y=m.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?Yc(o,a):dn(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 Oi(e){return on(e).position==="static"}function Qc(e,t){if(!pn(e)||on(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return hn(e)===n&&(n=n.ownerDocument.body),n}function eu(e,t){const n=Vt(e);if(qo(e))return n;if(!pn(e)){let o=An(e);for(;o&&!pr(o);){if(rn(o)&&!Oi(o))return o;o=An(o)}return n}let r=Qc(e,t);for(;r&&Ov(r)&&Oi(r);)r=Qc(r,t);return r&&pr(r)&&Oi(r)&&!_i(r)?n:r||Bv(e)||n}const ew=async function(e){const t=this.getOffsetParent||eu,n=this.getDimensions,r=await n(e.floating);return{reference:Qv(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function tw(e){return on(e).direction==="rtl"}const nw={convertOffsetParentRelativeRectToViewportRelativeRect:Wv,getDocumentElement:hn,getClippingRect:Jv,getOffsetParent:eu,getElementRects:ew,getClientRects:Vv,getDimensions:Zv,getScale:mr,isElement:rn,isRTL:tw};function tu(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function rw(e,t){let n=null,r;const o=hn(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:m}=u;if(a||t(),!h||!m)return;const w=Uo(f),v=Uo(o.clientWidth-(d+h)),g=Uo(o.clientHeight-(f+m)),x=Uo(d),S={rootMargin:-w+"px "+-v+"px "+-g+"px "+-x+"px",threshold:Wt(0,Nn(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&&!tu(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 ow(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=Ri(e),d=o||s?[...u?Hr(u):[],...Hr(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?rw(u,n):null;let h=-1,m=null;i&&(m=new ResizeObserver(x=>{let[b]=x;b&&b.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=m)==null||S.observe(t)})),n()}),u&&!l&&m.observe(u),m.observe(t));let w,v=l?Vn(e):null;l&&g();function g(){const x=Vn(e);v&&!tu(v,x)&&n(),v=x,w=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(x=m)==null||x.disconnect(),m=null,l&&cancelAnimationFrame(w)}}const sw=Av,iw=jv,aw=Ev,lw=Mv,cw=Iv,nu=Tv,uw=_v,dw=(e,t,n)=>{const r=new Map,o={platform:nw,...n},s={...o.platform,_c:r};return kv(e,t,{...o,platform:s})};var fw=typeof document<"u",hw=function(){},Xo=fw?y.useLayoutEffect:hw;function Jo(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(!Jo(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)&&!Jo(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function ru(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ou(e,t){const n=ru(e);return Math.round(t*n)/n}function Di(e){const t=p.useRef(e);return Xo(()=>{t.current=e}),t}function pw(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]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=p.useState(r);Jo(h,r)||m(r);const[w,v]=p.useState(null),[g,x]=p.useState(null),b=p.useCallback(M=>{M!==k.current&&(k.current=M,v(M))},[]),S=p.useCallback(M=>{M!==E.current&&(E.current=M,x(M))},[]),T=s||w,C=i||g,k=p.useRef(null),E=p.useRef(null),A=p.useRef(d),O=l!=null,$=Di(l),H=Di(o),U=Di(u),K=p.useCallback(()=>{if(!k.current||!E.current)return;const M={placement:t,strategy:n,middleware:h};H.current&&(M.platform=H.current),dw(k.current,E.current,M).then(j=>{const z={...j,isPositioned:U.current!==!1};R.current&&!Jo(A.current,z)&&(A.current=z,bo.flushSync(()=>{f(z)}))})},[h,t,n,H,U]);Xo(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(M=>({...M,isPositioned:!1})))},[u]);const R=p.useRef(!1);Xo(()=>(R.current=!0,()=>{R.current=!1}),[]),Xo(()=>{if(T&&(k.current=T),C&&(E.current=C),T&&C){if($.current)return $.current(T,C,K);K()}},[T,C,K,$,O]);const Y=p.useMemo(()=>({reference:k,floating:E,setReference:b,setFloating:S}),[b,S]),N=p.useMemo(()=>({reference:T,floating:C}),[T,C]),D=p.useMemo(()=>{const M={position:n,left:0,top:0};if(!N.floating)return M;const j=ou(N.floating,d.x),z=ou(N.floating,d.y);return a?{...M,transform:"translate("+j+"px, "+z+"px)",...ru(N.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:j,top:z}},[n,a,N.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:K,refs:Y,elements:N,floatingStyles:D}),[d,K,Y,N,D])}const mw=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?nu({element:r.current,padding:o}).fn(n):{}:r?nu({element:r,padding:o}).fn(n):{}}}},gw=(e,t)=>({...sw(e),options:[e,t]}),xw=(e,t)=>({...iw(e),options:[e,t]}),vw=(e,t)=>({...uw(e),options:[e,t]}),ww=(e,t)=>({...aw(e),options:[e,t]}),bw=(e,t)=>({...lw(e),options:[e,t]}),yw=(e,t)=>({...cw(e),options:[e,t]}),Sw=(e,t)=>({...mw(e),options:[e,t]});var Cw="Arrow",su=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(ye.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"})})});su.displayName=Cw;var kw=su;function iu(e){const[t,n]=p.useState(void 0);return Et(()=>{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 Li="Popper",[au,Zo]=yn(Li),[Tw,lu]=au(Li),cu=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return c.jsx(Tw,{scope:t,anchor:r,onAnchorChange:o,children:n})};cu.displayName=Li;var uu="PopperAnchor",du=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=lu(uu,n),i=p.useRef(null),a=ze(t,i),l=p.useRef(null);return p.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(ye.div,{...o,ref:a})});du.displayName=uu;var $i="PopperContent",[Ew,Iw]=au($i),fu=p.forwardRef((e,t)=>{var G,L,V,Z,q,X;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:m="optimized",onPlaced:w,...v}=e,g=lu($i,n),[x,b]=p.useState(null),S=ze(t,pe=>b(pe)),[T,C]=p.useState(null),k=iu(T),E=(k==null?void 0:k.width)??0,A=(k==null?void 0:k.height)??0,O=r+(s!=="center"?"-"+s:""),$=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},H=Array.isArray(u)?u:[u],U=H.length>0,K={padding:$,boundary:H.filter(Aw),altBoundary:U},{refs:R,floatingStyles:Y,placement:N,isPositioned:D,middlewareData:M}=pw({strategy:"fixed",placement:O,whileElementsMounted:(...pe)=>ow(...pe,{animationFrame:m==="always"}),elements:{reference:g.anchor},middleware:[gw({mainAxis:o+A,alignmentAxis:i}),l&&xw({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?vw():void 0,...K}),l&&ww({...K}),bw({...K,apply:({elements:pe,rects:he,availableWidth:ee,availableHeight:le})=>{const{width:we,height:je}=he.reference,Ne=pe.floating.style;Ne.setProperty("--radix-popper-available-width",`${ee}px`),Ne.setProperty("--radix-popper-available-height",`${le}px`),Ne.setProperty("--radix-popper-anchor-width",`${we}px`),Ne.setProperty("--radix-popper-anchor-height",`${je}px`)}}),T&&Sw({element:T,padding:a}),jw({arrowWidth:E,arrowHeight:A}),h&&yw({strategy:"referenceHidden",...K})]}),[j,z]=mu(N),W=It(w);Et(()=>{D&&(W==null||W())},[D,W]);const P=(G=M.arrow)==null?void 0:G.x,B=(L=M.arrow)==null?void 0:L.y,te=((V=M.arrow)==null?void 0:V.centerOffset)!==0,[J,re]=p.useState();return Et(()=>{x&&re(window.getComputedStyle(x).zIndex)},[x]),c.jsx("div",{ref:R.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:D?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(Z=M.transformOrigin)==null?void 0:Z.x,(q=M.transformOrigin)==null?void 0:q.y].join(" "),...((X=M.hide)==null?void 0:X.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(Ew,{scope:n,placedSide:j,onArrowChange:C,arrowX:P,arrowY:B,shouldHideArrow:te,children:c.jsx(ye.div,{"data-side":j,"data-align":z,...v,ref:S,style:{...v.style,animation:D?void 0:"none"}})})})});fu.displayName=$i;var hu="PopperArrow",Nw={top:"bottom",right:"left",bottom:"top",left:"right"},pu=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Iw(hu,r),i=Nw[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(kw,{...o,ref:n,style:{...o.style,display:"block"}})})});pu.displayName=hu;function Aw(e){return e!==null}var jw=e=>({name:"transformOrigin",options:e,fn(t){var g,x,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]=mu(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,m=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let w="",v="";return u==="bottom"?(w=i?f:`${h}px`,v=`${-l}px`):u==="top"?(w=i?f:`${h}px`,v=`${r.floating.height+l}px`):u==="right"?(w=`${-l}px`,v=i?f:`${m}px`):u==="left"&&(w=`${r.floating.width+l}px`,v=i?f:`${m}px`),{data:{x:w,y:v}}}});function mu(e){const[t,n="center"]=e.split("-");return[t,n]}var gu=cu,xu=du,vu=fu,wu=pu,_w="Portal",Qo=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);Et(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Zs.createPortal(c.jsx(ye.div,{...r,ref:t}),i):null});Qo.displayName=_w;function Mw(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Xt=e=>{const{present:t,children:n}=e,r=Pw(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=ze(r.ref,Rw(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};Xt.displayName="Presence";function Pw(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.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 p.useEffect(()=>{const u=es(r.current);s.current=a==="mounted"?u:"none"},[a]),Et(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,m=es(u);e?l("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&h!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Et(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const v=es(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&v&&(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=m=>{m.target===t&&(s.current=es(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:p.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function es(e){return(e==null?void 0:e.animationName)||"none"}function Rw(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 Fi="rovingFocusGroup.onEntryFocus",Ow={bubbles:!1,cancelable:!0},Ur="RovingFocusGroup",[Bi,bu,Dw]=bi(Ur),[Lw,yu]=yn(Ur,[Dw]),[$w,Fw]=Lw(Ur),Su=p.forwardRef((e,t)=>c.jsx(Bi.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Bi.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Bw,{...e,ref:t})})}));Su.displayName=Ur;var Bw=p.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=p.useRef(null),m=ze(t,h),w=Fo(s),[v,g]=dr({prop:i,defaultProp:a??null,onChange:l,caller:Ur}),[x,b]=p.useState(!1),S=It(u),T=bu(n),C=p.useRef(!1),[k,E]=p.useState(0);return p.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(Fi,S),()=>A.removeEventListener(Fi,S)},[S]),c.jsx($w,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:v,onItemFocus:p.useCallback(A=>g(A),[g]),onItemShiftTab:p.useCallback(()=>b(!0),[]),onFocusableItemAdd:p.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:p.useCallback(()=>E(A=>A-1),[]),children:c.jsx(ye.div,{tabIndex:x||k===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:me(e.onMouseDown,()=>{C.current=!0}),onFocus:me(e.onFocus,A=>{const O=!C.current;if(A.target===A.currentTarget&&O&&!x){const $=new CustomEvent(Fi,Ow);if(A.currentTarget.dispatchEvent($),!$.defaultPrevented){const H=T().filter(N=>N.focusable),U=H.find(N=>N.active),K=H.find(N=>N.id===v),Y=[U,K,...H].filter(Boolean).map(N=>N.ref.current);Tu(Y,d)}}C.current=!1}),onBlur:me(e.onBlur,()=>b(!1))})})}),Cu="RovingFocusGroupItem",ku=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Rt(),u=s||l,d=Fw(Cu,n),f=d.currentTabStopId===u,h=bu(n),{onFocusableItemAdd:m,onFocusableItemRemove:w,currentTabStopId:v}=d;return p.useEffect(()=>{if(r)return m(),()=>w()},[r,m,w]),c.jsx(Bi.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(ye.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:me(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:me(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:me(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=Uw(g,d.orientation,d.dir);if(x!==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(x==="last")S.reverse();else if(x==="prev"||x==="next"){x==="prev"&&S.reverse();const T=S.indexOf(g.currentTarget);S=d.loop?Ww(S,T+1):S.slice(T+1)}setTimeout(()=>Tu(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:v!=null}):i})})});ku.displayName=Cu;var zw={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Hw(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Uw(e,t,n){const r=Hw(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return zw[r]}function Tu(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ww(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Vw=Su,Kw=ku,qw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},gr=new WeakMap,ts=new WeakMap,ns={},zi=0,Eu=function(e){return e&&(e.host||Eu(e.parentNode))},Gw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Eu(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})},Yw=function(e,t,n,r){var o=Gw(t,Array.isArray(e)?e:[e]);ns[n]||(ns[n]=new WeakMap);var s=ns[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 m=h.getAttribute(r),w=m!==null&&m!=="false",v=(gr.get(h)||0)+1,g=(s.get(h)||0)+1;gr.set(h,v),s.set(h,g),i.push(h),v===1&&w&&ts.set(h,!0),g===1&&h.setAttribute(n,"true"),w||h.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return d(t),a.clear(),zi++,function(){i.forEach(function(f){var h=gr.get(f)-1,m=s.get(f)-1;gr.set(f,h),s.set(f,m),h||(ts.has(f)||f.removeAttribute(r),ts.delete(f)),m||f.removeAttribute(n)}),zi--,zi||(gr=new WeakMap,gr=new WeakMap,ts=new WeakMap,ns={})}},Hi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=qw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Yw(r,o,n,"aria-hidden")):function(){return null}},mn=function(){return mn=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},mn.apply(this,arguments)};function Iu(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 Xw(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 rs="right-scroll-bar-position",os="width-before-scroll-bar",Jw="with-scroll-bars-hidden",Zw="--removed-body-scroll-bar-size";function Ui(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Qw(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 eb=typeof window<"u"?p.useLayoutEffect:p.useEffect,Nu=new WeakMap;function tb(e,t){var n=Qw(null,function(r){return e.forEach(function(o){return Ui(o,r)})});return eb(function(){var r=Nu.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)})}Nu.set(n,e)},[e]),n}function nb(e){return e}function rb(e,t){t===void 0&&(t=nb);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 ob(e){e===void 0&&(e={});var t=rb(null);return t.options=mn({async:!0,ssr:!1},e),t}var Au=function(e){var t=e.sideCar,n=Iu(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 p.createElement(r,mn({},n))};Au.isSideCarExport=!0;function sb(e,t){return e.useMedium(t),Au}var ju=ob(),Wi=function(){},ss=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:Wi,onWheelCapture:Wi,onTouchMoveCapture:Wi}),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,m=e.noRelative,w=e.noIsolation,v=e.inert,g=e.allowPinchZoom,x=e.as,b=x===void 0?"div":x,S=e.gapMode,T=Iu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,k=tb([n,t]),E=mn(mn({},T),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:ju,removeScrollBar:u,shards:f,noRelative:m,noIsolation:w,inert:v,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?p.cloneElement(p.Children.only(a),mn(mn({},E),{ref:k})):p.createElement(b,mn({},E,{className:l,ref:k}),a))});ss.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ss.classNames={fullWidth:os,zeroRight:rs};var ib=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function ab(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=ib();return t&&e.setAttribute("nonce",t),e}function lb(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function cb(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ub=function(){var e=0,t=null;return{add:function(n){e==0&&(t=ab())&&(lb(t,n),cb(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},db=function(){var e=ub();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},_u=function(){var e=db(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},fb={left:0,top:0,right:0,gap:0},Vi=function(e){return parseInt(e||"",10)||0},hb=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)]},pb=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return fb;var t=hb(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])}},mb=_u(),xr="data-scroll-locked",gb=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(Jw,` {
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
  }
44
- body[`).concat(xr,`] {
44
+ body[`).concat(gr,`] {
45
45
  overflow: hidden `).concat(r,`;
46
46
  overscroll-behavior: contain;
47
47
  `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
@@ -54,56 +54,56 @@ 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(rs,` {
57
+ .`).concat(qo,` {
58
58
  right: `).concat(a,"px ").concat(r,`;
59
59
  }
60
60
 
61
- .`).concat(os,` {
61
+ .`).concat(Go,` {
62
62
  margin-right: `).concat(a,"px ").concat(r,`;
63
63
  }
64
64
 
65
- .`).concat(rs," .").concat(rs,` {
65
+ .`).concat(qo," .").concat(qo,` {
66
66
  right: 0 `).concat(r,`;
67
67
  }
68
68
 
69
- .`).concat(os," .").concat(os,` {
69
+ .`).concat(Go," .").concat(Go,` {
70
70
  margin-right: 0 `).concat(r,`;
71
71
  }
72
72
 
73
- body[`).concat(xr,`] {
74
- `).concat(Zw,": ").concat(a,`px;
73
+ body[`).concat(gr,`] {
74
+ `).concat($w,": ").concat(a,`px;
75
75
  }
76
- `)},Mu=function(){var e=parseInt(document.body.getAttribute(xr)||"0",10);return isFinite(e)?e:0},xb=function(){p.useEffect(function(){return document.body.setAttribute(xr,(Mu()+1).toString()),function(){var e=Mu()-1;e<=0?document.body.removeAttribute(xr):document.body.setAttribute(xr,e.toString())}},[])},vb=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;xb();var s=p.useMemo(function(){return pb(o)},[o]);return p.createElement(mb,{styles:gb(s,!t,o,n?"":"!important")})},Ki=!1;if(typeof window<"u")try{var is=Object.defineProperty({},"passive",{get:function(){return Ki=!0,!0}});window.addEventListener("test",is,is),window.removeEventListener("test",is,is)}catch{Ki=!1}var vr=Ki?{passive:!1}:!1,wb=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&&!wb(e)&&n[t]==="visible")},bb=function(e){return Pu(e,"overflowY")},yb=function(e){return Pu(e,"overflowX")},Ru=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Ou(e,r);if(o){var s=Du(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Sb=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]},Ou=function(e,t){return e==="v"?bb(t):yb(t)},Du=function(e,t){return e==="v"?Sb(t):Cb(t)},kb=function(e,t){return e==="h"&&t==="rtl"?-1:1},Tb=function(e,t,n,r,o){var s=kb(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 m=Du(e,a),w=m[0],v=m[1],g=m[2],x=v-g-s*w;(w||x)&&Ou(e,a)&&(f+=x,h+=w);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},as=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Lu=function(e){return[e.deltaX,e.deltaY]},$u=function(e){return e&&"current"in e?e.current:e},Eb=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Ib=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
- `)},Nb=0,wr=[];function Ab(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(Nb++)[0],s=p.useState(_u)[0],i=p.useRef(e);p.useEffect(function(){i.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=Xw([e.lockRef.current],(e.shards||[]).map($u),!0).filter(Boolean);return v.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(v,g){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!i.current.allowPinchZoom;var x=as(v),b=n.current,S="deltaX"in v?v.deltaX:b[0]-x[0],T="deltaY"in v?v.deltaY:b[1]-x[1],C,k=v.target,E=Math.abs(S)>Math.abs(T)?"h":"v";if("touches"in v&&E==="h"&&k.type==="range")return!1;var A=Ru(E,k);if(!A)return!0;if(A?C=E:(C=E==="v"?"h":"v",A=Ru(E,k)),!A)return!1;if(!r.current&&"changedTouches"in v&&(S||T)&&(r.current=C),!C)return!0;var O=r.current||C;return Tb(O,g,v,O==="h"?S:T)},[]),l=p.useCallback(function(v){var g=v;if(!(!wr.length||wr[wr.length-1]!==s)){var x="deltaY"in g?Lu(g):as(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&Eb(C.delta,x)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var S=(i.current.shards||[]).map($u).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=p.useCallback(function(v,g,x,b){var S={name:v,delta:g,target:x,should:b,shadowParent:jb(x)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(T){return T!==S})},1)},[]),d=p.useCallback(function(v){n.current=as(v),r.current=void 0},[]),f=p.useCallback(function(v){u(v.type,Lu(v),v.target,a(v,e.lockRef.current))},[]),h=p.useCallback(function(v){u(v.type,as(v),v.target,a(v,e.lockRef.current))},[]);p.useEffect(function(){return wr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,vr),document.addEventListener("touchmove",l,vr),document.addEventListener("touchstart",d,vr),function(){wr=wr.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,vr),document.removeEventListener("touchmove",l,vr),document.removeEventListener("touchstart",d,vr)}},[]);var m=e.removeScrollBar,w=e.inert;return p.createElement(p.Fragment,null,w?p.createElement(s,{styles:Ib(o)}):null,m?p.createElement(vb,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function jb(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const _b=sb(ju,Ab);var ls=p.forwardRef(function(e,t){return p.createElement(ss,mn({},e,{ref:t,sideCar:_b}))});ls.classNames=ss.classNames;var qi=["Enter"," "],Mb=["ArrowDown","PageUp","Home"],Fu=["ArrowUp","PageDown","End"],Pb=[...Mb,...Fu],Rb={ltr:[...qi,"ArrowRight"],rtl:[...qi,"ArrowLeft"]},Ob={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Wr="Menu",[Vr,Db,Lb]=bi(Wr),[Kn,Bu]=yn(Wr,[Lb,Zo,yu]),cs=Zo(),zu=yu(),[$b,qn]=Kn(Wr),[Fb,Kr]=Kn(Wr),Hu=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=cs(t),[l,u]=p.useState(null),d=p.useRef(!1),f=It(s),h=Fo(o);return p.useEffect(()=>{const m=()=>{d.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>d.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),c.jsx(gu,{...a,children:c.jsx($b,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(Fb,{scope:t,onClose:p.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Hu.displayName=Wr;var Bb="MenuAnchor",Gi=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=cs(n);return c.jsx(xu,{...o,...r,ref:t})});Gi.displayName=Bb;var Yi="MenuPortal",[zb,Uu]=Kn(Yi,{forceMount:void 0}),Wu=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=qn(Yi,t);return c.jsx(zb,{scope:t,forceMount:n,children:c.jsx(Xt,{present:n||s.open,children:c.jsx(Qo,{asChild:!0,container:o,children:r})})})};Wu.displayName=Yi;var Jt="MenuContent",[Hb,Xi]=Kn(Jt),Vu=p.forwardRef((e,t)=>{const n=Uu(Jt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=qn(Jt,e.__scopeMenu),i=Kr(Jt,e.__scopeMenu);return c.jsx(Vr.Provider,{scope:e.__scopeMenu,children:c.jsx(Xt,{present:r||s.open,children:c.jsx(Vr.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(Ub,{...o,ref:t}):c.jsx(Wb,{...o,ref:t})})})})}),Ub=p.forwardRef((e,t)=>{const n=qn(Jt,e.__scopeMenu),r=p.useRef(null),o=ze(t,r);return p.useEffect(()=>{const s=r.current;if(s)return Hi(s)},[]),c.jsx(Ji,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:me(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Wb=p.forwardRef((e,t)=>{const n=qn(Jt,e.__scopeMenu);return c.jsx(Ji,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Vb=Bn.createSlot("MenuContent.ScrollLock"),Ji=p.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:m,disableOutsideScroll:w,...v}=e,g=qn(Jt,n),x=Kr(Jt,n),b=cs(n),S=zu(n),T=Db(n),[C,k]=p.useState(null),E=p.useRef(null),A=ze(t,E,g.onContentChange),O=p.useRef(0),$=p.useRef(""),H=p.useRef(0),U=p.useRef(null),K=p.useRef("right"),R=p.useRef(0),Y=w?ls:p.Fragment,N=w?{as:Vb,allowPinchZoom:!0}:void 0,D=j=>{var G,L;const z=$.current+j,W=T().filter(V=>!V.disabled),P=document.activeElement,B=(G=W.find(V=>V.ref.current===P))==null?void 0:G.textValue,te=W.map(V=>V.textValue),J=ry(te,z,B),re=(L=W.find(V=>V.textValue===J))==null?void 0:L.ref.current;(function V(Z){$.current=Z,window.clearTimeout(O.current),Z!==""&&(O.current=window.setTimeout(()=>V(""),1e3))})(z),re&&setTimeout(()=>re.focus())};p.useEffect(()=>()=>window.clearTimeout(O.current),[]),Ci();const M=p.useCallback(j=>{var W,P;return K.current===((W=U.current)==null?void 0:W.side)&&sy(j,(P=U.current)==null?void 0:P.area)},[]);return c.jsx(Hb,{scope:n,searchRef:$,onItemEnter:p.useCallback(j=>{M(j)&&j.preventDefault()},[M]),onItemLeave:p.useCallback(j=>{var z;M(j)||((z=E.current)==null||z.focus(),k(null))},[M]),onTriggerLeave:p.useCallback(j=>{M(j)&&j.preventDefault()},[M]),pointerGraceTimerRef:H,onPointerGraceIntentChange:p.useCallback(j=>{U.current=j},[]),children:c.jsx(Y,{...N,children:c.jsx(zo,{asChild:!0,trapped:o,onMountAutoFocus:me(s,j=>{var z;j.preventDefault(),(z=E.current)==null||z.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:m,children:c.jsx(Vw,{asChild:!0,...S,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:me(l,j=>{x.isUsingKeyboardRef.current||j.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(vu,{role:"menu","aria-orientation":"vertical","data-state":ld(g.open),"data-radix-menu-content":"",dir:x.dir,...b,...v,ref:A,style:{outline:"none",...v.style},onKeyDown:me(v.onKeyDown,j=>{const W=j.target.closest("[data-radix-menu-content]")===j.currentTarget,P=j.ctrlKey||j.altKey||j.metaKey,B=j.key.length===1;W&&(j.key==="Tab"&&j.preventDefault(),!P&&B&&D(j.key));const te=E.current;if(j.target!==te||!Pb.includes(j.key))return;j.preventDefault();const re=T().filter(G=>!G.disabled).map(G=>G.ref.current);Fu.includes(j.key)&&re.reverse(),ty(re)}),onBlur:me(e.onBlur,j=>{j.currentTarget.contains(j.target)||(window.clearTimeout(O.current),$.current="")}),onPointerMove:me(e.onPointerMove,Gr(j=>{const z=j.target,W=R.current!==j.clientX;if(j.currentTarget.contains(z)&&W){const P=j.clientX>R.current?"right":"left";K.current=P,R.current=j.clientX}}))})})})})})})});Vu.displayName=Jt;var Kb="MenuGroup",Zi=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{role:"group",...r,ref:t})});Zi.displayName=Kb;var qb="MenuLabel",Ku=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{...r,ref:t})});Ku.displayName=qb;var us="MenuItem",qu="menu.itemSelect",ds=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=Kr(us,e.__scopeMenu),a=Xi(us,e.__scopeMenu),l=ze(t,s),u=p.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(qu,{bubbles:!0,cancelable:!0});f.addEventListener(qu,m=>r==null?void 0:r(m),{once:!0}),Ec(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(Gu,{...o,ref:l,disabled:n,onClick:me(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:me(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:me(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||qi.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});ds.displayName=us;var Gu=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Xi(us,n),a=zu(n),l=p.useRef(null),u=ze(t,l),[d,f]=p.useState(!1),[h,m]=p.useState("");return p.useEffect(()=>{const w=l.current;w&&m((w.textContent??"").trim())},[s.children]),c.jsx(Vr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(Kw,{asChild:!0,...a,focusable:!r,children:c.jsx(ye.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:me(e.onPointerMove,Gr(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:me(e.onPointerLeave,Gr(w=>i.onItemLeave(w))),onFocus:me(e.onFocus,()=>f(!0)),onBlur:me(e.onBlur,()=>f(!1))})})})}),Gb="MenuCheckboxItem",Yu=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(ed,{scope:e.__scopeMenu,checked:n,children:c.jsx(ds,{role:"menuitemcheckbox","aria-checked":fs(n)?"mixed":n,...o,ref:t,"data-state":ea(n),onSelect:me(o.onSelect,()=>r==null?void 0:r(fs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Yu.displayName=Gb;var Xu="MenuRadioGroup",[Yb,Xb]=Kn(Xu,{value:void 0,onValueChange:()=>{}}),Ju=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=It(r);return c.jsx(Yb,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(Zi,{...o,ref:t})})});Ju.displayName=Xu;var Zu="MenuRadioItem",Qu=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=Xb(Zu,e.__scopeMenu),s=n===o.value;return c.jsx(ed,{scope:e.__scopeMenu,checked:s,children:c.jsx(ds,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ea(s),onSelect:me(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Qu.displayName=Zu;var Qi="MenuItemIndicator",[ed,Jb]=Kn(Qi,{checked:!1}),td=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=Jb(Qi,n);return c.jsx(Xt,{present:r||fs(s.checked)||s.checked===!0,children:c.jsx(ye.span,{...o,ref:t,"data-state":ea(s.checked)})})});td.displayName=Qi;var Zb="MenuSeparator",nd=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});nd.displayName=Zb;var Qb="MenuArrow",rd=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=cs(n);return c.jsx(wu,{...o,...r,ref:t})});rd.displayName=Qb;var ey="MenuSub",[RT,od]=Kn(ey),qr="MenuSubTrigger",sd=p.forwardRef((e,t)=>{const n=qn(qr,e.__scopeMenu),r=Kr(qr,e.__scopeMenu),o=od(qr,e.__scopeMenu),s=Xi(qr,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>d,[d]),p.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(Gi,{asChild:!0,...u,children:c.jsx(Gu,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":ld(n.open),...e,ref:En(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:me(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:me(e.onPointerLeave,Gr(f=>{var m,w;d();const h=(m=n.content)==null?void 0:m.getBoundingClientRect();if(h){const v=(w=n.content)==null?void 0:w.dataset.side,g=v==="right",x=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:me(e.onKeyDown,f=>{var m;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||Rb[r.dir].includes(f.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),f.preventDefault())})})})});sd.displayName=qr;var id="MenuSubContent",ad=p.forwardRef((e,t)=>{const n=Uu(Jt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=qn(Jt,e.__scopeMenu),i=Kr(Jt,e.__scopeMenu),a=od(id,e.__scopeMenu),l=p.useRef(null),u=ze(t,l);return c.jsx(Vr.Provider,{scope:e.__scopeMenu,children:c.jsx(Xt,{present:r||s.open,children:c.jsx(Vr.Slot,{scope:e.__scopeMenu,children:c.jsx(Ji,{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:me(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:me(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:me(e.onKeyDown,d=>{var m;const f=d.currentTarget.contains(d.target),h=Ob[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(m=a.trigger)==null||m.focus(),d.preventDefault())})})})})})});ad.displayName=id;function ld(e){return e?"open":"closed"}function fs(e){return e==="indeterminate"}function ea(e){return fs(e)?"indeterminate":e?"checked":"unchecked"}function ty(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ny(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function ry(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=ny(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 oy(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 sy(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return oy(n,t)}function Gr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var iy=Hu,ay=Gi,ly=Wu,cy=Vu,uy=Zi,dy=Ku,fy=ds,hy=Yu,py=Ju,my=Qu,gy=td,xy=nd,vy=rd,wy=sd,by=ad,hs="DropdownMenu",[yy,OT]=yn(hs,[Bu]),Ot=Bu(),[Sy,cd]=yy(hs),ud=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ot(t),u=p.useRef(null),[d,f]=dr({prop:o,defaultProp:s??!1,onChange:i,caller:hs});return c.jsx(Sy,{scope:t,triggerId:Rt(),triggerRef:u,contentId:Rt(),open:d,onOpenChange:f,onOpenToggle:p.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(iy,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};ud.displayName=hs;var dd="DropdownMenuTrigger",fd=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=cd(dd,n),i=Ot(n);return c.jsx(ay,{asChild:!0,...i,children:c.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:En(t,s.triggerRef),onPointerDown:me(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:me(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});fd.displayName=dd;var Cy="DropdownMenuPortal",hd=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return c.jsx(ly,{...r,...n})};hd.displayName=Cy;var pd="DropdownMenuContent",md=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=cd(pd,n),s=Ot(n),i=p.useRef(!1);return c.jsx(cy,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:me(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:me(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)"}})});md.displayName=pd;var ky="DropdownMenuGroup",Ty=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(uy,{...o,...r,ref:t})});Ty.displayName=ky;var Ey="DropdownMenuLabel",gd=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(dy,{...o,...r,ref:t})});gd.displayName=Ey;var Iy="DropdownMenuItem",xd=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(fy,{...o,...r,ref:t})});xd.displayName=Iy;var Ny="DropdownMenuCheckboxItem",vd=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(hy,{...o,...r,ref:t})});vd.displayName=Ny;var Ay="DropdownMenuRadioGroup",jy=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(py,{...o,...r,ref:t})});jy.displayName=Ay;var _y="DropdownMenuRadioItem",wd=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(my,{...o,...r,ref:t})});wd.displayName=_y;var My="DropdownMenuItemIndicator",bd=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(gy,{...o,...r,ref:t})});bd.displayName=My;var Py="DropdownMenuSeparator",yd=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(xy,{...o,...r,ref:t})});yd.displayName=Py;var Ry="DropdownMenuArrow",Oy=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(vy,{...o,...r,ref:t})});Oy.displayName=Ry;var Dy="DropdownMenuSubTrigger",Sd=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(wy,{...o,...r,ref:t})});Sd.displayName=Dy;var Ly="DropdownMenuSubContent",Cd=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(by,{...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)"}})});Cd.displayName=Ly;var $y=ud,Fy=fd,By=hd,kd=md,Td=gd,Ed=xd,Id=vd,Nd=wd,Ad=bd,jd=yd,_d=Sd,Md=Cd;const ta=$y,na=Fy,zy=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(_d,{ref:o,className:oe("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(ae.ChevronRight,{className:"ml-auto h-4 w-4"})]}));zy.displayName=_d.displayName;const Hy=p.forwardRef(({className:e,...t},n)=>c.jsx(Md,{ref:n,className:oe("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}));Hy.displayName=Md.displayName;const ps=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(By,{children:c.jsx(kd,{ref:r,sideOffset:t,className:oe("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})}));ps.displayName=kd.displayName;const Gn=p.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Ed,{ref:r,className:oe("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}));Gn.displayName=Ed.displayName;const Uy=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Id,{ref:o,className:oe("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(Ad,{children:c.jsx(ae.Check,{className:"h-4 w-4"})})}),t]}));Uy.displayName=Id.displayName;const Wy=p.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Nd,{ref:r,className:oe("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(Ad,{children:c.jsx(ae.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Wy.displayName=Nd.displayName;const Vy=p.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Td,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Vy.displayName=Td.displayName;const Ky=p.forwardRef(({className:e,...t},n)=>c.jsx(jd,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));Ky.displayName=jd.displayName;const ms=0,jn=1,br=2,Pd=4;function Rd(e){return()=>e}function qy(e){e()}function Od(e,t){return n=>e(t(n))}function Dd(e,t){return()=>e(t)}function Gy(e,t){return n=>e(t,n)}function ra(e){return e!==void 0}function Yy(...e){return()=>{e.map(qy)}}function yr(){}function gs(e,t){return t(e),e}function Xy(e,t){return t(e)}function ct(...e){return e}function et(e,t){return e(jn,t)}function Pe(e,t){e(ms,t)}function oa(e){e(br)}function xt(e){return e(Pd)}function xe(e,t){return et(e,Gy(t,ms))}function sn(e,t){const n=e(jn,r=>{n(),t(r)});return n}function Ld(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function $d(e,t){return e===t}function ut(e=$d){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ie(e){return t=>n=>{e(n)&&t(n)}}function ue(e){return t=>Od(t,e)}function gn(e){return t=>()=>{t(e)}}function Q(e,...t){const n=Jy(...t);return(r,o)=>{switch(r){case br:oa(e);return;case jn:return et(e,n(o))}}}function xn(e,t){return n=>r=>{n(t=e(t,r))}}function Yn(e){return t=>n=>{e>0?e--:t(n)}}function kn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function De(...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);et(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 Jy(...e){return t=>e.reduceRight(Xy,t)}function Zy(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case jn:return s?n===s?void 0:(r(),n=s,t=et(e,s),t):(r(),yr);case br:r(),n=null;return}}}function se(e){let t=e;const n=He();return(r,o)=>{switch(r){case ms:t=o;break;case jn:{o(t);break}case Pd:return t}return n(r,o)}}function _t(e,t){return gs(se(t),n=>xe(e,n))}function He(){const e=[];return(t,n)=>{switch(t){case ms:e.slice().forEach(r=>{r(n)});return;case br:e.splice(0,e.length);return;case jn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Kt(e){return gs(He(),t=>xe(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Qy(),singleton:n}}const Qy=()=>Symbol();function e0(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 wt(...e){const t=He(),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);et(s,l=>{n[i]=l,r=r|a,r===o&&Pe(t,n)})}),function(s,i){switch(s){case br:{oa(t);return}case jn:return r===o&&i(n),et(t,i)}}}function Ce(e,t=$d){return Q(e,ut(t))}function sa(...e){return function(t,n){switch(t){case br:return;case jn:return Yy(...e.map(r=>et(r,n)))}}}var Bt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Bt||{});const t0={0:"debug",3:"error",1:"log",2:"warn"},n0=()=>typeof globalThis>"u"?window:globalThis,_n=Ge(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=n0().VIRTUOSO_LOG_LEVEL)!=null?o:xt(e);r>=s&&console[t0[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Xn(e,t,n){return ia(e,t,n).callbackRef}function ia(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 r0(e,t,n,r,o,s,i,a,l){const u=y.useCallback(d=>{const f=o0(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const m=h.lastElementChild.dataset.viewportType==="window";let w;m&&(w=h.ownerDocument.defaultView);const v=i?a?i.scrollLeft:i.scrollTop:m?a?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:m?a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:m?a?w.innerWidth:w.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(v,0),viewportHeight:x}),s==null||s(a?Fd("column-gap",getComputedStyle(d).columnGap,o):Fd("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ia(u,n,l)}function o0(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},Bt.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 Fd(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Bt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Bd(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 m=t.getBoundingClientRect(),w=u.top-m.top;h=m.height-Math.max(0,w),f=w+t.scrollTop}else{const m=i.current.ownerDocument.defaultView;h=m.innerHeight-Math.max(0,u.top),f=u.top+m.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ia(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 Dt=Ge(()=>{const e=He(),t=He(),n=se(0),r=He(),o=se(0),s=He(),i=He(),a=se(0),l=se(0),u=se(0),d=se(0),f=He(),h=He(),m=se(!1),w=se(!1),v=se(!1);return xe(Q(e,ue(({scrollTop:g})=>g)),t),xe(Q(e,ue(({scrollHeight:g})=>g)),i),xe(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:w,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:m,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:v,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Yr={lvl:0};function zd(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 ot(e){return e===Yr}function Xr(e,t){if(!ot(e))return t===e.k?e.v:t<e.k?Xr(e.l,t):Xr(e.r,t)}function an(e,t,n="k"){if(ot(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=an(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return an(e.l,t,n)}function qt(e,t,n){return ot(e)?Wd(t,n,1):t===e.k?bt(e,{k:t,v:n}):t<e.k?Vd(bt(e,{l:qt(e.l,t,n)})):Vd(bt(e,{r:qt(e.r,t,n)}))}function Sr(){return Yr}function xs(e,t,n){if(ot(e))return[];const r=an(e,t)[0];return s0(la(e,r,n))}function aa(e,t){if(ot(e))return Yr;const{k:n,l:r,r:o}=e;if(t===n){if(ot(r))return o;if(ot(o))return r;{const[s,i]=Ud(r);return vs(bt(e,{k:s,l:Hd(r),v:i}))}}else return t<n?vs(bt(e,{l:aa(r,t)})):vs(bt(e,{r:aa(o,t)}))}function Jn(e){return ot(e)?[]:[...Jn(e.l),{k:e.k,v:e.v},...Jn(e.r)]}function la(e,t,n){if(ot(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(la(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(la(s,t,n))),a}function vs(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(ca(t))return Kd(bt(e,{lvl:n-1}));if(!ot(t)&&!ot(t.r))return bt(t.r,{l:bt(t,{r:t.r.l}),lvl:n,r:bt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(ca(e))return ua(bt(e,{lvl:n-1}));if(!ot(r)&&!ot(r.l)){const o=r.l,s=ca(o)?r.lvl-1:r.lvl;return bt(o,{l:bt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ua(bt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function bt(e,t){return Wd(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 Hd(e){return ot(e.r)?e.l:vs(bt(e,{r:Hd(e.r)}))}function ca(e){return ot(e)||e.lvl>e.r.lvl}function Ud(e){return ot(e.r)?[e.k,e.v]:Ud(e.r)}function Wd(e,t,n,r=Yr,o=Yr){return{k:e,l:r,lvl:n,r:o,v:t}}function Vd(e){return ua(Kd(e))}function Kd(e){const{l:t}=e;return!ot(t)&&t.lvl===e.lvl?bt(t,{r:bt(e,{l:t.r})}):e}function ua(e){const{lvl:t,r:n}=e;return!ot(n)&&!ot(n.r)&&n.lvl===t&&n.r.lvl===t?bt(n,{l:bt(e,{r:n.l}),lvl:t+1}):e}function s0(e){return zd(e,({k:t,v:n})=>({index:t,value:n}))}function qd(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 da=Ge(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function Gd(e,t,n){return e[ws(e,t,n)]}function ws(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 i0(e,t,n,r){const o=ws(e,t,r),s=ws(e,n,r,o);return e.slice(o,s+1)}function Mn(e,t){return Math.round(e.getBoundingClientRect()[t])}function bs(e){return!ot(e.groupOffsetTree)}function fa({index:e},t){return t===e?0:t<e?-1:1}function a0(){return{groupIndices:[],groupOffsetTree:Sr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Sr()}}function l0(e,t){let n=ot(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ot(e)){e=qt(e,0,s);continue}const a=xs(e,i-1,o+1);if(a.some(m0(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=aa(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=qt(e,o+1,h));u&&(e=qt(e,i,s))}return[e,n]}function c0(e){return typeof e.groupIndex<"u"}function u0({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}=Gd(t,e,fa),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Yd(e,t){if(!bs(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Xd(e,t,n){if(c0(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Yd(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function d0(e,t,n,r=0){return r>0&&(t=Math.max(t,Gd(e,r,fa).offset)),zd(i0(e,t,n,u0),p0)}function f0(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Bt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&ot(s)&&t.length===2){const h=t[0].size,m=t[1].size;i=n.reduce((w,v)=>qt(qt(w,v,h),v+1,m),i)}else[i,a]=l0(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=ha(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,m)=>qt(h,m,Zr(m,f,o)),Sr()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function h0(e){return Jn(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 Jd(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function ha(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=ws(o,t-1,fa),a=o[l].offset;const u=an(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===an(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of xs(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 p0(e){return{index:e.index,value:e}}function m0(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 g0={offsetHeight:"height",offsetWidth:"width"},vn=Ge(([{log:e},{recalcInProgress:t}])=>{const n=He(),r=He(),o=_t(r,0),s=He(),i=He(),a=se(0),l=se([]),u=se(void 0),d=se(void 0),f=se((C,k)=>Mn(C,g0[k])),h=se(void 0),m=se(0),w=a0(),v=_t(Q(n,De(l,e,m),xn(f0,w),ut()),w),g=_t(Q(l,ut(),xn((C,k)=>({current:k,prev:C.current}),{current:[],prev:[]}),ue(({prev:C})=>C)),[]);xe(Q(l,Ie(C=>C.length>0),De(v,m),ue(([C,k,E])=>{const A=C.reduce((O,$,H)=>qt(O,$,Zr($,k.offsetTree,E)||H),Sr());return{...k,groupIndices:C,groupOffsetTree:A}})),v),xe(Q(r,De(v),Ie(([C,{lastIndex:k}])=>C<k),ue(([C,{lastIndex:k,lastSize:E}])=>[{endIndex:k,size:E,startIndex:C}])),n),xe(u,d);const x=_t(Q(u,ue(C=>C===void 0)),!0);xe(Q(d,Ie(C=>C!==void 0&&ot(xt(v).sizeTree)),ue(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=Kt(Q(n,De(v),xn(({sizes:C},[k,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:w}),ue(C=>C.changed)));et(Q(a,xn((C,k)=>({diff:C.prev-k,prev:k}),{diff:0,prev:0}),ue(C=>C.diff)),C=>{const{groupIndices:k}=xt(v);if(C>0)Pe(t,!0),Pe(s,C+Jd(C,k));else if(C<0){const E=xt(g);E.length>0&&(C-=Jd(-C,E)),Pe(i,C)}}),et(Q(a,De(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},Bt.ERROR)});const S=Kt(s);xe(Q(s,De(v),ue(([C,k])=>{const E=k.groupIndices.length>0,A=[],O=k.lastSize;if(E){const $=Xr(k.sizeTree,0);let H=0,U=0;for(;H<C;){const R=k.groupIndices[U],Y=k.groupIndices.length===U+1?1/0:k.groupIndices[U+1]-R-1;A.push({endIndex:R,size:$,startIndex:R}),A.push({endIndex:R+1+Y-1,size:O,startIndex:R+1}),U++,H+=Y+1}const K=Jn(k.sizeTree);return H!==C&&K.shift(),K.reduce((R,{k:Y,v:N})=>{let D=R.ranges;return R.prevSize!==0&&(D=[...R.ranges,{endIndex:Y+C-1,size:R.prevSize,startIndex:R.prevIndex}]),{prevIndex:Y+C,prevSize:N,ranges:D}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return Jn(k.sizeTree).reduce(($,{k:H,v:U})=>({prevIndex:H+C,prevSize:U,ranges:[...$.ranges,{endIndex:H+C-1,size:$.prevSize,startIndex:$.prevIndex}]}),{prevIndex:0,prevSize:O,ranges:[]}).ranges})),n);const T=Kt(Q(i,De(v,m),ue(([C,{offsetTree:k},E])=>{const A=-C;return Zr(A,k,E)})));return xe(Q(i,De(v,m),ue(([C,k,E])=>{if(k.groupIndices.length>0){if(ot(k.sizeTree))return k;let A=Sr();const O=xt(g);let $=0,H=0,U=0;for(;$<-C;){U=O[H];const K=O[H+1]-U-1;H++,$+=K+1}if(A=Jn(k.sizeTree).reduce((K,{k:R,v:Y})=>qt(K,Math.max(0,R+C),Y),A),$!==-C){const K=Xr(k.sizeTree,U);A=qt(A,0,K);const R=an(k.sizeTree,-C+1)[1];A=qt(A,1,R)}return{...k,sizeTree:A,...ha(k.offsetTree,0,A,E)}}else{const A=Jn(k.sizeTree).reduce((O,{k:$,v:H})=>qt(O,Math.max(0,$+C),H),Sr());return{...k,sizeTree:A,...ha(k.offsetTree,0,A,E)}}})),v),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:m,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:T,sizeRanges:n,sizes:v,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},ct(_n,da),{singleton:!0});function x0(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Zd=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=He(),i=He(),a=Kt(Q(s,ue(x0)));return xe(Q(a,ue(l=>l.totalCount)),n),xe(Q(a,ue(l=>l.groupIndices)),e),xe(Q(wt(o,t,r),Ie(([l,u])=>bs(u)),ue(([l,u,d])=>an(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),ut(),ue(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ct(vn,Dt)),Pn=Ge(([{log:e}])=>{const t=se(!1),n=Kt(Q(t,Ie(r=>r),ut()));return et(t,r=>{r&&xt(e)("props updated",{},Bt.DEBUG)}),{didMount:n,propsReady:t}},ct(_n),{singleton:!0}),v0=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Qd(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!v0)&&(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 m=He(),w=He(),v=se(0);let g=null,x=null,b=null;function S(){g&&(g(),g=null),b&&(b(),b=null),x&&(clearTimeout(x),x=null),Pe(l,!1)}return xe(Q(m,De(n,f,r,v,a,i,h),De(e,s,o),ue(([[T,C,k,E,A,O,$,H],U,K,R])=>{const Y=Qd(T),{align:N,behavior:D,offset:M}=Y,j=E-1,z=Xd(Y,C,j);let W=Zr(z,C.offsetTree,U)+O;N==="end"?(W+=K+an(C.sizeTree,z)[1]-k+R,z===j&&(W+=$)):N==="center"?W+=(K+an(C.sizeTree,z)[1]-k+R)/2:W-=A,M&&(W+=M);const P=B=>{S(),B?(H("retrying to scroll to",{location:T},Bt.DEBUG),Pe(m,T)):(Pe(w,!0),H("list did not change, scroll successful",{},Bt.DEBUG))};if(S(),D==="smooth"){let B=!1;b=et(t,te=>{B=B||te}),g=sn(d,()=>{P(B)})}else g=sn(Q(t,w0(150)),P);return x=setTimeout(()=>{S()},1200),Pe(l,!0),H("scrolling from index to",{behavior:D,index:z,top:W},Bt.DEBUG),{behavior:D,top:W}})),u),{scrollTargetReached:w,scrollToIndex:m,topListHeight:v}},ct(vn,Dt,_n),{singleton:!0});function w0(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function pa(e,t){e==0?t():requestAnimationFrame(()=>{pa(e-1,t)})}function ma(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=se(!0),l=se(0),u=se(!0);return xe(Q(i,De(l),Ie(([d,f])=>!!f),gn(!1)),a),xe(Q(i,De(l),Ie(([d,f])=>!!f),gn(!1)),u),et(Q(wt(t,i),De(a,n,e,u),Ie(([[,d],f,{sizeTree:h},m,w])=>d&&(!ot(h)||ra(m))&&!f&&!w),De(l)),([,d])=>{sn(o,()=>{Pe(u,!0)}),pa(4,()=>{sn(r,()=>{Pe(a,!0)}),Pe(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ct(vn,Dt,Qr,Pn),{singleton:!0});function ef(e,t){return Math.abs(e-t)<1.01}const to="up",no="down",b0="none",y0={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},S0=0,ro=Ge(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=se(!1),a=se(!0),l=He(),u=He(),d=se(4),f=se(S0),h=_t(Q(sa(Q(Ce(o),Yn(1),gn(!0)),Q(Ce(o),Yn(1),gn(!1),Ld(100))),ut()),!1),m=_t(Q(sa(Q(n,gn(!0)),Q(n,gn(!1),Ld(200))),ut()),!1);xe(Q(wt(Ce(o),Ce(f)),ue(([b,S])=>b<=S),ut()),a),xe(Q(a,kn(50)),u);const w=Kt(Q(wt(r,Ce(s),Ce(t),Ce(e),Ce(d)),xn((b,[{scrollHeight:S,scrollTop:T},C,k,E,A])=>{const O=T+C-S>-A,$={scrollHeight:S,scrollTop:T,viewportHeight:C};if(O){let U,K;return T>b.state.scrollTop?(U="SCROLLED_DOWN",K=b.state.scrollTop-T):(U="SIZE_DECREASED",K=b.state.scrollTop-T||b.scrollTopDelta),{atBottom:!0,atBottomBecause:U,scrollTopDelta:K,state:$}}let H;return $.scrollHeight>b.state.scrollHeight?H="SIZE_INCREASED":C<b.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":T<b.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:$}},y0),ut((b,S)=>b&&b.atBottom===S.atBottom))),v=_t(Q(r,xn((b,{scrollHeight:S,scrollTop:T,viewportHeight:C})=>{if(ef(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}),Ie(b=>b.changed),ue(b=>b.jump)),0);xe(Q(w,ue(b=>b.atBottom)),i),xe(Q(i,kn(50)),l);const g=se(no);xe(Q(r,ue(({scrollTop:b})=>b),ut(),xn((b,S)=>xt(m)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?to:no,prevScrollTop:S},{direction:no,prevScrollTop:0}),ue(b=>b.direction)),g),xe(Q(r,kn(50),gn(b0)),g);const x=se(0);return xe(Q(h,Ie(b=>!b),gn(0)),x),xe(Q(o,kn(100),De(h),Ie(([b,S])=>!!S),xn(([b,S],[T])=>[S,T],[0,0]),ue(([b,S])=>S-b)),x),{atBottomState:w,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:v,scrollDirection:g,scrollVelocity:x}},ct(Dt)),ys="top",Ss="bottom",tf="none";function nf(e,t,n){return typeof e=="number"?n===to&&t===ys||n===no&&t===Ss?e:0:n===to?t===ys?e.main:e.reverse:t===Ss?e.main:e.reverse}function rf(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ga=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=He(),i=se(0),a=se(0),l=se(0),u=_t(Q(wt(Ce(r),Ce(o),Ce(n),Ce(s,Jr),Ce(l),Ce(i),Ce(t),Ce(e),Ce(a)),ue(([d,f,h,[m,w],v,g,x,b,S])=>{const T=d-b,C=g+x,k=Math.max(h-T,0);let E=tf;const A=rf(S,ys),O=rf(S,Ss);return m-=b,m+=h+x,w+=h+x,w-=b,m>d+C-A&&(E=to),w<d-k+f+O&&(E=no),E!==tf?[Math.max(T-h-nf(v,ys,E)-A,0),T-k-x+f+nf(v,Ss,E)+O]:null}),Ie(d=>d!=null),ut(Jr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},ct(Dt),{singleton:!0});function C0(e,t,n){if(bs(t)){const r=Yd(e,t);return[{index:an(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 xa={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Cs(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 v=e[e.length-1];d=v.offset+v.size}const f=n-i,h=a+f*l+(f-1)*r,m=u,w=h-d;return{bottom:d,firstItemIndex:s,items:sf(e,o,s),offsetBottom:w,offsetTop:u,top:m,topItems:sf(t,o,s),topListHeight:t.reduce((v,g)=>g.size+v,0),totalCount:n}}function of(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=ma(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Cs(u,[],a,o,n,r)}function sf(e,t,n){if(e.length===0)return[];if(!bs(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=xs(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 Zn=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:m},{recalcInProgress:w}])=>{const v=se([]),g=se(0),x=He();xe(s.topItemsIndexes,v);const b=_t(Q(wt(m,w,Ce(l,Jr),Ce(o),Ce(r),Ce(u),d,Ce(v),Ce(t),Ce(n),e),Ie(([k,E,,A,,,,,,,O])=>{const $=O&&O.length!==A;return k&&!E&&!$}),ue(([,,[k,E],A,O,$,H,U,K,R,Y])=>{const N=O,{offsetTree:D,sizeTree:M}=N,j=xt(g);if(A===0)return{...xa,totalCount:A};if(k===0&&E===0)return j===0?{...xa,totalCount:A}:of(j,$,O,K,R,Y||[]);if(ot(M))return j>0?null:Cs(C0(ma($,A),N,Y),[],A,R,N,K);const z=[];if(U.length>0){const J=U[0],re=U[U.length-1];let G=0;for(const L of xs(M,J,re)){const V=L.value,Z=Math.max(L.start,J),q=Math.min(L.end,re);for(let X=Z;X<=q;X++)z.push({data:Y==null?void 0:Y[X],index:X,offset:G,size:V}),G+=V}}if(!H)return Cs([],z,A,R,N,K);const W=U.length>0?U[U.length-1]+1:0,P=d0(D,k,E,W);if(P.length===0)return null;const B=A-1,te=gs([],J=>{for(const re of P){const G=re.value;let L=G.offset,V=re.start;const Z=G.size;if(G.offset<k){V+=Math.floor((k-G.offset+R)/(Z+R));const X=V-re.start;L+=X*Z+X*R}V<W&&(L+=(W-V)*Z,V=W);const q=Math.min(re.end,B);for(let X=V;X<=q&&!(L>=E);X++)J.push({data:Y==null?void 0:Y[X],index:X,offset:L,size:Z}),L+=Z+R}});return Cs(te,z,A,R,N,K)}),Ie(k=>k!==null),ut()),xa);xe(Q(e,Ie(ra),ue(k=>k==null?void 0:k.length)),o),xe(Q(b,ue(k=>k.topListHeight)),f),xe(f,a),xe(Q(b,ue(k=>[k.top,k.bottom])),i),xe(Q(b,ue(k=>k.items)),x);const S=Kt(Q(b,Ie(({items:k})=>k.length>0),De(o,e),Ie(([{items:k},E])=>k[k.length-1].originalIndex===E-1),ue(([,k,E])=>[k-1,E]),ut(Jr),ue(([k])=>k))),T=Kt(Q(b,kn(200),Ie(({items:k,topItems:E})=>k.length>0&&k[0].originalIndex===E.length),ue(({items:k})=>k[0].index),ut())),C=Kt(Q(b,Ie(({items:k})=>k.length>0),ue(({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}}),ut(qd)));return{endReached:S,initialItemCount:g,itemsRendered:x,listState:b,rangeChanged:C,startReached:T,topItemsIndexes:v,...h}},ct(vn,Zd,ga,eo,Qr,ro,Pn,da),{singleton:!0}),af=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=He(),i=_t(Q(wt(n,e,r,t,o),ue(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return xe(Ce(i),s),{totalListHeight:i,totalListHeightChanged:s}},ct(Dt,Zn),{singleton:!0}),k0=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=_t(Q(wt(n,e,t),Ie(([o])=>o),ue(([,o,s])=>Math.max(0,o-s)),kn(0),ut()),0);return{alignToBottom:n,paddingTopAddition:r}},ct(Dt,af),{singleton:!0}),lf=Ge(()=>({context:se(null)})),T0=({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,cf=Ge(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=He();return xe(Q(d,De(t,l,n,s,o,r,a),De(e),ue(([[f,h,m,w,v,g,x,b],S])=>{const{align:T,behavior:C,calculateViewLocation:k=T0,done:E,...A}=f,O=Xd(f,h,w-1),$=Zr(O,h.offsetTree,S)+v+g,H=$+an(h.sizeTree,O)[1],U=b+g,K=b+m-x,R=k({itemBottom:H,itemTop:$,locationParams:{align:T,behavior:C,...A},viewportBottom:K,viewportTop:U});return R?E&&sn(Q(i,Ie(Y=>!Y),Yn(xt(i)?1:2)),E):E&&E(),R}),Ie(f=>f!==null)),u),{scrollIntoView:d}},ct(vn,Dt,Qr,Zn,_n),{singleton:!0});function uf(e){return e?e==="smooth"?"smooth":"auto":!1}const E0=(e,t)=>typeof e=="function"?uf(e(t)):t&&uf(e),I0=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:m}])=>{const w=se(!1),v=He();let g=null;function x(C){Pe(i,{align:"end",behavior:C,index:"LAST"})}et(Q(wt(Q(Ce(t),Yn(1)),l),De(Ce(w),s,a,f),ue(([[C,k],E,A,O,$])=>{let H=k&&O,U="auto";return H&&(U=E0(E,A||$),H=H&&!!U),{followOutputBehavior:U,shouldFollow:H,totalCount:C}}),Ie(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:k})=>{g&&(g(),g=null),xt(n)?requestAnimationFrame(()=>{xt(d)("following output to ",{totalCount:k},Bt.DEBUG),x(C)}):g=sn(e,()=>{xt(d)("following output to ",{totalCount:k},Bt.DEBUG),x(C),g=null})});function b(C){const k=sn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(xt(d)("scrolling to bottom due to increased size",{},Bt.DEBUG),x("auto"))});setTimeout(k,100)}et(Q(wt(Ce(w),t,u),Ie(([C,,k])=>C&&k),xn(({value:C},[,k])=>({refreshed:C===k,value:k}),{refreshed:!1,value:0}),Ie(({refreshed:C})=>C),De(w,t)),([,C])=>{xt(a)&&b(C!==!1)}),et(v,()=>{b(xt(w)!==!1)}),et(wt(Ce(w),o),([C,k])=>{C&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const S=se(null),T=He();return xe(sa(Q(Ce(r),ue(C=>{var k;return(k=C==null?void 0:C.length)!=null?k:0})),Q(Ce(t))),T),et(Q(wt(Q(T,Yn(1)),l),De(Ce(S),a,f,h),ue(([[C,k],E,A,O,$])=>k&&A&&(E==null?void 0:E({context:$,totalCount:C,scrollingInProgress:O}))),Ie(C=>!!C),kn(0)),C=>{g&&(g(),g=null),xt(n)?requestAnimationFrame(()=>{xt(d)("scrolling into view",{}),Pe(m,C)}):g=sn(e,()=>{xt(d)("scrolling into view",{}),Pe(m,C),g=null})}),{autoscrollToBottom:v,followOutput:w,scrollIntoViewOnChange:S}},ct(vn,ro,Qr,eo,Pn,_n,Dt,lf,cf)),N0=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(xe(Q(a,De(s),Ie(([,l])=>l!==0),De(o,r,t,n,e),ue(([[,l],u,d,f,h,m=[]])=>of(l,u,d,f,h,m))),i),{}),ct(vn,eo,Zn,Pn),{singleton:!0}),A0=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return et(Q(e,De(r),Ie(([,o])=>o!==0),ue(([,o])=>({top:o}))),o=>{sn(Q(n,Yn(1),Ie(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(t,o)})})}),{initialScrollTop:r}},ct(Pn,Dt,Zn),{singleton:!0}),df=Ge(([{scrollVelocity:e}])=>{const t=se(!1),n=He(),r=se(!1);return xe(Q(e,De(r,t,n),Ie(([o,s])=>!!s),ue(([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}),ut()),t),et(Q(wt(t,e,n),De(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ct(ro),{singleton:!0}),va=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=He(),r=He(),o=He(),s=se(!1),i=se(void 0);return xe(Q(wt(n,r),ue(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),xe(Q(t,De(r),ue(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ct(Dt)),j0=Ge(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=He(),d=se(void 0),f=se(null),h=se(null);return xe(a,f),xe(l,h),et(Q(u,De(t,r,i,f,h,n)),([m,w,v,g,x,b,S])=>{const T=h0(w.sizeTree);g&&x!==null&&b!==null&&(v=x.scrollTop-b.offsetTop),v-=S,m({ranges:T,scrollTop:v})}),xe(Q(d,Ie(ra),ue(_0)),o),xe(Q(s,De(d),Ie(([,m])=>m!==void 0),ut(),ue(([,m])=>m.ranges)),e),{getState:u,restoreStateFrom:d}},ct(vn,Dt,eo,Pn,va));function _0(e){return{align:"start",index:0,offset:e.scrollTop}}const M0=Ge(([{topItemsIndexes:e}])=>{const t=se(0);return xe(Q(t,Ie(n=>n>=0),ue(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ct(Zn));function ff(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const P0=ff(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),R0=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:m},{recalcInProgress:w}])=>{const v=Kt(Q(l,De(i),xn(([,x,b,S],[{bottom:T,items:C,offsetBottom:k,totalCount:E},A])=>{const O=T+k;let $=0;return b===E&&x.length>0&&C.length>0&&(C[0].originalIndex===0&&x[0].originalIndex===0||($=O-S,$!==0&&($+=A))),[$,C,E,O]},[0,[],0,0]),Ie(([x])=>x!==0),De(r,a,n,o,m,w),Ie(([,x,b,S,,,T])=>!T&&!S&&x!==0&&b===to),ue(([[x],,,,,b])=>(b("Upward scrolling compensation",{amount:x},Bt.DEBUG),x))));function g(x){x>0?(Pe(t,{behavior:"auto",top:-x}),Pe(e,0)):(Pe(e,0),Pe(t,{behavior:"auto",top:-x}))}return et(Q(v,De(e,s)),([x,b,S])=>{S&&P0()?Pe(e,b-x):g(-x)}),et(Q(wt(_t(s,!1),e,w),Ie(([x,b,S])=>!x&&!S&&b!==0),ue(([x,b])=>b),kn(1)),g),xe(Q(f,ue(x=>({top:-x}))),t),et(Q(u,De(h,d),ue(([x,{groupIndices:b,lastSize:S,sizeTree:T},C])=>{function k(E){return E*(S+C)}if(b.length===0)return k(x);{let E=0;const A=Xr(T,0);let O=0,$=0;for(;O<x;){O++,E+=A;let H=b.length===$+1?1/0:b[$+1]-b[$]-1;O+H>x&&(E-=A,H=x-O+1),O+=H,E+=k(H),$++}return E}})),x=>{Pe(e,x),requestAnimationFrame(()=>{Pe(t,{top:x}),requestAnimationFrame(()=>{Pe(e,0),Pe(w,!1)})})}),{deviation:e}},ct(Dt,ro,Zn,vn,_n,da)),O0=Ge(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),ct(ga,N0,Pn,df,af,A0,k0,va,cf,_n,lf)),hf=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:m,scrolledToInitialItem:w},v,g,x,{listState:b,topItemsIndexes:S,...T},{scrollToIndex:C},k,{topItemCount:E},{groupCounts:A},O])=>(xe(T.rangeChanged,O.scrollSeekRangeChanged),xe(Q(O.windowViewportRect,ue($=>$.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:m,scrolledToInitialItem:w,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...x,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...T,...O,...v,sizes:l,...g}),ct(vn,eo,Dt,j0,I0,Zn,Qr,R0,M0,Zd,O0));function D0(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 ks=typeof document<"u"?y.useLayoutEffect:y.useEffect;function pf(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,x){g.propsReady&&Pe(g.propsReady,!1);for(const b of r){const S=g[t.required[b]];Pe(S,x[b])}for(const b of o)if(b in x){const S=g[t.optional[b]];Pe(S,x[b])}g.propsReady&&Pe(g.propsReady,!0)}function u(g){return s.reduce((x,b)=>(x[b]=S=>{const T=g[t.methods[b]];Pe(T,S)},x),{})}function d(g){return i.reduce((x,b)=>(x[b]=Zy(g[t.events[b]]),x),{})}const f=y.forwardRef((g,x)=>{const{children:b,...S}=g,[T]=y.useState(()=>gs(e0(e),E=>{l(E,S)})),[C]=y.useState(Dd(d,T));ks(()=>{for(const E of i)E in S&&et(C[E],S[E]);return()=>{Object.values(C).map(oa)}},[S,C,T]),ks(()=>{l(T,S)}),y.useImperativeHandle(x,Rd(u(T)));const k=n;return c.jsx(a.Provider,{value:T,children:n?c.jsx(k,{...D0([...r,...o,...i],S),children:b}):b})}),h=g=>{const x=y.useContext(a);return y.useCallback(b=>{Pe(x[g],b)},[x,g])},m=g=>{const x=y.useContext(a)[g],b=y.useCallback(S=>et(x,S),[x]);return y.useSyncExternalStore(b,()=>xt(x),()=>xt(x))},w=g=>{const x=y.useContext(a)[g],[b,S]=y.useState(Dd(xt,x));return ks(()=>et(x,T=>{T!==b&&S(Rd(T))}),[x,b]),b},v=y.version.startsWith("18")?m:w;return{Component:f,useEmitter:(g,x)=>{const b=y.useContext(a)[g];ks(()=>et(b,x),[x,b])},useEmitterValue:v,usePublisher:h}}const mf=y.createContext(void 0),gf=y.createContext(void 0),xf=typeof document<"u"?y.useLayoutEffect:y.useEffect;function wa(e){return"self"in e}function L0(e){return"body"in e}function vf(e,t,n,r=yr,o,s){const i=y.useRef(null),a=y.useRef(null),l=y.useRef(null),u=y.useCallback(h=>{let m,w,v;const g=h.target;if(L0(g)||wa(g)){const b=wa(g)?g:g.defaultView;v=s?b.scrollX:b.scrollY,m=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,w=s?b.innerWidth:b.innerHeight}else v=s?g.scrollLeft:g.scrollTop,m=s?g.scrollWidth:g.scrollHeight,w=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:m,scrollTop:Math.max(v,0),viewportHeight:w})};h.suppressFlushSync?x():Zs.flushSync(x),a.current!==null&&(v===a.current||v<=0||v===m-w)&&(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 m=i.current;if(!m||(s?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const w=h.behavior==="smooth";let v,g,x;wa(m)?(g=Math.max(Mn(m.document.documentElement,s?"width":"height"),s?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),v=s?m.innerWidth:m.innerHeight,x=s?window.scrollX:window.scrollY):(g=m[s?"scrollWidth":"scrollHeight"],v=Mn(m,s?"width":"height"),x=m[s?"scrollLeft":"scrollTop"]);const b=g-v;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),ef(v,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:v}),w&&t(!0);return}w?(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}),m.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 ba="-webkit-sticky",wf="sticky",ya=ff(()=>{if(typeof document>"u")return wf;const e=document.createElement("div");return e.style.position=ba,e.style.position===ba?ba:wf});function Sa(e){return e}const $0=Ge(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(Sa),o=se("div"),s=se(yr),i=(a,l=null)=>_t(Q(n,ue(u=>u[a]),ut()),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")}}),F0=Ge(([e,t])=>({...e,...t}),ct(hf,$0)),B0=({height:e})=>c.jsx("div",{style:{height:e}}),z0={overflowAnchor:"none",position:ya(),zIndex:1},bf={overflowAnchor:"none"},H0={...bf,display:"inline-block",height:"100%"},yf=y.memo(function({showTopList:e=!1}){const t=Ae("listState"),n=Zt("sizeRanges"),r=Ae("useWindowScroll"),o=Ae("customScrollParent"),s=Zt("windowScrollContainerState"),i=Zt("scrollContainerState"),a=o||r?s:i,l=Ae("itemContent"),u=Ae("context"),d=Ae("groupContent"),f=Ae("trackItemSizes"),h=Ae("itemSize"),m=Ae("log"),w=Zt("gap"),v=Ae("horizontalDirection"),{callbackRef:g}=r0(n,h,f,e?yr:a,m,w,o,v,Ae("skipAnimationFrameInResizeObserver")),[x,b]=y.useState(0);Ca("deviation",R=>{x!==R&&b(R)});const S=Ae("EmptyPlaceholder"),T=Ae("ScrollSeekPlaceholder")||B0,C=Ae("ListComponent"),k=Ae("ItemComponent"),E=Ae("GroupComponent"),A=Ae("computeItemKey"),O=Ae("isSeeking"),$=Ae("groupIndices").length>0,H=Ae("alignToBottom"),U=Ae("initialItemFinalLocationReached"),K=e?{}:{boxSizing:"border-box",...v?{display:"inline-block",height:"100%",marginLeft:x!==0?x:H?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:H?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...U?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{...Mt(S,u)}):c.jsx(C,{...Mt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:K,children:(e?t.topItems:t.items).map(R=>{const Y=R.originalIndex,N=A(Y+t.firstItemIndex,R.data,u);return O?y.createElement(T,{...Mt(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,{...Mt(E,u),"data-index":Y,"data-item-index":R.index,"data-known-size":R.size,key:N,style:z0},d(R.index,u)):y.createElement(k,{...Mt(k,u),...K0(k,R.data),"data-index":Y,"data-item-group-index":R.groupIndex,"data-item-index":R.index,"data-known-size":R.size,key:N,style:v?H0:bf},$?l(R.index,R.groupIndex,R.data,u):l(R.index,R.data,u))})})}),U0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},W0={outline:"none",overflowX:"auto",position:"relative"},Ts=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),V0={position:ya(),top:0,width:"100%",zIndex:1};function Mt(e,t){if(typeof e!="string")return{context:t}}function K0(e,t){return{item:typeof e=="string"?void 0:t}}const q0=y.memo(function(){const e=Ae("HeaderComponent"),t=Zt("headerHeight"),n=Ae("HeaderFooterTag"),r=Xn(y.useMemo(()=>s=>{t(Mn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Mt(e,o)})}):null}),G0=y.memo(function(){const e=Ae("FooterComponent"),t=Zt("footerHeight"),n=Ae("HeaderFooterTag"),r=Xn(y.useMemo(()=>s=>{t(Mn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Mt(e,o)})}):null});function Sf({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:m,scrollToCallback:w}=vf(a,u,l,d,void 0,f);return e("scrollTo",w),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...f?W0:U0,...o},tabIndex:0,...i,...Mt(l,s),children:r})})}function Cf({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"),m=y.useRef(null),w=t("scrollerRef"),{scrollByCallback:v,scrollerRef:g,scrollToCallback:x}=vf(a,u,l,w,h);return xf(()=>{var b;return g.current=h||((b=m.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",v),c.jsx(l,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Mt(l,s),children:r})})}const Y0=({children:e})=>{const t=y.useContext(mf),n=Zt("viewportHeight"),r=Zt("fixedItemHeight"),o=Ae("alignToBottom"),s=Ae("horizontalDirection"),i=y.useMemo(()=>Od(n,l=>Mn(l,s?"width":"height")),[n,s]),a=Xn(i,!0,Ae("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:Ts(o),children:e})},X0=({children:e})=>{const t=y.useContext(mf),n=Zt("windowViewportRect"),r=Zt("fixedItemHeight"),o=Ae("customScrollParent"),s=Bd(n,o,Ae("skipAnimationFrameInResizeObserver")),i=Ae("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:Ts(i),children:e})},J0=({children:e})=>{const t=Ae("TopItemListComponent")||"div",n=Ae("headerHeight"),r={...V0,marginTop:`${n}px`},o=Ae("context");return c.jsx(t,{style:r,...Mt(t,o),children:e})},Z0=y.memo(function(e){const t=Ae("useWindowScroll"),n=Ae("topItemsIndexes").length>0,r=Ae("customScrollParent"),o=Ae("context");return c.jsxs(r||t?tS:eS,{...e,context:o,children:[n&&c.jsx(J0,{children:c.jsx(yf,{showTopList:!0})}),c.jsxs(r||t?X0:Y0,{children:[c.jsx(q0,{}),c.jsx(yf,{}),c.jsx(G0,{})]})]})}),{Component:Q0,useEmitter:Ca,useEmitterValue:Ae,usePublisher:Zt}=pf(F0,{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"}},Z0),eS=Sf({useEmitter:Ca,useEmitterValue:Ae,usePublisher:Zt}),tS=Cf({useEmitter:Ca,useEmitterValue:Ae,usePublisher:Zt}),nS=Q0;ct(hf,Ge(()=>{const e=se(u=>c.jsxs("td",{children:["Item $",u]})),t=se(null),n=se(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=se(null),o=se(null),s=se({}),i=se(Sa),a=se(yr),l=(u,d=null)=>_t(Q(s,ue(f=>f[u]),ut()),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")}})),ya();const kf={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},rS={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Tf,floor:Es,max:oo,min:ka,round:Ef}=Math;function If(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function oS(e){return{...rS,items:e}}function Is(e,t){return e&&e.width===t.width&&e.height===t.height}function sS(e,t){return e&&e.column===t.column&&e.row===t.row}const iS=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,m,{didMount:w,propsReady:v},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:T},C])=>{const k=se(0),E=se(0),A=se(kf),O=se({height:0,width:0}),$=se({height:0,width:0}),H=He(),U=He(),K=se(0),R=se(null),Y=se({column:0,row:0}),N=He(),D=He(),M=se(!1),j=se(0),z=se(!0),W=se(!1),P=se(!1);et(Q(w,De(j),Ie(([L,V])=>!!V)),()=>{Pe(z,!1)}),et(Q(wt(w,z,$,O,j,W),Ie(([L,V,Z,q,,X])=>L&&!V&&Z.height!==0&&q.height!==0&&!X)),([,,,,L])=>{Pe(W,!0),pa(1,()=>{Pe(H,L)}),sn(Q(u),()=>{Pe(t,[0,0]),Pe(z,!0)})}),xe(Q(D,Ie(L=>L!=null&&L.scrollTop>0),gn(0)),E),et(Q(w,De(D),Ie(([,L])=>L!=null)),([,L])=>{L&&(Pe(O,L.viewport),Pe($,L.item),Pe(Y,L.gap),L.scrollTop>0&&(Pe(M,!0),sn(Q(u,Yn(1)),V=>{Pe(M,!1)}),Pe(l,{top:L.scrollTop})))}),xe(Q(O,ue(({height:L})=>L)),f),xe(Q(wt(Ce(O,Is),Ce($,Is),Ce(Y,(L,V)=>L&&L.column===V.column&&L.row===V.row),Ce(u)),ue(([L,V,Z,q])=>({gap:Z,item:V,scrollTop:q,viewport:L}))),N),xe(Q(wt(Ce(k),r,Ce(Y,sS),Ce($,Is),Ce(O,Is),Ce(R),Ce(E),Ce(M),Ce(z),Ce(j)),Ie(([,,,,,,,L])=>!L),ue(([L,[V,Z],q,X,pe,he,ee,,le,we])=>{const{column:je,row:Ne}=q,{height:$e,width:Ye}=X,{width:nt}=pe;if(ee===0&&(L===0||nt===0))return kf;if(Ye===0){const ht=ma(we,L),Tt=ht+Math.max(ee-1,0);return oS(If(ht,Tt,he))}const Ve=Nf(nt,Ye,je);let qe,rt;le?V===0&&Z===0&&ee>0?(qe=0,rt=ee-1):(qe=Ve*Es((V+Ne)/($e+Ne)),rt=Ve*Tf((Z+Ne)/($e+Ne))-1,rt=ka(L-1,oo(rt,Ve-1)),qe=ka(rt,oo(0,qe))):(qe=0,rt=-1);const kt=If(qe,rt,he),{bottom:at,top:ke}=Af(pe,q,X,kt),Oe=Tf(L/Ve),it=Oe*$e+(Oe-1)*Ne-at;return{bottom:at,itemHeight:$e,items:kt,itemWidth:Ye,offsetBottom:it,offsetTop:ke,top:ke}})),A),xe(Q(R,Ie(L=>L!==null),ue(L=>L.length)),k),xe(Q(wt(O,$,A,Y),Ie(([L,V,{items:Z}])=>Z.length>0&&V.height!==0&&L.height!==0),ue(([L,V,{items:Z},q])=>{const{bottom:X,top:pe}=Af(L,q,V,Z);return[pe,X]}),ut(Jr)),t);const B=se(!1);xe(Q(u,De(B),ue(([L,V])=>V||L!==0)),B);const te=Kt(Q(wt(A,k),Ie(([{items:L}])=>L.length>0),De(B),Ie(([[L,V],Z])=>{const q=L.items[L.items.length-1].index===V-1;return(Z||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===V)&&q}),ue(([[,L]])=>L-1),ut())),J=Kt(Q(Ce(A),Ie(({items:L})=>L.length>0&&L[0].index===0),gn(0),ut())),re=Kt(Q(Ce(A),De(M),Ie(([{items:L},V])=>L.length>0&&!V),ue(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),ut(qd),kn(0)));xe(re,m.scrollSeekRangeChanged),xe(Q(H,De(O,$,k,Y),ue(([L,V,Z,q,X])=>{const pe=Qd(L),{align:he,behavior:ee,offset:le}=pe;let we=pe.index;we==="LAST"&&(we=q-1),we=oo(0,we,ka(q-1,we));let je=Ta(V,X,Z,we);return he==="end"?je=Ef(je-V.height+Z.height):he==="center"&&(je=Ef(je-V.height/2+Z.height/2)),le&&(je+=le),{behavior:ee,top:je}})),l);const G=_t(Q(A,ue(L=>L.offsetBottom+L.bottom)),0);return xe(Q(T,ue(L=>({height:L.visibleHeight,width:L.visibleWidth}))),O),{customScrollParent:g,data:R,deviation:K,footerHeight:o,gap:Y,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:$,overscan:n,restoreStateFrom:D,scrollBy:i,scrollContainerState:a,scrollHeight:U,scrollTo:l,scrollToIndex:H,scrollTop:u,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:x,viewportDimensions:O,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:T,...m,gridState:A,horizontalDirection:P,initialTopMostItemIndex:j,totalListHeight:G,...h,endReached:te,propsReady:v,rangeChanged:re,startReached:J,stateChanged:N,stateRestoreInProgress:M,...C}},ct(ga,Dt,ro,df,Pn,va,_n));function Nf(e,t,n){return oo(1,Es((e+n)/(Es(t)+n)))}function Af(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ta(e,t,n,r[0].index);return{bottom:Ta(e,t,n,r[r.length-1].index)+o,top:s}}function Ta(e,t,n,r){const o=Nf(e.width,n.width,t.column),s=Es(r/o),i=s*n.height+oo(0,s-1)*t.row;return i>0?i+t.row:i}const aS=Ge(()=>{const e=se(f=>`Item ${f}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(Sa),i=se("div"),a=se(yr),l=(f,h=null)=>_t(Q(t,ue(m=>m[f]),ut()),h),u=se(!1),d=se(!1);return xe(Ce(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")}}),lS=Ge(([e,t])=>({...e,...t}),ct(iS,aS)),cS=y.memo(function(){const e=ft("gridState"),t=ft("listClassName"),n=ft("itemClassName"),r=ft("itemContent"),o=ft("computeItemKey"),s=ft("isSeeking"),i=Qt("scrollHeight"),a=ft("ItemComponent"),l=ft("ListComponent"),u=ft("ScrollSeekPlaceholder"),d=ft("context"),f=Qt("itemDimensions"),h=Qt("gap"),m=ft("log"),w=ft("stateRestoreInProgress"),v=Qt("reportReadyState"),g=Xn(y.useMemo(()=>x=>{const b=x.parentElement.parentElement.scrollHeight;i(b);const S=x.firstChild;if(S){const{height:T,width:C}=S.getBoundingClientRect();f({height:T,width:C})}h({column:_f("column-gap",getComputedStyle(x).columnGap,m),row:_f("row-gap",getComputedStyle(x).rowGap,m)})},[i,f,h,m]),!0,!1);return xf(()=>{e.itemHeight>0&&e.itemWidth>0&&v(!0)},[e]),w?null:c.jsx(l,{className:t,ref:g,...Mt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const b=o(x.index,x.data,d);return s?c.jsx(u,{...Mt(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},b):y.createElement(a,{...Mt(a,d),className:n,"data-index":x.index,key:b},r(x.index,x.data,d))})})}),uS=y.memo(function(){const e=ft("HeaderComponent"),t=Qt("headerHeight"),n=ft("headerFooterTag"),r=Xn(y.useMemo(()=>s=>{t(Mn(s,"height"))},[t]),!0,!1),o=ft("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Mt(e,o)})}):null}),dS=y.memo(function(){const e=ft("FooterComponent"),t=Qt("footerHeight"),n=ft("headerFooterTag"),r=Xn(y.useMemo(()=>s=>{t(Mn(s,"height"))},[t]),!0,!1),o=ft("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Mt(e,o)})}):null}),fS=({children:e})=>{const t=y.useContext(gf),n=Qt("itemDimensions"),r=Qt("viewportDimensions"),o=Xn(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:Ts(!1),children:e})},hS=({children:e})=>{const t=y.useContext(gf),n=Qt("windowViewportRect"),r=Qt("itemDimensions"),o=ft("customScrollParent"),s=Bd(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:Ts(!1),children:e})},pS=y.memo(function({...e}){const t=ft("useWindowScroll"),n=ft("customScrollParent"),r=n||t?gS:mS,o=n||t?hS:fS,s=ft("context");return c.jsx(r,{...e,...Mt(r,s),children:c.jsxs(o,{children:[c.jsx(uS,{}),c.jsx(cS,{}),c.jsx(dS,{})]})})}),{useEmitter:jf,useEmitterValue:ft,usePublisher:Qt}=pf(lS,{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"}},pS),mS=Sf({useEmitter:jf,useEmitterValue:ft,usePublisher:Qt}),gS=Cf({useEmitter:jf,useEmitterValue:ft,usePublisher:Qt});function _f(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Bt.WARN),t==="normal"?0:parseInt(t??"0",10)}const xS=wo.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 Mf({className:e,variant:t,...n}){return c.jsx("div",{className:oe(xS({variant:t}),e),...n})}async function Pf(e,t){return await Yt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function Rf(e,t){return await(await Pf(`/files/${e}/view`,t)).text()}async function vS(e,t){const n=await Pf(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Yt(`/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 wS(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Yt("/files",{params:r})}var Ns="Dialog",[Of,LT]=yn(Ns),[bS,ln]=Of(Ns),Df=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=p.useRef(null),l=p.useRef(null),[u,d]=dr({prop:r,defaultProp:o??!1,onChange:s,caller:Ns});return c.jsx(bS,{scope:t,triggerRef:a,contentRef:l,contentId:Rt(),titleId:Rt(),descriptionId:Rt(),open:u,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Df.displayName=Ns;var Lf="DialogTrigger",$f=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Lf,n),s=ze(t,o.triggerRef);return c.jsx(ye.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Na(o.open),...r,ref:s,onClick:me(e.onClick,o.onOpenToggle)})});$f.displayName=Lf;var Ea="DialogPortal",[yS,Ff]=Of(Ea,{forceMount:void 0}),Bf=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=ln(Ea,t);return c.jsx(yS,{scope:t,forceMount:n,children:p.Children.map(r,i=>c.jsx(Xt,{present:n||s.open,children:c.jsx(Qo,{asChild:!0,container:o,children:i})}))})};Bf.displayName=Ea;var As="DialogOverlay",zf=p.forwardRef((e,t)=>{const n=Ff(As,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=ln(As,e.__scopeDialog);return s.modal?c.jsx(Xt,{present:r||s.open,children:c.jsx(CS,{...o,ref:t})}):null});zf.displayName=As;var SS=Bn.createSlot("DialogOverlay.RemoveScroll"),CS=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(As,n);return c.jsx(ls,{as:SS,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(ye.div,{"data-state":Na(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Qn="DialogContent",Hf=p.forwardRef((e,t)=>{const n=Ff(Qn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=ln(Qn,e.__scopeDialog);return c.jsx(Xt,{present:r||s.open,children:s.modal?c.jsx(kS,{...o,ref:t}):c.jsx(TS,{...o,ref:t})})});Hf.displayName=Qn;var kS=p.forwardRef((e,t)=>{const n=ln(Qn,e.__scopeDialog),r=p.useRef(null),o=ze(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return Hi(s)},[]),c.jsx(Uf,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:me(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:me(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:me(e.onFocusOutside,s=>s.preventDefault())})}),TS=p.forwardRef((e,t)=>{const n=ln(Qn,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return c.jsx(Uf,{...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()}})}),Uf=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=ln(Qn,n),l=p.useRef(null),u=ze(t,l);return Ci(),c.jsxs(c.Fragment,{children:[c.jsx(zo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Bo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Na(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(ES,{titleId:a.titleId}),c.jsx(NS,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ia="DialogTitle",Wf=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Ia,n);return c.jsx(ye.h2,{id:o.titleId,...r,ref:t})});Wf.displayName=Ia;var Vf="DialogDescription",Kf=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Vf,n);return c.jsx(ye.p,{id:o.descriptionId,...r,ref:t})});Kf.displayName=Vf;var qf="DialogClose",Gf=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(qf,n);return c.jsx(ye.button,{type:"button",...r,ref:t,onClick:me(e.onClick,()=>o.onOpenChange(!1))})});Gf.displayName=qf;function Na(e){return e?"open":"closed"}var Yf="DialogTitleWarning",[$T,Xf]=Ux(Yf,{contentName:Qn,titleName:Ia,docsSlug:"dialog"}),ES=({titleId:e})=>{const t=Xf(Yf),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 p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},IS="DialogDescriptionWarning",NS=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Xf(IS).contentName}}.`;return p.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},Aa=Df,AS=$f,ja=Bf,so=zf,io=Hf,er=Wf,js=Kf,Jf=Gf;const Zf=Aa,jS=ja,Qf=p.forwardRef(({className:e,...t},n)=>c.jsx(so,{ref:n,className:oe("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}));Qf.displayName=so.displayName;const _a=p.forwardRef(({className:e,children:t,...n},r)=>{const o=p.useMemo(()=>{let s=!1;function i(a){p.Children.forEach(a,l=>{if(s||!p.isValidElement(l))return;const u=l.type;if(u===er||(u==null?void 0:u.displayName)===er.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(jS,{children:[c.jsx(Qf,{}),c.jsxs(io,{ref:r,className:oe("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(er,{className:"sr-only",children:"Dialog"}),t,c.jsxs(Jf,{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(ae.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});_a.displayName=io.displayName;const Ma=({className:e,...t})=>c.jsx("div",{className:oe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ma.displayName="DialogHeader";const Pa=p.forwardRef(({className:e,...t},n)=>c.jsx(er,{ref:n,className:oe("text-lg font-semibold leading-none tracking-tight",e),...t}));Pa.displayName=er.displayName;const _S=p.forwardRef(({className:e,...t},n)=>c.jsx(js,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));_S.displayName=js.displayName;const MS=1,PS=1e6;let Ra=0;function RS(){return Ra=(Ra+1)%Number.MAX_SAFE_INTEGER,Ra.toString()}const Oa=new Map,eh=e=>{if(Oa.has(e))return;const t=setTimeout(()=>{Oa.delete(e),ao({type:"REMOVE_TOAST",toastId:e})},PS);Oa.set(e,t)},OS=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,MS)};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?eh(n):e.toasts.forEach(r=>{eh(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)}}},_s=[];let Ms={toasts:[]};function ao(e){Ms=OS(Ms,e),_s.forEach(t=>{t(Ms)})}function DS({...e}){const t=RS(),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 Da(){const[e,t]=p.useState(Ms);return p.useEffect(()=>(_s.push(t),()=>{const n=_s.indexOf(t);n>-1&&_s.splice(n,1)}),[e]),{...e,toast:DS,dismiss:n=>ao({type:"DISMISS_TOAST",toastId:n})}}function LS({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}=Da(),h=y.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const x=await Rf(n);l(x)}catch(x){console.error("Failed to load file:",x),d(x instanceof Error?x.message:"Failed to load file")}finally{i(!1)}}},[n]);y.useEffect(()=>{e&&n&&h()},[e,n,h]);const m=async()=>{if(n)try{await vS(n),f({title:"Download started",description:`Downloading ${r}`})}catch(x){console.error("Failed to download file:",x),f({title:"Download failed",description:String(x),variant:"destructive"})}},w=async()=>{if(n)try{const x=await Rf(n),b=new Blob([x],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(x){console.error("Failed to open file externally:",x),f({title:"Failed to open file",description:String(x),variant:"destructive"})}},v=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(ae.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(Qe,{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(ae.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(ae.Image,{className:"h-5 w-5"}):c.jsx(ae.FileText,{className:"h-5 w-5"});return c.jsx(Zf,{open:e,onOpenChange:t,children:c.jsxs(_a,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(Ma,{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(Pa,{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(Qe,{variant:"outline",size:"sm",onClick:w,className:"flex items-center gap-2",children:[c.jsx(ae.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(Qe,{variant:"outline",size:"sm",onClick:m,className:"flex items-center gap-2",children:[c.jsx(ae.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:v()})]})})}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 tr=th();function $S(e){tr=e}const nh=/[&<>"']/,FS=new RegExp(nh.source,"g"),rh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,BS=new RegExp(rh.source,"g"),zS={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},oh=e=>zS[e];function Pt(e,t){if(t){if(nh.test(e))return e.replace(FS,oh)}else if(rh.test(e))return e.replace(BS,oh);return e}const HS=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function sh(e){return e.replace(HS,(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 US=/(^|[^\[])\^/g;function st(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(US,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const WS=/[^\w:]/g,VS=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function ih(e,t,n){if(e){let r;try{r=decodeURIComponent(sh(n)).replace(WS,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!VS.test(n)&&(n=YS(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Ps={},KS=/^[^:]+:\/*[^/]*$/,qS=/^([^:]+:)[\s\S]*$/,GS=/^([^:]+:\/*[^/]*)[\s\S]*$/;function YS(e,t){Ps[" "+e]||(KS.test(e)?Ps[" "+e]=e+"/":Ps[" "+e]=Os(e,"/",!0)),e=Ps[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(qS,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(GS,"$1")+t:e+t}const Rs={exec:function(){}};function ah(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 Os(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 XS(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 JS(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 lh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function ch(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 ZS(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 La{constructor(t){this.options=t||tr}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:Os(r,`
86
- `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=ZS(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=Os(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,m,w,v=n[1].trim();const g=v.length>1,x={type:"list",raw:"",ordered:g,start:g?+v.slice(0,-1):"",loose:!1,items:[]};v=g?`\\d{1,9}\\${v.slice(-1)}`:`\\${v}`,this.options.pedantic&&(v=g?v:"[*+-]");const b=new RegExp(`^( {0,3}${v})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(w=!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,m=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,m=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(f)&&(r+=f+`
89
- `,t=t.substring(f.length+1),w=!0),!w){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())m+=`
91
- `+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||k.test(d)||E.test(d)||C.test(d))break;m+=`
92
- `+f}!l&&!f.trim()&&(l=!0),r+=h+`
93
- `,t=t.substring(h.length+1),d=f.slice(i)}}x.loose||(u?x.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(m),o&&(s=o[0]!=="[ ] ",m=m.replace(/^\[[ xX]\] +/,""))),x.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:m}),x.raw+=r}x.items[x.items.length-1].raw=r.trimRight(),x.items[x.items.length-1].text=m.trimRight(),x.raw=x.raw.trimRight();const S=x.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,x.items[a].tokens=this.lexer.blockTokens(x.items[a].text,[]),!x.loose){const T=x.items[a].tokens.filter(k=>k.type==="space"),C=T.length>0&&T.some(k=>/\n.*\n/.test(k.raw));x.loose=C}if(x.loose)for(a=0;a<S;a++)x.items[a].loose=!0;return x}}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:ah(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]=ah(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: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=Os(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=XS(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)),ch(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 ch(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 w=h.slice(1,-1);return{type:"em",raw:h,text:w,tokens:this.lexer.inlineTokens(w)}}const m=h.slice(2,-2);return{type:"strong",raw:h,text:m,tokens:this.lexer.inlineTokens(m)}}}}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 be={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:Rs,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};be._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,be._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,be.def=st(be.def).replace("label",be._label).replace("title",be._title).getRegex(),be.bullet=/(?:[*+-]|\d{1,9}[.)])/,be.listItemStart=st(/^( *)(bull) */).replace("bull",be.bullet).getRegex(),be.list=st(be.list).replace(/bull/g,be.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+be.def.source+")").getRegex(),be._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",be._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,be.html=st(be.html,"i").replace("comment",be._comment).replace("tag",be._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),be.paragraph=st(be._paragraph).replace("hr",be.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",be._tag).getRegex(),be.blockquote=st(be.blockquote).replace("paragraph",be.paragraph).getRegex(),be.normal={...be},be.gfm={...be.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},be.gfm.table=st(be.gfm.table).replace("hr",be.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",be._tag).getRegex(),be.gfm.paragraph=st(be._paragraph).replace("hr",be.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",be.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",be._tag).getRegex(),be.pedantic={...be.normal,html:st(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",be._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:Rs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:st(be.normal._paragraph).replace("hr",be.hr).replace("heading",` *#{1,6} *[^
96
- ]`).replace("lheading",be.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const fe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Rs,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:Rs,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};fe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",fe.punctuation=st(fe.punctuation).replace(/punctuation/g,fe._punctuation).getRegex(),fe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,fe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,fe._comment=st(be._comment).replace("(?:-->|$)","-->").getRegex(),fe.emStrong.lDelim=st(fe.emStrong.lDelim).replace(/punct/g,fe._punctuation).getRegex(),fe.emStrong.rDelimAst=st(fe.emStrong.rDelimAst,"g").replace(/punct/g,fe._punctuation).getRegex(),fe.emStrong.rDelimUnd=st(fe.emStrong.rDelimUnd,"g").replace(/punct/g,fe._punctuation).getRegex(),fe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,fe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,fe._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])?)+(?![-_])/,fe.autolink=st(fe.autolink).replace("scheme",fe._scheme).replace("email",fe._email).getRegex(),fe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,fe.tag=st(fe.tag).replace("comment",fe._comment).replace("attribute",fe._attribute).getRegex(),fe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,fe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,fe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,fe.link=st(fe.link).replace("label",fe._label).replace("href",fe._href).replace("title",fe._title).getRegex(),fe.reflink=st(fe.reflink).replace("label",fe._label).replace("ref",be._label).getRegex(),fe.nolink=st(fe.nolink).replace("ref",be._label).getRegex(),fe.reflinkSearch=st(fe.reflinkSearch,"g").replace("reflink",fe.reflink).replace("nolink",fe.nolink).getRegex(),fe.normal={...fe},fe.pedantic={...fe.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:st(/^!?\[(label)\]\((.*?)\)/).replace("label",fe._label).getRegex(),reflink:st(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",fe._label).getRegex()},fe.gfm={...fe.normal,escape:st(fe.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},fe.gfm.url=st(fe.gfm.url,"i").replace("email",fe.gfm._extended_email).getRegex(),fe.breaks={...fe.gfm,br:st(fe.br).replace("{2,}","*").getRegex(),text:st(fe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function QS(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 uh(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 Rn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||tr,this.options.tokenizer=this.options.tokenizer||new La,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:be.normal,inline:fe.normal};this.options.pedantic?(n.block=be.pedantic,n.inline=fe.pedantic):this.options.gfm&&(n.block=be.gfm,this.options.breaks?n.inline=fe.breaks:n.inline=fe.gfm),this.tokenizer.rules=n}static get rules(){return{block:be,inline:fe}}static lex(t,n){return new Rn(n).lex(t)}static lexInline(t,n){return new Rn(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)+"["+lh("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)+"["+lh("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,uh)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,uh))){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(m){h=m.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,QS)){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 $a{constructor(t){this.options=t||tr}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$/,"")+`
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
107
  `,o?'<pre><code class="'+this.options.langPrefix+Pt(o)+'">'+(r?t:Pt(t,!0))+`</code></pre>
108
108
  `:"<pre><code>"+(r?t:Pt(t,!0))+`</code></pre>
109
109
  `}blockquote(t){return`<blockquote>
@@ -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=ih(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=ih(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 dh{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 fh{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 On{constructor(t){this.options=t||tr,this.options.renderer=this.options.renderer||new $a,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new dh,this.slugger=new fh}static parse(t,n){return new On(n).parse(t)}static parseInline(t,n){return new On(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,m,w,v,g,x,b,S,T,C,k;const E=t.length;for(o=0;o<E;o++){if(m=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[m.type]&&(k=this.options.extensions.renderers[m.type].call({parser:this},m),k!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(m.type))){r+=k||"";continue}switch(m.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(m.tokens),m.depth,sh(this.parseInline(m.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(m.text,m.lang,m.escaped);continue}case"table":{for(f="",d="",a=m.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(m.header[s].tokens),{header:!0,align:m.align[s]});for(f+=this.renderer.tablerow(d),h="",a=m.rows.length,s=0;s<a;s++){for(u=m.rows[s],d="",l=u.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:m.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(m.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(w=m.ordered,v=m.start,g=m.loose,a=m.items.length,h="",s=0;s<a;s++)b=m.items[s],S=b.checked,T=b.task,x="",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}):x+=C),x+=this.parse(b.tokens,g),h+=this.renderer.listitem(x,T,S);r+=this.renderer.list(h,w,v);continue}case"html":{r+=this.renderer.html(m.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(m.tokens));continue}case"text":{for(h=m.tokens?this.parseInline(m.tokens):m.text;o+1<E&&t[o+1].type==="text";)m=t[++o],h+=`
127
- `+(m.tokens?this.parseInline(m.tokens):m.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const A='Token with "'+m.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 Ds{constructor(t){this.options=t||tr}preprocess(t){return t}postprocess(t){return t}}fm(Ds,"passThroughHooks",new Set(["preprocess","postprocess"]));function eC(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 hh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ve.defaults,...s};const i=eC(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(JS(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&&ve.walkTokens(l,r.walkTokens),h=t(l,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(m){f=m}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;ve.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,m){if(h)return u(h);m!=null&&m!==f.text&&(f.text=m,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(ve.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&&ve.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ve(e,t,n){return hh(Rn.lex,On.parse)(e,t,n)}ve.options=ve.setOptions=function(e){return ve.defaults={...ve.defaults,...e},$S(ve.defaults),ve},ve.getDefaults=th,ve.defaults=tr,ve.use=function(...e){const t=ve.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ve.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=ve.defaults.renderer||new $a;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=ve.defaults.tokenizer||new La;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=ve.defaults.hooks||new Ds;for(const s in n.hooks){const i=o[s];Ds.passThroughHooks.has(s)?o[s]=a=>{if(ve.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=ve.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}}ve.setOptions(r)})},ve.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ve,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ve.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ve.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ve.walkTokens(r.items,t));break}default:ve.defaults.extensions&&ve.defaults.extensions.childTokens&&ve.defaults.extensions.childTokens[r.type]?ve.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ve.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ve.walkTokens(r.tokens,t)))}return n},ve.parseInline=hh(Rn.lexInline,On.parseInline),ve.Parser=On,ve.parser=On.parse,ve.Renderer=$a,ve.TextRenderer=dh,ve.Lexer=Rn,ve.lexer=Rn.lex,ve.Tokenizer=La,ve.Slugger=fh,ve.Hooks=Ds,ve.parse=ve,ve.options,ve.setOptions,ve.use,ve.walkTokens,ve.parseInline,On.parse,Rn.lex;function Cr({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 ve.parse=="function"?ve.parse(i):ve(i)}return typeof ve.parse=="function"?ve.parse(e):ve(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:oe("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 tC={MODE:"library"};function nC(){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:Qs&&Qs.tagName.toUpperCase()==="SCRIPT"&&Qs.src||new URL("index.umd.js",document.baseURI).href}<"u"?tC: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 rC(){return!nC()}function oC(){return typeof window>"u"?!1:window.__ARTIFACT_DEBUG__===!0}function sC(){return rC()||oC()}function iC({preview:e,idx:t}){return y.useEffect(()=>{sC()&&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 aC({artifact:e}){const[t,n]=y.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=y.useState(c.jsx(ae.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(ae.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(ae.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(ae.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(ae.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(ae.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(Cr,{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(ae.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 lC({artifact:e,idx:t=0}){if((e==null?void 0:e.type)==="research_task_info")return c.jsx(aC,{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=>xx(o)).filter(o=>o!==null):[],[e]);return n.length>0?c.jsx("div",{className:"space-y-2",children:n.map((r,o)=>c.jsx(iC,{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=p.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:oe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));lo.displayName="Card";const co=p.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:oe("flex flex-col space-y-1.5 p-6",e),...t}));co.displayName="CardHeader";const uo=p.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...t}));uo.displayName="CardTitle";const ph=p.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));ph.displayName="CardDescription";const fo=p.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:oe("p-6 pt-0",e),...t}));fo.displayName="CardContent";const mh=p.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:oe("flex items-center p-6 pt-0",e),...t}));mh.displayName="CardFooter";function cC({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=ur(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:oe("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(ph,{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(mh,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(Qe,{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(Qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const uC="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 gh({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:uC,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:ur(e)}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:ur(e)})}function dC({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(ae.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 fC({message:e,viewMode:t,isStreaming:n=!1}){const o=gi(e).name||"tool",s=l=>{if(l==null)return null;const u=typeof l=="string"?mi(l)??l:l;if(u&&typeof u=="object")return c.jsx(gh,{data:u});const d=typeof u=="string"?u:(()=>{try{return ur(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}=ux(l);return d?c.jsx(Cr,{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 m=$r(h);return i(m)}const u=Lr(l),d=$r(u);return i(d)};return c.jsxs("div",{className:"space-y-2",children:[c.jsx(dC,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function hC(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Da(),[o,s]=y.useState({}),[i,a]=y.useState(null),[l,u]=y.useState(!1),d=y.useCallback(()=>{u(!1),a(null)},[]),f=y.useCallback(m=>{a(m),u(!0)},[]),h=y.useCallback(async(m,w,v)=>{var g,x;if(!t){m.preventDefault();return}if(o[v]){m.preventDefault();return}try{const b=String(w.url??""),S=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){m.preventDefault();const T=S[1],C=w.name||`file_${T}`,k=w.mimeType||"application/octet-stream";f({id:T,name:C,mimeType:k});return}if(b.startsWith("data:")){m.preventDefault(),s(C=>({...C,[v]:!0}));const T=r({title:"Fetching file...",description:"",open:!0});try{const C=await wS(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??"")===(w.name??""))?!1:typeof w.size=="number"&&typeof E.size=="number"?E.size===w.size:!0);if(!(k!=null&&k.id))throw new Error(`File "${w.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:w.name||k.filename||`file_${k.id}`,mimeType:w.mimeType||k.mime_type||"application/octet-stream"}),(g=T.update)==null||g.call(T,{id:T.id,title:"Success",description:`Opened ${w.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const k=C instanceof Error?C.message:"Unknown error occurred";(x=T.update)==null||x.call(T,{id:T.id,title:"Failed",description:k}),r({title:"Failed to fetch file",description:k,open:!0})}finally{s(C=>({...C,[v]:!1}))}}}catch(b){console.error("File click error:",b),s(S=>({...S,[v]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:h,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function pC({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:oe("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?c.jsx(Cr,{content:e,allowHtml:!1}):c.jsxs("pre",{className:oe("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(Qe,{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(ae.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ae.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function mC({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:oe("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function xh(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const Ls=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:m={},onEdit:w,onRegenerate:v,onCancelEdit:g,onCopy:x,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:T,onInterruptActionEnd:C,checkpointCandidates:k=[],activeCheckpointId:E=null,onSelectCheckpoint:A,defaultCheckpointId:O=null,messageParentCheckpointId:$=null}){const[H,U]=y.useState(!1),[K,R]=y.useState("preview"),[Y,N]=y.useState(!1),{currentThreadId:D}=Do(),{respondToInterrupt:M}=Lo(),j=l==="phone"||l==="half-screen",z=t.role,W=z==="tool",P=y.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),B=!!P,te=!(r&&z!=="user"),{uploadingFiles:J,handleFileClick:re,fileViewerOpen:G,currentFileInfo:L,closeFileViewer:V}=hC({allowFileOpen:te,currentThreadId:D}),Z=y.useMemo(()=>{switch(z){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))]"}},[z]),q=y.useMemo(()=>{if(P)return"";const _=t.content;return Array.isArray(_)?dx(_):""},[P,t]),X=y.useMemo(()=>{if(P)return{};const _=t.content;return Array.isArray(_)?gi(t):{}},[P,t]),pe=y.useMemo(()=>W?!!(t.additionalKwargs??{}).toolStreaming:!1,[W,t]),he=y.useMemo(()=>{if(P)return[];const _=t.content;return Array.isArray(_)?_.filter(ie=>ie.type==="image_url"):[]},[P,t]),ee=y.useMemo(()=>{if(P)return[];const _=t.content;return Array.isArray(_)?_.filter(ie=>ie.type==="file"):[]},[P,t]),le=y.useMemo(()=>{if(P)return[];const _=t.content;return Array.isArray(_)?_.filter(ie=>ie.type==="interrupt"):[]},[P,t]),we=(b==null?void 0:b.id)??(b==null?void 0:b.interrupt_id),je=Oo(we),Ne=b==null?void 0:b.value,$e=y.useMemo(()=>{if(P)return"";const _=t.content;return Array.isArray(_)?fx(_):""},[P,t]),Ye=y.useMemo(()=>P||!h?null:t.artifact||null,[P,t,h]),nt=y.useCallback(async()=>{const _=W?$e:q;async function ie(ge){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(ge);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const We=new Blob([ge],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":We})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ie(_),U(!0),setTimeout(()=>U(!1),2e3),x==null||x(_)}catch(ge){console.error("Failed to copy:",ge)}},[W,$e,q,x]),Ve=y.useCallback(()=>{if(!w)return;const _=W?$e:q,ie="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};w(t.id,_,ie)},[w,t.id,W,$e,q,t]),qe=y.useCallback(()=>{v==null||v(n)},[v,n]),rt=y.useCallback(()=>{const ie=oe(j?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Z);switch(z){case"user":return c.jsx(ae.User,{className:ie});case"assistant":return c.jsx(ae.Bot,{className:ie});case"tool":return c.jsx(ae.Wrench,{className:ie});default:return c.jsx(ae.Bot,{className:ie})}},[j,Z,z]),kt=y.useCallback(()=>{const _="group relative mb-4 flex w-full";switch(z){case"user":return oe(_,"justify-end");case"assistant":case"tool":case"system":return oe(_,"justify-start");default:return _}},[z]),at=y.useCallback(()=>{const _=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",j&&"px-3 py-2 text-sm");if(B)return oe(_,"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(z){case"user":return oe(_,"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 oe(_,"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 oe(_,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(_,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(_,"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,B,z]),ke=y.useCallback(async _=>{if(S)return;const ie=Oo((_==null?void 0:_.id)??(_==null?void 0:_.interrupt_id));if(!ie){console.warn("Interrupt part missing id",_);return}try{T==null||T(),await M(ie,!0)}catch(ge){console.error("Failed to approve interrupt:",ge)}finally{C==null||C()}},[S,C,T,M]),Oe=y.useCallback(async _=>{if(S)return;const ie=Oo((_==null?void 0:_.id)??(_==null?void 0:_.interrupt_id));if(!ie){console.warn("Interrupt part missing id",_);return}try{T==null||T(),await M(ie,!1)}catch(ge){console.error("Failed to reject interrupt:",ge)}finally{C==null||C()}},[S,C,T,M]),it=y.useCallback(({part:_,i:ie})=>{if(_.type==="text"){const ge=_.text??"",We=ge.trim(),Re=mi(We);return Re&&z!=="tool"?c.jsx(gh,{data:Re},ie):z==="user"&&u&&We.length>d?c.jsx(pC,{text:We,expanded:Y,onExpandedChange:N,previewLength:d,isCompact:j},ie):c.jsx(Cr,{content:ge,allowHtml:!1},ie)}if(_.type==="image_url"){const ge=_;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:ge.url,alt:ge.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},ie)}if(_.type==="file"){const ge=_,We=ge.name||"file";return c.jsxs("a",{href:ge.url,onClick:Re=>re(Re.nativeEvent,ge,ie),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[ie]?c.jsx(ae.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[We,J[ie]?" (processing)":""]})]},ie)}if(_.type==="interrupt"){const ge=_,We=Oo((ge==null?void 0:ge.id)??(ge==null?void 0:ge.interrupt_id)),Re=!!(je&&We&&We===je),mt=Re?Ne??(ge==null?void 0:ge.value):ge==null?void 0:ge.value,Je=We?{...ge,id:We,interrupt_id:We}:ge;return c.jsx(cC,{interruptPart:Je,onApprove:ke,onReject:Oe,disabled:S,isActive:Re,payload:mt},ie)}return null},[re,J,ke,Oe,z,u,d,Y,j,je,Ne,b,S,le]),ht=y.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(ae.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),Tt=y.useCallback(()=>{const _=q.trim().length>0||he.length>0||ee.length>0||le.length>0;if(!W&&ee.length>0&&!r)return ht();if(!W&&!_&&!r)return null;if(W)return!f&&Ye?null:f?c.jsx(fC,{message:t,viewMode:K,isStreaming:pe},t.id):null;if(!W&&!P){const ie=t,ge=c.jsx("div",{className:"space-y-2",children:ie.content.map((We,Re)=>c.jsx(it,{part:We,i:Re},Re))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[ge,c.jsx(mC,{className:Z})]}):ge}},[q,he.length,ee.length,le.length,r,W,K,f,Ye,ht,Z]),yt=y.useMemo(()=>P?"Assistant":hx(t),[P,t]),Le=y.useMemo(()=>P?[]:Array.isArray(k)?k:[],[k,P]),Ht=y.useMemo(()=>{var _;return Le.length?O&&Le.some(ie=>ie.id===O)?O:((_=Le[0])==null?void 0:_.id)??null:null},[O,Le]),Ke=y.useMemo(()=>!Le.length||!E?null:Le.some(_=>_.id===E)?E:null,[E,Le])??Ht,dt=z==="user"&&Le.length>0&&typeof A=="function",vt=y.useCallback((_,ie=!1)=>{if(!A)return;const ge=(_==null?void 0:_.id)??null,We=(_==null?void 0:_.parentId)??$??null;A(ge,We,ie)},[$,A]),Ue=y.useMemo(()=>Ke?Le.findIndex(_=>_.id===Ke):-1,[Ke,Le]),St=y.useMemo(()=>Ue<0?null:Le[Ue]??null,[Ue,Le]);return W&&!f&&!Ye?null:B&&P?c.jsx("div",{className:oe(kt(),m.container),children:c.jsxs("div",{className:oe(at(),m.content),children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[c.jsx(ae.Bot,{className:oe("h-4 w-4",Z)}),a&&c.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),c.jsx(Cr,{content:P.content,className:"text-current"})]})}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:oe(kt(),m.container),children:c.jsxs("div",{className:oe(at(),m.content),children:[(i||a||W)&&c.jsxs("div",{className:oe("flex items-center justify-between mb-2 pb-2 border-b border-current/10",j&&"mb-1 pb-1",Z,m.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[rt(),a&&yt&&c.jsx("span",{className:oe("font-medium",j?"text-xs":"text-sm"),children:yt}),W&&c.jsxs(Mf,{variant:"outline",className:oe("text-xs flex items-center gap-1 cursor-pointer select-none",Z,"border border-current/40",j&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":K==="expanded",onClick:()=>R(_=>_==="expanded"?"preview":"expanded"),onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),R(ie=>ie==="expanded"?"preview":"expanded"))},children:[c.jsx("span",{children:X.name??"Tool Output"}),X.toolCallId&&c.jsx("span",{className:"opacity-70",children:X.toolCallId.slice(0,8)}),K==="expanded"?c.jsx(ae.ChevronUp,{className:"h-3 w-3"}):c.jsx(ae.ChevronDown,{className:"h-3 w-3"})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[dt&&St&&Ue>=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:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ue<Le.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Ue>=Le.length-1)return;const _=Le[Ue+1];_&&vt(_)},"aria-label":"Older checkpoint (back in time)",disabled:Ue>=Le.length-1,children:c.jsx(ae.ChevronLeft,{className:"h-3 w-3"})}),c.jsx("div",{className:"flex items-center gap-2",children:c.jsxs("span",{className:"whitespace-nowrap",children:[Le.length-Ue," / ",Le.length]})}),c.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ue>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(!(Ue<=0))if(Ue===1)vt(null,!0);else{const _=Le[Ue-1];_&&vt(_,!1)}},"aria-label":"Newer checkpoint (forward in time)",disabled:Ue<=0,children:c.jsx(ae.ChevronRight,{className:"h-3 w-3"})})]})}),i&&t.createdAt&&c.jsx("time",{className:oe("text-xs opacity-60",Z,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:oe("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",m.actions),children:[c.jsx("div",{className:"relative",children:c.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>nt(),className:oe("h-6 w-6 p-0 hover:bg-foreground/10",Z,j&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:c.jsx(ae.Copy,{className:oe(H?"text-success":Z,j?"h-3 w-3":"h-4 w-4")})})}),z==="user"&&w&&c.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ve,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",Z,j&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ae.Edit,{className:oe(Z,j?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&v&&c.jsx(Qe,{variant:"ghost",size:"sm",onClick:qe,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",Z,j&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ae.RotateCcw,{className:oe(Z,j?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsxs("div",{className:"relative",children:[Tt(),h&&Ye&&c.jsx("div",{className:"mt-3",children:c.jsx(lC,{artifact:Ye,idx:0})})]}),W&&K==="expanded"&&(X.toolCallId||X.name)&&c.jsxs("div",{className:oe("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",j&&"text-xs"),children:[X.name&&c.jsxs("div",{children:["Function: ",X.name]}),X.toolCallId&&c.jsxs("div",{children:["Call ID: ",X.toolCallId]})]}),!(i||a||W)&&s&&!o&&c.jsxs("div",{className:oe("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",m.actions),children:[c.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>nt(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:c.jsx(ae.Copy,{className:oe(H?"text-success":"text-current",j?"h-3 w-3":"h-4 w-4")})}),z==="user"&&w&&c.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ve,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:c.jsx(ae.Edit,{className:oe("text-current",j?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&v&&c.jsx(Qe,{variant:"ghost",size:"sm",onClick:qe,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:c.jsx(ae.RotateCcw,{className:oe("text-current",j?"h-3 w-3":"h-4 w-4")})})]})]})}),L&&c.jsx(LS,{isOpen:G,onClose:V,fileId:L.id,fileName:L.name,mimeType:L.mimeType})]})},(e,t)=>{var l,u,d,f,h,m,w,v;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&lc(e.message)===lc(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","attemptMeta"].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)===((m=t.customStyles)==null?void 0:m.actions)&&((w=e.customStyles)==null?void 0:w.header)===((v=t.customStyles)==null?void 0:v.header);if(!o||!s)return!1;const i=xh(e.message),a=xh(t.message);return i.length===a.length});Ls.displayName="MessageComponent";const vh=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,wh=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:m,onInterruptActionStart:w,onInterruptActionEnd:v,showToolMessages:g,showArtifactPreviews:x,checkpointMetaById:b,checkpointIndexByKey:S,attemptMetaById:T,userMessageIdToAttempts:C,activeCheckpointId:k,onSelectCheckpoint:E}){const A=vh(t,n),O="type"in t&&t.type==="default_message",H=!!t.__syntheticStreaming,{checkpointCandidates:U,defaultCheckpointId:K,attemptMeta:R}=ox(t,{checkpointMetaById:b,checkpointIndexByKey:S,attemptMetaById:T,userMessageIdToAttempts:C}),Y=t&&!O?t.additionalKwargs??{}:{},N=t&&!O?t.responseMetadata??{}:{},D=(()=>{if(typeof Y.parentCheckpointId=="string")return Y.parentCheckpointId;if(typeof N.parentCheckpointId=="string")return N.parentCheckpointId})();return c.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":A,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(Ls,{message:t,messageIndex:n,isStreamingMessage:H||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:m,onInterruptActionStart:w,onInterruptActionEnd:v,showToolMessages:g,showArtifactPreviews:x,checkpointCandidates:U,activeCheckpointId:k??null,onSelectCheckpoint:E,defaultCheckpointId:K,messageParentCheckpointId:D,attemptMeta:R})})});wh.displayName="MessageRow";const Fa=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:m,followNewMessages:w=!0,isNavigatingCheckpoint:v=!1,onScrollAway:g,onAtBottom:x,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:T,onInterruptActionEnd:C,showToolMessages:k=!0,showArtifactPreviews:E=!0,checkpointMetaById:A,checkpointIndexByKey:O,attemptMetaById:$,userMessageIdToAttempts:H,activeCheckpointId:U,onSelectCheckpoint:K,createSyntheticThinkingMessage:R=!0},Y)=>{const N=y.useRef(null),D=y.useRef(null),M=y.useRef(!1),j=y.useRef(!1),[z,W]=y.useState(!0),P=y.useMemo(()=>b?e.some(ee=>"type"in ee&&ee.type==="default_message"?!1:Array.isArray(ee==null?void 0:ee.content)&&ee.content.some(le=>le&&le.type==="interrupt"&&(le.id??le.interrupt_id)===b.id)):!1,[b,e]),B=y.useMemo(()=>{if(!b||P)return null;const ee=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let le;const we=b.value;if(we&&typeof we=="object"&&!Array.isArray(we)){const je=we.title;typeof je=="string"&&je.trim()&&(le=je.trim())}return{id:`interrupt-${ee}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:ee,value:we,title:le}]}},[b,P]),te=y.useMemo(()=>B?[...e,B]:e,[e,B]),J=y.useMemo(()=>!R||!t?te:!te.some(le=>le.role==="assistant")&&te.length>0?[...te,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:te,[te,t,R]),re=y.useMemo(()=>k?J:J.filter(ee=>(ee==null?void 0:ee.role)!=="tool"),[J,k]),G=y.useCallback(ee=>{W(ee),g&&g(!ee),x&&x(ee)},[g,x]),L=y.useMemo(()=>{if(a)return async()=>{if(!M.current){M.current=!0;try{await a()}finally{M.current=!1}}}},[a]),V=y.useMemo(()=>!w||v?!1:z?"auto":!1,[z,w,v]),Z=y.useMemo(()=>{if(typeof m!="string")return null;const ee=m.trim();return ee?{id:"default-message",role:"assistant",type:"default_message",content:ee,createdAt:new Date().toISOString()}:null},[m]),q=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),X=()=>Z?c.jsx("div",{className:"p-6 h-full overflow-y-auto",children:c.jsx("div",{className:"w-full max-w-full",children:c.jsx(Ls,{message:Z,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:m??"No messages yet. Start a conversation!"}),pe=re.length,he=pe>0;return y.useEffect(()=>{var ee,le;if(pe===0){j.current=!1;return}if(!j.current)if(j.current=!0,N.current&&re.length>0){const we=re.length-1;(le=(ee=N.current).scrollToIndex)==null||le.call(ee,{index:we,align:"end",behavior:"auto"})}else D.current&&(D.current.scrollTop=D.current.scrollHeight)},[pe,re.length]),y.useImperativeHandle(Y,()=>({scrollToLatest:()=>{var ee,le;if(N.current&&re.length>0){const we=re.length-1;(le=(ee=N.current).scrollToIndex)==null||le.call(ee,{index:we,align:"end",behavior:"auto"})}else D.current&&(D.current.scrollTop=D.current.scrollHeight)},scrollToTop:()=>{var ee,le;N.current&&re.length>0?(le=(ee=N.current).scrollToIndex)==null||le.call(ee,{index:0,align:"start",behavior:"auto"}):D.current&&(D.current.scrollTop=0)}}),[re]),c.jsx("div",{className:q,style:h,children:c.jsx("div",{className:"relative flex-1 min-h-0",children:he?c.jsx(nS,{ref:ee=>{N.current=ee},scrollerRef:ee=>{D.current=ee instanceof HTMLDivElement?ee:null},data:re,followOutput:V,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{L&&L()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(ee,le)=>vh(le,ee),itemContent:(ee,le)=>c.jsx(wh,{message:le,index:ee,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,checkpointMetaById:A,checkpointIndexByKey:O,attemptMetaById:$,userMessageIdToAttempts:H,activeCheckpointId:U,onSelectCheckpoint:K})}):X()})})});Fa.displayName="MessageList";const bh={value:""};function $s({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:m,onExcelUploadSuccess:w,onError:v}){const{api:g}=pi(),{currentThreadId:x}=Do(),{threadId:b,messages:S,isHistoryLoading:T,isLoading:C,navigateToCheckpoint:k,returnToLatest:E,checkpoint:A,checkpoints:O,interrupt:$,metadata:H,timelineCheckpoints:U,messagePreviews:K}=Lo(),{isStreaming:R,error:Y,connectionState:N,submit:D,stop:M}=Sc(),j=b??x??null,z=(A==null?void 0:A.id)??null,W=(A==null?void 0:A.namespace)??null,P=(H==null?void 0:H.assemblingMessageId)??null,B=$,[te,J]=y.useState(!1);y.useEffect(()=>{B||J(!1)},[B]);const re=y.useCallback(()=>{J(!0)},[]),G=y.useCallback(()=>{J(!1)},[]),L=!!B||te,[V,Z]=y.useState(null),[q,X]=y.useState(""),[pe,he]=y.useState(null),[ee,le]=y.useState(null),[we,je]=y.useState([]),[Ne,$e]=y.useState(0),[Ye,nt]=y.useState(0),[Ve,qe]=y.useState(!1),[rt,kt]=y.useState(null),[at,ke]=y.useState(null),[Oe,it]=y.useState(!1),[ht,Tt]=y.useState(null),yt=y.useRef(!1),[Le,Ht]=y.useState(()=>bh.value),Xe=y.useRef(Le),Ke=y.useRef(null),dt=y.useCallback(de=>{bh.value=de,Ht(de)},[]),[vt,Ue]=y.useState(!1),St=y.useRef(null),{checkpointMetaById:_,checkpointIndexByKey:ie,attemptMetaById:ge,userMessageIdToAttempts:We}=rx(O),Re=U??[],mt=y.useRef(null),Je=y.useRef(null),Nt=y.useCallback(()=>{mt.current&&(mt.current.value=""),Je.current&&(Je.current.value=""),$e(de=>de+1),nt(de=>de+1)},[]),go=y.useCallback(de=>{dt(de)},[dt]),xo=y.useRef(!1);y.useEffect(()=>{xo.current&&!R&&(je([]),Nt()),xo.current=R},[R,Nt]);const[Xs,il]=y.useState("desktop");y.useEffect(()=>{const de=()=>{const Se=window.innerWidth;il(Se<640?"phone":Se<1024?"tablet":"desktop")};return de(),window.addEventListener("resize",de),()=>window.removeEventListener("resize",de)},[]),y.useEffect(()=>{yt.current=!1},[j]),y.useEffect(()=>{Xe.current=Le},[Le]),y.useEffect(()=>{if(!V){Ke.current=null;return}Ke.current===null&&(Ke.current=Xe.current),dt(q??"")},[q,V,dt]),y.useEffect(()=>{(async()=>{if(!g.baseUrl){Tt(null);return}try{const Me=(await g.getAgent("default")).uiDefaultMessage||"";Tt(Me||null)}catch(Se){console.warn("Failed to fetch default message:",Se),Tt(null)}})()},[g.baseUrl]),y.useEffect(()=>{Y&&!Oe&&(v==null||v(Y))},[Y,Oe,v]);const al=async de=>{const Se=de.trim();if(!(!Se&&we.length===0))try{const Me=V?(pe==null?void 0:pe.checkpointId)??z??void 0:z??void 0,lt=V?(pe==null?void 0:pe.checkpointNs)??W??void 0:W??void 0;await D({text:Se||"",attachments:we},{checkpointId:Me,checkpointNs:lt,edit:!!V,originalMessageId:V??void 0}),m==null||m(Se),dt(""),le(null),je([]),Nt(),Z(null),X(""),he(null)}catch(Me){const lt=(Me==null?void 0:Me.message)||"Failed to send message";le(lt),v==null||v(lt)}},Js=y.useCallback((de,Se,Me)=>{u&&(Ke.current=Le,Z(de),X(Se),dt(Se),le(null),he({checkpointId:(Me==null?void 0:Me.checkpointId)??null,checkpointNs:(Me==null?void 0:Me.checkpointNs)??null}))},[Le,u,dt]),vo=y.useCallback(()=>{Z(null),X(""),he(null),le(null),dt(Ke.current??Le),Ke.current=null},[Le,dt]),I=y.useCallback((de,Se,Me)=>{Js(de,Se,Me)},[Js]),ne=y.useCallback(de=>{let Se=null;for(let Ut=de-1;Ut>=0;Ut--)if(S[Ut].role==="user"){Se=S[Ut];break}if(!Se)return;const Me=Array.isArray(Se.content)?Se.content:[],Ct=Me.filter(Ut=>(Ut==null?void 0:Ut.type)==="text").map(Ut=>Ut.text).join("")||(()=>{try{return JSON.stringify(Me,null,2)}catch{return String(Me)}})();Ct&&D({text:Ct},{checkpointId:z??void 0,checkpointNs:W??void 0,edit:!0,originalMessageId:Se.id})},[S,D,z,W]),ce=de=>{const Se=Array.from(de.target.files||[]);je(Me=>[...Me,...Se]),de.target.value=""},Te=de=>{je(Se=>{const Me=Se.filter((lt,Ct)=>de!==Ct);return Me.length===0&&Nt(),Me})},Ze=async de=>{const Se=(de.target.files||[])[0];if(Se){kt(null),ke(null),qe(!0);try{await D({attachments:[Se]},{checkpointId:z??void 0,checkpointNs:W??void 0});const Me=`Uploaded ${Se.name} - processing through chat stream`;ke(Me)}catch(Me){const lt=Me instanceof Error?Me.message:"Failed to upload Excel file";console.error("Excel upload failed",Me),kt(lt),v==null||v(lt)}finally{qe(!1),de.target.value="",Nt()}}},tt=async de=>{if(x){Ue(!0);try{if(!de){await E(),requestAnimationFrame(()=>{var lt;(lt=St.current)==null||lt.scrollToLatest()});return}const Se=O.find(lt=>lt.checkpointId===de),Me=(Se==null?void 0:Se.checkpointNs)??null;await k(de,Me),requestAnimationFrame(()=>{var lt;(lt=St.current)==null||lt.scrollToTop()})}finally{Ue(!1)}}},Be=y.useCallback(async(de,Se,Me)=>{await tt(Me?null:de)},[tt]),Fe=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${h.container||""}`,At=`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||""}`,pt=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${h.inputArea||""}`;return c.jsxs("div",{className:Fe,children:[!!Y&&!Oe&&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:Y}),c.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>it(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(ae.X,{size:16})})]}),c.jsxs("div",{className:`relative ${At}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(Fa,{ref:St,className:"h-full",style:{height:"100%"},messages:S,isStreaming:R,streamingAssistantId:P,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Xs,enableMessageEditing:u,editingMessageId:V,onEdit:I,onRegenerate:ne,onCancelEdit:vo,emptyMessage:ht??void 0,isNavigatingCheckpoint:vt,activeInterrupt:B,disableInterruptActions:te,onInterruptActionStart:re,onInterruptActionEnd:G,showToolMessages:d,showArtifactPreviews:f,checkpointMetaById:_,checkpointIndexByKey:ie,attemptMetaById:ge,userMessageIdToAttempts:We,activeCheckpointId:z,onSelectCheckpoint:Be,timelineCheckpoints:Re,messagePreviews:K,createSyntheticThinkingMessage:!0}),(N==="reconnecting"||N==="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(ae.Loader2,{className:"h-3 w-3 animate-spin"}),N==="reconnecting"?"Reconnecting…":"Connecting…"]})}),N==="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(ae.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(T||vt)&&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(ae.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:pt,children:[V&&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(ae.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Qe,{variant:"ghost",size:"sm",onClick:vo,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(ae.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:de=>ce(de),className:"hidden"},Ne),we.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:we.map((de,Se)=>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(ae.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:de.name}),c.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>Te(Se),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 ${de.name}`,children:c.jsx(ae.X,{size:12})})]},Se))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:Je,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Ze,className:"hidden"},Ye),Ve&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ae.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),at&&!Ve&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:at}),rt&&!Ve&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:rt})]})]}),ee&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ee}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(ta,{children:[c.jsx(na,{asChild:!0,children:c.jsx(Qe,{type:"button",size:"icon",variant:"outline",disabled:R||L,title:"More input actions",className:h.moreButton||"",children:c.jsx(ae.Plus,{size:16})})}),c.jsxs(ps,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(Gn,{onClick:()=>{var de;return(de=mt.current)==null?void 0:de.click()},className:"cursor-pointer",children:[c.jsx(ae.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(Gn,{onClick:()=>{var de;Ve||(de=Je.current)==null||de.click()},className:`cursor-pointer ${Ve?"opacity-60 pointer-events-none":""}`,children:[c.jsx(ae.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(Hx,{initialValue:q,editingMessageId:V,value:Le,onValueChange:go,placeholder:V?"Edit your message...":t,isStreaming:R,disabled:L,onSend:al,onCancelEdit:vo,onStop:M,allowEmptySend:we.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${V?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ee?"border-red-400":""} ${h.textarea||""}`})})]})]})]})}var yh=1,gC=.9,xC=.8,vC=.17,Ba=.1,za=.999,wC=.9999,bC=.99,yC=/[\\\/_+.#"@\[\(\{&]/,SC=/[\\\/_+.#"@\[\(\{&]/g,CC=/[\s-]/,Sh=/[\s-]/g;function Ha(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?yh:bC;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,m,w;u>=0;)f=Ha(e,t,n,r,u+1,s+1,i),f>d&&(u===o?f*=yh:yC.test(e.charAt(u-1))?(f*=xC,m=e.slice(o,u-1).match(SC),m&&o>0&&(f*=Math.pow(za,m.length))):CC.test(e.charAt(u-1))?(f*=gC,w=e.slice(o,u-1).match(Sh),w&&o>0&&(f*=Math.pow(za,w.length))):(f*=vC,o>0&&(f*=Math.pow(za,u-o))),e.charAt(u)!==t.charAt(s)&&(f*=wC)),(f<Ba&&n.charAt(u-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(u-1)!==r.charAt(s))&&(h=Ha(e,t,n,r,u+1,s+2,i),h*Ba>f&&(f=h*Ba)),f>d&&(d=f),u=n.indexOf(l,u+1);return i[a]=d,d}function Ch(e){return e.toLowerCase().replace(Sh," ")}function kC(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Ha(e,t,Ch(e),Ch(t),0,0,{})}var ho='[cmdk-group=""]',Ua='[cmdk-group-items=""]',TC='[cmdk-group-heading=""]',kh='[cmdk-item=""]',Th=`${kh}:not([aria-disabled="true"])`,Wa="cmdk-item-select",kr="data-value",EC=(e,t,n)=>kC(e,t,n),Eh=p.createContext(void 0),po=()=>p.useContext(Eh),Ih=p.createContext(void 0),Va=()=>p.useContext(Ih),Nh=p.createContext(void 0),Ah=p.forwardRef((e,t)=>{let n=Tr(()=>{var P,B;return{search:"",value:(B=(P=e.value)!=null?P:e.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Tr(()=>new Set),o=Tr(()=>new Map),s=Tr(()=>new Map),i=Tr(()=>new Set),a=jh(e),{label:l,children:u,value:d,onValueChange:f,filter:h,shouldFilter:m,loop:w,disablePointerSelection:v=!1,vimBindings:g=!0,...x}=e,b=Rt(),S=Rt(),T=Rt(),C=p.useRef(null),k=LC();nr(()=>{if(d!==void 0){let P=d.trim();n.current.value=P,E.emit()}},[d]),nr(()=>{k(6,K)},[]);let E=p.useMemo(()=>({subscribe:P=>(i.current.add(P),()=>i.current.delete(P)),snapshot:()=>n.current,setState:(P,B,te)=>{var J,re,G,L;if(!Object.is(n.current[P],B)){if(n.current[P]=B,P==="search")U(),$(),k(1,H);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let V=document.getElementById(T);V?V.focus():(J=document.getElementById(b))==null||J.focus()}if(k(7,()=>{var V;n.current.selectedItemId=(V=R())==null?void 0:V.id,E.emit()}),te||k(5,K),((re=a.current)==null?void 0:re.value)!==void 0){let V=B??"";(L=(G=a.current).onValueChange)==null||L.call(G,V);return}}E.emit()}},emit:()=>{i.current.forEach(P=>P())}}),[]),A=p.useMemo(()=>({value:(P,B,te)=>{var J;B!==((J=s.current.get(P))==null?void 0:J.value)&&(s.current.set(P,{value:B,keywords:te}),n.current.filtered.items.set(P,O(B,te)),k(2,()=>{$(),E.emit()}))},item:(P,B)=>(r.current.add(P),B&&(o.current.has(B)?o.current.get(B).add(P):o.current.set(B,new Set([P]))),k(3,()=>{U(),$(),n.current.value||H(),E.emit()}),()=>{s.current.delete(P),r.current.delete(P),n.current.filtered.items.delete(P);let te=R();k(4,()=>{U(),(te==null?void 0:te.getAttribute("id"))===P&&H(),E.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:T,labelId:S,listInnerRef:C}),[]);function O(P,B){var te,J;let re=(J=(te=a.current)==null?void 0:te.filter)!=null?J:EC;return P?re(P,n.current.search,B):0}function $(){if(!n.current.search||a.current.shouldFilter===!1)return;let P=n.current.filtered.items,B=[];n.current.filtered.groups.forEach(J=>{let re=o.current.get(J),G=0;re.forEach(L=>{let V=P.get(L);G=Math.max(V,G)}),B.push([J,G])});let te=C.current;Y().sort((J,re)=>{var G,L;let V=J.getAttribute("id"),Z=re.getAttribute("id");return((G=P.get(Z))!=null?G:0)-((L=P.get(V))!=null?L:0)}).forEach(J=>{let re=J.closest(Ua);re?re.appendChild(J.parentElement===re?J:J.closest(`${Ua} > *`)):te.appendChild(J.parentElement===te?J:J.closest(`${Ua} > *`))}),B.sort((J,re)=>re[1]-J[1]).forEach(J=>{var re;let G=(re=C.current)==null?void 0:re.querySelector(`${ho}[${kr}="${encodeURIComponent(J[0])}"]`);G==null||G.parentElement.appendChild(G)})}function H(){let P=Y().find(te=>te.getAttribute("aria-disabled")!=="true"),B=P==null?void 0:P.getAttribute(kr);E.setState("value",B||void 0)}function U(){var P,B,te,J;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let re=0;for(let G of r.current){let L=(B=(P=s.current.get(G))==null?void 0:P.value)!=null?B:"",V=(J=(te=s.current.get(G))==null?void 0:te.keywords)!=null?J:[],Z=O(L,V);n.current.filtered.items.set(G,Z),Z>0&&re++}for(let[G,L]of o.current)for(let V of L)if(n.current.filtered.items.get(V)>0){n.current.filtered.groups.add(G);break}n.current.filtered.count=re}function K(){var P,B,te;let J=R();J&&(((P=J.parentElement)==null?void 0:P.firstChild)===J&&((te=(B=J.closest(ho))==null?void 0:B.querySelector(TC))==null||te.scrollIntoView({block:"nearest"})),J.scrollIntoView({block:"nearest"}))}function R(){var P;return(P=C.current)==null?void 0:P.querySelector(`${kh}[aria-selected="true"]`)}function Y(){var P;return Array.from(((P=C.current)==null?void 0:P.querySelectorAll(Th))||[])}function N(P){let B=Y()[P];B&&E.setState("value",B.getAttribute(kr))}function D(P){var B;let te=R(),J=Y(),re=J.findIndex(L=>L===te),G=J[re+P];(B=a.current)!=null&&B.loop&&(G=re+P<0?J[J.length-1]:re+P===J.length?J[0]:J[re+P]),G&&E.setState("value",G.getAttribute(kr))}function M(P){let B=R(),te=B==null?void 0:B.closest(ho),J;for(;te&&!J;)te=P>0?OC(te,ho):DC(te,ho),J=te==null?void 0:te.querySelector(Th);J?E.setState("value",J.getAttribute(kr)):D(P)}let j=()=>N(Y().length-1),z=P=>{P.preventDefault(),P.metaKey?j():P.altKey?M(1):D(1)},W=P=>{P.preventDefault(),P.metaKey?N(0):P.altKey?M(-1):D(-1)};return p.createElement(ye.div,{ref:t,tabIndex:-1,...x,"cmdk-root":"",onKeyDown:P=>{var B;(B=x.onKeyDown)==null||B.call(x,P);let te=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||te))switch(P.key){case"n":case"j":{g&&P.ctrlKey&&z(P);break}case"ArrowDown":{z(P);break}case"p":case"k":{g&&P.ctrlKey&&W(P);break}case"ArrowUp":{W(P);break}case"Home":{P.preventDefault(),N(0);break}case"End":{P.preventDefault(),j();break}case"Enter":{P.preventDefault();let J=R();if(J){let re=new Event(Wa);J.dispatchEvent(re)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:FC},l),Fs(e,P=>p.createElement(Ih.Provider,{value:E},p.createElement(Eh.Provider,{value:A},P))))}),IC=p.forwardRef((e,t)=>{var n,r;let o=Rt(),s=p.useRef(null),i=p.useContext(Nh),a=po(),l=jh(e),u=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;nr(()=>{if(!u)return a.item(o,i==null?void 0:i.id)},[u]);let d=_h(o,s,[e.value,e.children,s],e.keywords),f=Va(),h=Dn(k=>k.value&&k.value===d.current),m=Dn(k=>u||a.filter()===!1?!0:k.search?k.filtered.items.get(o)>0:!0);p.useEffect(()=>{let k=s.current;if(!(!k||e.disabled))return k.addEventListener(Wa,w),()=>k.removeEventListener(Wa,w)},[m,e.onSelect,e.disabled]);function w(){var k,E;v(),(E=(k=l.current).onSelect)==null||E.call(k,d.current)}function v(){f.setState("value",d.current,!0)}if(!m)return null;let{disabled:g,value:x,onSelect:b,forceMount:S,keywords:T,...C}=e;return p.createElement(ye.div,{ref:En(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:v,onClick:g?void 0:w},e.children)}),NC=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Rt(),a=p.useRef(null),l=p.useRef(null),u=Rt(),d=po(),f=Dn(m=>o||d.filter()===!1?!0:m.search?m.filtered.groups.has(i):!0);nr(()=>d.group(i),[]),_h(i,a,[e.value,e.heading,l]);let h=p.useMemo(()=>({id:i,forceMount:o}),[o]);return p.createElement(ye.div,{ref:En(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&p.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:u},n),Fs(e,m=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?u:void 0},p.createElement(Nh.Provider,{value:h},m))))}),AC=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=Dn(i=>!i.search);return!n&&!s?null:p.createElement(ye.div,{ref:En(o,t),...r,"cmdk-separator":"",role:"separator"})}),jC=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Va(),i=Dn(u=>u.search),a=Dn(u=>u.selectedItemId),l=po();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.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:u=>{o||s.setState("search",u.target.value),n==null||n(u.target.value)}})}),_C=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=Dn(u=>u.selectedItemId),l=po();return p.useEffect(()=>{if(i.current&&s.current){let u=i.current,d=s.current,f,h=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let m=u.offsetHeight;d.style.setProperty("--cmdk-list-height",m.toFixed(1)+"px")})});return h.observe(u),()=>{cancelAnimationFrame(f),h.unobserve(u)}}},[]),p.createElement(ye.div,{ref:En(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Fs(e,u=>p.createElement("div",{ref:En(i,l.listInnerRef),"cmdk-list-sizer":""},u)))}),MC=p.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return p.createElement(Aa,{open:n,onOpenChange:r},p.createElement(ja,{container:i},p.createElement(so,{"cmdk-overlay":"",className:o}),p.createElement(io,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(Ah,{ref:t,...a}))))}),PC=p.forwardRef((e,t)=>Dn(n=>n.filtered.count===0)?p.createElement(ye.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),RC=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(ye.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Fs(e,i=>p.createElement("div",{"aria-hidden":!0},i)))}),zt=Object.assign(Ah,{List:_C,Item:IC,Input:jC,Group:NC,Separator:AC,Dialog:MC,Empty:PC,Loading:RC});function OC(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function DC(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function jh(e){let t=p.useRef(e);return nr(()=>{t.current=e}),t}var nr=typeof window>"u"?p.useEffect:p.useLayoutEffect;function Tr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function Dn(e){let t=Va(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function _h(e,t,n,r=[]){let o=p.useRef(),s=po();return nr(()=>{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(kr,a),o.current=a}),o}var LC=()=>{let[e,t]=p.useState(),n=Tr(()=>new Map);return nr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function $C(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Fs({asChild:e,children:t},n){return e&&p.isValidElement(t)?p.cloneElement($C(t),{ref:t.ref},n(t.props.children)):n(t)}var FC={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Mh=p.forwardRef(({className:e,...t},n)=>c.jsx(zt,{ref:n,className:oe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Mh.displayName=zt.displayName;const Ph=p.forwardRef(({className:e,...t},n)=>c.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[c.jsx(ae.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),c.jsx(zt.Input,{ref:n,className:oe("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=zt.Input.displayName;const Rh=p.forwardRef(({className:e,...t},n)=>c.jsx(zt.List,{ref:n,className:oe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Rh.displayName=zt.List.displayName;const Oh=p.forwardRef((e,t)=>c.jsx(zt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Oh.displayName=zt.Empty.displayName;const Dh=p.forwardRef(({className:e,...t},n)=>c.jsx(zt.Group,{ref:n,className:oe("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}));Dh.displayName=zt.Group.displayName;const BC=p.forwardRef(({className:e,...t},n)=>c.jsx(zt.Separator,{ref:n,className:oe("-mx-1 h-px bg-border",e),...t}));BC.displayName=zt.Separator.displayName;const Lh=p.forwardRef(({className:e,...t},n)=>c.jsx(zt.Item,{ref:n,className:oe("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}));Lh.displayName=zt.Item.displayName;function Ka(e,[t,n]){return Math.min(n,Math.max(t,e))}function zC(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var qa="ScrollArea",[$h,FT]=yn(qa),[HC,en]=$h(qa),Fh=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=p.useState(null),[u,d]=p.useState(null),[f,h]=p.useState(null),[m,w]=p.useState(null),[v,g]=p.useState(null),[x,b]=p.useState(0),[S,T]=p.useState(0),[C,k]=p.useState(!1),[E,A]=p.useState(!1),O=ze(t,H=>l(H)),$=Fo(o);return c.jsx(HC,{scope:n,type:r,dir:$,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:m,onScrollbarXChange:w,scrollbarXEnabled:C,onScrollbarXEnabledChange:k,scrollbarY:v,onScrollbarYChange:g,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:T,children:c.jsx(ye.div,{dir:$,...i,ref:O,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Fh.displayName=qa;var Bh="ScrollAreaViewport",zh=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=en(Bh,n),a=p.useRef(null),l=ze(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(ye.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})})]})});zh.displayName=Bh;var wn="ScrollAreaScrollbar",Ga=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=en(wn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(UC,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(WC,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(Hh,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(Ya,{...r,ref:t}):null});Ga.displayName=wn;var UC=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=en(wn,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.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(Xt,{present:n||s,children:c.jsx(Hh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),WC=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=en(wn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Us(()=>l("SCROLL_END"),100),[a,l]=zC("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 p.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),p.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const m=u[d];f!==m&&(l("SCROLL"),i()),f=m};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(Xt,{present:n||a!=="hidden",children:c.jsx(Ya,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:me(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:me(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Hh=p.forwardRef((e,t)=>{const n=en(wn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",l=Us(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return Er(n.viewport,l),Er(n.content,l),c.jsx(Xt,{present:r||s,children:c.jsx(Ya,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ya=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=en(wn,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,l]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=qh(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,m){return XC(h,i.current,a,m)}return n==="horizontal"?c.jsx(VC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,m=Gh(h,a,o.dir);s.current.style.transform=`translate3d(${m}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(KC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,m=Gh(h,a);s.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),VC=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=en(wn,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),u=ze(t,l,s.onScrollbarXChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Wh,{"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":Hs(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),Xh(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:zs(i.paddingLeft),paddingEnd:zs(i.paddingRight)}})}})}),KC=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=en(wn,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),u=ze(t,l,s.onScrollbarYChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Wh,{"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":Hs(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),Xh(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:zs(i.paddingTop),paddingEnd:zs(i.paddingBottom)}})}})}),[qC,Uh]=$h(wn),Wh=p.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,m=en(wn,n),[w,v]=p.useState(null),g=ze(t,O=>v(O)),x=p.useRef(null),b=p.useRef(""),S=m.viewport,T=r.content-r.viewport,C=It(d),k=It(l),E=Us(f,10);function A(O){if(x.current){const $=O.clientX-x.current.left,H=O.clientY-x.current.top;u({x:$,y:H})}}return p.useEffect(()=>{const O=$=>{const H=$.target;(w==null?void 0:w.contains(H))&&C($,T)};return document.addEventListener("wheel",O,{passive:!1}),()=>document.removeEventListener("wheel",O,{passive:!1})},[S,w,T,C]),p.useEffect(k,[r,k]),Er(w,E),Er(m.content,E),c.jsx(qC,{scope:n,scrollbar:w,hasThumb:o,onThumbChange:It(s),onThumbPointerUp:It(i),onThumbPositionChange:k,onThumbPointerDown:It(a),children:c.jsx(ye.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:me(e.onPointerDown,O=>{O.button===0&&(O.target.setPointerCapture(O.pointerId),x.current=w.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),A(O))}),onPointerMove:me(e.onPointerMove,A),onPointerUp:me(e.onPointerUp,O=>{const $=O.target;$.hasPointerCapture(O.pointerId)&&$.releasePointerCapture(O.pointerId),document.body.style.webkitUserSelect=b.current,m.viewport&&(m.viewport.style.scrollBehavior=""),x.current=null})})})}),Bs="ScrollAreaThumb",Vh=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Uh(Bs,e.__scopeScrollArea);return c.jsx(Xt,{present:n||o.hasThumb,children:c.jsx(GC,{ref:t,...r})})}),GC=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=en(Bs,n),i=Uh(Bs,n),{onThumbPositionChange:a}=i,l=ze(t,f=>i.onThumbChange(f)),u=p.useRef(void 0),d=Us(()=>{u.current&&(u.current(),u.current=void 0)},100);return p.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const m=JC(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.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:me(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),w=f.clientX-m.left,v=f.clientY-m.top;i.onThumbPointerDown({x:w,y:v})}),onPointerUp:me(e.onPointerUp,i.onThumbPointerUp)})});Vh.displayName=Bs;var Xa="ScrollAreaCorner",Kh=p.forwardRef((e,t)=>{const n=en(Xa,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(YC,{...e,ref:t}):null});Kh.displayName=Xa;var YC=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=en(Xa,n),[s,i]=p.useState(0),[a,l]=p.useState(0),u=!!(s&&a);return Er(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Er(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.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 zs(e){return e?parseInt(e,10):0}function qh(e,t){const n=e/t;return isNaN(n)?0:n}function Hs(e){const t=qh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function XC(e,t,n,r="ltr"){const o=Hs(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 Yh([l,u],f)(e)}function Gh(e,t,n="ltr"){const r=Hs(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=Ka(e,l);return Yh([0,i],[0,a])(u)}function Yh(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 Xh(e,t){return e>0&&e<t}var JC=(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 Us(e,t){const n=It(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Er(e,t){const n=It(t);Et(()=>{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 Jh=Fh,ZC=zh,QC=Kh;const Zh=p.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Jh,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[c.jsx(ZC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(Qh,{}),c.jsx(QC,{})]}));Zh.displayName=Jh.displayName;const Qh=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Ga,{ref:r,orientation:t,className:oe("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(Vh,{className:"relative flex-1 rounded-full bg-border"})}));Qh.displayName=Ga.displayName;const Ws=p.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:oe("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}));Ws.displayName="Input";const ek="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",tk="bg-slate-700 border-slate-600 hover:bg-slate-600",nk="bg-slate-600 border-slate-500";function rk({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:m,getDisplayThreadTitle:w,secondaryLine:v,itemClassName:g,activeItemClassName:x}){const b=n===e.threadId,S=t?`${x??nk}`:`${g??tk}`,T=C=>{C.stopPropagation(),o(e.threadId)};return c.jsxs("div",{onClick:T,className:`${ek} ${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(Ws,{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(Qe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:c.jsx(ae.Check,{size:12})}),c.jsx(Qe,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:c.jsx(ae.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:w(e)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(ae.Calendar,{size:10}),c.jsx("span",{children:m(e.updatedAt||e.createdAt)})]}),v&&c.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:v})]})}),c.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:c.jsxs(ta,{children:[c.jsx(na,{asChild:!0,children:c.jsx(Qe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:c.jsx(ae.MoreHorizontal,{size:12})})}),c.jsxs(ps,{align:"end",sideOffset:6,className:"w-44",children:[c.jsxs(Gn,{onClick:C=>{C.preventDefault(),u(e.threadId)},children:[c.jsx(ae.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&n!==e.threadId&&c.jsxs(Gn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[c.jsx(ae.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),h&&d&&c.jsxs(Gn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[c.jsx(ae.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 ep=25,tp="thread-manager-view",ok=e=>e==="default"||e==="shared",sk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(tp);if(ok(e))return e}catch{}return null};function ik({defaultView:e}={}){const[t,n]=y.useState(()=>sk()??e??"default");y.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(tp,t)}catch{}},[t]);const r=y.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const ak=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function Ja({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:m,viewOptions:w,viewState:v,showHeader:g=!0,shareTargets:x,isLoadingShareTargets:b,shareTargetFilter:S}){const{threads:T,sharedThreads:C,currentThreadId:k,setCurrentThreadId:E,isLoading:A,isLoadingSharedThreads:O,actions:$,shareInFlight:H,shareStatus:U,clearShareStatus:K}=Do(),{createThread:R,deleteThread:Y,renameThread:N,shareThread:D}=$,{loadThread:M}=Lo(),j=i??k,[z,W]=y.useState(Array.isArray(T)?T:[]),P=y.useRef(z.length>0),B=y.useRef(null),te=y.useRef(0),[J,re]=y.useState(null),[G,L]=y.useState(""),[V,Z]=y.useState(!1),[q,X]=y.useState(!1),[pe,he]=y.useState(null),[ee,le]=y.useState(""),we=w&&w.length>0?w:ak,je=ik({defaultView:h}),Ne=v??je,$e=f??Ne.view,Ye=y.useCallback(_=>{f||Ne.setView(_),m==null||m(_)},[f,m,Ne]),nt=we.find(_=>_.key===$e)??we[0],Ve=_=>{he(_),le(""),X(!0)},qe=()=>{X(!1),he(null),le(""),K()},rt=y.useCallback(async _=>{if(!(!pe||H)&&_.id)try{await D(pe,_.id),setTimeout(()=>qe(),600)}catch(ie){console.error("Failed to share thread:",ie)}},[qe,H,pe,D]),kt=y.useMemo(()=>{const _=x??[],ie=ee.trim().toLowerCase();return ie?S?_.filter(ge=>S(ge,ie)):_.filter(ge=>`${ge.label} ${ge.secondaryLabel??""}`.toLowerCase().includes(ie)):_},[x,ee,S]),at=$e==="shared",ke=at?C:z,Oe=at?O:A,it=at?"No shared conversations yet":"No conversations yet",ht=_=>{const ie=_.sharedAt?` • ${vt(_.sharedAt)}`:"";return`Shared by ${_.sharedByUserId}${ie}`},Tt=_=>"sharedByUserId"in _;y.useEffect(()=>{const _=Array.isArray(T)?T:[];if(_.length>0){P.current=!0,W(_);return}A||(P.current=!1,W(_))},[T,A]),y.useEffect(()=>{if(!B.current)return;const _=B.current.querySelector("[data-radix-scroll-area-viewport]");if(!_)return;let ie=null,ge=null;return ie=requestAnimationFrame(()=>{ge=requestAnimationFrame(()=>{_.scrollTop=te.current})}),()=>{ie!==null&&cancelAnimationFrame(ie),ge!==null&&cancelAnimationFrame(ge)}},[z]);const yt=async _=>{try{E(_),await M(_),a==null||a(_),l==null||l(_)}catch(ie){console.error("Failed to select thread:",ie)}},Le=async()=>{try{Z(!0);const _=await R();_&&(u==null||u(_),a==null||a(_))}catch(_){console.error("Failed to create thread:",_)}finally{Z(!1)}},Ht=async(_,ie)=>{if(ie.stopPropagation(),!!confirm("Delete this thread?")){if(B.current){const ge=B.current.querySelector("[data-radix-scroll-area-viewport]");ge&&(te.current=ge.scrollTop)}try{await Y(_),d==null||d(_)}catch(ge){console.error("Failed to delete thread:",ge)}}},Xe=(_,ie)=>{ie.stopPropagation(),re(_.threadId),L(_.title||`Thread ${_.threadId.slice(0,8)}`)},Ke=async _=>{if(G.trim())try{await N(_,G.trim()),re(null),L("")}catch(ie){console.error("Failed to update title:",ie)}},dt=()=>{re(null),L("")},vt=_=>{if(!_)return"";try{const ie=new Date(_),We=new Date().getTime()-ie.getTime(),Re=Math.floor(We/(1e3*60*60*24));return Re===0?ie.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Re===1?"Yesterday":Re<7?`${Re} days ago`:ie.toLocaleDateString()}catch{return""}},Ue=_=>_.title||`Thread ${_.threadId.slice(0,8)}`,St=_=>{const ie=Ue(_);return ie.length<=ep?ie:`${ie.slice(0,ep)}...`};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(Qe,{onClick:Le,disabled:V||A,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:V?"Creating...":"New Chat",children:[c.jsx(ae.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(ta,{children:[c.jsx(na,{asChild:!0,children:c.jsx(Qe,{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:nt.label})}),c.jsx(ps,{align:"start",sideOffset:6,className:"w-40",children:we.map(_=>c.jsxs(Gn,{className:"justify-between text-[12px]",onClick:ie=>{ie.preventDefault(),Ye(_.key)},children:[c.jsx("span",{children:_.label}),$e===_.key&&c.jsx(ae.Check,{className:"h-3 w-3"})]},_.key))})]})]})]}),c.jsx(Zh,{ref:B,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:Oe?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(ae.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):ke.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(ae.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:it})]}):ke.slice().sort((_,ie)=>new Date(ie.updatedAt||ie.createdAt||"").getTime()-new Date(_.updatedAt||_.createdAt||"").getTime()).map(_=>c.jsx(rk,{thread:_,isActive:j===_.threadId,editingThreadId:J,editingTitle:G,onSelect:yt,onStartEditing:Xe,onEditingTitleChange:ie=>L(ie),onSaveEditing:Ke,onCancelEditing:dt,onShare:()=>Ve(_.threadId),onDelete:Ht,showEditTitle:r,showDeleteButton:n,formatDate:vt,getDisplayThreadTitle:St,secondaryLine:at&&Tt(_)?ht(_):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},_.threadId))})}),c.jsx(Zf,{open:q,onOpenChange:_=>!_&&qe(),children:c.jsxs(_a,{className:"max-w-md p-0",children:[c.jsx(Ma,{children:c.jsx(Pa,{children:"Share thread"})}),c.jsxs(Mh,{children:[c.jsx(Ph,{autoFocus:!0,value:ee,onValueChange:_=>le(_),placeholder:"Search for recipients..."}),c.jsxs(Rh,{children:[U&&c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[H&&c.jsx(ae.Loader2,{className:"h-3 w-3 animate-spin"}),c.jsx("span",{className:U.startsWith("Failed")?"text-red-500":U.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:U})]}),c.jsx(Oh,{children:b?c.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ae.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),kt.length>0&&c.jsx(Dh,{heading:"Recipients",children:kt.map(_=>c.jsx(Lh,{onSelect:()=>rt(_),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 Ir(e){if(!(typeof globalThis>"u"))return globalThis[e]}function lk(e){if(typeof e!="string")return;const t=e.trim();if(t)return bn(t)}function np(){const e=[Ir("__API_BASE_URL__"),Ir("__CHAT_API_BASE_URL__"),Ir("__CHAT_API_URL__")];for(const t of e){const n=lk(t);if(n)return n}}function rp(){const e=[Ir("__API_AUTH_TOKEN__"),Ir("__CHAT_API_KEY__"),Ir("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function op(...e){for(const t of e)if(typeof t=="string"&&t.trim())return bn(t);return bn()}function sp(){const e={},t=np(),n=rp();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function ip(){const e=sp(),t=Tn.getAuthToken(),n=np();return{apiBaseUrl:op(e.baseUrl,Tn.baseUrl,n),apiKey:t||e.apiKey||rp()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const ap="chat-settings";function ck(){try{const e=localStorage.getItem(ap);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function uk(e){try{const t={...e,apiBaseUrl:bn(e.apiBaseUrl)};localStorage.setItem(ap,JSON.stringify(t)),t.apiKey&&Tn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function dk(){const e=ip(),t=ck(),n=Tn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:op(Tn.baseUrl,r,e.apiBaseUrl)}}function fk(e){Tn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),uk(e)}var hk="Label",lp=p.forwardRef((e,t)=>c.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())}}));lp.displayName=hk;var cp=lp;const pk=wo.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),tn=p.forwardRef(({className:e,...t},n)=>c.jsx(cp,{ref:n,className:oe(pk(),e),...t}));tn.displayName=cp.displayName;function up(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var dp=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"}),mk="VisuallyHidden",gk=p.forwardRef((e,t)=>c.jsx(ye.span,{...e,ref:t,style:{...dp,...e.style}}));gk.displayName=mk;var xk=[" ","Enter","ArrowUp","ArrowDown"],vk=[" ","Enter"],rr="Select",[Vs,Ks,wk]=bi(rr),[Nr,BT]=yn(rr,[wk,Zo]),qs=Zo(),[bk,Ln]=Nr(rr),[yk,Sk]=Nr(rr),fp=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:m,form:w}=e,v=qs(t),[g,x]=p.useState(null),[b,S]=p.useState(null),[T,C]=p.useState(!1),k=Fo(u),[E,A]=dr({prop:r,defaultProp:o??!1,onChange:s,caller:rr}),[O,$]=dr({prop:i,defaultProp:a,onChange:l,caller:rr}),H=p.useRef(null),U=g?w||!!g.closest("form"):!0,[K,R]=p.useState(new Set),Y=Array.from(K).map(N=>N.props.value).join(";");return c.jsx(gu,{...v,children:c.jsxs(bk,{required:m,scope:t,trigger:g,onTriggerChange:x,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:T,onValueNodeHasChildrenChange:C,contentId:Rt(),value:O,onValueChange:$,open:E,onOpenChange:A,dir:k,triggerPointerDownPosRef:H,disabled:h,children:[c.jsx(Vs.Provider,{scope:t,children:c.jsx(yk,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(N=>{R(D=>new Set(D).add(N))},[]),onNativeOptionRemove:p.useCallback(N=>{R(D=>{const M=new Set(D);return M.delete(N),M})},[]),children:n})}),U?c.jsxs(Dp,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:O,onChange:N=>$(N.target.value),disabled:h,form:w,children:[O===void 0?c.jsx("option",{value:""}):null,Array.from(K)]},Y):null]})})};fp.displayName=rr;var hp="SelectTrigger",pp=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=qs(n),i=Ln(hp,n),a=i.disabled||r,l=ze(t,i.onTriggerChange),u=Ks(n),d=p.useRef("touch"),[f,h,m]=$p(v=>{const g=u().filter(S=>!S.disabled),x=g.find(S=>S.value===i.value),b=Fp(g,v,x);b!==void 0&&i.onValueChange(b.value)}),w=v=>{a||(i.onOpenChange(!0),m()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return c.jsx(xu,{asChild:!0,...s,children:c.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":Lp(i.value)?"":void 0,...o,ref:l,onClick:me(o.onClick,v=>{v.currentTarget.focus(),d.current!=="mouse"&&w(v)}),onPointerDown:me(o.onPointerDown,v=>{d.current=v.pointerType;const g=v.target;g.hasPointerCapture(v.pointerId)&&g.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(w(v),v.preventDefault())}),onKeyDown:me(o.onKeyDown,v=>{const g=f.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&h(v.key),!(g&&v.key===" ")&&xk.includes(v.key)&&(w(),v.preventDefault())})})})});pp.displayName=hp;var mp="SelectValue",gp=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Ln(mp,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=ze(t,l.onValueNodeChange);return Et(()=>{u(d)},[u,d]),c.jsx(ye.span,{...a,ref:f,style:{pointerEvents:"none"},children:Lp(l.value)?c.jsx(c.Fragment,{children:i}):s})});gp.displayName=mp;var Ck="SelectIcon",xp=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(ye.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});xp.displayName=Ck;var kk="SelectPortal",vp=e=>c.jsx(Qo,{asChild:!0,...e});vp.displayName=kk;var or="SelectContent",wp=p.forwardRef((e,t)=>{const n=Ln(or,e.__scopeSelect),[r,o]=p.useState();if(Et(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?bo.createPortal(c.jsx(bp,{scope:e.__scopeSelect,children:c.jsx(Vs.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(yp,{...e,ref:t})});wp.displayName=or;var cn=10,[bp,$n]=Nr(or),Tk="SelectContentImpl",Ek=Bn.createSlot("SelectContent.RemoveScroll"),yp=p.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:m,sticky:w,hideWhenDetached:v,avoidCollisions:g,...x}=e,b=Ln(or,n),[S,T]=p.useState(null),[C,k]=p.useState(null),E=ze(t,G=>T(G)),[A,O]=p.useState(null),[$,H]=p.useState(null),U=Ks(n),[K,R]=p.useState(!1),Y=p.useRef(!1);p.useEffect(()=>{if(S)return Hi(S)},[S]),Ci();const N=p.useCallback(G=>{const[L,...V]=U().map(X=>X.ref.current),[Z]=V.slice(-1),q=document.activeElement;for(const X of G)if(X===q||(X==null||X.scrollIntoView({block:"nearest"}),X===L&&C&&(C.scrollTop=0),X===Z&&C&&(C.scrollTop=C.scrollHeight),X==null||X.focus(),document.activeElement!==q))return},[U,C]),D=p.useCallback(()=>N([A,S]),[N,A,S]);p.useEffect(()=>{K&&D()},[K,D]);const{onOpenChange:M,triggerPointerDownPosRef:j}=b;p.useEffect(()=>{if(S){let G={x:0,y:0};const L=Z=>{var q,X;G={x:Math.abs(Math.round(Z.pageX)-(((q=j.current)==null?void 0:q.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((X=j.current)==null?void 0:X.y)??0))}},V=Z=>{G.x<=10&&G.y<=10?Z.preventDefault():S.contains(Z.target)||M(!1),document.removeEventListener("pointermove",L),j.current=null};return j.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",V,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",V,{capture:!0})}}},[S,M,j]),p.useEffect(()=>{const G=()=>M(!1);return window.addEventListener("blur",G),window.addEventListener("resize",G),()=>{window.removeEventListener("blur",G),window.removeEventListener("resize",G)}},[M]);const[z,W]=$p(G=>{const L=U().filter(q=>!q.disabled),V=L.find(q=>q.ref.current===document.activeElement),Z=Fp(L,G,V);Z&&setTimeout(()=>Z.ref.current.focus())}),P=p.useCallback((G,L,V)=>{const Z=!Y.current&&!V;(b.value!==void 0&&b.value===L||Z)&&(O(G),Z&&(Y.current=!0))},[b.value]),B=p.useCallback(()=>S==null?void 0:S.focus(),[S]),te=p.useCallback((G,L,V)=>{const Z=!Y.current&&!V;(b.value!==void 0&&b.value===L||Z)&&H(G)},[b.value]),J=r==="popper"?Za:Sp,re=J===Za?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:w,hideWhenDetached:v,avoidCollisions:g}:{};return c.jsx(bp,{scope:n,content:S,viewport:C,onViewportChange:k,itemRefCallback:P,selectedItem:A,onItemLeave:B,itemTextRefCallback:te,focusSelectedItem:D,selectedItemText:$,position:r,isPositioned:K,searchRef:z,children:c.jsx(ls,{as:Ek,allowPinchZoom:!0,children:c.jsx(zo,{asChild:!0,trapped:b.open,onMountAutoFocus:G=>{G.preventDefault()},onUnmountAutoFocus:me(o,G=>{var L;(L=b.trigger)==null||L.focus({preventScroll:!0}),G.preventDefault()}),children:c.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:G=>G.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(J,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:G=>G.preventDefault(),...x,...re,onPlaced:()=>R(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:me(x.onKeyDown,G=>{const L=G.ctrlKey||G.altKey||G.metaKey;if(G.key==="Tab"&&G.preventDefault(),!L&&G.key.length===1&&W(G.key),["ArrowUp","ArrowDown","Home","End"].includes(G.key)){let Z=U().filter(q=>!q.disabled).map(q=>q.ref.current);if(["ArrowUp","End"].includes(G.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(G.key)){const q=G.target,X=Z.indexOf(q);Z=Z.slice(X+1)}setTimeout(()=>N(Z)),G.preventDefault()}})})})})})})});yp.displayName=Tk;var Ik="SelectItemAlignedPosition",Sp=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Ln(or,n),i=$n(or,n),[a,l]=p.useState(null),[u,d]=p.useState(null),f=ze(t,E=>d(E)),h=Ks(n),m=p.useRef(!1),w=p.useRef(!0),{viewport:v,selectedItem:g,selectedItemText:x,focusSelectedItem:b}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&v&&g&&x){const E=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),O=s.valueNode.getBoundingClientRect(),$=x.getBoundingClientRect();if(s.dir!=="rtl"){const q=$.left-A.left,X=O.left-q,pe=E.left-X,he=E.width+pe,ee=Math.max(he,A.width),le=window.innerWidth-cn,we=Ka(X,[cn,Math.max(cn,le-ee)]);a.style.minWidth=he+"px",a.style.left=we+"px"}else{const q=A.right-$.right,X=window.innerWidth-O.right-q,pe=window.innerWidth-E.right-X,he=E.width+pe,ee=Math.max(he,A.width),le=window.innerWidth-cn,we=Ka(X,[cn,Math.max(cn,le-ee)]);a.style.minWidth=he+"px",a.style.right=we+"px"}const H=h(),U=window.innerHeight-cn*2,K=v.scrollHeight,R=window.getComputedStyle(u),Y=parseInt(R.borderTopWidth,10),N=parseInt(R.paddingTop,10),D=parseInt(R.borderBottomWidth,10),M=parseInt(R.paddingBottom,10),j=Y+N+K+M+D,z=Math.min(g.offsetHeight*5,j),W=window.getComputedStyle(v),P=parseInt(W.paddingTop,10),B=parseInt(W.paddingBottom,10),te=E.top+E.height/2-cn,J=U-te,re=g.offsetHeight/2,G=g.offsetTop+re,L=Y+N+G,V=j-L;if(L<=te){const q=H.length>0&&g===H[H.length-1].ref.current;a.style.bottom="0px";const X=u.clientHeight-v.offsetTop-v.offsetHeight,pe=Math.max(J,re+(q?B:0)+X+D),he=L+pe;a.style.height=he+"px"}else{const q=H.length>0&&g===H[0].ref.current;a.style.top="0px";const pe=Math.max(te,Y+v.offsetTop+(q?P:0)+re)+V;a.style.height=pe+"px",v.scrollTop=L-te+v.offsetTop}a.style.margin=`${cn}px 0`,a.style.minHeight=z+"px",a.style.maxHeight=U+"px",r==null||r(),requestAnimationFrame(()=>m.current=!0)}},[h,s.trigger,s.valueNode,a,u,v,g,x,s.dir,r]);Et(()=>S(),[S]);const[T,C]=p.useState();Et(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const k=p.useCallback(E=>{E&&w.current===!0&&(S(),b==null||b(),w.current=!1)},[S,b]);return c.jsx(Ak,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:k,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:T},children:c.jsx(ye.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Sp.displayName=Ik;var Nk="SelectPopperPosition",Za=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=cn,...s}=e,i=qs(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)"}})});Za.displayName=Nk;var[Ak,Qa]=Nr(or,{}),el="SelectViewport",Cp=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=$n(el,n),i=Qa(el,n),a=ze(t,s.onViewportChange),l=p.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(Vs.Slot,{scope:n,children:c.jsx(ye.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:me(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const m=Math.abs(l.current-d.scrollTop);if(m>0){const w=window.innerHeight-cn*2,v=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(v,g);if(x<w){const b=x+m,S=Math.min(w,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})})})]})});Cp.displayName=el;var kp="SelectGroup",[jk,_k]=Nr(kp),Mk=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Rt();return c.jsx(jk,{scope:n,id:o,children:c.jsx(ye.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Mk.displayName=kp;var Tp="SelectLabel",Ep=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_k(Tp,n);return c.jsx(ye.div,{id:o.id,...r,ref:t})});Ep.displayName=Tp;var Gs="SelectItem",[Pk,Ip]=Nr(Gs),Np=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Ln(Gs,n),l=$n(Gs,n),u=a.value===r,[d,f]=p.useState(s??""),[h,m]=p.useState(!1),w=ze(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),v=Rt(),g=p.useRef("touch"),x=()=>{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(Pk,{scope:n,value:r,disabled:o,textId:v,isSelected:u,onItemTextChange:p.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(Vs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(ye.div,{role:"option","aria-labelledby":v,"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:w,onFocus:me(i.onFocus,()=>m(!0)),onBlur:me(i.onBlur,()=>m(!1)),onClick:me(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:me(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:me(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:me(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:me(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:me(i.onKeyDown,b=>{var T;((T=l.searchRef)==null?void 0:T.current)!==""&&b.key===" "||(vk.includes(b.key)&&x(),b.key===" "&&b.preventDefault())})})})})});Np.displayName=Gs;var mo="SelectItemText",Ap=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Ln(mo,n),a=$n(mo,n),l=Ip(mo,n),u=Sk(mo,n),[d,f]=p.useState(null),h=ze(t,x=>f(x),l.onItemTextChange,x=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,x,l.value,l.disabled)}),m=d==null?void 0:d.textContent,w=p.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:m},l.value),[l.disabled,l.value,m]),{onNativeOptionAdd:v,onNativeOptionRemove:g}=u;return Et(()=>(v(w),()=>g(w)),[v,g,w]),c.jsxs(c.Fragment,{children:[c.jsx(ye.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?bo.createPortal(s.children,i.valueNode):null]})});Ap.displayName=mo;var jp="SelectItemIndicator",_p=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Ip(jp,n).isSelected?c.jsx(ye.span,{"aria-hidden":!0,...r,ref:t}):null});_p.displayName=jp;var tl="SelectScrollUpButton",Mp=p.forwardRef((e,t)=>{const n=$n(tl,e.__scopeSelect),r=Qa(tl,e.__scopeSelect),[o,s]=p.useState(!1),i=ze(t,r.onScrollButtonChange);return Et(()=>{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(Rp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Mp.displayName=tl;var nl="SelectScrollDownButton",Pp=p.forwardRef((e,t)=>{const n=$n(nl,e.__scopeSelect),r=Qa(nl,e.__scopeSelect),[o,s]=p.useState(!1),i=ze(t,r.onScrollButtonChange);return Et(()=>{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(Rp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Pp.displayName=nl;var Rp=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=$n("SelectScrollButton",n),i=p.useRef(null),a=Ks(n),l=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>l(),[l]),Et(()=>{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(ye.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:me(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:me(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:me(o.onPointerLeave,()=>{l()})})}),Rk="SelectSeparator",Op=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(ye.div,{"aria-hidden":!0,...r,ref:t})});Op.displayName=Rk;var rl="SelectArrow",Ok=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=qs(n),s=Ln(rl,n),i=$n(rl,n);return s.open&&i.position==="popper"?c.jsx(wu,{...o,...r,ref:t}):null});Ok.displayName=rl;var Dk="SelectBubbleInput",Dp=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=ze(r,o),i=up(t);return p.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(ye.select,{...n,style:{...dp,...n.style},ref:s,defaultValue:t})});Dp.displayName=Dk;function Lp(e){return e===""||e===void 0}function $p(e){const t=It(e),n=p.useRef(""),r=p.useRef(0),o=p.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=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Fp(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=Lk(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 Lk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var $k=fp,Bp=pp,Fk=gp,Bk=xp,zk=vp,zp=wp,Hk=Cp,Hp=Ep,Up=Np,Uk=Ap,Wk=_p,Wp=Mp,Vp=Pp,Kp=Op;const qp=$k,Gp=Fk,ol=p.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Bp,{ref:r,className:oe("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(Bk,{asChild:!0,children:c.jsx(ae.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ol.displayName=Bp.displayName;const Yp=p.forwardRef(({className:e,...t},n)=>c.jsx(Wp,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ae.ChevronUp,{className:"h-4 w-4"})}));Yp.displayName=Wp.displayName;const Xp=p.forwardRef(({className:e,...t},n)=>c.jsx(Vp,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ae.ChevronDown,{className:"h-4 w-4"})}));Xp.displayName=Vp.displayName;const sl=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(zk,{children:c.jsxs(zp,{ref:o,className:oe("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(Yp,{}),c.jsx(Hk,{className:oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(Xp,{})]})}));sl.displayName=zp.displayName;const Vk=p.forwardRef(({className:e,...t},n)=>c.jsx(Hp,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Vk.displayName=Hp.displayName;const sr=p.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Up,{ref:r,className:oe("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(Wk,{children:c.jsx(ae.Check,{className:"h-4 w-4"})})}),c.jsx(Uk,{children:t})]}));sr.displayName=Up.displayName;const Kk=p.forwardRef(({className:e,...t},n)=>c.jsx(Kp,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));Kk.displayName=Kp.displayName;var qk="Separator",Jp="horizontal",Gk=["horizontal","vertical"],Zp=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=Jp,...o}=e,s=Yk(r)?r:Jp,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(ye.div,{"data-orientation":s,...a,...o,ref:t})});Zp.displayName=qk;function Yk(e){return Gk.includes(e)}var Qp=Zp;const em=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(Qp,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));em.displayName=Qp.displayName;const Xk=Aa,Jk=AS,Zk=ja,tm=p.forwardRef(({className:e,...t},n)=>c.jsx(so,{className:oe("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}));tm.displayName=so.displayName;const Qk=wo.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"}}),nm=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(Zk,{children:[c.jsx(tm,{}),c.jsxs(io,{ref:o,className:oe(Qk({side:e}),t),...r,children:[n,c.jsxs(Jf,{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(ae.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));nm.displayName=io.displayName;const rm=({className:e,...t})=>c.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});rm.displayName="SheetHeader";const om=p.forwardRef(({className:e,...t},n)=>c.jsx(er,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));om.displayName=er.displayName;const sm=p.forwardRef(({className:e,...t},n)=>c.jsx(js,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));sm.displayName=js.displayName;var Ys="Switch",[eT,zT]=yn(Ys),[tT,nT]=eT(Ys),im=p.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,m]=p.useState(null),w=ze(t,S=>m(S)),v=p.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,b]=dr({prop:o,defaultProp:s??!1,onChange:u,caller:Ys});return c.jsxs(tT,{scope:n,checked:x,disabled:a,children:[c.jsx(ye.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":um(x),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:w,onClick:me(e.onClick,S=>{b(T=>!T),g&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})}),g&&c.jsx(cm,{control:h,bubbles:!v.current,name:r,value:l,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});im.displayName=Ys;var am="SwitchThumb",lm=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=nT(am,n);return c.jsx(ye.span,{"data-state":um(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});lm.displayName=am;var rT="SwitchBubbleInput",cm=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=ze(i,s),l=up(n),u=iu(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&m){const w=new Event("click",{bubbles:r});m.call(d,n),d.dispatchEvent(w)}},[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}})});cm.displayName=rT;function um(e){return e?"checked":"unchecked"}var dm=im,oT=lm;const Fn=p.forwardRef(({className:e,...t},n)=>c.jsx(dm,{className:oe("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(oT,{className:oe("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")})}));Fn.displayName=dm.displayName;const sT={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 iT({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}=Da();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."})},m=()=>{l(sT),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},w=()=>{l(e),d(!1),o(!1)},v=async()=>{try{const x=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${x.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(Xk,{open:r,onOpenChange:o,children:[c.jsx(Jk,{asChild:!0,children:c.jsxs(Qe,{variant:"outline",size:"sm",className:n,children:[c.jsx(ae.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(Mf,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(nm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(rm,{children:[c.jsx(om,{children:"Chat Settings"}),c.jsx(sm,{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(ae.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(tn,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ws,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(Qe,{variant:"outline",onClick:v,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(tn,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(Fn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(tn,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ws,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(Qe,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(ae.EyeOff,{className:"h-4 w-4"}):c.jsx(ae.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(ae.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(tn,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(qp,{value:a.ui.layout,onValueChange:g=>l(x=>({...x,ui:{...x.ui,layout:g}})),children:[c.jsx(ol,{children:c.jsx(Gp,{})}),c.jsxs(sl,{children:[c.jsx(sr,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(sr,{value:"fullscreen",children:"Fullscreen"}),c.jsx(sr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(tn,{htmlFor:"theme",children:"Theme"}),c.jsxs(qp,{value:a.ui.theme,onValueChange:g=>l(x=>({...x,ui:{...x.ui,theme:g}})),children:[c.jsx(ol,{children:c.jsx(Gp,{})}),c.jsxs(sl,{children:[c.jsx(sr,{value:"light",children:"Light"}),c.jsx(sr,{value:"dark",children:"Dark"}),c.jsx(sr,{value:"system",children:"System"})]})]})]}),c.jsx(em,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(tn,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(Fn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(tn,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(Fn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(tn,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(Fn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(x=>({...x,ui:{...x.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(ae.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(tn,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(Fn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(tn,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(Fn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(tn,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(Fn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(Qe,{variant:"outline",onClick:m,children:[c.jsx(ae.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Qe,{variant:"outline",onClick:w,children:"Cancel"}),c.jsxs(Qe,{onClick:h,disabled:!u,children:[c.jsx(ae.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function aT({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($o,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx($s,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx($o,{...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(Ja,{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($s,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx($o,{...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(Ja,{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($s,{onError:s.onError,enableFileUpload:!0})})]})})}Ee.ChatApi=tc,Ee.ChatInput=kc,Ee.ChatInterface=$s,Ee.ChatProviders=$o,Ee.ChatSettings=iT,Ee.MarkdownContent=Cr,Ee.MessageComponent=Ls,Ee.MessageList=Fa,Ee.ThreadManager=Ja,Ee.applySettings=fk,Ee.buildMessagePreviewMap=Kg,Ee.chatApiClient=Tn,Ee.default=aT,Ee.del=hi,Ee.get=Yt,Ee.getChatToken=Zl,Ee.getCurrentSettings=dk,Ee.getDefaultApiConfig=sp,Ee.getDefaultChatSettings=ip,Ee.onChatTokenChanged=Ql,Ee.post=Po,Ee.put=ec,Ee.setChatToken=Mo,Ee.useApi=pi,Ee.useChatStream=xc,Ee.useMessagesReducer=fc,Ee.useStream=Sc,Ee.useThreadState=Lo,Ee.useThreads=Do,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"}})});