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