vpschatbotwidget 1.2.2 → 1.2.4

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.
@@ -1,5 +1,5 @@
1
- "use strict";var Uc=Object.create;var or=Object.defineProperty;var zc=Object.getOwnPropertyDescriptor;var Wc=Object.getOwnPropertyNames;var qc=Object.getPrototypeOf,Gc=Object.prototype.hasOwnProperty;var Kc=(e,t,n)=>t in e?or(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Yc=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Wc(t))!Gc.call(e,o)&&o!==n&&or(e,o,{get:()=>t[o],enumerable:!(r=zc(t,o))||r.enumerable});return e};var Xc=(e,t,n)=>(n=e!=null?Uc(qc(e)):{},Yc(t||!e||!e.__esModule?or(n,"default",{value:e,enumerable:!0}):n,e));var ae=(e,t,n)=>Kc(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),I=require("react"),Jc=require("react-dom");var sr=typeof document<"u"?document.currentScript:null;function Us(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 v=Us(I),dt=Us(Jc),Zc={};function vt(e){if(e!=null&&e.trim()!=="")return e.trim().replace(/\/+$/,"");const t=(typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:sr&&sr.tagName.toUpperCase()==="SCRIPT"&&sr.src||new URL("vps-chatbot.cjs",document.baseURI).href}<"u"&&Zc,"");return String(t).trim().replace(/\/+$/,"")}function Rn(e,t){const n=vt(e);if(!n)return t;if(n.endsWith("/api")&&t.startsWith("/api/"))return`${n}${t.slice(4)}`;if(n.endsWith("/api")&&t==="/health"){const o=n.slice(0,-4);return o?`${o}/health`:"/health"}const r=t.startsWith("/")?t:`/${t}`;return`${n}${r}`}function zo(e){return e&&typeof e=="object"&&"data"in e&&e.success!==!1?e.data:e}function Wo(e,t,n){var s,i,c;const r=e,o=(s=r==null?void 0:r.error)==null?void 0:s.message;return o&&!Qc(o)?{code:(i=r==null?void 0:r.error)==null?void 0:i.code,message:o,requestId:(c=r==null?void 0:r.error)==null?void 0:c.request_id}:n>=500?{message:"I couldn't process that request right now."}:n===0?{message:"Something went wrong while connecting. Please try again."}:{message:t}}function Qc(e){return/traceback|sql|exception|stack|api[_ ]?key|password/i.test(e)}function ir(e){return{chunkId:e.chunk_id,source:e.source,score:e.score,title:e.title,...e.url?{url:e.url}:{},snippet:e.snippet}}function cr(e){return{toolName:e.tool_name,arguments:e.arguments??{},result:e.result??{}}}function ar(e){return{model:e.model,promptTokens:e.prompt_tokens,completionTokens:e.completion_tokens,totalTokens:e.total_tokens}}function ea(e){const t=e.role==="user"||e.role==="system"?e.role:"assistant";return{id:String(e.id),role:t,content:e.content,createdAt:e.created_at||new Date().toISOString(),status:"complete",usage:e.model?{model:e.model,promptTokens:e.prompt_tokens||0,completionTokens:e.completion_tokens||0,totalTokens:(e.prompt_tokens||0)+(e.completion_tokens||0)}:void 0}}async function lr(e){const t=await e.text();if(!t)return{};try{return JSON.parse(t)}catch{return{}}}function Gr(e){const t=vt(e);async function n(r,o){let s;const i=Rn(t,r);try{s=await fetch(i,{...o,headers:{"Content-Type":"application/json",...(o==null?void 0:o.headers)??{}}})}catch{throw{message:"Something went wrong while connecting. Please try again."}}if(s.status===204)return;const c=await lr(s);if(!s.ok)throw Wo(c,"I couldn't process that request right now.",s.status);return zo(c)}return{apiBaseUrl:t,async listModels(){try{const r=await n("/api/v1/models");return{defaultModelId:r.default_model_id,complexModelId:r.complex_model_id,models:r.models||[]}}catch{return null}},async createSession(r){const o=await n("/api/v1/sessions",{method:"POST",signal:r,body:JSON.stringify({})});return{sessionId:o.session_id,createdAt:o.created_at}},async sendMessage(r,o,s,i){const c=await n(`/api/v1/sessions/${r}/messages`,{method:"POST",signal:i,body:JSON.stringify({message:o,...(s==null?void 0:s.roleId)!==void 0?{role_id:s.roleId}:{},...s!=null&&s.client?{client:s.client}:{},...s!=null&&s.modelId?{model_id:s.modelId}:{}})});return{requestId:c.request_id,sessionId:c.session_id,answer:c.answer,sources:(c.sources||[]).map(ir),toolCalls:(c.tool_calls||[]).map(cr),usage:ar(c.usage),durationMs:c.duration_ms}},async sendMessageStream(r,o,s,i,c,a){var f,u;const l=Rn(t,`/api/v1/sessions/${r}/messages/stream`);try{const d=await fetch(l,{method:"POST",signal:a,headers:{"Content-Type":"application/json"},body:JSON.stringify({message:o,...(s==null?void 0:s.roleId)!==void 0?{role_id:s.roleId}:{},...s!=null&&s.client?{client:s.client}:{},...s!=null&&s.modelId?{model_id:s.modelId}:{}})});if(!d.ok){if(d.status===404||d.status===405)return await this.sendMessage(r,o,s,a);const S=await lr(d);throw Wo(S,"I couldn't process that request right now.",d.status)}if(!d.body||(u=(f=d.headers)==null?void 0:f.get("content-type"))!=null&&u.includes("application/json")){const S=zo(await lr(d));if(typeof S.answer!="string"||!S.usage)throw{message:"The response stream ended unexpectedly."};return{requestId:S.request_id,sessionId:S.session_id,answer:S.answer,sources:(S.sources||[]).map(ir),toolCalls:(S.tool_calls||[]).map(cr),usage:ar(S.usage),durationMs:S.duration_ms}}const m=d.body.getReader(),p=new TextDecoder;let g="";const b={value:null},y=S=>{const E=S.split(/\r?\n/).filter(w=>w.startsWith("data:")).map(w=>w.slice(5).trimStart()).join(`
2
- `);if(!E)return;let C={};try{const w=JSON.parse(E);if(!w||typeof w!="object")return;C=w}catch{return}if(C.type==="progress"&&typeof C.stage=="string")i==null||i(C.stage);else if(C.type==="token"&&typeof C.text=="string")c==null||c(C.text);else if(C.type==="complete")b.value={requestId:C.request_id||"",sessionId:C.session_id||r,answer:C.answer||"",sources:(C.sources||[]).map(ir),toolCalls:(C.tool_calls||[]).map(cr),usage:C.usage?ar(C.usage):{model:"",promptTokens:0,completionTokens:0,totalTokens:0},durationMs:C.duration_ms};else if(C.type==="error")throw{message:C.message||"I couldn't process that request right now.",requestId:C.request_id}};try{for(;!b.value;){const{done:S,value:E}=await m.read();if(S)break;if(g+=p.decode(E,{stream:!0}),g.length>1e6)throw{message:"The response stream was too large."};const C=g.split(/\r?\n\r?\n/);g=C.pop()||"";for(const w of C)if(y(w),b.value)break}g+=p.decode(),!b.value&&g.trim()&&y(g)}finally{await m.cancel().catch(()=>{}),m.releaseLock()}const x=b.value;if(x)return x;throw{message:"The response stream ended before the answer was complete."}}catch(d){throw!(d instanceof Error)&&d&&typeof d=="object"&&"message"in d?d:{message:"Something went wrong while connecting. Please try again."}}},async getHistory(r){try{return((await n(`/api/v1/sessions/${r}/messages`)).messages||[]).map(ea)}catch{return[]}},async closeSession(r){try{await n(`/api/v1/sessions/${r}`,{method:"DELETE"})}catch{}},async createTicket(){throw new Error("Ticket creation has been removed.")},async checkHealth(){try{const r=Rn(t,"/health");return(await fetch(r)).ok}catch{return!1}}}}const ta=Gr(),na=[{label:"How do I access my reports?",query:"How do I access my reports in the VPS Customer Portal?"},{label:"Where can I find sample status?",query:"Where can I find my sample status?"},{label:"How do I pre-register a sample?",query:"How do I pre-register a sample in the portal?"},{label:"How do I contact VPS Support?",query:"How can I contact VPS Customer Support?"}],qo="vps-chatbot-response-sound";function ra(){const[e,t]=I.useState(!0),n=I.useRef(!0),r=I.useRef(null);I.useEffect(()=>{try{n.current=window.localStorage.getItem(qo)!=="off",t(n.current)}catch{}return()=>{var c;(c=r.current)==null||c.close().catch(()=>{}),r.current=null}},[]);const o=I.useCallback(()=>{if(!(!n.current||typeof AudioContext>"u"))try{const c=r.current??(r.current=new AudioContext);c.state!=="running"&&c.resume().catch(()=>{})}catch{}},[]),s=I.useCallback(()=>{const c=!n.current;n.current=c,t(c);try{window.localStorage.setItem(qo,c?"on":"off")}catch{}c&&o()},[o]),i=I.useCallback(()=>{const c=r.current;if(!(!n.current||(c==null?void 0:c.state)!=="running"))try{const a=c.currentTime;for(const[l,f]of[660,880].entries()){const u=a+l*.09,d=c.createOscillator(),m=c.createGain();d.frequency.value=f,m.gain.setValueAtTime(.001,u),m.gain.exponentialRampToValueAtTime(.06,u+.015),m.gain.exponentialRampToValueAtTime(.001,u+.14),d.connect(m),m.connect(c.destination),d.onended=()=>{d.disconnect(),m.disconnect()},d.start(u),d.stop(u+.15)}}catch{}},[]);return{soundEnabled:e,toggleSound:s,prepareSound:o,playSound:i}}const Kr=I.createContext(null);function zs(){const e=I.useContext(Kr);if(!e)throw new Error("useChatbot must be used inside ChatProvider.");return e}function qn(){return I.useContext(Kr)}function Ot(e,t,n,r){if(typeof performance.measure!="function")return;const o=`vps-chatbot:${e}`;performance.clearMeasures(o),performance.measure(o,{start:t,end:n,detail:r?{requestId:r}:null})}const oa=`Hello! I am your **VPS Veritas assistant**.
1
+ "use strict";var zc=Object.create;var or=Object.defineProperty;var Wc=Object.getOwnPropertyDescriptor;var qc=Object.getOwnPropertyNames;var Gc=Object.getPrototypeOf,Kc=Object.prototype.hasOwnProperty;var Yc=(e,t,n)=>t in e?or(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Xc=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of qc(t))!Kc.call(e,o)&&o!==n&&or(e,o,{get:()=>t[o],enumerable:!(r=Wc(t,o))||r.enumerable});return e};var Jc=(e,t,n)=>(n=e!=null?zc(Gc(e)):{},Xc(t||!e||!e.__esModule?or(n,"default",{value:e,enumerable:!0}):n,e));var ae=(e,t,n)=>Yc(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),I=require("react"),Zc=require("react-dom");var sr=typeof document<"u"?document.currentScript:null;function zs(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=zs(I),dt=zs(Zc),Qc={};function yt(e){if(e!=null&&e.trim()!=="")return e.trim().replace(/\/+$/,"");const t=(typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:sr&&sr.tagName.toUpperCase()==="SCRIPT"&&sr.src||new URL("vps-chatbot.cjs",document.baseURI).href}<"u"&&Qc,"");return String(t).trim().replace(/\/+$/,"")}function Rn(e,t){const n=yt(e);if(!n)return t;if(n.endsWith("/api")&&t.startsWith("/api/"))return`${n}${t.slice(4)}`;if(n.endsWith("/api")&&t==="/health"){const o=n.slice(0,-4);return o?`${o}/health`:"/health"}const r=t.startsWith("/")?t:`/${t}`;return`${n}${r}`}function zo(e){return e&&typeof e=="object"&&"data"in e&&e.success!==!1?e.data:e}function Wo(e,t,n){var s,i,c;const r=e,o=(s=r==null?void 0:r.error)==null?void 0:s.message;return o&&!ea(o)?{code:(i=r==null?void 0:r.error)==null?void 0:i.code,message:o,requestId:(c=r==null?void 0:r.error)==null?void 0:c.request_id}:n>=500?{message:"I couldn't process that request right now."}:n===0?{message:"Something went wrong while connecting. Please try again."}:{message:t}}function ea(e){return/traceback|sql|exception|stack|api[_ ]?key|password/i.test(e)}function ir(e){return{chunkId:e.chunk_id,source:e.source,score:e.score,title:e.title,...e.url?{url:e.url}:{},snippet:e.snippet}}function cr(e){return{toolName:e.tool_name,arguments:e.arguments??{},result:e.result??{}}}function ar(e){return{model:e.model,promptTokens:e.prompt_tokens,completionTokens:e.completion_tokens,totalTokens:e.total_tokens}}function ta(e){const t=e.role==="user"||e.role==="system"?e.role:"assistant";return{id:String(e.id),role:t,content:e.content,createdAt:e.created_at||new Date().toISOString(),status:"complete",usage:e.model?{model:e.model,promptTokens:e.prompt_tokens||0,completionTokens:e.completion_tokens||0,totalTokens:(e.prompt_tokens||0)+(e.completion_tokens||0)}:void 0}}async function lr(e){const t=await e.text();if(!t)return{};try{return JSON.parse(t)}catch{return{}}}function Gr(e){const t=yt(e);async function n(r,o){let s;const i=Rn(t,r);try{s=await fetch(i,{...o,headers:{"Content-Type":"application/json",...(o==null?void 0:o.headers)??{}}})}catch{throw{message:"Something went wrong while connecting. Please try again."}}if(s.status===204)return;const c=await lr(s);if(!s.ok)throw Wo(c,"I couldn't process that request right now.",s.status);return zo(c)}return{apiBaseUrl:t,async listModels(){try{const r=await n("/api/v1/models");return{defaultModelId:r.default_model_id,complexModelId:r.complex_model_id,models:r.models||[]}}catch{return null}},async createSession(r){const o=await n("/api/v1/sessions",{method:"POST",signal:r,body:JSON.stringify({})});return{sessionId:o.session_id,createdAt:o.created_at}},async sendMessage(r,o,s,i){const c=await n(`/api/v1/sessions/${r}/messages`,{method:"POST",signal:i,body:JSON.stringify({message:o,...(s==null?void 0:s.roleId)!==void 0?{role_id:s.roleId}:{},...s!=null&&s.client?{client:s.client}:{},...s!=null&&s.modelId?{model_id:s.modelId}:{}})});return{requestId:c.request_id,sessionId:c.session_id,answer:c.answer,sources:(c.sources||[]).map(ir),toolCalls:(c.tool_calls||[]).map(cr),usage:ar(c.usage),durationMs:c.duration_ms}},async sendMessageStream(r,o,s,i,c,a){var f,u;const l=Rn(t,`/api/v1/sessions/${r}/messages/stream`);try{const h=await fetch(l,{method:"POST",signal:a,headers:{"Content-Type":"application/json"},body:JSON.stringify({message:o,...(s==null?void 0:s.roleId)!==void 0?{role_id:s.roleId}:{},...s!=null&&s.client?{client:s.client}:{},...s!=null&&s.modelId?{model_id:s.modelId}:{}})});if(!h.ok){if(h.status===404||h.status===405)return await this.sendMessage(r,o,s,a);const S=await lr(h);throw Wo(S,"I couldn't process that request right now.",h.status)}if(!h.body||(u=(f=h.headers)==null?void 0:f.get("content-type"))!=null&&u.includes("application/json")){const S=zo(await lr(h));if(typeof S.answer!="string"||!S.usage)throw{message:"The response stream ended unexpectedly."};return{requestId:S.request_id,sessionId:S.session_id,answer:S.answer,sources:(S.sources||[]).map(ir),toolCalls:(S.tool_calls||[]).map(cr),usage:ar(S.usage),durationMs:S.duration_ms}}const g=h.body.getReader(),d=new TextDecoder;let m="";const b={value:null},v=S=>{const E=S.split(/\r?\n/).filter(w=>w.startsWith("data:")).map(w=>w.slice(5).trimStart()).join(`
2
+ `);if(!E)return;let C={};try{const w=JSON.parse(E);if(!w||typeof w!="object")return;C=w}catch{return}if(C.type==="progress"&&typeof C.stage=="string")i==null||i(C.stage);else if(C.type==="token"&&typeof C.text=="string")c==null||c(C.text);else if(C.type==="complete")b.value={requestId:C.request_id||"",sessionId:C.session_id||r,answer:C.answer||"",sources:(C.sources||[]).map(ir),toolCalls:(C.tool_calls||[]).map(cr),usage:C.usage?ar(C.usage):{model:"",promptTokens:0,completionTokens:0,totalTokens:0},durationMs:C.duration_ms};else if(C.type==="error")throw{message:C.message||"I couldn't process that request right now.",requestId:C.request_id}};try{for(;!b.value;){const{done:S,value:E}=await g.read();if(S)break;if(m+=d.decode(E,{stream:!0}),m.length>1e6)throw{message:"The response stream was too large."};const C=m.split(/\r?\n\r?\n/);m=C.pop()||"";for(const w of C)if(v(w),b.value)break}m+=d.decode(),!b.value&&m.trim()&&v(m)}finally{await g.cancel().catch(()=>{}),g.releaseLock()}const x=b.value;if(x)return x;throw{message:"The response stream ended before the answer was complete."}}catch(h){throw!(h instanceof Error)&&h&&typeof h=="object"&&"message"in h?h:{message:"Something went wrong while connecting. Please try again."}}},async getHistory(r){try{return((await n(`/api/v1/sessions/${r}/messages`)).messages||[]).map(ta)}catch{return[]}},async closeSession(r){try{await n(`/api/v1/sessions/${r}`,{method:"DELETE"})}catch{}},async createTicket(){throw new Error("Ticket creation has been removed.")},async checkHealth(){try{const r=Rn(t,"/health");return(await fetch(r)).ok}catch{return!1}}}}const na=Gr(),ra=[{label:"How do I access my reports?",query:"How do I access my reports in the VPS Customer Portal?"},{label:"Where can I find sample status?",query:"Where can I find my sample status?"},{label:"How do I pre-register a sample?",query:"How do I pre-register a sample in the portal?"},{label:"How do I contact VPS Support?",query:"How can I contact VPS Customer Support?"}],qo="vps-chatbot-response-sound";function oa(){const[e,t]=I.useState(!0),n=I.useRef(!0),r=I.useRef(null);I.useEffect(()=>{try{n.current=window.localStorage.getItem(qo)!=="off",t(n.current)}catch{}return()=>{var c;(c=r.current)==null||c.close().catch(()=>{}),r.current=null}},[]);const o=I.useCallback(()=>{if(!(!n.current||typeof AudioContext>"u"))try{const c=r.current??(r.current=new AudioContext);c.state!=="running"&&c.resume().catch(()=>{})}catch{}},[]),s=I.useCallback(()=>{const c=!n.current;n.current=c,t(c);try{window.localStorage.setItem(qo,c?"on":"off")}catch{}c&&o()},[o]),i=I.useCallback(()=>{const c=r.current;if(!(!n.current||(c==null?void 0:c.state)!=="running"))try{const a=c.currentTime;for(const[l,f]of[660,880].entries()){const u=a+l*.09,h=c.createOscillator(),g=c.createGain();h.frequency.value=f,g.gain.setValueAtTime(.001,u),g.gain.exponentialRampToValueAtTime(.06,u+.015),g.gain.exponentialRampToValueAtTime(.001,u+.14),h.connect(g),g.connect(c.destination),h.onended=()=>{h.disconnect(),g.disconnect()},h.start(u),h.stop(u+.15)}}catch{}},[]);return{soundEnabled:e,toggleSound:s,prepareSound:o,playSound:i}}const Kr=I.createContext(null);function Ws(){const e=I.useContext(Kr);if(!e)throw new Error("useChatbot must be used inside ChatProvider.");return e}function qn(){return I.useContext(Kr)}function Pt(e,t,n,r){if(typeof performance.measure!="function")return;const o=`vps-chatbot:${e}`;performance.clearMeasures(o),performance.measure(o,{start:t,end:n,detail:r?{requestId:r}:null})}const sa=`Hello! I am your **VPS Veritas assistant**.
3
3
 
4
4
  I can help you with:
5
5
  - **Fuel Quality Testing (FQT)** & **Oil Condition Monitoring (OCM)**
@@ -8,175 +8,175 @@ I can help you with:
8
8
  - **FSC & FSQ E-Forms** — paperless fuel system checks and bunker sample pre-registration
9
9
  - **Samplogic** sample logistics, report downloads, and support tickets
10
10
 
11
- Feel free to ask a question or select one of the suggested topics below!`;function Go(e){return`${e}-${crypto.randomUUID()}`}function sa(e){if(e&&typeof e=="object"&&"message"in e){const t=String(e.message);if(t&&!/traceback|sql|exception|stack|api[_ ]?key|password/i.test(t))return t}return"I couldn't process that request right now."}const Yr=({children:e,userContext:t={},role:n,roleId:r,client:o,welcomeMessage:s,suggestions:i=na,disableSuggestions:c=!1,initialMessage:a,apiBaseUrl:l,apiUrl:f,proxyUrl:u,api:d,hideInspectSources:m=!1,showGroundedSources:p=!1,modelId:g="auto"})=>{const b=l??f??u,y=I.useMemo(()=>d??Gr(b),[d,b]),x=I.useMemo(()=>({...t,...n!==void 0?{role:n}:{},...r!==void 0?{roleId:r}:{},...o!==void 0?{client:o}:{}}),[t,n,r,o]),S=I.useMemo(()=>s===""?null:{id:"welcome-default",role:"assistant",content:s||oa,createdAt:new Date().toISOString(),status:"complete"},[s]),[E,C]=I.useState(null),[w,R]=I.useState(()=>S?[S]:[]),[O,P]=I.useState("idle"),[M,F]=I.useState(null),A=I.useRef(null),D=I.useRef(!1),_=I.useRef(null),T=I.useRef(null),k=I.useRef(!1),[U,j]=I.useState([]),[N,Y]=I.useState(g),{soundEnabled:K,toggleSound:le,prepareSound:ie,playSound:L}=ra();I.useEffect(()=>Y(g),[g]),I.useEffect(()=>{var J;let q=!0;return j([]),(J=y.listModels)==null||J.call(y).then(ce=>{q&&j((ce==null?void 0:ce.models)||[])}).catch(()=>{}),()=>{q=!1}},[y]);const X=I.useCallback(q=>{!k.current&&(q==="auto"||U.some(J=>J.id===q&&J.configured))&&Y(q)},[U]);I.useEffect(()=>()=>{var q;return(q=_.current)==null?void 0:q.abort()},[]),I.useLayoutEffect(()=>{const q=T.current;if(!q)return;const J=w.find(he=>he.id===q.messageId),ce=performance.now();(J==null?void 0:J.status)==="complete"&&q.completedAt!==void 0?(Ot("completion-to-commit",q.completedAt,ce),Ot("submit-to-complete-commit",q.startedAt,ce),T.current=null):(J==null?void 0:J.status)==="pending"&&J.content&&q.firstTokenAt!==void 0&&!q.firstCommitRecorded&&(Ot("first-token-to-commit",q.firstTokenAt,ce),q.firstCommitRecorded=!0)},[w]);const B=I.useCallback(async q=>{if(E)return E;P("connecting");const J=await y.createSession(q);if(q.aborted)throw new DOMException("Aborted","AbortError");return C(J.sessionId),J.sessionId},[E,y]),$=I.useCallback(async q=>{if(k.current)return;ie(),k.current=!0;const J=new AbortController;_.current=J;let ce,he="";const Pe=()=>{ce!==void 0&&cancelAnimationFrame(ce),ce=void 0};A.current=q;const je={id:Go("user"),role:"user",content:q,createdAt:new Date().toISOString(),status:"complete"},Re=Go("asst"),Me="Preparing your answer…",Be={id:Re,streamId:Re,role:"assistant",content:"",createdAt:new Date().toISOString(),status:"pending",progressText:Me,progressSteps:[Me]},H=performance.now(),G={messageId:Re,startedAt:H};T.current=G,R(be=>[...be,je,Be]),P("awaiting"),F(null);const Se=be=>{const me=be.trim();!me||J.signal.aborted||R(V=>V.map(W=>W.id===Re&&W.progressText!==me?{...W,progressText:me,progressSteps:[...W.progressSteps??[],me]}:W))};try{const be=await B(J.signal),me=performance.now();Ot("request-preparation",H,me);const V=y.sendMessageStream?await y.sendMessageStream(be,q,{roleId:x.roleId,client:x.client,modelId:N},Se,W=>{J.signal.aborted||(W&&G.firstTokenAt===void 0&&(G.firstTokenAt=performance.now(),Ot("first-token-received",me,G.firstTokenAt)),he+=W,ce===void 0&&(ce=requestAnimationFrame(()=>{ce=void 0,J.signal.aborted||R(Z=>Z.map(se=>se.id===Re?{...se,content:he}:se))})))},J.signal):await y.sendMessage(be,q,{roleId:x.roleId,client:x.client,modelId:N},J.signal);if(Pe(),J.signal.aborted)return;G.messageId=V.requestId||Re,G.completedAt=performance.now(),Ot("completion-received",me,G.completedAt,V.requestId),R(W=>W.map(Z=>Z.id===Re?{...Z,id:V.requestId||Re,content:V.answer,status:"complete",progressText:void 0,sources:V.sources,toolCalls:V.toolCalls,usage:V.usage,durationMs:Math.max(Math.round(performance.now()-H),V.durationMs??0)}:Z)),P("idle"),L()}catch(be){if(Pe(),T.current===G&&(T.current=null),J.signal.aborted)return;const me=sa(be);R(V=>V.map(W=>W.id===Re?{...W,content:me,status:"error",progressText:void 0}:W)),F(me),P("error")}finally{Pe(),_.current===J&&(_.current=null,k.current=!1)}},[B,y,x.client,x.roleId,N,ie,L]),Q=I.useCallback(async q=>{const J=q.trim();!J||O==="awaiting"||O==="connecting"||await $(J)},[$,O]),re=I.useCallback(async()=>{if(k.current)return;const q=A.current;q&&(R(J=>J.filter(ce=>ce.status!=="error")),await $(q))},[$]),ee=I.useCallback(()=>{const q=_.current;q&&(q.abort(),_.current=null,k.current=!1,T.current=null,R(J=>J.map(ce=>ce.status==="pending"?{...ce,status:"stopped",progressText:void 0}:ce)),P("idle"))},[]),te=I.useCallback((q,J)=>{R(ce=>ce.map(he=>he.id===q?{...he,feedback:he.feedback===J?void 0:J}:he))},[]),z=I.useCallback(async()=>{},[]),ne=I.useCallback(()=>{},[]),oe=I.useCallback(async()=>{var q;(q=_.current)==null||q.abort(),_.current=null,k.current=!1,C(null),R(S?[S]:[]),P("idle"),F(null),A.current=null,E&&await y.closeSession(E)},[E,y,S]);I.useEffect(()=>{!a||D.current||(D.current=!0,Q(a))},[a,Q]);const ye=I.useMemo(()=>({messages:w,status:O,error:M,sessionId:E,pendingTicket:null,ticketBusy:!1,lastTicket:null,suggestions:i,showSuggestions:!c&&(w.length===0||w.length===1&&w[0].id==="welcome-default"),suggestionBadgesEnabled:!c,userContext:x,apiBaseUrl:y.apiBaseUrl,hideInspectSources:m,showGroundedSources:p,soundEnabled:K,toggleSound:le,sendMessage:Q,stopResponse:ee,toggleMessageFeedback:te,retryLast:re,confirmTicket:z,cancelTicket:ne,resetConversation:oe,models:U,selectedModelId:N,selectModel:X}),[w,O,M,E,i,c,x,y.apiBaseUrl,m,p,K,le,Q,ee,te,re,z,ne,oe,U,N,X]);return h.jsx(Kr.Provider,{value:ye,children:e})};function Ws(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Ws(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function qs(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Ws(e))&&(r&&(r+=" "),r+=t);return r}function ue(...e){return qs(e)}function Gs({className:e,variant:t="default",...n}){return h.jsx("div",{...n,"data-slot":"marker","data-variant":t,className:ue("chat-marker",e)})}function ia({className:e,...t}){return h.jsx("span",{...t,"data-slot":"marker-icon",className:ue("chat-marker-icon",e),"aria-hidden":"true"})}function Ks({className:e,...t}){return h.jsx("span",{...t,"data-slot":"marker-content",className:ue("chat-marker-content",e)})}function en(){return zs()}/**
11
+ Feel free to ask a question or select one of the suggested topics below!`;function Go(e){return`${e}-${crypto.randomUUID()}`}function ia(e){if(e&&typeof e=="object"&&"message"in e){const t=String(e.message);if(t&&!/traceback|sql|exception|stack|api[_ ]?key|password/i.test(t))return t}return"I couldn't process that request right now."}const Yr=({children:e,userContext:t={},role:n,roleId:r,client:o,welcomeMessage:s,suggestions:i=ra,disableSuggestions:c=!1,initialMessage:a,apiBaseUrl:l,apiUrl:f,proxyUrl:u,api:h,hideInspectSources:g=!1,showGroundedSources:d=!1,modelId:m="auto"})=>{const b=l??f??u,v=I.useMemo(()=>h??Gr(b),[h,b]),x=I.useMemo(()=>({...t,...n!==void 0?{role:n}:{},...r!==void 0?{roleId:r}:{},...o!==void 0?{client:o}:{}}),[t,n,r,o]),S=I.useMemo(()=>s===""?null:{id:"welcome-default",role:"assistant",content:s||sa,createdAt:new Date().toISOString(),status:"complete"},[s]),[E,C]=I.useState(null),[w,R]=I.useState(()=>S?[S]:[]),[P,O]=I.useState("idle"),[M,F]=I.useState(null),A=I.useRef(null),D=I.useRef(!1),_=I.useRef(null),T=I.useRef(null),k=I.useRef(!1),[U,j]=I.useState([]),[N,Y]=I.useState(m),{soundEnabled:K,toggleSound:le,prepareSound:ie,playSound:L}=oa();I.useEffect(()=>Y(m),[m]),I.useEffect(()=>{var J;let z=!0;return j([]),(J=v.listModels)==null||J.call(v).then(ce=>{z&&j((ce==null?void 0:ce.models)||[])}).catch(()=>{}),()=>{z=!1}},[v]);const X=I.useCallback(z=>{!k.current&&(z==="auto"||U.some(J=>J.id===z&&J.configured))&&Y(z)},[U]);I.useEffect(()=>()=>{var z;return(z=_.current)==null?void 0:z.abort()},[]),I.useLayoutEffect(()=>{const z=T.current;if(!z)return;const J=w.find(he=>he.id===z.messageId),ce=performance.now();(J==null?void 0:J.status)==="complete"&&z.completedAt!==void 0?(Pt("completion-to-commit",z.completedAt,ce),Pt("submit-to-complete-commit",z.startedAt,ce),T.current=null):(J==null?void 0:J.status)==="pending"&&J.content&&z.firstTokenAt!==void 0&&!z.firstCommitRecorded&&(Pt("first-token-to-commit",z.firstTokenAt,ce),z.firstCommitRecorded=!0)},[w]);const B=I.useCallback(async z=>{if(E)return E;O("connecting");const J=await v.createSession(z);if(z.aborted)throw new DOMException("Aborted","AbortError");return C(J.sessionId),J.sessionId},[E,v]),$=I.useCallback(async z=>{if(k.current)return;ie(),k.current=!0;const J=new AbortController;_.current=J;let ce,he="";const Oe=()=>{ce!==void 0&&cancelAnimationFrame(ce),ce=void 0};A.current=z;const je={id:Go("user"),role:"user",content:z,createdAt:new Date().toISOString(),status:"complete"},Re=Go("asst"),Me="Preparing your answer…",Be={id:Re,streamId:Re,role:"assistant",content:"",createdAt:new Date().toISOString(),status:"pending",progressText:Me,progressSteps:[Me]},H=performance.now(),G={messageId:Re,startedAt:H};T.current=G,R(be=>[...be,je,Be]),O("awaiting"),F(null);const Se=be=>{const ge=be.trim();!ge||J.signal.aborted||R(V=>V.map(q=>q.id===Re&&q.progressText!==ge?{...q,progressText:ge,progressSteps:[...q.progressSteps??[],ge]}:q))};try{const be=await B(J.signal),ge=performance.now();Pt("request-preparation",H,ge);const V=v.sendMessageStream?await v.sendMessageStream(be,z,{roleId:x.roleId,client:x.client,modelId:N},Se,q=>{J.signal.aborted||(q&&G.firstTokenAt===void 0&&(G.firstTokenAt=performance.now(),Pt("first-token-received",ge,G.firstTokenAt)),he+=q,ce===void 0&&(ce=requestAnimationFrame(()=>{ce=void 0,J.signal.aborted||R(Z=>Z.map(se=>se.id===Re?{...se,content:he}:se))})))},J.signal):await v.sendMessage(be,z,{roleId:x.roleId,client:x.client,modelId:N},J.signal);if(Oe(),J.signal.aborted)return;G.messageId=V.requestId||Re,G.completedAt=performance.now(),Pt("completion-received",ge,G.completedAt,V.requestId),R(q=>q.map(Z=>Z.id===Re?{...Z,id:V.requestId||Re,content:V.answer,status:"complete",progressText:void 0,sources:V.sources,toolCalls:V.toolCalls,usage:V.usage,durationMs:Math.max(Math.round(performance.now()-H),V.durationMs??0)}:Z)),O("idle"),L()}catch(be){if(Oe(),T.current===G&&(T.current=null),J.signal.aborted)return;const ge=ia(be);R(V=>V.map(q=>q.id===Re?{...q,content:ge,status:"error",progressText:void 0}:q)),F(ge),O("error")}finally{Oe(),_.current===J&&(_.current=null,k.current=!1)}},[B,v,x.client,x.roleId,N,ie,L]),Q=I.useCallback(async z=>{const J=z.trim();!J||P==="awaiting"||P==="connecting"||await $(J)},[$,P]),re=I.useCallback(async()=>{if(k.current)return;const z=A.current;z&&(R(J=>J.filter(ce=>ce.status!=="error")),await $(z))},[$]),ee=I.useCallback(()=>{const z=_.current;z&&(z.abort(),_.current=null,k.current=!1,T.current=null,R(J=>J.map(ce=>ce.status==="pending"?{...ce,status:"stopped",progressText:void 0}:ce)),O("idle"))},[]),te=I.useCallback((z,J)=>{R(ce=>ce.map(he=>he.id===z?{...he,feedback:he.feedback===J?void 0:J}:he))},[]),W=I.useCallback(async()=>{},[]),ne=I.useCallback(()=>{},[]),oe=I.useCallback(async()=>{var z;(z=_.current)==null||z.abort(),_.current=null,k.current=!1,C(null),R(S?[S]:[]),O("idle"),F(null),A.current=null,E&&await v.closeSession(E)},[E,v,S]);I.useEffect(()=>{!a||D.current||(D.current=!0,Q(a))},[a,Q]);const ve=I.useMemo(()=>({messages:w,status:P,error:M,sessionId:E,pendingTicket:null,ticketBusy:!1,lastTicket:null,suggestions:i,showSuggestions:!c&&P==="idle"&&(w.length===0||w.length===1&&w[0].id==="welcome-default"||w.some(z=>z.role==="assistant"&&z.status==="complete"&&!z.id.startsWith("welcome"))),suggestionBadgesEnabled:!c,userContext:x,apiBaseUrl:v.apiBaseUrl,hideInspectSources:g,showGroundedSources:d,soundEnabled:K,toggleSound:le,sendMessage:Q,stopResponse:ee,toggleMessageFeedback:te,retryLast:re,confirmTicket:W,cancelTicket:ne,resetConversation:oe,models:U,selectedModelId:N,selectModel:X}),[w,P,M,E,i,c,x,v.apiBaseUrl,g,d,K,le,Q,ee,te,re,W,ne,oe,U,N,X]);return p.jsx(Kr.Provider,{value:ve,children:e})};function qs(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=qs(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Gs(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=qs(e))&&(r&&(r+=" "),r+=t);return r}function ue(...e){return Gs(e)}function Ks({className:e,variant:t="default",...n}){return p.jsx("div",{...n,"data-slot":"marker","data-variant":t,className:ue("chat-marker",e)})}function ca({className:e,...t}){return p.jsx("span",{...t,"data-slot":"marker-icon",className:ue("chat-marker-icon",e),"aria-hidden":"true"})}function Ys({className:e,...t}){return p.jsx("span",{...t,"data-slot":"marker-content",className:ue("chat-marker-content",e)})}function en(){return Ws()}/**
12
12
  * @license lucide-react v0.468.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const ca=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ys=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/**
16
+ */const aa=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Xs=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/**
17
17
  * @license lucide-react v0.468.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */var aa={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
21
+ */var la={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
22
22
  * @license lucide-react v0.468.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const la=I.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:i,...c},a)=>I.createElement("svg",{ref:a,...aa,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Ys("lucide",o),...c},[...i.map(([l,f])=>I.createElement(l,f)),...Array.isArray(s)?s:[s]]));/**
26
+ */const ua=I.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:i,...c},a)=>I.createElement("svg",{ref:a,...la,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Xs("lucide",o),...c},[...i.map(([l,f])=>I.createElement(l,f)),...Array.isArray(s)?s:[s]]));/**
27
27
  * @license lucide-react v0.468.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const ve=(e,t)=>{const n=I.forwardRef(({className:r,...o},s)=>I.createElement(la,{ref:s,iconNode:t,className:Ys(`lucide-${ca(e)}`,r),...o}));return n.displayName=`${e}`,n};/**
31
+ */const ye=(e,t)=>{const n=I.forwardRef(({className:r,...o},s)=>I.createElement(ua,{ref:s,iconNode:t,className:Xs(`lucide-${aa(e)}`,r),...o}));return n.displayName=`${e}`,n};/**
32
32
  * @license lucide-react v0.468.0 - ISC
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const ua=ve("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
36
+ */const fa=ye("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
37
37
  * @license lucide-react v0.468.0 - ISC
38
38
  *
39
39
  * This source code is licensed under the ISC license.
40
40
  * See the LICENSE file in the root directory of this source tree.
41
- */const fa=ve("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
41
+ */const da=ye("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
42
42
  * @license lucide-react v0.468.0 - ISC
43
43
  *
44
44
  * This source code is licensed under the ISC license.
45
45
  * See the LICENSE file in the root directory of this source tree.
46
- */const da=ve("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/**
46
+ */const pa=ye("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/**
47
47
  * @license lucide-react v0.468.0 - ISC
48
48
  *
49
49
  * This source code is licensed under the ISC license.
50
50
  * See the LICENSE file in the root directory of this source tree.
51
- */const pa=ve("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/**
51
+ */const ha=ye("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/**
52
52
  * @license lucide-react v0.468.0 - ISC
53
53
  *
54
54
  * This source code is licensed under the ISC license.
55
55
  * See the LICENSE file in the root directory of this source tree.
56
- */const Xs=ve("BotMessageSquare",[["path",{d:"M12 6V2H8",key:"1155em"}],["path",{d:"m8 18-4 4V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2Z",key:"w2lp3e"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M9 11v2",key:"1ueba0"}],["path",{d:"M15 11v2",key:"i11awn"}],["path",{d:"M20 12h2",key:"1q8mjw"}]]);/**
56
+ */const Js=ye("BotMessageSquare",[["path",{d:"M12 6V2H8",key:"1155em"}],["path",{d:"m8 18-4 4V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2Z",key:"w2lp3e"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M9 11v2",key:"1ueba0"}],["path",{d:"M15 11v2",key:"i11awn"}],["path",{d:"M20 12h2",key:"1q8mjw"}]]);/**
57
57
  * @license lucide-react v0.468.0 - ISC
58
58
  *
59
59
  * This source code is licensed under the ISC license.
60
60
  * See the LICENSE file in the root directory of this source tree.
61
- */const Xr=ve("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
61
+ */const Xr=ye("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
62
62
  * @license lucide-react v0.468.0 - ISC
63
63
  *
64
64
  * This source code is licensed under the ISC license.
65
65
  * See the LICENSE file in the root directory of this source tree.
66
- */const ha=ve("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
66
+ */const ga=ye("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
67
67
  * @license lucide-react v0.468.0 - ISC
68
68
  *
69
69
  * This source code is licensed under the ISC license.
70
70
  * See the LICENSE file in the root directory of this source tree.
71
- */const Js=ve("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
71
+ */const Zs=ye("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
72
72
  * @license lucide-react v0.468.0 - ISC
73
73
  *
74
74
  * This source code is licensed under the ISC license.
75
75
  * See the LICENSE file in the root directory of this source tree.
76
- */const ma=ve("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
76
+ */const ma=ye("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
77
77
  * @license lucide-react v0.468.0 - ISC
78
78
  *
79
79
  * This source code is licensed under the ISC license.
80
80
  * See the LICENSE file in the root directory of this source tree.
81
- */const Zs=ve("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
81
+ */const Qs=ye("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
82
82
  * @license lucide-react v0.468.0 - ISC
83
83
  *
84
84
  * This source code is licensed under the ISC license.
85
85
  * See the LICENSE file in the root directory of this source tree.
86
- */const ga=ve("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/**
86
+ */const ba=ye("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/**
87
87
  * @license lucide-react v0.468.0 - ISC
88
88
  *
89
89
  * This source code is licensed under the ISC license.
90
90
  * See the LICENSE file in the root directory of this source tree.
91
- */const Qs=ve("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
91
+ */const ei=ye("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
92
92
  * @license lucide-react v0.468.0 - ISC
93
93
  *
94
94
  * This source code is licensed under the ISC license.
95
95
  * See the LICENSE file in the root directory of this source tree.
96
- */const ba=ve("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
96
+ */const va=ye("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
97
97
  * @license lucide-react v0.468.0 - ISC
98
98
  *
99
99
  * This source code is licensed under the ISC license.
100
100
  * See the LICENSE file in the root directory of this source tree.
101
- */const ya=ve("FlaskConical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]);/**
101
+ */const ya=ye("FlaskConical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]);/**
102
102
  * @license lucide-react v0.468.0 - ISC
103
103
  *
104
104
  * This source code is licensed under the ISC license.
105
105
  * See the LICENSE file in the root directory of this source tree.
106
- */const va=ve("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/**
106
+ */const xa=ye("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/**
107
107
  * @license lucide-react v0.468.0 - ISC
108
108
  *
109
109
  * This source code is licensed under the ISC license.
110
110
  * See the LICENSE file in the root directory of this source tree.
111
- */const ei=ve("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
111
+ */const ti=ye("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
112
112
  * @license lucide-react v0.468.0 - ISC
113
113
  *
114
114
  * This source code is licensed under the ISC license.
115
115
  * See the LICENSE file in the root directory of this source tree.
116
- */const ti=ve("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
116
+ */const ni=ye("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
117
117
  * @license lucide-react v0.468.0 - ISC
118
118
  *
119
119
  * This source code is licensed under the ISC license.
120
120
  * See the LICENSE file in the root directory of this source tree.
121
- */const xa=ve("Microscope",[["path",{d:"M6 18h8",key:"1borvv"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M14 22a7 7 0 1 0 0-14h-1",key:"1jwaiy"}],["path",{d:"M9 14h2",key:"197e7h"}],["path",{d:"M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z",key:"1bmzmy"}],["path",{d:"M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3",key:"1drr47"}]]);/**
121
+ */const Ea=ye("Microscope",[["path",{d:"M6 18h8",key:"1borvv"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M14 22a7 7 0 1 0 0-14h-1",key:"1jwaiy"}],["path",{d:"M9 14h2",key:"197e7h"}],["path",{d:"M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z",key:"1bmzmy"}],["path",{d:"M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3",key:"1drr47"}]]);/**
122
122
  * @license lucide-react v0.468.0 - ISC
123
123
  *
124
124
  * This source code is licensed under the ISC license.
125
125
  * See the LICENSE file in the root directory of this source tree.
126
- */const Ea=ve("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
126
+ */const Sa=ye("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
127
127
  * @license lucide-react v0.468.0 - ISC
128
128
  *
129
129
  * This source code is licensed under the ISC license.
130
130
  * See the LICENSE file in the root directory of this source tree.
131
- */const Sa=ve("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
131
+ */const wa=ye("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
132
132
  * @license lucide-react v0.468.0 - ISC
133
133
  *
134
134
  * This source code is licensed under the ISC license.
135
135
  * See the LICENSE file in the root directory of this source tree.
136
- */const wa=ve("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
136
+ */const Ca=ye("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
137
137
  * @license lucide-react v0.468.0 - ISC
138
138
  *
139
139
  * This source code is licensed under the ISC license.
140
140
  * See the LICENSE file in the root directory of this source tree.
141
- */const ni=ve("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
141
+ */const ri=ye("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
142
142
  * @license lucide-react v0.468.0 - ISC
143
143
  *
144
144
  * This source code is licensed under the ISC license.
145
145
  * See the LICENSE file in the root directory of this source tree.
146
- */const Ca=ve("TestTubeDiagonal",[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]]);/**
146
+ */const Ra=ye("TestTubeDiagonal",[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]]);/**
147
147
  * @license lucide-react v0.468.0 - ISC
148
148
  *
149
149
  * This source code is licensed under the ISC license.
150
150
  * See the LICENSE file in the root directory of this source tree.
151
- */const Ra=ve("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);/**
151
+ */const Ta=ye("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);/**
152
152
  * @license lucide-react v0.468.0 - ISC
153
153
  *
154
154
  * This source code is licensed under the ISC license.
155
155
  * See the LICENSE file in the root directory of this source tree.
156
- */const Ta=ve("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);/**
156
+ */const Pa=ye("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);/**
157
157
  * @license lucide-react v0.468.0 - ISC
158
158
  *
159
159
  * This source code is licensed under the ISC license.
160
160
  * See the LICENSE file in the root directory of this source tree.
161
- */const Oa=ve("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/**
161
+ */const Oa=ye("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/**
162
162
  * @license lucide-react v0.468.0 - ISC
163
163
  *
164
164
  * This source code is licensed under the ISC license.
165
165
  * See the LICENSE file in the root directory of this source tree.
166
- */const Pa=ve("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);/**
166
+ */const Ia=ye("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);/**
167
167
  * @license lucide-react v0.468.0 - ISC
168
168
  *
169
169
  * This source code is licensed under the ISC license.
170
170
  * See the LICENSE file in the root directory of this source tree.
171
- */const Ia=ve("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/**
171
+ */const _a=ye("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/**
172
172
  * @license lucide-react v0.468.0 - ISC
173
173
  *
174
174
  * This source code is licensed under the ISC license.
175
175
  * See the LICENSE file in the root directory of this source tree.
176
- */const _a=ve("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Jr({align:e="start",className:t,...n}){return h.jsx("div",{...n,"data-slot":"message","data-align":e,className:ue("chat-message",t)})}function ri({className:e,...t}){return h.jsx("div",{...t,"data-slot":"message-avatar",className:ue("chat-message-avatar",e)})}function Zr({className:e,...t}){return h.jsx("div",{...t,"data-slot":"message-content",className:ue("chat-message-content",e)})}function ka({className:e,...t}){return h.jsx("div",{...t,"data-slot":"message-header",className:ue("chat-message-header",e)})}function Cr({className:e,...t}){return h.jsx("div",{...t,"data-slot":"message-footer",className:ue("chat-message-footer",e)})}const tt={...v},Ko={};function Ye(e,t){const n=v.useRef(Ko);return n.current===Ko&&(n.current=e(t)),n}const ur=tt.useInsertionEffect,Aa=ur&&ur!==tt.useLayoutEffect?ur:e=>e();function fe(e){const t=Ye(Na).current;return t.next=e,Aa(t.effect),t.trampoline}function Na(){const e={next:void 0,callback:ja,trampoline:(...t)=>{var n;return(n=e.callback)==null?void 0:n.call(e,...t)},effect:()=>{e.callback=e.next}};return e}function ja(){if(process.env.NODE_ENV!=="production")throw new Error("Base UI: Cannot call an event handler while rendering.")}function Rr(e,t,n,r){const o=Ye(oi).current;return Da(o,e,t,n,r)&&si(o,[e,t,n,r]),o.callback}function Ma(e){const t=Ye(oi).current;return Fa(t,e)&&si(t,e),t.callback}function oi(){return{callback:null,cleanup:null,refs:[]}}function Da(e,t,n,r,o){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==o}function Fa(e,t){return e.refs.length!==t.length||e.refs.some((n,r)=>n!==t[r])}function si(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const r=Array(t.length).fill(null);for(let o=0;o<t.length;o+=1){const s=t[o];if(s!=null)switch(typeof s){case"function":{const i=s(n);typeof i=="function"&&(r[o]=i);break}case"object":{s.current=n;break}}}e.cleanup=()=>{for(let o=0;o<t.length;o+=1){const s=t[o];if(s!=null)switch(typeof s){case"function":{const i=r[o];typeof i=="function"?i():s(null);break}case"object":{s.current=null;break}}}}}}}const La=parseInt(v.version,10);function ii(e){return La>=e}function Yo(e){if(!v.isValidElement(e))return null;const t=e,n=t.props;return(ii(19)?n==null?void 0:n.ref:t.ref)??null}function Tr(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}let Or;process.env.NODE_ENV!=="production"&&(Or=new Set);function ci(e,t){return function(...r){if(process.env.NODE_ENV!=="production"){const o=r.join(" "),s=`${t}: ${o}`,i=`${e}:${s}`;Or.has(i)||(Or.add(i),e==="warn"?console.warn(s):console.error(s))}}}const Qr=ci("warn","Base UI");function eo(){}const Ba=Object.freeze([]),Fe=Object.freeze({});function Va(e,t){const n={};for(const r in e){const o=e[r];if(t!=null&&t.hasOwnProperty(r)){const s=t[r](o);s!=null&&Object.assign(n,s);continue}o===!0?n[`data-${r.toLowerCase()}`]="":o&&(n[`data-${r.toLowerCase()}`]=o.toString())}return n}function $a(e,t){return typeof e=="function"?e(t):e}function ai(e,t){return typeof e=="function"?e(t):e}const li={};function to(e,t,n,r,o){if(!n&&!r&&!e)return kn(t);let s=kn(e);return t&&(s=Tn(s,t)),n&&(s=Tn(s,n)),r&&(s=Tn(s,r)),s}function Ha(e){if(e.length===0)return li;if(e.length===1)return kn(e[0]);let t=kn(e[0]);for(let n=1;n<e.length;n+=1)t=Tn(t,e[n]);return t}function kn(e){return fi(e)?{...e(li)}:Ua(e)}function Tn(e,t){return fi(t)?t(e):za(e,t)}function Ua(e){const t={...e};for(const n in t){const r=t[n];ui(n,r)&&(t[n]=di(r))}return t}function za(e,t){if(!t)return e;for(const n in t){const r=t[n];switch(n){case"style":{e[n]=Tr(e.style,r);break}case"className":{e[n]=pi(e.className,r);break}default:ui(n,r)?e[n]=Wa(e[n],r):e[n]=r}}return e}function ui(e,t){const n=e.charCodeAt(0),r=e.charCodeAt(1),o=e.charCodeAt(2);return n===111&&r===110&&o>=65&&o<=90&&(typeof t=="function"||typeof t>"u")}function fi(e){return typeof e=="function"}function Wa(e,t){return t?e?(...n)=>{const r=n[0];if(hi(r)){const s=r;An(s);const i=t(...n);return s.baseUIHandlerPrevented||e==null||e(...n),i}const o=t(...n);return e==null||e(...n),o}:di(t):e}function di(e){return e&&((...t)=>{const n=t[0];return hi(n)&&An(n),e(...t)})}function An(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function pi(e,t){return t?e?t+" "+e:t:e}function hi(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function pt(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=Ja(r));const o=qa(t,n,r);if(n.enabled===!1)return null;const s=n.state??Fe;return Za(e,r,o,s)}function qa(e,t,n){const{className:r,style:o}=e,{state:s=Fe,ref:i,props:c,stateAttributesMapping:a,enabled:l=!0}=t,f=l?$a(r,s):void 0,u=l?ai(o,s):void 0,d=l?Va(s,a):Fe,m=l&&c?Ga(c):void 0,p=l?Tr(d,m)??{}:Fe;return typeof document<"u"&&(l?Array.isArray(i)?p.ref=Ma([p.ref,Yo(n),...i]):p.ref=Rr(p.ref,Yo(n),i):Rr(null,null)),l?(f!==void 0&&(p.className=pi(p.className,f)),u!==void 0&&(p.style=Tr(p.style,u)),p):Fe}function Ga(e){return Array.isArray(e)?Ha(e):to(void 0,e)}const Ka=Symbol.for("react.lazy"),Ya=/^[A-Z][A-Za-z0-9$]*$/,Xa=/[a-z]/;function Ja(e){if((e==null?void 0:e.$$typeof)!==Ka)return e;const t=v.Children.toArray(e)[0];return v.isValidElement(t)?t:e}function Za(e,t,n,r){if(t){if(typeof t=="function")return process.env.NODE_ENV!=="production"&&Qa(t),t(n,r);const o=to(n,t.props);if(o.ref=n.ref,process.env.NODE_ENV!=="production"&&!v.isValidElement(t))throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.","A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.","https://base-ui.com/r/invalid-render-prop"].join(`
177
- `));return v.cloneElement(t,o)}return el(e,n)}function Qa(e){const t=e.name;t.length!==0&&Ya.test(t)&&Xa.test(t)&&Qr(`The \`render\` prop received a function named \`${t}\` that starts with an uppercase letter.`,"This usually means a React component was passed directly as `render={Component}`.","Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.","If this is an intentional render callback, rename it to start with a lowercase letter.","Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.","https://base-ui.com/r/invalid-render-prop")}function el(e,t){return e==="button"?I.createElement("button",{type:"button",...t,key:t.key}):e==="img"?I.createElement("img",{alt:"",...t,key:t.key}):v.createElement(e,t)}const Nn=ci("error","Base UI");function tl({controlled:e,default:t,name:n,state:r="value"}){const{current:o}=v.useRef(e!==void 0),[s,i]=v.useState(()=>t),c=o&&e!==void 0?e:s;if(process.env.NODE_ENV!=="production"){v.useEffect(()=>{o!==(e!==void 0)&&Nn([`A component is changing the ${o?"":"un"}controlled ${r} state of ${n} to be ${o?"un":""}controlled.`,"Elements should not switch from uncontrolled to controlled (or vice versa).",`Decide between using a controlled or uncontrolled ${n} element for the lifetime of the component.`,"The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.","More info: https://fb.me/react-controlled-components"].join(`
178
- `))},[r,n,e]);const{current:l}=v.useRef(t);v.useEffect(()=>{!o&&Xo(l)!==Xo(t)&&Nn([`A component is changing the default ${r} state of an uncontrolled ${n} after being initialized. To suppress this warning opt to use a controlled ${n}.`].join(`
179
- `))},[t])}const a=v.useCallback(l=>{o||i(l)},[]);return[c,a]}function Xo(e){let t=0;const n=new WeakMap;try{return JSON.stringify(e,function(s,i){if(!(s==="_owner"&&this!=null&&typeof this=="object"&&"$$typeof"in this)){if(typeof i=="bigint")return`__bigint__:${i}`;if(i!==null&&typeof i=="object"){const c=n.get(i);if(c!==void 0)return`__object__:${c}`;n.set(i,t),t+=1}return i}})??`__top__:${typeof e}`}catch{return"__unserializable__"}}function mi(){const[,e]=v.useState({});return v.useCallback(()=>{e({})},[])}let Jo=0;function nl(e,t="mui"){const n=v.useRef(void 0),r=mi(),o=e??n.current;return v.useEffect(()=>{n.current==null&&(Jo+=1,n.current=`${t}-${Jo}`,e==null&&r())},[e,t,r]),o}const Zo=tt.useId;function Gn(e,t){if(Zo!==void 0){const n=Zo();return e??(t?`${t}-${n}`:n)}return nl(e,t)}function gi(e){return Gn(e,"base-ui")}function Oe(e,t,n,r){let o=!1,s=!1;const i=Fe;return{reason:e,event:t??new Event("base-ui"),cancel(){o=!0},allowPropagation(){s=!0},get isCanceled(){return o},get isPropagationAllowed(){return s},trigger:n,...i}}const bi="none",Kn="trigger-press",We="trigger-hover",On="trigger-focus",rl="outside-press",ol="focus-out",no="escape-key",Pr="imperative-action",sl=()=>{},pe=typeof document<"u"?v.useLayoutEffect:sl;function ro(e){v.useEffect(e,Ba)}const pn=null;let Qo=globalThis.requestAnimationFrame;class il{constructor(){ae(this,"callbacks",[]);ae(this,"callbacksCount",0);ae(this,"nextId",1);ae(this,"startId",1);ae(this,"isScheduled",!1);ae(this,"tick",t=>{var o;this.isScheduled=!1;const n=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let s=0;s<n.length;s+=1)(o=n[s])==null||o.call(n,t)})}request(t){const n=this.nextId;this.nextId+=1,this.callbacks.push(t),this.callbacksCount+=1;const r=process.env.NODE_ENV!=="production"&&Qo!==requestAnimationFrame&&(Qo=requestAnimationFrame,!0);return(!this.isScheduled||r)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),n}cancel(t){const n=t-this.startId;n<0||n>=this.callbacks.length||this.callbacks[n]!==null&&(this.callbacks[n]=null,this.callbacksCount-=1)}}let hn=new il;class Ne{constructor(){ae(this,"currentId",pn);ae(this,"cancel",()=>{this.currentId!==pn&&(hn.cancel(this.currentId),this.currentId=pn)});ae(this,"disposeEffect",()=>this.cancel)}static create(){return new Ne}static request(t){return hn.request(t)}static cancel(t){return hn.cancel(t)}request(t){this.cancel(),this.currentId=hn.request(()=>{this.currentId=pn,t()})}}function cl(){const e=Ye(Ne.create).current;return ro(e.disposeEffect),e}function yi(e,t=!1,n=!1,r=!1){const[o,s]=v.useState(e&&t?"idle":void 0),[i,c]=v.useState(e&&!r);return e&&!i&&(c(!0),s("starting")),!e&&i&&o!=="ending"&&!n&&s("ending"),!e&&!i&&o==="ending"&&s(void 0),pe(()=>{if(!e&&i&&o!=="ending"&&n){const a=Ne.request(()=>{s("ending")});return()=>{Ne.cancel(a)}}},[e,i,o,n]),pe(()=>{if(!e||t||o===void 0)return;const a=Ne.request(()=>{s(void 0)});return()=>{Ne.cancel(a)}},[t,e,o]),pe(()=>{if(!e||!t)return;e&&i&&o!=="idle"&&s("starting");const a=Ne.request(()=>{s("idle")});return()=>{Ne.cancel(a)}},[t,e,i,o]),{mounted:i,setMounted:c,transitionStatus:o}}function al(e){const{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:o}=e,[s,i]=tl({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:c,setMounted:a,transitionStatus:l}=yi(s,!0,!0),f=gi(),[u,d]=v.useState(),m=u===null?void 0:u??f,p=fe(g=>{const b=!s,y=Oe(Kn,g.nativeEvent);r(b,y),!y.isCanceled&&i(b)});return v.useMemo(()=>({defaultPanelId:f,disabled:o,handleTrigger:p,mounted:c,open:s,panelId:m,setMounted:a,setOpen:i,setPanelIdState:d,transitionStatus:l}),[f,o,p,c,s,m,a,i,d,l])}function ll(e,t){return function(r,...o){const s=new URL(e);return s.searchParams.set("code",r.toString()),o.forEach(i=>s.searchParams.append("args[]",i)),`${t} error #${r}; visit ${s} for the full message.`}}const wt=ll("https://base-ui.com/production-error","Base UI"),oo=v.createContext(void 0);process.env.NODE_ENV!=="production"&&(oo.displayName="CollapsibleRootContext");function vi(){const e=v.useContext(oo);if(e===void 0)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>.":wt(15));return e}const so="data-starting-style",ul="data-ending-style",fl={[so]:""},dl={[ul]:""},io={transitionStatus(e){return e==="starting"?fl:e==="ending"?dl:null}},pl="data-open",hl="data-closed",mn=so,ml="data-panel-open",gl={[pl]:""},bl={[hl]:""},yl={open(e){return e?{[ml]:""}:null}},vl={open(e){return e?gl:bl}},xi={...vl,...io},Ei=v.forwardRef(function(t,n){const{render:r,className:o,defaultOpen:s=!1,disabled:i=!1,onOpenChange:c,open:a,style:l,...f}=t,u=fe(c),d=al({open:a,defaultOpen:s,onOpenChange:u,disabled:i}),m=v.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=v.useMemo(()=>({...d,onOpenChange:u,state:m}),[d,u,m]),g=pt("div",t,{state:m,ref:n,props:f,stateAttributesMapping:xi});return h.jsx(oo.Provider,{value:p,children:g})});process.env.NODE_ENV!=="production"&&(Ei.displayName="CollapsibleRoot");function Yn(){return typeof window<"u"}function Le(e){return co(e)?(e.nodeName||"").toLowerCase():"#document"}function Ie(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ot(e){var t;return(t=(co(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function co(e){return Yn()?e instanceof Node||e instanceof Ie(e).Node:!1}function ge(e){return Yn()?e instanceof Element||e instanceof Ie(e).Element:!1}function _e(e){return Yn()?e instanceof HTMLElement||e instanceof Ie(e).HTMLElement:!1}function At(e){return!Yn()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ie(e).ShadowRoot}function Xn(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=$e(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function xl(e){return/^(table|td|th)$/.test(Le(e))}function Jn(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const El=/transform|translate|scale|rotate|perspective|filter/,Sl=/paint|layout|strict|content/,gt=e=>!!e&&e!=="none";let fr;function ao(e){const t=ge(e)?$e(e):e;return gt(t.transform)||gt(t.translate)||gt(t.scale)||gt(t.rotate)||gt(t.perspective)||!lo()&&(gt(t.backdropFilter)||gt(t.filter))||El.test(t.willChange||"")||Sl.test(t.contain||"")}function wl(e){let t=lt(e);for(;_e(t)&&!ct(t);){if(ao(t))return t;if(Jn(t))return null;t=lt(t)}return null}function lo(){return fr==null&&(fr=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),fr}function ct(e){return/^(html|body|#document)$/.test(Le(e))}function $e(e){return Ie(e).getComputedStyle(e)}function Zn(e){return ge(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function lt(e){if(Le(e)==="html")return e;const t=e.assignedSlot||e.parentNode||At(e)&&e.host||ot(e);return At(t)?t.host:t}function Si(e){const t=lt(e);return ct(t)?(e.ownerDocument||e).body:_e(t)&&Xn(t)?t:Si(t)}function Gt(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Si(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Ie(o);if(s){const c=Ir(i);return t.concat(i,i.visualViewport||[],Xn(o)?o:[],c&&n?Gt(c):[])}else return t.concat(o,Gt(o,[],n))}function Ir(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const wi=v.createContext(void 0);process.env.NODE_ENV!=="production"&&(wi.displayName="CompositeRootContext");function Cl(e=!1){const t=v.useContext(wi);if(t===void 0&&!e)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>.":wt(16));return t}function Rl(e){const{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:o=0,isNativeButton:s}=e,i=r&&t!==!1,c=r&&t===!1;return{props:v.useMemo(()=>{const l={onKeyDown(f){n&&t&&f.key!=="Tab"&&f.preventDefault()}};return r||(l.tabIndex=o,!s&&n&&(l.tabIndex=t?o:-1)),(s&&(t||i)||!s&&n)&&(l["aria-disabled"]=n),s&&(!t||c)&&(l.disabled=n),l},[r,n,t,i,c,s,o])}}function Ke(e){return(e==null?void 0:e.ownerDocument)||document}function dr(e,t,{detail:n=0,pointerType:r=""}={}){e.dispatchEvent(new(Ie(e)).PointerEvent("click",{bubbles:!0,cancelable:!0,composed:!0,detail:n,pointerType:r,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function Ci(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:o=!0,composite:s}=e,i=v.useRef(null),c=Cl(!0),a=s??c!==void 0,{props:l}=Rl({focusableWhenDisabled:n,disabled:t,composite:a,tabIndex:r,isNativeButton:o});process.env.NODE_ENV!=="production"&&v.useEffect(()=>{var p,g;if(!i.current)return;const m=gn(i.current);if(o){if(!m){const b=((p=tt.captureOwnerStack)==null?void 0:p.call(tt))||"";Nn(`A component that acts as a button expected a native <button> because the \`nativeButton\` prop is true. Rendering a non-<button> removes native button semantics, which can impact forms and accessibility. Use a real <button> in the \`render\` prop, or set \`nativeButton\` to \`false\`.${b}`)}}else if(m){const b=((g=tt.captureOwnerStack)==null?void 0:g.call(tt))||"";Nn(`A component that acts as a button expected a non-<button> because the \`nativeButton\` prop is false. Rendering a <button> keeps native behavior while Base UI applies non-native attributes and handlers, which can add unintended extra attributes (such as \`role\` or \`aria-disabled\`). Use a non-<button> in the \`render\` prop, or set \`nativeButton\` to \`true\`.${b}`)}},[o]);const f=v.useCallback(()=>{const m=i.current;gn(m)&&a&&t&&l.disabled===void 0&&m.disabled&&(m.disabled=!1)},[t,l.disabled,a]);pe(f,[f]);const u=v.useCallback((m={})=>{const{onClick:p,onMouseDown:g,onKeyUp:b,onKeyDown:y,onPointerDown:x,...S}=m;return to({onClick(E){if(t){E.preventDefault();return}p==null||p(E)},onMouseDown(E){t||g==null||g(E)},onKeyDown(E){if(t||(An(E),y==null||y(E),E.baseUIHandlerPrevented))return;const C=E.target===E.currentTarget,w=E.currentTarget,R=gn(w),O=!o&&Tl(w),P=C&&(o?R:!O),M=E.key==="Enter",F=E.key===" ",A=w.getAttribute("role"),D=(A==null?void 0:A.startsWith("menuitem"))||A==="option"||A==="gridcell";if(C&&a&&F){if(E.defaultPrevented&&D)return;E.preventDefault(),(!o||R)&&(E.preventBaseUIHandler(),dr(w,E));return}if(!P||o||!F&&!M){C&&O&&F&&E.preventDefault();return}E.defaultPrevented||(E.preventDefault(),M&&(E.preventBaseUIHandler(),dr(w,E)))},onKeyUp(E){if(!t){if(An(E),b==null||b(E),E.target===E.currentTarget&&o&&a&&gn(E.currentTarget)&&E.key===" "){E.preventDefault();return}E.baseUIHandlerPrevented||E.target===E.currentTarget&&!o&&!a&&!E.defaultPrevented&&E.key===" "&&(E.preventBaseUIHandler(),dr(E.currentTarget,E))}},onPointerDown(E){if(t){E.preventDefault();return}x==null||x(E)}},o?{type:"button"}:{role:"button"},l,S)},[t,l,a,o]),d=fe(m=>{i.current=m,f()});return{getButtonProps:u,buttonRef:d}}function gn(e){return _e(e)&&e.tagName==="BUTTON"}function Tl(e){return _e(e)&&e.tagName==="A"&&!!e.href}const Ol={...yl,...io},Ri=v.forwardRef(function(t,n){const{panelId:r,open:o,handleTrigger:s,state:i,disabled:c}=vi(),{className:a,disabled:l=c,render:f,nativeButton:u=!0,style:d,...m}=t,{getButtonProps:p,buttonRef:g}=Ci({disabled:l,native:u});return pt("button",t,{state:i,ref:[n,g],props:[{"aria-controls":o?r:void 0,"aria-expanded":o,onClick:s},m,p],stateAttributesMapping:Ol})});process.env.NODE_ENV!=="production"&&(Ri.displayName="CollapsibleTrigger");function Ee(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}const Ht=0;class ut{constructor(){ae(this,"currentId",Ht);ae(this,"clear",()=>{this.currentId!==Ht&&(clearTimeout(this.currentId),this.currentId=Ht)});ae(this,"disposeEffect",()=>this.clear)}static create(){return new ut}start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Ht,n()},t)}isStarted(){return this.currentId!==Ht}}function zt(){const e=Ye(ut.create).current;return ro(e.disposeEffect),e}function qe(e){const t=Ye(Pl,e).current;return t.next=e,pe(t.effect),t}function Pl(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function Il(e){return e==null?e:"current"in e?e.current:e}function es(e,t){return e.getAnimations(t).filter(n=>{var o;const r=(o=n.effect)==null?void 0:o.getTiming();return(r==null?void 0:r.duration)!==1/0&&(r==null?void 0:r.iterations)!==1/0})}let bn=null;function _l(e){if(!bn){const t=[];bn=t,queueMicrotask(()=>{bn=null,dt.flushSync(()=>{for(const n of t)n()})})}bn.push(e)}function Ti(e,t=!1,n=!1){const r=cl();return fe((o,s=null)=>{r.cancel();const i=Il(e);if(i==null)return;const c=i,a=()=>{if(!n){dt.flushSync(o);return}_l(()=>{s!=null&&s.aborted||o()})};if(typeof c.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){o();return}function l(){Promise.all(es(c).map(f=>f.finished.then(eo))).then(()=>{s!=null&&s.aborted||a()},()=>{if(s!=null&&s.aborted)return;if(es(c).some(u=>u.pending||u.playState!=="finished")){l();return}a()})}if(t){const f=so;if(!c.hasAttribute(f)){r.request(l);return}const u=new MutationObserver(()=>{c.hasAttribute(f)||(u.disconnect(),l())});u.observe(c,{attributes:!0,attributeFilter:[f]}),s==null||s.addEventListener("abort",()=>u.disconnect(),{once:!0});return}r.request(l)})}function uo(e){const{enabled:t=!0,open:n,ref:r,batch:o=!1,onComplete:s}=e,i=fe(s),c=Ti(r,n,o);v.useEffect(()=>{if(!t)return;const a=new AbortController;return c(i,a.signal),()=>{a.abort()}},[t,n,i,c])}const Pt={height:void 0,width:void 0};function kl(e){const{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:o,mounted:s,onOpenChange:i,open:c,setMounted:a,setOpen:l,transitionStatus:f}=e,u=v.useRef(null),d=v.useRef(null),[m,p]=v.useState(Pt),g=v.useRef(Pt),b=v.useRef(!1),y=v.useRef(c),x=v.useRef(!1),[S,E]=v.useState(!1),C=v.useRef(null),w=Rr(t,u),R=qe(c),O=Ti(u),P=!c&&!s,M=S?"idle":f,F=c&&(y.current||x.current),A=!c&&s&&d.current==="css-animation"&&m.height===void 0&&m.width===void 0?g.current:m,D=n&&P&&d.current!=="css-animation",_=fe((N,Y=!0)=>{Y&&(g.current=N),p(N)}),T=fe(()=>{var N;(N=C.current)==null||N.call(C),C.current=null}),k=fe(N=>{T(),C.current=()=>{C.current=null,N()}}),U=fe(()=>{c&&s&&d.current==="css-animation"&&(x.current=!0)});pe(()=>{!S||f==="starting"||E(!1)},[S,f]),v.useEffect(()=>()=>{U(),T()},[U,T]),pe(()=>{c||(y.current=!1,x.current=!1);const N=u.current;if(!N)return;!c&&C.current&&T();const Y=Al(N,F);if(d.current=Y,c&&f==="idle"&&y.current&&Y==="css-animation"){g.current=It(N);return}if(c&&f==="starting"){const ie=b.current;if(b.current=!1,Y==="none"){_(It(N)),E(!0);return}if(Y==="css-transition"){const B=Nl(N);if(_(It(N)),!ie)return B;const $=yn(N,"transition-duration","0s");return k($),E(!0),B}_(It(N));const L=yn(N,"animation-name","none");if(!ie){L();return}const X=yn(N,"animation-duration","0s");L(),k(X),E(!0);return}if(!c&&s&&(f==="idle"||f==="starting")){if(Y==="none"){_(Pt,!1),a(!1);return}_(It(N));return}if(f!=="ending")return;if(Y==="none"){a(!1);return}const K=It(N);if(!(K.height>0||K.width>0)){a(!1);return}_(K),Y==="css-animation"&&yn(N,"animation-name","none")()},[s,c,T,_,a,k,F,f]),uo({enabled:c&&s&&M==="idle",open:!0,ref:u,onComplete(){c&&_(Pt,!1)}}),v.useEffect(()=>{if(c||!s||M!=="ending")return;if(!u.current){a(!1),_(Pt,!1);return}const Y=new AbortController;let K=-1;function le(){R.current||(a(!1),_(Pt,!1))}return K=Ne.request(()=>{O(le,Y.signal)}),()=>{Ne.cancel(K),Y.abort()}},[R,s,c,M,O,_,a]),pe(()=>{const N=u.current;!N||!n||!P||N.setAttribute("hidden","until-found")},[P,n]),v.useEffect(function(){const Y=u.current;if(!Y)return;const K=ut.create();let le=-1;const ie=(B,$)=>{K.start(0,()=>{R.current||(le=Ne.request(()=>{R.current||(B&&(b.current=!1),$&&Y.setAttribute(mn,""),Y.setAttribute("hidden","until-found"))}))})},X=Ee(Y,"beforematch",B=>{const $=Oe(bi,B);if(i(!0,$),$.isCanceled){ie(!1,!1);return}b.current=!0;const Q=Y.hasAttribute(mn);Y.removeAttribute(mn),l(!0),ie(!0,Q)});return()=>{K.clear(),Ne.cancel(le),X()}},[R,i,l]);const j=o||n||s||c;return{height:A.height,props:{...D?{[mn]:""}:void 0,hidden:P,id:r},ref:w,shouldPreventOpenAnimation:F,shouldRender:j,transitionStatus:M,width:A.width}}function It(e){return{height:e.scrollHeight,width:e.scrollWidth}}function Al(e,t){const n=Ie(e).getComputedStyle(e),r=(n.animationName.split(",").map(s=>s.trim()).some(s=>s!==""&&s!=="none")||t)&&ts(n.animationDuration),o=ts(n.transitionDuration);return r&&o?(process.env.NODE_ENV!=="production"&&Qr("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.","Only one of either animation type should be used."),"css-transition"):o?"css-transition":r?"css-animation":"none"}function ts(e){return e.split(",").map(t=>t.trim()).some(t=>t!==""&&Number.parseFloat(t)>0)}function yn(e,t,n){const r=e.style.getPropertyValue(t),o=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===""){e.style.removeProperty(t);return}e.style.setProperty(t,r,o)}}function Nl(e){const t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(o=>{e.style.setProperty(o,"initial","important")});function n(){Object.entries(t).forEach(([o,s])=>{if(s===""){e.style.removeProperty(o);return}e.style.setProperty(o,s)})}const r=Ne.request(n);return()=>{Ne.cancel(r),n()}}const jl="--collapsible-panel-height",Ml="--collapsible-panel-width",Oi=v.forwardRef(function(t,n){const{className:r,hiddenUntilFound:o,keepMounted:s,render:i,id:c,style:a,...l}=t;process.env.NODE_ENV!=="production"&&v.useEffect(()=>{o&&s===!1&&Qr("The `keepMounted={false}` prop on `Collapsible.Panel` is ignored when `hiddenUntilFound` is enabled, since the panel must remain mounted while closed.")},[o,s]);const{defaultPanelId:f,mounted:u,onOpenChange:d,open:m,setMounted:p,setPanelIdState:g,setOpen:b,state:y,transitionStatus:x}=vi(),S=o??!1,E=s??!1,C=c||void 0,w=C??f;pe(()=>(g(U=>C??(U===null?void 0:U)),()=>{g(U=>U===C?null:U)}),[C,g]);const{height:R,props:O,ref:P,shouldPreventOpenAnimation:M,shouldRender:F,transitionStatus:A,width:D}=kl({externalRef:n,hiddenUntilFound:S,id:w,keepMounted:E,mounted:u,onOpenChange:d,open:m,setMounted:p,setOpen:b,transitionStatus:x}),_={...y,transitionStatus:A},T=ai(a,_),k=pt("div",{...t,style:void 0},{state:_,ref:P,props:[O,{style:{[jl]:R===void 0?"auto":`${R}px`,[Ml]:D===void 0?"auto":`${D}px`}},l,T?{style:T}:void 0,M?{style:{animationName:"none"}}:void 0],stateAttributesMapping:xi});return F?k:null});process.env.NODE_ENV!=="production"&&(Oi.displayName="CollapsiblePanel");function bt({className:e,...t}){return h.jsx("div",{"data-slot":"trace",className:ue("trace",e),...t})}function Nt({className:e,status:t,...n}){return h.jsx("span",{"data-slot":"trace-line","data-status":t,className:ue("trace-line",e),...n})}function xt({className:e,...t}){return h.jsx("span",{"data-slot":"trace-icon",className:ue("trace-icon",e),...t,"aria-hidden":"true"})}function jt({className:e,...t}){return h.jsx("span",{"data-slot":"trace-title",className:ue("trace-title",e),...t})}function Kt({className:e,...t}){return h.jsx("span",{"data-slot":"trace-description",className:ue("trace-description",e),...t})}function Pi(e){return h.jsx(Ei,{"data-slot":"trace-collapsible",...e})}function Ii({children:e,className:t,...n}){return h.jsxs(Ri,{type:"button","data-slot":"trace-collapsible-trigger",className:ue("trace-trigger",t),...n,children:[e,h.jsx(xt,{className:"trace-chevron",children:h.jsx(Js,{size:13})})]})}function _i({className:e,...t}){return h.jsx(Oi,{...t,"data-slot":"trace-collapsible-content",className:ue("trace-content",e)})}const Dl=({message:e,onRetry:t})=>h.jsx(Jr,{className:"chat-error-banner",role:"alert",children:h.jsxs(Zr,{children:[h.jsx(bt,{className:"chat-message-body",children:h.jsxs(Nt,{status:"error",children:[h.jsx(xt,{children:h.jsx(ma,{size:14})}),h.jsx(jt,{className:"chat-error-title",children:e})]})}),t&&h.jsx(Cr,{children:h.jsx("button",{type:"button",onClick:t,className:"chat-error-retry-btn",children:"Try again"})})]})}),Fl={alpha:{label:"Alpha",Icon:ya,variant:"env-badge--alpha",tooltip:"Alpha build — internal testing only"},beta:{label:"Beta",Icon:Ca,variant:"env-badge--beta",tooltip:"Beta build — public pre-release"},gamma:{label:"Gamma",Icon:xa,variant:"env-badge--gamma",tooltip:"Gamma / Release Candidate"},qa:{label:"QA",Icon:ga,variant:"env-badge--qa",tooltip:"Quality Assurance build"}},Ll=({stage:e,pulse:t=!0,className:n=""})=>{if(!e)return null;const{label:r,Icon:o,variant:s,tooltip:i}=Fl[e];return h.jsxs("span",{className:`env-badge-inline ${s} ${n}`.trim(),title:i,"aria-label":`${r} build`,role:"status",children:[h.jsx(o,{size:10,className:"env-badge-icon","aria-hidden":"true"}),h.jsx("span",{className:"env-badge-inline-label",children:r})]})},Bl=e=>h.jsx("svg",{width:e.width||"24px",height:e.height||"24px",viewBox:"0 0 24 24",role:"img",xmlns:"http://www.w3.org/2000/svg",fill:e.Color||"currentColor",...e,children:h.jsx("path",{d:"M11.999 0c-2.25 0-4.5.06-6.6.21a5.57 5.57 0 0 0-5.19 5.1c-.24 3.21-.27 6.39-.06 9.6a5.644 5.644 0 0 0 5.7 5.19h3.15v-3.9h-3.15c-.93.03-1.74-.63-1.83-1.56-.18-3-.15-6 .06-9 .06-.84.72-1.47 1.56-1.53 2.04-.15 4.2-.21 6.36-.21s4.32.09 6.36.18c.81.06 1.5.69 1.56 1.53.24 3 .24 6 .06 9-.12.93-.9 1.62-1.83 1.59h-3.15l-6 3.9V24l6-3.9h3.15c2.97.03 5.46-2.25 5.7-5.19.21-3.18.18-6.39-.03-9.57a5.57 5.57 0 0 0-5.19-5.1c-2.13-.18-4.38-.24-6.63-.24zm-5.04 8.76c-.36 0-.66.3-.66.66v2.34c0 .33.18.63.48.78 1.62.78 3.42 1.2 5.22 1.26 1.8-.06 3.6-.48 5.22-1.26.3-.15.48-.45.48-.78V9.42c0-.09-.03-.15-.09-.21a.648.648 0 0 0-.87-.36c-1.5.66-3.12 1.02-4.77 1.05-1.65-.03-3.27-.42-4.77-1.08a.566.566 0 0 0-.24-.06z"})}),Vl=({title:e="VPS AI Assistant",subtitle:t="Customer portal support",onClose:n,onReset:r,onBack:o,soundEnabled:s,onToggleSound:i,showMinimize:c=!1,envStage:a,envPulse:l=!0})=>h.jsxs("header",{className:"chat-header",children:[h.jsxs("div",{className:"chat-header-left",children:[o&&h.jsx("button",{type:"button",onClick:o,className:"icon-btn-back","aria-label":"Back",children:h.jsx(fa,{size:16})}),h.jsx("div",{className:"avatar-circle","aria-hidden":"true",children:h.jsx(Bl,{width:"16px",height:"16px",color:"white"})}),h.jsxs("div",{children:[h.jsxs("div",{className:"chat-header-title-row",children:[h.jsx("h2",{className:"chat-header-title",children:e}),h.jsx(Ll,{stage:a,pulse:l})]}),h.jsx("p",{className:"chat-header-subtitle",children:t||"Customer portal support"})]})]}),h.jsxs("div",{className:"chat-header-actions",children:[i&&h.jsx("button",{type:"button",className:"icon-btn-action chat-sound-btn","aria-label":"Response sound","aria-pressed":!!s,title:s?"Mute response sound":"Enable response sound",onClick:i,children:s?h.jsx(Oa,{size:16,"aria-hidden":"true"}):h.jsx(Pa,{size:16,"aria-hidden":"true"})}),r&&h.jsx("button",{type:"button",onClick:r,className:"icon-btn-action","aria-label":"Start a new conversation",title:"New conversation",children:h.jsx(wa,{size:15})}),n&&h.jsx("button",{type:"button",onClick:n,className:"icon-btn-action","aria-label":c?"Minimize chat":"Close chat",children:h.jsx(Ea,{size:16})})]})]});function $l(e,t){const n=I.useRef(e);I.useEffect(()=>{var r;n.current&&!e&&((r=t.current)==null||r.focus()),n.current=e},[e,t])}function Hl({className:e,...t}){return h.jsx("div",{...t,"data-slot":"input-group",className:ue("chat-input-group",e)})}function Ul({className:e,...t}){return h.jsx("textarea",{...t,"data-slot":"input-group-textarea",className:ue("chat-textarea",e)})}function zl({className:e,...t}){return h.jsx("div",{...t,"data-slot":"input-group-addon",className:ue("chat-input-actions",e)})}function ns({className:e,...t}){return h.jsx("button",{type:"button",...t,"data-slot":"input-group-button",className:ue("chat-send-btn",e)})}const ki=v.forwardRef(function(t,n){const{render:r,className:o,disabled:s=!1,focusableWhenDisabled:i=!1,nativeButton:c=!0,style:a,...l}=t,{getButtonProps:f,buttonRef:u}=Ci({disabled:s,focusableWhenDisabled:i,native:c});return pt("button",t,{state:{disabled:s},ref:[n,u],props:[l,f]})});process.env.NODE_ENV!=="production"&&(ki.displayName="Button");const rs=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,os=qs,Wl=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return os(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:s}=t,i=Object.keys(o).map(l=>{const f=n==null?void 0:n[l],u=s==null?void 0:s[l];if(f===null)return null;const d=rs(f)||rs(u);return o[l][d]}),c=n&&Object.entries(n).reduce((l,f)=>{let[u,d]=f;return d===void 0||(l[u]=d),l},{}),a=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((l,f)=>{let{class:u,className:d,...m}=f;return Object.entries(m).every(p=>{let[g,b]=p;return Array.isArray(b)?b.includes({...s,...c}[g]):{...s,...c}[g]===b})?[...l,u,d]:l},[]);return os(e,i,a,n==null?void 0:n.class,n==null?void 0:n.className)},ql=Wl("vps-ui-button",{variants:{variant:{default:"vps-ui-button--default",outline:"vps-ui-button--outline",secondary:"vps-ui-button--secondary",ghost:"vps-ui-button--ghost",destructive:"vps-ui-button--destructive",link:"vps-ui-button--link"},size:{default:"vps-ui-button--size-default",xs:"vps-ui-button--size-xs",sm:"vps-ui-button--size-sm",lg:"vps-ui-button--size-lg",icon:"vps-ui-button--size-icon","icon-xs":"vps-ui-button--size-icon-xs","icon-sm":"vps-ui-button--size-icon-sm","icon-lg":"vps-ui-button--size-icon-lg"}},defaultVariants:{variant:"default",size:"default"}});function fo({className:e,variant:t,size:n,...r}){return h.jsx(ki,{type:"button","data-slot":"button",...r,className:o=>ue(ql({variant:t,size:n}),typeof e=="function"?e(o):e)})}function Gl({className:e,...t}){return h.jsx("div",{...t,className:ue("flex scroll-fade-x scrollbar-none gap-2 overflow-x-auto overscroll-x-contain",e),"data-slot":"suggestions"})}function Kl({suggestion:e,onClick:t,children:n,className:r,variant:o="outline",size:s="sm",...i}){return h.jsx(fo,{...i,variant:o,size:s,className:c=>ue("shrink-0",typeof r=="function"?r(c):r),onClick:()=>t==null?void 0:t(e),children:n??e})}function Yl(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.label.toLowerCase().includes(n)||r.query.toLowerCase().includes(n)):e}const Xl=({suggestions:e,onSelect:t,disabled:n,variant:r="list"})=>e.length?h.jsx(Gl,{className:r==="badge"?"chat-suggestion-strip":"suggestions-list",role:"list","aria-label":"Suggested questions",children:e.map(o=>h.jsx("div",{role:"listitem",children:h.jsx(Kl,{suggestion:o.query,disabled:n,onClick:()=>t(o),title:o.query,children:o.label})},o.query))}):null,Jl=({onSend:e,onStop:t,disabled:n=!1,placeholder:r="Ask something…",ref:o})=>{const{suggestions:s,showSuggestions:i,suggestionBadgesEnabled:c,models:a,selectedModelId:l,selectModel:f}=en(),[u,d]=I.useState(""),m=I.useRef(null),p=I.useId(),g=I.useId(),b=E=>{E&&(E.style.height="auto",E.style.height=`${Math.min(E.scrollHeight,96)}px`)};$l(n,m),I.useImperativeHandle(o,()=>({edit(E){var C;n||(d(E),(C=m.current)==null||C.focus())}}),[n]),I.useEffect(()=>{b(m.current)},[u]);const y=I.useMemo(()=>{if(!c||n)return[];const E=u.trim();return E?Yl(s,E):i?s:[]},[n,i,c,s,u]),x=E=>{d(E.query);const C=m.current;C==null||C.focus()},S=()=>{const E=u.trim();!E||n||(e(E),d(""))};return h.jsxs("div",{className:"chat-input-wrapper",children:[h.jsx(Xl,{variant:"badge",suggestions:y,onSelect:x,disabled:n}),h.jsxs("form",{onSubmit:E=>{E.preventDefault(),S()},children:[h.jsx("label",{htmlFor:p,className:"sr-only",children:"Chat message"}),h.jsxs(Hl,{children:[h.jsx(Ul,{id:p,ref:m,rows:1,value:u,disabled:n,placeholder:r,onChange:E=>d(E.target.value),onKeyDown:E=>{var C;E.key==="Enter"&&!E.shiftKey&&!E.nativeEvent.isComposing&&(E.preventDefault(),(C=E.currentTarget.form)==null||C.requestSubmit())}}),h.jsxs(zl,{children:[a.length>1&&h.jsxs("div",{className:"chat-model-picker",children:[h.jsx("label",{htmlFor:g,className:"sr-only",children:"AI model"}),h.jsxs("select",{id:g,value:l,disabled:n,onChange:E=>f(E.target.value),children:[h.jsx("option",{value:"auto",children:"Automatic"}),a.map(E=>h.jsx("option",{value:E.id,disabled:!E.configured,children:E.label},E.id))]})]}),t?h.jsx(ns,{onClick:t,"aria-label":"Stop response",title:"Stop response",children:h.jsx(ni,{size:13,fill:"currentColor","aria-hidden":"true"})}):h.jsx(ns,{type:"submit",disabled:n||!u.trim(),"aria-label":"Send message",title:"Send message",children:h.jsx(da,{size:16,"aria-hidden":"true"})})]})]})]}),h.jsxs("p",{className:"chat-input-footer",children:[h.jsx("span",{className:"chat-input-note",children:"AI can make mistakes."}),"Powered by ",h.jsx("span",{className:"chat-input-footer-brand",children:"VPS Veritas AI"})]})]})};function Zl({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:o}){let s=_r(Ql(r,o),t);if(!n)return v.createElement(e,s);if(typeof n=="function")return n(s,r);if(!v.isValidElement(n))return null;let i=n.props,c={..._r(s,i),ref:tn(s.ref,i.ref)};return v.cloneElement(n,c)}function _r(...e){let t={};for(let n of e){if(!n)continue;let r=n;for(let o of Object.keys(r)){let s=r[o];if(s===void 0)continue;let i=t[o];o==="className"?t[o]=[i,s].filter(Boolean).join(" "):o==="style"?t[o]={...i,...s}:o==="ref"?t[o]=tn(i,s):tu(o)&&typeof i=="function"&&typeof s=="function"?t[o]=eu(s,i):t[o]=s}}return t}function Ql(e,t){var r;let n={};for(let o of Object.keys(e)){let s=e[o],i=(r=t==null?void 0:t[o])==null?void 0:r.call(t,s);if(i){Object.assign(n,i);continue}if(o==="slot"){n["data-slot"]=s;continue}let c=`data-${String(o).replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`)}`;typeof s=="boolean"?n[c]=s?"":void 0:s!=null&&(n[c]=String(s))}return n}function eu(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function tu(e){return/^on[A-Z]/.test(e)}function tn(...e){let t=e.filter(Boolean);if(t.length!==0)return n=>{for(let r of t)typeof r=="function"?r(n):r&&(r.current=n)}}var nu=8,ru=64,ou=0,jn=.5,su=180,iu=new Set(["ArrowDown","ArrowUp","End","Home","PageDown","PageUp"," "]),Ai={start:!1,end:!1},cu=[],Mn={currentAnchorId:null,visibleMessageIds:cu};function au({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return Ai;let o=po({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:o-r.scrollTop-r.clientHeight>t}}function lu({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:o,visibleMessageIds:s}){if(!e||!o)return Mn;let i=o.getBoundingClientRect(),c=i.top+t+n,a=typeof IntersectionObserver>"u",l=[],f=null;for(let u of Yt(e,r)){let d=u.dataset.messageId;if(!d)continue;let m=u.dataset.scrollAnchor==="true",p=m||a?u.getBoundingClientRect():null;(a&&p?p.bottom>c&&p.top<i.bottom:s.has(d))&&l.push(d),m&&p&&p.top<=c+jn&&(f=d)}return l.length===0&&f===null?Mn:{currentAnchorId:f,visibleMessageIds:l}}function Yt(e,t){return Array.from(e.children).filter(n=>n instanceof HTMLElement&&n!==t)}function uu(e,t){for(let n=t;n<e.length;n++){let r=e[n];if((r==null?void 0:r.dataset.scrollAnchor)==="true")return r}return null}function fu(e,t){for(let n of e)if(n.dataset.scrollAnchor==="true"&&!t.has(n))return n;return null}function du(e,t){var r;let n=0;for(let o=t;o<e.length;o++)if(((r=e[o])==null?void 0:r.dataset.scrollAnchor)==="true"&&(n+=1,n>1))return!0;return!1}function pu(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if((n==null?void 0:n.dataset.scrollAnchor)==="true")return n}return null}function hu({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let o of Yt(e,t)){if(!o.dataset.messageId)continue;let s=o.getBoundingClientRect();if(s.bottom>r.top&&s.top<r.bottom)return o}return null}function mu({align:e,element:t,scrollMargin:n,spacer:r,viewport:o}){let s=Ni(t,o),i=t.getBoundingClientRect().height,c=yu(r);if(e==="center"){let a=Math.max(0,o.clientHeight-c.start-c.end);return s-c.start-(a-i)/2-n}if(e==="end")return s-o.clientHeight+i+c.end+n;if(e==="nearest"){let a=s+i,l=o.scrollTop+c.start,f=o.scrollTop+o.clientHeight-c.end;return s>=l&&a<=f?o.scrollTop:s<l?s-c.start-n:a-o.clientHeight+c.end+n}return s-c.start-n}function Ni(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function Pn(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function gu({content:e,scrollTop:t,spacer:n,viewport:r}){let o=po({content:e,spacer:n,viewport:r});return t+r.clientHeight-o}function po({content:e,spacer:t,viewport:n}){let r=Yt(e,t),o=ji(e),s=n.getBoundingClientRect(),i=n.scrollTop,c=o.start+o.end;for(let a of r){let l=a.getBoundingClientRect();c=Math.max(c,l.bottom-s.top+i+o.end)}return c}function bu(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function ji(e){let t=window.getComputedStyle(e);return{end:kr(t.paddingBlockEnd||t.paddingBottom),start:kr(t.paddingBlockStart||t.paddingTop)}}function yu(e){let t=e==null?void 0:e.parentElement;return t?ji(t):{end:0,start:0}}function vu(e){if(!e)return 0;let t=window.getComputedStyle(e),n=t.rowGap==="normal"?t.gap:t.rowGap;return kr(n)}function kr(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Mi(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:o=>{t(n,o)||(n=o,r.forEach(s=>s()))},subscribe:(o,s,i)=>{let c=r.size===0;return r.add(o),c&&(s==null||s()),()=>{r.delete(o),r.size===0&&(i==null||i())}}}}function ss(e,t){return Mi(e,t)}function xu(){return Mi(Mn,Su)}function Eu(e,t){return e.start===t.start&&e.end===t.end}function Su(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((n,r)=>n===t.visibleMessageIds[r])}function wu({autoScroll:e,defaultScrollPosition:t,scrollEdgeThreshold:n,scrollMargin:r,scrollPreviousItemPeek:o}){let s=v.useRef(e),i=v.useRef(!1),c=v.useRef(null),a=v.useRef(!1),l=v.useRef(n),f=v.useRef(0),u=v.useRef(null),d=v.useRef(0),m=v.useRef(e?"following-bottom":"free-scrolling"),p=v.useRef(new Map),g=v.useRef(null),b=v.useRef(null),y=v.useRef(null),x=v.useRef(o),S=v.useRef(!0),E=v.useRef(null),C=v.useRef(r),w=v.useRef(null),R=v.useRef(0),O=v.useRef(0),P=v.useRef(null),M=v.useRef(null),F=v.useRef(null),A=v.useRef(null),D=v.useRef(null),_=v.useRef(null),T=v.useRef(null),k=v.useRef(null),U=v.useRef(null),j=v.useRef(new Set),N=v.useRef(new WeakSet);return F.current===null&&(F.current=ss(t==="end"||t==="last-anchor",(Y,K)=>Y===K)),A.current===null&&(A.current=ss(Ai,Eu)),U.current===null&&(U.current=xu()),s.current=e,l.current=n,C.current=r,x.current=o,{autoScrollRef:s,autoscrollingRef:i,autoscrollingTimeoutRef:D,streamingTurnRef:y,contentRef:c,defaultScrollPositionAppliedRef:a,firstItemRef:u,itemCountRef:f,lastScrollTopRef:d,messageElementsRef:p,modeRef:m,pendingScrollFrameRef:w,pendingScrollToMessageRef:g,prependRestoreRef:b,preserveScrollOnPrependRef:S,pendingDefaultScrollStore:F.current,rootRef:E,scrollEdgeThresholdRef:l,scrollMarginRef:C,scrollPreviousItemPeekRef:x,spacerGapRef:R,spacerHeightRef:O,spacerRef:P,stateFrameRef:M,stateStore:A.current,viewportRef:_,visibilityFrameRef:T,visibilityObserverRef:k,visibilityStore:U.current,visibleMessageIdsRef:j,handledScrollAnchorsRef:N}}function Di(e){e.pendingDefaultScrollStore.setSnapshot(!1)}function In(e){e.defaultScrollPositionAppliedRef.current=!0,Di(e)}function Cu({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:o,autoScrollRef:s,autoscrollingRef:i,autoscrollingTimeoutRef:c,contentRef:a,itemCountRef:l,messageElementsRef:f,modeRef:u,pendingScrollToMessageRef:d,prependRestoreRef:m,scrollMarginRef:p,scrollPreviousItemPeekRef:g,spacerGapRef:b,spacerHeightRef:y,spacerRef:x,viewportRef:S}=e,E=v.useCallback(A=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null),i.current!==A&&(i.current=A,t()),A&&(c.current=window.setTimeout(()=>{c.current=null,i.current=!1,t()},su))},[t]),C=v.useCallback(A=>{let D=x.current;if(!D)return;let _=Math.max(0,Math.ceil(A));y.current!==_&&(y.current=_,D.hidden=_===0,D.style.height=`${_}px`,D.style.marginTop=_>0?`${-b.current}px`:"")},[]),w=v.useCallback((A,{behavior:D="auto",autoscrolling:_=!1}={})=>{let T=S.current;if(!T)return;let k=Math.max(0,A);if(Math.abs(T.scrollTop-k)<=jn){T.scrollTop=k,t();return}_&&E(!0),T.scrollTo({top:k,behavior:D}),n()},[t,n,E]),R=v.useCallback(({behavior:A="auto"}={})=>S.current?(C(0),o.current=null,u.current="free-scrolling",w(0,{behavior:A}),r(),!0):!1,[r,w,C]),O=v.useCallback(({behavior:A="auto"}={})=>{let D=S.current;return D?(C(0),o.current=null,u.current=s.current?"following-bottom":"free-scrolling",w(bu(D),{autoscrolling:!0,behavior:A}),r(),!0):!1},[r,w,C]),P=v.useCallback((A,{align:D="start",behavior:_="auto",scrollMargin:T=p.current}={},{keepPreviousPeek:k=!1}={})=>{let U=a.current,j=S.current;if(!U||!j||!U.contains(A))return!1;let N=mu({align:D,element:A,scrollMargin:k?T+g.current:T,spacer:x.current,viewport:j}),Y=gu({content:U,scrollTop:N,spacer:x.current,viewport:j});return C(Y),m.current={element:A,viewportTop:Pn(A,j)},u.current=k?"anchored-to-message":"settling-jump",o.current=k?A:null,w(N,{behavior:_}),r(),!0},[r,w,C]),M=v.useCallback(()=>{let A=o.current;return!A||!A.isConnected||u.current!=="anchored-to-message"?!1:P(A,{align:"start"},{keepPreviousPeek:!0})},[P]),F=v.useCallback((A,D)=>{let _=f.current.get(A);return _?(In(e),P(_,D)?(d.current=null,!0):(d.current={messageId:A,options:D},!0)):l.current===0?(d.current={messageId:A,options:D},In(e),!0):!1},[P]);return{flushPendingScrollToMessage:v.useCallback(()=>{let A=d.current;if(!A)return!1;let D=f.current.get(A.messageId);return!D||!P(D,A.options)?!1:(d.current=null,In(e),!0)},[P]),reanchorToAnchoredMessage:M,scrollToElement:P,scrollToEnd:O,scrollToMessage:F,scrollToStart:R}}function is(e,t){return v.useCallback(n=>{e.current=n,n&&t()},[e,t])}function Ru({autoScroll:e=!1,defaultScrollPosition:t="end",scrollEdgeThreshold:n=nu,scrollPreviousItemPeek:r=ru,scrollMargin:o=ou}){let s=wu({autoScroll:e,defaultScrollPosition:t,scrollEdgeThreshold:n,scrollMargin:o,scrollPreviousItemPeek:r}),{streamingTurnRef:i,autoScrollRef:c,autoscrollingRef:a,autoscrollingTimeoutRef:l,contentRef:f,defaultScrollPositionAppliedRef:u,firstItemRef:d,itemCountRef:m,lastScrollTopRef:p,messageElementsRef:g,modeRef:b,pendingScrollFrameRef:y,pendingScrollToMessageRef:x,prependRestoreRef:S,preserveScrollOnPrependRef:E,pendingDefaultScrollStore:C,rootRef:w,scrollEdgeThresholdRef:R,scrollMarginRef:O,scrollPreviousItemPeekRef:P,spacerGapRef:M,spacerHeightRef:F,spacerRef:A,stateFrameRef:D,stateStore:_,viewportRef:T,visibilityFrameRef:k,visibilityObserverRef:U,visibilityStore:j,visibleMessageIdsRef:N,handledScrollAnchorsRef:Y}=s,K=v.useRef(t);K.current!==t&&(K.current=t,u.current=!1);let le=v.useCallback(V=>{let W=w.current,Z=T.current,se=[V.start&&"start",V.end&&"end"].filter(Boolean).join(" "),ke=a.current;for(let Ce of[W,Z])Ce&&(se?Ce.setAttribute("data-scrollable",se):Ce.removeAttribute("data-scrollable"),Ce.toggleAttribute("data-autoscrolling",ke))},[]),ie=v.useCallback(V=>{var se;let W=((se=T.current)==null?void 0:se.scrollTop)??0,Z=W<p.current-jn;p.current=W,c.current&&!V.end&&b.current!=="settling-jump"&&b.current!=="anchored-to-message"?b.current="following-bottom":b.current==="following-bottom"&&V.end&&Z&&!a.current&&(b.current="free-scrolling")},[]),L=v.useCallback(()=>{let V=au({content:f.current,scrollEdgeThreshold:R.current,spacer:A.current,viewport:T.current});ie(V);let W=b.current==="following-bottom"?{...V,end:!1}:V;le(W),_.setSnapshot(W)},[ie,_,le]),X=v.useCallback(()=>{D.current===null&&(D.current=window.requestAnimationFrame(()=>{D.current=null,L()}))},[L]),B=v.useCallback(()=>{j.hasListeners()&&k.current===null&&(k.current=window.requestAnimationFrame(()=>{k.current=null,j.hasListeners()&&j.setSnapshot(lu({content:f.current,scrollMargin:O.current,scrollPreviousItemPeek:P.current,spacer:A.current,viewport:T.current,visibleMessageIds:N.current}))}))},[j]),{flushPendingScrollToMessage:$,reanchorToAnchoredMessage:Q,scrollToElement:re,scrollToEnd:ee,scrollToMessage:te,scrollToStart:z}=Cu({refs:s,commitScrollState:L,scheduleStateCommit:X,scheduleVisibilitySync:B}),ne=v.useCallback(()=>{let V=S.current,W=T.current;if(!V||!W||!V.element.isConnected)return!1;let Z=Pn(V.element,W)-V.viewportTop;return Math.abs(Z)<=jn?!1:(W.scrollTop+=Z,V.viewportTop=Pn(V.element,W),X(),B(),!0)},[X,B]),oe=v.useCallback(()=>{let V=f.current,W=T.current;if(!V||!W){S.current=null;return}let Z=hu({content:V,spacer:A.current,viewport:W});S.current=Z?{element:Z,viewportTop:Pn(Z,W)}:null},[]),ye=v.useCallback(()=>{y.current===null&&(y.current=window.requestAnimationFrame(()=>{y.current=null,$()&&oe()}))},[oe,$]),q=v.useCallback(()=>{if(!t||u.current||m.current===0)return!1;let V=!1;if(t==="last-anchor"){let W=f.current,Z=T.current,se=W&&Z?pu(Yt(W,A.current)):null;if(!W||!Z||!se)V=ee({behavior:"auto"});else{let ke=Ni(se,Z);V=po({content:W,spacer:A.current,viewport:Z})-ke<=Z.clientHeight?ee({behavior:"auto"}):re(se,{align:"start"},{keepPreviousPeek:!0})}}else V=t==="end"?ee({behavior:"auto"}):z({behavior:"auto"});return V?(In(s),!0):!1},[t,re,ee,z]),J=v.useCallback(()=>{let V=f.current;if(!V)return;let W=Yt(V,A.current),Z=m.current,se=d.current;m.current=W.length,d.current=W[0]??null,(()=>{if($())return;if(Z===0){if(q()||W.length>0&&c.current&&ee({behavior:"auto"}))return;L(),B();return}let ke=se?W.indexOf(se):-1;if(E.current&&ke>0){ne();return}if(W.length>Z){let Ce=uu(W,Z);if(Ce){if(c.current&&b.current==="following-bottom"&&du(W,Z)){ee({behavior:"auto"});return}re(Ce,{align:"start"},{keepPreviousPeek:!0}),Y.current.add(Ce);return}}if(W.length===Z){let Ce=fu(W,Y.current);if(Ce){re(Ce,{align:"start"},{keepPreviousPeek:!0}),Y.current.add(Ce);return}}b.current==="following-bottom"&&c.current?ee({behavior:"auto"}):(L(),B())})(),oe()},[q,oe,L,$,ne,B,re,ee]),ce=v.useCallback(()=>{if(b.current==="following-bottom"&&c.current){ee({behavior:"auto"});return}let V=F.current;if(Q()){c.current&&V>0&&F.current===0&&ee({behavior:"auto"});return}X(),B()},[Q,X,B,ee]),he=v.useCallback(()=>{let V=T.current;if(!(!V||!j.hasListeners())){if(typeof IntersectionObserver>"u"){B();return}U.current||(U.current=new IntersectionObserver(W=>{for(let Z of W){let se=Z.target.dataset.messageId;se&&(Z.isIntersecting?N.current.add(se):N.current.delete(se))}B()},{root:V,rootMargin:`${-(O.current+P.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]})),g.current.forEach(W=>{var Z;(Z=U.current)==null||Z.observe(W)}),B()}},[B,j]),Pe=v.useCallback(()=>{var V;k.current!==null&&(window.cancelAnimationFrame(k.current),k.current=null),(V=U.current)==null||V.disconnect(),U.current=null,N.current.clear(),j.setSnapshot(Mn)},[j]),je=v.useCallback((V,W,Z)=>{var se,ke,Ce;if(W){g.current.set(V,W),(se=U.current)==null||se.observe(W),B(),((ke=x.current)==null?void 0:ke.messageId)===V&&ye();return}Z&&g.current.get(V)===Z&&(g.current.delete(V),N.current.delete(V),(Ce=U.current)==null||Ce.unobserve(Z),B())},[ye,B]),Re=v.useCallback(()=>{(b.current==="following-bottom"||b.current==="anchored-to-message"||b.current==="settling-jump")&&(i.current=null,b.current="free-scrolling")},[]),Me=v.useCallback(()=>le(_.getSnapshot()),[_,le]),Be=is(w,Me),H=is(T,Me),G=v.useCallback(V=>{f.current=V},[]),Se=v.useCallback(V=>{A.current=V,M.current=vu((V==null?void 0:V.parentElement)??null)},[]),be=v.useCallback(()=>{L(),B(),oe()},[oe,L,B]),me=v.useMemo(()=>({handleContentChange:J,handleResize:ce,observeVisibility:he,pendingDefaultScrollStore:C,preserveScrollOnPrependRef:E,scrollToEnd:ee,scrollToMessage:te,scrollToStart:z,setContentElement:G,setRootElement:Be,setSpacerElement:Se,setViewportElement:H,stateStore:_,syncAfterScroll:be,unobserveVisibility:Pe,userScrollIntent:Re,viewportRef:T,visibilityStore:j}),[J,ce,he,C,ee,te,z,G,Be,Se,H,_,be,Pe,Re,j]);return v.useLayoutEffect(()=>{q()||m.current===0&&Di(s)},[q]),v.useEffect(()=>()=>{var V;D.current!==null&&(window.cancelAnimationFrame(D.current),D.current=null),k.current!==null&&(window.cancelAnimationFrame(k.current),k.current=null),l.current!==null&&(window.clearTimeout(l.current),l.current=null),y.current!==null&&(window.cancelAnimationFrame(y.current),y.current=null),(V=U.current)==null||V.disconnect(),U.current=null},[]),v.useLayoutEffect(()=>{if(e&&b.current==="following-bottom"&&m.current>0){ee({behavior:"auto"});return}L()},[e,L,ee]),{context:me,registerMessage:je}}function Tu(e){let t=v.useRef(e);return t.current=e,t}var Fi=v.createContext(null),Li=v.createContext(null);function nn(){let e=v.useContext(Fi);if(!e)throw new Error("useMessageScroller must be used within a MessageScroller.");return e}function Ou(){let e=v.useContext(Li);if(!e)throw new Error("MessageScrollerItem must be used within a MessageScroller.");return e}function Pu({autoScroll:e=!1,children:t,defaultScrollPosition:n="end",scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:s}){let{context:i,registerMessage:c}=Ru({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:s});return h.jsx(Fi.Provider,{value:i,children:h.jsx(Li.Provider,{value:c,children:t})})}function Bi(){let{pendingDefaultScrollStore:e}=nn();return v.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function Iu({children:e,...t}){let{setRootElement:n}=nn(),r=Bi();return h.jsx("div",{ref:n,...t,...r?{"data-pending-scroll":""}:null,children:e})}function _u({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:o,onWheel:s,preserveScrollOnPrepend:i=!0,ref:c,role:a,tabIndex:l,...f}){let{handleResize:u,preserveScrollOnPrependRef:d,setViewportElement:m,syncAfterScroll:p,userScrollIntent:g,viewportRef:b}=nn(),y=Bi();d.current=i;let x=v.useCallback(R=>{var O;m(R),(O=tn(c))==null||O(R)},[c,m]);function S(R){p(),r==null||r(R)}function E(R){g(),s==null||s(R)}function C(R){g(),o==null||o(R)}function w(R){iu.has(R.key)&&g(),n==null||n(R)}return v.useEffect(()=>{let R=b.current;if(!R||typeof ResizeObserver>"u")return;let O=0,P=new ResizeObserver(()=>{window.cancelAnimationFrame(O),O=window.requestAnimationFrame(u)});return P.observe(R),()=>{window.cancelAnimationFrame(O),P.disconnect()}},[u,b]),h.jsx("div",{ref:x,role:a??"region","aria-label":e??"Messages",tabIndex:l??0,onKeyDown:w,onScroll:S,onTouchMove:C,onWheel:E,...f,...y?{"data-pending-scroll":""}:null,children:t})}function ku({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:o,...s}){let{handleContentChange:i,handleResize:c,setContentElement:a,setSpacerElement:l}=nn(),f=v.useRef(null),u=v.useCallback(d=>{var m;f.current=d,a(d),(m=tn(n))==null||m(d)},[n,a]);return v.useLayoutEffect(()=>{let d=f.current;if(!d||(i(),typeof MutationObserver>"u"))return;let m=new MutationObserver(()=>{i()});return m.observe(d,{childList:!0}),()=>m.disconnect()},[i]),v.useEffect(()=>{let d=f.current;if(!d||typeof ResizeObserver>"u")return;let m=0,p=new ResizeObserver(()=>{window.cancelAnimationFrame(m),m=window.requestAnimationFrame(c)});return p.observe(d),()=>{window.cancelAnimationFrame(m),p.disconnect()}},[c]),h.jsxs("div",{ref:u,role:r??"log","aria-relevant":e??"additions",...s,children:[t,h.jsx("div",{ref:l,"aria-hidden":"true","data-message-scroller-spacer":"",hidden:!0,className:o})]})}function Au({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let o=Ou(),s=v.useRef(null),i=v.useCallback(c=>{var l;let a=s.current;s.current=c,e&&o(e,c,a),(l=tn(t))==null||l(c)},[e,t,o]);return h.jsx("div",{ref:i,"data-message-id":e,"data-scroll-anchor":n?"true":"false",...r})}function Nu({behavior:e="smooth",children:t,direction:n="end",onClick:r,render:o,tabIndex:s,type:i="button",...c}){let{scrollToEnd:a,scrollToStart:l,stateStore:f}=nn(),u=Tu(r),d=v.useCallback(b=>f.subscribe(b),[f]),m=v.useCallback(()=>{let b=f.getSnapshot();return n==="start"?b.start:b.end},[n,f]),p=v.useSyncExternalStore(d,m,m),g=v.useCallback(b=>{var y;p&&((y=u.current)==null||y.call(u,b),b.defaultPrevented||(b.currentTarget.blur(),n==="start"?l({behavior:e}):a({behavior:e})))},[e,n,p,u,a,l]);return Zl({defaultTagName:"button",props:_r({type:i,inert:!p,tabIndex:p?s:-1,children:t??h.jsxs("span",{children:["Scroll to ",n]}),onClick:g},c),render:o,state:{active:p,direction:n},stateAttributesMapping:{active:b=>({"data-active":b?"true":"false"})}})}var Ft={Provider:Pu,Root:Iu,Viewport:_u,Content:ku,Item:Au,Button:Nu};function ju(e){return h.jsx(Ft.Provider,{...e})}function Mu({className:e,...t}){return h.jsx(Ft.Root,{"data-slot":"message-scroller",className:ue("msg-scroller-root",e),...t})}function Du({className:e,...t}){return h.jsx(Ft.Viewport,{"data-slot":"message-scroller-viewport",className:ue("msg-scroller-viewport",e),...t})}function Fu({className:e,...t}){return h.jsx(Ft.Content,{"data-slot":"message-scroller-content",className:ue("msg-scroller-content",e),...t})}function cs({className:e,scrollAnchor:t=!1,...n}){return h.jsx(Ft.Item,{"data-slot":"message-scroller-item",scrollAnchor:t,className:ue("msg-scroller-item",e),...n})}function Lu({direction:e="end",className:t,children:n,...r}){return h.jsx(Ft.Button,{"data-slot":"message-scroller-button",direction:e,className:ue("msg-scroller-btn",t),...r,children:n??h.jsxs(h.Fragment,{children:[h.jsx(ua,{size:16,"aria-hidden":"true",className:e==="start"?"rotate-180":void 0}),h.jsx("span",{className:"sr-only",children:e==="end"?"Jump to latest":"Jump to start"})]})})}function Ar({align:e="start",variant:t="muted",className:n,...r}){return h.jsx("div",{...r,"data-slot":"bubble","data-align":e,"data-variant":t,className:ue("chat-bubble",n)})}function Nr({className:e,...t}){return h.jsx("div",{...t,"data-slot":"bubble-content",className:ue("chat-bubble-content",e)})}const Bu=()=>h.jsxs(Jr,{children:[h.jsx(ri,{className:"avatar-circle","aria-hidden":"true",children:h.jsx(Xs,{size:15})}),h.jsx(Zr,{children:h.jsx(Ar,{children:h.jsx(Nr,{children:"Hello — I am the VPS Veritas assistant. Ask about reports, sample status, registration, or support, or choose a suggested question."})})})]});function Vi(){const[e,t]=I.useState("idle");I.useEffect(()=>{if(e!=="copied")return;const r=window.setTimeout(()=>t("idle"),2e3);return()=>window.clearTimeout(r)},[e]);async function n(r){t("copying");try{await navigator.clipboard.writeText(r),t("copied")}catch{t("failed")}}return{status:e,copy:n}}function Vu({message:e,onFeedback:t}){const{status:n,copy:r}=Vi();return h.jsxs("div",{className:"chat-message-actions",role:"group","aria-label":"Response actions",children:[h.jsx("button",{type:"button",className:"chat-message-action","aria-label":"Copy response",title:"Copy response",disabled:n==="copying",onClick:()=>void r(e.content),children:n==="copied"?h.jsx(Xr,{size:16,"aria-hidden":"true"}):h.jsx(Qs,{size:16,"aria-hidden":"true"})}),h.jsx("button",{type:"button",className:"chat-message-action","aria-label":"Like response",title:"Like response","aria-pressed":e.feedback==="like",onClick:()=>t(e.id,"like"),children:h.jsx(Ta,{size:16,"aria-hidden":"true"})}),h.jsx("button",{type:"button",className:"chat-message-action","aria-label":"Dislike response",title:"Dislike response","aria-pressed":e.feedback==="dislike",onClick:()=>t(e.id,"dislike"),children:h.jsx(Ra,{size:16,"aria-hidden":"true"})}),h.jsxs("span",{className:"chat-message-copy-status",role:"status",children:[n==="copied"&&"Copied",n==="failed"&&"Couldn’t copy"]})]})}function ho(e){const t=e.trim();if(!/[\u0000-\u001f\u007f]/.test(t)&&/^(https?:\/\/|mailto:|\/(?!\/)|#)/i.test(t))return t}function $u(e){return Object.prototype.toString.call(e)==="[object Object]"}function as(e){return $u(e)||Array.isArray(e)}function Hu(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}function mo(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;const o=JSON.stringify(Object.keys(e.breakpoints||{})),s=JSON.stringify(Object.keys(t.breakpoints||{}));return o!==s?!1:n.every(i=>{const c=e[i],a=t[i];return typeof c=="function"?`${c}`==`${a}`:!as(c)||!as(a)?c===a:mo(c,a)})}function ls(e){return e.concat().sort((t,n)=>t.name>n.name?1:-1).map(t=>t.options)}function Uu(e,t){if(e.length!==t.length)return!1;const n=ls(e),r=ls(t);return n.every((o,s)=>{const i=r[s];return mo(o,i)})}function go(e){return typeof e=="number"}function jr(e){return typeof e=="string"}function Qn(e){return typeof e=="boolean"}function us(e){return Object.prototype.toString.call(e)==="[object Object]"}function we(e){return Math.abs(e)}function bo(e){return Math.sign(e)}function Wt(e,t){return we(e-t)}function zu(e,t){if(e===0||t===0||we(e)<=we(t))return 0;const n=Wt(we(e),we(t));return we(n/e)}function Wu(e){return Math.round(e*100)/100}function Xt(e){return Jt(e).map(Number)}function Ge(e){return e[rn(e)]}function rn(e){return Math.max(0,e.length-1)}function yo(e,t){return t===rn(e)}function fs(e,t=0){return Array.from(Array(e),(n,r)=>t+r)}function Jt(e){return Object.keys(e)}function $i(e,t){return[e,t].reduce((n,r)=>(Jt(r).forEach(o=>{const s=n[o],i=r[o],c=us(s)&&us(i);n[o]=c?$i(s,i):i}),n),{})}function Mr(e,t){return typeof t.MouseEvent<"u"&&e instanceof t.MouseEvent}function qu(e,t){const n={start:r,center:o,end:s};function r(){return 0}function o(a){return s(a)/2}function s(a){return t-a}function i(a,l){return jr(e)?n[e](a):e(t,a,l)}return{measure:i}}function Zt(){let e=[];function t(o,s,i,c={passive:!0}){let a;if("addEventListener"in o)o.addEventListener(s,i,c),a=()=>o.removeEventListener(s,i,c);else{const l=o;l.addListener(i),a=()=>l.removeListener(i)}return e.push(a),r}function n(){e=e.filter(o=>o())}const r={add:t,clear:n};return r}function Gu(e,t,n,r){const o=Zt(),s=1e3/60;let i=null,c=0,a=0;function l(){o.add(e,"visibilitychange",()=>{e.hidden&&p()})}function f(){m(),o.clear()}function u(b){if(!a)return;i||(i=b,n(),n());const y=b-i;for(i=b,c+=y;c>=s;)n(),c-=s;const x=c/s;r(x),a&&(a=t.requestAnimationFrame(u))}function d(){a||(a=t.requestAnimationFrame(u))}function m(){t.cancelAnimationFrame(a),i=null,c=0,a=0}function p(){i=null,c=0}return{init:l,destroy:f,start:d,stop:m,update:n,render:r}}function Ku(e,t){const n=t==="rtl",r=e==="y",o=r?"y":"x",s=r?"x":"y",i=!r&&n?-1:1,c=f(),a=u();function l(p){const{height:g,width:b}=p;return r?g:b}function f(){return r?"top":n?"right":"left"}function u(){return r?"bottom":n?"left":"right"}function d(p){return p*i}return{scroll:o,cross:s,startEdge:c,endEdge:a,measureSize:l,direction:d}}function Et(e=0,t=0){const n=we(e-t);function r(l){return l<e}function o(l){return l>t}function s(l){return r(l)||o(l)}function i(l){return s(l)?r(l)?e:t:l}function c(l){return n?l-n*Math.ceil((l-t)/n):l}return{length:n,max:t,min:e,constrain:i,reachedAny:s,reachedMax:o,reachedMin:r,removeOffset:c}}function Hi(e,t,n){const{constrain:r}=Et(0,e),o=e+1;let s=i(t);function i(d){return n?we((o+d)%o):r(d)}function c(){return s}function a(d){return s=i(d),u}function l(d){return f().set(c()+d)}function f(){return Hi(e,c(),n)}const u={get:c,set:a,add:l,clone:f};return u}function Yu(e,t,n,r,o,s,i,c,a,l,f,u,d,m,p,g,b,y,x){const{cross:S,direction:E}=e,C=["INPUT","SELECT","TEXTAREA"],w={passive:!1},R=Zt(),O=Zt(),P=Et(50,225).constrain(m.measure(20)),M={mouse:300,touch:400},F={mouse:500,touch:600},A=p?43:25;let D=!1,_=0,T=0,k=!1,U=!1,j=!1,N=!1;function Y(z){if(!x)return;function ne(ye){(Qn(x)||x(z,ye))&&B(ye)}const oe=t;R.add(oe,"dragstart",ye=>ye.preventDefault(),w).add(oe,"touchmove",()=>{},w).add(oe,"touchend",()=>{}).add(oe,"touchstart",ne).add(oe,"mousedown",ne).add(oe,"touchcancel",Q).add(oe,"contextmenu",Q).add(oe,"click",re,!0)}function K(){R.clear(),O.clear()}function le(){const z=N?n:t;O.add(z,"touchmove",$,w).add(z,"touchend",Q).add(z,"mousemove",$,w).add(z,"mouseup",Q)}function ie(z){const ne=z.nodeName||"";return C.includes(ne)}function L(){return(p?F:M)[N?"mouse":"touch"]}function X(z,ne){const oe=u.add(bo(z)*-1),ye=f.byDistance(z,!p).distance;return p||we(z)<P?ye:b&&ne?ye*.5:f.byIndex(oe.get(),0).distance}function B(z){const ne=Mr(z,r);N=ne,j=p&&ne&&!z.buttons&&D,D=Wt(o.get(),i.get())>=2,!(ne&&z.button!==0)&&(ie(z.target)||(k=!0,s.pointerDown(z),l.useFriction(0).useDuration(0),o.set(i),le(),_=s.readPoint(z),T=s.readPoint(z,S),d.emit("pointerDown")))}function $(z){if(!Mr(z,r)&&z.touches.length>=2)return Q(z);const oe=s.readPoint(z),ye=s.readPoint(z,S),q=Wt(oe,_),J=Wt(ye,T);if(!U&&!N&&(!z.cancelable||(U=q>J,!U)))return Q(z);const ce=s.pointerMove(z);q>g&&(j=!0),l.useFriction(.3).useDuration(.75),c.start(),o.add(E(ce)),z.preventDefault()}function Q(z){const oe=f.byDistance(0,!1).index!==u.get(),ye=s.pointerUp(z)*L(),q=X(E(ye),oe),J=zu(ye,q),ce=A-10*J,he=y+J/50;U=!1,k=!1,O.clear(),l.useDuration(ce).useFriction(he),a.distance(q,!p),N=!1,d.emit("pointerUp")}function re(z){j&&(z.stopPropagation(),z.preventDefault(),j=!1)}function ee(){return k}return{init:Y,destroy:K,pointerDown:ee}}function Xu(e,t){let r,o;function s(u){return u.timeStamp}function i(u,d){const p=`client${(d||e.scroll)==="x"?"X":"Y"}`;return(Mr(u,t)?u:u.touches[0])[p]}function c(u){return r=u,o=u,i(u)}function a(u){const d=i(u)-i(o),m=s(u)-s(r)>170;return o=u,m&&(r=u),d}function l(u){if(!r||!o)return 0;const d=i(o)-i(r),m=s(u)-s(r),p=s(u)-s(o)>170,g=d/m;return m&&!p&&we(g)>.1?g:0}return{pointerDown:c,pointerMove:a,pointerUp:l,readPoint:i}}function Ju(){function e(n){const{offsetTop:r,offsetLeft:o,offsetWidth:s,offsetHeight:i}=n;return{top:r,right:o+s,bottom:r+i,left:o,width:s,height:i}}return{measure:e}}function Zu(e){function t(r){return e*(r/100)}return{measure:t}}function Qu(e,t,n,r,o,s,i){const c=[e].concat(r);let a,l,f=[],u=!1;function d(b){return o.measureSize(i.measure(b))}function m(b){if(!s)return;l=d(e),f=r.map(d);function y(x){for(const S of x){if(u)return;const E=S.target===e,C=r.indexOf(S.target),w=E?l:f[C],R=d(E?e:r[C]);if(we(R-w)>=.5){b.reInit(),t.emit("resize");break}}}a=new ResizeObserver(x=>{(Qn(s)||s(b,x))&&y(x)}),n.requestAnimationFrame(()=>{c.forEach(x=>a.observe(x))})}function p(){u=!0,a&&a.disconnect()}return{init:m,destroy:p}}function ef(e,t,n,r,o,s){let i=0,c=0,a=o,l=s,f=e.get(),u=0;function d(){const w=r.get()-e.get(),R=!a;let O=0;return R?(i=0,n.set(r),e.set(r),O=w):(n.set(e),i+=w/a,i*=l,f+=i,e.add(i),O=f-u),c=bo(O),u=f,C}function m(){const w=r.get()-t.get();return we(w)<.001}function p(){return a}function g(){return c}function b(){return i}function y(){return S(o)}function x(){return E(s)}function S(w){return a=w,C}function E(w){return l=w,C}const C={direction:g,duration:p,velocity:b,seek:d,settled:m,useBaseFriction:x,useBaseDuration:y,useFriction:E,useDuration:S};return C}function tf(e,t,n,r,o){const s=o.measure(10),i=o.measure(50),c=Et(.1,.99);let a=!1;function l(){return!(a||!e.reachedAny(n.get())||!e.reachedAny(t.get()))}function f(m){if(!l())return;const p=e.reachedMin(t.get())?"min":"max",g=we(e[p]-t.get()),b=n.get()-t.get(),y=c.constrain(g/i);n.subtract(b*y),!m&&we(b)<s&&(n.set(e.constrain(n.get())),r.useDuration(25).useBaseFriction())}function u(m){a=!m}return{shouldConstrain:l,constrain:f,toggleActive:u}}function nf(e,t,n,r,o){const s=Et(-t+e,0),i=u(),c=f(),a=d();function l(p,g){return Wt(p,g)<=1}function f(){const p=i[0],g=Ge(i),b=i.lastIndexOf(p),y=i.indexOf(g)+1;return Et(b,y)}function u(){return n.map((p,g)=>{const{min:b,max:y}=s,x=s.constrain(p),S=!g,E=yo(n,g);return S?y:E||l(b,x)?b:l(y,x)?y:x}).map(p=>parseFloat(p.toFixed(3)))}function d(){if(t<=e+o)return[s.max];if(r==="keepSnaps")return i;const{min:p,max:g}=c;return i.slice(p,g)}return{snapsContained:a,scrollContainLimit:c}}function rf(e,t,n){const r=t[0],o=n?r-e:Ge(t);return{limit:Et(o,r)}}function of(e,t,n,r){const s=t.min+.1,i=t.max+.1,{reachedMin:c,reachedMax:a}=Et(s,i);function l(d){return d===1?a(n.get()):d===-1?c(n.get()):!1}function f(d){if(!l(d))return;const m=e*(d*-1);r.forEach(p=>p.add(m))}return{loop:f}}function sf(e){const{max:t,length:n}=e;function r(s){const i=s-t;return n?i/-n:0}return{get:r}}function cf(e,t,n,r,o){const{startEdge:s,endEdge:i}=e,{groupSlides:c}=o,a=u().map(t.measure),l=d(),f=m();function u(){return c(r).map(g=>Ge(g)[i]-g[0][s]).map(we)}function d(){return r.map(g=>n[s]-g[s]).map(g=>-we(g))}function m(){return c(l).map(g=>g[0]).map((g,b)=>g+a[b])}return{snaps:l,snapsAligned:f}}function af(e,t,n,r,o,s){const{groupSlides:i}=o,{min:c,max:a}=r,l=f();function f(){const d=i(s),m=!e||t==="keepSnaps";return n.length===1?[s]:m?d:d.slice(c,a).map((p,g,b)=>{const y=!g,x=yo(b,g);if(y){const S=Ge(b[0])+1;return fs(S)}if(x){const S=rn(s)-Ge(b)[0]+1;return fs(S,Ge(b)[0])}return p})}return{slideRegistry:l}}function lf(e,t,n,r,o){const{reachedAny:s,removeOffset:i,constrain:c}=r;function a(p){return p.concat().sort((g,b)=>we(g)-we(b))[0]}function l(p){const g=e?i(p):c(p),b=t.map((x,S)=>({diff:f(x-g,0),index:S})).sort((x,S)=>we(x.diff)-we(S.diff)),{index:y}=b[0];return{index:y,distance:g}}function f(p,g){const b=[p,p+n,p-n];if(!e)return p;if(!g)return a(b);const y=b.filter(x=>bo(x)===g);return y.length?a(y):Ge(b)-n}function u(p,g){const b=t[p]-o.get(),y=f(b,g);return{index:p,distance:y}}function d(p,g){const b=o.get()+p,{index:y,distance:x}=l(b),S=!e&&s(b);if(!g||S)return{index:y,distance:p};const E=t[y]-x,C=p+f(E,0);return{index:y,distance:C}}return{byDistance:d,byIndex:u,shortcut:f}}function uf(e,t,n,r,o,s,i){function c(u){const d=u.distance,m=u.index!==t.get();s.add(d),d&&(r.duration()?e.start():(e.update(),e.render(1),e.update())),m&&(n.set(t.get()),t.set(u.index),i.emit("select"))}function a(u,d){const m=o.byDistance(u,d);c(m)}function l(u,d){const m=t.clone().set(u),p=o.byIndex(m.get(),d);c(p)}return{distance:a,index:l}}function ff(e,t,n,r,o,s,i,c){const a={passive:!0,capture:!0};let l=0;function f(m){if(!c)return;function p(g){if(new Date().getTime()-l>10)return;i.emit("slideFocusStart"),e.scrollLeft=0;const x=n.findIndex(S=>S.includes(g));go(x)&&(o.useDuration(0),r.index(x,0),i.emit("slideFocus"))}s.add(document,"keydown",u,!1),t.forEach((g,b)=>{s.add(g,"focus",y=>{(Qn(c)||c(m,y))&&p(b)},a)})}function u(m){m.code==="Tab"&&(l=new Date().getTime())}return{init:f}}function Ut(e){let t=e;function n(){return t}function r(a){t=i(a)}function o(a){t+=i(a)}function s(a){t-=i(a)}function i(a){return go(a)?a:a.get()}return{get:n,set:r,add:o,subtract:s}}function Ui(e,t){const n=e.scroll==="x"?i:c,r=t.style;let o=null,s=!1;function i(d){return`translate3d(${d}px,0px,0px)`}function c(d){return`translate3d(0px,${d}px,0px)`}function a(d){if(s)return;const m=Wu(e.direction(d));m!==o&&(r.transform=n(m),o=m)}function l(d){s=!d}function f(){s||(r.transform="",t.getAttribute("style")||t.removeAttribute("style"))}return{clear:f,to:a,toggleActive:l}}function df(e,t,n,r,o,s,i,c,a){const f=Xt(o),u=Xt(o).reverse(),d=y().concat(x());function m(R,O){return R.reduce((P,M)=>P-o[M],O)}function p(R,O){return R.reduce((P,M)=>m(P,O)>0?P.concat([M]):P,[])}function g(R){return s.map((O,P)=>({start:O-r[P]+.5+R,end:O+t-.5+R}))}function b(R,O,P){const M=g(O);return R.map(F=>{const A=P?0:-n,D=P?n:0,_=P?"end":"start",T=M[F][_];return{index:F,loopPoint:T,slideLocation:Ut(-1),translate:Ui(e,a[F]),target:()=>c.get()>T?A:D}})}function y(){const R=i[0],O=p(u,R);return b(O,n,!1)}function x(){const R=t-i[0]-1,O=p(f,R);return b(O,-n,!0)}function S(){return d.every(({index:R})=>{const O=f.filter(P=>P!==R);return m(O,t)<=.1})}function E(){d.forEach(R=>{const{target:O,translate:P,slideLocation:M}=R,F=O();F!==M.get()&&(P.to(F),M.set(F))})}function C(){d.forEach(R=>R.translate.clear())}return{canLoop:S,clear:C,loop:E,loopPoints:d}}function pf(e,t,n){let r,o=!1;function s(a){if(!n)return;function l(f){for(const u of f)if(u.type==="childList"){a.reInit(),t.emit("slidesChanged");break}}r=new MutationObserver(f=>{o||(Qn(n)||n(a,f))&&l(f)}),r.observe(e,{childList:!0})}function i(){r&&r.disconnect(),o=!0}return{init:s,destroy:i}}function hf(e,t,n,r){const o={};let s=null,i=null,c,a=!1;function l(){c=new IntersectionObserver(p=>{a||(p.forEach(g=>{const b=t.indexOf(g.target);o[b]=g}),s=null,i=null,n.emit("slidesInView"))},{root:e.parentElement,threshold:r}),t.forEach(p=>c.observe(p))}function f(){c&&c.disconnect(),a=!0}function u(p){return Jt(o).reduce((g,b)=>{const y=parseInt(b),{isIntersecting:x}=o[y];return(p&&x||!p&&!x)&&g.push(y),g},[])}function d(p=!0){if(p&&s)return s;if(!p&&i)return i;const g=u(p);return p&&(s=g),p||(i=g),g}return{init:l,destroy:f,get:d}}function mf(e,t,n,r,o,s){const{measureSize:i,startEdge:c,endEdge:a}=e,l=n[0]&&o,f=p(),u=g(),d=n.map(i),m=b();function p(){if(!l)return 0;const x=n[0];return we(t[c]-x[c])}function g(){if(!l)return 0;const x=s.getComputedStyle(Ge(r));return parseFloat(x.getPropertyValue(`margin-${a}`))}function b(){return n.map((x,S,E)=>{const C=!S,w=yo(E,S);return C?d[S]+f:w?d[S]+u:E[S+1][c]-x[c]}).map(we)}return{slideSizes:d,slideSizesWithGaps:m,startGap:f,endGap:u}}function gf(e,t,n,r,o,s,i,c,a){const{startEdge:l,endEdge:f,direction:u}=e,d=go(n);function m(y,x){return Xt(y).filter(S=>S%x===0).map(S=>y.slice(S,S+x))}function p(y){return y.length?Xt(y).reduce((x,S,E)=>{const C=Ge(x)||0,w=C===0,R=S===rn(y),O=o[l]-s[C][l],P=o[l]-s[S][f],M=!r&&w?u(i):0,F=!r&&R?u(c):0,A=we(P-F-(O+M));return E&&A>t+a&&x.push(S),R&&x.push(y.length),x},[]).map((x,S,E)=>{const C=Math.max(E[S-1]||0);return y.slice(C,x)}):[]}function g(y){return d?m(y,n):p(y)}return{groupSlides:g}}function bf(e,t,n,r,o,s,i){const{align:c,axis:a,direction:l,startIndex:f,loop:u,duration:d,dragFree:m,dragThreshold:p,inViewThreshold:g,slidesToScroll:b,skipSnaps:y,containScroll:x,watchResize:S,watchSlides:E,watchDrag:C,watchFocus:w}=s,R=2,O=Ju(),P=O.measure(t),M=n.map(O.measure),F=Ku(a,l),A=F.measureSize(P),D=Zu(A),_=qu(c,A),T=!u&&!!x,k=u||!!x,{slideSizes:U,slideSizesWithGaps:j,startGap:N,endGap:Y}=mf(F,P,M,n,k,o),K=gf(F,A,b,u,P,M,N,Y,R),{snaps:le,snapsAligned:ie}=cf(F,_,P,M,K),L=-Ge(le)+Ge(j),{snapsContained:X,scrollContainLimit:B}=nf(A,L,ie,x,R),$=T?X:ie,{limit:Q}=rf(L,$,u),re=Hi(rn($),f,u),ee=re.clone(),te=Xt(n),z=({dragHandler:V,scrollBody:W,scrollBounds:Z,options:{loop:se}})=>{se||Z.constrain(V.pointerDown()),W.seek()},ne=({scrollBody:V,translate:W,location:Z,offsetLocation:se,previousLocation:ke,scrollLooper:Ce,slideLooper:Ct,dragHandler:st,animation:Rt,eventHandler:Ze,scrollBounds:Qe,options:{loop:ht}},mt)=>{const Lt=V.settled(),an=!Qe.shouldConstrain(),Bt=ht?Lt:Lt&&an,Vt=Bt&&!st.pointerDown();Vt&&Rt.stop();const ln=Z.get()*mt+ke.get()*(1-mt);se.set(ln),ht&&(Ce.loop(V.direction()),Ct.loop()),W.to(se.get()),Vt&&Ze.emit("settle"),Bt||Ze.emit("scroll")},oe=Gu(r,o,()=>z(me),V=>ne(me,V)),ye=.68,q=$[re.get()],J=Ut(q),ce=Ut(q),he=Ut(q),Pe=Ut(q),je=ef(J,he,ce,Pe,d,ye),Re=lf(u,$,L,Q,Pe),Me=uf(oe,re,ee,je,Re,Pe,i),Be=sf(Q),H=Zt(),G=hf(t,n,i,g),{slideRegistry:Se}=af(T,x,$,B,K,te),be=ff(e,n,Se,Me,je,H,i,w),me={ownerDocument:r,ownerWindow:o,eventHandler:i,containerRect:P,slideRects:M,animation:oe,axis:F,dragHandler:Yu(F,e,r,o,Pe,Xu(F,o),J,oe,Me,je,Re,re,i,D,m,p,y,ye,C),eventStore:H,percentOfView:D,index:re,indexPrevious:ee,limit:Q,location:J,offsetLocation:he,previousLocation:ce,options:s,resizeHandler:Qu(t,i,o,n,F,S,O),scrollBody:je,scrollBounds:tf(Q,he,Pe,je,D),scrollLooper:of(L,Q,he,[J,he,ce,Pe]),scrollProgress:Be,scrollSnapList:$.map(Be.get),scrollSnaps:$,scrollTarget:Re,scrollTo:Me,slideLooper:df(F,A,L,U,j,le,$,he,n),slideFocus:be,slidesHandler:pf(t,i,E),slidesInView:G,slideIndexes:te,slideRegistry:Se,slidesToScroll:K,target:Pe,translate:Ui(F,t)};return me}function yf(){let e={},t;function n(l){t=l}function r(l){return e[l]||[]}function o(l){return r(l).forEach(f=>f(t,l)),a}function s(l,f){return e[l]=r(l).concat([f]),a}function i(l,f){return e[l]=r(l).filter(u=>u!==f),a}function c(){e={}}const a={init:n,emit:o,off:i,on:s,clear:c};return a}const vf={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function xf(e){function t(s,i){return $i(s,i||{})}function n(s){const i=s.breakpoints||{},c=Jt(i).filter(a=>e.matchMedia(a).matches).map(a=>i[a]).reduce((a,l)=>t(a,l),{});return t(s,c)}function r(s){return s.map(i=>Jt(i.breakpoints||{})).reduce((i,c)=>i.concat(c),[]).map(e.matchMedia)}return{mergeOptions:t,optionsAtMedia:n,optionsMediaQueries:r}}function Ef(e){let t=[];function n(s,i){return t=i.filter(({options:c})=>e.optionsAtMedia(c).active!==!1),t.forEach(c=>c.init(s,e)),i.reduce((c,a)=>Object.assign(c,{[a.name]:a}),{})}function r(){t=t.filter(s=>s.destroy())}return{init:n,destroy:r}}function Dn(e,t,n){const r=e.ownerDocument,o=r.defaultView,s=xf(o),i=Ef(s),c=Zt(),a=yf(),{mergeOptions:l,optionsAtMedia:f,optionsMediaQueries:u}=s,{on:d,off:m,emit:p}=a,g=F;let b=!1,y,x=l(vf,Dn.globalOptions),S=l(x),E=[],C,w,R;function O(){const{container:te,slides:z}=S;w=(jr(te)?e.querySelector(te):te)||e.children[0];const oe=jr(z)?w.querySelectorAll(z):z;R=[].slice.call(oe||w.children)}function P(te){const z=bf(e,w,R,r,o,te,a);if(te.loop&&!z.slideLooper.canLoop()){const ne=Object.assign({},te,{loop:!1});return P(ne)}return z}function M(te,z){b||(x=l(x,te),S=f(x),E=z||E,O(),y=P(S),u([x,...E.map(({options:ne})=>ne)]).forEach(ne=>c.add(ne,"change",F)),S.active&&(y.translate.to(y.location.get()),y.animation.init(),y.slidesInView.init(),y.slideFocus.init(ee),y.eventHandler.init(ee),y.resizeHandler.init(ee),y.slidesHandler.init(ee),y.options.loop&&y.slideLooper.loop(),w.offsetParent&&R.length&&y.dragHandler.init(ee),C=i.init(ee,E)))}function F(te,z){const ne=K();A(),M(l({startIndex:ne},te),z),a.emit("reInit")}function A(){y.dragHandler.destroy(),y.eventStore.clear(),y.translate.clear(),y.slideLooper.clear(),y.resizeHandler.destroy(),y.slidesHandler.destroy(),y.slidesInView.destroy(),y.animation.destroy(),i.destroy(),c.clear()}function D(){b||(b=!0,c.clear(),A(),a.emit("destroy"),a.clear())}function _(te,z,ne){!S.active||b||(y.scrollBody.useBaseFriction().useDuration(z===!0?0:S.duration),y.scrollTo.index(te,ne||0))}function T(te){const z=y.index.add(1).get();_(z,te,-1)}function k(te){const z=y.index.add(-1).get();_(z,te,1)}function U(){return y.index.add(1).get()!==K()}function j(){return y.index.add(-1).get()!==K()}function N(){return y.scrollSnapList}function Y(){return y.scrollProgress.get(y.offsetLocation.get())}function K(){return y.index.get()}function le(){return y.indexPrevious.get()}function ie(){return y.slidesInView.get()}function L(){return y.slidesInView.get(!1)}function X(){return C}function B(){return y}function $(){return e}function Q(){return w}function re(){return R}const ee={canScrollNext:U,canScrollPrev:j,containerNode:Q,internalEngine:B,destroy:D,off:m,on:d,emit:p,plugins:X,previousScrollSnap:le,reInit:g,rootNode:$,scrollNext:T,scrollPrev:k,scrollProgress:Y,scrollSnapList:N,scrollTo:_,selectedScrollSnap:K,slideNodes:re,slidesInView:ie,slidesNotInView:L};return M(t,n),setTimeout(()=>a.emit("init"),0),ee}Dn.globalOptions=void 0;function vo(e={},t=[]){const n=I.useRef(e),r=I.useRef(t),[o,s]=I.useState(),[i,c]=I.useState(),a=I.useCallback(()=>{o&&o.reInit(n.current,r.current)},[o]);return I.useEffect(()=>{mo(n.current,e)||(n.current=e,a())},[e,a]),I.useEffect(()=>{Uu(r.current,t)||(r.current=t,a())},[t,a]),I.useEffect(()=>{if(Hu()&&i){Dn.globalOptions=vo.globalOptions;const l=Dn(i,n.current,r.current);return s(l),()=>l.destroy()}else s(void 0)},[i,s]),[c,o]}vo.globalOptions=void 0;const Dr=[];let Fr;function Sf(){return Fr}function wf(e){Dr.push(e)}function zi(e){const t=(n,r)=>{const o=Ye(Rf).current;let s;try{Fr=o;for(const i of Dr)i.before(o);s=e(n,r);for(const i of Dr)i.after(o);o.didInitialize=!0}finally{Fr=void 0}return s};return t.displayName=e.displayName||e.name,t}function Cf(e){return v.forwardRef(zi(e))}function Rf(){return{didInitialize:!1}}function Tf(){if(typeof navigator>"u")return{userAgent:"",platform:"",maxTouchPoints:0};if(process.env.NODE_ENV!=="production"){const e=navigator.userAgentData;if(e&&Array.isArray(e.brands))return{userAgent:e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "),platform:e.platform??navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}return{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:Of,platform:Pf,maxTouchPoints:If}=Tf(),er=Of.toLowerCase(),Qt=Pf.toLowerCase(),Wi=/^i(os$|p)/.test(Qt)||Qt==="macintel"&&If>1,ds="android",_f=Qt===ds||er.includes(ds),qi=!Wi&&Qt.startsWith("mac");Qt.startsWith("win");const kf=qi||Wi;var Hs;const on=typeof CSS<"u"&&!!((Hs=CSS.supports)!=null&&Hs.call(CSS,"-webkit-backdrop-filter:none"));!on&&er.includes("firefox");!on&&er.includes("chrom");const Af=kf,Nf=/jsdom|happydom/.test(er);function jf(e){return"nativeEvent"in e}function Mf(e){return e.pointerType===""&&e.isTrusted?!0:_f&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Lr(e,t){const n=["mouse","pen"];return n.push("",void 0),n.includes(e)}function Df(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}function Br(e){var n;let t=e.activeElement;for(;((n=t==null?void 0:t.shadowRoot)==null?void 0:n.activeElement)!=null;)t=t.shadowRoot.activeElement;return t}function Te(e,t){var r;if(!e||!t)return!1;const n=(r=t.getRootNode)==null?void 0:r.call(t);if(e.contains(t))return!0;if(n&&At(n)){let o=t;for(;o;){if(e===o)return!0;o=o.parentNode||o.host}}return!1}function Vr(e,t){let n=e;for(;n;){if(ge(n)&&n.matches(t))return n;n=n.assignedSlot??n.parentNode??(At(n)?n.host:null)}return null}function yt(e){return"composedPath"in e?e.composedPath()[0]??e.target:e.target}const Ff="data-base-ui-focusable",Gi="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Lf="data-open",Bf="data-closed",Vf="data-anchor-hidden",$f="data-popup-open",Hf={[$f]:""},Uf={[Lf]:""},zf={[Bf]:""},Wf={[Vf]:""},qf={open(e){return e?Hf:null}},Ki={open(e){return e?Uf:zf},anchorHidden(e){return e?Wf:null}},Gf={...Ki,...io},ps="data-trigger-disabled";function Fn(e,t){if(!ge(e))return!1;const n=e;if(t.hasElement(n))return!n.hasAttribute(ps);for(const[,r]of t.entries())if(Te(r,n))return!r.hasAttribute(ps);return!1}function pr(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 Kf(e){return e.matches("html,body")}function Yf(e){return _e(e)&&e.matches(Gi)}function Xf(e){return Vr(e,`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${Gi}`)!=null}function Jf(e){if(!e||Nf)return!0;try{return e.matches(":focus-visible")}catch{return!0}}function Zf(e,t){return t!=null&&!Lr(t)?0:typeof e=="function"?e():e}function $r(e,t,n){const r=Zf(e,n);return typeof r=="number"?r:r==null?void 0:r[t]}function hs(e){return typeof e=="function"?e():e}function Yi(e,t){return t||e==="click"||e==="mousedown"}function Qf(e){return(e==null?void 0:e.includes("mouse"))&&e!=="mousedown"}function at(...e){return()=>{for(let t=0;t<e.length;t+=1){const n=e[t];n&&n()}}}const ed={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},td={...ed,position:"fixed",margin:0,top:0,left:0},Hr=v.forwardRef(function(t,n){const[r,o]=v.useState();pe(()=>{Af&&on&&o("button")},[]);const s={tabIndex:0,role:r};return h.jsx("span",{...t,ref:n,style:td,"aria-hidden":r?void 0:!0,...s,"data-base-ui-focus-guard":""})});process.env.NODE_ENV!=="production"&&(Hr.displayName="FocusGuard");const Mt=Math.min,nt=Math.max,Ln=Math.round,vn=Math.floor,rt=e=>({x:e,y:e}),nd={left:"right",right:"left",bottom:"top",top:"bottom"};function Xi(e,t,n){return nt(e,Mt(t,n))}function ft(e,t){return typeof e=="function"?e(t):e}function Ve(e){return e.split("-")[0]}function Je(e){return e.split("-")[1]}function xo(e){return e==="x"?"y":"x"}function Eo(e){return e==="y"?"height":"width"}function Ue(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function So(e){return xo(Ue(e))}function rd(e,t,n){n===void 0&&(n=!1);const r=Je(e),o=So(e),s=Eo(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Bn(i)),[i,Bn(i)]}function od(e){const t=Bn(e);return[Ur(e),t,Ur(t)]}function Ur(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const ms=["left","right"],gs=["right","left"],sd=["top","bottom"],id=["bottom","top"];function cd(e,t,n){switch(e){case"top":case"bottom":return n?t?gs:ms:t?ms:gs;case"left":case"right":return t?sd:id;default:return[]}}function ad(e,t,n,r){const o=Je(e);let s=cd(Ve(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ur)))),s}function Bn(e){const t=Ve(e);return nd[t]+e.slice(t.length)}function ld(e){var t,n,r,o;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(o=e.left)!=null?o:0}}function Ji(e){return typeof e!="number"?ld(e):{top:e,right:e,bottom:e,left:e}}function Vn(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function ud(e){return e.visibility==="hidden"||e.visibility==="collapse"}function fd(e,t=e?$e(e):null){return!e||!e.isConnected||!t||ud(t)?!1:typeof e.checkVisibility=="function"?e.checkVisibility():t.display!=="none"&&t.display!=="contents"}const dd='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function pd(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.getRootNode();return At(n)?n.host:null}function zr(e){for(const t of Array.from(e.children))if(Le(t)==="summary")return t;return null}function hd(e,t){const n=zr(t);return!!n&&(e===n||Te(n,e))}function Zi(e){const t=e?Le(e):"";return e!=null&&e.matches(dd)&&(t!=="summary"||e.parentElement!=null&&Le(e.parentElement)==="details"&&zr(e.parentElement)===e)&&(t!=="details"||zr(e)==null)&&(t!=="input"||e.type!=="hidden")}function md(e){if(!Zi(e)||!e.isConnected||e.matches(":disabled"))return!1;for(let t=e;t;t=pd(t)){const n=t!==e,r=Le(t)==="slot";if(t.hasAttribute("inert")||n&&Le(t)==="details"&&!t.open&&!hd(e,t)||t.hasAttribute("hidden")||!r&&!gd(t,n))return!1}return!0}function gd(e,t){const n=$e(e);return t?n.display!=="none":fd(e,n)}function bd(e){const t=e.tabIndex;if(t<0){const n=Le(e);if(n==="details"||n==="audio"||n==="video"||_e(e)&&e.isContentEditable)return 0}return t}function hr(e){if(Le(e)!=="input")return null;const t=e;return t.type==="radio"&&t.name!==""?t:null}function yd(e,t){const n=hr(e);if(!n)return!0;const r=t.find(o=>{const s=hr(o);return(s==null?void 0:s.name)===n.name&&s.form===n.form&&s.checked});return r?r===n:t.find(o=>{const s=hr(o);return(s==null?void 0:s.name)===n.name&&s.form===n.form})===n}function Qi(e){if(_e(e)&&Le(e)==="slot"){const t=e.assignedElements({flatten:!0});if(t.length>0)return t}return _e(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function ec(e,t){Qi(e).forEach(n=>{Zi(n)&&t.push(n),ec(n,t)})}function tc(e,t,n){Qi(e).forEach(r=>{_e(r)&&r.matches(t)&&n.push(r),tc(r,t,n)})}function vd(e){const t=[];return ec(e,t),t.filter(md)}function nc(e){const t=vd(e);return t.filter(n=>bd(n)>=0&&yd(n,t))}function rc(e,t){const n=nc(e),r=n.length;if(r===0)return;const o=Br(Ke(e)),s=n.indexOf(o),i=s===-1?t===1?0:r-1:s+t;return n[i]}function xd(e){return rc(Ke(e).body,1)||e}function Ed(e){return rc(Ke(e).body,-1)||e}function mr(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!Te(n,r)}function Sd(e){nc(e).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function bs(e){const t=[];tc(e,"[data-tabindex]",t),t.forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}function Dt(e,t,n=!0){return e.filter(o=>o.parentId===t).flatMap(o=>{var s;return[...!n||(s=o.context)!=null&&s.open?[o]:[],...Dt(e,o.id,n)]})}function wo(e){return`data-base-ui-${e}`}const wd={style:{transition:"none"}},Cd={fallbackAxisSide:"end"},Rd={clipPath:"inset(50%)",position:"fixed",top:0,left:0},Co=v.createContext(null);process.env.NODE_ENV!=="production"&&(Co.displayName="PortalContext");const Td=()=>v.useContext(Co),Od=wo("portal");function oc(e={}){const{ref:t,container:n,componentProps:r=Fe,elementProps:o}=e,s=Gn(),i=Td(),c=i==null?void 0:i.portalNode,[a,l]=v.useState(null),[f,u]=v.useState(null),d=fe(b=>{b!==null&&u(b)}),m=v.useRef(null);pe(()=>{if(n===null){m.current&&(m.current=null,u(null),l(null));return}const b=(n&&(co(n)?n:n.current))??c??document.body;if(b==null){m.current&&(m.current=null,u(null),l(null));return}m.current!==b&&(m.current=b,u(null),l(b))},[n,c]);const p=pt("div",r,{ref:[t,d],props:[{id:s,[Od]:""},o]}),g=a&&p?dt.createPortal(p,a):null;return{node:f,nodeId:v.isValidElement(p)?p.props.id:void 0,subtree:g}}const Pd=v.forwardRef(function(t,n){const{render:r,className:o,style:s,children:i,container:c,portalOwnerRole:a,...l}=t,{node:f,nodeId:u,subtree:d}=oc({container:c,ref:n,componentProps:t,elementProps:l}),m=v.useRef(null),p=v.useRef(null),g=v.useRef(null),b=v.useRef(null),[y,x]=v.useState(null),S=v.useRef(!1),E=y==null?void 0:y.modal,C=y==null?void 0:y.open,w=!!y&&!y.modal&&y.open&&!!f;v.useEffect(()=>{if(!f||E)return;function O(P){f&&P.relatedTarget&&mr(P)&&(P.type==="focusin"?S.current&&(bs(f),S.current=!1):(Sd(f),S.current=!0))}return at(Ee(f,"focusin",O,!0),Ee(f,"focusout",O,!0))},[f,E]),pe(()=>{!f||C!==!0||!S.current||(bs(f),S.current=!1)},[C,f]);const R=v.useMemo(()=>({beforeOutsideRef:m,afterOutsideRef:p,beforeInsideRef:g,afterInsideRef:b,portalNode:f,setFocusManagerState:x}),[f]);return h.jsxs(v.Fragment,{children:[d,h.jsxs(Co.Provider,{value:R,children:[w&&f&&h.jsx(Hr,{"data-type":"outside",ref:m,onFocus:O=>{var P;if(mr(O,f))(P=g.current)==null||P.focus();else{const M=y?y.domReference:null,F=Ed(M);F==null||F.focus()}}}),w&&f&&h.jsx("span",{role:a,"aria-owns":u,style:Rd}),f&&dt.createPortal(i,f),w&&f&&h.jsx(Hr,{"data-type":"outside",ref:p,onFocus:O=>{var P;if(mr(O,f))(P=b.current)==null||P.focus();else{const M=y?y.domReference:null,F=xd(M);F==null||F.focus(),y!=null&&y.closeOnFocusOut&&(y==null||y.onOpenChange(!1,Oe(ol,O.nativeEvent)))}}})]})]})});process.env.NODE_ENV!=="production"&&(Pd.displayName="FloatingPortal");function sc(){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)}}}class Id{constructor(){ae(this,"nodesRef",{current:[]});ae(this,"events",sc())}addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(r=>r===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const Ro=v.createContext(null);process.env.NODE_ENV!=="production"&&(Ro.displayName="FloatingNodeContext");const To=v.createContext(null);process.env.NODE_ENV!=="production"&&(To.displayName="FloatingTreeContext");const tr=()=>{var e;return((e=v.useContext(Ro))==null?void 0:e.id)||null},sn=e=>{const t=v.useContext(To);return e??t};function _d(e){const t=Gn(),n=sn(e),r=tr();return pe(()=>{if(!t)return;const o={id:t,parentId:r};return n==null||n.addNode(o),()=>{n==null||n.removeNode(o)}},[n,t,r]),t}function kd(e){const{children:t,id:n}=e,r=tr();return h.jsx(Ro.Provider,{value:v.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Ad(e){const{children:t,externalTree:n}=e,r=Ye(()=>n??new Id).current;return h.jsx(To.Provider,{value:r,children:t})}function Nd(){return!1}function jd(e){return{escapeKey:typeof e=="boolean"?e:(e==null?void 0:e.escapeKey)??!1,outsidePress:typeof e=="boolean"?e:(e==null?void 0:e.outsidePress)??!0}}function Md(e,t={}){const{enabled:n=!0,escapeKey:r=!0,outsidePress:o=!0,outsidePressEvent:s="sloppy",referencePress:i=Nd,bubbles:c,externalTree:a}=t,l=e.useState("open"),f=e.useState("floatingElement"),{dataRef:u,events:d}=e.context,m=sn(a),p=fe(typeof o=="function"?o:()=>!1),g=typeof o=="function"?p:o,b=g!==!1,y=fe(()=>s),{escapeKey:x,outsidePress:S}=jd(c),E=v.useRef(!1),C=v.useRef(!1),w=v.useRef(!1),R=v.useRef(!1),O=v.useRef(!1),P=v.useRef(""),M=v.useRef(null),F=zt(),A=zt(),D=zt(),_=fe(()=>{A.clear(),u.current.insideReactTree=!1}),T=fe(L=>{var $;const X=($=u.current.floatingContext)==null?void 0:$.nodeId;return(m?Dt(m.nodesRef.current,X):[]).some(Q=>{var re;return((re=Q.context)==null?void 0:re.open)&&!Q.context.dataRef.current[L]})}),k=fe(L=>pr(L,e.select("floatingElement"))||pr(L,e.select("domReferenceElement"))),U=fe(L=>{i()&&e.setOpen(!1,Oe(Kn,L.nativeEvent))}),j=fe(L=>{if(!l||!n||!r||L.key!=="Escape")return;const X=jf(L)?L.nativeEvent:L;if(O.current||X.isComposing||!x&&T("__escapeKeyBubbles"))return;const B=Oe(no,X);e.setOpen(!1,B),B.isCanceled||L.preventDefault(),!x&&!B.isPropagationAllowed&&L.stopPropagation()}),N=fe(()=>{u.current.insideReactTree=!0,A.start(0,_)}),Y=fe(L=>{if(!l||!n||L.button!==0)return;const X=yt(L.nativeEvent);Te(e.select("floatingElement"),X)&&(E.current||(E.current=!0,C.current=!1))}),K=fe(L=>{!l||!n||(L.defaultPrevented||L.nativeEvent.defaultPrevented)&&E.current&&(C.current=!0)});v.useEffect(()=>{function L(X){X.open||(R.current=!1)}return d.on("openchange",L),()=>{d.off("openchange",L)}},[d]),v.useEffect(()=>_,[_]),v.useEffect(()=>{if(!l||!n)return l||(R.current=!1,O.current=!1,P.current="",M.current=null),_;u.current.__escapeKeyBubbles=x,u.current.__outsidePressBubbles=S;const L=new ut,X=Ke(f);function B(){D.clear(),O.current=!0}function $(){O.current=!0,D.start(on?5:0,()=>{O.current=!1})}function Q(){w.current=!0,L.start(0,()=>{w.current=!1})}function re(){E.current=!1,C.current=!1}function ee(){const H=P.current,G=H==="pen"||!H?"mouse":H,Se=y(),be=typeof Se=="function"?Se():Se;return typeof be=="string"?be:be[G]}function te(H){const G=ee();return G==="intentional"&&H.type!=="click"||G==="sloppy"&&H.type==="click"}function z(H){var be;const G=(be=u.current.floatingContext)==null?void 0:be.nodeId,Se=m&&Dt(m.nodesRef.current,G).some(me=>{var V;return pr(H,(V=me.context)==null?void 0:V.elements.floating)});return k(H)||Se}function ne(H){if(te(H)){H.type!=="click"&&!k(H)&&(L.clear(),w.current=!1),_();return}if(u.current.insideReactTree){_();return}const G=yt(H),Se=`[${wo("inert")}]`,be=ge(G)?G.getRootNode():null,me=Array.from((At(be)?be:Ke(e.select("floatingElement"))).querySelectorAll(Se)),V=e.context.triggerElements;if(G&&(V.hasElement(G)||V.hasMatchingElement(Z=>Te(Z,G))))return;let W=ge(G)?G:null;for(;W&&!ct(W);){const Z=lt(W);if(ct(Z)||!ge(Z))break;W=Z}if(!(me.length&&ge(G)&&!Kf(G)&&!Te(G,e.select("floatingElement"))&&me.every(Z=>!Te(W,Z)))){if(_e(G)&&!("touches"in H)){const Z=ct(G),se=$e(G),ke=/auto|scroll/,Ce=Z||ke.test(se.overflowX),Ct=Z||ke.test(se.overflowY),st=Ce&&G.clientWidth>0&&G.scrollWidth>G.clientWidth,Rt=Ct&&G.clientHeight>0&&G.scrollHeight>G.clientHeight,Ze=se.direction==="rtl",Qe=Rt&&(Ze?H.offsetX<=G.offsetWidth-G.clientWidth:H.offsetX>G.clientWidth),ht=st&&H.offsetY>G.clientHeight;if(Qe||ht)return}if(!z(H)){if(ee()==="intentional"){if(H.detail!==0&&!Mf(H)&&!R.current)return;if(w.current){L.clear(),w.current=!1;return}}typeof g=="function"&&!g(H)||T("__outsidePressBubbles")||(e.setOpen(!1,Oe(rl,H)),_())}}}function oe(H){ee()!=="sloppy"||H.pointerType==="touch"||!e.select("open")||!n||k(H)||ne(H)}function ye(H){if(ee()!=="sloppy"||!e.select("open")||!n||k(H))return;const G=H.touches[0];G&&(M.current={startTime:Date.now(),startX:G.clientX,startY:G.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},F.start(1e3,()=>{M.current&&(M.current.dismissOnTouchEnd=!1,M.current.dismissOnMouseDown=!1)}))}function q(H,G){const Se=yt(H);if(!Se)return;const be=Ee(Se,H.type,()=>{G(H),be()})}function J(H){P.current="touch",q(H,ye)}function ce(H){F.clear(),H.type==="pointerdown"&&(H.button===0&&(R.current=!0),P.current=H.pointerType),!(H.type==="mousedown"&&M.current&&!M.current.dismissOnMouseDown)&&q(H,G=>{G.type==="pointerdown"?oe(G):ne(G)})}function he(H){if(H.type==="pointercancel"&&(R.current=!1),!E.current)return;const G=C.current;if(re(),ee()==="intentional"){if(H.type==="pointercancel"){G&&Q();return}if(!z(H)){if(G){Q();return}typeof g=="function"&&!g(H)||(L.clear(),w.current=!0,_())}}}function Pe(H){if(ee()!=="sloppy"||!M.current||k(H))return;const G=H.touches[0];if(!G)return;const Se=Math.abs(G.clientX-M.current.startX),be=Math.abs(G.clientY-M.current.startY),me=Math.sqrt(Se*Se+be*be);me>5&&(M.current.dismissOnTouchEnd=!0),me>10&&(ne(H),F.clear(),M.current=null)}function je(H){q(H,Pe)}function Re(H){ee()!=="sloppy"||!M.current||k(H)||(M.current.dismissOnTouchEnd&&ne(H),F.clear(),M.current=null)}function Me(H){q(H,Re)}const Be=at(r&&at(Ee(X,"keydown",j),Ee(X,"compositionstart",B),Ee(X,"compositionend",$)),b&&at(Ee(X,"click",ce,!0),Ee(X,"pointerdown",ce,!0),Ee(X,"pointerup",he,!0),Ee(X,"pointercancel",he,!0),Ee(X,"mousedown",ce,!0),Ee(X,"mouseup",he,!0),Ee(X,"touchstart",J,{capture:!0,passive:!0}),Ee(X,"touchmove",je,{capture:!0,passive:!0}),Ee(X,"touchend",Me,{capture:!0,passive:!0})));return()=>{Be(),L.clear(),re(),w.current=!1}},[u,f,r,b,g,l,n,x,S,j,_,y,T,k,m,e,F,D]);const le=v.useMemo(()=>({onKeyDown:j,onPointerDown:U,onClick:U}),[j,U]),ie=v.useMemo(()=>({onKeyDown:j,onPointerDown:K,onMouseDown:K,onClickCapture:N,onMouseDownCapture(L){N(),Y(L)},onPointerDownCapture(L){N(),Y(L)},onMouseUpCapture:N,onTouchEndCapture:N,onTouchMoveCapture:N}),[j,N,Y,K]);return v.useMemo(()=>n?{reference:le,floating:ie,trigger:le}:{},[n,le,ie])}function $n(e,t,n,r){return{left:e,top:t,right:n,bottom:r,x:e,y:t,width:n-e,height:r-t}}function Dd(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom,width:e.width,height:e.height}}function ic(e){const t=[];let n,r=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const c of Array.from(e).sort((a,l)=>a.top-l.top)){if(r=Math.min(r,c.left),o=Math.min(o,c.top),s=Math.max(s,c.right),i=Math.max(i,c.bottom),!n||c.top-n.top>n.height/2)t.push(Dd(c));else{const a=t[t.length-1];a.left=Math.min(a.left,c.left),a.right=Math.max(a.right,c.right),a.bottom=Math.max(a.bottom,c.bottom),a.width=a.right-a.left,a.height=a.bottom-a.top}n=c}return{lines:t,fallback:$n(r,o,s,i)}}function cc(e,t,n){return e.findIndex(r=>t>r.left-2&&t<r.right+2&&n>r.top-2&&n<r.bottom+2)}function ys(e){return $n(e.left,e.top,e.right,e.bottom)}function Fd(e,t,n){const{lines:r}=ic(e.getClientRects());if(r.length<2)return;const o=cc(r,t,n);return{x:t,y:n,lineIndex:o===-1?void 0:o,element:e}}function Ld(e,t,n){const{lines:r,fallback:o}=ic(e.getClientRects());if(r.length<2)return null;const s=n==null?void 0:n.x,i=n==null?void 0:n.y,c=t[0];if((n==null?void 0:n.lineIndex)!=null&&r[n.lineIndex])return ys(r[n.lineIndex]);if(s!=null&&i!=null){const p=cc(r,s,i);if(p!==-1)return ys(r[p])}if(r.length===2&&r[0].left>r[1].right&&s!=null&&i!=null)return o;if(c==="t"||c==="b"){const p=r[0],g=r[r.length-1],b=c==="t"?p:g;return $n(b.left,p.top,b.right,g.bottom)}const a=c==="l";let l=r[0].left,f=r[0].right,u=a?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY,d=r[0],m=r[0];for(const p of r){l=Math.min(l,p.left),f=Math.max(f,p.right);const g=a?p.left:p.right;a&&g<u||!a&&g>u?(u=g,d=p,m=p):g===u&&(m=p)}return $n(l,d.top,f,m.bottom)}function Bd(e){return"contextElement"in e&&e.contextElement?e.contextElement:ge(e)?e:void 0}function Vd(e,t){function n(o){ac(e,o.currentTarget,o.clientX,o.clientY)}function r(o){t||n(o)}return{onFocus(){e.current=void 0},onMouseEnter:r,onMouseMove:r}}function ac(e,t,n,r){const o=Fd(t,n,r);return e.current=o,o}function $d(e){return{name:"inline",async fn(t){const n=t.elements.reference;if(typeof(n==null?void 0:n.getClientRects)!="function")return{};const r=Bd(n),o=e.current,s=(o==null?void 0:o.element)===n||(o==null?void 0:o.element)===r?o:void 0,i=Ld(n,t.placement,s);if(!i||typeof t.platform.getElementRects!="function")return{};const c=await t.platform.getElementRects({reference:{contextElement:r,getBoundingClientRect(){return i}},floating:t.elements.floating,strategy:t.strategy});return t.rects.reference.x===c.reference.x&&t.rects.reference.y===c.reference.y&&t.rects.reference.width===c.reference.width&&t.rects.reference.height===c.reference.height?{}:{reset:{rects:c}}}}}class Hd{constructor(t,n,r=!0){ae(this,"attachedStores",[]);ae(this,"attachedStoreValue",null);ae(this,"storeListeners",new Set);this.fallbackStore=t,this.componentName=n,this.throwOnMissingTrigger=r}get attachedStore(){return this.attachedStoreValue}get store(){return this.attachedStoreValue??this.fallbackStore}get serverStore(){return this.fallbackStore}subscribeStore(t){return this.storeListeners.add(t),()=>{this.storeListeners.delete(t)}}attachStore(t){if(this.attachedStores.push(t),this.setActiveStore(t),process.env.NODE_ENV!=="production"&&this.attachedStores.length>1){const n=this;(n.overlapWarningFrame??(n.overlapWarningFrame=Ne.create())).request(()=>{this.attachedStores.length>1&&console.warn("Base UI: A handle is attached to more than one mounted root at the same time. The most recently mounted root takes over and the previous one stops being controlled by the handle. A handle should be used by a single root that stays mounted for the lifetime of the handle.")})}return()=>{const n=this.attachedStores.lastIndexOf(t);n!==-1&&this.attachedStores.splice(n,1),this.setActiveStore(this.attachedStores[this.attachedStores.length-1]??null)}}setActiveStore(t){this.attachedStoreValue!==t&&(this.attachedStoreValue=t,this.storeListeners.forEach(n=>{n()}))}openByTrigger(t){const n=this.attachedStore;if(n===null){process.env.NODE_ENV!=="production"&&console.warn(`Base UI: ${this.componentName}Handle.open() was called while no root using this handle is mounted. The call was ignored; mount a root with this handle before opening it imperatively.`);return}let r;if(t){for(let o=this.attachedStores.length-1;o>=0&&!r;o-=1)r=this.attachedStores[o].context.triggerElements.getById(t);r??(r=this.fallbackStore.context.triggerElements.getById(t))}if(t&&!r){if(this.throwOnMissingTrigger)throw new Error(process.env.NODE_ENV!=="production"?`Base UI: ${this.componentName}Handle.open() was called with the trigger id "${t}", but no matching trigger is registered with this handle. An anchored popup cannot open without a trigger to anchor to. Pass the id of a mounted ${this.componentName}.Trigger that has this handle set on its "handle" prop.`:wt(99,this.componentName,t,this.componentName));process.env.NODE_ENV!=="production"&&console.warn(`Base UI: ${this.componentName}Handle.open: No trigger found with id "${t}". The popup will open, but the trigger will not be associated with it.`)}n.setOpen(!0,Oe(Pr,void 0,r))}closePopup(){const t=this.attachedStore;if(t===null){process.env.NODE_ENV!=="production"&&console.warn(`Base UI: ${this.componentName}Handle.close() was called while no root using this handle is mounted. The call was ignored.`);return}t.setOpen(!1,Oe(Pr))}}function Ud(e){const{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:o,nested:s,onOpenChange:i}=e,c=t.useState("open"),a=t.useState("activeTriggerElement"),l=t.useState(n?"popupElement":"positionerElement"),f=i;return t.useSyncedValue("floatingId",o),pe(()=>{const u={open:c,floatingId:o,referenceElement:a,floatingElement:l};ge(a)&&(u.domReferenceElement=a),r.state.positionReference===r.state.referenceElement&&(u.positionReference=a),r.update(u)},[c,o,a,l,r]),r.context.onOpenChange=f,r.context.nested=s,r}function zd(e){const{open:t,ref:n,preventUnmountOnClose:r,setPreventUnmountOnClose:o,onUnmount:s,animateInitialOpen:i}=e,c=fe(o),{mounted:a,setMounted:l,transitionStatus:f}=yi(t,!1,!1,i),u=t?!1:r;pe(()=>{t&&c(!1)},[t,c]);const d=v.useRef(a),m=v.useRef(!1),p=mi(),g=()=>{d.current=!1,l(!1),s()};pe(()=>{d.current=a,m.current&&(m.current=!1,!t&&a&&g())});const b=fe(()=>{if(d.current){if(t){m.current=!0,p();return}g()}});return uo({enabled:a&&!t&&!u,open:t,ref:n,onComplete(){t||b()}}),{mounted:a,transitionStatus:f,preventUnmountingOnClose:u,forceUnmount:b}}const Wd={tabIndex:-1,[Ff]:""};function qd(e,t=!1){const n=Gn(),r=tr()!=null,o=Ye(()=>e(n,r)).current;return Ud({popupStore:o,treatPopupAsFloatingElement:t,floatingRootContext:o.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:o.setOpen}),o}function Gd({handle:e,store:t}){return pe(()=>e.attachStore(t),[e,t]),null}function vs(e){const t=e.context.triggerElements.size;e.select("open")&&e.state.triggerCount!==t&&e.set("triggerCount",t)}function Kd(e,t){const n=v.useRef(null);return fe(r=>{const o=n.current;if(o!==null){if(o.element===r&&o.store===t&&o.id===e)return;n.current=null;const s=o.store;s.context.triggerElements.getById(o.id)===o.element&&(s.context.triggerElements.delete(o.id),vs(s))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),vs(t))})}function Yd(e,t,n,r=!1){let o=e.preventUnmountingOnClose;t?o=!1:r&&(o=!0);const s=(n==null?void 0:n.id)??null;let i=e.activeTriggerId,c=e.activeTriggerElement;return(s||t)&&(i=s,c=n??null),{open:t,preventUnmountingOnClose:o,activeTriggerId:i,activeTriggerElement:c,openedWithoutTrigger:t?n==null:e.openedWithoutTrigger}}function Xd(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function Jd(e,t,n,r={}){var f,u,d;const o=n.reason,s=o===We,i=t&&o===On,c=!t&&(o===Kn||o===no),a=Xd(n);if((u=(f=e.context).onOpenChange)==null||u.call(f,t,n),n.isCanceled)return;(d=r.onBeforeDispatch)==null||d.call(r),e.state.floatingRootContext.dispatchOpenChange(t,n);const l=()=>{const m=Yd(e.state,t,n.trigger,a()),p={...r.extraState,...m};i?p.instantType="focus":c?p.instantType="dismiss":s&&(p.instantType=void 0),e.update(p)};s?dt.flushSync(l):l()}function Zd(e,t,n,r){const o=n.useState("isMountedByTrigger",e),s=Kd(e,n),i=fe(a=>{const l=n.select("open"),f=n.select("activeTriggerId");if(f===e){const u={activeTriggerElement:a,...l?r:null};n.update(u);return}if(f==null&&l&&!n.state.openedWithoutTrigger){const u={activeTriggerId:e??null,activeTriggerElement:a,...r};n.update(u)}}),c=fe(a=>{s(a),a&&i(a)});return pe(()=>(c(t.current),()=>c(null)),[c,t,n,e]),pe(()=>{if(o){const a={activeTriggerElement:t.current,...r};n.update(a)}},[o,n,t,...Object.values(r)]),{registerTrigger:c,isMountedByThisTrigger:o}}function Qd(e,t={}){const{closeOnActiveTriggerUnmount:n=!1}=t,r=v.useRef(null),o=e.useState("open"),s=e.useState("triggerCount"),i=e.useState("activeTriggerId"),c=e.useState("activeTriggerElement");pe(()=>{if(!o){r.current=null,e.state.triggerCount!==0&&e.set("triggerCount",0),e.state.openedWithoutTrigger&&e.set("openedWithoutTrigger",!1);return}const a=e.context.triggerElements.size,l={};e.state.triggerCount!==a&&(l.triggerCount=a);const f=e.select("activeTriggerId");let u=null;if(f){const d=e.context.triggerElements.getById(f);if(d)r.current=f,d!==e.state.activeTriggerElement&&(l.activeTriggerElement=d);else{for(const[m,p]of e.context.triggerElements.entries())if(p===e.state.activeTriggerElement){l.activeTriggerId=m,l.activeTriggerElement=p,r.current=m;break}l.activeTriggerId===void 0&&(r.current===f?u=f:r.current=null)}}else r.current=null;if(!u&&!f&&!e.state.openedWithoutTrigger&&a===1){const d=e.context.triggerElements.entries().next();if(!d.done){const[m,p]=d.value;l.activeTriggerId=m,l.activeTriggerElement=p,r.current=m}}(l.triggerCount!==void 0||l.activeTriggerId!==void 0||l.activeTriggerElement!==void 0)&&e.update(l),u&&n&&queueMicrotask(()=>{if(e.select("open")&&e.select("activeTriggerId")===u&&!e.context.triggerElements.getById(u)){const d=Oe(bi);e.setOpen(!1,d),d.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[o,e,s,i,c,n])}function ep(e,t,n,r){const{mounted:o,transitionStatus:s,forceUnmount:i}=zd({open:e,ref:t.context.popupRef,preventUnmountOnClose:t.useState("preventUnmountingOnClose"),setPreventUnmountOnClose:c=>t.set("preventUnmountingOnClose",c),animateInitialOpen:r,onUnmount(){var c,a;t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n==null||n(),(a=(c=t.context).onOpenChangeComplete)==null||a.call(c,!1)}});return Ye(()=>(t.set("mounted",o),null)),t.useSyncedValues({mounted:o,transitionStatus:s}),{forceUnmount:i,transitionStatus:s}}function tp(e,t){e.useSyncedValues(t),pe(()=>()=>{e.update({activeTriggerProps:Fe,inactiveTriggerProps:Fe,popupProps:Fe})},[e])}let _t;function np(e){_t??(_t=new WeakMap);let t=_t.get(e);return t||(t=new WeakMap,_t.set(e,t)),t}class lc{constructor(){ae(this,"idMap",new Map)}add(t,n){if(process.env.NODE_ENV!=="production"){const r=np(this),o=r.get(n);if(o!==void 0&&o!==t)throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");const s=this.idMap.get(t);s!==void 0&&s!==n&&r.delete(s),r.set(n,t)}this.idMap.set(t,n)}delete(t){var n;if(process.env.NODE_ENV!=="production"){const r=this.idMap.get(t);r!==void 0&&((n=_t==null?void 0:_t.get(this))==null||n.delete(r))}this.idMap.delete(t)}hasElement(t){for(const n of this.idMap.values())if(n===t)return!0;return!1}hasMatchingElement(t){for(const n of this.idMap.values())if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}}var xn={exports:{}},gr={};/**
176
+ */const ka=ye("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Jr({align:e="start",className:t,...n}){return p.jsx("div",{...n,"data-slot":"message","data-align":e,className:ue("chat-message",t)})}function oi({className:e,...t}){return p.jsx("div",{...t,"data-slot":"message-avatar",className:ue("chat-message-avatar",e)})}function Zr({className:e,...t}){return p.jsx("div",{...t,"data-slot":"message-content",className:ue("chat-message-content",e)})}function Aa({className:e,...t}){return p.jsx("div",{...t,"data-slot":"message-header",className:ue("chat-message-header",e)})}function Cr({className:e,...t}){return p.jsx("div",{...t,"data-slot":"message-footer",className:ue("chat-message-footer",e)})}const tt={...y},Ko={};function Ye(e,t){const n=y.useRef(Ko);return n.current===Ko&&(n.current=e(t)),n}const ur=tt.useInsertionEffect,Na=ur&&ur!==tt.useLayoutEffect?ur:e=>e();function fe(e){const t=Ye(ja).current;return t.next=e,Na(t.effect),t.trampoline}function ja(){const e={next:void 0,callback:Ma,trampoline:(...t)=>{var n;return(n=e.callback)==null?void 0:n.call(e,...t)},effect:()=>{e.callback=e.next}};return e}function Ma(){if(process.env.NODE_ENV!=="production")throw new Error("Base UI: Cannot call an event handler while rendering.")}function Rr(e,t,n,r){const o=Ye(si).current;return Fa(o,e,t,n,r)&&ii(o,[e,t,n,r]),o.callback}function Da(e){const t=Ye(si).current;return La(t,e)&&ii(t,e),t.callback}function si(){return{callback:null,cleanup:null,refs:[]}}function Fa(e,t,n,r,o){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==o}function La(e,t){return e.refs.length!==t.length||e.refs.some((n,r)=>n!==t[r])}function ii(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const r=Array(t.length).fill(null);for(let o=0;o<t.length;o+=1){const s=t[o];if(s!=null)switch(typeof s){case"function":{const i=s(n);typeof i=="function"&&(r[o]=i);break}case"object":{s.current=n;break}}}e.cleanup=()=>{for(let o=0;o<t.length;o+=1){const s=t[o];if(s!=null)switch(typeof s){case"function":{const i=r[o];typeof i=="function"?i():s(null);break}case"object":{s.current=null;break}}}}}}}const Ba=parseInt(y.version,10);function ci(e){return Ba>=e}function Yo(e){if(!y.isValidElement(e))return null;const t=e,n=t.props;return(ci(19)?n==null?void 0:n.ref:t.ref)??null}function Tr(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}let Pr;process.env.NODE_ENV!=="production"&&(Pr=new Set);function ai(e,t){return function(...r){if(process.env.NODE_ENV!=="production"){const o=r.join(" "),s=`${t}: ${o}`,i=`${e}:${s}`;Pr.has(i)||(Pr.add(i),e==="warn"?console.warn(s):console.error(s))}}}const Qr=ai("warn","Base UI");function eo(){}const Va=Object.freeze([]),Fe=Object.freeze({});function $a(e,t){const n={};for(const r in e){const o=e[r];if(t!=null&&t.hasOwnProperty(r)){const s=t[r](o);s!=null&&Object.assign(n,s);continue}o===!0?n[`data-${r.toLowerCase()}`]="":o&&(n[`data-${r.toLowerCase()}`]=o.toString())}return n}function Ha(e,t){return typeof e=="function"?e(t):e}function li(e,t){return typeof e=="function"?e(t):e}const ui={};function to(e,t,n,r,o){if(!n&&!r&&!e)return kn(t);let s=kn(e);return t&&(s=Tn(s,t)),n&&(s=Tn(s,n)),r&&(s=Tn(s,r)),s}function Ua(e){if(e.length===0)return ui;if(e.length===1)return kn(e[0]);let t=kn(e[0]);for(let n=1;n<e.length;n+=1)t=Tn(t,e[n]);return t}function kn(e){return di(e)?{...e(ui)}:za(e)}function Tn(e,t){return di(t)?t(e):Wa(e,t)}function za(e){const t={...e};for(const n in t){const r=t[n];fi(n,r)&&(t[n]=pi(r))}return t}function Wa(e,t){if(!t)return e;for(const n in t){const r=t[n];switch(n){case"style":{e[n]=Tr(e.style,r);break}case"className":{e[n]=hi(e.className,r);break}default:fi(n,r)?e[n]=qa(e[n],r):e[n]=r}}return e}function fi(e,t){const n=e.charCodeAt(0),r=e.charCodeAt(1),o=e.charCodeAt(2);return n===111&&r===110&&o>=65&&o<=90&&(typeof t=="function"||typeof t>"u")}function di(e){return typeof e=="function"}function qa(e,t){return t?e?(...n)=>{const r=n[0];if(gi(r)){const s=r;An(s);const i=t(...n);return s.baseUIHandlerPrevented||e==null||e(...n),i}const o=t(...n);return e==null||e(...n),o}:pi(t):e}function pi(e){return e&&((...t)=>{const n=t[0];return gi(n)&&An(n),e(...t)})}function An(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function hi(e,t){return t?e?t+" "+e:t:e}function gi(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function pt(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=Za(r));const o=Ga(t,n,r);if(n.enabled===!1)return null;const s=n.state??Fe;return Qa(e,r,o,s)}function Ga(e,t,n){const{className:r,style:o}=e,{state:s=Fe,ref:i,props:c,stateAttributesMapping:a,enabled:l=!0}=t,f=l?Ha(r,s):void 0,u=l?li(o,s):void 0,h=l?$a(s,a):Fe,g=l&&c?Ka(c):void 0,d=l?Tr(h,g)??{}:Fe;return typeof document<"u"&&(l?Array.isArray(i)?d.ref=Da([d.ref,Yo(n),...i]):d.ref=Rr(d.ref,Yo(n),i):Rr(null,null)),l?(f!==void 0&&(d.className=hi(d.className,f)),u!==void 0&&(d.style=Tr(d.style,u)),d):Fe}function Ka(e){return Array.isArray(e)?Ua(e):to(void 0,e)}const Ya=Symbol.for("react.lazy"),Xa=/^[A-Z][A-Za-z0-9$]*$/,Ja=/[a-z]/;function Za(e){if((e==null?void 0:e.$$typeof)!==Ya)return e;const t=y.Children.toArray(e)[0];return y.isValidElement(t)?t:e}function Qa(e,t,n,r){if(t){if(typeof t=="function")return process.env.NODE_ENV!=="production"&&el(t),t(n,r);const o=to(n,t.props);if(o.ref=n.ref,process.env.NODE_ENV!=="production"&&!y.isValidElement(t))throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.","A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.","https://base-ui.com/r/invalid-render-prop"].join(`
177
+ `));return y.cloneElement(t,o)}return tl(e,n)}function el(e){const t=e.name;t.length!==0&&Xa.test(t)&&Ja.test(t)&&Qr(`The \`render\` prop received a function named \`${t}\` that starts with an uppercase letter.`,"This usually means a React component was passed directly as `render={Component}`.","Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.","If this is an intentional render callback, rename it to start with a lowercase letter.","Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.","https://base-ui.com/r/invalid-render-prop")}function tl(e,t){return e==="button"?I.createElement("button",{type:"button",...t,key:t.key}):e==="img"?I.createElement("img",{alt:"",...t,key:t.key}):y.createElement(e,t)}const Nn=ai("error","Base UI");function nl({controlled:e,default:t,name:n,state:r="value"}){const{current:o}=y.useRef(e!==void 0),[s,i]=y.useState(()=>t),c=o&&e!==void 0?e:s;if(process.env.NODE_ENV!=="production"){y.useEffect(()=>{o!==(e!==void 0)&&Nn([`A component is changing the ${o?"":"un"}controlled ${r} state of ${n} to be ${o?"un":""}controlled.`,"Elements should not switch from uncontrolled to controlled (or vice versa).",`Decide between using a controlled or uncontrolled ${n} element for the lifetime of the component.`,"The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.","More info: https://fb.me/react-controlled-components"].join(`
178
+ `))},[r,n,e]);const{current:l}=y.useRef(t);y.useEffect(()=>{!o&&Xo(l)!==Xo(t)&&Nn([`A component is changing the default ${r} state of an uncontrolled ${n} after being initialized. To suppress this warning opt to use a controlled ${n}.`].join(`
179
+ `))},[t])}const a=y.useCallback(l=>{o||i(l)},[]);return[c,a]}function Xo(e){let t=0;const n=new WeakMap;try{return JSON.stringify(e,function(s,i){if(!(s==="_owner"&&this!=null&&typeof this=="object"&&"$$typeof"in this)){if(typeof i=="bigint")return`__bigint__:${i}`;if(i!==null&&typeof i=="object"){const c=n.get(i);if(c!==void 0)return`__object__:${c}`;n.set(i,t),t+=1}return i}})??`__top__:${typeof e}`}catch{return"__unserializable__"}}function mi(){const[,e]=y.useState({});return y.useCallback(()=>{e({})},[])}let Jo=0;function rl(e,t="mui"){const n=y.useRef(void 0),r=mi(),o=e??n.current;return y.useEffect(()=>{n.current==null&&(Jo+=1,n.current=`${t}-${Jo}`,e==null&&r())},[e,t,r]),o}const Zo=tt.useId;function Gn(e,t){if(Zo!==void 0){const n=Zo();return e??(t?`${t}-${n}`:n)}return rl(e,t)}function bi(e){return Gn(e,"base-ui")}function Pe(e,t,n,r){let o=!1,s=!1;const i=Fe;return{reason:e,event:t??new Event("base-ui"),cancel(){o=!0},allowPropagation(){s=!0},get isCanceled(){return o},get isPropagationAllowed(){return s},trigger:n,...i}}const vi="none",Kn="trigger-press",We="trigger-hover",Pn="trigger-focus",ol="outside-press",sl="focus-out",no="escape-key",Or="imperative-action",il=()=>{},pe=typeof document<"u"?y.useLayoutEffect:il;function ro(e){y.useEffect(e,Va)}const pn=null;let Qo=globalThis.requestAnimationFrame;class cl{constructor(){ae(this,"callbacks",[]);ae(this,"callbacksCount",0);ae(this,"nextId",1);ae(this,"startId",1);ae(this,"isScheduled",!1);ae(this,"tick",t=>{var o;this.isScheduled=!1;const n=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let s=0;s<n.length;s+=1)(o=n[s])==null||o.call(n,t)})}request(t){const n=this.nextId;this.nextId+=1,this.callbacks.push(t),this.callbacksCount+=1;const r=process.env.NODE_ENV!=="production"&&Qo!==requestAnimationFrame&&(Qo=requestAnimationFrame,!0);return(!this.isScheduled||r)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),n}cancel(t){const n=t-this.startId;n<0||n>=this.callbacks.length||this.callbacks[n]!==null&&(this.callbacks[n]=null,this.callbacksCount-=1)}}let hn=new cl;class Ne{constructor(){ae(this,"currentId",pn);ae(this,"cancel",()=>{this.currentId!==pn&&(hn.cancel(this.currentId),this.currentId=pn)});ae(this,"disposeEffect",()=>this.cancel)}static create(){return new Ne}static request(t){return hn.request(t)}static cancel(t){return hn.cancel(t)}request(t){this.cancel(),this.currentId=hn.request(()=>{this.currentId=pn,t()})}}function al(){const e=Ye(Ne.create).current;return ro(e.disposeEffect),e}function yi(e,t=!1,n=!1,r=!1){const[o,s]=y.useState(e&&t?"idle":void 0),[i,c]=y.useState(e&&!r);return e&&!i&&(c(!0),s("starting")),!e&&i&&o!=="ending"&&!n&&s("ending"),!e&&!i&&o==="ending"&&s(void 0),pe(()=>{if(!e&&i&&o!=="ending"&&n){const a=Ne.request(()=>{s("ending")});return()=>{Ne.cancel(a)}}},[e,i,o,n]),pe(()=>{if(!e||t||o===void 0)return;const a=Ne.request(()=>{s(void 0)});return()=>{Ne.cancel(a)}},[t,e,o]),pe(()=>{if(!e||!t)return;e&&i&&o!=="idle"&&s("starting");const a=Ne.request(()=>{s("idle")});return()=>{Ne.cancel(a)}},[t,e,i,o]),{mounted:i,setMounted:c,transitionStatus:o}}function ll(e){const{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:o}=e,[s,i]=nl({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:c,setMounted:a,transitionStatus:l}=yi(s,!0,!0),f=bi(),[u,h]=y.useState(),g=u===null?void 0:u??f,d=fe(m=>{const b=!s,v=Pe(Kn,m.nativeEvent);r(b,v),!v.isCanceled&&i(b)});return y.useMemo(()=>({defaultPanelId:f,disabled:o,handleTrigger:d,mounted:c,open:s,panelId:g,setMounted:a,setOpen:i,setPanelIdState:h,transitionStatus:l}),[f,o,d,c,s,g,a,i,h,l])}function ul(e,t){return function(r,...o){const s=new URL(e);return s.searchParams.set("code",r.toString()),o.forEach(i=>s.searchParams.append("args[]",i)),`${t} error #${r}; visit ${s} for the full message.`}}const wt=ul("https://base-ui.com/production-error","Base UI"),oo=y.createContext(void 0);process.env.NODE_ENV!=="production"&&(oo.displayName="CollapsibleRootContext");function xi(){const e=y.useContext(oo);if(e===void 0)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>.":wt(15));return e}const so="data-starting-style",fl="data-ending-style",dl={[so]:""},pl={[fl]:""},io={transitionStatus(e){return e==="starting"?dl:e==="ending"?pl:null}},hl="data-open",gl="data-closed",gn=so,ml="data-panel-open",bl={[hl]:""},vl={[gl]:""},yl={open(e){return e?{[ml]:""}:null}},xl={open(e){return e?bl:vl}},Ei={...xl,...io},Si=y.forwardRef(function(t,n){const{render:r,className:o,defaultOpen:s=!1,disabled:i=!1,onOpenChange:c,open:a,style:l,...f}=t,u=fe(c),h=ll({open:a,defaultOpen:s,onOpenChange:u,disabled:i}),g=y.useMemo(()=>({open:h.open,disabled:h.disabled,transitionStatus:h.transitionStatus}),[h.open,h.disabled,h.transitionStatus]),d=y.useMemo(()=>({...h,onOpenChange:u,state:g}),[h,u,g]),m=pt("div",t,{state:g,ref:n,props:f,stateAttributesMapping:Ei});return p.jsx(oo.Provider,{value:d,children:m})});process.env.NODE_ENV!=="production"&&(Si.displayName="CollapsibleRoot");function Yn(){return typeof window<"u"}function Le(e){return co(e)?(e.nodeName||"").toLowerCase():"#document"}function Ie(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ot(e){var t;return(t=(co(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function co(e){return Yn()?e instanceof Node||e instanceof Ie(e).Node:!1}function me(e){return Yn()?e instanceof Element||e instanceof Ie(e).Element:!1}function _e(e){return Yn()?e instanceof HTMLElement||e instanceof Ie(e).HTMLElement:!1}function At(e){return!Yn()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ie(e).ShadowRoot}function Xn(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=$e(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function El(e){return/^(table|td|th)$/.test(Le(e))}function Jn(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Sl=/transform|translate|scale|rotate|perspective|filter/,wl=/paint|layout|strict|content/,mt=e=>!!e&&e!=="none";let fr;function ao(e){const t=me(e)?$e(e):e;return mt(t.transform)||mt(t.translate)||mt(t.scale)||mt(t.rotate)||mt(t.perspective)||!lo()&&(mt(t.backdropFilter)||mt(t.filter))||Sl.test(t.willChange||"")||wl.test(t.contain||"")}function Cl(e){let t=lt(e);for(;_e(t)&&!ct(t);){if(ao(t))return t;if(Jn(t))return null;t=lt(t)}return null}function lo(){return fr==null&&(fr=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),fr}function ct(e){return/^(html|body|#document)$/.test(Le(e))}function $e(e){return Ie(e).getComputedStyle(e)}function Zn(e){return me(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function lt(e){if(Le(e)==="html")return e;const t=e.assignedSlot||e.parentNode||At(e)&&e.host||ot(e);return At(t)?t.host:t}function wi(e){const t=lt(e);return ct(t)?(e.ownerDocument||e).body:_e(t)&&Xn(t)?t:wi(t)}function Gt(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=wi(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Ie(o);if(s){const c=Ir(i);return t.concat(i,i.visualViewport||[],Xn(o)?o:[],c&&n?Gt(c):[])}else return t.concat(o,Gt(o,[],n))}function Ir(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const Ci=y.createContext(void 0);process.env.NODE_ENV!=="production"&&(Ci.displayName="CompositeRootContext");function Rl(e=!1){const t=y.useContext(Ci);if(t===void 0&&!e)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>.":wt(16));return t}function Tl(e){const{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:o=0,isNativeButton:s}=e,i=r&&t!==!1,c=r&&t===!1;return{props:y.useMemo(()=>{const l={onKeyDown(f){n&&t&&f.key!=="Tab"&&f.preventDefault()}};return r||(l.tabIndex=o,!s&&n&&(l.tabIndex=t?o:-1)),(s&&(t||i)||!s&&n)&&(l["aria-disabled"]=n),s&&(!t||c)&&(l.disabled=n),l},[r,n,t,i,c,s,o])}}function Ke(e){return(e==null?void 0:e.ownerDocument)||document}function dr(e,t,{detail:n=0,pointerType:r=""}={}){e.dispatchEvent(new(Ie(e)).PointerEvent("click",{bubbles:!0,cancelable:!0,composed:!0,detail:n,pointerType:r,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function Ri(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:o=!0,composite:s}=e,i=y.useRef(null),c=Rl(!0),a=s??c!==void 0,{props:l}=Tl({focusableWhenDisabled:n,disabled:t,composite:a,tabIndex:r,isNativeButton:o});process.env.NODE_ENV!=="production"&&y.useEffect(()=>{var d,m;if(!i.current)return;const g=mn(i.current);if(o){if(!g){const b=((d=tt.captureOwnerStack)==null?void 0:d.call(tt))||"";Nn(`A component that acts as a button expected a native <button> because the \`nativeButton\` prop is true. Rendering a non-<button> removes native button semantics, which can impact forms and accessibility. Use a real <button> in the \`render\` prop, or set \`nativeButton\` to \`false\`.${b}`)}}else if(g){const b=((m=tt.captureOwnerStack)==null?void 0:m.call(tt))||"";Nn(`A component that acts as a button expected a non-<button> because the \`nativeButton\` prop is false. Rendering a <button> keeps native behavior while Base UI applies non-native attributes and handlers, which can add unintended extra attributes (such as \`role\` or \`aria-disabled\`). Use a non-<button> in the \`render\` prop, or set \`nativeButton\` to \`true\`.${b}`)}},[o]);const f=y.useCallback(()=>{const g=i.current;mn(g)&&a&&t&&l.disabled===void 0&&g.disabled&&(g.disabled=!1)},[t,l.disabled,a]);pe(f,[f]);const u=y.useCallback((g={})=>{const{onClick:d,onMouseDown:m,onKeyUp:b,onKeyDown:v,onPointerDown:x,...S}=g;return to({onClick(E){if(t){E.preventDefault();return}d==null||d(E)},onMouseDown(E){t||m==null||m(E)},onKeyDown(E){if(t||(An(E),v==null||v(E),E.baseUIHandlerPrevented))return;const C=E.target===E.currentTarget,w=E.currentTarget,R=mn(w),P=!o&&Pl(w),O=C&&(o?R:!P),M=E.key==="Enter",F=E.key===" ",A=w.getAttribute("role"),D=(A==null?void 0:A.startsWith("menuitem"))||A==="option"||A==="gridcell";if(C&&a&&F){if(E.defaultPrevented&&D)return;E.preventDefault(),(!o||R)&&(E.preventBaseUIHandler(),dr(w,E));return}if(!O||o||!F&&!M){C&&P&&F&&E.preventDefault();return}E.defaultPrevented||(E.preventDefault(),M&&(E.preventBaseUIHandler(),dr(w,E)))},onKeyUp(E){if(!t){if(An(E),b==null||b(E),E.target===E.currentTarget&&o&&a&&mn(E.currentTarget)&&E.key===" "){E.preventDefault();return}E.baseUIHandlerPrevented||E.target===E.currentTarget&&!o&&!a&&!E.defaultPrevented&&E.key===" "&&(E.preventBaseUIHandler(),dr(E.currentTarget,E))}},onPointerDown(E){if(t){E.preventDefault();return}x==null||x(E)}},o?{type:"button"}:{role:"button"},l,S)},[t,l,a,o]),h=fe(g=>{i.current=g,f()});return{getButtonProps:u,buttonRef:h}}function mn(e){return _e(e)&&e.tagName==="BUTTON"}function Pl(e){return _e(e)&&e.tagName==="A"&&!!e.href}const Ol={...yl,...io},Ti=y.forwardRef(function(t,n){const{panelId:r,open:o,handleTrigger:s,state:i,disabled:c}=xi(),{className:a,disabled:l=c,render:f,nativeButton:u=!0,style:h,...g}=t,{getButtonProps:d,buttonRef:m}=Ri({disabled:l,native:u});return pt("button",t,{state:i,ref:[n,m],props:[{"aria-controls":o?r:void 0,"aria-expanded":o,onClick:s},g,d],stateAttributesMapping:Ol})});process.env.NODE_ENV!=="production"&&(Ti.displayName="CollapsibleTrigger");function Ee(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}const Ht=0;class ut{constructor(){ae(this,"currentId",Ht);ae(this,"clear",()=>{this.currentId!==Ht&&(clearTimeout(this.currentId),this.currentId=Ht)});ae(this,"disposeEffect",()=>this.clear)}static create(){return new ut}start(t,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Ht,n()},t)}isStarted(){return this.currentId!==Ht}}function zt(){const e=Ye(ut.create).current;return ro(e.disposeEffect),e}function qe(e){const t=Ye(Il,e).current;return t.next=e,pe(t.effect),t}function Il(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function _l(e){return e==null?e:"current"in e?e.current:e}function es(e,t){return e.getAnimations(t).filter(n=>{var o;const r=(o=n.effect)==null?void 0:o.getTiming();return(r==null?void 0:r.duration)!==1/0&&(r==null?void 0:r.iterations)!==1/0})}let bn=null;function kl(e){if(!bn){const t=[];bn=t,queueMicrotask(()=>{bn=null,dt.flushSync(()=>{for(const n of t)n()})})}bn.push(e)}function Pi(e,t=!1,n=!1){const r=al();return fe((o,s=null)=>{r.cancel();const i=_l(e);if(i==null)return;const c=i,a=()=>{if(!n){dt.flushSync(o);return}kl(()=>{s!=null&&s.aborted||o()})};if(typeof c.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){o();return}function l(){Promise.all(es(c).map(f=>f.finished.then(eo))).then(()=>{s!=null&&s.aborted||a()},()=>{if(s!=null&&s.aborted)return;if(es(c).some(u=>u.pending||u.playState!=="finished")){l();return}a()})}if(t){const f=so;if(!c.hasAttribute(f)){r.request(l);return}const u=new MutationObserver(()=>{c.hasAttribute(f)||(u.disconnect(),l())});u.observe(c,{attributes:!0,attributeFilter:[f]}),s==null||s.addEventListener("abort",()=>u.disconnect(),{once:!0});return}r.request(l)})}function uo(e){const{enabled:t=!0,open:n,ref:r,batch:o=!1,onComplete:s}=e,i=fe(s),c=Pi(r,n,o);y.useEffect(()=>{if(!t)return;const a=new AbortController;return c(i,a.signal),()=>{a.abort()}},[t,n,i,c])}const Ot={height:void 0,width:void 0};function Al(e){const{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:o,mounted:s,onOpenChange:i,open:c,setMounted:a,setOpen:l,transitionStatus:f}=e,u=y.useRef(null),h=y.useRef(null),[g,d]=y.useState(Ot),m=y.useRef(Ot),b=y.useRef(!1),v=y.useRef(c),x=y.useRef(!1),[S,E]=y.useState(!1),C=y.useRef(null),w=Rr(t,u),R=qe(c),P=Pi(u),O=!c&&!s,M=S?"idle":f,F=c&&(v.current||x.current),A=!c&&s&&h.current==="css-animation"&&g.height===void 0&&g.width===void 0?m.current:g,D=n&&O&&h.current!=="css-animation",_=fe((N,Y=!0)=>{Y&&(m.current=N),d(N)}),T=fe(()=>{var N;(N=C.current)==null||N.call(C),C.current=null}),k=fe(N=>{T(),C.current=()=>{C.current=null,N()}}),U=fe(()=>{c&&s&&h.current==="css-animation"&&(x.current=!0)});pe(()=>{!S||f==="starting"||E(!1)},[S,f]),y.useEffect(()=>()=>{U(),T()},[U,T]),pe(()=>{c||(v.current=!1,x.current=!1);const N=u.current;if(!N)return;!c&&C.current&&T();const Y=Nl(N,F);if(h.current=Y,c&&f==="idle"&&v.current&&Y==="css-animation"){m.current=It(N);return}if(c&&f==="starting"){const ie=b.current;if(b.current=!1,Y==="none"){_(It(N)),E(!0);return}if(Y==="css-transition"){const B=jl(N);if(_(It(N)),!ie)return B;const $=vn(N,"transition-duration","0s");return k($),E(!0),B}_(It(N));const L=vn(N,"animation-name","none");if(!ie){L();return}const X=vn(N,"animation-duration","0s");L(),k(X),E(!0);return}if(!c&&s&&(f==="idle"||f==="starting")){if(Y==="none"){_(Ot,!1),a(!1);return}_(It(N));return}if(f!=="ending")return;if(Y==="none"){a(!1);return}const K=It(N);if(!(K.height>0||K.width>0)){a(!1);return}_(K),Y==="css-animation"&&vn(N,"animation-name","none")()},[s,c,T,_,a,k,F,f]),uo({enabled:c&&s&&M==="idle",open:!0,ref:u,onComplete(){c&&_(Ot,!1)}}),y.useEffect(()=>{if(c||!s||M!=="ending")return;if(!u.current){a(!1),_(Ot,!1);return}const Y=new AbortController;let K=-1;function le(){R.current||(a(!1),_(Ot,!1))}return K=Ne.request(()=>{P(le,Y.signal)}),()=>{Ne.cancel(K),Y.abort()}},[R,s,c,M,P,_,a]),pe(()=>{const N=u.current;!N||!n||!O||N.setAttribute("hidden","until-found")},[O,n]),y.useEffect(function(){const Y=u.current;if(!Y)return;const K=ut.create();let le=-1;const ie=(B,$)=>{K.start(0,()=>{R.current||(le=Ne.request(()=>{R.current||(B&&(b.current=!1),$&&Y.setAttribute(gn,""),Y.setAttribute("hidden","until-found"))}))})},X=Ee(Y,"beforematch",B=>{const $=Pe(vi,B);if(i(!0,$),$.isCanceled){ie(!1,!1);return}b.current=!0;const Q=Y.hasAttribute(gn);Y.removeAttribute(gn),l(!0),ie(!0,Q)});return()=>{K.clear(),Ne.cancel(le),X()}},[R,i,l]);const j=o||n||s||c;return{height:A.height,props:{...D?{[gn]:""}:void 0,hidden:O,id:r},ref:w,shouldPreventOpenAnimation:F,shouldRender:j,transitionStatus:M,width:A.width}}function It(e){return{height:e.scrollHeight,width:e.scrollWidth}}function Nl(e,t){const n=Ie(e).getComputedStyle(e),r=(n.animationName.split(",").map(s=>s.trim()).some(s=>s!==""&&s!=="none")||t)&&ts(n.animationDuration),o=ts(n.transitionDuration);return r&&o?(process.env.NODE_ENV!=="production"&&Qr("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.","Only one of either animation type should be used."),"css-transition"):o?"css-transition":r?"css-animation":"none"}function ts(e){return e.split(",").map(t=>t.trim()).some(t=>t!==""&&Number.parseFloat(t)>0)}function vn(e,t,n){const r=e.style.getPropertyValue(t),o=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===""){e.style.removeProperty(t);return}e.style.setProperty(t,r,o)}}function jl(e){const t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(o=>{e.style.setProperty(o,"initial","important")});function n(){Object.entries(t).forEach(([o,s])=>{if(s===""){e.style.removeProperty(o);return}e.style.setProperty(o,s)})}const r=Ne.request(n);return()=>{Ne.cancel(r),n()}}const Ml="--collapsible-panel-height",Dl="--collapsible-panel-width",Oi=y.forwardRef(function(t,n){const{className:r,hiddenUntilFound:o,keepMounted:s,render:i,id:c,style:a,...l}=t;process.env.NODE_ENV!=="production"&&y.useEffect(()=>{o&&s===!1&&Qr("The `keepMounted={false}` prop on `Collapsible.Panel` is ignored when `hiddenUntilFound` is enabled, since the panel must remain mounted while closed.")},[o,s]);const{defaultPanelId:f,mounted:u,onOpenChange:h,open:g,setMounted:d,setPanelIdState:m,setOpen:b,state:v,transitionStatus:x}=xi(),S=o??!1,E=s??!1,C=c||void 0,w=C??f;pe(()=>(m(U=>C??(U===null?void 0:U)),()=>{m(U=>U===C?null:U)}),[C,m]);const{height:R,props:P,ref:O,shouldPreventOpenAnimation:M,shouldRender:F,transitionStatus:A,width:D}=Al({externalRef:n,hiddenUntilFound:S,id:w,keepMounted:E,mounted:u,onOpenChange:h,open:g,setMounted:d,setOpen:b,transitionStatus:x}),_={...v,transitionStatus:A},T=li(a,_),k=pt("div",{...t,style:void 0},{state:_,ref:O,props:[P,{style:{[Ml]:R===void 0?"auto":`${R}px`,[Dl]:D===void 0?"auto":`${D}px`}},l,T?{style:T}:void 0,M?{style:{animationName:"none"}}:void 0],stateAttributesMapping:Ei});return F?k:null});process.env.NODE_ENV!=="production"&&(Oi.displayName="CollapsiblePanel");function bt({className:e,...t}){return p.jsx("div",{"data-slot":"trace",className:ue("trace",e),...t})}function Nt({className:e,status:t,...n}){return p.jsx("span",{"data-slot":"trace-line","data-status":t,className:ue("trace-line",e),...n})}function xt({className:e,...t}){return p.jsx("span",{"data-slot":"trace-icon",className:ue("trace-icon",e),...t,"aria-hidden":"true"})}function jt({className:e,...t}){return p.jsx("span",{"data-slot":"trace-title",className:ue("trace-title",e),...t})}function Kt({className:e,...t}){return p.jsx("span",{"data-slot":"trace-description",className:ue("trace-description",e),...t})}function Ii(e){return p.jsx(Si,{"data-slot":"trace-collapsible",...e})}function _i({children:e,className:t,...n}){return p.jsxs(Ti,{type:"button","data-slot":"trace-collapsible-trigger",className:ue("trace-trigger",t),...n,children:[e,p.jsx(xt,{className:"trace-chevron",children:p.jsx(Zs,{size:13})})]})}function ki({className:e,...t}){return p.jsx(Oi,{...t,"data-slot":"trace-collapsible-content",className:ue("trace-content",e)})}const Fl=({message:e,onRetry:t})=>p.jsx(Jr,{className:"chat-error-banner",role:"alert",children:p.jsxs(Zr,{children:[p.jsx(bt,{className:"chat-message-body",children:p.jsxs(Nt,{status:"error",children:[p.jsx(xt,{children:p.jsx(ma,{size:14})}),p.jsx(jt,{className:"chat-error-title",children:e})]})}),t&&p.jsx(Cr,{children:p.jsx("button",{type:"button",onClick:t,className:"chat-error-retry-btn",children:"Try again"})})]})}),Ll={alpha:{label:"Alpha",Icon:ya,variant:"env-badge--alpha",tooltip:"Alpha build — internal testing only"},beta:{label:"Beta",Icon:Ra,variant:"env-badge--beta",tooltip:"Beta build — public pre-release"},gamma:{label:"Gamma",Icon:Ea,variant:"env-badge--gamma",tooltip:"Gamma / Release Candidate"},qa:{label:"QA",Icon:ba,variant:"env-badge--qa",tooltip:"Quality Assurance build"}},Bl=({stage:e,pulse:t=!0,className:n=""})=>{if(!e)return null;const{label:r,Icon:o,variant:s,tooltip:i}=Ll[e];return p.jsxs("span",{className:`env-badge-inline ${s} ${n}`.trim(),title:i,"aria-label":`${r} build`,role:"status",children:[p.jsx(o,{size:10,className:"env-badge-icon","aria-hidden":"true"}),p.jsx("span",{className:"env-badge-inline-label",children:r})]})},Vl=e=>p.jsx("svg",{width:e.width||"24px",height:e.height||"24px",viewBox:"0 0 24 24",role:"img",xmlns:"http://www.w3.org/2000/svg",fill:e.Color||"currentColor",...e,children:p.jsx("path",{d:"M11.999 0c-2.25 0-4.5.06-6.6.21a5.57 5.57 0 0 0-5.19 5.1c-.24 3.21-.27 6.39-.06 9.6a5.644 5.644 0 0 0 5.7 5.19h3.15v-3.9h-3.15c-.93.03-1.74-.63-1.83-1.56-.18-3-.15-6 .06-9 .06-.84.72-1.47 1.56-1.53 2.04-.15 4.2-.21 6.36-.21s4.32.09 6.36.18c.81.06 1.5.69 1.56 1.53.24 3 .24 6 .06 9-.12.93-.9 1.62-1.83 1.59h-3.15l-6 3.9V24l6-3.9h3.15c2.97.03 5.46-2.25 5.7-5.19.21-3.18.18-6.39-.03-9.57a5.57 5.57 0 0 0-5.19-5.1c-2.13-.18-4.38-.24-6.63-.24zm-5.04 8.76c-.36 0-.66.3-.66.66v2.34c0 .33.18.63.48.78 1.62.78 3.42 1.2 5.22 1.26 1.8-.06 3.6-.48 5.22-1.26.3-.15.48-.45.48-.78V9.42c0-.09-.03-.15-.09-.21a.648.648 0 0 0-.87-.36c-1.5.66-3.12 1.02-4.77 1.05-1.65-.03-3.27-.42-4.77-1.08a.566.566 0 0 0-.24-.06z"})}),$l=({title:e="VPS AI Assistant",subtitle:t="Customer portal support",onClose:n,onReset:r,onBack:o,soundEnabled:s,onToggleSound:i,showMinimize:c=!1,envStage:a,envPulse:l=!0})=>p.jsxs("header",{className:"chat-header",children:[p.jsxs("div",{className:"chat-header-left",children:[o&&p.jsx("button",{type:"button",onClick:o,className:"icon-btn-back","aria-label":"Back",children:p.jsx(da,{size:16})}),p.jsx("div",{className:"avatar-circle","aria-hidden":"true",children:p.jsx(Vl,{width:"16px",height:"16px",color:"white"})}),p.jsxs("div",{children:[p.jsxs("div",{className:"chat-header-title-row",children:[p.jsx("h2",{className:"chat-header-title",children:e}),p.jsx(Bl,{stage:a,pulse:l})]}),p.jsx("p",{className:"chat-header-subtitle",children:t||"Customer portal support"})]})]}),p.jsxs("div",{className:"chat-header-actions",children:[i&&p.jsx("button",{type:"button",className:"icon-btn-action chat-sound-btn","aria-label":"Response sound","aria-pressed":!!s,title:s?"Mute response sound":"Enable response sound",onClick:i,children:s?p.jsx(Oa,{size:16,"aria-hidden":"true"}):p.jsx(Ia,{size:16,"aria-hidden":"true"})}),r&&p.jsx("button",{type:"button",onClick:r,className:"icon-btn-action","aria-label":"Start a new conversation",title:"New conversation",children:p.jsx(Ca,{size:15})}),n&&p.jsx("button",{type:"button",onClick:n,className:"icon-btn-action","aria-label":c?"Minimize chat":"Close chat",children:p.jsx(Sa,{size:16})})]})]});function Hl(e,t){const n=I.useRef(e);I.useEffect(()=>{var r;n.current&&!e&&((r=t.current)==null||r.focus()),n.current=e},[e,t])}function Ul({className:e,...t}){return p.jsx("div",{...t,"data-slot":"input-group",className:ue("chat-input-group",e)})}function zl({className:e,...t}){return p.jsx("textarea",{...t,"data-slot":"input-group-textarea",className:ue("chat-textarea",e)})}function Wl({className:e,...t}){return p.jsx("div",{...t,"data-slot":"input-group-addon",className:ue("chat-input-actions",e)})}function ns({className:e,...t}){return p.jsx("button",{type:"button",...t,"data-slot":"input-group-button",className:ue("chat-send-btn",e)})}const Ai=y.forwardRef(function(t,n){const{render:r,className:o,disabled:s=!1,focusableWhenDisabled:i=!1,nativeButton:c=!0,style:a,...l}=t,{getButtonProps:f,buttonRef:u}=Ri({disabled:s,focusableWhenDisabled:i,native:c});return pt("button",t,{state:{disabled:s},ref:[n,u],props:[l,f]})});process.env.NODE_ENV!=="production"&&(Ai.displayName="Button");const rs=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,os=Gs,ql=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return os(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:s}=t,i=Object.keys(o).map(l=>{const f=n==null?void 0:n[l],u=s==null?void 0:s[l];if(f===null)return null;const h=rs(f)||rs(u);return o[l][h]}),c=n&&Object.entries(n).reduce((l,f)=>{let[u,h]=f;return h===void 0||(l[u]=h),l},{}),a=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((l,f)=>{let{class:u,className:h,...g}=f;return Object.entries(g).every(d=>{let[m,b]=d;return Array.isArray(b)?b.includes({...s,...c}[m]):{...s,...c}[m]===b})?[...l,u,h]:l},[]);return os(e,i,a,n==null?void 0:n.class,n==null?void 0:n.className)},Gl=ql("vps-ui-button",{variants:{variant:{default:"vps-ui-button--default",outline:"vps-ui-button--outline",secondary:"vps-ui-button--secondary",ghost:"vps-ui-button--ghost",destructive:"vps-ui-button--destructive",link:"vps-ui-button--link"},size:{default:"vps-ui-button--size-default",xs:"vps-ui-button--size-xs",sm:"vps-ui-button--size-sm",lg:"vps-ui-button--size-lg",icon:"vps-ui-button--size-icon","icon-xs":"vps-ui-button--size-icon-xs","icon-sm":"vps-ui-button--size-icon-sm","icon-lg":"vps-ui-button--size-icon-lg"}},defaultVariants:{variant:"default",size:"default"}});function fo({className:e,variant:t,size:n,...r}){return p.jsx(Ai,{type:"button","data-slot":"button",...r,className:o=>ue(Gl({variant:t,size:n}),typeof e=="function"?e(o):e)})}function Kl({className:e,...t}){return p.jsx("div",{...t,className:ue("flex scroll-fade-x scrollbar-none gap-2 overflow-x-auto overscroll-x-contain",e),"data-slot":"suggestions"})}function Yl({suggestion:e,onClick:t,children:n,className:r,variant:o="outline",size:s="sm",...i}){return p.jsx(fo,{...i,variant:o,size:s,className:c=>ue("shrink-0",typeof r=="function"?r(c):r),onClick:()=>t==null?void 0:t(e),children:n??e})}function Xl(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.label.toLowerCase().includes(n)||r.query.toLowerCase().includes(n)):e}const Jl=({suggestions:e,onSelect:t,disabled:n,variant:r="list"})=>e.length?p.jsx(Kl,{className:r==="badge"?"chat-suggestion-strip":"suggestions-list",role:"list","aria-label":"Suggested questions",children:e.map(o=>p.jsx("div",{role:"listitem",children:p.jsx(Yl,{suggestion:o.query,disabled:n,onClick:()=>t(o),title:o.query,children:o.label})},o.query))}):null,Zl=({onSend:e,onStop:t,disabled:n=!1,placeholder:r="Ask something…",ref:o})=>{const{suggestions:s,showSuggestions:i,suggestionBadgesEnabled:c,models:a,selectedModelId:l,selectModel:f}=en(),[u,h]=I.useState(""),g=I.useRef(null),d=I.useId(),m=I.useId(),b=E=>{E&&(E.style.height="auto",E.style.height=`${Math.min(E.scrollHeight,96)}px`)};Hl(n,g),I.useImperativeHandle(o,()=>({edit(E){var C;n||(h(E),(C=g.current)==null||C.focus())}}),[n]),I.useEffect(()=>{b(g.current)},[u]);const v=I.useMemo(()=>{if(!c||n)return[];const E=u.trim();return E?Xl(s,E):i?s:[]},[n,i,c,s,u]),x=E=>{h(E.query);const C=g.current;C==null||C.focus()},S=()=>{const E=u.trim();!E||n||(e(E),h(""))};return p.jsxs("div",{className:"chat-input-wrapper",children:[p.jsx(Jl,{variant:"badge",suggestions:v,onSelect:x,disabled:n}),p.jsxs("form",{onSubmit:E=>{E.preventDefault(),S()},children:[p.jsx("label",{htmlFor:d,className:"sr-only",children:"Chat message"}),p.jsxs(Ul,{children:[p.jsx(zl,{id:d,ref:g,rows:1,value:u,disabled:n,placeholder:r,onChange:E=>h(E.target.value),onKeyDown:E=>{var C;E.key==="Enter"&&!E.shiftKey&&!E.nativeEvent.isComposing&&(E.preventDefault(),(C=E.currentTarget.form)==null||C.requestSubmit())}}),p.jsxs(Wl,{children:[a.length>1&&p.jsxs("div",{className:"chat-model-picker",children:[p.jsx("label",{htmlFor:m,className:"sr-only",children:"AI model"}),p.jsxs("select",{id:m,value:l,disabled:n,onChange:E=>f(E.target.value),children:[p.jsx("option",{value:"auto",children:"Automatic"}),a.map(E=>p.jsx("option",{value:E.id,disabled:!E.configured,children:E.label},E.id))]})]}),t?p.jsx(ns,{onClick:t,"aria-label":"Stop response",title:"Stop response",children:p.jsx(ri,{size:13,fill:"currentColor","aria-hidden":"true"})}):p.jsx(ns,{type:"submit",disabled:n||!u.trim(),"aria-label":"Send message",title:"Send message",children:p.jsx(pa,{size:16,"aria-hidden":"true"})})]})]})]}),p.jsxs("p",{className:"chat-input-footer",children:[p.jsx("span",{className:"chat-input-note",children:"AI can make mistakes."}),"Powered by ",p.jsx("span",{className:"chat-input-footer-brand",children:"VPS Veritas AI"})]})]})};function Ql({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:o}){let s=_r(eu(r,o),t);if(!n)return y.createElement(e,s);if(typeof n=="function")return n(s,r);if(!y.isValidElement(n))return null;let i=n.props,c={..._r(s,i),ref:tn(s.ref,i.ref)};return y.cloneElement(n,c)}function _r(...e){let t={};for(let n of e){if(!n)continue;let r=n;for(let o of Object.keys(r)){let s=r[o];if(s===void 0)continue;let i=t[o];o==="className"?t[o]=[i,s].filter(Boolean).join(" "):o==="style"?t[o]={...i,...s}:o==="ref"?t[o]=tn(i,s):nu(o)&&typeof i=="function"&&typeof s=="function"?t[o]=tu(s,i):t[o]=s}}return t}function eu(e,t){var r;let n={};for(let o of Object.keys(e)){let s=e[o],i=(r=t==null?void 0:t[o])==null?void 0:r.call(t,s);if(i){Object.assign(n,i);continue}if(o==="slot"){n["data-slot"]=s;continue}let c=`data-${String(o).replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`)}`;typeof s=="boolean"?n[c]=s?"":void 0:s!=null&&(n[c]=String(s))}return n}function tu(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function nu(e){return/^on[A-Z]/.test(e)}function tn(...e){let t=e.filter(Boolean);if(t.length!==0)return n=>{for(let r of t)typeof r=="function"?r(n):r&&(r.current=n)}}var ru=8,ou=64,su=0,jn=.5,iu=180,cu=new Set(["ArrowDown","ArrowUp","End","Home","PageDown","PageUp"," "]),Ni={start:!1,end:!1},au=[],Mn={currentAnchorId:null,visibleMessageIds:au};function lu({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return Ni;let o=po({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:o-r.scrollTop-r.clientHeight>t}}function uu({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:o,visibleMessageIds:s}){if(!e||!o)return Mn;let i=o.getBoundingClientRect(),c=i.top+t+n,a=typeof IntersectionObserver>"u",l=[],f=null;for(let u of Yt(e,r)){let h=u.dataset.messageId;if(!h)continue;let g=u.dataset.scrollAnchor==="true",d=g||a?u.getBoundingClientRect():null;(a&&d?d.bottom>c&&d.top<i.bottom:s.has(h))&&l.push(h),g&&d&&d.top<=c+jn&&(f=h)}return l.length===0&&f===null?Mn:{currentAnchorId:f,visibleMessageIds:l}}function Yt(e,t){return Array.from(e.children).filter(n=>n instanceof HTMLElement&&n!==t)}function fu(e,t){for(let n=t;n<e.length;n++){let r=e[n];if((r==null?void 0:r.dataset.scrollAnchor)==="true")return r}return null}function du(e,t){for(let n of e)if(n.dataset.scrollAnchor==="true"&&!t.has(n))return n;return null}function pu(e,t){var r;let n=0;for(let o=t;o<e.length;o++)if(((r=e[o])==null?void 0:r.dataset.scrollAnchor)==="true"&&(n+=1,n>1))return!0;return!1}function hu(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if((n==null?void 0:n.dataset.scrollAnchor)==="true")return n}return null}function gu({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let o of Yt(e,t)){if(!o.dataset.messageId)continue;let s=o.getBoundingClientRect();if(s.bottom>r.top&&s.top<r.bottom)return o}return null}function mu({align:e,element:t,scrollMargin:n,spacer:r,viewport:o}){let s=ji(t,o),i=t.getBoundingClientRect().height,c=yu(r);if(e==="center"){let a=Math.max(0,o.clientHeight-c.start-c.end);return s-c.start-(a-i)/2-n}if(e==="end")return s-o.clientHeight+i+c.end+n;if(e==="nearest"){let a=s+i,l=o.scrollTop+c.start,f=o.scrollTop+o.clientHeight-c.end;return s>=l&&a<=f?o.scrollTop:s<l?s-c.start-n:a-o.clientHeight+c.end+n}return s-c.start-n}function ji(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function On(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function bu({content:e,scrollTop:t,spacer:n,viewport:r}){let o=po({content:e,spacer:n,viewport:r});return t+r.clientHeight-o}function po({content:e,spacer:t,viewport:n}){let r=Yt(e,t),o=Mi(e),s=n.getBoundingClientRect(),i=n.scrollTop,c=o.start+o.end;for(let a of r){let l=a.getBoundingClientRect();c=Math.max(c,l.bottom-s.top+i+o.end)}return c}function vu(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function Mi(e){let t=window.getComputedStyle(e);return{end:kr(t.paddingBlockEnd||t.paddingBottom),start:kr(t.paddingBlockStart||t.paddingTop)}}function yu(e){let t=e==null?void 0:e.parentElement;return t?Mi(t):{end:0,start:0}}function xu(e){if(!e)return 0;let t=window.getComputedStyle(e),n=t.rowGap==="normal"?t.gap:t.rowGap;return kr(n)}function kr(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Di(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:o=>{t(n,o)||(n=o,r.forEach(s=>s()))},subscribe:(o,s,i)=>{let c=r.size===0;return r.add(o),c&&(s==null||s()),()=>{r.delete(o),r.size===0&&(i==null||i())}}}}function ss(e,t){return Di(e,t)}function Eu(){return Di(Mn,wu)}function Su(e,t){return e.start===t.start&&e.end===t.end}function wu(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((n,r)=>n===t.visibleMessageIds[r])}function Cu({autoScroll:e,defaultScrollPosition:t,scrollEdgeThreshold:n,scrollMargin:r,scrollPreviousItemPeek:o}){let s=y.useRef(e),i=y.useRef(!1),c=y.useRef(null),a=y.useRef(!1),l=y.useRef(n),f=y.useRef(0),u=y.useRef(null),h=y.useRef(0),g=y.useRef(e?"following-bottom":"free-scrolling"),d=y.useRef(new Map),m=y.useRef(null),b=y.useRef(null),v=y.useRef(null),x=y.useRef(o),S=y.useRef(!0),E=y.useRef(null),C=y.useRef(r),w=y.useRef(null),R=y.useRef(0),P=y.useRef(0),O=y.useRef(null),M=y.useRef(null),F=y.useRef(null),A=y.useRef(null),D=y.useRef(null),_=y.useRef(null),T=y.useRef(null),k=y.useRef(null),U=y.useRef(null),j=y.useRef(new Set),N=y.useRef(new WeakSet);return F.current===null&&(F.current=ss(t==="end"||t==="last-anchor",(Y,K)=>Y===K)),A.current===null&&(A.current=ss(Ni,Su)),U.current===null&&(U.current=Eu()),s.current=e,l.current=n,C.current=r,x.current=o,{autoScrollRef:s,autoscrollingRef:i,autoscrollingTimeoutRef:D,streamingTurnRef:v,contentRef:c,defaultScrollPositionAppliedRef:a,firstItemRef:u,itemCountRef:f,lastScrollTopRef:h,messageElementsRef:d,modeRef:g,pendingScrollFrameRef:w,pendingScrollToMessageRef:m,prependRestoreRef:b,preserveScrollOnPrependRef:S,pendingDefaultScrollStore:F.current,rootRef:E,scrollEdgeThresholdRef:l,scrollMarginRef:C,scrollPreviousItemPeekRef:x,spacerGapRef:R,spacerHeightRef:P,spacerRef:O,stateFrameRef:M,stateStore:A.current,viewportRef:_,visibilityFrameRef:T,visibilityObserverRef:k,visibilityStore:U.current,visibleMessageIdsRef:j,handledScrollAnchorsRef:N}}function Fi(e){e.pendingDefaultScrollStore.setSnapshot(!1)}function In(e){e.defaultScrollPositionAppliedRef.current=!0,Fi(e)}function Ru({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:o,autoScrollRef:s,autoscrollingRef:i,autoscrollingTimeoutRef:c,contentRef:a,itemCountRef:l,messageElementsRef:f,modeRef:u,pendingScrollToMessageRef:h,prependRestoreRef:g,scrollMarginRef:d,scrollPreviousItemPeekRef:m,spacerGapRef:b,spacerHeightRef:v,spacerRef:x,viewportRef:S}=e,E=y.useCallback(A=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null),i.current!==A&&(i.current=A,t()),A&&(c.current=window.setTimeout(()=>{c.current=null,i.current=!1,t()},iu))},[t]),C=y.useCallback(A=>{let D=x.current;if(!D)return;let _=Math.max(0,Math.ceil(A));v.current!==_&&(v.current=_,D.hidden=_===0,D.style.height=`${_}px`,D.style.marginTop=_>0?`${-b.current}px`:"")},[]),w=y.useCallback((A,{behavior:D="auto",autoscrolling:_=!1}={})=>{let T=S.current;if(!T)return;let k=Math.max(0,A);if(Math.abs(T.scrollTop-k)<=jn){T.scrollTop=k,t();return}_&&E(!0),T.scrollTo({top:k,behavior:D}),n()},[t,n,E]),R=y.useCallback(({behavior:A="auto"}={})=>S.current?(C(0),o.current=null,u.current="free-scrolling",w(0,{behavior:A}),r(),!0):!1,[r,w,C]),P=y.useCallback(({behavior:A="auto"}={})=>{let D=S.current;return D?(C(0),o.current=null,u.current=s.current?"following-bottom":"free-scrolling",w(vu(D),{autoscrolling:!0,behavior:A}),r(),!0):!1},[r,w,C]),O=y.useCallback((A,{align:D="start",behavior:_="auto",scrollMargin:T=d.current}={},{keepPreviousPeek:k=!1}={})=>{let U=a.current,j=S.current;if(!U||!j||!U.contains(A))return!1;let N=mu({align:D,element:A,scrollMargin:k?T+m.current:T,spacer:x.current,viewport:j}),Y=bu({content:U,scrollTop:N,spacer:x.current,viewport:j});return C(Y),g.current={element:A,viewportTop:On(A,j)},u.current=k?"anchored-to-message":"settling-jump",o.current=k?A:null,w(N,{behavior:_}),r(),!0},[r,w,C]),M=y.useCallback(()=>{let A=o.current;return!A||!A.isConnected||u.current!=="anchored-to-message"?!1:O(A,{align:"start"},{keepPreviousPeek:!0})},[O]),F=y.useCallback((A,D)=>{let _=f.current.get(A);return _?(In(e),O(_,D)?(h.current=null,!0):(h.current={messageId:A,options:D},!0)):l.current===0?(h.current={messageId:A,options:D},In(e),!0):!1},[O]);return{flushPendingScrollToMessage:y.useCallback(()=>{let A=h.current;if(!A)return!1;let D=f.current.get(A.messageId);return!D||!O(D,A.options)?!1:(h.current=null,In(e),!0)},[O]),reanchorToAnchoredMessage:M,scrollToElement:O,scrollToEnd:P,scrollToMessage:F,scrollToStart:R}}function is(e,t){return y.useCallback(n=>{e.current=n,n&&t()},[e,t])}function Tu({autoScroll:e=!1,defaultScrollPosition:t="end",scrollEdgeThreshold:n=ru,scrollPreviousItemPeek:r=ou,scrollMargin:o=su}){let s=Cu({autoScroll:e,defaultScrollPosition:t,scrollEdgeThreshold:n,scrollMargin:o,scrollPreviousItemPeek:r}),{streamingTurnRef:i,autoScrollRef:c,autoscrollingRef:a,autoscrollingTimeoutRef:l,contentRef:f,defaultScrollPositionAppliedRef:u,firstItemRef:h,itemCountRef:g,lastScrollTopRef:d,messageElementsRef:m,modeRef:b,pendingScrollFrameRef:v,pendingScrollToMessageRef:x,prependRestoreRef:S,preserveScrollOnPrependRef:E,pendingDefaultScrollStore:C,rootRef:w,scrollEdgeThresholdRef:R,scrollMarginRef:P,scrollPreviousItemPeekRef:O,spacerGapRef:M,spacerHeightRef:F,spacerRef:A,stateFrameRef:D,stateStore:_,viewportRef:T,visibilityFrameRef:k,visibilityObserverRef:U,visibilityStore:j,visibleMessageIdsRef:N,handledScrollAnchorsRef:Y}=s,K=y.useRef(t);K.current!==t&&(K.current=t,u.current=!1);let le=y.useCallback(V=>{let q=w.current,Z=T.current,se=[V.start&&"start",V.end&&"end"].filter(Boolean).join(" "),ke=a.current;for(let Ce of[q,Z])Ce&&(se?Ce.setAttribute("data-scrollable",se):Ce.removeAttribute("data-scrollable"),Ce.toggleAttribute("data-autoscrolling",ke))},[]),ie=y.useCallback(V=>{var se;let q=((se=T.current)==null?void 0:se.scrollTop)??0,Z=q<d.current-jn;d.current=q,c.current&&!V.end&&b.current!=="settling-jump"&&b.current!=="anchored-to-message"?b.current="following-bottom":b.current==="following-bottom"&&V.end&&Z&&!a.current&&(b.current="free-scrolling")},[]),L=y.useCallback(()=>{let V=lu({content:f.current,scrollEdgeThreshold:R.current,spacer:A.current,viewport:T.current});ie(V);let q=b.current==="following-bottom"?{...V,end:!1}:V;le(q),_.setSnapshot(q)},[ie,_,le]),X=y.useCallback(()=>{D.current===null&&(D.current=window.requestAnimationFrame(()=>{D.current=null,L()}))},[L]),B=y.useCallback(()=>{j.hasListeners()&&k.current===null&&(k.current=window.requestAnimationFrame(()=>{k.current=null,j.hasListeners()&&j.setSnapshot(uu({content:f.current,scrollMargin:P.current,scrollPreviousItemPeek:O.current,spacer:A.current,viewport:T.current,visibleMessageIds:N.current}))}))},[j]),{flushPendingScrollToMessage:$,reanchorToAnchoredMessage:Q,scrollToElement:re,scrollToEnd:ee,scrollToMessage:te,scrollToStart:W}=Ru({refs:s,commitScrollState:L,scheduleStateCommit:X,scheduleVisibilitySync:B}),ne=y.useCallback(()=>{let V=S.current,q=T.current;if(!V||!q||!V.element.isConnected)return!1;let Z=On(V.element,q)-V.viewportTop;return Math.abs(Z)<=jn?!1:(q.scrollTop+=Z,V.viewportTop=On(V.element,q),X(),B(),!0)},[X,B]),oe=y.useCallback(()=>{let V=f.current,q=T.current;if(!V||!q){S.current=null;return}let Z=gu({content:V,spacer:A.current,viewport:q});S.current=Z?{element:Z,viewportTop:On(Z,q)}:null},[]),ve=y.useCallback(()=>{v.current===null&&(v.current=window.requestAnimationFrame(()=>{v.current=null,$()&&oe()}))},[oe,$]),z=y.useCallback(()=>{if(!t||u.current||g.current===0)return!1;let V=!1;if(t==="last-anchor"){let q=f.current,Z=T.current,se=q&&Z?hu(Yt(q,A.current)):null;if(!q||!Z||!se)V=ee({behavior:"auto"});else{let ke=ji(se,Z);V=po({content:q,spacer:A.current,viewport:Z})-ke<=Z.clientHeight?ee({behavior:"auto"}):re(se,{align:"start"},{keepPreviousPeek:!0})}}else V=t==="end"?ee({behavior:"auto"}):W({behavior:"auto"});return V?(In(s),!0):!1},[t,re,ee,W]),J=y.useCallback(()=>{let V=f.current;if(!V)return;let q=Yt(V,A.current),Z=g.current,se=h.current;g.current=q.length,h.current=q[0]??null,(()=>{if($())return;if(Z===0){if(z()||q.length>0&&c.current&&ee({behavior:"auto"}))return;L(),B();return}let ke=se?q.indexOf(se):-1;if(E.current&&ke>0){ne();return}if(q.length>Z){let Ce=fu(q,Z);if(Ce){if(c.current&&b.current==="following-bottom"&&pu(q,Z)){ee({behavior:"auto"});return}re(Ce,{align:"start"},{keepPreviousPeek:!0}),Y.current.add(Ce);return}}if(q.length===Z){let Ce=du(q,Y.current);if(Ce){re(Ce,{align:"start"},{keepPreviousPeek:!0}),Y.current.add(Ce);return}}b.current==="following-bottom"&&c.current?ee({behavior:"auto"}):(L(),B())})(),oe()},[z,oe,L,$,ne,B,re,ee]),ce=y.useCallback(()=>{if(b.current==="following-bottom"&&c.current){ee({behavior:"auto"});return}let V=F.current;if(Q()){c.current&&V>0&&F.current===0&&ee({behavior:"auto"});return}X(),B()},[Q,X,B,ee]),he=y.useCallback(()=>{let V=T.current;if(!(!V||!j.hasListeners())){if(typeof IntersectionObserver>"u"){B();return}U.current||(U.current=new IntersectionObserver(q=>{for(let Z of q){let se=Z.target.dataset.messageId;se&&(Z.isIntersecting?N.current.add(se):N.current.delete(se))}B()},{root:V,rootMargin:`${-(P.current+O.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]})),m.current.forEach(q=>{var Z;(Z=U.current)==null||Z.observe(q)}),B()}},[B,j]),Oe=y.useCallback(()=>{var V;k.current!==null&&(window.cancelAnimationFrame(k.current),k.current=null),(V=U.current)==null||V.disconnect(),U.current=null,N.current.clear(),j.setSnapshot(Mn)},[j]),je=y.useCallback((V,q,Z)=>{var se,ke,Ce;if(q){m.current.set(V,q),(se=U.current)==null||se.observe(q),B(),((ke=x.current)==null?void 0:ke.messageId)===V&&ve();return}Z&&m.current.get(V)===Z&&(m.current.delete(V),N.current.delete(V),(Ce=U.current)==null||Ce.unobserve(Z),B())},[ve,B]),Re=y.useCallback(()=>{(b.current==="following-bottom"||b.current==="anchored-to-message"||b.current==="settling-jump")&&(i.current=null,b.current="free-scrolling")},[]),Me=y.useCallback(()=>le(_.getSnapshot()),[_,le]),Be=is(w,Me),H=is(T,Me),G=y.useCallback(V=>{f.current=V},[]),Se=y.useCallback(V=>{A.current=V,M.current=xu((V==null?void 0:V.parentElement)??null)},[]),be=y.useCallback(()=>{L(),B(),oe()},[oe,L,B]),ge=y.useMemo(()=>({handleContentChange:J,handleResize:ce,observeVisibility:he,pendingDefaultScrollStore:C,preserveScrollOnPrependRef:E,scrollToEnd:ee,scrollToMessage:te,scrollToStart:W,setContentElement:G,setRootElement:Be,setSpacerElement:Se,setViewportElement:H,stateStore:_,syncAfterScroll:be,unobserveVisibility:Oe,userScrollIntent:Re,viewportRef:T,visibilityStore:j}),[J,ce,he,C,ee,te,W,G,Be,Se,H,_,be,Oe,Re,j]);return y.useLayoutEffect(()=>{z()||g.current===0&&Fi(s)},[z]),y.useEffect(()=>()=>{var V;D.current!==null&&(window.cancelAnimationFrame(D.current),D.current=null),k.current!==null&&(window.cancelAnimationFrame(k.current),k.current=null),l.current!==null&&(window.clearTimeout(l.current),l.current=null),v.current!==null&&(window.cancelAnimationFrame(v.current),v.current=null),(V=U.current)==null||V.disconnect(),U.current=null},[]),y.useLayoutEffect(()=>{if(e&&b.current==="following-bottom"&&g.current>0){ee({behavior:"auto"});return}L()},[e,L,ee]),{context:ge,registerMessage:je}}function Pu(e){let t=y.useRef(e);return t.current=e,t}var Li=y.createContext(null),Bi=y.createContext(null);function nn(){let e=y.useContext(Li);if(!e)throw new Error("useMessageScroller must be used within a MessageScroller.");return e}function Ou(){let e=y.useContext(Bi);if(!e)throw new Error("MessageScrollerItem must be used within a MessageScroller.");return e}function Iu({autoScroll:e=!1,children:t,defaultScrollPosition:n="end",scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:s}){let{context:i,registerMessage:c}=Tu({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:s});return p.jsx(Li.Provider,{value:i,children:p.jsx(Bi.Provider,{value:c,children:t})})}function Vi(){let{pendingDefaultScrollStore:e}=nn();return y.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function _u({children:e,...t}){let{setRootElement:n}=nn(),r=Vi();return p.jsx("div",{ref:n,...t,...r?{"data-pending-scroll":""}:null,children:e})}function ku({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:o,onWheel:s,preserveScrollOnPrepend:i=!0,ref:c,role:a,tabIndex:l,...f}){let{handleResize:u,preserveScrollOnPrependRef:h,setViewportElement:g,syncAfterScroll:d,userScrollIntent:m,viewportRef:b}=nn(),v=Vi();h.current=i;let x=y.useCallback(R=>{var P;g(R),(P=tn(c))==null||P(R)},[c,g]);function S(R){d(),r==null||r(R)}function E(R){m(),s==null||s(R)}function C(R){m(),o==null||o(R)}function w(R){cu.has(R.key)&&m(),n==null||n(R)}return y.useEffect(()=>{let R=b.current;if(!R||typeof ResizeObserver>"u")return;let P=0,O=new ResizeObserver(()=>{window.cancelAnimationFrame(P),P=window.requestAnimationFrame(u)});return O.observe(R),()=>{window.cancelAnimationFrame(P),O.disconnect()}},[u,b]),p.jsx("div",{ref:x,role:a??"region","aria-label":e??"Messages",tabIndex:l??0,onKeyDown:w,onScroll:S,onTouchMove:C,onWheel:E,...f,...v?{"data-pending-scroll":""}:null,children:t})}function Au({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:o,...s}){let{handleContentChange:i,handleResize:c,setContentElement:a,setSpacerElement:l}=nn(),f=y.useRef(null),u=y.useCallback(h=>{var g;f.current=h,a(h),(g=tn(n))==null||g(h)},[n,a]);return y.useLayoutEffect(()=>{let h=f.current;if(!h||(i(),typeof MutationObserver>"u"))return;let g=new MutationObserver(()=>{i()});return g.observe(h,{childList:!0}),()=>g.disconnect()},[i]),y.useEffect(()=>{let h=f.current;if(!h||typeof ResizeObserver>"u")return;let g=0,d=new ResizeObserver(()=>{window.cancelAnimationFrame(g),g=window.requestAnimationFrame(c)});return d.observe(h),()=>{window.cancelAnimationFrame(g),d.disconnect()}},[c]),p.jsxs("div",{ref:u,role:r??"log","aria-relevant":e??"additions",...s,children:[t,p.jsx("div",{ref:l,"aria-hidden":"true","data-message-scroller-spacer":"",hidden:!0,className:o})]})}function Nu({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let o=Ou(),s=y.useRef(null),i=y.useCallback(c=>{var l;let a=s.current;s.current=c,e&&o(e,c,a),(l=tn(t))==null||l(c)},[e,t,o]);return p.jsx("div",{ref:i,"data-message-id":e,"data-scroll-anchor":n?"true":"false",...r})}function ju({behavior:e="smooth",children:t,direction:n="end",onClick:r,render:o,tabIndex:s,type:i="button",...c}){let{scrollToEnd:a,scrollToStart:l,stateStore:f}=nn(),u=Pu(r),h=y.useCallback(b=>f.subscribe(b),[f]),g=y.useCallback(()=>{let b=f.getSnapshot();return n==="start"?b.start:b.end},[n,f]),d=y.useSyncExternalStore(h,g,g),m=y.useCallback(b=>{var v;d&&((v=u.current)==null||v.call(u,b),b.defaultPrevented||(b.currentTarget.blur(),n==="start"?l({behavior:e}):a({behavior:e})))},[e,n,d,u,a,l]);return Ql({defaultTagName:"button",props:_r({type:i,inert:!d,tabIndex:d?s:-1,children:t??p.jsxs("span",{children:["Scroll to ",n]}),onClick:m},c),render:o,state:{active:d,direction:n},stateAttributesMapping:{active:b=>({"data-active":b?"true":"false"})}})}var Ft={Provider:Iu,Root:_u,Viewport:ku,Content:Au,Item:Nu,Button:ju};function Mu(e){return p.jsx(Ft.Provider,{...e})}function Du({className:e,...t}){return p.jsx(Ft.Root,{"data-slot":"message-scroller",className:ue("msg-scroller-root",e),...t})}function Fu({className:e,...t}){return p.jsx(Ft.Viewport,{"data-slot":"message-scroller-viewport",className:ue("msg-scroller-viewport",e),...t})}function Lu({className:e,...t}){return p.jsx(Ft.Content,{"data-slot":"message-scroller-content",className:ue("msg-scroller-content",e),...t})}function cs({className:e,scrollAnchor:t=!1,...n}){return p.jsx(Ft.Item,{"data-slot":"message-scroller-item",scrollAnchor:t,className:ue("msg-scroller-item",e),...n})}function Bu({direction:e="end",className:t,children:n,...r}){return p.jsx(Ft.Button,{"data-slot":"message-scroller-button",direction:e,className:ue("msg-scroller-btn",t),...r,children:n??p.jsxs(p.Fragment,{children:[p.jsx(fa,{size:16,"aria-hidden":"true",className:e==="start"?"rotate-180":void 0}),p.jsx("span",{className:"sr-only",children:e==="end"?"Jump to latest":"Jump to start"})]})})}function Ar({align:e="start",variant:t="muted",className:n,...r}){return p.jsx("div",{...r,"data-slot":"bubble","data-align":e,"data-variant":t,className:ue("chat-bubble",n)})}function Nr({className:e,...t}){return p.jsx("div",{...t,"data-slot":"bubble-content",className:ue("chat-bubble-content",e)})}const Vu=()=>p.jsxs(Jr,{children:[p.jsx(oi,{className:"avatar-circle","aria-hidden":"true",children:p.jsx(Js,{size:15})}),p.jsx(Zr,{children:p.jsx(Ar,{children:p.jsx(Nr,{children:"Hello — I am the VPS Veritas assistant. Ask about reports, sample status, registration, or support, or choose a suggested question."})})})]});function $i(){const[e,t]=I.useState("idle");I.useEffect(()=>{if(e!=="copied")return;const r=window.setTimeout(()=>t("idle"),2e3);return()=>window.clearTimeout(r)},[e]);async function n(r){t("copying");try{await navigator.clipboard.writeText(r),t("copied")}catch{t("failed")}}return{status:e,copy:n}}function $u({message:e,onFeedback:t}){const{status:n,copy:r}=$i();return p.jsxs("div",{className:"chat-message-actions",role:"group","aria-label":"Response actions",children:[p.jsx("button",{type:"button",className:"chat-message-action","aria-label":"Copy response",title:"Copy response",disabled:n==="copying",onClick:()=>void r(e.content),children:n==="copied"?p.jsx(Xr,{size:16,"aria-hidden":"true"}):p.jsx(ei,{size:16,"aria-hidden":"true"})}),p.jsx("button",{type:"button",className:"chat-message-action","aria-label":"Like response",title:"Like response","aria-pressed":e.feedback==="like",onClick:()=>t(e.id,"like"),children:p.jsx(Pa,{size:16,"aria-hidden":"true"})}),p.jsx("button",{type:"button",className:"chat-message-action","aria-label":"Dislike response",title:"Dislike response","aria-pressed":e.feedback==="dislike",onClick:()=>t(e.id,"dislike"),children:p.jsx(Ta,{size:16,"aria-hidden":"true"})}),p.jsxs("span",{className:"chat-message-copy-status",role:"status",children:[n==="copied"&&"Copied",n==="failed"&&"Couldn’t copy"]})]})}function ho(e){const t=e.trim();if(!/[\u0000-\u001f\u007f]/.test(t)&&/^(https?:\/\/|mailto:|\/(?!\/)|#)/i.test(t))return t}function Hu(e){return Object.prototype.toString.call(e)==="[object Object]"}function as(e){return Hu(e)||Array.isArray(e)}function Uu(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}function go(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;const o=JSON.stringify(Object.keys(e.breakpoints||{})),s=JSON.stringify(Object.keys(t.breakpoints||{}));return o!==s?!1:n.every(i=>{const c=e[i],a=t[i];return typeof c=="function"?`${c}`==`${a}`:!as(c)||!as(a)?c===a:go(c,a)})}function ls(e){return e.concat().sort((t,n)=>t.name>n.name?1:-1).map(t=>t.options)}function zu(e,t){if(e.length!==t.length)return!1;const n=ls(e),r=ls(t);return n.every((o,s)=>{const i=r[s];return go(o,i)})}function mo(e){return typeof e=="number"}function jr(e){return typeof e=="string"}function Qn(e){return typeof e=="boolean"}function us(e){return Object.prototype.toString.call(e)==="[object Object]"}function we(e){return Math.abs(e)}function bo(e){return Math.sign(e)}function Wt(e,t){return we(e-t)}function Wu(e,t){if(e===0||t===0||we(e)<=we(t))return 0;const n=Wt(we(e),we(t));return we(n/e)}function qu(e){return Math.round(e*100)/100}function Xt(e){return Jt(e).map(Number)}function Ge(e){return e[rn(e)]}function rn(e){return Math.max(0,e.length-1)}function vo(e,t){return t===rn(e)}function fs(e,t=0){return Array.from(Array(e),(n,r)=>t+r)}function Jt(e){return Object.keys(e)}function Hi(e,t){return[e,t].reduce((n,r)=>(Jt(r).forEach(o=>{const s=n[o],i=r[o],c=us(s)&&us(i);n[o]=c?Hi(s,i):i}),n),{})}function Mr(e,t){return typeof t.MouseEvent<"u"&&e instanceof t.MouseEvent}function Gu(e,t){const n={start:r,center:o,end:s};function r(){return 0}function o(a){return s(a)/2}function s(a){return t-a}function i(a,l){return jr(e)?n[e](a):e(t,a,l)}return{measure:i}}function Zt(){let e=[];function t(o,s,i,c={passive:!0}){let a;if("addEventListener"in o)o.addEventListener(s,i,c),a=()=>o.removeEventListener(s,i,c);else{const l=o;l.addListener(i),a=()=>l.removeListener(i)}return e.push(a),r}function n(){e=e.filter(o=>o())}const r={add:t,clear:n};return r}function Ku(e,t,n,r){const o=Zt(),s=1e3/60;let i=null,c=0,a=0;function l(){o.add(e,"visibilitychange",()=>{e.hidden&&d()})}function f(){g(),o.clear()}function u(b){if(!a)return;i||(i=b,n(),n());const v=b-i;for(i=b,c+=v;c>=s;)n(),c-=s;const x=c/s;r(x),a&&(a=t.requestAnimationFrame(u))}function h(){a||(a=t.requestAnimationFrame(u))}function g(){t.cancelAnimationFrame(a),i=null,c=0,a=0}function d(){i=null,c=0}return{init:l,destroy:f,start:h,stop:g,update:n,render:r}}function Yu(e,t){const n=t==="rtl",r=e==="y",o=r?"y":"x",s=r?"x":"y",i=!r&&n?-1:1,c=f(),a=u();function l(d){const{height:m,width:b}=d;return r?m:b}function f(){return r?"top":n?"right":"left"}function u(){return r?"bottom":n?"left":"right"}function h(d){return d*i}return{scroll:o,cross:s,startEdge:c,endEdge:a,measureSize:l,direction:h}}function Et(e=0,t=0){const n=we(e-t);function r(l){return l<e}function o(l){return l>t}function s(l){return r(l)||o(l)}function i(l){return s(l)?r(l)?e:t:l}function c(l){return n?l-n*Math.ceil((l-t)/n):l}return{length:n,max:t,min:e,constrain:i,reachedAny:s,reachedMax:o,reachedMin:r,removeOffset:c}}function Ui(e,t,n){const{constrain:r}=Et(0,e),o=e+1;let s=i(t);function i(h){return n?we((o+h)%o):r(h)}function c(){return s}function a(h){return s=i(h),u}function l(h){return f().set(c()+h)}function f(){return Ui(e,c(),n)}const u={get:c,set:a,add:l,clone:f};return u}function Xu(e,t,n,r,o,s,i,c,a,l,f,u,h,g,d,m,b,v,x){const{cross:S,direction:E}=e,C=["INPUT","SELECT","TEXTAREA"],w={passive:!1},R=Zt(),P=Zt(),O=Et(50,225).constrain(g.measure(20)),M={mouse:300,touch:400},F={mouse:500,touch:600},A=d?43:25;let D=!1,_=0,T=0,k=!1,U=!1,j=!1,N=!1;function Y(W){if(!x)return;function ne(ve){(Qn(x)||x(W,ve))&&B(ve)}const oe=t;R.add(oe,"dragstart",ve=>ve.preventDefault(),w).add(oe,"touchmove",()=>{},w).add(oe,"touchend",()=>{}).add(oe,"touchstart",ne).add(oe,"mousedown",ne).add(oe,"touchcancel",Q).add(oe,"contextmenu",Q).add(oe,"click",re,!0)}function K(){R.clear(),P.clear()}function le(){const W=N?n:t;P.add(W,"touchmove",$,w).add(W,"touchend",Q).add(W,"mousemove",$,w).add(W,"mouseup",Q)}function ie(W){const ne=W.nodeName||"";return C.includes(ne)}function L(){return(d?F:M)[N?"mouse":"touch"]}function X(W,ne){const oe=u.add(bo(W)*-1),ve=f.byDistance(W,!d).distance;return d||we(W)<O?ve:b&&ne?ve*.5:f.byIndex(oe.get(),0).distance}function B(W){const ne=Mr(W,r);N=ne,j=d&&ne&&!W.buttons&&D,D=Wt(o.get(),i.get())>=2,!(ne&&W.button!==0)&&(ie(W.target)||(k=!0,s.pointerDown(W),l.useFriction(0).useDuration(0),o.set(i),le(),_=s.readPoint(W),T=s.readPoint(W,S),h.emit("pointerDown")))}function $(W){if(!Mr(W,r)&&W.touches.length>=2)return Q(W);const oe=s.readPoint(W),ve=s.readPoint(W,S),z=Wt(oe,_),J=Wt(ve,T);if(!U&&!N&&(!W.cancelable||(U=z>J,!U)))return Q(W);const ce=s.pointerMove(W);z>m&&(j=!0),l.useFriction(.3).useDuration(.75),c.start(),o.add(E(ce)),W.preventDefault()}function Q(W){const oe=f.byDistance(0,!1).index!==u.get(),ve=s.pointerUp(W)*L(),z=X(E(ve),oe),J=Wu(ve,z),ce=A-10*J,he=v+J/50;U=!1,k=!1,P.clear(),l.useDuration(ce).useFriction(he),a.distance(z,!d),N=!1,h.emit("pointerUp")}function re(W){j&&(W.stopPropagation(),W.preventDefault(),j=!1)}function ee(){return k}return{init:Y,destroy:K,pointerDown:ee}}function Ju(e,t){let r,o;function s(u){return u.timeStamp}function i(u,h){const d=`client${(h||e.scroll)==="x"?"X":"Y"}`;return(Mr(u,t)?u:u.touches[0])[d]}function c(u){return r=u,o=u,i(u)}function a(u){const h=i(u)-i(o),g=s(u)-s(r)>170;return o=u,g&&(r=u),h}function l(u){if(!r||!o)return 0;const h=i(o)-i(r),g=s(u)-s(r),d=s(u)-s(o)>170,m=h/g;return g&&!d&&we(m)>.1?m:0}return{pointerDown:c,pointerMove:a,pointerUp:l,readPoint:i}}function Zu(){function e(n){const{offsetTop:r,offsetLeft:o,offsetWidth:s,offsetHeight:i}=n;return{top:r,right:o+s,bottom:r+i,left:o,width:s,height:i}}return{measure:e}}function Qu(e){function t(r){return e*(r/100)}return{measure:t}}function ef(e,t,n,r,o,s,i){const c=[e].concat(r);let a,l,f=[],u=!1;function h(b){return o.measureSize(i.measure(b))}function g(b){if(!s)return;l=h(e),f=r.map(h);function v(x){for(const S of x){if(u)return;const E=S.target===e,C=r.indexOf(S.target),w=E?l:f[C],R=h(E?e:r[C]);if(we(R-w)>=.5){b.reInit(),t.emit("resize");break}}}a=new ResizeObserver(x=>{(Qn(s)||s(b,x))&&v(x)}),n.requestAnimationFrame(()=>{c.forEach(x=>a.observe(x))})}function d(){u=!0,a&&a.disconnect()}return{init:g,destroy:d}}function tf(e,t,n,r,o,s){let i=0,c=0,a=o,l=s,f=e.get(),u=0;function h(){const w=r.get()-e.get(),R=!a;let P=0;return R?(i=0,n.set(r),e.set(r),P=w):(n.set(e),i+=w/a,i*=l,f+=i,e.add(i),P=f-u),c=bo(P),u=f,C}function g(){const w=r.get()-t.get();return we(w)<.001}function d(){return a}function m(){return c}function b(){return i}function v(){return S(o)}function x(){return E(s)}function S(w){return a=w,C}function E(w){return l=w,C}const C={direction:m,duration:d,velocity:b,seek:h,settled:g,useBaseFriction:x,useBaseDuration:v,useFriction:E,useDuration:S};return C}function nf(e,t,n,r,o){const s=o.measure(10),i=o.measure(50),c=Et(.1,.99);let a=!1;function l(){return!(a||!e.reachedAny(n.get())||!e.reachedAny(t.get()))}function f(g){if(!l())return;const d=e.reachedMin(t.get())?"min":"max",m=we(e[d]-t.get()),b=n.get()-t.get(),v=c.constrain(m/i);n.subtract(b*v),!g&&we(b)<s&&(n.set(e.constrain(n.get())),r.useDuration(25).useBaseFriction())}function u(g){a=!g}return{shouldConstrain:l,constrain:f,toggleActive:u}}function rf(e,t,n,r,o){const s=Et(-t+e,0),i=u(),c=f(),a=h();function l(d,m){return Wt(d,m)<=1}function f(){const d=i[0],m=Ge(i),b=i.lastIndexOf(d),v=i.indexOf(m)+1;return Et(b,v)}function u(){return n.map((d,m)=>{const{min:b,max:v}=s,x=s.constrain(d),S=!m,E=vo(n,m);return S?v:E||l(b,x)?b:l(v,x)?v:x}).map(d=>parseFloat(d.toFixed(3)))}function h(){if(t<=e+o)return[s.max];if(r==="keepSnaps")return i;const{min:d,max:m}=c;return i.slice(d,m)}return{snapsContained:a,scrollContainLimit:c}}function of(e,t,n){const r=t[0],o=n?r-e:Ge(t);return{limit:Et(o,r)}}function sf(e,t,n,r){const s=t.min+.1,i=t.max+.1,{reachedMin:c,reachedMax:a}=Et(s,i);function l(h){return h===1?a(n.get()):h===-1?c(n.get()):!1}function f(h){if(!l(h))return;const g=e*(h*-1);r.forEach(d=>d.add(g))}return{loop:f}}function cf(e){const{max:t,length:n}=e;function r(s){const i=s-t;return n?i/-n:0}return{get:r}}function af(e,t,n,r,o){const{startEdge:s,endEdge:i}=e,{groupSlides:c}=o,a=u().map(t.measure),l=h(),f=g();function u(){return c(r).map(m=>Ge(m)[i]-m[0][s]).map(we)}function h(){return r.map(m=>n[s]-m[s]).map(m=>-we(m))}function g(){return c(l).map(m=>m[0]).map((m,b)=>m+a[b])}return{snaps:l,snapsAligned:f}}function lf(e,t,n,r,o,s){const{groupSlides:i}=o,{min:c,max:a}=r,l=f();function f(){const h=i(s),g=!e||t==="keepSnaps";return n.length===1?[s]:g?h:h.slice(c,a).map((d,m,b)=>{const v=!m,x=vo(b,m);if(v){const S=Ge(b[0])+1;return fs(S)}if(x){const S=rn(s)-Ge(b)[0]+1;return fs(S,Ge(b)[0])}return d})}return{slideRegistry:l}}function uf(e,t,n,r,o){const{reachedAny:s,removeOffset:i,constrain:c}=r;function a(d){return d.concat().sort((m,b)=>we(m)-we(b))[0]}function l(d){const m=e?i(d):c(d),b=t.map((x,S)=>({diff:f(x-m,0),index:S})).sort((x,S)=>we(x.diff)-we(S.diff)),{index:v}=b[0];return{index:v,distance:m}}function f(d,m){const b=[d,d+n,d-n];if(!e)return d;if(!m)return a(b);const v=b.filter(x=>bo(x)===m);return v.length?a(v):Ge(b)-n}function u(d,m){const b=t[d]-o.get(),v=f(b,m);return{index:d,distance:v}}function h(d,m){const b=o.get()+d,{index:v,distance:x}=l(b),S=!e&&s(b);if(!m||S)return{index:v,distance:d};const E=t[v]-x,C=d+f(E,0);return{index:v,distance:C}}return{byDistance:h,byIndex:u,shortcut:f}}function ff(e,t,n,r,o,s,i){function c(u){const h=u.distance,g=u.index!==t.get();s.add(h),h&&(r.duration()?e.start():(e.update(),e.render(1),e.update())),g&&(n.set(t.get()),t.set(u.index),i.emit("select"))}function a(u,h){const g=o.byDistance(u,h);c(g)}function l(u,h){const g=t.clone().set(u),d=o.byIndex(g.get(),h);c(d)}return{distance:a,index:l}}function df(e,t,n,r,o,s,i,c){const a={passive:!0,capture:!0};let l=0;function f(g){if(!c)return;function d(m){if(new Date().getTime()-l>10)return;i.emit("slideFocusStart"),e.scrollLeft=0;const x=n.findIndex(S=>S.includes(m));mo(x)&&(o.useDuration(0),r.index(x,0),i.emit("slideFocus"))}s.add(document,"keydown",u,!1),t.forEach((m,b)=>{s.add(m,"focus",v=>{(Qn(c)||c(g,v))&&d(b)},a)})}function u(g){g.code==="Tab"&&(l=new Date().getTime())}return{init:f}}function Ut(e){let t=e;function n(){return t}function r(a){t=i(a)}function o(a){t+=i(a)}function s(a){t-=i(a)}function i(a){return mo(a)?a:a.get()}return{get:n,set:r,add:o,subtract:s}}function zi(e,t){const n=e.scroll==="x"?i:c,r=t.style;let o=null,s=!1;function i(h){return`translate3d(${h}px,0px,0px)`}function c(h){return`translate3d(0px,${h}px,0px)`}function a(h){if(s)return;const g=qu(e.direction(h));g!==o&&(r.transform=n(g),o=g)}function l(h){s=!h}function f(){s||(r.transform="",t.getAttribute("style")||t.removeAttribute("style"))}return{clear:f,to:a,toggleActive:l}}function pf(e,t,n,r,o,s,i,c,a){const f=Xt(o),u=Xt(o).reverse(),h=v().concat(x());function g(R,P){return R.reduce((O,M)=>O-o[M],P)}function d(R,P){return R.reduce((O,M)=>g(O,P)>0?O.concat([M]):O,[])}function m(R){return s.map((P,O)=>({start:P-r[O]+.5+R,end:P+t-.5+R}))}function b(R,P,O){const M=m(P);return R.map(F=>{const A=O?0:-n,D=O?n:0,_=O?"end":"start",T=M[F][_];return{index:F,loopPoint:T,slideLocation:Ut(-1),translate:zi(e,a[F]),target:()=>c.get()>T?A:D}})}function v(){const R=i[0],P=d(u,R);return b(P,n,!1)}function x(){const R=t-i[0]-1,P=d(f,R);return b(P,-n,!0)}function S(){return h.every(({index:R})=>{const P=f.filter(O=>O!==R);return g(P,t)<=.1})}function E(){h.forEach(R=>{const{target:P,translate:O,slideLocation:M}=R,F=P();F!==M.get()&&(O.to(F),M.set(F))})}function C(){h.forEach(R=>R.translate.clear())}return{canLoop:S,clear:C,loop:E,loopPoints:h}}function hf(e,t,n){let r,o=!1;function s(a){if(!n)return;function l(f){for(const u of f)if(u.type==="childList"){a.reInit(),t.emit("slidesChanged");break}}r=new MutationObserver(f=>{o||(Qn(n)||n(a,f))&&l(f)}),r.observe(e,{childList:!0})}function i(){r&&r.disconnect(),o=!0}return{init:s,destroy:i}}function gf(e,t,n,r){const o={};let s=null,i=null,c,a=!1;function l(){c=new IntersectionObserver(d=>{a||(d.forEach(m=>{const b=t.indexOf(m.target);o[b]=m}),s=null,i=null,n.emit("slidesInView"))},{root:e.parentElement,threshold:r}),t.forEach(d=>c.observe(d))}function f(){c&&c.disconnect(),a=!0}function u(d){return Jt(o).reduce((m,b)=>{const v=parseInt(b),{isIntersecting:x}=o[v];return(d&&x||!d&&!x)&&m.push(v),m},[])}function h(d=!0){if(d&&s)return s;if(!d&&i)return i;const m=u(d);return d&&(s=m),d||(i=m),m}return{init:l,destroy:f,get:h}}function mf(e,t,n,r,o,s){const{measureSize:i,startEdge:c,endEdge:a}=e,l=n[0]&&o,f=d(),u=m(),h=n.map(i),g=b();function d(){if(!l)return 0;const x=n[0];return we(t[c]-x[c])}function m(){if(!l)return 0;const x=s.getComputedStyle(Ge(r));return parseFloat(x.getPropertyValue(`margin-${a}`))}function b(){return n.map((x,S,E)=>{const C=!S,w=vo(E,S);return C?h[S]+f:w?h[S]+u:E[S+1][c]-x[c]}).map(we)}return{slideSizes:h,slideSizesWithGaps:g,startGap:f,endGap:u}}function bf(e,t,n,r,o,s,i,c,a){const{startEdge:l,endEdge:f,direction:u}=e,h=mo(n);function g(v,x){return Xt(v).filter(S=>S%x===0).map(S=>v.slice(S,S+x))}function d(v){return v.length?Xt(v).reduce((x,S,E)=>{const C=Ge(x)||0,w=C===0,R=S===rn(v),P=o[l]-s[C][l],O=o[l]-s[S][f],M=!r&&w?u(i):0,F=!r&&R?u(c):0,A=we(O-F-(P+M));return E&&A>t+a&&x.push(S),R&&x.push(v.length),x},[]).map((x,S,E)=>{const C=Math.max(E[S-1]||0);return v.slice(C,x)}):[]}function m(v){return h?g(v,n):d(v)}return{groupSlides:m}}function vf(e,t,n,r,o,s,i){const{align:c,axis:a,direction:l,startIndex:f,loop:u,duration:h,dragFree:g,dragThreshold:d,inViewThreshold:m,slidesToScroll:b,skipSnaps:v,containScroll:x,watchResize:S,watchSlides:E,watchDrag:C,watchFocus:w}=s,R=2,P=Zu(),O=P.measure(t),M=n.map(P.measure),F=Yu(a,l),A=F.measureSize(O),D=Qu(A),_=Gu(c,A),T=!u&&!!x,k=u||!!x,{slideSizes:U,slideSizesWithGaps:j,startGap:N,endGap:Y}=mf(F,O,M,n,k,o),K=bf(F,A,b,u,O,M,N,Y,R),{snaps:le,snapsAligned:ie}=af(F,_,O,M,K),L=-Ge(le)+Ge(j),{snapsContained:X,scrollContainLimit:B}=rf(A,L,ie,x,R),$=T?X:ie,{limit:Q}=of(L,$,u),re=Ui(rn($),f,u),ee=re.clone(),te=Xt(n),W=({dragHandler:V,scrollBody:q,scrollBounds:Z,options:{loop:se}})=>{se||Z.constrain(V.pointerDown()),q.seek()},ne=({scrollBody:V,translate:q,location:Z,offsetLocation:se,previousLocation:ke,scrollLooper:Ce,slideLooper:Ct,dragHandler:st,animation:Rt,eventHandler:Ze,scrollBounds:Qe,options:{loop:ht}},gt)=>{const Lt=V.settled(),an=!Qe.shouldConstrain(),Bt=ht?Lt:Lt&&an,Vt=Bt&&!st.pointerDown();Vt&&Rt.stop();const ln=Z.get()*gt+ke.get()*(1-gt);se.set(ln),ht&&(Ce.loop(V.direction()),Ct.loop()),q.to(se.get()),Vt&&Ze.emit("settle"),Bt||Ze.emit("scroll")},oe=Ku(r,o,()=>W(ge),V=>ne(ge,V)),ve=.68,z=$[re.get()],J=Ut(z),ce=Ut(z),he=Ut(z),Oe=Ut(z),je=tf(J,he,ce,Oe,h,ve),Re=uf(u,$,L,Q,Oe),Me=ff(oe,re,ee,je,Re,Oe,i),Be=cf(Q),H=Zt(),G=gf(t,n,i,m),{slideRegistry:Se}=lf(T,x,$,B,K,te),be=df(e,n,Se,Me,je,H,i,w),ge={ownerDocument:r,ownerWindow:o,eventHandler:i,containerRect:O,slideRects:M,animation:oe,axis:F,dragHandler:Xu(F,e,r,o,Oe,Ju(F,o),J,oe,Me,je,Re,re,i,D,g,d,v,ve,C),eventStore:H,percentOfView:D,index:re,indexPrevious:ee,limit:Q,location:J,offsetLocation:he,previousLocation:ce,options:s,resizeHandler:ef(t,i,o,n,F,S,P),scrollBody:je,scrollBounds:nf(Q,he,Oe,je,D),scrollLooper:sf(L,Q,he,[J,he,ce,Oe]),scrollProgress:Be,scrollSnapList:$.map(Be.get),scrollSnaps:$,scrollTarget:Re,scrollTo:Me,slideLooper:pf(F,A,L,U,j,le,$,he,n),slideFocus:be,slidesHandler:hf(t,i,E),slidesInView:G,slideIndexes:te,slideRegistry:Se,slidesToScroll:K,target:Oe,translate:zi(F,t)};return ge}function yf(){let e={},t;function n(l){t=l}function r(l){return e[l]||[]}function o(l){return r(l).forEach(f=>f(t,l)),a}function s(l,f){return e[l]=r(l).concat([f]),a}function i(l,f){return e[l]=r(l).filter(u=>u!==f),a}function c(){e={}}const a={init:n,emit:o,off:i,on:s,clear:c};return a}const xf={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function Ef(e){function t(s,i){return Hi(s,i||{})}function n(s){const i=s.breakpoints||{},c=Jt(i).filter(a=>e.matchMedia(a).matches).map(a=>i[a]).reduce((a,l)=>t(a,l),{});return t(s,c)}function r(s){return s.map(i=>Jt(i.breakpoints||{})).reduce((i,c)=>i.concat(c),[]).map(e.matchMedia)}return{mergeOptions:t,optionsAtMedia:n,optionsMediaQueries:r}}function Sf(e){let t=[];function n(s,i){return t=i.filter(({options:c})=>e.optionsAtMedia(c).active!==!1),t.forEach(c=>c.init(s,e)),i.reduce((c,a)=>Object.assign(c,{[a.name]:a}),{})}function r(){t=t.filter(s=>s.destroy())}return{init:n,destroy:r}}function Dn(e,t,n){const r=e.ownerDocument,o=r.defaultView,s=Ef(o),i=Sf(s),c=Zt(),a=yf(),{mergeOptions:l,optionsAtMedia:f,optionsMediaQueries:u}=s,{on:h,off:g,emit:d}=a,m=F;let b=!1,v,x=l(xf,Dn.globalOptions),S=l(x),E=[],C,w,R;function P(){const{container:te,slides:W}=S;w=(jr(te)?e.querySelector(te):te)||e.children[0];const oe=jr(W)?w.querySelectorAll(W):W;R=[].slice.call(oe||w.children)}function O(te){const W=vf(e,w,R,r,o,te,a);if(te.loop&&!W.slideLooper.canLoop()){const ne=Object.assign({},te,{loop:!1});return O(ne)}return W}function M(te,W){b||(x=l(x,te),S=f(x),E=W||E,P(),v=O(S),u([x,...E.map(({options:ne})=>ne)]).forEach(ne=>c.add(ne,"change",F)),S.active&&(v.translate.to(v.location.get()),v.animation.init(),v.slidesInView.init(),v.slideFocus.init(ee),v.eventHandler.init(ee),v.resizeHandler.init(ee),v.slidesHandler.init(ee),v.options.loop&&v.slideLooper.loop(),w.offsetParent&&R.length&&v.dragHandler.init(ee),C=i.init(ee,E)))}function F(te,W){const ne=K();A(),M(l({startIndex:ne},te),W),a.emit("reInit")}function A(){v.dragHandler.destroy(),v.eventStore.clear(),v.translate.clear(),v.slideLooper.clear(),v.resizeHandler.destroy(),v.slidesHandler.destroy(),v.slidesInView.destroy(),v.animation.destroy(),i.destroy(),c.clear()}function D(){b||(b=!0,c.clear(),A(),a.emit("destroy"),a.clear())}function _(te,W,ne){!S.active||b||(v.scrollBody.useBaseFriction().useDuration(W===!0?0:S.duration),v.scrollTo.index(te,ne||0))}function T(te){const W=v.index.add(1).get();_(W,te,-1)}function k(te){const W=v.index.add(-1).get();_(W,te,1)}function U(){return v.index.add(1).get()!==K()}function j(){return v.index.add(-1).get()!==K()}function N(){return v.scrollSnapList}function Y(){return v.scrollProgress.get(v.offsetLocation.get())}function K(){return v.index.get()}function le(){return v.indexPrevious.get()}function ie(){return v.slidesInView.get()}function L(){return v.slidesInView.get(!1)}function X(){return C}function B(){return v}function $(){return e}function Q(){return w}function re(){return R}const ee={canScrollNext:U,canScrollPrev:j,containerNode:Q,internalEngine:B,destroy:D,off:g,on:h,emit:d,plugins:X,previousScrollSnap:le,reInit:m,rootNode:$,scrollNext:T,scrollPrev:k,scrollProgress:Y,scrollSnapList:N,scrollTo:_,selectedScrollSnap:K,slideNodes:re,slidesInView:ie,slidesNotInView:L};return M(t,n),setTimeout(()=>a.emit("init"),0),ee}Dn.globalOptions=void 0;function yo(e={},t=[]){const n=I.useRef(e),r=I.useRef(t),[o,s]=I.useState(),[i,c]=I.useState(),a=I.useCallback(()=>{o&&o.reInit(n.current,r.current)},[o]);return I.useEffect(()=>{go(n.current,e)||(n.current=e,a())},[e,a]),I.useEffect(()=>{zu(r.current,t)||(r.current=t,a())},[t,a]),I.useEffect(()=>{if(Uu()&&i){Dn.globalOptions=yo.globalOptions;const l=Dn(i,n.current,r.current);return s(l),()=>l.destroy()}else s(void 0)},[i,s]),[c,o]}yo.globalOptions=void 0;const Dr=[];let Fr;function wf(){return Fr}function Cf(e){Dr.push(e)}function Wi(e){const t=(n,r)=>{const o=Ye(Tf).current;let s;try{Fr=o;for(const i of Dr)i.before(o);s=e(n,r);for(const i of Dr)i.after(o);o.didInitialize=!0}finally{Fr=void 0}return s};return t.displayName=e.displayName||e.name,t}function Rf(e){return y.forwardRef(Wi(e))}function Tf(){return{didInitialize:!1}}function Pf(){if(typeof navigator>"u")return{userAgent:"",platform:"",maxTouchPoints:0};if(process.env.NODE_ENV!=="production"){const e=navigator.userAgentData;if(e&&Array.isArray(e.brands))return{userAgent:e.brands.map(({brand:t,version:n})=>`${t}/${n}`).join(" "),platform:e.platform??navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}return{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:Of,platform:If,maxTouchPoints:_f}=Pf(),er=Of.toLowerCase(),Qt=If.toLowerCase(),qi=/^i(os$|p)/.test(Qt)||Qt==="macintel"&&_f>1,ds="android",kf=Qt===ds||er.includes(ds),Gi=!qi&&Qt.startsWith("mac");Qt.startsWith("win");const Af=Gi||qi;var Us;const on=typeof CSS<"u"&&!!((Us=CSS.supports)!=null&&Us.call(CSS,"-webkit-backdrop-filter:none"));!on&&er.includes("firefox");!on&&er.includes("chrom");const Nf=Af,jf=/jsdom|happydom/.test(er);function Mf(e){return"nativeEvent"in e}function Df(e){return e.pointerType===""&&e.isTrusted?!0:kf&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Lr(e,t){const n=["mouse","pen"];return n.push("",void 0),n.includes(e)}function Ff(e){const t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}function Br(e){var n;let t=e.activeElement;for(;((n=t==null?void 0:t.shadowRoot)==null?void 0:n.activeElement)!=null;)t=t.shadowRoot.activeElement;return t}function Te(e,t){var r;if(!e||!t)return!1;const n=(r=t.getRootNode)==null?void 0:r.call(t);if(e.contains(t))return!0;if(n&&At(n)){let o=t;for(;o;){if(e===o)return!0;o=o.parentNode||o.host}}return!1}function Vr(e,t){let n=e;for(;n;){if(me(n)&&n.matches(t))return n;n=n.assignedSlot??n.parentNode??(At(n)?n.host:null)}return null}function vt(e){return"composedPath"in e?e.composedPath()[0]??e.target:e.target}const Lf="data-base-ui-focusable",Ki="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Bf="data-open",Vf="data-closed",$f="data-anchor-hidden",Hf="data-popup-open",Uf={[Hf]:""},zf={[Bf]:""},Wf={[Vf]:""},qf={[$f]:""},Gf={open(e){return e?Uf:null}},Yi={open(e){return e?zf:Wf},anchorHidden(e){return e?qf:null}},Kf={...Yi,...io},ps="data-trigger-disabled";function Fn(e,t){if(!me(e))return!1;const n=e;if(t.hasElement(n))return!n.hasAttribute(ps);for(const[,r]of t.entries())if(Te(r,n))return!r.hasAttribute(ps);return!1}function pr(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 Yf(e){return e.matches("html,body")}function Xf(e){return _e(e)&&e.matches(Ki)}function Jf(e){return Vr(e,`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${Ki}`)!=null}function Zf(e){if(!e||jf)return!0;try{return e.matches(":focus-visible")}catch{return!0}}function Qf(e,t){return t!=null&&!Lr(t)?0:typeof e=="function"?e():e}function $r(e,t,n){const r=Qf(e,n);return typeof r=="number"?r:r==null?void 0:r[t]}function hs(e){return typeof e=="function"?e():e}function Xi(e,t){return t||e==="click"||e==="mousedown"}function ed(e){return(e==null?void 0:e.includes("mouse"))&&e!=="mousedown"}function at(...e){return()=>{for(let t=0;t<e.length;t+=1){const n=e[t];n&&n()}}}const td={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},nd={...td,position:"fixed",margin:0,top:0,left:0},Hr=y.forwardRef(function(t,n){const[r,o]=y.useState();pe(()=>{Nf&&on&&o("button")},[]);const s={tabIndex:0,role:r};return p.jsx("span",{...t,ref:n,style:nd,"aria-hidden":r?void 0:!0,...s,"data-base-ui-focus-guard":""})});process.env.NODE_ENV!=="production"&&(Hr.displayName="FocusGuard");const Mt=Math.min,nt=Math.max,Ln=Math.round,yn=Math.floor,rt=e=>({x:e,y:e}),rd={left:"right",right:"left",bottom:"top",top:"bottom"};function Ji(e,t,n){return nt(e,Mt(t,n))}function ft(e,t){return typeof e=="function"?e(t):e}function Ve(e){return e.split("-")[0]}function Je(e){return e.split("-")[1]}function xo(e){return e==="x"?"y":"x"}function Eo(e){return e==="y"?"height":"width"}function Ue(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function So(e){return xo(Ue(e))}function od(e,t,n){n===void 0&&(n=!1);const r=Je(e),o=So(e),s=Eo(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Bn(i)),[i,Bn(i)]}function sd(e){const t=Bn(e);return[Ur(e),t,Ur(t)]}function Ur(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const gs=["left","right"],ms=["right","left"],id=["top","bottom"],cd=["bottom","top"];function ad(e,t,n){switch(e){case"top":case"bottom":return n?t?ms:gs:t?gs:ms;case"left":case"right":return t?id:cd;default:return[]}}function ld(e,t,n,r){const o=Je(e);let s=ad(Ve(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ur)))),s}function Bn(e){const t=Ve(e);return rd[t]+e.slice(t.length)}function ud(e){var t,n,r,o;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(o=e.left)!=null?o:0}}function Zi(e){return typeof e!="number"?ud(e):{top:e,right:e,bottom:e,left:e}}function Vn(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function fd(e){return e.visibility==="hidden"||e.visibility==="collapse"}function dd(e,t=e?$e(e):null){return!e||!e.isConnected||!t||fd(t)?!1:typeof e.checkVisibility=="function"?e.checkVisibility():t.display!=="none"&&t.display!=="contents"}const pd='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function hd(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.getRootNode();return At(n)?n.host:null}function zr(e){for(const t of Array.from(e.children))if(Le(t)==="summary")return t;return null}function gd(e,t){const n=zr(t);return!!n&&(e===n||Te(n,e))}function Qi(e){const t=e?Le(e):"";return e!=null&&e.matches(pd)&&(t!=="summary"||e.parentElement!=null&&Le(e.parentElement)==="details"&&zr(e.parentElement)===e)&&(t!=="details"||zr(e)==null)&&(t!=="input"||e.type!=="hidden")}function md(e){if(!Qi(e)||!e.isConnected||e.matches(":disabled"))return!1;for(let t=e;t;t=hd(t)){const n=t!==e,r=Le(t)==="slot";if(t.hasAttribute("inert")||n&&Le(t)==="details"&&!t.open&&!gd(e,t)||t.hasAttribute("hidden")||!r&&!bd(t,n))return!1}return!0}function bd(e,t){const n=$e(e);return t?n.display!=="none":dd(e,n)}function vd(e){const t=e.tabIndex;if(t<0){const n=Le(e);if(n==="details"||n==="audio"||n==="video"||_e(e)&&e.isContentEditable)return 0}return t}function hr(e){if(Le(e)!=="input")return null;const t=e;return t.type==="radio"&&t.name!==""?t:null}function yd(e,t){const n=hr(e);if(!n)return!0;const r=t.find(o=>{const s=hr(o);return(s==null?void 0:s.name)===n.name&&s.form===n.form&&s.checked});return r?r===n:t.find(o=>{const s=hr(o);return(s==null?void 0:s.name)===n.name&&s.form===n.form})===n}function ec(e){if(_e(e)&&Le(e)==="slot"){const t=e.assignedElements({flatten:!0});if(t.length>0)return t}return _e(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function tc(e,t){ec(e).forEach(n=>{Qi(n)&&t.push(n),tc(n,t)})}function nc(e,t,n){ec(e).forEach(r=>{_e(r)&&r.matches(t)&&n.push(r),nc(r,t,n)})}function xd(e){const t=[];return tc(e,t),t.filter(md)}function rc(e){const t=xd(e);return t.filter(n=>vd(n)>=0&&yd(n,t))}function oc(e,t){const n=rc(e),r=n.length;if(r===0)return;const o=Br(Ke(e)),s=n.indexOf(o),i=s===-1?t===1?0:r-1:s+t;return n[i]}function Ed(e){return oc(Ke(e).body,1)||e}function Sd(e){return oc(Ke(e).body,-1)||e}function gr(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!Te(n,r)}function wd(e){rc(e).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function bs(e){const t=[];nc(e,"[data-tabindex]",t),t.forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}function Dt(e,t,n=!0){return e.filter(o=>o.parentId===t).flatMap(o=>{var s;return[...!n||(s=o.context)!=null&&s.open?[o]:[],...Dt(e,o.id,n)]})}function wo(e){return`data-base-ui-${e}`}const Cd={style:{transition:"none"}},Rd={fallbackAxisSide:"end"},Td={clipPath:"inset(50%)",position:"fixed",top:0,left:0},Co=y.createContext(null);process.env.NODE_ENV!=="production"&&(Co.displayName="PortalContext");const Pd=()=>y.useContext(Co),Od=wo("portal");function sc(e={}){const{ref:t,container:n,componentProps:r=Fe,elementProps:o}=e,s=Gn(),i=Pd(),c=i==null?void 0:i.portalNode,[a,l]=y.useState(null),[f,u]=y.useState(null),h=fe(b=>{b!==null&&u(b)}),g=y.useRef(null);pe(()=>{if(n===null){g.current&&(g.current=null,u(null),l(null));return}const b=(n&&(co(n)?n:n.current))??c??document.body;if(b==null){g.current&&(g.current=null,u(null),l(null));return}g.current!==b&&(g.current=b,u(null),l(b))},[n,c]);const d=pt("div",r,{ref:[t,h],props:[{id:s,[Od]:""},o]}),m=a&&d?dt.createPortal(d,a):null;return{node:f,nodeId:y.isValidElement(d)?d.props.id:void 0,subtree:m}}const Id=y.forwardRef(function(t,n){const{render:r,className:o,style:s,children:i,container:c,portalOwnerRole:a,...l}=t,{node:f,nodeId:u,subtree:h}=sc({container:c,ref:n,componentProps:t,elementProps:l}),g=y.useRef(null),d=y.useRef(null),m=y.useRef(null),b=y.useRef(null),[v,x]=y.useState(null),S=y.useRef(!1),E=v==null?void 0:v.modal,C=v==null?void 0:v.open,w=!!v&&!v.modal&&v.open&&!!f;y.useEffect(()=>{if(!f||E)return;function P(O){f&&O.relatedTarget&&gr(O)&&(O.type==="focusin"?S.current&&(bs(f),S.current=!1):(wd(f),S.current=!0))}return at(Ee(f,"focusin",P,!0),Ee(f,"focusout",P,!0))},[f,E]),pe(()=>{!f||C!==!0||!S.current||(bs(f),S.current=!1)},[C,f]);const R=y.useMemo(()=>({beforeOutsideRef:g,afterOutsideRef:d,beforeInsideRef:m,afterInsideRef:b,portalNode:f,setFocusManagerState:x}),[f]);return p.jsxs(y.Fragment,{children:[h,p.jsxs(Co.Provider,{value:R,children:[w&&f&&p.jsx(Hr,{"data-type":"outside",ref:g,onFocus:P=>{var O;if(gr(P,f))(O=m.current)==null||O.focus();else{const M=v?v.domReference:null,F=Sd(M);F==null||F.focus()}}}),w&&f&&p.jsx("span",{role:a,"aria-owns":u,style:Td}),f&&dt.createPortal(i,f),w&&f&&p.jsx(Hr,{"data-type":"outside",ref:d,onFocus:P=>{var O;if(gr(P,f))(O=b.current)==null||O.focus();else{const M=v?v.domReference:null,F=Ed(M);F==null||F.focus(),v!=null&&v.closeOnFocusOut&&(v==null||v.onOpenChange(!1,Pe(sl,P.nativeEvent)))}}})]})]})});process.env.NODE_ENV!=="production"&&(Id.displayName="FloatingPortal");function ic(){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)}}}class _d{constructor(){ae(this,"nodesRef",{current:[]});ae(this,"events",ic())}addNode(t){this.nodesRef.current.push(t)}removeNode(t){const n=this.nodesRef.current.findIndex(r=>r===t);n!==-1&&this.nodesRef.current.splice(n,1)}}const Ro=y.createContext(null);process.env.NODE_ENV!=="production"&&(Ro.displayName="FloatingNodeContext");const To=y.createContext(null);process.env.NODE_ENV!=="production"&&(To.displayName="FloatingTreeContext");const tr=()=>{var e;return((e=y.useContext(Ro))==null?void 0:e.id)||null},sn=e=>{const t=y.useContext(To);return e??t};function kd(e){const t=Gn(),n=sn(e),r=tr();return pe(()=>{if(!t)return;const o={id:t,parentId:r};return n==null||n.addNode(o),()=>{n==null||n.removeNode(o)}},[n,t,r]),t}function Ad(e){const{children:t,id:n}=e,r=tr();return p.jsx(Ro.Provider,{value:y.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Nd(e){const{children:t,externalTree:n}=e,r=Ye(()=>n??new _d).current;return p.jsx(To.Provider,{value:r,children:t})}function jd(){return!1}function Md(e){return{escapeKey:typeof e=="boolean"?e:(e==null?void 0:e.escapeKey)??!1,outsidePress:typeof e=="boolean"?e:(e==null?void 0:e.outsidePress)??!0}}function Dd(e,t={}){const{enabled:n=!0,escapeKey:r=!0,outsidePress:o=!0,outsidePressEvent:s="sloppy",referencePress:i=jd,bubbles:c,externalTree:a}=t,l=e.useState("open"),f=e.useState("floatingElement"),{dataRef:u,events:h}=e.context,g=sn(a),d=fe(typeof o=="function"?o:()=>!1),m=typeof o=="function"?d:o,b=m!==!1,v=fe(()=>s),{escapeKey:x,outsidePress:S}=Md(c),E=y.useRef(!1),C=y.useRef(!1),w=y.useRef(!1),R=y.useRef(!1),P=y.useRef(!1),O=y.useRef(""),M=y.useRef(null),F=zt(),A=zt(),D=zt(),_=fe(()=>{A.clear(),u.current.insideReactTree=!1}),T=fe(L=>{var $;const X=($=u.current.floatingContext)==null?void 0:$.nodeId;return(g?Dt(g.nodesRef.current,X):[]).some(Q=>{var re;return((re=Q.context)==null?void 0:re.open)&&!Q.context.dataRef.current[L]})}),k=fe(L=>pr(L,e.select("floatingElement"))||pr(L,e.select("domReferenceElement"))),U=fe(L=>{i()&&e.setOpen(!1,Pe(Kn,L.nativeEvent))}),j=fe(L=>{if(!l||!n||!r||L.key!=="Escape")return;const X=Mf(L)?L.nativeEvent:L;if(P.current||X.isComposing||!x&&T("__escapeKeyBubbles"))return;const B=Pe(no,X);e.setOpen(!1,B),B.isCanceled||L.preventDefault(),!x&&!B.isPropagationAllowed&&L.stopPropagation()}),N=fe(()=>{u.current.insideReactTree=!0,A.start(0,_)}),Y=fe(L=>{if(!l||!n||L.button!==0)return;const X=vt(L.nativeEvent);Te(e.select("floatingElement"),X)&&(E.current||(E.current=!0,C.current=!1))}),K=fe(L=>{!l||!n||(L.defaultPrevented||L.nativeEvent.defaultPrevented)&&E.current&&(C.current=!0)});y.useEffect(()=>{function L(X){X.open||(R.current=!1)}return h.on("openchange",L),()=>{h.off("openchange",L)}},[h]),y.useEffect(()=>_,[_]),y.useEffect(()=>{if(!l||!n)return l||(R.current=!1,P.current=!1,O.current="",M.current=null),_;u.current.__escapeKeyBubbles=x,u.current.__outsidePressBubbles=S;const L=new ut,X=Ke(f);function B(){D.clear(),P.current=!0}function $(){P.current=!0,D.start(on?5:0,()=>{P.current=!1})}function Q(){w.current=!0,L.start(0,()=>{w.current=!1})}function re(){E.current=!1,C.current=!1}function ee(){const H=O.current,G=H==="pen"||!H?"mouse":H,Se=v(),be=typeof Se=="function"?Se():Se;return typeof be=="string"?be:be[G]}function te(H){const G=ee();return G==="intentional"&&H.type!=="click"||G==="sloppy"&&H.type==="click"}function W(H){var be;const G=(be=u.current.floatingContext)==null?void 0:be.nodeId,Se=g&&Dt(g.nodesRef.current,G).some(ge=>{var V;return pr(H,(V=ge.context)==null?void 0:V.elements.floating)});return k(H)||Se}function ne(H){if(te(H)){H.type!=="click"&&!k(H)&&(L.clear(),w.current=!1),_();return}if(u.current.insideReactTree){_();return}const G=vt(H),Se=`[${wo("inert")}]`,be=me(G)?G.getRootNode():null,ge=Array.from((At(be)?be:Ke(e.select("floatingElement"))).querySelectorAll(Se)),V=e.context.triggerElements;if(G&&(V.hasElement(G)||V.hasMatchingElement(Z=>Te(Z,G))))return;let q=me(G)?G:null;for(;q&&!ct(q);){const Z=lt(q);if(ct(Z)||!me(Z))break;q=Z}if(!(ge.length&&me(G)&&!Yf(G)&&!Te(G,e.select("floatingElement"))&&ge.every(Z=>!Te(q,Z)))){if(_e(G)&&!("touches"in H)){const Z=ct(G),se=$e(G),ke=/auto|scroll/,Ce=Z||ke.test(se.overflowX),Ct=Z||ke.test(se.overflowY),st=Ce&&G.clientWidth>0&&G.scrollWidth>G.clientWidth,Rt=Ct&&G.clientHeight>0&&G.scrollHeight>G.clientHeight,Ze=se.direction==="rtl",Qe=Rt&&(Ze?H.offsetX<=G.offsetWidth-G.clientWidth:H.offsetX>G.clientWidth),ht=st&&H.offsetY>G.clientHeight;if(Qe||ht)return}if(!W(H)){if(ee()==="intentional"){if(H.detail!==0&&!Df(H)&&!R.current)return;if(w.current){L.clear(),w.current=!1;return}}typeof m=="function"&&!m(H)||T("__outsidePressBubbles")||(e.setOpen(!1,Pe(ol,H)),_())}}}function oe(H){ee()!=="sloppy"||H.pointerType==="touch"||!e.select("open")||!n||k(H)||ne(H)}function ve(H){if(ee()!=="sloppy"||!e.select("open")||!n||k(H))return;const G=H.touches[0];G&&(M.current={startTime:Date.now(),startX:G.clientX,startY:G.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},F.start(1e3,()=>{M.current&&(M.current.dismissOnTouchEnd=!1,M.current.dismissOnMouseDown=!1)}))}function z(H,G){const Se=vt(H);if(!Se)return;const be=Ee(Se,H.type,()=>{G(H),be()})}function J(H){O.current="touch",z(H,ve)}function ce(H){F.clear(),H.type==="pointerdown"&&(H.button===0&&(R.current=!0),O.current=H.pointerType),!(H.type==="mousedown"&&M.current&&!M.current.dismissOnMouseDown)&&z(H,G=>{G.type==="pointerdown"?oe(G):ne(G)})}function he(H){if(H.type==="pointercancel"&&(R.current=!1),!E.current)return;const G=C.current;if(re(),ee()==="intentional"){if(H.type==="pointercancel"){G&&Q();return}if(!W(H)){if(G){Q();return}typeof m=="function"&&!m(H)||(L.clear(),w.current=!0,_())}}}function Oe(H){if(ee()!=="sloppy"||!M.current||k(H))return;const G=H.touches[0];if(!G)return;const Se=Math.abs(G.clientX-M.current.startX),be=Math.abs(G.clientY-M.current.startY),ge=Math.sqrt(Se*Se+be*be);ge>5&&(M.current.dismissOnTouchEnd=!0),ge>10&&(ne(H),F.clear(),M.current=null)}function je(H){z(H,Oe)}function Re(H){ee()!=="sloppy"||!M.current||k(H)||(M.current.dismissOnTouchEnd&&ne(H),F.clear(),M.current=null)}function Me(H){z(H,Re)}const Be=at(r&&at(Ee(X,"keydown",j),Ee(X,"compositionstart",B),Ee(X,"compositionend",$)),b&&at(Ee(X,"click",ce,!0),Ee(X,"pointerdown",ce,!0),Ee(X,"pointerup",he,!0),Ee(X,"pointercancel",he,!0),Ee(X,"mousedown",ce,!0),Ee(X,"mouseup",he,!0),Ee(X,"touchstart",J,{capture:!0,passive:!0}),Ee(X,"touchmove",je,{capture:!0,passive:!0}),Ee(X,"touchend",Me,{capture:!0,passive:!0})));return()=>{Be(),L.clear(),re(),w.current=!1}},[u,f,r,b,m,l,n,x,S,j,_,v,T,k,g,e,F,D]);const le=y.useMemo(()=>({onKeyDown:j,onPointerDown:U,onClick:U}),[j,U]),ie=y.useMemo(()=>({onKeyDown:j,onPointerDown:K,onMouseDown:K,onClickCapture:N,onMouseDownCapture(L){N(),Y(L)},onPointerDownCapture(L){N(),Y(L)},onMouseUpCapture:N,onTouchEndCapture:N,onTouchMoveCapture:N}),[j,N,Y,K]);return y.useMemo(()=>n?{reference:le,floating:ie,trigger:le}:{},[n,le,ie])}function $n(e,t,n,r){return{left:e,top:t,right:n,bottom:r,x:e,y:t,width:n-e,height:r-t}}function Fd(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom,width:e.width,height:e.height}}function cc(e){const t=[];let n,r=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const c of Array.from(e).sort((a,l)=>a.top-l.top)){if(r=Math.min(r,c.left),o=Math.min(o,c.top),s=Math.max(s,c.right),i=Math.max(i,c.bottom),!n||c.top-n.top>n.height/2)t.push(Fd(c));else{const a=t[t.length-1];a.left=Math.min(a.left,c.left),a.right=Math.max(a.right,c.right),a.bottom=Math.max(a.bottom,c.bottom),a.width=a.right-a.left,a.height=a.bottom-a.top}n=c}return{lines:t,fallback:$n(r,o,s,i)}}function ac(e,t,n){return e.findIndex(r=>t>r.left-2&&t<r.right+2&&n>r.top-2&&n<r.bottom+2)}function vs(e){return $n(e.left,e.top,e.right,e.bottom)}function Ld(e,t,n){const{lines:r}=cc(e.getClientRects());if(r.length<2)return;const o=ac(r,t,n);return{x:t,y:n,lineIndex:o===-1?void 0:o,element:e}}function Bd(e,t,n){const{lines:r,fallback:o}=cc(e.getClientRects());if(r.length<2)return null;const s=n==null?void 0:n.x,i=n==null?void 0:n.y,c=t[0];if((n==null?void 0:n.lineIndex)!=null&&r[n.lineIndex])return vs(r[n.lineIndex]);if(s!=null&&i!=null){const d=ac(r,s,i);if(d!==-1)return vs(r[d])}if(r.length===2&&r[0].left>r[1].right&&s!=null&&i!=null)return o;if(c==="t"||c==="b"){const d=r[0],m=r[r.length-1],b=c==="t"?d:m;return $n(b.left,d.top,b.right,m.bottom)}const a=c==="l";let l=r[0].left,f=r[0].right,u=a?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY,h=r[0],g=r[0];for(const d of r){l=Math.min(l,d.left),f=Math.max(f,d.right);const m=a?d.left:d.right;a&&m<u||!a&&m>u?(u=m,h=d,g=d):m===u&&(g=d)}return $n(l,h.top,f,g.bottom)}function Vd(e){return"contextElement"in e&&e.contextElement?e.contextElement:me(e)?e:void 0}function $d(e,t){function n(o){lc(e,o.currentTarget,o.clientX,o.clientY)}function r(o){t||n(o)}return{onFocus(){e.current=void 0},onMouseEnter:r,onMouseMove:r}}function lc(e,t,n,r){const o=Ld(t,n,r);return e.current=o,o}function Hd(e){return{name:"inline",async fn(t){const n=t.elements.reference;if(typeof(n==null?void 0:n.getClientRects)!="function")return{};const r=Vd(n),o=e.current,s=(o==null?void 0:o.element)===n||(o==null?void 0:o.element)===r?o:void 0,i=Bd(n,t.placement,s);if(!i||typeof t.platform.getElementRects!="function")return{};const c=await t.platform.getElementRects({reference:{contextElement:r,getBoundingClientRect(){return i}},floating:t.elements.floating,strategy:t.strategy});return t.rects.reference.x===c.reference.x&&t.rects.reference.y===c.reference.y&&t.rects.reference.width===c.reference.width&&t.rects.reference.height===c.reference.height?{}:{reset:{rects:c}}}}}class Ud{constructor(t,n,r=!0){ae(this,"attachedStores",[]);ae(this,"attachedStoreValue",null);ae(this,"storeListeners",new Set);this.fallbackStore=t,this.componentName=n,this.throwOnMissingTrigger=r}get attachedStore(){return this.attachedStoreValue}get store(){return this.attachedStoreValue??this.fallbackStore}get serverStore(){return this.fallbackStore}subscribeStore(t){return this.storeListeners.add(t),()=>{this.storeListeners.delete(t)}}attachStore(t){if(this.attachedStores.push(t),this.setActiveStore(t),process.env.NODE_ENV!=="production"&&this.attachedStores.length>1){const n=this;(n.overlapWarningFrame??(n.overlapWarningFrame=Ne.create())).request(()=>{this.attachedStores.length>1&&console.warn("Base UI: A handle is attached to more than one mounted root at the same time. The most recently mounted root takes over and the previous one stops being controlled by the handle. A handle should be used by a single root that stays mounted for the lifetime of the handle.")})}return()=>{const n=this.attachedStores.lastIndexOf(t);n!==-1&&this.attachedStores.splice(n,1),this.setActiveStore(this.attachedStores[this.attachedStores.length-1]??null)}}setActiveStore(t){this.attachedStoreValue!==t&&(this.attachedStoreValue=t,this.storeListeners.forEach(n=>{n()}))}openByTrigger(t){const n=this.attachedStore;if(n===null){process.env.NODE_ENV!=="production"&&console.warn(`Base UI: ${this.componentName}Handle.open() was called while no root using this handle is mounted. The call was ignored; mount a root with this handle before opening it imperatively.`);return}let r;if(t){for(let o=this.attachedStores.length-1;o>=0&&!r;o-=1)r=this.attachedStores[o].context.triggerElements.getById(t);r??(r=this.fallbackStore.context.triggerElements.getById(t))}if(t&&!r){if(this.throwOnMissingTrigger)throw new Error(process.env.NODE_ENV!=="production"?`Base UI: ${this.componentName}Handle.open() was called with the trigger id "${t}", but no matching trigger is registered with this handle. An anchored popup cannot open without a trigger to anchor to. Pass the id of a mounted ${this.componentName}.Trigger that has this handle set on its "handle" prop.`:wt(99,this.componentName,t,this.componentName));process.env.NODE_ENV!=="production"&&console.warn(`Base UI: ${this.componentName}Handle.open: No trigger found with id "${t}". The popup will open, but the trigger will not be associated with it.`)}n.setOpen(!0,Pe(Or,void 0,r))}closePopup(){const t=this.attachedStore;if(t===null){process.env.NODE_ENV!=="production"&&console.warn(`Base UI: ${this.componentName}Handle.close() was called while no root using this handle is mounted. The call was ignored.`);return}t.setOpen(!1,Pe(Or))}}function zd(e){const{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:o,nested:s,onOpenChange:i}=e,c=t.useState("open"),a=t.useState("activeTriggerElement"),l=t.useState(n?"popupElement":"positionerElement"),f=i;return t.useSyncedValue("floatingId",o),pe(()=>{const u={open:c,floatingId:o,referenceElement:a,floatingElement:l};me(a)&&(u.domReferenceElement=a),r.state.positionReference===r.state.referenceElement&&(u.positionReference=a),r.update(u)},[c,o,a,l,r]),r.context.onOpenChange=f,r.context.nested=s,r}function Wd(e){const{open:t,ref:n,preventUnmountOnClose:r,setPreventUnmountOnClose:o,onUnmount:s,animateInitialOpen:i}=e,c=fe(o),{mounted:a,setMounted:l,transitionStatus:f}=yi(t,!1,!1,i),u=t?!1:r;pe(()=>{t&&c(!1)},[t,c]);const h=y.useRef(a),g=y.useRef(!1),d=mi(),m=()=>{h.current=!1,l(!1),s()};pe(()=>{h.current=a,g.current&&(g.current=!1,!t&&a&&m())});const b=fe(()=>{if(h.current){if(t){g.current=!0,d();return}m()}});return uo({enabled:a&&!t&&!u,open:t,ref:n,onComplete(){t||b()}}),{mounted:a,transitionStatus:f,preventUnmountingOnClose:u,forceUnmount:b}}const qd={tabIndex:-1,[Lf]:""};function Gd(e,t=!1){const n=Gn(),r=tr()!=null,o=Ye(()=>e(n,r)).current;return zd({popupStore:o,treatPopupAsFloatingElement:t,floatingRootContext:o.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:o.setOpen}),o}function Kd({handle:e,store:t}){return pe(()=>e.attachStore(t),[e,t]),null}function ys(e){const t=e.context.triggerElements.size;e.select("open")&&e.state.triggerCount!==t&&e.set("triggerCount",t)}function Yd(e,t){const n=y.useRef(null);return fe(r=>{const o=n.current;if(o!==null){if(o.element===r&&o.store===t&&o.id===e)return;n.current=null;const s=o.store;s.context.triggerElements.getById(o.id)===o.element&&(s.context.triggerElements.delete(o.id),ys(s))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),ys(t))})}function Xd(e,t,n,r=!1){let o=e.preventUnmountingOnClose;t?o=!1:r&&(o=!0);const s=(n==null?void 0:n.id)??null;let i=e.activeTriggerId,c=e.activeTriggerElement;return(s||t)&&(i=s,c=n??null),{open:t,preventUnmountingOnClose:o,activeTriggerId:i,activeTriggerElement:c,openedWithoutTrigger:t?n==null:e.openedWithoutTrigger}}function Jd(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function Zd(e,t,n,r={}){var f,u,h;const o=n.reason,s=o===We,i=t&&o===Pn,c=!t&&(o===Kn||o===no),a=Jd(n);if((u=(f=e.context).onOpenChange)==null||u.call(f,t,n),n.isCanceled)return;(h=r.onBeforeDispatch)==null||h.call(r),e.state.floatingRootContext.dispatchOpenChange(t,n);const l=()=>{const g=Xd(e.state,t,n.trigger,a()),d={...r.extraState,...g};i?d.instantType="focus":c?d.instantType="dismiss":s&&(d.instantType=void 0),e.update(d)};s?dt.flushSync(l):l()}function Qd(e,t,n,r){const o=n.useState("isMountedByTrigger",e),s=Yd(e,n),i=fe(a=>{const l=n.select("open"),f=n.select("activeTriggerId");if(f===e){const u={activeTriggerElement:a,...l?r:null};n.update(u);return}if(f==null&&l&&!n.state.openedWithoutTrigger){const u={activeTriggerId:e??null,activeTriggerElement:a,...r};n.update(u)}}),c=fe(a=>{s(a),a&&i(a)});return pe(()=>(c(t.current),()=>c(null)),[c,t,n,e]),pe(()=>{if(o){const a={activeTriggerElement:t.current,...r};n.update(a)}},[o,n,t,...Object.values(r)]),{registerTrigger:c,isMountedByThisTrigger:o}}function ep(e,t={}){const{closeOnActiveTriggerUnmount:n=!1}=t,r=y.useRef(null),o=e.useState("open"),s=e.useState("triggerCount"),i=e.useState("activeTriggerId"),c=e.useState("activeTriggerElement");pe(()=>{if(!o){r.current=null,e.state.triggerCount!==0&&e.set("triggerCount",0),e.state.openedWithoutTrigger&&e.set("openedWithoutTrigger",!1);return}const a=e.context.triggerElements.size,l={};e.state.triggerCount!==a&&(l.triggerCount=a);const f=e.select("activeTriggerId");let u=null;if(f){const h=e.context.triggerElements.getById(f);if(h)r.current=f,h!==e.state.activeTriggerElement&&(l.activeTriggerElement=h);else{for(const[g,d]of e.context.triggerElements.entries())if(d===e.state.activeTriggerElement){l.activeTriggerId=g,l.activeTriggerElement=d,r.current=g;break}l.activeTriggerId===void 0&&(r.current===f?u=f:r.current=null)}}else r.current=null;if(!u&&!f&&!e.state.openedWithoutTrigger&&a===1){const h=e.context.triggerElements.entries().next();if(!h.done){const[g,d]=h.value;l.activeTriggerId=g,l.activeTriggerElement=d,r.current=g}}(l.triggerCount!==void 0||l.activeTriggerId!==void 0||l.activeTriggerElement!==void 0)&&e.update(l),u&&n&&queueMicrotask(()=>{if(e.select("open")&&e.select("activeTriggerId")===u&&!e.context.triggerElements.getById(u)){const h=Pe(vi);e.setOpen(!1,h),h.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[o,e,s,i,c,n])}function tp(e,t,n,r){const{mounted:o,transitionStatus:s,forceUnmount:i}=Wd({open:e,ref:t.context.popupRef,preventUnmountOnClose:t.useState("preventUnmountingOnClose"),setPreventUnmountOnClose:c=>t.set("preventUnmountingOnClose",c),animateInitialOpen:r,onUnmount(){var c,a;t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n==null||n(),(a=(c=t.context).onOpenChangeComplete)==null||a.call(c,!1)}});return Ye(()=>(t.set("mounted",o),null)),t.useSyncedValues({mounted:o,transitionStatus:s}),{forceUnmount:i,transitionStatus:s}}function np(e,t){e.useSyncedValues(t),pe(()=>()=>{e.update({activeTriggerProps:Fe,inactiveTriggerProps:Fe,popupProps:Fe})},[e])}let _t;function rp(e){_t??(_t=new WeakMap);let t=_t.get(e);return t||(t=new WeakMap,_t.set(e,t)),t}class uc{constructor(){ae(this,"idMap",new Map)}add(t,n){if(process.env.NODE_ENV!=="production"){const r=rp(this),o=r.get(n);if(o!==void 0&&o!==t)throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");const s=this.idMap.get(t);s!==void 0&&s!==n&&r.delete(s),r.set(n,t)}this.idMap.set(t,n)}delete(t){var n;if(process.env.NODE_ENV!=="production"){const r=this.idMap.get(t);r!==void 0&&((n=_t==null?void 0:_t.get(this))==null||n.delete(r))}this.idMap.delete(t)}hasElement(t){for(const n of this.idMap.values())if(n===t)return!0;return!1}hasMatchingElement(t){for(const n of this.idMap.values())if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}}var xn={exports:{}},mr={};/**
180
180
  * @license React
181
181
  * use-sync-external-store-shim.production.js
182
182
  *
@@ -184,7 +184,7 @@ Feel free to ask a question or select one of the suggested topics below!`;functi
184
184
  *
185
185
  * This source code is licensed under the MIT license found in the
186
186
  * LICENSE file in the root directory of this source tree.
187
- */var xs;function rp(){if(xs)return gr;xs=1;var e=I;function t(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,i=e.useDebugValue;function c(u,d){var m=d(),p=r({inst:{value:m,getSnapshot:d}}),g=p[0].inst,b=p[1];return s(function(){g.value=m,g.getSnapshot=d,a(g)&&b({inst:g})},[u,m,d]),o(function(){return a(g)&&b({inst:g}),u(function(){a(g)&&b({inst:g})})},[u]),i(m),m}function a(u){var d=u.getSnapshot;u=u.value;try{var m=d();return!n(u,m)}catch{return!0}}function l(u,d){return d()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:c;return gr.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,gr}var br={};/**
187
+ */var xs;function op(){if(xs)return mr;xs=1;var e=I;function t(u,h){return u===h&&(u!==0||1/u===1/h)||u!==u&&h!==h}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,i=e.useDebugValue;function c(u,h){var g=h(),d=r({inst:{value:g,getSnapshot:h}}),m=d[0].inst,b=d[1];return s(function(){m.value=g,m.getSnapshot=h,a(m)&&b({inst:m})},[u,g,h]),o(function(){return a(m)&&b({inst:m}),u(function(){a(m)&&b({inst:m})})},[u]),i(g),g}function a(u){var h=u.getSnapshot;u=u.value;try{var g=h();return!n(u,g)}catch{return!0}}function l(u,h){return h()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:c;return mr.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,mr}var br={};/**
188
188
  * @license React
189
189
  * use-sync-external-store-shim.development.js
190
190
  *
@@ -192,7 +192,7 @@ Feel free to ask a question or select one of the suggested topics below!`;functi
192
192
  *
193
193
  * This source code is licensed under the MIT license found in the
194
194
  * LICENSE file in the root directory of this source tree.
195
- */var Es;function op(){return Es||(Es=1,process.env.NODE_ENV!=="production"&&(function(){function e(m,p){return m===p&&(m!==0||1/m===1/p)||m!==m&&p!==p}function t(m,p){f||o.startTransition===void 0||(f=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var g=p();if(!u){var b=p();s(g,b)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}b=i({inst:{value:g,getSnapshot:p}});var y=b[0].inst,x=b[1];return a(function(){y.value=g,y.getSnapshot=p,n(y)&&x({inst:y})},[m,g,p]),c(function(){return n(y)&&x({inst:y}),m(function(){n(y)&&x({inst:y})})},[m]),l(g),g}function n(m){var p=m.getSnapshot;m=m.value;try{var g=p();return!s(m,g)}catch{return!0}}function r(m,p){return p()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=I,s=typeof Object.is=="function"?Object.is:e,i=o.useState,c=o.useEffect,a=o.useLayoutEffect,l=o.useDebugValue,f=!1,u=!1,d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:t;br.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:d,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),br}var Ss;function Oo(){return Ss||(Ss=1,process.env.NODE_ENV==="production"?xn.exports=rp():xn.exports=op()),xn.exports}var Po=Oo(),En={exports:{}},yr={};/**
195
+ */var Es;function sp(){return Es||(Es=1,process.env.NODE_ENV!=="production"&&(function(){function e(g,d){return g===d&&(g!==0||1/g===1/d)||g!==g&&d!==d}function t(g,d){f||o.startTransition===void 0||(f=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var m=d();if(!u){var b=d();s(m,b)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}b=i({inst:{value:m,getSnapshot:d}});var v=b[0].inst,x=b[1];return a(function(){v.value=m,v.getSnapshot=d,n(v)&&x({inst:v})},[g,m,d]),c(function(){return n(v)&&x({inst:v}),g(function(){n(v)&&x({inst:v})})},[g]),l(m),m}function n(g){var d=g.getSnapshot;g=g.value;try{var m=d();return!s(g,m)}catch{return!0}}function r(g,d){return d()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=I,s=typeof Object.is=="function"?Object.is:e,i=o.useState,c=o.useEffect,a=o.useLayoutEffect,l=o.useDebugValue,f=!1,u=!1,h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:t;br.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:h,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),br}var Ss;function Po(){return Ss||(Ss=1,process.env.NODE_ENV==="production"?xn.exports=op():xn.exports=sp()),xn.exports}var Oo=Po(),En={exports:{}},vr={};/**
196
196
  * @license React
197
197
  * use-sync-external-store-shim/with-selector.production.js
198
198
  *
@@ -200,7 +200,7 @@ Feel free to ask a question or select one of the suggested topics below!`;functi
200
200
  *
201
201
  * This source code is licensed under the MIT license found in the
202
202
  * LICENSE file in the root directory of this source tree.
203
- */var ws;function sp(){if(ws)return yr;ws=1;var e=I,t=Oo();function n(l,f){return l===f&&(l!==0||1/l===1/f)||l!==l&&f!==f}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,s=e.useRef,i=e.useEffect,c=e.useMemo,a=e.useDebugValue;return yr.useSyncExternalStoreWithSelector=function(l,f,u,d,m){var p=s(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=c(function(){function y(w){if(!x){if(x=!0,S=w,w=d(w),m!==void 0&&g.hasValue){var R=g.value;if(m(R,w))return E=R}return E=w}if(R=E,r(S,w))return R;var O=d(w);return m!==void 0&&m(R,O)?(S=w,R):(S=w,E=O)}var x=!1,S,E,C=u===void 0?null:u;return[function(){return y(f())},C===null?void 0:function(){return y(C())}]},[f,u,d,m]);var b=o(l,p[0],p[1]);return i(function(){g.hasValue=!0,g.value=b},[b]),a(b),b},yr}var vr={};/**
203
+ */var ws;function ip(){if(ws)return vr;ws=1;var e=I,t=Po();function n(l,f){return l===f&&(l!==0||1/l===1/f)||l!==l&&f!==f}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,s=e.useRef,i=e.useEffect,c=e.useMemo,a=e.useDebugValue;return vr.useSyncExternalStoreWithSelector=function(l,f,u,h,g){var d=s(null);if(d.current===null){var m={hasValue:!1,value:null};d.current=m}else m=d.current;d=c(function(){function v(w){if(!x){if(x=!0,S=w,w=h(w),g!==void 0&&m.hasValue){var R=m.value;if(g(R,w))return E=R}return E=w}if(R=E,r(S,w))return R;var P=h(w);return g!==void 0&&g(R,P)?(S=w,R):(S=w,E=P)}var x=!1,S,E,C=u===void 0?null:u;return[function(){return v(f())},C===null?void 0:function(){return v(C())}]},[f,u,h,g]);var b=o(l,d[0],d[1]);return i(function(){m.hasValue=!0,m.value=b},[b]),a(b),b},vr}var yr={};/**
204
204
  * @license React
205
205
  * use-sync-external-store-shim/with-selector.development.js
206
206
  *
@@ -208,8 +208,8 @@ Feel free to ask a question or select one of the suggested topics below!`;functi
208
208
  *
209
209
  * This source code is licensed under the MIT license found in the
210
210
  * LICENSE file in the root directory of this source tree.
211
- */var Cs;function ip(){return Cs||(Cs=1,process.env.NODE_ENV!=="production"&&(function(){function e(l,f){return l===f&&(l!==0||1/l===1/f)||l!==l&&f!==f}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=I,n=Oo(),r=typeof Object.is=="function"?Object.is:e,o=n.useSyncExternalStore,s=t.useRef,i=t.useEffect,c=t.useMemo,a=t.useDebugValue;vr.useSyncExternalStoreWithSelector=function(l,f,u,d,m){var p=s(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=c(function(){function y(w){if(!x){if(x=!0,S=w,w=d(w),m!==void 0&&g.hasValue){var R=g.value;if(m(R,w))return E=R}return E=w}if(R=E,r(S,w))return R;var O=d(w);return m!==void 0&&m(R,O)?(S=w,R):(S=w,E=O)}var x=!1,S,E,C=u===void 0?null:u;return[function(){return y(f())},C===null?void 0:function(){return y(C())}]},[f,u,d,m]);var b=o(l,p[0],p[1]);return i(function(){g.hasValue=!0,g.value=b},[b]),a(b),b},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),vr}var Rs;function cp(){return Rs||(Rs=1,process.env.NODE_ENV==="production"?En.exports=sp():En.exports=ip()),En.exports}var ap=cp();const lp=ii(19),up=lp?dp:pp;function uc(e,t,n,r,o){return up(e,t,n,r,o)}function fp(e,t,n,r,o){const s=v.useCallback(()=>t(e.getSnapshot(),n,r,o),[e,t,n,r,o]);return Po.useSyncExternalStore(e.subscribe,s,s)}wf({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){const r=e.syncHooks[n],o=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,o)||(t=!0,r.value=o)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{const n=new Set;for(const o of e.syncHooks)n.add(o.store);const r=[];for(const o of n)r.push(o.subscribe(t));return()=>{for(const o of r)o()}}),Po.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot))}});function dp(e,t,n,r,o){const s=Sf();if(!s)return fp(e,t,n,r,o);const i=s.syncIndex;s.syncIndex+=1;let c;return s.didInitialize?(c=s.syncHooks[i],(c.store!==e||c.selector!==t||!Object.is(c.a1,n)||!Object.is(c.a2,r)||!Object.is(c.a3,o))&&(c.store!==e&&(s.didChangeStore=!0),c.store=e,c.selector=t,c.a1=n,c.a2=r,c.a3=o,c.value=t(e.getSnapshot(),n,r,o))):(c={store:e,selector:t,a1:n,a2:r,a3:o,value:t(e.getSnapshot(),n,r,o)},s.syncHooks.push(c)),c.value}function pp(e,t,n,r,o){return ap.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,s=>t(s,n,r,o))}class hp{constructor(t){ae(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));ae(this,"getSnapshot",()=>this.state);this.state=t,this.listeners=new Set,this.updateTick=0}static create(t){return new this(t)}setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const n=this.updateTick;for(const r of this.listeners){if(n!==this.updateTick)return;r(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){this.setState({...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||this.setState({...this.state,[t]:n})}notifyAll(){const t={...this.state};this.setState(t)}use(t,n,r,o){return uc(this,t,n,r,o)}}class Io extends hp{constructor(t,n={},r){super(t),this.context=n,this.selectors=r}useSyncedValue(t,n){v.useDebugValue(t);const r=this;pe(()=>{r.state[t]!==n&&r.set(t,n)},[r,t,n])}useSyncedValueWithCleanup(t,n){const r=this;pe(()=>(r.state[t]!==n&&r.set(t,n),()=>{r.set(t,void 0)}),[r,t,n])}useSyncedValues(t){const n=this;if(process.env.NODE_ENV!=="production"){v.useDebugValue(t,i=>Object.keys(i));const o=v.useRef(Object.keys(t)).current,s=Object.keys(t);(o.length!==s.length||o.some((i,c)=>i!==s[c]))&&console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.")}const r=Object.values(t);pe(()=>{n.update(t)},[n,...r])}useControlledProp(t,n){v.useDebugValue(t);const r=this,o=n!==void 0;if(pe(()=>{o&&!Object.is(r.state[t],n)&&r.setState({...r.state,[t]:n})},[r,t,n,o]),process.env.NODE_ENV!=="production"){const s=this.controlledValues??(this.controlledValues=new Map);s.has(t)||s.set(t,o);const i=s.get(t);i!==void 0&&i!==o&&console.error(`A component is changing the ${i?"":"un"}controlled state of ${t.toString()} to be ${i?"un":""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`)}}select(t,n,r,o){const s=this.selectors[t];return s(this.state,n,r,o)}useState(t,n,r,o){return v.useDebugValue(t),uc(this,this.selectors[t],n,r,o)}useContextCallback(t,n){v.useDebugValue(t);const r=fe(n??eo);this.context[t]=r}useStateSetter(t){const n=v.useRef(void 0);return n.current===void 0&&(n.current=r=>{this.set(t,r)}),n.current}observe(t,n){let r;typeof t=="function"?r=t:r=this.selectors[t];let o=r(this.state);return n(o,o,this),this.subscribe(s=>{const i=r(s);if(!Object.is(o,i)){const c=o;o=i,n(i,c,this)}})}}const mp={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId};class gp extends Io{constructor(n){const{syncOnly:r,nested:o,onOpenChange:s,triggerElements:i,...c}=n;super({...c,positionReference:c.referenceElement,domReferenceElement:c.referenceElement},{onOpenChange:s,dataRef:{current:{}},events:sc(),nested:o,triggerElements:i},mp);ae(this,"syncOpenEvent",(n,r)=>{(!n||!this.state.open||r!=null&&Df(r))&&(this.context.dataRef.current.openEvent=n?r:void 0)});ae(this,"dispatchOpenChange",(n,r)=>{this.syncOpenEvent(n,r.event);const o={open:n,reason:r.reason,nativeEvent:r.event,nested:this.context.nested,triggerElement:r.trigger};this.context.events.emit("openchange",o)});ae(this,"setOpen",(n,r)=>{var o,s,i,c;if(this.syncOnly){(s=(o=this.context).onOpenChange)==null||s.call(o,n,r);return}this.dispatchOpenChange(n,r),(c=(i=this.context).onOpenChange)==null||c.call(i,n,r)});this.syncOnly=r}}function bp(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new gp({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,openedWithoutTrigger:!1,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:Fe,inactiveTriggerProps:Fe,popupProps:Fe}}const qt=e=>e.triggerIdProp??e.activeTriggerId,Hn=e=>e.openProp??e.open,Ts=e=>{var n;return(((n=e.popupElement)==null?void 0:n.id)??e.floatingId)||void 0};function fc(e,t){return t!==void 0&&Hn(e)&&qt(e)===t}function yp(e,t){return fc(e,t)?!0:t!==void 0&&Hn(e)&&qt(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}const vp={open:Hn,mounted:e=>e.mounted,transitionStatus:e=>Hn(e)&&!e.mounted?"starting":e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:qt,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Ts,isTriggerActive:(e,t)=>t!==void 0&&qt(e)===t,isOpenedByTrigger:(e,t)=>fc(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&qt(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>yp(e,t)?Ts(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function xp(e){const t=v.useCallback(r=>e===void 0?eo:e.subscribeStore(r),[e]),n=v.useCallback(()=>e===void 0?void 0:e.store,[e]);return Po.useSyncExternalStore(t,n,()=>e==null?void 0:e.serverStore)}const xr=qi&&on;function Ep(e,t={}){const{enabled:n=!0,delay:r}=t,{events:o,dataRef:s}=e.context,i=v.useRef(!1),c=v.useRef(null),a=v.useRef(!0),l=zt();v.useEffect(()=>{const u=e.select("domReferenceElement");if(!n)return;const d=Ie(u);function m(){const b=e.select("domReferenceElement");!e.select("open")&&_e(b)&&b===Br(Ke(b))&&(i.current=!0,c.current=b)}function p(){a.current=!0}function g(){a.current=!1}return at(Ee(d,"blur",m),xr&&Ee(d,"keydown",p,!0),xr&&Ee(d,"pointerdown",g,!0))},[e,n]),v.useEffect(()=>{if(!n)return;function u(d){if(d.reason===Kn||d.reason===no){const m=e.select("domReferenceElement");ge(m)&&(c.current=m,i.current=!0)}}return o.on("openchange",u),()=>{o.off("openchange",u)}},[o,n,e]);const f=v.useMemo(()=>{function u(){i.current=!1,c.current=null}return{onMouseLeave(){u()},onFocus(d){const m=d.currentTarget;if(i.current){if(c.current===m)return;u()}const p=yt(d.nativeEvent);if(ge(p)){if(xr&&!d.relatedTarget){if(!a.current&&!Yf(p))return}else if(!Jf(p))return}const g=Fn(d.relatedTarget,e.context.triggerElements),{nativeEvent:b,currentTarget:y}=d;if(e.select("open")&&g||!r){e.setOpen(!0,Oe(On,b,y));return}l.start(r,()=>{i.current||e.setOpen(!0,Oe(On,b,y))})},onBlur(d){u();const m=d.relatedTarget,p=d.nativeEvent,g=ge(m)&&m.hasAttribute(wo("focus-guard"))&&m.getAttribute("data-type")==="outside";l.start(0,()=>{var S;const b=e.select("domReferenceElement"),y=Br(Ke(b));!m&&y===b||Te((S=s.current.floatingContext)==null?void 0:S.refs.floating.current,y)||Te(b,y)||g||Fn(m??y,e.context.triggerElements)||e.setOpen(!1,Oe(On,p))})}}},[s,r,e,l]);return v.useMemo(()=>n?{reference:f,trigger:f}:{},[n,f])}class _o{constructor(){ae(this,"pointerType");ae(this,"interactedInside",!1);ae(this,"handler");ae(this,"blockMouseMove",!0);ae(this,"performedPointerEventsMutation",!1);ae(this,"pointerEventsScopeElement",null);ae(this,"pointerEventsReferenceElement",null);ae(this,"pointerEventsFloatingElement",null);ae(this,"restTimeoutPending",!1);ae(this,"openChangeTimeout",new ut);ae(this,"restTimeout",new ut);ae(this,"handleCloseOptions");ae(this,"dispose",()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()});ae(this,"disposeEffect",()=>this.dispose)}static create(){return new _o}}const Un=new WeakMap;function zn(e){var n,r,o;if(!e.performedPointerEventsMutation)return;const t=e.pointerEventsScopeElement;t&&Un.get(t)===e&&((n=e.pointerEventsScopeElement)==null||n.style.removeProperty("pointer-events"),(r=e.pointerEventsReferenceElement)==null||r.style.removeProperty("pointer-events"),(o=e.pointerEventsFloatingElement)==null||o.style.removeProperty("pointer-events"),Un.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function dc(e,t){const{scopeElement:n,referenceElement:r,floatingElement:o}=t,s=Un.get(n);s&&s!==e&&zn(s),zn(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=o,Un.set(n,e),n.style.pointerEvents="none",r.style.pointerEvents="auto",o.style.pointerEvents="auto"}function pc(e){const t=e.context.dataRef.current,n=Ye(()=>t.hoverInteractionState??_o.create()).current;return t.hoverInteractionState||(t.hoverInteractionState=n),ro(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function Sp(e,t={}){const{enabled:n=!0,closeDelay:r=0,nodeId:o}=t,s=e.useState("open"),i=e.useState("floatingElement"),c=e.useState("domReferenceElement"),{dataRef:a}=e.context,l=sn(),f=tr(),u=pc(e),d=zt(),m=fe(()=>{var b;return Yi((b=a.current.openEvent)==null?void 0:b.type,u.interactedInside)}),p=fe(()=>{var b;return Qf((b=a.current.openEvent)==null?void 0:b.type)}),g=fe(()=>{zn(u)});pe(()=>{s||(u.pointerType=void 0,u.restTimeoutPending=!1,u.interactedInside=!1,g())},[s,u,g]),v.useEffect(()=>g,[g]),pe(()=>{var b,y,x,S,E;if(n&&s&&(b=u.handleCloseOptions)!=null&&b.blockPointerEvents&&p()&&ge(c)&&i){const C=c,w=i,R=Ke(i),O=(x=(y=l==null?void 0:l.nodesRef.current.find(A=>A.id===f))==null?void 0:y.context)==null?void 0:x.elements.floating;O&&(O.style.pointerEvents="");const P=u.pointerEventsScopeElement!==w?u.pointerEventsScopeElement:null,M=O!==w?O:null,F=((E=(S=u.handleCloseOptions)==null?void 0:S.getScope)==null?void 0:E.call(S))??P??M??Vr(C,"[data-rootownerid]")??R.body;return dc(u,{scopeElement:F,referenceElement:C,floatingElement:w}),()=>{g()}}},[n,s,c,i,u,p,l,f,g]),v.useEffect(()=>{if(!n)return;function b(){return!!(l&&f&&Dt(l.nodesRef.current,f).length>0)}function y(R){const O=$r(r,"close",u.pointerType),P=()=>{e.setOpen(!1,Oe(We,R)),l==null||l.events.emit("floating.closed",R)};O?u.openChangeTimeout.start(O,P):(u.openChangeTimeout.clear(),P())}function x(R){const O=yt(R);if(!Xf(O)){u.interactedInside=!1;return}u.interactedInside=Vr(O,"[aria-haspopup]")!=null}function S(){u.openChangeTimeout.clear(),d.clear(),l==null||l.events.off("floating.closed",C),g()}function E(R){var F;if(b()&&l){l.events.on("floating.closed",C);return}if(Fn(R.relatedTarget,e.context.triggerElements))return;const O=((F=a.current.floatingContext)==null?void 0:F.nodeId)??o,P=R.relatedTarget;if(!(l&&O&&ge(P)&&Dt(l.nodesRef.current,O,!1).some(A=>{var D;return Te((D=A.context)==null?void 0:D.elements.floating,P)}))){if(u.handler){u.handler(R);return}g(),p()&&!m()&&y(R)}}function C(R){!l||!f||b()||d.start(0,()=>{l.events.off("floating.closed",C),e.setOpen(!1,Oe(We,R)),l.events.emit("floating.closed",R)})}const w=i;return at(w&&Ee(w,"mouseenter",S),w&&Ee(w,"mouseleave",E),w&&Ee(w,"pointerdown",x,!0),()=>{l==null||l.events.off("floating.closed",C)})},[n,i,e,a,r,o,p,m,g,u,l,f,d])}const wp={current:null};function Cp(e,t={}){const{enabled:n=!0,delay:r=0,handleClose:o=null,mouseOnly:s=!1,restMs:i=0,move:c=!0,triggerElementRef:a=wp,externalTree:l,isActiveTrigger:f=!0,getHandleCloseContext:u,isClosing:d,shouldOpen:m,guardStaleOpen:p=!1}=t,{dataRef:g,events:b}=e.context,y=sn(l),x=pc(e),S=v.useRef(!1),E=qe(o),C=qe(r),w=qe(i),R=qe(n),O=qe(m),P=qe(d),M=fe(()=>{var T;return Yi((T=g.current.openEvent)==null?void 0:T.type,x.interactedInside)}),F=fe(()=>{var T;return((T=O.current)==null?void 0:T.call(O))!==!1}),A=fe((T,k,U)=>{const j=e.context.triggerElements;if(j.hasElement(k))return!T||!Te(T,k);if(!ge(U))return!1;const N=U;return j.hasMatchingElement(Y=>Te(Y,N))&&(!T||!Te(T,N))}),D=fe(()=>{if(!x.handler)return;Ke(e.select("domReferenceElement")).removeEventListener("mousemove",x.handler),x.handler=void 0}),_=fe(()=>{zn(x)});return f&&(x.handleCloseOptions=o==null?void 0:o.__options),v.useEffect(()=>D,[D]),v.useEffect(()=>{if(!n)return;function T(k){k.open?S.current=!1:(S.current=k.reason===We,D(),x.openChangeTimeout.clear(),x.restTimeout.clear(),x.blockMouseMove=!0,x.restTimeoutPending=!1)}return b.on("openchange",T),()=>{b.off("openchange",T)}},[n,b,x,D]),v.useEffect(()=>{if(!n)return;function T(K,le=!0){const ie=$r(C.current,"close",x.pointerType);ie?x.openChangeTimeout.start(ie,()=>{e.setOpen(!1,Oe(We,K)),y==null||y.events.emit("floating.closed",K)}):le&&(x.openChangeTimeout.clear(),e.setOpen(!1,Oe(We,K)),y==null||y.events.emit("floating.closed",K))}const k=a.current??(f?e.select("domReferenceElement"):null);if(!ge(k))return;function U(K){var q;if(x.openChangeTimeout.clear(),x.blockMouseMove=!1,s&&!Lr(x.pointerType))return;const le=hs(w.current),ie=$r(C.current,"open",x.pointerType),L=yt(K),X=K.currentTarget??null,B=e.select("domReferenceElement");let $=X;if(ge(L)&&!e.context.triggerElements.hasElement(L)){for(const J of e.context.triggerElements.elements())if(Te(J,L)){$=J;break}}ge(X)&&ge(B)&&!e.context.triggerElements.hasElement(X)&&Te(X,B)&&($=B);const Q=$==null?!1:A(B,$,L),re=e.select("open"),ee=((q=P.current)==null?void 0:q.call(P))??e.select("transitionStatus")==="ending",te=!re&&ee&&S.current,z=!Q&&ge($)&&ge(B)&&Te(B,$)&&te,ne=le>0&&!ie,oe=Q&&(re||te)||z,ye=!re||Q;if(oe){F()&&e.setOpen(!0,Oe(We,K,$));return}ne||(ie?x.openChangeTimeout.start(ie,()=>{ye&&F()&&e.setOpen(!0,Oe(We,K,$))}):ye&&F()&&e.setOpen(!0,Oe(We,K,$)))}function j(K){if(M()){_();return}D();const le=e.select("domReferenceElement"),ie=Ke(le);x.restTimeout.clear(),x.restTimeoutPending=!1;const L=g.current.floatingContext??(u==null?void 0:u());if(Fn(K.relatedTarget,e.context.triggerElements))return;if(E.current&&L){e.select("open")||x.openChangeTimeout.clear();const B=a.current;x.handler=E.current({...L,tree:y,x:K.clientX,y:K.clientY,onClose(){_(),D(),R.current&&!M()&&B===e.select("domReferenceElement")&&T(K,!0)}}),ie.addEventListener("mousemove",x.handler),x.handler(K);return}(x.pointerType==="touch"?!Te(e.select("floatingElement"),K.relatedTarget):!0)&&T(K)}function N(K){Te(k,K.relatedTarget)||(x.openChangeTimeout.clear(),x.restTimeout.clear(),x.restTimeoutPending=!1)}const Y=p?Ee(k,"mouseout",N):void 0;return c?at(Ee(k,"mousemove",U,{once:!0}),Ee(k,"mouseenter",U),Ee(k,"mouseleave",j),Y):at(Ee(k,"mouseenter",U),Ee(k,"mouseleave",j),Y)},[D,_,g,C,e,n,E,x,f,A,M,s,c,w,a,y,R,u,P,F,p]),v.useMemo(()=>{if(!n)return;function T(k){x.pointerType=k.pointerType}return{onPointerDown:T,onPointerEnter:T,onMouseMove(k){var L,X,B;const{nativeEvent:U}=k,j=k.currentTarget,N=e.select("domReferenceElement"),Y=e.select("open"),K=A(N,j,k.target);if(s&&!Lr(x.pointerType))return;if(Y&&K&&((L=x.handleCloseOptions)!=null&&L.blockPointerEvents)){const $=e.select("floatingElement");if($){const Q=((B=(X=x.handleCloseOptions)==null?void 0:X.getScope)==null?void 0:B.call(X))??j.ownerDocument.body;dc(x,{scopeElement:Q,referenceElement:j,floatingElement:$})}}const le=hs(w.current);if(Y&&!K||le===0||!K&&x.restTimeoutPending&&k.movementX**2+k.movementY**2<2)return;x.restTimeout.clear();function ie(){if(x.restTimeoutPending=!1,M())return;const $=e.select("open");!x.blockMouseMove&&(!$||K)&&F()&&e.setOpen(!0,Oe(We,U,j))}x.pointerType==="touch"?dt.flushSync(()=>{ie()}):K&&Y?ie():(x.restTimeoutPending=!0,x.restTimeout.start(le,ie))}}},[n,x,M,A,s,e,w,F])}const Os=.1,Rp=Os*Os,xe=.5;function Sn(e,t,n,r,o,s){return r>=t!=s>=t&&e<=(o-n)*(t-r)/(s-r)+n}function wn(e,t,n,r,o,s,i,c,a,l){let f=!1;return Sn(e,t,n,r,o,s)&&(f=!f),Sn(e,t,o,s,i,c)&&(f=!f),Sn(e,t,i,c,a,l)&&(f=!f),Sn(e,t,a,l,n,r)&&(f=!f),f}function Tp(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function Cn(e,t,n,r,o,s){const i=Math.min(n,o),c=Math.max(n,o),a=Math.min(r,s),l=Math.max(r,s);return e>=i&&e<=c&&t>=a&&t<=l}function Op(e={}){const{blockPointerEvents:t=!1}=e,n=new ut,r=({x:o,y:s,placement:i,elements:c,onClose:a,nodeId:l,tree:f})=>{const u=i==null?void 0:i.split("-")[0];let d=!1,m=null,p=null,g=typeof performance<"u"?performance.now():0;function b(x,S){const E=performance.now(),C=E-g;if(m===null||p===null||C===0)return m=x,p=S,g=E,!1;const w=x-m,R=S-p,O=w*w+R*R,P=C*C*Rp;return m=x,p=S,g=E,O<P}function y(){n.clear(),a()}return function(S){n.clear();const E=c.domReference,C=c.floating;if(!E||!C||u==null||o==null||s==null)return;const{clientX:w,clientY:R}=S,O=yt(S),P=S.type==="mouseleave",M=Te(C,O),F=Te(E,O);if(M&&(d=!0,!P))return;if(F&&(d=!1,!P)){d=!0;return}if(P&&ge(S.relatedTarget)&&Te(C,S.relatedTarget))return;function A(){return!!(f&&Dt(f.nodesRef.current,l).length>0)}function D(){A()||y()}if(A())return;const _=E.getBoundingClientRect(),T=C.getBoundingClientRect(),k=o>T.right-T.width/2,U=s>T.bottom-T.height/2,j=T.width>_.width,N=T.height>_.height,Y=(j?_:T).left,K=(j?_:T).right,le=(N?_:T).top,ie=(N?_:T).bottom;if(u==="top"&&s>=_.bottom-1||u==="bottom"&&s<=_.top+1||u==="left"&&o>=_.right-1||u==="right"&&o<=_.left+1){D();return}let L=!1;switch(u){case"top":L=Cn(w,R,Y,_.top+1,K,T.bottom-1);break;case"bottom":L=Cn(w,R,Y,T.top+1,K,_.bottom-1);break;case"left":L=Cn(w,R,T.right-1,ie,_.left+1,le);break;case"right":L=Cn(w,R,_.right-1,ie,T.left+1,le);break}if(L)return;if(d&&!Tp(w,R,_)){D();return}if(!P&&b(w,R)){D();return}let X=!1;switch(u){case"top":{const B=j?xe/2:xe*4,$=j||k?o+B:o-B,Q=j?o-B:k?o+B:o-B,re=s+xe+1,ee=k||j?T.bottom-xe:T.top,te=k?j?T.bottom-xe:T.top:T.bottom-xe;X=wn(w,R,$,re,Q,re,T.left,ee,T.right,te);break}case"bottom":{const B=j?xe/2:xe*4,$=j||k?o+B:o-B,Q=j?o-B:k?o+B:o-B,re=s-xe,ee=k||j?T.top+xe:T.bottom,te=k?j?T.top+xe:T.bottom:T.top+xe;X=wn(w,R,$,re,Q,re,T.left,ee,T.right,te);break}case"left":{const B=N?xe/2:xe*4,$=N||U?s+B:s-B,Q=N?s-B:U?s+B:s-B,re=o+xe+1,ee=U||N?T.right-xe:T.left,te=U?N?T.right-xe:T.left:T.right-xe;X=wn(w,R,ee,T.top,te,T.bottom,re,$,re,Q);break}case"right":{const B=N?xe/2:xe*4,$=N||U?s+B:s-B,Q=N?s-B:U?s+B:s-B,re=o-xe,ee=U||N?T.left+xe:T.right,te=U?N?T.left+xe:T.right:T.left+xe;X=wn(w,R,re,$,re,Q,ee,T.top,te,T.bottom);break}}X?d||n.start(40,D):D()}};return r.__options={...e,blockPointerEvents:t},r}function Ps(e,t,n){let{reference:r,floating:o}=e;const s=Ue(t),i=So(t),c=Eo(i),a=Ve(t),l=s==="y",f=r.x+r.width/2-o.width/2,u=r.y+r.height/2-o.height/2,d=r[c]/2-o[c]/2;let m;switch(a){case"top":m={x:f,y:r.y-o.height};break;case"bottom":m={x:f,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:u};break;case"left":m={x:r.x-o.width,y:u};break;default:m={x:r.x,y:r.y}}const p=Je(t);return p&&(m[i]+=d*(p==="end"?1:-1)*(n&&l?-1:1)),m}async function Pp(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:c,strategy:a}=e,{boundary:l="clippingAncestors",rootBoundary:f="viewport",elementContext:u="floating",altBoundary:d=!1,padding:m=0}=ft(t,e),p=Ji(m),b=c[d?u==="floating"?"reference":"floating":u],y=Vn(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(b)))==null||n?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(c.floating)),boundary:l,rootBoundary:f,strategy:a})),x=u==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c.floating)),E=await(s.isElement==null?void 0:s.isElement(S))&&await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1},C=Vn(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:x,offsetParent:S,strategy:a}):x);return{top:(y.top-C.top+p.top)/E.y,bottom:(C.bottom-y.bottom+p.bottom)/E.y,left:(y.left-C.left+p.left)/E.x,right:(C.right-y.right+p.right)/E.x}}const Ip=50,_p=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,c=i.detectOverflow?i:{...i,detectOverflow:Pp},a=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:u}=Ps(l,r,a),d=r,m=0;const p={};for(let g=0;g<s.length;g++){const b=s[g];if(!b)continue;const{name:y,fn:x}=b,{x:S,y:E,data:C,reset:w}=await x({x:f,y:u,initialPlacement:r,placement:d,strategy:o,middlewareData:p,rects:l,platform:c,elements:{reference:e,floating:t}});f=S??f,u=E??u,p[y]={...p[y],...C},w&&m<Ip&&(m++,typeof w=="object"&&(w.placement&&(d=w.placement),w.rects&&(l=w.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):w.rects),{x:f,y:u}=Ps(l,d,a)),g=-1)}return{x:f,y:u,placement:d,strategy:o,middlewareData:p}},kp=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:c,platform:a,elements:l}=t,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...b}=ft(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Ve(o),x=Ue(c),S=Ve(c)===c,E=await(a.isRTL==null?void 0:a.isRTL(l.floating)),C=d||(S||!g?[Bn(c)]:od(c)),w=p!=="none";!d&&w&&C.push(...ad(c,g,p,E));const R=[c,...C],O=await a.detectOverflow(t,b),P=[];let M=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&P.push(O[y]),u){const _=rd(o,i,E);P.push(O[_[0]],O[_[1]])}if(M=[...M,{placement:o,overflows:P}],!P.every(_=>_<=0)){var F,A;const _=(((F=s.flip)==null?void 0:F.index)||0)+1,T=R[_];if(T&&(!(u==="alignment"?x!==Ue(T):!1)||M.every(j=>Ue(j.placement)===x?j.overflows[0]>0:!0)))return{data:{index:_,overflows:M},reset:{placement:T}};let k=(A=M.filter(U=>U.overflows[0]<=0).sort((U,j)=>U.overflows[1]-j.overflows[1])[0])==null?void 0:A.placement;if(!k)switch(m){case"bestFit":{var D;const U=(D=M.filter(j=>{if(w){const N=Ue(j.placement);return N===x||N==="y"}return!0}).map(j=>[j.placement,j.overflows.filter(N=>N>0).reduce((N,Y)=>N+Y,0)]).sort((j,N)=>j[1]-N[1])[0])==null?void 0:D[0];U&&(k=U);break}case"initialPlacement":k=c;break}if(o!==k)return{reset:{placement:k}}}return{}}}},hc=new Set(["left","top"]);async function Ap(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Ve(n),c=Je(n),a=Ue(n)==="y",l=hc.has(i)?-1:1,f=s&&a?-1:1,u=ft(t,e);let{mainAxis:d,crossAxis:m,alignmentAxis:p}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return c&&typeof p=="number"&&(m=c==="end"?p*-1:p),a?{x:m*f,y:d*l}:{x:d*l,y:m*f}}const Np=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:c}=t,a=await Ap(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:o+a.x,y:s+a.y,data:{...a,placement:i}}}}},jp=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:s}=t,{mainAxis:i=!0,crossAxis:c=!1,limiter:a={fn:x=>{let{x:S,y:E}=x;return{x:S,y:E}}},...l}=ft(e,t),f={x:n,y:r},u=await s.detectOverflow(t,l),d=Ue(o),m=xo(d);let p=f[m],g=f[d];const b=(x,S)=>Xi(S+u[x==="y"?"top":"left"],S,S-u[x==="y"?"bottom":"right"]);i&&(p=b(m,p)),c&&(g=b(d,g));const y=a.fn({...t,[m]:p,[d]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[m]:i,[d]:c}}}}}},Mp=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:o,y:s,placement:i,rects:c,middlewareData:a}=t,{offset:l=0,mainAxis:f=!0,crossAxis:u=!0}=ft(e,t),d={x:o,y:s},m=Ue(i),p=xo(m);let g=d[p],b=d[m];const y=ft(l,t),x=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:(n=y.mainAxis)!=null?n:0,crossAxis:(r=y.crossAxis)!=null?r:0};if(f){const C=p==="y"?"height":"width",w=c.reference[p]-c.floating[C]+x.mainAxis,R=c.reference[p]+c.reference[C]-x.mainAxis;g<w?g=w:g>R&&(g=R)}if(u){var S,E;const C=p==="y"?"width":"height",w=hc.has(Ve(i)),R=c.reference[m]-c.floating[C]+(w&&((S=a.offset)==null?void 0:S[m])||0)+(w?0:x.crossAxis),O=c.reference[m]+c.reference[C]+(w?0:((E=a.offset)==null?void 0:E[m])||0)-(w?x.crossAxis:0);b<R?b=R:b>O&&(b=O)}return{[p]:g,[m]:b}}}},Dp=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:o,elements:s}=t,{apply:i=()=>{},...c}=ft(e,t),a=await o.detectOverflow(t,c),l=Ve(n),f=Je(n),u=Ue(n)==="y",{width:d,height:m}=r.floating;let p,g;l==="top"||l==="bottom"?(p=l,g=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(g=l,p=f==="end"?"top":"bottom");const b=m-a.top-a.bottom,y=d-a.left-a.right,x=Mt(m-a[p],b),S=Mt(d-a[g],y),E=t.middlewareData.shift,C=!E;let w=x,R=S;E!=null&&E.enabled.x&&(R=y),E!=null&&E.enabled.y&&(w=b),C&&!f&&(u?R=d-2*nt(a.left,a.right):w=m-2*nt(a.top,a.bottom)),await i({...t,availableWidth:R,availableHeight:w});const O=await o.getDimensions(s.floating);return d!==O.width||m!==O.height?{reset:{rects:!0}}:{}}}};function mc(e){const t=$e(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=_e(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,c=Ln(n)!==s||Ln(r)!==i;return c&&(n=s,r=i),{width:n,height:r,$:c}}function ko(e){return ge(e)?e:e.contextElement}function kt(e){const t=ko(e);if(!_e(t))return rt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=mc(t);let i=(s?Ln(n.width):n.width)/r,c=(s?Ln(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Fp=rt(0);function gc(e){const t=Ie(e);return!lo()||!t.visualViewport?Fp:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Lp(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Ie(e)}function St(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ko(e);let i=rt(1);t&&(r?ge(r)&&(i=kt(r)):i=kt(e));const c=Lp(s,n,r)?gc(s):rt(0);let a=(o.left+c.x)/i.x,l=(o.top+c.y)/i.y,f=o.width/i.x,u=o.height/i.y;if(s&&r){const d=Ie(s),m=ge(r)?Ie(r):r;let p=d,g=Ir(p);for(;g&&m!==p;){const b=kt(g),y=g.getBoundingClientRect(),x=$e(g),S=y.left+(g.clientLeft+parseFloat(x.paddingLeft))*b.x,E=y.top+(g.clientTop+parseFloat(x.paddingTop))*b.y;a*=b.x,l*=b.y,f*=b.x,u*=b.y,a+=S,l+=E,p=Ie(g),g=Ir(p)}}return Vn({width:f,height:u,x:a,y:l})}function nr(e,t){const n=Zn(e).scrollLeft;return t?t.left+n:St(ot(e)).left+n}function bc(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-nr(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Bp(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=ot(r),c=t?Jn(t.floating):!1;if(r===i||c&&s)return n;let a={scrollLeft:0,scrollTop:0},l=rt(1);const f=rt(0),u=_e(r);if((u||!s)&&((Le(r)!=="body"||Xn(i))&&(a=Zn(r)),u)){const m=St(r);l=kt(r),f.x=m.x+r.clientLeft,f.y=m.y+r.clientTop}const d=i&&!u&&!s?bc(i,a):rt(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-a.scrollLeft*l.x+f.x+d.x,y:n.y*l.y-a.scrollTop*l.y+f.y+d.y}}function Vp(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function $p(e){const t=Zn(e),n=e.ownerDocument.body,r=nt(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),o=nt(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-t.scrollLeft+nr(e);const i=-t.scrollTop;return $e(n).direction==="rtl"&&(s+=nt(e.clientWidth,n.clientWidth)-r),{width:r,height:o,x:s,y:i}}const Hp=25;function Up(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",o=Ie(e),s=ot(e),i=o.visualViewport;let c=s.clientWidth,a=s.clientHeight,l=0,f=0;if(i){const d=!lo()||t==="fixed";r?d||(l=-i.offsetLeft,f=-i.offsetTop):(c=i.width,a=i.height,d&&(l=i.offsetLeft,f=i.offsetTop))}if(nr(s)<=0){const d=s.ownerDocument,m=d.body,p=getComputedStyle(m),g=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,b=Math.abs(s.clientWidth-m.clientWidth-g),y=getComputedStyle(s).scrollbarGutter==="stable both-edges"?b/2:b;y<=Hp&&(c-=y)}return{width:c,height:a,x:l,y:f}}function zp(e,t){const n=St(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=kt(e),i=e.clientWidth*s.x,c=e.clientHeight*s.y,a=o*s.x,l=r*s.y;return{width:i,height:c,x:a,y:l}}function Is(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=Up(e,n,t);else if(t==="document")r=$p(ot(e));else if(ge(t))r=zp(t,n);else{const o=gc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Vn(r)}function Wp(e,t){const n=t.get(e);if(n)return n;let r=Gt(e,[],!1).filter(c=>ge(c)&&Le(c)!=="body"),o=null;const s=$e(e).position==="fixed";let i=s?lt(e):e;for(;ge(i)&&!ct(i);){const c=$e(i),a=ao(i),l=o?o.position:s?"fixed":"";!a&&(l==="fixed"||l==="absolute"&&c.position==="static")?r=r.filter(u=>u!==i):o=c,i=lt(i)}return t.set(e,r),r}function qp(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Jn(t)?[]:Wp(t,this._c):[].concat(n),r],c=Is(t,i[0],o);let a=c.top,l=c.right,f=c.bottom,u=c.left;for(let d=1;d<i.length;d++){const m=Is(t,i[d],o);a=nt(m.top,a),l=Mt(m.right,l),f=Mt(m.bottom,f),u=nt(m.left,u)}return{width:l-u,height:f-a,x:u,y:a}}function Gp(e){const{width:t,height:n}=mc(e);return{width:t,height:n}}function Kp(e,t,n){const r=_e(t),o=ot(t),s=n==="fixed",i=St(e,!0,s,t);let c={scrollLeft:0,scrollTop:0};const a=rt(0);if((r||!s)&&((Le(t)!=="body"||Xn(o))&&(c=Zn(t)),r)){const d=St(t,!0,s,t);a.x=d.x+t.clientLeft,a.y=d.y+t.clientTop}!r&&o&&(a.x=nr(o));const l=o&&!r&&!s?bc(o,c):rt(0),f=i.left+c.scrollLeft-a.x-l.x,u=i.top+c.scrollTop-a.y-l.y;return{x:f,y:u,width:i.width,height:i.height}}function Er(e){return $e(e).position==="static"}function _s(e,t){if(!_e(e)||$e(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ot(e)===n&&(n=n.ownerDocument.body),n}function yc(e,t){const n=Ie(e);if(Jn(e))return n;if(!_e(e)){let o=lt(e);for(;o&&!ct(o);){if(ge(o)&&!Er(o))return o;o=lt(o)}return n}let r=_s(e,t);for(;r&&xl(r)&&Er(r);)r=_s(r,t);return r&&ct(r)&&Er(r)&&!ao(r)?n:r||wl(e)||n}const Yp=async function(e){const t=this.getOffsetParent||yc,n=this.getDimensions,r=await n(e.floating);return{reference:Kp(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Xp(e){return $e(e).direction==="rtl"}const Jp={convertOffsetParentRelativeRectToViewportRelativeRect:Bp,getDocumentElement:ot,getClippingRect:qp,getOffsetParent:yc,getElementRects:Yp,getClientRects:Vp,getDimensions:Gp,getScale:kt,isElement:ge,isRTL:Xp};function vc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Zp(e,t,n){let r=null,o;const s=ot(e);function i(){var f;clearTimeout(o),(f=r)==null||f.disconnect(),r=null}function c(f,u){f===void 0&&(f=!1),u===void 0&&(u=1),i();const d=e.getBoundingClientRect(),{left:m,top:p,width:g,height:b}=d;if(f||t(),!g||!b)return;const y=vn(p),x=vn(s.clientWidth-(m+g)),S=vn(s.clientHeight-(p+b)),E=vn(m),w={rootMargin:-y+"px "+-x+"px "+-S+"px "+-E+"px",threshold:nt(0,Mt(1,u))||1};let R=!0;function O(P){const M=P[0].intersectionRatio;if(!vc(d,e.getBoundingClientRect()))return c();if(M!==u){if(!R)return c();M?c(!1,M):o=setTimeout(()=>{c(!1,1e-7)},1e3)}R=!1}try{r=new IntersectionObserver(O,{...w,root:s.ownerDocument})}catch{r=new IntersectionObserver(O,w)}r.observe(e)}const a=Ie(e),l=()=>c(n);return a.addEventListener("resize",l),c(!0),()=>{a.removeEventListener("resize",l),i()}}function ks(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,l=ko(e),f=o||s?[...l?Gt(l):[],...t?Gt(t):[]]:[];f.forEach(y=>{o&&y.addEventListener("scroll",n),s&&y.addEventListener("resize",n)});const u=l&&c?Zp(l,n,s):null;let d=-1,m=null;i&&(m=new ResizeObserver(y=>{let[x]=y;x&&x.target===l&&m&&t&&(m.unobserve(t),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var S;(S=m)==null||S.observe(t)})),n()}),l&&!a&&m.observe(l),t&&m.observe(t));let p,g=a?St(e):null;a&&b();function b(){const y=St(e);g&&!vc(g,y)&&n(),g=y,p=requestAnimationFrame(b)}return n(),()=>{var y;f.forEach(x=>{o&&x.removeEventListener("scroll",n),s&&x.removeEventListener("resize",n)}),u==null||u(),(y=m)==null||y.disconnect(),m=null,a&&cancelAnimationFrame(p)}}const Qp=Np,eh=jp,th=kp,nh=Dp,rh=Mp,oh=(e,t,n)=>{const r=new Map,o=n??{},s={...Jp,...o.platform,_c:r};return _p(e,t,{...o,platform:s})};var sh=typeof document<"u",ih=function(){},_n=sh?I.useLayoutEffect:ih;function Wn(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(!Wn(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Wn(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function xc(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function As(e,t){const n=xc(e);return Math.round(t*n)/n}function Sr(e){const t=v.useRef(e);return _n(()=>{t.current=e}),t}function ch(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:c=!0,whileElementsMounted:a,open:l}=e,[f,u]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[d,m]=v.useState(r);Wn(d,r)||m(r);const[p,g]=v.useState(null),[b,y]=v.useState(null),x=v.useCallback(j=>{j!==w.current&&(w.current=j,g(j))},[]),S=v.useCallback(j=>{j!==R.current&&(R.current=j,y(j))},[]),E=s||p,C=i||b,w=v.useRef(null),R=v.useRef(null),O=v.useRef(f),P=a!=null,M=Sr(a),F=Sr(o),A=Sr(l),D=v.useCallback(()=>{if(!w.current||!R.current)return;const j={placement:t,strategy:n,middleware:d};F.current&&(j.platform=F.current),oh(w.current,R.current,j).then(N=>{const Y={...N,isPositioned:A.current!==!1};_.current&&!Wn(O.current,Y)&&(O.current=Y,dt.flushSync(()=>{u(Y)}))})},[d,t,n,F,A]);_n(()=>{l===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,u(j=>({...j,isPositioned:!1})))},[l]);const _=v.useRef(!1);_n(()=>(_.current=!0,()=>{_.current=!1}),[]),_n(()=>{if(E&&(w.current=E),C&&(R.current=C),E&&C){if(M.current)return M.current(E,C,D);D()}},[E,C,D,M,P]);const T=v.useMemo(()=>({reference:w,floating:R,setReference:x,setFloating:S}),[x,S]),k=v.useMemo(()=>({reference:E,floating:C}),[E,C]),U=v.useMemo(()=>{const j={position:n,left:0,top:0};if(!k.floating)return j;const N=As(k.floating,f.x),Y=As(k.floating,f.y);return c?{...j,transform:"translate("+N+"px, "+Y+"px)",...xc(k.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:N,top:Y}},[n,c,k.floating,f.x,f.y]);return v.useMemo(()=>({...f,update:D,refs:T,elements:k,floatingStyles:U}),[f,D,T,k,U])}const ah=(e,t)=>{const n=Qp(e);return{name:n.name,fn:n.fn,options:[e,t]}},lh=(e,t)=>{const n=eh(e);return{name:n.name,fn:n.fn,options:[e,t]}},uh=(e,t)=>({fn:rh(e).fn,options:[e,t]}),fh=(e,t)=>{const n=th(e);return{name:n.name,fn:n.fn,options:[e,t]}},dh=(e,t)=>{const n=nh(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ao=v.createContext(void 0);process.env.NODE_ENV!=="production"&&(Ao.displayName="PreviewCardRootContext");function cn(e){const t=v.useContext(Ao);if(t===void 0&&!e)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: PreviewCardRootContext is missing. PreviewCard parts must be placed within <PreviewCard.Root>.":wt(50));return t}class ph extends Io{setState(t){}update(t){}set(t,n){}notifyAll(){}}const hh=600,Ec=300,Sc={...vp,instantType:e=>e.instantType,adaptiveOrigin:e=>e.adaptiveOrigin,closeDelay:e=>e.closeDelay};class mh extends Io{constructor(n,r,o){const s=new lc;super(wc(n,s,r,o),Cc(s),Sc);ae(this,"setOpen",(n,r)=>{const{inlineRectCoordsRef:o}=this.context;Jd(this,n,r,{onBeforeDispatch(){var i;const s=r.event;n&&r.reason===We&&r.trigger&&"clientX"in s&&"clientY"in s&&((i=o.current)==null?void 0:i.element)!==r.trigger&&ac(o,r.trigger,s.clientX,s.clientY)}})})}}function gh(){const e=new lc;return new ph(Object.freeze(wc(void 0,e)),Object.freeze(Cc(e)),Sc)}function wc(e,t,n,r=!1){return{...bp(t,n,r),instantType:void 0,adaptiveOrigin:void 0,closeDelay:Ec,...e}}function Cc(e){return{popupRef:v.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e,inlineRectCoordsRef:{current:void 0}}}function Ns(e){const{open:t,defaultOpen:n=!1,onOpenChange:r,onOpenChangeComplete:o,actionsRef:s,handle:i,triggerId:c,defaultTriggerId:a=null,children:l}=e,f=qd((y,x)=>new mh({open:n,openProp:t,activeTriggerId:a,triggerIdProp:c},y,x));f.useControlledProp("openProp",t),f.useControlledProp("triggerIdProp",c),f.useContextCallback("onOpenChange",r),f.useContextCallback("onOpenChangeComplete",o);const u=f.useState("open"),d=f.useState("activeTriggerId"),m=f.useState("mounted"),p=f.useState("payload");Qd(f,{closeOnActiveTriggerUnmount:!0});const{forceUnmount:g}=ep(u,f,()=>{f.context.inlineRectCoordsRef.current=void 0});pe(()=>{u&&d==null&&f.set("payload",void 0)},[f,d,u]),v.useImperativeHandle(s,()=>({unmount:g,close:()=>f.setOpen(!1,Oe(Pr))}),[g,f]);const b=u||m||i!=null;return h.jsxs(Ao.Provider,{value:f,children:[i&&h.jsx(Gd,{handle:i,store:f}),b&&h.jsx(bh,{store:f}),typeof l=="function"?l({payload:p}):l]})}function bh({store:e}){const t=e.useState("floatingRootContext"),n=Md(t);return tp(e,{activeTriggerProps:n.reference,inactiveTriggerProps:n.trigger,popupProps:n.floating}),null}const Rc=zi(function(t){return cn(!0)?h.jsx(Ns,{...t}):h.jsx(Ad,{children:h.jsx(Ns,{...t})})});process.env.NODE_ENV!=="production"&&(Rc.displayName="PreviewCardRoot");const No=v.createContext(void 0);process.env.NODE_ENV!=="production"&&(No.displayName="PreviewCardPortalContext");function yh(){const e=v.useContext(No);if(e===void 0)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: <PreviewCard.Portal> is missing.":wt(48));return e}const Tc=v.forwardRef(function(t,n){const{children:r,container:o,className:s,render:i,style:c,...a}=t,{node:l,subtree:f}=oc({container:o,ref:n,componentProps:t,elementProps:a});return!f&&!l?null:h.jsxs(v.Fragment,{children:[f,l&&dt.createPortal(r,l)]})});process.env.NODE_ENV!=="production"&&(Tc.displayName="FloatingPortalLite");const Oc=v.forwardRef(function(t,n){const{keepMounted:r=!1,...o}=t;return cn().useState("mounted")||r?h.jsx(No.Provider,{value:r,children:h.jsx(Tc,{ref:n,...o})}):null});process.env.NODE_ENV!=="production"&&(Oc.displayName="PreviewCardPortal");const Pc=Cf(function(t,n){const{render:r,className:o,delay:s,closeDelay:i,id:c,payload:a,handle:l,style:f,...u}=t,d=cn(!0),p=xp(l)??d;if(!p)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: <PreviewCard.Trigger> must be either used within a <PreviewCard.Root> component or provided with a handle.":wt(89));const g=gi(c),b=p.useState("isTriggerActive",g),y=p.useState("isOpenedByTrigger",g),x=p.useState("floatingRootContext"),S=p.context.inlineRectCoordsRef,E=v.useRef(null),C=s??hh,w=i??Ec,{registerTrigger:R,isMountedByThisTrigger:O}=Zd(g,E,p,{payload:a,closeDelay:w}),P=Cp(x,{mouseOnly:!0,move:!1,handleClose:Op(),delay:()=>({open:C,close:w}),triggerElementRef:E,isActiveTrigger:b,isClosing:()=>p.select("transitionStatus")==="ending"}),M=Ep(x,{delay:C}),F={open:y},A=p.useState("triggerProps",O),D=Vd(S,y);return pt("a",t,{state:F,ref:[n,R,E],props:[P,M.reference,A,D,{id:g},u],stateAttributesMapping:qf})});process.env.NODE_ENV!=="production"&&(Pc.displayName="PreviewCardTrigger");const jo=v.createContext(void 0);process.env.NODE_ENV!=="production"&&(jo.displayName="PreviewCardPositionerContext");function vh(){const e=v.useContext(jo);if(e===void 0)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: PreviewCardPositionerContext is missing. PreviewCardPositioner parts must be placed within <PreviewCard.Positioner>.":wt(49));return e}function xh(e){const{nodeId:t,externalTree:n,rootContext:r}=e,o=r.useState("referenceElement"),s=r.useState("floatingElement"),i=r.useState("domReferenceElement"),c=r.useState("open"),a=r.useState("floatingId"),[l,f]=v.useState(null),u=v.useRef(null),d=sn(n),m=v.useMemo(()=>({reference:o,floating:s,domReference:i}),[o,s,i]),p=ch({...e,elements:{...m,...l&&{reference:l}}}),g=v.useCallback(S=>{const E=ge(S)?{getBoundingClientRect:()=>S.getBoundingClientRect(),getClientRects:()=>S.getClientRects(),contextElement:S}:S;f(E),p.refs.setReference(E)},[p.refs]),b=v.useMemo(()=>({...p.refs,setPositionReference:g,domReference:u}),[p.refs,g]),y=v.useMemo(()=>({...p.elements,domReference:i}),[p.elements,i]),x=v.useMemo(()=>({...p,dataRef:r.context.dataRef,open:c,onOpenChange:r.setOpen,events:r.context.events,floatingId:a,refs:b,elements:y,nodeId:t,rootStore:r}),[p,b,y,t,r,c,a]);return pe(()=>{i&&(u.current=i)},[i]),pe(()=>{r.context.dataRef.current.floatingContext=x;const S=d==null?void 0:d.nodesRef.current.find(E=>E.id===t);S&&(S.context=x)}),v.useMemo(()=>({...p,context:x,refs:b,elements:y,rootStore:r}),[p,b,y,x,r])}const Ic=v.createContext(void 0);process.env.NODE_ENV!=="production"&&(Ic.displayName="DirectionContext");function Eh(){const e=v.useContext(Ic);return(e==null?void 0:e.direction)??"ltr"}const Sh=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:c,middlewareData:a}=t,{element:l,padding:f=0}=ft(e,t)||{};if(l==null)return{};const u=Ji(f),d={x:n,y:r},m=So(o),p=Eo(m),g=await i.getDimensions(l),b=m==="y",y=b?"top":"left",x=b?"bottom":"right",S=b?"clientHeight":"clientWidth",E=s.reference[p]+s.reference[m]-d[m]-s.floating[p],C=d[m]-s.reference[m],w=c.floating[S]||s.floating[p],R=E/2-C/2,O=w/2-g[p]/2-1,P=Math.min(u[y],O),M=Math.min(u[x],O),F=P,A=w-g[p]-M,D=w/2-g[p]/2+R,_=Xi(F,D,A),T=!a.arrow&&Je(o)!=null&&D!==_&&s.reference[p]/2-(D<F?P:M)-g[p]/2<0,k=T?D<F?D-F:D-A:0;return{[m]:d[m]+k,data:{[m]:_,centerOffset:D-_-k,...T&&{alignmentOffset:k}},reset:T}}}),wh=(e,t)=>{const{name:n,fn:r}=Sh(e);return{name:n,fn:r,options:[e,t]}},Ch={name:"hide",async fn(e){const{width:t,height:n,x:r,y:o}=e.rects.reference,s=t===0&&n===0&&r===0&&o===0,i=await e.platform.detectOverflow(e,{elementContext:"reference"});return{data:{referenceHidden:i.top-n>=0||i.right-t>=0||i.bottom-n>=0||i.left-t>=0||s}}}},Rh={sideX:"left",sideY:"top"},Th="--available-width",Oh="--available-height",Ph="--anchor-width",Ih="--anchor-height",_h="--transform-origin",js=Th,Ms=Oh;function _c(e,t,n){const r=e==="inline-start"||e==="inline-end";return{top:"top",right:r?n?"inline-start":"inline-end":"right",bottom:"bottom",left:r?n?"inline-end":"inline-start":"left"}[t]}function Ds(e,t,n){const{rects:r,placement:o}=e;return{side:_c(t,Ve(o),n),align:Je(o)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function kh(e){return Ah(e,xh)}function Ah(e,t){var Vt,ln;const{anchor:n,positionMethod:r="absolute",side:o="bottom",sideOffset:s=0,align:i="center",alignOffset:c=0,collisionBoundary:a,collisionPadding:l=5,sticky:f=!1,arrowPadding:u=5,disableAnchorTracking:d=!1,inline:m,keepMounted:p=!1,floatingRootContext:g,mounted:b,collisionAvoidance:y,shift:x,nodeId:S,adaptiveOrigin:E,lazyFlip:C=!1,externalTree:w}=e,R=y.side||"flip",O=y.align||"flip",P=y.fallbackAxisSide||"end",M=(x==null?void 0:x.crossAxis)??!1,F=x==null?void 0:x.rootBoundary,A=typeof n=="function"?n:void 0,D=fe(A),_=A?D:n,T=qe(n),k=qe(b),j=Eh()==="rtl",[N,Y]=v.useState(null);!b&&N!==null&&Y(null);const K=C==="placement",le=N?Ve(N):null,ie=N&&K?Je(N)||"center":null,L=le||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":j?"left":"right","inline-start":j?"right":"left"}[o],X=ie||i,B=X==="center"?L:`${L}-${X}`;let $=l;typeof $=="number"?$={top:$,right:$,bottom:$,left:$}:$&&($={top:$.top||0,right:$.right||0,bottom:$.bottom||0,left:$.left||0});const Q=1,re=o==="bottom"?Q:0,ee=o==="top"?Q:0,te=o==="right"?Q:0,z=o==="left"?Q:0,ne={boundary:a==="clipping-ancestors"?"clippingAncestors":a,padding:$},oe=v.useRef(null),ye=qe(s),q=qe(c),J=typeof s!="function"?s:0,ce=typeof c!="function"?c:0,he=[];m&&he.push(m),he.push(ah(de=>{const Ae=Ds(de,o,j),He=typeof ye.current=="function"?ye.current(Ae):ye.current,De=typeof q.current=="function"?q.current(Ae):q.current;return{mainAxis:He,crossAxis:De,alignmentAxis:De}},[J,ce,j,o]));const Pe=O==="none"&&R!=="shift",je=!Pe&&(f||M||R==="shift"),Re=R==="none"?null:fh({...ne,padding:{top:$.top+Q+re,right:$.right+Q+z,bottom:$.bottom+Q+ee,left:$.left+Q+te},mainAxis:!M&&R==="flip",crossAxis:O==="flip"?"alignment":!1,fallbackAxisSideDirection:P}),Me=Pe?null:lh({...ne,rootBoundary:F,mainAxis:O!=="none",crossAxis:je,limiter:f||M?void 0:uh(de=>{if(!oe.current)return{};const{width:Ae,height:He}=oe.current.getBoundingClientRect(),De=Ue(Ve(de.placement)),Xe=De==="y"?Ae:He,ze=De==="y"?$.left+$.right:$.top+$.bottom;return{offset:Xe/2+ze/2}})},[ne,f,M,F,$,O]);R==="shift"||O==="shift"||X==="center"?he.push(Me,Re):he.push(Re,Me),he.push(dh({...ne,apply({elements:{floating:de},availableWidth:Ae,availableHeight:He,rects:De}){if(!k.current)return;const Xe=de.style;Xe.setProperty(js,`${Ae}px`),Xe.setProperty(Ms,`${He}px`);const ze=Ie(de).devicePixelRatio||1,{x:un,y:Tt,width:fn,height:it}=De.reference,et=(Math.round((un+fn)*ze)-Math.round(un*ze))/ze,$t=(Math.round((Tt+it)*ze)-Math.round(Tt*ze))/ze;Xe.setProperty(Ph,`${et}px`),Xe.setProperty(Ih,`${$t}px`)}}),wh(de=>({element:oe.current||Ke(de.elements.floating).createElement("div"),padding:oe.current?u:0}),[u]),{name:"transformOrigin",fn(de){var Lo,Bo,Vo,$o,Ho,Uo;const{elements:{floating:Ae},middlewareData:He,placement:De,platform:Xe,rects:ze,y:un}=de,Tt=Ve(De),fn=Je(De),it=Ue(Tt)==="y",et=oe.current,$t=typeof s=="function"?s(Ds(de,o,j)):s;let dn;if(!et&&fn&&Math.abs(it?((Lo=He.shift)==null?void 0:Lo.x)||0:((Bo=He.shift)==null?void 0:Bo.y)||0)<=1)dn=fn==="start"===(it&&((Vo=Xe.isRTL)==null?void 0:Vo.call(Xe,Ae))===!0)?"100%":"0%";else{const $c=it?(($o=He.arrow)==null?void 0:$o.x)||0:((Ho=He.arrow)==null?void 0:Ho.y)||0,Hc=it?(et==null?void 0:et.clientWidth)||0:(et==null?void 0:et.clientHeight)||0;dn=`${$c+Hc/2}px`}let rr=Tt==="top"||Tt==="left"?`calc(100% + ${$t}px)`:`${-$t}px`;return je&&it&&Math.abs(((Uo=He.shift)==null?void 0:Uo.y)||0)>$t&&(rr=`${ze.reference.y+ze.reference.height/2-un}px`),Ae.style.setProperty(_h,it?`${dn} ${rr}`:`${rr} ${dn}`),{}}},Ch,E),pe(()=>{!b&&g&&g.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[b,g]);const Be=v.useMemo(()=>({ancestorScroll:!d,elementResize:!d&&typeof ResizeObserver<"u",layoutShift:!d&&typeof IntersectionObserver<"u"}),[d]),{refs:H,elements:G,x:Se,y:be,middlewareData:me,update:V,placement:W,context:Z,isPositioned:se,floatingStyles:ke}=t({rootContext:g,open:p?b:void 0,placement:B,middleware:he,strategy:r,whileElementsMounted:p?void 0:(...de)=>ks(...de,Be),nodeId:S,externalTree:w}),{sideX:Ce,sideY:Ct}=me.adaptiveOrigin||Rh,st=se?r:"fixed",Rt=v.useMemo(()=>{let de;return se?E?de={position:st,[Ce]:Se,[Ct]:be}:de={...ke,position:st}:de={position:st,top:0,left:0},de[js]="100vw",de[Ms]="100vh",se||(de.opacity=0),de},[E,st,Ce,Se,Ct,be,ke,se]),Ze=v.useRef(null);pe(()=>{if(!b)return;const de=T.current,Ae=typeof de=="function"?de():de,De=(Fs(Ae)?Ae.current:Ae)||null||null;De!==Ze.current&&(H.setPositionReference(De),Ze.current=De)},[b,H,_,T]),v.useEffect(()=>{if(!b)return;const de=T.current;typeof de!="function"&&Fs(de)&&de.current!==Ze.current&&(H.setPositionReference(de.current),Ze.current=de.current)},[b,H,_,T]),v.useEffect(()=>{if(p&&b&&G.reference&&G.floating)return ks(G.reference,G.floating,V,Be)},[p,b,G,V,Be]);const Qe=Ve(W),ht=_c(o,Qe,j),mt=Je(W)||"center",Lt=!!((Vt=me.hide)!=null&&Vt.referenceHidden);pe(()=>{C&&b&&se&&(Qe!==L||K&&mt!==X)&&Y(W)},[C,K,b,se,W,Qe,mt,L,X]);const an=v.useMemo(()=>{var de,Ae;return{position:"absolute",top:(de=me.arrow)==null?void 0:de.y,left:(Ae=me.arrow)==null?void 0:Ae.x}},[me.arrow]),Bt=((ln=me.arrow)==null?void 0:ln.centerOffset)!==0;return v.useMemo(()=>({positionerStyles:Rt,arrowStyles:an,arrowRef:oe,arrowUncentered:Bt,side:ht,align:mt,physicalSide:Qe,anchorHidden:Lt,refs:H,context:Z,isPositioned:se,update:V}),[Rt,an,oe,Bt,ht,mt,Qe,Lt,H,Z,se,V])}function Fs(e){return e!=null&&"current"in e}function kc(e){return e==="starting"?wd:Fe}function Nh(e,t,{styles:n,transitionStatus:r,props:o,refs:s,hidden:i,inert:c=!1}){const a={...n};return c&&(a.pointerEvents="none"),pt("div",e,{state:t,ref:s,props:[{role:"presentation",hidden:i,style:a},kc(r),o],stateAttributesMapping:Ki})}const Ac=v.forwardRef(function(t,n){const{render:r,className:o,anchor:s,positionMethod:i="absolute",side:c="bottom",align:a="center",sideOffset:l=0,alignOffset:f=0,collisionBoundary:u="clipping-ancestors",collisionPadding:d=5,arrowPadding:m=5,sticky:p=!1,disableAnchorTracking:g=!1,collisionAvoidance:b=Cd,style:y,...x}=t,S=cn(),E=yh(),C=_d(),w=S.useState("open"),R=S.useState("mounted"),O=S.useState("floatingRootContext"),P=S.useState("instantType"),M=S.useState("transitionStatus"),F=S.useState("adaptiveOrigin"),A=S.context.inlineRectCoordsRef,D=kh({anchor:s,floatingRootContext:O,positionMethod:i,mounted:R,side:c,sideOffset:l,align:a,alignOffset:f,arrowPadding:m,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:g,keepMounted:E,nodeId:C,collisionAvoidance:b,adaptiveOrigin:F,inline:$d(A)}),_=D.update;pe(()=>{w&&R&&_()},[w,R,_]);const T={open:w,side:D.side,align:D.align,anchorHidden:D.anchorHidden,instant:P},k=Nh(t,T,{styles:D.positionerStyles,transitionStatus:M,props:x,refs:[n,S.useStateSetter("positionerElement")],hidden:!R,inert:!w});return h.jsx(jo.Provider,{value:D,children:h.jsx(kd,{id:C,children:k})})});process.env.NODE_ENV!=="production"&&(Ac.displayName="PreviewCardPositioner");const Nc=v.forwardRef(function(t,n){const{className:r,render:o,style:s,...i}=t,c=cn(),{side:a,align:l}=vh(),f=c.useState("open"),u=c.useState("instantType"),d=c.useState("transitionStatus"),m=c.useState("popupProps"),p=c.useState("floatingRootContext"),g=c.useState("closeDelay");return uo({open:f,ref:c.context.popupRef,onComplete(){var x,S;f&&((S=(x=c.context).onOpenChangeComplete)==null||S.call(x,!0))}}),Sp(p,{closeDelay:g}),pt("div",t,{state:{open:f,side:a,align:l,instant:u,transitionStatus:d},ref:[n,c.context.popupRef,c.useStateSetter("popupElement")],props:[Wd,m,kc(d),i],stateAttributesMapping:Gf})});process.env.NODE_ENV!=="production"&&(Nc.displayName="PreviewCardPopup");class jh extends Hd{constructor(){super(gh(),"PreviewCard")}open(t){this.openByTrigger(t)}close(){this.closePopup()}get isOpen(){var t;return((t=this.attachedStore)==null?void 0:t.select("open"))??!1}}function Mh(){return new jh}const Dh=Mh;function Fh(e){return h.jsx(Rc,{...e})}function Lh(e){return h.jsx(Pc,{"data-slot":"hover-card-trigger",...e})}function Bh({className:e,side:t="bottom",sideOffset:n=6,align:r="center",alignOffset:o=0,...s}){return h.jsx(Oc,{children:h.jsx(Ac,{align:r,alignOffset:o,side:t,sideOffset:n,className:"vps-hover-card-positioner",children:h.jsx(Nc,{"data-slot":"hover-card-content",...s,className:i=>ue("vps-hover-card",typeof e=="function"?e(i):e)})})})}function Vh({className:e,...t}){return h.jsx("span",{className:ue("inline-citation",e),...t})}const Mo=I.createContext(null);function jc(e){!e.popup||!e.focusRequested||!e.handle.isOpen||(e.focusRequested=!1,e.popup.focus())}function $h({handle:e,onOpenChange:t,openDelay:n=80,closeDelay:r=180,...o}){const[s]=I.useState(()=>Dh()),i=e??s,c=I.useMemo(()=>({handle:i,openDelay:n,closeDelay:r,trigger:null,popup:null,focusRequested:!1}),[i,n,r]);return h.jsx(Mo.Provider,{value:c,children:h.jsx(Fh,{...o,handle:i,onOpenChange:(a,l)=>{var f,u;t==null||t(a,l),!a&&l.reason==="escape-key"&&((f=c.popup)!=null&&f.contains(document.activeElement))&&((u=c.trigger)==null||u.focus())}})})}function Wr(e){try{return new URL(e).hostname||e}catch{return e}}function Hh({sources:e,delay:t,closeDelay:n,id:r,children:o,onClick:s,...i}){const c=I.useContext(Mo),a=I.useId(),l=r??a,f=e[0],u=f?Wr(f):"Source";return h.jsx(Lh,{id:l,handle:c==null?void 0:c.handle,delay:t??(c==null?void 0:c.openDelay)??80,closeDelay:n??(c==null?void 0:c.closeDelay)??180,render:h.jsx(fo,{variant:"secondary",size:"xs","aria-haspopup":"dialog",...i,onClick:d=>{s==null||s(d),!(!c||d.defaultPrevented)&&(c.trigger=d.currentTarget,c.focusRequested=!0,c.handle.open(l),jc(c))}}),children:o??(e.length>1?`${u} +${e.length-1}`:u)})}function Uh({ref:e,onBlur:t,...n}){const r=I.useContext(Mo);return h.jsx(Bh,{tabIndex:-1,role:"dialog","aria-label":"Source preview",...n,ref:o=>{typeof e=="function"?e(o):e&&(e.current=o),r&&(r.popup=o,o&&jc(r))},onBlur:o=>{t==null||t(o),!(!r||o.defaultPrevented)&&o.relatedTarget!==r.trigger&&!o.currentTarget.contains(o.relatedTarget)&&r.handle.close()}})}const Mc=I.createContext(null);function Do(){const e=I.useContext(Mc);if(!e)throw new Error("Citation carousel parts must be rendered inside InlineCitationCarousel.");return e}function zh({opts:e,plugins:t,orientation:n="horizontal",setApi:r,className:o,...s}){const[i,c]=vo({...e,axis:n==="vertical"?"y":"x"},t),[{selected:a,count:l},f]=I.useState({selected:0,count:0});return I.useEffect(()=>{if(!c)return;r==null||r(c);const u=()=>f({selected:c.selectedScrollSnap(),count:c.scrollSnapList().length});return u(),c.on("select",u).on("reInit",u),()=>{c.off("select",u).off("reInit",u)}},[c,r]),h.jsx(Mc.Provider,{value:{viewportRef:i,api:c,selected:a,count:l},children:h.jsx("div",{role:"region","aria-roledescription":"carousel",...s,className:ue("inline-citation-carousel",o),"data-orientation":n})})}function Wh({className:e,...t}){const{viewportRef:n}=Do();return h.jsx("div",{ref:n,className:"inline-citation-viewport",children:h.jsx("div",{className:ue("inline-citation-track",e),...t})})}function qh({className:e,...t}){return h.jsx("div",{role:"group","aria-roledescription":"slide",className:ue("inline-citation-slide",e),...t})}function Gh({className:e,...t}){return h.jsx("div",{className:ue("inline-citation-carousel-header",e),...t})}function Kh({children:e,...t}){const{selected:n,count:r}=Do();return h.jsx("div",{"aria-live":"polite",...t,children:e??(r?`${n+1}/${r}`:"")})}function Dc({next:e,children:t,disabled:n,onClick:r,...o}){const{api:s}=Do(),i=e?s==null?void 0:s.canScrollNext():s==null?void 0:s.canScrollPrev();return h.jsx(fo,{variant:"ghost",size:"icon-xs","aria-label":e?"Next source":"Previous source",...o,disabled:n||!i,onClick:c=>{r==null||r(c),!c.defaultPrevented&&(e?s==null||s.scrollNext():s==null||s.scrollPrev())},children:t??(e?h.jsx(Js,{size:14,"aria-hidden":"true"}):h.jsx(ha,{size:14,"aria-hidden":"true"}))})}function Yh(e){return h.jsx(Dc,{...e,next:!1})}function Xh(e){return h.jsx(Dc,{...e,next:!0})}function Jh({title:e,url:t,description:n,className:r,children:o,...s}){const i=t?ho(t):void 0;return h.jsxs("div",{className:ue("inline-citation-source",r),...s,children:[h.jsx("div",{className:"inline-citation-title",children:e||(i?Wr(i):"Source")}),i&&h.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:[Wr(i),h.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]}),n&&h.jsx("p",{children:n}),o]})}function Zh({className:e,...t}){return h.jsx("blockquote",{className:ue("inline-citation-quote",e),...t})}const Qh={"fuel-defect-reporting":{label:"Fuel Defect Reporting",path:"/dashboard/fuel-Defect-Reporting"},"bunker-master":{label:"Bunker Master",path:"/dashboard/bunker-master"},"fsc-fsq-e-forms":{label:"Pre-Registration & E-Forms",path:"/dashboard/pre-registration"},"pre-registration-ship":{label:"Pre-Registration",path:"/dashboard/pre-registration"},"reports-fuel":{label:"Fuel Reports",path:"/dashboard/reports"},"sample-fuel":{label:"Sample Status",path:"/dashboard/sample-status"}};function Fc(e){const n=(e.split(/[/\\]/).pop()||"").replace(/\.md$/i,"").toLowerCase();for(const[r,o]of Object.entries(Qh))if(n.includes(r))return o;return null}function qr(e){return e.title?e.title:(e.source.split(/[/\\]/).pop()||e.source).replace(/\.md$/i,"").replace(/[-_]/g," ").replace(/\b\w/g,n=>n.toUpperCase())}const em=({sources:e,hideInspectSources:t=!1,showInspectSources:n=!0,defaultExpanded:r=!1,maxSources:o=5})=>{const s=t||n===!1,[i,c]=I.useState(r&&!s),[a,l]=I.useState(null);if(!e||!e.length)return null;const f=e.slice(0,o),u=f.length===1?"source":"sources",d=h.jsxs(Nt,{children:[h.jsx(xt,{children:h.jsx(va,{size:14})}),h.jsx(jt,{children:`${f.length} retrieved VPS ${u}`}),!s&&h.jsx(Kt,{children:i?"Hide Details":"Inspect Sources"})]}),m=h.jsx(bt,{className:"grounded-source-rows",children:f.map((p,g)=>{const b=a===g,y=h.jsxs(Nt,{children:[h.jsx(xt,{children:h.jsx(pa,{size:13})}),h.jsxs(jt,{children:["[S",g+1,"] ",qr(p)]}),h.jsxs(Kt,{title:"Ranking score, not a probability of correctness",children:["Score ",p.score.toFixed(2)]})]});return s?h.jsx("div",{children:y},`${p.chunkId}-${g}`):h.jsx("button",{type:"button",className:`trace-trigger${i&&b?" grounded-source-selected":""}`,"aria-pressed":i&&b,onClick:()=>{c(!0),l(b?null:g)},title:p.source,children:y},`${p.chunkId}-${g}`)})});return s?h.jsxs(bt,{className:"grounded-sources-card",children:[d,m]}):h.jsx(bt,{className:"grounded-sources-card",children:h.jsxs(Pi,{open:i,onOpenChange:c,children:[h.jsx(Ii,{children:d}),m,h.jsx(_i,{children:h.jsx("div",{className:"grounded-sources-details-list",children:f.map((p,g)=>{const b=qr(p),y=Fc(p.source),x=a===g;return h.jsxs("div",{className:`grounded-detail-item${x?" grounded-detail-item--highlighted":""}`,children:[h.jsxs("div",{className:"grounded-detail-top",children:[h.jsxs("div",{className:"grounded-detail-title-group",children:[h.jsxs("span",{className:"grounded-detail-index",children:["[",g+1,"]"]}),h.jsx("span",{className:"grounded-detail-title",children:b})]}),h.jsxs("div",{className:"grounded-detail-meta",children:[h.jsxs("span",{className:"grounded-detail-score",children:["Rank score ",p.score.toFixed(2)]}),y&&h.jsxs("a",{href:y.path,onClick:S=>{S.preventDefault(),window.location.href=y.path},className:"grounded-route-link",title:`Navigate to ${y.label}`,children:[h.jsx("span",{children:y.label}),h.jsx(ba,{size:10,"aria-hidden":"true"})]})]})]}),h.jsx("div",{className:"grounded-detail-path",children:h.jsx("code",{children:p.source})}),p.snippet&&h.jsxs("p",{className:"grounded-detail-snippet",children:['"',p.snippet,'"']})]},`detail-${p.chunkId}-${g}`)})})})]})})};function tm({label:e,sources:t}){const n=t.map(r=>{var i;const o=qr(r),s=ho(r.url||r.source)??((i=Fc(r.source))==null?void 0:i.path);return{key:r.chunkId,label:s||o,content:h.jsxs(h.Fragment,{children:[h.jsx(Jh,{title:o,url:s}),r.snippet&&h.jsx(Zh,{children:r.snippet})]})}});return h.jsx(Vh,{children:h.jsxs($h,{children:[h.jsx(Hh,{sources:n.map(r=>r.label),"aria-label":"View sources "+e,children:e}),h.jsx(Uh,{children:n.length===1?n[0].content:h.jsxs(zh,{"aria-label":"Sources",children:[h.jsxs(Gh,{children:[h.jsx(Kh,{}),h.jsx(Yh,{}),h.jsx(Xh,{})]}),h.jsx(Wh,{children:n.map((r,o)=>h.jsx(qh,{"aria-label":"Source "+(o+1),children:r.content},r.key+"-"+o))})]})})]})})}function nm(e,t){if(!e)return[];const n=/(\[[^\]]+\]\([^)]+\)|\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`|https?:\/\/[^\s]+|\[S\d+(?:\s*,\s*S\d+)*\])/g;return e.split(n).map((o,s)=>{if(!o)return null;if(t!=null&&t.length&&/^\[S\d+(?:\s*,\s*S\d+)*\]$/.test(o)){const c=[...new Set(o.match(/\d+/g))].map(a=>t[Number(a)-1]);if(c.every(a=>a!==void 0))return h.jsx(tm,{label:o,sources:c},s)}const i=o.match(/^\[([^\]]+)\]\(([^)]+)\)$/);if(i){const c=i[1],a=i[2],l=ho(a);if(!l)return h.jsx(I.Fragment,{children:c},s);const f=/^https?:\/\//i.test(a);return h.jsx("a",{href:l,target:f?"_blank":void 0,rel:f?"noopener noreferrer":void 0,className:"md-link",children:c},s)}return o.startsWith("**")&&o.endsWith("**")&&o.length>=4?h.jsx("strong",{children:o.slice(2,-2)},s):o.startsWith("*")&&o.endsWith("*")&&o.length>=2?h.jsx("em",{children:o.slice(1,-1)},s):o.startsWith("`")&&o.endsWith("`")&&o.length>=2?h.jsx("code",{className:"md-code",children:o.slice(1,-1)},s):/^https?:\/\//i.test(o)?h.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"md-link",children:o},s):h.jsx(I.Fragment,{children:o},s)})}function rm(e){const t=e.replace(/\r\n/g,`
211
+ */var Cs;function cp(){return Cs||(Cs=1,process.env.NODE_ENV!=="production"&&(function(){function e(l,f){return l===f&&(l!==0||1/l===1/f)||l!==l&&f!==f}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=I,n=Po(),r=typeof Object.is=="function"?Object.is:e,o=n.useSyncExternalStore,s=t.useRef,i=t.useEffect,c=t.useMemo,a=t.useDebugValue;yr.useSyncExternalStoreWithSelector=function(l,f,u,h,g){var d=s(null);if(d.current===null){var m={hasValue:!1,value:null};d.current=m}else m=d.current;d=c(function(){function v(w){if(!x){if(x=!0,S=w,w=h(w),g!==void 0&&m.hasValue){var R=m.value;if(g(R,w))return E=R}return E=w}if(R=E,r(S,w))return R;var P=h(w);return g!==void 0&&g(R,P)?(S=w,R):(S=w,E=P)}var x=!1,S,E,C=u===void 0?null:u;return[function(){return v(f())},C===null?void 0:function(){return v(C())}]},[f,u,h,g]);var b=o(l,d[0],d[1]);return i(function(){m.hasValue=!0,m.value=b},[b]),a(b),b},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),yr}var Rs;function ap(){return Rs||(Rs=1,process.env.NODE_ENV==="production"?En.exports=ip():En.exports=cp()),En.exports}var lp=ap();const up=ci(19),fp=up?pp:hp;function fc(e,t,n,r,o){return fp(e,t,n,r,o)}function dp(e,t,n,r,o){const s=y.useCallback(()=>t(e.getSnapshot(),n,r,o),[e,t,n,r,o]);return Oo.useSyncExternalStore(e.subscribe,s,s)}Cf({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){const r=e.syncHooks[n],o=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,o)||(t=!0,r.value=o)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{const n=new Set;for(const o of e.syncHooks)n.add(o.store);const r=[];for(const o of n)r.push(o.subscribe(t));return()=>{for(const o of r)o()}}),Oo.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot))}});function pp(e,t,n,r,o){const s=wf();if(!s)return dp(e,t,n,r,o);const i=s.syncIndex;s.syncIndex+=1;let c;return s.didInitialize?(c=s.syncHooks[i],(c.store!==e||c.selector!==t||!Object.is(c.a1,n)||!Object.is(c.a2,r)||!Object.is(c.a3,o))&&(c.store!==e&&(s.didChangeStore=!0),c.store=e,c.selector=t,c.a1=n,c.a2=r,c.a3=o,c.value=t(e.getSnapshot(),n,r,o))):(c={store:e,selector:t,a1:n,a2:r,a3:o,value:t(e.getSnapshot(),n,r,o)},s.syncHooks.push(c)),c.value}function hp(e,t,n,r,o){return lp.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,s=>t(s,n,r,o))}class gp{constructor(t){ae(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));ae(this,"getSnapshot",()=>this.state);this.state=t,this.listeners=new Set,this.updateTick=0}static create(t){return new this(t)}setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const n=this.updateTick;for(const r of this.listeners){if(n!==this.updateTick)return;r(t)}}update(t){for(const n in t)if(!Object.is(this.state[n],t[n])){this.setState({...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||this.setState({...this.state,[t]:n})}notifyAll(){const t={...this.state};this.setState(t)}use(t,n,r,o){return fc(this,t,n,r,o)}}class Io extends gp{constructor(t,n={},r){super(t),this.context=n,this.selectors=r}useSyncedValue(t,n){y.useDebugValue(t);const r=this;pe(()=>{r.state[t]!==n&&r.set(t,n)},[r,t,n])}useSyncedValueWithCleanup(t,n){const r=this;pe(()=>(r.state[t]!==n&&r.set(t,n),()=>{r.set(t,void 0)}),[r,t,n])}useSyncedValues(t){const n=this;if(process.env.NODE_ENV!=="production"){y.useDebugValue(t,i=>Object.keys(i));const o=y.useRef(Object.keys(t)).current,s=Object.keys(t);(o.length!==s.length||o.some((i,c)=>i!==s[c]))&&console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.")}const r=Object.values(t);pe(()=>{n.update(t)},[n,...r])}useControlledProp(t,n){y.useDebugValue(t);const r=this,o=n!==void 0;if(pe(()=>{o&&!Object.is(r.state[t],n)&&r.setState({...r.state,[t]:n})},[r,t,n,o]),process.env.NODE_ENV!=="production"){const s=this.controlledValues??(this.controlledValues=new Map);s.has(t)||s.set(t,o);const i=s.get(t);i!==void 0&&i!==o&&console.error(`A component is changing the ${i?"":"un"}controlled state of ${t.toString()} to be ${i?"un":""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`)}}select(t,n,r,o){const s=this.selectors[t];return s(this.state,n,r,o)}useState(t,n,r,o){return y.useDebugValue(t),fc(this,this.selectors[t],n,r,o)}useContextCallback(t,n){y.useDebugValue(t);const r=fe(n??eo);this.context[t]=r}useStateSetter(t){const n=y.useRef(void 0);return n.current===void 0&&(n.current=r=>{this.set(t,r)}),n.current}observe(t,n){let r;typeof t=="function"?r=t:r=this.selectors[t];let o=r(this.state);return n(o,o,this),this.subscribe(s=>{const i=r(s);if(!Object.is(o,i)){const c=o;o=i,n(i,c,this)}})}}const mp={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId};class bp extends Io{constructor(n){const{syncOnly:r,nested:o,onOpenChange:s,triggerElements:i,...c}=n;super({...c,positionReference:c.referenceElement,domReferenceElement:c.referenceElement},{onOpenChange:s,dataRef:{current:{}},events:ic(),nested:o,triggerElements:i},mp);ae(this,"syncOpenEvent",(n,r)=>{(!n||!this.state.open||r!=null&&Ff(r))&&(this.context.dataRef.current.openEvent=n?r:void 0)});ae(this,"dispatchOpenChange",(n,r)=>{this.syncOpenEvent(n,r.event);const o={open:n,reason:r.reason,nativeEvent:r.event,nested:this.context.nested,triggerElement:r.trigger};this.context.events.emit("openchange",o)});ae(this,"setOpen",(n,r)=>{var o,s,i,c;if(this.syncOnly){(s=(o=this.context).onOpenChange)==null||s.call(o,n,r);return}this.dispatchOpenChange(n,r),(c=(i=this.context).onOpenChange)==null||c.call(i,n,r)});this.syncOnly=r}}function vp(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new bp({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,openedWithoutTrigger:!1,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:Fe,inactiveTriggerProps:Fe,popupProps:Fe}}const qt=e=>e.triggerIdProp??e.activeTriggerId,Hn=e=>e.openProp??e.open,Ts=e=>{var n;return(((n=e.popupElement)==null?void 0:n.id)??e.floatingId)||void 0};function dc(e,t){return t!==void 0&&Hn(e)&&qt(e)===t}function yp(e,t){return dc(e,t)?!0:t!==void 0&&Hn(e)&&qt(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}const xp={open:Hn,mounted:e=>e.mounted,transitionStatus:e=>Hn(e)&&!e.mounted?"starting":e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:qt,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Ts,isTriggerActive:(e,t)=>t!==void 0&&qt(e)===t,isOpenedByTrigger:(e,t)=>dc(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&qt(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>yp(e,t)?Ts(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function Ep(e){const t=y.useCallback(r=>e===void 0?eo:e.subscribeStore(r),[e]),n=y.useCallback(()=>e===void 0?void 0:e.store,[e]);return Oo.useSyncExternalStore(t,n,()=>e==null?void 0:e.serverStore)}const xr=Gi&&on;function Sp(e,t={}){const{enabled:n=!0,delay:r}=t,{events:o,dataRef:s}=e.context,i=y.useRef(!1),c=y.useRef(null),a=y.useRef(!0),l=zt();y.useEffect(()=>{const u=e.select("domReferenceElement");if(!n)return;const h=Ie(u);function g(){const b=e.select("domReferenceElement");!e.select("open")&&_e(b)&&b===Br(Ke(b))&&(i.current=!0,c.current=b)}function d(){a.current=!0}function m(){a.current=!1}return at(Ee(h,"blur",g),xr&&Ee(h,"keydown",d,!0),xr&&Ee(h,"pointerdown",m,!0))},[e,n]),y.useEffect(()=>{if(!n)return;function u(h){if(h.reason===Kn||h.reason===no){const g=e.select("domReferenceElement");me(g)&&(c.current=g,i.current=!0)}}return o.on("openchange",u),()=>{o.off("openchange",u)}},[o,n,e]);const f=y.useMemo(()=>{function u(){i.current=!1,c.current=null}return{onMouseLeave(){u()},onFocus(h){const g=h.currentTarget;if(i.current){if(c.current===g)return;u()}const d=vt(h.nativeEvent);if(me(d)){if(xr&&!h.relatedTarget){if(!a.current&&!Xf(d))return}else if(!Zf(d))return}const m=Fn(h.relatedTarget,e.context.triggerElements),{nativeEvent:b,currentTarget:v}=h;if(e.select("open")&&m||!r){e.setOpen(!0,Pe(Pn,b,v));return}l.start(r,()=>{i.current||e.setOpen(!0,Pe(Pn,b,v))})},onBlur(h){u();const g=h.relatedTarget,d=h.nativeEvent,m=me(g)&&g.hasAttribute(wo("focus-guard"))&&g.getAttribute("data-type")==="outside";l.start(0,()=>{var S;const b=e.select("domReferenceElement"),v=Br(Ke(b));!g&&v===b||Te((S=s.current.floatingContext)==null?void 0:S.refs.floating.current,v)||Te(b,v)||m||Fn(g??v,e.context.triggerElements)||e.setOpen(!1,Pe(Pn,d))})}}},[s,r,e,l]);return y.useMemo(()=>n?{reference:f,trigger:f}:{},[n,f])}class _o{constructor(){ae(this,"pointerType");ae(this,"interactedInside",!1);ae(this,"handler");ae(this,"blockMouseMove",!0);ae(this,"performedPointerEventsMutation",!1);ae(this,"pointerEventsScopeElement",null);ae(this,"pointerEventsReferenceElement",null);ae(this,"pointerEventsFloatingElement",null);ae(this,"restTimeoutPending",!1);ae(this,"openChangeTimeout",new ut);ae(this,"restTimeout",new ut);ae(this,"handleCloseOptions");ae(this,"dispose",()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()});ae(this,"disposeEffect",()=>this.dispose)}static create(){return new _o}}const Un=new WeakMap;function zn(e){var n,r,o;if(!e.performedPointerEventsMutation)return;const t=e.pointerEventsScopeElement;t&&Un.get(t)===e&&((n=e.pointerEventsScopeElement)==null||n.style.removeProperty("pointer-events"),(r=e.pointerEventsReferenceElement)==null||r.style.removeProperty("pointer-events"),(o=e.pointerEventsFloatingElement)==null||o.style.removeProperty("pointer-events"),Un.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function pc(e,t){const{scopeElement:n,referenceElement:r,floatingElement:o}=t,s=Un.get(n);s&&s!==e&&zn(s),zn(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=o,Un.set(n,e),n.style.pointerEvents="none",r.style.pointerEvents="auto",o.style.pointerEvents="auto"}function hc(e){const t=e.context.dataRef.current,n=Ye(()=>t.hoverInteractionState??_o.create()).current;return t.hoverInteractionState||(t.hoverInteractionState=n),ro(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function wp(e,t={}){const{enabled:n=!0,closeDelay:r=0,nodeId:o}=t,s=e.useState("open"),i=e.useState("floatingElement"),c=e.useState("domReferenceElement"),{dataRef:a}=e.context,l=sn(),f=tr(),u=hc(e),h=zt(),g=fe(()=>{var b;return Xi((b=a.current.openEvent)==null?void 0:b.type,u.interactedInside)}),d=fe(()=>{var b;return ed((b=a.current.openEvent)==null?void 0:b.type)}),m=fe(()=>{zn(u)});pe(()=>{s||(u.pointerType=void 0,u.restTimeoutPending=!1,u.interactedInside=!1,m())},[s,u,m]),y.useEffect(()=>m,[m]),pe(()=>{var b,v,x,S,E;if(n&&s&&(b=u.handleCloseOptions)!=null&&b.blockPointerEvents&&d()&&me(c)&&i){const C=c,w=i,R=Ke(i),P=(x=(v=l==null?void 0:l.nodesRef.current.find(A=>A.id===f))==null?void 0:v.context)==null?void 0:x.elements.floating;P&&(P.style.pointerEvents="");const O=u.pointerEventsScopeElement!==w?u.pointerEventsScopeElement:null,M=P!==w?P:null,F=((E=(S=u.handleCloseOptions)==null?void 0:S.getScope)==null?void 0:E.call(S))??O??M??Vr(C,"[data-rootownerid]")??R.body;return pc(u,{scopeElement:F,referenceElement:C,floatingElement:w}),()=>{m()}}},[n,s,c,i,u,d,l,f,m]),y.useEffect(()=>{if(!n)return;function b(){return!!(l&&f&&Dt(l.nodesRef.current,f).length>0)}function v(R){const P=$r(r,"close",u.pointerType),O=()=>{e.setOpen(!1,Pe(We,R)),l==null||l.events.emit("floating.closed",R)};P?u.openChangeTimeout.start(P,O):(u.openChangeTimeout.clear(),O())}function x(R){const P=vt(R);if(!Jf(P)){u.interactedInside=!1;return}u.interactedInside=Vr(P,"[aria-haspopup]")!=null}function S(){u.openChangeTimeout.clear(),h.clear(),l==null||l.events.off("floating.closed",C),m()}function E(R){var F;if(b()&&l){l.events.on("floating.closed",C);return}if(Fn(R.relatedTarget,e.context.triggerElements))return;const P=((F=a.current.floatingContext)==null?void 0:F.nodeId)??o,O=R.relatedTarget;if(!(l&&P&&me(O)&&Dt(l.nodesRef.current,P,!1).some(A=>{var D;return Te((D=A.context)==null?void 0:D.elements.floating,O)}))){if(u.handler){u.handler(R);return}m(),d()&&!g()&&v(R)}}function C(R){!l||!f||b()||h.start(0,()=>{l.events.off("floating.closed",C),e.setOpen(!1,Pe(We,R)),l.events.emit("floating.closed",R)})}const w=i;return at(w&&Ee(w,"mouseenter",S),w&&Ee(w,"mouseleave",E),w&&Ee(w,"pointerdown",x,!0),()=>{l==null||l.events.off("floating.closed",C)})},[n,i,e,a,r,o,d,g,m,u,l,f,h])}const Cp={current:null};function Rp(e,t={}){const{enabled:n=!0,delay:r=0,handleClose:o=null,mouseOnly:s=!1,restMs:i=0,move:c=!0,triggerElementRef:a=Cp,externalTree:l,isActiveTrigger:f=!0,getHandleCloseContext:u,isClosing:h,shouldOpen:g,guardStaleOpen:d=!1}=t,{dataRef:m,events:b}=e.context,v=sn(l),x=hc(e),S=y.useRef(!1),E=qe(o),C=qe(r),w=qe(i),R=qe(n),P=qe(g),O=qe(h),M=fe(()=>{var T;return Xi((T=m.current.openEvent)==null?void 0:T.type,x.interactedInside)}),F=fe(()=>{var T;return((T=P.current)==null?void 0:T.call(P))!==!1}),A=fe((T,k,U)=>{const j=e.context.triggerElements;if(j.hasElement(k))return!T||!Te(T,k);if(!me(U))return!1;const N=U;return j.hasMatchingElement(Y=>Te(Y,N))&&(!T||!Te(T,N))}),D=fe(()=>{if(!x.handler)return;Ke(e.select("domReferenceElement")).removeEventListener("mousemove",x.handler),x.handler=void 0}),_=fe(()=>{zn(x)});return f&&(x.handleCloseOptions=o==null?void 0:o.__options),y.useEffect(()=>D,[D]),y.useEffect(()=>{if(!n)return;function T(k){k.open?S.current=!1:(S.current=k.reason===We,D(),x.openChangeTimeout.clear(),x.restTimeout.clear(),x.blockMouseMove=!0,x.restTimeoutPending=!1)}return b.on("openchange",T),()=>{b.off("openchange",T)}},[n,b,x,D]),y.useEffect(()=>{if(!n)return;function T(K,le=!0){const ie=$r(C.current,"close",x.pointerType);ie?x.openChangeTimeout.start(ie,()=>{e.setOpen(!1,Pe(We,K)),v==null||v.events.emit("floating.closed",K)}):le&&(x.openChangeTimeout.clear(),e.setOpen(!1,Pe(We,K)),v==null||v.events.emit("floating.closed",K))}const k=a.current??(f?e.select("domReferenceElement"):null);if(!me(k))return;function U(K){var z;if(x.openChangeTimeout.clear(),x.blockMouseMove=!1,s&&!Lr(x.pointerType))return;const le=hs(w.current),ie=$r(C.current,"open",x.pointerType),L=vt(K),X=K.currentTarget??null,B=e.select("domReferenceElement");let $=X;if(me(L)&&!e.context.triggerElements.hasElement(L)){for(const J of e.context.triggerElements.elements())if(Te(J,L)){$=J;break}}me(X)&&me(B)&&!e.context.triggerElements.hasElement(X)&&Te(X,B)&&($=B);const Q=$==null?!1:A(B,$,L),re=e.select("open"),ee=((z=O.current)==null?void 0:z.call(O))??e.select("transitionStatus")==="ending",te=!re&&ee&&S.current,W=!Q&&me($)&&me(B)&&Te(B,$)&&te,ne=le>0&&!ie,oe=Q&&(re||te)||W,ve=!re||Q;if(oe){F()&&e.setOpen(!0,Pe(We,K,$));return}ne||(ie?x.openChangeTimeout.start(ie,()=>{ve&&F()&&e.setOpen(!0,Pe(We,K,$))}):ve&&F()&&e.setOpen(!0,Pe(We,K,$)))}function j(K){if(M()){_();return}D();const le=e.select("domReferenceElement"),ie=Ke(le);x.restTimeout.clear(),x.restTimeoutPending=!1;const L=m.current.floatingContext??(u==null?void 0:u());if(Fn(K.relatedTarget,e.context.triggerElements))return;if(E.current&&L){e.select("open")||x.openChangeTimeout.clear();const B=a.current;x.handler=E.current({...L,tree:v,x:K.clientX,y:K.clientY,onClose(){_(),D(),R.current&&!M()&&B===e.select("domReferenceElement")&&T(K,!0)}}),ie.addEventListener("mousemove",x.handler),x.handler(K);return}(x.pointerType==="touch"?!Te(e.select("floatingElement"),K.relatedTarget):!0)&&T(K)}function N(K){Te(k,K.relatedTarget)||(x.openChangeTimeout.clear(),x.restTimeout.clear(),x.restTimeoutPending=!1)}const Y=d?Ee(k,"mouseout",N):void 0;return c?at(Ee(k,"mousemove",U,{once:!0}),Ee(k,"mouseenter",U),Ee(k,"mouseleave",j),Y):at(Ee(k,"mouseenter",U),Ee(k,"mouseleave",j),Y)},[D,_,m,C,e,n,E,x,f,A,M,s,c,w,a,v,R,u,O,F,d]),y.useMemo(()=>{if(!n)return;function T(k){x.pointerType=k.pointerType}return{onPointerDown:T,onPointerEnter:T,onMouseMove(k){var L,X,B;const{nativeEvent:U}=k,j=k.currentTarget,N=e.select("domReferenceElement"),Y=e.select("open"),K=A(N,j,k.target);if(s&&!Lr(x.pointerType))return;if(Y&&K&&((L=x.handleCloseOptions)!=null&&L.blockPointerEvents)){const $=e.select("floatingElement");if($){const Q=((B=(X=x.handleCloseOptions)==null?void 0:X.getScope)==null?void 0:B.call(X))??j.ownerDocument.body;pc(x,{scopeElement:Q,referenceElement:j,floatingElement:$})}}const le=hs(w.current);if(Y&&!K||le===0||!K&&x.restTimeoutPending&&k.movementX**2+k.movementY**2<2)return;x.restTimeout.clear();function ie(){if(x.restTimeoutPending=!1,M())return;const $=e.select("open");!x.blockMouseMove&&(!$||K)&&F()&&e.setOpen(!0,Pe(We,U,j))}x.pointerType==="touch"?dt.flushSync(()=>{ie()}):K&&Y?ie():(x.restTimeoutPending=!0,x.restTimeout.start(le,ie))}}},[n,x,M,A,s,e,w,F])}const Ps=.1,Tp=Ps*Ps,xe=.5;function Sn(e,t,n,r,o,s){return r>=t!=s>=t&&e<=(o-n)*(t-r)/(s-r)+n}function wn(e,t,n,r,o,s,i,c,a,l){let f=!1;return Sn(e,t,n,r,o,s)&&(f=!f),Sn(e,t,o,s,i,c)&&(f=!f),Sn(e,t,i,c,a,l)&&(f=!f),Sn(e,t,a,l,n,r)&&(f=!f),f}function Pp(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function Cn(e,t,n,r,o,s){const i=Math.min(n,o),c=Math.max(n,o),a=Math.min(r,s),l=Math.max(r,s);return e>=i&&e<=c&&t>=a&&t<=l}function Op(e={}){const{blockPointerEvents:t=!1}=e,n=new ut,r=({x:o,y:s,placement:i,elements:c,onClose:a,nodeId:l,tree:f})=>{const u=i==null?void 0:i.split("-")[0];let h=!1,g=null,d=null,m=typeof performance<"u"?performance.now():0;function b(x,S){const E=performance.now(),C=E-m;if(g===null||d===null||C===0)return g=x,d=S,m=E,!1;const w=x-g,R=S-d,P=w*w+R*R,O=C*C*Tp;return g=x,d=S,m=E,P<O}function v(){n.clear(),a()}return function(S){n.clear();const E=c.domReference,C=c.floating;if(!E||!C||u==null||o==null||s==null)return;const{clientX:w,clientY:R}=S,P=vt(S),O=S.type==="mouseleave",M=Te(C,P),F=Te(E,P);if(M&&(h=!0,!O))return;if(F&&(h=!1,!O)){h=!0;return}if(O&&me(S.relatedTarget)&&Te(C,S.relatedTarget))return;function A(){return!!(f&&Dt(f.nodesRef.current,l).length>0)}function D(){A()||v()}if(A())return;const _=E.getBoundingClientRect(),T=C.getBoundingClientRect(),k=o>T.right-T.width/2,U=s>T.bottom-T.height/2,j=T.width>_.width,N=T.height>_.height,Y=(j?_:T).left,K=(j?_:T).right,le=(N?_:T).top,ie=(N?_:T).bottom;if(u==="top"&&s>=_.bottom-1||u==="bottom"&&s<=_.top+1||u==="left"&&o>=_.right-1||u==="right"&&o<=_.left+1){D();return}let L=!1;switch(u){case"top":L=Cn(w,R,Y,_.top+1,K,T.bottom-1);break;case"bottom":L=Cn(w,R,Y,T.top+1,K,_.bottom-1);break;case"left":L=Cn(w,R,T.right-1,ie,_.left+1,le);break;case"right":L=Cn(w,R,_.right-1,ie,T.left+1,le);break}if(L)return;if(h&&!Pp(w,R,_)){D();return}if(!O&&b(w,R)){D();return}let X=!1;switch(u){case"top":{const B=j?xe/2:xe*4,$=j||k?o+B:o-B,Q=j?o-B:k?o+B:o-B,re=s+xe+1,ee=k||j?T.bottom-xe:T.top,te=k?j?T.bottom-xe:T.top:T.bottom-xe;X=wn(w,R,$,re,Q,re,T.left,ee,T.right,te);break}case"bottom":{const B=j?xe/2:xe*4,$=j||k?o+B:o-B,Q=j?o-B:k?o+B:o-B,re=s-xe,ee=k||j?T.top+xe:T.bottom,te=k?j?T.top+xe:T.bottom:T.top+xe;X=wn(w,R,$,re,Q,re,T.left,ee,T.right,te);break}case"left":{const B=N?xe/2:xe*4,$=N||U?s+B:s-B,Q=N?s-B:U?s+B:s-B,re=o+xe+1,ee=U||N?T.right-xe:T.left,te=U?N?T.right-xe:T.left:T.right-xe;X=wn(w,R,ee,T.top,te,T.bottom,re,$,re,Q);break}case"right":{const B=N?xe/2:xe*4,$=N||U?s+B:s-B,Q=N?s-B:U?s+B:s-B,re=o-xe,ee=U||N?T.left+xe:T.right,te=U?N?T.left+xe:T.right:T.left+xe;X=wn(w,R,re,$,re,Q,ee,T.top,te,T.bottom);break}}X?h||n.start(40,D):D()}};return r.__options={...e,blockPointerEvents:t},r}function Os(e,t,n){let{reference:r,floating:o}=e;const s=Ue(t),i=So(t),c=Eo(i),a=Ve(t),l=s==="y",f=r.x+r.width/2-o.width/2,u=r.y+r.height/2-o.height/2,h=r[c]/2-o[c]/2;let g;switch(a){case"top":g={x:f,y:r.y-o.height};break;case"bottom":g={x:f,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:u};break;case"left":g={x:r.x-o.width,y:u};break;default:g={x:r.x,y:r.y}}const d=Je(t);return d&&(g[i]+=h*(d==="end"?1:-1)*(n&&l?-1:1)),g}async function Ip(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:c,strategy:a}=e,{boundary:l="clippingAncestors",rootBoundary:f="viewport",elementContext:u="floating",altBoundary:h=!1,padding:g=0}=ft(t,e),d=Zi(g),b=c[h?u==="floating"?"reference":"floating":u],v=Vn(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(b)))==null||n?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(c.floating)),boundary:l,rootBoundary:f,strategy:a})),x=u==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c.floating)),E=await(s.isElement==null?void 0:s.isElement(S))&&await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1},C=Vn(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:x,offsetParent:S,strategy:a}):x);return{top:(v.top-C.top+d.top)/E.y,bottom:(C.bottom-v.bottom+d.bottom)/E.y,left:(v.left-C.left+d.left)/E.x,right:(C.right-v.right+d.right)/E.x}}const _p=50,kp=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,c=i.detectOverflow?i:{...i,detectOverflow:Ip},a=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:u}=Os(l,r,a),h=r,g=0;const d={};for(let m=0;m<s.length;m++){const b=s[m];if(!b)continue;const{name:v,fn:x}=b,{x:S,y:E,data:C,reset:w}=await x({x:f,y:u,initialPlacement:r,placement:h,strategy:o,middlewareData:d,rects:l,platform:c,elements:{reference:e,floating:t}});f=S??f,u=E??u,d[v]={...d[v],...C},w&&g<_p&&(g++,typeof w=="object"&&(w.placement&&(h=w.placement),w.rects&&(l=w.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):w.rects),{x:f,y:u}=Os(l,h,a)),m=-1)}return{x:f,y:u,placement:h,strategy:o,middlewareData:d}},Ap=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:c,platform:a,elements:l}=t,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:h,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:d="none",flipAlignment:m=!0,...b}=ft(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const v=Ve(o),x=Ue(c),S=Ve(c)===c,E=await(a.isRTL==null?void 0:a.isRTL(l.floating)),C=h||(S||!m?[Bn(c)]:sd(c)),w=d!=="none";!h&&w&&C.push(...ld(c,m,d,E));const R=[c,...C],P=await a.detectOverflow(t,b),O=[];let M=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&O.push(P[v]),u){const _=od(o,i,E);O.push(P[_[0]],P[_[1]])}if(M=[...M,{placement:o,overflows:O}],!O.every(_=>_<=0)){var F,A;const _=(((F=s.flip)==null?void 0:F.index)||0)+1,T=R[_];if(T&&(!(u==="alignment"?x!==Ue(T):!1)||M.every(j=>Ue(j.placement)===x?j.overflows[0]>0:!0)))return{data:{index:_,overflows:M},reset:{placement:T}};let k=(A=M.filter(U=>U.overflows[0]<=0).sort((U,j)=>U.overflows[1]-j.overflows[1])[0])==null?void 0:A.placement;if(!k)switch(g){case"bestFit":{var D;const U=(D=M.filter(j=>{if(w){const N=Ue(j.placement);return N===x||N==="y"}return!0}).map(j=>[j.placement,j.overflows.filter(N=>N>0).reduce((N,Y)=>N+Y,0)]).sort((j,N)=>j[1]-N[1])[0])==null?void 0:D[0];U&&(k=U);break}case"initialPlacement":k=c;break}if(o!==k)return{reset:{placement:k}}}return{}}}},gc=new Set(["left","top"]);async function Np(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Ve(n),c=Je(n),a=Ue(n)==="y",l=gc.has(i)?-1:1,f=s&&a?-1:1,u=ft(t,e);let{mainAxis:h,crossAxis:g,alignmentAxis:d}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return c&&typeof d=="number"&&(g=c==="end"?d*-1:d),a?{x:g*f,y:h*l}:{x:h*l,y:g*f}}const jp=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:c}=t,a=await Np(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:o+a.x,y:s+a.y,data:{...a,placement:i}}}}},Mp=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:s}=t,{mainAxis:i=!0,crossAxis:c=!1,limiter:a={fn:x=>{let{x:S,y:E}=x;return{x:S,y:E}}},...l}=ft(e,t),f={x:n,y:r},u=await s.detectOverflow(t,l),h=Ue(o),g=xo(h);let d=f[g],m=f[h];const b=(x,S)=>Ji(S+u[x==="y"?"top":"left"],S,S-u[x==="y"?"bottom":"right"]);i&&(d=b(g,d)),c&&(m=b(h,m));const v=a.fn({...t,[g]:d,[h]:m});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[g]:i,[h]:c}}}}}},Dp=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:o,y:s,placement:i,rects:c,middlewareData:a}=t,{offset:l=0,mainAxis:f=!0,crossAxis:u=!0}=ft(e,t),h={x:o,y:s},g=Ue(i),d=xo(g);let m=h[d],b=h[g];const v=ft(l,t),x=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:(n=v.mainAxis)!=null?n:0,crossAxis:(r=v.crossAxis)!=null?r:0};if(f){const C=d==="y"?"height":"width",w=c.reference[d]-c.floating[C]+x.mainAxis,R=c.reference[d]+c.reference[C]-x.mainAxis;m<w?m=w:m>R&&(m=R)}if(u){var S,E;const C=d==="y"?"width":"height",w=gc.has(Ve(i)),R=c.reference[g]-c.floating[C]+(w&&((S=a.offset)==null?void 0:S[g])||0)+(w?0:x.crossAxis),P=c.reference[g]+c.reference[C]+(w?0:((E=a.offset)==null?void 0:E[g])||0)-(w?x.crossAxis:0);b<R?b=R:b>P&&(b=P)}return{[d]:m,[g]:b}}}},Fp=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:o,elements:s}=t,{apply:i=()=>{},...c}=ft(e,t),a=await o.detectOverflow(t,c),l=Ve(n),f=Je(n),u=Ue(n)==="y",{width:h,height:g}=r.floating;let d,m;l==="top"||l==="bottom"?(d=l,m=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(m=l,d=f==="end"?"top":"bottom");const b=g-a.top-a.bottom,v=h-a.left-a.right,x=Mt(g-a[d],b),S=Mt(h-a[m],v),E=t.middlewareData.shift,C=!E;let w=x,R=S;E!=null&&E.enabled.x&&(R=v),E!=null&&E.enabled.y&&(w=b),C&&!f&&(u?R=h-2*nt(a.left,a.right):w=g-2*nt(a.top,a.bottom)),await i({...t,availableWidth:R,availableHeight:w});const P=await o.getDimensions(s.floating);return h!==P.width||g!==P.height?{reset:{rects:!0}}:{}}}};function mc(e){const t=$e(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=_e(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,c=Ln(n)!==s||Ln(r)!==i;return c&&(n=s,r=i),{width:n,height:r,$:c}}function ko(e){return me(e)?e:e.contextElement}function kt(e){const t=ko(e);if(!_e(t))return rt(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=mc(t);let i=(s?Ln(n.width):n.width)/r,c=(s?Ln(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Lp=rt(0);function bc(e){const t=Ie(e);return!lo()||!t.visualViewport?Lp:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Bp(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Ie(e)}function St(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ko(e);let i=rt(1);t&&(r?me(r)&&(i=kt(r)):i=kt(e));const c=Bp(s,n,r)?bc(s):rt(0);let a=(o.left+c.x)/i.x,l=(o.top+c.y)/i.y,f=o.width/i.x,u=o.height/i.y;if(s&&r){const h=Ie(s),g=me(r)?Ie(r):r;let d=h,m=Ir(d);for(;m&&g!==d;){const b=kt(m),v=m.getBoundingClientRect(),x=$e(m),S=v.left+(m.clientLeft+parseFloat(x.paddingLeft))*b.x,E=v.top+(m.clientTop+parseFloat(x.paddingTop))*b.y;a*=b.x,l*=b.y,f*=b.x,u*=b.y,a+=S,l+=E,d=Ie(m),m=Ir(d)}}return Vn({width:f,height:u,x:a,y:l})}function nr(e,t){const n=Zn(e).scrollLeft;return t?t.left+n:St(ot(e)).left+n}function vc(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-nr(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Vp(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=ot(r),c=t?Jn(t.floating):!1;if(r===i||c&&s)return n;let a={scrollLeft:0,scrollTop:0},l=rt(1);const f=rt(0),u=_e(r);if((u||!s)&&((Le(r)!=="body"||Xn(i))&&(a=Zn(r)),u)){const g=St(r);l=kt(r),f.x=g.x+r.clientLeft,f.y=g.y+r.clientTop}const h=i&&!u&&!s?vc(i,a):rt(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-a.scrollLeft*l.x+f.x+h.x,y:n.y*l.y-a.scrollTop*l.y+f.y+h.y}}function $p(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Hp(e){const t=Zn(e),n=e.ownerDocument.body,r=nt(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),o=nt(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-t.scrollLeft+nr(e);const i=-t.scrollTop;return $e(n).direction==="rtl"&&(s+=nt(e.clientWidth,n.clientWidth)-r),{width:r,height:o,x:s,y:i}}const Up=25;function zp(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",o=Ie(e),s=ot(e),i=o.visualViewport;let c=s.clientWidth,a=s.clientHeight,l=0,f=0;if(i){const h=!lo()||t==="fixed";r?h||(l=-i.offsetLeft,f=-i.offsetTop):(c=i.width,a=i.height,h&&(l=i.offsetLeft,f=i.offsetTop))}if(nr(s)<=0){const h=s.ownerDocument,g=h.body,d=getComputedStyle(g),m=h.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,b=Math.abs(s.clientWidth-g.clientWidth-m),v=getComputedStyle(s).scrollbarGutter==="stable both-edges"?b/2:b;v<=Up&&(c-=v)}return{width:c,height:a,x:l,y:f}}function Wp(e,t){const n=St(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=kt(e),i=e.clientWidth*s.x,c=e.clientHeight*s.y,a=o*s.x,l=r*s.y;return{width:i,height:c,x:a,y:l}}function Is(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=zp(e,n,t);else if(t==="document")r=Hp(ot(e));else if(me(t))r=Wp(t,n);else{const o=bc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Vn(r)}function qp(e,t){const n=t.get(e);if(n)return n;let r=Gt(e,[],!1).filter(c=>me(c)&&Le(c)!=="body"),o=null;const s=$e(e).position==="fixed";let i=s?lt(e):e;for(;me(i)&&!ct(i);){const c=$e(i),a=ao(i),l=o?o.position:s?"fixed":"";!a&&(l==="fixed"||l==="absolute"&&c.position==="static")?r=r.filter(u=>u!==i):o=c,i=lt(i)}return t.set(e,r),r}function Gp(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Jn(t)?[]:qp(t,this._c):[].concat(n),r],c=Is(t,i[0],o);let a=c.top,l=c.right,f=c.bottom,u=c.left;for(let h=1;h<i.length;h++){const g=Is(t,i[h],o);a=nt(g.top,a),l=Mt(g.right,l),f=Mt(g.bottom,f),u=nt(g.left,u)}return{width:l-u,height:f-a,x:u,y:a}}function Kp(e){const{width:t,height:n}=mc(e);return{width:t,height:n}}function Yp(e,t,n){const r=_e(t),o=ot(t),s=n==="fixed",i=St(e,!0,s,t);let c={scrollLeft:0,scrollTop:0};const a=rt(0);if((r||!s)&&((Le(t)!=="body"||Xn(o))&&(c=Zn(t)),r)){const h=St(t,!0,s,t);a.x=h.x+t.clientLeft,a.y=h.y+t.clientTop}!r&&o&&(a.x=nr(o));const l=o&&!r&&!s?vc(o,c):rt(0),f=i.left+c.scrollLeft-a.x-l.x,u=i.top+c.scrollTop-a.y-l.y;return{x:f,y:u,width:i.width,height:i.height}}function Er(e){return $e(e).position==="static"}function _s(e,t){if(!_e(e)||$e(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return ot(e)===n&&(n=n.ownerDocument.body),n}function yc(e,t){const n=Ie(e);if(Jn(e))return n;if(!_e(e)){let o=lt(e);for(;o&&!ct(o);){if(me(o)&&!Er(o))return o;o=lt(o)}return n}let r=_s(e,t);for(;r&&El(r)&&Er(r);)r=_s(r,t);return r&&ct(r)&&Er(r)&&!ao(r)?n:r||Cl(e)||n}const Xp=async function(e){const t=this.getOffsetParent||yc,n=this.getDimensions,r=await n(e.floating);return{reference:Yp(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Jp(e){return $e(e).direction==="rtl"}const Zp={convertOffsetParentRelativeRectToViewportRelativeRect:Vp,getDocumentElement:ot,getClippingRect:Gp,getOffsetParent:yc,getElementRects:Xp,getClientRects:$p,getDimensions:Kp,getScale:kt,isElement:me,isRTL:Jp};function xc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Qp(e,t,n){let r=null,o;const s=ot(e);function i(){var f;clearTimeout(o),(f=r)==null||f.disconnect(),r=null}function c(f,u){f===void 0&&(f=!1),u===void 0&&(u=1),i();const h=e.getBoundingClientRect(),{left:g,top:d,width:m,height:b}=h;if(f||t(),!m||!b)return;const v=yn(d),x=yn(s.clientWidth-(g+m)),S=yn(s.clientHeight-(d+b)),E=yn(g),w={rootMargin:-v+"px "+-x+"px "+-S+"px "+-E+"px",threshold:nt(0,Mt(1,u))||1};let R=!0;function P(O){const M=O[0].intersectionRatio;if(!xc(h,e.getBoundingClientRect()))return c();if(M!==u){if(!R)return c();M?c(!1,M):o=setTimeout(()=>{c(!1,1e-7)},1e3)}R=!1}try{r=new IntersectionObserver(P,{...w,root:s.ownerDocument})}catch{r=new IntersectionObserver(P,w)}r.observe(e)}const a=Ie(e),l=()=>c(n);return a.addEventListener("resize",l),c(!0),()=>{a.removeEventListener("resize",l),i()}}function ks(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,l=ko(e),f=o||s?[...l?Gt(l):[],...t?Gt(t):[]]:[];f.forEach(v=>{o&&v.addEventListener("scroll",n),s&&v.addEventListener("resize",n)});const u=l&&c?Qp(l,n,s):null;let h=-1,g=null;i&&(g=new ResizeObserver(v=>{let[x]=v;x&&x.target===l&&g&&t&&(g.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=g)==null||S.observe(t)})),n()}),l&&!a&&g.observe(l),t&&g.observe(t));let d,m=a?St(e):null;a&&b();function b(){const v=St(e);m&&!xc(m,v)&&n(),m=v,d=requestAnimationFrame(b)}return n(),()=>{var v;f.forEach(x=>{o&&x.removeEventListener("scroll",n),s&&x.removeEventListener("resize",n)}),u==null||u(),(v=g)==null||v.disconnect(),g=null,a&&cancelAnimationFrame(d)}}const eh=jp,th=Mp,nh=Ap,rh=Fp,oh=Dp,sh=(e,t,n)=>{const r=new Map,o=n??{},s={...Zp,...o.platform,_c:r};return kp(e,t,{...o,platform:s})};var ih=typeof document<"u",ch=function(){},_n=ih?I.useLayoutEffect:ch;function Wn(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(!Wn(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Wn(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ec(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function As(e,t){const n=Ec(e);return Math.round(t*n)/n}function Sr(e){const t=y.useRef(e);return _n(()=>{t.current=e}),t}function ah(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:c=!0,whileElementsMounted:a,open:l}=e,[f,u]=y.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,g]=y.useState(r);Wn(h,r)||g(r);const[d,m]=y.useState(null),[b,v]=y.useState(null),x=y.useCallback(j=>{j!==w.current&&(w.current=j,m(j))},[]),S=y.useCallback(j=>{j!==R.current&&(R.current=j,v(j))},[]),E=s||d,C=i||b,w=y.useRef(null),R=y.useRef(null),P=y.useRef(f),O=a!=null,M=Sr(a),F=Sr(o),A=Sr(l),D=y.useCallback(()=>{if(!w.current||!R.current)return;const j={placement:t,strategy:n,middleware:h};F.current&&(j.platform=F.current),sh(w.current,R.current,j).then(N=>{const Y={...N,isPositioned:A.current!==!1};_.current&&!Wn(P.current,Y)&&(P.current=Y,dt.flushSync(()=>{u(Y)}))})},[h,t,n,F,A]);_n(()=>{l===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,u(j=>({...j,isPositioned:!1})))},[l]);const _=y.useRef(!1);_n(()=>(_.current=!0,()=>{_.current=!1}),[]),_n(()=>{if(E&&(w.current=E),C&&(R.current=C),E&&C){if(M.current)return M.current(E,C,D);D()}},[E,C,D,M,O]);const T=y.useMemo(()=>({reference:w,floating:R,setReference:x,setFloating:S}),[x,S]),k=y.useMemo(()=>({reference:E,floating:C}),[E,C]),U=y.useMemo(()=>{const j={position:n,left:0,top:0};if(!k.floating)return j;const N=As(k.floating,f.x),Y=As(k.floating,f.y);return c?{...j,transform:"translate("+N+"px, "+Y+"px)",...Ec(k.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:N,top:Y}},[n,c,k.floating,f.x,f.y]);return y.useMemo(()=>({...f,update:D,refs:T,elements:k,floatingStyles:U}),[f,D,T,k,U])}const lh=(e,t)=>{const n=eh(e);return{name:n.name,fn:n.fn,options:[e,t]}},uh=(e,t)=>{const n=th(e);return{name:n.name,fn:n.fn,options:[e,t]}},fh=(e,t)=>({fn:oh(e).fn,options:[e,t]}),dh=(e,t)=>{const n=nh(e);return{name:n.name,fn:n.fn,options:[e,t]}},ph=(e,t)=>{const n=rh(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ao=y.createContext(void 0);process.env.NODE_ENV!=="production"&&(Ao.displayName="PreviewCardRootContext");function cn(e){const t=y.useContext(Ao);if(t===void 0&&!e)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: PreviewCardRootContext is missing. PreviewCard parts must be placed within <PreviewCard.Root>.":wt(50));return t}class hh extends Io{setState(t){}update(t){}set(t,n){}notifyAll(){}}const gh=600,Sc=300,wc={...xp,instantType:e=>e.instantType,adaptiveOrigin:e=>e.adaptiveOrigin,closeDelay:e=>e.closeDelay};class mh extends Io{constructor(n,r,o){const s=new uc;super(Cc(n,s,r,o),Rc(s),wc);ae(this,"setOpen",(n,r)=>{const{inlineRectCoordsRef:o}=this.context;Zd(this,n,r,{onBeforeDispatch(){var i;const s=r.event;n&&r.reason===We&&r.trigger&&"clientX"in s&&"clientY"in s&&((i=o.current)==null?void 0:i.element)!==r.trigger&&lc(o,r.trigger,s.clientX,s.clientY)}})})}}function bh(){const e=new uc;return new hh(Object.freeze(Cc(void 0,e)),Object.freeze(Rc(e)),wc)}function Cc(e,t,n,r=!1){return{...vp(t,n,r),instantType:void 0,adaptiveOrigin:void 0,closeDelay:Sc,...e}}function Rc(e){return{popupRef:y.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e,inlineRectCoordsRef:{current:void 0}}}function Ns(e){const{open:t,defaultOpen:n=!1,onOpenChange:r,onOpenChangeComplete:o,actionsRef:s,handle:i,triggerId:c,defaultTriggerId:a=null,children:l}=e,f=Gd((v,x)=>new mh({open:n,openProp:t,activeTriggerId:a,triggerIdProp:c},v,x));f.useControlledProp("openProp",t),f.useControlledProp("triggerIdProp",c),f.useContextCallback("onOpenChange",r),f.useContextCallback("onOpenChangeComplete",o);const u=f.useState("open"),h=f.useState("activeTriggerId"),g=f.useState("mounted"),d=f.useState("payload");ep(f,{closeOnActiveTriggerUnmount:!0});const{forceUnmount:m}=tp(u,f,()=>{f.context.inlineRectCoordsRef.current=void 0});pe(()=>{u&&h==null&&f.set("payload",void 0)},[f,h,u]),y.useImperativeHandle(s,()=>({unmount:m,close:()=>f.setOpen(!1,Pe(Or))}),[m,f]);const b=u||g||i!=null;return p.jsxs(Ao.Provider,{value:f,children:[i&&p.jsx(Kd,{handle:i,store:f}),b&&p.jsx(vh,{store:f}),typeof l=="function"?l({payload:d}):l]})}function vh({store:e}){const t=e.useState("floatingRootContext"),n=Dd(t);return np(e,{activeTriggerProps:n.reference,inactiveTriggerProps:n.trigger,popupProps:n.floating}),null}const Tc=Wi(function(t){return cn(!0)?p.jsx(Ns,{...t}):p.jsx(Nd,{children:p.jsx(Ns,{...t})})});process.env.NODE_ENV!=="production"&&(Tc.displayName="PreviewCardRoot");const No=y.createContext(void 0);process.env.NODE_ENV!=="production"&&(No.displayName="PreviewCardPortalContext");function yh(){const e=y.useContext(No);if(e===void 0)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: <PreviewCard.Portal> is missing.":wt(48));return e}const Pc=y.forwardRef(function(t,n){const{children:r,container:o,className:s,render:i,style:c,...a}=t,{node:l,subtree:f}=sc({container:o,ref:n,componentProps:t,elementProps:a});return!f&&!l?null:p.jsxs(y.Fragment,{children:[f,l&&dt.createPortal(r,l)]})});process.env.NODE_ENV!=="production"&&(Pc.displayName="FloatingPortalLite");const Oc=y.forwardRef(function(t,n){const{keepMounted:r=!1,...o}=t;return cn().useState("mounted")||r?p.jsx(No.Provider,{value:r,children:p.jsx(Pc,{ref:n,...o})}):null});process.env.NODE_ENV!=="production"&&(Oc.displayName="PreviewCardPortal");const Ic=Rf(function(t,n){const{render:r,className:o,delay:s,closeDelay:i,id:c,payload:a,handle:l,style:f,...u}=t,h=cn(!0),d=Ep(l)??h;if(!d)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: <PreviewCard.Trigger> must be either used within a <PreviewCard.Root> component or provided with a handle.":wt(89));const m=bi(c),b=d.useState("isTriggerActive",m),v=d.useState("isOpenedByTrigger",m),x=d.useState("floatingRootContext"),S=d.context.inlineRectCoordsRef,E=y.useRef(null),C=s??gh,w=i??Sc,{registerTrigger:R,isMountedByThisTrigger:P}=Qd(m,E,d,{payload:a,closeDelay:w}),O=Rp(x,{mouseOnly:!0,move:!1,handleClose:Op(),delay:()=>({open:C,close:w}),triggerElementRef:E,isActiveTrigger:b,isClosing:()=>d.select("transitionStatus")==="ending"}),M=Sp(x,{delay:C}),F={open:v},A=d.useState("triggerProps",P),D=$d(S,v);return pt("a",t,{state:F,ref:[n,R,E],props:[O,M.reference,A,D,{id:m},u],stateAttributesMapping:Gf})});process.env.NODE_ENV!=="production"&&(Ic.displayName="PreviewCardTrigger");const jo=y.createContext(void 0);process.env.NODE_ENV!=="production"&&(jo.displayName="PreviewCardPositionerContext");function xh(){const e=y.useContext(jo);if(e===void 0)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: PreviewCardPositionerContext is missing. PreviewCardPositioner parts must be placed within <PreviewCard.Positioner>.":wt(49));return e}function Eh(e){const{nodeId:t,externalTree:n,rootContext:r}=e,o=r.useState("referenceElement"),s=r.useState("floatingElement"),i=r.useState("domReferenceElement"),c=r.useState("open"),a=r.useState("floatingId"),[l,f]=y.useState(null),u=y.useRef(null),h=sn(n),g=y.useMemo(()=>({reference:o,floating:s,domReference:i}),[o,s,i]),d=ah({...e,elements:{...g,...l&&{reference:l}}}),m=y.useCallback(S=>{const E=me(S)?{getBoundingClientRect:()=>S.getBoundingClientRect(),getClientRects:()=>S.getClientRects(),contextElement:S}:S;f(E),d.refs.setReference(E)},[d.refs]),b=y.useMemo(()=>({...d.refs,setPositionReference:m,domReference:u}),[d.refs,m]),v=y.useMemo(()=>({...d.elements,domReference:i}),[d.elements,i]),x=y.useMemo(()=>({...d,dataRef:r.context.dataRef,open:c,onOpenChange:r.setOpen,events:r.context.events,floatingId:a,refs:b,elements:v,nodeId:t,rootStore:r}),[d,b,v,t,r,c,a]);return pe(()=>{i&&(u.current=i)},[i]),pe(()=>{r.context.dataRef.current.floatingContext=x;const S=h==null?void 0:h.nodesRef.current.find(E=>E.id===t);S&&(S.context=x)}),y.useMemo(()=>({...d,context:x,refs:b,elements:v,rootStore:r}),[d,b,v,x,r])}const _c=y.createContext(void 0);process.env.NODE_ENV!=="production"&&(_c.displayName="DirectionContext");function Sh(){const e=y.useContext(_c);return(e==null?void 0:e.direction)??"ltr"}const wh=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:c,middlewareData:a}=t,{element:l,padding:f=0}=ft(e,t)||{};if(l==null)return{};const u=Zi(f),h={x:n,y:r},g=So(o),d=Eo(g),m=await i.getDimensions(l),b=g==="y",v=b?"top":"left",x=b?"bottom":"right",S=b?"clientHeight":"clientWidth",E=s.reference[d]+s.reference[g]-h[g]-s.floating[d],C=h[g]-s.reference[g],w=c.floating[S]||s.floating[d],R=E/2-C/2,P=w/2-m[d]/2-1,O=Math.min(u[v],P),M=Math.min(u[x],P),F=O,A=w-m[d]-M,D=w/2-m[d]/2+R,_=Ji(F,D,A),T=!a.arrow&&Je(o)!=null&&D!==_&&s.reference[d]/2-(D<F?O:M)-m[d]/2<0,k=T?D<F?D-F:D-A:0;return{[g]:h[g]+k,data:{[g]:_,centerOffset:D-_-k,...T&&{alignmentOffset:k}},reset:T}}}),Ch=(e,t)=>{const{name:n,fn:r}=wh(e);return{name:n,fn:r,options:[e,t]}},Rh={name:"hide",async fn(e){const{width:t,height:n,x:r,y:o}=e.rects.reference,s=t===0&&n===0&&r===0&&o===0,i=await e.platform.detectOverflow(e,{elementContext:"reference"});return{data:{referenceHidden:i.top-n>=0||i.right-t>=0||i.bottom-n>=0||i.left-t>=0||s}}}},Th={sideX:"left",sideY:"top"},Ph="--available-width",Oh="--available-height",Ih="--anchor-width",_h="--anchor-height",kh="--transform-origin",js=Ph,Ms=Oh;function kc(e,t,n){const r=e==="inline-start"||e==="inline-end";return{top:"top",right:r?n?"inline-start":"inline-end":"right",bottom:"bottom",left:r?n?"inline-end":"inline-start":"left"}[t]}function Ds(e,t,n){const{rects:r,placement:o}=e;return{side:kc(t,Ve(o),n),align:Je(o)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function Ah(e){return Nh(e,Eh)}function Nh(e,t){var Vt,ln;const{anchor:n,positionMethod:r="absolute",side:o="bottom",sideOffset:s=0,align:i="center",alignOffset:c=0,collisionBoundary:a,collisionPadding:l=5,sticky:f=!1,arrowPadding:u=5,disableAnchorTracking:h=!1,inline:g,keepMounted:d=!1,floatingRootContext:m,mounted:b,collisionAvoidance:v,shift:x,nodeId:S,adaptiveOrigin:E,lazyFlip:C=!1,externalTree:w}=e,R=v.side||"flip",P=v.align||"flip",O=v.fallbackAxisSide||"end",M=(x==null?void 0:x.crossAxis)??!1,F=x==null?void 0:x.rootBoundary,A=typeof n=="function"?n:void 0,D=fe(A),_=A?D:n,T=qe(n),k=qe(b),j=Sh()==="rtl",[N,Y]=y.useState(null);!b&&N!==null&&Y(null);const K=C==="placement",le=N?Ve(N):null,ie=N&&K?Je(N)||"center":null,L=le||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":j?"left":"right","inline-start":j?"right":"left"}[o],X=ie||i,B=X==="center"?L:`${L}-${X}`;let $=l;typeof $=="number"?$={top:$,right:$,bottom:$,left:$}:$&&($={top:$.top||0,right:$.right||0,bottom:$.bottom||0,left:$.left||0});const Q=1,re=o==="bottom"?Q:0,ee=o==="top"?Q:0,te=o==="right"?Q:0,W=o==="left"?Q:0,ne={boundary:a==="clipping-ancestors"?"clippingAncestors":a,padding:$},oe=y.useRef(null),ve=qe(s),z=qe(c),J=typeof s!="function"?s:0,ce=typeof c!="function"?c:0,he=[];g&&he.push(g),he.push(lh(de=>{const Ae=Ds(de,o,j),He=typeof ve.current=="function"?ve.current(Ae):ve.current,De=typeof z.current=="function"?z.current(Ae):z.current;return{mainAxis:He,crossAxis:De,alignmentAxis:De}},[J,ce,j,o]));const Oe=P==="none"&&R!=="shift",je=!Oe&&(f||M||R==="shift"),Re=R==="none"?null:dh({...ne,padding:{top:$.top+Q+re,right:$.right+Q+W,bottom:$.bottom+Q+ee,left:$.left+Q+te},mainAxis:!M&&R==="flip",crossAxis:P==="flip"?"alignment":!1,fallbackAxisSideDirection:O}),Me=Oe?null:uh({...ne,rootBoundary:F,mainAxis:P!=="none",crossAxis:je,limiter:f||M?void 0:fh(de=>{if(!oe.current)return{};const{width:Ae,height:He}=oe.current.getBoundingClientRect(),De=Ue(Ve(de.placement)),Xe=De==="y"?Ae:He,ze=De==="y"?$.left+$.right:$.top+$.bottom;return{offset:Xe/2+ze/2}})},[ne,f,M,F,$,P]);R==="shift"||P==="shift"||X==="center"?he.push(Me,Re):he.push(Re,Me),he.push(ph({...ne,apply({elements:{floating:de},availableWidth:Ae,availableHeight:He,rects:De}){if(!k.current)return;const Xe=de.style;Xe.setProperty(js,`${Ae}px`),Xe.setProperty(Ms,`${He}px`);const ze=Ie(de).devicePixelRatio||1,{x:un,y:Tt,width:fn,height:it}=De.reference,et=(Math.round((un+fn)*ze)-Math.round(un*ze))/ze,$t=(Math.round((Tt+it)*ze)-Math.round(Tt*ze))/ze;Xe.setProperty(Ih,`${et}px`),Xe.setProperty(_h,`${$t}px`)}}),Ch(de=>({element:oe.current||Ke(de.elements.floating).createElement("div"),padding:oe.current?u:0}),[u]),{name:"transformOrigin",fn(de){var Lo,Bo,Vo,$o,Ho,Uo;const{elements:{floating:Ae},middlewareData:He,placement:De,platform:Xe,rects:ze,y:un}=de,Tt=Ve(De),fn=Je(De),it=Ue(Tt)==="y",et=oe.current,$t=typeof s=="function"?s(Ds(de,o,j)):s;let dn;if(!et&&fn&&Math.abs(it?((Lo=He.shift)==null?void 0:Lo.x)||0:((Bo=He.shift)==null?void 0:Bo.y)||0)<=1)dn=fn==="start"===(it&&((Vo=Xe.isRTL)==null?void 0:Vo.call(Xe,Ae))===!0)?"100%":"0%";else{const Hc=it?(($o=He.arrow)==null?void 0:$o.x)||0:((Ho=He.arrow)==null?void 0:Ho.y)||0,Uc=it?(et==null?void 0:et.clientWidth)||0:(et==null?void 0:et.clientHeight)||0;dn=`${Hc+Uc/2}px`}let rr=Tt==="top"||Tt==="left"?`calc(100% + ${$t}px)`:`${-$t}px`;return je&&it&&Math.abs(((Uo=He.shift)==null?void 0:Uo.y)||0)>$t&&(rr=`${ze.reference.y+ze.reference.height/2-un}px`),Ae.style.setProperty(kh,it?`${dn} ${rr}`:`${rr} ${dn}`),{}}},Rh,E),pe(()=>{!b&&m&&m.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[b,m]);const Be=y.useMemo(()=>({ancestorScroll:!h,elementResize:!h&&typeof ResizeObserver<"u",layoutShift:!h&&typeof IntersectionObserver<"u"}),[h]),{refs:H,elements:G,x:Se,y:be,middlewareData:ge,update:V,placement:q,context:Z,isPositioned:se,floatingStyles:ke}=t({rootContext:m,open:d?b:void 0,placement:B,middleware:he,strategy:r,whileElementsMounted:d?void 0:(...de)=>ks(...de,Be),nodeId:S,externalTree:w}),{sideX:Ce,sideY:Ct}=ge.adaptiveOrigin||Th,st=se?r:"fixed",Rt=y.useMemo(()=>{let de;return se?E?de={position:st,[Ce]:Se,[Ct]:be}:de={...ke,position:st}:de={position:st,top:0,left:0},de[js]="100vw",de[Ms]="100vh",se||(de.opacity=0),de},[E,st,Ce,Se,Ct,be,ke,se]),Ze=y.useRef(null);pe(()=>{if(!b)return;const de=T.current,Ae=typeof de=="function"?de():de,De=(Fs(Ae)?Ae.current:Ae)||null||null;De!==Ze.current&&(H.setPositionReference(De),Ze.current=De)},[b,H,_,T]),y.useEffect(()=>{if(!b)return;const de=T.current;typeof de!="function"&&Fs(de)&&de.current!==Ze.current&&(H.setPositionReference(de.current),Ze.current=de.current)},[b,H,_,T]),y.useEffect(()=>{if(d&&b&&G.reference&&G.floating)return ks(G.reference,G.floating,V,Be)},[d,b,G,V,Be]);const Qe=Ve(q),ht=kc(o,Qe,j),gt=Je(q)||"center",Lt=!!((Vt=ge.hide)!=null&&Vt.referenceHidden);pe(()=>{C&&b&&se&&(Qe!==L||K&&gt!==X)&&Y(q)},[C,K,b,se,q,Qe,gt,L,X]);const an=y.useMemo(()=>{var de,Ae;return{position:"absolute",top:(de=ge.arrow)==null?void 0:de.y,left:(Ae=ge.arrow)==null?void 0:Ae.x}},[ge.arrow]),Bt=((ln=ge.arrow)==null?void 0:ln.centerOffset)!==0;return y.useMemo(()=>({positionerStyles:Rt,arrowStyles:an,arrowRef:oe,arrowUncentered:Bt,side:ht,align:gt,physicalSide:Qe,anchorHidden:Lt,refs:H,context:Z,isPositioned:se,update:V}),[Rt,an,oe,Bt,ht,gt,Qe,Lt,H,Z,se,V])}function Fs(e){return e!=null&&"current"in e}function Ac(e){return e==="starting"?Cd:Fe}function jh(e,t,{styles:n,transitionStatus:r,props:o,refs:s,hidden:i,inert:c=!1}){const a={...n};return c&&(a.pointerEvents="none"),pt("div",e,{state:t,ref:s,props:[{role:"presentation",hidden:i,style:a},Ac(r),o],stateAttributesMapping:Yi})}const Nc=y.forwardRef(function(t,n){const{render:r,className:o,anchor:s,positionMethod:i="absolute",side:c="bottom",align:a="center",sideOffset:l=0,alignOffset:f=0,collisionBoundary:u="clipping-ancestors",collisionPadding:h=5,arrowPadding:g=5,sticky:d=!1,disableAnchorTracking:m=!1,collisionAvoidance:b=Rd,style:v,...x}=t,S=cn(),E=yh(),C=kd(),w=S.useState("open"),R=S.useState("mounted"),P=S.useState("floatingRootContext"),O=S.useState("instantType"),M=S.useState("transitionStatus"),F=S.useState("adaptiveOrigin"),A=S.context.inlineRectCoordsRef,D=Ah({anchor:s,floatingRootContext:P,positionMethod:i,mounted:R,side:c,sideOffset:l,align:a,alignOffset:f,arrowPadding:g,collisionBoundary:u,collisionPadding:h,sticky:d,disableAnchorTracking:m,keepMounted:E,nodeId:C,collisionAvoidance:b,adaptiveOrigin:F,inline:Hd(A)}),_=D.update;pe(()=>{w&&R&&_()},[w,R,_]);const T={open:w,side:D.side,align:D.align,anchorHidden:D.anchorHidden,instant:O},k=jh(t,T,{styles:D.positionerStyles,transitionStatus:M,props:x,refs:[n,S.useStateSetter("positionerElement")],hidden:!R,inert:!w});return p.jsx(jo.Provider,{value:D,children:p.jsx(Ad,{id:C,children:k})})});process.env.NODE_ENV!=="production"&&(Nc.displayName="PreviewCardPositioner");const jc=y.forwardRef(function(t,n){const{className:r,render:o,style:s,...i}=t,c=cn(),{side:a,align:l}=xh(),f=c.useState("open"),u=c.useState("instantType"),h=c.useState("transitionStatus"),g=c.useState("popupProps"),d=c.useState("floatingRootContext"),m=c.useState("closeDelay");return uo({open:f,ref:c.context.popupRef,onComplete(){var x,S;f&&((S=(x=c.context).onOpenChangeComplete)==null||S.call(x,!0))}}),wp(d,{closeDelay:m}),pt("div",t,{state:{open:f,side:a,align:l,instant:u,transitionStatus:h},ref:[n,c.context.popupRef,c.useStateSetter("popupElement")],props:[qd,g,Ac(h),i],stateAttributesMapping:Kf})});process.env.NODE_ENV!=="production"&&(jc.displayName="PreviewCardPopup");class Mh extends Ud{constructor(){super(bh(),"PreviewCard")}open(t){this.openByTrigger(t)}close(){this.closePopup()}get isOpen(){var t;return((t=this.attachedStore)==null?void 0:t.select("open"))??!1}}function Dh(){return new Mh}const Fh=Dh;function Lh(e){return p.jsx(Tc,{...e})}function Bh(e){return p.jsx(Ic,{"data-slot":"hover-card-trigger",...e})}function Vh({className:e,side:t="bottom",sideOffset:n=6,align:r="center",alignOffset:o=0,...s}){return p.jsx(Oc,{children:p.jsx(Nc,{align:r,alignOffset:o,side:t,sideOffset:n,className:"vps-hover-card-positioner",children:p.jsx(jc,{"data-slot":"hover-card-content",...s,className:i=>ue("vps-hover-card",typeof e=="function"?e(i):e)})})})}function $h({className:e,...t}){return p.jsx("span",{className:ue("inline-citation",e),...t})}const Mo=I.createContext(null);function Mc(e){!e.popup||!e.focusRequested||!e.handle.isOpen||(e.focusRequested=!1,e.popup.focus())}function Hh({handle:e,onOpenChange:t,openDelay:n=80,closeDelay:r=180,...o}){const[s]=I.useState(()=>Fh()),i=e??s,c=I.useMemo(()=>({handle:i,openDelay:n,closeDelay:r,trigger:null,popup:null,focusRequested:!1}),[i,n,r]);return p.jsx(Mo.Provider,{value:c,children:p.jsx(Lh,{...o,handle:i,onOpenChange:(a,l)=>{var f,u;t==null||t(a,l),!a&&l.reason==="escape-key"&&((f=c.popup)!=null&&f.contains(document.activeElement))&&((u=c.trigger)==null||u.focus())}})})}function Wr(e){try{return new URL(e).hostname||e}catch{return e}}function Uh({sources:e,delay:t,closeDelay:n,id:r,children:o,onClick:s,...i}){const c=I.useContext(Mo),a=I.useId(),l=r??a,f=e[0],u=f?Wr(f):"Source";return p.jsx(Bh,{id:l,handle:c==null?void 0:c.handle,delay:t??(c==null?void 0:c.openDelay)??80,closeDelay:n??(c==null?void 0:c.closeDelay)??180,render:p.jsx(fo,{variant:"secondary",size:"xs","aria-haspopup":"dialog",...i,onClick:h=>{s==null||s(h),!(!c||h.defaultPrevented)&&(c.trigger=h.currentTarget,c.focusRequested=!0,c.handle.open(l),Mc(c))}}),children:o??(e.length>1?`${u} +${e.length-1}`:u)})}function zh({ref:e,onBlur:t,...n}){const r=I.useContext(Mo);return p.jsx(Vh,{tabIndex:-1,role:"dialog","aria-label":"Source preview",...n,ref:o=>{typeof e=="function"?e(o):e&&(e.current=o),r&&(r.popup=o,o&&Mc(r))},onBlur:o=>{t==null||t(o),!(!r||o.defaultPrevented)&&o.relatedTarget!==r.trigger&&!o.currentTarget.contains(o.relatedTarget)&&r.handle.close()}})}const Dc=I.createContext(null);function Do(){const e=I.useContext(Dc);if(!e)throw new Error("Citation carousel parts must be rendered inside InlineCitationCarousel.");return e}function Wh({opts:e,plugins:t,orientation:n="horizontal",setApi:r,className:o,...s}){const[i,c]=yo({...e,axis:n==="vertical"?"y":"x"},t),[{selected:a,count:l},f]=I.useState({selected:0,count:0});return I.useEffect(()=>{if(!c)return;r==null||r(c);const u=()=>f({selected:c.selectedScrollSnap(),count:c.scrollSnapList().length});return u(),c.on("select",u).on("reInit",u),()=>{c.off("select",u).off("reInit",u)}},[c,r]),p.jsx(Dc.Provider,{value:{viewportRef:i,api:c,selected:a,count:l},children:p.jsx("div",{role:"region","aria-roledescription":"carousel",...s,className:ue("inline-citation-carousel",o),"data-orientation":n})})}function qh({className:e,...t}){const{viewportRef:n}=Do();return p.jsx("div",{ref:n,className:"inline-citation-viewport",children:p.jsx("div",{className:ue("inline-citation-track",e),...t})})}function Gh({className:e,...t}){return p.jsx("div",{role:"group","aria-roledescription":"slide",className:ue("inline-citation-slide",e),...t})}function Kh({className:e,...t}){return p.jsx("div",{className:ue("inline-citation-carousel-header",e),...t})}function Yh({children:e,...t}){const{selected:n,count:r}=Do();return p.jsx("div",{"aria-live":"polite",...t,children:e??(r?`${n+1}/${r}`:"")})}function Fc({next:e,children:t,disabled:n,onClick:r,...o}){const{api:s}=Do(),i=e?s==null?void 0:s.canScrollNext():s==null?void 0:s.canScrollPrev();return p.jsx(fo,{variant:"ghost",size:"icon-xs","aria-label":e?"Next source":"Previous source",...o,disabled:n||!i,onClick:c=>{r==null||r(c),!c.defaultPrevented&&(e?s==null||s.scrollNext():s==null||s.scrollPrev())},children:t??(e?p.jsx(Zs,{size:14,"aria-hidden":"true"}):p.jsx(ga,{size:14,"aria-hidden":"true"}))})}function Xh(e){return p.jsx(Fc,{...e,next:!1})}function Jh(e){return p.jsx(Fc,{...e,next:!0})}function Zh({title:e,url:t,description:n,className:r,children:o,...s}){const i=t?ho(t):void 0;return p.jsxs("div",{className:ue("inline-citation-source",r),...s,children:[p.jsx("div",{className:"inline-citation-title",children:e||(i?Wr(i):"Source")}),i&&p.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:[Wr(i),p.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]}),n&&p.jsx("p",{children:n}),o]})}function Qh({className:e,...t}){return p.jsx("blockquote",{className:ue("inline-citation-quote",e),...t})}const eg={"fuel-defect-reporting":{label:"Fuel Defect Reporting",path:"/dashboard/fuel-Defect-Reporting"},"bunker-master":{label:"Bunker Master",path:"/dashboard/bunker-master"},"fsc-fsq-e-forms":{label:"Pre-Registration & E-Forms",path:"/dashboard/pre-registration"},"pre-registration-ship":{label:"Pre-Registration",path:"/dashboard/pre-registration"},"reports-fuel":{label:"Fuel Reports",path:"/dashboard/reports"},"sample-fuel":{label:"Sample Status",path:"/dashboard/sample-status"}};function Lc(e){const n=(e.split(/[/\\]/).pop()||"").replace(/\.md$/i,"").toLowerCase();for(const[r,o]of Object.entries(eg))if(n.includes(r))return o;return null}function qr(e){return e.title?e.title:(e.source.split(/[/\\]/).pop()||e.source).replace(/\.md$/i,"").replace(/[-_]/g," ").replace(/\b\w/g,n=>n.toUpperCase())}const tg=({sources:e,hideInspectSources:t=!1,showInspectSources:n=!0,defaultExpanded:r=!1,maxSources:o=5})=>{const s=t||n===!1,[i,c]=I.useState(r&&!s),[a,l]=I.useState(null);if(!e||!e.length)return null;const f=e.slice(0,o),u=f.length===1?"source":"sources",h=p.jsxs(Nt,{children:[p.jsx(xt,{children:p.jsx(xa,{size:14})}),p.jsx(jt,{children:`${f.length} retrieved VPS ${u}`}),!s&&p.jsx(Kt,{children:i?"Hide Details":"Inspect Sources"})]}),g=p.jsx(bt,{className:"grounded-source-rows",children:f.map((d,m)=>{const b=a===m,v=p.jsxs(Nt,{children:[p.jsx(xt,{children:p.jsx(ha,{size:13})}),p.jsxs(jt,{children:["[S",m+1,"] ",qr(d)]}),p.jsxs(Kt,{title:"Ranking score, not a probability of correctness",children:["Score ",d.score.toFixed(2)]})]});return s?p.jsx("div",{children:v},`${d.chunkId}-${m}`):p.jsx("button",{type:"button",className:`trace-trigger${i&&b?" grounded-source-selected":""}`,"aria-pressed":i&&b,onClick:()=>{c(!0),l(b?null:m)},title:d.source,children:v},`${d.chunkId}-${m}`)})});return s?p.jsxs(bt,{className:"grounded-sources-card",children:[h,g]}):p.jsx(bt,{className:"grounded-sources-card",children:p.jsxs(Ii,{open:i,onOpenChange:c,children:[p.jsx(_i,{children:h}),g,p.jsx(ki,{children:p.jsx("div",{className:"grounded-sources-details-list",children:f.map((d,m)=>{const b=qr(d),v=Lc(d.source),x=a===m;return p.jsxs("div",{className:`grounded-detail-item${x?" grounded-detail-item--highlighted":""}`,children:[p.jsxs("div",{className:"grounded-detail-top",children:[p.jsxs("div",{className:"grounded-detail-title-group",children:[p.jsxs("span",{className:"grounded-detail-index",children:["[",m+1,"]"]}),p.jsx("span",{className:"grounded-detail-title",children:b})]}),p.jsxs("div",{className:"grounded-detail-meta",children:[p.jsxs("span",{className:"grounded-detail-score",children:["Rank score ",d.score.toFixed(2)]}),v&&p.jsxs("a",{href:v.path,onClick:S=>{S.preventDefault(),window.location.href=v.path},className:"grounded-route-link",title:`Navigate to ${v.label}`,children:[p.jsx("span",{children:v.label}),p.jsx(va,{size:10,"aria-hidden":"true"})]})]})]}),p.jsx("div",{className:"grounded-detail-path",children:p.jsx("code",{children:d.source})}),d.snippet&&p.jsxs("p",{className:"grounded-detail-snippet",children:['"',d.snippet,'"']})]},`detail-${d.chunkId}-${m}`)})})})]})})};function ng({label:e,sources:t}){const n=t.map(r=>{var i;const o=qr(r),s=ho(r.url||r.source)??((i=Lc(r.source))==null?void 0:i.path);return{key:r.chunkId,label:s||o,content:p.jsxs(p.Fragment,{children:[p.jsx(Zh,{title:o,url:s}),r.snippet&&p.jsx(Qh,{children:r.snippet})]})}});return p.jsx($h,{children:p.jsxs(Hh,{children:[p.jsx(Uh,{sources:n.map(r=>r.label),"aria-label":"View sources "+e,children:e}),p.jsx(zh,{children:n.length===1?n[0].content:p.jsxs(Wh,{"aria-label":"Sources",children:[p.jsxs(Kh,{children:[p.jsx(Yh,{}),p.jsx(Xh,{}),p.jsx(Jh,{})]}),p.jsx(qh,{children:n.map((r,o)=>p.jsx(Gh,{"aria-label":"Source "+(o+1),children:r.content},r.key+"-"+o))})]})})]})})}function rg(e,t){if(!e)return[];const n=/(\[[^\]]+\]\([^)]+\)|\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`|https?:\/\/[^\s]+|\[S\d+(?:\s*,\s*S\d+)*\])/g;return e.split(n).map((o,s)=>{if(!o)return null;if(t!=null&&t.length&&/^\[S\d+(?:\s*,\s*S\d+)*\]$/.test(o)){const c=[...new Set(o.match(/\d+/g))].map(a=>t[Number(a)-1]);if(c.every(a=>a!==void 0))return p.jsx(ng,{label:o,sources:c},s)}const i=o.match(/^\[([^\]]+)\]\(([^)]+)\)$/);if(i){const c=i[1],a=i[2],l=ho(a);if(!l)return p.jsx(I.Fragment,{children:c},s);const f=/^https?:\/\//i.test(a);return p.jsx("a",{href:l,target:f?"_blank":void 0,rel:f?"noopener noreferrer":void 0,className:"md-link",children:c},s)}return o.startsWith("**")&&o.endsWith("**")&&o.length>=4?p.jsx("strong",{children:o.slice(2,-2)},s):o.startsWith("*")&&o.endsWith("*")&&o.length>=2?p.jsx("em",{children:o.slice(1,-1)},s):o.startsWith("`")&&o.endsWith("`")&&o.length>=2?p.jsx("code",{className:"md-code",children:o.slice(1,-1)},s):/^https?:\/\//i.test(o)?p.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"md-link",children:o},s):p.jsx(I.Fragment,{children:o},s)})}function og(e){const t=e.replace(/\r\n/g,`
212
212
  `).split(`
213
213
  `),n=[];let r=0;for(;r<t.length;){const s=t[r].trim();if(!s){r++;continue}if(s.startsWith("```")){const a=s.slice(3).trim(),l=[];for(r++;r<t.length&&!t[r].trim().startsWith("```");)l.push(t[r]),r++;r<t.length&&t[r].trim().startsWith("```")&&r++,n.push({type:"code",lang:a,code:l.join(`
214
- `)});continue}if(/^(---|___|\*\*\*)$/.test(s)){n.push({type:"hr"}),r++;continue}const i=s.match(/^(#{1,4})\s+(.*)$/);if(i){n.push({type:"h",level:i[1].length,content:i[2]}),r++;continue}if(s.startsWith(">")){const a=[];for(;r<t.length&&t[r].trim().startsWith(">");)a.push(t[r].trim().replace(/^>\s?/,"")),r++;n.push({type:"quote",lines:a});continue}if(/^[-*]\s+/.test(s)){const a=[];for(;r<t.length&&/^[-*]\s+/.test(t[r].trim());)a.push(t[r].trim().replace(/^[-*]\s+/,"")),r++;n.push({type:"ul",items:a});continue}if(/^\d+\.\s+/.test(s)){const a=[];for(;r<t.length&&/^\d+\.\s+/.test(t[r].trim());)a.push(t[r].trim().replace(/^\d+\.\s+/,"")),r++;n.push({type:"ol",items:a});continue}if(s.startsWith("|")&&s.endsWith("|")){const a=[];for(;r<t.length&&t[r].trim().startsWith("|")&&t[r].trim().endsWith("|");)a.push(t[r].trim()),r++;if(a.length>=2){const l=m=>m.slice(1,-1).split("|").map(p=>p.trim()),f=l(a[0]),u=a[1].includes("-")?2:1,d=a.slice(u).map(l);n.push({type:"table",headers:f,rows:d});continue}}const c=[];for(;r<t.length&&t[r].trim()&&!t[r].trim().startsWith("```")&&!/^(#{1,4})\s+/.test(t[r].trim())&&!/^[-*]\s+/.test(t[r].trim())&&!/^\d+\.\s+/.test(t[r].trim())&&!t[r].trim().startsWith(">")&&!/^(---|___|\*\*\*)$/.test(t[r].trim());)c.push(t[r].trim()),r++;c.length>0&&n.push({type:"p",lines:c})}return n}function om({code:e,lang:t,streaming:n}){const{status:r,copy:o}=Vi();return h.jsxs("div",{className:"md-code-block",children:[h.jsxs("div",{className:"md-code-header",children:[h.jsx("span",{children:t||"Code"}),!n&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{className:"md-code-status",role:"status",children:[r==="copied"&&"Copied",r==="failed"&&"Couldn’t copy"]}),h.jsx("button",{type:"button",className:"chat-message-action","aria-label":"Copy code",title:"Copy code",disabled:r==="copying",onClick:()=>void o(e),children:r==="copied"?h.jsx(Xr,{size:15,"aria-hidden":"true"}):h.jsx(Qs,{size:15,"aria-hidden":"true"})})]})]}),h.jsx("pre",{className:"md-pre",children:h.jsx("code",{children:e.split(`
215
- `).map((s,i)=>h.jsxs("span",{className:"md-code-line",children:[h.jsx("span",{className:"md-code-number","aria-hidden":"true",children:i+1}),h.jsx("span",{children:s||" "})]},i))})})]})}const Ls=I.memo(function({text:t,streaming:n=!1,sources:r}){if(!t)return null;const o=rm(t),s=i=>nm(i,r);return h.jsx("div",{className:"md-content",children:o.map((i,c)=>{switch(i.type){case"h":return i.level===1?h.jsx("h2",{className:"md-h1",children:s(i.content)},c):i.level===2?h.jsx("h3",{className:"md-h2",children:s(i.content)},c):i.level===3?h.jsx("h4",{className:"md-h3",children:s(i.content)},c):h.jsx("h5",{className:"md-h4",children:s(i.content)},c);case"ul":return h.jsx("ul",{className:"md-ul",children:i.items.map((a,l)=>h.jsx("li",{className:"md-li",children:s(a)},l))},c);case"ol":return h.jsx("ol",{className:"md-ol",children:i.items.map((a,l)=>h.jsx("li",{className:"md-li",children:s(a)},l))},c);case"code":return h.jsx(om,{code:i.code,lang:i.lang,streaming:n},c);case"quote":return h.jsx("blockquote",{className:"md-quote",children:i.lines.map((a,l)=>h.jsx("p",{children:s(a)},l))},c);case"hr":return h.jsx("hr",{className:"md-hr"},c);case"table":return h.jsx("div",{className:"md-table-wrap",children:h.jsxs("table",{className:"md-table",children:[h.jsx("thead",{children:h.jsx("tr",{children:i.headers.map((a,l)=>h.jsx("th",{children:s(a)},l))})}),h.jsx("tbody",{children:i.rows.map((a,l)=>h.jsx("tr",{children:a.map((f,u)=>h.jsx("td",{children:s(f)},u))},l))})]})},c);case"p":default:return h.jsx("p",{className:"md-p",children:i.lines.map((a,l)=>h.jsxs(I.Fragment,{children:[s(a),l<i.lines.length-1&&h.jsx("br",{})]},l))},c)}})})}),sm=I.lazy(async()=>({default:(await import("streamdown")).Streamdown})),Lc=I.createContext(null);function Bc(){const e=I.useContext(Lc);if(!e)throw new Error("Reasoning parts must be rendered inside Reasoning.");return e}function im({isStreaming:e=!1,open:t,defaultOpen:n,onOpenChange:r,duration:o,className:s,...i}){const[c,a]=I.useState(n),[l,f]=I.useState(),u=I.useRef(null),d=t??c??e;I.useEffect(()=>{e?u.current=performance.now():u.current!==null&&(f(Math.round((performance.now()-u.current)/1e3)),u.current=null)},[e]);function m(p){t===void 0&&a(p),r==null||r(p)}return h.jsx(Lc.Provider,{value:{isStreaming:e,isOpen:d,setIsOpen:m,duration:o??l},children:h.jsx(bt,{className:s,children:h.jsx(Pi,{...i,open:d,onOpenChange:m})})})}function cm({getThinkingMessage:e,children:t,icon:n,description:r,...o}){const{isStreaming:s,duration:i}=Bc(),c=s?"Thinking":i===void 0?"Thought":`Thought for ${i}s`;return h.jsx(Ii,{...o,children:h.jsxs(Nt,{status:s?"running":void 0,children:[h.jsx(xt,{children:n??(s?h.jsx(ei,{size:14,className:"trace-spinner"}):h.jsx(Zs,{size:14}))}),h.jsx(jt,{children:t??(e==null?void 0:e(s,i))??c}),r&&h.jsx(Kt,{"aria-hidden":s||void 0,children:r})]})})}function am({children:e,className:t,...n}){const{isStreaming:r}=Bc();return h.jsx(_i,{className:ue("reasoning-content",t),...n,children:typeof e=="string"?h.jsx(I.Suspense,{fallback:h.jsx("div",{className:"md-content reasoning-text",children:e}),children:h.jsx(sm,{className:"md-content",isAnimating:r,mode:r?"streaming":"static",children:e})}):e})}function lm(e){return e==="create_ticket"?"Support ticket processed":e==="get_customer"?"Account verified":e==="get_ticket"?"Ticket status loaded":"Information retrieved"}const um=({status:e="complete",progressText:t,progressSteps:n=[],durationMs:r,toolCalls:o=[]})=>{const s=e==="pending",i=e==="stopped",[c,a]=I.useState(0);I.useEffect(()=>{if(!s)return;const u=Date.now(),d=setInterval(()=>{a(Number(((Date.now()-u)/1e3).toFixed(1)))},250);return()=>clearInterval(d)},[s]);const l=n.length>0||o.length>0,f=r===void 0?void 0:Number((r/1e3).toFixed(1));return l?h.jsxs(im,{className:"chat-response-trace",isStreaming:s,duration:f,children:[h.jsx(cm,{getThinkingMessage:i?()=>"Response stopped":void 0,icon:i?h.jsx(ni,{size:12}):void 0,description:s?`${c.toFixed(1)}s`:void 0}),h.jsx(am,{children:h.jsxs(bt,{children:[n.map((u,d)=>h.jsxs(Gs,{children:[h.jsx(ia,{children:h.jsx("span",{className:"chat-progress-dot"})}),h.jsx(Ks,{children:u})]},`${u}-${d}`)),o.map((u,d)=>h.jsxs(Nt,{children:[h.jsx(xt,{children:h.jsx(Ia,{size:13})}),h.jsx(jt,{children:lm(u.toolName)})]},`${u.toolName}-${d}`))]})})]}):h.jsx(bt,{className:"chat-response-trace",children:h.jsxs(Nt,{status:s?"running":void 0,children:[h.jsx(xt,{children:s?h.jsx(ei,{size:14,className:"trace-spinner"}):h.jsx(Zs,{size:14})}),h.jsx(jt,{children:s?t||"Thinking":i?"Response stopped":"Thought"}),s?h.jsxs(Kt,{"aria-hidden":"true",children:[c.toFixed(1),"s"]}):!i&&f!==void 0&&h.jsxs(Kt,{children:[f,"s"]})]})})},fm=({message:e,onEdit:t})=>{var m,p,g,b;const n=qn(),r=(n==null?void 0:n.hideInspectSources)??!1,o=(n==null?void 0:n.showGroundedSources)??!1,s=e.role==="user",i=e.status==="error",c=e.status==="pending",a=e.status==="stopped",l=e.id.startsWith("welcome"),f=e.role==="assistant"&&!l&&!i,u=f&&(c||a||e.durationMs!==void 0||!!((m=e.progressSteps)!=null&&m.length||(p=e.sources)!=null&&p.length||(g=e.toolCalls)!=null&&g.length||e.usage)),d=f&&!c&&!a&&e.content.trim().length>0;return h.jsxs(Jr,{align:s?"end":"start",children:[e.role==="assistant"&&h.jsx(ri,{className:"avatar-circle","aria-hidden":"true",children:h.jsx(Xs,{size:15})}),h.jsxs(Zr,{children:[u&&h.jsx(ka,{children:h.jsx(um,{status:c?"pending":a?"stopped":"complete",progressText:e.progressText,progressSteps:e.progressSteps,durationMs:e.durationMs,toolCalls:e.toolCalls})}),s?h.jsx(Ar,{align:"end",children:h.jsx(Nr,{className:"msg-user-pre",children:e.content})}):l||i?h.jsx(Ar,{variant:i?"destructive":"muted",children:h.jsx(Nr,{children:h.jsx(Ls,{text:e.content})})}):e.content&&h.jsxs("div",{className:"chat-message-body",children:[h.jsx(Ls,{text:e.content,streaming:c,sources:f&&!c&&!a&&!r?e.sources:void 0}),f&&!c&&!a&&o&&((b=e.sources)!=null&&b.length)?h.jsx(em,{sources:e.sources,hideInspectSources:r}):null]}),d&&n&&h.jsx(Cr,{children:h.jsx(Vu,{message:e,onFeedback:n.toggleMessageFeedback})}),s&&!i&&h.jsxs(Cr,{children:[t&&h.jsx("button",{type:"button",className:"chat-message-action","aria-label":"Edit message",title:"Edit message",disabled:(n==null?void 0:n.status)==="awaiting"||(n==null?void 0:n.status)==="connecting"||!!(n!=null&&n.pendingTicket),onClick:()=>t(e.content),children:h.jsx(Sa,{size:14,"aria-hidden":"true"})}),h.jsx(Xr,{size:13,className:"msg-tick","aria-hidden":"true"})]})]})]})},dm=({onEdit:e})=>{const{messages:t,status:n}=en(),r=n==="awaiting"||n==="connecting",o=t.filter(s=>s.status!=="error");return h.jsx(ju,{autoScroll:!0,defaultScrollPosition:"last-anchor",scrollPreviousItemPeek:64,children:h.jsxs(Mu,{children:[h.jsx(Du,{"aria-label":"Chat messages",children:h.jsxs(Fu,{"aria-busy":r,children:[o.length===0&&h.jsx(cs,{messageId:"welcome",children:h.jsx(Bu,{})}),o.map(s=>h.jsx(cs,{messageId:s.streamId??s.id,"data-role":s.role,scrollAnchor:s.role==="user",children:h.jsx(fm,{message:s,onEdit:e})},s.streamId??s.id))]})}),h.jsx(Lu,{})]})})},pm=()=>{const{pendingTicket:e,ticketBusy:t,userContext:n,confirmTicket:r,cancelTicket:o}=en(),s=!n.customerId&&!n.email,[i,c]=I.useState("");return e?h.jsxs("div",{className:"ticket-card",role:"region","aria-label":"Create support ticket",children:[h.jsx("h3",{className:"ticket-card-title",children:"Create support ticket?"}),h.jsx("p",{className:"ticket-card-desc",children:"I can open a support request for you. Nothing is created until you confirm."}),h.jsx("p",{className:"ticket-card-body",children:e.description}),s&&h.jsxs("label",{className:"ticket-id-label",children:["Customer ID or email",h.jsx("input",{value:i,onChange:a=>c(a.target.value),className:"ticket-id-input",placeholder:"CUST-1001 or you@company.com",autoComplete:"email"})]}),h.jsxs("div",{className:"ticket-actions",children:[h.jsx("button",{type:"button",onClick:o,disabled:t,className:"ticket-cancel-btn",children:"Cancel"}),h.jsx("button",{type:"button",onClick:()=>void r(i),disabled:t||s&&!i.trim(),className:"ticket-confirm-btn",children:t?"Creating…":"Create ticket"})]})]}):null},Fo=({className:e,onClose:t,showMinimize:n,title:r,subtitle:o,envStage:s,envPulse:i=!0})=>{const{messages:c,sendMessage:a,stopResponse:l,status:f,error:u,resetConversation:d,retryLast:m,pendingTicket:p,soundEnabled:g,toggleSound:b}=en(),y=I.useRef(null),x=f==="awaiting"||f==="connecting",S=c[c.length-1],E=x?S==null?void 0:S.progressText:(S==null?void 0:S.status)==="stopped"?"Response stopped":void 0;return h.jsxs("section",{className:`chat-panel${e?` ${e}`:""}`,"aria-label":"VPS AI Assistant",children:[h.jsx(Vl,{title:r,subtitle:o,onClose:t,onReset:()=>void d(),showMinimize:n,soundEnabled:g,onToggleSound:b,envStage:s,envPulse:i}),h.jsx("div",{className:"chat-panel-body",children:h.jsx(dm,{onEdit:C=>{var w;return(w=y.current)==null?void 0:w.edit(C)}})}),h.jsx(Gs,{className:"sr-only",role:"status",children:h.jsx(Ks,{children:E})}),u&&f==="error"&&h.jsx(Dl,{message:u,onRetry:()=>void m()}),h.jsx(pm,{}),h.jsx(Jl,{ref:y,onSend:C=>void a(C),onStop:x?l:void 0,disabled:x||!!p})]})},hm=({open:e,onClose:t,envStage:n,envPulse:r=!0})=>e?h.jsx("div",{id:"vps-chatbot-widget-panel",className:"widget-panel",children:h.jsx(Fo,{onClose:t,showMinimize:!0,title:"VPS AI Assistant",envStage:n,envPulse:r})}):null,mm=({open:e,onToggle:t})=>h.jsx("button",{type:"button",onClick:t,"aria-expanded":e,"aria-controls":"vps-chatbot-widget-panel","aria-label":e?"Close assistant":"Open assistant",className:"widget-trigger-btn",children:e?h.jsx(_a,{size:22}):h.jsx(ti,{size:24})}),Bs=({defaultOpen:e=!1,open:t,onOpenChange:n,envStage:r,envPulse:o=!0})=>{const[s,i]=I.useState(e),c=t??s,a=l=>{n==null||n(l),t===void 0&&i(l)};return h.jsxs(h.Fragment,{children:[h.jsx(hm,{open:c,onClose:()=>a(!1),envStage:r,envPulse:o}),h.jsx(mm,{open:c,onToggle:()=>a(!c)})]})},gm=({apiBaseUrl:e,apiUrl:t,proxyUrl:n,userContext:r,role:o,roleId:s,client:i,welcomeMessage:c,suggestions:a,disableSuggestions:l,initialMessage:f,hideInspectSources:u,showGroundedSources:d,modelId:m,...p})=>{const g=qn(),b=e??t??n;return!!g&&(!b||vt(b)===vt(g==null?void 0:g.apiBaseUrl))&&!r&&o===void 0&&s===void 0&&i===void 0&&c===void 0&&!a&&l===void 0&&!f&&u===void 0&&d===void 0&&m===void 0?h.jsx(Bs,{...p}):h.jsx(Yr,{apiBaseUrl:b,userContext:r,role:o,roleId:s,client:i,welcomeMessage:c,suggestions:a,disableSuggestions:l,initialMessage:f,hideInspectSources:u,showGroundedSources:d,modelId:m,children:h.jsx(Bs,{...p})})},bm=({open:e,onClose:t,subtitle:n,title:r,envStage:o,envPulse:s=!0})=>h.jsxs(h.Fragment,{children:[h.jsx("div",{className:`embedded-overlay ${e?"embedded-overlay--open":"embedded-overlay--closed"}`,hidden:!e,onClick:t,"aria-hidden":"true"}),h.jsx("aside",{id:"vps-embedded-chat-panel",className:`embedded-panel ${e?"embedded-panel--open":"embedded-panel--closed"}`,"aria-hidden":!e,children:e&&h.jsx(Fo,{onClose:t,title:r||"VPS AI Assistant",subtitle:n,envStage:o,envPulse:s})})]}),ym=5,wr=8,Vc="vps-embedded-assistant-top";function vm(e,t,n){return Math.min(n,Math.max(t,e))}function Vs(e,t){const n=Math.max(wr,window.innerHeight-t-wr);return vm(e,wr,n)}function xm(){try{const e=window.localStorage.getItem(Vc);if(!e)return null;const t=Number(e);return Number.isFinite(t)?t:null}catch{return null}}function Em(e){try{window.localStorage.setItem(Vc,String(e))}catch{}}const Sm=({onOpen:e})=>{const t=I.useRef(null),n=I.useRef({pointerId:null,startY:0,startTop:0,moved:!1}),[r,o]=I.useState(()=>typeof window>"u"?null:xm()),s=I.useRef(r),i=I.useRef(!1),[c,a]=I.useState(!1);I.useEffect(()=>{s.current=r},[r]),I.useEffect(()=>{const d=t.current;if(!d)return;const m=()=>{o(p=>{const g=p??Math.round(window.innerHeight/2-d.offsetHeight/2),b=Vs(g,d.offsetHeight);return s.current=b,b})};return m(),window.addEventListener("resize",m),()=>window.removeEventListener("resize",m)},[]);const l=d=>{if(d.button!==0)return;const m=d.currentTarget,p=m.getBoundingClientRect();n.current={pointerId:d.pointerId,startY:d.clientY,startTop:p.top,moved:!1};try{m.setPointerCapture(d.pointerId)}catch{}},f=d=>{if(n.current.pointerId!==d.pointerId)return;const m=d.clientY-n.current.startY;if(!n.current.moved&&Math.abs(m)<ym)return;n.current.moved=!0,a(!0);const p=Vs(n.current.startTop+m,d.currentTarget.offsetHeight);s.current=p,o(p)},u=d=>{var p,g;if(n.current.pointerId!==d.pointerId)return;try{(g=(p=d.currentTarget).hasPointerCapture)!=null&&g.call(p,d.pointerId)&&d.currentTarget.releasePointerCapture(d.pointerId)}catch{}const m=n.current.moved;n.current.pointerId=null,n.current.moved=!1,a(!1),m&&(i.current=!0,s.current!=null&&Em(s.current))};return h.jsxs("button",{ref:t,type:"button",onPointerDown:l,onPointerMove:f,onPointerUp:u,onPointerCancel:u,onClick:()=>{if(i.current){i.current=!1;return}e()},"aria-expanded":!1,"aria-controls":"vps-embedded-chat-panel","aria-label":"Assistant",className:`embedded-trigger-btn ${c?"embedded-trigger-btn--grabbing":"embedded-trigger-btn--grab"}`,style:{top:r??"50%",transform:r==null?"translateY(-50%)":void 0},children:[h.jsx(ti,{size:16}),"Assistant"]})},$s=({defaultOpen:e=!1,open:t,onOpenChange:n,showTrigger:r=!0,envStage:o,envPulse:s=!0})=>{const[i,c]=I.useState(e),a=t??i,l=f=>{n==null||n(f),t===void 0&&c(f)};return h.jsxs(h.Fragment,{children:[r&&!a&&h.jsx(Sm,{onOpen:()=>l(!0)}),h.jsx(bm,{open:a,onClose:()=>l(!1),envStage:o,envPulse:s})]})},wm=({apiBaseUrl:e,apiUrl:t,proxyUrl:n,userContext:r,role:o,roleId:s,client:i,welcomeMessage:c,suggestions:a,disableSuggestions:l,initialMessage:f,hideInspectSources:u,showGroundedSources:d,modelId:m,...p})=>{const g=qn(),b=e??t??n;return!!g&&(!b||vt(b)===vt(g==null?void 0:g.apiBaseUrl))&&!r&&o===void 0&&s===void 0&&i===void 0&&c===void 0&&!a&&l===void 0&&!f&&u===void 0&&d===void 0&&m===void 0?h.jsx($s,{...p}):h.jsx(Yr,{apiBaseUrl:b,userContext:r,role:o,roleId:s,client:i,welcomeMessage:c,suggestions:a,disableSuggestions:l,initialMessage:f,hideInspectSources:u,showGroundedSources:d,modelId:m,children:h.jsx($s,{...p})})},Cm={Colors:{VPS_White:"#fff",VPS_Dark_Blue:"#1A1A31",VPS_Light_Blue:"#353552",VPS_Light_Grey:"#D1D1D6",VPS_Orange:"#FF4717",Dark_Blue_50:"#F1F5FC",Dark_Blue_100:"#E5EBFA",Dark_Blue_200:"#D1DAF4",Dark_Blue_300:"#B4C2ED",Dark_Blue_400:"#96A2E3",Dark_Blue_500:"#7C84D8",Dark_Blue_600:"#6262C9",Dark_Blue_700:"#5351B1",Dark_Blue_800:"#44448F",Dark_Blue_900:"#3C3D73",Dark_Blue_950:"#1A1A31",Light_Blue_50:"#F4F6FA",Light_Blue_100:"#E6E9F3",Light_Blue_200:"#D3D8EA",Light_Blue_300:"#B4BEDC",Light_Blue_400:"#909DCA",Light_Blue_500:"#7580BC",Light_Blue_600:"#6369AD",Light_Blue_700:"#575A9E",Light_Blue_800:"#4B4B82",Light_Blue_900:"#404168",Light_Blue_950:"#353552",Grey_50:"#F6F6F7",Grey_100:"#EFEFF0",Grey_200:"#E2E1E4",Grey_300:"#D1D1D6",Grey_400:"#B9B9C0",Grey_500:"#A7A6AE",Grey_600:"#93919A",Grey_700:"#7E7D85",Grey_800:"#67666D",Grey_900:"#56555A",Grey_950:"#323234",Orange_50:"#FFF3ED",Orange_100:"#FFE4D4",Orange_200:"#FFC5A8",Orange_300:"#FF9D70",Orange_400:"#FF6837",Orange_500:"#FF4717",Orange_600:"#F02706",Orange_700:"#C71807",Orange_800:"#9E150E",Orange_900:"#7F150F",Orange_950:"#450605",Success_50:"#F1FCF5",Success_100:"#DEFAEA",Success_200:"#BEF4D4",Success_300:"#8BEAB3",Success_400:"#52D689",Success_500:"#2ECC71",Success_600:"#1D9C53",Success_700:"#1B7A43",Success_800:"#1A6139",Success_900:"#175031",Success_950:"#072C18",Warning_50:"#FFFEEA",Warning_100:"#FFF9C5",Warning_200:"#FFF485",Warning_300:"#FFE846",Warning_400:"#FFD81B",Warning_500:"#FFB800",Warning_600:"#E28D00",Warning_700:"#BB6302",Warning_800:"#984C08",Warning_900:"#7C3F0B",Warning_950:"#482000",Error_50:"#FFF1F1",Error_100:"#FFDFDF",Error_200:"#FFC5C5",Error_300:"#FF9D9D",Error_400:"#FF6464",Error_500:"#FF2E2E",Error_600:"#ED1515",Error_700:"#C80D0D",Error_800:"#A50F0F",Error_900:"#881414",Error_950:"#4B0404",Netural_25:"#FDFDFD",Netural_50:"#FAFAFA",Netural_100:"#F5F5F5",Netural_200:"#E9EAEC",Netural_300:"#D6D7DB",Netural_400:"#A4A7AE",Netural_500:"#727681",Netural_600:"#545863",Netural_700:"#424651",Netural_800:"#252B37",Netural_900:"#191D28",Netural_950:"#0A0D12",Tint_Dark_Blue_100:"#1A1A31",Tint_Dark_Blue_90:"#313146",Tint_Dark_Blue_80:"#48485A",Tint_Dark_Blue_70:"#5F5F6F",Tint_Dark_Blue_60:"#767683",Tint_Dark_Blue_50:"#8C8C98",Tint_Dark_Blue_40:"#A3A3AD",Tint_Dark_Blue_30:"#BABAC1",Tint_Dark_Blue_20:"#D1D1D6",Tint_Dark_Blue_10:"#E8E8EA",Tint_Dark_Blue_5:"#F4F4F5",Tint_Light_Blue_100:"#353552",Tint_Light_Blue_90:"#494963",Tint_Light_Blue_80:"#5D5D75",Tint_Light_Blue_70:"#727286",Tint_Light_Blue_60:"#868697",Tint_Light_Blue_50:"#9A9AA8",Tint_Light_Blue_40:"#AEAEBA",Tint_Light_Blue_30:"#C2C2CB",Tint_Light_Blue_20:"#D7D7DC",Tint_Light_Blue_10:"#EBEBEE",Tint_Light_Blue_5:"#F5F5F6",Tint_Grey_100:"#D1D1D6",Tint_Grey_90:"#D6D6DA",Tint_Grey_80:"#DADADE",Tint_Grey_70:"#DFDFE2",Tint_Grey_60:"#E3E3E6",Tint_Grey_50:"#E8E8EB",Tint_Grey_40:"#EDEDEF",Tint_Grey_30:"#F1F1F3",Tint_Grey_20:"#F6F6F7",Tint_Grey_10:"#FAFAFB",Tint_Grey_5:"#FDFDFD",Tint_Solus_100:"#FF4717",Tint_Solus_90:"#FF592E",Tint_Solus_80:"#FF6C45",Tint_Solus_70:"#FF7E5D",Tint_Solus_60:"#FF9174",Tint_Solus_50:"#FFA38B",Tint_Solus_40:"#FFB5A2",Tint_Solus_30:"#FFC8B9",Tint_Solus_20:"#FFDAD1",Tint_Solus_10:"#FFEDE8",Tint_Solus_5:"#FFF6F3",Other_Color:"#00ABC9"},StatusColor:{tested:"#3E4784",received:"#EE46BC",InTransit:"#6938EF",registered:"#1570EF",reported:"#2ECC71",noStatus:"#727681",Action:"#FF2E2E",Caution:"#FFB800",Pass:"#2ECC71",No_Rating:"#FF6837",Received:"#EE46BC",Tested:"#3E4784",Reported:"#2ECC71",No_Status:"#6938EF",Overdue:"#FF2E2E",Duesoon:"#FFB800",Scheduled:"#1570EF",Good:"#2ECC71",NotApplicable:"#353552"}};exports.ChatPanel=Fo;exports.ChatProvider=Yr;exports.ChatbotWidget=gm;exports.ColorPalette=Cm;exports.EmbeddedChatbot=wm;exports.buildApiUrl=Rn;exports.chatApi=ta;exports.createChatApi=Gr;exports.resolveApiBaseUrl=vt;exports.useChatContext=zs;exports.useChatbot=en;exports.useOptionalChatContext=qn;
214
+ `)});continue}if(/^(---|___|\*\*\*)$/.test(s)){n.push({type:"hr"}),r++;continue}const i=s.match(/^(#{1,4})\s+(.*)$/);if(i){n.push({type:"h",level:i[1].length,content:i[2]}),r++;continue}if(s.startsWith(">")){const a=[];for(;r<t.length&&t[r].trim().startsWith(">");)a.push(t[r].trim().replace(/^>\s?/,"")),r++;n.push({type:"quote",lines:a});continue}if(/^[-*]\s+/.test(s)){const a=[];for(;r<t.length&&/^[-*]\s+/.test(t[r].trim());)a.push(t[r].trim().replace(/^[-*]\s+/,"")),r++;n.push({type:"ul",items:a});continue}if(/^\d+\.\s+/.test(s)){const a=[];for(;r<t.length&&/^\d+\.\s+/.test(t[r].trim());)a.push(t[r].trim().replace(/^\d+\.\s+/,"")),r++;n.push({type:"ol",items:a});continue}if(s.startsWith("|")&&s.endsWith("|")){const a=[];for(;r<t.length&&t[r].trim().startsWith("|")&&t[r].trim().endsWith("|");)a.push(t[r].trim()),r++;if(a.length>=2){const l=g=>g.slice(1,-1).split("|").map(d=>d.trim()),f=l(a[0]),u=a[1].includes("-")?2:1,h=a.slice(u).map(l);n.push({type:"table",headers:f,rows:h});continue}}const c=[];for(;r<t.length&&t[r].trim()&&!t[r].trim().startsWith("```")&&!/^(#{1,4})\s+/.test(t[r].trim())&&!/^[-*]\s+/.test(t[r].trim())&&!/^\d+\.\s+/.test(t[r].trim())&&!t[r].trim().startsWith(">")&&!/^(---|___|\*\*\*)$/.test(t[r].trim());)c.push(t[r].trim()),r++;c.length>0&&n.push({type:"p",lines:c})}return n}function sg({code:e,lang:t,streaming:n}){const{status:r,copy:o}=$i();return p.jsxs("div",{className:"md-code-block",children:[p.jsxs("div",{className:"md-code-header",children:[p.jsx("span",{children:t||"Code"}),!n&&p.jsxs(p.Fragment,{children:[p.jsxs("span",{className:"md-code-status",role:"status",children:[r==="copied"&&"Copied",r==="failed"&&"Couldn’t copy"]}),p.jsx("button",{type:"button",className:"chat-message-action","aria-label":"Copy code",title:"Copy code",disabled:r==="copying",onClick:()=>void o(e),children:r==="copied"?p.jsx(Xr,{size:15,"aria-hidden":"true"}):p.jsx(ei,{size:15,"aria-hidden":"true"})})]})]}),p.jsx("pre",{className:"md-pre",children:p.jsx("code",{children:e.split(`
215
+ `).map((s,i)=>p.jsxs("span",{className:"md-code-line",children:[p.jsx("span",{className:"md-code-number","aria-hidden":"true",children:i+1}),p.jsx("span",{children:s||" "})]},i))})})]})}const Ls=I.memo(function({text:t,streaming:n=!1,sources:r}){if(!t)return null;const o=og(t),s=i=>rg(i,r);return p.jsx("div",{className:"md-content",children:o.map((i,c)=>{switch(i.type){case"h":return i.level===1?p.jsx("h2",{className:"md-h1",children:s(i.content)},c):i.level===2?p.jsx("h3",{className:"md-h2",children:s(i.content)},c):i.level===3?p.jsx("h4",{className:"md-h3",children:s(i.content)},c):p.jsx("h5",{className:"md-h4",children:s(i.content)},c);case"ul":return p.jsx("ul",{className:"md-ul",children:i.items.map((a,l)=>p.jsx("li",{className:"md-li",children:s(a)},l))},c);case"ol":return p.jsx("ol",{className:"md-ol",children:i.items.map((a,l)=>p.jsx("li",{className:"md-li",children:s(a)},l))},c);case"code":return p.jsx(sg,{code:i.code,lang:i.lang,streaming:n},c);case"quote":return p.jsx("blockquote",{className:"md-quote",children:i.lines.map((a,l)=>p.jsx("p",{children:s(a)},l))},c);case"hr":return p.jsx("hr",{className:"md-hr"},c);case"table":return p.jsx("div",{className:"md-table-wrap",children:p.jsxs("table",{className:"md-table",children:[p.jsx("thead",{children:p.jsx("tr",{children:i.headers.map((a,l)=>p.jsx("th",{children:s(a)},l))})}),p.jsx("tbody",{children:i.rows.map((a,l)=>p.jsx("tr",{children:a.map((f,u)=>p.jsx("td",{children:s(f)},u))},l))})]})},c);case"p":default:return p.jsx("p",{className:"md-p",children:i.lines.map((a,l)=>p.jsxs(I.Fragment,{children:[s(a),l<i.lines.length-1&&p.jsx("br",{})]},l))},c)}})})}),ig=I.lazy(async()=>({default:(await import("streamdown")).Streamdown})),Bc=I.createContext(null);function Vc(){const e=I.useContext(Bc);if(!e)throw new Error("Reasoning parts must be rendered inside Reasoning.");return e}function cg({isStreaming:e=!1,open:t,defaultOpen:n,onOpenChange:r,duration:o,className:s,...i}){const[c,a]=I.useState(n),[l,f]=I.useState(),u=I.useRef(null),h=t??c??e;I.useEffect(()=>{e?u.current=performance.now():u.current!==null&&(f(Math.round((performance.now()-u.current)/1e3)),u.current=null)},[e]);function g(d){t===void 0&&a(d),r==null||r(d)}return p.jsx(Bc.Provider,{value:{isStreaming:e,isOpen:h,setIsOpen:g,duration:o??l},children:p.jsx(bt,{className:s,children:p.jsx(Ii,{...i,open:h,onOpenChange:g})})})}function ag({getThinkingMessage:e,children:t,icon:n,description:r,...o}){const{isStreaming:s,duration:i}=Vc(),c=s?"Thinking":i===void 0?"Thought":`Thought for ${i}s`;return p.jsx(_i,{...o,children:p.jsxs(Nt,{status:s?"running":void 0,children:[p.jsx(xt,{children:n??(s?p.jsx(ti,{size:14,className:"trace-spinner"}):p.jsx(Qs,{size:14}))}),p.jsx(jt,{children:t??(e==null?void 0:e(s,i))??c}),r&&p.jsx(Kt,{"aria-hidden":s||void 0,children:r})]})})}function lg({children:e,className:t,...n}){const{isStreaming:r}=Vc();return p.jsx(ki,{className:ue("reasoning-content",t),...n,children:typeof e=="string"?p.jsx(I.Suspense,{fallback:p.jsx("div",{className:"md-content reasoning-text",children:e}),children:p.jsx(ig,{className:"md-content",isAnimating:r,mode:r?"streaming":"static",children:e})}):e})}function ug(e){return e==="create_ticket"?"Support ticket processed":e==="get_customer"?"Account verified":e==="get_ticket"?"Ticket status loaded":"Information retrieved"}const fg=({status:e="complete",progressText:t,progressSteps:n=[],durationMs:r,toolCalls:o=[]})=>{const s=e==="pending",i=e==="stopped",[c,a]=I.useState(0);I.useEffect(()=>{if(!s)return;const u=Date.now(),h=setInterval(()=>{a(Number(((Date.now()-u)/1e3).toFixed(1)))},250);return()=>clearInterval(h)},[s]);const l=n.length>0||o.length>0,f=r===void 0?void 0:Number((r/1e3).toFixed(1));return l?p.jsxs(cg,{className:"chat-response-trace",isStreaming:s,duration:f,children:[p.jsx(ag,{getThinkingMessage:i?()=>"Response stopped":void 0,icon:i?p.jsx(ri,{size:12}):void 0,description:s?`${c.toFixed(1)}s`:void 0}),p.jsx(lg,{children:p.jsxs(bt,{children:[n.map((u,h)=>p.jsxs(Ks,{children:[p.jsx(ca,{children:p.jsx("span",{className:"chat-progress-dot"})}),p.jsx(Ys,{children:u})]},`${u}-${h}`)),o.map((u,h)=>p.jsxs(Nt,{children:[p.jsx(xt,{children:p.jsx(_a,{size:13})}),p.jsx(jt,{children:ug(u.toolName)})]},`${u.toolName}-${h}`))]})})]}):p.jsx(bt,{className:"chat-response-trace",children:p.jsxs(Nt,{status:s?"running":void 0,children:[p.jsx(xt,{children:s?p.jsx(ti,{size:14,className:"trace-spinner"}):p.jsx(Qs,{size:14})}),p.jsx(jt,{children:s?t||"Thinking":i?"Response stopped":"Thought"}),s?p.jsxs(Kt,{"aria-hidden":"true",children:[c.toFixed(1),"s"]}):!i&&f!==void 0&&p.jsxs(Kt,{children:[f,"s"]})]})})},dg=({message:e,onEdit:t})=>{var g,d,m,b;const n=qn(),r=(n==null?void 0:n.hideInspectSources)??!1,o=(n==null?void 0:n.showGroundedSources)??!1,s=e.role==="user",i=e.status==="error",c=e.status==="pending",a=e.status==="stopped",l=e.id.startsWith("welcome"),f=e.role==="assistant"&&!l&&!i,u=f&&(c||a||e.durationMs!==void 0||!!((g=e.progressSteps)!=null&&g.length||(d=e.sources)!=null&&d.length||(m=e.toolCalls)!=null&&m.length||e.usage)),h=f&&!c&&!a&&e.content.trim().length>0;return p.jsxs(Jr,{align:s?"end":"start",children:[e.role==="assistant"&&p.jsx(oi,{className:"avatar-circle","aria-hidden":"true",children:p.jsx(Js,{size:15})}),p.jsxs(Zr,{children:[u&&p.jsx(Aa,{children:p.jsx(fg,{status:c?"pending":a?"stopped":"complete",progressText:e.progressText,progressSteps:e.progressSteps,durationMs:e.durationMs,toolCalls:e.toolCalls})}),s?p.jsx(Ar,{align:"end",children:p.jsx(Nr,{className:"msg-user-pre",children:e.content})}):l||i?p.jsx(Ar,{variant:i?"destructive":"muted",children:p.jsx(Nr,{children:p.jsx(Ls,{text:e.content})})}):e.content&&p.jsxs("div",{className:"chat-message-body",children:[p.jsx(Ls,{text:e.content,streaming:c,sources:f&&!c&&!a&&!r?e.sources:void 0}),f&&!c&&!a&&o&&((b=e.sources)!=null&&b.length)?p.jsx(tg,{sources:e.sources,hideInspectSources:r}):null]}),h&&n&&p.jsx(Cr,{children:p.jsx($u,{message:e,onFeedback:n.toggleMessageFeedback})}),s&&!i&&p.jsxs(Cr,{children:[t&&p.jsx("button",{type:"button",className:"chat-message-action","aria-label":"Edit message",title:"Edit message",disabled:(n==null?void 0:n.status)==="awaiting"||(n==null?void 0:n.status)==="connecting"||!!(n!=null&&n.pendingTicket),onClick:()=>t(e.content),children:p.jsx(wa,{size:14,"aria-hidden":"true"})}),p.jsx(Xr,{size:13,className:"msg-tick","aria-hidden":"true"})]})]})]})},pg=({onEdit:e})=>{const{messages:t,status:n,suggestions:r,showSuggestions:o,sendMessage:s}=en(),i=n==="awaiting"||n==="connecting",c=t.filter(a=>a.status!=="error");return p.jsx(Mu,{autoScroll:!0,defaultScrollPosition:"last-anchor",scrollPreviousItemPeek:64,children:p.jsxs(Du,{children:[p.jsx(Fu,{"aria-label":"Chat messages",children:p.jsxs(Lu,{"aria-busy":i,children:[c.length===0&&p.jsx(cs,{messageId:"welcome",children:p.jsx(Vu,{})}),c.map(a=>p.jsx(cs,{messageId:a.streamId??a.id,"data-role":a.role,scrollAnchor:a.role==="user",children:p.jsx(dg,{message:a,onEdit:e})},a.streamId??a.id))]})}),p.jsx(Bu,{})]})})},hg=()=>{const{pendingTicket:e,ticketBusy:t,userContext:n,confirmTicket:r,cancelTicket:o}=en(),s=!n.customerId&&!n.email,[i,c]=I.useState("");return e?p.jsxs("div",{className:"ticket-card",role:"region","aria-label":"Create support ticket",children:[p.jsx("h3",{className:"ticket-card-title",children:"Create support ticket?"}),p.jsx("p",{className:"ticket-card-desc",children:"I can open a support request for you. Nothing is created until you confirm."}),p.jsx("p",{className:"ticket-card-body",children:e.description}),s&&p.jsxs("label",{className:"ticket-id-label",children:["Customer ID or email",p.jsx("input",{value:i,onChange:a=>c(a.target.value),className:"ticket-id-input",placeholder:"CUST-1001 or you@company.com",autoComplete:"email"})]}),p.jsxs("div",{className:"ticket-actions",children:[p.jsx("button",{type:"button",onClick:o,disabled:t,className:"ticket-cancel-btn",children:"Cancel"}),p.jsx("button",{type:"button",onClick:()=>void r(i),disabled:t||s&&!i.trim(),className:"ticket-confirm-btn",children:t?"Creating…":"Create ticket"})]})]}):null},Fo=({className:e,onClose:t,showMinimize:n,title:r,subtitle:o,envStage:s,envPulse:i=!0})=>{const{messages:c,sendMessage:a,stopResponse:l,status:f,error:u,resetConversation:h,retryLast:g,pendingTicket:d,soundEnabled:m,toggleSound:b}=en(),v=I.useRef(null),x=f==="awaiting"||f==="connecting",S=c[c.length-1],E=x?S==null?void 0:S.progressText:(S==null?void 0:S.status)==="stopped"?"Response stopped":void 0;return p.jsxs("section",{className:`chat-panel${e?` ${e}`:""}`,"aria-label":"VPS AI Assistant",children:[p.jsx($l,{title:r,subtitle:o,onClose:t,onReset:()=>void h(),showMinimize:n,soundEnabled:m,onToggleSound:b,envStage:s,envPulse:i}),p.jsx("div",{className:"chat-panel-body",children:p.jsx(pg,{onEdit:C=>{var w;return(w=v.current)==null?void 0:w.edit(C)}})}),p.jsx(Ks,{className:"sr-only",role:"status",children:p.jsx(Ys,{children:E})}),u&&f==="error"&&p.jsx(Fl,{message:u,onRetry:()=>void g()}),p.jsx(hg,{}),p.jsx(Zl,{ref:v,onSend:C=>void a(C),onStop:x?l:void 0,disabled:x||!!d})]})},gg=({open:e,onClose:t,envStage:n,envPulse:r=!0})=>e?p.jsx("div",{id:"vps-chatbot-widget-panel",className:"widget-panel",children:p.jsx(Fo,{onClose:t,showMinimize:!0,title:"VPS AI Assistant",envStage:n,envPulse:r})}):null,mg=({open:e,onToggle:t})=>p.jsx("button",{type:"button",onClick:t,"aria-expanded":e,"aria-controls":"vps-chatbot-widget-panel","aria-label":e?"Close assistant":"Open assistant",className:"widget-trigger-btn",children:e?p.jsx(ka,{size:22}):p.jsx(ni,{size:24})}),Bs=({defaultOpen:e=!1,open:t,onOpenChange:n,envStage:r,envPulse:o=!0})=>{const[s,i]=I.useState(e),c=t??s,a=l=>{n==null||n(l),t===void 0&&i(l)};return p.jsxs(p.Fragment,{children:[p.jsx(gg,{open:c,onClose:()=>a(!1),envStage:r,envPulse:o}),p.jsx(mg,{open:c,onToggle:()=>a(!c)})]})},bg=({apiBaseUrl:e,apiUrl:t,proxyUrl:n,userContext:r,role:o,roleId:s,client:i,welcomeMessage:c,suggestions:a,disableSuggestions:l,initialMessage:f,hideInspectSources:u,showGroundedSources:h,modelId:g,...d})=>{const m=qn(),b=e??t??n;return!!m&&(!b||yt(b)===yt(m==null?void 0:m.apiBaseUrl))&&!r&&o===void 0&&s===void 0&&i===void 0&&c===void 0&&!a&&l===void 0&&!f&&u===void 0&&h===void 0&&g===void 0?p.jsx(Bs,{...d}):p.jsx(Yr,{apiBaseUrl:b,userContext:r,role:o,roleId:s,client:i,welcomeMessage:c,suggestions:a,disableSuggestions:l,initialMessage:f,hideInspectSources:u,showGroundedSources:h,modelId:g,children:p.jsx(Bs,{...d})})},vg=({open:e,onClose:t,subtitle:n,title:r,envStage:o,envPulse:s=!0})=>p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`embedded-overlay ${e?"embedded-overlay--open":"embedded-overlay--closed"}`,hidden:!e,onClick:t,"aria-hidden":"true"}),p.jsx("aside",{id:"vps-embedded-chat-panel",className:`embedded-panel ${e?"embedded-panel--open":"embedded-panel--closed"}`,"aria-hidden":!e,children:e&&p.jsx(Fo,{onClose:t,title:r||"VPS AI Assistant",subtitle:n,envStage:o,envPulse:s})})]}),yg=5,wr=8,$c="vps-embedded-assistant-top",Vs=16;function xg(e,t,n){return Math.min(n,Math.max(t,e))}function $s(e,t){const n=Math.max(wr,window.innerHeight-t-wr);return xg(e,wr,n)}function Eg(){try{const e=window.localStorage.getItem($c);if(!e)return null;const t=Number(e);return Number.isFinite(t)?t:null}catch{return null}}function Sg(e){try{window.localStorage.setItem($c,String(e))}catch{}}const wg=({onOpen:e})=>{const t=I.useRef(null),n=I.useRef({pointerId:null,startY:0,startTop:0,moved:!1}),[r,o]=I.useState(()=>typeof window>"u"?null:Eg()),s=I.useRef(r),i=I.useRef(!1),[c,a]=I.useState(!1),[l,f]=I.useState(!1);I.useEffect(()=>{s.current=r},[r]),I.useEffect(()=>{const d=t.current;if(!d)return;const m=()=>{o(b=>{const x=$s(b??Vs,d.offsetHeight);return s.current=x,x})};return m(),window.addEventListener("resize",m),()=>window.removeEventListener("resize",m)},[]);const u=d=>{if(d.button!==0)return;const m=d.currentTarget,b=m.getBoundingClientRect();n.current={pointerId:d.pointerId,startY:d.clientY,startTop:b.top,moved:!1};try{m.setPointerCapture(d.pointerId)}catch{}},h=d=>{if(n.current.pointerId!==d.pointerId)return;const m=d.clientY-n.current.startY;if(!n.current.moved&&Math.abs(m)<yg)return;n.current.moved=!0,a(!0);const b=$s(n.current.startTop+m,d.currentTarget.offsetHeight);s.current=b,o(b)},g=d=>{var b,v;if(n.current.pointerId!==d.pointerId)return;try{(v=(b=d.currentTarget).hasPointerCapture)!=null&&v.call(b,d.pointerId)&&d.currentTarget.releasePointerCapture(d.pointerId)}catch{}const m=n.current.moved;n.current.pointerId=null,n.current.moved=!1,a(!1),m&&(i.current=!0,s.current!=null&&Sg(s.current))};return p.jsxs("button",{ref:t,type:"button",onPointerDown:u,onPointerMove:h,onPointerUp:g,onPointerCancel:g,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onClick:()=>{if(i.current){i.current=!1;return}e()},"aria-expanded":!1,"aria-controls":"vps-embedded-chat-panel","aria-label":"Assistant",className:`embedded-trigger-btn ${c?"embedded-trigger-btn--grabbing":"embedded-trigger-btn--grab"}${l?" embedded-trigger-btn--expanded":" embedded-trigger-btn--collapsed"}`,style:{top:r??Vs,transform:void 0},children:[p.jsx(ni,{size:18}),p.jsx("span",{className:"embedded-trigger-label",children:"Assistant"})]})},Hs=({defaultOpen:e=!1,open:t,onOpenChange:n,showTrigger:r=!0,envStage:o,envPulse:s=!0})=>{const[i,c]=I.useState(e),a=t??i,l=f=>{n==null||n(f),t===void 0&&c(f)};return p.jsxs(p.Fragment,{children:[r&&!a&&p.jsx(wg,{onOpen:()=>l(!0)}),p.jsx(vg,{open:a,onClose:()=>l(!1),envStage:o,envPulse:s})]})},Cg=({apiBaseUrl:e,apiUrl:t,proxyUrl:n,userContext:r,role:o,roleId:s,client:i,welcomeMessage:c,suggestions:a,disableSuggestions:l,initialMessage:f,hideInspectSources:u,showGroundedSources:h,modelId:g,...d})=>{const m=qn(),b=e??t??n;return!!m&&(!b||yt(b)===yt(m==null?void 0:m.apiBaseUrl))&&!r&&o===void 0&&s===void 0&&i===void 0&&c===void 0&&!a&&l===void 0&&!f&&u===void 0&&h===void 0&&g===void 0?p.jsx(Hs,{...d}):p.jsx(Yr,{apiBaseUrl:b,userContext:r,role:o,roleId:s,client:i,welcomeMessage:c,suggestions:a,disableSuggestions:l,initialMessage:f,hideInspectSources:u,showGroundedSources:h,modelId:g,children:p.jsx(Hs,{...d})})},Rg={Colors:{VPS_White:"#fff",VPS_Dark_Blue:"#1A1A31",VPS_Light_Blue:"#353552",VPS_Light_Grey:"#D1D1D6",VPS_Orange:"#FF4717",Dark_Blue_50:"#F1F5FC",Dark_Blue_100:"#E5EBFA",Dark_Blue_200:"#D1DAF4",Dark_Blue_300:"#B4C2ED",Dark_Blue_400:"#96A2E3",Dark_Blue_500:"#7C84D8",Dark_Blue_600:"#6262C9",Dark_Blue_700:"#5351B1",Dark_Blue_800:"#44448F",Dark_Blue_900:"#3C3D73",Dark_Blue_950:"#1A1A31",Light_Blue_50:"#F4F6FA",Light_Blue_100:"#E6E9F3",Light_Blue_200:"#D3D8EA",Light_Blue_300:"#B4BEDC",Light_Blue_400:"#909DCA",Light_Blue_500:"#7580BC",Light_Blue_600:"#6369AD",Light_Blue_700:"#575A9E",Light_Blue_800:"#4B4B82",Light_Blue_900:"#404168",Light_Blue_950:"#353552",Grey_50:"#F6F6F7",Grey_100:"#EFEFF0",Grey_200:"#E2E1E4",Grey_300:"#D1D1D6",Grey_400:"#B9B9C0",Grey_500:"#A7A6AE",Grey_600:"#93919A",Grey_700:"#7E7D85",Grey_800:"#67666D",Grey_900:"#56555A",Grey_950:"#323234",Orange_50:"#FFF3ED",Orange_100:"#FFE4D4",Orange_200:"#FFC5A8",Orange_300:"#FF9D70",Orange_400:"#FF6837",Orange_500:"#FF4717",Orange_600:"#F02706",Orange_700:"#C71807",Orange_800:"#9E150E",Orange_900:"#7F150F",Orange_950:"#450605",Success_50:"#F1FCF5",Success_100:"#DEFAEA",Success_200:"#BEF4D4",Success_300:"#8BEAB3",Success_400:"#52D689",Success_500:"#2ECC71",Success_600:"#1D9C53",Success_700:"#1B7A43",Success_800:"#1A6139",Success_900:"#175031",Success_950:"#072C18",Warning_50:"#FFFEEA",Warning_100:"#FFF9C5",Warning_200:"#FFF485",Warning_300:"#FFE846",Warning_400:"#FFD81B",Warning_500:"#FFB800",Warning_600:"#E28D00",Warning_700:"#BB6302",Warning_800:"#984C08",Warning_900:"#7C3F0B",Warning_950:"#482000",Error_50:"#FFF1F1",Error_100:"#FFDFDF",Error_200:"#FFC5C5",Error_300:"#FF9D9D",Error_400:"#FF6464",Error_500:"#FF2E2E",Error_600:"#ED1515",Error_700:"#C80D0D",Error_800:"#A50F0F",Error_900:"#881414",Error_950:"#4B0404",Netural_25:"#FDFDFD",Netural_50:"#FAFAFA",Netural_100:"#F5F5F5",Netural_200:"#E9EAEC",Netural_300:"#D6D7DB",Netural_400:"#A4A7AE",Netural_500:"#727681",Netural_600:"#545863",Netural_700:"#424651",Netural_800:"#252B37",Netural_900:"#191D28",Netural_950:"#0A0D12",Tint_Dark_Blue_100:"#1A1A31",Tint_Dark_Blue_90:"#313146",Tint_Dark_Blue_80:"#48485A",Tint_Dark_Blue_70:"#5F5F6F",Tint_Dark_Blue_60:"#767683",Tint_Dark_Blue_50:"#8C8C98",Tint_Dark_Blue_40:"#A3A3AD",Tint_Dark_Blue_30:"#BABAC1",Tint_Dark_Blue_20:"#D1D1D6",Tint_Dark_Blue_10:"#E8E8EA",Tint_Dark_Blue_5:"#F4F4F5",Tint_Light_Blue_100:"#353552",Tint_Light_Blue_90:"#494963",Tint_Light_Blue_80:"#5D5D75",Tint_Light_Blue_70:"#727286",Tint_Light_Blue_60:"#868697",Tint_Light_Blue_50:"#9A9AA8",Tint_Light_Blue_40:"#AEAEBA",Tint_Light_Blue_30:"#C2C2CB",Tint_Light_Blue_20:"#D7D7DC",Tint_Light_Blue_10:"#EBEBEE",Tint_Light_Blue_5:"#F5F5F6",Tint_Grey_100:"#D1D1D6",Tint_Grey_90:"#D6D6DA",Tint_Grey_80:"#DADADE",Tint_Grey_70:"#DFDFE2",Tint_Grey_60:"#E3E3E6",Tint_Grey_50:"#E8E8EB",Tint_Grey_40:"#EDEDEF",Tint_Grey_30:"#F1F1F3",Tint_Grey_20:"#F6F6F7",Tint_Grey_10:"#FAFAFB",Tint_Grey_5:"#FDFDFD",Tint_Solus_100:"#FF4717",Tint_Solus_90:"#FF592E",Tint_Solus_80:"#FF6C45",Tint_Solus_70:"#FF7E5D",Tint_Solus_60:"#FF9174",Tint_Solus_50:"#FFA38B",Tint_Solus_40:"#FFB5A2",Tint_Solus_30:"#FFC8B9",Tint_Solus_20:"#FFDAD1",Tint_Solus_10:"#FFEDE8",Tint_Solus_5:"#FFF6F3",Other_Color:"#00ABC9"},StatusColor:{tested:"#3E4784",received:"#EE46BC",InTransit:"#6938EF",registered:"#1570EF",reported:"#2ECC71",noStatus:"#727681",Action:"#FF2E2E",Caution:"#FFB800",Pass:"#2ECC71",No_Rating:"#FF6837",Received:"#EE46BC",Tested:"#3E4784",Reported:"#2ECC71",No_Status:"#6938EF",Overdue:"#FF2E2E",Duesoon:"#FFB800",Scheduled:"#1570EF",Good:"#2ECC71",NotApplicable:"#353552"}};exports.ChatPanel=Fo;exports.ChatProvider=Yr;exports.ChatbotWidget=bg;exports.ColorPalette=Rg;exports.EmbeddedChatbot=Cg;exports.buildApiUrl=Rn;exports.chatApi=na;exports.createChatApi=Gr;exports.resolveApiBaseUrl=yt;exports.useChatContext=Ws;exports.useChatbot=en;exports.useOptionalChatContext=qn;