@sciol/xyzen 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/xyzen.es.js +2 -2
- package/dist/xyzen.umd.js +1 -1
- package/package.json +1 -1
package/dist/xyzen.es.js
CHANGED
|
@@ -82386,13 +82386,13 @@ function fce() {
|
|
|
82386
82386
|
}
|
|
82387
82387
|
);
|
|
82388
82388
|
}
|
|
82389
|
-
const hce = !1, mce = !
|
|
82389
|
+
const hce = !1, mce = !0;
|
|
82390
82390
|
console.log("=== Environment Debug ===");
|
|
82391
82391
|
console.log("MODE:", "production");
|
|
82392
82392
|
console.log("isDevelopment:", hce);
|
|
82393
82393
|
console.log("isProduction:", mce);
|
|
82394
82394
|
console.log("VITE_XYZEN_BACKEND_URL:", void 0);
|
|
82395
|
-
const gce = () => "http://localhost:48196", $I = gce();
|
|
82395
|
+
const gce = () => window !== void 0 ? `${window.location.protocol}//${window.location.host}` : "http://localhost:48196", $I = gce();
|
|
82396
82396
|
console.log("Final DEFAULT_BACKEND_URL:", $I);
|
|
82397
82397
|
const bce = 280, Ece = 600, Rk = 380, yce = ({
|
|
82398
82398
|
isActive: e,
|
package/dist/xyzen.umd.js
CHANGED
|
@@ -387,4 +387,4 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
387
387
|
left-0 mb-2 rounded-lg border
|
|
388
388
|
border-neutral-200 bg-white p-3 shadow-lg
|
|
389
389
|
dark:border-neutral-700 dark:bg-neutral-800 z-50`,children:[b.jsxs("div",{className:"mb-2",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(nu,{className:"h-4 w-4 text-indigo-500"}),b.jsx("span",{className:"text-sm font-medium text-neutral-900 dark:text-neutral-100",children:"MCP 工具连接"})]}),b.jsxs("div",{className:"mt-1 text-xs text-neutral-600 dark:text-neutral-400",children:["助手: ",c.agent.name]})]}),b.jsx("div",{className:"space-y-2",children:c.servers.map(k=>b.jsxs("div",{className:`rounded-md bg-neutral-50 p-2
|
|
390
|
-
dark:bg-neutral-700/50`,children:[b.jsxs("div",{className:"flex items-center justify-between",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx("div",{className:`h-2 w-2 rounded-full ${k.status==="online"?"bg-green-500":"bg-red-500"}`}),b.jsx("span",{className:"text-sm font-medium text-neutral-900 dark:text-neutral-100",children:k.name})]}),b.jsxs("span",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:[k.tools?.length||0," 工具"]})]}),k.tools&&k.tools.length>0&&b.jsx("div",{className:"mt-2",children:b.jsxs("div",{className:"flex flex-wrap gap-1",children:[k.tools.slice(0,5).map((_,A)=>b.jsx("span",{className:"inline-block rounded bg-indigo-100 px-2 py-0.5 text-xs text-indigo-700 dark:bg-indigo-900/30 dark:text-indigo-300",children:_.name},A)),k.tools.length>5&&b.jsxs("span",{className:"inline-block rounded bg-neutral-200 px-2 py-0.5 text-xs text-neutral-600 dark:bg-neutral-600 dark:text-neutral-300",children:["+",k.tools.length-5]})]})})]},k.id))}),b.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-white dark:border-t-neutral-800"})]})]})]}),b.jsx("button",{onClick:e,className:"flex items-center justify-center rounded-md p-1.5 text-neutral-500 transition-colors hover:bg-neutral-200/60 hover:text-neutral-700 dark:text-neutral-400 dark:hover:bg-neutral-800/60 dark:hover:text-neutral-300",title:"历史记录",children:b.jsx(yT,{className:"h-4 w-4"})})]})]})})}const tR=()=>{const[e]=v.useState(!1),{createDefaultChannel:t}=Kt();return b.jsxs("div",{className:"flex h-full flex-col items-center justify-center space-y-6 p-4 text-center",children:[b.jsx(ke.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},transition:{duration:.5},className:"rounded-full bg-neutral-100 p-4 dark:bg-neutral-800",children:b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-neutral-500 dark:text-neutral-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:b.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M17 8h2a2 2 0 012 2v6a2 2 0 01-2 2h-2v4l-4-4H9a1.994 1.994 0 01-1.414-.586m0 0L11 14h4a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2v4l.586-.586z"})})}),b.jsxs(ke.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2,duration:.5},children:[b.jsx("h3",{className:"text-lg font-medium text-neutral-900 dark:text-white",children:"开始一个新对话"}),b.jsx("p",{className:"mt-2 max-w-md text-sm text-neutral-600 dark:text-neutral-300",children:"您可以从列表选择一个专业助手,或者直接开始一个自由对话。"})]}),b.jsx(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.4,duration:.5},className:"flex flex-col space-y-3 sm:flex-row sm:space-x-3 sm:space-y-0",children:b.jsx("button",{onClick:()=>t(),disabled:e,className:`flex items-center justify-center rounded-md ${e?"bg-indigo-400 dark:bg-indigo-700":"bg-indigo-600 hover:bg-indigo-700 dark:bg-indigo-500 dark:hover:bg-indigo-600"} px-4 py-2 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2`,children:e?b.jsxs(b.Fragment,{children:[b.jsxs("svg",{className:"mr-2 h-4 w-4 animate-spin",viewBox:"0 0 24 24",children:[b.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),b.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"创建中..."]}):b.jsxs(b.Fragment,{children:[b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"mr-2 h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:b.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"开始新对话"]})})})]})},nR=6048e5,bie=864e5,uc=43200,rR=1440,aR=Symbol.for("constructDateFrom");function fr(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&aR in e?e[aR](t):e instanceof Date?new e.constructor(t):new Date(t)}function Jt(e,t){return fr(t||e,e)}function Eie(e,t,n){const r=Jt(e,n?.in);return isNaN(t)?fr(e,NaN):(r.setDate(r.getDate()+t),r)}let yie={};function nl(){return yie}function xi(e,t){const n=nl(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,a=Jt(e,t?.in),i=a.getDay(),s=(i<r?7:0)+i-r;return a.setDate(a.getDate()-s),a.setHours(0,0,0,0),a}function cc(e,t){return xi(e,{...t,weekStartsOn:1})}function iR(e,t){const n=Jt(e,t?.in),r=n.getFullYear(),a=fr(n,0);a.setFullYear(r+1,0,4),a.setHours(0,0,0,0);const i=cc(a),s=fr(n,0);s.setFullYear(r,0,4),s.setHours(0,0,0,0);const o=cc(s);return n.getTime()>=i.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function dc(e){const t=Jt(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Ss(e,...t){const n=fr.bind(null,e||t.find(r=>typeof r=="object"));return t.map(n)}function pc(e,t){const n=Jt(e,t?.in);return n.setHours(0,0,0,0),n}function vie(e,t,n){const[r,a]=Ss(n?.in,e,t),i=pc(r),s=pc(a),o=+i-dc(i),l=+s-dc(s);return Math.round((o-l)/bie)}function Tie(e,t){const n=iR(e,t),r=fr(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),cc(r)}function fc(e,t){const n=+Jt(e)-+Jt(t);return n<0?-1:n>0?1:n}function ny(e){return fr(e,Date.now())}function sR(e,t,n){const[r,a]=Ss(n?.in,e,t);return+pc(r)==+pc(a)}function Sie(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function xie(e){return!(!Sie(e)&&typeof e!="number"||isNaN(+Jt(e)))}function wie(e,t,n){const[r,a]=Ss(n?.in,e,t),i=r.getFullYear()-a.getFullYear(),s=r.getMonth()-a.getMonth();return i*12+s}function Aie(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function _ie(e,t){return+Jt(e)-+Jt(t)}function kie(e,t){const n=Jt(e,t?.in);return n.setHours(23,59,59,999),n}function Nie(e,t){const n=Jt(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Cie(e,t){const n=Jt(e,t?.in);return+kie(n,t)==+Nie(n,t)}function Iie(e,t,n){const[r,a,i]=Ss(n?.in,e,e,t),s=fc(a,i),o=Math.abs(wie(a,i));if(o<1)return 0;a.getMonth()===1&&a.getDate()>27&&a.setDate(30),a.setMonth(a.getMonth()-s*o);let l=fc(a,i)===-s;Cie(r)&&o===1&&fc(r,i)===1&&(l=!1);const u=s*(o-+l);return u===0?0:u}function Rie(e,t,n){const r=_ie(e,t)/1e3;return Aie(n?.roundingMethod)(r)}function Oie(e,t){const n=Jt(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const Lie={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Die=(e,t,n)=>{let r;const a=Lie[e];return typeof a=="string"?r=a:t===1?r=a.one:r=a.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function xs(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Mie={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Pie={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Fie={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Bie={date:xs({formats:Mie,defaultWidth:"full"}),time:xs({formats:Pie,defaultWidth:"full"}),dateTime:xs({formats:Fie,defaultWidth:"full"})},Uie={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Hie=(e,t,n,r)=>Uie[e];function Wr(e){return(t,n)=>{const r=n?.context?String(n.context):"standalone";let a;if(r==="formatting"&&e.formattingValues){const s=e.defaultFormattingWidth||e.defaultWidth,o=n?.width?String(n.width):s;a=e.formattingValues[o]||e.formattingValues[s]}else{const s=e.defaultWidth,o=n?.width?String(n.width):e.defaultWidth;a=e.values[o]||e.values[s]}const i=e.argumentCallback?e.argumentCallback(t):t;return a[i]}}const $ie={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},zie={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},qie={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},jie={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Gie={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Vie={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Wie={ordinalNumber:(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},era:Wr({values:$ie,defaultWidth:"wide"}),quarter:Wr({values:zie,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Wr({values:qie,defaultWidth:"wide"}),day:Wr({values:jie,defaultWidth:"wide"}),dayPeriod:Wr({values:Gie,defaultWidth:"wide",formattingValues:Vie,defaultFormattingWidth:"wide"})};function Yr(e){return(t,n={})=>{const r=n.width,a=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],i=t.match(a);if(!i)return null;const s=i[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?Kie(o,d=>d.test(s)):Yie(o,d=>d.test(s));let u;u=e.valueCallback?e.valueCallback(l):l,u=n.valueCallback?n.valueCallback(u):u;const c=t.slice(s.length);return{value:u,rest:c}}}function Yie(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function Kie(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function oR(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const a=r[0],i=t.match(e.parsePattern);if(!i)return null;let s=e.valueCallback?e.valueCallback(i[0]):i[0];s=n.valueCallback?n.valueCallback(s):s;const o=t.slice(a.length);return{value:s,rest:o}}}const Xie=/^(\d+)(th|st|nd|rd)?/i,Zie=/\d+/i,Qie={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Jie={any:[/^b/i,/^(a|c)/i]},ese={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},tse={any:[/1/i,/2/i,/3/i,/4/i]},nse={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},rse={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},ase={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},ise={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},sse={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},ose={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},lse={ordinalNumber:oR({matchPattern:Xie,parsePattern:Zie,valueCallback:e=>parseInt(e,10)}),era:Yr({matchPatterns:Qie,defaultMatchWidth:"wide",parsePatterns:Jie,defaultParseWidth:"any"}),quarter:Yr({matchPatterns:ese,defaultMatchWidth:"wide",parsePatterns:tse,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Yr({matchPatterns:nse,defaultMatchWidth:"wide",parsePatterns:rse,defaultParseWidth:"any"}),day:Yr({matchPatterns:ase,defaultMatchWidth:"wide",parsePatterns:ise,defaultParseWidth:"any"}),dayPeriod:Yr({matchPatterns:sse,defaultMatchWidth:"any",parsePatterns:ose,defaultParseWidth:"any"})},lR={code:"en-US",formatDistance:Die,formatLong:Bie,formatRelative:Hie,localize:Wie,match:lse,options:{weekStartsOn:0,firstWeekContainsDate:1}};function use(e,t){const n=Jt(e,t?.in);return vie(n,Oie(n))+1}function cse(e,t){const n=Jt(e,t?.in),r=+cc(n)-+Tie(n);return Math.round(r/nR)+1}function uR(e,t){const n=Jt(e,t?.in),r=n.getFullYear(),a=nl(),i=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,s=fr(t?.in||e,0);s.setFullYear(r+1,0,i),s.setHours(0,0,0,0);const o=xi(s,t),l=fr(t?.in||e,0);l.setFullYear(r,0,i),l.setHours(0,0,0,0);const u=xi(l,t);return+n>=+o?r+1:+n>=+u?r:r-1}function dse(e,t){const n=nl(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,a=uR(e,t),i=fr(t?.in||e,0);return i.setFullYear(a,0,r),i.setHours(0,0,0,0),xi(i,t)}function pse(e,t){const n=Jt(e,t?.in),r=+xi(n,t)-+dse(n,t);return Math.round(r/nR)+1}function nt(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const Ga={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return nt(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):nt(n+1,2)},d(e,t){return nt(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return nt(e.getHours()%12||12,t.length)},H(e,t){return nt(e.getHours(),t.length)},m(e,t){return nt(e.getMinutes(),t.length)},s(e,t){return nt(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return nt(a,t.length)}},ws={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},cR={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),a=r>0?r:1-r;return n.ordinalNumber(a,{unit:"year"})}return Ga.y(e,t)},Y:function(e,t,n,r){const a=uR(e,r),i=a>0?a:1-a;if(t==="YY"){const s=i%100;return nt(s,2)}return t==="Yo"?n.ordinalNumber(i,{unit:"year"}):nt(i,t.length)},R:function(e,t){const n=iR(e);return nt(n,t.length)},u:function(e,t){const n=e.getFullYear();return nt(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return nt(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return nt(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return Ga.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return nt(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const a=pse(e,r);return t==="wo"?n.ordinalNumber(a,{unit:"week"}):nt(a,t.length)},I:function(e,t,n){const r=cse(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):nt(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):Ga.d(e,t)},D:function(e,t,n){const r=use(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):nt(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const a=e.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(i);case"ee":return nt(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const a=e.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(i);case"cc":return nt(i,t.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),a=r===0?7:r;switch(t){case"i":return String(a);case"ii":return nt(a,t.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let a;switch(r===12?a=ws.noon:r===0?a=ws.midnight:a=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let a;switch(r>=17?a=ws.evening:r>=12?a=ws.afternoon:r>=4?a=ws.morning:a=ws.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Ga.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):Ga.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):nt(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):nt(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):Ga.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):Ga.s(e,t)},S:function(e,t){return Ga.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return pR(r);case"XXXX":case"XX":return wi(r);case"XXXXX":case"XXX":default:return wi(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return pR(r);case"xxxx":case"xx":return wi(r);case"xxxxx":case"xxx":default:return wi(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+dR(r,":");case"OOOO":default:return"GMT"+wi(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+dR(r,":");case"zzzz":default:return"GMT"+wi(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return nt(r,t.length)},T:function(e,t,n){return nt(+e,t.length)}};function dR(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=Math.trunc(r/60),i=r%60;return i===0?n+String(a):n+String(a)+t+nt(i,2)}function pR(e,t){return e%60===0?(e>0?"-":"+")+nt(Math.abs(e)/60,2):wi(e,t)}function wi(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=nt(Math.trunc(r/60),2),i=nt(r%60,2);return n+a+t+i}const fR=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},hR=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},fse={p:hR,P:(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return fR(e,t);let i;switch(r){case"P":i=t.dateTime({width:"short"});break;case"PP":i=t.dateTime({width:"medium"});break;case"PPP":i=t.dateTime({width:"long"});break;case"PPPP":default:i=t.dateTime({width:"full"});break}return i.replace("{{date}}",fR(r,t)).replace("{{time}}",hR(a,t))}},hse=/^D+$/,mse=/^Y+$/,gse=["D","DD","YY","YYYY"];function bse(e){return hse.test(e)}function Ese(e){return mse.test(e)}function yse(e,t,n){const r=vse(e,t,n);if(console.warn(r),gse.includes(e))throw new RangeError(r)}function vse(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Tse=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Sse=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,xse=/^'([^]*?)'?$/,wse=/''/g,Ase=/[a-zA-Z]/;function ry(e,t,n){const r=nl(),a=r.locale??lR,i=r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,s=r.weekStartsOn??r.locale?.options?.weekStartsOn??0,o=Jt(e,n?.in);if(!xie(o))throw new RangeError("Invalid time value");let l=t.match(Sse).map(c=>{const d=c[0];if(d==="p"||d==="P"){const p=fse[d];return p(c,a.formatLong)}return c}).join("").match(Tse).map(c=>{if(c==="''")return{isToken:!1,value:"'"};const d=c[0];if(d==="'")return{isToken:!1,value:_se(c)};if(cR[d])return{isToken:!0,value:c};if(d.match(Ase))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return{isToken:!1,value:c}});a.localize.preprocessor&&(l=a.localize.preprocessor(o,l));const u={firstWeekContainsDate:i,weekStartsOn:s,locale:a};return l.map(c=>{if(!c.isToken)return c.value;const d=c.value;(Ese(d)||bse(d))&&yse(d,t,String(e));const p=cR[d[0]];return p(o,d,a.localize,u)}).join("")}function _se(e){const t=e.match(xse);return t?t[1].replace(wse,"'"):e}function kse(e,t,n){const r=nl(),a=n?.locale??r.locale??lR,i=2520,s=fc(e,t);if(isNaN(s))throw new RangeError("Invalid time value");const o=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:s}),[l,u]=Ss(n?.in,...s>0?[t,e]:[e,t]),c=Rie(u,l),d=(dc(u)-dc(l))/1e3,p=Math.round((c-d)/60);let f;if(p<2)return n?.includeSeconds?c<5?a.formatDistance("lessThanXSeconds",5,o):c<10?a.formatDistance("lessThanXSeconds",10,o):c<20?a.formatDistance("lessThanXSeconds",20,o):c<40?a.formatDistance("halfAMinute",0,o):c<60?a.formatDistance("lessThanXMinutes",1,o):a.formatDistance("xMinutes",1,o):p===0?a.formatDistance("lessThanXMinutes",1,o):a.formatDistance("xMinutes",p,o);if(p<45)return a.formatDistance("xMinutes",p,o);if(p<90)return a.formatDistance("aboutXHours",1,o);if(p<rR){const m=Math.round(p/60);return a.formatDistance("aboutXHours",m,o)}else{if(p<i)return a.formatDistance("xDays",1,o);if(p<uc){const m=Math.round(p/rR);return a.formatDistance("xDays",m,o)}else if(p<uc*2)return f=Math.round(p/uc),a.formatDistance("aboutXMonths",f,o)}if(f=Iie(u,l),f<12){const m=Math.round(p/uc);return a.formatDistance("xMonths",m,o)}else{const m=f%12,g=Math.trunc(f/12);return m<3?a.formatDistance("aboutXYears",g,o):m<9?a.formatDistance("overXYears",g,o):a.formatDistance("almostXYears",g+1,o)}}function Nse(e,t){return kse(e,ny(e),t)}function Cse(e,t,n){const[r,a]=Ss(n?.in,e,t);return+xi(r,n)==+xi(a,n)}function Ise(e,t){return sR(fr(e,e),ny(e))}function Rse(e,t,n){return Eie(e,-1,n)}function Ose(e,t){return sR(fr(e,e),Rse(ny(e)))}const Lse={lessThanXSeconds:{one:"不到 1 秒",other:"不到 {{count}} 秒"},xSeconds:{one:"1 秒",other:"{{count}} 秒"},halfAMinute:"半分钟",lessThanXMinutes:{one:"不到 1 分钟",other:"不到 {{count}} 分钟"},xMinutes:{one:"1 分钟",other:"{{count}} 分钟"},xHours:{one:"1 小时",other:"{{count}} 小时"},aboutXHours:{one:"大约 1 小时",other:"大约 {{count}} 小时"},xDays:{one:"1 天",other:"{{count}} 天"},aboutXWeeks:{one:"大约 1 个星期",other:"大约 {{count}} 个星期"},xWeeks:{one:"1 个星期",other:"{{count}} 个星期"},aboutXMonths:{one:"大约 1 个月",other:"大约 {{count}} 个月"},xMonths:{one:"1 个月",other:"{{count}} 个月"},aboutXYears:{one:"大约 1 年",other:"大约 {{count}} 年"},xYears:{one:"1 年",other:"{{count}} 年"},overXYears:{one:"超过 1 年",other:"超过 {{count}} 年"},almostXYears:{one:"将近 1 年",other:"将近 {{count}} 年"}},Dse=(e,t,n)=>{let r;const a=Lse[e];return typeof a=="string"?r=a:t===1?r=a.one:r=a.other.replace("{{count}}",String(t)),n?.addSuffix?n.comparison&&n.comparison>0?r+"内":r+"前":r},Mse={full:"y'年'M'月'd'日' EEEE",long:"y'年'M'月'd'日'",medium:"yyyy-MM-dd",short:"yy-MM-dd"},Pse={full:"zzzz a h:mm:ss",long:"z a h:mm:ss",medium:"a h:mm:ss",short:"a h:mm"},Fse={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},Bse={date:xs({formats:Mse,defaultWidth:"full"}),time:xs({formats:Pse,defaultWidth:"full"}),dateTime:xs({formats:Fse,defaultWidth:"full"})};function mR(e,t,n){const r="eeee p";return Cse(e,t,n)?r:e.getTime()>t.getTime()?"'下个'"+r:"'上个'"+r}const Use={lastWeek:mR,yesterday:"'昨天' p",today:"'今天' p",tomorrow:"'明天' p",nextWeek:mR,other:"PP p"},Hse=(e,t,n,r)=>{const a=Use[e];return typeof a=="function"?a(t,n,r):a},$se={narrow:["前","公元"],abbreviated:["前","公元"],wide:["公元前","公元"]},zse={narrow:["1","2","3","4"],abbreviated:["第一季","第二季","第三季","第四季"],wide:["第一季度","第二季度","第三季度","第四季度"]},qse={narrow:["一","二","三","四","五","六","七","八","九","十","十一","十二"],abbreviated:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],wide:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},jse={narrow:["日","一","二","三","四","五","六"],short:["日","一","二","三","四","五","六"],abbreviated:["周日","周一","周二","周三","周四","周五","周六"],wide:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},Gse={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},Vse={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},Wse={ordinalNumber:(e,t)=>{const n=Number(e);switch(t?.unit){case"date":return n.toString()+"日";case"hour":return n.toString()+"时";case"minute":return n.toString()+"分";case"second":return n.toString()+"秒";default:return"第 "+n.toString()}},era:Wr({values:$se,defaultWidth:"wide"}),quarter:Wr({values:zse,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Wr({values:qse,defaultWidth:"wide"}),day:Wr({values:jse,defaultWidth:"wide"}),dayPeriod:Wr({values:Gse,defaultWidth:"wide",formattingValues:Vse,defaultFormattingWidth:"wide"})},Yse=/^(第\s*)?\d+(日|时|分|秒)?/i,Kse=/\d+/i,Xse={narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},Zse={any:[/^(前)/i,/^(公元)/i]},Qse={narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻钟/i},Jse={any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},eoe={narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},toe={narrow:[/^一/i,/^二/i,/^三/i,/^四/i,/^五/i,/^六/i,/^七/i,/^八/i,/^九/i,/^十(?!(一|二))/i,/^十一/i,/^十二/i],any:[/^一|1/i,/^二|2/i,/^三|3/i,/^四|4/i,/^五|5/i,/^六|6/i,/^七|7/i,/^八|8/i,/^九|9/i,/^十(?!(一|二))|10/i,/^十一|11/i,/^十二|12/i]},noe={narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^周[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},roe={any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},aoe={any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨|)/i},ioe={any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},soe={ordinalNumber:oR({matchPattern:Yse,parsePattern:Kse,valueCallback:e=>parseInt(e,10)}),era:Yr({matchPatterns:Xse,defaultMatchWidth:"wide",parsePatterns:Zse,defaultParseWidth:"any"}),quarter:Yr({matchPatterns:Qse,defaultMatchWidth:"wide",parsePatterns:Jse,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Yr({matchPatterns:eoe,defaultMatchWidth:"wide",parsePatterns:toe,defaultParseWidth:"any"}),day:Yr({matchPatterns:noe,defaultMatchWidth:"wide",parsePatterns:roe,defaultParseWidth:"any"}),dayPeriod:Yr({matchPatterns:aoe,defaultMatchWidth:"any",parsePatterns:ioe,defaultParseWidth:"any"})},ooe={code:"zh-CN",formatDistance:Dse,formatLong:Bse,formatRelative:Hse,localize:Wse,match:soe,options:{weekStartsOn:1,firstWeekContainsDate:4}};function loe(e){const t=new Date(e),n=new Date,r=Nse(t,{addSuffix:!0,locale:ooe});return n.getTime()-t.getTime()<24*60*60*1e3?r:Ose(t)?`昨天 ${ry(t,"HH:mm")}`:Ise(t)?ry(t,"HH:mm"):ry(t,"yyyy-MM-dd")}function uoe({isOpen:e,onClose:t,onSelectTopic:n}){const{chatHistory:r,chatHistoryLoading:a,activeChatChannel:i,channels:s,activateChannel:o,togglePinChat:l,user:u,fetchChatHistory:c,updateTopicName:d}=Kt();v.useEffect(()=>{e&&(console.log("SessionHistory: Component opened, fetching history..."),c())},[e,c]);const p=v.useMemo(()=>{const _=u&&(u.id||u.username);return console.log("SessionHistory: User login check:",{user:u,hasUser:_}),_},[u]),m=[...v.useMemo(()=>{if(console.log("SessionHistory: Processing topics",{activeChatChannel:i,channels:s,chatHistory:r.length}),!i||!s[i])return console.log("SessionHistory: No active channel or channel not found"),[];const _=s[i].sessionId;console.log("SessionHistory: Current session ID:",_);const A=r.filter(R=>{const M=s[R.id],P=M&&M.sessionId===_;return console.log(`SessionHistory: Topic ${R.id} belongs to current session:`,P),P});return console.log("SessionHistory: Current session topics:",A.length),A},[i,s,r])].sort((_,A)=>{if(_.isPinned&&!A.isPinned)return-1;if(!_.isPinned&&A.isPinned)return 1;const R=new Date(_.updatedAt);return new Date(A.updatedAt).getTime()-R.getTime()});console.log("SessionHistory: Final sorted history:",m.length);const g=async _=>{await o(_),n?.(_),t()},x=(_,A)=>{_.stopPropagation(),l(A)},T=()=>b.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-6 text-center",children:[b.jsx(Pd,{className:"h-16 w-16 text-neutral-300 dark:text-neutral-600"}),b.jsx("h3",{className:"mt-4 text-lg font-medium text-neutral-800 dark:text-white",children:"请先登录"}),b.jsx("p",{className:"mt-2 text-sm text-neutral-500 dark:text-neutral-400",children:"登录后即可查看和管理您的会话历史记录"}),b.jsx("div",{className:"mt-6",children:b.jsx("button",{onClick:t,className:"rounded-md bg-indigo-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-indigo-700",children:"关闭"})})]}),y=()=>b.jsx("div",{className:"flex h-full items-center justify-center",children:b.jsx(Ui,{size:"lg"})}),w=()=>b.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-6 text-center",children:[b.jsx(yT,{className:"h-16 w-16 text-neutral-300 dark:text-neutral-600"}),b.jsx("h3",{className:"mt-4 text-lg font-medium text-neutral-800 dark:text-white",children:"当前会话暂无历史记录"}),b.jsx("p",{className:"mt-2 text-sm text-neutral-500 dark:text-neutral-400",children:"开始对话即可创建历史记录"})]}),k=()=>b.jsxs("div",{className:"h-full overflow-y-auto",children:[b.jsxs("div",{className:"sticky top-0 z-10 bg-white px-4 py-3 border-b border-neutral-200 dark:bg-neutral-900 dark:border-neutral-800",children:[b.jsxs("div",{className:"flex items-center justify-between",children:[b.jsx("h2",{className:"text-lg font-semibold text-neutral-800 dark:text-white",children:"会话历史"}),b.jsx("button",{onClick:t,className:"rounded-md p-1.5 text-neutral-500 hover:bg-neutral-100 hover:text-neutral-700 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-300",title:"关闭历史记录",children:b.jsx(Fd,{className:"h-5 w-5"})})]}),b.jsx("p",{className:"mt-1 text-sm text-neutral-500 dark:text-neutral-400",children:"当前会话的对话主题"})]}),b.jsx("div",{className:"p-4",children:b.jsx("div",{className:"space-y-2",children:m.map(_=>b.jsxs("div",{className:`group relative flex cursor-pointer items-center justify-between rounded-lg border p-3 transition-colors hover:bg-neutral-50 dark:hover:bg-neutral-900 ${_.id===i?"border-indigo-200 bg-indigo-50 dark:border-indigo-800 dark:bg-indigo-950":"border-neutral-200 dark:border-neutral-800"}`,children:[b.jsxs("div",{className:"flex-1 overflow-hidden",onClick:()=>g(_.id),children:[b.jsxs("div",{className:"flex items-center",children:[_.isPinned&&b.jsx(Tx,{className:"mr-2 h-3.5 w-3.5 rotate-45 text-indigo-500 dark:text-indigo-400"}),b.jsx("div",{className:"flex-1",children:b.jsx(ep,{title:_.title,onSave:A=>d(_.id,A),className:"w-full",textClassName:`truncate text-sm font-medium ${_.id===i?"text-indigo-700 dark:text-indigo-300":_.isPinned?"text-indigo-700 dark:text-indigo-400":"text-neutral-800 dark:text-white"}`})})]}),b.jsxs("div",{className:"mt-1 flex items-center text-xs text-neutral-500 dark:text-neutral-400",children:[b.jsx("span",{className:"truncate",children:_.assistantTitle}),b.jsx("span",{className:"mx-1.5",children:"·"}),b.jsx("span",{className:"whitespace-nowrap",children:loe(_.updatedAt)})]}),_.lastMessage&&b.jsx("p",{className:"mt-1 truncate text-xs text-neutral-500 dark:text-neutral-400",children:_.lastMessage})]}),b.jsxs("div",{className:"ml-3 flex items-center gap-1",children:[b.jsx("button",{className:"invisible rounded p-1 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700 group-hover:visible dark:hover:bg-neutral-800 dark:hover:text-neutral-300",title:_.isPinned?"取消置顶":"置顶会话",onClick:A=>x(A,_.id),children:b.jsx(Tx,{className:`h-3.5 w-3.5 ${_.isPinned?"rotate-45":""}`})}),b.jsx("div",{className:"rounded-full p-1 text-neutral-400 group-hover:text-neutral-500",children:b.jsx(ET,{className:"h-3.5 w-3.5"})})]})]},_.id))})})]});return b.jsxs(b.Fragment,{children:[b.jsx(Qs,{show:e,as:v.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:b.jsx("div",{className:"fixed inset-0 z-40 bg-black/20 backdrop-blur-sm",onClick:t})}),b.jsx(Qs,{show:e,as:v.Fragment,enter:"transform transition ease-in-out duration-300",enterFrom:"translate-x-full",enterTo:"translate-x-0",leave:"transform transition ease-in-out duration-300",leaveFrom:"translate-x-0",leaveTo:"translate-x-full",children:b.jsx("div",{className:"fixed inset-y-0 right-0 z-50 w-80 bg-white shadow-2xl dark:bg-neutral-900",children:(console.log("SessionHistory: Render decision",{isUserLoggedIn:p,chatHistoryLoading:a,sortedHistoryLength:m.length}),p?a?(console.log("SessionHistory: Rendering loading state"),y()):m.length===0?(console.log("SessionHistory: Rendering empty state"),w()):(console.log("SessionHistory: Rendering history list"),k()):(console.log("SessionHistory: Rendering login prompt"),T()))})})]})}const coe=({assistant:e})=>{const t=e?.iconColor||"indigo",n={blue:"bg-blue-100 dark:bg-blue-900/30",green:"bg-green-100 dark:bg-green-900/30",purple:"bg-purple-100 dark:bg-purple-900/30",amber:"bg-amber-100 dark:bg-amber-900/30",red:"bg-red-100 dark:bg-red-900/30",indigo:"bg-indigo-100 dark:bg-indigo-900/30"},r={blue:"text-blue-600 dark:text-blue-400",green:"text-green-600 dark:text-green-400",purple:"text-purple-600 dark:text-purple-400",amber:"text-amber-600 dark:text-amber-400",red:"text-red-600 dark:text-red-400",indigo:"text-indigo-600 dark:text-indigo-400"},a=n[t]||n.indigo,i=r[t]||r.indigo,s=e?`欢迎使用 ${e.title}`:"欢迎使用自由对话",o=e?.description||"您现在可以自由提问任何问题。无需选择特定助手,系统将根据您的问题提供合适的回复。";return b.jsxs(ke.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.6},className:"flex flex-col items-center justify-center space-y-4 p-6 text-center",children:[b.jsx("div",{className:`rounded-full ${a} p-5`,children:b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`h-10 w-10 ${i}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:b.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})})}),b.jsxs(ke.div,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},transition:{delay:.2,duration:.5},children:[b.jsx("h3",{className:"text-lg font-medium text-neutral-900 dark:text-white",children:s}),b.jsx("p",{className:"mt-2 max-w-md text-sm leading-relaxed text-neutral-600 dark:text-neutral-300",children:o})]})]})};function doe(){const{activeChatChannel:e,channels:t,agents:n,sendMessage:r,connectToChannel:a,updateTopicName:i}=Kt(),s=v.useRef(null),o=v.useRef(null),[l,u]=v.useState(!0),[c,d]=v.useState(!1),[p,f]=v.useState(!1),[m,g]=v.useState(()=>{const V=localStorage.getItem("chatInputHeight");return V?parseInt(V,10):80}),x=e?t[e]:null,T=x?.agentId?n.find(V=>V.id===x.agentId):null,y=x?.messages||[],w=x?.connected||!1,k=x?.error||null,_=v.useCallback((V=!1)=>{!l&&!V||setTimeout(()=>{o.current?.scrollTo({top:o.current.scrollHeight,behavior:V?"auto":"smooth"})},50)},[l]),A=v.useCallback(()=>{if(o.current){const{scrollTop:V,scrollHeight:K,clientHeight:te}=o.current,ge=K-V-te<80;u(ge)}},[]),R=V=>{!V.trim()||!e||(r(V),u(!0),setTimeout(()=>_(!0),100))},M=()=>{f(!p)},P=()=>{f(!1)},D=V=>{f(!1)},z=V=>{g(V)},W=()=>{x&&(d(!0),a(x.sessionId,x.id),setTimeout(()=>{d(!1)},2e3))};return v.useEffect(()=>{l&&_()},[y.length,l,_]),v.useEffect(()=>{const V=o.current;if(V)return u(!0),setTimeout(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},50),V.addEventListener("scroll",A,{passive:!0}),()=>V.removeEventListener("scroll",A)},[e,A]),e?b.jsxs("div",{className:"flex h-full flex-col",children:[e?b.jsxs(b.Fragment,{children:[T?b.jsxs("div",{className:"flex-shrink-0 px-4 pb-2",children:[b.jsx(ep,{title:x?.title||"新的聊天",onSave:V=>e?i(e,V):Promise.resolve(),className:"mb-1",textClassName:"text-lg font-medium text-neutral-800 dark:text-white"}),b.jsx("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:T.description})]}):b.jsxs("div",{className:"flex-shrink-0 px-4 pb-2",children:[b.jsx(ep,{title:x?.title||"新的聊天",onSave:V=>e?i(e,V):Promise.resolve(),className:"mb-1",textClassName:"text-lg font-medium text-neutral-800 dark:text-white"}),b.jsx("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"您可以在这里与AI助手自由讨论任何话题"})]}),!w&&b.jsxs("div",{className:"mb-1 flex flex-shrink-0 items-center justify-between rounded-md bg-amber-50 px-3 py-1.5 dark:bg-amber-900/20",children:[b.jsx("span",{className:"text-xs text-amber-700 dark:text-amber-200",children:k||"正在连接聊天服务..."}),b.jsx("button",{onClick:W,disabled:c,className:"ml-2 rounded-md p-1 text-amber-700 hover:bg-amber-100 focus:outline-none focus:ring-1 focus:ring-amber-500 dark:text-amber-300 dark:hover:bg-amber-800/30",title:"重试连接",children:b.jsx(mT,{className:`h-4 w-4 ${c?"animate-spin":""}`})})]}),b.jsxs("div",{className:"relative flex-grow overflow-y-auto",children:[b.jsx("div",{ref:o,className:"h-full overflow-y-auto rounded-lg bg-neutral-50 pt-6 dark:bg-black custom-scrollbar",onScroll:A,children:b.jsx("div",{className:"px-3",children:y.length===0?b.jsx(coe,{}):b.jsxs("div",{className:"space-y-6",children:[b.jsx(Dr,{children:y.map(V=>b.jsx(hie,{message:V},V.id))}),b.jsx("div",{ref:s,className:"h-4"})]})})}),!l&&y.length>0&&b.jsx("button",{onClick:()=>{u(!0),_(!0)},className:"absolute bottom-4 right-4 z-20 rounded-full bg-indigo-600 p-2 text-white shadow-md transition-colors hover:bg-indigo-700","aria-label":"Scroll to bottom",children:b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:b.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})})]}),b.jsx("div",{className:"border-t border-neutral-200 dark:border-neutral-800"}),b.jsxs("div",{className:"flex-shrink-0",children:[b.jsx(eR,{onShowHistory:M,onHeightChange:z}),b.jsx("div",{className:"bg-neutral-50/80 dark:bg-neutral-950/80",children:b.jsx(mie,{onSendMessage:R,disabled:!w,placeholder:"输入消息...",height:m})})]})]}):b.jsxs(b.Fragment,{children:[b.jsx(tR,{}),b.jsx("div",{className:"border-t border-neutral-200 dark:border-neutral-800"}),b.jsx("div",{className:"flex-shrink-0",children:b.jsx(eR,{onShowHistory:M,onHeightChange:z})})]}),b.jsx(uoe,{isOpen:p,onClose:P,onSelectTopic:D})]}):b.jsx(tR,{})}function poe(){const{isAddLlmProviderModalOpen:e,closeAddLlmProviderModal:t,addLlmProvider:n}=Kt(),[r,a]=v.useState({Name:"",Api:"",Key:"",Model:"",MaxTokens:null,Temperature:null,Timeout:null}),[i,s]=v.useState([]);console.log(i);const[o,l]=v.useState(null),[u,c]=v.useState(!1);v.useEffect(()=>{e&&(async()=>{try{const y=await Ni.getSupportedTypes();s(y)}catch(y){console.error("Failed to fetch supported types:",y)}})()},[e,s]);const d=T=>{const{name:y,value:w}=T.target;a(k=>({...k,[y]:y==="MaxTokens"||y==="Temperature"||y==="Timeout"?w===""?null:Number(w):w}))},p=()=>{a({Name:"",Api:"",Key:"",Model:"",MaxTokens:null,Temperature:null,Timeout:null}),l(null)},f=async()=>{if(l(null),c(!0),!r.Name||!r.Api||!r.Key||!r.Model){l("Name, API endpoint, API key, and model are required."),c(!1);return}try{await n(r),p()}catch(T){l(T instanceof Error?T.message:"Failed to add provider")}finally{c(!1)}},m=()=>{p(),t()},g=T=>{const y=T.toLowerCase();return y.includes("openai")&&!y.includes("azure")?{Api:"https://api.openai.com/v1",Model:"gpt-4o-mini"}:y.includes("azure")?{Api:"https://your-resource.openai.azure.com/",Model:"gpt-4o"}:y.includes("anthropic")||y.includes("claude")?{Api:"https://api.anthropic.com",Model:"claude-3-haiku-20240307"}:{}},x=T=>{const{value:y}=T.target,w=g(y);a(k=>({...k,Name:y,...w}))};return b.jsx(Eo,{isOpen:e,onClose:m,title:"Add LLM Provider",children:b.jsxs("div",{className:"space-y-4",children:[b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Provider Name *"}),b.jsx(Vn,{name:"Name",value:r.Name,onChange:x,placeholder:"e.g., OpenAI GPT-4, Azure OpenAI, Claude",className:"mt-1"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"API Endpoint *"}),b.jsx(Vn,{name:"Api",value:r.Api,onChange:d,placeholder:"https://api.openai.com/v1",className:"mt-1"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"API Key *"}),b.jsx(Vn,{name:"Key",type:"password",value:r.Key,onChange:d,placeholder:"sk-...",className:"mt-1"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Model *"}),b.jsx(Vn,{name:"Model",value:r.Model,onChange:d,placeholder:"gpt-4o, claude-3-haiku-20240307",className:"mt-1"})]}),b.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Max Tokens"}),b.jsx(Vn,{name:"MaxTokens",type:"number",value:r.MaxTokens?.toString()||"",onChange:d,placeholder:"4096",className:"mt-1"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Temperature"}),b.jsx(Vn,{name:"Temperature",type:"number",step:"0.1",min:"0",max:"2",value:r.Temperature?.toString()||"",onChange:d,placeholder:"0.7",className:"mt-1"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Timeout (s)"}),b.jsx(Vn,{name:"Timeout",type:"number",value:r.Timeout?.toString()||"",onChange:d,placeholder:"30",className:"mt-1"})]})]}),o&&b.jsx("div",{className:"rounded-md bg-red-50 p-3 dark:bg-red-950/50",children:b.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:o})}),b.jsxs("div",{className:"flex justify-end space-x-3 pt-4",children:[b.jsx(xn,{onClick:m,className:"rounded-md border border-neutral-300 bg-white px-4 py-2 text-sm font-medium text-neutral-700 hover:bg-neutral-50 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-700",children:"Cancel"}),b.jsx(xn,{onClick:f,disabled:u,className:"inline-flex items-center rounded-md bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 disabled:opacity-50 dark:bg-indigo-500 dark:hover:bg-indigo-600",children:u?"Adding...":"Add Provider"})]})]})})}function foe(){const{isAddMcpServerModalOpen:e,closeAddMcpServerModal:t,addMcpServer:n,getLoading:r,user:a,token:i}=Kt(),[s,o]=v.useState({name:"",description:"",url:"",token:""}),[l,u]=v.useState(null),[c,d]=v.useState(!1),[p,f]=v.useState(!1),[m,g]=v.useState(!1),x=r("mcpServerCreate"),T=k=>{const{name:_,value:A}=k.target;o(R=>({...R,[_]:A})),l&&u(null)},y=async()=>{if(u(null),!s.name.trim()||!s.url.trim()){u("Name and URL are required.");return}try{const k={...s,token:p?i||"":s.token};await n(k),d(!0),setTimeout(()=>{o({name:"",description:"",url:"",token:""}),d(!1),f(!0),g(!1)},1500)}catch(k){u("Failed to add server. Please check the details and try again."),console.error(k)}},w=()=>{x||(o({name:"",description:"",url:"",token:""}),u(null),d(!1),f(!0),g(!1),t())};return b.jsx(Eo,{isOpen:e,onClose:w,title:"Add New MCP Server",children:b.jsx(Dr,{mode:"wait",children:c?b.jsxs(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.4,ease:"easeOut"},className:"flex flex-col items-center justify-center py-8",children:[b.jsx(ke.div,{initial:{scale:0,rotate:-180},animate:{scale:1,rotate:0},transition:{delay:.2,duration:.5,type:"spring",stiffness:200,damping:15},className:"mb-6 rounded-full bg-gradient-to-br from-green-100 to-green-50 p-4 shadow-lg dark:from-green-900/30 dark:to-green-800/20",children:b.jsx(gT,{className:"h-8 w-8 text-green-600 dark:text-green-400"})}),b.jsxs(ke.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.4,duration:.3},className:"text-center",children:[b.jsx("h3",{className:"text-lg font-semibold text-neutral-900 dark:text-white",children:"Server Added Successfully!"}),b.jsx("p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:"Your MCP server is now ready to use."})]})]},"success"):b.jsxs(ke.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:[b.jsxs("div",{className:"mb-6 flex items-center space-x-3",children:[b.jsx("div",{className:"rounded-lg bg-gradient-to-br from-indigo-500 to-purple-600 p-2",children:b.jsx(Md,{className:"h-5 w-5 text-white"})}),b.jsxs("div",{children:[b.jsx("p",{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Connect a New Server"}),b.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:"Enter the connection details for your MCP server"})]})]}),b.jsxs("div",{className:"space-y-5",children:[b.jsx(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},children:b.jsxs(Zt,{children:[b.jsxs(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:["Server Name ",b.jsx("span",{className:"text-indigo-500",children:"*"})]}),b.jsx(Vn,{name:"name",value:s.name,onChange:T,placeholder:"My Local Server",required:!0,className:"mt-1"})]})}),b.jsx(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},children:b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Description"}),b.jsx(Vn,{name:"description",value:s.description,onChange:T,placeholder:"A brief description of the server",className:"mt-1"})]})}),b.jsx(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.3},children:b.jsxs(Zt,{children:[b.jsxs(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:["Server URL ",b.jsx("span",{className:"text-indigo-500",children:"*"})]}),b.jsx(Vn,{name:"url",value:s.url,onChange:T,placeholder:"http://localhost:8000",required:!0,className:"mt-1"})]})}),b.jsx(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.4},children:b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Authentication Token"}),b.jsxs("div",{className:"mt-2 space-y-3",children:[a&&i&&b.jsx(ke.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},transition:{delay:.1},children:b.jsxs("button",{type:"button",onClick:()=>f(!0),className:`w-full flex items-center justify-between p-3 rounded-lg border-2 transition-all duration-200 ${p?"border-indigo-500 bg-indigo-50 dark:border-indigo-400 dark:bg-indigo-900/20":"border-neutral-200 bg-neutral-50 hover:border-neutral-300 dark:border-neutral-700 dark:bg-neutral-800/50 dark:hover:border-neutral-600"}`,children:[b.jsxs("div",{className:"flex items-center space-x-3",children:[b.jsx("div",{className:`p-2 rounded-lg ${p?"bg-indigo-100 text-indigo-600 dark:bg-indigo-800/50 dark:text-indigo-300":"bg-neutral-200 text-neutral-600 dark:bg-neutral-700 dark:text-neutral-400"}`,children:b.jsx(Pd,{className:"h-4 w-4"})}),b.jsxs("div",{className:"text-left",children:[b.jsx("p",{className:"text-sm font-medium text-neutral-900 dark:text-white",children:"Use Current User Token"}),b.jsxs("p",{className:"text-xs text-neutral-500 dark:text-neutral-400 truncate max-w-48",children:["Authenticated as ",a.username]})]})]}),b.jsx("div",{className:`h-4 w-4 rounded-full border-2 transition-colors ${p?"border-indigo-500 bg-indigo-500":"border-neutral-300 dark:border-neutral-600"}`,children:p&&b.jsx(ke.div,{initial:{scale:0},animate:{scale:1},className:"h-full w-full rounded-full bg-white scale-50"})})]})}),b.jsx(ke.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},transition:{delay:.2},children:b.jsxs("button",{type:"button",onClick:()=>{g(!m),m||f(!1)},className:"w-full flex items-center justify-between p-3 rounded-lg border-2 border-neutral-200 bg-neutral-50 hover:border-neutral-300 transition-all duration-200 dark:border-neutral-700 dark:bg-neutral-800/50 dark:hover:border-neutral-600",children:[b.jsxs("div",{className:"flex items-center space-x-3",children:[b.jsx("div",{className:"p-2 rounded-lg bg-neutral-200 text-neutral-600 dark:bg-neutral-700 dark:text-neutral-400",children:b.jsx(vT,{className:"h-4 w-4"})}),b.jsxs("div",{className:"text-left",children:[b.jsx("p",{className:"text-sm font-medium text-neutral-900 dark:text-white",children:"Advanced Options"}),b.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:"Custom token configuration"})]})]}),b.jsx(ke.div,{animate:{rotate:m?180:0},transition:{duration:.2},children:b.jsx(bT,{className:"h-4 w-4 text-neutral-500"})})]})}),b.jsx(Dr,{children:m&&b.jsx(ke.div,{initial:{opacity:0,height:0,y:-10},animate:{opacity:1,height:"auto",y:0},exit:{opacity:0,height:0,y:-10},transition:{duration:.3,ease:"easeInOut"},className:"overflow-hidden",children:b.jsxs("div",{className:"p-4 rounded-lg bg-neutral-100/50 border border-neutral-200 dark:bg-neutral-800/30 dark:border-neutral-700",children:[b.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[b.jsx(lM,{className:"h-4 w-4 text-neutral-600 dark:text-neutral-400"}),b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Custom Token"})]}),b.jsx(Vn,{name:"token",value:s.token,onChange:T,placeholder:"Enter custom authentication token",type:"password",className:"bg-white dark:bg-neutral-900"}),b.jsx("p",{className:"mt-2 text-xs text-neutral-500 dark:text-neutral-400",children:"Leave empty if no authentication is required"})]})})})]})]})})]}),b.jsx(Dr,{children:l&&b.jsxs(ke.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mt-4 flex items-center space-x-2 rounded-lg bg-red-50 p-3 dark:bg-red-900/20",children:[b.jsx(ST,{className:"h-4 w-4 text-red-500"}),b.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:l})]})}),b.jsxs(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.5},className:"mt-8 flex justify-end gap-3",children:[b.jsx(xn,{onClick:w,disabled:x,className:"inline-flex items-center gap-2 rounded-lg bg-neutral-100 px-4 py-2 text-sm font-medium text-neutral-700 transition-colors hover:bg-neutral-200 focus:outline-none focus:ring-2 focus:ring-neutral-500 focus:ring-offset-2 disabled:opacity-50 dark:bg-neutral-800 dark:text-neutral-200 dark:hover:bg-neutral-700",children:"Cancel"}),b.jsx(xn,{onClick:y,disabled:x||!s.name.trim()||!s.url.trim(),className:"inline-flex items-center gap-2 rounded-lg bg-gradient-to-r from-indigo-600 to-indigo-700 px-4 py-2 text-sm font-medium text-white shadow-sm transition-all hover:from-indigo-500 hover:to-indigo-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",children:x?b.jsxs(b.Fragment,{children:[b.jsx(ke.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},className:"h-4 w-4 rounded-full border-2 border-white border-t-transparent"}),"Creating..."]}):b.jsxs(b.Fragment,{children:[b.jsx(xT,{className:"h-4 w-4"}),"Add Server"]})})]})]},"form")})})}const hoe=!1,moe=!1;console.log("=== Environment Debug ==="),console.log("MODE:","production"),console.log("isDevelopment:",hoe),console.log("isProduction:",moe),console.log("VITE_XYZEN_BACKEND_URL:",void 0);const gR="http://localhost:48196";console.log("Final DEFAULT_BACKEND_URL:",gR);const goe=280,boe=600,bR=380,Eoe=({isActive:e,onDoubleClick:t})=>{const{attributes:n,listeners:r,setNodeRef:a}=ed({id:"xyzen-resizer"});return b.jsx("div",{ref:a,className:`absolute left-0 top-0 z-50 h-full w-1 cursor-col-resize ${e?"bg-indigo-500 shadow-md dark:bg-indigo-400":"bg-transparent hover:bg-indigo-400/60 hover:shadow-sm dark:hover:bg-indigo-500/60"} transition-all duration-150 ease-in-out`,...r,...n,onDoubleClick:t})},yoe=({onOpenClick:e})=>{const{attributes:t,listeners:n,setNodeRef:r,transform:a}=ed({id:"xyzen-floater"}),i=a?{transform:`translate3d(0, ${a.y}px, 0)`}:void 0;return b.jsx("button",{ref:r,style:i,...n,...t,onClick:e,className:"flex h-12 w-12 items-center justify-center rounded-full bg-indigo-600 text-white shadow-lg transition-transform duration-200 ease-in-out hover:scale-110 hover:bg-indigo-700",title:"Open Xyzen",children:b.jsx(xT,{className:"h-6 w-6"})})};function voe({backendUrl:e=gR,showThemeToggle:t=!0,showLlmProvider:n=!1}){const{isXyzenOpen:r,closeXyzen:a,panelWidth:i,setPanelWidth:s,toggleXyzen:o,activeTabIndex:l,setTabIndex:u,setBackendUrl:c,user:d,fetchAgents:p,fetchMcpServers:f}=Kt(),[m,g]=v.useState(!1),[x,T]=v.useState(!1),[y,w]=v.useState(!1),[k,_]=v.useState(!1),[A,R]=v.useState({y:typeof window<"u"?window.innerHeight/2:300}),M=v.useRef(i),P=[{id:"agent",title:"助手",component:b.jsx(SU,{})},{id:"chat",title:"聊天",component:b.jsx(doe,{})}];v.useEffect(()=>{g(!0),c(e)},[e,c]);const D=v.useCallback(async()=>{if(d&&e)try{await Promise.all([p(),f()])}catch(X){console.error("Failed to load initial data:",X)}},[d,e,p,f]);v.useEffect(()=>{D()},[D]);const z=$c(Hc(Fs,{activationConstraint:{distance:5}})),W=$c(Hc(Fs,{activationConstraint:{distance:8}})),V=()=>{T(!0),M.current=i},K=X=>{const se=Math.min(Math.max(M.current-X.delta.x,goe),boe);s(se)},te=()=>{T(!1)},ge=X=>{const{delta:se}=X;R(C=>({y:C.y+se.y}))},ce=()=>{s(bR),M.current=bR};return v.useEffect(()=>{const X=se=>{(se.metaKey||se.ctrlKey)&&se.shiftKey&&se.key==="X"&&(se.preventDefault(),o())};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[o]),m?r?b.jsxs(Jc,{sensors:z,onDragStart:V,onDragMove:K,onDragEnd:te,modifiers:[S7],children:[b.jsxs("div",{className:"fixed right-0 top-0 z-50 h-full bg-white shadow-xl dark:border-l dark:border-neutral-800 dark:bg-black",style:{width:`${i}px`,transition:x?"none":"width 0.2s ease-in-out"},children:[b.jsx(Eoe,{isActive:x,onDoubleClick:ce}),b.jsxs(Js.Group,{as:"div",selectedIndex:l,onChange:u,className:"flex h-full flex-col",children:[b.jsxs("div",{className:"flex h-16 flex-shrink-0 items-center justify-between border-b border-neutral-200 px-4 dark:border-neutral-800",children:[b.jsx(Js.List,{className:"flex items-center space-x-1",children:P.map(X=>b.jsx(Js,{className:({selected:se})=>`whitespace-nowrap rounded-md px-3 py-2 text-sm font-medium outline-none transition-colors duration-200 ${se?"bg-neutral-100 text-indigo-600 dark:bg-neutral-900 dark:text-indigo-400":"text-neutral-500 hover:bg-neutral-100/50 dark:text-neutral-400 dark:hover:bg-neutral-800/50"}`,children:X.title},X.id))}),b.jsxs("div",{className:"flex items-center space-x-1",children:[t&&b.jsx(fU,{}),b.jsx("button",{className:"rounded-md p-1.5 text-neutral-500 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:bg-neutral-800",title:"MCP 管理",onClick:()=>w(!0),children:b.jsx(nu,{className:"h-5 w-5"})}),n&&b.jsx("button",{className:"rounded-md p-1.5 text-neutral-500 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:bg-neutral-800",title:"LLM 提供商",onClick:()=>_(!0),children:b.jsx(vT,{className:"h-5 w-5"})}),b.jsx("div",{className:"mx-2 h-6 w-px bg-neutral-200 dark:bg-neutral-700"}),b.jsx(pU,{className:"ml-2"}),b.jsx("button",{onClick:a,className:"rounded-md p-1.5 text-neutral-500 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:bg-neutral-800",title:"关闭",children:b.jsx(Fd,{className:"h-5 w-5"})})]})]}),b.jsx("div",{className:"flex-grow overflow-y-auto py-4",children:b.jsx(Js.Panels,{className:"h-full",children:P.map(X=>b.jsx(Js.Panel,{className:"h-full",unmount:!1,children:X.component},X.id))})})]}),b.jsx(Qs,{appear:!0,show:y,as:v.Fragment,children:b.jsxs(Nd,{open:y,onClose:()=>w(!1),className:"relative z-50",children:[b.jsx(ai,{as:v.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:b.jsx("div",{className:"fixed inset-0 bg-black/30","aria-hidden":"true"})}),b.jsx("div",{className:"fixed inset-0 flex w-screen items-center justify-center p-4",children:b.jsx(ai,{as:v.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:b.jsx(Bl,{className:"w-full max-w-2xl rounded-lg",children:b.jsx(uU,{})})})})]})}),n&&b.jsx(Qs,{appear:!0,show:k,as:v.Fragment,children:b.jsxs(Nd,{open:k,onClose:()=>_(!1),className:"relative z-50",children:[b.jsx(ai,{as:v.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:b.jsx("div",{className:"fixed inset-0 bg-black/30","aria-hidden":"true"})}),b.jsx("div",{className:"fixed inset-0 flex w-screen items-center justify-center p-4",children:b.jsx(ai,{as:v.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:b.jsx(Bl,{className:"w-full max-w-2xl rounded-lg bg-white p-6 dark:bg-neutral-900",children:b.jsx(NM,{})})})})]})})]}),b.jsx(foe,{}),n&&b.jsx(poe,{})]}):b.jsx(Jc,{sensors:W,onDragEnd:ge,modifiers:[x7],children:b.jsx("div",{className:"fixed right-4 z-50",style:{top:A.y,transform:"translateY(-50%)"},children:b.jsx(yoe,{onOpenClick:o})})}):null}gr.Xyzen=voe,gr.useTheme=Ex,gr.useXyzen=Kt,gr.xyzenService=Ea,Object.defineProperty(gr,Symbol.toStringTag,{value:"Module"})});
|
|
390
|
+
dark:bg-neutral-700/50`,children:[b.jsxs("div",{className:"flex items-center justify-between",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx("div",{className:`h-2 w-2 rounded-full ${k.status==="online"?"bg-green-500":"bg-red-500"}`}),b.jsx("span",{className:"text-sm font-medium text-neutral-900 dark:text-neutral-100",children:k.name})]}),b.jsxs("span",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:[k.tools?.length||0," 工具"]})]}),k.tools&&k.tools.length>0&&b.jsx("div",{className:"mt-2",children:b.jsxs("div",{className:"flex flex-wrap gap-1",children:[k.tools.slice(0,5).map((_,A)=>b.jsx("span",{className:"inline-block rounded bg-indigo-100 px-2 py-0.5 text-xs text-indigo-700 dark:bg-indigo-900/30 dark:text-indigo-300",children:_.name},A)),k.tools.length>5&&b.jsxs("span",{className:"inline-block rounded bg-neutral-200 px-2 py-0.5 text-xs text-neutral-600 dark:bg-neutral-600 dark:text-neutral-300",children:["+",k.tools.length-5]})]})})]},k.id))}),b.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-white dark:border-t-neutral-800"})]})]})]}),b.jsx("button",{onClick:e,className:"flex items-center justify-center rounded-md p-1.5 text-neutral-500 transition-colors hover:bg-neutral-200/60 hover:text-neutral-700 dark:text-neutral-400 dark:hover:bg-neutral-800/60 dark:hover:text-neutral-300",title:"历史记录",children:b.jsx(yT,{className:"h-4 w-4"})})]})]})})}const tR=()=>{const[e]=v.useState(!1),{createDefaultChannel:t}=Kt();return b.jsxs("div",{className:"flex h-full flex-col items-center justify-center space-y-6 p-4 text-center",children:[b.jsx(ke.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},transition:{duration:.5},className:"rounded-full bg-neutral-100 p-4 dark:bg-neutral-800",children:b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-neutral-500 dark:text-neutral-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:b.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M17 8h2a2 2 0 012 2v6a2 2 0 01-2 2h-2v4l-4-4H9a1.994 1.994 0 01-1.414-.586m0 0L11 14h4a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2v4l.586-.586z"})})}),b.jsxs(ke.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2,duration:.5},children:[b.jsx("h3",{className:"text-lg font-medium text-neutral-900 dark:text-white",children:"开始一个新对话"}),b.jsx("p",{className:"mt-2 max-w-md text-sm text-neutral-600 dark:text-neutral-300",children:"您可以从列表选择一个专业助手,或者直接开始一个自由对话。"})]}),b.jsx(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.4,duration:.5},className:"flex flex-col space-y-3 sm:flex-row sm:space-x-3 sm:space-y-0",children:b.jsx("button",{onClick:()=>t(),disabled:e,className:`flex items-center justify-center rounded-md ${e?"bg-indigo-400 dark:bg-indigo-700":"bg-indigo-600 hover:bg-indigo-700 dark:bg-indigo-500 dark:hover:bg-indigo-600"} px-4 py-2 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2`,children:e?b.jsxs(b.Fragment,{children:[b.jsxs("svg",{className:"mr-2 h-4 w-4 animate-spin",viewBox:"0 0 24 24",children:[b.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),b.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"创建中..."]}):b.jsxs(b.Fragment,{children:[b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"mr-2 h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:b.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"开始新对话"]})})})]})},nR=6048e5,bie=864e5,uc=43200,rR=1440,aR=Symbol.for("constructDateFrom");function fr(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&aR in e?e[aR](t):e instanceof Date?new e.constructor(t):new Date(t)}function Jt(e,t){return fr(t||e,e)}function Eie(e,t,n){const r=Jt(e,n?.in);return isNaN(t)?fr(e,NaN):(r.setDate(r.getDate()+t),r)}let yie={};function nl(){return yie}function xi(e,t){const n=nl(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,a=Jt(e,t?.in),i=a.getDay(),s=(i<r?7:0)+i-r;return a.setDate(a.getDate()-s),a.setHours(0,0,0,0),a}function cc(e,t){return xi(e,{...t,weekStartsOn:1})}function iR(e,t){const n=Jt(e,t?.in),r=n.getFullYear(),a=fr(n,0);a.setFullYear(r+1,0,4),a.setHours(0,0,0,0);const i=cc(a),s=fr(n,0);s.setFullYear(r,0,4),s.setHours(0,0,0,0);const o=cc(s);return n.getTime()>=i.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function dc(e){const t=Jt(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Ss(e,...t){const n=fr.bind(null,e||t.find(r=>typeof r=="object"));return t.map(n)}function pc(e,t){const n=Jt(e,t?.in);return n.setHours(0,0,0,0),n}function vie(e,t,n){const[r,a]=Ss(n?.in,e,t),i=pc(r),s=pc(a),o=+i-dc(i),l=+s-dc(s);return Math.round((o-l)/bie)}function Tie(e,t){const n=iR(e,t),r=fr(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),cc(r)}function fc(e,t){const n=+Jt(e)-+Jt(t);return n<0?-1:n>0?1:n}function ny(e){return fr(e,Date.now())}function sR(e,t,n){const[r,a]=Ss(n?.in,e,t);return+pc(r)==+pc(a)}function Sie(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function xie(e){return!(!Sie(e)&&typeof e!="number"||isNaN(+Jt(e)))}function wie(e,t,n){const[r,a]=Ss(n?.in,e,t),i=r.getFullYear()-a.getFullYear(),s=r.getMonth()-a.getMonth();return i*12+s}function Aie(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function _ie(e,t){return+Jt(e)-+Jt(t)}function kie(e,t){const n=Jt(e,t?.in);return n.setHours(23,59,59,999),n}function Nie(e,t){const n=Jt(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Cie(e,t){const n=Jt(e,t?.in);return+kie(n,t)==+Nie(n,t)}function Iie(e,t,n){const[r,a,i]=Ss(n?.in,e,e,t),s=fc(a,i),o=Math.abs(wie(a,i));if(o<1)return 0;a.getMonth()===1&&a.getDate()>27&&a.setDate(30),a.setMonth(a.getMonth()-s*o);let l=fc(a,i)===-s;Cie(r)&&o===1&&fc(r,i)===1&&(l=!1);const u=s*(o-+l);return u===0?0:u}function Rie(e,t,n){const r=_ie(e,t)/1e3;return Aie(n?.roundingMethod)(r)}function Oie(e,t){const n=Jt(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const Lie={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Die=(e,t,n)=>{let r;const a=Lie[e];return typeof a=="string"?r=a:t===1?r=a.one:r=a.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function xs(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Mie={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Pie={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Fie={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Bie={date:xs({formats:Mie,defaultWidth:"full"}),time:xs({formats:Pie,defaultWidth:"full"}),dateTime:xs({formats:Fie,defaultWidth:"full"})},Uie={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Hie=(e,t,n,r)=>Uie[e];function Wr(e){return(t,n)=>{const r=n?.context?String(n.context):"standalone";let a;if(r==="formatting"&&e.formattingValues){const s=e.defaultFormattingWidth||e.defaultWidth,o=n?.width?String(n.width):s;a=e.formattingValues[o]||e.formattingValues[s]}else{const s=e.defaultWidth,o=n?.width?String(n.width):e.defaultWidth;a=e.values[o]||e.values[s]}const i=e.argumentCallback?e.argumentCallback(t):t;return a[i]}}const $ie={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},zie={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},qie={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},jie={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Gie={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Vie={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Wie={ordinalNumber:(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},era:Wr({values:$ie,defaultWidth:"wide"}),quarter:Wr({values:zie,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Wr({values:qie,defaultWidth:"wide"}),day:Wr({values:jie,defaultWidth:"wide"}),dayPeriod:Wr({values:Gie,defaultWidth:"wide",formattingValues:Vie,defaultFormattingWidth:"wide"})};function Yr(e){return(t,n={})=>{const r=n.width,a=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],i=t.match(a);if(!i)return null;const s=i[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?Kie(o,d=>d.test(s)):Yie(o,d=>d.test(s));let u;u=e.valueCallback?e.valueCallback(l):l,u=n.valueCallback?n.valueCallback(u):u;const c=t.slice(s.length);return{value:u,rest:c}}}function Yie(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function Kie(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function oR(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const a=r[0],i=t.match(e.parsePattern);if(!i)return null;let s=e.valueCallback?e.valueCallback(i[0]):i[0];s=n.valueCallback?n.valueCallback(s):s;const o=t.slice(a.length);return{value:s,rest:o}}}const Xie=/^(\d+)(th|st|nd|rd)?/i,Zie=/\d+/i,Qie={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Jie={any:[/^b/i,/^(a|c)/i]},ese={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},tse={any:[/1/i,/2/i,/3/i,/4/i]},nse={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},rse={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},ase={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},ise={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},sse={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},ose={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},lse={ordinalNumber:oR({matchPattern:Xie,parsePattern:Zie,valueCallback:e=>parseInt(e,10)}),era:Yr({matchPatterns:Qie,defaultMatchWidth:"wide",parsePatterns:Jie,defaultParseWidth:"any"}),quarter:Yr({matchPatterns:ese,defaultMatchWidth:"wide",parsePatterns:tse,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Yr({matchPatterns:nse,defaultMatchWidth:"wide",parsePatterns:rse,defaultParseWidth:"any"}),day:Yr({matchPatterns:ase,defaultMatchWidth:"wide",parsePatterns:ise,defaultParseWidth:"any"}),dayPeriod:Yr({matchPatterns:sse,defaultMatchWidth:"any",parsePatterns:ose,defaultParseWidth:"any"})},lR={code:"en-US",formatDistance:Die,formatLong:Bie,formatRelative:Hie,localize:Wie,match:lse,options:{weekStartsOn:0,firstWeekContainsDate:1}};function use(e,t){const n=Jt(e,t?.in);return vie(n,Oie(n))+1}function cse(e,t){const n=Jt(e,t?.in),r=+cc(n)-+Tie(n);return Math.round(r/nR)+1}function uR(e,t){const n=Jt(e,t?.in),r=n.getFullYear(),a=nl(),i=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,s=fr(t?.in||e,0);s.setFullYear(r+1,0,i),s.setHours(0,0,0,0);const o=xi(s,t),l=fr(t?.in||e,0);l.setFullYear(r,0,i),l.setHours(0,0,0,0);const u=xi(l,t);return+n>=+o?r+1:+n>=+u?r:r-1}function dse(e,t){const n=nl(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,a=uR(e,t),i=fr(t?.in||e,0);return i.setFullYear(a,0,r),i.setHours(0,0,0,0),xi(i,t)}function pse(e,t){const n=Jt(e,t?.in),r=+xi(n,t)-+dse(n,t);return Math.round(r/nR)+1}function nt(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const Ga={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return nt(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):nt(n+1,2)},d(e,t){return nt(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return nt(e.getHours()%12||12,t.length)},H(e,t){return nt(e.getHours(),t.length)},m(e,t){return nt(e.getMinutes(),t.length)},s(e,t){return nt(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return nt(a,t.length)}},ws={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},cR={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),a=r>0?r:1-r;return n.ordinalNumber(a,{unit:"year"})}return Ga.y(e,t)},Y:function(e,t,n,r){const a=uR(e,r),i=a>0?a:1-a;if(t==="YY"){const s=i%100;return nt(s,2)}return t==="Yo"?n.ordinalNumber(i,{unit:"year"}):nt(i,t.length)},R:function(e,t){const n=iR(e);return nt(n,t.length)},u:function(e,t){const n=e.getFullYear();return nt(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return nt(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return nt(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return Ga.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return nt(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const a=pse(e,r);return t==="wo"?n.ordinalNumber(a,{unit:"week"}):nt(a,t.length)},I:function(e,t,n){const r=cse(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):nt(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):Ga.d(e,t)},D:function(e,t,n){const r=use(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):nt(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const a=e.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(i);case"ee":return nt(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const a=e.getDay(),i=(a-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(i);case"cc":return nt(i,t.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),a=r===0?7:r;switch(t){case"i":return String(a);case"ii":return nt(a,t.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let a;switch(r===12?a=ws.noon:r===0?a=ws.midnight:a=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let a;switch(r>=17?a=ws.evening:r>=12?a=ws.afternoon:r>=4?a=ws.morning:a=ws.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Ga.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):Ga.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):nt(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):nt(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):Ga.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):Ga.s(e,t)},S:function(e,t){return Ga.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return pR(r);case"XXXX":case"XX":return wi(r);case"XXXXX":case"XXX":default:return wi(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return pR(r);case"xxxx":case"xx":return wi(r);case"xxxxx":case"xxx":default:return wi(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+dR(r,":");case"OOOO":default:return"GMT"+wi(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+dR(r,":");case"zzzz":default:return"GMT"+wi(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return nt(r,t.length)},T:function(e,t,n){return nt(+e,t.length)}};function dR(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=Math.trunc(r/60),i=r%60;return i===0?n+String(a):n+String(a)+t+nt(i,2)}function pR(e,t){return e%60===0?(e>0?"-":"+")+nt(Math.abs(e)/60,2):wi(e,t)}function wi(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=nt(Math.trunc(r/60),2),i=nt(r%60,2);return n+a+t+i}const fR=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},hR=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},fse={p:hR,P:(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return fR(e,t);let i;switch(r){case"P":i=t.dateTime({width:"short"});break;case"PP":i=t.dateTime({width:"medium"});break;case"PPP":i=t.dateTime({width:"long"});break;case"PPPP":default:i=t.dateTime({width:"full"});break}return i.replace("{{date}}",fR(r,t)).replace("{{time}}",hR(a,t))}},hse=/^D+$/,mse=/^Y+$/,gse=["D","DD","YY","YYYY"];function bse(e){return hse.test(e)}function Ese(e){return mse.test(e)}function yse(e,t,n){const r=vse(e,t,n);if(console.warn(r),gse.includes(e))throw new RangeError(r)}function vse(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Tse=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Sse=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,xse=/^'([^]*?)'?$/,wse=/''/g,Ase=/[a-zA-Z]/;function ry(e,t,n){const r=nl(),a=r.locale??lR,i=r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,s=r.weekStartsOn??r.locale?.options?.weekStartsOn??0,o=Jt(e,n?.in);if(!xie(o))throw new RangeError("Invalid time value");let l=t.match(Sse).map(c=>{const d=c[0];if(d==="p"||d==="P"){const p=fse[d];return p(c,a.formatLong)}return c}).join("").match(Tse).map(c=>{if(c==="''")return{isToken:!1,value:"'"};const d=c[0];if(d==="'")return{isToken:!1,value:_se(c)};if(cR[d])return{isToken:!0,value:c};if(d.match(Ase))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return{isToken:!1,value:c}});a.localize.preprocessor&&(l=a.localize.preprocessor(o,l));const u={firstWeekContainsDate:i,weekStartsOn:s,locale:a};return l.map(c=>{if(!c.isToken)return c.value;const d=c.value;(Ese(d)||bse(d))&&yse(d,t,String(e));const p=cR[d[0]];return p(o,d,a.localize,u)}).join("")}function _se(e){const t=e.match(xse);return t?t[1].replace(wse,"'"):e}function kse(e,t,n){const r=nl(),a=n?.locale??r.locale??lR,i=2520,s=fc(e,t);if(isNaN(s))throw new RangeError("Invalid time value");const o=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:s}),[l,u]=Ss(n?.in,...s>0?[t,e]:[e,t]),c=Rie(u,l),d=(dc(u)-dc(l))/1e3,p=Math.round((c-d)/60);let f;if(p<2)return n?.includeSeconds?c<5?a.formatDistance("lessThanXSeconds",5,o):c<10?a.formatDistance("lessThanXSeconds",10,o):c<20?a.formatDistance("lessThanXSeconds",20,o):c<40?a.formatDistance("halfAMinute",0,o):c<60?a.formatDistance("lessThanXMinutes",1,o):a.formatDistance("xMinutes",1,o):p===0?a.formatDistance("lessThanXMinutes",1,o):a.formatDistance("xMinutes",p,o);if(p<45)return a.formatDistance("xMinutes",p,o);if(p<90)return a.formatDistance("aboutXHours",1,o);if(p<rR){const m=Math.round(p/60);return a.formatDistance("aboutXHours",m,o)}else{if(p<i)return a.formatDistance("xDays",1,o);if(p<uc){const m=Math.round(p/rR);return a.formatDistance("xDays",m,o)}else if(p<uc*2)return f=Math.round(p/uc),a.formatDistance("aboutXMonths",f,o)}if(f=Iie(u,l),f<12){const m=Math.round(p/uc);return a.formatDistance("xMonths",m,o)}else{const m=f%12,g=Math.trunc(f/12);return m<3?a.formatDistance("aboutXYears",g,o):m<9?a.formatDistance("overXYears",g,o):a.formatDistance("almostXYears",g+1,o)}}function Nse(e,t){return kse(e,ny(e),t)}function Cse(e,t,n){const[r,a]=Ss(n?.in,e,t);return+xi(r,n)==+xi(a,n)}function Ise(e,t){return sR(fr(e,e),ny(e))}function Rse(e,t,n){return Eie(e,-1,n)}function Ose(e,t){return sR(fr(e,e),Rse(ny(e)))}const Lse={lessThanXSeconds:{one:"不到 1 秒",other:"不到 {{count}} 秒"},xSeconds:{one:"1 秒",other:"{{count}} 秒"},halfAMinute:"半分钟",lessThanXMinutes:{one:"不到 1 分钟",other:"不到 {{count}} 分钟"},xMinutes:{one:"1 分钟",other:"{{count}} 分钟"},xHours:{one:"1 小时",other:"{{count}} 小时"},aboutXHours:{one:"大约 1 小时",other:"大约 {{count}} 小时"},xDays:{one:"1 天",other:"{{count}} 天"},aboutXWeeks:{one:"大约 1 个星期",other:"大约 {{count}} 个星期"},xWeeks:{one:"1 个星期",other:"{{count}} 个星期"},aboutXMonths:{one:"大约 1 个月",other:"大约 {{count}} 个月"},xMonths:{one:"1 个月",other:"{{count}} 个月"},aboutXYears:{one:"大约 1 年",other:"大约 {{count}} 年"},xYears:{one:"1 年",other:"{{count}} 年"},overXYears:{one:"超过 1 年",other:"超过 {{count}} 年"},almostXYears:{one:"将近 1 年",other:"将近 {{count}} 年"}},Dse=(e,t,n)=>{let r;const a=Lse[e];return typeof a=="string"?r=a:t===1?r=a.one:r=a.other.replace("{{count}}",String(t)),n?.addSuffix?n.comparison&&n.comparison>0?r+"内":r+"前":r},Mse={full:"y'年'M'月'd'日' EEEE",long:"y'年'M'月'd'日'",medium:"yyyy-MM-dd",short:"yy-MM-dd"},Pse={full:"zzzz a h:mm:ss",long:"z a h:mm:ss",medium:"a h:mm:ss",short:"a h:mm"},Fse={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},Bse={date:xs({formats:Mse,defaultWidth:"full"}),time:xs({formats:Pse,defaultWidth:"full"}),dateTime:xs({formats:Fse,defaultWidth:"full"})};function mR(e,t,n){const r="eeee p";return Cse(e,t,n)?r:e.getTime()>t.getTime()?"'下个'"+r:"'上个'"+r}const Use={lastWeek:mR,yesterday:"'昨天' p",today:"'今天' p",tomorrow:"'明天' p",nextWeek:mR,other:"PP p"},Hse=(e,t,n,r)=>{const a=Use[e];return typeof a=="function"?a(t,n,r):a},$se={narrow:["前","公元"],abbreviated:["前","公元"],wide:["公元前","公元"]},zse={narrow:["1","2","3","4"],abbreviated:["第一季","第二季","第三季","第四季"],wide:["第一季度","第二季度","第三季度","第四季度"]},qse={narrow:["一","二","三","四","五","六","七","八","九","十","十一","十二"],abbreviated:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],wide:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},jse={narrow:["日","一","二","三","四","五","六"],short:["日","一","二","三","四","五","六"],abbreviated:["周日","周一","周二","周三","周四","周五","周六"],wide:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},Gse={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},Vse={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},Wse={ordinalNumber:(e,t)=>{const n=Number(e);switch(t?.unit){case"date":return n.toString()+"日";case"hour":return n.toString()+"时";case"minute":return n.toString()+"分";case"second":return n.toString()+"秒";default:return"第 "+n.toString()}},era:Wr({values:$se,defaultWidth:"wide"}),quarter:Wr({values:zse,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Wr({values:qse,defaultWidth:"wide"}),day:Wr({values:jse,defaultWidth:"wide"}),dayPeriod:Wr({values:Gse,defaultWidth:"wide",formattingValues:Vse,defaultFormattingWidth:"wide"})},Yse=/^(第\s*)?\d+(日|时|分|秒)?/i,Kse=/\d+/i,Xse={narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},Zse={any:[/^(前)/i,/^(公元)/i]},Qse={narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻钟/i},Jse={any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},eoe={narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},toe={narrow:[/^一/i,/^二/i,/^三/i,/^四/i,/^五/i,/^六/i,/^七/i,/^八/i,/^九/i,/^十(?!(一|二))/i,/^十一/i,/^十二/i],any:[/^一|1/i,/^二|2/i,/^三|3/i,/^四|4/i,/^五|5/i,/^六|6/i,/^七|7/i,/^八|8/i,/^九|9/i,/^十(?!(一|二))|10/i,/^十一|11/i,/^十二|12/i]},noe={narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^周[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},roe={any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},aoe={any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨|)/i},ioe={any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},soe={ordinalNumber:oR({matchPattern:Yse,parsePattern:Kse,valueCallback:e=>parseInt(e,10)}),era:Yr({matchPatterns:Xse,defaultMatchWidth:"wide",parsePatterns:Zse,defaultParseWidth:"any"}),quarter:Yr({matchPatterns:Qse,defaultMatchWidth:"wide",parsePatterns:Jse,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Yr({matchPatterns:eoe,defaultMatchWidth:"wide",parsePatterns:toe,defaultParseWidth:"any"}),day:Yr({matchPatterns:noe,defaultMatchWidth:"wide",parsePatterns:roe,defaultParseWidth:"any"}),dayPeriod:Yr({matchPatterns:aoe,defaultMatchWidth:"any",parsePatterns:ioe,defaultParseWidth:"any"})},ooe={code:"zh-CN",formatDistance:Dse,formatLong:Bse,formatRelative:Hse,localize:Wse,match:soe,options:{weekStartsOn:1,firstWeekContainsDate:4}};function loe(e){const t=new Date(e),n=new Date,r=Nse(t,{addSuffix:!0,locale:ooe});return n.getTime()-t.getTime()<24*60*60*1e3?r:Ose(t)?`昨天 ${ry(t,"HH:mm")}`:Ise(t)?ry(t,"HH:mm"):ry(t,"yyyy-MM-dd")}function uoe({isOpen:e,onClose:t,onSelectTopic:n}){const{chatHistory:r,chatHistoryLoading:a,activeChatChannel:i,channels:s,activateChannel:o,togglePinChat:l,user:u,fetchChatHistory:c,updateTopicName:d}=Kt();v.useEffect(()=>{e&&(console.log("SessionHistory: Component opened, fetching history..."),c())},[e,c]);const p=v.useMemo(()=>{const _=u&&(u.id||u.username);return console.log("SessionHistory: User login check:",{user:u,hasUser:_}),_},[u]),m=[...v.useMemo(()=>{if(console.log("SessionHistory: Processing topics",{activeChatChannel:i,channels:s,chatHistory:r.length}),!i||!s[i])return console.log("SessionHistory: No active channel or channel not found"),[];const _=s[i].sessionId;console.log("SessionHistory: Current session ID:",_);const A=r.filter(R=>{const M=s[R.id],P=M&&M.sessionId===_;return console.log(`SessionHistory: Topic ${R.id} belongs to current session:`,P),P});return console.log("SessionHistory: Current session topics:",A.length),A},[i,s,r])].sort((_,A)=>{if(_.isPinned&&!A.isPinned)return-1;if(!_.isPinned&&A.isPinned)return 1;const R=new Date(_.updatedAt);return new Date(A.updatedAt).getTime()-R.getTime()});console.log("SessionHistory: Final sorted history:",m.length);const g=async _=>{await o(_),n?.(_),t()},x=(_,A)=>{_.stopPropagation(),l(A)},T=()=>b.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-6 text-center",children:[b.jsx(Pd,{className:"h-16 w-16 text-neutral-300 dark:text-neutral-600"}),b.jsx("h3",{className:"mt-4 text-lg font-medium text-neutral-800 dark:text-white",children:"请先登录"}),b.jsx("p",{className:"mt-2 text-sm text-neutral-500 dark:text-neutral-400",children:"登录后即可查看和管理您的会话历史记录"}),b.jsx("div",{className:"mt-6",children:b.jsx("button",{onClick:t,className:"rounded-md bg-indigo-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-indigo-700",children:"关闭"})})]}),y=()=>b.jsx("div",{className:"flex h-full items-center justify-center",children:b.jsx(Ui,{size:"lg"})}),w=()=>b.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-6 text-center",children:[b.jsx(yT,{className:"h-16 w-16 text-neutral-300 dark:text-neutral-600"}),b.jsx("h3",{className:"mt-4 text-lg font-medium text-neutral-800 dark:text-white",children:"当前会话暂无历史记录"}),b.jsx("p",{className:"mt-2 text-sm text-neutral-500 dark:text-neutral-400",children:"开始对话即可创建历史记录"})]}),k=()=>b.jsxs("div",{className:"h-full overflow-y-auto",children:[b.jsxs("div",{className:"sticky top-0 z-10 bg-white px-4 py-3 border-b border-neutral-200 dark:bg-neutral-900 dark:border-neutral-800",children:[b.jsxs("div",{className:"flex items-center justify-between",children:[b.jsx("h2",{className:"text-lg font-semibold text-neutral-800 dark:text-white",children:"会话历史"}),b.jsx("button",{onClick:t,className:"rounded-md p-1.5 text-neutral-500 hover:bg-neutral-100 hover:text-neutral-700 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-300",title:"关闭历史记录",children:b.jsx(Fd,{className:"h-5 w-5"})})]}),b.jsx("p",{className:"mt-1 text-sm text-neutral-500 dark:text-neutral-400",children:"当前会话的对话主题"})]}),b.jsx("div",{className:"p-4",children:b.jsx("div",{className:"space-y-2",children:m.map(_=>b.jsxs("div",{className:`group relative flex cursor-pointer items-center justify-between rounded-lg border p-3 transition-colors hover:bg-neutral-50 dark:hover:bg-neutral-900 ${_.id===i?"border-indigo-200 bg-indigo-50 dark:border-indigo-800 dark:bg-indigo-950":"border-neutral-200 dark:border-neutral-800"}`,children:[b.jsxs("div",{className:"flex-1 overflow-hidden",onClick:()=>g(_.id),children:[b.jsxs("div",{className:"flex items-center",children:[_.isPinned&&b.jsx(Tx,{className:"mr-2 h-3.5 w-3.5 rotate-45 text-indigo-500 dark:text-indigo-400"}),b.jsx("div",{className:"flex-1",children:b.jsx(ep,{title:_.title,onSave:A=>d(_.id,A),className:"w-full",textClassName:`truncate text-sm font-medium ${_.id===i?"text-indigo-700 dark:text-indigo-300":_.isPinned?"text-indigo-700 dark:text-indigo-400":"text-neutral-800 dark:text-white"}`})})]}),b.jsxs("div",{className:"mt-1 flex items-center text-xs text-neutral-500 dark:text-neutral-400",children:[b.jsx("span",{className:"truncate",children:_.assistantTitle}),b.jsx("span",{className:"mx-1.5",children:"·"}),b.jsx("span",{className:"whitespace-nowrap",children:loe(_.updatedAt)})]}),_.lastMessage&&b.jsx("p",{className:"mt-1 truncate text-xs text-neutral-500 dark:text-neutral-400",children:_.lastMessage})]}),b.jsxs("div",{className:"ml-3 flex items-center gap-1",children:[b.jsx("button",{className:"invisible rounded p-1 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700 group-hover:visible dark:hover:bg-neutral-800 dark:hover:text-neutral-300",title:_.isPinned?"取消置顶":"置顶会话",onClick:A=>x(A,_.id),children:b.jsx(Tx,{className:`h-3.5 w-3.5 ${_.isPinned?"rotate-45":""}`})}),b.jsx("div",{className:"rounded-full p-1 text-neutral-400 group-hover:text-neutral-500",children:b.jsx(ET,{className:"h-3.5 w-3.5"})})]})]},_.id))})})]});return b.jsxs(b.Fragment,{children:[b.jsx(Qs,{show:e,as:v.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:b.jsx("div",{className:"fixed inset-0 z-40 bg-black/20 backdrop-blur-sm",onClick:t})}),b.jsx(Qs,{show:e,as:v.Fragment,enter:"transform transition ease-in-out duration-300",enterFrom:"translate-x-full",enterTo:"translate-x-0",leave:"transform transition ease-in-out duration-300",leaveFrom:"translate-x-0",leaveTo:"translate-x-full",children:b.jsx("div",{className:"fixed inset-y-0 right-0 z-50 w-80 bg-white shadow-2xl dark:bg-neutral-900",children:(console.log("SessionHistory: Render decision",{isUserLoggedIn:p,chatHistoryLoading:a,sortedHistoryLength:m.length}),p?a?(console.log("SessionHistory: Rendering loading state"),y()):m.length===0?(console.log("SessionHistory: Rendering empty state"),w()):(console.log("SessionHistory: Rendering history list"),k()):(console.log("SessionHistory: Rendering login prompt"),T()))})})]})}const coe=({assistant:e})=>{const t=e?.iconColor||"indigo",n={blue:"bg-blue-100 dark:bg-blue-900/30",green:"bg-green-100 dark:bg-green-900/30",purple:"bg-purple-100 dark:bg-purple-900/30",amber:"bg-amber-100 dark:bg-amber-900/30",red:"bg-red-100 dark:bg-red-900/30",indigo:"bg-indigo-100 dark:bg-indigo-900/30"},r={blue:"text-blue-600 dark:text-blue-400",green:"text-green-600 dark:text-green-400",purple:"text-purple-600 dark:text-purple-400",amber:"text-amber-600 dark:text-amber-400",red:"text-red-600 dark:text-red-400",indigo:"text-indigo-600 dark:text-indigo-400"},a=n[t]||n.indigo,i=r[t]||r.indigo,s=e?`欢迎使用 ${e.title}`:"欢迎使用自由对话",o=e?.description||"您现在可以自由提问任何问题。无需选择特定助手,系统将根据您的问题提供合适的回复。";return b.jsxs(ke.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.6},className:"flex flex-col items-center justify-center space-y-4 p-6 text-center",children:[b.jsx("div",{className:`rounded-full ${a} p-5`,children:b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`h-10 w-10 ${i}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:b.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})})}),b.jsxs(ke.div,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},transition:{delay:.2,duration:.5},children:[b.jsx("h3",{className:"text-lg font-medium text-neutral-900 dark:text-white",children:s}),b.jsx("p",{className:"mt-2 max-w-md text-sm leading-relaxed text-neutral-600 dark:text-neutral-300",children:o})]})]})};function doe(){const{activeChatChannel:e,channels:t,agents:n,sendMessage:r,connectToChannel:a,updateTopicName:i}=Kt(),s=v.useRef(null),o=v.useRef(null),[l,u]=v.useState(!0),[c,d]=v.useState(!1),[p,f]=v.useState(!1),[m,g]=v.useState(()=>{const V=localStorage.getItem("chatInputHeight");return V?parseInt(V,10):80}),x=e?t[e]:null,T=x?.agentId?n.find(V=>V.id===x.agentId):null,y=x?.messages||[],w=x?.connected||!1,k=x?.error||null,_=v.useCallback((V=!1)=>{!l&&!V||setTimeout(()=>{o.current?.scrollTo({top:o.current.scrollHeight,behavior:V?"auto":"smooth"})},50)},[l]),A=v.useCallback(()=>{if(o.current){const{scrollTop:V,scrollHeight:K,clientHeight:te}=o.current,ge=K-V-te<80;u(ge)}},[]),R=V=>{!V.trim()||!e||(r(V),u(!0),setTimeout(()=>_(!0),100))},M=()=>{f(!p)},P=()=>{f(!1)},D=V=>{f(!1)},z=V=>{g(V)},W=()=>{x&&(d(!0),a(x.sessionId,x.id),setTimeout(()=>{d(!1)},2e3))};return v.useEffect(()=>{l&&_()},[y.length,l,_]),v.useEffect(()=>{const V=o.current;if(V)return u(!0),setTimeout(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},50),V.addEventListener("scroll",A,{passive:!0}),()=>V.removeEventListener("scroll",A)},[e,A]),e?b.jsxs("div",{className:"flex h-full flex-col",children:[e?b.jsxs(b.Fragment,{children:[T?b.jsxs("div",{className:"flex-shrink-0 px-4 pb-2",children:[b.jsx(ep,{title:x?.title||"新的聊天",onSave:V=>e?i(e,V):Promise.resolve(),className:"mb-1",textClassName:"text-lg font-medium text-neutral-800 dark:text-white"}),b.jsx("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:T.description})]}):b.jsxs("div",{className:"flex-shrink-0 px-4 pb-2",children:[b.jsx(ep,{title:x?.title||"新的聊天",onSave:V=>e?i(e,V):Promise.resolve(),className:"mb-1",textClassName:"text-lg font-medium text-neutral-800 dark:text-white"}),b.jsx("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"您可以在这里与AI助手自由讨论任何话题"})]}),!w&&b.jsxs("div",{className:"mb-1 flex flex-shrink-0 items-center justify-between rounded-md bg-amber-50 px-3 py-1.5 dark:bg-amber-900/20",children:[b.jsx("span",{className:"text-xs text-amber-700 dark:text-amber-200",children:k||"正在连接聊天服务..."}),b.jsx("button",{onClick:W,disabled:c,className:"ml-2 rounded-md p-1 text-amber-700 hover:bg-amber-100 focus:outline-none focus:ring-1 focus:ring-amber-500 dark:text-amber-300 dark:hover:bg-amber-800/30",title:"重试连接",children:b.jsx(mT,{className:`h-4 w-4 ${c?"animate-spin":""}`})})]}),b.jsxs("div",{className:"relative flex-grow overflow-y-auto",children:[b.jsx("div",{ref:o,className:"h-full overflow-y-auto rounded-lg bg-neutral-50 pt-6 dark:bg-black custom-scrollbar",onScroll:A,children:b.jsx("div",{className:"px-3",children:y.length===0?b.jsx(coe,{}):b.jsxs("div",{className:"space-y-6",children:[b.jsx(Dr,{children:y.map(V=>b.jsx(hie,{message:V},V.id))}),b.jsx("div",{ref:s,className:"h-4"})]})})}),!l&&y.length>0&&b.jsx("button",{onClick:()=>{u(!0),_(!0)},className:"absolute bottom-4 right-4 z-20 rounded-full bg-indigo-600 p-2 text-white shadow-md transition-colors hover:bg-indigo-700","aria-label":"Scroll to bottom",children:b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:b.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})})]}),b.jsx("div",{className:"border-t border-neutral-200 dark:border-neutral-800"}),b.jsxs("div",{className:"flex-shrink-0",children:[b.jsx(eR,{onShowHistory:M,onHeightChange:z}),b.jsx("div",{className:"bg-neutral-50/80 dark:bg-neutral-950/80",children:b.jsx(mie,{onSendMessage:R,disabled:!w,placeholder:"输入消息...",height:m})})]})]}):b.jsxs(b.Fragment,{children:[b.jsx(tR,{}),b.jsx("div",{className:"border-t border-neutral-200 dark:border-neutral-800"}),b.jsx("div",{className:"flex-shrink-0",children:b.jsx(eR,{onShowHistory:M,onHeightChange:z})})]}),b.jsx(uoe,{isOpen:p,onClose:P,onSelectTopic:D})]}):b.jsx(tR,{})}function poe(){const{isAddLlmProviderModalOpen:e,closeAddLlmProviderModal:t,addLlmProvider:n}=Kt(),[r,a]=v.useState({Name:"",Api:"",Key:"",Model:"",MaxTokens:null,Temperature:null,Timeout:null}),[i,s]=v.useState([]);console.log(i);const[o,l]=v.useState(null),[u,c]=v.useState(!1);v.useEffect(()=>{e&&(async()=>{try{const y=await Ni.getSupportedTypes();s(y)}catch(y){console.error("Failed to fetch supported types:",y)}})()},[e,s]);const d=T=>{const{name:y,value:w}=T.target;a(k=>({...k,[y]:y==="MaxTokens"||y==="Temperature"||y==="Timeout"?w===""?null:Number(w):w}))},p=()=>{a({Name:"",Api:"",Key:"",Model:"",MaxTokens:null,Temperature:null,Timeout:null}),l(null)},f=async()=>{if(l(null),c(!0),!r.Name||!r.Api||!r.Key||!r.Model){l("Name, API endpoint, API key, and model are required."),c(!1);return}try{await n(r),p()}catch(T){l(T instanceof Error?T.message:"Failed to add provider")}finally{c(!1)}},m=()=>{p(),t()},g=T=>{const y=T.toLowerCase();return y.includes("openai")&&!y.includes("azure")?{Api:"https://api.openai.com/v1",Model:"gpt-4o-mini"}:y.includes("azure")?{Api:"https://your-resource.openai.azure.com/",Model:"gpt-4o"}:y.includes("anthropic")||y.includes("claude")?{Api:"https://api.anthropic.com",Model:"claude-3-haiku-20240307"}:{}},x=T=>{const{value:y}=T.target,w=g(y);a(k=>({...k,Name:y,...w}))};return b.jsx(Eo,{isOpen:e,onClose:m,title:"Add LLM Provider",children:b.jsxs("div",{className:"space-y-4",children:[b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Provider Name *"}),b.jsx(Vn,{name:"Name",value:r.Name,onChange:x,placeholder:"e.g., OpenAI GPT-4, Azure OpenAI, Claude",className:"mt-1"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"API Endpoint *"}),b.jsx(Vn,{name:"Api",value:r.Api,onChange:d,placeholder:"https://api.openai.com/v1",className:"mt-1"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"API Key *"}),b.jsx(Vn,{name:"Key",type:"password",value:r.Key,onChange:d,placeholder:"sk-...",className:"mt-1"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Model *"}),b.jsx(Vn,{name:"Model",value:r.Model,onChange:d,placeholder:"gpt-4o, claude-3-haiku-20240307",className:"mt-1"})]}),b.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Max Tokens"}),b.jsx(Vn,{name:"MaxTokens",type:"number",value:r.MaxTokens?.toString()||"",onChange:d,placeholder:"4096",className:"mt-1"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Temperature"}),b.jsx(Vn,{name:"Temperature",type:"number",step:"0.1",min:"0",max:"2",value:r.Temperature?.toString()||"",onChange:d,placeholder:"0.7",className:"mt-1"})]}),b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Timeout (s)"}),b.jsx(Vn,{name:"Timeout",type:"number",value:r.Timeout?.toString()||"",onChange:d,placeholder:"30",className:"mt-1"})]})]}),o&&b.jsx("div",{className:"rounded-md bg-red-50 p-3 dark:bg-red-950/50",children:b.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:o})}),b.jsxs("div",{className:"flex justify-end space-x-3 pt-4",children:[b.jsx(xn,{onClick:m,className:"rounded-md border border-neutral-300 bg-white px-4 py-2 text-sm font-medium text-neutral-700 hover:bg-neutral-50 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-700",children:"Cancel"}),b.jsx(xn,{onClick:f,disabled:u,className:"inline-flex items-center rounded-md bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 disabled:opacity-50 dark:bg-indigo-500 dark:hover:bg-indigo-600",children:u?"Adding...":"Add Provider"})]})]})})}function foe(){const{isAddMcpServerModalOpen:e,closeAddMcpServerModal:t,addMcpServer:n,getLoading:r,user:a,token:i}=Kt(),[s,o]=v.useState({name:"",description:"",url:"",token:""}),[l,u]=v.useState(null),[c,d]=v.useState(!1),[p,f]=v.useState(!1),[m,g]=v.useState(!1),x=r("mcpServerCreate"),T=k=>{const{name:_,value:A}=k.target;o(R=>({...R,[_]:A})),l&&u(null)},y=async()=>{if(u(null),!s.name.trim()||!s.url.trim()){u("Name and URL are required.");return}try{const k={...s,token:p?i||"":s.token};await n(k),d(!0),setTimeout(()=>{o({name:"",description:"",url:"",token:""}),d(!1),f(!0),g(!1)},1500)}catch(k){u("Failed to add server. Please check the details and try again."),console.error(k)}},w=()=>{x||(o({name:"",description:"",url:"",token:""}),u(null),d(!1),f(!0),g(!1),t())};return b.jsx(Eo,{isOpen:e,onClose:w,title:"Add New MCP Server",children:b.jsx(Dr,{mode:"wait",children:c?b.jsxs(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.4,ease:"easeOut"},className:"flex flex-col items-center justify-center py-8",children:[b.jsx(ke.div,{initial:{scale:0,rotate:-180},animate:{scale:1,rotate:0},transition:{delay:.2,duration:.5,type:"spring",stiffness:200,damping:15},className:"mb-6 rounded-full bg-gradient-to-br from-green-100 to-green-50 p-4 shadow-lg dark:from-green-900/30 dark:to-green-800/20",children:b.jsx(gT,{className:"h-8 w-8 text-green-600 dark:text-green-400"})}),b.jsxs(ke.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.4,duration:.3},className:"text-center",children:[b.jsx("h3",{className:"text-lg font-semibold text-neutral-900 dark:text-white",children:"Server Added Successfully!"}),b.jsx("p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:"Your MCP server is now ready to use."})]})]},"success"):b.jsxs(ke.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:[b.jsxs("div",{className:"mb-6 flex items-center space-x-3",children:[b.jsx("div",{className:"rounded-lg bg-gradient-to-br from-indigo-500 to-purple-600 p-2",children:b.jsx(Md,{className:"h-5 w-5 text-white"})}),b.jsxs("div",{children:[b.jsx("p",{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Connect a New Server"}),b.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:"Enter the connection details for your MCP server"})]})]}),b.jsxs("div",{className:"space-y-5",children:[b.jsx(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},children:b.jsxs(Zt,{children:[b.jsxs(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:["Server Name ",b.jsx("span",{className:"text-indigo-500",children:"*"})]}),b.jsx(Vn,{name:"name",value:s.name,onChange:T,placeholder:"My Local Server",required:!0,className:"mt-1"})]})}),b.jsx(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},children:b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Description"}),b.jsx(Vn,{name:"description",value:s.description,onChange:T,placeholder:"A brief description of the server",className:"mt-1"})]})}),b.jsx(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.3},children:b.jsxs(Zt,{children:[b.jsxs(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:["Server URL ",b.jsx("span",{className:"text-indigo-500",children:"*"})]}),b.jsx(Vn,{name:"url",value:s.url,onChange:T,placeholder:"http://localhost:8000",required:!0,className:"mt-1"})]})}),b.jsx(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.4},children:b.jsxs(Zt,{children:[b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Authentication Token"}),b.jsxs("div",{className:"mt-2 space-y-3",children:[a&&i&&b.jsx(ke.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},transition:{delay:.1},children:b.jsxs("button",{type:"button",onClick:()=>f(!0),className:`w-full flex items-center justify-between p-3 rounded-lg border-2 transition-all duration-200 ${p?"border-indigo-500 bg-indigo-50 dark:border-indigo-400 dark:bg-indigo-900/20":"border-neutral-200 bg-neutral-50 hover:border-neutral-300 dark:border-neutral-700 dark:bg-neutral-800/50 dark:hover:border-neutral-600"}`,children:[b.jsxs("div",{className:"flex items-center space-x-3",children:[b.jsx("div",{className:`p-2 rounded-lg ${p?"bg-indigo-100 text-indigo-600 dark:bg-indigo-800/50 dark:text-indigo-300":"bg-neutral-200 text-neutral-600 dark:bg-neutral-700 dark:text-neutral-400"}`,children:b.jsx(Pd,{className:"h-4 w-4"})}),b.jsxs("div",{className:"text-left",children:[b.jsx("p",{className:"text-sm font-medium text-neutral-900 dark:text-white",children:"Use Current User Token"}),b.jsxs("p",{className:"text-xs text-neutral-500 dark:text-neutral-400 truncate max-w-48",children:["Authenticated as ",a.username]})]})]}),b.jsx("div",{className:`h-4 w-4 rounded-full border-2 transition-colors ${p?"border-indigo-500 bg-indigo-500":"border-neutral-300 dark:border-neutral-600"}`,children:p&&b.jsx(ke.div,{initial:{scale:0},animate:{scale:1},className:"h-full w-full rounded-full bg-white scale-50"})})]})}),b.jsx(ke.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},transition:{delay:.2},children:b.jsxs("button",{type:"button",onClick:()=>{g(!m),m||f(!1)},className:"w-full flex items-center justify-between p-3 rounded-lg border-2 border-neutral-200 bg-neutral-50 hover:border-neutral-300 transition-all duration-200 dark:border-neutral-700 dark:bg-neutral-800/50 dark:hover:border-neutral-600",children:[b.jsxs("div",{className:"flex items-center space-x-3",children:[b.jsx("div",{className:"p-2 rounded-lg bg-neutral-200 text-neutral-600 dark:bg-neutral-700 dark:text-neutral-400",children:b.jsx(vT,{className:"h-4 w-4"})}),b.jsxs("div",{className:"text-left",children:[b.jsx("p",{className:"text-sm font-medium text-neutral-900 dark:text-white",children:"Advanced Options"}),b.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:"Custom token configuration"})]})]}),b.jsx(ke.div,{animate:{rotate:m?180:0},transition:{duration:.2},children:b.jsx(bT,{className:"h-4 w-4 text-neutral-500"})})]})}),b.jsx(Dr,{children:m&&b.jsx(ke.div,{initial:{opacity:0,height:0,y:-10},animate:{opacity:1,height:"auto",y:0},exit:{opacity:0,height:0,y:-10},transition:{duration:.3,ease:"easeInOut"},className:"overflow-hidden",children:b.jsxs("div",{className:"p-4 rounded-lg bg-neutral-100/50 border border-neutral-200 dark:bg-neutral-800/30 dark:border-neutral-700",children:[b.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[b.jsx(lM,{className:"h-4 w-4 text-neutral-600 dark:text-neutral-400"}),b.jsx(Lt,{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Custom Token"})]}),b.jsx(Vn,{name:"token",value:s.token,onChange:T,placeholder:"Enter custom authentication token",type:"password",className:"bg-white dark:bg-neutral-900"}),b.jsx("p",{className:"mt-2 text-xs text-neutral-500 dark:text-neutral-400",children:"Leave empty if no authentication is required"})]})})})]})]})})]}),b.jsx(Dr,{children:l&&b.jsxs(ke.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mt-4 flex items-center space-x-2 rounded-lg bg-red-50 p-3 dark:bg-red-900/20",children:[b.jsx(ST,{className:"h-4 w-4 text-red-500"}),b.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:l})]})}),b.jsxs(ke.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.5},className:"mt-8 flex justify-end gap-3",children:[b.jsx(xn,{onClick:w,disabled:x,className:"inline-flex items-center gap-2 rounded-lg bg-neutral-100 px-4 py-2 text-sm font-medium text-neutral-700 transition-colors hover:bg-neutral-200 focus:outline-none focus:ring-2 focus:ring-neutral-500 focus:ring-offset-2 disabled:opacity-50 dark:bg-neutral-800 dark:text-neutral-200 dark:hover:bg-neutral-700",children:"Cancel"}),b.jsx(xn,{onClick:y,disabled:x||!s.name.trim()||!s.url.trim(),className:"inline-flex items-center gap-2 rounded-lg bg-gradient-to-r from-indigo-600 to-indigo-700 px-4 py-2 text-sm font-medium text-white shadow-sm transition-all hover:from-indigo-500 hover:to-indigo-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",children:x?b.jsxs(b.Fragment,{children:[b.jsx(ke.div,{animate:{rotate:360},transition:{duration:1,repeat:1/0,ease:"linear"},className:"h-4 w-4 rounded-full border-2 border-white border-t-transparent"}),"Creating..."]}):b.jsxs(b.Fragment,{children:[b.jsx(xT,{className:"h-4 w-4"}),"Add Server"]})})]})]},"form")})})}const hoe=!1,moe=!0;console.log("=== Environment Debug ==="),console.log("MODE:","production"),console.log("isDevelopment:",hoe),console.log("isProduction:",moe),console.log("VITE_XYZEN_BACKEND_URL:",void 0);const gR=window!==void 0?`${window.location.protocol}//${window.location.host}`:"http://localhost:48196";console.log("Final DEFAULT_BACKEND_URL:",gR);const goe=280,boe=600,bR=380,Eoe=({isActive:e,onDoubleClick:t})=>{const{attributes:n,listeners:r,setNodeRef:a}=ed({id:"xyzen-resizer"});return b.jsx("div",{ref:a,className:`absolute left-0 top-0 z-50 h-full w-1 cursor-col-resize ${e?"bg-indigo-500 shadow-md dark:bg-indigo-400":"bg-transparent hover:bg-indigo-400/60 hover:shadow-sm dark:hover:bg-indigo-500/60"} transition-all duration-150 ease-in-out`,...r,...n,onDoubleClick:t})},yoe=({onOpenClick:e})=>{const{attributes:t,listeners:n,setNodeRef:r,transform:a}=ed({id:"xyzen-floater"}),i=a?{transform:`translate3d(0, ${a.y}px, 0)`}:void 0;return b.jsx("button",{ref:r,style:i,...n,...t,onClick:e,className:"flex h-12 w-12 items-center justify-center rounded-full bg-indigo-600 text-white shadow-lg transition-transform duration-200 ease-in-out hover:scale-110 hover:bg-indigo-700",title:"Open Xyzen",children:b.jsx(xT,{className:"h-6 w-6"})})};function voe({backendUrl:e=gR,showThemeToggle:t=!0,showLlmProvider:n=!1}){const{isXyzenOpen:r,closeXyzen:a,panelWidth:i,setPanelWidth:s,toggleXyzen:o,activeTabIndex:l,setTabIndex:u,setBackendUrl:c,user:d,fetchAgents:p,fetchMcpServers:f}=Kt(),[m,g]=v.useState(!1),[x,T]=v.useState(!1),[y,w]=v.useState(!1),[k,_]=v.useState(!1),[A,R]=v.useState({y:typeof window<"u"?window.innerHeight/2:300}),M=v.useRef(i),P=[{id:"agent",title:"助手",component:b.jsx(SU,{})},{id:"chat",title:"聊天",component:b.jsx(doe,{})}];v.useEffect(()=>{g(!0),c(e)},[e,c]);const D=v.useCallback(async()=>{if(d&&e)try{await Promise.all([p(),f()])}catch(X){console.error("Failed to load initial data:",X)}},[d,e,p,f]);v.useEffect(()=>{D()},[D]);const z=$c(Hc(Fs,{activationConstraint:{distance:5}})),W=$c(Hc(Fs,{activationConstraint:{distance:8}})),V=()=>{T(!0),M.current=i},K=X=>{const se=Math.min(Math.max(M.current-X.delta.x,goe),boe);s(se)},te=()=>{T(!1)},ge=X=>{const{delta:se}=X;R(C=>({y:C.y+se.y}))},ce=()=>{s(bR),M.current=bR};return v.useEffect(()=>{const X=se=>{(se.metaKey||se.ctrlKey)&&se.shiftKey&&se.key==="X"&&(se.preventDefault(),o())};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[o]),m?r?b.jsxs(Jc,{sensors:z,onDragStart:V,onDragMove:K,onDragEnd:te,modifiers:[S7],children:[b.jsxs("div",{className:"fixed right-0 top-0 z-50 h-full bg-white shadow-xl dark:border-l dark:border-neutral-800 dark:bg-black",style:{width:`${i}px`,transition:x?"none":"width 0.2s ease-in-out"},children:[b.jsx(Eoe,{isActive:x,onDoubleClick:ce}),b.jsxs(Js.Group,{as:"div",selectedIndex:l,onChange:u,className:"flex h-full flex-col",children:[b.jsxs("div",{className:"flex h-16 flex-shrink-0 items-center justify-between border-b border-neutral-200 px-4 dark:border-neutral-800",children:[b.jsx(Js.List,{className:"flex items-center space-x-1",children:P.map(X=>b.jsx(Js,{className:({selected:se})=>`whitespace-nowrap rounded-md px-3 py-2 text-sm font-medium outline-none transition-colors duration-200 ${se?"bg-neutral-100 text-indigo-600 dark:bg-neutral-900 dark:text-indigo-400":"text-neutral-500 hover:bg-neutral-100/50 dark:text-neutral-400 dark:hover:bg-neutral-800/50"}`,children:X.title},X.id))}),b.jsxs("div",{className:"flex items-center space-x-1",children:[t&&b.jsx(fU,{}),b.jsx("button",{className:"rounded-md p-1.5 text-neutral-500 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:bg-neutral-800",title:"MCP 管理",onClick:()=>w(!0),children:b.jsx(nu,{className:"h-5 w-5"})}),n&&b.jsx("button",{className:"rounded-md p-1.5 text-neutral-500 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:bg-neutral-800",title:"LLM 提供商",onClick:()=>_(!0),children:b.jsx(vT,{className:"h-5 w-5"})}),b.jsx("div",{className:"mx-2 h-6 w-px bg-neutral-200 dark:bg-neutral-700"}),b.jsx(pU,{className:"ml-2"}),b.jsx("button",{onClick:a,className:"rounded-md p-1.5 text-neutral-500 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:bg-neutral-800",title:"关闭",children:b.jsx(Fd,{className:"h-5 w-5"})})]})]}),b.jsx("div",{className:"flex-grow overflow-y-auto py-4",children:b.jsx(Js.Panels,{className:"h-full",children:P.map(X=>b.jsx(Js.Panel,{className:"h-full",unmount:!1,children:X.component},X.id))})})]}),b.jsx(Qs,{appear:!0,show:y,as:v.Fragment,children:b.jsxs(Nd,{open:y,onClose:()=>w(!1),className:"relative z-50",children:[b.jsx(ai,{as:v.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:b.jsx("div",{className:"fixed inset-0 bg-black/30","aria-hidden":"true"})}),b.jsx("div",{className:"fixed inset-0 flex w-screen items-center justify-center p-4",children:b.jsx(ai,{as:v.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:b.jsx(Bl,{className:"w-full max-w-2xl rounded-lg",children:b.jsx(uU,{})})})})]})}),n&&b.jsx(Qs,{appear:!0,show:k,as:v.Fragment,children:b.jsxs(Nd,{open:k,onClose:()=>_(!1),className:"relative z-50",children:[b.jsx(ai,{as:v.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-200",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:b.jsx("div",{className:"fixed inset-0 bg-black/30","aria-hidden":"true"})}),b.jsx("div",{className:"fixed inset-0 flex w-screen items-center justify-center p-4",children:b.jsx(ai,{as:v.Fragment,enter:"ease-out duration-300",enterFrom:"opacity-0 scale-95",enterTo:"opacity-100 scale-100",leave:"ease-in duration-200",leaveFrom:"opacity-100 scale-100",leaveTo:"opacity-0 scale-95",children:b.jsx(Bl,{className:"w-full max-w-2xl rounded-lg bg-white p-6 dark:bg-neutral-900",children:b.jsx(NM,{})})})})]})})]}),b.jsx(foe,{}),n&&b.jsx(poe,{})]}):b.jsx(Jc,{sensors:W,onDragEnd:ge,modifiers:[x7],children:b.jsx("div",{className:"fixed right-4 z-50",style:{top:A.y,transform:"translateY(-50%)"},children:b.jsx(yoe,{onOpenClick:o})})}):null}gr.Xyzen=voe,gr.useTheme=Ex,gr.useXyzen=Kt,gr.xyzenService=Ea,Object.defineProperty(gr,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@sciol/xyzen",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"packageManager": "yarn@4.9.2",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.8",
|
|
6
6
|
"description": "A modern, lightweight, and extensible chat component for React.",
|
|
7
7
|
"author": "Haohui <harveyque@outlook.com>",
|
|
8
8
|
"license": "GPL-3.0-only",
|