@epam/statgpt-conversation-list 0.1.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 EPAM Systems
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # Conversation List
2
+
3
+ This is StatGpt portals library, provides reusable React components and utilities for displaying and managing lists of conversations in StatGPT Portals projects. It handles rendering, selection, and interaction with conversation items.
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/mit)
6
+ [![React](https://img.shields.io/badge/React-19+-61dafb.svg)](https://reactjs.org/)
7
+ [![Typescript](https://img.shields.io/badge/Typescript-5+-61dafb.svg)](https://www.typescriptlang.org/)
8
+
9
+
10
+ ## Table of Contents
11
+
12
+ - [Features](#features)
13
+ - [Installation](#installation)
14
+ - [Usage](#usage)
15
+ - [Styling & Customization](#styling--customization)
16
+ - [Localization](#localization)
17
+ - [Contributing](#contributing)
18
+ - [Security](#security)
19
+ - [License](#license)
20
+
21
+ ## Features
22
+
23
+ - UI components for rendering conversation lists and items
24
+ - Support for highlighting search queries within conversation names
25
+ - Action menus for conversation management (delete, share, etc.)
26
+ - Customizable styles and icons
27
+ - Smooth scrolling to selected conversation
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ npm install @epam/statgpt-conversation-list
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ```tsx
38
+ import { ConversationList } from '@epam/statgpt-conversation-list';
39
+
40
+ // Example usage
41
+ <ConversationList
42
+ selectedConversationId={selectedId}
43
+ conversations={conversations}
44
+ handleConversationClick={handleConversationSelect}
45
+ handleSelectedConversationRemove={handleSelectedConversationRemove}
46
+ conversationStyles={conversationStyles}
47
+ actions={actions}
48
+ locale={locale}
49
+ ...
50
+ />
51
+ ```
52
+
53
+
54
+ ## Styling & Customization
55
+
56
+ You can customize the appearance of the conversation list and items using the `conversationStyles` prop. This allows you to override icons & default styles with your own CSS styles.
57
+
58
+ ## Localization
59
+
60
+ The component supports localization of used chat-model through the `locale` prop. You can also provide translations for various UI elements using the `titles` prop.
61
+
62
+ ## Contributing
63
+
64
+ We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for details on:
65
+
66
+ - Code style guidelines
67
+ - Testing requirements
68
+ - Pull request process
69
+
70
+
71
+ ## Security
72
+
73
+ If you discover a security vulnerability, please refer to our [Security Policy](https://github.com/epam/statgpt-portal-frontend/blob/development/SECURITY.md).
74
+
75
+ ## License
76
+
77
+ [MIT](https://github.com/epam/statgpt-portal-frontend/blob/development/LICENSE) - see the [LICENSE](https://github.com/epam/statgpt-portal-frontend/blob/development/LICENSE) file for details.
package/index.css ADDED
@@ -0,0 +1 @@
1
+ @tailwind base;@tailwind components;@tailwind utilities;
package/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './models/titles';
2
+ export * from './types/action-menu-item';
3
+ export { ConversationList } from './components/ConversationList/ConversationList';
4
+ export { ActionMenu } from './components/ActionMenu/ActionMenu';
package/index.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),Z=require("classnames"),M=require("react"),Vt=require("lodash"),Ne=require("@tabler/icons-react"),Pr=require("react-dom"),Or=require("jszip");function Nn(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 E=Nn(M),Pn=Nn(Pr);var fe=(e=>(e.DELETE="delete",e.EXPORT="export",e.SHARE="share",e))(fe||{}),ee=(e=>(e.SHARED="shared",e.TODAY="today",e.YESTERDAY="yesterday",e.WEEK="week",e.EARLIER="earlier",e))(ee||{});const Dr={[ee.TODAY]:[],[ee.YESTERDAY]:[],[ee.WEEK]:[],[ee.EARLIER]:[]},On=(e,t)=>e.toDateString()===t.toDateString(),Lr=(e,t)=>{const n=new Date(e.getFullYear(),e.getMonth(),e.getDate()-1);return On(t,n)},Fr=(e,t)=>{const n=e.getTime()-t.getTime();return Math.floor(n/(1e3*60*60*24))},kr=e=>{const t=new Date,n=Vt.cloneDeep(Dr);for(const r of e)if(r.updatedAt){const o=new Date(r.updatedAt);let l;On(t,o)?l=n[ee.TODAY]:Lr(t,o)?l=n[ee.YESTERDAY]:Fr(t,o)<=7?l=n[ee.WEEK]:l=n[ee.EARLIER],l!=null&&l.some(a=>a.id===r.id)||l.push(r)}return n},Dn=e=>e==null?void 0:e.sort((t,n)=>((n==null?void 0:n.updatedAt)||0)-((t==null?void 0:t.updatedAt)||0)),jr=(e,t)=>e===ee.SHARED?(t==null?void 0:t.shared)||"Shared":e===ee.TODAY?(t==null?void 0:t.today)||"Today":e===ee.YESTERDAY?(t==null?void 0:t.yesterday)||"Yesterday":e===ee.WEEK?(t==null?void 0:t.lastWeek)||"Last week":(t==null?void 0:t.earlier)||"Earlier",Br=({text:e,highlightText:t})=>{const n=M.useMemo(()=>{var a;const r=[];if(!t)return[{id:0,text:e,highlight:!1}];const o=(t==null?void 0:t.toLowerCase())||"",l=((a=e==null?void 0:e.toLowerCase())==null?void 0:a.split(o))||"";for(let u=0,s=0;u<(l==null?void 0:l.length);u++){const i=l==null?void 0:l[u],c=i.length;i!==""&&r.push({id:r.length,highlight:!1,text:e==null?void 0:e.substring(s,s+c)}),s+=c,u!==(l==null?void 0:l.length)-1&&(r.push({id:r.length,highlight:!0,text:e==null?void 0:e.substring(s,s+t.length)}),s+=t.length)}return r},[t,e]);return x.jsx(x.Fragment,{children:n.map(r=>x.jsx("span",{className:Z((r==null?void 0:r.highlight)&&"bg-highlight"),children:r==null?void 0:r.text},r==null?void 0:r.id))})},Ht=()=>x.jsx("div",{className:"flex items-center justify-center h-full",children:x.jsx("div",{className:"loader"})}),Ve=({buttonClassName:e,isLoading:t=!1,title:n,disabled:r,iconAfter:o,iconBefore:l,onClick:a,isSmallButton:u})=>{const s=Z(u?"font-semibold":"",o?"mr-2":"",l?"ml-2":"");return x.jsxs("button",{type:"button",className:Z("base-button",e,u?"small-button":""),disabled:r||t,"aria-label":"button",onClick:i=>a==null?void 0:a(i),title:n,children:[l,t&&x.jsx(Ht,{}),n?u?x.jsx("h4",{className:s,children:n}):x.jsx("h3",{className:s,children:n}):null,o]})};function ht(){return typeof window<"u"}function Me(e){return Wt(e)?(e.nodeName||"").toLowerCase():"#document"}function se(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function pe(e){var t;return(t=(Wt(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Wt(e){return ht()?e instanceof Node||e instanceof se(e).Node:!1}function Y(e){return ht()?e instanceof Element||e instanceof se(e).Element:!1}function X(e){return ht()?e instanceof HTMLElement||e instanceof se(e).HTMLElement:!1}function Pt(e){return!ht()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof se(e).ShadowRoot}const _r=new Set(["inline","contents"]);function Ye(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=ae(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!_r.has(o)}const $r=new Set(["table","td","th"]);function Ur(e){return $r.has(Me(e))}const Vr=[":popover-open",":modal"];function mt(e){return Vr.some(t=>{try{return e.matches(t)}catch{return!1}})}const Hr=["transform","translate","scale","rotate","perspective"],Wr=["transform","translate","scale","rotate","perspective","filter"],zr=["paint","layout","strict","content"];function zt(e){const t=pt(),n=Y(e)?ae(e):e;return Hr.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)||Wr.some(r=>(n.willChange||"").includes(r))||zr.some(r=>(n.contain||"").includes(r))}function Yr(e){let t=xe(e);for(;X(t)&&!we(t);){if(zt(t))return t;if(mt(t))return null;t=xe(t)}return null}function pt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Kr=new Set(["html","body","#document"]);function we(e){return Kr.has(Me(e))}function ae(e){return se(e).getComputedStyle(e)}function gt(e){return Y(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function xe(e){if(Me(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Pt(e)&&e.host||pe(e);return Pt(t)?t.host:t}function Ln(e){const t=xe(e);return we(t)?e.ownerDocument?e.ownerDocument.body:e.body:X(t)&&Ye(t)?t:Ln(t)}function Se(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Ln(e),l=o===((r=e.ownerDocument)==null?void 0:r.body),a=se(o);if(l){const u=Ot(a);return t.concat(a,a.visualViewport||[],Ye(o)?o:[],u&&n?Se(u):[])}return t.concat(o,Se(o,[],n))}function Ot(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const nt=Math.min,Ie=Math.max,rt=Math.round,qe=Math.floor,me=e=>({x:e,y:e}),Gr={left:"right",right:"left",bottom:"top",top:"bottom"},Xr={start:"end",end:"start"};function Qt(e,t,n){return Ie(e,nt(t,n))}function bt(e,t){return typeof e=="function"?e(t):e}function Pe(e){return e.split("-")[0]}function wt(e){return e.split("-")[1]}function Fn(e){return e==="x"?"y":"x"}function kn(e){return e==="y"?"height":"width"}const qr=new Set(["top","bottom"]);function Ce(e){return qr.has(Pe(e))?"y":"x"}function jn(e){return Fn(Ce(e))}function Qr(e,t,n){n===void 0&&(n=!1);const r=wt(e),o=jn(e),l=kn(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[l]>t.floating[l]&&(a=ot(a)),[a,ot(a)]}function Zr(e){const t=ot(e);return[Dt(e),t,Dt(t)]}function Dt(e){return e.replace(/start|end/g,t=>Xr[t])}const Zt=["left","right"],Jt=["right","left"],Jr=["top","bottom"],eo=["bottom","top"];function to(e,t,n){switch(e){case"top":case"bottom":return n?t?Jt:Zt:t?Zt:Jt;case"left":case"right":return t?Jr:eo;default:return[]}}function no(e,t,n,r){const o=wt(e);let l=to(Pe(e),n==="start",r);return o&&(l=l.map(a=>a+"-"+o),t&&(l=l.concat(l.map(Dt)))),l}function ot(e){return e.replace(/left|right|bottom|top/g,t=>Gr[t])}function ro(e){return{top:0,right:0,bottom:0,left:0,...e}}function oo(e){return typeof e!="number"?ro(e):{top:e,right:e,bottom:e,left:e}}function st(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}}/*!
2
+ * tabbable 6.2.0
3
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
4
+ */var so=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],it=so.join(","),Bn=typeof Element>"u",$e=Bn?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,lt=!Bn&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e==null?void 0:e.ownerDocument},ct=function e(t,n){var r;n===void 0&&(n=!0);var o=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"inert"),l=o===""||o==="true",a=l||n&&t&&e(t.parentNode);return a},io=function(t){var n,r=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"contenteditable");return r===""||r==="true"},_n=function(t,n,r){if(ct(t))return[];var o=Array.prototype.slice.apply(t.querySelectorAll(it));return n&&$e.call(t,it)&&o.unshift(t),o=o.filter(r),o},$n=function e(t,n,r){for(var o=[],l=Array.from(t);l.length;){var a=l.shift();if(!ct(a,!1))if(a.tagName==="SLOT"){var u=a.assignedElements(),s=u.length?u:a.children,i=e(s,!0,r);r.flatten?o.push.apply(o,i):o.push({scopeParent:a,candidates:i})}else{var c=$e.call(a,it);c&&r.filter(a)&&(n||!t.includes(a))&&o.push(a);var f=a.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(a),d=!ct(f,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(a));if(f&&d){var h=e(f===!0?a.children:f.children,!0,r);r.flatten?o.push.apply(o,h):o.push({scopeParent:a,candidates:h})}else l.unshift.apply(l,a.children)}}return o},Un=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Vn=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||io(t))&&!Un(t)?0:t.tabIndex},lo=function(t,n){var r=Vn(t);return r<0&&n&&!Un(t)?0:r},co=function(t,n){return t.tabIndex===n.tabIndex?t.documentOrder-n.documentOrder:t.tabIndex-n.tabIndex},Hn=function(t){return t.tagName==="INPUT"},ao=function(t){return Hn(t)&&t.type==="hidden"},uo=function(t){var n=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(r){return r.tagName==="SUMMARY"});return n},fo=function(t,n){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===n)return t[r]},ho=function(t){if(!t.name)return!0;var n=t.form||lt(t),r=function(u){return n.querySelectorAll('input[type="radio"][name="'+u+'"]')},o;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")o=r(window.CSS.escape(t.name));else try{o=r(t.name)}catch(a){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",a.message),!1}var l=fo(o,t.form);return!l||l===t},mo=function(t){return Hn(t)&&t.type==="radio"},po=function(t){return mo(t)&&!ho(t)},go=function(t){var n,r=t&&lt(t),o=(n=r)===null||n===void 0?void 0:n.host,l=!1;if(r&&r!==t){var a,u,s;for(l=!!((a=o)!==null&&a!==void 0&&(u=a.ownerDocument)!==null&&u!==void 0&&u.contains(o)||t!=null&&(s=t.ownerDocument)!==null&&s!==void 0&&s.contains(t));!l&&o;){var i,c,f;r=lt(o),o=(i=r)===null||i===void 0?void 0:i.host,l=!!((c=o)!==null&&c!==void 0&&(f=c.ownerDocument)!==null&&f!==void 0&&f.contains(o))}}return l},en=function(t){var n=t.getBoundingClientRect(),r=n.width,o=n.height;return r===0&&o===0},bo=function(t,n){var r=n.displayCheck,o=n.getShadowRoot;if(getComputedStyle(t).visibility==="hidden")return!0;var l=$e.call(t,"details>summary:first-of-type"),a=l?t.parentElement:t;if($e.call(a,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="legacy-full"){if(typeof o=="function"){for(var u=t;t;){var s=t.parentElement,i=lt(t);if(s&&!s.shadowRoot&&o(s)===!0)return en(t);t.assignedSlot?t=t.assignedSlot:!s&&i!==t.ownerDocument?t=i.host:t=s}t=u}if(go(t))return!t.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return en(t);return!1},wo=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var n=t.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var o=n.children.item(r);if(o.tagName==="LEGEND")return $e.call(n,"fieldset[disabled] *")?!0:!o.contains(t)}return!0}n=n.parentElement}return!1},Lt=function(t,n){return!(n.disabled||ct(n)||ao(n)||bo(n,t)||uo(n)||wo(n))},Ft=function(t,n){return!(po(n)||Vn(n)<0||!Lt(t,n))},xo=function(t){var n=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},yo=function e(t){var n=[],r=[];return t.forEach(function(o,l){var a=!!o.scopeParent,u=a?o.scopeParent:o,s=lo(u,a),i=a?e(o.candidates):u;s===0?a?n.push.apply(n,i):n.push(u):r.push({documentOrder:l,tabIndex:s,item:o,isScope:a,content:i})}),r.sort(co).reduce(function(o,l){return l.isScope?o.push.apply(o,l.content):o.push(l.content),o},[]).concat(n)},xt=function(t,n){n=n||{};var r;return n.getShadowRoot?r=$n([t],n.includeContainer,{filter:Ft.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:xo}):r=_n(t,n.includeContainer,Ft.bind(null,n)),yo(r)},Eo=function(t,n){n=n||{};var r;return n.getShadowRoot?r=$n([t],n.includeContainer,{filter:Lt.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=_n(t,n.includeContainer,Lt.bind(null,n)),r},Wn=function(t,n){if(n=n||{},!t)throw new Error("No node provided");return $e.call(t,it)===!1?!1:Ft(n,t)};function zn(){const e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform}function Yn(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:r}=t;return n+"/"+r}).join(" "):navigator.userAgent}function vo(){return/apple/i.test(navigator.vendor)}function kt(){const e=/android/i;return e.test(zn())||e.test(Yn())}function Ro(){return Yn().includes("jsdom/")}const tn="data-floating-ui-focusable",Co="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function Fe(e){let t=e.activeElement;for(;((n=t)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;t=t.shadowRoot.activeElement}return t}function ne(e,t){if(!e||!t)return!1;const n=t.getRootNode==null?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&Pt(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function Re(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Ct(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function Ao(e){return e.matches("html,body")}function de(e){return(e==null?void 0:e.ownerDocument)||document}function Kn(e){return X(e)&&e.matches(Co)}function nn(e){return e?e.getAttribute("role")==="combobox"&&Kn(e):!1}function jt(e){return e?e.hasAttribute(tn)?e:e.querySelector("["+tn+"]")||e:null}function je(e,t,n){return n===void 0&&(n=!0),e.filter(o=>{var l;return o.parentId===t&&(!n||((l=o.context)==null?void 0:l.open))}).flatMap(o=>[o,...je(e,o.id,n)])}function rn(e,t){var n;let r=[],o=(n=e.find(l=>l.id===t))==null?void 0:n.parentId;for(;o;){const l=e.find(a=>a.id===o);o=l==null?void 0:l.parentId,l&&(r=r.concat(l))}return r}function At(e){e.preventDefault(),e.stopPropagation()}function So(e){return"nativeEvent"in e}function Mo(e){return e.mozInputSource===0&&e.isTrusted?!0:kt()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function To(e){return Ro()?!1:!kt()&&e.width===0&&e.height===0||kt()&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function on(e,t){return["mouse","pen"].includes(e)}var Io=typeof document<"u",No=function(){},oe=Io?M.useLayoutEffect:No;const Po={...E};function St(e){const t=E.useRef(e);return oe(()=>{t.current=e}),t}const Oo=Po.useInsertionEffect,Do=Oo||(e=>e());function he(e){const t=E.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return Do(()=>{t.current=e}),E.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}const Ke=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Gn(e,t){const n=xt(e,Ke()),r=n.length;if(r===0)return;const o=Fe(de(e)),l=n.indexOf(o),a=l===-1?t===1?0:r-1:l+t;return n[a]}function Xn(e){return Gn(de(e).body,1)||e}function qn(e){return Gn(de(e).body,-1)||e}function Ue(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!ne(n,r)}function Lo(e){xt(e,Ke()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function sn(e){e.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}function ln(e,t,n){let{reference:r,floating:o}=e;const l=Ce(t),a=jn(t),u=kn(a),s=Pe(t),i=l==="y",c=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,d=r[u]/2-o[u]/2;let h;switch(s){case"top":h={x:c,y:r.y-o.height};break;case"bottom":h={x:c,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-o.width,y:f};break;default:h={x:r.x,y:r.y}}switch(wt(t)){case"start":h[a]-=d*(n&&i?-1:1);break;case"end":h[a]+=d*(n&&i?-1:1);break}return h}const Fo=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:l=[],platform:a}=n,u=l.filter(Boolean),s=await(a.isRTL==null?void 0:a.isRTL(t));let i=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:c,y:f}=ln(i,r,s),d=r,h={},m=0;for(let p=0;p<u.length;p++){const{name:g,fn:y}=u[p],{x:w,y:b,data:C,reset:S}=await y({x:c,y:f,initialPlacement:r,placement:d,strategy:o,middlewareData:h,rects:i,platform:a,elements:{reference:e,floating:t}});c=w??c,f=b??f,h={...h,[g]:{...h[g],...C}},S&&m<=50&&(m++,typeof S=="object"&&(S.placement&&(d=S.placement),S.rects&&(i=S.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:c,y:f}=ln(i,d,s)),p=-1)}return{x:c,y:f,placement:d,strategy:o,middlewareData:h}};async function Qn(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:l,rects:a,elements:u,strategy:s}=e,{boundary:i="clippingAncestors",rootBoundary:c="viewport",elementContext:f="floating",altBoundary:d=!1,padding:h=0}=bt(t,e),m=oo(h),g=u[d?f==="floating"?"reference":"floating":f],y=st(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(g)))==null||n?g:g.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(u.floating)),boundary:i,rootBoundary:c,strategy:s})),w=f==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,b=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u.floating)),C=await(l.isElement==null?void 0:l.isElement(b))?await(l.getScale==null?void 0:l.getScale(b))||{x:1,y:1}:{x:1,y:1},S=st(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:w,offsetParent:b,strategy:s}):w);return{top:(y.top-S.top+m.top)/C.y,bottom:(S.bottom-y.bottom+m.bottom)/C.y,left:(y.left-S.left+m.left)/C.x,right:(S.right-y.right+m.right)/C.x}}const ko=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:l,rects:a,initialPlacement:u,platform:s,elements:i}=t,{mainAxis:c=!0,crossAxis:f=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:p=!0,...g}=bt(e,t);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const y=Pe(o),w=Ce(u),b=Pe(u)===u,C=await(s.isRTL==null?void 0:s.isRTL(i.floating)),S=d||(b||!p?[ot(u)]:Zr(u)),T=m!=="none";!d&&T&&S.push(...no(u,p,m,C));const F=[u,...S],$=await Qn(t,g),W=[];let U=((r=l.flip)==null?void 0:r.overflows)||[];if(c&&W.push($[y]),f){const v=Qr(o,a,C);W.push($[v[0]],$[v[1]])}if(U=[...U,{placement:o,overflows:W}],!W.every(v=>v<=0)){var N,q;const v=(((N=l.flip)==null?void 0:N.index)||0)+1,A=F[v];if(A&&(!(f==="alignment"?w!==Ce(A):!1)||U.every(R=>Ce(R.placement)===w?R.overflows[0]>0:!0)))return{data:{index:v,overflows:U},reset:{placement:A}};let k=(q=U.filter(j=>j.overflows[0]<=0).sort((j,R)=>j.overflows[1]-R.overflows[1])[0])==null?void 0:q.placement;if(!k)switch(h){case"bestFit":{var O;const j=(O=U.filter(R=>{if(T){const I=Ce(R.placement);return I===w||I==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(I=>I>0).reduce((I,_)=>I+_,0)]).sort((R,I)=>R[1]-I[1])[0])==null?void 0:O[0];j&&(k=j);break}case"initialPlacement":k=u;break}if(o!==k)return{reset:{placement:k}}}return{}}}},jo=new Set(["left","top"]);async function Bo(e,t){const{placement:n,platform:r,elements:o}=e,l=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=Pe(n),u=wt(n),s=Ce(n)==="y",i=jo.has(a)?-1:1,c=l&&s?-1:1,f=bt(t,e);let{mainAxis:d,crossAxis:h,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return u&&typeof m=="number"&&(h=u==="end"?m*-1:m),s?{x:h*c,y:d*i}:{x:d*i,y:h*c}}const _o=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:l,placement:a,middlewareData:u}=t,s=await Bo(t,e);return a===((n=u.offset)==null?void 0:n.placement)&&(r=u.arrow)!=null&&r.alignmentOffset?{}:{x:o+s.x,y:l+s.y,data:{...s,placement:a}}}}},$o=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:l=!0,crossAxis:a=!1,limiter:u={fn:g=>{let{x:y,y:w}=g;return{x:y,y:w}}},...s}=bt(e,t),i={x:n,y:r},c=await Qn(t,s),f=Ce(Pe(o)),d=Fn(f);let h=i[d],m=i[f];if(l){const g=d==="y"?"top":"left",y=d==="y"?"bottom":"right",w=h+c[g],b=h-c[y];h=Qt(w,h,b)}if(a){const g=f==="y"?"top":"left",y=f==="y"?"bottom":"right",w=m+c[g],b=m-c[y];m=Qt(w,m,b)}const p=u.fn({...t,[d]:h,[f]:m});return{...p,data:{x:p.x-n,y:p.y-r,enabled:{[d]:l,[f]:a}}}}}};function Zn(e){const t=ae(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=X(e),l=o?e.offsetWidth:n,a=o?e.offsetHeight:r,u=rt(n)!==l||rt(r)!==a;return u&&(n=l,r=a),{width:n,height:r,$:u}}function Yt(e){return Y(e)?e:e.contextElement}function Be(e){const t=Yt(e);if(!X(t))return me(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:l}=Zn(t);let a=(l?rt(n.width):n.width)/r,u=(l?rt(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!u||!Number.isFinite(u))&&(u=1),{x:a,y:u}}const Uo=me(0);function Jn(e){const t=se(e);return!pt()||!t.visualViewport?Uo:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Vo(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==se(e)?!1:t}function Oe(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),l=Yt(e);let a=me(1);t&&(r?Y(r)&&(a=Be(r)):a=Be(e));const u=Vo(l,n,r)?Jn(l):me(0);let s=(o.left+u.x)/a.x,i=(o.top+u.y)/a.y,c=o.width/a.x,f=o.height/a.y;if(l){const d=se(l),h=r&&Y(r)?se(r):r;let m=d,p=Ot(m);for(;p&&r&&h!==m;){const g=Be(p),y=p.getBoundingClientRect(),w=ae(p),b=y.left+(p.clientLeft+parseFloat(w.paddingLeft))*g.x,C=y.top+(p.clientTop+parseFloat(w.paddingTop))*g.y;s*=g.x,i*=g.y,c*=g.x,f*=g.y,s+=b,i+=C,m=se(p),p=Ot(m)}}return st({width:c,height:f,x:s,y:i})}function yt(e,t){const n=gt(e).scrollLeft;return t?t.left+n:Oe(pe(e)).left+n}function er(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-yt(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Ho(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const l=o==="fixed",a=pe(r),u=t?mt(t.floating):!1;if(r===a||u&&l)return n;let s={scrollLeft:0,scrollTop:0},i=me(1);const c=me(0),f=X(r);if((f||!f&&!l)&&((Me(r)!=="body"||Ye(a))&&(s=gt(r)),X(r))){const h=Oe(r);i=Be(r),c.x=h.x+r.clientLeft,c.y=h.y+r.clientTop}const d=a&&!f&&!l?er(a,s):me(0);return{width:n.width*i.x,height:n.height*i.y,x:n.x*i.x-s.scrollLeft*i.x+c.x+d.x,y:n.y*i.y-s.scrollTop*i.y+c.y+d.y}}function Wo(e){return Array.from(e.getClientRects())}function zo(e){const t=pe(e),n=gt(e),r=e.ownerDocument.body,o=Ie(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),l=Ie(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+yt(e);const u=-n.scrollTop;return ae(r).direction==="rtl"&&(a+=Ie(t.clientWidth,r.clientWidth)-o),{width:o,height:l,x:a,y:u}}const cn=25;function Yo(e,t){const n=se(e),r=pe(e),o=n.visualViewport;let l=r.clientWidth,a=r.clientHeight,u=0,s=0;if(o){l=o.width,a=o.height;const c=pt();(!c||c&&t==="fixed")&&(u=o.offsetLeft,s=o.offsetTop)}const i=yt(r);if(i<=0){const c=r.ownerDocument,f=c.body,d=getComputedStyle(f),h=c.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,m=Math.abs(r.clientWidth-f.clientWidth-h);m<=cn&&(l-=m)}else i<=cn&&(l+=i);return{width:l,height:a,x:u,y:s}}const Ko=new Set(["absolute","fixed"]);function Go(e,t){const n=Oe(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,l=X(e)?Be(e):me(1),a=e.clientWidth*l.x,u=e.clientHeight*l.y,s=o*l.x,i=r*l.y;return{width:a,height:u,x:s,y:i}}function an(e,t,n){let r;if(t==="viewport")r=Yo(e,n);else if(t==="document")r=zo(pe(e));else if(Y(t))r=Go(t,n);else{const o=Jn(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return st(r)}function tr(e,t){const n=xe(e);return n===t||!Y(n)||we(n)?!1:ae(n).position==="fixed"||tr(n,t)}function Xo(e,t){const n=t.get(e);if(n)return n;let r=Se(e,[],!1).filter(u=>Y(u)&&Me(u)!=="body"),o=null;const l=ae(e).position==="fixed";let a=l?xe(e):e;for(;Y(a)&&!we(a);){const u=ae(a),s=zt(a);!s&&u.position==="fixed"&&(o=null),(l?!s&&!o:!s&&u.position==="static"&&!!o&&Ko.has(o.position)||Ye(a)&&!s&&tr(e,a))?r=r.filter(c=>c!==a):o=u,a=xe(a)}return t.set(e,r),r}function qo(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?mt(t)?[]:Xo(t,this._c):[].concat(n),r],u=a[0],s=a.reduce((i,c)=>{const f=an(t,c,o);return i.top=Ie(f.top,i.top),i.right=nt(f.right,i.right),i.bottom=nt(f.bottom,i.bottom),i.left=Ie(f.left,i.left),i},an(t,u,o));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}}function Qo(e){const{width:t,height:n}=Zn(e);return{width:t,height:n}}function Zo(e,t,n){const r=X(t),o=pe(t),l=n==="fixed",a=Oe(e,!0,l,t);let u={scrollLeft:0,scrollTop:0};const s=me(0);function i(){s.x=yt(o)}if(r||!r&&!l)if((Me(t)!=="body"||Ye(o))&&(u=gt(t)),r){const h=Oe(t,!0,l,t);s.x=h.x+t.clientLeft,s.y=h.y+t.clientTop}else o&&i();l&&!r&&o&&i();const c=o&&!r&&!l?er(o,u):me(0),f=a.left+u.scrollLeft-s.x-c.x,d=a.top+u.scrollTop-s.y-c.y;return{x:f,y:d,width:a.width,height:a.height}}function Mt(e){return ae(e).position==="static"}function un(e,t){if(!X(e)||ae(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return pe(e)===n&&(n=n.ownerDocument.body),n}function nr(e,t){const n=se(e);if(mt(e))return n;if(!X(e)){let o=xe(e);for(;o&&!we(o);){if(Y(o)&&!Mt(o))return o;o=xe(o)}return n}let r=un(e,t);for(;r&&Ur(r)&&Mt(r);)r=un(r,t);return r&&we(r)&&Mt(r)&&!zt(r)?n:r||Yr(e)||n}const Jo=async function(e){const t=this.getOffsetParent||nr,n=this.getDimensions,r=await n(e.floating);return{reference:Zo(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function es(e){return ae(e).direction==="rtl"}const ts={convertOffsetParentRelativeRectToViewportRelativeRect:Ho,getDocumentElement:pe,getClippingRect:qo,getOffsetParent:nr,getElementRects:Jo,getClientRects:Wo,getDimensions:Qo,getScale:Be,isElement:Y,isRTL:es};function rr(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ns(e,t){let n=null,r;const o=pe(e);function l(){var u;clearTimeout(r),(u=n)==null||u.disconnect(),n=null}function a(u,s){u===void 0&&(u=!1),s===void 0&&(s=1),l();const i=e.getBoundingClientRect(),{left:c,top:f,width:d,height:h}=i;if(u||t(),!d||!h)return;const m=qe(f),p=qe(o.clientWidth-(c+d)),g=qe(o.clientHeight-(f+h)),y=qe(c),b={rootMargin:-m+"px "+-p+"px "+-g+"px "+-y+"px",threshold:Ie(0,nt(1,s))||1};let C=!0;function S(T){const F=T[0].intersectionRatio;if(F!==s){if(!C)return a();F?a(!1,F):r=setTimeout(()=>{a(!1,1e-7)},1e3)}F===1&&!rr(i,e.getBoundingClientRect())&&a(),C=!1}try{n=new IntersectionObserver(S,{...b,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,b)}n.observe(e)}return a(!0),l}function rs(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:l=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:s=!1}=r,i=Yt(e),c=o||l?[...i?Se(i):[],...Se(t)]:[];c.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),l&&y.addEventListener("resize",n)});const f=i&&u?ns(i,n):null;let d=-1,h=null;a&&(h=new ResizeObserver(y=>{let[w]=y;w&&w.target===i&&h&&(h.unobserve(t),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var b;(b=h)==null||b.observe(t)})),n()}),i&&!s&&h.observe(i),h.observe(t));let m,p=s?Oe(e):null;s&&g();function g(){const y=Oe(e);p&&!rr(p,y)&&n(),p=y,m=requestAnimationFrame(g)}return n(),()=>{var y;c.forEach(w=>{o&&w.removeEventListener("scroll",n),l&&w.removeEventListener("resize",n)}),f==null||f(),(y=h)==null||y.disconnect(),h=null,s&&cancelAnimationFrame(m)}}const os=_o,ss=$o,is=ko,ls=(e,t,n)=>{const r=new Map,o={platform:ts,...n},l={...o.platform,_c:r};return Fo(e,t,{...o,platform:l})};var cs=typeof document<"u",as=function(){},tt=cs?M.useLayoutEffect:as;function at(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(!at(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 l=o[r];if(!(l==="_owner"&&e.$$typeof)&&!at(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}function or(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function fn(e,t){const n=or(e);return Math.round(t*n)/n}function Tt(e){const t=E.useRef(e);return tt(()=>{t.current=e}),t}function us(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:l,floating:a}={},transform:u=!0,whileElementsMounted:s,open:i}=e,[c,f]=E.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[d,h]=E.useState(r);at(d,r)||h(r);const[m,p]=E.useState(null),[g,y]=E.useState(null),w=E.useCallback(R=>{R!==T.current&&(T.current=R,p(R))},[]),b=E.useCallback(R=>{R!==F.current&&(F.current=R,y(R))},[]),C=l||m,S=a||g,T=E.useRef(null),F=E.useRef(null),$=E.useRef(c),W=s!=null,U=Tt(s),N=Tt(o),q=Tt(i),O=E.useCallback(()=>{if(!T.current||!F.current)return;const R={placement:t,strategy:n,middleware:d};N.current&&(R.platform=N.current),ls(T.current,F.current,R).then(I=>{const _={...I,isPositioned:q.current!==!1};v.current&&!at($.current,_)&&($.current=_,Pn.flushSync(()=>{f(_)}))})},[d,t,n,N,q]);tt(()=>{i===!1&&$.current.isPositioned&&($.current.isPositioned=!1,f(R=>({...R,isPositioned:!1})))},[i]);const v=E.useRef(!1);tt(()=>(v.current=!0,()=>{v.current=!1}),[]),tt(()=>{if(C&&(T.current=C),S&&(F.current=S),C&&S){if(U.current)return U.current(C,S,O);O()}},[C,S,O,U,W]);const A=E.useMemo(()=>({reference:T,floating:F,setReference:w,setFloating:b}),[w,b]),k=E.useMemo(()=>({reference:C,floating:S}),[C,S]),j=E.useMemo(()=>{const R={position:n,left:0,top:0};if(!k.floating)return R;const I=fn(k.floating,c.x),_=fn(k.floating,c.y);return u?{...R,transform:"translate("+I+"px, "+_+"px)",...or(k.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:_}},[n,u,k.floating,c.x,c.y]);return E.useMemo(()=>({...c,update:O,refs:A,elements:k,floatingStyles:j}),[c,O,A,k,j])}const fs=(e,t)=>({...os(e),options:[e,t]}),ds=(e,t)=>({...ss(e),options:[e,t]}),hs=(e,t)=>({...is(e),options:[e,t]}),ms="data-floating-ui-focusable",dn="active",hn="selected",ps={...E};let mn=!1,gs=0;const pn=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+gs++;function bs(){const[e,t]=E.useState(()=>mn?pn():void 0);return oe(()=>{e==null&&t(pn())},[]),E.useEffect(()=>{mn=!0},[]),e}const ws=ps.useId,Kt=ws||bs;let Bt;process.env.NODE_ENV!=="production"&&(Bt=new Set);function xs(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const o="Floating UI: "+n.join(" ");if(!((e=Bt)!=null&&e.has(o))){var l;(l=Bt)==null||l.add(o),console.error(o)}}function ys(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(o=>o(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){var r;(r=e.get(t))==null||r.delete(n)}}}const Es=E.createContext(null),vs=E.createContext(null),sr=()=>{var e;return((e=E.useContext(Es))==null?void 0:e.id)||null},Gt=()=>E.useContext(vs);function He(e){return"data-floating-ui-"+e}function Rs(e){e.current!==-1&&(clearTimeout(e.current),e.current=-1)}let gn=0;function Le(e,t){t===void 0&&(t={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=t;r&&cancelAnimationFrame(gn);const l=()=>e==null?void 0:e.focus({preventScroll:n});o?l():gn=requestAnimationFrame(l)}function Cs(e){return(e==null?void 0:e.ownerDocument)||document}const _e={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function bn(e){return e==="inert"?_e.inert:e==="aria-hidden"?_e["aria-hidden"]:_e.none}let Qe=new WeakSet,Ze={},It=0;const As=()=>typeof HTMLElement<"u"&&"inert"in HTMLElement.prototype,ir=e=>e&&(e.host||ir(e.parentNode)),Ss=(e,t)=>t.map(n=>{if(e.contains(n))return n;const r=ir(n);return e.contains(r)?r:null}).filter(n=>n!=null);function Ms(e,t,n,r){const o="data-floating-ui-inert",l=r?"inert":n?"aria-hidden":null,a=Ss(t,e),u=new Set,s=new Set(a),i=[];Ze[o]||(Ze[o]=new WeakMap);const c=Ze[o];a.forEach(f),d(t),u.clear();function f(h){!h||u.has(h)||(u.add(h),h.parentNode&&f(h.parentNode))}function d(h){!h||s.has(h)||[].forEach.call(h.children,m=>{if(Me(m)!=="script")if(u.has(m))d(m);else{const p=l?m.getAttribute(l):null,g=p!==null&&p!=="false",y=bn(l),w=(y.get(m)||0)+1,b=(c.get(m)||0)+1;y.set(m,w),c.set(m,b),i.push(m),w===1&&g&&Qe.add(m),b===1&&m.setAttribute(o,""),!g&&l&&m.setAttribute(l,l==="inert"?"":"true")}})}return It++,()=>{i.forEach(h=>{const m=bn(l),g=(m.get(h)||0)-1,y=(c.get(h)||0)-1;m.set(h,g),c.set(h,y),g||(!Qe.has(h)&&l&&h.removeAttribute(l),Qe.delete(h)),y||h.removeAttribute(o)}),It--,It||(_e.inert=new WeakMap,_e["aria-hidden"]=new WeakMap,_e.none=new WeakMap,Qe=new WeakSet,Ze={})}}function wn(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=Cs(e[0]).body;return Ms(e.concat(Array.from(r.querySelectorAll('[aria-live],[role="status"],output'))),r,t,n)}const Et={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},ut=E.forwardRef(function(t,n){const[r,o]=E.useState();oe(()=>{vo()&&o("button")},[]);const l={ref:n,tabIndex:0,role:r,"aria-hidden":r?void 0:!0,[He("focus-guard")]:"",style:Et};return x.jsx("span",{...t,...l})}),lr=E.createContext(null),xn=He("portal");function Ts(e){e===void 0&&(e={});const{id:t,root:n}=e,r=Kt(),o=cr(),[l,a]=E.useState(null),u=E.useRef(null);return oe(()=>()=>{l==null||l.remove(),queueMicrotask(()=>{u.current=null})},[l]),oe(()=>{if(!r||u.current)return;const s=t?document.getElementById(t):null;if(!s)return;const i=document.createElement("div");i.id=r,i.setAttribute(xn,""),s.appendChild(i),u.current=i,a(i)},[t,r]),oe(()=>{if(n===null||!r||u.current)return;let s=n||(o==null?void 0:o.portalNode);s&&!Wt(s)&&(s=s.current),s=s||document.body;let i=null;t&&(i=document.createElement("div"),i.id=t,s.appendChild(i));const c=document.createElement("div");c.id=r,c.setAttribute(xn,""),s=i||s,s.appendChild(c),u.current=c,a(c)},[t,n,r,o]),l}function Is(e){const{children:t,id:n,root:r,preserveTabOrder:o=!0}=e,l=Ts({id:n,root:r}),[a,u]=E.useState(null),s=E.useRef(null),i=E.useRef(null),c=E.useRef(null),f=E.useRef(null),d=a==null?void 0:a.modal,h=a==null?void 0:a.open,m=!!a&&!a.modal&&a.open&&o&&!!(r||l);return E.useEffect(()=>{if(!l||!o||d)return;function p(g){l&&Ue(g)&&(g.type==="focusin"?sn:Lo)(l)}return l.addEventListener("focusin",p,!0),l.addEventListener("focusout",p,!0),()=>{l.removeEventListener("focusin",p,!0),l.removeEventListener("focusout",p,!0)}},[l,o,d]),E.useEffect(()=>{l&&(h||sn(l))},[h,l]),x.jsxs(lr.Provider,{value:E.useMemo(()=>({preserveTabOrder:o,beforeOutsideRef:s,afterOutsideRef:i,beforeInsideRef:c,afterInsideRef:f,portalNode:l,setFocusManagerState:u}),[o,l]),children:[m&&l&&x.jsx(ut,{"data-type":"outside",ref:s,onFocus:p=>{if(Ue(p,l)){var g;(g=c.current)==null||g.focus()}else{const y=a?a.domReference:null,w=qn(y);w==null||w.focus()}}}),m&&l&&x.jsx("span",{"aria-owns":l.id,style:Et}),l&&Pn.createPortal(t,l),m&&l&&x.jsx(ut,{"data-type":"outside",ref:i,onFocus:p=>{if(Ue(p,l)){var g;(g=f.current)==null||g.focus()}else{const y=a?a.domReference:null,w=Xn(y);w==null||w.focus(),a!=null&&a.closeOnFocusOut&&(a==null||a.onOpenChange(!1,p.nativeEvent,"focus-out"))}}})]})}const cr=()=>E.useContext(lr);function yn(e){return E.useMemo(()=>t=>{e.forEach(n=>{n&&(n.current=t)})},e)}const Ns=20;let Ae=[];function Xt(){Ae=Ae.filter(e=>e.isConnected)}function Ps(e){Xt(),e&&Me(e)!=="body"&&(Ae.push(e),Ae.length>Ns&&(Ae=Ae.slice(-20)))}function En(){return Xt(),Ae[Ae.length-1]}function Os(e){const t=Ke();return Wn(e,t)?e:xt(e,t)[0]||e}function vn(e,t){var n;if(!t.current.includes("floating")&&!((n=e.getAttribute("role"))!=null&&n.includes("dialog")))return;const r=Ke(),l=Eo(e,r).filter(u=>{const s=u.getAttribute("data-tabindex")||"";return Wn(u,r)||u.hasAttribute("data-tabindex")&&!s.startsWith("-")}),a=e.getAttribute("tabindex");t.current.includes("floating")||l.length===0?a!=="0"&&e.setAttribute("tabindex","0"):(a!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}const Ds=E.forwardRef(function(t,n){return x.jsx("button",{...t,type:"button",ref:n,tabIndex:-1,style:Et})});function Ls(e){const{context:t,children:n,disabled:r=!1,order:o=["content"],guards:l=!0,initialFocus:a=0,returnFocus:u=!0,restoreFocus:s=!1,modal:i=!0,visuallyHiddenDismiss:c=!1,closeOnFocusOut:f=!0,outsideElementsInert:d=!1,getInsideElements:h=()=>[]}=e,{open:m,onOpenChange:p,events:g,dataRef:y,elements:{domReference:w,floating:b}}=t,C=he(()=>{var L;return(L=y.current.floatingContext)==null?void 0:L.nodeId}),S=he(h),T=typeof a=="number"&&a<0,F=nn(w)&&T,$=As(),W=$?l:!0,U=!W||$&&d,N=St(o),q=St(a),O=St(u),v=Gt(),A=cr(),k=E.useRef(null),j=E.useRef(null),R=E.useRef(!1),I=E.useRef(!1),_=E.useRef(-1),J=E.useRef(-1),ue=A!=null,P=jt(b),ie=he(function(L){return L===void 0&&(L=P),L?xt(L,Ke()):[]}),G=he(L=>{const V=ie(L);return N.current.map(B=>w&&B==="reference"?w:P&&B==="floating"?P:V).filter(Boolean).flat()});E.useEffect(()=>{if(r||!i)return;function L(B){if(B.key==="Tab"){ne(P,Fe(de(P)))&&ie().length===0&&!F&&At(B);const K=G(),Q=Re(B);N.current[0]==="reference"&&Q===w&&(At(B),B.shiftKey?Le(K[K.length-1]):Le(K[1])),N.current[1]==="floating"&&Q===P&&B.shiftKey&&(At(B),Le(K[0]))}}const V=de(P);return V.addEventListener("keydown",L),()=>{V.removeEventListener("keydown",L)}},[r,w,P,i,N,F,ie,G]),E.useEffect(()=>{if(r||!b)return;function L(V){const B=Re(V),Q=ie().indexOf(B);Q!==-1&&(_.current=Q)}return b.addEventListener("focusin",L),()=>{b.removeEventListener("focusin",L)}},[r,b,ie]),E.useEffect(()=>{if(r||!f)return;function L(){I.current=!0,setTimeout(()=>{I.current=!1})}function V(Q){const H=Q.relatedTarget,ge=Q.currentTarget,ce=Re(Q);queueMicrotask(()=>{const te=C(),Te=!(ne(w,H)||ne(b,H)||ne(H,b)||ne(A==null?void 0:A.portalNode,H)||H!=null&&H.hasAttribute(He("focus-guard"))||v&&(je(v.nodesRef.current,te).find(Ee=>{var be,ve;return ne((be=Ee.context)==null?void 0:be.elements.floating,H)||ne((ve=Ee.context)==null?void 0:ve.elements.domReference,H)})||rn(v.nodesRef.current,te).find(Ee=>{var be,ve,qt;return[(be=Ee.context)==null?void 0:be.elements.floating,jt((ve=Ee.context)==null?void 0:ve.elements.floating)].includes(H)||((qt=Ee.context)==null?void 0:qt.elements.domReference)===H})));if(ge===w&&P&&vn(P,N),s&&ge!==w&&!(ce!=null&&ce.isConnected)&&Fe(de(P))===de(P).body){X(P)&&P.focus();const Ee=_.current,be=ie(),ve=be[Ee]||be[be.length-1]||P;X(ve)&&ve.focus()}if(y.current.insideReactTree){y.current.insideReactTree=!1;return}(F||!i)&&H&&Te&&!I.current&&H!==En()&&(R.current=!0,p(!1,Q,"focus-out"))})}const B=!!(!v&&A);function K(){Rs(J),y.current.insideReactTree=!0,J.current=window.setTimeout(()=>{y.current.insideReactTree=!1})}if(b&&X(w))return w.addEventListener("focusout",V),w.addEventListener("pointerdown",L),b.addEventListener("focusout",V),B&&b.addEventListener("focusout",K,!0),()=>{w.removeEventListener("focusout",V),w.removeEventListener("pointerdown",L),b.removeEventListener("focusout",V),B&&b.removeEventListener("focusout",K,!0)}},[r,w,b,P,i,v,A,p,f,s,ie,F,C,N,y]);const le=E.useRef(null),ye=E.useRef(null),vt=yn([le,A==null?void 0:A.beforeInsideRef]),Rt=yn([ye,A==null?void 0:A.afterInsideRef]);E.useEffect(()=>{var L,V;if(r||!b)return;const B=Array.from((A==null||(L=A.portalNode)==null?void 0:L.querySelectorAll("["+He("portal")+"]"))||[]),Q=(V=(v?rn(v.nodesRef.current,C()):[]).find(ce=>{var te;return nn(((te=ce.context)==null?void 0:te.elements.domReference)||null)}))==null||(V=V.context)==null?void 0:V.elements.domReference,H=[b,Q,...B,...S(),k.current,j.current,le.current,ye.current,A==null?void 0:A.beforeOutsideRef.current,A==null?void 0:A.afterOutsideRef.current,N.current.includes("reference")||F?w:null].filter(ce=>ce!=null),ge=i||F?wn(H,!U,U):wn(H);return()=>{ge()}},[r,w,b,i,N,A,F,W,U,v,C,S]),oe(()=>{if(r||!X(P))return;const L=de(P),V=Fe(L);queueMicrotask(()=>{const B=G(P),K=q.current,Q=(typeof K=="number"?B[K]:K.current)||P,H=ne(P,V);!T&&!H&&m&&Le(Q,{preventScroll:Q===P})})},[r,m,P,T,G,q]),oe(()=>{if(r||!P)return;const L=de(P),V=Fe(L);Ps(V);function B(H){let{reason:ge,event:ce,nested:te}=H;if(["hover","safe-polygon"].includes(ge)&&ce.type==="mouseleave"&&(R.current=!0),ge==="outside-press")if(te)R.current=!1;else if(Mo(ce)||To(ce))R.current=!1;else{let Te=!1;document.createElement("div").focus({get preventScroll(){return Te=!0,!1}}),Te?R.current=!1:R.current=!0}}g.on("openchange",B);const K=L.createElement("span");K.setAttribute("tabindex","-1"),K.setAttribute("aria-hidden","true"),Object.assign(K.style,Et),ue&&w&&w.insertAdjacentElement("afterend",K);function Q(){if(typeof O.current=="boolean"){const H=w||En();return H&&H.isConnected?H:K}return O.current.current||K}return()=>{g.off("openchange",B);const H=Fe(L),ge=ne(b,H)||v&&je(v.nodesRef.current,C(),!1).some(te=>{var Te;return ne((Te=te.context)==null?void 0:Te.elements.floating,H)}),ce=Q();queueMicrotask(()=>{const te=Os(ce);O.current&&!R.current&&X(te)&&(!(te!==H&&H!==L.body)||ge)&&te.focus({preventScroll:!0}),K.remove()})}},[r,b,P,O,y,g,v,ue,w,C]),E.useEffect(()=>(queueMicrotask(()=>{R.current=!1}),()=>{queueMicrotask(Xt)}),[r]),oe(()=>{if(!r&&A)return A.setFocusManagerState({modal:i,closeOnFocusOut:f,open:m,onOpenChange:p,domReference:w}),()=>{A.setFocusManagerState(null)}},[r,A,i,m,p,f,w]),oe(()=>{r||P&&vn(P,N)},[r,P,N]);function Ge(L){return r||!c||!i?null:x.jsx(Ds,{ref:L==="start"?k:j,onClick:V=>p(!1,V.nativeEvent),children:typeof c=="string"?c:"Dismiss"})}const Xe=!r&&W&&(i?!F:!0)&&(ue||i);return x.jsxs(x.Fragment,{children:[Xe&&x.jsx(ut,{"data-type":"inside",ref:vt,onFocus:L=>{if(i){const B=G();Le(o[0]==="reference"?B[0]:B[B.length-1])}else if(A!=null&&A.preserveTabOrder&&A.portalNode)if(R.current=!1,Ue(L,A.portalNode)){const B=Xn(w);B==null||B.focus()}else{var V;(V=A.beforeOutsideRef.current)==null||V.focus()}}}),!F&&Ge("start"),n,Ge("end"),Xe&&x.jsx(ut,{"data-type":"inside",ref:Rt,onFocus:L=>{if(i)Le(G()[0]);else if(A!=null&&A.preserveTabOrder&&A.portalNode)if(f&&(R.current=!0),Ue(L,A.portalNode)){const B=qn(w);B==null||B.focus()}else{var V;(V=A.afterOutsideRef.current)==null||V.focus()}}})]})}let Je=0;const Rn="--floating-ui-scrollbar-width";function Fs(){const e=zn(),t=/iP(hone|ad|od)|iOS/.test(e)||e==="MacIntel"&&navigator.maxTouchPoints>1,n=document.body.style,o=Math.round(document.documentElement.getBoundingClientRect().left)+document.documentElement.scrollLeft?"paddingLeft":"paddingRight",l=window.innerWidth-document.documentElement.clientWidth,a=n.left?parseFloat(n.left):window.scrollX,u=n.top?parseFloat(n.top):window.scrollY;if(n.overflow="hidden",n.setProperty(Rn,l+"px"),l&&(n[o]=l+"px"),t){var s,i;const c=((s=window.visualViewport)==null?void 0:s.offsetLeft)||0,f=((i=window.visualViewport)==null?void 0:i.offsetTop)||0;Object.assign(n,{position:"fixed",top:-(u-Math.floor(f))+"px",left:-(a-Math.floor(c))+"px",right:"0"})}return()=>{Object.assign(n,{overflow:"",[o]:""}),n.removeProperty(Rn),t&&(Object.assign(n,{position:"",top:"",left:"",right:""}),window.scrollTo(a,u))}}let Cn=()=>{};const ks=E.forwardRef(function(t,n){const{lockScroll:r=!1,...o}=t;return oe(()=>{if(r)return Je++,Je===1&&(Cn=Fs()),()=>{Je--,Je===0&&Cn()}},[r]),x.jsx("div",{ref:n,...o,style:{position:"fixed",overflow:"auto",top:0,right:0,bottom:0,left:0,...o.style}})});function An(e){return X(e.target)&&e.target.tagName==="BUTTON"}function js(e){return X(e.target)&&e.target.tagName==="A"}function Sn(e){return Kn(e)}function Bs(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,dataRef:o,elements:{domReference:l}}=e,{enabled:a=!0,event:u="click",toggle:s=!0,ignoreMouse:i=!1,keyboardHandlers:c=!0,stickIfOpen:f=!0}=t,d=E.useRef(),h=E.useRef(!1),m=E.useMemo(()=>({onPointerDown(p){d.current=p.pointerType},onMouseDown(p){const g=d.current;p.button===0&&u!=="click"&&(on(g)&&i||(n&&s&&(!(o.current.openEvent&&f)||o.current.openEvent.type==="mousedown")?r(!1,p.nativeEvent,"click"):(p.preventDefault(),r(!0,p.nativeEvent,"click"))))},onClick(p){const g=d.current;if(u==="mousedown"&&d.current){d.current=void 0;return}on(g)&&i||(n&&s&&(!(o.current.openEvent&&f)||o.current.openEvent.type==="click")?r(!1,p.nativeEvent,"click"):r(!0,p.nativeEvent,"click"))},onKeyDown(p){d.current=void 0,!(p.defaultPrevented||!c||An(p))&&(p.key===" "&&!Sn(l)&&(p.preventDefault(),h.current=!0),!js(p)&&p.key==="Enter"&&r(!(n&&s),p.nativeEvent,"click"))},onKeyUp(p){p.defaultPrevented||!c||An(p)||Sn(l)||p.key===" "&&h.current&&(h.current=!1,r(!(n&&s),p.nativeEvent,"click"))}}),[o,l,u,i,c,r,n,f,s]);return E.useMemo(()=>a?{reference:m}:{},[a,m])}const _s={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},$s={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Mn=e=>{var t,n;return{escapeKey:typeof e=="boolean"?e:(t=e==null?void 0:e.escapeKey)!=null?t:!1,outsidePress:typeof e=="boolean"?e:(n=e==null?void 0:e.outsidePress)!=null?n:!0}};function ar(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,elements:o,dataRef:l}=e,{enabled:a=!0,escapeKey:u=!0,outsidePress:s=!0,outsidePressEvent:i="pointerdown",referencePress:c=!1,referencePressEvent:f="pointerdown",ancestorScroll:d=!1,bubbles:h,capture:m}=t,p=Gt(),g=he(typeof s=="function"?s:()=>!1),y=typeof s=="function"?g:s,w=E.useRef(!1),{escapeKey:b,outsidePress:C}=Mn(h),{escapeKey:S,outsidePress:T}=Mn(m),F=E.useRef(!1),$=he(v=>{var A;if(!n||!a||!u||v.key!=="Escape"||F.current)return;const k=(A=l.current.floatingContext)==null?void 0:A.nodeId,j=p?je(p.nodesRef.current,k):[];if(!b&&(v.stopPropagation(),j.length>0)){let R=!0;if(j.forEach(I=>{var _;if((_=I.context)!=null&&_.open&&!I.context.dataRef.current.__escapeKeyBubbles){R=!1;return}}),!R)return}r(!1,So(v)?v.nativeEvent:v,"escape-key")}),W=he(v=>{var A;const k=()=>{var j;$(v),(j=Re(v))==null||j.removeEventListener("keydown",k)};(A=Re(v))==null||A.addEventListener("keydown",k)}),U=he(v=>{var A;const k=l.current.insideReactTree;l.current.insideReactTree=!1;const j=w.current;if(w.current=!1,i==="click"&&j||k||typeof y=="function"&&!y(v))return;const R=Re(v),I="["+He("inert")+"]",_=de(o.floating).querySelectorAll(I);let J=Y(R)?R:null;for(;J&&!we(J);){const G=xe(J);if(we(G)||!Y(G))break;J=G}if(_.length&&Y(R)&&!Ao(R)&&!ne(R,o.floating)&&Array.from(_).every(G=>!ne(J,G)))return;if(X(R)&&O){const G=we(R),le=ae(R),ye=/auto|scroll/,vt=G||ye.test(le.overflowX),Rt=G||ye.test(le.overflowY),Ge=vt&&R.clientWidth>0&&R.scrollWidth>R.clientWidth,Xe=Rt&&R.clientHeight>0&&R.scrollHeight>R.clientHeight,L=le.direction==="rtl",V=Xe&&(L?v.offsetX<=R.offsetWidth-R.clientWidth:v.offsetX>R.clientWidth),B=Ge&&v.offsetY>R.clientHeight;if(V||B)return}const ue=(A=l.current.floatingContext)==null?void 0:A.nodeId,P=p&&je(p.nodesRef.current,ue).some(G=>{var le;return Ct(v,(le=G.context)==null?void 0:le.elements.floating)});if(Ct(v,o.floating)||Ct(v,o.domReference)||P)return;const ie=p?je(p.nodesRef.current,ue):[];if(ie.length>0){let G=!0;if(ie.forEach(le=>{var ye;if((ye=le.context)!=null&&ye.open&&!le.context.dataRef.current.__outsidePressBubbles){G=!1;return}}),!G)return}r(!1,v,"outside-press")}),N=he(v=>{var A;const k=()=>{var j;U(v),(j=Re(v))==null||j.removeEventListener(i,k)};(A=Re(v))==null||A.addEventListener(i,k)});E.useEffect(()=>{if(!n||!a)return;l.current.__escapeKeyBubbles=b,l.current.__outsidePressBubbles=C;let v=-1;function A(_){r(!1,_,"ancestor-scroll")}function k(){window.clearTimeout(v),F.current=!0}function j(){v=window.setTimeout(()=>{F.current=!1},pt()?5:0)}const R=de(o.floating);u&&(R.addEventListener("keydown",S?W:$,S),R.addEventListener("compositionstart",k),R.addEventListener("compositionend",j)),y&&R.addEventListener(i,T?N:U,T);let I=[];return d&&(Y(o.domReference)&&(I=Se(o.domReference)),Y(o.floating)&&(I=I.concat(Se(o.floating))),!Y(o.reference)&&o.reference&&o.reference.contextElement&&(I=I.concat(Se(o.reference.contextElement)))),I=I.filter(_=>{var J;return _!==((J=R.defaultView)==null?void 0:J.visualViewport)}),I.forEach(_=>{_.addEventListener("scroll",A,{passive:!0})}),()=>{u&&(R.removeEventListener("keydown",S?W:$,S),R.removeEventListener("compositionstart",k),R.removeEventListener("compositionend",j)),y&&R.removeEventListener(i,T?N:U,T),I.forEach(_=>{_.removeEventListener("scroll",A)}),window.clearTimeout(v)}},[l,o,u,y,i,n,r,d,a,b,C,$,S,W,U,T,N]),E.useEffect(()=>{l.current.insideReactTree=!1},[l,y,i]);const q=E.useMemo(()=>({onKeyDown:$,...c&&{[_s[f]]:v=>{r(!1,v.nativeEvent,"reference-press")},...f!=="click"&&{onClick(v){r(!1,v.nativeEvent,"reference-press")}}}}),[$,r,c,f]),O=E.useMemo(()=>({onKeyDown:$,onMouseDown(){w.current=!0},onMouseUp(){w.current=!0},[$s[i]]:()=>{l.current.insideReactTree=!0}}),[$,i,l]);return E.useMemo(()=>a?{reference:q,floating:O}:{},[a,q,O])}function Us(e){const{open:t=!1,onOpenChange:n,elements:r}=e,o=Kt(),l=E.useRef({}),[a]=E.useState(()=>ys()),u=sr()!=null;if(process.env.NODE_ENV!=="production"){const h=r.reference;h&&!Y(h)&&xs("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[s,i]=E.useState(r.reference),c=he((h,m,p)=>{l.current.openEvent=h?m:void 0,a.emit("openchange",{open:h,event:m,reason:p,nested:u}),n==null||n(h,m,p)}),f=E.useMemo(()=>({setPositionReference:i}),[]),d=E.useMemo(()=>({reference:s||r.reference||null,floating:r.floating||null,domReference:r.reference}),[s,r.reference,r.floating]);return E.useMemo(()=>({dataRef:l,open:t,onOpenChange:c,elements:d,events:a,floatingId:o,refs:f}),[t,c,d,a,o,f])}function ur(e){e===void 0&&(e={});const{nodeId:t}=e,n=Us({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||n,o=r.elements,[l,a]=E.useState(null),[u,s]=E.useState(null),c=(o==null?void 0:o.domReference)||l,f=E.useRef(null),d=Gt();oe(()=>{c&&(f.current=c)},[c]);const h=us({...e,elements:{...o,...u&&{reference:u}}}),m=E.useCallback(b=>{const C=Y(b)?{getBoundingClientRect:()=>b.getBoundingClientRect(),getClientRects:()=>b.getClientRects(),contextElement:b}:b;s(C),h.refs.setReference(C)},[h.refs]),p=E.useCallback(b=>{(Y(b)||b===null)&&(f.current=b,a(b)),(Y(h.refs.reference.current)||h.refs.reference.current===null||b!==null&&!Y(b))&&h.refs.setReference(b)},[h.refs]),g=E.useMemo(()=>({...h.refs,setReference:p,setPositionReference:m,domReference:f}),[h.refs,p,m]),y=E.useMemo(()=>({...h.elements,domReference:c}),[h.elements,c]),w=E.useMemo(()=>({...h,...r,refs:g,elements:y,nodeId:t}),[h,g,y,t,r]);return oe(()=>{r.dataRef.current.floatingContext=w;const b=d==null?void 0:d.nodesRef.current.find(C=>C.id===t);b&&(b.context=w)}),E.useMemo(()=>({...h,context:w,refs:g,elements:y}),[h,g,y,w])}function Nt(e,t,n){const r=new Map,o=n==="item";let l=e;if(o&&e){const{[dn]:a,[hn]:u,...s}=e;l=s}return{...n==="floating"&&{tabIndex:-1,[ms]:""},...l,...t.map(a=>{const u=a?a[n]:null;return typeof u=="function"?e?u(e):null:u}).concat(e).reduce((a,u)=>(u&&Object.entries(u).forEach(s=>{let[i,c]=s;if(!(o&&[dn,hn].includes(i)))if(i.indexOf("on")===0){if(r.has(i)||r.set(i,[]),typeof c=="function"){var f;(f=r.get(i))==null||f.push(c),a[i]=function(){for(var d,h=arguments.length,m=new Array(h),p=0;p<h;p++)m[p]=arguments[p];return(d=r.get(i))==null?void 0:d.map(g=>g(...m)).find(g=>g!==void 0)}}}else a[i]=c}),a),{})}}function fr(e){e===void 0&&(e=[]);const t=e.map(u=>u==null?void 0:u.reference),n=e.map(u=>u==null?void 0:u.floating),r=e.map(u=>u==null?void 0:u.item),o=E.useCallback(u=>Nt(u,e,"reference"),t),l=E.useCallback(u=>Nt(u,e,"floating"),n),a=E.useCallback(u=>Nt(u,e,"item"),r);return E.useMemo(()=>({getReferenceProps:o,getFloatingProps:l,getItemProps:a}),[o,l,a])}const Vs=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function Hs(e,t){var n,r;t===void 0&&(t={});const{open:o,elements:l,floatingId:a}=e,{enabled:u=!0,role:s="dialog"}=t,i=Kt(),c=((n=l.domReference)==null?void 0:n.id)||i,f=E.useMemo(()=>{var w;return((w=jt(l.floating))==null?void 0:w.id)||a},[l.floating,a]),d=(r=Vs.get(s))!=null?r:s,m=sr()!=null,p=E.useMemo(()=>d==="tooltip"||s==="label"?{["aria-"+(s==="label"?"labelledby":"describedby")]:o?f:void 0}:{"aria-expanded":o?"true":"false","aria-haspopup":d==="alertdialog"?"dialog":d,"aria-controls":o?f:void 0,...d==="listbox"&&{role:"combobox"},...d==="menu"&&{id:c},...d==="menu"&&m&&{role:"menuitem"},...s==="select"&&{"aria-autocomplete":"none"},...s==="combobox"&&{"aria-autocomplete":"list"}},[d,f,m,o,c,s]),g=E.useMemo(()=>{const w={id:f,...d&&{role:d}};return d==="tooltip"||s==="label"?w:{...w,...d==="menu"&&{"aria-labelledby":c}}},[d,f,c,s]),y=E.useCallback(w=>{let{active:b,selected:C}=w;const S={role:"option",...b&&{id:f+"-fui-option"}};switch(s){case"select":case"combobox":return{...S,"aria-selected":C}}return{}},[f,s]);return E.useMemo(()=>u?{reference:p,floating:g,item:y}:{},[u,p,g,y])}var re=(e=>(e.Closed="Closed",e.Opened="Opened",e))(re||{}),We=(e=>(e.LG="Large",e.SM="Small",e))(We||{});const Ws=({title:e,btnClassNames:t,iconWidth:n,iconHeight:r,onClick:o})=>x.jsx("button",{type:"button","aria-label":"button",className:t,title:e,onClick:o,children:x.jsx(Ne.IconX,{height:r||20,width:n||20})}),zs=({portalId:e,state:t=re.Opened,heading:n,size:r,onClose:o,children:l,overlayClassName:a,containerClassName:u,dividers:s=!0,closeButtonTitle:i})=>{const{refs:c,context:f}=ur({open:t!==re.Closed&&!!t,onOpenChange:o}),d=Hs(f,{role:"dialog"}),h=ar(f,{outsidePress:!0}),{getFloatingProps:m}=fr([d,h]),p=M.useCallback(g=>{g==null||g.preventDefault(),g==null||g.stopPropagation(),o()},[o]);return x.jsx(Is,{id:e,children:t!==re.Closed&&x.jsx(ks,{className:Z("z-[52] flex items-center justify-center bg-blackout p-4",a),children:x.jsx(Ls,{context:f,children:x.jsxs("div",{className:Z("relative max-h-full modal rounded bg-white flex flex-col shadow w-full",r===We.LG&&"max-w-[65%]",r===We.SM&&"max-w-[30%]",s&&"divide-neutrals-400 divide-y",u,"sm:w-full sm:max-w-full sm:px-4 sm:py-6"),ref:c.setFloating,...m({onClick(g){g.stopPropagation()}}),children:[x.jsxs("div",{className:"flex flex-row justify-between py-3 px-6 items-center mb-2 modal-heading sm:p-0 sm:pb-2",children:[n&&(typeof n=="string"?x.jsx("h2",{className:"flex-1 min-w-0 mr-3 modal-heading-title sm:h3",children:n}):n),x.jsx(Ws,{title:i,onClick:p,btnClassNames:"sm:h-[24px] sm:w-[24px] sm:top-4"})]}),l.map(g=>g)]})})})})},dr=e=>e.state===re.Closed?null:x.jsx(zs,{...e}),Ys=({onCloseModal:e,disableModalDividers:t,deleteConversation:n,isSmallButton:r,titles:o,locale:l})=>x.jsxs(dr,{heading:(o==null?void 0:o.deleteTitle)??"Delete conversation",portalId:"delete-conversation",containerClassName:"delete-conversation-popup",size:We.SM,dividers:!t,onClose:e,closeButtonTitle:(o==null?void 0:o.close)??"Cancel",children:[x.jsx("div",{className:"py-4 px-6",lang:l,children:(o==null?void 0:o.deleteMessage)??"Are you sure you want to delete this conversation? This action cannot be undone."}),x.jsxs("div",{className:"flex justify-end gap-x-2 py-3 px-6 delete-conversation-popup-footer",children:[x.jsx(Ve,{buttonClassName:"cancel-button",title:(o==null?void 0:o.cancel)??"Cancel",isSmallButton:r,onClick:a=>{a.stopPropagation(),e()}}),x.jsx(Ve,{buttonClassName:"text-button-primary text-button-primary-error",title:(o==null?void 0:o.delete)??"Delete",isSmallButton:r,onClick:a=>{a.stopPropagation(),n()}})]})]}),Ks=e=>{const t=e.messages.flatMap(r=>{var a,u,s;const o=((a=r.custom_content)==null?void 0:a.attachments)||[],l=((s=(u=r.custom_content)==null?void 0:u.stages)==null?void 0:s.flatMap(({attachments:i})=>i??[]))||[];return[...o,...l]})||[],n=Qs(t).map(r=>({...r,relativePath:"",contentLength:0}));return Vt.uniqBy(n,r=>ze(r.relativePath,r.name))},Gs=e=>e.endsWith("/"),Xs=e=>{const t=e.toLowerCase();return["data:","//","http://","https://","file://","ftp://","mailto:","telnet://","api/files"].some(n=>t.startsWith(n))},qs=e=>{const t=ze(...e.split("/").map(r=>decodeURIComponent(r))),n=t.lastIndexOf("/");return{absolutePath:t.slice(0,n),name:t.slice(n+1)}},Qs=e=>e?e.map(t=>{if(!t.url||Xs(t.url)||Gs(t.url))return null;const{absolutePath:n,name:r}=qs(t.url);return{id:t.url,name:r,contentType:t.type,folderId:n,absolutePath:n}}).filter(Boolean):[];async function Zs(e,t){const n=Ks(e),r=new Or;n.forEach(u=>{const s=encodeURI(ze(u.absolutePath,u.name)),i=t(`${s}`.replace("files/","")),c=Js(u.folderId),f=ze("res",c,u.name);r.file(f,i)});const o={version:5,history:[e].map(ei)||[],folders:[]},l=JSON.stringify(o,null,2);return r.file("conversations/conversations_history.json",l),await r.generateAsync({type:"base64"})}const Js=e=>{const t=e.split("/");return t.length>2?ze(...t.slice(2)):void 0},ei=e=>Vt.omit(e,["publicationInfo"]),ze=(...e)=>e.filter(Boolean).join("/");function ti(e,t){const n=document.createElement("a");n.download=t,n.href=e,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(e)}var ni=Object.defineProperty,ft=Object.getOwnPropertySymbols,hr=Object.prototype.hasOwnProperty,mr=Object.prototype.propertyIsEnumerable,Tn=(e,t,n)=>t in e?ni(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_t=(e,t)=>{for(var n in t||(t={}))hr.call(t,n)&&Tn(e,n,t[n]);if(ft)for(var n of ft(t))mr.call(t,n)&&Tn(e,n,t[n]);return e},$t=(e,t)=>{var n={};for(var r in e)hr.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ft)for(var r of ft(e))t.indexOf(r)<0&&mr.call(e,r)&&(n[r]=e[r]);return n};/**
5
+ * @license QR Code generator library (TypeScript)
6
+ * Copyright (c) Project Nayuki.
7
+ * SPDX-License-Identifier: MIT
8
+ */var De;(e=>{const t=class D{constructor(s,i,c,f){if(this.version=s,this.errorCorrectionLevel=i,this.modules=[],this.isFunction=[],s<D.MIN_VERSION||s>D.MAX_VERSION)throw new RangeError("Version value out of range");if(f<-1||f>7)throw new RangeError("Mask value out of range");this.size=s*4+17;let d=[];for(let m=0;m<this.size;m++)d.push(!1);for(let m=0;m<this.size;m++)this.modules.push(d.slice()),this.isFunction.push(d.slice());this.drawFunctionPatterns();const h=this.addEccAndInterleave(c);if(this.drawCodewords(h),f==-1){let m=1e9;for(let p=0;p<8;p++){this.applyMask(p),this.drawFormatBits(p);const g=this.getPenaltyScore();g<m&&(f=p,m=g),this.applyMask(p)}}o(0<=f&&f<=7),this.mask=f,this.applyMask(f),this.drawFormatBits(f),this.isFunction=[]}static encodeText(s,i){const c=e.QrSegment.makeSegments(s);return D.encodeSegments(c,i)}static encodeBinary(s,i){const c=e.QrSegment.makeBytes(s);return D.encodeSegments([c],i)}static encodeSegments(s,i,c=1,f=40,d=-1,h=!0){if(!(D.MIN_VERSION<=c&&c<=f&&f<=D.MAX_VERSION)||d<-1||d>7)throw new RangeError("Invalid value");let m,p;for(m=c;;m++){const b=D.getNumDataCodewords(m,i)*8,C=a.getTotalBits(s,m);if(C<=b){p=C;break}if(m>=f)throw new RangeError("Data too long")}for(const b of[D.Ecc.MEDIUM,D.Ecc.QUARTILE,D.Ecc.HIGH])h&&p<=D.getNumDataCodewords(m,b)*8&&(i=b);let g=[];for(const b of s){n(b.mode.modeBits,4,g),n(b.numChars,b.mode.numCharCountBits(m),g);for(const C of b.getData())g.push(C)}o(g.length==p);const y=D.getNumDataCodewords(m,i)*8;o(g.length<=y),n(0,Math.min(4,y-g.length),g),n(0,(8-g.length%8)%8,g),o(g.length%8==0);for(let b=236;g.length<y;b^=253)n(b,8,g);let w=[];for(;w.length*8<g.length;)w.push(0);return g.forEach((b,C)=>w[C>>>3]|=b<<7-(C&7)),new D(m,i,w,d)}getModule(s,i){return 0<=s&&s<this.size&&0<=i&&i<this.size&&this.modules[i][s]}getModules(){return this.modules}drawFunctionPatterns(){for(let c=0;c<this.size;c++)this.setFunctionModule(6,c,c%2==0),this.setFunctionModule(c,6,c%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const s=this.getAlignmentPatternPositions(),i=s.length;for(let c=0;c<i;c++)for(let f=0;f<i;f++)c==0&&f==0||c==0&&f==i-1||c==i-1&&f==0||this.drawAlignmentPattern(s[c],s[f]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(s){const i=this.errorCorrectionLevel.formatBits<<3|s;let c=i;for(let d=0;d<10;d++)c=c<<1^(c>>>9)*1335;const f=(i<<10|c)^21522;o(f>>>15==0);for(let d=0;d<=5;d++)this.setFunctionModule(8,d,r(f,d));this.setFunctionModule(8,7,r(f,6)),this.setFunctionModule(8,8,r(f,7)),this.setFunctionModule(7,8,r(f,8));for(let d=9;d<15;d++)this.setFunctionModule(14-d,8,r(f,d));for(let d=0;d<8;d++)this.setFunctionModule(this.size-1-d,8,r(f,d));for(let d=8;d<15;d++)this.setFunctionModule(8,this.size-15+d,r(f,d));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let s=this.version;for(let c=0;c<12;c++)s=s<<1^(s>>>11)*7973;const i=this.version<<12|s;o(i>>>18==0);for(let c=0;c<18;c++){const f=r(i,c),d=this.size-11+c%3,h=Math.floor(c/3);this.setFunctionModule(d,h,f),this.setFunctionModule(h,d,f)}}drawFinderPattern(s,i){for(let c=-4;c<=4;c++)for(let f=-4;f<=4;f++){const d=Math.max(Math.abs(f),Math.abs(c)),h=s+f,m=i+c;0<=h&&h<this.size&&0<=m&&m<this.size&&this.setFunctionModule(h,m,d!=2&&d!=4)}}drawAlignmentPattern(s,i){for(let c=-2;c<=2;c++)for(let f=-2;f<=2;f++)this.setFunctionModule(s+f,i+c,Math.max(Math.abs(f),Math.abs(c))!=1)}setFunctionModule(s,i,c){this.modules[i][s]=c,this.isFunction[i][s]=!0}addEccAndInterleave(s){const i=this.version,c=this.errorCorrectionLevel;if(s.length!=D.getNumDataCodewords(i,c))throw new RangeError("Invalid argument");const f=D.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][i],d=D.ECC_CODEWORDS_PER_BLOCK[c.ordinal][i],h=Math.floor(D.getNumRawDataModules(i)/8),m=f-h%f,p=Math.floor(h/f);let g=[];const y=D.reedSolomonComputeDivisor(d);for(let b=0,C=0;b<f;b++){let S=s.slice(C,C+p-d+(b<m?0:1));C+=S.length;const T=D.reedSolomonComputeRemainder(S,y);b<m&&S.push(0),g.push(S.concat(T))}let w=[];for(let b=0;b<g[0].length;b++)g.forEach((C,S)=>{(b!=p-d||S>=m)&&w.push(C[b])});return o(w.length==h),w}drawCodewords(s){if(s.length!=Math.floor(D.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let i=0;for(let c=this.size-1;c>=1;c-=2){c==6&&(c=5);for(let f=0;f<this.size;f++)for(let d=0;d<2;d++){const h=c-d,p=(c+1&2)==0?this.size-1-f:f;!this.isFunction[p][h]&&i<s.length*8&&(this.modules[p][h]=r(s[i>>>3],7-(i&7)),i++)}}o(i==s.length*8)}applyMask(s){if(s<0||s>7)throw new RangeError("Mask value out of range");for(let i=0;i<this.size;i++)for(let c=0;c<this.size;c++){let f;switch(s){case 0:f=(c+i)%2==0;break;case 1:f=i%2==0;break;case 2:f=c%3==0;break;case 3:f=(c+i)%3==0;break;case 4:f=(Math.floor(c/3)+Math.floor(i/2))%2==0;break;case 5:f=c*i%2+c*i%3==0;break;case 6:f=(c*i%2+c*i%3)%2==0;break;case 7:f=((c+i)%2+c*i%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[i][c]&&f&&(this.modules[i][c]=!this.modules[i][c])}}getPenaltyScore(){let s=0;for(let d=0;d<this.size;d++){let h=!1,m=0,p=[0,0,0,0,0,0,0];for(let g=0;g<this.size;g++)this.modules[d][g]==h?(m++,m==5?s+=D.PENALTY_N1:m>5&&s++):(this.finderPenaltyAddHistory(m,p),h||(s+=this.finderPenaltyCountPatterns(p)*D.PENALTY_N3),h=this.modules[d][g],m=1);s+=this.finderPenaltyTerminateAndCount(h,m,p)*D.PENALTY_N3}for(let d=0;d<this.size;d++){let h=!1,m=0,p=[0,0,0,0,0,0,0];for(let g=0;g<this.size;g++)this.modules[g][d]==h?(m++,m==5?s+=D.PENALTY_N1:m>5&&s++):(this.finderPenaltyAddHistory(m,p),h||(s+=this.finderPenaltyCountPatterns(p)*D.PENALTY_N3),h=this.modules[g][d],m=1);s+=this.finderPenaltyTerminateAndCount(h,m,p)*D.PENALTY_N3}for(let d=0;d<this.size-1;d++)for(let h=0;h<this.size-1;h++){const m=this.modules[d][h];m==this.modules[d][h+1]&&m==this.modules[d+1][h]&&m==this.modules[d+1][h+1]&&(s+=D.PENALTY_N2)}let i=0;for(const d of this.modules)i=d.reduce((h,m)=>h+(m?1:0),i);const c=this.size*this.size,f=Math.ceil(Math.abs(i*20-c*10)/c)-1;return o(0<=f&&f<=9),s+=f*D.PENALTY_N4,o(0<=s&&s<=2568888),s}getAlignmentPatternPositions(){if(this.version==1)return[];{const s=Math.floor(this.version/7)+2,i=this.version==32?26:Math.ceil((this.version*4+4)/(s*2-2))*2;let c=[6];for(let f=this.size-7;c.length<s;f-=i)c.splice(1,0,f);return c}}static getNumRawDataModules(s){if(s<D.MIN_VERSION||s>D.MAX_VERSION)throw new RangeError("Version number out of range");let i=(16*s+128)*s+64;if(s>=2){const c=Math.floor(s/7)+2;i-=(25*c-10)*c-55,s>=7&&(i-=36)}return o(208<=i&&i<=29648),i}static getNumDataCodewords(s,i){return Math.floor(D.getNumRawDataModules(s)/8)-D.ECC_CODEWORDS_PER_BLOCK[i.ordinal][s]*D.NUM_ERROR_CORRECTION_BLOCKS[i.ordinal][s]}static reedSolomonComputeDivisor(s){if(s<1||s>255)throw new RangeError("Degree out of range");let i=[];for(let f=0;f<s-1;f++)i.push(0);i.push(1);let c=1;for(let f=0;f<s;f++){for(let d=0;d<i.length;d++)i[d]=D.reedSolomonMultiply(i[d],c),d+1<i.length&&(i[d]^=i[d+1]);c=D.reedSolomonMultiply(c,2)}return i}static reedSolomonComputeRemainder(s,i){let c=i.map(f=>0);for(const f of s){const d=f^c.shift();c.push(0),i.forEach((h,m)=>c[m]^=D.reedSolomonMultiply(h,d))}return c}static reedSolomonMultiply(s,i){if(s>>>8||i>>>8)throw new RangeError("Byte out of range");let c=0;for(let f=7;f>=0;f--)c=c<<1^(c>>>7)*285,c^=(i>>>f&1)*s;return o(c>>>8==0),c}finderPenaltyCountPatterns(s){const i=s[1];o(i<=this.size*3);const c=i>0&&s[2]==i&&s[3]==i*3&&s[4]==i&&s[5]==i;return(c&&s[0]>=i*4&&s[6]>=i?1:0)+(c&&s[6]>=i*4&&s[0]>=i?1:0)}finderPenaltyTerminateAndCount(s,i,c){return s&&(this.finderPenaltyAddHistory(i,c),i=0),i+=this.size,this.finderPenaltyAddHistory(i,c),this.finderPenaltyCountPatterns(c)}finderPenaltyAddHistory(s,i){i[0]==0&&(s+=this.size),i.pop(),i.unshift(s)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(u,s,i){if(s<0||s>31||u>>>s)throw new RangeError("Value out of range");for(let c=s-1;c>=0;c--)i.push(u>>>c&1)}function r(u,s){return(u>>>s&1)!=0}function o(u){if(!u)throw new Error("Assertion error")}const l=class z{constructor(s,i,c){if(this.mode=s,this.numChars=i,this.bitData=c,i<0)throw new RangeError("Invalid argument");this.bitData=c.slice()}static makeBytes(s){let i=[];for(const c of s)n(c,8,i);return new z(z.Mode.BYTE,s.length,i)}static makeNumeric(s){if(!z.isNumeric(s))throw new RangeError("String contains non-numeric characters");let i=[];for(let c=0;c<s.length;){const f=Math.min(s.length-c,3);n(parseInt(s.substring(c,c+f),10),f*3+1,i),c+=f}return new z(z.Mode.NUMERIC,s.length,i)}static makeAlphanumeric(s){if(!z.isAlphanumeric(s))throw new RangeError("String contains unencodable characters in alphanumeric mode");let i=[],c;for(c=0;c+2<=s.length;c+=2){let f=z.ALPHANUMERIC_CHARSET.indexOf(s.charAt(c))*45;f+=z.ALPHANUMERIC_CHARSET.indexOf(s.charAt(c+1)),n(f,11,i)}return c<s.length&&n(z.ALPHANUMERIC_CHARSET.indexOf(s.charAt(c)),6,i),new z(z.Mode.ALPHANUMERIC,s.length,i)}static makeSegments(s){return s==""?[]:z.isNumeric(s)?[z.makeNumeric(s)]:z.isAlphanumeric(s)?[z.makeAlphanumeric(s)]:[z.makeBytes(z.toUtf8ByteArray(s))]}static makeEci(s){let i=[];if(s<0)throw new RangeError("ECI assignment value out of range");if(s<128)n(s,8,i);else if(s<16384)n(2,2,i),n(s,14,i);else if(s<1e6)n(6,3,i),n(s,21,i);else throw new RangeError("ECI assignment value out of range");return new z(z.Mode.ECI,0,i)}static isNumeric(s){return z.NUMERIC_REGEX.test(s)}static isAlphanumeric(s){return z.ALPHANUMERIC_REGEX.test(s)}getData(){return this.bitData.slice()}static getTotalBits(s,i){let c=0;for(const f of s){const d=f.mode.numCharCountBits(i);if(f.numChars>=1<<d)return 1/0;c+=4+d+f.bitData.length}return c}static toUtf8ByteArray(s){s=encodeURI(s);let i=[];for(let c=0;c<s.length;c++)s.charAt(c)!="%"?i.push(s.charCodeAt(c)):(i.push(parseInt(s.substring(c+1,c+3),16)),c+=2);return i}};l.NUMERIC_REGEX=/^[0-9]*$/,l.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,l.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let a=l;e.QrSegment=l})(De||(De={}));(e=>{(t=>{const n=class{constructor(o,l){this.ordinal=o,this.formatBits=l}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),t.Ecc=n})(e.QrCode||(e.QrCode={}))})(De||(De={}));(e=>{(t=>{const n=class{constructor(o,l){this.modeBits=o,this.numBitsCharCount=l}numCharCountBits(o){return this.numBitsCharCount[Math.floor((o+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),t.Mode=n})(e.QrSegment||(e.QrSegment={}))})(De||(De={}));var ke=De;/**
9
+ * @license qrcode.react
10
+ * Copyright (c) Paul O'Shannessy
11
+ * SPDX-License-Identifier: ISC
12
+ */var ri={L:ke.QrCode.Ecc.LOW,M:ke.QrCode.Ecc.MEDIUM,Q:ke.QrCode.Ecc.QUARTILE,H:ke.QrCode.Ecc.HIGH},pr=128,gr="L",br="#FFFFFF",wr="#000000",xr=!1,yr=1,oi=4,si=0,ii=.1;function Er(e,t=0){const n=[];return e.forEach(function(r,o){let l=null;r.forEach(function(a,u){if(!a&&l!==null){n.push(`M${l+t} ${o+t}h${u-l}v1H${l+t}z`),l=null;return}if(u===r.length-1){if(!a)return;l===null?n.push(`M${u+t},${o+t} h1v1H${u+t}z`):n.push(`M${l+t},${o+t} h${u+1-l}v1H${l+t}z`);return}a&&l===null&&(l=u)})}),n.join("")}function vr(e,t){return e.slice().map((n,r)=>r<t.y||r>=t.y+t.h?n:n.map((o,l)=>l<t.x||l>=t.x+t.w?o:!1))}function li(e,t,n,r){if(r==null)return null;const o=e.length+n*2,l=Math.floor(t*ii),a=o/t,u=(r.width||l)*a,s=(r.height||l)*a,i=r.x==null?e.length/2-u/2:r.x*a,c=r.y==null?e.length/2-s/2:r.y*a,f=r.opacity==null?1:r.opacity;let d=null;if(r.excavate){let m=Math.floor(i),p=Math.floor(c),g=Math.ceil(u+i-m),y=Math.ceil(s+c-p);d={x:m,y:p,w:g,h:y}}const h=r.crossOrigin;return{x:i,y:c,h:s,w:u,excavation:d,opacity:f,crossOrigin:h}}function ci(e,t){return t!=null?Math.max(Math.floor(t),0):e?oi:si}function Rr({value:e,level:t,minVersion:n,includeMargin:r,marginSize:o,imageSettings:l,size:a,boostLevel:u}){let s=M.useMemo(()=>{const m=(Array.isArray(e)?e:[e]).reduce((p,g)=>(p.push(...ke.QrSegment.makeSegments(g)),p),[]);return ke.QrCode.encodeSegments(m,ri[t],n,void 0,void 0,u)},[e,t,n,u]);const{cells:i,margin:c,numCells:f,calculatedImageSettings:d}=M.useMemo(()=>{let h=s.getModules();const m=ci(r,o),p=h.length+m*2,g=li(h,a,m,l);return{cells:h,margin:m,numCells:p,calculatedImageSettings:g}},[s,a,l,r,o]);return{qrcode:s,margin:c,cells:i,numCells:f,calculatedImageSettings:d}}var ai=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),ui=M.forwardRef(function(t,n){const r=t,{value:o,size:l=pr,level:a=gr,bgColor:u=br,fgColor:s=wr,includeMargin:i=xr,minVersion:c=yr,boostLevel:f,marginSize:d,imageSettings:h}=r,p=$t(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:g}=p,y=$t(p,["style"]),w=h==null?void 0:h.src,b=M.useRef(null),C=M.useRef(null),S=M.useCallback(v=>{b.current=v,typeof n=="function"?n(v):n&&(n.current=v)},[n]),[T,F]=M.useState(!1),{margin:$,cells:W,numCells:U,calculatedImageSettings:N}=Rr({value:o,level:a,minVersion:c,boostLevel:f,includeMargin:i,marginSize:d,imageSettings:h,size:l});M.useEffect(()=>{if(b.current!=null){const v=b.current,A=v.getContext("2d");if(!A)return;let k=W;const j=C.current,R=N!=null&&j!==null&&j.complete&&j.naturalHeight!==0&&j.naturalWidth!==0;R&&N.excavation!=null&&(k=vr(W,N.excavation));const I=window.devicePixelRatio||1;v.height=v.width=l*I;const _=l/U*I;A.scale(_,_),A.fillStyle=u,A.fillRect(0,0,U,U),A.fillStyle=s,ai?A.fill(new Path2D(Er(k,$))):W.forEach(function(J,ue){J.forEach(function(P,ie){P&&A.fillRect(ie+$,ue+$,1,1)})}),N&&(A.globalAlpha=N.opacity),R&&A.drawImage(j,N.x+$,N.y+$,N.w,N.h)}}),M.useEffect(()=>{F(!1)},[w]);const q=_t({height:l,width:l},g);let O=null;return w!=null&&(O=M.createElement("img",{src:w,key:w,style:{display:"none"},onLoad:()=>{F(!0)},ref:C,crossOrigin:N==null?void 0:N.crossOrigin})),M.createElement(M.Fragment,null,M.createElement("canvas",_t({style:q,height:l,width:l,ref:S,role:"img"},y)),O)});ui.displayName="QRCodeCanvas";var Cr=M.forwardRef(function(t,n){const r=t,{value:o,size:l=pr,level:a=gr,bgColor:u=br,fgColor:s=wr,includeMargin:i=xr,minVersion:c=yr,boostLevel:f,title:d,marginSize:h,imageSettings:m}=r,p=$t(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:g,cells:y,numCells:w,calculatedImageSettings:b}=Rr({value:o,level:a,minVersion:c,boostLevel:f,includeMargin:i,marginSize:h,imageSettings:m,size:l});let C=y,S=null;m!=null&&b!=null&&(b.excavation!=null&&(C=vr(y,b.excavation)),S=M.createElement("image",{href:m.src,height:b.h,width:b.w,x:b.x+g,y:b.y+g,preserveAspectRatio:"none",opacity:b.opacity,crossOrigin:b.crossOrigin}));const T=Er(C,g);return M.createElement("svg",_t({height:l,width:l,viewBox:`0 0 ${w} ${w}`,ref:n,role:"img"},p),!!d&&M.createElement("title",null,d),M.createElement("path",{fill:u,d:`M0,0 h${w}v${w}H0z`,shapeRendering:"crispEdges"}),M.createElement("path",{fill:s,d:T,shapeRendering:"crispEdges"}),S)});Cr.displayName="QRCodeSVG";var Ar=(e=>(e.LINK="link",e))(Ar||{});const fi=(e,t)=>({invitationType:Ar.LINK,resources:[{url:`conversations/${encodeURI(e)}`},...t]}),di=e=>{var n;return`/share/${((n=e==null?void 0:e.invitationLink)==null?void 0:n.split("/").at(-1))||""}`},hi=(e,t)=>t==null?void 0:t.find(n=>{var l,a,u,s;const r=(a=(l=e==null?void 0:e.id)==null?void 0:l.split("/"))==null?void 0:a.pop(),o=((s=(u=n==null?void 0:n.url)==null?void 0:u.split("/"))==null?void 0:s.pop())||"";return o===r||decodeURI(o)===r}),mi=e=>{var n,r;const t=(n=e==null?void 0:e.messages)==null?void 0:n.filter(o=>{var l;return!!((l=o==null?void 0:o.custom_content)!=null&&l.attachments)});return((r=t==null?void 0:t.flatMap(o=>{var l,a;return((a=(l=o==null?void 0:o.custom_content)==null?void 0:l.attachments)==null?void 0:a.map(u=>({url:(u==null?void 0:u.url)||""})))||[]}))==null?void 0:r.filter(o=>!!(o!=null&&o.url)))||[]},pi=({value:e,inputId:t,placeholder:n="",cssClass:r="",type:o="text",disabled:l,readonly:a,onChange:u,onKeyDown:s})=>{const i=Z("truncate outline-none shadow-none body-1",r,a?"pointer-events-none":"");return x.jsx("input",{type:o,autoComplete:"off",id:t,placeholder:n,value:e||"",title:e?String(e):"",disabled:l,className:i,onKeyDown:s,onChange:c=>u==null?void 0:u(c.currentTarget.value)})},Sr=({iconBeforeInput:e,iconAfterInput:t,containerClasses:n,cssClass:r,...o})=>x.jsxs("div",{className:Z("input w-full flex flex-row",n),children:[e,x.jsx(pi,{cssClass:Z("border-0 bg-transparent p-0 h-full shadow-none flex-1 min-w-0 rounded-none",r),...o}),t]});var Mr=(e=>(e.CONVERSATION="CONVERSATION",e))(Mr||{}),dt=(e=>(e.ME="me",e.OTHERS="others",e))(dt||{});const Ut=e=>({resourceTypes:[Mr.CONVERSATION],with:e}),gi=({conversation:e,locale:t,onCloseModal:n,modalDividers:r,getConversation:o,generateConversationLink:l,chatExpiration:a,chatExpirationDays:u,close:s,chatWarning:i,shareLink:c,shareCopyLink:f,shareCopiedLink:d,shareDescription:h,shareRemoveAccessToUsers:m,chatName:p,getSharedConversations:g,revokeSharedConversations:y,baseUrl:w,id:b})=>{const[C,S]=M.useState(null),[T,F]=M.useState(),[$,W]=M.useState(!1),[U,N]=M.useState(!1),[q,O]=M.useState(),v=M.useMemo(()=>`${w||window.location.origin}/${t}${C}`,[w,C,t]);M.useEffect(()=>{(async()=>{try{const _=decodeURI(e?e==null?void 0:e.id:`${b==null?void 0:b[0]}/${t}/${b==null?void 0:b[1]}`),J=await(o==null?void 0:o(decodeURI(_))),ue=await(l==null?void 0:l(fi(_,mi(J)))),P=await(g==null?void 0:g(Ut(dt.OTHERS)));ue&&P&&(W(!0),S(di(ue)),F(hi(e,P==null?void 0:P.resources)))}catch(_){W(!1),console.error("Error sharing conversation",_)}})()},[e,l,o,g,b,t]);const A=M.useCallback(()=>{n(),S(null),W(!1),N(!1)},[n]),k=M.useCallback(()=>{N(!0),navigator.clipboard.writeText(v||"")},[v]),j=async()=>{try{O(!0),T&&await(y==null?void 0:y({resources:[T]}))}catch(I){O(!1),console.error("Error revoking shared conversation",I)}},R=M.useCallback(()=>x.jsx(Ve,{buttonClassName:U?"text-button-secondary":"text-button-primary",iconBefore:U?x.jsx(Ne.IconCheck,{width:20,height:20}):x.jsx(Ne.IconCopy,{width:20,height:20}),title:U?d??"Copied":f??"Copy link",disabled:U,onClick:k}),[U,k,d,f]);return x.jsxs(dr,{heading:c??"Share link",portalId:"share",size:We.SM,dividers:r,onClose:A,closeButtonTitle:s??"Close",children:[$?x.jsxs("div",{className:"share flex flex-col gap-y-4 px-6 pb-6 overflow-auto sm:p-0",children:[e!=null&&e.name?x.jsxs("div",{className:"flex share-info w-full",children:[x.jsx("p",{className:"share-info-title text-neutrals-800 mr-1 body-1",children:p??"Chat name:"}),x.jsx("h3",{className:"flex-1 min-w-0 truncate",title:e==null?void 0:e.name,children:e==null?void 0:e.name})]}):null,x.jsxs("div",{className:"flex share-info",children:[x.jsx("p",{className:"share-info-title text-neutrals-800 mr-1 body-1",children:a??"Link expiration date:"}),x.jsxs("h3",{children:["3 ",u??"days"]})]}),x.jsx(Cr,{className:"self-center border border-neutrals-600 p-2 rounded min-h-[200px]",value:v,size:200}),x.jsx("p",{className:"body-2 text-neutrals-1000",children:h??"Your name, special instructions, and any messages you add after sharing remain confidential."}),x.jsx(Sr,{containerClasses:"share-input-container",cssClass:"share-input",readonly:!0,placeholder:v,value:v,inputId:"conversationLink",iconAfterInput:R()})]}):x.jsx("div",{className:"flex justify-center items-center py-6 px-6",children:x.jsx(Ht,{})}),$?e&&T?x.jsx("div",{className:"remove-access",children:x.jsx(Ve,{title:m??"Remove access to all users",buttonClassName:"remove-access-button py-3 px-4",isSmallButton:!0,disabled:q,onClick:j})}):x.jsx("p",{className:"body-2 text-neutrals-800 share-footer",children:i??"This chat has not been shared with anyone yet."}):x.jsx("div",{})]})},bi=({triggerButton:e,options:t,selectedOption:n,disabled:r,containerClassName:o,openedClassName:l,onOptionSelect:a})=>{const[u,s]=M.useState(!1),{refs:i,floatingStyles:c,context:f}=ur({open:u,onOpenChange:r?void 0:s,placement:"bottom-end",middleware:[fs(8),hs(),ds()],whileElementsMounted:rs}),d=Bs(f),h=ar(f,{outsidePress:!0}),{getReferenceProps:m,getFloatingProps:p}=fr([d,h]);return x.jsxs(x.Fragment,{children:[x.jsx("div",{ref:i.setReference,...m({onClick(g){g.stopPropagation()}}),className:Z(o,u&&l),children:e}),u&&x.jsx("div",{ref:i.setFloating,style:c,className:"flex flex-col z-10 dropdown-menu-shadow bg-white dropdown-container rounded",...p(),children:t.map(g=>x.jsx("div",{onClick:y=>{y.stopPropagation(),a==null||a(g.key),s(!1)},className:Z("text-neutrals-900 body-3 cursor-pointer dropdown-item min-w-[200px]",n===g.key&&"bg-hues-100"),children:x.jsxs("div",{className:"p-2 hover:bg-hues-100 h-full dropdown-item-text flex items-center gap-x-2",title:g.title,children:[g.icon?g.icon:null,x.jsx("p",{children:g==null?void 0:g.title})]})},g.key))})]})},Tr=({conversation:e,conversationStyles:t,shareConversationProps:n,onConversationDelete:r,getConversation:o,getFileBlob:l,triggerButton:a,locale:u})=>{const s=M.useMemo(()=>{var y,w,b,C,S,T;return[...e.isShared?[]:[{key:fe.SHARE,title:((y=t==null?void 0:t.titles)==null?void 0:y.share)??"Share",icon:(w=t.actionsIcons)==null?void 0:w[fe.SHARE]}],{key:fe.EXPORT,title:((b=t==null?void 0:t.titles)==null?void 0:b.export)??"Export",icon:(C=t.actionsIcons)==null?void 0:C[fe.EXPORT]},{key:fe.DELETE,title:((S=t==null?void 0:t.titles)==null?void 0:S.delete)??"Delete",icon:(T=t.actionsIcons)==null?void 0:T[fe.DELETE]}]},[e.isShared,t.titles,t.actionsIcons]),[i,c]=M.useState(re.Closed),[f,d]=M.useState(re.Closed),h=M.useCallback(()=>{c(re.Closed)},[c]),m=M.useCallback(()=>{d(re.Closed)},[d]),p=M.useCallback(()=>{r(e),h()},[e,r,h]),g=y=>{y===fe.DELETE&&c(re.Opened),y===fe.SHARE&&d(re.Opened),y===fe.EXPORT&&o(decodeURI(e.id)).then(w=>{Zs(w,l).then(b=>{ti(`data:application/zip;base64,${b}`,`chat_with_attachments_${new Date().toLocaleDateString()}.dial`)})})};return x.jsxs(x.Fragment,{children:[x.jsx(bi,{containerClassName:"transition-opacity ml-3 group-hover:opacity-100",triggerButton:a??x.jsx(wi,{}),options:s,openedClassName:"action-menu-opened",onOptionSelect:g}),i===re.Opened&&x.jsx(Ys,{titles:t.titles,locale:u,disableModalDividers:t.disableModalDividers,isSmallButton:t.isSmallModalButton,deleteConversation:p,onCloseModal:h}),f===re.Opened&&x.jsx(gi,{conversation:e,locale:u,onCloseModal:m,...n})]})},wi=()=>x.jsx("div",{className:"cursor-pointer flex items-center justify-center w-[24px]",children:x.jsx(Ne.IconDotsVertical,{width:20,height:20,stroke:2,className:"text-primary"})}),Ir=e=>(e==null?void 0:e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").replace(/-/g," "))||"",Nr=({conversation:e,selectedConversationId:t,searchQuery:n,onConversationClick:r,actions:o,locale:l,conversationStyles:a,shareConversationProps:u})=>{const s=M.useRef(null),i=Ir(e==null?void 0:e.name);return M.useEffect(()=>{var c;(e==null?void 0:e.id)===t&&((c=s==null?void 0:s.current)==null||c.scrollIntoView({block:"center",behavior:"smooth"}))},[e,t]),x.jsxs("div",{ref:s,className:Z("flex justify-between items-center py-2 px-3 border-transparent relative group cursor-pointer border hover:border-hues-600","conversation-item",t===(e==null?void 0:e.id)&&"bg-hues-100 conversation-item-active"),onClick:()=>r(e.folderId,e==null?void 0:e.id),title:i,children:[x.jsxs("div",{className:"flex w-full min-w-0 items-center",children:[a.conversationItemIcon?a.conversationItemIcon:null,x.jsx("h3",{className:Z("truncate font-semibold text-neutrals-1000 sm:body-2","conversation-item-text",t===(e==null?void 0:e.id)?"conversation-item-text-active":""),title:i,children:n!=null&&n.length?x.jsx(Br,{text:i,highlightText:n}):i})]}),x.jsx(Tr,{locale:l,conversationStyles:a,conversation:e,onConversationDelete:o.deleteConversation,getConversation:o.getConversation,getFileBlob:o.getFileBlob,shareConversationProps:u})]})},xi=({handleConversationClick:e,actions:t,selectedConversationId:n,groupLabel:r,conversationStyles:o,groupedConversations:l,shareConversationProps:a,locale:u})=>{const[s,i]=M.useState(!1),c=M.useCallback(()=>{i(f=>!f)},[i]);return x.jsxs("div",{children:[x.jsxs("div",{className:"inline-flex gap-1 items-center text-neutrals-700 mb-3 cursor-pointer conversation-group-items-title",onClick:c,children:[x.jsx(Ne.IconCaretRightFilled,{className:Z("w-3 h-3 conversation-group-items-arrow",s?"rotate-[90deg]":"rotate-0")}),x.jsx("span",{className:"body-3 conversation-group-items-title-text",children:jr(r,o==null?void 0:o.titles)})]}),!s&&x.jsx("div",{className:Z("flex flex-col gap-y-3","conversation-group-items"),children:Dn(l).map(f=>x.jsx(Nr,{locale:u,conversationStyles:o,conversation:f,selectedConversationId:n,onConversationClick:e,actions:t,shareConversationProps:a},f.id||f.name))})]},r)},yi=({icon:e,onClick:t,buttonClassName:n,disabled:r,title:o})=>x.jsx("button",{type:"button",className:Z(n,"base-icon-button"),onClick:l=>t==null?void 0:t(l),disabled:r,title:o,"aria-label":"button",children:e}),Ei=({searchQuery:e,isExpandedSearch:t,titles:n,onSearchConversations:r,toggleSearchField:o})=>x.jsx(x.Fragment,{children:t?x.jsx(Sr,{inputId:"conversations-search",placeholder:(n==null?void 0:n.searchPlaceholder)??"Search",containerClasses:"h-[40px] bg-transparent px-4 py-2 rounded-full border-neutrals-400 shadow-none",cssClass:"h-auto",value:e,iconAfterInput:x.jsx(yi,{buttonClassName:"text-button-tertiary items-center p-0 ml-4 border-0 w-5 h-5",onClick:o,icon:x.jsx(Ne.IconX,{})}),onChange:r}):x.jsx(Ve,{buttonClassName:"text-button-tertiary p-0",iconBefore:x.jsx(Ne.IconSearch,{className:"w-5 h-5"}),onClick:o})}),vi=({conversations:e,selectedConversationId:t,searchQuery:n,conversationStyles:r,handleConversationClick:o,actions:l,locale:a,shareConversationProps:u})=>{var c;const[s,i]=M.useState([]);return M.useEffect(()=>{i(Dn(e==null?void 0:e.filter(f=>{var d;return(d=Ir(f==null?void 0:f.name))==null?void 0:d.includes(n||"")})))},[e,n]),x.jsx(x.Fragment,{children:s!=null&&s.length?s.map(f=>x.jsx(Nr,{locale:a,conversationStyles:r,conversation:f,searchQuery:n,selectedConversationId:t,onConversationClick:o,actions:l,shareConversationProps:u},f.id)):x.jsx("h3",{className:"text-neutrals-800",children:((c=r==null?void 0:r.titles)==null?void 0:c.noConversation)??"No conversations yet"})})},Ri=({titles:e})=>x.jsxs("div",{className:"p-8 text-center flex flex-col",children:[x.jsx("p",{className:"text-neutrals-800",children:(e==null?void 0:e.noConversation)??"No conversations yet"}),x.jsx("p",{className:"text-sm text-neutrals-800 mt-2",children:(e==null?void 0:e.clickNewChat)??'Click "New Chat" to start a conversation'})]}),et=e=>e.map(t=>({...t,name:t.name.split(/-\d+$/)[0]})),In=(e,t)=>{var n,r;return((r=(n=e==null?void 0:e.resources)==null?void 0:n.filter(o=>(o==null?void 0:o.parentPath)===t))==null?void 0:r.map(o=>{var u,s,i;const l=`${o==null?void 0:o.bucket}/${t}`,a=(i=(s=(u=o==null?void 0:o.url)==null?void 0:u.split("/"))==null?void 0:s.slice(1))==null?void 0:i.join("/");return{...o,folderId:l,id:a,isShared:!0}}))||[]},Ci=e=>({[ee.SHARED]:e}),Ai=({handleConversationClick:e,selectedConversationId:t,actions:n,children:r,isCollapsed:o,conversationStyles:l,conversations:a,locale:u,sharedConversations:s,setConversations:i,setSharedConversations:c,shareConversationProps:f,handleSelectedConversationRemove:d})=>{var q;const[h,m]=M.useState({}),[p,g]=M.useState(!0),[y,w]=M.useState(""),[b,C]=M.useState(!1),{getConversations:S,getSharedConversations:T,deleteConversation:F}=n,$=M.useMemo(()=>!!(y!=null&&y.length),[y]);M.useEffect(()=>{m({...Ci(s),...kr(a)})},[a,s]),M.useEffect(()=>{async function O(){try{g(!0);const v=await S(u),A=await T(Ut(dt.ME));i(et(v)),c(et(In(A,u)))}catch(v){console.error("Error loading conversation",v)}finally{g(!1)}}O()},[S,i,u,T,c]);const W=M.useCallback(async O=>{try{await F(O);const v=await S(u),A=await T(Ut(dt.ME));i(et(v)),c(et(In(A,u))),t===(O==null?void 0:O.id)&&d()}catch(v){console.error("Error deleting conversation",v)}},[F,S,u,T,i,c,t,d]),U=M.useCallback(O=>{w(O)},[w]),N=M.useCallback(()=>{C(O=>!O),w("")},[C]);return p?x.jsx(Ht,{}):x.jsxs(x.Fragment,{children:[!o&&x.jsxs("div",{className:Z("flex justify-between items-center",b?" pt-4 pb-0 sm:pt-10":" pt-6 pb-2 sm:pt-10"),children:[!b&&x.jsx("h3",{className:"text-neutrals-700 sm:body-2",children:((q=l==null?void 0:l.titles)==null?void 0:q.allChats)??"All Chats"}),x.jsx(Ei,{searchQuery:y,titles:l.titles,isExpandedSearch:b,onSearchConversations:U,toggleSearchField:N})]}),x.jsx("div",{className:Z("overflow-y-auto flex flex-col mt-4 flex-1 min-h-0 pr-2",$?"gap-y-1":"gap-y-6"),children:o?null:x.jsx(x.Fragment,{children:(a==null?void 0:a.length)===0&&(s==null?void 0:s.length)===0?x.jsx(Ri,{titles:l.titles}):$?x.jsx(vi,{locale:u,conversationStyles:l,conversations:[...s,...a],searchQuery:y,selectedConversationId:t,handleConversationClick:e,shareConversationProps:f,actions:{...n,deleteConversation:W}}):Object.entries(h).map(([O,v])=>(v==null?void 0:v.length)>0&&x.jsx(xi,{locale:u,groupLabel:O,conversationStyles:l,groupedConversations:v,handleConversationClick:e,actions:{...n,deleteConversation:W},shareConversationProps:f,selectedConversationId:t},O))})}),r]})};exports.ActionMenu=Tr;exports.ActionMenuItem=fe;exports.ConversationList=Ai;