orbitchat 3.10.7 → 3.10.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/LICENSE +201 -0
  2. package/dist/assets/ChartRenderer-Cbyse7LH.js +105 -0
  3. package/dist/assets/MermaidRenderer-yw6DgH3b.js +312 -0
  4. package/dist/assets/MusicRenderer-BSZsjBll.js +18 -0
  5. package/dist/assets/SVGRenderer-DfMpobkd.js +6 -0
  6. package/dist/assets/architectureDiagram-3BPJPVTR-e2_vf6sQ.js +36 -0
  7. package/dist/assets/blockDiagram-GPEHLZMM-SCn-DUpY.js +132 -0
  8. package/dist/assets/{c4Diagram-LMCZKHZV-BUftbNWY.js → c4Diagram-AAUBKEIU-CD0XXb4K.js} +2 -2
  9. package/dist/assets/channel-zV0lWbMa.js +1 -0
  10. package/dist/assets/{chunk-VR4S4FIN-uT68_7rT.js → chunk-2J33WTMH-D1ecF70l.js} +1 -1
  11. package/dist/assets/{chunk-JWPE2WC7-BjHi_aEM.js → chunk-4BX2VUAB-BdC2_BbM.js} +1 -1
  12. package/dist/assets/{chunk-XXDRQBXY-BrvJt-u-.js → chunk-55IACEB6-EK7W6T2M.js} +1 -1
  13. package/dist/assets/{chunk-V7JOEXUC-hSR6fEWT.js → chunk-727SXJPM-CcXyDAeg.js} +4 -4
  14. package/dist/assets/chunk-AQP2D5EJ-DW6XiznW.js +231 -0
  15. package/dist/assets/{chunk-5VM5RSS4-CQacO1HV.js → chunk-FMBD7UC4-CPehXR20.js} +1 -1
  16. package/dist/assets/{chunk-32BRIVSS-DnDG740s.js → chunk-ND2GUHAM-CSSdlZau.js} +1 -1
  17. package/dist/assets/{chunk-2Q5K7J3B-CdU2Q6YZ.js → chunk-QZHKN3VN-DqF1rB9S.js} +1 -1
  18. package/dist/assets/classDiagram-4FO5ZUOK-CcqSZVcR.js +1 -0
  19. package/dist/assets/classDiagram-v2-Q7XG4LA2-CcqSZVcR.js +1 -0
  20. package/dist/assets/cose-bilkent-S5V4N54A-eZksLHnB.js +1 -0
  21. package/dist/assets/{cynefin-VYW2F7L2-CyM6ijR6.js → cynefin-VYW2F7L2-CPNTSJVR.js} +1 -1
  22. package/dist/assets/dagre-BM42HDAG-28cMnF2H.js +4 -0
  23. package/dist/assets/diagram-2AECGRRQ-BO7iijXf.js +43 -0
  24. package/dist/assets/diagram-5GNKFQAL-DomATWxv.js +10 -0
  25. package/dist/assets/{diagram-FQU43EPY-IlESJ0wh.js → diagram-KO2AKTUF-PtoEeRz1.js} +3 -3
  26. package/dist/assets/diagram-LMA3HP47-CASxB1FB.js +24 -0
  27. package/dist/assets/diagram-OG6HWLK6-CyXBWSCx.js +24 -0
  28. package/dist/assets/erDiagram-TEJ5UH35-BsN2y1Xk.js +85 -0
  29. package/dist/assets/flowDiagram-I6XJVG4X-Cq2OCvg1.js +162 -0
  30. package/dist/assets/ganttDiagram-6RSMTGT7-jqEV7dNL.js +292 -0
  31. package/dist/assets/gitGraphDiagram-PVQCEYII-CZV87DUI.js +106 -0
  32. package/dist/assets/{graph-C9eacEi8.js → graph-CAnANduQ.js} +1 -1
  33. package/dist/assets/graphExportUtils-DrqBjeAI.js +1 -0
  34. package/dist/assets/index-ADlI5-NQ.css +1 -0
  35. package/dist/assets/{index-DfypiZL2.js → index-DJM2KXCF.js} +3 -3
  36. package/dist/assets/infoDiagram-5YYISTIA-BTT1LXE4.js +2 -0
  37. package/dist/assets/{ishikawaDiagram-FXEZZL3T-BEPnPebm.js → ishikawaDiagram-YF4QCWOH-D9KfSIa7.js} +5 -5
  38. package/dist/assets/{journeyDiagram-5HDEW3XC-B3Sx5g-O.js → journeyDiagram-JHISSGLW-tDXNol4d.js} +2 -2
  39. package/dist/assets/{kanban-definition-HUTT4EX6-BZwqoKM8.js → kanban-definition-UN3LZRKU-DBwlSBF_.js} +6 -6
  40. package/dist/assets/layout-DGIYPm2g.js +1 -0
  41. package/dist/assets/{mindmap-definition-LN4V7U3C-CyjRWos4.js → mindmap-definition-RKZ34NQL-DnqCIXkX.js} +10 -10
  42. package/dist/assets/pieDiagram-4H26LBE5-C4OTftBM.js +30 -0
  43. package/dist/assets/{quadrantDiagram-ABIIQ3AL-DW4gRbec.js → quadrantDiagram-W4KKPZXB-CAZOzJOz.js} +3 -3
  44. package/dist/assets/{requirementDiagram-TGXJPOKE-D898qBnU.js → requirementDiagram-4Y6WPE33-Ji0UfPIj.js} +2 -2
  45. package/dist/assets/sankeyDiagram-5OEKKPKP-Bw7GXHmh.js +40 -0
  46. package/dist/assets/sequenceDiagram-3UESZ5HK-m5wt325o.js +162 -0
  47. package/dist/assets/stateDiagram-AJRCARHV-BkfQ-aKY.js +1 -0
  48. package/dist/assets/stateDiagram-v2-BHNVJYJU-CrYKygqF.js +1 -0
  49. package/dist/assets/{timeline-definition-FHXFAJF6-CgFiawCT.js → timeline-definition-PNZ67QCA-f8uHcy4Y.js} +4 -4
  50. package/dist/assets/vennDiagram-CIIHVFJN-CuKQ09R1.js +34 -0
  51. package/dist/assets/{wardleyDiagram-EHGQE667-CtRzQ3q6.js → wardleyDiagram-YWT4CUSO-iQQlbl48.js} +4 -4
  52. package/dist/assets/xychartDiagram-2RQKCTM6-B4vp4-Xh.js +7 -0
  53. package/dist/index.html +2 -2
  54. package/package.json +2 -2
  55. package/dist/assets/ChartRenderer-9FnwPEBX.js +0 -105
  56. package/dist/assets/MermaidRenderer-CnzIvTlj.js +0 -317
  57. package/dist/assets/MusicRenderer-fgx5dq-k.js +0 -18
  58. package/dist/assets/SVGRenderer-CZNFFAA_.js +0 -6
  59. package/dist/assets/abnfDiagram-VRR7QNED-DChuAW5u.js +0 -1
  60. package/dist/assets/architectureDiagram-ZJ3FMSHR-DHJZWJhu.js +0 -36
  61. package/dist/assets/blockDiagram-677ZJIJ3-H_CNYF5m.js +0 -132
  62. package/dist/assets/channel-Cfw3OpIn.js +0 -1
  63. package/dist/assets/chunk-EX3LRPZG-Bq0HhB2B.js +0 -231
  64. package/dist/assets/chunk-MOJQB5TN-D2zfH4wm.js +0 -88
  65. package/dist/assets/chunk-RYQCIY6F-DSJh0d2F.js +0 -1
  66. package/dist/assets/classDiagram-OUVF2IWQ-BkFPBJiF.js +0 -1
  67. package/dist/assets/classDiagram-v2-EOCWNBFH-BkFPBJiF.js +0 -1
  68. package/dist/assets/cose-bilkent-JH36ORCC-C0vhiJLV.js +0 -1
  69. package/dist/assets/cynefinDiagram-TSTJHNR4-MevACWGH.js +0 -62
  70. package/dist/assets/dagre-VKFMJZFB-BqR7tzk8.js +0 -4
  71. package/dist/assets/diagram-G47NLZAW-Bqjk3ZYu.js +0 -24
  72. package/dist/assets/diagram-NH7WQ7WH-B63W-pyC.js +0 -24
  73. package/dist/assets/diagram-OA4YK3LP-B0THRF0G.js +0 -30
  74. package/dist/assets/diagram-WEI45ONY-IZZ69bsz.js +0 -41
  75. package/dist/assets/ebnfDiagram-CCIWWBDH-B_U7c6VT.js +0 -1
  76. package/dist/assets/erDiagram-Q63AITRT-oGWxlmE8.js +0 -85
  77. package/dist/assets/flowDiagram-23GEKE2U-0scCMi71.js +0 -156
  78. package/dist/assets/ganttDiagram-NO4QXBWP-DIS-iO_q.js +0 -292
  79. package/dist/assets/gitGraphDiagram-IHSO6WYX-DsT87XU7.js +0 -106
  80. package/dist/assets/index-DqIwGcah.css +0 -1
  81. package/dist/assets/infoDiagram-FWYZ7A6U-CkLm2oOh.js +0 -2
  82. package/dist/assets/layout-DEXfKzaS.js +0 -1
  83. package/dist/assets/map-Czzmt4hB.js +0 -1
  84. package/dist/assets/pegDiagram-2B236MQR-DItVX4G3.js +0 -1
  85. package/dist/assets/pieDiagram-ENE6RG2P-CTRyME0H.js +0 -39
  86. package/dist/assets/railroadDiagram-RFXS5EU6-_rBw9Q9b.js +0 -1
  87. package/dist/assets/sankeyDiagram-HTMAVEWB-doAkRLNI.js +0 -40
  88. package/dist/assets/sequenceDiagram-DBY2YBRQ-D4HUsfB2.js +0 -162
  89. package/dist/assets/sizeCapture-X5ZJPWSS-DJJLR6R7.js +0 -1
  90. package/dist/assets/stateDiagram-2N3HPSRC-0IOXcLaP.js +0 -1
  91. package/dist/assets/stateDiagram-v2-6OUMAXLB-BjcuRalB.js +0 -1
  92. package/dist/assets/swimlanes-5IMT3BWC-HIPL1mdx.js +0 -2
  93. package/dist/assets/swimlanesDiagram-G3AALYLV-usVEFD6y.js +0 -8
  94. package/dist/assets/vennDiagram-L72KCM5P-DiY3ySIT.js +0 -34
  95. package/dist/assets/xychartDiagram-FW5EYKEG-OjszPLMV.js +0 -7
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MermaidRenderer-CnzIvTlj.js","assets/vendor-markdown-BRX1CUPf.js","assets/vendor-syntax-DG6Vo7Ci.js","assets/purify.es-D6gMnemd.js","assets/isPrototype-DezZrpQP.js","assets/SVGRenderer-CZNFFAA_.js","assets/ChartRenderer-9FnwPEBX.js","assets/band-CquvqAHh.js","assets/init-Dmth1JHB.js","assets/ordinal-DILIJJjt.js","assets/linear-BGneeY6s.js","assets/defaultLocale-DX6XiGOO.js","assets/time-DJ0lCX4i.js","assets/vendor-react-BAJBiXxk.js","assets/vendor-auth-CF3lY_Q5.js","assets/MusicRenderer-fgx5dq-k.js","assets/papaparse.min-BWA-Odol.js","assets/docx-preview-CMb3nQfR.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MermaidRenderer-yw6DgH3b.js","assets/vendor-markdown-BRX1CUPf.js","assets/vendor-syntax-DG6Vo7Ci.js","assets/purify.es-D6gMnemd.js","assets/isPrototype-DezZrpQP.js","assets/graphExportUtils-DrqBjeAI.js","assets/SVGRenderer-DfMpobkd.js","assets/ChartRenderer-Cbyse7LH.js","assets/band-CquvqAHh.js","assets/init-Dmth1JHB.js","assets/ordinal-DILIJJjt.js","assets/linear-BGneeY6s.js","assets/defaultLocale-DX6XiGOO.js","assets/time-DJ0lCX4i.js","assets/vendor-react-BAJBiXxk.js","assets/vendor-auth-CF3lY_Q5.js","assets/MusicRenderer-BSZsjBll.js","assets/papaparse.min-BWA-Odol.js","assets/docx-preview-CMb3nQfR.js"])))=>i.map(i=>d[i]);
2
2
  var hx=Object.defineProperty;var px=(r,l,i)=>l in r?hx(r,l,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[l]=i;var xa=(r,l,i)=>px(r,typeof l!="symbol"?l+"":l,i);import{a as gx,r as g,j as u,k as pd,R as Rn,M as xx,b as rp,d as bx,e as yx}from"./vendor-markdown-BRX1CUPf.js";import{r as Pp}from"./vendor-react-BAJBiXxk.js";import{_ as Un,h as vx}from"./vendor-syntax-DG6Vo7Ci.js";import{u as gd,a as xd,b as wx,P as Sx,M as kx,A as _x}from"./vendor-auth-CF3lY_Q5.js";(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))c(d);new MutationObserver(d=>{for(const f of d)if(f.type==="childList")for(const h of f.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&c(h)}).observe(document,{childList:!0,subtree:!0});function i(d){const f={};return d.integrity&&(f.integrity=d.integrity),d.referrerPolicy&&(f.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?f.credentials="include":d.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function c(d){if(d.ep)return;d.ep=!0;const f=i(d);fetch(d.href,f)}})();var Zu={exports:{}},li={},Ku={exports:{}},Ju={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
@@ -327,7 +327,7 @@ $$
327
327
  `),l=l.replace(/\\(ne|neq)\$(?=\s*[-+0-9A-Za-z(])/g,"\\$1"),l=xb(l),l=bb(l),l=vb(l,c);const d=new Map;let f=0;const h=String.raw`-?\$\(?\d{1,3}(?:,\d{3})*(?:\.\d+)?\)?(?:\s?(?:[KMBkmb]|[Kk]ilo|[Mm]illion|[Bb]illion))?|\$-?\d+(?:\.\d+)?(?:\s?(?:[KMBkmb]|[Kk]ilo|[Mm]illion|[Bb]illion))?`,p=new RegExp(String.raw`(${h})(\s?[–-]\s?)(${h})`,"g");l=l.replace(p,(k,S,_,A)=>{const D=`__CURRENCY_${f++}__`,O=`__CURRENCY_${f++}__`;return d.set(D,S),d.set(O,A),`${D}${_}${O}`});const x=new RegExp(String.raw`-?\$\(?\d{1,3}(?:,\d{3})*(?:\.\d+)?\)?(?:\s?(?:[KMBkmb]|[Kk]ilo|[Mm]illion|[Bb]illion))?(?!\w)|\$-?\d+(?:\.\d+)?(?:\s?(?:[KMBkmb]|[Kk]ilo|[Mm]illion|[Bb]illion))?(?!\w)`,"g");l=l.replace(x,(k,S,_)=>{if(_.substring(S+k.length).match(/^[a-zA-Z]/)&&!k.match(/[KMBkmb]|[Kk]ilo|[Mm]illion|[Bb]illion$/))return k;const D=`__CURRENCY_${f++}__`;return d.set(D,k),D});const{masked:v,masks:b}=pb(l);return l=v,Object.assign(c,b),l=gb(l),[/(?:^|\s)([a-zA-Z0-9]+\s*[\^_]\s*[a-zA-Z0-9{}]+(?:\s*[+\-*/]\s*[a-zA-Z0-9]+\s*[\^_]\s*[a-zA-Z0-9{}]+)*\s*=\s*[^$\n]+)(?:\s|$)/g,/(?:^|\s)(\\frac\{[^}]+\}\{[^}]+\})(?:\s|$)/g,/(?:^|\s)(\\(?:sqrt|int|sum|prod|lim|log|ln|sin|cos|tan|exp)\b[^$\n]{0,50})(?:\s|$)/g,/(?:^|\s)([A-Z][a-z]?(?:\d+)?(?:\([A-Z][a-z]?(?:\d+)?\))?(?:\d+)?(?:[+-]\d*)?)+(?:\s|$)/g].forEach(k=>{l=l.replace(k,(S,_)=>{if(S.includes("$")||S.includes("__INLINE_MATH_")||S.includes("__DISPLAY_MATH_")||S.includes("__CURRENCY_"))return S;const A=String(_??"").trim();if(/^[A-Za-z]$/.test(A))return S;const D=/[\\^_+=<>]|\\b(?:frac|sqrt|sum|int|lim|log|ln|sin|cos|tan|exp)\b/.test(A),O=/\d/.test(A),ee=/[()]/.test(A),U=(A.match(/[A-Z]/g)||[]).length,z=(A.match(/[a-z]/g)||[]).length,H=U>=2,K=O||ee||H&&z>0;return!D&&!K?S:S.replace(_,`$${_}$`)})}),l=l.replace(new RegExp("(?<!\\\\)\\$(?!\\$)([^$\\n]*?)(?<!\\\\)\\$(?!\\$)","g"),(k,S)=>{if(k.includes("__CURRENCY_")||k.includes("__INLINE_MATH_")||k.includes("__DISPLAY_MATH_")||S.trim()==="")return k;const _=/^\d+(?:,\d{3})*(?:\.\d{2})?$/.test(S.trim()),A=/\\/.test(S),D=/[+\-*/=<>^_{}()]/.test(S),O=/[a-zA-Z].*\d|\d.*[a-zA-Z]/.test(S),ee=/\\(?:alpha|beta|gamma|delta|epsilon|theta|lambda|mu|pi|sigma|omega)/.test(S),U=/\\(?:frac|sqrt|sum|int|lim|log|ln|sin|cos|tan|exp)/.test(S),z=/^[A-Za-z]$/.test(S.trim());return!_&&(A||D||O||ee||U||z||S.length>1)?k:`\\$${S}\\$`}),l=l.split(`
328
328
  `).map(k=>{const S=k.indexOf("$$");return S===-1||k.trim()==="$$"||k.indexOf("$$",S+2)!==-1?k:k.replace("$$","\\$\\$")}).join(`
329
329
  `),d.forEach((k,S)=>{const _=k.replace(/\$/g,"&#36;");l=l.replace(new RegExp(S.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),_)}),l=l.replace(/\\&#36;/g,"&#36;"),l=wb(l,c),l=l.trimEnd()+`
330
- `,l}catch(l){return console.warn("Error preprocessing markdown:",l),r}},kb={'code[class*="language-"]':{color:"#393A34",fontFamily:'"Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",fontSize:".9em",lineHeight:"1.2em",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"#393A34",fontFamily:'"Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",fontSize:".9em",lineHeight:"1.2em",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",border:"1px solid #dddddd",backgroundColor:"white"},'pre > code[class*="language-"]':{fontSize:"1em"},'pre[class*="language-"]::-moz-selection':{background:"#C1DEF1"},'pre[class*="language-"] ::-moz-selection':{background:"#C1DEF1"},'code[class*="language-"]::-moz-selection':{background:"#C1DEF1"},'code[class*="language-"] ::-moz-selection':{background:"#C1DEF1"},'pre[class*="language-"]::selection':{background:"#C1DEF1"},'pre[class*="language-"] ::selection':{background:"#C1DEF1"},'code[class*="language-"]::selection':{background:"#C1DEF1"},'code[class*="language-"] ::selection':{background:"#C1DEF1"},':not(pre) > code[class*="language-"]':{padding:".2em",paddingTop:"1px",paddingBottom:"1px",background:"#f8f8f8",border:"1px solid #dddddd"},comment:{color:"#008000",fontStyle:"italic"},prolog:{color:"#008000",fontStyle:"italic"},doctype:{color:"#008000",fontStyle:"italic"},cdata:{color:"#008000",fontStyle:"italic"},namespace:{Opacity:".7"},string:{color:"#A31515"},punctuation:{color:"#393A34"},operator:{color:"#393A34"},url:{color:"#36acaa"},symbol:{color:"#36acaa"},number:{color:"#36acaa"},boolean:{color:"#36acaa"},variable:{color:"#36acaa"},constant:{color:"#36acaa"},inserted:{color:"#36acaa"},atrule:{color:"#0000ff"},keyword:{color:"#0000ff"},"attr-value":{color:"#0000ff"},".language-autohotkey .token.selector":{color:"#0000ff"},".language-json .token.boolean":{color:"#0000ff"},".language-json .token.number":{color:"#0000ff"},'code[class*="language-css"]':{color:"#0000ff"},function:{color:"#393A34"},deleted:{color:"#9a050f"},".language-autohotkey .token.tag":{color:"#9a050f"},selector:{color:"#800000"},".language-autohotkey .token.keyword":{color:"#00009f"},important:{color:"#e90",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},"class-name":{color:"#2B91AF"},".language-json .token.property":{color:"#2B91AF"},tag:{color:"#800000"},"attr-name":{color:"#ff0000"},property:{color:"#ff0000"},regex:{color:"#ff0000"},entity:{color:"#ff0000"},"directive.tag.tag":{background:"#ffff00",color:"#393A34"},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:"#a5a5a5"},".line-numbers .line-numbers-rows > span:before":{color:"#2B91AF"},".line-highlight.line-highlight":{background:"linear-gradient(to right, rgba(193, 222, 241, 0.2) 70%, rgba(221, 222, 241, 0))"}},_b={'pre[class*="language-"]':{color:"#d4d4d4",fontSize:"13px",textShadow:"none",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",background:"#1e1e1e"},'code[class*="language-"]':{color:"#d4d4d4",fontSize:"13px",textShadow:"none",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]::selection':{textShadow:"none",background:"#264F78"},'code[class*="language-"]::selection':{textShadow:"none",background:"#264F78"},'pre[class*="language-"] *::selection':{textShadow:"none",background:"#264F78"},'code[class*="language-"] *::selection':{textShadow:"none",background:"#264F78"},':not(pre) > code[class*="language-"]':{padding:".1em .3em",borderRadius:".3em",color:"#db4c69",background:"#1e1e1e"},".namespace":{Opacity:".7"},"doctype.doctype-tag":{color:"#569CD6"},"doctype.name":{color:"#9cdcfe"},comment:{color:"#6a9955"},prolog:{color:"#6a9955"},punctuation:{color:"#d4d4d4"},".language-html .language-css .token.punctuation":{color:"#d4d4d4"},".language-html .language-javascript .token.punctuation":{color:"#d4d4d4"},property:{color:"#9cdcfe"},tag:{color:"#569cd6"},boolean:{color:"#569cd6"},number:{color:"#b5cea8"},constant:{color:"#9cdcfe"},symbol:{color:"#b5cea8"},inserted:{color:"#b5cea8"},unit:{color:"#b5cea8"},selector:{color:"#d7ba7d"},"attr-name":{color:"#9cdcfe"},string:{color:"#ce9178"},char:{color:"#ce9178"},builtin:{color:"#ce9178"},deleted:{color:"#ce9178"},".language-css .token.string.url":{textDecoration:"underline"},operator:{color:"#d4d4d4"},entity:{color:"#569cd6"},"operator.arrow":{color:"#569CD6"},atrule:{color:"#ce9178"},"atrule.rule":{color:"#c586c0"},"atrule.url":{color:"#9cdcfe"},"atrule.url.function":{color:"#dcdcaa"},"atrule.url.punctuation":{color:"#d4d4d4"},keyword:{color:"#569CD6"},"keyword.module":{color:"#c586c0"},"keyword.control-flow":{color:"#c586c0"},function:{color:"#dcdcaa"},"function.maybe-class-name":{color:"#dcdcaa"},regex:{color:"#d16969"},important:{color:"#569cd6"},italic:{fontStyle:"italic"},"class-name":{color:"#4ec9b0"},"maybe-class-name":{color:"#4ec9b0"},console:{color:"#9cdcfe"},parameter:{color:"#9cdcfe"},interpolation:{color:"#9cdcfe"},"punctuation.interpolation-punctuation":{color:"#569cd6"},variable:{color:"#9cdcfe"},"imports.maybe-class-name":{color:"#9cdcfe"},"exports.maybe-class-name":{color:"#9cdcfe"},escape:{color:"#d7ba7d"},"tag.punctuation":{color:"#808080"},cdata:{color:"#808080"},"attr-value":{color:"#ce9178"},"attr-value.punctuation":{color:"#ce9178"},"attr-value.punctuation.attr-equals":{color:"#d4d4d4"},namespace:{color:"#4ec9b0"},'pre[class*="language-javascript"]':{color:"#9cdcfe"},'code[class*="language-javascript"]':{color:"#9cdcfe"},'pre[class*="language-jsx"]':{color:"#9cdcfe"},'code[class*="language-jsx"]':{color:"#9cdcfe"},'pre[class*="language-typescript"]':{color:"#9cdcfe"},'code[class*="language-typescript"]':{color:"#9cdcfe"},'pre[class*="language-tsx"]':{color:"#9cdcfe"},'code[class*="language-tsx"]':{color:"#9cdcfe"},'pre[class*="language-css"]':{color:"#ce9178"},'code[class*="language-css"]':{color:"#ce9178"},'pre[class*="language-html"]':{color:"#d4d4d4"},'code[class*="language-html"]':{color:"#d4d4d4"},".language-regex .token.anchor":{color:"#dcdcaa"},".language-html .token.punctuation":{color:"#808080"},'pre[class*="language-"] > code[class*="language-"]':{position:"relative",zIndex:"1"},".line-highlight.line-highlight":{background:"#f7ebc6",boxShadow:"inset 5px 0 0 #f7d87c",zIndex:"0"}},Ab=g.lazy(()=>Un(()=>import("./MermaidRenderer-CnzIvTlj.js").then(r=>r.ax),__vite__mapDeps([0,1,2,3,4])).then(r=>({default:r.MermaidRenderer}))),Cb=g.lazy(()=>Un(()=>import("./SVGRenderer-CZNFFAA_.js"),__vite__mapDeps([5,1,3])).then(r=>({default:r.SVGRenderer}))),jb=g.lazy(()=>Un(()=>import("./ChartRenderer-9FnwPEBX.js"),__vite__mapDeps([6,1,4,7,8,9,10,11,12,13,2,14])).then(r=>({default:r.ChartRenderer}))),Nb=g.lazy(()=>Un(()=>import("./MusicRenderer-fgx5dq-k.js"),__vite__mapDeps([15,2,1])).then(r=>({default:r.MusicRenderer}))),Tb=r=>{var c,d;if(!r)return typeof window<"u"&&((c=window.matchMedia)!=null&&c.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light";const l=r.closest(".markdown-content");if(l){if(l.classList.contains("dark"))return"dark";if(l.classList.contains("light"))return"light"}if(r.closest(".dark"))return"dark";if(r.closest(".light"))return"light";const i=r.closest("[data-theme]");if(i){const f=i.getAttribute("data-theme");if(f==="dark")return"dark";if(f==="light")return"light"}return typeof window<"u"&&((d=window.matchMedia)!=null&&d.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light"},Eb=(r,l)=>{const[i,c]=g.useState("light"),d=g.useRef("light");return g.useEffect(()=>{var v,b,w;if(l||typeof window>"u"||typeof document>"u")return;const f=()=>{const k=Tb(r.current);k!==d.current&&(d.current=k,c(k))};f();const h=((v=window.matchMedia)==null?void 0:v.call(window,"(prefers-color-scheme: dark)"))??null,p=()=>f();h==null||h.addEventListener("change",p);const x=typeof MutationObserver<"u"?new MutationObserver(()=>f()):null;if(x){const k=((w=(b=r.current)==null?void 0:b.closest)==null?void 0:w.call(b,".markdown-content"))??null;k&&x.observe(k,{attributes:!0,attributeFilter:["class","data-theme"]}),document.body&&x.observe(document.body,{attributes:!0,attributeFilter:["class","data-theme"]})}return()=>{h==null||h.removeEventListener("change",p),x==null||x.disconnect()}},[l,r]),l??i},Mb={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"tsx",sh:"bash",shell:"bash",shellsession:"bash",yml:"yaml",yaml:"yaml",py:"python",rb:"ruby",kt:"kotlin",md:"markdown",csharp:"csharp","c#":"csharp","c++":"cpp",tf:"hcl",terraform:"hcl",docker:"dockerfile",dotenv:"env",env:"env",plaintext:"text",text:"text"},zb=r=>{if(!r)return"";const l=r.match(/(?:^|\s)language-([^\s]+)/);if(!l)return"";const c=l[1].toLowerCase().split("{")[0].split("[")[0].split("<")[0].split(":")[0].trim().replace(/[^a-z0-9+#-]+$/g,"");return c?Mb[c]??c:""},Db=r=>Rn.Children.toArray(r).map(l=>typeof l=="string"||typeof l=="number"?String(l):"").join("").replace(/\n$/,""),xp=({code:r})=>{const[l,i]=g.useState(!1),c=async()=>{try{await navigator.clipboard.writeText(r),i(!0),setTimeout(()=>i(!1),2e3)}catch{const d=document.createElement("textarea");d.value=r,d.style.position="fixed",d.style.opacity="0",document.body.appendChild(d),d.select();try{document.execCommand("copy"),i(!0),setTimeout(()=>i(!1),2e3)}catch(f){console.error("Failed to copy code:",f)}document.body.removeChild(d)}};return u.jsxs("button",{className:"code-copy-button",onClick:c,title:l?"Copied!":"Copy code","aria-label":l?"Copied!":"Copy code to clipboard",children:[l?u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("path",{d:"M5.5 4.5H3.5C2.94772 4.5 2.5 4.94772 2.5 5.5V12.5C2.5 13.0523 2.94772 13.5 3.5 13.5H10.5C11.0523 13.5 11.5 13.0523 11.5 12.5V10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M6.5 2.5H12.5C13.0523 2.5 13.5 2.94772 13.5 3.5V9.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M9.5 6.5L13.5 2.5L9.5 2.5V6.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),u.jsx("span",{className:"code-copy-button-text",children:l?"Copied!":"Copy"})]})},Lb=({inline:r,className:l="",children:i,enableGraphs:c=!0,enableMermaid:d=!0,enableSVG:f=!0,enableCharts:h=!0,enableMusic:p=!0,enableSyntaxHighlighting:x=!0,syntaxTheme:v})=>{const b=g.useRef(null),w=Eb(b,v),k=u.jsx("div",{className:"markdown-code-block code-block-container",children:"Loading renderer..."});if(r)return u.jsx("code",{className:l,children:i});const S=zb(l),_=Db(i);if(h&&(S==="chart"||S==="chart-json"||S==="chart-table"))return u.jsx("div",{ref:b,children:u.jsx(g.Suspense,{fallback:k,children:u.jsx(jb,{code:_,language:S})})});if(p&&(S==="abc"||S==="music"))return u.jsx("div",{ref:b,children:u.jsx(g.Suspense,{fallback:k,children:u.jsx(Nb,{code:_})})});if(c){if(S==="mermaid"&&d)return u.jsx("div",{ref:b,children:u.jsx(g.Suspense,{fallback:k,children:u.jsx(Ab,{code:_})})});if(S==="svg"&&f)return u.jsx("div",{ref:b,children:u.jsx(g.Suspense,{fallback:k,children:u.jsx(Cb,{code:_})})})}if(x&&S){const A=w==="light"?kb:_b;return u.jsxs("div",{ref:b,className:"syntax-highlighted-wrapper code-block-container",children:[u.jsx(xp,{code:_}),u.jsx(vx,{language:S,style:A,customStyle:{margin:"12px 0",borderRadius:"6px",fontSize:"0.9em"},showLineNumbers:!1,children:_})]})}return u.jsxs("div",{ref:b,className:`markdown-code-block code-block-container ${l}`.trim(),children:[u.jsx(xp,{code:_}),u.jsx("pre",{style:{margin:0,padding:0,background:"transparent",border:"none"},children:u.jsx("code",{children:_})})]})},bp=new Set(["div","pre","blockquote","ul","ol","table","thead","tbody","tr","td","th","h1","h2","h3","h4","h5","h6","section","article","figure"]),Rb=({children:r,href:l="",className:i="",...c})=>{const d=Rn.Children.toArray(r).map(b=>typeof b=="string"?b:"").join("").trim(),f=/^https?:\/\//i.test(l),h=!!(f&&d&&yp(d)===yp(l)),p=f?Ub(l):null,x=!!(h&&p),v=["markdown-link",x?"markdown-link--card":"markdown-link--inline",i].filter(Boolean).join(" ");return u.jsxs("a",{...c,href:l,target:"_blank",rel:"noopener noreferrer",className:v,children:[u.jsx("span",{className:"markdown-link__content",children:x&&p?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"markdown-link__hostname",children:p.hostname}),p.path&&p.path!=="/"&&u.jsx("span",{className:"markdown-link__path",children:p.path})]}):r}),f&&u.jsx("span",{className:"markdown-link__icon","aria-hidden":"true",children:u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:"M8 16L16 8M16 8H9M16 8V15",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})})]})};function yp(r){return r.trim().replace(/\/$/,"")}function Ub(r){try{const l=new URL(r),i=l.hostname.replace(/^www\./i,""),c=`${l.pathname}${l.search}${l.hash}`||"/";return{hostname:i,path:c}}catch{return null}}const rl=({content:r,className:l="",disableMath:i=!1,enableGraphs:c=!0,enableMermaid:d=!0,enableSVG:f=!0,enableCharts:h=!0,enableMusic:p=!0,enableSyntaxHighlighting:x=!0,syntaxTheme:v="dark"})=>{const b=Sb(r);if(!b)return null;const w=i?[rp]:[rp,[bx,{singleDollarTextMath:!0}]],k=[];i||k.push([yx,{throwOnError:!1,errorColor:"#cc0000",strict:!1,trust:!0,macros:{"\\RR":"\\mathbb{R}","\\NN":"\\mathbb{N}","\\ZZ":"\\mathbb{Z}","\\QQ":"\\mathbb{Q}","\\CC":"\\mathbb{C}","\\dx":"\\,dx","\\dy":"\\,dy","\\dt":"\\,dt","\\dz":"\\,dz"}}]);const S={table:({children:_,...A})=>u.jsx("div",{style:{overflowX:"auto",WebkitOverflowScrolling:"touch"},children:u.jsx("table",{...A,children:_})}),a:Rb,code:_=>{const{className:A,children:D,...O}=_,ee=A&&/language-/.test(A),U="inline"in _&&typeof _.inline=="boolean"&&_.inline||!ee,z=ee;return u.jsx(Lb,{inline:U,className:A,enableGraphs:c,enableMermaid:d,enableSVG:f,enableCharts:h,enableMusic:p,enableSyntaxHighlighting:x,syntaxTheme:v,"data-block-code":z?"true":void 0,...O,children:D})},p:({node:_,...A})=>{var U;const O=Rn.Children.toArray(A.children).filter(z=>!(typeof z=="string"&&z.trim()==="")).some(z=>{if(!Rn.isValidElement(z))return!1;const H=z.props;return(H==null?void 0:H["data-block-code"])==="true"?!0:typeof z.type=="string"?bp.has(z.type):!1}),ee=(U=_==null?void 0:_.children)==null?void 0:U.some(z=>{var H;if(z.type==="code")return!0;if(z.type==="element"){if(z.tagName&&bp.has(z.tagName))return!0;if(z.tagName==="code"){const K=(H=z.properties)==null?void 0:H.className;return Array.isArray(K)?K.some(j=>typeof j=="string"&&j.startsWith("language-")):!0}}return!1});return O||ee?u.jsx(u.Fragment,{children:A.children}):u.jsx("p",{...A})}};return u.jsx("div",{className:`markdown-content ${l}`,children:u.jsx(xx,{remarkPlugins:w,rehypePlugins:k,components:S,children:b})})};var Ob={agentMode:{mode:"multi",defaultAdapterId:"simple-chat"},application:{name:"ORBIT Chat",description:"Explore ideas with ORBIT's AI copilots, share context, and build together.",inputPlaceholder:"Message ORBIT...",settingsAboutMsg:"ORBIT Chat",locale:"en-US",favicon:null},seo:{includeSitemap:!1,siteUrl:"http://localhost:5173",exposeAgentNotes:!0},debug:{consoleDebug:!1},features:{enableUpload:!0,enableAudioOutput:!0,enableAudioInput:!0,enableFeedbackButtons:!0,enableConversationThreads:!0,enableAutocomplete:!0},voice:{silenceTimeoutMs:4e3,recognitionLanguage:""},limits:{files:{perConversation:5,maxSizeMB:50,totalFiles:100},conversations:{maxConversations:10,messagesPerConversation:1e3,messagesPerThread:1e3,totalMessages:1e4},messages:{maxLength:1e4}},guestLimits:{files:{perConversation:1,maxSizeMB:5,totalFiles:1},conversations:{maxConversations:2,messagesPerConversation:5,messagesPerThread:2,totalMessages:10},messages:{maxLength:500},rateLimit:{enabled:!0,windowMs:6e4,maxRequests:60,chat:{windowMs:6e4,maxRequests:10}}},auth:{enabled:!1,provider:"auth0"},header:{enabled:!1,logoUrl:"",logoUrlLight:"",logoUrlDark:"",logoHeight:"3.5rem",logoWidth:"auto",bgColor:"",textColor:"",showBorder:!1,navLinks:[{label:"Docs",url:"/"},{label:"About",url:"/about"}]},footer:{enabled:!0,text:"Copyright © 2025 Schmitech Inc.",bgColor:"",textColor:"",showBorder:!1,layout:"stacked",align:"center",topPadding:"large",navLinks:[{label:"Support",url:"/"},{label:"Privacy",url:"/about"}]},adapters:[{id:"simple-chat",name:"Simple AI Chat",apiUrl:"http://localhost:3000",description:"Basic chat interface using the default conversational agent (Similar to ChatGPT - no files).",inputPlaceholder:"Simple chat, ask anything..."},{id:"web-search",name:"Simple AI Chat (Web Search)",apiUrl:"http://localhost:3000",description:"Basic chat interface using the default conversational agent with web search supports.",inputPlaceholder:"Simple chat, ask anything..."},{id:"chat-with-files",name:"Simple AI Chat (Multimodal)",apiUrl:"http://localhost:3000",description:"Extract knowledge from PDF, Images, Word, etc. (Similar to ChatGPT Multimodal)",inputPlaceholder:"Files chat, ask anything..."},{id:"image-generator",name:"AI Image Generator",apiUrl:"http://localhost:3000",description:"Generate images from text descriptions using DALL-E 3 or Imagen 3.",inputPlaceholder:"Describe the image you want to create..."},{id:"video-generator",name:"AI Video Generator",apiUrl:"http://localhost:3000",description:"Generate videos from text descriptions.",inputPlaceholder:"Describe the video you want to create..."},{id:"qa-sql",name:"City FAQ Assistant (SQLite)",apiUrl:"http://localhost:3000",description:"Quick-test QA assistant over the sample city Q&A SQLite database.",inputPlaceholder:"Ask a city services question..."},{id:"qa-vector-chroma",name:"City FAQ Assistant (Chroma)",apiUrl:"http://localhost:3000",description:"Quick-test semantic QA assistant over the sample city Q&A Chroma collection.",inputPlaceholder:"Ask a city services question..."},{id:"hr-db-chatbot",name:"HR System Assistant",apiUrl:"http://localhost:3000",description:"HR database assistant: natural language queries over SQLite HR data via intent templates.",inputPlaceholder:"Ask HR questions..."},{id:"intent-sql-postgres",name:"Customer Orders Assistant",apiUrl:"http://localhost:3000",description:"Customer orders assistant: natural language queries over PostgreSQL customer orders data."},{id:"ecomm-analytics",name:"Business Analytics Assistant",apiUrl:"http://localhost:3000",description:"DuckDB analytics assistant: natural language analytics queries over the analytics demo. This agent is the perfect example of how to use something like OLAP to quickly discover insigths."},{id:"composite-multi-source-explorer",name:"Multi-Source Explorer",apiUrl:"http://localhost:3000",description:"Multi-domain assistant: natural language over HR (SQLite), customer orders (PostgreSQL), and sales analytics (DuckDB)—one chat, retrieval routes each question to the best source.",inputPlaceholder:"Ask about employees, orders, or sales analytics..."},{id:"intent-http-jsonplaceholder",name:"REST API Chat",apiUrl:"http://localhost:3000",description:"Natural language queries over the fake REST API."},{id:"intent-http-paris-opendata",name:"City of Paris Chat",apiUrl:"http://localhost:3000",description:"Paris open data: events and activities (Que Faire à Paris) via natural language."},{id:"intent-mongodb-mflix",name:"Chat With Movies DB",apiUrl:"http://localhost:3000",description:"MFlix movies assistant: query the sample_mflix MongoDB database via intent templates."},{id:"intent-graphql-spacex",name:"GraphQL Chatbot",apiUrl:"http://localhost:3000",description:"SpaceX GraphQL assistant: natural language queries over the SpaceX API.",inputPlaceholder:"Ask SpaceX questions..."},{id:"audio-transcription",name:"Audio Transcription",apiUrl:"http://localhost:3000",description:"Audio Transcription Test.",inputPlaceholder:"Use the microphone for voice..."},{id:"voice-chat",name:"Voice Chat",apiUrl:"http://localhost:3000",description:"Voice chat adapter test.",inputPlaceholder:"Use the microphone for voice..."},{id:"real-time-voice-chat",name:"Real-Time Voice Chat",apiUrl:"http://localhost:3000",description:"Real-time voice chat adapter test (websocket).",inputPlaceholder:"Use the microphone for voice..."},{id:"intent-elasticsearch-log",name:"Log Analysis Assistant",apiUrl:"http://localhost:3000",description:"Analyze app logs, troubleshoot errors, and monitor performance via Elasticsearch."}]};const id="http://localhost:3000",$b="/favicon.svg",qb="/orbit-logo-light.png",Bb="/orbit-logo-dark.png",Hb={agentMode:{mode:"multi",defaultAdapterId:""},application:{name:"ORBIT Chat",description:"Explore ideas with ORBIT's AI copilots, share context, and build together.",inputPlaceholder:"Message ORBIT...",settingsAboutMsg:"ORBIT Chat",locale:"en-US",favicon:""},debug:{consoleDebug:!1},seo:{includeSitemap:!1,siteUrl:"",alternateSiteUrls:[],hostPatterns:[],exposeAgentNotes:!0},features:{enableUpload:!1,enableAudioOutput:!1,enableAudioInput:!1,enableFeedbackButtons:!1,enableConversationThreads:!0,enableAutocomplete:!1},voice:{silenceTimeoutMs:4e3,recognitionLanguage:""},outOfServiceMessage:null,limits:{files:{perConversation:5,maxSizeMB:50,totalFiles:100},conversations:{maxConversations:10,messagesPerConversation:1e3,messagesPerThread:1e3,totalMessages:1e4},messages:{maxLength:1e3}},guestLimits:{files:{perConversation:1,maxSizeMB:10,totalFiles:2},conversations:{maxConversations:1,messagesPerConversation:10,messagesPerThread:10,totalMessages:10},messages:{maxLength:500}},auth:{enabled:!1,provider:"auth0",domain:"",clientId:"",audience:"",tenantId:"",scopes:[]},header:{enabled:!1,logoUrl:"",logoUrlLight:"",logoUrlDark:"",logoHeight:"",logoWidth:"",bgColor:"",textColor:"",showBorder:!0,navLinks:[]},footer:{enabled:!1,text:"",bgColor:"",textColor:"",showBorder:!1,layout:"stacked",align:"center",topPadding:"large",navLinks:[]},startupScripts:[],adapters:[]};function So(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function od(r,l){if(!So(r)||!So(l))return l;const i={...r};return Object.keys(l).forEach(c=>{if(c==="__proto__"||c==="constructor"||c==="prototype")return;const d=i[c],f=l[c];So(d)&&So(f)?i[c]=od(d,f):f!==void 0&&(i[c]=f)}),i}function Fb(r){if(typeof r!="string")return null;const l=r.trim();if(!l)return null;const i=l.toLowerCase();return i==="false"||i==="0"||i==="off"||i==="disabled"?null:l}function Ib(r){return r==="single"?"single":"multi"}function Gb(r){const l=r.trim();if(l.startsWith("["))try{const i=JSON.parse(l);return Array.isArray(i)?i.filter(Boolean):[]}catch{return[]}return l.split(/\s+/).filter(Boolean)}function Vb(){const r=Ob||{},l=typeof window<"u"&&window.ORBIT_CHAT_CONFIG||{},i=!!(typeof window<"u"&&window.ORBIT_CHAT_CONFIG);let c=od(Hb,r);return c=od(c,l),(!i||!c.auth.domain)&&(c.auth.domain="dev-3c4dpzhecz4gundm.us.auth0.com"),(!i||!c.auth.clientId)&&(c.auth.clientId="9JSe5xtoi5mLXRuov2K7FHYU10ojCQLH"),!i||c.auth.audience,!i||c.auth.provider,!i||c.auth.tenantId,(!i||c.auth.scopes.length===0)&&(c.auth.scopes=Gb("openid profile email User.Read")),c.outOfServiceMessage=Fb(c.outOfServiceMessage),c.agentMode.mode=Ib(c.agentMode.mode),c.agentMode.defaultAdapterId=typeof c.agentMode.defaultAdapterId=="string"?c.agentMode.defaultAdapterId.trim():"",c}const Se=Vb();function kt(){var l;const r=Se.adapters;if(Array.isArray(r)&&r.length>0){const i=(l=r[0].apiUrl)==null?void 0:l.trim();if(i)return i}return id}function Ta(r){const l=r==null?void 0:r.trim();return l&&l.length>0?l:kt()}function Xb(){const r=Se.adapters;return Array.isArray(r)&&r.length>0?r[0].id:"default-key"}function Yb(){return Se.agentMode.mode}function Xo(){return Yb()==="single"}function Sd(){if(!Xo())return null;const r=Se.agentMode.defaultAdapterId;return r&&Se.adapters.some(i=>{var c;return((c=i==null?void 0:i.id)==null?void 0:c.trim())===r})?r:null}function kd(){return Se.application.name}function _d(){return Se.application.description}function og(){return Se.application.inputPlaceholder}function Qb(r){var d;const l=r==null?void 0:r.trim();if(!l)return null;const i=Se.adapters.find(f=>{var h;return((h=f==null?void 0:f.id)==null?void 0:h.trim())===l});return((d=i==null?void 0:i.name)==null?void 0:d.trim())||null}function Zb(r){var d;const l=r==null?void 0:r.trim();if(!l)return null;const i=Se.adapters.find(f=>{var h;return((h=f==null?void 0:f.id)==null?void 0:h.trim())===l});return((d=i==null?void 0:i.inputPlaceholder)==null?void 0:d.trim())||null}function cg(){return Se.seo.siteUrl.trim()}function Kb(){return Array.isArray(Se.seo.alternateSiteUrls)?Se.seo.alternateSiteUrls.filter(r=>typeof r=="string").map(r=>r.trim()).filter(Boolean):[]}function Jb(){return Array.isArray(Se.seo.hostPatterns)?Se.seo.hostPatterns.filter(r=>typeof r=="string").map(r=>r.trim()).filter(Boolean):[]}function Pb(){return Se.seo.exposeAgentNotes}function Wb(){var l;return((l=Se.application.favicon)==null?void 0:l.trim())||$b}function ey(){return Se.features.enableUpload}function ty(){return Se.features.enableAudioOutput}function ay(){return Se.features.enableAudioInput}function vp(){return Se.features.enableFeedbackButtons}function ny(){return Se.features.enableConversationThreads}function ug(){return Se.features.enableAutocomplete}function ly(){return Math.max(1e3,Se.voice.silenceTimeoutMs)}function ry(){return Se.voice.recognitionLanguage}function sy(){const r=Sd();if(r)return r;const l=Se.adapters;if(Array.isArray(l)&&l.length>0)for(const i of l){const c=typeof(i==null?void 0:i.id)=="string"?i.id.trim():"";if(c)return c}return null}function iy(){return Se.outOfServiceMessage}function Ad(){return Se.auth.enabled}function Ea(){const{enabled:r,provider:l,domain:i,clientId:c,tenantId:d}=Se.auth;return!r||!c?!1:l==="entra"?!!d:!!i}function oy(){return Se.auth.domain}function dg(){return Se.auth.clientId}function cy(){return Se.auth.audience}function Yo(){return Se.auth.provider}function uy(){return Se.auth.tenantId}function Cd(){const r=Se.auth.scopes;return r.length>0?r:["openid","profile","email"]}function cd(){return Se.header.enabled}function dy(){return Se.header.logoUrl}function fy(){var l;return((l=Se.header.logoUrlLight)==null?void 0:l.trim())||qb}function my(){var l;return((l=Se.header.logoUrlDark)==null?void 0:l.trim())||Bb}function hy(){var r;return((r=Se.header.logoHeight)==null?void 0:r.trim())||""}function py(){var r;return((r=Se.header.logoWidth)==null?void 0:r.trim())||""}function gy(){return Se.header.bgColor}function xy(){return Se.header.textColor}function by(){return Se.header.showBorder}function fg(r){if(Array.isArray(r))return r;if(typeof r=="string")try{const l=JSON.parse(r);return Array.isArray(l)?l:[]}catch{return[]}return[]}function mg(){return fg(Se.header.navLinks)}function hg(){return Se.footer.enabled}function yy(){return Se.footer.text}function vy(){return Se.footer.bgColor}function wy(){return Se.footer.textColor}function Sy(){return Se.footer.showBorder}function ky(){return Se.footer.layout==="inline"?"inline":"stacked"}function _y(){return Se.footer.topPadding==="normal"?"normal":"large"}function Ay(){const r=Se.startupScripts;return Array.isArray(r)?r.filter(l=>!!(l&&typeof l=="object")).map(l=>{const i=typeof l.src=="string"?l.src.trim():"",c=typeof l.content=="string"?l.content.trim():"",d=typeof l.id=="string"?l.id.trim():"";return{...l,src:i||void 0,content:c||void 0,id:d||void 0}}).filter(l=>!!(l.src||l.content)):[]}function Cy(){return fg(Se.footer.navLinks)}const jd=()=>Se.debug.consoleDebug,ne=(...r)=>{jd()&&console.log(...r)},Fe=(...r)=>{jd()&&console.warn(...r)},Ie=(...r)=>{jd()&&console.error(...r)},Mt=(...r)=>{console.error(...r)};function wp({audio:r,audioFormat:l="mp3",autoPlay:i=!1,maxSizeMB:c=10}){const d=g.useRef(null),[f,h]=g.useState(!1),[p,x]=g.useState(0),[v,b]=g.useState(0),[w,k]=g.useState(!0),[S,_]=g.useState(null),[A,D]=g.useState(null);g.useEffect(()=>{if(!r)return;let V=null,I=!0;return(async()=>{try{k(!0),_(null),D(null);const _e=r.length*3/4/(1024*1024);if(_e>c)throw new Error(`Audio file too large (${_e.toFixed(1)}MB > ${c}MB limit)`);if(_e>2&&(D(`Large audio file (${_e.toFixed(1)}MB) - may take time to load`),ne("[AudioPlayer] Large audio file detected",{sizeMB:_e.toFixed(2)})),!/^[A-Za-z0-9+/=]+$/.test(r.replace(/\s/g,"")))throw new Error("Invalid base64 audio data");const te=atob(r),oe=new Uint8Array(te.length);for(let B=0;B<te.length;B++)oe[B]=te.charCodeAt(B);const E=l==="mp3"?"audio/mpeg":l==="wav"?"audio/wav":l==="ogg"?"audio/ogg":l==="opus"?"audio/opus":l==="webm"?"audio/webm":`audio/${l}`,Y=new Blob([oe],{type:E});if(V=URL.createObjectURL(Y),!I||!d.current){V&&URL.revokeObjectURL(V);return}d.current.src=V,k(!1),ne("[AudioPlayer] Audio loaded successfully",{format:l,mimeType:E,size:Y.size}),i&&d.current&&d.current.play().catch(B=>{Ie("[AudioPlayer] Auto-play failed:",B)})}catch(ue){Ie("[AudioPlayer] Failed to load audio:",ue),I&&(_("Failed to load audio"),k(!1))}})(),()=>{I=!1,V&&URL.revokeObjectURL(V)}},[r,l,i,c]);const O=()=>{d.current&&x(d.current.duration)},ee=()=>{d.current&&b(d.current.currentTime)},U=()=>h(!0),z=()=>h(!1),H=()=>{h(!1),b(0)},K=()=>{d.current&&(f?d.current.pause():d.current.play().catch(V=>{Ie("[AudioPlayer] Playback failed:",V),_("Playback failed")}))},j=V=>{if(!d.current)return;const I=parseFloat(V.target.value);d.current.currentTime=I,b(I)},q=V=>{if(!isFinite(V))return"0:00";const I=Math.floor(V/60),P=Math.floor(V%60);return`${I}:${P.toString().padStart(2,"0")}`};return S?u.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-700 dark:bg-red-900/20 dark:text-red-400",children:[u.jsx($o,{className:"h-4 w-4"}),u.jsx("span",{children:S})]}):u.jsxs("div",{className:"mt-3 flex flex-col gap-1",children:[A&&u.jsxs("div",{className:"text-xs text-amber-600 dark:text-amber-400 px-1",children:["⚠️ ",A]}),u.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-gray-300 bg-white px-3 py-2 dark:border-[#4a4b54] dark:bg-[#343541]",children:[u.jsx("audio",{ref:d,onLoadedMetadata:O,onTimeUpdate:ee,onPlay:U,onPause:z,onEnded:H}),u.jsx("button",{onClick:K,disabled:w,className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 disabled:opacity-50 dark:bg-[#4a4b54] dark:hover:bg-[#565869]",title:f?"Pause":"Play","aria-label":f?"Pause audio":"Play audio",children:w?u.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-gray-400 border-t-transparent"}):f?u.jsx(Wx,{className:"h-4 w-4 text-gray-700 dark:text-[#ececf1]"}):u.jsx(eb,{className:"h-4 w-4 text-gray-700 dark:text-[#ececf1]"})}),u.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[u.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:q(v)}),u.jsx("input",{type:"range",min:"0",max:p||0,value:v,onChange:j,disabled:w||!p,className:"flex-1 cursor-pointer accent-gray-600 dark:accent-[#bfc2cd]",style:{background:p?`linear-gradient(to right, rgb(75 85 99) 0%, rgb(75 85 99) ${v/p*100}%, rgb(229 231 235) ${v/p*100}%, rgb(229 231 235) 100%)`:"rgb(229 231 235)"}}),u.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:q(p)})]}),u.jsx($o,{className:"h-4 w-4 text-gray-500 dark:text-[#bfc2cd]"})]})]})}var Qo=Pp();function Sp({image:r,imageUrl:l,imageFormat:i="png",revisedPrompt:c}){const[d,f]=g.useState(!1),[h,p]=g.useState(!1),[x,v]=g.useState(null),b=g.useRef(null);g.useEffect(()=>{if(r||!l)return;let _=!1;return(async()=>{try{const A=typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null,D=await fetch(l,{headers:A?{"X-Adapter-Name":A}:{}});if(!D.ok){console.warn("[ImageDisplay] Server returned",D.status,"for",l);return}if(_)return;const O=await D.arrayBuffer();if(_)return;const ee=new Blob([O],{type:`image/${i}`}),U=URL.createObjectURL(ee);b.current=U,v(U)}catch(A){console.warn("[ImageDisplay] Failed to fetch image from",l,A)}})(),()=>{_=!0,b.current&&(URL.revokeObjectURL(b.current),b.current=null)}},[l,r,i]);const k=(r?`data:image/${i};base64,${r}`:null)??x;g.useEffect(()=>{if(!d)return;const _=A=>{A.key==="Escape"&&f(!1)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[d]);const S=_=>{if(_.stopPropagation(),!k)return;const A=document.createElement("a");A.href=k,A.download=`generated-image.${i}`,A.click()};return k?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"generated-image-wrapper",style:{marginTop:"0.75rem"},children:[u.jsxs("div",{className:"generated-image-container",style:{position:"relative",display:"inline-block",cursor:"zoom-in",maxWidth:"100%"},onClick:()=>f(!0),title:c||"Generated image — click to enlarge",children:[u.jsx("img",{src:k,alt:c||"Generated image",style:{maxWidth:"100%",maxHeight:"480px",borderRadius:"8px",display:"block",objectFit:"contain"}}),u.jsxs("div",{style:{position:"absolute",bottom:"8px",right:"8px",display:"flex",gap:"6px"},children:[u.jsx("button",{onClick:S,title:"Download image",style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(bd,{size:14})}),u.jsx("button",{onClick:_=>{_.stopPropagation(),f(!0)},title:"View full size",style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(db,{size:14})})]})]}),c&&u.jsxs("div",{style:{marginTop:"8px",maxWidth:"480px"},children:[u.jsxs("button",{type:"button",onClick:()=>p(_=>!_),style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:0,background:"transparent",border:"none",cursor:"pointer",fontSize:"0.75rem",fontWeight:500,opacity:.72},"aria-expanded":h,children:[h?u.jsx(Oo,{size:14}):u.jsx(fi,{size:14}),h?"Hide prompt":"Show prompt"]}),h&&u.jsxs("div",{style:{marginTop:"8px",padding:"8px 10px",background:"rgba(128,128,128,0.08)",borderRadius:"6px"},children:[u.jsx("span",{style:{display:"block",fontSize:"0.65rem",fontWeight:600,opacity:.5,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:"3px"},children:"Prompt"}),u.jsx("span",{style:{fontSize:"0.8rem",lineHeight:1.45,opacity:.85},children:c})]})]})]}),d&&typeof document<"u"&&Qo.createPortal(u.jsxs("div",{onClick:()=>f(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.85)",zIndex:9999,overflow:"auto",padding:"56px 24px 24px"},children:[u.jsx("button",{onClick:_=>{_.stopPropagation(),f(!1)},style:{position:"fixed",top:"16px",right:"16px",background:"rgba(255,255,255,0.15)",border:"none",borderRadius:"50%",padding:"8px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(ba,{size:20})}),u.jsx("img",{src:k,alt:c||"Generated image",style:{display:"block",width:"auto",height:"auto",maxWidth:"calc(100vw - 48px)",maxHeight:"calc(100vh - 80px)",objectFit:"contain",borderRadius:"8px",margin:"0 auto"},onClick:_=>_.stopPropagation()})]}),document.body)]}):null}const Wu=[750,1500,3e3,5e3],jy=new Set([403,404,409,425,429,500,502,503,504]),Ny=r=>new Promise(l=>setTimeout(l,r));function kp({video:r,videoUrl:l,videoFormat:i="mp4",revisedPrompt:c,adapterName:d}){const[f,h]=g.useState(!1),[p,x]=g.useState(!1),[v,b]=g.useState(null),w=g.useRef(null);g.useEffect(()=>{if(r||!l)return;let A=!1;return(async()=>{try{const D=d||(typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null);let O=null;for(let H=0;H<=Wu.length&&(O=await fetch(l,{headers:D?{"X-Adapter-Name":D}:{}}),!(O.ok||!jy.has(O.status)||H===Wu.length));H+=1)if(await Ny(Wu[H]),A)return;if(!(O!=null&&O.ok)){console.warn("[VideoDisplay] Server returned",O.status,"for",l);return}if(A)return;const ee=await O.arrayBuffer();if(A)return;const U=new Blob([ee],{type:`video/${i}`}),z=URL.createObjectURL(U);w.current=z,b(z)}catch(D){console.warn("[VideoDisplay] Failed to fetch video from",l,D)}})(),()=>{A=!0,w.current&&(URL.revokeObjectURL(w.current),w.current=null)}},[l,r,i,d]);const S=(r?`data:video/${i};base64,${r}`:null)??v;g.useEffect(()=>{if(!f)return;const A=D=>{D.key==="Escape"&&h(!1)};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[f]);const _=A=>{if(A.stopPropagation(),!S)return;const D=document.createElement("a");D.href=S,D.download=`generated-video.${i}`,D.click()};return S?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"generated-video-wrapper",style:{marginTop:"0.75rem"},children:[u.jsxs("div",{style:{position:"relative",display:"inline-block",maxWidth:"100%"},children:[u.jsx("video",{src:S,controls:!0,style:{maxWidth:"100%",maxHeight:"480px",borderRadius:"8px",display:"block",backgroundColor:"#000"}}),u.jsxs("div",{style:{position:"absolute",bottom:"48px",right:"8px",display:"flex",gap:"6px"},children:[u.jsx("button",{onClick:_,title:"Download video",style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(bd,{size:14})}),u.jsx("button",{onClick:A=>{A.stopPropagation(),h(!0)},title:"View full size",style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(Ix,{size:14})})]})]}),c&&u.jsxs("div",{style:{marginTop:"8px",maxWidth:"480px"},children:[u.jsxs("button",{type:"button",onClick:()=>x(A=>!A),style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:0,background:"transparent",border:"none",cursor:"pointer",fontSize:"0.75rem",fontWeight:500,opacity:.72},"aria-expanded":p,children:[p?u.jsx(Oo,{size:14}):u.jsx(fi,{size:14}),p?"Hide prompt":"Show prompt"]}),p&&u.jsxs("div",{style:{marginTop:"8px",padding:"8px 10px",background:"rgba(128,128,128,0.08)",borderRadius:"6px"},children:[u.jsx("span",{style:{display:"block",fontSize:"0.65rem",fontWeight:600,opacity:.5,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:"3px"},children:"Prompt"}),u.jsx("span",{style:{fontSize:"0.8rem",lineHeight:1.45,opacity:.85},children:c})]})]})]}),f&&u.jsxs("div",{onClick:()=>h(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.9)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center"},children:[u.jsx("button",{onClick:A=>{A.stopPropagation(),h(!1)},style:{position:"fixed",top:"16px",right:"16px",background:"rgba(255,255,255,0.15)",border:"none",borderRadius:"50%",padding:"8px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(ba,{size:20})}),u.jsx("video",{src:S,controls:!0,autoPlay:!0,style:{maxWidth:"92vw",maxHeight:"92vh",borderRadius:"8px"},onClick:A=>A.stopPropagation()})]})]}):null}let qo=null;function pg(r){qo=r}function Zo(){qo=null}async function Nd(){if(!qo)return null;try{return await qo()}catch{return null}}let ud=!1,ci=null;const dd=new Set;function gg(){dd.forEach(r=>r())}function vn(){return ud}function Ty(){return ci}function Ko(r){ud!==r&&(ud=r,!r&&ci!==null&&(ci=null),gg())}function os(r){const l=typeof r=="string"&&r.trim().length>0?r.trim():null;ci!==l&&(ci=l,gg())}function Ey(r){return dd.add(r),()=>{dd.delete(r)}}const _p="orbitchat-guest-user-id";function ko(r){if(typeof r!="string")return null;const l=r.trim();return l.length>0?l:null}function My(r){const l=r.split(".");if(l.length<2)return null;try{const i=l[1].replace(/-/g,"+").replace(/_/g,"/"),c=i.padEnd(Math.ceil(i.length/4)*4,"="),d=atob(c);return JSON.parse(d)}catch{return null}}function zy(){const r=globalThis.crypto;if(r&&typeof r.randomUUID=="function")return`guest:orbitchat:${r.randomUUID()}`;if(!r||typeof r.getRandomValues!="function")throw new Error("Secure random number generation is unavailable");const l=new Uint8Array(16);return r.getRandomValues(l),`guest:orbitchat:${Array.from(l,c=>c.toString(16).padStart(2,"0")).join("")}`}function Dy(){if(typeof window>"u")return"guest:orbitchat:server";const r=window.localStorage.getItem(_p);if(r&&r.trim().length>0)return r;const l=zy();return window.localStorage.setItem(_p,l),l}async function xg(){const r=Ty();if(r)return r;const l=await Nd();if(l){const i=My(l),c=ko(i==null?void 0:i.sub)||ko(i==null?void 0:i.user_id)||ko(i==null?void 0:i.preferred_username)||ko(i==null?void 0:i.email);if(c)return c}return vn()?"authenticated:orbitchat:unknown":Dy()}const Ly={pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",md:"text/markdown",csv:"text/csv"},Ap={pdf:"PDF",docx:"Word document",xlsx:"Excel workbook",pptx:"PowerPoint deck",md:"Markdown document",csv:"CSV file"},Ro=/[\uE000-\uF8FF]|\\[eE][0-9a-fA-F]{2,3}|\\[fF][0-8][0-9a-fA-F]{2,3}/,Ry=/((?:p\.)?generated-docx-preview-num-\d+-\d+:before\s*\{[^}]*?)content\s*:\s*"([^"]*)"\s*;([^}]*?\})/g;function Uy(r){var i;return Ro.test(r)?`•${((i=r.match(/(?:\\9|\t|\u00A0| )+$/))==null?void 0:i[0])||"\\9"}`:null}function Cp(r){Array.from(r.querySelectorAll("style")).forEach(c=>{const d=c.textContent;!d||!Ro.test(d)||(c.textContent=d.replace(Ry,(f,h,p,x)=>{const v=Uy(p);if(!v)return f;const b=x.replace(/\s*font-family\s*:\s*[^;{}]+;?/gi,"");return`${h}content: "${v}";${b}`}))}),Array.from(r.querySelectorAll('span[style*="font-family"]')).forEach(c=>{if(!/\b(symbol|wingdings|webdings)\b/i.test(c.style.fontFamily))return;const d=c.textContent||"";Ro.test(d)&&(c.textContent=d.replace(Ro,"•"),c.style.fontFamily="")})}function Oy(r){return(r||"pdf").toLowerCase().replace(/^\./,"")||"pdf"}function $y(r){const l=window.atob(r),i=new Uint8Array(l.length);for(let c=0;c<l.length;c+=1)i[c]=l.charCodeAt(c);return i.buffer}function qy(r){return r==="xlsx"||r==="csv"?u.jsx($x,{className:"h-5 w-5"}):r==="pptx"?u.jsx(ab,{className:"h-5 w-5"}):r==="md"?u.jsx(Ox,{className:"h-5 w-5"}):u.jsx(qx,{className:"h-5 w-5"})}function jp({document:r,documentUrl:l,documentFormat:i="pdf",revisedPrompt:c,adapterName:d}){const f=Oy(i),[h,p]=g.useState(r||l?"loading":"idle"),[x,v]=g.useState(null),[b,w]=g.useState(null),[k,S]=g.useState([]),[_,A]=g.useState(""),[D,O]=g.useState(null),[ee,U]=g.useState([]),[z,H]=g.useState(0),[K,j]=g.useState(!1),[q,V]=g.useState(null),I=g.useRef(null),P=g.useRef(null),ue=g.useRef(null),_e=c||Ap[f]||"Generated document",te=g.useMemo(()=>`generated-document.${f}`,[f]),oe=Ly[f]||"application/octet-stream";g.useEffect(()=>{if(!r&&!l)return;let re=!1;return(async()=>{p("loading"),V(null),S([]),A(""),O(null),U([]),H(0);try{const ge=r?$y(r):await(async()=>{const me=(d==null?void 0:d.trim())||(typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null),de={"X-User-ID":await xg()};me&&(de["X-Adapter-Name"]=me);const fe=await Nd();fe&&(de.Authorization=`Bearer ${fe}`);const ye=await fetch(l,{headers:de});if(!ye.ok)throw new Error(`Server returned ${ye.status}`);return ye.arrayBuffer()})();if(re)return;const pe=new Blob([ge],{type:oe}),G=URL.createObjectURL(pe);if(I.current&&URL.revokeObjectURL(I.current),I.current=G,v(G),w(ge.slice(0)),f==="xlsx"){const{default:me}=await Un(async()=>{const{default:ye}=await import("./index-CZz_ECqk.js");return{default:ye}},[]),fe=(await me(pe))[0];A((fe==null?void 0:fe.sheet)||"First sheet"),S(((fe==null?void 0:fe.data)||[]).slice(0,100).map(ye=>ye.slice(0,30).map(ae=>ae==null?"":String(ae))))}if(f==="md"&&O(new TextDecoder("utf-8").decode(ge)),f==="csv"){const me=new TextDecoder("utf-8").decode(ge),{default:de}=await Un(async()=>{const{default:ye}=await import("./papaparse.min-BWA-Odol.js").then(ae=>ae.p);return{default:ye}},__vite__mapDeps([16,1])),fe=de.parse(me,{skipEmptyLines:!0});H(fe.data.length),U(fe.data.slice(0,25))}p("ready")}catch(ge){if(re)return;console.warn("[DocumentDisplay] Failed to load document from",l,ge),V(ge instanceof Error?ge.message:"Unable to load document"),p("error")}})(),()=>{re=!0,I.current&&(URL.revokeObjectURL(I.current),I.current=null)}},[d,r,l,f,oe]),g.useEffect(()=>{if(h!=="ready"||f!=="docx"||!b||!P.current)return;const re=P.current;re.replaceChildren(),Un(()=>import("./docx-preview-CMb3nQfR.js"),__vite__mapDeps([17,1])).then(async({renderAsync:ce})=>{await ce(b.slice(0),re,void 0,{className:"generated-docx-preview",inWrapper:!1,ignoreWidth:!0,ignoreHeight:!0}),Cp(re)}).catch(ce=>{console.warn("[DocumentDisplay] Failed to render DOCX preview",ce),V("Unable to render document preview")})},[b,f,h]),g.useEffect(()=>{if(!K||f!=="docx"||!b||!ue.current)return;const re=ue.current;re.replaceChildren(),Un(()=>import("./docx-preview-CMb3nQfR.js"),__vite__mapDeps([17,1])).then(async({renderAsync:ce})=>{await ce(b.slice(0),re,void 0,{className:"generated-docx-preview",inWrapper:!1,ignoreWidth:!0,ignoreHeight:!0}),Cp(re)}).catch(ce=>{console.warn("[DocumentDisplay] Failed to render modal DOCX preview",ce)})},[b,f,K]),g.useEffect(()=>{if(!K)return;const re=ce=>{ce.key==="Escape"&&j(!1)};return window.document.addEventListener("keydown",re),()=>window.document.removeEventListener("keydown",re)},[K]);const E=re=>{if(re==null||re.stopPropagation(),!x)return;const ce=window.document.createElement("a");ce.href=x,ce.download=te,ce.click()},Y=h==="ready"&&(f==="pdf"||f==="docx"||f==="xlsx"||f==="md"||f==="csv"),B=Y&&f!=="xlsx"&&f!=="csv";return h==="idle"?null:u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"mt-3 max-w-full overflow-hidden rounded-lg border border-gray-200 bg-white shadow-sm dark:border-[#3b3c49] dark:bg-[#202123]",children:[u.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-100 px-3 py-2.5 dark:border-[#3b3c49]",children:[u.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-blue-50 text-blue-600 dark:bg-blue-500/10 dark:text-blue-300",children:qy(f)}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"truncate text-sm font-medium text-[#353740] dark:text-[#ececf1]",children:_e}),u.jsxs("p",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:[Ap[f]||`${f.toUpperCase()} document`,h==="loading"?" · Loading preview...":"",h==="error"?` · ${q||"Preview unavailable"}`:""]})]}),B&&u.jsx("button",{type:"button",onClick:()=>j(!0),className:"rounded-md p-2 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-[#bfc2cd] dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]",title:"Open preview","aria-label":"Open preview",children:u.jsx(Ux,{className:"h-4 w-4"})}),u.jsx("button",{type:"button",onClick:E,disabled:!x,className:"rounded-md p-2 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 disabled:cursor-not-allowed disabled:opacity-50 dark:text-[#bfc2cd] dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]",title:"Download document","aria-label":"Download document",children:u.jsx(bd,{className:"h-4 w-4"})})]}),Y&&u.jsxs("div",{className:"max-h-[460px] overflow-auto bg-gray-50 dark:bg-[#171717]",children:[f==="pdf"&&x&&u.jsx("iframe",{src:x,title:_e,className:"block h-[460px] w-full border-0 bg-white"}),f==="docx"&&u.jsx("div",{ref:P,className:"min-h-[240px] bg-white p-5 text-sm text-[#111827] dark:bg-white dark:text-[#111827]"}),f==="xlsx"&&u.jsxs("div",{className:"p-3",children:[_&&u.jsx("p",{className:"mb-2 text-xs font-medium text-gray-500 dark:text-[#bfc2cd]",children:_}),u.jsx("div",{className:"overflow-auto rounded-md border border-gray-200 bg-white dark:border-[#3b3c49] dark:bg-[#202123]",children:u.jsx("table",{className:"min-w-full border-collapse text-left text-xs",children:u.jsx("tbody",{children:k.length>0?k.map((re,ce)=>u.jsx("tr",{className:ce===0?"bg-gray-50 font-medium dark:bg-white/5":void 0,children:re.map((ge,pe)=>u.jsx("td",{className:"max-w-[220px] truncate border-b border-r border-gray-100 px-2 py-1.5 text-[#353740] dark:border-[#3b3c49] dark:text-[#ececf1]",children:ge},pe))},ce)):u.jsx("tr",{children:u.jsx("td",{className:"px-3 py-4 text-sm text-gray-500 dark:text-[#bfc2cd]",children:"No sheet data found."})})})})})]}),f==="md"&&D!==null&&u.jsx("div",{className:"bg-white p-5 text-sm text-[#111827] dark:bg-[#171717] dark:text-[#ececf1]",children:u.jsx(rl,{content:D,disableMath:!0})}),f==="csv"&&u.jsxs("div",{className:"p-3",children:[z>25&&u.jsxs("p",{className:"mb-2 text-xs text-gray-500 dark:text-[#bfc2cd]",children:["Showing first 25 of ",z," rows — download for the full file."]}),u.jsx("div",{className:"overflow-auto rounded-md border border-gray-200 bg-white dark:border-[#3b3c49] dark:bg-[#202123]",children:u.jsx("table",{className:"min-w-full border-collapse text-left text-xs",children:u.jsx("tbody",{children:ee.length>0?ee.map((re,ce)=>u.jsx("tr",{className:ce===0?"bg-gray-50 font-medium dark:bg-white/5":void 0,children:re.map((ge,pe)=>u.jsx("td",{className:"max-w-[220px] truncate border-b border-r border-gray-100 px-2 py-1.5 text-[#353740] dark:border-[#3b3c49] dark:text-[#ececf1]",children:ge},pe))},ce)):u.jsx("tr",{children:u.jsx("td",{className:"px-3 py-4 text-sm text-gray-500 dark:text-[#bfc2cd]",children:"No data found."})})})})})]})]}),h==="ready"&&!Y&&u.jsx("div",{className:"px-3 py-4 text-sm text-gray-600 dark:text-[#bfc2cd]",children:"Preview is not available for this format. Use download to open it locally."})]}),K&&x&&u.jsxs("div",{onClick:()=>j(!1),className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/85 p-4",children:[u.jsx("button",{onClick:re=>{re.stopPropagation(),j(!1)},className:"fixed right-4 top-4 flex items-center rounded-full border-0 bg-white/15 p-2 text-white",title:"Close preview","aria-label":"Close preview",children:u.jsx(ba,{className:"h-5 w-5"})}),u.jsxs("div",{onClick:re=>re.stopPropagation(),className:"h-[92vh] w-[92vw] overflow-auto rounded-lg bg-white",children:[f==="pdf"&&u.jsx("iframe",{src:x,title:_e,className:"h-full w-full border-0"}),f==="docx"&&u.jsx("div",{ref:ue,className:"min-h-full bg-white p-8 text-[#111827]"}),f==="md"&&D!==null&&u.jsx("div",{className:"min-h-full bg-white p-8 text-sm text-[#111827]",children:u.jsx(rl,{content:D,disableMath:!0})})]})]})]})}const By=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(",");function ui(r,{enabled:l,onEscape:i}){g.useEffect(()=>{if(!l||!r.current)return;const c=r.current,d=document.activeElement,f=Array.from(c.querySelectorAll(By)).filter(v=>v.tabIndex!==-1),h=f[0]||c,p=f[f.length-1]||c;h.focus({preventScroll:!0});const x=v=>{if(v.key==="Escape"){i==null||i();return}if(v.key!=="Tab")return;if(f.length===0){v.preventDefault(),c.focus({preventScroll:!0});return}const b=document.activeElement;if(v.shiftKey){(!b||b===h||!c.contains(b))&&(v.preventDefault(),p.focus({preventScroll:!0}));return}(!b||b===p||!c.contains(b))&&(v.preventDefault(),h.focus({preventScroll:!0}))};return document.addEventListener("keydown",x),()=>{var v;document.removeEventListener("keydown",x),(v=d==null?void 0:d.focus)==null||v.call(d,{preventScroll:!0})}},[l,i,r])}function Bo({isOpen:r,onClose:l,onConfirm:i,title:c,message:d,confirmText:f="Confirm",cancelText:h="Cancel",type:p="danger",isLoading:x=!1}){const v=g.useRef(null);if(ui(v,{enabled:r,onEscape:l}),!r)return null;const b=()=>{x||i()},k=(()=>{switch(p){case"danger":return{icon:"text-red-500",iconBg:"bg-red-100 dark:bg-red-900/20",confirmButton:"bg-red-600 hover:bg-red-700 focus:ring-red-500",border:"border-red-200 dark:border-red-800"};case"warning":return{icon:"text-amber-500",iconBg:"bg-amber-100 dark:bg-amber-900/20",confirmButton:"bg-amber-600 hover:bg-amber-700 focus:ring-amber-500",border:"border-amber-200 dark:border-amber-800"};default:return{icon:"text-blue-500",iconBg:"bg-blue-100 dark:bg-blue-900/20",confirmButton:"bg-blue-600 hover:bg-blue-700 focus:ring-blue-500",border:"border-blue-200 dark:border-blue-800"}}})(),S=u.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center overflow-y-auto bg-black/60 p-4 backdrop-blur-sm animate-fadeIn",children:u.jsxs("div",{ref:v,role:"dialog","aria-modal":"true","aria-labelledby":"confirm-title",tabIndex:-1,className:"w-full max-w-md max-h-[calc(100vh-2rem)] overflow-y-auto rounded-2xl bg-white shadow-2xl transform animate-fadeIn dark:bg-[#1a1b1e]",children:[u.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-[#2d2f39]",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:`w-10 h-10 rounded-full ${k.iconBg} flex items-center justify-center`,children:u.jsx(wd,{className:`w-5 h-5 ${k.icon}`})}),u.jsx("h2",{id:"confirm-title",className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:c})]}),u.jsx("button",{type:"button",onClick:l,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors","aria-label":"Close",children:u.jsx(ba,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})]}),u.jsx("div",{className:"p-6",children:u.jsx("p",{className:"text-gray-600 dark:text-gray-300 leading-relaxed",children:d})}),u.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-gray-200 dark:border-[#2d2f39] bg-gray-50 dark:bg-[#131416] rounded-b-2xl",children:[u.jsx("button",{type:"button",onClick:l,disabled:x,className:"px-4 py-3 md:py-2.5 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-lg transition-colors font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:h}),u.jsx("button",{type:"button",onClick:b,disabled:x,className:`px-4 py-3 md:py-2.5 text-white rounded-lg transition-all font-medium shadow-sm hover:shadow-md transform hover:scale-105 active:scale-95 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white dark:focus:ring-offset-gray-800 disabled:opacity-50 disabled:cursor-not-allowed disabled:transform-none ${k.confirmButton}`,children:x?u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Clearing..."]}):f})]})]})});return typeof document>"u"?S:Qo.createPortal(S,document.body)}const Hy=["#","*","`","[","]","(",")","{","}","|","<",">"],bg=r=>Hy.some(l=>r.includes(l));function yg(r){if(!r||r.length<1e3)return!1;const l=/^[A-Za-z0-9+/=]+$/,i=r.replace(/\s+/g,"");if(i.length>1e4&&l.test(i)){const c=/\b(the|and|for|are|but|not|you|all|can|function|const|let|var|class|return|import|export|async|await|if|else|while|true|false|null|undefined|http|https|www|error|data|response|request|api|json|xml|html|css|js|py|java|cpp|def|print|console|log)\b/i.test(r),d=bg(r),f=/[-.,;:!?'"()]/.test(r);if(!c&&!d&&!f)return!0}return!!(i.length>5e4&&l.test(i)&&r.replace(/[A-Za-z0-9+/=\s]/g,"").length<10)}const Fy=/(?:\u202F|\u2009|\u200A|\u200B|\u200C|\u200D|\uFEFF)/g;function rs(r){if(!r)return r;let l=r.replace(Fy," ");if(yg(l))return"";const i=/([A-Za-z0-9+/=]{10000,})/g;return l=l.replace(i,c=>{const d=c.replace(/\s+/g,"");if(d.length>1e4&&/^[A-Za-z0-9+/=]+$/.test(d)){const f=/\b(function|const|let|var|class|return|import|export|if|else|while|for|true|false|null|def|print)\b/i.test(c),h=bg(c),p=/[-.,;:!?'"()]/.test(c);if(!f&&!h&&!p)return""}return c}),l}function fd(r,l=5e4){return!r||r.length<=l?r:yg(r)?"":r.substring(0,l)+`
330
+ `,l}catch(l){return console.warn("Error preprocessing markdown:",l),r}},kb={'code[class*="language-"]':{color:"#393A34",fontFamily:'"Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",fontSize:".9em",lineHeight:"1.2em",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"#393A34",fontFamily:'"Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",fontSize:".9em",lineHeight:"1.2em",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",border:"1px solid #dddddd",backgroundColor:"white"},'pre > code[class*="language-"]':{fontSize:"1em"},'pre[class*="language-"]::-moz-selection':{background:"#C1DEF1"},'pre[class*="language-"] ::-moz-selection':{background:"#C1DEF1"},'code[class*="language-"]::-moz-selection':{background:"#C1DEF1"},'code[class*="language-"] ::-moz-selection':{background:"#C1DEF1"},'pre[class*="language-"]::selection':{background:"#C1DEF1"},'pre[class*="language-"] ::selection':{background:"#C1DEF1"},'code[class*="language-"]::selection':{background:"#C1DEF1"},'code[class*="language-"] ::selection':{background:"#C1DEF1"},':not(pre) > code[class*="language-"]':{padding:".2em",paddingTop:"1px",paddingBottom:"1px",background:"#f8f8f8",border:"1px solid #dddddd"},comment:{color:"#008000",fontStyle:"italic"},prolog:{color:"#008000",fontStyle:"italic"},doctype:{color:"#008000",fontStyle:"italic"},cdata:{color:"#008000",fontStyle:"italic"},namespace:{Opacity:".7"},string:{color:"#A31515"},punctuation:{color:"#393A34"},operator:{color:"#393A34"},url:{color:"#36acaa"},symbol:{color:"#36acaa"},number:{color:"#36acaa"},boolean:{color:"#36acaa"},variable:{color:"#36acaa"},constant:{color:"#36acaa"},inserted:{color:"#36acaa"},atrule:{color:"#0000ff"},keyword:{color:"#0000ff"},"attr-value":{color:"#0000ff"},".language-autohotkey .token.selector":{color:"#0000ff"},".language-json .token.boolean":{color:"#0000ff"},".language-json .token.number":{color:"#0000ff"},'code[class*="language-css"]':{color:"#0000ff"},function:{color:"#393A34"},deleted:{color:"#9a050f"},".language-autohotkey .token.tag":{color:"#9a050f"},selector:{color:"#800000"},".language-autohotkey .token.keyword":{color:"#00009f"},important:{color:"#e90",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},"class-name":{color:"#2B91AF"},".language-json .token.property":{color:"#2B91AF"},tag:{color:"#800000"},"attr-name":{color:"#ff0000"},property:{color:"#ff0000"},regex:{color:"#ff0000"},entity:{color:"#ff0000"},"directive.tag.tag":{background:"#ffff00",color:"#393A34"},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:"#a5a5a5"},".line-numbers .line-numbers-rows > span:before":{color:"#2B91AF"},".line-highlight.line-highlight":{background:"linear-gradient(to right, rgba(193, 222, 241, 0.2) 70%, rgba(221, 222, 241, 0))"}},_b={'pre[class*="language-"]':{color:"#d4d4d4",fontSize:"13px",textShadow:"none",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",background:"#1e1e1e"},'code[class*="language-"]':{color:"#d4d4d4",fontSize:"13px",textShadow:"none",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]::selection':{textShadow:"none",background:"#264F78"},'code[class*="language-"]::selection':{textShadow:"none",background:"#264F78"},'pre[class*="language-"] *::selection':{textShadow:"none",background:"#264F78"},'code[class*="language-"] *::selection':{textShadow:"none",background:"#264F78"},':not(pre) > code[class*="language-"]':{padding:".1em .3em",borderRadius:".3em",color:"#db4c69",background:"#1e1e1e"},".namespace":{Opacity:".7"},"doctype.doctype-tag":{color:"#569CD6"},"doctype.name":{color:"#9cdcfe"},comment:{color:"#6a9955"},prolog:{color:"#6a9955"},punctuation:{color:"#d4d4d4"},".language-html .language-css .token.punctuation":{color:"#d4d4d4"},".language-html .language-javascript .token.punctuation":{color:"#d4d4d4"},property:{color:"#9cdcfe"},tag:{color:"#569cd6"},boolean:{color:"#569cd6"},number:{color:"#b5cea8"},constant:{color:"#9cdcfe"},symbol:{color:"#b5cea8"},inserted:{color:"#b5cea8"},unit:{color:"#b5cea8"},selector:{color:"#d7ba7d"},"attr-name":{color:"#9cdcfe"},string:{color:"#ce9178"},char:{color:"#ce9178"},builtin:{color:"#ce9178"},deleted:{color:"#ce9178"},".language-css .token.string.url":{textDecoration:"underline"},operator:{color:"#d4d4d4"},entity:{color:"#569cd6"},"operator.arrow":{color:"#569CD6"},atrule:{color:"#ce9178"},"atrule.rule":{color:"#c586c0"},"atrule.url":{color:"#9cdcfe"},"atrule.url.function":{color:"#dcdcaa"},"atrule.url.punctuation":{color:"#d4d4d4"},keyword:{color:"#569CD6"},"keyword.module":{color:"#c586c0"},"keyword.control-flow":{color:"#c586c0"},function:{color:"#dcdcaa"},"function.maybe-class-name":{color:"#dcdcaa"},regex:{color:"#d16969"},important:{color:"#569cd6"},italic:{fontStyle:"italic"},"class-name":{color:"#4ec9b0"},"maybe-class-name":{color:"#4ec9b0"},console:{color:"#9cdcfe"},parameter:{color:"#9cdcfe"},interpolation:{color:"#9cdcfe"},"punctuation.interpolation-punctuation":{color:"#569cd6"},variable:{color:"#9cdcfe"},"imports.maybe-class-name":{color:"#9cdcfe"},"exports.maybe-class-name":{color:"#9cdcfe"},escape:{color:"#d7ba7d"},"tag.punctuation":{color:"#808080"},cdata:{color:"#808080"},"attr-value":{color:"#ce9178"},"attr-value.punctuation":{color:"#ce9178"},"attr-value.punctuation.attr-equals":{color:"#d4d4d4"},namespace:{color:"#4ec9b0"},'pre[class*="language-javascript"]':{color:"#9cdcfe"},'code[class*="language-javascript"]':{color:"#9cdcfe"},'pre[class*="language-jsx"]':{color:"#9cdcfe"},'code[class*="language-jsx"]':{color:"#9cdcfe"},'pre[class*="language-typescript"]':{color:"#9cdcfe"},'code[class*="language-typescript"]':{color:"#9cdcfe"},'pre[class*="language-tsx"]':{color:"#9cdcfe"},'code[class*="language-tsx"]':{color:"#9cdcfe"},'pre[class*="language-css"]':{color:"#ce9178"},'code[class*="language-css"]':{color:"#ce9178"},'pre[class*="language-html"]':{color:"#d4d4d4"},'code[class*="language-html"]':{color:"#d4d4d4"},".language-regex .token.anchor":{color:"#dcdcaa"},".language-html .token.punctuation":{color:"#808080"},'pre[class*="language-"] > code[class*="language-"]':{position:"relative",zIndex:"1"},".line-highlight.line-highlight":{background:"#f7ebc6",boxShadow:"inset 5px 0 0 #f7d87c",zIndex:"0"}},Ab=g.lazy(()=>Un(()=>import("./MermaidRenderer-yw6DgH3b.js").then(r=>r.au),__vite__mapDeps([0,1,2,3,4,5])).then(r=>({default:r.MermaidRenderer}))),Cb=g.lazy(()=>Un(()=>import("./SVGRenderer-DfMpobkd.js"),__vite__mapDeps([6,1,3,5])).then(r=>({default:r.SVGRenderer}))),jb=g.lazy(()=>Un(()=>import("./ChartRenderer-Cbyse7LH.js"),__vite__mapDeps([7,1,5,4,8,9,10,11,12,13,14,2,15])).then(r=>({default:r.ChartRenderer}))),Nb=g.lazy(()=>Un(()=>import("./MusicRenderer-BSZsjBll.js"),__vite__mapDeps([16,2,1,5])).then(r=>({default:r.MusicRenderer}))),Tb=r=>{var c,d;if(!r)return typeof window<"u"&&((c=window.matchMedia)!=null&&c.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light";const l=r.closest(".markdown-content");if(l){if(l.classList.contains("dark"))return"dark";if(l.classList.contains("light"))return"light"}if(r.closest(".dark"))return"dark";if(r.closest(".light"))return"light";const i=r.closest("[data-theme]");if(i){const f=i.getAttribute("data-theme");if(f==="dark")return"dark";if(f==="light")return"light"}return typeof window<"u"&&((d=window.matchMedia)!=null&&d.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light"},Eb=(r,l)=>{const[i,c]=g.useState("light"),d=g.useRef("light");return g.useEffect(()=>{var v,b,w;if(l||typeof window>"u"||typeof document>"u")return;const f=()=>{const k=Tb(r.current);k!==d.current&&(d.current=k,c(k))};f();const h=((v=window.matchMedia)==null?void 0:v.call(window,"(prefers-color-scheme: dark)"))??null,p=()=>f();h==null||h.addEventListener("change",p);const x=typeof MutationObserver<"u"?new MutationObserver(()=>f()):null;if(x){const k=((w=(b=r.current)==null?void 0:b.closest)==null?void 0:w.call(b,".markdown-content"))??null;k&&x.observe(k,{attributes:!0,attributeFilter:["class","data-theme"]}),document.body&&x.observe(document.body,{attributes:!0,attributeFilter:["class","data-theme"]})}return()=>{h==null||h.removeEventListener("change",p),x==null||x.disconnect()}},[l,r]),l??i},Mb={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"tsx",sh:"bash",shell:"bash",shellsession:"bash",yml:"yaml",yaml:"yaml",py:"python",rb:"ruby",kt:"kotlin",md:"markdown",csharp:"csharp","c#":"csharp","c++":"cpp",tf:"hcl",terraform:"hcl",docker:"dockerfile",dotenv:"env",env:"env",plaintext:"text",text:"text"},zb=r=>{if(!r)return"";const l=r.match(/(?:^|\s)language-([^\s]+)/);if(!l)return"";const c=l[1].toLowerCase().split("{")[0].split("[")[0].split("<")[0].split(":")[0].trim().replace(/[^a-z0-9+#-]+$/g,"");return c?Mb[c]??c:""},Db=r=>Rn.Children.toArray(r).map(l=>typeof l=="string"||typeof l=="number"?String(l):"").join("").replace(/\n$/,""),xp=({code:r})=>{const[l,i]=g.useState(!1),c=async()=>{try{await navigator.clipboard.writeText(r),i(!0),setTimeout(()=>i(!1),2e3)}catch{const d=document.createElement("textarea");d.value=r,d.style.position="fixed",d.style.opacity="0",document.body.appendChild(d),d.select();try{document.execCommand("copy"),i(!0),setTimeout(()=>i(!1),2e3)}catch(f){console.error("Failed to copy code:",f)}document.body.removeChild(d)}};return u.jsxs("button",{className:"code-copy-button",onClick:c,title:l?"Copied!":"Copy code","aria-label":l?"Copied!":"Copy code to clipboard",children:[l?u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("path",{d:"M5.5 4.5H3.5C2.94772 4.5 2.5 4.94772 2.5 5.5V12.5C2.5 13.0523 2.94772 13.5 3.5 13.5H10.5C11.0523 13.5 11.5 13.0523 11.5 12.5V10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M6.5 2.5H12.5C13.0523 2.5 13.5 2.94772 13.5 3.5V9.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M9.5 6.5L13.5 2.5L9.5 2.5V6.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),u.jsx("span",{className:"code-copy-button-text",children:l?"Copied!":"Copy"})]})},Lb=({inline:r,className:l="",children:i,enableGraphs:c=!0,enableMermaid:d=!0,enableSVG:f=!0,enableCharts:h=!0,enableMusic:p=!0,enableSyntaxHighlighting:x=!0,syntaxTheme:v})=>{const b=g.useRef(null),w=Eb(b,v),k=u.jsx("div",{className:"markdown-code-block code-block-container",children:"Loading renderer..."});if(r)return u.jsx("code",{className:l,children:i});const S=zb(l),_=Db(i);if(h&&(S==="chart"||S==="chart-json"||S==="chart-table"))return u.jsx("div",{ref:b,children:u.jsx(g.Suspense,{fallback:k,children:u.jsx(jb,{code:_,language:S})})});if(p&&(S==="abc"||S==="music"))return u.jsx("div",{ref:b,children:u.jsx(g.Suspense,{fallback:k,children:u.jsx(Nb,{code:_})})});if(c){if(S==="mermaid"&&d)return u.jsx("div",{ref:b,children:u.jsx(g.Suspense,{fallback:k,children:u.jsx(Ab,{code:_})})});if(S==="svg"&&f)return u.jsx("div",{ref:b,children:u.jsx(g.Suspense,{fallback:k,children:u.jsx(Cb,{code:_})})})}if(x&&S){const A=w==="light"?kb:_b;return u.jsxs("div",{ref:b,className:"syntax-highlighted-wrapper code-block-container",children:[u.jsx(xp,{code:_}),u.jsx(vx,{language:S,style:A,customStyle:{margin:"12px 0",borderRadius:"6px",fontSize:"0.9em"},showLineNumbers:!1,children:_})]})}return u.jsxs("div",{ref:b,className:`markdown-code-block code-block-container ${l}`.trim(),children:[u.jsx(xp,{code:_}),u.jsx("pre",{style:{margin:0,padding:0,background:"transparent",border:"none"},children:u.jsx("code",{children:_})})]})},bp=new Set(["div","pre","blockquote","ul","ol","table","thead","tbody","tr","td","th","h1","h2","h3","h4","h5","h6","section","article","figure"]),Rb=({children:r,href:l="",className:i="",...c})=>{const d=Rn.Children.toArray(r).map(b=>typeof b=="string"?b:"").join("").trim(),f=/^https?:\/\//i.test(l),h=!!(f&&d&&yp(d)===yp(l)),p=f?Ub(l):null,x=!!(h&&p),v=["markdown-link",x?"markdown-link--card":"markdown-link--inline",i].filter(Boolean).join(" ");return u.jsxs("a",{...c,href:l,target:"_blank",rel:"noopener noreferrer",className:v,children:[u.jsx("span",{className:"markdown-link__content",children:x&&p?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"markdown-link__hostname",children:p.hostname}),p.path&&p.path!=="/"&&u.jsx("span",{className:"markdown-link__path",children:p.path})]}):r}),f&&u.jsx("span",{className:"markdown-link__icon","aria-hidden":"true",children:u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:"M8 16L16 8M16 8H9M16 8V15",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})})]})};function yp(r){return r.trim().replace(/\/$/,"")}function Ub(r){try{const l=new URL(r),i=l.hostname.replace(/^www\./i,""),c=`${l.pathname}${l.search}${l.hash}`||"/";return{hostname:i,path:c}}catch{return null}}const rl=({content:r,className:l="",disableMath:i=!1,enableGraphs:c=!0,enableMermaid:d=!0,enableSVG:f=!0,enableCharts:h=!0,enableMusic:p=!0,enableSyntaxHighlighting:x=!0,syntaxTheme:v="dark"})=>{const b=Sb(r);if(!b)return null;const w=i?[rp]:[rp,[bx,{singleDollarTextMath:!0}]],k=[];i||k.push([yx,{throwOnError:!1,errorColor:"#cc0000",strict:!1,trust:!0,macros:{"\\RR":"\\mathbb{R}","\\NN":"\\mathbb{N}","\\ZZ":"\\mathbb{Z}","\\QQ":"\\mathbb{Q}","\\CC":"\\mathbb{C}","\\dx":"\\,dx","\\dy":"\\,dy","\\dt":"\\,dt","\\dz":"\\,dz"}}]);const S={table:({children:_,...A})=>u.jsx("div",{style:{overflowX:"auto",WebkitOverflowScrolling:"touch"},children:u.jsx("table",{...A,children:_})}),a:Rb,code:_=>{const{className:A,children:D,...O}=_,ee=A&&/language-/.test(A),U="inline"in _&&typeof _.inline=="boolean"&&_.inline||!ee,z=ee;return u.jsx(Lb,{inline:U,className:A,enableGraphs:c,enableMermaid:d,enableSVG:f,enableCharts:h,enableMusic:p,enableSyntaxHighlighting:x,syntaxTheme:v,"data-block-code":z?"true":void 0,...O,children:D})},p:({node:_,...A})=>{var U;const O=Rn.Children.toArray(A.children).filter(z=>!(typeof z=="string"&&z.trim()==="")).some(z=>{if(!Rn.isValidElement(z))return!1;const H=z.props;return(H==null?void 0:H["data-block-code"])==="true"?!0:typeof z.type=="string"?bp.has(z.type):!1}),ee=(U=_==null?void 0:_.children)==null?void 0:U.some(z=>{var H;if(z.type==="code")return!0;if(z.type==="element"){if(z.tagName&&bp.has(z.tagName))return!0;if(z.tagName==="code"){const K=(H=z.properties)==null?void 0:H.className;return Array.isArray(K)?K.some(j=>typeof j=="string"&&j.startsWith("language-")):!0}}return!1});return O||ee?u.jsx(u.Fragment,{children:A.children}):u.jsx("p",{...A})}};return u.jsx("div",{className:`markdown-content ${l}`,children:u.jsx(xx,{remarkPlugins:w,rehypePlugins:k,components:S,children:b})})};var Ob={agentMode:{mode:"multi",defaultAdapterId:"chat-with-files"},application:{name:"ORBIT Chat",description:"Explore ideas with ORBIT's AI copilots, share context, and build together.",inputPlaceholder:"Message ORBIT...",settingsAboutMsg:"ORBIT Chat",locale:"en-US",favicon:null},seo:{includeSitemap:!1,siteUrl:"http://localhost:5173",exposeAgentNotes:!0},debug:{consoleDebug:!1},features:{enableUpload:!0,enableAudioOutput:!0,enableAudioInput:!0,enableFeedbackButtons:!0,enableConversationThreads:!0,enableAutocomplete:!0},voice:{silenceTimeoutMs:4e3,recognitionLanguage:""},outOfServiceMessage:null,limits:{files:{perConversation:5,maxSizeMB:50,totalFiles:100},conversations:{maxConversations:10,messagesPerConversation:1e3,messagesPerThread:1e3,totalMessages:1e4},messages:{maxLength:1e4}},guestLimits:{files:{perConversation:1,maxSizeMB:5,totalFiles:1},conversations:{maxConversations:2,messagesPerConversation:5,messagesPerThread:2,totalMessages:10},messages:{maxLength:500},rateLimit:{enabled:!0,windowMs:6e4,maxRequests:60,chat:{windowMs:6e4,maxRequests:10}}},auth:{enabled:!1,provider:"auth0"},header:{enabled:!1,logoUrl:"",logoUrlLight:"",logoUrlDark:"",logoHeight:"3.5rem",logoWidth:"auto",bgColor:"",textColor:"",showBorder:!1,navLinks:[{label:"Docs",url:"/"},{label:"About",url:"/about"}]},footer:{enabled:!0,text:"Copyright © 2025 Schmitech Inc.",bgColor:"",textColor:"",showBorder:!1,layout:"stacked",align:"center",topPadding:"large",navLinks:[{label:"Support",url:"/"},{label:"Privacy",url:"/about"}]},adapters:[{id:"simple-chat",name:"Simple AI Chat",apiUrl:"http://99.79.50.155:3000",description:"Basic chat interface using the default conversational agent (Similar to ChatGPT - no files).",inputPlaceholder:"Simple chat, ask anything..."},{id:"web-search",name:"Simple AI Chat (Web Search)",apiUrl:"http://99.79.50.155:3000",description:"Basic chat interface using the default conversational agent with web search supports.",inputPlaceholder:"Simple chat, ask anything..."},{id:"chat-with-files",name:"Simple AI Chat (Multimodal)",apiUrl:"http://99.79.50.155:3000",description:"Extract knowledge from PDF, Images, Word, etc. (Similar to ChatGPT Multimodal)",inputPlaceholder:"Files chat, ask anything..."},{id:"image-generator",name:"AI Image Generator",apiUrl:"http://99.79.50.155:3000",description:"Generate images from text descriptions using DALL-E 3 or Imagen 3.",inputPlaceholder:"Describe the image you want to create..."},{id:"video-generator",name:"AI Video Generator",apiUrl:"http://99.79.50.155:3000",description:"Generate videos from text descriptions.",inputPlaceholder:"Describe the video you want to create..."},{id:"qa-sql",name:"City FAQ Assistant (SQLite)",apiUrl:"http://99.79.50.155:3000",description:"Quick-test QA assistant over the sample city Q&A SQLite database.",inputPlaceholder:"Ask a city services question..."},{id:"qa-vector-chroma",name:"City FAQ Assistant (Chroma)",apiUrl:"http://99.79.50.155:3000",description:"Quick-test semantic QA assistant over the sample city Q&A Chroma collection.",inputPlaceholder:"Ask a city services question..."},{id:"hr-db-chatbot",name:"HR System Assistant",apiUrl:"http://99.79.50.155:3000",description:"HR database assistant: natural language queries over SQLite HR data via intent templates.",inputPlaceholder:"Ask HR questions..."},{id:"intent-sql-postgres",name:"Customer Orders Assistant",apiUrl:"http://99.79.50.155:3000",description:"Customer orders assistant: natural language queries over PostgreSQL customer orders data."},{id:"ecomm-analytics",name:"Business Analytics Assistant",apiUrl:"http://99.79.50.155:3000",description:"DuckDB analytics assistant: natural language analytics queries over the analytics demo. This agent is the perfect example of how to use something like OLAP to quickly discover insigths."},{id:"intent-http-jsonplaceholder",name:"REST API Chat",apiUrl:"http://99.79.50.155:3000",description:"Natural language queries over the fake REST API."},{id:"intent-http-paris-opendata",name:"City of Paris Chat",apiUrl:"http://99.79.50.155:3000",description:"Paris open data: events and activities (Que Faire à Paris) via natural language."},{id:"intent-mongodb-mflix",name:"Chat With Movies DB",apiUrl:"http://99.79.50.155:3000",description:"MFlix movies assistant: query the sample_mflix MongoDB database via intent templates."},{id:"intent-graphql-spacex",name:"GraphQL Chatbot",apiUrl:"http://99.79.50.155:3000",description:"SpaceX GraphQL assistant: natural language queries over the SpaceX API.",inputPlaceholder:"Ask SpaceX questions..."},{id:"audio-transcription",name:"Audio Transcription",apiUrl:"http://99.79.50.155:3000",description:"Audio Transcription Test.",inputPlaceholder:"Use the microphone for voice..."},{id:"voice-chat",name:"Voice Chat",apiUrl:"http://99.79.50.155:3000",description:"Voice chat adapter test.",inputPlaceholder:"Use the microphone for voice..."},{id:"real-time-voice-chat",name:"Real-Time Voice Chat",apiUrl:"http://99.79.50.155:3000",description:"Real-time voice chat adapter test (websocket).",inputPlaceholder:"Use the microphone for voice..."}]};const id="http://localhost:3000",$b="/favicon.svg",qb="/orbit-logo-light.png",Bb="/orbit-logo-dark.png",Hb={agentMode:{mode:"multi",defaultAdapterId:""},application:{name:"ORBIT Chat",description:"Explore ideas with ORBIT's AI copilots, share context, and build together.",inputPlaceholder:"Message ORBIT...",settingsAboutMsg:"ORBIT Chat",locale:"en-US",favicon:""},debug:{consoleDebug:!1},seo:{includeSitemap:!1,siteUrl:"",alternateSiteUrls:[],hostPatterns:[],exposeAgentNotes:!0},features:{enableUpload:!1,enableAudioOutput:!1,enableAudioInput:!1,enableFeedbackButtons:!1,enableConversationThreads:!0,enableAutocomplete:!1},voice:{silenceTimeoutMs:4e3,recognitionLanguage:""},outOfServiceMessage:null,limits:{files:{perConversation:5,maxSizeMB:50,totalFiles:100},conversations:{maxConversations:10,messagesPerConversation:1e3,messagesPerThread:1e3,totalMessages:1e4},messages:{maxLength:1e3}},guestLimits:{files:{perConversation:1,maxSizeMB:10,totalFiles:2},conversations:{maxConversations:1,messagesPerConversation:10,messagesPerThread:10,totalMessages:10},messages:{maxLength:500}},auth:{enabled:!1,provider:"auth0",domain:"",clientId:"",audience:"",tenantId:"",scopes:[]},header:{enabled:!1,logoUrl:"",logoUrlLight:"",logoUrlDark:"",logoHeight:"",logoWidth:"",bgColor:"",textColor:"",showBorder:!0,navLinks:[]},footer:{enabled:!1,text:"",bgColor:"",textColor:"",showBorder:!1,layout:"stacked",align:"center",topPadding:"large",navLinks:[]},startupScripts:[],adapters:[]};function So(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function od(r,l){if(!So(r)||!So(l))return l;const i={...r};return Object.keys(l).forEach(c=>{if(c==="__proto__"||c==="constructor"||c==="prototype")return;const d=i[c],f=l[c];So(d)&&So(f)?i[c]=od(d,f):f!==void 0&&(i[c]=f)}),i}function Fb(r){if(typeof r!="string")return null;const l=r.trim();if(!l)return null;const i=l.toLowerCase();return i==="false"||i==="0"||i==="off"||i==="disabled"?null:l}function Ib(r){return r==="single"?"single":"multi"}function Gb(r){const l=r.trim();if(l.startsWith("["))try{const i=JSON.parse(l);return Array.isArray(i)?i.filter(Boolean):[]}catch{return[]}return l.split(/\s+/).filter(Boolean)}function Vb(){const r=Ob||{},l=typeof window<"u"&&window.ORBIT_CHAT_CONFIG||{},i=!!(typeof window<"u"&&window.ORBIT_CHAT_CONFIG);let c=od(Hb,r);return c=od(c,l),(!i||!c.auth.domain)&&(c.auth.domain="dev-3c4dpzhecz4gundm.us.auth0.com"),(!i||!c.auth.clientId)&&(c.auth.clientId="9JSe5xtoi5mLXRuov2K7FHYU10ojCQLH"),!i||c.auth.audience,!i||c.auth.provider,!i||c.auth.tenantId,(!i||c.auth.scopes.length===0)&&(c.auth.scopes=Gb("openid profile email User.Read")),c.outOfServiceMessage=Fb(c.outOfServiceMessage),c.agentMode.mode=Ib(c.agentMode.mode),c.agentMode.defaultAdapterId=typeof c.agentMode.defaultAdapterId=="string"?c.agentMode.defaultAdapterId.trim():"",c}const Se=Vb();function kt(){var l;const r=Se.adapters;if(Array.isArray(r)&&r.length>0){const i=(l=r[0].apiUrl)==null?void 0:l.trim();if(i)return i}return id}function Ta(r){const l=r==null?void 0:r.trim();return l&&l.length>0?l:kt()}function Xb(){const r=Se.adapters;return Array.isArray(r)&&r.length>0?r[0].id:"default-key"}function Yb(){return Se.agentMode.mode}function Xo(){return Yb()==="single"}function Sd(){if(!Xo())return null;const r=Se.agentMode.defaultAdapterId;return r&&Se.adapters.some(i=>{var c;return((c=i==null?void 0:i.id)==null?void 0:c.trim())===r})?r:null}function kd(){return Se.application.name}function _d(){return Se.application.description}function og(){return Se.application.inputPlaceholder}function Qb(r){var d;const l=r==null?void 0:r.trim();if(!l)return null;const i=Se.adapters.find(f=>{var h;return((h=f==null?void 0:f.id)==null?void 0:h.trim())===l});return((d=i==null?void 0:i.name)==null?void 0:d.trim())||null}function Zb(r){var d;const l=r==null?void 0:r.trim();if(!l)return null;const i=Se.adapters.find(f=>{var h;return((h=f==null?void 0:f.id)==null?void 0:h.trim())===l});return((d=i==null?void 0:i.inputPlaceholder)==null?void 0:d.trim())||null}function cg(){return Se.seo.siteUrl.trim()}function Kb(){return Array.isArray(Se.seo.alternateSiteUrls)?Se.seo.alternateSiteUrls.filter(r=>typeof r=="string").map(r=>r.trim()).filter(Boolean):[]}function Jb(){return Array.isArray(Se.seo.hostPatterns)?Se.seo.hostPatterns.filter(r=>typeof r=="string").map(r=>r.trim()).filter(Boolean):[]}function Pb(){return Se.seo.exposeAgentNotes}function Wb(){var l;return((l=Se.application.favicon)==null?void 0:l.trim())||$b}function ey(){return Se.features.enableUpload}function ty(){return Se.features.enableAudioOutput}function ay(){return Se.features.enableAudioInput}function vp(){return Se.features.enableFeedbackButtons}function ny(){return Se.features.enableConversationThreads}function ug(){return Se.features.enableAutocomplete}function ly(){return Math.max(1e3,Se.voice.silenceTimeoutMs)}function ry(){return Se.voice.recognitionLanguage}function sy(){const r=Sd();if(r)return r;const l=Se.adapters;if(Array.isArray(l)&&l.length>0)for(const i of l){const c=typeof(i==null?void 0:i.id)=="string"?i.id.trim():"";if(c)return c}return null}function iy(){return Se.outOfServiceMessage}function Ad(){return Se.auth.enabled}function Ea(){const{enabled:r,provider:l,domain:i,clientId:c,tenantId:d}=Se.auth;return!r||!c?!1:l==="entra"?!!d:!!i}function oy(){return Se.auth.domain}function dg(){return Se.auth.clientId}function cy(){return Se.auth.audience}function Yo(){return Se.auth.provider}function uy(){return Se.auth.tenantId}function Cd(){const r=Se.auth.scopes;return r.length>0?r:["openid","profile","email"]}function cd(){return Se.header.enabled}function dy(){return Se.header.logoUrl}function fy(){var l;return((l=Se.header.logoUrlLight)==null?void 0:l.trim())||qb}function my(){var l;return((l=Se.header.logoUrlDark)==null?void 0:l.trim())||Bb}function hy(){var r;return((r=Se.header.logoHeight)==null?void 0:r.trim())||""}function py(){var r;return((r=Se.header.logoWidth)==null?void 0:r.trim())||""}function gy(){return Se.header.bgColor}function xy(){return Se.header.textColor}function by(){return Se.header.showBorder}function fg(r){if(Array.isArray(r))return r;if(typeof r=="string")try{const l=JSON.parse(r);return Array.isArray(l)?l:[]}catch{return[]}return[]}function mg(){return fg(Se.header.navLinks)}function hg(){return Se.footer.enabled}function yy(){return Se.footer.text}function vy(){return Se.footer.bgColor}function wy(){return Se.footer.textColor}function Sy(){return Se.footer.showBorder}function ky(){return Se.footer.layout==="inline"?"inline":"stacked"}function _y(){return Se.footer.topPadding==="normal"?"normal":"large"}function Ay(){const r=Se.startupScripts;return Array.isArray(r)?r.filter(l=>!!(l&&typeof l=="object")).map(l=>{const i=typeof l.src=="string"?l.src.trim():"",c=typeof l.content=="string"?l.content.trim():"",d=typeof l.id=="string"?l.id.trim():"";return{...l,src:i||void 0,content:c||void 0,id:d||void 0}}).filter(l=>!!(l.src||l.content)):[]}function Cy(){return fg(Se.footer.navLinks)}const jd=()=>Se.debug.consoleDebug,ne=(...r)=>{jd()&&console.log(...r)},Fe=(...r)=>{jd()&&console.warn(...r)},Ie=(...r)=>{jd()&&console.error(...r)},Mt=(...r)=>{console.error(...r)};function wp({audio:r,audioFormat:l="mp3",autoPlay:i=!1,maxSizeMB:c=10}){const d=g.useRef(null),[f,h]=g.useState(!1),[p,x]=g.useState(0),[v,b]=g.useState(0),[w,k]=g.useState(!0),[S,_]=g.useState(null),[A,D]=g.useState(null);g.useEffect(()=>{if(!r)return;let V=null,I=!0;return(async()=>{try{k(!0),_(null),D(null);const _e=r.length*3/4/(1024*1024);if(_e>c)throw new Error(`Audio file too large (${_e.toFixed(1)}MB > ${c}MB limit)`);if(_e>2&&(D(`Large audio file (${_e.toFixed(1)}MB) - may take time to load`),ne("[AudioPlayer] Large audio file detected",{sizeMB:_e.toFixed(2)})),!/^[A-Za-z0-9+/=]+$/.test(r.replace(/\s/g,"")))throw new Error("Invalid base64 audio data");const te=atob(r),oe=new Uint8Array(te.length);for(let B=0;B<te.length;B++)oe[B]=te.charCodeAt(B);const E=l==="mp3"?"audio/mpeg":l==="wav"?"audio/wav":l==="ogg"?"audio/ogg":l==="opus"?"audio/opus":l==="webm"?"audio/webm":`audio/${l}`,Y=new Blob([oe],{type:E});if(V=URL.createObjectURL(Y),!I||!d.current){V&&URL.revokeObjectURL(V);return}d.current.src=V,k(!1),ne("[AudioPlayer] Audio loaded successfully",{format:l,mimeType:E,size:Y.size}),i&&d.current&&d.current.play().catch(B=>{Ie("[AudioPlayer] Auto-play failed:",B)})}catch(ue){Ie("[AudioPlayer] Failed to load audio:",ue),I&&(_("Failed to load audio"),k(!1))}})(),()=>{I=!1,V&&URL.revokeObjectURL(V)}},[r,l,i,c]);const O=()=>{d.current&&x(d.current.duration)},ee=()=>{d.current&&b(d.current.currentTime)},U=()=>h(!0),z=()=>h(!1),H=()=>{h(!1),b(0)},K=()=>{d.current&&(f?d.current.pause():d.current.play().catch(V=>{Ie("[AudioPlayer] Playback failed:",V),_("Playback failed")}))},j=V=>{if(!d.current)return;const I=parseFloat(V.target.value);d.current.currentTime=I,b(I)},q=V=>{if(!isFinite(V))return"0:00";const I=Math.floor(V/60),P=Math.floor(V%60);return`${I}:${P.toString().padStart(2,"0")}`};return S?u.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-700 dark:bg-red-900/20 dark:text-red-400",children:[u.jsx($o,{className:"h-4 w-4"}),u.jsx("span",{children:S})]}):u.jsxs("div",{className:"mt-3 flex flex-col gap-1",children:[A&&u.jsxs("div",{className:"text-xs text-amber-600 dark:text-amber-400 px-1",children:["⚠️ ",A]}),u.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-gray-300 bg-white px-3 py-2 dark:border-[#4a4b54] dark:bg-[#343541]",children:[u.jsx("audio",{ref:d,onLoadedMetadata:O,onTimeUpdate:ee,onPlay:U,onPause:z,onEnded:H}),u.jsx("button",{onClick:K,disabled:w,className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 disabled:opacity-50 dark:bg-[#4a4b54] dark:hover:bg-[#565869]",title:f?"Pause":"Play","aria-label":f?"Pause audio":"Play audio",children:w?u.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-gray-400 border-t-transparent"}):f?u.jsx(Wx,{className:"h-4 w-4 text-gray-700 dark:text-[#ececf1]"}):u.jsx(eb,{className:"h-4 w-4 text-gray-700 dark:text-[#ececf1]"})}),u.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[u.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:q(v)}),u.jsx("input",{type:"range",min:"0",max:p||0,value:v,onChange:j,disabled:w||!p,className:"flex-1 cursor-pointer accent-gray-600 dark:accent-[#bfc2cd]",style:{background:p?`linear-gradient(to right, rgb(75 85 99) 0%, rgb(75 85 99) ${v/p*100}%, rgb(229 231 235) ${v/p*100}%, rgb(229 231 235) 100%)`:"rgb(229 231 235)"}}),u.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:q(p)})]}),u.jsx($o,{className:"h-4 w-4 text-gray-500 dark:text-[#bfc2cd]"})]})]})}var Qo=Pp();function Sp({image:r,imageUrl:l,imageFormat:i="png",revisedPrompt:c}){const[d,f]=g.useState(!1),[h,p]=g.useState(!1),[x,v]=g.useState(null),b=g.useRef(null);g.useEffect(()=>{if(r||!l)return;let _=!1;return(async()=>{try{const A=typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null,D=await fetch(l,{headers:A?{"X-Adapter-Name":A}:{}});if(!D.ok){console.warn("[ImageDisplay] Server returned",D.status,"for",l);return}if(_)return;const O=await D.arrayBuffer();if(_)return;const ee=new Blob([O],{type:`image/${i}`}),U=URL.createObjectURL(ee);b.current=U,v(U)}catch(A){console.warn("[ImageDisplay] Failed to fetch image from",l,A)}})(),()=>{_=!0,b.current&&(URL.revokeObjectURL(b.current),b.current=null)}},[l,r,i]);const k=(r?`data:image/${i};base64,${r}`:null)??x;g.useEffect(()=>{if(!d)return;const _=A=>{A.key==="Escape"&&f(!1)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[d]);const S=_=>{if(_.stopPropagation(),!k)return;const A=document.createElement("a");A.href=k,A.download=`generated-image.${i}`,A.click()};return k?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"generated-image-wrapper",style:{marginTop:"0.75rem"},children:[u.jsxs("div",{className:"generated-image-container",style:{position:"relative",display:"inline-block",cursor:"zoom-in",maxWidth:"100%"},onClick:()=>f(!0),title:c||"Generated image — click to enlarge",children:[u.jsx("img",{src:k,alt:c||"Generated image",style:{maxWidth:"100%",maxHeight:"480px",borderRadius:"8px",display:"block",objectFit:"contain"}}),u.jsxs("div",{style:{position:"absolute",bottom:"8px",right:"8px",display:"flex",gap:"6px"},children:[u.jsx("button",{onClick:S,title:"Download image",style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(bd,{size:14})}),u.jsx("button",{onClick:_=>{_.stopPropagation(),f(!0)},title:"View full size",style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(db,{size:14})})]})]}),c&&u.jsxs("div",{style:{marginTop:"8px",maxWidth:"480px"},children:[u.jsxs("button",{type:"button",onClick:()=>p(_=>!_),style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:0,background:"transparent",border:"none",cursor:"pointer",fontSize:"0.75rem",fontWeight:500,opacity:.72},"aria-expanded":h,children:[h?u.jsx(Oo,{size:14}):u.jsx(fi,{size:14}),h?"Hide prompt":"Show prompt"]}),h&&u.jsxs("div",{style:{marginTop:"8px",padding:"8px 10px",background:"rgba(128,128,128,0.08)",borderRadius:"6px"},children:[u.jsx("span",{style:{display:"block",fontSize:"0.65rem",fontWeight:600,opacity:.5,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:"3px"},children:"Prompt"}),u.jsx("span",{style:{fontSize:"0.8rem",lineHeight:1.45,opacity:.85},children:c})]})]})]}),d&&typeof document<"u"&&Qo.createPortal(u.jsxs("div",{onClick:()=>f(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.85)",zIndex:9999,overflow:"auto",padding:"56px 24px 24px"},children:[u.jsx("button",{onClick:_=>{_.stopPropagation(),f(!1)},style:{position:"fixed",top:"16px",right:"16px",background:"rgba(255,255,255,0.15)",border:"none",borderRadius:"50%",padding:"8px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(ba,{size:20})}),u.jsx("img",{src:k,alt:c||"Generated image",style:{display:"block",width:"auto",height:"auto",maxWidth:"calc(100vw - 48px)",maxHeight:"calc(100vh - 80px)",objectFit:"contain",borderRadius:"8px",margin:"0 auto"},onClick:_=>_.stopPropagation()})]}),document.body)]}):null}const Wu=[750,1500,3e3,5e3],jy=new Set([403,404,409,425,429,500,502,503,504]),Ny=r=>new Promise(l=>setTimeout(l,r));function kp({video:r,videoUrl:l,videoFormat:i="mp4",revisedPrompt:c,adapterName:d}){const[f,h]=g.useState(!1),[p,x]=g.useState(!1),[v,b]=g.useState(null),w=g.useRef(null);g.useEffect(()=>{if(r||!l)return;let A=!1;return(async()=>{try{const D=d||(typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null);let O=null;for(let H=0;H<=Wu.length&&(O=await fetch(l,{headers:D?{"X-Adapter-Name":D}:{}}),!(O.ok||!jy.has(O.status)||H===Wu.length));H+=1)if(await Ny(Wu[H]),A)return;if(!(O!=null&&O.ok)){console.warn("[VideoDisplay] Server returned",O.status,"for",l);return}if(A)return;const ee=await O.arrayBuffer();if(A)return;const U=new Blob([ee],{type:`video/${i}`}),z=URL.createObjectURL(U);w.current=z,b(z)}catch(D){console.warn("[VideoDisplay] Failed to fetch video from",l,D)}})(),()=>{A=!0,w.current&&(URL.revokeObjectURL(w.current),w.current=null)}},[l,r,i,d]);const S=(r?`data:video/${i};base64,${r}`:null)??v;g.useEffect(()=>{if(!f)return;const A=D=>{D.key==="Escape"&&h(!1)};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[f]);const _=A=>{if(A.stopPropagation(),!S)return;const D=document.createElement("a");D.href=S,D.download=`generated-video.${i}`,D.click()};return S?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"generated-video-wrapper",style:{marginTop:"0.75rem"},children:[u.jsxs("div",{style:{position:"relative",display:"inline-block",maxWidth:"100%"},children:[u.jsx("video",{src:S,controls:!0,style:{maxWidth:"100%",maxHeight:"480px",borderRadius:"8px",display:"block",backgroundColor:"#000"}}),u.jsxs("div",{style:{position:"absolute",bottom:"48px",right:"8px",display:"flex",gap:"6px"},children:[u.jsx("button",{onClick:_,title:"Download video",style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(bd,{size:14})}),u.jsx("button",{onClick:A=>{A.stopPropagation(),h(!0)},title:"View full size",style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(Ix,{size:14})})]})]}),c&&u.jsxs("div",{style:{marginTop:"8px",maxWidth:"480px"},children:[u.jsxs("button",{type:"button",onClick:()=>x(A=>!A),style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:0,background:"transparent",border:"none",cursor:"pointer",fontSize:"0.75rem",fontWeight:500,opacity:.72},"aria-expanded":p,children:[p?u.jsx(Oo,{size:14}):u.jsx(fi,{size:14}),p?"Hide prompt":"Show prompt"]}),p&&u.jsxs("div",{style:{marginTop:"8px",padding:"8px 10px",background:"rgba(128,128,128,0.08)",borderRadius:"6px"},children:[u.jsx("span",{style:{display:"block",fontSize:"0.65rem",fontWeight:600,opacity:.5,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:"3px"},children:"Prompt"}),u.jsx("span",{style:{fontSize:"0.8rem",lineHeight:1.45,opacity:.85},children:c})]})]})]}),f&&u.jsxs("div",{onClick:()=>h(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.9)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center"},children:[u.jsx("button",{onClick:A=>{A.stopPropagation(),h(!1)},style:{position:"fixed",top:"16px",right:"16px",background:"rgba(255,255,255,0.15)",border:"none",borderRadius:"50%",padding:"8px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(ba,{size:20})}),u.jsx("video",{src:S,controls:!0,autoPlay:!0,style:{maxWidth:"92vw",maxHeight:"92vh",borderRadius:"8px"},onClick:A=>A.stopPropagation()})]})]}):null}let qo=null;function pg(r){qo=r}function Zo(){qo=null}async function Nd(){if(!qo)return null;try{return await qo()}catch{return null}}let ud=!1,ci=null;const dd=new Set;function gg(){dd.forEach(r=>r())}function vn(){return ud}function Ty(){return ci}function Ko(r){ud!==r&&(ud=r,!r&&ci!==null&&(ci=null),gg())}function os(r){const l=typeof r=="string"&&r.trim().length>0?r.trim():null;ci!==l&&(ci=l,gg())}function Ey(r){return dd.add(r),()=>{dd.delete(r)}}const _p="orbitchat-guest-user-id";function ko(r){if(typeof r!="string")return null;const l=r.trim();return l.length>0?l:null}function My(r){const l=r.split(".");if(l.length<2)return null;try{const i=l[1].replace(/-/g,"+").replace(/_/g,"/"),c=i.padEnd(Math.ceil(i.length/4)*4,"="),d=atob(c);return JSON.parse(d)}catch{return null}}function zy(){const r=globalThis.crypto;if(r&&typeof r.randomUUID=="function")return`guest:orbitchat:${r.randomUUID()}`;if(!r||typeof r.getRandomValues!="function")throw new Error("Secure random number generation is unavailable");const l=new Uint8Array(16);return r.getRandomValues(l),`guest:orbitchat:${Array.from(l,c=>c.toString(16).padStart(2,"0")).join("")}`}function Dy(){if(typeof window>"u")return"guest:orbitchat:server";const r=window.localStorage.getItem(_p);if(r&&r.trim().length>0)return r;const l=zy();return window.localStorage.setItem(_p,l),l}async function xg(){const r=Ty();if(r)return r;const l=await Nd();if(l){const i=My(l),c=ko(i==null?void 0:i.sub)||ko(i==null?void 0:i.user_id)||ko(i==null?void 0:i.preferred_username)||ko(i==null?void 0:i.email);if(c)return c}return vn()?"authenticated:orbitchat:unknown":Dy()}const Ly={pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",md:"text/markdown",csv:"text/csv"},Ap={pdf:"PDF",docx:"Word document",xlsx:"Excel workbook",pptx:"PowerPoint deck",md:"Markdown document",csv:"CSV file"},Ro=/[\uE000-\uF8FF]|\\[eE][0-9a-fA-F]{2,3}|\\[fF][0-8][0-9a-fA-F]{2,3}/,Ry=/((?:p\.)?generated-docx-preview-num-\d+-\d+:before\s*\{[^}]*?)content\s*:\s*"([^"]*)"\s*;([^}]*?\})/g;function Uy(r){var i;return Ro.test(r)?`•${((i=r.match(/(?:\\9|\t|\u00A0| )+$/))==null?void 0:i[0])||"\\9"}`:null}function Cp(r){Array.from(r.querySelectorAll("style")).forEach(c=>{const d=c.textContent;!d||!Ro.test(d)||(c.textContent=d.replace(Ry,(f,h,p,x)=>{const v=Uy(p);if(!v)return f;const b=x.replace(/\s*font-family\s*:\s*[^;{}]+;?/gi,"");return`${h}content: "${v}";${b}`}))}),Array.from(r.querySelectorAll('span[style*="font-family"]')).forEach(c=>{if(!/\b(symbol|wingdings|webdings)\b/i.test(c.style.fontFamily))return;const d=c.textContent||"";Ro.test(d)&&(c.textContent=d.replace(Ro,"•"),c.style.fontFamily="")})}function Oy(r){return(r||"pdf").toLowerCase().replace(/^\./,"")||"pdf"}function $y(r){const l=window.atob(r),i=new Uint8Array(l.length);for(let c=0;c<l.length;c+=1)i[c]=l.charCodeAt(c);return i.buffer}function qy(r){return r==="xlsx"||r==="csv"?u.jsx($x,{className:"h-5 w-5"}):r==="pptx"?u.jsx(ab,{className:"h-5 w-5"}):r==="md"?u.jsx(Ox,{className:"h-5 w-5"}):u.jsx(qx,{className:"h-5 w-5"})}function jp({document:r,documentUrl:l,documentFormat:i="pdf",revisedPrompt:c,adapterName:d}){const f=Oy(i),[h,p]=g.useState(r||l?"loading":"idle"),[x,v]=g.useState(null),[b,w]=g.useState(null),[k,S]=g.useState([]),[_,A]=g.useState(""),[D,O]=g.useState(null),[ee,U]=g.useState([]),[z,H]=g.useState(0),[K,j]=g.useState(!1),[q,V]=g.useState(null),I=g.useRef(null),P=g.useRef(null),ue=g.useRef(null),_e=c||Ap[f]||"Generated document",te=g.useMemo(()=>`generated-document.${f}`,[f]),oe=Ly[f]||"application/octet-stream";g.useEffect(()=>{if(!r&&!l)return;let re=!1;return(async()=>{p("loading"),V(null),S([]),A(""),O(null),U([]),H(0);try{const ge=r?$y(r):await(async()=>{const me=(d==null?void 0:d.trim())||(typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null),de={"X-User-ID":await xg()};me&&(de["X-Adapter-Name"]=me);const fe=await Nd();fe&&(de.Authorization=`Bearer ${fe}`);const ye=await fetch(l,{headers:de});if(!ye.ok)throw new Error(`Server returned ${ye.status}`);return ye.arrayBuffer()})();if(re)return;const pe=new Blob([ge],{type:oe}),G=URL.createObjectURL(pe);if(I.current&&URL.revokeObjectURL(I.current),I.current=G,v(G),w(ge.slice(0)),f==="xlsx"){const{default:me}=await Un(async()=>{const{default:ye}=await import("./index-CZz_ECqk.js");return{default:ye}},[]),fe=(await me(pe))[0];A((fe==null?void 0:fe.sheet)||"First sheet"),S(((fe==null?void 0:fe.data)||[]).slice(0,100).map(ye=>ye.slice(0,30).map(ae=>ae==null?"":String(ae))))}if(f==="md"&&O(new TextDecoder("utf-8").decode(ge)),f==="csv"){const me=new TextDecoder("utf-8").decode(ge),{default:de}=await Un(async()=>{const{default:ye}=await import("./papaparse.min-BWA-Odol.js").then(ae=>ae.p);return{default:ye}},__vite__mapDeps([17,1])),fe=de.parse(me,{skipEmptyLines:!0});H(fe.data.length),U(fe.data.slice(0,25))}p("ready")}catch(ge){if(re)return;console.warn("[DocumentDisplay] Failed to load document from",l,ge),V(ge instanceof Error?ge.message:"Unable to load document"),p("error")}})(),()=>{re=!0,I.current&&(URL.revokeObjectURL(I.current),I.current=null)}},[d,r,l,f,oe]),g.useEffect(()=>{if(h!=="ready"||f!=="docx"||!b||!P.current)return;const re=P.current;re.replaceChildren(),Un(()=>import("./docx-preview-CMb3nQfR.js"),__vite__mapDeps([18,1])).then(async({renderAsync:ce})=>{await ce(b.slice(0),re,void 0,{className:"generated-docx-preview",inWrapper:!1,ignoreWidth:!0,ignoreHeight:!0}),Cp(re)}).catch(ce=>{console.warn("[DocumentDisplay] Failed to render DOCX preview",ce),V("Unable to render document preview")})},[b,f,h]),g.useEffect(()=>{if(!K||f!=="docx"||!b||!ue.current)return;const re=ue.current;re.replaceChildren(),Un(()=>import("./docx-preview-CMb3nQfR.js"),__vite__mapDeps([18,1])).then(async({renderAsync:ce})=>{await ce(b.slice(0),re,void 0,{className:"generated-docx-preview",inWrapper:!1,ignoreWidth:!0,ignoreHeight:!0}),Cp(re)}).catch(ce=>{console.warn("[DocumentDisplay] Failed to render modal DOCX preview",ce)})},[b,f,K]),g.useEffect(()=>{if(!K)return;const re=ce=>{ce.key==="Escape"&&j(!1)};return window.document.addEventListener("keydown",re),()=>window.document.removeEventListener("keydown",re)},[K]);const E=re=>{if(re==null||re.stopPropagation(),!x)return;const ce=window.document.createElement("a");ce.href=x,ce.download=te,ce.click()},Y=h==="ready"&&(f==="pdf"||f==="docx"||f==="xlsx"||f==="md"||f==="csv"),B=Y&&f!=="xlsx"&&f!=="csv";return h==="idle"?null:u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"mt-3 max-w-full overflow-hidden rounded-lg border border-gray-200 bg-white shadow-sm dark:border-[#3b3c49] dark:bg-[#202123]",children:[u.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-100 px-3 py-2.5 dark:border-[#3b3c49]",children:[u.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-blue-50 text-blue-600 dark:bg-blue-500/10 dark:text-blue-300",children:qy(f)}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"truncate text-sm font-medium text-[#353740] dark:text-[#ececf1]",children:_e}),u.jsxs("p",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:[Ap[f]||`${f.toUpperCase()} document`,h==="loading"?" · Loading preview...":"",h==="error"?` · ${q||"Preview unavailable"}`:""]})]}),B&&u.jsx("button",{type:"button",onClick:()=>j(!0),className:"rounded-md p-2 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-[#bfc2cd] dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]",title:"Open preview","aria-label":"Open preview",children:u.jsx(Ux,{className:"h-4 w-4"})}),u.jsx("button",{type:"button",onClick:E,disabled:!x,className:"rounded-md p-2 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 disabled:cursor-not-allowed disabled:opacity-50 dark:text-[#bfc2cd] dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]",title:"Download document","aria-label":"Download document",children:u.jsx(bd,{className:"h-4 w-4"})})]}),Y&&u.jsxs("div",{className:"max-h-[460px] overflow-auto bg-gray-50 dark:bg-[#171717]",children:[f==="pdf"&&x&&u.jsx("iframe",{src:x,title:_e,className:"block h-[460px] w-full border-0 bg-white"}),f==="docx"&&u.jsx("div",{ref:P,className:"min-h-[240px] bg-white p-5 text-sm text-[#111827] dark:bg-white dark:text-[#111827]"}),f==="xlsx"&&u.jsxs("div",{className:"p-3",children:[_&&u.jsx("p",{className:"mb-2 text-xs font-medium text-gray-500 dark:text-[#bfc2cd]",children:_}),u.jsx("div",{className:"overflow-auto rounded-md border border-gray-200 bg-white dark:border-[#3b3c49] dark:bg-[#202123]",children:u.jsx("table",{className:"min-w-full border-collapse text-left text-xs",children:u.jsx("tbody",{children:k.length>0?k.map((re,ce)=>u.jsx("tr",{className:ce===0?"bg-gray-50 font-medium dark:bg-white/5":void 0,children:re.map((ge,pe)=>u.jsx("td",{className:"max-w-[220px] truncate border-b border-r border-gray-100 px-2 py-1.5 text-[#353740] dark:border-[#3b3c49] dark:text-[#ececf1]",children:ge},pe))},ce)):u.jsx("tr",{children:u.jsx("td",{className:"px-3 py-4 text-sm text-gray-500 dark:text-[#bfc2cd]",children:"No sheet data found."})})})})})]}),f==="md"&&D!==null&&u.jsx("div",{className:"bg-white p-5 text-sm text-[#111827] dark:bg-[#171717] dark:text-[#ececf1]",children:u.jsx(rl,{content:D,disableMath:!0})}),f==="csv"&&u.jsxs("div",{className:"p-3",children:[z>25&&u.jsxs("p",{className:"mb-2 text-xs text-gray-500 dark:text-[#bfc2cd]",children:["Showing first 25 of ",z," rows — download for the full file."]}),u.jsx("div",{className:"overflow-auto rounded-md border border-gray-200 bg-white dark:border-[#3b3c49] dark:bg-[#202123]",children:u.jsx("table",{className:"min-w-full border-collapse text-left text-xs",children:u.jsx("tbody",{children:ee.length>0?ee.map((re,ce)=>u.jsx("tr",{className:ce===0?"bg-gray-50 font-medium dark:bg-white/5":void 0,children:re.map((ge,pe)=>u.jsx("td",{className:"max-w-[220px] truncate border-b border-r border-gray-100 px-2 py-1.5 text-[#353740] dark:border-[#3b3c49] dark:text-[#ececf1]",children:ge},pe))},ce)):u.jsx("tr",{children:u.jsx("td",{className:"px-3 py-4 text-sm text-gray-500 dark:text-[#bfc2cd]",children:"No data found."})})})})})]})]}),h==="ready"&&!Y&&u.jsx("div",{className:"px-3 py-4 text-sm text-gray-600 dark:text-[#bfc2cd]",children:"Preview is not available for this format. Use download to open it locally."})]}),K&&x&&u.jsxs("div",{onClick:()=>j(!1),className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/85 p-4",children:[u.jsx("button",{onClick:re=>{re.stopPropagation(),j(!1)},className:"fixed right-4 top-4 flex items-center rounded-full border-0 bg-white/15 p-2 text-white",title:"Close preview","aria-label":"Close preview",children:u.jsx(ba,{className:"h-5 w-5"})}),u.jsxs("div",{onClick:re=>re.stopPropagation(),className:"h-[92vh] w-[92vw] overflow-auto rounded-lg bg-white",children:[f==="pdf"&&u.jsx("iframe",{src:x,title:_e,className:"h-full w-full border-0"}),f==="docx"&&u.jsx("div",{ref:ue,className:"min-h-full bg-white p-8 text-[#111827]"}),f==="md"&&D!==null&&u.jsx("div",{className:"min-h-full bg-white p-8 text-sm text-[#111827]",children:u.jsx(rl,{content:D,disableMath:!0})})]})]})]})}const By=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(",");function ui(r,{enabled:l,onEscape:i}){g.useEffect(()=>{if(!l||!r.current)return;const c=r.current,d=document.activeElement,f=Array.from(c.querySelectorAll(By)).filter(v=>v.tabIndex!==-1),h=f[0]||c,p=f[f.length-1]||c;h.focus({preventScroll:!0});const x=v=>{if(v.key==="Escape"){i==null||i();return}if(v.key!=="Tab")return;if(f.length===0){v.preventDefault(),c.focus({preventScroll:!0});return}const b=document.activeElement;if(v.shiftKey){(!b||b===h||!c.contains(b))&&(v.preventDefault(),p.focus({preventScroll:!0}));return}(!b||b===p||!c.contains(b))&&(v.preventDefault(),h.focus({preventScroll:!0}))};return document.addEventListener("keydown",x),()=>{var v;document.removeEventListener("keydown",x),(v=d==null?void 0:d.focus)==null||v.call(d,{preventScroll:!0})}},[l,i,r])}function Bo({isOpen:r,onClose:l,onConfirm:i,title:c,message:d,confirmText:f="Confirm",cancelText:h="Cancel",type:p="danger",isLoading:x=!1}){const v=g.useRef(null);if(ui(v,{enabled:r,onEscape:l}),!r)return null;const b=()=>{x||i()},k=(()=>{switch(p){case"danger":return{icon:"text-red-500",iconBg:"bg-red-100 dark:bg-red-900/20",confirmButton:"bg-red-600 hover:bg-red-700 focus:ring-red-500",border:"border-red-200 dark:border-red-800"};case"warning":return{icon:"text-amber-500",iconBg:"bg-amber-100 dark:bg-amber-900/20",confirmButton:"bg-amber-600 hover:bg-amber-700 focus:ring-amber-500",border:"border-amber-200 dark:border-amber-800"};default:return{icon:"text-blue-500",iconBg:"bg-blue-100 dark:bg-blue-900/20",confirmButton:"bg-blue-600 hover:bg-blue-700 focus:ring-blue-500",border:"border-blue-200 dark:border-blue-800"}}})(),S=u.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center overflow-y-auto bg-black/60 p-4 backdrop-blur-sm animate-fadeIn",children:u.jsxs("div",{ref:v,role:"dialog","aria-modal":"true","aria-labelledby":"confirm-title",tabIndex:-1,className:"w-full max-w-md max-h-[calc(100vh-2rem)] overflow-y-auto rounded-2xl bg-white shadow-2xl transform animate-fadeIn dark:bg-[#1a1b1e]",children:[u.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-[#2d2f39]",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:`w-10 h-10 rounded-full ${k.iconBg} flex items-center justify-center`,children:u.jsx(wd,{className:`w-5 h-5 ${k.icon}`})}),u.jsx("h2",{id:"confirm-title",className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:c})]}),u.jsx("button",{type:"button",onClick:l,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors","aria-label":"Close",children:u.jsx(ba,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})]}),u.jsx("div",{className:"p-6",children:u.jsx("p",{className:"text-gray-600 dark:text-gray-300 leading-relaxed",children:d})}),u.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-gray-200 dark:border-[#2d2f39] bg-gray-50 dark:bg-[#131416] rounded-b-2xl",children:[u.jsx("button",{type:"button",onClick:l,disabled:x,className:"px-4 py-3 md:py-2.5 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-lg transition-colors font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:h}),u.jsx("button",{type:"button",onClick:b,disabled:x,className:`px-4 py-3 md:py-2.5 text-white rounded-lg transition-all font-medium shadow-sm hover:shadow-md transform hover:scale-105 active:scale-95 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white dark:focus:ring-offset-gray-800 disabled:opacity-50 disabled:cursor-not-allowed disabled:transform-none ${k.confirmButton}`,children:x?u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Clearing..."]}):f})]})]})});return typeof document>"u"?S:Qo.createPortal(S,document.body)}const Hy=["#","*","`","[","]","(",")","{","}","|","<",">"],bg=r=>Hy.some(l=>r.includes(l));function yg(r){if(!r||r.length<1e3)return!1;const l=/^[A-Za-z0-9+/=]+$/,i=r.replace(/\s+/g,"");if(i.length>1e4&&l.test(i)){const c=/\b(the|and|for|are|but|not|you|all|can|function|const|let|var|class|return|import|export|async|await|if|else|while|true|false|null|undefined|http|https|www|error|data|response|request|api|json|xml|html|css|js|py|java|cpp|def|print|console|log)\b/i.test(r),d=bg(r),f=/[-.,;:!?'"()]/.test(r);if(!c&&!d&&!f)return!0}return!!(i.length>5e4&&l.test(i)&&r.replace(/[A-Za-z0-9+/=\s]/g,"").length<10)}const Fy=/(?:\u202F|\u2009|\u200A|\u200B|\u200C|\u200D|\uFEFF)/g;function rs(r){if(!r)return r;let l=r.replace(Fy," ");if(yg(l))return"";const i=/([A-Za-z0-9+/=]{10000,})/g;return l=l.replace(i,c=>{const d=c.replace(/\s+/g,"");if(d.length>1e4&&/^[A-Za-z0-9+/=]+$/.test(d)){const f=/\b(function|const|let|var|class|return|import|export|if|else|while|for|true|false|null|def|print)\b/i.test(c),h=bg(c),p=/[-.,;:!?'"()]/.test(c);if(!f&&!h&&!p)return""}return c}),l}function fd(r,l=5e4){return!r||r.length<=l?r:yg(r)?"":r.substring(0,l)+`
331
331
 
332
332
  ... (content truncated due to length)`}const Iy={maxFilesPerConversation:Se.limits.files.perConversation,maxFileSizeMB:Se.limits.files.maxSizeMB,maxTotalFiles:Se.limits.files.totalFiles,maxConversations:Se.limits.conversations.maxConversations,maxMessagesPerConversation:Se.limits.conversations.maxMessagesPerConversation,maxMessagesPerThread:Se.limits.conversations.maxMessagesPerThread,maxTotalMessages:Se.limits.conversations.totalMessages,maxMessageLength:Se.limits.messages.maxLength};function Gy(r){const l=Se.guestLimits;switch(r){case"maxConversations":return l.conversations.maxConversations;case"maxMessagesPerConversation":return l.conversations.messagesPerConversation;case"maxMessagesPerThread":return l.conversations.messagesPerThread;case"maxTotalMessages":return l.conversations.totalMessages;case"maxFilesPerConversation":return l.files.perConversation;case"maxTotalFiles":return l.files.totalFiles;case"maxMessageLength":return l.messages.maxLength;case"maxFileSizeMB":return l.files.maxSizeMB;default:return}}const ze=new Proxy(Iy,{get(r,l){if(Ea()&&!vn()){const i=Gy(l);if(i!==void 0)return i}return r[l]}});function us(){return g.useSyncExternalStore(Ey,vn,vn)}class vg extends Error{constructor(i,c){super(i);xa(this,"status");xa(this,"statusText");this.name="ApiRequestError",this.status=c.status,this.statusText=c.statusText}}async function Et(r={}){const l={"X-User-ID":await xg(),...r},i=await Nd();return i&&(l.Authorization=`Bearer ${i}`),l}function zn(r){return encodeURIComponent(r)}function Vy(r){return!r||r.length===0?"":`?file_ids=${r.map(encodeURIComponent).join(",")}`}async function ri(r){const l=`API request failed: ${r.status} ${r.statusText}`;try{if((r.headers.get("content-type")||"").includes("application/json")){const c=await r.json(),d=typeof c.detail=="string"&&c.detail.trim()||typeof c.error=="string"&&c.error.trim()||typeof c.message=="string"&&c.message.trim();if(d)return`${l}: ${d}`}else{const c=(await r.text()).trim();if(c)return`${l}: ${c}`}}catch{}return l}function Np(r){if(!r.startsWith("data: "))return null;try{const l=JSON.parse(r.substring(6));return l.request_id&&!l.response&&!l.done?{text:"",done:!1,request_id:l.request_id}:{text:l.text||l.content||l.message||l.response||"",done:l.done||!1,request_id:l.request_id,audio:l.audio,audioFormat:l.audio_format||l.audioFormat,audio_chunk:l.audio_chunk,chunk_index:l.chunk_index,image:l.image,image_format:l.image_format,image_revised_prompt:l.image_revised_prompt,image_url:l.image_url,video:l.video,video_format:l.video_format,video_revised_prompt:l.video_revised_prompt,video_url:l.video_url,document:l.document,document_format:l.document_format,document_revised_prompt:l.document_revised_prompt,document_url:l.document_url,assistant_message_id:l.assistant_message_id,threading:l.threading}}catch{return null}}let _o=null;function Xy(){let r=null,l=null;const i=(d,f,h)=>{r=f||null,l=h||null},c=(d,f)=>({async*streamChat(h,p,x,v,b,w,k,S,_,A,D,O,ee){var H,K;const U={messages:[{role:"user",content:h}],stream:p!==!1};x&&x.length>0&&(U.file_ids=x),v&&(U.thread_id=v),b&&(U.audio_input=b),w&&(U.audio_format=w),k&&(U.language=k),S!==void 0&&(U.return_audio=S),_&&(U.tts_voice=_),A&&(U.source_language=A),D&&(U.target_language=D),O&&(U.model=O),ee&&(U.skill=ee);const z=await fetch("/api/v1/chat",{method:"POST",headers:await Et({"Content-Type":"application/json","X-Adapter-Name":d,...f?{"X-Session-ID":f}:{}}),body:JSON.stringify(U)});if(!z.ok)throw new Error(await ri(z));if((H=z.headers.get("content-type"))!=null&&H.includes("text/event-stream")){const j=(K=z.body)==null?void 0:K.getReader(),q=new TextDecoder;let V="";if(!j)throw new Error("Response body is not readable");for(;;){const{done:I,value:P}=await j.read();if(I)break;V+=q.decode(P,{stream:!0});const ue=V.split(`
333
333
  `);V=ue.pop()||"";for(const _e of ue){const te=Np(_e);te&&(yield te)}}if(V.trim())for(const I of V.split(`
@@ -363,4 +363,4 @@ $$
363
363
  "contract-history": "contract-history",
364
364
  "standing-offers": "standing-offers"
365
365
  }`;if(!i.trim())return[];try{const c=JSON.parse(i),d=new Set(Object.entries(c).filter(([,f])=>{if(typeof f=="string")return f.trim().length>0;if(f&&typeof f=="object"){const h=f;if(typeof h.apiKey=="string"&&h.apiKey.trim().length>0||typeof h.key=="string"&&h.key.trim().length>0)return!0}return!1}).map(([f])=>f));return l.filter(f=>d.has(f.id))}catch{return[]}}}return null}async function Td(){if($l&&Date.now()-ad<Fv)return $l;try{const l=await fetch("/api/adapters?refresh=1",{cache:"no-store",headers:{"Cache-Control":"no-cache"}});if(l.ok){const i=await l.json(),c=Ng(i.adapters);if(c.length>0)return $l=c,ad=Date.now(),ne("Fetched adapters from /api/adapters:",$l),$l;ne("/api/adapters response did not contain valid adapters, trying fallback")}ne(`/api/adapters returned ${l.status}, trying fallback`)}catch(l){ne("Could not fetch from /api/adapters, trying fallback:",l)}const r=Iv();if(r&&r.length>0)return $l=r,ad=Date.now(),ne("Loaded adapters from config:",$l),$l;throw Ie("No adapters available from API or config"),new Error("No adapters available. Define adapters in orbitchat.yaml and provide matching ids in VITE_ADAPTER_KEYS.")}const Gv="h-[96px]";function Vv({onAdapterSelect:r,className:l="",title:i="",subtitle:c="",eyebrow:d=""}){const[f,h]=g.useState([]),[p,x]=g.useState(!0),[v,b]=g.useState(null),w=g.useRef(null),k=g.useRef(null),[S,_]=g.useState(""),[A,D]=g.useState(!1),O=g.useCallback(()=>{const te=w.current;if(!te){D(!1);return}D(te.scrollHeight-te.scrollTop-te.clientHeight>20)},[]),ee=()=>typeof window<"u"&&window.matchMedia("(min-width: 768px)").matches,U=()=>{var te;return Array.from(((te=w.current)==null?void 0:te.querySelectorAll('[data-agent-card="true"]'))??[])},z=te=>{const E=U()[te]??null;E&&(E.focus(),E.scrollIntoView({block:"nearest"}))},H=()=>{z(0)},K=()=>{const te=U();te.length!==0&&z(te.length-1)},j=te=>{if(!p&&!v&&I.length>0&&ee()){if(te.key==="Tab"&&!te.shiftKey){te.preventDefault(),H();return}if(te.key==="ArrowDown"){te.preventDefault(),H();return}te.key==="ArrowUp"&&(te.preventDefault(),K())}},q=te=>{var B;if(!P||!ee()||te.key!=="ArrowDown"&&te.key!=="ArrowUp")return;const oe=document.activeElement;if(!(oe instanceof HTMLElement)||oe.dataset.agentCard!=="true")return;const E=U(),Y=E.indexOf(oe);if(Y!==-1){if(te.preventDefault(),te.key==="ArrowDown"){z((Y+1)%E.length);return}if(Y===0){(B=k.current)==null||B.focus();return}z(Y-1)}},V=S.trim().toLowerCase(),I=V?f.filter(te=>{var B,re;const oe=te.name.toLowerCase().includes(V),E=((B=te.description)==null?void 0:B.toLowerCase().includes(V))??!1,Y=((re=te.model)==null?void 0:re.toLowerCase().includes(V))??!1;return oe||E||Y}):f,P=S.trim().length>0,ue=P||I.length===1;g.useEffect(()=>{const te=w.current;if(te)return O(),te.addEventListener("scroll",O,{passive:!0}),()=>te.removeEventListener("scroll",O)},[O,I]),g.useEffect(()=>{let te=!0;return(async()=>{try{x(!0),b(null);const Y=(await Td()).slice().sort((B,re)=>B.name.localeCompare(re.name,void 0,{sensitivity:"base"}));te&&h(Y)}catch(E){Ie("[AgentSelectionList] Failed to load adapters",E),te&&b("Unable to load agents right now.")}finally{te&&x(!1)}})(),()=>{te=!1}},[]),g.useEffect(()=>{var te;p||v||f.length===0||(te=k.current)==null||te.focus()},[p,v,f.length]);const _e=()=>p?u.jsx("div",{className:"grid gap-4",children:Array.from({length:3}).map((te,oe)=>u.jsx("div",{className:`${Gv} animate-pulse rounded-2xl border border-gray-200 bg-transparent dark:border-[#3b3c49]`},oe))}):v?u.jsx("div",{className:"rounded-2xl border border-red-200 bg-transparent px-4 py-6 text-sm text-red-700 dark:border-red-900 dark:text-red-200",children:v}):f.length===0?u.jsx("div",{className:"rounded-2xl border border-gray-200 bg-transparent px-4 py-6 text-sm text-gray-600 dark:border-[#3b3c49] dark:text-gray-300",children:"No agents are available yet. Configure adapters in your middleware settings to continue."}):I.length===0?u.jsx("div",{className:"rounded-2xl border border-gray-200 bg-transparent px-4 py-6 text-sm text-gray-600 dark:border-[#3b3c49] dark:text-gray-300",children:"No agents match your search."}):u.jsxs("div",{className:"relative flex flex-col h-full min-h-0",children:[u.jsx("div",{ref:w,onKeyDown:q,className:"agent-selection-scroll flex-1 min-h-0 overflow-y-auto pr-1 pb-2",children:ue?u.jsx("div",{className:"mx-auto flex w-full max-w-xl flex-col gap-3 lg:max-w-2xl",children:I.map(te=>u.jsx(qp,{adapter:te,onSelect:oe=>r(oe.id)},te.id))}):u.jsx("div",{className:"grid gap-3 lg:grid-cols-2",children:I.map(te=>u.jsx(qp,{adapter:te,onSelect:oe=>r(oe.id)},te.id))})}),A&&u.jsx("div",{className:"pointer-events-none absolute bottom-0 left-0 right-0 h-12 md:hidden bg-gradient-to-t from-white dark:from-[#212121] to-transparent","aria-hidden":"true"})]});return u.jsxs("div",{className:`flex w-full flex-col gap-4 md:gap-6 ${l}`,children:[(d||i||c)&&u.jsxs("div",{className:"flex-shrink-0",children:[d&&u.jsx("p",{className:"text-sm font-semibold uppercase tracking-wide text-blue-600 dark:text-blue-300",children:d}),i&&u.jsx("h2",{className:"mt-2 text-2xl font-bold text-gray-900 dark:text-white",children:i}),c&&u.jsx("p",{className:"mt-2 text-base text-gray-600 dark:text-gray-300",children:c})]}),u.jsx("div",{className:"flex w-full flex-shrink-0 justify-center",children:u.jsx("div",{className:"w-full max-w-xl lg:max-w-2xl",children:u.jsxs("div",{className:"relative overflow-hidden rounded-[1.75rem] border border-slate-300/90 bg-[linear-gradient(180deg,rgba(255,255,255,0.96),rgba(248,250,252,0.94))] shadow-[0_10px_28px_rgba(15,23,42,0.05)] dark:border-white/20 dark:bg-[linear-gradient(180deg,rgba(37,39,49,0.95),rgba(29,31,39,0.92))] dark:shadow-[0_12px_30px_rgba(0,0,0,0.2)]",children:[u.jsx("div",{className:"pointer-events-none absolute inset-0 rounded-[inherit] bg-[linear-gradient(180deg,rgba(255,255,255,0.45),rgba(255,255,255,0))] dark:bg-[linear-gradient(180deg,rgba(255,255,255,0.03),rgba(255,255,255,0))]"}),u.jsx(yd,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400 dark:text-slate-500"}),u.jsx("input",{ref:k,type:"text",placeholder:"Search agents",value:S,maxLength:100,disabled:p||!!v||f.length===0,onChange:te=>_(te.target.value),onKeyDown:j,className:"relative z-10 w-full bg-transparent py-3 pl-11 pr-11 text-sm font-medium text-slate-700 placeholder:font-normal placeholder:text-slate-400 focus:outline-none focus:ring-0 focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-60 dark:text-slate-100 dark:placeholder:text-slate-400"}),S&&u.jsx("button",{type:"button",onClick:()=>_(""),className:"absolute right-3 top-1/2 z-10 inline-flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-full border border-slate-200/80 bg-white/90 text-slate-400 transition-colors hover:border-slate-300 hover:text-slate-600 focus:outline-none focus:ring-2 focus:ring-sky-200 dark:border-white/10 dark:bg-white/5 dark:text-slate-500 dark:hover:border-white/20 dark:hover:text-slate-200 dark:focus:ring-sky-500/20","aria-label":"Clear search",children:u.jsx(ba,{className:"h-3.5 w-3.5"})})]})})}),u.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:_e()})]})}function md(){return Ad()?Yo()==="entra"?u.jsx(Yv,{}):u.jsx(Xv,{}):null}function Xv(){const{user:r,logout:l,loginWithRedirect:i}=xd();if(!us()||!r)return u.jsx(Tg,{onClick:()=>i()});const d=r.name||r.email||"User";return u.jsx(Eg,{displayName:d,onClick:()=>l({logoutParams:{returnTo:window.location.origin}})})}function Yv(){const{instance:r,accounts:l}=gd();if(!us()||l.length===0)return u.jsx(Tg,{onClick:()=>r.loginRedirect({scopes:Cd()}).catch(()=>{})});const c=l[0],d=c.name||c.username||"User";return u.jsx(Eg,{displayName:d,onClick:()=>r.logoutRedirect({postLogoutRedirectUri:window.location.origin}).catch(()=>{})})}function Tg({onClick:r}){return u.jsxs("button",{onClick:r,className:"inline-flex items-center justify-center gap-1.5 rounded-lg border border-blue-400/70 bg-blue-600 px-3 py-2 text-xs font-semibold text-white shadow-sm active:scale-[0.97] transition-all duration-150 hover:bg-blue-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:border-blue-500 dark:bg-blue-500 dark:hover:bg-blue-600",children:[u.jsx(ag,{className:"h-4 w-4"}),u.jsx("span",{children:"Sign in"})]})}function Eg({displayName:r,onClick:l}){return u.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm text-gray-600 dark:text-[#bfc2cd]",children:[u.jsx("span",{className:"hidden max-w-[170px] truncate font-medium md:block",title:r,children:r}),u.jsxs("button",{onClick:l,className:"inline-flex min-h-10 items-center justify-center gap-1.5 rounded-lg border border-slate-200 px-3 py-2 text-xs font-semibold text-slate-600 shadow-sm transition-colors hover:border-red-200 hover:bg-red-50 hover:text-red-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-400 dark:border-[#454755] dark:text-[#c4c8d4] dark:hover:border-red-900/40 dark:hover:bg-red-900/20 dark:hover:text-red-300 md:rounded-full md:text-sm md:font-medium",title:"Log out","aria-label":"Log out",children:[u.jsx(Fx,{className:"h-4 w-4"}),u.jsx("span",{className:"hidden md:inline",children:"Log out"})]})]})}function Mg({placement:r="default",compact:l=!1}){if(!hg())return null;const i=yy(),c=vy(),d=wy(),f=Sy(),h=ky(),p=_y(),x=Cy(),v=f?"border-t border-slate-200/80 dark:border-[#333645]":"",b=l?r==="sidebar"?"pt-4 pb-2":"pt-2 pb-2":p==="normal"?"pt-3 pb-3":"pt-5 pb-3",w=h==="inline"?"flex w-full flex-col gap-1 items-center justify-center text-center sm:flex-row sm:items-center sm:justify-center":"flex w-full flex-col items-center justify-center gap-1 text-center",k="justify-center",S=r==="sidebar"?"w-full px-2":"w-full px-3 sm:px-6",_=r==="sidebar"?"w-full":"mx-auto w-full max-w-7xl",A=l?"inline-flex min-h-8 items-center rounded px-1.5 text-xs font-medium transition-colors hover:bg-slate-100 hover:text-blue-700 hover:no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:hover:bg-[#2b2d39] dark:hover:text-blue-300":"inline-flex min-h-10 items-center rounded-md px-2.5 text-sm font-medium transition-colors hover:bg-slate-100 hover:text-blue-700 hover:no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:hover:bg-[#2b2d39] dark:hover:text-blue-300 sm:text-base";return u.jsx("footer",{className:`shrink-0 bg-white dark:bg-black text-sm ${b} ${v}`.trim(),style:{backgroundColor:c||void 0,color:d||void 0},children:u.jsx("div",{className:S,children:u.jsx("div",{className:_,children:u.jsxs("div",{className:w,children:[i&&u.jsx("p",{className:`${l?"text-xs leading-snug":"text-sm"} text-slate-700 dark:text-slate-200 ${r==="sidebar"?"pt-0.5":""}`.trim(),children:i}),x.length>0&&u.jsx("nav",{"aria-label":"Footer links",children:u.jsx("ul",{className:`flex flex-wrap items-center ${k} ${l?"gap-1":"gap-1.5 sm:gap-2"}`,children:x.map((D,O)=>{const ee=h==="inline"&&O>0;return u.jsxs("li",{className:"flex items-center",children:[ee&&u.jsx("span",{className:"mr-1.5 text-slate-400 dark:text-slate-500","aria-hidden":"true",children:"·"}),u.jsx("a",{href:D.url,target:"_blank",rel:"noopener noreferrer",className:A,style:{color:d||void 0},children:D.label})]},D.url)})})})]})})})})}const Qv=60*1e3;let nd=null,Bp=0;const ld=r=>{if(!r||r==="/")return"/";const l=r.trim();if(!l)return"/";const i=l.startsWith("/")?l:`/${l}`;return i==="/"?"/":i.endsWith("/")?i.slice(0,-1):i},zg=()=>{if(typeof window>"u")return ld("/");const r=ld("/");if(typeof document>"u")return r;const l=document.querySelector("base[href]");if(!l)return r;try{const i=new URL(l.getAttribute("href")||"/",window.location.origin);return ld(i.pathname||r)}catch{return r}},Go=r=>r.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),Zv=async()=>{const r=Date.now();if(nd&&r-Bp<Qv)return nd;let l=[];try{l=await Td()}catch(c){Fe("[agentRouting] Unable to load adapters for slug resolution",c)}const i=new Map;return l.forEach(c=>{const d=Go(c.name);d&&i.set(d,c.id);const f=Go(c.id);f&&f!==d&&i.set(f,c.id)}),nd=i,Bp=r,i},hd=r=>{var f;const l=zg(),i=r.startsWith("/")?r:`/${r}`;let c=i;if(l!=="/"){if(!i.startsWith(l))return null;c=i.slice(l.length)}const d=c.split("/").filter(Boolean);return d.length===0?null:((f=d[0])==null?void 0:f.toLowerCase())||null},Dg=r=>{const l=zg();if(!r)return l;const i=r.replace(/^\/+|\/+$/g,"");return l==="/"?i?`/${i}`:"/":`${l}/${i}`.replace(/\/{2,}/g,"/")},Ln=r=>{if(typeof window>"u")return;const l=Dg(r),i=window.location.pathname;if(l===i)return;const c=window.location.search||"",d=window.location.hash||"";window.history.replaceState(window.history.state,"",`${l}${c}${d}`)},Kv=()=>Dg(null),Jv=async r=>{const l=r.trim().toLowerCase();return l&&(await Zv()).get(l)||null},Pv="Single adapter mode requires agentMode.defaultAdapterId to match an adapter id in orbitchat.yaml.";function Wv({currentConversation:r,showEmptyState:l,createConversation:i,configureApiSettings:c,clearError:d,clearCurrentConversationAdapter:f}){var ye;const[h,p]=g.useState(!1),[x,v]=g.useState(null),b=Xo(),w=Sd(),k=typeof window<"u"?hd(window.location.pathname):null,[S,_]=g.useState(k),[A,D]=g.useState(()=>!b&&l&&!k),O=g.useRef(null),ee=g.useRef(new Map),U=g.useRef(0),z=3e4,H=!!r,K=(r==null?void 0:r.messages.length)??0,j=((ye=r==null?void 0:r.attachedFiles)==null?void 0:ye.length)??0,q=g.useMemo(()=>H&&(K>0||j>0),[j,K,H]),V=g.useCallback(()=>{sa(()=>Ye.getState())},[]),I=g.useCallback((ae,ie)=>{if(!ae)return;const xe=ie||"Unable to configure this agent.";let Ne=!1;Ye.setState(ve=>{const Te=ve.conversations.find(Le=>Le.id===ae);return!Te||Te.messages.length>0?ve:(Ne=!0,{conversations:ve.conversations.map(Le=>Le.id===ae?{...Le,adapterLoadError:xe}:Le)})}),Ne&&V()},[V]),P=g.useCallback(ae=>{if(!ae)return;let ie=!1;Ye.setState(xe=>{const Ne=xe.conversations.find(ve=>ve.id===ae);return!Ne||!Ne.adapterLoadError?xe:(ie=!0,{conversations:xe.conversations.map(ve=>ve.id===ae?{...ve,adapterLoadError:null}:ve)})}),ie&&V()},[V]),ue=g.useCallback(ae=>ae instanceof vg?ae.status===401?"We couldn’t load this agent. It may not exist or you might not have access to it.":ae.status===404?"This agent was not found on the server. Please pick another agent.":ae.message:ae instanceof Error?ae.message:"Unable to load agent overview right now.",[]),_e=g.useCallback(()=>{const ae=Ye.getState(),ie=ae.currentConversationId?ae.conversations.find(xe=>xe.id===ae.currentConversationId):null;if(!ie||ie.messages.length>0)try{return i()}catch(xe){Fe("Cannot create a new conversation for agent selection:",xe instanceof Error?xe.message:"Unknown error")}return(ie==null?void 0:ie.id)||null},[i]),te=g.useCallback(async ae=>{if(!(ae!=null&&ae.adapterName))return{ok:!1};try{const ie=await xt(),xe=new ie.ApiClient({apiUrl:ae.apiUrl||kt(),sessionId:null,adapterName:ae.adapterName});if(typeof xe.getAdapterInfo!="function")return{ok:!1};const Ne=await xe.getAdapterInfo();return Ye.setState(ve=>({conversations:ve.conversations.map(Te=>Te.id===ae.id?{...Te,adapterInfo:Ne,adapterLoadError:null,updatedAt:new Date}:Te)})),Ye.getState().currentConversationId===ae.id&&v(null),V(),{ok:!0}}catch(ie){const xe=ue(ie),Ne=Ye.getState();Ne.currentConversationId===ae.id&&v({conversationId:ae.id,message:xe});const ve=Ne.conversations.find(Te=>Te.id===ae.id);return ve&&ve.messages.length===0&&I(ae.id,xe),{ok:!1,error:ie}}},[ue,I,V]),oe=g.useCallback(async ae=>{if(!ae)return;const ie=Ye.getState(),xe=ie.currentConversationId?ie.conversations.find(Ne=>Ne.id===ie.currentConversationId):null;if(xe){p(!0),v(null),P(xe.id);try{const Ne=xe.apiUrl||kt();await c(Ne,void 0,ae),d();const ve=Ye.getState(),Te=ve.conversations.find(Le=>Le.id===ve.currentConversationId);if((Te==null?void 0:Te.adapterName)===ae&&(!Te.adapterInfo||Te.adapterInfo.notes===void 0)){const Le=await te(Te);!Le.ok&&Le.error&&Ie("Failed to load adapter info after selecting adapter:",Le.error)}}catch(Ne){Ie("Failed to configure adapter from empty state:",Ne);const ve=ue(Ne);v({conversationId:xe.id,message:ve}),I(xe.id,ve)}finally{p(!1)}}},[P,d,c,te,ue,I]),E=g.useCallback(ae=>{b||(_e(),D(!1),Ln(Go(ae)),oe(ae))},[_e,oe,b]),Y=g.useCallback(()=>{b||(f(),Ln(null),D(!0))},[f,b]),B=g.useCallback(()=>{var Ne,ve;if(b){const Te=Ye.getState(),Le=Te.currentConversationId?Te.conversations.find(Be=>Be.id===Te.currentConversationId):null;if(!!Le&&(Le.messages.length>0||(((Ne=Le.attachedFiles)==null?void 0:Ne.length)||0)>0))try{i()}catch(Be){Fe("Cannot go home (new conversation):",Be instanceof Error?Be.message:"Unknown error")}Ln(null),D(!1);return}_(null);const ae=Ye.getState(),ie=ae.currentConversationId?ae.conversations.find(Te=>Te.id===ae.currentConversationId):null;if(!!ie&&(ie.messages.length>0||(((ve=ie.attachedFiles)==null?void 0:ve.length)||0)>0))try{i()}catch(Te){Fe("Cannot go home (new conversation):",Te instanceof Error?Te.message:"Unknown error");return}else ie!=null&&ie.adapterName&&f();Ln(null),D(!0)},[f,i,b]),ce=!b&&l&&!S&&!(r!=null&&r.adapterName)&&!q||!b&&l&&A&&!(r!=null&&r.adapterName)&&!q;g.useEffect(()=>{if(b){Ln(null);return}if(!S){if(ce||!(r!=null&&r.adapterName)){Ln(null);return}Ln(Go(r.adapterName))}},[r==null?void 0:r.adapterName,b,S,ce]);const ge=g.useCallback(async()=>{if(typeof window>"u")return;const ae=++U.current;if(b){Ln(null),_(null);return}const ie=hd(window.location.pathname);if(!ie)return;const xe=await Jv(ie);if(ae===U.current){if(!xe){_e(),Ln(null),f(),D(!0),_(null);return}_e(),D(!1),Ln(ie),await oe(xe),_(null)}},[f,_e,oe,b]);g.useEffect(()=>{const ae=window.setTimeout(()=>{ge()},0),ie=()=>{ge()};return window.addEventListener("popstate",ie),()=>{window.clearTimeout(ae),U.current+=1,window.removeEventListener("popstate",ie)}},[ge]);const pe=r==null?void 0:r.id,G=r==null?void 0:r.adapterName,me=r==null?void 0:r.apiUrl,de=!!(r!=null&&r.adapterInfo);g.useEffect(()=>{if(!b||!w||!l||!pe||q||h)return;const ae=(G==null?void 0:G.trim())||w,ie=(G==null?void 0:G.trim())!==ae||!de;if(!ae||!ie)return;let xe=!1;return(async()=>{p(!0),v(null),P(pe);try{const ve=me||kt();await c(ve,void 0,ae),d()}catch(ve){if(!xe){const Te=ue(ve);v({conversationId:pe,message:Te}),I(pe,Te)}}finally{xe||p(!1)}})(),()=>{xe=!0}},[P,d,c,q,ue,h,b,I,l,G,me,de,pe,w]),g.useEffect(()=>{(async()=>{var Ne;const ie=r==null?void 0:r.adapterName;if(O.current===ie)return;const xe=!(r!=null&&r.adapterInfo)||(r==null?void 0:r.adapterInfo)&&r.adapterInfo.notes===void 0;if(ie&&xe){O.current=ie,ne("[ChatInterface] Loading adapter info - adapterName:",ie,"reason:",r!=null&&r.adapterInfo?"notes undefined":"missing");const ve=await te(r);if(ve.ok)ne("[ChatInterface] Adapter info loaded successfully");else{const Te=ve.error;Ie("[ChatInterface] Failed to load adapter info:",Te);const Le=Te instanceof Error?Te.message:String(Te);if((Le.includes("429")||Le.includes("Too Many Requests"))&&ie){const Be=ee.current.get(ie);Be&&clearTimeout(Be);const Ge=setTimeout(()=>{O.current===ie&&(O.current=null),ee.current.delete(ie)},z);ee.current.set(ie,Ge),Fe(`[ChatInterface] Adapter info request rate-limited; retrying in ${z/1e3}s`)}else O.current=null}}else ne("[ChatInterface] Skipping adapter info load:",{adapterName:ie,hasAdapterInfo:!!(r!=null&&r.adapterInfo),hasNotes:((Ne=r==null?void 0:r.adapterInfo)==null?void 0:Ne.notes)!==void 0,refValue:O.current})})()},[te,r]),g.useEffect(()=>{const ae=ee.current;return()=>{ae.forEach(ie=>clearTimeout(ie)),ae.clear()}},[]);const fe=b&&!w?Pv:(r==null?void 0:r.adapterLoadError)??((x==null?void 0:x.conversationId)===(r==null?void 0:r.id)?x.message:null);return{adapterNotesError:fe,handleAgentCardSelection:E,handleChangeAgent:Y,goToAgentSelectionHome:B,hasAdapterConfigurationError:!!fe,isAgentSelectionVisible:A,isConfiguringAdapter:h,isSingleAdapterMode:b,setIsAgentSelectionVisible:D,shouldShowAgentSelectionList:ce}}const Lg=g.createContext(null),e1={registerGoHome:()=>{},goHome:()=>{}};function Rg(){return g.useContext(Lg)??e1}function t1({adapter:r,syntaxTheme:l,forcedThemeClass:i=""}){var d;const c=(d=r.notes)==null?void 0:d.trim();return c?u.jsxs("section",{"aria-labelledby":"agent-seo-content-title",className:"mx-auto w-full max-w-[56rem] px-1 text-left sm:px-0",children:[u.jsx("h2",{id:"agent-seo-content-title",className:"sr-only",children:r.name}),u.jsx("div",{children:u.jsx(rl,{content:c,className:`message-markdown prose prose-slate dark:prose-invert max-w-none text-sm leading-relaxed text-[#434654] dark:text-[#d7dae3] [&>:first-child]:mt-0 [&>:last-child]:mb-0 ${i}`,syntaxTheme:l})})]}):null}const a1='meta[name="description"]',n1='meta[property="og:title"]',l1='meta[property="og:description"]',r1='meta[property="og:type"]',s1='link[rel="canonical"]';function Hp(r){return r.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function i1(r){return r.replace(/```[\s\S]*?```/g," ").replace(/`([^`]+)`/g,"$1").replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/^>\s?/gm,"").replace(/[*_~]/g,"").replace(/\s+/g," ").trim()}function o1(r,l){const i=r==null?void 0:r.trim();if(i)return i;if(!l)return _d();const c=i1(l);return c.length>160?`${c.slice(0,157).trimEnd()}...`:c}function c1(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function u1(r){const l=r.trim();if(!l)return null;try{return new URL(l).origin}catch{return null}}function d1(r){const l=r.trim();if(!l)return null;const i=`^${c1(l).replace(/\\\*/g,".*")}$`;try{return new RegExp(i,"i")}catch{return null}}function f1(r){return[cg(),...Kb()].map(u1).filter(i=>!!i).includes(r)?!0:Jb().some(i=>{const c=d1(i);return c?c.test(r):!1})}function m1(r){var c,d,f;const l=r==null?void 0:r.trim();if(!l)return null;const i=Se.adapters.find(h=>{var p;return((p=h==null?void 0:h.id)==null?void 0:p.trim())===l});return i?{id:i.id,name:((c=i.name)==null?void 0:c.trim())||i.id,description:((d=i.description)==null?void 0:d.trim())||void 0,notes:((f=i.notes)==null?void 0:f.trim())||void 0}:null}function h1(r){var c,d,f;if(typeof window>"u")return null;const l=hd(window.location.pathname);if(!l)return null;const i=Se.adapters.find(h=>{const p=Hp(h.name||""),x=Hp(h.id||"");return l===p||l===x});return i?{id:i.id,name:((c=i.name)==null?void 0:c.trim())||i.id,description:((d=i.description)==null?void 0:d.trim())||void 0,notes:((f=i.notes)==null?void 0:f.trim())||void 0}:null}function Mo(r,l,i){if(typeof document>"u")return null;const c=document.querySelector(r);if(c)return c;const d=document.createElement("meta");return d.setAttribute(l,i),document.head.appendChild(d),d}function p1(){if(typeof document>"u")return null;const r=document.querySelector(s1);if(r)return r;const l=document.createElement("link");return l.rel="canonical",document.head.appendChild(l),l}function Ug(r){if(typeof document>"u")return;const l=kd(),i=r?`${r.name} | ${l}`:l,c=r?o1(r.description,r.notes):_d();document.title=i;const d=Mo(a1,"name","description");d&&(d.content=c);const f=Mo(n1,"property","og:title");f&&(f.content=i);const h=Mo(l1,"property","og:description");h&&(h.content=c);const p=Mo(r1,"property","og:type");p&&(p.content="website");const x=p1();if(x&&typeof window<"u"){const v=cg(),b=window.location.origin,w=v?new URL(v.endsWith("/")?v:`${v}/`).origin:"",S=`${b&&f1(b)?b:w||b}${window.location.pathname}`;x.href=S}}function g1(){return Pb()}class Ed{static async getAdapterModels(l,i){const c=await xt(),d=new c.ApiClient({apiUrl:"",adapterName:i});if(!d.getAdapterModels)throw new Error("getAdapterModels is not available on this API client");return d.getAdapterModels(l)}static async getAllModels(l){const i=await xt(),c=new i.ApiClient({apiUrl:"",adapterName:l});if(!c.getAllModels)throw new Error("getAllModels is not available on this API client");return c.getAllModels()}static async listAdapterModels(l,i){return(await Ed.getAdapterModels(l,i)).models}}const x1="rounded-t-[32px] border border-white/40 bg-transparent px-4 pb-4 pt-[max(env(safe-area-inset-top),1rem)] shadow-none backdrop-blur-0 dark:border-[#2f303d] dark:bg-transparent md:rounded-none md:border-0 md:bg-transparent md:px-0 md:pb-0 md:pt-3 md:shadow-none md:backdrop-blur-0 md:dark:bg-transparent md:dark:border-0",b1="shrink-0 sticky bottom-[calc(var(--app-footer-height,0px)+0.25rem)] z-10 -mx-4 mt-auto overflow-visible bg-transparent pb-[max(env(safe-area-inset-bottom),0.5rem)] shadow-none backdrop-blur-0 transition-all duration-200 dark:bg-transparent md:bottom-[calc(var(--app-footer-height,0px)+0.5rem)] md:z-10 md:mx-0 md:mt-0 md:overflow-visible md:rounded-none md:border-0 md:bg-transparent md:pb-0 md:shadow-none md:backdrop-blur-0 md:dark:bg-transparent md:dark:border-0 [&>div]:bg-transparent md:[&>div]:rounded-none md:[&>div]:px-0",y1="relative z-20 shrink-0 -mx-4 px-4 pt-2 pb-2 bg-transparent border-b border-transparent dark:border-transparent dark:bg-transparent md:static md:mx-0 md:px-0 md:pt-6 md:pb-6 md:bg-transparent md:border-gray-200 md:dark:border-[#4a4b54] md:dark:bg-transparent";function v1({onOpenSettings:r,onOpenSidebar:l}){var On,Lt,_t,ia,Re,oa,za;const{conversations:i,currentConversationId:c,createConversation:d,canCreateNewConversation:f,sendMessage:h,regenerateResponse:p,editMessageAndRegenerate:x,isLoading:v,configureApiSettings:b,error:w,clearError:k,createThread:S,clearCurrentConversationAdapter:_}=Ye(),{settings:A}=Vo(),D=us(),O=Ea()&&!D,{theme:ee,isDark:U}=cs(),z=ee.mode==="dark"?"dark":ee.mode==="light"?"light":"",H=U?"dark":"light",K=["application-description agent-home-markdown prose prose-slate dark:prose-invert max-w-none text-sm md:text-base leading-relaxed","text-[#4a4c5a] dark:text-[#bfc2cd]","[&>:first-child]:mt-0 [&>:last-child]:mb-0",z].filter(Boolean).join(" "),j=i.find(Me=>Me.id===c),q=i.some(Me=>{var Qe;return(Me.messages.length>0||(((Qe=Me.attachedFiles)==null?void 0:Qe.length)||0)>0)&&!Me.adapterLoadError}),V=!j||j.messages.length===0,I=((On=j==null?void 0:j.adapterInfo)==null?void 0:On.supportsThreading)===!0,P=!!(j!=null&&j.adapterName&&(j!=null&&j.adapterInfo))&&!I,ue=wg({adapterName:j==null?void 0:j.adapterName,enabled:P,selectionScopeKey:c,supportsThreading:I}),_e=og(),te=kd(),oe=_d().trim(),E=oe.length>0,{registerGoHome:Y}=Rg(),[B,re]=g.useState([]),[ce,ge]=g.useState(null);g.useEffect(()=>{const Me=j==null?void 0:j.adapterName;let Qe=!1;async function it(){if(ge(null),!Me){re([]);return}try{const be=await Ed.listAdapterModels(Me,Me);if(Qe)return;re(be),ge(be.length>0?be[0].name:null)}catch{Qe||(re([]),ge(null))}}return it(),()=>{Qe=!0}},[j==null?void 0:j.adapterName]);const{adapterNotesError:pe,handleAgentCardSelection:G,handleChangeAgent:me,goToAgentSelectionHome:de,hasAdapterConfigurationError:fe,isAgentSelectionVisible:ye,isConfiguringAdapter:ae,isSingleAdapterMode:ie,shouldShowAgentSelectionList:xe}=Wv({currentConversation:j,showEmptyState:V,createConversation:d,configureApiSettings:b,clearError:k,clearCurrentConversationAdapter:_});g.useLayoutEffect(()=>(Y(()=>de()),()=>Y(null)),[Y,de]);const Ne="max-w-[96rem]",ve="max-w-[64rem]",Te="max-w-[56rem]",Le=`mx-auto w-full ${Ne}`,qe=f(),Be=!!(j!=null&&j.adapterName)&&((j==null?void 0:j.messages.length)||0)===0,Ge=qe?"Start a new conversation":O?"Guest conversation limit reached. Sign in for more conversations.":"Finish your current conversation before starting a new one.",He=!!(j&&!xe),vt=xe?"border-transparent dark:border-transparent md:border-transparent md:dark:border-transparent":"",st=!cd()&&xe?"pt-0 pb-0 md:pt-0 md:pb-1":"",Ee=`${y1} ${vt} ${st}`.trim(),zt=hg(),we=i.some(Me=>{var Qe;return(Me.messages.length>0||(((Qe=Me.attachedFiles)==null?void 0:Qe.length)??0)>0)&&!Me.adapterLoadError}),Xt=zt&&!we,sn=xe?"pt-0 md:pt-0":"pt-4 md:pt-6",Dt=g.useMemo(()=>{var be,It,Rt;if(xe)return null;const Me=m1(j==null?void 0:j.adapterName)||h1();if(!Me&&!(j!=null&&j.adapterName))return null;const Qe=(be=j==null?void 0:j.adapterName)==null?void 0:be.trim(),it=(Rt=(It=j==null?void 0:j.adapterInfo)==null?void 0:It.notes)==null?void 0:Rt.trim();return Me?{...Me,notes:it||Me.notes}:Qe?{id:Qe,name:Qe,notes:it||void 0}:null},[(Lt=j==null?void 0:j.adapterInfo)==null?void 0:Lt.notes,j==null?void 0:j.adapterName,xe]);g.useEffect(()=>{Ug(Dt)},[Dt]),g.useEffect(()=>{let Me=null;const Qe=()=>{Me&&(Me(),Me=null)};if(A.voiceEnabled){if(ql.isAudioEnabled())return ne("[ChatInterface] Audio streaming already enabled"),Qe;const it=()=>{Qe();const be=async()=>{Qe(),await ql.enableAudio()?ne("[ChatInterface] Audio streaming enabled after user gesture"):(Fe("[ChatInterface] User gesture did not enable audio streaming"),it())};document.addEventListener("pointerdown",be,{once:!0}),document.addEventListener("keydown",be,{once:!0}),Me=()=>{document.removeEventListener("pointerdown",be),document.removeEventListener("keydown",be)},ne("[ChatInterface] Waiting for user gesture to enable audio streaming")};return it(),Qe}return Qe(),ql.disableAudio(),ne("[ChatInterface] Audio streaming disabled via settings"),Qe},[A.voiceEnabled]);const Ft=(Me,Qe,it,be)=>{h(Me,Qe,it,ce??void 0,be)},Hl=async(Me,Qe,it,be,It)=>{await h(it,void 0,Me,It??ce??void 0,be)},ya=()=>{try{d()}catch(Me){Fe("Cannot create new conversation:",Me instanceof Error?Me.message:"Unknown error")}},wn=g.useCallback(async(Me,Qe)=>{if(j)try{await Ye.getState().deleteThread(j.id,Me,Qe)}catch(it){Ie("Failed to clear thread:",it)}},[j]);return u.jsx("main",{className:"flex-1 flex flex-col bg-transparent overflow-hidden","aria-label":"Chat workspace",children:u.jsx("div",{className:"flex h-full w-full flex-col overflow-hidden px-3 sm:px-5 lg:px-8",children:u.jsxs("div",{className:`mx-auto flex h-full w-full ${Ne} flex-col overflow-hidden md:pb-4 ${x1}`,children:[w&&u.jsx("div",{role:"alert",className:"mt-6 rounded-md border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-600/40 dark:bg-red-900/30 dark:text-red-200",children:u.jsxs("div",{className:"flex items-start justify-between",children:[u.jsx("p",{children:w}),u.jsx("button",{onClick:k,className:"ml-4 rounded p-1 text-red-500 hover:bg-red-100 hover:text-red-700 dark:text-red-200 dark:hover:bg-red-800/40","aria-label":"Dismiss error",children:"×"})]})}),u.jsxs("div",{className:Ee,children:[l&&u.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 md:hidden",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("button",{onClick:l,disabled:!q,className:`inline-flex items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-semibold shadow-sm transition-all duration-150 ${q?"border-white/50 bg-white/80 text-gray-800 active:scale-[0.97] hover:bg-white dark:border-[#2f303d] dark:bg-[#232430] dark:text-[#ececf1]":"cursor-not-allowed border-gray-200 bg-gray-100 text-gray-400 shadow-none dark:border-[#2f303d] dark:bg-[#181922] dark:text-[#6b6f7a]"}`,"aria-label":"Open conversations menu",children:[u.jsx(Gx,{className:"h-4 w-4"}),"Chats"]}),u.jsxs("button",{onClick:r,className:"inline-flex items-center justify-center gap-1.5 rounded-lg border border-white/50 bg-[#11121a]/90 px-3 py-2 text-xs font-semibold text-white shadow-sm active:scale-[0.97] transition-all duration-150 hover:bg-[#0c0d14] dark:border-[#3b3c49] dark:bg-[#565869] dark:hover:bg-[#6b6f7a]","aria-label":"Open settings",children:[u.jsx(hp,{className:"h-4 w-4"}),"Settings"]})]}),u.jsx("div",{className:"ml-auto flex-shrink-0",children:u.jsx(md,{})})]}),u.jsxs("div",{className:"flex flex-col gap-2 md:gap-4 sm:flex-row sm:items-end sm:justify-between",children:[u.jsx("div",{className:"min-w-0 flex-1",children:He&&u.jsx("div",{className:"space-y-1.5 md:space-y-3",children:u.jsxs("div",{className:"md:space-y-1",children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("h1",{className:"min-w-0 truncate text-lg md:text-2xl font-semibold text-[#353740] dark:text-[#ececf1]",children:(j==null?void 0:j.title)||"New Chat"}),j&&u.jsx("span",{className:"flex-shrink-0 text-xs md:hidden text-gray-500 dark:text-[#bfc2cd]",children:j.updatedAt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),j&&u.jsx("div",{className:"hidden md:flex items-center text-sm text-gray-500 dark:text-[#bfc2cd]",children:u.jsxs("span",{children:["Updated ",j.updatedAt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})})]})})}),u.jsxs("div",{className:"flex w-full flex-wrap items-center gap-2 my-2 md:my-0 sm:w-auto md:justify-end md:gap-3",children:[u.jsx("div",{className:"hidden flex-shrink-0 items-center md:inline-flex",children:u.jsx("button",{onClick:r,className:"inline-flex h-[42px] w-[42px] items-center justify-center rounded-full border border-gray-200 text-gray-500 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:text-gray-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-400/50 dark:border-[#3c3f4a] dark:text-[#9aa1bc] dark:hover:border-[#4d5166] dark:hover:bg-[#2d2f39] dark:hover:text-[#ececf1]","aria-label":"Settings",title:"Settings",children:u.jsx(hp,{className:"h-4 w-4"})})}),!ie&&!xe&&!!(j!=null&&j.adapterName)&&u.jsx("button",{type:"button",onClick:()=>{Be&&me()},disabled:!Be,className:`order-2 sm:order-1 inline-flex h-8 md:h-[42px] w-[calc(50%-0.25rem)] min-w-[140px] md:w-[190px] items-center justify-center gap-1 md:gap-2 rounded-full border px-2.5 md:px-3.5 py-1.5 md:py-2.5 text-[11px] md:text-[13px] font-medium tracking-[0.01em] transition-colors focus-visible:outline-none focus-visible:ring-2 ${Be?"border-blue-300 text-blue-700 hover:bg-blue-50 hover:border-blue-400 focus-visible:ring-blue-500 dark:border-blue-500/40 dark:text-blue-300 dark:hover:bg-blue-900/20 dark:hover:border-blue-400/60 dark:focus-visible:ring-blue-400/60":"cursor-not-allowed border-gray-200 text-gray-400 bg-transparent dark:border-[#3c3f4a] dark:text-[#6b6f7a]"}`,title:Be?"Switch to a different agent before starting this conversation":"Agent cannot be changed after the conversation has started",children:"Change Agent"}),!xe&&u.jsxs("button",{onClick:ya,disabled:!qe,className:`order-3 sm:order-2 inline-flex h-8 md:h-[42px] w-[calc(50%-0.25rem)] min-w-[140px] md:w-[190px] items-center justify-center gap-1 md:gap-2 rounded-full border px-2.5 md:px-3.5 py-1.5 md:py-2.5 text-[11px] md:text-[13px] font-medium tracking-[0.01em] ${qe?"border-[#1f2937] bg-[#1f2937] text-white shadow-[0_2px_8px_rgba(15,23,42,0.12)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#1f2937]/40 dark:border-[#4b5568] dark:bg-[#2f3747] dark:text-[#e9edf8] dark:shadow-[0_2px_8px_rgba(0,0,0,0.25)] dark:focus-visible:ring-[#6f809f]/35":"cursor-not-allowed border-gray-200 text-gray-400 bg-white/40 dark:border-[#3c3f4a] dark:text-[#6b6f7a] dark:bg-transparent"}`,title:Ge,children:[u.jsx(tb,{className:"h-3.5 w-3.5"}),"New Conversation"]}),!cd()&&u.jsx("div",{className:"order-4 hidden flex-shrink-0 items-center md:inline-flex",children:u.jsx(md,{})})]})]})]}),V?u.jsxs("div",{className:`flex flex-1 flex-col min-h-0 ${sn} ${xe?"overflow-hidden":""}`,children:[xe?u.jsx("div",{className:"flex-1 flex flex-col md:justify-start min-h-0 overflow-hidden",children:u.jsx("div",{className:"w-full flex flex-col min-h-0 overflow-hidden flex-1",children:u.jsxs("div",{className:"flex flex-col min-h-0 flex-1 gap-3 overflow-hidden md:gap-6",children:[u.jsx("div",{className:`${Le} flex-shrink-0 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,children:u.jsxs("div",{className:"flex-1",children:[u.jsx(rl,{content:te,className:"agent-home-markdown prose prose-slate dark:prose-invert max-w-none [&>:first-child]:mt-0 [&>:last-child]:mb-0 text-2xl font-semibold text-[#11111b] dark:text-white text-center md:text-left [&_p]:text-2xl [&_p]:font-semibold [&_p]:leading-tight [&_p]:m-0",syntaxTheme:H}),E&&u.jsx("div",{className:"mt-2",children:u.jsx(rl,{content:oe,className:K,syntaxTheme:H})})]})}),u.jsx(Vv,{onAdapterSelect:G,className:`${Le} md:flex-1 md:min-h-0 md:overflow-hidden`})]})})}):u.jsx("div",{className:"flex flex-1 w-full min-h-0 flex-col overflow-y-auto pt-4 md:pt-6",children:u.jsxs("div",{className:`mx-auto flex w-full ${Te} flex-col items-center gap-4 pb-8 md:gap-5 md:pb-12`,children:[pe?u.jsx("p",{className:"w-full text-center text-sm text-red-600 dark:text-red-400",children:pe}):j!=null&&j.adapterName?u.jsx("h2",{className:"w-full text-center text-xl font-semibold tracking-tight text-[#353740] dark:text-[#ececf1] md:text-2xl",style:{fontFamily:'-apple-system, "SF Pro Display", BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'},children:Qb(j.adapterName)||j.adapterName}):ae?u.jsx("p",{className:"w-full text-center text-sm text-gray-500 dark:text-[#bfc2cd]",children:"Configuring your agent…"}):null,Dt&&g1()&&u.jsx(t1,{adapter:Dt,syntaxTheme:H,forcedThemeClass:z}),u.jsx("div",{className:"w-full min-w-0",children:u.jsx($p,{onSend:Ft,disabled:v||!j||!(j!=null&&j.adapterName)||fe,autoFocusEnabled:!0,placeholder:_e,isCentered:!0,maxWidthClass:Te,adapterNotes:(_t=j==null?void 0:j.adapterInfo)==null?void 0:_t.notes,skillState:ue,availableModels:B,defaultModel:((ia=j==null?void 0:j.adapterInfo)==null?void 0:ia.model)??null,selectedModel:ce,onSelectModel:ge})})]})}),Xt&&u.jsx("div",{className:"shrink-0 pt-5 md:pt-6",children:u.jsx(Mg,{compact:!0})})]}):u.jsxs("div",{className:"flex flex-1 flex-col min-h-0",children:[u.jsx(wv,{messages:j.messages,onRegenerate:Me=>p(Me,ce??void 0),onEditMessage:(Me,Qe)=>x(Me,Qe,ce??void 0),onStartThread:async(Me,Qe)=>{try{await S(Me,Qe)}catch(it){Ie("Failed to create thread:",it)}},onClearThread:wn,onSendThreadMessage:Hl,sessionId:j.sessionId,isLoading:v,contentMaxWidthClass:ve,availableModels:B,defaultModel:((Re=j==null?void 0:j.adapterInfo)==null?void 0:Re.model)??null,selectedModel:ce}),u.jsx("div",{className:b1,children:u.jsx("div",{className:"mx-auto w-full max-w-[96rem] px-3 sm:px-5 md:px-6 lg:px-8 xl:px-10",children:u.jsx($p,{onSend:Ft,disabled:v||!j||!j.adapterName||ye||fe,autoFocusEnabled:!0,placeholder:"Start a new topic...",maxWidthClass:ve,isCentered:!1,adapterNotes:(oa=j==null?void 0:j.adapterInfo)==null?void 0:oa.notes,skillState:ue,availableModels:B,defaultModel:((za=j==null?void 0:j.adapterInfo)==null?void 0:za.model)??null,selectedModel:ce,onSelectModel:ge})})})]})]})})})}function w1({selectedAdapter:r,onAdapterChange:l,disabled:i,showDescriptions:c=!1,variant:d="sidebar",label:f,showLabel:h}){const[p,x]=g.useState([]),[v,b]=g.useState(!0),[w,k]=g.useState(null),[S,_]=g.useState(!1);g.useEffect(()=>{let q=!0;async function V(){try{b(!0),k(null);const I=await Td();q&&x(I)}catch(I){Ie("Failed to load adapters:",I),q&&k("Failed to load adapters. Please check your connection.")}finally{q&&b(!1)}}return V(),()=>{q=!1}},[]);const A=p.find(q=>q.id===r),D=typeof h=="boolean"?h:d==="prominent",O=f||(d==="prominent"?"Select an agent":"Adapter"),ee=g.useMemo(()=>d==="prominent"?"relative w-full text-left":"relative w-full",[d]),U=g.useMemo(()=>{const q="w-full rounded-md border bg-white px-4 py-3 text-left text-sm text-[#353740] focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 dark:bg-[#343541] dark:text-[#ececf1]";return d==="prominent"?[q,"border-gray-300 shadow-sm transition-all duration-200 focus-visible:ring-blue-500 dark:border-[#4a4b54] dark:focus-visible:ring-blue-400"].join(" "):["w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-left text-sm text-[#353740] focus:border-gray-400 focus:outline-none dark:border-[#4a4b54] dark:bg-[#343541] dark:text-[#ececf1] dark:focus:border-[#6b6f7a]"].join(" ")},[d]),z=g.useMemo(()=>d==="prominent"?"absolute z-20 mt-2 w-full rounded-xl border border-gray-200 bg-white shadow-xl ring-1 ring-black/5 dark:border-[#4a4b54] dark:bg-[#1f2027]":"absolute z-20 mt-1 w-full rounded-md border border-gray-200 bg-white shadow-lg ring-1 ring-black/5 dark:border-[#4a4b54] dark:bg-[#1f2027]",[d]),j=D?`mb-2 block text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-[#bfc2cd] ${d==="prominent"?"!text-sm !font-semibold !text-gray-700 dark:!text-white":""}`:"sr-only";return u.jsxs("div",{className:ee,children:[u.jsx("label",{className:j,children:O}),u.jsxs("div",{className:"relative",children:[u.jsx("button",{type:"button",onClick:()=>!i&&_(!S),disabled:i||v||p.length===0,className:`${U} disabled:opacity-50 disabled:cursor-not-allowed`,"aria-label":O,children:u.jsxs("div",{className:"flex items-center justify-between gap-2",children:[u.jsxs("div",{className:"flex flex-col min-w-0",children:[u.jsx("span",{className:`truncate font-medium ${A?"text-[#11121a] dark:text-white":"text-gray-500 dark:text-gray-400"}`,children:v?"Loading agents…":w?"Error loading agents":A?A.name:p.length===0?"No agents available":"Select an agent"}),d==="prominent"&&(A==null?void 0:A.description)&&u.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:A.description})]}),u.jsx(fi,{className:`h-4 w-4 flex-shrink-0 transition-transform text-gray-400 dark:text-gray-300 ${S?"rotate-180":""}`})]})}),S&&!i&&p.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>_(!1)}),u.jsx("div",{className:z,children:u.jsx("div",{className:"max-h-72 overflow-auto py-2",children:p.map(q=>{const V=q.id===r;return u.jsx("button",{type:"button",onClick:()=>{V||l(q.id),_(!1)},className:`w-full px-4 py-3 text-left text-sm transition-colors ${V?"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-200":"text-[#353740] hover:bg-gray-50 dark:text-[#ececf1] dark:hover:bg-[#2a2d35]"}`,children:u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("span",{className:"font-medium truncate",children:q.name}),c&&q.description&&u.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:q.description})]})},q.id)})})})]})]}),w&&u.jsx("p",{className:"mt-1 text-xs text-red-600 dark:text-red-400",children:w})]})}const zo=100;function S1(r,l){const i=new Date(l.getFullYear(),l.getMonth(),l.getDate()),c=new Date(i);c.setDate(c.getDate()-1);const d=new Date(i);d.setDate(d.getDate()-i.getDay());const f=new Date(l.getFullYear(),l.getMonth(),1);return r>=i?"Today":r>=c?"Yesterday":r>=d?"This Week":r>=f?"This Month":"Earlier"}function k1(r){const l=new Date,i=["Today","Yesterday","This Week","This Month","Earlier"],c=new Map;for(const d of r){const f=S1(d.updatedAt,l),h=c.get(f);h?h.push(d):c.set(f,[d])}return i.filter(d=>c.has(d)).map(d=>({label:d,conversations:c.get(d)}))}function Fp({onRequestClose:r,onToggleDesktopSidebar:l}){const i=Xo(),{conversations:c,currentConversationId:d,selectConversation:f,deleteConversation:h,deleteAllConversations:p,updateConversationTitle:x,getConversationCount:v,configureApiSettings:b,clearError:w}=Ye(),k=c.find(se=>se.id===d),[S,_]=g.useState(""),[A,D]=g.useState(null),[O,ee]=g.useState(""),[U,z]=g.useState({isOpen:!1,conversationId:"",conversationTitle:"",isDeleting:!1}),[H,K]=g.useState({isOpen:!1,isDeleting:!1}),[j,q]=g.useState(!1),[V,I]=g.useState(null),[P,ue]=g.useState(!1),[_e,te]=g.useState(null),oe=g.useRef(null),E=g.useRef(null),Y=g.useRef(null),B=!k||k.messages.length===0,re=(V==null?void 0:V.conversationId)===d?V.adapterName:(k==null?void 0:k.adapterName)??null,ce=(_e==null?void 0:_e.conversationId)===d?_e.message:null,ge=g.useMemo(()=>c.filter(se=>{var Ee;return(se.messages.length>0||(((Ee=se.attachedFiles)==null?void 0:Ee.length)||0)>0)&&!se.adapterLoadError}),[c]),pe=g.useMemo(()=>{if(!S)return ge;const se=S.toLowerCase();return ge.filter(Ee=>Ee.title.toLowerCase().includes(se)||Ee.messages.some(zt=>zt.content.toLowerCase().includes(se))||(Ee.attachedFiles||[]).some(zt=>zt.filename.toLowerCase().includes(se)))},[ge,S]),G=g.useMemo(()=>k1(pe),[pe]),me=v(),de=S.length>0,fe=ge.length>0;g.useEffect(()=>{if(!d||!E.current)return;const se=E.current.querySelector('[aria-current="true"]');se&&se.scrollIntoView({block:"nearest",behavior:"smooth"})},[d]);const ye=g.useCallback(se=>{var sn;if(se.key!=="ArrowDown"&&se.key!=="ArrowUp")return;se.preventDefault();const Ee=(sn=E.current)==null?void 0:sn.querySelectorAll('[role="option"]');if(!Ee||Ee.length===0)return;const zt=document.activeElement,we=Array.from(Ee).indexOf(zt);let Xt;se.key==="ArrowDown"?Xt=we<Ee.length-1?we+1:0:Xt=we>0?we-1:Ee.length-1,Ee[Xt].focus()},[]),ae=async se=>{if(!(!B||!se)){I({conversationId:d??null,adapterName:se}),te(null),ue(!0);try{const Ee=(k==null?void 0:k.apiUrl)||kt();await b(Ee,void 0,se),w(),q(!1)}catch(Ee){Ie("Failed to configure adapter:",Ee),te({conversationId:d??null,message:Ee instanceof Error?Ee.message:"Failed to configure adapter"})}finally{ue(!1)}}},ie=async se=>{try{await f(se),r==null||r()}catch(Ee){Ie("Failed to select conversation:",Ee)}},xe=(se,Ee)=>{se.stopPropagation(),z({isOpen:!0,conversationId:Ee.id,conversationTitle:Ee.title,isDeleting:!1})},Ne=async()=>{z(se=>({...se,isDeleting:!0}));try{await h(U.conversationId)}catch(se){Ie("Failed to delete conversation:",se)}z({isOpen:!1,conversationId:"",conversationTitle:"",isDeleting:!1})},ve=()=>{z({isOpen:!1,conversationId:"",conversationTitle:"",isDeleting:!1})},Te=(se,Ee)=>{se.stopPropagation(),D(Ee.id),ee(Ee.title.slice(0,zo))},Le=se=>{const Ee=O.slice(0,zo).trim();Ee&&x(se,Ee),D(null),ee("")},qe=()=>{D(null),ee("")},Be=()=>{K({isOpen:!0,isDeleting:!1})},Ge=async()=>{K(se=>({...se,isDeleting:!0}));try{await p()}catch(se){Ie("Failed to clear all conversations:",se)}K({isOpen:!1,isDeleting:!1})},He=()=>{K({isOpen:!1,isDeleting:!1})},vt=se=>{var Ee,zt,we;return(Ee=se.adapterName)!=null&&Ee.trim()?se.adapterName:(we=(zt=se.adapterInfo)==null?void 0:zt.adapter_name)!=null&&we.trim()?se.adapterInfo.adapter_name:null};ui(oe,{enabled:j,onEscape:()=>q(!1)});const st=se=>{const Ee=d===se.id,zt=vt(se);return u.jsx("div",{role:"option","aria-selected":Ee,tabIndex:0,onKeyDown:we=>{(we.key==="Enter"||we.key===" ")&&(we.preventDefault(),ie(se.id))},onClick:()=>ie(se.id),className:`group relative flex w-full cursor-pointer items-center rounded-lg px-3 py-2 text-left text-sm transition-colors duration-100
366
- ${Ee?"bg-slate-100 dark:bg-[#2a2b36]":"hover:bg-slate-100/70 dark:hover:bg-[#25262f]"} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-500/50 dark:focus-visible:ring-sky-400/40`,"aria-current":Ee?"true":void 0,"aria-label":`Open conversation: ${se.title}`,children:A===se.id?u.jsx("input",{type:"text",value:O,onChange:we=>ee(we.target.value.slice(0,zo)),onKeyDown:we=>{we.key==="Enter"&&Le(se.id),we.key==="Escape"&&qe(),we.stopPropagation()},onBlur:()=>Le(se.id),maxLength:zo,className:"flex-1 rounded border border-sky-300 bg-white px-2 py-0.5 text-sm text-[#353740] focus:outline-none focus:ring-2 focus:ring-sky-400/50 dark:border-sky-500/40 dark:bg-[#1a1b1e] dark:text-[#ececf1]",autoFocus:!0,"aria-label":"Edit conversation title"}):u.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[u.jsx("h3",{className:`flex-1 truncate text-sm leading-snug ${Ee?"font-medium text-slate-900 dark:text-[#ececf1]":"font-normal text-slate-700 dark:text-[#c5c8d6]"}`,children:se.title}),u.jsxs("div",{className:"ml-1 flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity duration-100 group-hover:opacity-100 group-focus-within:opacity-100",children:[u.jsx("button",{onClick:we=>Te(we,se),className:"rounded p-1 text-slate-400 transition-colors hover:bg-slate-200/80 hover:text-slate-600 dark:text-[#6b6f7a] dark:hover:bg-[#3c3f4a] dark:hover:text-[#c5c8d6]","aria-label":`Rename conversation: ${se.title}`,children:u.jsx(ng,{className:"h-3 w-3"})}),u.jsx("button",{onClick:we=>xe(we,se),className:"rounded p-1 text-slate-400 transition-colors hover:bg-red-100/80 hover:text-red-600 dark:text-[#6b6f7a] dark:hover:bg-red-900/30 dark:hover:text-red-400","aria-label":`Delete conversation: ${se.title}`,children:u.jsx(sg,{className:"h-3 w-3"})})]})]}),zt&&u.jsx("span",{className:"truncate text-[11px] leading-none text-slate-400 dark:text-[#6b6f7a]",children:zt})]})},se.id)};return u.jsxs(u.Fragment,{children:[!i&&j&&u.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm px-4",children:u.jsxs("div",{ref:oe,role:"dialog","aria-modal":"true","aria-labelledby":"select-agent-title",tabIndex:-1,className:"w-full max-w-md rounded-2xl border border-gray-200 bg-white p-6 shadow-2xl dark:border-[#3d4050] dark:bg-[#1a1b1e]",children:[u.jsx("h2",{id:"select-agent-title",className:"mb-4 text-lg font-semibold text-gray-900 dark:text-[#ececf1]",children:"Select an Agent"}),u.jsxs("div",{className:"space-y-5",children:[u.jsx(w1,{selectedAdapter:re,onAdapterChange:ae,disabled:P,variant:"prominent",showDescriptions:!0,showLabel:!1}),ce&&u.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-600/40 dark:bg-red-900/30 dark:text-red-200",children:ce}),u.jsx("div",{className:"flex justify-end gap-3 pt-2",children:u.jsx("button",{type:"button",onClick:()=>{te(null),q(!1)},className:"rounded-lg px-4 py-2 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:text-[#d1d5db] dark:hover:bg-[#2d2f39]",disabled:P,children:"Cancel"})})]})]})}),u.jsxs("nav",{"aria-label":"Conversation sidebar",className:"flex h-full md:h-[calc(100%-2rem)] md:mt-4 w-full md:w-72 flex-col border-r border-b border-gray-200 md:border-l md:border-t md:rounded-2xl md:overflow-hidden bg-transparent dark:border-[#2d2f39]",children:[u.jsxs("div",{className:"bg-transparent px-4 pb-4 pt-4 dark:border-[#2d2f39]",children:[u.jsxs("div",{className:"flex items-center gap-2 pb-3",children:[c.length>0&&c.some(se=>se.messages.length>0)&&u.jsxs("button",{onClick:Be,className:"flex flex-1 items-center justify-center gap-2 rounded-lg border border-red-200 px-3 py-2 text-sm font-medium text-red-600 transition-all duration-150 hover:bg-red-50 hover:border-red-300 hover:shadow-sm dark:border-red-500/25 dark:text-red-400 dark:hover:bg-red-950/20 dark:hover:border-red-500/40",title:"Delete all conversations",children:[u.jsx(ib,{className:"h-4 w-4"}),"Delete Conversations"]}),l&&u.jsx("button",{type:"button",onClick:l,className:"ml-auto hidden shrink-0 md:inline-flex h-9 w-9 items-center justify-center rounded-xl border border-slate-200/80 bg-white text-slate-600 transition-colors hover:border-slate-300 hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:border-[#333645] dark:bg-[#161616] dark:text-[#d1d5db] dark:hover:border-[#43465a] dark:hover:bg-[#202020] dark:hover:text-white","aria-label":"Close sidebar",title:"Close sidebar",children:u.jsx(Kx,{className:"h-4 w-4"})})]}),ce&&!j&&u.jsx("p",{role:"alert",className:"mt-2 text-xs text-red-600 dark:text-red-400",children:ce}),fe&&u.jsxs("div",{className:"border-t border-gray-200 pt-4 mt-4 dark:border-[#2d2f39]",children:[u.jsxs("div",{className:"relative overflow-hidden rounded-[1.75rem] border border-slate-200/85 bg-[linear-gradient(180deg,rgba(255,255,255,0.96),rgba(248,250,252,0.94))] shadow-[0_10px_28px_rgba(15,23,42,0.05)] transition-all duration-200 focus-within:border-sky-300/90 focus-within:shadow-[0_0_0_1px_rgba(125,211,252,0.55),0_10px_28px_rgba(15,23,42,0.05)] dark:border-white/10 dark:bg-[linear-gradient(180deg,rgba(37,39,49,0.95),rgba(29,31,39,0.92))] dark:shadow-[0_12px_30px_rgba(0,0,0,0.2)] dark:focus-within:border-sky-400/30 dark:focus-within:shadow-[0_0_0_1px_rgba(56,189,248,0.22),0_12px_30px_rgba(0,0,0,0.2)]",children:[u.jsx("div",{className:"pointer-events-none absolute inset-0 rounded-[inherit] bg-[linear-gradient(180deg,rgba(255,255,255,0.45),rgba(255,255,255,0))] dark:bg-[linear-gradient(180deg,rgba(255,255,255,0.03),rgba(255,255,255,0))]"}),u.jsx(yd,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400 dark:text-slate-500"}),u.jsx("input",{ref:Y,type:"text",role:"searchbox","aria-label":"Search conversations",placeholder:"Search Conversations",value:S,onChange:se=>_(se.target.value),className:"relative z-10 w-full bg-transparent py-3 pl-11 pr-11 text-sm font-medium text-slate-700 placeholder:font-normal placeholder:text-slate-400 focus:outline-none dark:text-slate-100 dark:placeholder:text-slate-500"}),S&&u.jsx("button",{type:"button",onClick:()=>{var se;_(""),(se=Y.current)==null||se.focus()},className:"absolute right-3 top-1/2 z-10 inline-flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-full border border-slate-200/80 bg-white/90 text-slate-400 transition-colors hover:border-slate-300 hover:text-slate-600 focus:outline-none focus:ring-2 focus:ring-sky-200 dark:border-white/10 dark:bg-white/5 dark:text-slate-500 dark:hover:border-white/20 dark:hover:text-slate-200 dark:focus:ring-sky-500/20","aria-label":"Clear search",children:u.jsx(ba,{className:"h-3.5 w-3.5"})})]}),de&&u.jsx("p",{"aria-live":"polite",className:"mt-2 text-center text-[11px] tabular-nums text-gray-400 dark:text-[#6e7490]",children:pe.length===0?"No results":`${pe.length} ${pe.length===1?"result":"results"}`})]})]}),u.jsx("div",{ref:E,role:"listbox","aria-label":"Conversations",onKeyDown:ye,className:"flex-1 overflow-y-auto bg-transparent px-3 py-2",children:pe.length===0?null:de?u.jsx("div",{className:"space-y-1",children:pe.map(st)}):u.jsx("div",{className:"space-y-4",children:G.map(se=>u.jsxs("section",{"aria-label":se.label,children:[u.jsx("h4",{className:"sticky top-0 z-10 mb-1 bg-transparent px-1 pb-1 pt-0.5 text-[11px] font-semibold uppercase tracking-wider text-gray-400 backdrop-blur-sm dark:text-[#6e7490]",children:se.label}),u.jsx("div",{className:"space-y-1",children:se.conversations.map(st)})]},se.label))})}),(()=>{const se=mg();return se.length===0?null:u.jsx("div",{className:"shrink-0 border-t border-gray-200/80 px-4 py-3 md:hidden dark:border-[#2d2f39]",children:u.jsx("nav",{"aria-label":"Header links",children:u.jsx("ul",{className:"flex flex-wrap gap-2",children:se.map(Ee=>u.jsx("li",{children:u.jsx("a",{href:Ee.url,className:"inline-flex items-center rounded-md px-2.5 py-1.5 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100 dark:text-[#d1d5db] dark:hover:bg-[#2b2d39]",children:Ee.label})},Ee.url))})})})})(),u.jsx("div",{className:"shrink-0 border-t border-gray-200/80 dark:border-[#2d2f39]",children:u.jsx(Mg,{placement:"sidebar",compact:!0})})]}),u.jsx(Bo,{isOpen:U.isOpen,onClose:ve,onConfirm:Ne,title:"Delete Conversation",message:`Are you sure you want to delete "${U.conversationTitle}"? This will clear the conversation history.`,confirmText:"Delete",cancelText:"Cancel",type:"danger",isLoading:U.isDeleting}),u.jsx(Bo,{isOpen:H.isOpen,onClose:He,onConfirm:Ge,title:"Clear All Conversations",message:me===1?"Are you sure you want to delete this conversation? This will clear all conversation history.":`Are you sure you want to delete all ${me} conversations? This will clear all conversation history.`,confirmText:"Clear All",cancelText:"Cancel",type:"danger",isLoading:H.isDeleting})]})}const _1="3.10.7",A1={version:_1},Md=A1.version,C1=["@@auth0spajs@@","a0.spajs","auth0","com.auth0"];function j1(r){const l=r.toLowerCase();return C1.some(i=>l.includes(i.toLowerCase()))}function N1(r){const l=[];for(let i=0;i<r.length;i++){const c=r.key(i);c&&j1(c)&&l.push(c)}l.forEach(i=>r.removeItem(i))}function Ip(r){try{N1(r),r.clear()}catch(l){console.warn("[Settings] Failed to clear browser storage during reset.",l)}}function T1(){if(typeof document>"u"||!document.cookie)return;const r=new Set([void 0]),l=window.location.hostname;l&&l!=="localhost"&&!/^\d{1,3}(?:\.\d{1,3}){3}$/.test(l)&&(r.add(l),r.add(`.${l}`)),document.cookie.split(";").forEach(c=>{const d=c.indexOf("="),f=(d>-1?c.slice(0,d):c).trim();f&&r.forEach(h=>{const p=h?`;domain=${h}`:"";document.cookie=`${f}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${p}`})})}function E1(){Ip(localStorage),Ip(sessionStorage),T1()}function M1({isOpen:r,onClose:l}){const{theme:i,updateTheme:c}=cs(),{settings:d,updateSettings:f}=Vo(),[h,p]=g.useState(!1),x=g.useRef(null),v=g.useRef(null),b=A=>{c({mode:A})},w=()=>{f({soundEnabled:!d.soundEnabled})},k=()=>{p(!0)},S=()=>{p(!1)},_=()=>{S(),Zo(),Ko(!1),os(null),Ma.getState().closeLoginPrompt(),E1(),window.location.reload()};return ui(x,{enabled:r&&!h,onEscape:l}),ui(v,{enabled:h,onEscape:S}),r?u.jsxs("div",{className:"fixed inset-0 z-50 flex items-end md:items-center justify-center overflow-y-auto bg-black/50 p-0 md:p-4",children:[u.jsx("button",{type:"button",onClick:l,"aria-label":"Close settings overlay",className:"absolute inset-0"}),u.jsxs("div",{onClick:A=>A.stopPropagation(),ref:x,role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",tabIndex:-1,className:"relative flex h-[100dvh] w-full max-w-none flex-col overflow-hidden bg-white shadow-2xl dark:bg-[#1a1b1e] md:h-auto md:max-h-[90vh] md:max-w-md md:rounded-2xl",children:[u.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between border-b border-gray-200 px-6 pb-4 pt-[max(env(safe-area-inset-top),1rem)] dark:border-[#2d2f39] md:p-6",children:[u.jsx("h2",{id:"settings-title",className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:"Settings"}),u.jsx("button",{onClick:l,className:"p-2 hover:bg-gray-100 dark:hover:bg-[#25262f] rounded-lg transition-colors","aria-label":"Close settings",children:u.jsx(ba,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})]}),u.jsxs("div",{className:"flex-1 min-h-0 space-y-6 overflow-y-auto px-6 pb-[max(env(safe-area-inset-bottom),1.25rem)] pt-6 md:p-6",children:[u.jsxs("div",{className:"space-y-4",children:[u.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 flex items-center gap-2",children:[u.jsx(Zx,{className:"w-5 h-5"}),"Appearance"]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Theme"}),u.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{value:"light",label:"Light",icon:sb},{value:"dark",label:"Dark",icon:Qx},{value:"system",label:"System",icon:Yx}].map(({value:A,label:D,icon:O})=>u.jsxs("button",{onClick:()=>b(A),className:`flex flex-col items-center gap-2 p-3 rounded-lg border-2 transition-all duration-200 ${i.mode===A?"border-blue-500 bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"border-gray-200 dark:border-[#2d2f39] hover:border-gray-300 dark:hover:border-[#43465a] text-gray-700 dark:text-gray-300"}`,children:[u.jsx(O,{className:"w-5 h-5"}),u.jsx("span",{className:"text-sm font-medium",children:D})]},A))})]})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Chat Preferences"}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx($o,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"}),u.jsxs("div",{children:[u.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Sound Effects"}),u.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Play sounds for notifications and events"})]})]}),u.jsx("button",{onClick:w,role:"switch","aria-checked":d.soundEnabled,"aria-label":"Toggle sound effects",className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${d.soundEnabled?"bg-blue-600":"bg-gray-200 dark:bg-[#3c3f4a]"}`,children:u.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${d.soundEnabled?"translate-x-6":"translate-x-1"}`})})]})]}),u.jsxs("div",{className:"space-y-4 pt-4 border-t border-gray-200 dark:border-[#2d2f39]",children:[u.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 flex items-center gap-2",children:[u.jsx(sg,{className:"w-5 h-5"}),"Data Management"]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Clear all application data including conversations, and personalized settings."}),u.jsx("button",{onClick:k,className:"w-full px-4 py-2 text-sm font-medium text-red-600 dark:text-red-400 border border-red-300 dark:border-red-700 rounded-lg hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:"Reset Application"})]})]}),u.jsxs("p",{className:"pt-2 text-center text-xs text-gray-400 dark:text-[#858999]",children:["v",Md]})]}),h&&u.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/70 p-4",children:u.jsxs("div",{ref:v,role:"dialog","aria-modal":"true","aria-labelledby":"reset-dialog-title",tabIndex:-1,className:"max-h-[calc(100dvh-2rem)] w-full max-w-sm overflow-y-auto rounded-2xl border border-red-100 bg-white p-6 shadow-2xl dark:border-red-800/60 dark:bg-[#111113]",children:[u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"mt-0.5 flex h-10 w-10 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/40",children:u.jsx(wd,{className:"w-5 h-5 text-red-600 dark:text-red-400"})}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("p",{id:"reset-dialog-title",className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:"Reset application data?"}),u.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"This removes everything stored on this device and reloads the app."})]})]}),u.jsxs("div",{className:"mt-4 flex gap-2 pt-2",children:[u.jsx("button",{onClick:S,className:"flex-1 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-[#2d2f39] rounded-lg hover:bg-gray-50 dark:hover:bg-[#1a1b1e] transition-colors",children:"Cancel"}),u.jsx("button",{onClick:_,className:"flex-1 px-4 py-2 text-sm font-semibold rounded-lg transition-colors bg-red-600 text-white hover:bg-red-700 dark:bg-red-700 dark:hover:bg-red-600",children:"Reset"})]})]})})]})]}):null}function z1({message:r}){const l=kd();return u.jsx("main",{className:"min-h-dvh bg-white px-4 py-6 text-slate-950 dark:bg-black dark:text-slate-100 sm:px-6 lg:px-8",children:u.jsxs("div",{className:"mx-auto flex min-h-[calc(100dvh-3rem)] w-full max-w-5xl flex-col",children:[u.jsxs("header",{className:"flex items-center justify-between gap-4",children:[u.jsx("p",{className:"min-w-0 truncate text-lg font-semibold tracking-tight sm:text-xl",children:l}),u.jsxs("span",{className:"shrink-0 text-xs font-medium text-slate-400 dark:text-[#858999]",children:["v",Md]})]}),u.jsx("section",{className:"flex flex-1 items-center justify-center py-12",children:u.jsxs("div",{className:"w-full max-w-lg space-y-8",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("span",{className:"relative flex h-2.5 w-2.5 shrink-0",children:[u.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-60 dark:bg-amber-500"}),u.jsx("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full bg-amber-500 dark:bg-amber-400"})]}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-widest text-amber-700 dark:text-amber-400",children:"Service paused"})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-slate-950 dark:text-white sm:text-4xl",children:"Temporarily unavailable"}),u.jsx("p",{className:"max-w-md whitespace-pre-wrap text-base leading-relaxed text-slate-500 dark:text-slate-400",children:r})]}),u.jsx("div",{className:"border-t border-slate-200 dark:border-[#242424]"}),u.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[u.jsxs("button",{type:"button",onClick:()=>window.location.reload(),className:"inline-flex items-center justify-center gap-2 rounded-lg bg-slate-950 px-5 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:bg-white dark:text-slate-950 dark:hover:bg-slate-200",children:[u.jsx(nb,{className:"h-4 w-4","aria-hidden":"true"}),"Try again"]}),u.jsx("span",{className:"hidden text-slate-300 dark:text-slate-700 sm:block","aria-hidden":"true",children:"·"})]})]})})]})})}function D1({children:r}){const{instance:l,accounts:i}=gd(),c=wx();return g.useEffect(()=>{Ko(c)},[c]),g.useEffect(()=>{if(!c||i.length===0){os(null);return}const d=i[0];os(d.username||d.name||d.localAccountId||null)},[c,i]),g.useEffect(()=>{if(!c||i.length===0)return;const d=i[0],f=Cd();return pg(async()=>(await l.acquireTokenSilent({scopes:f,account:d})).accessToken),()=>Zo()},[c,i,l]),u.jsx(u.Fragment,{children:r})}function L1({children:r}){return u.jsx(D1,{children:r})}function R1({children:r}){const{isLoading:l,isAuthenticated:i,getAccessTokenSilently:c,user:d}=xd();return g.useEffect(()=>{Ko(i)},[i]),g.useEffect(()=>{if(!i){os(null);return}const f=(d==null?void 0:d.sub)||(d==null?void 0:d.email)||(d==null?void 0:d.nickname)||(d==null?void 0:d.name)||null;os(f)},[i,d]),g.useEffect(()=>(i&&pg(()=>c()),()=>Zo()),[i,c]),l?u.jsx("div",{className:"flex items-center justify-center h-screen bg-white dark:bg-[#212121]",children:u.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 dark:border-gray-100"})}):u.jsx(u.Fragment,{children:r})}function U1({children:r}){return g.useEffect(()=>{Ko(!1),os(null),Zo()},[]),u.jsx(u.Fragment,{children:r})}function O1({children:r}){return Ea()?Yo()==="entra"?u.jsx(L1,{children:r}):u.jsx(R1,{children:r}):u.jsx(U1,{children:r})}function $1(){const r=Ad(),l=Ea(),i=us(),{showLoginPrompt:c,promptMessage:d,closeLoginPrompt:f}=Ma();return g.useEffect(()=>{c&&(!r||!l||i)&&f()},[c,r,l,i,f]),!r||!l||i||!c?null:Yo()==="entra"?u.jsx(B1,{message:d,onClose:f}):u.jsx(q1,{message:d,onClose:f})}function q1({message:r,onClose:l}){const{loginWithRedirect:i}=xd();return u.jsx(Og,{message:r,onClose:l,onLogin:()=>i()})}function B1({message:r,onClose:l}){const{instance:i}=gd();return u.jsx(Og,{message:r,onClose:l,onLogin:()=>i.loginRedirect({scopes:Cd()}).catch(()=>{})})}function Og({message:r,onClose:l,onLogin:i}){return u.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center",children:[u.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:l,"aria-hidden":"true"}),u.jsxs("div",{className:"relative z-10 mx-4 w-full max-w-md rounded-2xl border border-gray-200 bg-white p-6 shadow-2xl dark:border-[#4a4b54] dark:bg-[#2d2f39]",children:[u.jsx("button",{onClick:l,className:"absolute right-3 top-3 rounded-full p-1.5 text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]","aria-label":"Close",children:u.jsx(ba,{className:"h-4 w-4"})}),u.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[u.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/40",children:u.jsx(ag,{className:"h-5 w-5 text-blue-600 dark:text-blue-300"})}),u.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-[#ececf1]",children:"Sign in for more"})]}),u.jsx("p",{className:"mb-6 text-sm leading-relaxed text-gray-600 dark:text-[#bfc2cd]",children:r}),u.jsxs("div",{className:"flex gap-3",children:[u.jsx("button",{onClick:i,className:"flex-1 rounded-lg bg-blue-600 px-4 py-2.5 text-sm font-medium text-white shadow-sm hover:bg-blue-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:bg-blue-500 dark:hover:bg-blue-600",children:"Sign in"}),u.jsx("button",{onClick:l,className:"flex-1 rounded-lg border border-gray-300 bg-white px-4 py-2.5 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-400 dark:border-[#4a4b54] dark:bg-[#2d2f39] dark:text-[#bfc2cd] dark:hover:bg-[#3c3f4a]",children:"Cancel"})]})]})]})}function H1(){const{goHome:r}=Rg(),{isDark:l}=cs(),i=Kv(),c=g.useRef(!1),d=dy(),f=fy(),h=my(),p=l?h:f,x=hy(),v=py(),b=!!(x||v),w=gy(),k=xy(),S=by(),_=mg(),A=S?"border-b border-slate-200/80 dark:border-[#333645]":"",D="inline-flex min-h-10 items-center rounded-md px-2.5 text-sm font-medium transition-colors hover:bg-slate-100 hover:text-blue-700 hover:no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:hover:bg-[#2b2d39] dark:hover:text-blue-300";return g.useEffect(()=>{c.current},[h,d,f]),cd()?u.jsx("header",{className:`relative z-30 shrink-0 bg-white px-3 pb-1 pt-2 dark:bg-black sm:px-5 sm:pb-2 sm:pt-3 lg:px-8 md:pt-5 ${A}`.trim(),style:{backgroundColor:w||void 0,color:k||void 0},children:u.jsxs("div",{className:"mx-auto flex w-full max-w-[96rem] items-center justify-between gap-3",children:[u.jsx("div",{className:"flex min-w-0 flex-1 items-center justify-center gap-2 md:justify-start md:gap-3",children:u.jsx("a",{href:i,"aria-label":"Go to home page",onClick:O=>{O.preventDefault(),r()},className:"inline-flex items-center rounded-sm px-1 py-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-300 dark:focus-visible:ring-offset-black md:-ml-1",children:u.jsx("img",{src:p,alt:"Logo",draggable:!1,className:`block max-w-full flex-shrink-0 select-none ${b?"":"h-8 w-auto sm:h-10 md:h-11"}`.trim(),style:{WebkitUserDrag:"none",...x?{height:x}:{},...v?{width:v}:{}}})})}),u.jsxs("div",{className:"hidden min-w-0 flex-1 items-center justify-end gap-2 sm:gap-4 md:flex",children:[_.length>0&&u.jsx("nav",{"aria-label":"Header links",className:"hidden sm:block",children:u.jsx("ul",{className:"flex items-center gap-1.5 sm:gap-2",children:_.map(O=>u.jsx("li",{children:u.jsx("a",{href:O.url,target:"_blank",rel:"noopener noreferrer",className:D,style:{color:k||void 0},children:O.label})},O.url))})}),u.jsx(md,{})]})]})}):null}function F1({children:r}){const l=g.useRef(null),i=g.useCallback(d=>{l.current=d},[]),c=g.useCallback(()=>{var d;(d=l.current)==null||d.call(l)},[]);return u.jsx(Lg.Provider,{value:{registerGoHome:i,goHome:c},children:r})}function I1(){const[r,l]=g.useState(!1),[i,c]=g.useState(!1),[d,f]=g.useState(()=>localStorage.getItem("desktop-sidebar-collapsed")==="true"),h=Ye(v=>v.conversations),p=iy();if(g.useEffect(()=>{localStorage.setItem("desktop-sidebar-collapsed",String(d))},[d]),p)return u.jsx(up,{children:u.jsx(z1,{message:p})});const x=h.some(v=>{var b;return(v.messages.length>0||(((b=v.attachedFiles)==null?void 0:b.length)??0)>0)&&!v.adapterLoadError});return u.jsx(up,{children:u.jsx(Ex,{children:u.jsx(O1,{children:u.jsx(F1,{children:u.jsxs("div",{className:"h-dvh flex flex-col bg-white dark:bg-black text-slate-900 dark:text-slate-100",children:[u.jsxs("div",{className:"flex-1 flex flex-col md:flex-row md:pl-4 min-h-0",children:[x&&(d?u.jsx("div",{className:"hidden md:flex md:w-16 md:h-full shrink-0 items-start justify-center pt-8",children:u.jsx("button",{type:"button",onClick:()=>f(!1),className:"inline-flex h-9 w-9 items-center justify-center rounded-xl border border-slate-200/80 bg-white text-slate-600 transition-colors hover:border-slate-300 hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:border-[#333645] dark:bg-[#161616] dark:text-[#d1d5db] dark:hover:border-[#43465a] dark:hover:bg-[#202020] dark:hover:text-white","aria-label":"Open sidebar",title:"Open sidebar",children:u.jsx(Jx,{className:"h-4 w-4"})})}):u.jsx("div",{className:"hidden md:h-full md:flex",children:u.jsx(Fp,{onToggleDesktopSidebar:()=>f(!0)})})),u.jsxs("div",{className:"flex-1 flex flex-col w-full min-h-0",children:[u.jsx(H1,{}),u.jsx("div",{className:"flex-1 flex justify-center w-full min-h-0",children:u.jsx(v1,{onOpenSettings:()=>l(!0),onOpenSidebar:()=>c(!0)})})]})]}),u.jsx($1,{}),u.jsx(M1,{isOpen:r,onClose:()=>l(!1)}),i&&u.jsxs("div",{className:"fixed inset-0 z-50 flex md:hidden",children:[u.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>c(!1),"aria-hidden":"true"}),u.jsxs("div",{className:"relative z-10 h-full w-[min(20rem,90vw)] animate-slideIn bg-white dark:bg-black",children:[u.jsx(Fp,{onRequestClose:()=>c(!1)}),u.jsx("button",{onClick:()=>c(!1),className:"absolute -right-3 top-[max(env(safe-area-inset-top),0.75rem)] rounded-full bg-white/95 p-3 text-gray-600 shadow-lg active:scale-95 transition-transform dark:bg-[#2d2f39] dark:text-[#ececf1]","aria-label":"Close menu",children:u.jsx(ba,{className:"h-5 w-5"})})]})]})]})})})})})}const rd=new Sx({auth:{clientId:dg(),authority:`https://login.microsoftonline.com/${uy()}`,redirectUri:typeof window<"u"?window.location.origin:"/"},cache:{cacheLocation:"sessionStorage"}});function G1({children:r}){const[l,i]=g.useState(!1);return g.useEffect(()=>{rd.initialize().then(()=>rd.handleRedirectPromise()).catch(c=>{console.error("[EntraAuth] Redirect processing failed:",c)}).finally(()=>i(!0))},[]),l?u.jsx(kx,{instance:rd,children:r}):null}function V1({children:r}){if(!Ad()||!Ea())return u.jsx(u.Fragment,{children:r});if(Yo()==="entra")return u.jsx(G1,{children:r});const i=oy(),c=dg(),d=cy();return!i||!c?u.jsx(u.Fragment,{children:r}):u.jsx(_x,{domain:i,clientId:c,authorizationParams:{redirect_uri:window.location.origin,...d?{audience:d}:{}},cacheLocation:"memory",children:r})}Ug(null);const Gp=Wb(),Vp=document.querySelector('link[rel="icon"]');if(Vp)Vp.href=Gp;else{const r=document.createElement("link");r.rel="icon",r.href=Gp,document.head.appendChild(r)}const X1=Ay();var Xp,Yp,Qp,Zp,Kp,Jp;for(const r of X1){const l=((Xp=r.src)==null?void 0:Xp.trim())||"",i=((Yp=r.content)==null?void 0:Yp.trim())||"",c=((Qp=r.id)==null?void 0:Qp.trim())||"";if(!l&&!i||c&&document.querySelector(`script[data-orbitchat-startup-script-id="${c}"]`)||Array.from(document.querySelectorAll("script[data-orbitchat-startup-script]")).some(h=>{const p=l&&h.dataset.orbitchatStartupScriptSrc===l,x=i&&(h.textContent||"").trim()===i;return!!(p||x)}))continue;const f=document.createElement("script");l&&(f.src=l),i&&(f.text=i),f.async=r.async??!0,r.defer!==void 0&&(f.defer=r.defer),(Zp=r.type)!=null&&Zp.trim()&&(f.type=r.type.trim()),(Kp=r.integrity)!=null&&Kp.trim()&&(f.integrity=r.integrity.trim()),r.crossOrigin&&(f.crossOrigin=r.crossOrigin),(Jp=r.referrerPolicy)!=null&&Jp.trim()&&(f.referrerPolicy=r.referrerPolicy.trim()),f.dataset.orbitchatStartupScript="true",c&&(f.dataset.orbitchatStartupScriptId=c),l&&(f.dataset.orbitchatStartupScriptSrc=l),document.head.appendChild(f)}ne("🚀 AI Chat Application started");ne(`📱 App Version: v${Md}`);Tx.createRoot(document.getElementById("root")).render(u.jsx(g.StrictMode,{children:u.jsx(V1,{children:u.jsx(I1,{})})}));export{Qo as r};
366
+ ${Ee?"bg-slate-100 dark:bg-[#2a2b36]":"hover:bg-slate-100/70 dark:hover:bg-[#25262f]"} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-500/50 dark:focus-visible:ring-sky-400/40`,"aria-current":Ee?"true":void 0,"aria-label":`Open conversation: ${se.title}`,children:A===se.id?u.jsx("input",{type:"text",value:O,onChange:we=>ee(we.target.value.slice(0,zo)),onKeyDown:we=>{we.key==="Enter"&&Le(se.id),we.key==="Escape"&&qe(),we.stopPropagation()},onBlur:()=>Le(se.id),maxLength:zo,className:"flex-1 rounded border border-sky-300 bg-white px-2 py-0.5 text-sm text-[#353740] focus:outline-none focus:ring-2 focus:ring-sky-400/50 dark:border-sky-500/40 dark:bg-[#1a1b1e] dark:text-[#ececf1]",autoFocus:!0,"aria-label":"Edit conversation title"}):u.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[u.jsx("h3",{className:`flex-1 truncate text-sm leading-snug ${Ee?"font-medium text-slate-900 dark:text-[#ececf1]":"font-normal text-slate-700 dark:text-[#c5c8d6]"}`,children:se.title}),u.jsxs("div",{className:"ml-1 flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity duration-100 group-hover:opacity-100 group-focus-within:opacity-100",children:[u.jsx("button",{onClick:we=>Te(we,se),className:"rounded p-1 text-slate-400 transition-colors hover:bg-slate-200/80 hover:text-slate-600 dark:text-[#6b6f7a] dark:hover:bg-[#3c3f4a] dark:hover:text-[#c5c8d6]","aria-label":`Rename conversation: ${se.title}`,children:u.jsx(ng,{className:"h-3 w-3"})}),u.jsx("button",{onClick:we=>xe(we,se),className:"rounded p-1 text-slate-400 transition-colors hover:bg-red-100/80 hover:text-red-600 dark:text-[#6b6f7a] dark:hover:bg-red-900/30 dark:hover:text-red-400","aria-label":`Delete conversation: ${se.title}`,children:u.jsx(sg,{className:"h-3 w-3"})})]})]}),zt&&u.jsx("span",{className:"truncate text-[11px] leading-none text-slate-400 dark:text-[#6b6f7a]",children:zt})]})},se.id)};return u.jsxs(u.Fragment,{children:[!i&&j&&u.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm px-4",children:u.jsxs("div",{ref:oe,role:"dialog","aria-modal":"true","aria-labelledby":"select-agent-title",tabIndex:-1,className:"w-full max-w-md rounded-2xl border border-gray-200 bg-white p-6 shadow-2xl dark:border-[#3d4050] dark:bg-[#1a1b1e]",children:[u.jsx("h2",{id:"select-agent-title",className:"mb-4 text-lg font-semibold text-gray-900 dark:text-[#ececf1]",children:"Select an Agent"}),u.jsxs("div",{className:"space-y-5",children:[u.jsx(w1,{selectedAdapter:re,onAdapterChange:ae,disabled:P,variant:"prominent",showDescriptions:!0,showLabel:!1}),ce&&u.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-600/40 dark:bg-red-900/30 dark:text-red-200",children:ce}),u.jsx("div",{className:"flex justify-end gap-3 pt-2",children:u.jsx("button",{type:"button",onClick:()=>{te(null),q(!1)},className:"rounded-lg px-4 py-2 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:text-[#d1d5db] dark:hover:bg-[#2d2f39]",disabled:P,children:"Cancel"})})]})]})}),u.jsxs("nav",{"aria-label":"Conversation sidebar",className:"flex h-full md:h-[calc(100%-2rem)] md:mt-4 w-full md:w-72 flex-col border-r border-b border-gray-200 md:border-l md:border-t md:rounded-2xl md:overflow-hidden bg-transparent dark:border-[#2d2f39]",children:[u.jsxs("div",{className:"bg-transparent px-4 pb-4 pt-4 dark:border-[#2d2f39]",children:[u.jsxs("div",{className:"flex items-center gap-2 pb-3",children:[c.length>0&&c.some(se=>se.messages.length>0)&&u.jsxs("button",{onClick:Be,className:"flex flex-1 items-center justify-center gap-2 rounded-lg border border-red-200 px-3 py-2 text-sm font-medium text-red-600 transition-all duration-150 hover:bg-red-50 hover:border-red-300 hover:shadow-sm dark:border-red-500/25 dark:text-red-400 dark:hover:bg-red-950/20 dark:hover:border-red-500/40",title:"Delete all conversations",children:[u.jsx(ib,{className:"h-4 w-4"}),"Delete Conversations"]}),l&&u.jsx("button",{type:"button",onClick:l,className:"ml-auto hidden shrink-0 md:inline-flex h-9 w-9 items-center justify-center rounded-xl border border-slate-200/80 bg-white text-slate-600 transition-colors hover:border-slate-300 hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:border-[#333645] dark:bg-[#161616] dark:text-[#d1d5db] dark:hover:border-[#43465a] dark:hover:bg-[#202020] dark:hover:text-white","aria-label":"Close sidebar",title:"Close sidebar",children:u.jsx(Kx,{className:"h-4 w-4"})})]}),ce&&!j&&u.jsx("p",{role:"alert",className:"mt-2 text-xs text-red-600 dark:text-red-400",children:ce}),fe&&u.jsxs("div",{className:"border-t border-gray-200 pt-4 mt-4 dark:border-[#2d2f39]",children:[u.jsxs("div",{className:"relative overflow-hidden rounded-[1.75rem] border border-slate-200/85 bg-[linear-gradient(180deg,rgba(255,255,255,0.96),rgba(248,250,252,0.94))] shadow-[0_10px_28px_rgba(15,23,42,0.05)] transition-all duration-200 focus-within:border-sky-300/90 focus-within:shadow-[0_0_0_1px_rgba(125,211,252,0.55),0_10px_28px_rgba(15,23,42,0.05)] dark:border-white/10 dark:bg-[linear-gradient(180deg,rgba(37,39,49,0.95),rgba(29,31,39,0.92))] dark:shadow-[0_12px_30px_rgba(0,0,0,0.2)] dark:focus-within:border-sky-400/30 dark:focus-within:shadow-[0_0_0_1px_rgba(56,189,248,0.22),0_12px_30px_rgba(0,0,0,0.2)]",children:[u.jsx("div",{className:"pointer-events-none absolute inset-0 rounded-[inherit] bg-[linear-gradient(180deg,rgba(255,255,255,0.45),rgba(255,255,255,0))] dark:bg-[linear-gradient(180deg,rgba(255,255,255,0.03),rgba(255,255,255,0))]"}),u.jsx(yd,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400 dark:text-slate-500"}),u.jsx("input",{ref:Y,type:"text",role:"searchbox","aria-label":"Search conversations",placeholder:"Search Conversations",value:S,onChange:se=>_(se.target.value),className:"relative z-10 w-full bg-transparent py-3 pl-11 pr-11 text-sm font-medium text-slate-700 placeholder:font-normal placeholder:text-slate-400 focus:outline-none dark:text-slate-100 dark:placeholder:text-slate-500"}),S&&u.jsx("button",{type:"button",onClick:()=>{var se;_(""),(se=Y.current)==null||se.focus()},className:"absolute right-3 top-1/2 z-10 inline-flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-full border border-slate-200/80 bg-white/90 text-slate-400 transition-colors hover:border-slate-300 hover:text-slate-600 focus:outline-none focus:ring-2 focus:ring-sky-200 dark:border-white/10 dark:bg-white/5 dark:text-slate-500 dark:hover:border-white/20 dark:hover:text-slate-200 dark:focus:ring-sky-500/20","aria-label":"Clear search",children:u.jsx(ba,{className:"h-3.5 w-3.5"})})]}),de&&u.jsx("p",{"aria-live":"polite",className:"mt-2 text-center text-[11px] tabular-nums text-gray-400 dark:text-[#6e7490]",children:pe.length===0?"No results":`${pe.length} ${pe.length===1?"result":"results"}`})]})]}),u.jsx("div",{ref:E,role:"listbox","aria-label":"Conversations",onKeyDown:ye,className:"flex-1 overflow-y-auto bg-transparent px-3 py-2",children:pe.length===0?null:de?u.jsx("div",{className:"space-y-1",children:pe.map(st)}):u.jsx("div",{className:"space-y-4",children:G.map(se=>u.jsxs("section",{"aria-label":se.label,children:[u.jsx("h4",{className:"sticky top-0 z-10 mb-1 bg-transparent px-1 pb-1 pt-0.5 text-[11px] font-semibold uppercase tracking-wider text-gray-400 backdrop-blur-sm dark:text-[#6e7490]",children:se.label}),u.jsx("div",{className:"space-y-1",children:se.conversations.map(st)})]},se.label))})}),(()=>{const se=mg();return se.length===0?null:u.jsx("div",{className:"shrink-0 border-t border-gray-200/80 px-4 py-3 md:hidden dark:border-[#2d2f39]",children:u.jsx("nav",{"aria-label":"Header links",children:u.jsx("ul",{className:"flex flex-wrap gap-2",children:se.map(Ee=>u.jsx("li",{children:u.jsx("a",{href:Ee.url,className:"inline-flex items-center rounded-md px-2.5 py-1.5 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100 dark:text-[#d1d5db] dark:hover:bg-[#2b2d39]",children:Ee.label})},Ee.url))})})})})(),u.jsx("div",{className:"shrink-0 border-t border-gray-200/80 dark:border-[#2d2f39]",children:u.jsx(Mg,{placement:"sidebar",compact:!0})})]}),u.jsx(Bo,{isOpen:U.isOpen,onClose:ve,onConfirm:Ne,title:"Delete Conversation",message:`Are you sure you want to delete "${U.conversationTitle}"? This will clear the conversation history.`,confirmText:"Delete",cancelText:"Cancel",type:"danger",isLoading:U.isDeleting}),u.jsx(Bo,{isOpen:H.isOpen,onClose:He,onConfirm:Ge,title:"Clear All Conversations",message:me===1?"Are you sure you want to delete this conversation? This will clear all conversation history.":`Are you sure you want to delete all ${me} conversations? This will clear all conversation history.`,confirmText:"Clear All",cancelText:"Cancel",type:"danger",isLoading:H.isDeleting})]})}const _1="3.10.9",A1={version:_1},Md=A1.version,C1=["@@auth0spajs@@","a0.spajs","auth0","com.auth0"];function j1(r){const l=r.toLowerCase();return C1.some(i=>l.includes(i.toLowerCase()))}function N1(r){const l=[];for(let i=0;i<r.length;i++){const c=r.key(i);c&&j1(c)&&l.push(c)}l.forEach(i=>r.removeItem(i))}function Ip(r){try{N1(r),r.clear()}catch(l){console.warn("[Settings] Failed to clear browser storage during reset.",l)}}function T1(){if(typeof document>"u"||!document.cookie)return;const r=new Set([void 0]),l=window.location.hostname;l&&l!=="localhost"&&!/^\d{1,3}(?:\.\d{1,3}){3}$/.test(l)&&(r.add(l),r.add(`.${l}`)),document.cookie.split(";").forEach(c=>{const d=c.indexOf("="),f=(d>-1?c.slice(0,d):c).trim();f&&r.forEach(h=>{const p=h?`;domain=${h}`:"";document.cookie=`${f}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${p}`})})}function E1(){Ip(localStorage),Ip(sessionStorage),T1()}function M1({isOpen:r,onClose:l}){const{theme:i,updateTheme:c}=cs(),{settings:d,updateSettings:f}=Vo(),[h,p]=g.useState(!1),x=g.useRef(null),v=g.useRef(null),b=A=>{c({mode:A})},w=()=>{f({soundEnabled:!d.soundEnabled})},k=()=>{p(!0)},S=()=>{p(!1)},_=()=>{S(),Zo(),Ko(!1),os(null),Ma.getState().closeLoginPrompt(),E1(),window.location.reload()};return ui(x,{enabled:r&&!h,onEscape:l}),ui(v,{enabled:h,onEscape:S}),r?u.jsxs("div",{className:"fixed inset-0 z-50 flex items-end md:items-center justify-center overflow-y-auto bg-black/50 p-0 md:p-4",children:[u.jsx("button",{type:"button",onClick:l,"aria-label":"Close settings overlay",className:"absolute inset-0"}),u.jsxs("div",{onClick:A=>A.stopPropagation(),ref:x,role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",tabIndex:-1,className:"relative flex h-[100dvh] w-full max-w-none flex-col overflow-hidden bg-white shadow-2xl dark:bg-[#1a1b1e] md:h-auto md:max-h-[90vh] md:max-w-md md:rounded-2xl",children:[u.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between border-b border-gray-200 px-6 pb-4 pt-[max(env(safe-area-inset-top),1rem)] dark:border-[#2d2f39] md:p-6",children:[u.jsx("h2",{id:"settings-title",className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:"Settings"}),u.jsx("button",{onClick:l,className:"p-2 hover:bg-gray-100 dark:hover:bg-[#25262f] rounded-lg transition-colors","aria-label":"Close settings",children:u.jsx(ba,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})]}),u.jsxs("div",{className:"flex-1 min-h-0 space-y-6 overflow-y-auto px-6 pb-[max(env(safe-area-inset-bottom),1.25rem)] pt-6 md:p-6",children:[u.jsxs("div",{className:"space-y-4",children:[u.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 flex items-center gap-2",children:[u.jsx(Zx,{className:"w-5 h-5"}),"Appearance"]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Theme"}),u.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{value:"light",label:"Light",icon:sb},{value:"dark",label:"Dark",icon:Qx},{value:"system",label:"System",icon:Yx}].map(({value:A,label:D,icon:O})=>u.jsxs("button",{onClick:()=>b(A),className:`flex flex-col items-center gap-2 p-3 rounded-lg border-2 transition-all duration-200 ${i.mode===A?"border-blue-500 bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"border-gray-200 dark:border-[#2d2f39] hover:border-gray-300 dark:hover:border-[#43465a] text-gray-700 dark:text-gray-300"}`,children:[u.jsx(O,{className:"w-5 h-5"}),u.jsx("span",{className:"text-sm font-medium",children:D})]},A))})]})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Chat Preferences"}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx($o,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"}),u.jsxs("div",{children:[u.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Sound Effects"}),u.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Play sounds for notifications and events"})]})]}),u.jsx("button",{onClick:w,role:"switch","aria-checked":d.soundEnabled,"aria-label":"Toggle sound effects",className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${d.soundEnabled?"bg-blue-600":"bg-gray-200 dark:bg-[#3c3f4a]"}`,children:u.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${d.soundEnabled?"translate-x-6":"translate-x-1"}`})})]})]}),u.jsxs("div",{className:"space-y-4 pt-4 border-t border-gray-200 dark:border-[#2d2f39]",children:[u.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 flex items-center gap-2",children:[u.jsx(sg,{className:"w-5 h-5"}),"Data Management"]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Clear all application data including conversations, and personalized settings."}),u.jsx("button",{onClick:k,className:"w-full px-4 py-2 text-sm font-medium text-red-600 dark:text-red-400 border border-red-300 dark:border-red-700 rounded-lg hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:"Reset Application"})]})]}),u.jsxs("p",{className:"pt-2 text-center text-xs text-gray-400 dark:text-[#858999]",children:["v",Md]})]}),h&&u.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/70 p-4",children:u.jsxs("div",{ref:v,role:"dialog","aria-modal":"true","aria-labelledby":"reset-dialog-title",tabIndex:-1,className:"max-h-[calc(100dvh-2rem)] w-full max-w-sm overflow-y-auto rounded-2xl border border-red-100 bg-white p-6 shadow-2xl dark:border-red-800/60 dark:bg-[#111113]",children:[u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"mt-0.5 flex h-10 w-10 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/40",children:u.jsx(wd,{className:"w-5 h-5 text-red-600 dark:text-red-400"})}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("p",{id:"reset-dialog-title",className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:"Reset application data?"}),u.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"This removes everything stored on this device and reloads the app."})]})]}),u.jsxs("div",{className:"mt-4 flex gap-2 pt-2",children:[u.jsx("button",{onClick:S,className:"flex-1 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-[#2d2f39] rounded-lg hover:bg-gray-50 dark:hover:bg-[#1a1b1e] transition-colors",children:"Cancel"}),u.jsx("button",{onClick:_,className:"flex-1 px-4 py-2 text-sm font-semibold rounded-lg transition-colors bg-red-600 text-white hover:bg-red-700 dark:bg-red-700 dark:hover:bg-red-600",children:"Reset"})]})]})})]})]}):null}function z1({message:r}){const l=kd();return u.jsx("main",{className:"min-h-dvh bg-white px-4 py-6 text-slate-950 dark:bg-black dark:text-slate-100 sm:px-6 lg:px-8",children:u.jsxs("div",{className:"mx-auto flex min-h-[calc(100dvh-3rem)] w-full max-w-5xl flex-col",children:[u.jsxs("header",{className:"flex items-center justify-between gap-4",children:[u.jsx("p",{className:"min-w-0 truncate text-lg font-semibold tracking-tight sm:text-xl",children:l}),u.jsxs("span",{className:"shrink-0 text-xs font-medium text-slate-400 dark:text-[#858999]",children:["v",Md]})]}),u.jsx("section",{className:"flex flex-1 items-center justify-center py-12",children:u.jsxs("div",{className:"w-full max-w-lg space-y-8",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("span",{className:"relative flex h-2.5 w-2.5 shrink-0",children:[u.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-60 dark:bg-amber-500"}),u.jsx("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full bg-amber-500 dark:bg-amber-400"})]}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-widest text-amber-700 dark:text-amber-400",children:"Service paused"})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-slate-950 dark:text-white sm:text-4xl",children:"Temporarily unavailable"}),u.jsx("p",{className:"max-w-md whitespace-pre-wrap text-base leading-relaxed text-slate-500 dark:text-slate-400",children:r})]}),u.jsx("div",{className:"border-t border-slate-200 dark:border-[#242424]"}),u.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[u.jsxs("button",{type:"button",onClick:()=>window.location.reload(),className:"inline-flex items-center justify-center gap-2 rounded-lg bg-slate-950 px-5 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:bg-white dark:text-slate-950 dark:hover:bg-slate-200",children:[u.jsx(nb,{className:"h-4 w-4","aria-hidden":"true"}),"Try again"]}),u.jsx("span",{className:"hidden text-slate-300 dark:text-slate-700 sm:block","aria-hidden":"true",children:"·"})]})]})})]})})}function D1({children:r}){const{instance:l,accounts:i}=gd(),c=wx();return g.useEffect(()=>{Ko(c)},[c]),g.useEffect(()=>{if(!c||i.length===0){os(null);return}const d=i[0];os(d.username||d.name||d.localAccountId||null)},[c,i]),g.useEffect(()=>{if(!c||i.length===0)return;const d=i[0],f=Cd();return pg(async()=>(await l.acquireTokenSilent({scopes:f,account:d})).accessToken),()=>Zo()},[c,i,l]),u.jsx(u.Fragment,{children:r})}function L1({children:r}){return u.jsx(D1,{children:r})}function R1({children:r}){const{isLoading:l,isAuthenticated:i,getAccessTokenSilently:c,user:d}=xd();return g.useEffect(()=>{Ko(i)},[i]),g.useEffect(()=>{if(!i){os(null);return}const f=(d==null?void 0:d.sub)||(d==null?void 0:d.email)||(d==null?void 0:d.nickname)||(d==null?void 0:d.name)||null;os(f)},[i,d]),g.useEffect(()=>(i&&pg(()=>c()),()=>Zo()),[i,c]),l?u.jsx("div",{className:"flex items-center justify-center h-screen bg-white dark:bg-[#212121]",children:u.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 dark:border-gray-100"})}):u.jsx(u.Fragment,{children:r})}function U1({children:r}){return g.useEffect(()=>{Ko(!1),os(null),Zo()},[]),u.jsx(u.Fragment,{children:r})}function O1({children:r}){return Ea()?Yo()==="entra"?u.jsx(L1,{children:r}):u.jsx(R1,{children:r}):u.jsx(U1,{children:r})}function $1(){const r=Ad(),l=Ea(),i=us(),{showLoginPrompt:c,promptMessage:d,closeLoginPrompt:f}=Ma();return g.useEffect(()=>{c&&(!r||!l||i)&&f()},[c,r,l,i,f]),!r||!l||i||!c?null:Yo()==="entra"?u.jsx(B1,{message:d,onClose:f}):u.jsx(q1,{message:d,onClose:f})}function q1({message:r,onClose:l}){const{loginWithRedirect:i}=xd();return u.jsx(Og,{message:r,onClose:l,onLogin:()=>i()})}function B1({message:r,onClose:l}){const{instance:i}=gd();return u.jsx(Og,{message:r,onClose:l,onLogin:()=>i.loginRedirect({scopes:Cd()}).catch(()=>{})})}function Og({message:r,onClose:l,onLogin:i}){return u.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center",children:[u.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:l,"aria-hidden":"true"}),u.jsxs("div",{className:"relative z-10 mx-4 w-full max-w-md rounded-2xl border border-gray-200 bg-white p-6 shadow-2xl dark:border-[#4a4b54] dark:bg-[#2d2f39]",children:[u.jsx("button",{onClick:l,className:"absolute right-3 top-3 rounded-full p-1.5 text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]","aria-label":"Close",children:u.jsx(ba,{className:"h-4 w-4"})}),u.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[u.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/40",children:u.jsx(ag,{className:"h-5 w-5 text-blue-600 dark:text-blue-300"})}),u.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-[#ececf1]",children:"Sign in for more"})]}),u.jsx("p",{className:"mb-6 text-sm leading-relaxed text-gray-600 dark:text-[#bfc2cd]",children:r}),u.jsxs("div",{className:"flex gap-3",children:[u.jsx("button",{onClick:i,className:"flex-1 rounded-lg bg-blue-600 px-4 py-2.5 text-sm font-medium text-white shadow-sm hover:bg-blue-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:bg-blue-500 dark:hover:bg-blue-600",children:"Sign in"}),u.jsx("button",{onClick:l,className:"flex-1 rounded-lg border border-gray-300 bg-white px-4 py-2.5 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-400 dark:border-[#4a4b54] dark:bg-[#2d2f39] dark:text-[#bfc2cd] dark:hover:bg-[#3c3f4a]",children:"Cancel"})]})]})]})}function H1(){const{goHome:r}=Rg(),{isDark:l}=cs(),i=Kv(),c=g.useRef(!1),d=dy(),f=fy(),h=my(),p=l?h:f,x=hy(),v=py(),b=!!(x||v),w=gy(),k=xy(),S=by(),_=mg(),A=S?"border-b border-slate-200/80 dark:border-[#333645]":"",D="inline-flex min-h-10 items-center rounded-md px-2.5 text-sm font-medium transition-colors hover:bg-slate-100 hover:text-blue-700 hover:no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:hover:bg-[#2b2d39] dark:hover:text-blue-300";return g.useEffect(()=>{c.current},[h,d,f]),cd()?u.jsx("header",{className:`relative z-30 shrink-0 bg-white px-3 pb-1 pt-2 dark:bg-black sm:px-5 sm:pb-2 sm:pt-3 lg:px-8 md:pt-5 ${A}`.trim(),style:{backgroundColor:w||void 0,color:k||void 0},children:u.jsxs("div",{className:"mx-auto flex w-full max-w-[96rem] items-center justify-between gap-3",children:[u.jsx("div",{className:"flex min-w-0 flex-1 items-center justify-center gap-2 md:justify-start md:gap-3",children:u.jsx("a",{href:i,"aria-label":"Go to home page",onClick:O=>{O.preventDefault(),r()},className:"inline-flex items-center rounded-sm px-1 py-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-300 dark:focus-visible:ring-offset-black md:-ml-1",children:u.jsx("img",{src:p,alt:"Logo",draggable:!1,className:`block max-w-full flex-shrink-0 select-none ${b?"":"h-8 w-auto sm:h-10 md:h-11"}`.trim(),style:{WebkitUserDrag:"none",...x?{height:x}:{},...v?{width:v}:{}}})})}),u.jsxs("div",{className:"hidden min-w-0 flex-1 items-center justify-end gap-2 sm:gap-4 md:flex",children:[_.length>0&&u.jsx("nav",{"aria-label":"Header links",className:"hidden sm:block",children:u.jsx("ul",{className:"flex items-center gap-1.5 sm:gap-2",children:_.map(O=>u.jsx("li",{children:u.jsx("a",{href:O.url,target:"_blank",rel:"noopener noreferrer",className:D,style:{color:k||void 0},children:O.label})},O.url))})}),u.jsx(md,{})]})]})}):null}function F1({children:r}){const l=g.useRef(null),i=g.useCallback(d=>{l.current=d},[]),c=g.useCallback(()=>{var d;(d=l.current)==null||d.call(l)},[]);return u.jsx(Lg.Provider,{value:{registerGoHome:i,goHome:c},children:r})}function I1(){const[r,l]=g.useState(!1),[i,c]=g.useState(!1),[d,f]=g.useState(()=>localStorage.getItem("desktop-sidebar-collapsed")==="true"),h=Ye(v=>v.conversations),p=iy();if(g.useEffect(()=>{localStorage.setItem("desktop-sidebar-collapsed",String(d))},[d]),p)return u.jsx(up,{children:u.jsx(z1,{message:p})});const x=h.some(v=>{var b;return(v.messages.length>0||(((b=v.attachedFiles)==null?void 0:b.length)??0)>0)&&!v.adapterLoadError});return u.jsx(up,{children:u.jsx(Ex,{children:u.jsx(O1,{children:u.jsx(F1,{children:u.jsxs("div",{className:"h-dvh flex flex-col bg-white dark:bg-black text-slate-900 dark:text-slate-100",children:[u.jsxs("div",{className:"flex-1 flex flex-col md:flex-row md:pl-4 min-h-0",children:[x&&(d?u.jsx("div",{className:"hidden md:flex md:w-16 md:h-full shrink-0 items-start justify-center pt-8",children:u.jsx("button",{type:"button",onClick:()=>f(!1),className:"inline-flex h-9 w-9 items-center justify-center rounded-xl border border-slate-200/80 bg-white text-slate-600 transition-colors hover:border-slate-300 hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:border-[#333645] dark:bg-[#161616] dark:text-[#d1d5db] dark:hover:border-[#43465a] dark:hover:bg-[#202020] dark:hover:text-white","aria-label":"Open sidebar",title:"Open sidebar",children:u.jsx(Jx,{className:"h-4 w-4"})})}):u.jsx("div",{className:"hidden md:h-full md:flex",children:u.jsx(Fp,{onToggleDesktopSidebar:()=>f(!0)})})),u.jsxs("div",{className:"flex-1 flex flex-col w-full min-h-0",children:[u.jsx(H1,{}),u.jsx("div",{className:"flex-1 flex justify-center w-full min-h-0",children:u.jsx(v1,{onOpenSettings:()=>l(!0),onOpenSidebar:()=>c(!0)})})]})]}),u.jsx($1,{}),u.jsx(M1,{isOpen:r,onClose:()=>l(!1)}),i&&u.jsxs("div",{className:"fixed inset-0 z-50 flex md:hidden",children:[u.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>c(!1),"aria-hidden":"true"}),u.jsxs("div",{className:"relative z-10 h-full w-[min(20rem,90vw)] animate-slideIn bg-white dark:bg-black",children:[u.jsx(Fp,{onRequestClose:()=>c(!1)}),u.jsx("button",{onClick:()=>c(!1),className:"absolute -right-3 top-[max(env(safe-area-inset-top),0.75rem)] rounded-full bg-white/95 p-3 text-gray-600 shadow-lg active:scale-95 transition-transform dark:bg-[#2d2f39] dark:text-[#ececf1]","aria-label":"Close menu",children:u.jsx(ba,{className:"h-5 w-5"})})]})]})]})})})})})}const rd=new Sx({auth:{clientId:dg(),authority:`https://login.microsoftonline.com/${uy()}`,redirectUri:typeof window<"u"?window.location.origin:"/"},cache:{cacheLocation:"sessionStorage"}});function G1({children:r}){const[l,i]=g.useState(!1);return g.useEffect(()=>{rd.initialize().then(()=>rd.handleRedirectPromise()).catch(c=>{console.error("[EntraAuth] Redirect processing failed:",c)}).finally(()=>i(!0))},[]),l?u.jsx(kx,{instance:rd,children:r}):null}function V1({children:r}){if(!Ad()||!Ea())return u.jsx(u.Fragment,{children:r});if(Yo()==="entra")return u.jsx(G1,{children:r});const i=oy(),c=dg(),d=cy();return!i||!c?u.jsx(u.Fragment,{children:r}):u.jsx(_x,{domain:i,clientId:c,authorizationParams:{redirect_uri:window.location.origin,...d?{audience:d}:{}},cacheLocation:"memory",children:r})}Ug(null);const Gp=Wb(),Vp=document.querySelector('link[rel="icon"]');if(Vp)Vp.href=Gp;else{const r=document.createElement("link");r.rel="icon",r.href=Gp,document.head.appendChild(r)}const X1=Ay();var Xp,Yp,Qp,Zp,Kp,Jp;for(const r of X1){const l=((Xp=r.src)==null?void 0:Xp.trim())||"",i=((Yp=r.content)==null?void 0:Yp.trim())||"",c=((Qp=r.id)==null?void 0:Qp.trim())||"";if(!l&&!i||c&&document.querySelector(`script[data-orbitchat-startup-script-id="${c}"]`)||Array.from(document.querySelectorAll("script[data-orbitchat-startup-script]")).some(h=>{const p=l&&h.dataset.orbitchatStartupScriptSrc===l,x=i&&(h.textContent||"").trim()===i;return!!(p||x)}))continue;const f=document.createElement("script");l&&(f.src=l),i&&(f.text=i),f.async=r.async??!0,r.defer!==void 0&&(f.defer=r.defer),(Zp=r.type)!=null&&Zp.trim()&&(f.type=r.type.trim()),(Kp=r.integrity)!=null&&Kp.trim()&&(f.integrity=r.integrity.trim()),r.crossOrigin&&(f.crossOrigin=r.crossOrigin),(Jp=r.referrerPolicy)!=null&&Jp.trim()&&(f.referrerPolicy=r.referrerPolicy.trim()),f.dataset.orbitchatStartupScript="true",c&&(f.dataset.orbitchatStartupScriptId=c),l&&(f.dataset.orbitchatStartupScriptSrc=l),document.head.appendChild(f)}ne("🚀 AI Chat Application started");ne(`📱 App Version: v${Md}`);Tx.createRoot(document.getElementById("root")).render(u.jsx(g.StrictMode,{children:u.jsx(V1,{children:u.jsx(I1,{})})}));export{Qo as r};