@lacneu/atrium 0.60.0 → 0.60.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/assets/{AccessTab-BBYqbyQz.js → AccessTab-BlTwl2Uk.js} +1 -1
  2. package/dist/assets/{AdvancedFilter-BTcB0NuZ.js → AdvancedFilter-C5pnO4fi.js} +1 -1
  3. package/dist/assets/{AgentFilesTab-BjPywJ7Q.js → AgentFilesTab-tYeG81Bo.js} +1 -1
  4. package/dist/assets/{AnomaliesTab-CYpcTOYy.js → AnomaliesTab-C94n-0pQ.js} +1 -1
  5. package/dist/assets/{AuditTab-NnWwJHq_.js → AuditTab-D_mhJO5w.js} +1 -1
  6. package/dist/assets/{BridgeTab-C_I81PZ8.js → BridgeTab-s6Ggg8Zu.js} +1 -1
  7. package/dist/assets/{ChatDefaultsTab-STVjXTAX.js → ChatDefaultsTab-DYVQXktp.js} +1 -1
  8. package/dist/assets/{DataTableShell-DAEVsm3y.js → DataTableShell-COEwE2Hv.js} +1 -1
  9. package/dist/assets/{DetailChips-DerZpgh4.js → DetailChips-8ZpH5ZXE.js} +1 -1
  10. package/dist/assets/{FeedbacksTab-BdYRB-_C.js → FeedbacksTab-CqJ8NDLb.js} +1 -1
  11. package/dist/assets/{FieldLabel-BJRoUSf1.js → FieldLabel-hLNtge_D.js} +1 -1
  12. package/dist/assets/{FilesTab-h10yjTHp.js → FilesTab-lytzpFwp.js} +1 -1
  13. package/dist/assets/{FilterBar-Byr6OGo7.js → FilterBar-CY1WfFDB.js} +1 -1
  14. package/dist/assets/{GroupsTab-BJWQQexi.js → GroupsTab-BjjiPSDY.js} +1 -1
  15. package/dist/assets/{InstancesTab-ZJeQ4rRg.js → InstancesTab-bbthnf8h.js} +1 -1
  16. package/dist/assets/{IntegrationsTab-CSOlJvFa.js → IntegrationsTab-DQt4Kllc.js} +1 -1
  17. package/dist/assets/{KpiTab-Dz5IcL9k.js → KpiTab-qUWozfhc.js} +1 -1
  18. package/dist/assets/{PreferencesTab-Bd-GUi0T.js → PreferencesTab-B1JSLFVE.js} +1 -1
  19. package/dist/assets/{PromptInjectionsTab-H8zrJADs.js → PromptInjectionsTab-Df6PKtxv.js} +1 -1
  20. package/dist/assets/{RolesTab-rgpFvkKx.js → RolesTab-DbSxOWRh.js} +1 -1
  21. package/dist/assets/{ScheduledTab-DbMIc4wG.js → ScheduledTab-km3Zx4dq.js} +1 -1
  22. package/dist/assets/{ServiceAccountsTab-BeEdMciQ.js → ServiceAccountsTab-Bcd88LfG.js} +1 -1
  23. package/dist/assets/{SubAgentReportsTab-BgM9O4QZ.js → SubAgentReportsTab-xgRtphLV.js} +1 -1
  24. package/dist/assets/{ThemeShowroom-BjDGGE3i.js → ThemeShowroom-DxcANzhZ.js} +1 -1
  25. package/dist/assets/{TimeRangePicker-RVc6k7g6.js → TimeRangePicker-BYCcnF0a.js} +1 -1
  26. package/dist/assets/{TracesTab-Cb65hpku.js → TracesTab-ColoY1Nx.js} +1 -1
  27. package/dist/assets/{UsersTab-BPRPmEOS.js → UsersTab-B0IdN_hl.js} +1 -1
  28. package/dist/assets/{VoiceTab-tgovFfm-.js → VoiceTab-qZ5tMxmC.js} +1 -1
  29. package/dist/assets/{highlighted-body-OFNGDK62-Dj4OC_Nj.js → highlighted-body-OFNGDK62-xjw7PDBM.js} +1 -1
  30. package/dist/assets/{index-CW5WE31O.js → index-CNwjY680.js} +6 -6
  31. package/dist/assets/mermaid-GHXKKRXX-DxPFrHWq.js +1 -0
  32. package/dist/assets/{pdf-Bx7jp7ID.js → pdf-CLjbM27Z.js} +1 -1
  33. package/dist/assets/{tabs-Kb2_G-yp.js → tabs-fDXC7itk.js} +1 -1
  34. package/dist/index.html +1 -1
  35. package/package.json +1 -1
  36. package/dist/assets/mermaid-GHXKKRXX-DURCfVhS.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlighted-body-OFNGDK62-Dj4OC_Nj.js","assets/bundle-mjs-C73ZY4La.js","assets/RolesTab-rgpFvkKx.js","assets/dist-De2K23IB.js","assets/roleDescriptions-zLFA4zEm.js","assets/button-Bd43O_sm.js","assets/InstancesTab-ZJeQ4rRg.js","assets/FieldLabel-BJRoUSf1.js","assets/curation-CQksaIbm.js","assets/locales-CPjguROj.js","assets/BridgeTab-C_I81PZ8.js","assets/compatView-B2BXfBvC.js","assets/dist-CXJY_tYD.js","assets/tabs-Kb2_G-yp.js","assets/chevrons-up-down-DIXCqs3W.js","assets/FilterBar-Byr6OGo7.js","assets/TimeRangePicker-RVc6k7g6.js","assets/table-BRilRxUj.js","assets/dispatchErrorInfo-DKMvYSfG.js","assets/DataTableShell-DAEVsm3y.js","assets/PromptInjectionsTab-H8zrJADs.js","assets/localePickerView-C2RmOS86.js","assets/confTabs-C35Io1ep.css","assets/GroupsTab-BJWQQexi.js","assets/x-DXaZHGzl.js","assets/DetailChips-DerZpgh4.js","assets/IntegrationsTab-CSOlJvFa.js","assets/FeedbacksTab-BdYRB-_C.js","assets/SubAgentReportsTab-BgM9O4QZ.js","assets/FilesTab-h10yjTHp.js","assets/ScheduledTab-DbMIc4wG.js","assets/AgentFilesTab-BjPywJ7Q.js","assets/PreferencesTab-Bd-GUi0T.js","assets/ChatDefaultsTab-STVjXTAX.js","assets/AccessTab-BBYqbyQz.js","assets/ThemeShowroom-BjDGGE3i.js","assets/dist-Du1hJWyV.js","assets/AdvancedFilter-BTcB0NuZ.js","assets/card-Bkvykfxh.js","assets/TracesTab-Cb65hpku.js","assets/VoiceTab-tgovFfm-.js","assets/AuditTab-NnWwJHq_.js","assets/AnomaliesTab-CYpcTOYy.js","assets/KpiTab-Dz5IcL9k.js","assets/ServiceAccountsTab-BeEdMciQ.js","assets/UsersTab-BPRPmEOS.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlighted-body-OFNGDK62-xjw7PDBM.js","assets/bundle-mjs-C73ZY4La.js","assets/RolesTab-DbSxOWRh.js","assets/dist-De2K23IB.js","assets/roleDescriptions-zLFA4zEm.js","assets/button-Bd43O_sm.js","assets/InstancesTab-bbthnf8h.js","assets/FieldLabel-hLNtge_D.js","assets/curation-CQksaIbm.js","assets/locales-CPjguROj.js","assets/BridgeTab-s6Ggg8Zu.js","assets/compatView-B2BXfBvC.js","assets/dist-CXJY_tYD.js","assets/tabs-fDXC7itk.js","assets/chevrons-up-down-DIXCqs3W.js","assets/FilterBar-CY1WfFDB.js","assets/TimeRangePicker-BYCcnF0a.js","assets/table-BRilRxUj.js","assets/dispatchErrorInfo-DKMvYSfG.js","assets/DataTableShell-COEwE2Hv.js","assets/PromptInjectionsTab-Df6PKtxv.js","assets/localePickerView-C2RmOS86.js","assets/confTabs-C35Io1ep.css","assets/GroupsTab-BjjiPSDY.js","assets/x-DXaZHGzl.js","assets/DetailChips-8ZpH5ZXE.js","assets/IntegrationsTab-DQt4Kllc.js","assets/FeedbacksTab-CqJ8NDLb.js","assets/SubAgentReportsTab-xgRtphLV.js","assets/FilesTab-lytzpFwp.js","assets/ScheduledTab-km3Zx4dq.js","assets/AgentFilesTab-tYeG81Bo.js","assets/PreferencesTab-B1JSLFVE.js","assets/ChatDefaultsTab-DYVQXktp.js","assets/AccessTab-BlTwl2Uk.js","assets/ThemeShowroom-DxcANzhZ.js","assets/dist-Du1hJWyV.js","assets/AdvancedFilter-C5pnO4fi.js","assets/card-Bkvykfxh.js","assets/TracesTab-ColoY1Nx.js","assets/VoiceTab-qZ5tMxmC.js","assets/AuditTab-D_mhJO5w.js","assets/AnomaliesTab-C94n-0pQ.js","assets/KpiTab-qUWozfhc.js","assets/ServiceAccountsTab-Bcd88LfG.js","assets/UsersTab-B0IdN_hl.js"])))=>i.map(i=>d[i]);
2
2
  import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./bundle-mjs-C73ZY4La.js";import{$ as l,$D as u,$E as d,$M as f,$P as p,$_ as m,$d as h,$i as g,$l as _,$m as v,$o as y,$p as b,$s as x,A as S,AD as C,AE as w,Aa as T,Af as E,Am as D,Ap as O,Ar as k,As as A,B as j,BD as M,BE as N,BM as ee,BP as P,Ba as F,Bf as te,Bl as ne,Bm as re,Bn as ie,Bp as ae,Br as oe,Bs as se,Bt as ce,C as le,CD as ue,CE as de,CO as fe,CT as pe,Cc as me,Cf as he,Ch as ge,Cm as _e,Cr as ve,Cs as ye,Cu as be,Cy as xe,D as I,DD as Se,DE as Ce,DO as we,Dc as Te,Df as Ee,Dm as De,Dp as Oe,Dr as ke,Ds as Ae,Du as je,Dy as Me,E as L,ED as Ne,EE as Pe,EO as Fe,Ec as Ie,Ef as Le,Em as Re,Ep as ze,Er as Be,Es as Ve,Eu as He,Ey as Ue,F as We,FD as Ge,FE as Ke,FM as qe,Fa as Je,Ff as Ye,Fi as Xe,Fl as Ze,Fm as Qe,Fn as $e,Fp as et,Fr as tt,Fs as nt,G as rt,GD as it,GE as at,GM as ot,GP as st,G_ as ct,Gi as lt,Gl as ut,Gm as dt,Gn as ft,Go as pt,Gp as mt,Gr as ht,Gs as gt,H as _t,HD as vt,HE as yt,HM as bt,HP as xt,Ha as St,Hi as Ct,Hl as wt,Hm as Tt,Hn as Et,Ho as Dt,Hp as Ot,Hr as kt,Hs as At,Ht as jt,I as Mt,ID as Nt,IE as Pt,IM as Ft,IN as It,Ia as Lt,If as Rt,Ii as zt,Il as Bt,Im as Vt,In as Ht,Ip as Ut,Ir as Wt,Is as Gt,J as Kt,JD as qt,JE as Jt,JM as Yt,JP as Xt,J_ as Zt,Ji as Qt,Jl as $t,Jm as en,Jn as tn,Jo as nn,Jp as rn,Js as an,K as on,KD as sn,KE as cn,KM as ln,KP as un,K_ as dn,Ki as fn,Kl as pn,Km as mn,Kn as hn,Ko as gn,Kp as _n,Kr as vn,Ks as yn,L as bn,LD as xn,LE as Sn,LM as Cn,La as wn,Lf as Tn,Ll as En,Lm as Dn,Ln as On,Lp as kn,Lr as An,Ls as jn,M as Mn,MD as Nn,ME as Pn,MM as Fn,Ma as In,Mf as Ln,Mm as Rn,Mp as zn,Mr as Bn,Ms as Vn,N as Hn,ND as Un,NE as Wn,NM as Gn,Na as Kn,Nf as qn,Nm as Jn,Np as Yn,Nr as Xn,Ns as Zn,O as Qn,OD as $n,OE as er,OO as tr,Oc as nr,Of as rr,Om as ir,Op as ar,Or as or,Os as sr,Oy as cr,P as lr,PD as ur,PE as dr,PM as fr,Pa as pr,Pf as mr,Pl as hr,Pm as gr,Pp as _r,Pr as vr,Ps as yr,Q as br,QD as xr,QE as Sr,QM as Cr,QP as wr,Q_ as Tr,Qi as Er,Ql as Dr,Qm as Or,Qo as kr,Qp as Ar,Qs as jr,R as Mr,RD as Nr,RE as Pr,RM as Fr,RP as Ir,Ra as Lr,Rf as Rr,Rl as zr,Rm as Br,Rn as Vr,Rp as Hr,Rr as Ur,Rs as Wr,Rt as Gr,S as Kr,SD as qr,SE as Jr,SN as Yr,SO as Xr,ST as Zr,Sc as Qr,Sf as $r,Sh as ei,Sm as ti,Sr as ni,Ss as ri,Su as ii,Sy as ai,T as oi,TD as si,TE as ci,TO as li,Tc as ui,Tf as di,Tm as fi,Tn as pi,Tr as mi,Ts as hi,Tu as gi,Ty as _i,U as vi,UD as yi,UE as bi,UM as xi,UP as Si,Ul as Ci,Um as wi,Un as Ti,Uo as Ei,Up as Di,Ur as Oi,Us as ki,Ut as Ai,V as ji,VD as Mi,VE as Ni,VM as Pi,VP as Fi,Va as Ii,Vf as Li,Vi as Ri,Vl as zi,Vm as Bi,Vn as Vi,Vo as Hi,Vp as Ui,Vr as Wi,Vs as Gi,Vt as Ki,W as qi,WD as Ji,WE as Yi,WM as Xi,WP as Zi,W_ as Qi,Wl as $i,Wm as ea,Wn as ta,Wo as na,Wp as ra,Wr as ia,Ws as aa,Wt as oa,X as sa,XD as ca,XE as la,XM as ua,XP as da,X_ as fa,Xi as pa,Xl as ma,Xm as ha,Xo as ga,Xp as _a,Xs as va,Xx as ya,Y as ba,YD as xa,YE as Sa,YM as Ca,YP as wa,Y_ as Ta,Yg as Ea,Yi as Da,Yl as Oa,Ym as ka,Yo as Aa,Yp as ja,Ys as Ma,Z as Na,ZD as Pa,ZE as Fa,ZM as Ia,ZP as La,Z_ as Ra,Zi as za,Zl as Ba,Zm as Va,Zo as Ha,Zp as Ua,Zs as Wa,_ as Ga,_D as Ka,_E as qa,_N as Ja,_O as Ya,_T as Xa,_a as Za,_c as Qa,_f as $a,_h as eo,_m as to,_n as no,_r as ro,_s as io,_u as ao,_y as oo,a as so,aD as co,aF as lo,aM as uo,aN as fo,aO as po,aa as mo,ac as ho,af as go,ah as _o,ar as vo,at as yo,au as bo,av as xo,ay as So,b as Co,bD as wo,bE as To,bN as Eo,bO as Do,bT as Oo,bc as ko,bf as Ao,bg as jo,bh as Mo,bm as No,br as Po,bs as Fo,bt as Io,bu as Lo,by as Ro,c as zo,cD as Bo,cF as Vo,cN as Ho,cO as Uo,cT as Wo,ca as Go,cc as Ko,cf as qo,ch as Jo,cr as Yo,ct as Xo,cu as Zo,cv as Qo,cy as $o,d as es,dD as ts,dF as ns,dM as rs,dN as is,dO as as,dT as os,da as ss,dc as cs,df as ls,dh as us,dr as ds,du as fs,dv as ps,dy as ms,eD as hs,eF as R,eN as gs,eO as _s,ea as vs,ec as ys,ef as bs,eh as xs,em as Ss,es as Cs,et as ws,eu as Ts,ev as Es,f as Ds,fD as Os,fM as ks,fN as As,fO as js,fT as Ms,fa as Ns,fc as Ps,ff as Fs,fh as Is,fm as Ls,fr as Rs,fu as zs,fv as Bs,fy as Vs,g as Hs,gD as Us,gE as Ws,gN as Gs,gO as Ks,gT as qs,ga as Js,gc as Ys,gf as Xs,gh as Zs,gm as Qs,gr as $s,gs as ec,gu as tc,gv as nc,gy as rc,h as ic,hD as ac,hE as oc,hN as sc,hO as cc,hT as lc,ha as uc,hc as dc,hf as fc,hh as pc,hm as mc,hr as hc,hs as gc,hu as _c,hv as vc,hy as yc,i as bc,iD as xc,iF as Sc,iN as Cc,iO as wc,ia as Tc,ic as Ec,if as Dc,ih as Oc,im as kc,ir as Ac,is as jc,it as Mc,iu as Nc,iv as Pc,iy as Fc,j as Ic,jD as Lc,jE as Rc,ja as zc,jf as Bc,jm as Vc,jp as Hc,jr as Uc,js as Wc,k as Gc,kD as Kc,kE as qc,ka as Jc,kf as Yc,km as Xc,kp as Zc,kr as Qc,ks as $c,l as el,lD as tl,lF as nl,lM as rl,lN as il,lO as al,lT as ol,la as sl,lc as cl,lf as ll,lh as ul,lr as dl,lt as fl,lu as pl,lv as ml,ly as hl,mD as gl,mN as _l,mO as vl,mT as yl,ma as bl,mc as xl,mf as Sl,mh as Cl,mm as wl,mr as Tl,ms as El,mu as Dl,mv as Ol,my as kl,n as Al,nD as jl,nF as Ml,nN as Nl,nO as Pl,na as Fl,nc as Il,nf as Ll,nh as Rl,nm as zl,ns as Bl,nt as Vl,nu as Hl,nv as Ul,ny as Wl,o as Gl,oD as Kl,oF as ql,oM as Jl,oN as Yl,oO as Xl,oa as Zl,oc as Ql,of as $l,oh as eu,or as tu,ot as nu,ou as ru,ov as iu,oy as au,p as ou,pD as su,pM as cu,pN as lu,pO as uu,pT as du,pa as fu,pc as pu,pf as mu,ph as hu,pm as gu,pr as _u,pu as vu,pv as yu,py as bu,q as xu,qD as Su,qE as Cu,qM as wu,qP as Tu,q_ as Eu,qi as Du,ql as Ou,qm as ku,qn as Au,qo as ju,qp as Mu,qr as Nu,qs as Pu,r as Fu,rD as Iu,rF as Lu,rN as Ru,rO as zu,ra as Bu,rc as Vu,rf as Hu,rh as Uu,rl as Wu,rm as Gu,rs as Ku,rt as qu,ru as Ju,rv as Yu,ry as Xu,s as Zu,sD as Qu,sM as $u,sN as ed,sO as td,sT as nd,sa as rd,sc as id,sf as ad,sh as od,sr as sd,st as cd,su as ld,sv as ud,sy as dd,t as fd,tD as pd,tF as md,tN as hd,tO as gd,ta as _d,tc as vd,tf as yd,th as bd,tm as xd,ts as Sd,tt as Cd,tu as wd,tv as Td,u as Ed,uD as Dd,uF as Od,uM as kd,uN as Ad,uO as jd,uT as Md,ua as Nd,uc as Pd,uf as Fd,uh as Id,ur as Ld,uu as Rd,uv as zd,uy as Bd,v as z,vD as Vd,vE as Hd,vN as Ud,vO as Wd,vT as Gd,va as Kd,vc as qd,vf as Jd,vh as Yd,vm as Xd,vn as Zd,vr as Qd,vs as $d,vu as ef,vy as tf,w as nf,wD as rf,wE as af,wO as of,wT as sf,wc as cf,wf as lf,wm as uf,wr as df,ws as ff,wu as pf,wy as mf,x as hf,xD as gf,xE as _f,xN as vf,xO as yf,xT as bf,xc as xf,xf as Sf,xh as Cf,xm as wf,xr as Tf,xs as Ef,xt as Df,xu as Of,xy as kf,y as Af,yD as jf,yE as Mf,yN as Nf,yO as Pf,yP as Ff,yT as If,yc as Lf,yf as Rf,yh as zf,ym as Bf,yn as Vf,yr as Hf,ys as Uf,yt as Wf,yu as Gf,yy as Kf,z as qf,zD as Jf,zE as Yf,zM as Xf,zP as Zf,za as Qf,zf as $f,zi as ep,zl as tp,zm as np,zn as rp,zp as ip,zr as ap,zs as op,zt as sp}from"./dist-De2K23IB.js";import{n as cp,t as lp}from"./dist-Du1hJWyV.js";import{i as up,n as dp,r as fp,t as pp}from"./dist-CXJY_tYD.js";import{t as mp}from"./x-DXaZHGzl.js";import{a as hp,c as gp,i as _p,l as vp,n as yp,o as bp,r as xp,s as Sp,t as Cp,u as wp}from"./dist-DfildYj4.js";import{n as Tp,t as Ep}from"./button-Bd43O_sm.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Dp=a((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),eee=a(((e,t)=>{t.exports=Dp()})),Op=a((t=>{var r=eee(),i=e(),a=n();function o(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function l(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(c(e)!==e)throw Error(o(188))}function f(e){var t=e.alternate;if(!t){if(t=c(e),t===null)throw Error(o(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return d(i),e;if(a===r)return d(i),t;a=a.sibling}throw Error(o(188))}if(n.return!==r.return)n=i,r=a;else{for(var s=!1,l=i.child;l;){if(l===n){s=!0,n=i,r=a;break}if(l===r){s=!0,r=i,n=a;break}l=l.sibling}if(!s){for(l=a.child;l;){if(l===n){s=!0,n=a,r=i;break}if(l===r){s=!0,r=a,n=i;break}l=l.sibling}if(!s)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,h=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),T=Symbol.for(`react.suspense_list`),E=Symbol.for(`react.memo`),D=Symbol.for(`react.lazy`),O=Symbol.for(`react.activity`),k=Symbol.for(`react.memo_cache_sentinel`),A=Symbol.iterator;function j(e){return typeof e!=`object`||!e?null:(e=A&&e[A]||e[`@@iterator`],typeof e==`function`?e:null)}var M=Symbol.for(`react.client.reference`);function N(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===M?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case w:return`Suspense`;case T:return`SuspenseList`;case O:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case E:return t=e.displayName||null,t===null?N(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return N(e(t))}catch{}}return null}var ee=Array.isArray,P=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te={pending:!1,data:null,method:null,action:null},ne=[],re=-1;function ie(e){return{current:e}}function ae(e){0>re||(e.current=ne[re],ne[re]=null,re--)}function oe(e,t){re++,ne[re]=e.current,e.current=t}var se=ie(null),ce=ie(null),le=ie(null),ue=ie(null);function de(e,t){switch(oe(le,t),oe(ce,e),oe(se,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?ef(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=ef(t),e=tf(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ae(se),oe(se,e)}function fe(){ae(se),ae(ce),ae(le)}function pe(e){e.memoizedState!==null&&oe(ue,e);var t=se.current,n=tf(t,e.type);t!==n&&(oe(ce,e),oe(se,n))}function me(e){ce.current===e&&(ae(se),ae(ce)),ue.current===e&&(ae(ue),dp._currentValue=te)}var he,ge;function _e(e){if(he===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);he=t&&t[1]||``,ge=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+he+e+ge}var ve=!1;function ye(e,t){if(!e||ve)return``;ve=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -200,14 +200,14 @@ ${e}</tr>
200
200
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${n4(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=r4(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+n4(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=r4(e);if(i===null)return n4(n);e=i;let a=`<img src="${e}" alt="${n4(n)}"`;return t&&(a+=` title="${n4(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:n4(e.text)}},u4=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},d4=class e{options;renderer;textRenderer;constructor(e){this.options=e||w2,this.options.renderer=this.options.renderer||new l4,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new u4}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},f4=class{options;block;constructor(e){this.options=e||w2}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?c4.lex:c4.lexInline}provideParser(e=this.block){return e?d4.parse:d4.parseInline}},p4=new class{defaults=C2();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=d4;Renderer=l4;TextRenderer=u4;Lexer=c4;Tokenizer=s4;Hooks=f4;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new l4(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new s4(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new f4;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];f4.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&f4.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return c4.lex(e,t??this.defaults)}parser(e,t){return d4.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?c4.lex:c4.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?d4.parse:d4.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?c4.lex:c4.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?d4.parse:d4.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
201
201
  Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+n4(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function m4(e,t){return p4.parse(e,t)}m4.options=m4.setOptions=function(e){return p4.setOptions(e),m4.defaults=p4.defaults,T2(m4.defaults),m4},m4.getDefaults=C2,m4.defaults=w2,m4.use=function(...e){return p4.use(...e),m4.defaults=p4.defaults,T2(m4.defaults),m4},m4.walkTokens=function(e,t){return p4.walkTokens(e,t)},m4.parseInline=p4.parseInline,m4.Parser=d4,m4.parser=d4.parse,m4.Renderer=l4,m4.TextRenderer=u4,m4.Lexer=c4,m4.lexer=c4.lex,m4.Tokenizer=s4,m4.Hooks=f4,m4.parse=m4,m4.options,m4.setOptions,m4.use,m4.walkTokens,m4.parseInline,d4.parse,c4.lex;var vge=`modulepreload`,yge=function(e){return`/`+e},h4={},g4=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=yge(t,n),t in h4)return;h4[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:vge,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},bge=300,xge=`300px`,Sge=500;function Cge(e={}){let{immediate:t=!1,debounceDelay:n=bge,rootMargin:r=xge,idleTimeout:i=Sge}=e,[a,o]=(0,B.useState)(!1),s=(0,B.useRef)(null),c=(0,B.useRef)(null),l=(0,B.useRef)(null),u=(0,B.useMemo)(()=>e=>{let t=Date.now();return window.setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})},1)},[]),d=(0,B.useMemo)(()=>typeof window<`u`&&window.requestIdleCallback?(e,t)=>window.requestIdleCallback(e,t):u,[u]),f=(0,B.useMemo)(()=>typeof window<`u`&&window.cancelIdleCallback?e=>window.cancelIdleCallback(e):e=>{clearTimeout(e)},[]);return(0,B.useEffect)(()=>{if(t){o(!0);return}let e=s.current;if(!e)return;c.current&&=(clearTimeout(c.current),null),l.current&&=(f(l.current),null);let a=()=>{c.current&&=(clearTimeout(c.current),null),l.current&&=(f(l.current),null)},u=e=>{l.current=d(t=>{t.timeRemaining()>0||t.didTimeout?(o(!0),e.disconnect()):l.current=d(()=>{o(!0),e.disconnect()},{timeout:i/2})},{timeout:i})},p=e=>{a(),c.current=window.setTimeout(()=>{var t;let n=e.takeRecords();(n.length===0||(t=n.at(-1)?.isIntersecting)!=null&&t)&&u(e)},n)},m=(e,t)=>{e.isIntersecting?p(t):a()},h=new IntersectionObserver(e=>{for(let t of e)m(t,h)},{rootMargin:r,threshold:0});return h.observe(e),()=>{c.current&&clearTimeout(c.current),l.current&&f(l.current),h.disconnect()}},[t,n,r,i,f,d]),{shouldRender:a,containerRef:s}}var _4=/\s/,wge=/^\s+$/,Tge=new Set([`code`,`pre`,`svg`,`math`,`annotation`]),Ege=e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`element`,Dge=e=>e.some(e=>Ege(e)&&Tge.has(e.tagName)),Oge=e=>{let t=[],n=``,r=!1;for(let i of e){let e=_4.test(i);e!==r&&n&&(t.push(n),n=``),n+=i,r=e}return n&&t.push(n),t},kge=e=>{let t=[],n=``;for(let r of e)_4.test(r)?n+=r:(n&&=(t.push(n),``),t.push(r));return n&&t.push(n),t},Age=(e,t,n,r,i,a)=>{let o=`--sd-animation:sd-${t};--sd-duration:${i?0:n}ms;--sd-easing:${r}`;return a&&(o+=`;--sd-delay:${a}ms`),{type:`element`,tagName:`span`,properties:{"data-sd-animate":!0,style:o},children:[{type:`text`,value:e}]}},jge=(e,t,n,r,i)=>{let a=t.at(-1);if(!(a&&`children`in a))return;if(Dge(t))return UK;let o=a,s=o.children.indexOf(e);if(s===-1)return;let c=e.value;if(!c.trim()){i.count+=c.length;return}let l=n.sep===`char`?kge(c):Oge(c),u=r.prevContentLength,d=l.map(e=>{let t=i.count;if(i.count+=e.length,wge.test(e))return{type:`text`,value:e};let r=u>0&&t<u,a=r?0:i.newIndex++*n.stagger;return Age(e,n.animation,n.duration,n.easing,r,a)});return o.children.splice(s,1,...d),s+d.length},Mge=0;function v4(e){let t={animation:e?.animation??`fadeIn`,duration:e?.duration??150,easing:e?.easing??`ease`,sep:e?.sep??`word`,stagger:e?.stagger??40},n={prevContentLength:0,lastRenderCharCount:0},r=Mge++,i=()=>e=>{let r={count:0,newIndex:0};WK(e,`text`,(e,i)=>jge(e,i,t,n,r)),n.lastRenderCharCount=r.count,n.prevContentLength=0};return Object.defineProperty(i,"name",{value:`rehypeAnimate$${r}`}),{name:`animate`,type:`animate`,rehypePlugin:i,setPrevContentLength(e){n.prevContentLength=e},getLastRenderCharCount(){let e=n.lastRenderCharCount;return n.lastRenderCharCount=0,e}}}v4();var y4=(0,B.createContext)(!1),Nge=()=>(0,B.useContext)(y4),b4=(...e)=>c(i(e)),Pge=(e,t)=>{if(!e||!t)return t;let n=`${e}:`;return t.split(/\s+/).filter(Boolean).map(t=>t.startsWith(n)?t:`${e}:${t}`).join(` `)},Fge=e=>e?(...t)=>Pge(e,c(i(t))):b4,x4=(e,t,n)=>{let r=typeof t==`string`&&n.startsWith(`text/csv`)?``:``,i=typeof t==`string`?new Blob([r+t],{type:n}):t,a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},S4=(0,B.createContext)(b4),C4=()=>(0,B.useContext)(S4),Ige=b4(`block`,`before:content-[counter(line)]`,`before:inline-block`,`before:[counter-increment:line]`,`before:w-6`,`before:mr-4`,`before:text-[13px]`,`before:text-right`,`before:text-muted-foreground/50`,`before:font-mono`,`before:select-none`),Lge=e=>{let t={};for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e>0){let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();r&&i&&(t[r]=i)}}return t},w4=(0,B.memo)(({children:e,result:t,language:n,className:r,startLine:i,lineNumbers:a=!0,...o})=>{let s=C4(),c=(0,B.useMemo)(()=>s(Ige),[s]),l=(0,B.useMemo)(()=>{let e={};return t.bg&&(e[`--sdm-bg`]=t.bg),t.fg&&(e[`--sdm-fg`]=t.fg),t.rootStyle&&Object.assign(e,Lge(t.rootStyle)),e},[t.bg,t.fg,t.rootStyle]);return(0,V.jsx)(`div`,{className:s(r,`overflow-x-auto rounded-md border border-border bg-background p-4 text-sm`),"data-language":n,"data-streamdown":`code-block-body`,...o,children:(0,V.jsx)(`pre`,{className:s(r,`bg-[var(--sdm-bg,inherit]`,`dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]`),style:l,children:(0,V.jsx)(`code`,{className:a?s(`[counter-increment:line_0] [counter-reset:line]`):void 0,style:a&&i&&i>1?{counterReset:`line ${i-1}`}:void 0,children:t.tokens.map((e,t)=>(0,V.jsx)(`span`,{className:a?c:void 0,children:e.length===0||e.length===1&&e[0].content===``?`
202
202
  `:e.map((e,t)=>{let n={},r=!!e.bgColor;if(e.color&&(n[`--sdm-c`]=e.color),e.bgColor&&(n[`--sdm-tbg`]=e.bgColor),e.htmlStyle)for(let[t,i]of Object.entries(e.htmlStyle))t===`color`?n[`--sdm-c`]=i:t===`background-color`?(n[`--sdm-tbg`]=i,r=!0):n[t]=i;return(0,V.jsx)(`span`,{className:s(`text-[var(--sdm-c,inherit)]`,`dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]`,r&&`bg-[var(--sdm-tbg)]`,r&&`dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]`),style:n,...e.htmlAttrs,children:e.content},t)})},t))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers),Rge=({className:e,language:t,style:n,isIncomplete:r,...i})=>(0,V.jsx)(`div`,{className:C4()(`my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,e),"data-incomplete":r||void 0,"data-language":t,"data-streamdown":`code-block`,style:{contentVisibility:`auto`,containIntrinsicSize:`auto 200px`,...n},...i}),T4=(0,B.createContext)({code:``}),E4=()=>(0,B.useContext)(T4),zge=({language:e})=>{let t=C4();return(0,V.jsx)(`div`,{className:t(`flex h-8 items-center text-muted-foreground text-xs`),"data-language":e,"data-streamdown":`code-block-header`,children:(0,V.jsx)(`span`,{className:t(`ml-1 font-mono lowercase`),children:e})})},Bge=e=>{let t=e.length;for(;t>0&&e[t-1]===`
203
- `;)t--;return e.slice(0,t)},Vge=(0,B.lazy)(()=>g4(()=>import(`./highlighted-body-OFNGDK62-Dj4OC_Nj.js`).then(e=>({default:e.HighlightedCodeBlockBody})),__vite__mapDeps([0,1]))),Hge=({code:e,language:t,className:n,children:r,isIncomplete:i=!1,startLine:a,lineNumbers:o,...s})=>{let c=C4(),l=(0,B.useMemo)(()=>Bge(e),[e]),u=(0,B.useMemo)(()=>({bg:`transparent`,fg:`inherit`,tokens:l.split(`
203
+ `;)t--;return e.slice(0,t)},Vge=(0,B.lazy)(()=>g4(()=>import(`./highlighted-body-OFNGDK62-xjw7PDBM.js`).then(e=>({default:e.HighlightedCodeBlockBody})),__vite__mapDeps([0,1]))),Hge=({code:e,language:t,className:n,children:r,isIncomplete:i=!1,startLine:a,lineNumbers:o,...s})=>{let c=C4(),l=(0,B.useMemo)(()=>Bge(e),[e]),u=(0,B.useMemo)(()=>({bg:`transparent`,fg:`inherit`,tokens:l.split(`
204
204
  `).map(e=>[{content:e,color:`inherit`,bgColor:`transparent`,htmlStyle:{},offset:0}])}),[l]);return(0,V.jsx)(T4.Provider,{value:{code:e},children:(0,V.jsxs)(Rge,{isIncomplete:i,language:t,children:[(0,V.jsx)(zge,{language:t}),r?(0,V.jsx)(`div`,{className:c(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,V.jsx)(`div`,{className:c(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`code-block-actions`,children:r})}):null,(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(w4,{className:n,language:t,lineNumbers:o,result:u,startLine:a,...s}),children:(0,V.jsx)(Vge,{className:n,code:l,language:t,lineNumbers:o,raw:u,startLine:a,...s})})]})})},D4={CheckIcon:e=>(0,V.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,V.jsx)(`path`,{clipRule:`evenodd`,d:`M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z`,fill:`currentColor`,fillRule:`evenodd`})}),CopyIcon:e=>(0,V.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,V.jsx)(`path`,{clipRule:`evenodd`,d:`M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),DownloadIcon:e=>(0,V.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,V.jsx)(`path`,{clipRule:`evenodd`,d:`M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),ExternalLinkIcon:e=>(0,V.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,V.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z`,fill:`currentColor`,fillRule:`evenodd`})}),Loader2Icon:e=>(0,V.jsxs)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:[(0,V.jsx)(`path`,{d:`M8 0V4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,V.jsx)(`path`,{d:`M8 16V12`,opacity:`0.5`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,V.jsx)(`path`,{d:`M3.29773 1.52783L5.64887 4.7639`,opacity:`0.9`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,V.jsx)(`path`,{d:`M12.7023 1.52783L10.3511 4.7639`,opacity:`0.1`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,V.jsx)(`path`,{d:`M12.7023 14.472L10.3511 11.236`,opacity:`0.4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,V.jsx)(`path`,{d:`M3.29773 14.472L5.64887 11.236`,opacity:`0.6`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,V.jsx)(`path`,{d:`M15.6085 5.52783L11.8043 6.7639`,opacity:`0.2`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,V.jsx)(`path`,{d:`M0.391602 10.472L4.19583 9.23598`,opacity:`0.7`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,V.jsx)(`path`,{d:`M15.6085 10.4722L11.8043 9.2361`,opacity:`0.3`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,V.jsx)(`path`,{d:`M0.391602 5.52783L4.19583 6.7639`,opacity:`0.8`,stroke:`currentColor`,strokeWidth:`1.5`})]}),Maximize2Icon:e=>(0,V.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,V.jsx)(`path`,{clipRule:`evenodd`,d:`M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z`,fill:`currentColor`,fillRule:`evenodd`})}),RotateCcwIcon:e=>(0,V.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,V.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z`,fill:`currentColor`,fillRule:`evenodd`})}),XIcon:e=>(0,V.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,V.jsx)(`path`,{clipRule:`evenodd`,d:`M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomInIcon:e=>(0,V.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,V.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomOutIcon:e=>(0,V.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,V.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})})},O4=(0,B.createContext)(D4),Uge=(e,t)=>{if(e===t)return!0;if(!(e&&t))return e===t;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length?n.every(n=>e[n]===t[n]):!1},k4=({icons:e,children:t})=>{let n=(0,B.useRef)(e),r=(0,B.useRef)(e?{...D4,...e}:D4);Uge(n.current,e)||(n.current=e,r.current=e?{...D4,...e}:D4);let i=r.current;return(0,V.jsx)(O4.Provider,{value:i,children:t})},A4=()=>(0,B.useContext)(O4),j4={copyCode:`Copy Code`,downloadFile:`Download file`,downloadDiagram:`Download diagram`,downloadDiagramAsSvg:`Download diagram as SVG`,downloadDiagramAsPng:`Download diagram as PNG`,downloadDiagramAsMmd:`Download diagram as MMD`,viewFullscreen:`View fullscreen`,exitFullscreen:`Exit fullscreen`,mermaidFormatSvg:`SVG`,mermaidFormatPng:`PNG`,mermaidFormatMmd:`MMD`,copyTable:`Copy table`,copyTableAsMarkdown:`Copy table as Markdown`,copyTableAsCsv:`Copy table as CSV`,copyTableAsTsv:`Copy table as TSV`,downloadTable:`Download table`,downloadTableAsCsv:`Download table as CSV`,downloadTableAsMarkdown:`Download table as Markdown`,tableFormatMarkdown:`Markdown`,tableFormatCsv:`CSV`,tableFormatTsv:`TSV`,imageNotAvailable:`Image not available`,downloadImage:`Download image`,openExternalLink:`Open external link?`,externalLinkWarning:`You're about to visit an external website.`,close:`Close`,copyLink:`Copy link`,copied:`Copied`,openLink:`Open link`},M4=(0,B.createContext)(j4),N4=()=>(0,B.useContext)(M4),P4=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,code:a,...o})=>{let s=C4(),[c,l]=(0,B.useState)(!1),u=(0,B.useRef)(0),{code:d}=E4(),{isAnimating:f}=(0,B.useContext)(U3),p=N4(),m=a??d,h=async()=>{var r;if(typeof window>`u`||!((r=navigator==null?void 0:navigator.clipboard)!=null&&r.writeText)){t?.(Error(`Clipboard API not available`));return}try{c||(await navigator.clipboard.writeText(m),l(!0),e?.(),u.current=window.setTimeout(()=>l(!1),n))}catch(e){t?.(e)}};(0,B.useEffect)(()=>()=>{window.clearTimeout(u.current)},[]);let g=A4(),_=c?g.CheckIcon:g.CopyIcon;return(0,V.jsx)(`button`,{className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-copy-button`,disabled:f,onClick:h,title:p.copyCode,type:`button`,...o,children:r??(0,V.jsx)(_,{size:14})})},F4={"1c":`1c`,"1c-query":`1cq`,abap:`abap`,"actionscript-3":`as`,ada:`ada`,adoc:`adoc`,"angular-html":`html`,"angular-ts":`ts`,apache:`conf`,apex:`cls`,apl:`apl`,applescript:`applescript`,ara:`ara`,asciidoc:`adoc`,asm:`asm`,astro:`astro`,awk:`awk`,ballerina:`bal`,bash:`sh`,bat:`bat`,batch:`bat`,be:`be`,beancount:`beancount`,berry:`berry`,bibtex:`bib`,bicep:`bicep`,blade:`blade.php`,bsl:`bsl`,c:`c`,"c#":`cs`,"c++":`cpp`,cadence:`cdc`,cairo:`cairo`,cdc:`cdc`,clarity:`clar`,clj:`clj`,clojure:`clj`,"closure-templates":`soy`,cmake:`cmake`,cmd:`cmd`,cobol:`cob`,codeowners:`CODEOWNERS`,codeql:`ql`,coffee:`coffee`,coffeescript:`coffee`,"common-lisp":`lisp`,console:`sh`,coq:`v`,cpp:`cpp`,cql:`cql`,crystal:`cr`,cs:`cs`,csharp:`cs`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cql`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,docker:`dockerfile`,dockerfile:`dockerfile`,dotenv:`env`,"dream-maker":`dm`,edge:`edge`,elisp:`el`,elixir:`ex`,elm:`elm`,"emacs-lisp":`el`,erb:`erb`,erl:`erl`,erlang:`erl`,f:`f`,"f#":`fs`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`f90`,f95:`f95`,fennel:`fnl`,fish:`fish`,fluent:`ftl`,for:`for`,"fortran-fixed-form":`f`,"fortran-free-form":`f90`,fs:`fs`,fsharp:`fs`,fsl:`fsl`,ftl:`ftl`,gdresource:`tres`,gdscript:`gd`,gdshader:`gdshader`,genie:`gs`,gherkin:`feature`,"git-commit":`gitcommit`,"git-rebase":`gitrebase`,gjs:`js`,gleam:`gleam`,"glimmer-js":`js`,"glimmer-ts":`ts`,glsl:`glsl`,gnuplot:`plt`,go:`go`,gql:`gql`,graphql:`graphql`,groovy:`groovy`,gts:`gts`,hack:`hack`,haml:`haml`,handlebars:`hbs`,haskell:`hs`,haxe:`hx`,hbs:`hbs`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,hs:`hs`,html:`html`,"html-derivative":`html`,http:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,jade:`jade`,java:`java`,javascript:`js`,jinja:`jinja`,jison:`jison`,jl:`jl`,js:`js`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,julia:`jl`,kotlin:`kt`,kql:`kql`,kt:`kt`,kts:`kts`,kusto:`kql`,latex:`tex`,lean:`lean`,lean4:`lean`,less:`less`,liquid:`liquid`,lisp:`lisp`,lit:`lit`,llvm:`ll`,log:`log`,logo:`logo`,lua:`lua`,luau:`luau`,make:`mak`,makefile:`mak`,markdown:`md`,marko:`marko`,matlab:`m`,md:`md`,mdc:`mdc`,mdx:`mdx`,mediawiki:`wiki`,mermaid:`mmd`,mips:`s`,mipsasm:`s`,mmd:`mmd`,mojo:`mojo`,move:`move`,nar:`nar`,narrat:`narrat`,nextflow:`nf`,nf:`nf`,nginx:`conf`,nim:`nim`,nix:`nix`,nu:`nu`,nushell:`nu`,objc:`m`,"objective-c":`m`,"objective-cpp":`mm`,ocaml:`ml`,pascal:`pas`,perl:`pl`,perl6:`p6`,php:`php`,plsql:`pls`,po:`po`,polar:`polar`,postcss:`pcss`,pot:`pot`,potx:`potx`,powerquery:`pq`,powershell:`ps1`,prisma:`prisma`,prolog:`pl`,properties:`properties`,proto:`proto`,protobuf:`proto`,ps:`ps`,ps1:`ps1`,pug:`pug`,puppet:`pp`,purescript:`purs`,py:`py`,python:`py`,ql:`ql`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,racket:`rkt`,raku:`raku`,razor:`cshtml`,rb:`rb`,reg:`reg`,regex:`regex`,regexp:`regexp`,rel:`rel`,riscv:`s`,rs:`rs`,rst:`rst`,ruby:`rb`,rust:`rs`,sas:`sas`,sass:`sass`,scala:`scala`,scheme:`scm`,scss:`scss`,sdbl:`sdbl`,sh:`sh`,shader:`shader`,shaderlab:`shader`,shell:`sh`,shellscript:`sh`,shellsession:`sh`,smalltalk:`st`,solidity:`sol`,soy:`soy`,sparql:`rq`,spl:`spl`,splunk:`spl`,sql:`sql`,"ssh-config":`config`,stata:`do`,styl:`styl`,stylus:`styl`,svelte:`svelte`,swift:`swift`,"system-verilog":`sv`,systemd:`service`,talon:`talon`,talonscript:`talon`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,terraform:`tf`,tex:`tex`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`ts`,"ts-tags":`ts`,tsp:`tsp`,tsv:`tsv`,tsx:`tsx`,turtle:`ttl`,twig:`twig`,typ:`typ`,typescript:`ts`,typespec:`tsp`,typst:`typ`,v:`v`,vala:`vala`,vb:`vb`,verilog:`v`,vhdl:`vhdl`,vim:`vim`,viml:`vim`,vimscript:`vim`,vue:`vue`,"vue-html":`html`,"vue-vine":`vine`,vy:`vy`,vyper:`vy`,wasm:`wasm`,wenyan:`wy`,wgsl:`wgsl`,wiki:`wiki`,wikitext:`wiki`,wit:`wit`,wl:`wl`,wolfram:`wl`,xml:`xml`,xsl:`xsl`,yaml:`yaml`,yml:`yml`,zenscript:`zs`,zig:`zig`,zsh:`zsh`,文言:`wy`},Wge=({onDownload:e,onError:t,language:n,children:r,className:i,code:a,...o})=>{let s=C4(),{code:c}=E4(),{isAnimating:l}=(0,B.useContext)(U3),u=N4(),d=A4(),f=a??c,p=`file.${n&&n in F4?F4[n]:`txt`}`;return(0,V.jsx)(`button`,{className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-download-button`,disabled:l,onClick:()=>{try{x4(p,f,`text/plain`),e?.()}catch(e){t?.(e)}},title:u.downloadFile,type:`button`,...o,children:r??(0,V.jsx)(d.DownloadIcon,{size:14})})},I4=()=>{let{Loader2Icon:e}=A4(),t=C4();return(0,V.jsxs)(`div`,{className:t(`w-full divide-y divide-border overflow-hidden rounded-xl border border-border`),children:[(0,V.jsx)(`div`,{className:t(`h-[46px] w-full bg-muted/80`)}),(0,V.jsx)(`div`,{className:t(`flex w-full items-center justify-center p-4`),children:(0,V.jsx)(e,{className:t(`size-4 animate-spin`)})})]})},Gge=/\.[^/.]+$/,Kge=({node:e,className:t,src:n,alt:r,onLoad:i,onError:a,...o})=>{let{DownloadIcon:s}=A4(),c=C4(),l=(0,B.useRef)(null),[u,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(!1),m=N4(),h=o.width!=null||o.height!=null,g=(u||h)&&!f,_=f&&!h;(0,B.useEffect)(()=>{let e=l.current;if(e!=null&&e.complete){let t=e.naturalWidth>0;d(t),p(!t)}},[]);let v=(0,B.useCallback)(e=>{d(!0),p(!1),i?.(e)},[i]),y=(0,B.useCallback)(e=>{d(!1),p(!0),a?.(e)},[a]),b=async()=>{if(n)try{let e=await(await fetch(n)).blob(),t=new URL(n,window.location.origin).pathname.split(`/`).pop()||``,i=t.split(`.`).pop(),a=t.includes(`.`)&&i!==void 0&&i.length<=4,o=``;if(a)o=t;else{let n=e.type,i=`png`;n.includes(`jpeg`)||n.includes(`jpg`)?i=`jpg`:n.includes(`png`)?i=`png`:n.includes(`svg`)?i=`svg`:n.includes(`gif`)?i=`gif`:n.includes(`webp`)&&(i=`webp`),o=`${(r||t||`image`).replace(Gge,``)}.${i}`}x4(o,e,e.type)}catch{window.open(n,`_blank`)}};return n?(0,V.jsxs)(`div`,{className:c(`group relative my-4 inline-block`),"data-streamdown":`image-wrapper`,children:[(0,V.jsx)(`img`,{alt:r,className:c(`max-w-full rounded-lg`,_&&`hidden`,t),"data-streamdown":`image`,onError:y,onLoad:v,ref:l,src:n,...o}),_&&(0,V.jsx)(`span`,{className:c(`text-muted-foreground text-xs italic`),"data-streamdown":`image-fallback`,children:m.imageNotAvailable}),(0,V.jsx)(`div`,{className:c(`pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block`)}),g&&(0,V.jsx)(`button`,{className:c(`absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background`,`opacity-0 group-hover:opacity-100`),onClick:b,title:m.downloadImage,type:`button`,children:(0,V.jsx)(s,{size:14})})]}):null},L4=0,R4=()=>{L4+=1,L4===1&&(document.body.style.overflow=`hidden`)},z4=()=>{L4=Math.max(0,L4-1),L4===0&&(document.body.style.overflow=``)},qge=({url:e,isOpen:t,onClose:n,onConfirm:r})=>{let{CheckIcon:i,CopyIcon:a,ExternalLinkIcon:o,XIcon:s}=A4(),c=C4(),[l,u]=(0,B.useState)(!1),d=N4(),f=(0,B.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),u(!0),setTimeout(()=>u(!1),2e3)}catch{}},[e]),p=(0,B.useCallback)(()=>{r(),n()},[r,n]);return(0,B.useEffect)(()=>{if(t){R4();let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),z4()}}},[t,n]),t?(0,V.jsx)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm`),"data-streamdown":`link-safety-modal`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&n()},role:`button`,tabIndex:0,children:(0,V.jsxs)(`div`,{className:c(`relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,V.jsx)(`button`,{className:c(`absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:n,title:d.close,type:`button`,children:(0,V.jsx)(s,{size:16})}),(0,V.jsxs)(`div`,{className:c(`flex flex-col gap-2`),children:[(0,V.jsxs)(`div`,{className:c(`flex items-center gap-2 font-semibold text-lg`),children:[(0,V.jsx)(o,{size:20}),(0,V.jsx)(`span`,{children:d.openExternalLink})]}),(0,V.jsx)(`p`,{className:c(`text-muted-foreground text-sm`),children:d.externalLinkWarning})]}),(0,V.jsx)(`div`,{className:c(`break-all rounded-md bg-muted p-3 font-mono text-sm`,e.length>100&&`max-h-32 overflow-y-auto`),children:e}),(0,V.jsxs)(`div`,{className:c(`flex gap-2`),children:[(0,V.jsx)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted`),onClick:f,type:`button`,children:l?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(i,{size:14}),(0,V.jsx)(`span`,{children:d.copied})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(a,{size:14}),(0,V.jsx)(`span`,{children:d.copyLink})]})}),(0,V.jsxs)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90`),onClick:p,type:`button`,children:[(0,V.jsx)(o,{size:14}),(0,V.jsx)(`span`,{children:d.openLink})]})]})]})}):null},B4=(0,B.createContext)(null),V4=()=>(0,B.useContext)(B4),Jge=()=>V4()?.code??null,H4=()=>V4()?.mermaid??null,Yge=e=>{var t;let n=V4();return n!=null&&n.renderers&&e&&(t=n.renderers.find(t=>Array.isArray(t.language)?t.language.includes(e):t.language===e))!=null?t:null},Xge=(e,t)=>new Promise((t,n)=>{let r=`data:image/svg+xml;base64,`+btoa(unescape(encodeURIComponent(e))),i=new Image;i.crossOrigin=`anonymous`,i.onload=()=>{let e=document.createElement(`canvas`),r=i.width*5,a=i.height*5;e.width=r,e.height=a;let o=e.getContext(`2d`);if(!o){n(Error(`Failed to create 2D canvas context for PNG export`));return}o.drawImage(i,0,0,r,a),e.toBlob(e=>{if(!e){n(Error(`Failed to create PNG blob`));return}t(e)},`image/png`)},i.onerror=()=>n(Error(`Failed to load SVG image`)),i.src=r}),Zge=({chart:e,children:t,className:n,onDownload:r,config:i,onError:a})=>{let o=C4(),[s,c]=(0,B.useState)(!1),l=(0,B.useRef)(null),{isAnimating:u}=(0,B.useContext)(U3),d=A4(),f=H4(),p=N4(),m=async t=>{try{if(t===`mmd`){x4(`diagram.mmd`,e,`text/plain`),c(!1),r?.(t);return}if(!f){a?.(Error(`Mermaid plugin not available`));return}let n=f.getMermaid(i),o=e.split(``).reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0),s=`mermaid-${Math.abs(o)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:l}=await n.render(s,e);if(!l){a?.(Error(`SVG not found. Please wait for the diagram to render.`));return}if(t===`svg`){x4(`diagram.svg`,l,`image/svg+xml`),c(!1),r?.(t);return}if(t===`png`){x4(`diagram.png`,await Xge(l),`image/png`),r?.(t),c(!1);return}}catch(e){a?.(e)}};return(0,B.useEffect)(()=>{let e=e=>{let t=e.composedPath();l.current&&!t.includes(l.current)&&c(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,V.jsxs)(`div`,{className:o(`relative`),ref:l,children:[(0,V.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,n),disabled:u,onClick:()=>c(!s),title:p.downloadDiagram,type:`button`,children:t??(0,V.jsx)(d.DownloadIcon,{size:14})}),s?(0,V.jsxs)(`div`,{className:o(`absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,V.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`svg`),title:p.downloadDiagramAsSvg,type:`button`,children:p.mermaidFormatSvg}),(0,V.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`png`),title:p.downloadDiagramAsPng,type:`button`,children:p.mermaidFormatPng}),(0,V.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`mmd`),title:p.downloadDiagramAsMmd,type:`button`,children:p.mermaidFormatMmd})]}):null]})},Qge=({chart:e,config:t,onFullscreen:n,onExit:r,className:i,...a})=>{let{Maximize2Icon:o,XIcon:s}=A4(),c=C4(),[l,u]=(0,B.useState)(!1),{isAnimating:d,controls:f}=(0,B.useContext)(U3),p=N4(),m=(()=>{if(typeof f==`boolean`)return f;let e=f.mermaid;return e===!1?!1:e===!0||e===void 0?!0:e.panZoom!==!1})(),h=()=>{u(!l)};return(0,B.useEffect)(()=>{if(l){R4();let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),z4()}}},[l]),(0,B.useEffect)(()=>{l?n?.():r&&r()},[l,n,r]),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{className:c(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),disabled:d,onClick:h,title:p.viewFullscreen,type:`button`,...a,children:(0,V.jsx)(o,{size:14})}),l?(0,Lg.createPortal)((0,V.jsxs)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm`),onClick:h,onKeyDown:e=>{e.key===`Escape`&&h()},role:`button`,tabIndex:0,children:[(0,V.jsx)(`button`,{className:c(`absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:h,title:p.exitFullscreen,type:`button`,children:(0,V.jsx)(s,{size:20})}),(0,V.jsx)(`div`,{className:c(`flex size-full items-center justify-center p-4`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:(0,V.jsx)(K3,{chart:e,className:c(`size-full [&_svg]:h-auto [&_svg]:w-auto`),config:t,fullscreen:!0,showControls:m})})]}),document.body):null]})},U4=e=>{let t=[],n=[],r=e.querySelectorAll(`thead th`);for(let e of r)t.push(e.textContent?.trim()||``);let i=e.querySelectorAll(`tbody tr`);for(let e of i){let t=[],r=e.querySelectorAll(`td`);for(let e of r)t.push(e.textContent?.trim()||``);n.push(t)}return{headers:t,rows:n}},W4=e=>{let{headers:t,rows:n}=e,r=e=>{let t=!1,n=!1;for(let r of e){if(r===`"`){t=!0,n=!0;break}(r===`,`||r===`
205
205
  `)&&(t=!0)}return t?n?`"${e.replace(/"/g,`""`)}"`:`"${e}"`:e},i=t.length>0?n.length+1:n.length,a=Array(i),o=0;t.length>0&&(a[o]=t.map(r).join(`,`),o+=1);for(let e of n)a[o]=e.map(r).join(`,`),o+=1;return a.join(`
206
206
  `)},$ge=e=>{let{headers:t,rows:n}=e,r=e=>{let t=!1;for(let n of e)if(n===` `||n===`
207
207
  `||n===`\r`){t=!0;break}if(!t)return e;let n=[];for(let t of e)t===` `?n.push(`\\t`):t===`
208
208
  `?n.push(`\\n`):t===`\r`?n.push(`\\r`):n.push(t);return n.join(``)},i=t.length>0?n.length+1:n.length,a=Array(i),o=0;t.length>0&&(a[o]=t.map(r).join(` `),o+=1);for(let e of n)a[o]=e.map(r).join(` `),o+=1;return a.join(`
209
209
  `)},G4=e=>{let t=!1;for(let n of e)if(n===`\\`||n===`|`){t=!0;break}if(!t)return e;let n=[];for(let t of e)t===`\\`?n.push(`\\\\`):t===`|`?n.push(`\\|`):n.push(t);return n.join(``)},K4=e=>{let{headers:t,rows:n}=e;if(t.length===0)return``;let r=Array(n.length+2),i=0;r[i]=`| ${t.map(e=>G4(e)).join(` | `)} |`,i+=1;let a=Array(t.length);for(let e=0;e<t.length;e+=1)a[e]=`---`;r[i]=`| ${a.join(` | `)} |`,i+=1;for(let e of n)if(e.length<t.length){let n=Array(t.length);for(let r=0;r<t.length;r+=1)n[r]=r<e.length?G4(e[r]):``;r[i]=`| ${n.join(` | `)} |`,i+=1}else r[i]=`| ${e.map(e=>G4(e)).join(` | `)} |`,i+=1;return r.join(`
210
- `)},q4=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let a=C4(),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(!1),u=(0,B.useRef)(null),d=(0,B.useRef)(0),{isAnimating:f}=(0,B.useContext)(U3),p=N4(),m=async e=>{var t;if(typeof window>`u`||!((t=navigator==null?void 0:navigator.clipboard)!=null&&t.write)){r?.(Error(`Clipboard API not available`));return}try{let t=(u.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let a=U4(t),o=({csv:W4,tsv:$ge,md:K4}[e]||K4)(a),c=new ClipboardItem({"text/plain":new Blob([o],{type:`text/plain`}),"text/html":new Blob([t.outerHTML],{type:`text/html`})});await navigator.clipboard.write([c]),l(!0),s(!1),n?.(e),d.current=window.setTimeout(()=>l(!1),i)}catch(e){r?.(e)}};(0,B.useEffect)(()=>{let e=e=>{let t=e.composedPath();u.current&&!t.includes(u.current)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e),window.clearTimeout(d.current)}},[]);let h=A4(),g=c?h.CheckIcon:h.CopyIcon;return(0,V.jsxs)(`div`,{className:a(`relative`),ref:u,children:[(0,V.jsx)(`button`,{className:a(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:f,onClick:()=>s(!o),title:p.copyTable,type:`button`,children:e??(0,V.jsx)(g,{height:14,width:14})}),o?(0,V.jsxs)(`div`,{className:a(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,V.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`md`),title:p.copyTableAsMarkdown,type:`button`,children:p.tableFormatMarkdown}),(0,V.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`csv`),title:p.copyTableAsCsv,type:`button`,children:p.tableFormatCsv}),(0,V.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`tsv`),title:p.copyTableAsTsv,type:`button`,children:p.tableFormatTsv})]}):null]})},J4=({children:e,className:t,onDownload:n,onError:r})=>{let i=C4(),[a,o]=(0,B.useState)(!1),s=(0,B.useRef)(null),{isAnimating:c}=(0,B.useContext)(U3),l=N4(),u=A4(),d=e=>{try{let t=(s.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let i=U4(t),a=e===`csv`?W4(i):K4(i);x4(`table.${e===`csv`?`csv`:`md`}`,a,e===`csv`?`text/csv`:`text/markdown`),o(!1),n?.(e)}catch(e){r?.(e)}};return(0,B.useEffect)(()=>{let e=e=>{let t=e.composedPath();s.current&&!t.includes(s.current)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,V.jsxs)(`div`,{className:i(`relative`),ref:s,children:[(0,V.jsx)(`button`,{className:i(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:c,onClick:()=>o(!a),title:l.downloadTable,type:`button`,children:e??(0,V.jsx)(u.DownloadIcon,{size:14})}),a?(0,V.jsxs)(`div`,{className:i(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,V.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`csv`),title:l.downloadTableAsCsv,type:`button`,children:l.tableFormatCsv}),(0,V.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`markdown`),title:l.downloadTableAsMarkdown,type:`button`,children:l.tableFormatMarkdown})]}):null]})},e_e=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=A4(),o=C4(),[s,c]=(0,B.useState)(!1),{isAnimating:l}=(0,B.useContext)(U3),u=N4(),d=()=>{c(!0)},f=()=>{c(!1)};return(0,B.useEffect)(()=>{if(s){R4();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),z4()}}},[s]),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:l,onClick:d,title:u.viewFullscreen,type:`button`,children:(0,V.jsx)(i,{size:14})}),s?(0,Lg.createPortal)((0,V.jsx)(`div`,{"aria-label":u.viewFullscreen,"aria-modal":`true`,className:o(`fixed inset-0 z-50 flex flex-col bg-background`),"data-streamdown":`table-fullscreen`,onClick:f,onKeyDown:e=>{e.key===`Escape`&&f()},role:`dialog`,children:(0,V.jsxs)(`div`,{className:o(`flex h-full flex-col`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,V.jsxs)(`div`,{className:o(`flex items-center justify-end gap-1 p-4`),children:[n?(0,V.jsx)(q4,{}):null,r?(0,V.jsx)(J4,{}):null,(0,V.jsx)(`button`,{className:o(`rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:f,title:u.exitFullscreen,type:`button`,children:(0,V.jsx)(a,{size:20})})]}),(0,V.jsx)(`div`,{className:o(`flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10`),children:(0,V.jsx)(`table`,{className:o(`w-full border-collapse border border-border`),"data-streamdown":`table`,children:e})})]})}),document.body):null]})},t_e=({children:e,className:t,showControls:n,showCopy:r=!0,showDownload:i=!0,showFullscreen:a=!0,...o})=>{let s=C4(),c=n&&r,l=n&&i,u=n&&a,d=c||l||u;return(0,V.jsxs)(`div`,{className:s(`my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2`),"data-streamdown":`table-wrapper`,children:[d?(0,V.jsxs)(`div`,{className:s(`flex items-center justify-end gap-1`),children:[c?(0,V.jsx)(q4,{}):null,l?(0,V.jsx)(J4,{}):null,u?(0,V.jsx)(e_e,{showCopy:c,showDownload:l,children:e}):null]}):null,(0,V.jsx)(`div`,{className:s(`border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background`),children:(0,V.jsx)(`table`,{className:s(`w-full divide-y divide-border`,t),"data-streamdown":`table`,...o,children:e})})]})},n_e=/startLine=(\d+)/,r_e=/\bnoLineNumbers\b/,i_e=(0,B.lazy)(()=>g4(()=>import(`./mermaid-GHXKKRXX-DURCfVhS.js`).then(e=>({default:e.Mermaid})),[])),a_e=/language-([^\s]+)/;function Y4(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&t!=null&&t.position))return!1;let n=e.position.start,r=t.position.start,i=e.position.end,a=t.position.end;return n?.line===r?.line&&n?.column===r?.column&&i?.line===a?.line&&i?.column===a?.column}function X4(e,t){return e.className===t.className&&Y4(e.node,t.node)}var Z4=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,Q4=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.table;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},$4=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.code;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},e3=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},t3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`ol`,{className:C4()(`list-inside list-decimal whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`ordered-list`,...r,children:e}),(e,t)=>X4(e,t));t3.displayName=`MarkdownOl`;var n3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`li`,{className:C4()(`py-1 [&>p]:inline`,t),"data-streamdown":`list-item`,...r,children:e}),(e,t)=>e.className===t.className&&Y4(e.node,t.node));n3.displayName=`MarkdownLi`;var r3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`ul`,{className:C4()(`list-inside list-disc whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`unordered-list`,...r,children:e}),(e,t)=>X4(e,t));r3.displayName=`MarkdownUl`;var i3=(0,B.memo)(({className:e,node:t,...n})=>(0,V.jsx)(`hr`,{className:C4()(`my-6 border-border`,e),"data-streamdown":`horizontal-rule`,...n}),(e,t)=>X4(e,t));i3.displayName=`MarkdownHr`;var a3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`span`,{className:C4()(`font-semibold`,t),"data-streamdown":`strong`,...r,children:e}),(e,t)=>X4(e,t));a3.displayName=`MarkdownStrong`;var o3=(0,B.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=C4(),{linkSafety:o}=(0,B.useContext)(U3),[s,c]=(0,B.useState)(!1),l=n===`streamdown:incomplete-link`,u=(0,B.useCallback)(async e=>{if(!(!(o!=null&&o.enabled&&n)||l)){if(e.preventDefault(),o.onLinkCheck&&await o.onLinkCheck(n)){window.open(n,`_blank`,`noreferrer`);return}c(!0)}},[o,n,l]),d=(0,B.useCallback)(()=>{n&&window.open(n,`_blank`,`noreferrer`)},[n]),f=(0,B.useCallback)(()=>{c(!1)},[]),p={url:n??``,isOpen:s,onClose:f,onConfirm:d};return o!=null&&o.enabled&&n?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{className:a(`wrap-anywhere appearance-none text-left font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,onClick:u,type:`button`,children:e}),o.renderModal?o.renderModal(p):(0,V.jsx)(qge,{...p})]}):(0,V.jsx)(`a`,{className:a(`wrap-anywhere font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,href:n,rel:`noreferrer`,target:`_blank`,...i,children:e})},(e,t)=>X4(e,t)&&e.href===t.href);o3.displayName=`MarkdownA`;var s3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`h1`,{className:C4()(`mt-6 mb-2 font-semibold text-3xl`,t),"data-streamdown":`heading-1`,...r,children:e}),(e,t)=>X4(e,t));s3.displayName=`MarkdownH1`;var c3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`h2`,{className:C4()(`mt-6 mb-2 font-semibold text-2xl`,t),"data-streamdown":`heading-2`,...r,children:e}),(e,t)=>X4(e,t));c3.displayName=`MarkdownH2`;var l3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`h3`,{className:C4()(`mt-6 mb-2 font-semibold text-xl`,t),"data-streamdown":`heading-3`,...r,children:e}),(e,t)=>X4(e,t));l3.displayName=`MarkdownH3`;var u3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`h4`,{className:C4()(`mt-6 mb-2 font-semibold text-lg`,t),"data-streamdown":`heading-4`,...r,children:e}),(e,t)=>X4(e,t));u3.displayName=`MarkdownH4`;var d3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`h5`,{className:C4()(`mt-6 mb-2 font-semibold text-base`,t),"data-streamdown":`heading-5`,...r,children:e}),(e,t)=>X4(e,t));d3.displayName=`MarkdownH5`;var f3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`h6`,{className:C4()(`mt-6 mb-2 font-semibold text-sm`,t),"data-streamdown":`heading-6`,...r,children:e}),(e,t)=>X4(e,t));f3.displayName=`MarkdownH6`;var p3=(0,B.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i}=(0,B.useContext)(U3);return(0,V.jsx)(t_e,{className:t,showControls:Z4(i,`table`),showCopy:Q4(i,`copy`),showDownload:Q4(i,`download`),showFullscreen:Q4(i,`fullscreen`),...r,children:e})},(e,t)=>X4(e,t));p3.displayName=`MarkdownTable`;var m3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`thead`,{className:C4()(`bg-muted/80`,t),"data-streamdown":`table-header`,...r,children:e}),(e,t)=>X4(e,t));m3.displayName=`MarkdownThead`;var h3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`tbody`,{className:C4()(`divide-y divide-border`,t),"data-streamdown":`table-body`,...r,children:e}),(e,t)=>X4(e,t));h3.displayName=`MarkdownTbody`;var g3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`tr`,{className:C4()(`border-border`,t),"data-streamdown":`table-row`,...r,children:e}),(e,t)=>X4(e,t));g3.displayName=`MarkdownTr`;var _3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`th`,{className:C4()(`whitespace-nowrap px-4 py-2 text-left font-semibold text-sm`,t),"data-streamdown":`table-header-cell`,...r,children:e}),(e,t)=>X4(e,t));_3.displayName=`MarkdownTh`;var v3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`td`,{className:C4()(`px-4 py-2 text-sm`,t),"data-streamdown":`table-cell`,...r,children:e}),(e,t)=>X4(e,t));v3.displayName=`MarkdownTd`;var y3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`blockquote`,{className:C4()(`my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic`,t),"data-streamdown":`blockquote`,...r,children:e}),(e,t)=>X4(e,t));y3.displayName=`MarkdownBlockquote`;var b3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`sup`,{className:C4()(`text-sm`,t),"data-streamdown":`superscript`,...r,children:e}),(e,t)=>X4(e,t));b3.displayName=`MarkdownSup`;var x3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`sub`,{className:C4()(`text-sm`,t),"data-streamdown":`subscript`,...r,children:e}),(e,t)=>X4(e,t));x3.displayName=`MarkdownSub`;var S3=(0,B.memo)(({children:e,className:t,node:n,...r})=>{if(`data-footnotes`in r){let n=e=>{if(!(0,B.isValidElement)(e))return!1;let t=Array.isArray(e.props.children)?e.props.children:[e.props.children],n=!1,r=!1;for(let e of t)if(e){if(typeof e==`string`)e.trim()!==``&&(n=!0);else if((0,B.isValidElement)(e))if(e.props?.[`data-footnote-backref`]!==void 0)r=!0;else{let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t){if(typeof e==`string`&&e.trim()!==``){n=!0;break}if((0,B.isValidElement)(e)&&e.props?.[`data-footnote-backref`]===void 0){n=!0;break}}}}return r&&!n},i=Array.isArray(e)?e.map(e=>{if(!(0,B.isValidElement)(e))return e;if(e.type===t3){let t=(Array.isArray(e.props.children)?e.props.children:[e.props.children]).filter(e=>!n(e));return t.length===0?null:{...e,props:{...e.props,children:t}}}return e}):e;return(Array.isArray(i)?i.some(e=>e!==null):i!==null)?(0,V.jsx)(`section`,{className:t,...r,children:i}):null}return(0,V.jsx)(`section`,{className:t,...r,children:e})},(e,t)=>X4(e,t));S3.displayName=`MarkdownSection`;var C3=(0,B.memo)(({node:e,className:t,children:n,...r})=>{let i=C4(),a=!(`data-block`in r),{mermaid:o,controls:s,lineNumbers:c}=(0,B.useContext)(U3),l=H4(),u=Nge(),d=(t?.match(a_e))?.at(1)??``,f=Yge(d);if(a)return(0,V.jsx)(`code`,{className:i(`rounded bg-muted px-1.5 py-0.5 font-mono text-sm`,t),"data-streamdown":`inline-code`,...r,children:n});let p=e?.properties?.metastring,m=p?.match(n_e),h=m?Number.parseInt(m[1],10):void 0,g=h!==void 0&&h>=1?h:void 0,_=!(p&&r_e.test(p))&&c!==!1,v=``;if((0,B.isValidElement)(n)&&n.props&&typeof n.props==`object`&&`children`in n.props&&typeof n.props.children==`string`?v=n.props.children:typeof n==`string`&&(v=n),f){let e=f.component;return(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(I4,{}),children:(0,V.jsx)(e,{code:v,isIncomplete:u,language:d,meta:p})})}if(d===`mermaid`&&l){let e=Z4(s,`mermaid`),n=e3(s,`download`),r=e3(s,`copy`),a=e3(s,`fullscreen`),c=e3(s,`panZoom`),l=e&&(n||r||a);return(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(I4,{}),children:(0,V.jsxs)(`div`,{className:i(`group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,t),"data-streamdown":`mermaid-block`,children:[(0,V.jsx)(`div`,{className:i(`flex h-8 items-center text-muted-foreground text-xs`),children:(0,V.jsx)(`span`,{className:i(`ml-1 font-mono lowercase`),children:`mermaid`})}),l?(0,V.jsx)(`div`,{className:i(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,V.jsxs)(`div`,{className:i(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`mermaid-block-actions`,children:[n?(0,V.jsx)(Zge,{chart:v,config:o?.config}):null,r?(0,V.jsx)(P4,{code:v}):null,a?(0,V.jsx)(Qge,{chart:v,config:o?.config}):null]})}):null,(0,V.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,V.jsx)(i_e,{chart:v,config:o?.config,showControls:c})})]})})}let y=Z4(s,`code`),b=$4(s,`download`),x=$4(s,`copy`);return(0,V.jsx)(Hge,{className:t,code:v,isIncomplete:u,language:d,lineNumbers:_,startLine:g,children:y?(0,V.jsxs)(V.Fragment,{children:[b?(0,V.jsx)(Wge,{code:v,language:d}):null,x?(0,V.jsx)(P4,{}):null]}):null})},(e,t)=>e.className===t.className&&Y4(e.node,t.node));C3.displayName=`MarkdownCode`;var w3=(0,B.memo)(Kge,(e,t)=>e.className===t.className&&Y4(e.node,t.node));w3.displayName=`MarkdownImg`;var T3=(0,B.memo)(({children:e,node:t,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(e=>e!=null&&e!==``);if(r.length===1&&(0,B.isValidElement)(r[0])){let t=r[0].props.node?.tagName;if(t===`img`||t===`code`&&`data-block`in r[0].props)return(0,V.jsx)(V.Fragment,{children:e})}return(0,V.jsx)(`p`,{...n,children:e})},(e,t)=>X4(e,t));T3.displayName=`MarkdownParagraph`;var o_e={ol:t3,li:n3,ul:r3,hr:i3,strong:a3,a:o3,h1:s3,h2:c3,h3:l3,h4:u3,h5:d3,h6:f3,table:p3,thead:m3,tbody:h3,tr:g3,th:_3,td:v3,blockquote:y3,code:C3,img:w3,pre:({children:e})=>(0,B.isValidElement)(e)?(0,B.cloneElement)(e,{"data-block":`true`}):e,sup:b3,sub:x3,p:T3,section:S3},s_e=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,c_e=/\p{L}/u;function E3(e){let t=e.replace(/^#{1,6}\s+/gm,``).replace(/(\*{1,3}|_{1,3})/g,``).replace(/`[^`]*`/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/^[\s>*\-+\d.]+/gm,``);for(let e of t){if(s_e.test(e))return`rtl`;if(c_e.test(e))return`ltr`}return`ltr`}var l_e=/^[ \t]{0,3}(`{3,}|~{3,})/,u_e=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,D3=e=>{let t=e.split(`
210
+ `)},q4=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let a=C4(),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(!1),u=(0,B.useRef)(null),d=(0,B.useRef)(0),{isAnimating:f}=(0,B.useContext)(U3),p=N4(),m=async e=>{var t;if(typeof window>`u`||!((t=navigator==null?void 0:navigator.clipboard)!=null&&t.write)){r?.(Error(`Clipboard API not available`));return}try{let t=(u.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let a=U4(t),o=({csv:W4,tsv:$ge,md:K4}[e]||K4)(a),c=new ClipboardItem({"text/plain":new Blob([o],{type:`text/plain`}),"text/html":new Blob([t.outerHTML],{type:`text/html`})});await navigator.clipboard.write([c]),l(!0),s(!1),n?.(e),d.current=window.setTimeout(()=>l(!1),i)}catch(e){r?.(e)}};(0,B.useEffect)(()=>{let e=e=>{let t=e.composedPath();u.current&&!t.includes(u.current)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e),window.clearTimeout(d.current)}},[]);let h=A4(),g=c?h.CheckIcon:h.CopyIcon;return(0,V.jsxs)(`div`,{className:a(`relative`),ref:u,children:[(0,V.jsx)(`button`,{className:a(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:f,onClick:()=>s(!o),title:p.copyTable,type:`button`,children:e??(0,V.jsx)(g,{height:14,width:14})}),o?(0,V.jsxs)(`div`,{className:a(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,V.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`md`),title:p.copyTableAsMarkdown,type:`button`,children:p.tableFormatMarkdown}),(0,V.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`csv`),title:p.copyTableAsCsv,type:`button`,children:p.tableFormatCsv}),(0,V.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`tsv`),title:p.copyTableAsTsv,type:`button`,children:p.tableFormatTsv})]}):null]})},J4=({children:e,className:t,onDownload:n,onError:r})=>{let i=C4(),[a,o]=(0,B.useState)(!1),s=(0,B.useRef)(null),{isAnimating:c}=(0,B.useContext)(U3),l=N4(),u=A4(),d=e=>{try{let t=(s.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let i=U4(t),a=e===`csv`?W4(i):K4(i);x4(`table.${e===`csv`?`csv`:`md`}`,a,e===`csv`?`text/csv`:`text/markdown`),o(!1),n?.(e)}catch(e){r?.(e)}};return(0,B.useEffect)(()=>{let e=e=>{let t=e.composedPath();s.current&&!t.includes(s.current)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,V.jsxs)(`div`,{className:i(`relative`),ref:s,children:[(0,V.jsx)(`button`,{className:i(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:c,onClick:()=>o(!a),title:l.downloadTable,type:`button`,children:e??(0,V.jsx)(u.DownloadIcon,{size:14})}),a?(0,V.jsxs)(`div`,{className:i(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,V.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`csv`),title:l.downloadTableAsCsv,type:`button`,children:l.tableFormatCsv}),(0,V.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`markdown`),title:l.downloadTableAsMarkdown,type:`button`,children:l.tableFormatMarkdown})]}):null]})},e_e=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=A4(),o=C4(),[s,c]=(0,B.useState)(!1),{isAnimating:l}=(0,B.useContext)(U3),u=N4(),d=()=>{c(!0)},f=()=>{c(!1)};return(0,B.useEffect)(()=>{if(s){R4();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),z4()}}},[s]),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:l,onClick:d,title:u.viewFullscreen,type:`button`,children:(0,V.jsx)(i,{size:14})}),s?(0,Lg.createPortal)((0,V.jsx)(`div`,{"aria-label":u.viewFullscreen,"aria-modal":`true`,className:o(`fixed inset-0 z-50 flex flex-col bg-background`),"data-streamdown":`table-fullscreen`,onClick:f,onKeyDown:e=>{e.key===`Escape`&&f()},role:`dialog`,children:(0,V.jsxs)(`div`,{className:o(`flex h-full flex-col`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,V.jsxs)(`div`,{className:o(`flex items-center justify-end gap-1 p-4`),children:[n?(0,V.jsx)(q4,{}):null,r?(0,V.jsx)(J4,{}):null,(0,V.jsx)(`button`,{className:o(`rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:f,title:u.exitFullscreen,type:`button`,children:(0,V.jsx)(a,{size:20})})]}),(0,V.jsx)(`div`,{className:o(`flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10`),children:(0,V.jsx)(`table`,{className:o(`w-full border-collapse border border-border`),"data-streamdown":`table`,children:e})})]})}),document.body):null]})},t_e=({children:e,className:t,showControls:n,showCopy:r=!0,showDownload:i=!0,showFullscreen:a=!0,...o})=>{let s=C4(),c=n&&r,l=n&&i,u=n&&a,d=c||l||u;return(0,V.jsxs)(`div`,{className:s(`my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2`),"data-streamdown":`table-wrapper`,children:[d?(0,V.jsxs)(`div`,{className:s(`flex items-center justify-end gap-1`),children:[c?(0,V.jsx)(q4,{}):null,l?(0,V.jsx)(J4,{}):null,u?(0,V.jsx)(e_e,{showCopy:c,showDownload:l,children:e}):null]}):null,(0,V.jsx)(`div`,{className:s(`border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background`),children:(0,V.jsx)(`table`,{className:s(`w-full divide-y divide-border`,t),"data-streamdown":`table`,...o,children:e})})]})},n_e=/startLine=(\d+)/,r_e=/\bnoLineNumbers\b/,i_e=(0,B.lazy)(()=>g4(()=>import(`./mermaid-GHXKKRXX-DxPFrHWq.js`).then(e=>({default:e.Mermaid})),[])),a_e=/language-([^\s]+)/;function Y4(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&t!=null&&t.position))return!1;let n=e.position.start,r=t.position.start,i=e.position.end,a=t.position.end;return n?.line===r?.line&&n?.column===r?.column&&i?.line===a?.line&&i?.column===a?.column}function X4(e,t){return e.className===t.className&&Y4(e.node,t.node)}var Z4=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,Q4=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.table;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},$4=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.code;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},e3=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},t3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`ol`,{className:C4()(`list-inside list-decimal whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`ordered-list`,...r,children:e}),(e,t)=>X4(e,t));t3.displayName=`MarkdownOl`;var n3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`li`,{className:C4()(`py-1 [&>p]:inline`,t),"data-streamdown":`list-item`,...r,children:e}),(e,t)=>e.className===t.className&&Y4(e.node,t.node));n3.displayName=`MarkdownLi`;var r3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`ul`,{className:C4()(`list-inside list-disc whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`unordered-list`,...r,children:e}),(e,t)=>X4(e,t));r3.displayName=`MarkdownUl`;var i3=(0,B.memo)(({className:e,node:t,...n})=>(0,V.jsx)(`hr`,{className:C4()(`my-6 border-border`,e),"data-streamdown":`horizontal-rule`,...n}),(e,t)=>X4(e,t));i3.displayName=`MarkdownHr`;var a3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`span`,{className:C4()(`font-semibold`,t),"data-streamdown":`strong`,...r,children:e}),(e,t)=>X4(e,t));a3.displayName=`MarkdownStrong`;var o3=(0,B.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=C4(),{linkSafety:o}=(0,B.useContext)(U3),[s,c]=(0,B.useState)(!1),l=n===`streamdown:incomplete-link`,u=(0,B.useCallback)(async e=>{if(!(!(o!=null&&o.enabled&&n)||l)){if(e.preventDefault(),o.onLinkCheck&&await o.onLinkCheck(n)){window.open(n,`_blank`,`noreferrer`);return}c(!0)}},[o,n,l]),d=(0,B.useCallback)(()=>{n&&window.open(n,`_blank`,`noreferrer`)},[n]),f=(0,B.useCallback)(()=>{c(!1)},[]),p={url:n??``,isOpen:s,onClose:f,onConfirm:d};return o!=null&&o.enabled&&n?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{className:a(`wrap-anywhere appearance-none text-left font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,onClick:u,type:`button`,children:e}),o.renderModal?o.renderModal(p):(0,V.jsx)(qge,{...p})]}):(0,V.jsx)(`a`,{className:a(`wrap-anywhere font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,href:n,rel:`noreferrer`,target:`_blank`,...i,children:e})},(e,t)=>X4(e,t)&&e.href===t.href);o3.displayName=`MarkdownA`;var s3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`h1`,{className:C4()(`mt-6 mb-2 font-semibold text-3xl`,t),"data-streamdown":`heading-1`,...r,children:e}),(e,t)=>X4(e,t));s3.displayName=`MarkdownH1`;var c3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`h2`,{className:C4()(`mt-6 mb-2 font-semibold text-2xl`,t),"data-streamdown":`heading-2`,...r,children:e}),(e,t)=>X4(e,t));c3.displayName=`MarkdownH2`;var l3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`h3`,{className:C4()(`mt-6 mb-2 font-semibold text-xl`,t),"data-streamdown":`heading-3`,...r,children:e}),(e,t)=>X4(e,t));l3.displayName=`MarkdownH3`;var u3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`h4`,{className:C4()(`mt-6 mb-2 font-semibold text-lg`,t),"data-streamdown":`heading-4`,...r,children:e}),(e,t)=>X4(e,t));u3.displayName=`MarkdownH4`;var d3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`h5`,{className:C4()(`mt-6 mb-2 font-semibold text-base`,t),"data-streamdown":`heading-5`,...r,children:e}),(e,t)=>X4(e,t));d3.displayName=`MarkdownH5`;var f3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`h6`,{className:C4()(`mt-6 mb-2 font-semibold text-sm`,t),"data-streamdown":`heading-6`,...r,children:e}),(e,t)=>X4(e,t));f3.displayName=`MarkdownH6`;var p3=(0,B.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i}=(0,B.useContext)(U3);return(0,V.jsx)(t_e,{className:t,showControls:Z4(i,`table`),showCopy:Q4(i,`copy`),showDownload:Q4(i,`download`),showFullscreen:Q4(i,`fullscreen`),...r,children:e})},(e,t)=>X4(e,t));p3.displayName=`MarkdownTable`;var m3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`thead`,{className:C4()(`bg-muted/80`,t),"data-streamdown":`table-header`,...r,children:e}),(e,t)=>X4(e,t));m3.displayName=`MarkdownThead`;var h3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`tbody`,{className:C4()(`divide-y divide-border`,t),"data-streamdown":`table-body`,...r,children:e}),(e,t)=>X4(e,t));h3.displayName=`MarkdownTbody`;var g3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`tr`,{className:C4()(`border-border`,t),"data-streamdown":`table-row`,...r,children:e}),(e,t)=>X4(e,t));g3.displayName=`MarkdownTr`;var _3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`th`,{className:C4()(`whitespace-nowrap px-4 py-2 text-left font-semibold text-sm`,t),"data-streamdown":`table-header-cell`,...r,children:e}),(e,t)=>X4(e,t));_3.displayName=`MarkdownTh`;var v3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`td`,{className:C4()(`px-4 py-2 text-sm`,t),"data-streamdown":`table-cell`,...r,children:e}),(e,t)=>X4(e,t));v3.displayName=`MarkdownTd`;var y3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`blockquote`,{className:C4()(`my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic`,t),"data-streamdown":`blockquote`,...r,children:e}),(e,t)=>X4(e,t));y3.displayName=`MarkdownBlockquote`;var b3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`sup`,{className:C4()(`text-sm`,t),"data-streamdown":`superscript`,...r,children:e}),(e,t)=>X4(e,t));b3.displayName=`MarkdownSup`;var x3=(0,B.memo)(({children:e,className:t,node:n,...r})=>(0,V.jsx)(`sub`,{className:C4()(`text-sm`,t),"data-streamdown":`subscript`,...r,children:e}),(e,t)=>X4(e,t));x3.displayName=`MarkdownSub`;var S3=(0,B.memo)(({children:e,className:t,node:n,...r})=>{if(`data-footnotes`in r){let n=e=>{if(!(0,B.isValidElement)(e))return!1;let t=Array.isArray(e.props.children)?e.props.children:[e.props.children],n=!1,r=!1;for(let e of t)if(e){if(typeof e==`string`)e.trim()!==``&&(n=!0);else if((0,B.isValidElement)(e))if(e.props?.[`data-footnote-backref`]!==void 0)r=!0;else{let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t){if(typeof e==`string`&&e.trim()!==``){n=!0;break}if((0,B.isValidElement)(e)&&e.props?.[`data-footnote-backref`]===void 0){n=!0;break}}}}return r&&!n},i=Array.isArray(e)?e.map(e=>{if(!(0,B.isValidElement)(e))return e;if(e.type===t3){let t=(Array.isArray(e.props.children)?e.props.children:[e.props.children]).filter(e=>!n(e));return t.length===0?null:{...e,props:{...e.props,children:t}}}return e}):e;return(Array.isArray(i)?i.some(e=>e!==null):i!==null)?(0,V.jsx)(`section`,{className:t,...r,children:i}):null}return(0,V.jsx)(`section`,{className:t,...r,children:e})},(e,t)=>X4(e,t));S3.displayName=`MarkdownSection`;var C3=(0,B.memo)(({node:e,className:t,children:n,...r})=>{let i=C4(),a=!(`data-block`in r),{mermaid:o,controls:s,lineNumbers:c}=(0,B.useContext)(U3),l=H4(),u=Nge(),d=(t?.match(a_e))?.at(1)??``,f=Yge(d);if(a)return(0,V.jsx)(`code`,{className:i(`rounded bg-muted px-1.5 py-0.5 font-mono text-sm`,t),"data-streamdown":`inline-code`,...r,children:n});let p=e?.properties?.metastring,m=p?.match(n_e),h=m?Number.parseInt(m[1],10):void 0,g=h!==void 0&&h>=1?h:void 0,_=!(p&&r_e.test(p))&&c!==!1,v=``;if((0,B.isValidElement)(n)&&n.props&&typeof n.props==`object`&&`children`in n.props&&typeof n.props.children==`string`?v=n.props.children:typeof n==`string`&&(v=n),f){let e=f.component;return(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(I4,{}),children:(0,V.jsx)(e,{code:v,isIncomplete:u,language:d,meta:p})})}if(d===`mermaid`&&l){let e=Z4(s,`mermaid`),n=e3(s,`download`),r=e3(s,`copy`),a=e3(s,`fullscreen`),c=e3(s,`panZoom`),l=e&&(n||r||a);return(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(I4,{}),children:(0,V.jsxs)(`div`,{className:i(`group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,t),"data-streamdown":`mermaid-block`,children:[(0,V.jsx)(`div`,{className:i(`flex h-8 items-center text-muted-foreground text-xs`),children:(0,V.jsx)(`span`,{className:i(`ml-1 font-mono lowercase`),children:`mermaid`})}),l?(0,V.jsx)(`div`,{className:i(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,V.jsxs)(`div`,{className:i(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`mermaid-block-actions`,children:[n?(0,V.jsx)(Zge,{chart:v,config:o?.config}):null,r?(0,V.jsx)(P4,{code:v}):null,a?(0,V.jsx)(Qge,{chart:v,config:o?.config}):null]})}):null,(0,V.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,V.jsx)(i_e,{chart:v,config:o?.config,showControls:c})})]})})}let y=Z4(s,`code`),b=$4(s,`download`),x=$4(s,`copy`);return(0,V.jsx)(Hge,{className:t,code:v,isIncomplete:u,language:d,lineNumbers:_,startLine:g,children:y?(0,V.jsxs)(V.Fragment,{children:[b?(0,V.jsx)(Wge,{code:v,language:d}):null,x?(0,V.jsx)(P4,{}):null]}):null})},(e,t)=>e.className===t.className&&Y4(e.node,t.node));C3.displayName=`MarkdownCode`;var w3=(0,B.memo)(Kge,(e,t)=>e.className===t.className&&Y4(e.node,t.node));w3.displayName=`MarkdownImg`;var T3=(0,B.memo)(({children:e,node:t,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(e=>e!=null&&e!==``);if(r.length===1&&(0,B.isValidElement)(r[0])){let t=r[0].props.node?.tagName;if(t===`img`||t===`code`&&`data-block`in r[0].props)return(0,V.jsx)(V.Fragment,{children:e})}return(0,V.jsx)(`p`,{...n,children:e})},(e,t)=>X4(e,t));T3.displayName=`MarkdownParagraph`;var o_e={ol:t3,li:n3,ul:r3,hr:i3,strong:a3,a:o3,h1:s3,h2:c3,h3:l3,h4:u3,h5:d3,h6:f3,table:p3,thead:m3,tbody:h3,tr:g3,th:_3,td:v3,blockquote:y3,code:C3,img:w3,pre:({children:e})=>(0,B.isValidElement)(e)?(0,B.cloneElement)(e,{"data-block":`true`}):e,sup:b3,sub:x3,p:T3,section:S3},s_e=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,c_e=/\p{L}/u;function E3(e){let t=e.replace(/^#{1,6}\s+/gm,``).replace(/(\*{1,3}|_{1,3})/g,``).replace(/`[^`]*`/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/^[\s>*\-+\d.]+/gm,``);for(let e of t){if(s_e.test(e))return`rtl`;if(c_e.test(e))return`ltr`}return`ltr`}var l_e=/^[ \t]{0,3}(`{3,}|~{3,})/,u_e=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,D3=e=>{let t=e.split(`
211
211
  `),n=null,r=0;for(let e of t){let t=l_e.exec(e);if(n===null){if(t){let e=t[1];n=e[0],r=e.length}}else if(t){let e=t[1],i=e[0],a=e.length;i===n&&a>=r&&(n=null,r=0)}}return n!==null},d_e=e=>{let t=e.split(`
212
212
  `);for(let e of t){let t=e.trim();if(t.length>0&&t.includes(`|`)&&u_e.test(t))return!0}return!1},f_e=()=>e=>{KK(e,`html`,(e,t,n)=>{!n||typeof t!=`number`||(n.children[t]={type:`text`,value:e.value})})},O3=[],k3={allowDangerousHtml:!0},A3=new WeakMap,j3=new class{constructor(){this.cache=new Map,this.keyCache=new WeakMap,this.maxSize=100}generateCacheKey(e){let t=this.keyCache.get(e);if(t)return t;let n=e.rehypePlugins,r=e.remarkPlugins,i=e.remarkRehypeOptions;if(!(n||r||i)){let t=`default`;return this.keyCache.set(e,t),t}let a=e=>{if(!e||e.length===0)return``;let t=``;for(let n=0;n<e.length;n+=1){let r=e[n];if(n>0&&(t+=`,`),Array.isArray(r)){let[e,n]=r;if(typeof e==`function`){let n=A3.get(e);n||(n=e.name,A3.set(e,n)),t+=n}else t+=String(e);t+=`:`,t+=JSON.stringify(n)}else if(typeof r==`function`){let e=A3.get(r);e||(e=r.name,A3.set(r,e)),t+=e}else t+=String(r)}return t},o=a(n),s=`${a(r)}::${o}::${i?JSON.stringify(i):``}`;return this.keyCache.set(e,s),s}get(e){let t=this.generateCacheKey(e),n=this.cache.get(t);return n&&(this.cache.delete(t),this.cache.set(t,n)),n}set(e,t){let n=this.generateCacheKey(e);if(this.cache.size>=this.maxSize){let e=this.cache.keys().next().value;e&&this.cache.delete(e)}this.cache.set(n,t)}clear(){this.cache.clear()}},M3=e=>{let t=p_e(e),n=e.children||``;return b_e(t.runSync(t.parse(n),n),e)},p_e=e=>{let t=j3.get(e);if(t)return t;let n=h_e(e);return j3.set(e,n),n},m_e=e=>e.some(e=>Array.isArray(e)?e[0]===_$:e===_$),h_e=e=>{let t=e.rehypePlugins||O3,n=e.remarkPlugins||O3,r=m_e(t)?n:[...n,f_e],i=e.remarkRehypeOptions?{...k3,...e.remarkRehypeOptions}:k3;return Ahe().use(Ame).use(r).use(fhe,i).use(t)},g_e=e=>e,__e=(e,t,n,r)=>{n?e.children.splice(t,1):e.children[t]={type:`text`,value:r}},v_e=(e,t)=>{for(let n in U0)if(Object.hasOwn(U0,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],i=U0[n];(i===null||i.includes(e.tagName))&&(e.properties[n]=t(String(r||``),n,e)??void 0)}},y_e=(e,t,n,r,i,a)=>{let o=!1;return r?o=!r.includes(e.tagName):i&&(o=i.includes(e.tagName)),!o&&a&&typeof t==`number`&&(o=!a(e,t,n)),o},b_e=(e,t)=>{let{allowElement:n,allowedElements:r,disallowedElements:i,skipHtml:a,unwrapDisallowed:o,urlTransform:s}=t;if(n||r||i||a||s){let t=s||g_e;KK(e,(e,s,c)=>{if(e.type===`raw`&&c&&typeof s==`number`)return __e(c,s,a,e.value),s;if(e.type===`element`&&(v_e(e,t),y_e(e,s,c,r,i,n)&&c&&typeof s==`number`))return o&&e.children?c.children.splice(s,1,...e.children):c.children.splice(s,1),s})}return Rpe(e,{Fragment:V.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:V.jsx,jsxs:V.jsxs,passKeys:!0,passNode:!0})},x_e=/\[\^[\w-]{1,200}\](?!:)/,S_e=/\[\^[\w-]{1,200}\]:/,C_e=/<(\w+)[\s>]/,w_e=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),N3=new Map,P3=new Map,T_e=e=>{let t=e.toLowerCase(),n=N3.get(t);if(n)return n;let r=RegExp(`<${t}(?=[\\s>/])[^>]*>`,`gi`);return N3.set(t,r),r},E_e=e=>{let t=e.toLowerCase(),n=P3.get(t);if(n)return n;let r=RegExp(`</${t}(?=[\\s>])[^>]*>`,`gi`);return P3.set(t,r),r},F3=(e,t)=>{if(w_e.has(t.toLowerCase()))return 0;let n=e.match(T_e(t));if(!n)return 0;let r=0;for(let e of n)e.trimEnd().endsWith(`/>`)||(r+=1);return r},I3=(e,t)=>{let n=e.match(E_e(t));return n?n.length:0},D_e=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]===`$`&&e[n+1]===`$`&&(t+=1,n+=1);return t},O_e=e=>{let t=x_e.test(e),n=S_e.test(e);if(t||n)return[e];let r=c4.lex(e,{gfm:!0}),i=[],a=[],o=!1;for(let e of r){let t=e.raw,n=i.length;if(a.length>0){i[n-1]+=t;let e=a.at(-1),r=F3(t,e),o=I3(t,e);for(let t=0;t<r;t+=1)a.push(e);for(let t=0;t<o;t+=1)a.length>0&&a.at(-1)===e&&a.pop();continue}if(e.type===`html`&&e.block){let e=t.match(C_e);if(e){let n=e[1];F3(t,n)>I3(t,n)&&a.push(n)}}if(n>0&&!o){let e=i[n-1];if(D_e(e)%2==1){i[n-1]=e+t;continue}}i.push(t),e.type!==`space`&&(o=e.type===`code`)}return i},k_e=(e,t)=>{if(!t.length)return e;let n=e;for(let e of t){let t=RegExp(`(<${e}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${e}\\s*>)`,`gi`);n=n.replace(t,(e,t,n,r)=>{if(!n.includes(`
213
213
 
@@ -223,9 +223,9 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
223
223
  `).trim()}\n`}function Q_e(e){let t=e.trim();if(t===``)return``;let n=t.slice(t.lastIndexOf(`:`)+1)||t;return n.length>10?`${n.slice(0,8)}…`:n}function $_e(e){return/^agent:(.+?):subagent:/.exec(e.trim())?.[1]?.trim()||void 0}function eve(e){if(!Number.isFinite(e)||e<0)return``;if(e<1e3)return`< 1 s`;let t=Math.round(e/1e3);if(t<60)return`${t} s`;let n=Math.floor(t/60),r=t%60;if(n<60)return r>0?`${n} min ${r} s`:`${n} min`;let i=Math.floor(n/60),a=n%60;return a>0?`${i} h ${String(a).padStart(2,`0`)} min`:`${i} h`}function tve(e){if(!Number.isFinite(e)||e<0)return``;let t=e>0&&e<.01?4:2;return`${e.toFixed(t).replace(`.`,`,`)} $`}function n6(e){return e.moaRole===`moa_aggregator`?Zd():e.moaRole===`moa_reference`?Vf():xf()}function nve(e){return e.kind===`task`?rl({tool:e.taskName?.trim()||`task`}):e.taskName?.trim()||Q_e(e.childSessionKey)||Qr()}function rve(e){return e.some(e=>e.status===`running`&&e.kind!==`task`)}function ive(e){return e===`running`?`running`:e===`done`?`done`:`failed`}function ave(e){return e!==`running`}function ove(e){return e!==void 0&&e.tone!==`running`&&e.sessionMeta?.cleanup===`delete`}function sve(e){return e.startsWith(`fork:`)}function cve(e){let t=ive(e.status),n=e.sessionMeta?.subagentRole;return{id:e._id,childSessionKey:e.childSessionKey,...e.kind===`task`?{isTask:!0}:{},...n===`moa_reference`||n===`moa_aggregator`?{moaRole:n}:{},taskName:e.taskName?.trim()||void 0,label:nve(e),status:e.status,tone:t,failure:t===`failed`,phase:e.status===`running`?e.phase:void 0,errorMessage:e.errorMessage,resultText:e.resultText,tools:e.tools?.map(e=>({name:e.name,status:e.status,toolCallId:e.toolCallId})),sessionMeta:e.sessionMeta,telemetry:e.telemetry,childAgentId:$_e(e.childSessionKey)}}function r6(e){let t=[...e].sort((e,t)=>t.createdAt-e.createdAt).map(cve).sort((e,t)=>{let n=e=>e.moaRole===`moa_aggregator`?0:e.moaRole===`moa_reference`?1:2,r=e=>e.moaRole?e.childSessionKey.replace(/:(ref\d+|aggregate)$/,``):``,i=r(e).localeCompare(r(t));if(e.moaRole&&t.moaRole&&i!==0)return i;let a=n(e),o=n(t);if(a!==o)return a-o;if(a===1){let n=e=>{let t=/ref(\d+)$/.exec(e.childSessionKey);return t?.[1]?Number.parseInt(t[1],10):0};return n(e)-n(t)}return 0});return{cards:t,total:t.length,done:t.filter(e=>e.tone===`done`).length,running:t.filter(e=>e.tone===`running`).length,failed:t.filter(e=>e.tone===`failed`).length}}function lve(e){if(e.total<=1)return[];let t={done:e.done,running:e.running,failed:e.failed};return[`done`,`running`,`failed`].filter(e=>t[e]>0).map(e=>({tone:e,count:t[e]}))}function i6(e,t,n){let r=new Set(t);return e.filter(e=>n!==void 0&&e.parentMessageId===n||r.has(e.childSessionKey))}function uve(e){return e===1?nr({count:e}):Te({count:e})}var a6=120,dve=/EXTERNAL_UNTRUSTED_CONTENT|SECURITY\s*NOTICE|UNTRUSTED\s*CONTENT/i,fve=/DO NOT/;function o6(e){return dve.test(e)||fve.test(e)}function s6(e){return e.length<=a6?e:`${e.slice(0,a6-1)}…`}function pve(e){for(let t of e.split(/\r?\n/)){let e=t.replace(/\s+/g,` `).trim();if(!(e.length<3)&&/[\p{L}\p{N}]/u.test(e)&&!o6(e))return e}return null}function c6(e){let t=me();if(e==null)return t;let n=e.trim();if(n===``)return t;let r=/([A-Za-z][\w.-]*)\s+failed\s*\(([^)]{1,40})\)/i.exec(n);if(r)return s6(`${r[1]} (${r[2].trim()})`);let i=pve(n);return i&&!o6(i)?s6(i):t}function mve(e){let t=document.querySelector(`[data-message-id="${CSS.escape(e)}"]`);if(!t)return;let n=t.closest(`.oc-thread__viewport`);if(n){let e=t.getBoundingClientRect().top-n.getBoundingClientRect().top;n.scrollTo({top:n.scrollTop+e-12,behavior:`smooth`})}else t.scrollIntoView({block:`start`,behavior:`smooth`});t.classList.remove(`oc-msg--highlight`),t.offsetWidth,t.classList.add(`oc-msg--highlight`),window.setTimeout(()=>t.classList.remove(`oc-msg--highlight`),2400)}function hve(e,t){let n=new Blob([t],{type:`text/markdown;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}var l6=(0,B.createContext)(null);function gve({card:e}){let t=e.tone===`running`?Ie():e.tone===`failed`?cf():ui();return(0,V.jsxs)(`span`,{className:`oc-subpanel__status oc-subpanel__status--${e.tone}`,children:[t,e.tone===`running`?(0,V.jsx)(MS,{size:13,className:`oc-subagent__spin`,"aria-hidden":!0}):e.tone===`failed`?(0,V.jsx)(_S,{size:13,"aria-hidden":!0}):(0,V.jsx)(cp,{size:13,"aria-hidden":!0})]})}function _ve(e){if(e)try{return JSON.parse(e)}catch{return}}function vve(e){return{type:e===`error`?`error`:e===`done`?`completed`:`running`}}function u6(e){return e.toolCallId??`name:${e.name}`}function yve({summary:e,parts:t,subAgentRunning:n}){let[r,i]=(0,B.useState)(!1),a=n,o=e.length===1?Jr({count:e.length}):_f({count:e.length}),s=a?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(MS,{size:13,className:`oc-actrow__status-icon oc-actrow__spin`,"aria-hidden":!0}),sf()]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(cp,{size:13,className:`oc-actrow__status-icon`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-sr-only`,children:pe()})]}),c=new Map;for(let e of t??[])c.set(e.toolCallId,e);return(0,V.jsxs)(`div`,{className:`oc-toolact`,children:[(0,V.jsx)(dH,{icon:(0,V.jsx)(QS,{size:14}),label:o,trailing:s,open:r,ariaExpanded:r,title:r?bf():Zr(),onClick:()=>i(!r)}),r?(0,V.jsx)(`div`,{className:`oc-toolact__detail`,children:e.map((e,t)=>{let r=c.get(u6(e));return(0,V.jsx)(OW,{toolName:e.name,args:r?_ve(r.argsText):void 0,argsText:r?.argsText,result:r?.resultText,status:vve(r?.status??e.status),turnSettled:!n},`${u6(e)}-${t}`)})}):null]})}function bve({meta:e,telemetry:t,childAgentId:n,instanceName:r,parentAgentLabel:i,onExport:a}){let[o,s]=(0,B.useState)(!1),c=!!e&&Object.values(e).some(e=>e!==void 0)||!!t&&Object.values(t).some(e=>e!==void 0)||n!==void 0;if(!c&&!i&&!a)return(0,V.jsx)(`div`,{className:`oc-subpanel__barslot`,"aria-hidden":!0});let l=e?.fastMode===void 0?null:e.fastMode?Vu():Il();return(0,V.jsxs)(`div`,{className:`oc-subpanel__bar`,children:[(0,V.jsxs)(`div`,{className:`oc-subpanel__bar-chips`,children:[e?.model?(0,V.jsxs)(`span`,{className:`oc-chip oc-chip--info`,title:e.modelProvider?jd({provider:e.modelProvider}):id(),children:[(0,V.jsx)(Wne,{size:12,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-chip__label`,children:e.model})]}):null,e?.thinkingLevel?(0,V.jsxs)(`span`,{className:`oc-chip`,title:ho(),children:[(0,V.jsx)(pS,{size:12,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-chip__label`,children:e.thinkingLevel})]}):null,l?(0,V.jsxs)(`span`,{className:`oc-chip`,title:Ec(),children:[(0,V.jsx)(AS,{size:12,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-chip__label`,children:l})]}):null,e?.context?(0,V.jsxs)(`span`,{className:`oc-chip`,title:e.context===`fork`?Ma():va(),children:[(0,V.jsx)(fre,{size:12,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-chip__label`,children:e.context})]}):null,i?(0,V.jsxs)(`span`,{className:`oc-chip`,title:jr(),children:[(0,V.jsx)(fS,{size:12,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-chip__label`,children:i})]}):null,a?(0,V.jsxs)(xV,{children:[(0,V.jsx)(SV,{asChild:!0,children:(0,V.jsxs)(`button`,{type:`button`,className:`oc-chip oc-chip--btn oc-subpanel__bar-export`,title:Ko(),children:[(0,V.jsx)(CS,{size:12,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-chip__label`,children:cl()}),(0,V.jsx)(up,{size:12,className:`oc-chip__chev`,"aria-hidden":!0})]})}),(0,V.jsxs)(CV,{align:`end`,className:`w-44`,children:[(0,V.jsx)(TV,{children:cl()}),(0,V.jsx)(wV,{onClick:()=>a(`md`),children:xr()}),(0,V.jsx)(wV,{onClick:()=>a(`json`),children:Pa()})]})]}):null]}),c?(0,V.jsxs)(`button`,{type:`button`,className:`oc-subpanel__adv-toggle${o?` is-open`:``}`,"aria-expanded":o,onClick:()=>s(e=>!e),children:[(0,V.jsx)(KS,{size:13,"aria-hidden":!0}),Wa(),(0,V.jsx)(gS,{size:13,className:`oc-subpanel__adv-chevron`,"aria-hidden":!0})]}):null,o&&c?(0,V.jsx)(Sve,{meta:e??{},telemetry:t,childAgentId:n,instanceName:r}):null]})}function xve(e){return e===`leaf`?Wc():e===`orchestrator`?A():null}function Sve({meta:e,telemetry:t,childAgentId:n,instanceName:r}){let i=[];e.model&&i.push([id(),e.model]),e.modelProvider&&i.push([Ql(),e.modelProvider]);let a=e.agentId??n;a&&i.push([At(),a]),r&&i.push([Ju(),r]),e.label&&i.push([Gi(),e.label]),e.thinkingLevel&&i.push([ho(),e.thinkingLevel]),e.fastMode!==void 0&&i.push([Ec(),e.fastMode?Vu():Il()]),e.context&&i.push([va(),e.context]),e.lightContext!==void 0&&i.push([se(),e.lightContext?op():Wr()]),e.runtime&&i.push([an(),e.runtime]),e.mode&&i.push([Pu(),e.mode]),e.cleanup&&i.push([yn(),e.cleanup]),e.sandbox&&i.push([gt(),e.sandbox]),e.controlScope&&i.push([vd(),e.controlScope]),e.subagentRole&&i.push([ys(),e.subagentRole]),e.spawnDepth!==void 0&&i.push([x(),String(e.spawnDepth)]);let o=xve(e.subagentRole);if(o&&i.push([ki(),o]),e.sessionId&&i.push([jn(),e.sessionId]),e.gatewayKind&&i.push([aa(),e.gatewayKind]),t?.runtimeMs!==void 0){let e=eve(t.runtimeMs);e&&i.push([Gt(),e])}if(t?.totalTokens!==void 0&&i.push([nt(),MV(t.totalTokens)]),t?.estimatedCostUsd!==void 0){let e=typeof t.totalTokens==`number`&&t.totalTokens>0;if(t.estimatedCostUsd<=0&&e)i.push([yr(),mo()]);else{let e=tve(t.estimatedCostUsd);e&&i.push([yr(),e])}}return(0,V.jsx)(`dl`,{className:`oc-subpanel__adv-list`,children:i.map(([e,t])=>(0,V.jsxs)(`div`,{className:`oc-subpanel__adv-row`,children:[(0,V.jsx)(`dt`,{children:e}),(0,V.jsx)(`dd`,{children:t})]},e))})}function d6({chatId:e,childKey:t,onClose:n,parentAgentLabel:r}){let i=R(L.subAgents.listSubAgents,{chatId:e}),a=R(L.agents.getChatAgent,{chatId:e}),o=R(L.messages.getSessionMeta,{chatId:e})?.perTurnRouting===!0?void 0:a?.agent?.instanceName,s=(i??[]).find(e=>e.childSessionKey===t),c=s?r6([s]).cards[0]:void 0,l=s?.taskName?.trim(),u=ove(c),d=sve(t),f=R(L.subAgentReports.myReportedSubAgentIds,{chatId:e}),m=R(L.subAgents.listSubAgentToolParts,{chatId:e,childSessionKey:t}),h=R(L.subAgentInteractions.listSubAgentInteractions,{chatId:e,childSessionKey:t}),g=La(L.subAgentInteractions.sendToSubAgent),_=p(L.chats.generateUploadUrl),v=p(L.uploads.registerUpload),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(!0),[C,w]=(0,B.useState)(!1),[T,E]=(0,B.useState)(``),[D,O]=(0,B.useState)(!1),[k,A]=(0,B.useState)([]),[j,M]=(0,B.useState)(!1),[N,ee]=(0,B.useState)(!0),P=(0,B.useRef)(null),F=(0,B.useRef)(null),te=(0,B.useCallback)(async e=>{if(!(!e||e.length===0)){M(!0);try{for(let t of Array.from(e)){if(k.length>=6)break;let e=await _(),{storageId:n}=await(await fetch(e,{method:`POST`,headers:{"Content-Type":t.type||`application/octet-stream`},body:t})).json();await v({storageId:n}),A(e=>e.length>=6?e:[...e,{storageId:n,filename:t.name,mimeType:t.type||`application/octet-stream`}])}}finally{M(!1),P.current&&(P.current.value=``)}}},[k.length,_,v]),[ne,re]=(0,B.useState)(null),ie=c?(f??[]).includes(c.id):!1,ae=(0,B.useCallback)(e=>{if(!c)return;let t=m&&m.length>0?m.map(e=>({name:e.name,status:e.status,argsText:e.argsText,resultText:e.resultText})):(c.tools??[]).map(e=>({name:e.name,status:e.status})),n={taskName:l,status:c.status,parentAgentLabel:r,sessionMeta:c.sessionMeta,telemetry:c.telemetry,result:c.resultText,error:c.failure?c6(c.errorMessage):void 0,tools:t};hve(Y_e(l,e),e===`md`?Z_e(n):X_e({...n,exportedAt:Date.now()}))},[c,m,l,r]);(0,B.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,B.useEffect)(()=>{i!==void 0&&!s&&n()},[i,s,n]);let oe=h&&h.length>0?`${h.length}:${h[h.length-1].status}`:``;(0,B.useEffect)(()=>{if(!oe)return;let e=F.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`smooth`})},[oe]);let se=async()=>{let n=T.trim();if(!(u||d)&&!(!n&&k.length===0||y||j)){b(!0);try{await g({chatId:e,childSessionKey:t,text:n,...k.length>0?{attachments:k.map(e=>({storageId:e.storageId,filename:e.filename,mimeType:e.mimeType}))}:{}}),E(``),A([])}finally{b(!1)}}};return(0,V.jsxs)(`div`,{className:`oc-subpanel`,children:[(0,V.jsxs)(`header`,{className:`oc-subpanel__head`,children:[(0,V.jsx)(`button`,{type:`button`,className:`oc-subpanel__avatar oc-subpanel__back${c?` oc-subpanel__avatar--${c.tone}`:``}`,disabled:!s?.parentMessageId,title:Ps(),"aria-label":pu(),onClick:()=>s?.parentMessageId&&mve(s.parentMessageId),children:(0,V.jsx)(Bne,{size:16})}),(0,V.jsxs)(`div`,{className:`oc-subpanel__headmain`,children:[(0,V.jsxs)(`div`,{className:`oc-subpanel__head-top`,children:[(0,V.jsx)(`span`,{className:`oc-subpanel__kind`,children:c?n6(c):xf()}),(0,V.jsxs)(`div`,{className:`oc-subpanel__head-ctrls`,children:[c?(0,V.jsx)(gve,{card:c}):null,c&&ave(c.status)?(0,V.jsx)(`button`,{type:`button`,className:`oc-iconbtn oc-subpanel__report${ie?` is-on`:``}`,title:ie?Ku():Pd(),"aria-label":Pd(),disabled:ie,onClick:()=>re({subAgentId:c.id,label:c.label}),children:(0,V.jsx)(OS,{size:15,"aria-hidden":!0})}):null,(0,V.jsx)(Ep,{variant:`ghost`,size:`icon-sm`,onClick:n,"aria-label":Lf(),className:`oc-subpanel__close`,children:(0,V.jsx)(mp,{size:16})})]})]}),l?(0,V.jsx)(`button`,{type:`button`,className:`oc-subpanel__task${D?` is-expanded`:``}`,title:cs(),"aria-expanded":D,onClick:()=>O(e=>!e),children:l}):null]})]}),(0,V.jsx)(bve,{meta:c?.sessionMeta,telemetry:c?.telemetry,childAgentId:c?.childAgentId,instanceName:o,parentAgentLabel:r,onExport:c?ae:void 0}),(0,V.jsx)(`div`,{className:`oc-subpanel__body`,ref:F,children:c?(0,V.jsxs)(V.Fragment,{children:[c.tools&&c.tools.length>0&&N?(0,V.jsxs)(`section`,{className:`oc-subpanel__section`,children:[(0,V.jsx)(`h3`,{className:`oc-subpanel__section-title`,children:Qa()}),(0,V.jsx)(yve,{summary:c.tools,parts:m,subAgentRunning:c.tone===`running`})]}):null,c.failure?(0,V.jsxs)(`section`,{className:`oc-subpanel__section`,children:[(0,V.jsx)(`h3`,{className:`oc-subpanel__section-title`,children:Ys()}),(0,V.jsx)(`p`,{className:`oc-subpanel__error`,children:c6(c.errorMessage)})]}):null,c.resultText?(0,V.jsxs)(`section`,{className:`oc-subpanel__section oc-subpanel__result${x?` is-open`:``}`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`oc-subpanel__result-toggle`,"aria-expanded":x,onClick:()=>S(!x),children:[(0,V.jsx)(gS,{size:13,className:`oc-subpanel__result-chevron`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-subpanel__section-title`,children:dc()})]}),x?(0,V.jsx)(Y3,{text:c.resultText}):null]}):c.tone===`running`?(0,V.jsxs)(`p`,{className:`oc-subpanel__muted oc-subpanel__working`,children:[(0,V.jsx)(MS,{size:14,className:`oc-subagent__spin`,"aria-hidden":!0}),xl()]}):null,h&&h.length>0?(0,V.jsxs)(`section`,{className:`oc-subpanel__section`,children:[(0,V.jsx)(`h3`,{className:`oc-subpanel__section-title`,children:$c()}),(0,V.jsx)(`div`,{className:`oc-subpanel__thread`,children:h.map(e=>(0,V.jsxs)(`div`,{className:`oc-subpanel__exchange`,children:[(0,V.jsxs)(`div`,{className:`oc-subpanel__msg oc-subpanel__msg--user`,children:[e.userText,e.attachments&&e.attachments.length>0?(0,V.jsx)(`div`,{className:`oc-subpanel__msg-atts`,children:e.attachments.map((t,n)=>(0,V.jsxs)(`span`,{className:`oc-subpanel__attchip oc-subpanel__attchip--sent`,title:t.filename,children:[(0,V.jsx)(RS,{size:11,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-subpanel__attchip-name`,children:t.filename})]},`${e._id}-att-${n}`))}):null]}),e.status===`pending`?(0,V.jsxs)(`div`,{className:`oc-subpanel__msg oc-subpanel__msg--pending`,children:[(0,V.jsx)(MS,{size:13,className:`oc-actrow__spin`,"aria-hidden":!0}),sr()]}):e.status===`error`?(0,V.jsx)(`div`,{className:`oc-subpanel__msg oc-subpanel__msg--err`,children:e.errorMessage??Ae()}):(0,V.jsx)(`div`,{className:`oc-subpanel__msg oc-subpanel__msg--reply`,children:(0,V.jsx)(Y3,{text:e.replyText??``})})]},e._id))})]}):null]}):(0,V.jsx)(`p`,{className:`oc-subpanel__muted`,children:qd()})}),(0,V.jsx)(`footer`,{className:`oc-subpanel__foot`,children:C?(0,V.jsxs)(`div`,{className:`oc-subpanel__prompt`,children:[k.length>0?(0,V.jsx)(`div`,{className:`oc-subpanel__attstrip`,children:k.map((e,t)=>(0,V.jsxs)(`span`,{className:`oc-subpanel__attchip`,title:e.filename,children:[(0,V.jsx)(RS,{size:12,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-subpanel__attchip-name`,children:e.filename}),(0,V.jsx)(`button`,{type:`button`,className:`oc-subpanel__attchip-x`,"aria-label":ri(),onClick:()=>A(e=>e.filter((e,n)=>n!==t)),children:(0,V.jsx)(mp,{size:11,"aria-hidden":!0})})]},`${e.storageId}-${t}`))}):null,(0,V.jsx)(`textarea`,{className:`oc-subpanel__prompt-input`,rows:2,value:T,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),se())},placeholder:Fo(),autoFocus:!0}),(0,V.jsxs)(`div`,{className:`oc-subpanel__prompt-bar`,children:[(0,V.jsxs)(`div`,{className:`oc-subpanel__composer-actions`,children:[(0,V.jsx)(`button`,{type:`button`,className:`oc-subpanel__composer-btn`,title:ff(),"aria-label":ff(),disabled:j||k.length>=6,onClick:()=>P.current?.click(),children:j?(0,V.jsx)(MS,{size:15,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,V.jsx)(HS,{size:15,"aria-hidden":!0})}),c?.tools&&c.tools.length>0?(0,V.jsxs)(`button`,{type:`button`,className:`oc-subpanel__composer-btn oc-subpanel__composer-btn--label${N?` is-on`:``}`,title:ye(),"aria-pressed":N,onClick:()=>ee(e=>!e),children:[(0,V.jsx)(QS,{size:14,"aria-hidden":!0}),Qa()]}):null]}),c?.tone===`running`?(0,V.jsx)(`span`,{className:`oc-subpanel__prompt-hint`,children:Ve()}):d?(0,V.jsx)(`span`,{className:`oc-subpanel__prompt-hint`,children:Vn()}):u?(0,V.jsx)(`span`,{className:`oc-subpanel__prompt-hint`,children:Zn()}):(h??[]).some(e=>e.status===`pending`)?(0,V.jsx)(`span`,{className:`oc-subpanel__prompt-hint`,children:hi()}):null,(0,V.jsxs)(Ep,{variant:`default`,size:`sm`,className:`gap-1.5`,disabled:!T.trim()&&k.length===0||y||j||c?.tone===`running`||u||d||(h??[]).some(e=>e.status===`pending`),onClick:()=>void se(),children:[y?(0,V.jsx)(MS,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,V.jsx)(lre,{size:14,"aria-hidden":!0}),Uf()]})]}),(0,V.jsx)(`input`,{ref:P,type:`file`,multiple:!0,className:`oc-subpanel__fileinput`,onChange:e=>void te(e.target.files)})]}):(0,V.jsxs)(`button`,{type:`button`,className:`oc-subpanel__interact`,onClick:()=>w(!0),children:[(0,V.jsx)($ne,{size:15,"aria-hidden":!0}),Ef()]})}),(0,V.jsx)(J_e,{target:ne,onClose:()=>re(null)})]})}var Cve=new Set([`knobThinkingLevel`,`knobModel`,`knobFastMode`,`knobUnset`,`agentFiles`,`sessionCompact`,`configDefaults`,`subagents`,`inboundAttachments`]),wve=new Set([`knobThinkingLevel`,`knobModel`]);function f6(e,t){return Cve.has(t)?e==null?wve.has(t):e[t]===!0:!1}function Tve(e,t){return{model:e(`knobModel`)&&t.hasModels,thinking:e(`knobThinkingLevel`)&&t.hasLevels,speed:e(`knobFastMode`),reset:e(`knobUnset`)}}function Eve(e,t){return e===void 0?`loading`:e===null?{blocked:!f6(null,t),gatewayVersion:null,provider:null}:{blocked:!f6(e.capabilities,t),gatewayVersion:e.gatewayVersion,provider:e.provider}}function p6(e){let t=R(L.compat.forChat,e===null?`skip`:{chatId:e}),n=t==null?null:t.capabilities;return{can:(0,B.useCallback)(e=>f6(n,e),[n]),resolved:n!==null,loading:t===void 0,gatewayVersion:t?.gatewayVersion??null}}function m6(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function h6(e){let t=[];for(let n of e){if(n.toolName!==`sessions_spawn`)continue;let e=n.result;if(!m6(e))continue;let r=e.contentItems;if(Array.isArray(r))for(let e of r){let n=m6(e)?e.text:void 0;if(typeof n==`string`)try{let e=JSON.parse(n),r=m6(e)?e.childSessionKey:void 0;typeof r==`string`&&r!==``&&t.push(r)}catch{}}}return t}var Dve=new Set([`sessions_spawn`,`delegate_task`,`mixture_of_agents`]);function Ove(e){return e.some(e=>Dve.has(e.toolName))}function kve(e){return e.some(e=>{let t=e.result;if(typeof t!=`object`||!t)return!1;let n=t.details;if(typeof n!=`object`||!n)return!1;let r=n;return r.async===!0&&typeof r.taskId==`string`})}function g6(e){return e?.trim()||void 0}function Ave(e,t,n,r){if(e.hasText||e.hasMedia||e.status!==`complete`)return{kind:`none`};let i=new Set(h6(t)),a=n.filter(e=>r!==void 0&&e.parentMessageId===r||i.has(e.childSessionKey)),o=a.find(e=>e.status===`running`);if(o)return{kind:`waiting`,taskName:g6(o.taskName)};let s=a.filter(e=>e.kind!==`task`),c=s.find(e=>e.status===`error`||e.status===`aborted`);if(c)return{kind:`failed`,taskName:g6(c.taskName),reason:c6(c.errorMessage)};let l=s.find(e=>e.status===`done`);return l?{kind:`done`,taskName:g6(l.taskName),resultText:l.resultText}:{kind:`generic`}}function _6(e,t){return e===`done`?Go({count:t}):e===`running`?rd({count:t}):Zl({count:t})}function jve({card:e}){let t=e.tone===`running`?MS:e.tone===`failed`?_S:cp,n=(0,B.useContext)(l6),r=e.tools?.length??0,i=n?.activeChildKey===e.childSessionKey,a=(0,V.jsxs)(V.Fragment,{children:[r>0?(0,V.jsx)(`span`,{className:`oc-actrow__toolcount`,children:r===1?Jr({count:r}):_f({count:r})}):null,(0,V.jsx)(t,{size:13,className:`oc-actrow__status-icon${e.tone===`running`?` oc-actrow__spin`:``}`,"aria-hidden":!0})]});return(0,V.jsxs)(`div`,{className:`oc-subagent oc-subagent--${e.tone}${e.moaRole===`moa_reference`?` oc-subagent--nested`:``}`,children:[(0,V.jsx)(dH,{tone:e.tone,icon:e.isTask?(0,V.jsx)($S,{size:15}):(0,V.jsx)(fS,{size:15}),label:e.isTask?e.label:n6(e),sublabel:e.isTask?void 0:e.taskName,trailing:a,active:i,ariaExpanded:e.isTask?void 0:i,ariaHasPopup:!e.isTask,title:e.isTask?void 0:ko(),ariaLabel:e.isTask?void 0:ko(),inert:e.isTask,onClick:()=>{e.isTask||n?.openFor(e.childSessionKey)}}),e.failure?(0,V.jsx)(`p`,{className:`oc-subagent__error`,role:`status`,children:c6(e.errorMessage)}):null]})}var Mve=[];function Nve(){let e=Yk(e=>e.metadata?.custom?.chatId),t=Yk(e=>e.metadata?.custom?.toolParts??Mve),n=(0,B.useMemo)(()=>h6(t),[t]),r=(0,B.useMemo)(()=>Ove(t)||kve(t),[t]),i=Yk(e=>e.metadata?.custom?.messageId),a=r&&e?e:null,{can:o}=p6(a),s=R(L.subAgents.listSubAgents,a?{chatId:a}:`skip`),[c,l]=(0,B.useState)(!1);if(!r||!o(`subagents`))return null;let u=r6(i6(s??[],n,i)),d=[...u.cards];if(d.length===0)return null;let f=lve(u);return(0,V.jsxs)(`div`,{className:`oc-msg-subagents`,children:[f.length>0?(0,V.jsx)(dH,{icon:(0,V.jsx)(fS,{size:15}),label:uve(u.total),trailing:f.map(e=>(0,V.jsxs)(`span`,{className:`oc-subagent-badge oc-subagent-badge--${e.tone}`,title:_6(e.tone,e.count),"aria-label":_6(e.tone,e.count),children:[e.tone===`done`?(0,V.jsx)(cp,{size:12,"aria-hidden":!0}):e.tone===`running`?(0,V.jsx)(MS,{size:12,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,V.jsx)(_S,{size:12,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-subagent-badge__count`,children:e.count})]},e.tone)),open:c,ariaExpanded:c,title:c?bf():Zr(),onClick:()=>l(!c)}):null,(f.length===0||c)&&d.map(e=>(0,V.jsx)(`div`,{className:`oc-msg-subagents__anchor`,"data-subagent-id":e.id,"data-subagent-failed":e.failure?``:void 0,children:(0,V.jsx)(jve,{card:e})},e.id))]})}function v6({delayDuration:e=0,...t}){return(0,V.jsx)(Ale,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function y6({...e}){return(0,V.jsx)(jle,{"data-slot":`tooltip`,...e})}function b6({...e}){return(0,V.jsx)(Mle,{"data-slot":`tooltip-trigger`,...e})}function x6({className:e,sideOffset:t=0,children:n,...r}){return(0,V.jsx)(Nle,{children:(0,V.jsxs)(Ple,{"data-slot":`tooltip-content`,sideOffset:t,className:Al(`z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[n,(0,V.jsx)(Fle,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function Pve(){return Yk(e=>e.metadata?.custom?.compaction??null)}function Fve(){let e=Pve();if(!e)return null;let t=e.phase===`midturn`?Fl():Bu();return(0,V.jsx)(v6,{delayDuration:150,children:(0,V.jsxs)(y6,{children:[(0,V.jsx)(b6,{asChild:!0,children:(0,V.jsxs)(`div`,{className:`oc-compaction`,role:`note`,"aria-label":t,children:[(0,V.jsx)(`span`,{className:`oc-compaction__rule`,"aria-hidden":!0}),(0,V.jsxs)(`span`,{className:`oc-compaction__label`,children:[(0,V.jsx)(Kne,{size:12,"aria-hidden":!0}),Tc()]}),(0,V.jsx)(`span`,{className:`oc-compaction__rule`,"aria-hidden":!0})]})}),(0,V.jsx)(x6,{className:`oc-compaction__tip`,children:t})]})})}function Ive(e,t){if(e===null||e<=t)return null;let n=Math.floor((e-t)/6e4);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24){let e=n%60;return e>0?`${r}h ${e}m`:`${r}h`}return`${Math.floor(r/24)}${Pl()} ${r%24}h`}function S6(e,t){if(!e||e.length===0)return null;let n=[];for(let r of e)for(let e of r.windows)n.push({provider:r.provider,label:e.label,percentLeft:Math.round(Math.min(100,Math.max(0,100-e.usedPercent))),resetText:Ive(e.resetAt,t)});if(n.length===0)return null;let r=n.reduce((e,t)=>t.percentLeft<e.percentLeft?t:e),i=r.percentLeft<=10?`is-critical`:r.percentLeft<=25?`is-warn`:`is-ok`;return{percentLeft:r.percentLeft,label:r.label,resetText:r.resetText,level:i,windows:n}}var C6=(0,B.createContext)(null);function Lve(){return(0,B.useContext)(C6)??{open:()=>{}}}function Rve({children:e}){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(!1),s=(0,B.useRef)(null),c=(0,B.useCallback)(e=>{n(e),i(!1)},[]),l=(0,B.useCallback)(()=>{document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),n(null),o(!1)},[]);(0,B.useEffect)(()=>{if(t===null)return;let e=e=>{e.key===`Escape`&&l()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,l]),(0,B.useEffect)(()=>{let e=()=>o(document.fullscreenElement!==null);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let u=(0,B.useCallback)(()=>{let e=s.current;e&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):e.requestFullscreen().catch(()=>{}))},[]);return(0,V.jsxs)(C6.Provider,{value:{open:c},children:[e,t===null?null:(0,Lg.createPortal)((0,V.jsxs)(`div`,{ref:s,className:`oc-lightbox`,role:`dialog`,"aria-modal":`true`,"aria-label":t.name,onClick:e=>{e.target===e.currentTarget&&l()},children:[(0,V.jsxs)(`div`,{className:`oc-lightbox__bar`,children:[(0,V.jsx)(`span`,{className:`oc-lightbox__name`,title:t.name,children:t.name}),(0,V.jsx)(`button`,{type:`button`,className:`oc-lightbox__btn`,onClick:()=>i(e=>!e),"aria-label":r?_d():vs(),title:r?_d():vs(),children:r?(0,V.jsx)(gre,{size:18}):(0,V.jsx)(hre,{size:18})}),(0,V.jsx)(`button`,{type:`button`,className:`oc-lightbox__btn`,onClick:u,"aria-label":a?Er():g(),title:a?Er():g(),children:a?(0,V.jsx)(ere,{size:18}):(0,V.jsx)(FS,{size:18})}),(0,V.jsx)(`a`,{className:`oc-lightbox__btn`,href:t.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":za(),title:za(),children:(0,V.jsx)(TS,{size:18})}),(0,V.jsx)(`button`,{type:`button`,className:`oc-lightbox__btn`,onClick:l,"aria-label":pa(),title:pa(),children:(0,V.jsx)(mp,{size:18})})]}),(0,V.jsx)(`div`,{className:`oc-lightbox__stage${r?` oc-lightbox__stage--scroll`:``}`,onClick:e=>{e.target===e.currentTarget&&l()},children:(0,V.jsx)(`img`,{src:t.url,alt:t.name,className:r?`oc-lightbox__img--actual`:`oc-lightbox__img--fit`,decoding:`async`})})]}),document.body)]})}var zve=/^(?:[a-z0-9][a-z0-9_.]{0,15}-)?[a-z0-9]{25,40}$/;function Bve(e){let t=e.trim();return zve.test(t)?t:null}var w6=(0,B.createContext)(null);function Vve(e){let t=0,n=e.match(/`+/g);if(n!==null)for(let e of n)t=Math.max(t,e.length);return"`".repeat(Math.max(3,t+1))}function Hve(e,t,n){let r=Vve(t);return`\n${e} ${n}\n${r}\n${t}\n${r}\n`}var T6=null;function Uve(e,t){T6={messageId:e,terms:t}}function Wve(e){if(T6===null||T6.messageId!==e)return null;let t=T6.terms;return T6=null,t}function Gve(e){return e.turnRunning?{mode:`queue`,reason:`turn`}:e.hasRunningSubAgent?{mode:`queue`,reason:`subagent`}:{mode:`send`,reason:null}}function E6({className:e,...t}){return(0,V.jsx)(bj,{"data-slot":`checkbox`,className:Al(`peer size-4 shrink-0 rounded-[4px] border border-input bg-background ring-offset-background transition-shadow outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground`,e),...t,children:(0,V.jsx)(Sj,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center text-current`,children:t.checked===`indeterminate`?(0,V.jsx)(tre,{className:`size-3.5`}):(0,V.jsx)(cp,{className:`size-3.5`})})})}function D6(e,t){return t===`memory`?`memory`:e.context===!0||!e.file_name?`context`:`document`}function O6(e){let t={memory:0,documents:0,context:0};for(let n of e)for(let e of n.items){let r=D6(e,n.group);r===`memory`?t.memory+=1:r===`document`?t.documents+=1:t.context+=1}return t}function Kve(e){return e.memory+e.documents+e.context>0}function k6(e){let t=[];return e.memory>0&&t.push(e.memory===1?Nt():Ge({count:e.memory})),e.documents>0&&t.push(e.documents===1?ur():Un({count:e.documents})),e.context>0&&t.push(e.context===1?Kc():$n({count:e.context})),t.join(` · `)}function A6(e){return e.title??e.file_name??e.id??e.type??si()}function j6(e){return e.title&&e.file_name?e.file_name:void 0}function qve(e){return e.file_name??A6(e)}function M6(e){let t=[];return e.type&&A6(e)!==e.type&&t.push(e.type),e.date&&t.push(e.date),e.collection&&t.push(e.collection),typeof e.score==`number`&&t.push(Ne({score:e.score.toFixed(2)})),t}function N6(e,t){let n=[];return e.forEach((e,r)=>{e.group===t&&e.items.forEach((t,i)=>{n.push({key:`${e.pluginId}|${e.group}|${t.id??t.file_name??`?`}|${r}.${i}`,group:e.group,pluginId:e.pluginId,source:e.source,item:t})})}),n.sort((e,t)=>(t.item.score??0)-(e.item.score??0))}function P6(e,t){let n=t.trim().toLowerCase();return n===``?!0:[L6(e),e.item.file_name??``,e.item.text??``,...M6(e.item)].join(` `).toLowerCase().includes(n)}function F6(e){return D6(e.item,e.group)===`document`}function I6(e){return D6(e.item,e.group)===`context`}function L6(e){return I6(e)?Se():A6(e.item)}var R6=(0,B.createContext)(null),Jve=[];function Yve(){let e=Yk(e=>e.metadata?.custom?.provenanceParts??Jve),t=Yk(e=>e.metadata?.custom?.messageId),n=Yk(e=>e.metadata?.custom?.attachedDocCount??0),r=(0,B.useContext)(R6),i=O6(e);if(e.length===0||!Kve(i))return null;let a=r?.activeMessageId===t&&t!==void 0,o=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`oc-actrow__counts`,children:k6(i)}),n>0?(0,V.jsxs)(`span`,{className:`oc-actrow__badge`,title:Us({count:n}),children:[(0,V.jsx)(CS,{size:12,"aria-hidden":!0}),n]}):null]});return(0,V.jsx)(dH,{icon:(0,V.jsx)(DS,{size:14}),label:xn(),trailing:o,active:a,ariaExpanded:a,ariaHasPopup:!0,ariaLabel:ue(),onClick:()=>t&&r?.openFor(t)})}function z6({messageId:e,onClose:t}){let n=R(L.messages.getProvenanceParts,{messageId:e}),r=(0,B.useMemo)(()=>n??[],[n]),i=R(L.agents.documentaryAvailable,{}),a=R(L.documentAttachments.getDocumentAttachments,{sourceMessageId:e}),o=p(L.documentAttachments.attachDocuments),s=uH(),c=(0,B.useMemo)(()=>{let e=new Map;for(let t of a??[])e.set(t.entryKey,t);return e},[a]),l=(a??[]).some(e=>e.status===`pending`),[u,d]=(0,B.useState)(``),[f,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(!1),[y,b]=(0,B.useState)(new Set);(0,B.useEffect)(()=>{d(``),m(!1),g(!1),v(!1),b(new Set)},[e]);let x=(0,B.useMemo)(()=>N6(r,`documents`).filter(e=>F6(e)&&P6(e,u)),[r,u]),S=(0,B.useMemo)(()=>N6(r,`documents`).filter(e=>I6(e)&&P6(e,u)),[r,u]),w=(0,B.useMemo)(()=>N6(r,`memory`).filter(e=>P6(e,u)),[r,u]),T=O6(r),E=e=>b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),D=(e,t)=>b(n=>{let r=new Set(n);for(let n of e)t?r.add(n):r.delete(n);return r}),O=(0,B.useMemo)(()=>N6(r,`documents`).filter(e=>F6(e)&&y.has(e.key)),[r,y]),k=i!=null&&O.length>0&&!l;async function A(){if(k)try{await o({sourceMessageId:e,items:O.map(e=>({entryKey:e.key,reference:qve(e.item)}))}),s.success(Os())}catch(e){let t=cH(e);t.includes(`fetch_in_flight`)?s.error(su()):t.includes(`no_documentary_agent`)?s.error(gl()):s.error(ts(),e)}}let j=n===void 0;return(0,V.jsxs)(`div`,{className:`oc-sources-panel`,children:[(0,V.jsxs)(`div`,{className:`oc-sources-panel__head`,children:[(0,V.jsxs)(`div`,{className:`oc-sources-panel__heading`,children:[(0,V.jsx)(`h2`,{className:`oc-sources-panel__title`,children:rf()}),(0,V.jsx)(`p`,{className:`oc-sources-panel__sub`,children:k6(T)})]}),(0,V.jsx)(`button`,{type:`button`,className:`oc-iconbtn`,onClick:t,"aria-label":co(),title:co(),children:(0,V.jsx)(mp,{size:16,"aria-hidden":!0})})]}),(0,V.jsxs)(`div`,{className:`oc-sources-panel__search`,children:[(0,V.jsx)(WS,{size:15,"aria-hidden":!0}),(0,V.jsx)(QB,{value:u,onChange:e=>d(e.target.value),placeholder:qr(),"aria-label":qr()})]}),(0,V.jsx)(`div`,{className:`oc-sources-panel__body`,children:j?(0,V.jsx)(`p`,{className:`oc-sources-panel__empty`,children:(0,V.jsx)(MS,{size:14,className:`oc-iconbtn__spin`,"aria-hidden":!0})}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(B6,{icon:(0,V.jsx)(DS,{size:14,"aria-hidden":!0}),label:Lc(),count:x.length,expanded:f,onToggle:()=>m(e=>!e),entries:x,selectable:!0,selected:y,onToggle1:E,onToggleAll:e=>D(x.map(e=>e.key),e),attachmentByKey:c}),(0,V.jsx)(B6,{icon:(0,V.jsx)(ire,{size:14,"aria-hidden":!0}),label:C(),count:S.length,expanded:h,onToggle:()=>g(e=>!e),entries:S,selectable:!1,selected:y,onToggle1:E,onToggleAll:e=>D(S.map(e=>e.key),e),attachmentByKey:c}),(0,V.jsx)(B6,{icon:(0,V.jsx)(pS,{size:14,"aria-hidden":!0}),label:Nn(),count:w.length,expanded:_,onToggle:()=>v(e=>!e),entries:w,selectable:!1,selected:y,onToggle1:E,onToggleAll:e=>D(w.map(e=>e.key),e),attachmentByKey:c}),x.length===0&&S.length===0&&w.length===0?(0,V.jsx)(`p`,{className:`oc-sources-panel__empty`,children:gf()}):null]})}),O.length>0?(0,V.jsxs)(`div`,{className:`oc-sources-panel__actions`,children:[(0,V.jsxs)(`div`,{className:`oc-sources-panel__actrow`,children:[(0,V.jsx)(`span`,{className:`oc-sources-panel__selcount`,children:jf({count:O.length})}),(0,V.jsxs)(Ep,{variant:`outline`,size:`sm`,disabled:!k,onClick:()=>void A(),children:[l?(0,V.jsx)(MS,{size:14,className:`oc-iconbtn__spin`,"aria-hidden":!0}):(0,V.jsx)(dre,{size:14,"aria-hidden":!0}),Vd()]})]}),(0,V.jsx)(`p`,{className:`oc-sources-panel__acthint`,children:i==null?gl():l?su():Ka()})]}):null]})}function B6({icon:e,label:t,count:n,expanded:r,onToggle:i,entries:a,selectable:o,selected:s,onToggle1:c,onToggleAll:l,attachmentByKey:u}){if(n===0)return null;let d=a.every(e=>s.has(e.key));return(0,V.jsxs)(`section`,{className:`oc-srcsec${r?` is-open`:``}`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`oc-srcsec__head`,"aria-expanded":r,onClick:i,children:[r?(0,V.jsx)(up,{size:14,"aria-hidden":!0}):(0,V.jsx)(gS,{size:14,"aria-hidden":!0}),e,(0,V.jsx)(`span`,{className:`oc-srcsec__label`,children:t}),(0,V.jsx)(`span`,{className:`oc-srcsec__count`,children:n})]}),r?(0,V.jsxs)(`div`,{className:`oc-srcsec__body`,children:[o?(0,V.jsxs)(`label`,{className:`oc-srcsec__all`,children:[(0,V.jsx)(E6,{checked:d,onCheckedChange:e=>l(e===!0)}),(0,V.jsx)(`span`,{children:wo()})]}):null,a.map(e=>(0,V.jsx)(Xve,{entry:e,selectable:o,selected:s.has(e.key),onToggle:()=>c(e.key),attachment:u.get(e.key)},e.key))]}):null]})}function Xve({entry:e,selectable:t,selected:n,onToggle:r,attachment:i}){let[a,o]=(0,B.useState)(!1),s=(0,B.useRef)(null),[c,l]=(0,B.useState)(!1),{item:u}=e;(0,B.useEffect)(()=>{let e=s.current;if(!e)return;let t=()=>l(e.scrollHeight>e.clientHeight+1);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[u.text]);let d=M6(u),f=typeof u.score==`number`?Math.max(0,Math.min(1,u.score)):null,p=F6(e);return(0,V.jsxs)(`div`,{className:`oc-srccard${t&&n?` is-selected`:``}`,children:[t?(0,V.jsx)(`label`,{className:`oc-srccard__pick`,children:(0,V.jsx)(E6,{checked:n,onCheckedChange:r})}):null,(0,V.jsxs)(`div`,{className:`oc-srccard__body`,children:[(0,V.jsx)(`div`,{className:`oc-srccard__title`,children:L6(e)}),p&&j6(e.item)?(0,V.jsx)(`div`,{className:`oc-srccard__subid`,title:j6(e.item),children:j6(e.item)}):null,d.length>0||f!==null?(0,V.jsxs)(`div`,{className:`oc-srccard__meta`,children:[d.map(e=>(0,V.jsx)(`span`,{className:`oc-srccard__chip`,children:e},e)),f===null?null:(0,V.jsx)(`span`,{className:`oc-srccard__relev`,title:Ne({score:f.toFixed(2)}),children:(0,V.jsx)(`span`,{className:`oc-srccard__relev-track`,"aria-hidden":!0,children:(0,V.jsx)(`span`,{className:`oc-srccard__relev-fill`,style:{width:`${Math.round(f*100)}%`}})})})]}):null,u.text?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`blockquote`,{ref:s,className:`oc-srccard__excerpt${a?` is-full`:``}`,children:u.text}),c||a?(0,V.jsx)(`button`,{type:`button`,className:`oc-srccard__more`,onClick:()=>o(e=>!e),children:a?Kl():Qu()}):null]}):null,p?(0,V.jsx)(Zve,{attachment:i}):null]})]})}function Zve({attachment:e}){if(e?.status===`ready`&&e.url){let t=e.filename??tl();return(0,V.jsxs)(`a`,{className:`oc-srccard__origin oc-srccard__origin--ready`,href:e.url,download:e.filename??void 0,target:`_blank`,rel:`noreferrer`,title:tl(),children:[(0,V.jsx)(CS,{size:13,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-srccard__origin-name`,children:t})]})}return e?.status===`pending`?(0,V.jsxs)(`div`,{className:`oc-srccard__origin oc-srccard__origin--pending`,children:[(0,V.jsx)(MS,{size:13,"aria-hidden":!0}),Dd()]}):e?.status===`not_found`||e?.status===`failed`?(0,V.jsxs)(`div`,{className:`oc-srccard__origin oc-srccard__origin--missing`,"aria-disabled":!0,children:[(0,V.jsx)(mp,{size:13,"aria-hidden":!0}),Bo()]}):(0,V.jsxs)(`div`,{className:`oc-srccard__origin`,"aria-disabled":!0,children:[(0,V.jsx)(CS,{size:13,"aria-hidden":!0}),ac()]})}var Qve=`oc.sidebar.width`,V6=`oc.sidebar.collapsed`,H6=200,U6=520,$ve=260,W6=`(max-width: 767px)`;function G6(){let[e,t]=(0,B.useState)(()=>typeof window<`u`&&window.matchMedia(W6).matches);return(0,B.useEffect)(()=>{let e=window.matchMedia(W6),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function K6(e){let{storageKey:t,defaultWidth:n,min:r,max:i,edge:a,maxViewportFraction:o}=e,s=(0,B.useCallback)(e=>{let t=o===void 0?1/0:Math.round(window.innerWidth*o);return Math.min(Math.max(r,Math.min(i,t)),Math.max(r,e))},[r,i,o]),[c,l]=(0,B.useState)(()=>s(Number(localStorage.getItem(t))||n));(0,B.useEffect)(()=>{localStorage.setItem(t,String(c))},[t,c]),(0,B.useEffect)(()=>{if(o===void 0)return;let e=()=>l(e=>s(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[o,s]);let u=(0,B.useRef)(!1),d=(0,B.useRef)(null);return{width:c,startResize:(0,B.useCallback)(e=>{e.preventDefault(),u.current=!0;let t=e.clientX,n=c,r=a===`left`?1:-1,i=n,o=0,f=()=>{o=0;let e=d.current;e&&(e.style.width=`${i}px`,e.style.flex=`0 0 ${i}px`)},p=e=>{u.current&&(i=s(n+r*(e.clientX-t)),d.current?o===0&&(o=requestAnimationFrame(f)):l(i))},m=()=>{u.current=!1,o!==0&&cancelAnimationFrame(o);let e=d.current;e&&(e.style.width=`${i}px`,e.style.flex=`0 0 ${i}px`),window.removeEventListener(`pointermove`,p),window.removeEventListener(`pointerup`,m),document.body.style.cursor=``,document.body.style.userSelect=``,l(i)};window.addEventListener(`pointermove`,p),window.addEventListener(`pointerup`,m),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[c,a,s]),setWidth:l,columnRef:d}}function q6(){let{width:e,startResize:t,columnRef:n}=K6({storageKey:Qve,defaultWidth:$ve,min:H6,max:U6,edge:`left`}),[r,i]=(0,B.useState)(()=>localStorage.getItem(V6)===`1`),a=G6();return(0,B.useEffect)(()=>{localStorage.setItem(V6,r?`1`:`0`)},[r]),(0,B.useEffect)(()=>{a&&i(!0)},[a]),{width:e,columnRef:n,collapsed:r,toggleCollapsed:(0,B.useCallback)(()=>i(e=>!e),[]),collapse:(0,B.useCallback)(()=>i(!0),[]),startResize:t,isMobile:a,MIN_WIDTH:H6,MAX_WIDTH:U6}}function J6({...e}){return(0,V.jsx)(bp,{"data-slot":`sheet`,...e})}function eye({...e}){return(0,V.jsx)(hp,{"data-slot":`sheet-portal`,...e})}function tye({className:e,...t}){return(0,V.jsx)(_p,{"data-slot":`sheet-overlay`,className:Al(`fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function Y6({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,V.jsxs)(eye,{children:[(0,V.jsx)(tye,{}),(0,V.jsxs)(yp,{"data-slot":`sheet-content`,"data-side":n,className:Al(`fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10`,e),...i,children:[t,r&&(0,V.jsx)(Cp,{"data-slot":`sheet-close`,asChild:!0,children:(0,V.jsxs)(Ep,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,V.jsx)(mp,{}),(0,V.jsx)(`span`,{className:`sr-only`,children:Gf()})]})})]})]})}function X6({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`sheet-header`,className:Al(`flex flex-col gap-0.5 p-4`,e),...t})}function Z6({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`sheet-footer`,className:Al(`mt-auto flex flex-col gap-2 p-4`,e),...t})}function Q6({className:e,...t}){return(0,V.jsx)(Sp,{"data-slot":`sheet-title`,className:Al(`font-heading text-base font-medium text-foreground`,e),...t})}function $6({className:e,...t}){return(0,V.jsx)(xp,{"data-slot":`sheet-description`,className:Al(`text-sm text-muted-foreground`,e),...t})}var nye=new Set(`txt.md.markdown.csv.tsv.log.json.yaml.yml.xml.html.css.js.ts.tsx.jsx.py.rb.go.rs.java.c.h.cpp.hpp.sh.bash.sql.toml.ini.env`.split(`.`)),rye=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`avif`,`bmp`]),iye=new Set([`application/vnd.openxmlformats-officedocument.presentationml.presentation`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.ms-powerpoint`,`application/msword`,`application/vnd.ms-excel`,`application/vnd.oasis.opendocument.text`,`application/vnd.oasis.opendocument.presentation`,`application/vnd.oasis.opendocument.spreadsheet`,`application/rtf`]),aye=new Set([`pptx`,`ppt`,`docx`,`doc`,`xlsx`,`xls`,`odt`,`odp`,`ods`,`rtf`]);function e8(e,t){let n=(e??``).toLowerCase();if(iye.has(n))return!0;let r=t8(t);return r!==null&&aye.has(r)}function t8(e){if(!e)return null;let t=e.lastIndexOf(`.`);return t<=0||t===e.length-1?null:e.slice(t+1).toLowerCase()}function n8(e,t){let n=(e??``).split(`;`)[0].trim().toLowerCase(),r=t8(t);if(n===`application/pdf`)return`pdf`;if(n.startsWith(`image/`))return`image`;if(n.startsWith(`video/`))return`video`;if(n.startsWith(`audio/`))return`audio`;if(n===`text/markdown`)return`markdown`;if(n===`text/csv`||n===`text/tab-separated-values`)return`csv`;if(n===`application/json`||n.endsWith(`+json`))return`json`;if(n===`text/x-log`)return`log`;if(n===``||n===`text/plain`||n===`application/octet-stream`||n===`binary/octet-stream`){if(r===`md`||r===`markdown`)return`markdown`;if(r===`csv`||r===`tsv`)return`csv`;if(r===`json`)return`json`;if(r===`log`)return`log`}return n.startsWith(`text/`)||n===`application/json`||n===`application/xml`||n===`application/x-yaml`?`text`:r===`pdf`?`pdf`:r!==null&&rye.has(r)?`image`:r!==null&&nye.has(r)?`text`:`none`}var oye=[`fit`,.5,.75,1,1.5,2];function r8(e,t){return Number.isFinite(e)?Math.min(Math.max(1,Math.floor(e)),Math.max(1,Math.floor(t))):1}var i8=512*1024,sye=1e3,cye=5e3;function lye(e,t){if((e??``).split(`;`)[0].trim().toLowerCase()===`text/tab-separated-values`||t8(t)===`tsv`)return` `}function uye(e){let t=`,`,n=0;for(let r of[`,`,`;`,` `]){let i=a8(e,r).length;i>n&&(t=r,n=i)}return t}function a8(e,t){let n=[],r=``,i=!1;for(let a=0;a<e.length;a++){let o=e[a];i?o===`"`?e[a+1]===`"`?(r+=`"`,a++):i=!1:r+=o:o===`"`?i=!0:o===t?(n.push(r),r=``):r+=o}return n.push(r),n}function dye(e,t=sye,n){let r=[],i=``,a=!1,o=e.replace(/\r\n/g,`
224
224
  `).replace(/\r/g,`
225
225
  `);for(let e of o)e===`"`&&(a=!a),e===`
226
- `&&!a?(r.push(i),i=``):i+=e;i!==``&&r.push(i);let s=r.findIndex(e=>e.trim()!==``);if(s===-1)return{header:[],rows:[],totalRows:0,truncatedRows:!1,delimiter:`,`};let c=n??uye(r[s]),l=a8(r[s],c),u=r.slice(s+1);return{header:l,rows:u.slice(0,t).map(e=>a8(e,c)),totalRows:u.length,truncatedRows:u.length>t,delimiter:c}}function fye(e,t){let n=e.trim(),r=t.trim();if(/^-?\d+$/.test(n)&&/^-?\d+$/.test(r)){let e=BigInt(n),t=BigInt(r);return e<t?-1:+(e>t)}let i=Number(e),a=Number(t);return n!==``&&r!==``&&!Number.isNaN(i)&&!Number.isNaN(a)?i-a:e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function pye(e){return/\b(error|err|fatal|critical|panic)\b/i.test(e)?`error`:/\b(warn|warning)\b/i.test(e)?`warn`:/\b(info|notice)\b/i.test(e)?`info`:/\b(debug|trace|verbose)\b/i.test(e)?`debug`:`plain`}var o8=60;function s8({url:e,filename:t}){let[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(1),[c,l]=(0,B.useState)(`fit`);if((0,B.useEffect)(()=>{let t=!1,n=null;return r(null),a(!1),s(1),(async()=>{try{let i=await g4(()=>import(`./pdf-Bx7jp7ID.js`),[]);i.GlobalWorkerOptions.workerSrc=new URL(`/assets/pdf.worker.min-DEtVeC4l.mjs`,``+import.meta.url).toString();let a=i.getDocument({url:e}),o=await a.promise;if(t){a.destroy().catch(()=>{});return}n=a,r(o)}catch(e){console.error(`[docviewer] pdf load failed:`,e?.message??e),t||a(!0)}})(),()=>{t=!0,n&&n.destroy().catch(()=>{})}},[e]),i)return(0,V.jsxs)(`div`,{className:`oc-docviewer__fallback`,children:[(0,V.jsx)(`p`,{children:Rs()}),(0,V.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`oc-docviewer__fallbacklink`,children:$s()})]});if(n===null)return(0,V.jsx)(`div`,{className:`oc-docviewer__loading`,children:_u()});let u=n.numPages,d=r8(o,u);return(0,V.jsxs)(`div`,{className:`oc-docviewer__pdf`,children:[(0,V.jsxs)(`div`,{className:`oc-docviewer__toolbar`,children:[(0,V.jsx)(`button`,{type:`button`,className:`oc-docviewer__navbtn`,onClick:()=>s(e=>r8(e-1,u)),disabled:d<=1,"aria-label":tu(),children:(0,V.jsx)(hS,{size:15})}),(0,V.jsxs)(`span`,{className:`oc-docviewer__pageinfo`,children:[d,` / `,u]}),(0,V.jsx)(`button`,{type:`button`,className:`oc-docviewer__navbtn`,onClick:()=>s(e=>r8(e+1,u)),disabled:d>=u,"aria-label":vo(),children:(0,V.jsx)(gS,{size:15})}),(0,V.jsx)(`select`,{className:`oc-docviewer__zoom`,value:String(c),onChange:e=>{let t=e.target.value;l(t===`fit`?`fit`:Number(t))},"aria-label":Tl(),children:oye.map(e=>(0,V.jsx)(`option`,{value:String(e),children:e===`fit`?hc():`${Math.round(e*100)}%`},String(e)))})]}),(0,V.jsxs)(`div`,{className:`oc-docviewer__pdfbody`,children:[u>1?(0,V.jsxs)(`div`,{className:`oc-docviewer__rail`,"aria-label":sd(),children:[Array.from({length:Math.min(u,o8)},(e,t)=>(0,V.jsx)(hye,{doc:n,page:t+1,active:t+1===d,onClick:()=>s(t+1)},t+1)),u>o8?(0,V.jsxs)(`span`,{className:`oc-docviewer__railmore`,children:[`+`,u-o8]}):null]}):null,(0,V.jsx)(mye,{doc:n,page:d,zoom:c,filename:t})]})]})}function mye({doc:e,page:t,zoom:n,filename:r}){let i=(0,B.useRef)(null),a=(0,B.useRef)(null),[o,s]=(0,B.useState)(0);return(0,B.useEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width??0;s(e=>Math.abs(e-t)>1?t:e)});return t.observe(e),()=>t.disconnect()},[]),(0,B.useEffect)(()=>{let r=!1,i=null;return(async()=>{try{let s=await e.getPage(t),c=a.current;if(r||!c)return;let l=s.getViewport({scale:1}),u=n===`fit`?Math.max(.1,(o-16)/l.width):n,d=window.devicePixelRatio||1,f=s.getViewport({scale:u*d});c.width=Math.floor(f.width),c.height=Math.floor(f.height),c.style.width=`${Math.floor(f.width/d)}px`,c.style.height=`${Math.floor(f.height/d)}px`;let p=s.render({canvas:c,viewport:f});i=p,await p.promise}catch(e){e?.name!==`RenderingCancelledException`&&console.error(`[docviewer] page render failed:`,e?.message??e)}})(),()=>{r=!0,i?.cancel()}},[e,t,n,o]),(0,V.jsx)(`div`,{ref:i,className:`oc-docviewer__main`,children:(0,V.jsx)(`canvas`,{ref:a,className:`oc-docviewer__canvas`,"aria-label":r})})}function hye({doc:e,page:t,active:n,onClick:r}){let i=(0,B.useRef)(null);return(0,B.useEffect)(()=>{let n=!1,r=null;return(async()=>{try{let a=await e.getPage(t),o=i.current;if(n||!o)return;let s=104/a.getViewport({scale:1}).width,c=a.getViewport({scale:s});o.width=Math.floor(c.width),o.height=Math.floor(c.height);let l=a.render({canvas:o,viewport:c});r=l,await l.promise}catch(e){e?.name!==`RenderingCancelledException`&&console.error(`[docviewer] thumbnail render failed:`,e?.message??e)}})(),()=>{n=!0,r?.cancel()}},[e,t]),(0,V.jsxs)(`button`,{type:`button`,className:`oc-docviewer__thumb${n?` is-active`:``}`,onClick:r,"aria-label":Ac({page:t}),"aria-current":n?`true`:void 0,children:[(0,V.jsx)(`canvas`,{ref:i,className:`oc-docviewer__thumbcanvas`}),(0,V.jsx)(`span`,{className:`oc-docviewer__thumbnum`,children:t})]})}var c8=(0,B.createContext)({activeDoc:null,openFor:()=>{},close:()=>{}});function l8(){return(0,B.useContext)(c8)}function u8({doc:e,chatId:t,onClose:n}){let r=n8(e.mimeType,e.filename),i=r===`none`&&e.sourceStorageId!==void 0,a=l8(),o=R(L.documentDrafts.latestDeliveredFile,t===null?`skip`:{chatId:t,filename:e.filename,...e.storageId===void 0?{}:{currentStorageId:e.storageId}}),s=o!=null&&(e.storageId===void 0?o.url!==e.url:o.storageId!==e.storageId)?o:null;return(0,V.jsxs)(`div`,{className:`oc-docviewer`,children:[(0,V.jsxs)(`header`,{className:`oc-docviewer__header`,children:[(0,V.jsx)(DS,{size:15,"aria-hidden":!0,className:`oc-docviewer__icon`}),(0,V.jsx)(`span`,{className:`oc-docviewer__name`,title:e.filename,children:e.filename}),(0,V.jsx)(`a`,{className:`oc-docviewer__action`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:$s(),"aria-label":$s(),children:(0,V.jsx)(TS,{size:14})}),(0,V.jsx)(`a`,{className:`oc-docviewer__action`,href:e.url,download:e.filename,title:Uc(),"aria-label":Uc(),children:(0,V.jsx)(CS,{size:14})}),(0,V.jsx)(Ep,{type:`button`,size:`icon-sm`,variant:`ghost`,onClick:n,"aria-label":Bn(),children:(0,V.jsx)(mp,{size:15})})]}),(0,V.jsxs)(`div`,{className:`oc-docviewer__body`,children:[s===null?null:(0,V.jsxs)(`div`,{className:`oc-docviewer__newversion`,role:`status`,children:[(0,V.jsx)(`span`,{children:Hn()}),(0,V.jsx)(Ep,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>a.openFor({url:s.url,filename:e.filename,mimeType:s.mimeType||null,storageId:s.storageId,sourceStorageId:e8(s.mimeType,e.filename)?s.storageId:void 0}),children:Mn()})]}),r===`pdf`?(0,V.jsx)(s8,{url:e.url,filename:e.filename}):r===`image`?(0,V.jsx)(`div`,{className:`oc-docviewer__imagewrap`,children:(0,V.jsx)(`img`,{src:e.url,alt:e.filename,className:`oc-docviewer__image`})}):r===`video`?(0,V.jsx)(`video`,{controls:!0,preload:`metadata`,src:e.url,className:`oc-docviewer__video`}):r===`audio`?(0,V.jsx)(`div`,{className:`oc-docviewer__audiowrap`,children:(0,V.jsx)(`audio`,{controls:!0,preload:`metadata`,src:e.url,className:`oc-docviewer__audio`})}):r===`text`?(0,V.jsx)(f8,{url:e.url,chatId:t,filename:e.filename,mimeType:e.mimeType,storageId:e.storageId??null},e.url):r===`markdown`||r===`csv`||r===`log`||r===`json`?(0,V.jsx)(f8,{url:e.url,chatId:t,filename:e.filename,mimeType:e.mimeType,storageId:e.storageId??null,rich:r,csvDelimiter:r===`csv`?lye(e.mimeType,e.filename):void 0},e.url):i?(0,V.jsx)(gye,{sourceStorageId:e.sourceStorageId,downloadUrl:e.url,filename:e.filename}):(0,V.jsxs)(`div`,{className:`oc-docviewer__fallback`,children:[(0,V.jsx)(`p`,{children:ds()}),(0,V.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`oc-docviewer__fallbacklink`,children:Uc()})]})]})]})}function gye({sourceStorageId:e,downloadUrl:t,filename:n}){let r=R(L.fileRenditions.getRendition,{sourceStorageId:e}),i=p(L.fileRenditions.requestRendition),a=(0,B.useRef)(null);return(0,B.useEffect)(()=>{a.current=null},[e]),(0,B.useEffect)(()=>{r?.status===`pending`&&a.current!==e&&(a.current=e,i({sourceStorageId:e}).catch(e=>{console.error(`[docviewer] rendition request failed:`,e)}))},[r?.status,e,i]),r===void 0?(0,V.jsx)(`div`,{className:`oc-docviewer__loading`,children:_u()}):r.status===`ready`?(0,V.jsx)(s8,{url:r.pdfUrl,filename:r.filename}):r.status===`pending`?(0,V.jsxs)(`div`,{className:`oc-docviewer__preparing`,children:[(0,V.jsx)(`span`,{className:`oc-docviewer__spinner`,"aria-hidden":!0}),(0,V.jsx)(`p`,{children:Ld()}),(0,V.jsx)(`a`,{href:t,download:n,className:`oc-docviewer__fallbacklink`,children:Uc()})]}):(0,V.jsxs)(`div`,{className:`oc-docviewer__fallback`,children:[(0,V.jsx)(`p`,{children:r.status===`unconfigured`?ds():dl()}),(0,V.jsx)(`a`,{href:t,download:n,className:`oc-docviewer__fallbacklink`,children:Uc()})]})}function _ye(e){switch(e){case`markdown`:return or();case`csv`:return ke();case`log`:return Be();case`json`:return mi()}}var d8=e=>`oc.docviewer.raw.${e}`;function f8({url:e,chatId:t,filename:n,mimeType:r,storageId:i,rich:a,csvDelimiter:o}){let[s,c]=(0,B.useState)({phase:`loading`}),[l,u]=(0,B.useState)(()=>a?localStorage.getItem(d8(a))===`1`:!1),d=e=>{u(e),a&&localStorage.setItem(d8(a),e?`1`:`0`)},[f,p]=(0,B.useState)(!1),m=R(L.documentDrafts.getDraft,t===null?`skip`:{chatId:t,filename:n}),h=t!==null&&s.phase===`ready`&&!s.truncated&&m!==void 0;if((0,B.useEffect)(()=>{let t=!1;return c({phase:`loading`}),(async()=>{try{let n=await fetch(e);if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.blob(),i=r.size>i8,a=await(i?r.slice(0,i8):r).text();t||c({phase:`ready`,text:a,truncated:i})}catch(e){console.error(`[docviewer] text fetch failed:`,e?.message??e),t||c({phase:`error`})}})(),()=>{t=!0}},[e]),s.phase===`loading`)return(0,V.jsx)(`div`,{className:`oc-docviewer__loading`,children:_u()});if(s.phase===`error`)return(0,V.jsxs)(`div`,{className:`oc-docviewer__fallback`,children:[(0,V.jsx)(`p`,{children:Rs()}),(0,V.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`oc-docviewer__fallbacklink`,children:$s()})]});let g=a!==void 0&&!l,_=s.truncated?(0,V.jsx)(`p`,{className:`oc-docviewer__truncated`,children:Yo()}):null,v=m?.text??s.text,y=m==null?null:(0,V.jsx)(vye,{chatId:t,filename:n,diverged:m.sourceStorageId!==null&&i!==null&&m.sourceStorageId!==i}),b=f?(0,V.jsx)(yye,{chatId:t,filename:n,mimeType:r,sourceStorageId:i,initialText:v,hasDraft:m!=null,onExit:()=>p(!1)}):g&&a===`markdown`?(0,V.jsx)(`div`,{className:`oc-docviewer__mdwrap`,children:(0,V.jsx)(Y3,{text:v})}):g&&a===`csv`?(0,V.jsx)(bye,{text:v,textTruncated:s.truncated,delimiter:o}):g&&a===`log`?(0,V.jsx)(xye,{text:v,textTruncated:s.truncated}):g&&a===`json`?(0,V.jsx)(Sye,{text:v}):(0,V.jsx)(`pre`,{className:`oc-docviewer__text`,children:v});return a===void 0&&!h?(0,V.jsxs)(`div`,{className:`oc-docviewer__textwrap`,children:[_,y,b]}):(0,V.jsxs)(`div`,{className:`oc-docviewer__textwrap oc-docviewer__textwrap--bar`,children:[(0,V.jsxs)(`div`,{className:`oc-docviewer__mdbar`,role:`group`,"aria-label":k(),children:[a===void 0?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ep,{type:`button`,size:`sm`,variant:g&&!f?`secondary`:`ghost`,"aria-pressed":g&&!f,onClick:()=>{p(!1),d(!1)},children:_ye(a)}),(0,V.jsx)(Ep,{type:`button`,size:`sm`,variant:l&&!f?`secondary`:`ghost`,"aria-pressed":l&&!f,onClick:()=>{p(!1),d(!0)},children:Qc()})]}),h?(0,V.jsxs)(Ep,{type:`button`,size:`sm`,variant:f?`secondary`:`ghost`,"aria-pressed":f,onClick:()=>p(e=>!e),className:`oc-docviewer__editbtn`,children:[(0,V.jsx)(BS,{size:13,"aria-hidden":!0}),rt(),m==null?null:(0,V.jsx)(`span`,{className:`oc-docviewer__draftdot`,"aria-hidden":!0})]}):null]}),f?b:(0,V.jsx)(`div`,{className:`oc-docviewer__textscroll`,children:(0,V.jsxs)(`div`,{className:`oc-docviewer__scrollpad`,children:[_,y,b]})})]})}function vye({chatId:e,filename:t,diverged:n}){let r=p(L.documentDrafts.deleteDraft),i=uH();return(0,V.jsxs)(`p`,{className:`oc-docviewer__draftnote`,children:[n?lr():We(),(0,V.jsx)(`button`,{type:`button`,className:`oc-docviewer__draftnote-discard`,onClick:()=>void r({chatId:e,filename:t}).then(e=>{e.applied===!1&&i.error(Qn())}).catch(()=>i.error(Gc())),children:ji()})]})}function yye({chatId:e,filename:t,mimeType:n,sourceStorageId:r,initialText:i,hasDraft:a,onExit:o}){let s=p(L.documentDrafts.saveDraft),c=p(L.documentDrafts.deleteDraft),l=(0,B.useContext)(w6),u=uH(),d=`oc.docdraft.fallback.${e}.${t}`,[f,m]=(0,B.useState)(()=>{try{let e=localStorage.getItem(d);if(e!==null)return e}catch{}return i}),[h,g]=(0,B.useState)(`idle`),_=(0,B.useRef)(0),v=(0,B.useRef)(f);v.current=f;let y=(0,B.useRef)(!1),b=(0,B.useRef)(!1),x=(0,B.useCallback)(n=>{g(`saving`),s({chatId:e,filename:t,text:n,...r!==null&&(b.current||!a)?{sourceStorageId:r}:{}}).then(e=>{if(e.applied===!1){u.error(Qn()),g(`idle`);return}g(`saved`)}).catch(e=>{console.error(`[docviewer] draft save failed:`,e),u.error(_t()),g(`idle`)})},[s,e,t,r,a,u]),C=e=>{b.current=!0,m(e),window.clearTimeout(_.current),_.current=window.setTimeout(()=>x(e),800)};return(0,B.useEffect)(()=>{try{localStorage.getItem(d)!==null&&(b.current=!0,s({chatId:e,filename:t,text:v.current,...r===null?{}:{sourceStorageId:r}}).then(()=>localStorage.removeItem(d)))}catch{}let n=()=>{if(!(!b.current||y.current))try{localStorage.setItem(d,v.current)}catch{}};return window.addEventListener(`pagehide`,n),()=>{if(window.removeEventListener(`pagehide`,n),window.clearTimeout(_.current),!y.current&&b.current){try{localStorage.setItem(d,v.current)}catch{}s({chatId:e,filename:t,text:v.current,...r===null?{}:{sourceStorageId:r}}).then(()=>{try{localStorage.removeItem(d)}catch{}}).catch(()=>{})}}},[]),(0,V.jsxs)(`div`,{className:`oc-docviewer__editor`,children:[(0,V.jsx)(`textarea`,{className:`oc-docviewer__editarea`,value:f,onChange:e=>C(e.target.value),spellCheck:!1,"aria-label":rt()}),(0,V.jsxs)(`div`,{className:`oc-docviewer__editbar`,children:[(0,V.jsx)(`span`,{className:`oc-docviewer__savestate`,role:`status`,children:h===`saving`?qi():h===`saved`?vi():`\xA0`}),(0,V.jsx)(Ep,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{y.current=!0,window.clearTimeout(_.current);try{localStorage.removeItem(d)}catch{}c({chatId:e,filename:t}).then(e=>{if(e.applied===!1){y.current=!1,u.error(Qn());return}o()}).catch(e=>{console.error(`[docviewer] draft discard failed:`,e),y.current=!1,u.error(Gc())})},children:ji()}),(0,V.jsx)(Ep,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>{let e=l?.current??null;if(e===null){u.error(Mt());return}if(window.clearTimeout(_.current),x(f),e.canAttach){let r=(n??`text/plain`).split(`;`)[0].trim(),i=new File([f],t,{type:`${r}; charset=utf-8`});e.attachFile(i).catch(e=>{console.error(`[docviewer] attach failed:`,e),u.error(bn())})}else{if(f.length>8e3){u.error(S());return}e.insertText(Hve(t,f,Ic()))}},children:j()})]})]})}function bye({text:e,textTruncated:t,delimiter:n}){let r=(0,B.useMemo)(()=>dye(e,void 0,n),[e,n]),[i,a]=(0,B.useState)(null),o=(0,B.useMemo)(()=>i?[...r.rows].sort((e,t)=>fye(e[i.col]??``,t[i.col]??``)*i.dir):r.rows,[r.rows,i]);if(r.header.length===0)return(0,V.jsx)(`pre`,{className:`oc-docviewer__text`,children:e});let s=r.header.slice(0,100),c=r.header.length>s.length;return(0,V.jsxs)(`div`,{className:`oc-docviewer__csvwrap`,children:[r.truncatedRows?(0,V.jsx)(`p`,{className:`oc-docviewer__truncated`,children:t?ve({shown:r.rows.length}):df({shown:r.rows.length,total:r.totalRows})}):null,c?(0,V.jsx)(`p`,{className:`oc-docviewer__truncated`,children:ni({shown:s.length,total:r.header.length})}):null,(0,V.jsxs)(`table`,{className:`oc-docviewer__csv`,children:[(0,V.jsx)(`thead`,{children:(0,V.jsx)(`tr`,{children:s.map((e,t)=>(0,V.jsx)(`th`,{children:(0,V.jsxs)(`button`,{type:`button`,className:`oc-docviewer__csvsort`,onClick:()=>a(e=>e?.col===t?e.dir===1?{col:t,dir:-1}:null:{col:t,dir:1}),"aria-label":Tf({column:e}),children:[e,i?.col===t?i.dir===1?` ▲`:` ▼`:``]})},t))})}),(0,V.jsx)(`tbody`,{children:o.map((e,t)=>(0,V.jsx)(`tr`,{children:s.map((t,n)=>(0,V.jsx)(`td`,{children:e[n]??``},n))},t))})]})]})}function xye({text:e,textTruncated:t}){let n=(0,B.useMemo)(()=>{let t=e.split(`
226
+ `&&!a?(r.push(i),i=``):i+=e;i!==``&&r.push(i);let s=r.findIndex(e=>e.trim()!==``);if(s===-1)return{header:[],rows:[],totalRows:0,truncatedRows:!1,delimiter:`,`};let c=n??uye(r[s]),l=a8(r[s],c),u=r.slice(s+1);return{header:l,rows:u.slice(0,t).map(e=>a8(e,c)),totalRows:u.length,truncatedRows:u.length>t,delimiter:c}}function fye(e,t){let n=e.trim(),r=t.trim();if(/^-?\d+$/.test(n)&&/^-?\d+$/.test(r)){let e=BigInt(n),t=BigInt(r);return e<t?-1:+(e>t)}let i=Number(e),a=Number(t);return n!==``&&r!==``&&!Number.isNaN(i)&&!Number.isNaN(a)?i-a:e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function pye(e){return/\b(error|err|fatal|critical|panic)\b/i.test(e)?`error`:/\b(warn|warning)\b/i.test(e)?`warn`:/\b(info|notice)\b/i.test(e)?`info`:/\b(debug|trace|verbose)\b/i.test(e)?`debug`:`plain`}var o8=60;function s8({url:e,filename:t}){let[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(1),[c,l]=(0,B.useState)(`fit`);if((0,B.useEffect)(()=>{let t=!1,n=null;return r(null),a(!1),s(1),(async()=>{try{let i=await g4(()=>import(`./pdf-CLjbM27Z.js`),[]);i.GlobalWorkerOptions.workerSrc=new URL(`/assets/pdf.worker.min-DEtVeC4l.mjs`,``+import.meta.url).toString();let a=i.getDocument({url:e}),o=await a.promise;if(t){a.destroy().catch(()=>{});return}n=a,r(o)}catch(e){console.error(`[docviewer] pdf load failed:`,e?.message??e),t||a(!0)}})(),()=>{t=!0,n&&n.destroy().catch(()=>{})}},[e]),i)return(0,V.jsxs)(`div`,{className:`oc-docviewer__fallback`,children:[(0,V.jsx)(`p`,{children:Rs()}),(0,V.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`oc-docviewer__fallbacklink`,children:$s()})]});if(n===null)return(0,V.jsx)(`div`,{className:`oc-docviewer__loading`,children:_u()});let u=n.numPages,d=r8(o,u);return(0,V.jsxs)(`div`,{className:`oc-docviewer__pdf`,children:[(0,V.jsxs)(`div`,{className:`oc-docviewer__toolbar`,children:[(0,V.jsx)(`button`,{type:`button`,className:`oc-docviewer__navbtn`,onClick:()=>s(e=>r8(e-1,u)),disabled:d<=1,"aria-label":tu(),children:(0,V.jsx)(hS,{size:15})}),(0,V.jsxs)(`span`,{className:`oc-docviewer__pageinfo`,children:[d,` / `,u]}),(0,V.jsx)(`button`,{type:`button`,className:`oc-docviewer__navbtn`,onClick:()=>s(e=>r8(e+1,u)),disabled:d>=u,"aria-label":vo(),children:(0,V.jsx)(gS,{size:15})}),(0,V.jsx)(`select`,{className:`oc-docviewer__zoom`,value:String(c),onChange:e=>{let t=e.target.value;l(t===`fit`?`fit`:Number(t))},"aria-label":Tl(),children:oye.map(e=>(0,V.jsx)(`option`,{value:String(e),children:e===`fit`?hc():`${Math.round(e*100)}%`},String(e)))})]}),(0,V.jsxs)(`div`,{className:`oc-docviewer__pdfbody`,children:[u>1?(0,V.jsxs)(`div`,{className:`oc-docviewer__rail`,"aria-label":sd(),children:[Array.from({length:Math.min(u,o8)},(e,t)=>(0,V.jsx)(hye,{doc:n,page:t+1,active:t+1===d,onClick:()=>s(t+1)},t+1)),u>o8?(0,V.jsxs)(`span`,{className:`oc-docviewer__railmore`,children:[`+`,u-o8]}):null]}):null,(0,V.jsx)(mye,{doc:n,page:d,zoom:c,filename:t})]})]})}function mye({doc:e,page:t,zoom:n,filename:r}){let i=(0,B.useRef)(null),a=(0,B.useRef)(null),[o,s]=(0,B.useState)(0);return(0,B.useEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width??0;s(e=>Math.abs(e-t)>1?t:e)});return t.observe(e),()=>t.disconnect()},[]),(0,B.useEffect)(()=>{let r=!1,i=null;return(async()=>{try{let s=await e.getPage(t),c=a.current;if(r||!c)return;let l=s.getViewport({scale:1}),u=n===`fit`?Math.max(.1,(o-16)/l.width):n,d=window.devicePixelRatio||1,f=s.getViewport({scale:u*d});c.width=Math.floor(f.width),c.height=Math.floor(f.height),c.style.width=`${Math.floor(f.width/d)}px`,c.style.height=`${Math.floor(f.height/d)}px`;let p=s.render({canvas:c,viewport:f});i=p,await p.promise}catch(e){e?.name!==`RenderingCancelledException`&&console.error(`[docviewer] page render failed:`,e?.message??e)}})(),()=>{r=!0,i?.cancel()}},[e,t,n,o]),(0,V.jsx)(`div`,{ref:i,className:`oc-docviewer__main`,children:(0,V.jsx)(`canvas`,{ref:a,className:`oc-docviewer__canvas`,"aria-label":r})})}function hye({doc:e,page:t,active:n,onClick:r}){let i=(0,B.useRef)(null);return(0,B.useEffect)(()=>{let n=!1,r=null;return(async()=>{try{let a=await e.getPage(t),o=i.current;if(n||!o)return;let s=104/a.getViewport({scale:1}).width,c=a.getViewport({scale:s});o.width=Math.floor(c.width),o.height=Math.floor(c.height);let l=a.render({canvas:o,viewport:c});r=l,await l.promise}catch(e){e?.name!==`RenderingCancelledException`&&console.error(`[docviewer] thumbnail render failed:`,e?.message??e)}})(),()=>{n=!0,r?.cancel()}},[e,t]),(0,V.jsxs)(`button`,{type:`button`,className:`oc-docviewer__thumb${n?` is-active`:``}`,onClick:r,"aria-label":Ac({page:t}),"aria-current":n?`true`:void 0,children:[(0,V.jsx)(`canvas`,{ref:i,className:`oc-docviewer__thumbcanvas`}),(0,V.jsx)(`span`,{className:`oc-docviewer__thumbnum`,children:t})]})}var c8=(0,B.createContext)({activeDoc:null,openFor:()=>{},close:()=>{}});function l8(){return(0,B.useContext)(c8)}function u8({doc:e,chatId:t,onClose:n}){let r=n8(e.mimeType,e.filename),i=r===`none`&&e.sourceStorageId!==void 0,a=l8(),o=R(L.documentDrafts.latestDeliveredFile,t===null?`skip`:{chatId:t,filename:e.filename,...e.storageId===void 0?{}:{currentStorageId:e.storageId}}),s=o!=null&&(e.storageId===void 0?o.url!==e.url:o.storageId!==e.storageId)?o:null;return(0,V.jsxs)(`div`,{className:`oc-docviewer`,children:[(0,V.jsxs)(`header`,{className:`oc-docviewer__header`,children:[(0,V.jsx)(DS,{size:15,"aria-hidden":!0,className:`oc-docviewer__icon`}),(0,V.jsx)(`span`,{className:`oc-docviewer__name`,title:e.filename,children:e.filename}),(0,V.jsx)(`a`,{className:`oc-docviewer__action`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:$s(),"aria-label":$s(),children:(0,V.jsx)(TS,{size:14})}),(0,V.jsx)(`a`,{className:`oc-docviewer__action`,href:e.url,download:e.filename,title:Uc(),"aria-label":Uc(),children:(0,V.jsx)(CS,{size:14})}),(0,V.jsx)(Ep,{type:`button`,size:`icon-sm`,variant:`ghost`,onClick:n,"aria-label":Bn(),children:(0,V.jsx)(mp,{size:15})})]}),(0,V.jsxs)(`div`,{className:`oc-docviewer__body`,children:[s===null?null:(0,V.jsxs)(`div`,{className:`oc-docviewer__newversion`,role:`status`,children:[(0,V.jsx)(`span`,{children:Hn()}),(0,V.jsx)(Ep,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>a.openFor({url:s.url,filename:e.filename,mimeType:s.mimeType||null,storageId:s.storageId,sourceStorageId:e8(s.mimeType,e.filename)?s.storageId:void 0}),children:Mn()})]}),r===`pdf`?(0,V.jsx)(s8,{url:e.url,filename:e.filename}):r===`image`?(0,V.jsx)(`div`,{className:`oc-docviewer__imagewrap`,children:(0,V.jsx)(`img`,{src:e.url,alt:e.filename,className:`oc-docviewer__image`})}):r===`video`?(0,V.jsx)(`video`,{controls:!0,preload:`metadata`,src:e.url,className:`oc-docviewer__video`}):r===`audio`?(0,V.jsx)(`div`,{className:`oc-docviewer__audiowrap`,children:(0,V.jsx)(`audio`,{controls:!0,preload:`metadata`,src:e.url,className:`oc-docviewer__audio`})}):r===`text`?(0,V.jsx)(f8,{url:e.url,chatId:t,filename:e.filename,mimeType:e.mimeType,storageId:e.storageId??null},e.url):r===`markdown`||r===`csv`||r===`log`||r===`json`?(0,V.jsx)(f8,{url:e.url,chatId:t,filename:e.filename,mimeType:e.mimeType,storageId:e.storageId??null,rich:r,csvDelimiter:r===`csv`?lye(e.mimeType,e.filename):void 0},e.url):i?(0,V.jsx)(gye,{sourceStorageId:e.sourceStorageId,downloadUrl:e.url,filename:e.filename}):(0,V.jsxs)(`div`,{className:`oc-docviewer__fallback`,children:[(0,V.jsx)(`p`,{children:ds()}),(0,V.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`oc-docviewer__fallbacklink`,children:Uc()})]})]})]})}function gye({sourceStorageId:e,downloadUrl:t,filename:n}){let r=R(L.fileRenditions.getRendition,{sourceStorageId:e}),i=p(L.fileRenditions.requestRendition),a=(0,B.useRef)(null);return(0,B.useEffect)(()=>{a.current=null},[e]),(0,B.useEffect)(()=>{r?.status===`pending`&&a.current!==e&&(a.current=e,i({sourceStorageId:e}).catch(e=>{console.error(`[docviewer] rendition request failed:`,e)}))},[r?.status,e,i]),r===void 0?(0,V.jsx)(`div`,{className:`oc-docviewer__loading`,children:_u()}):r.status===`ready`?(0,V.jsx)(s8,{url:r.pdfUrl,filename:r.filename}):r.status===`pending`?(0,V.jsxs)(`div`,{className:`oc-docviewer__preparing`,children:[(0,V.jsx)(`span`,{className:`oc-docviewer__spinner`,"aria-hidden":!0}),(0,V.jsx)(`p`,{children:Ld()}),(0,V.jsx)(`a`,{href:t,download:n,className:`oc-docviewer__fallbacklink`,children:Uc()})]}):(0,V.jsxs)(`div`,{className:`oc-docviewer__fallback`,children:[(0,V.jsx)(`p`,{children:r.status===`unconfigured`?ds():dl()}),(0,V.jsx)(`a`,{href:t,download:n,className:`oc-docviewer__fallbacklink`,children:Uc()})]})}function _ye(e){switch(e){case`markdown`:return or();case`csv`:return ke();case`log`:return Be();case`json`:return mi()}}var d8=e=>`oc.docviewer.raw.${e}`;function f8({url:e,chatId:t,filename:n,mimeType:r,storageId:i,rich:a,csvDelimiter:o}){let[s,c]=(0,B.useState)({phase:`loading`}),[l,u]=(0,B.useState)(()=>a?localStorage.getItem(d8(a))===`1`:!1),d=e=>{u(e),a&&localStorage.setItem(d8(a),e?`1`:`0`)},[f,p]=(0,B.useState)(!1),m=R(L.documentDrafts.getDraft,t===null?`skip`:{chatId:t,filename:n}),h=t!==null&&s.phase===`ready`&&!s.truncated&&m!==void 0;if((0,B.useEffect)(()=>{let t=!1;return c({phase:`loading`}),(async()=>{try{let n=await fetch(e);if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.blob(),i=r.size>i8,a=await(i?r.slice(0,i8):r).text();t||c({phase:`ready`,text:a,truncated:i})}catch(e){console.error(`[docviewer] text fetch failed:`,e?.message??e),t||c({phase:`error`})}})(),()=>{t=!0}},[e]),s.phase===`loading`)return(0,V.jsx)(`div`,{className:`oc-docviewer__loading`,children:_u()});if(s.phase===`error`)return(0,V.jsxs)(`div`,{className:`oc-docviewer__fallback`,children:[(0,V.jsx)(`p`,{children:Rs()}),(0,V.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`oc-docviewer__fallbacklink`,children:$s()})]});let g=a!==void 0&&!l,_=s.truncated?(0,V.jsx)(`p`,{className:`oc-docviewer__truncated`,children:Yo()}):null,v=m?.text??s.text,y=m==null?null:(0,V.jsx)(vye,{chatId:t,filename:n,diverged:m.sourceStorageId!==null&&i!==null&&m.sourceStorageId!==i}),b=f?(0,V.jsx)(yye,{chatId:t,filename:n,mimeType:r,sourceStorageId:i,initialText:v,hasDraft:m!=null,onExit:()=>p(!1)}):g&&a===`markdown`?(0,V.jsx)(`div`,{className:`oc-docviewer__mdwrap`,children:(0,V.jsx)(Y3,{text:v})}):g&&a===`csv`?(0,V.jsx)(bye,{text:v,textTruncated:s.truncated,delimiter:o}):g&&a===`log`?(0,V.jsx)(xye,{text:v,textTruncated:s.truncated}):g&&a===`json`?(0,V.jsx)(Sye,{text:v}):(0,V.jsx)(`pre`,{className:`oc-docviewer__text`,children:v});return a===void 0&&!h?(0,V.jsxs)(`div`,{className:`oc-docviewer__textwrap`,children:[_,y,b]}):(0,V.jsxs)(`div`,{className:`oc-docviewer__textwrap oc-docviewer__textwrap--bar`,children:[(0,V.jsxs)(`div`,{className:`oc-docviewer__mdbar`,role:`group`,"aria-label":k(),children:[a===void 0?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ep,{type:`button`,size:`sm`,variant:g&&!f?`secondary`:`ghost`,"aria-pressed":g&&!f,onClick:()=>{p(!1),d(!1)},children:_ye(a)}),(0,V.jsx)(Ep,{type:`button`,size:`sm`,variant:l&&!f?`secondary`:`ghost`,"aria-pressed":l&&!f,onClick:()=>{p(!1),d(!0)},children:Qc()})]}),h?(0,V.jsxs)(Ep,{type:`button`,size:`sm`,variant:f?`secondary`:`ghost`,"aria-pressed":f,onClick:()=>p(e=>!e),className:`oc-docviewer__editbtn`,children:[(0,V.jsx)(BS,{size:13,"aria-hidden":!0}),rt(),m==null?null:(0,V.jsx)(`span`,{className:`oc-docviewer__draftdot`,"aria-hidden":!0})]}):null]}),f?b:(0,V.jsx)(`div`,{className:`oc-docviewer__textscroll`,children:(0,V.jsxs)(`div`,{className:`oc-docviewer__scrollpad`,children:[_,y,b]})})]})}function vye({chatId:e,filename:t,diverged:n}){let r=p(L.documentDrafts.deleteDraft),i=uH();return(0,V.jsxs)(`p`,{className:`oc-docviewer__draftnote`,children:[n?lr():We(),(0,V.jsx)(`button`,{type:`button`,className:`oc-docviewer__draftnote-discard`,onClick:()=>void r({chatId:e,filename:t}).then(e=>{e.applied===!1&&i.error(Qn())}).catch(()=>i.error(Gc())),children:ji()})]})}function yye({chatId:e,filename:t,mimeType:n,sourceStorageId:r,initialText:i,hasDraft:a,onExit:o}){let s=p(L.documentDrafts.saveDraft),c=p(L.documentDrafts.deleteDraft),l=(0,B.useContext)(w6),u=uH(),d=`oc.docdraft.fallback.${e}.${t}`,[f,m]=(0,B.useState)(()=>{try{let e=localStorage.getItem(d);if(e!==null)return e}catch{}return i}),[h,g]=(0,B.useState)(`idle`),_=(0,B.useRef)(0),v=(0,B.useRef)(f);v.current=f;let y=(0,B.useRef)(!1),b=(0,B.useRef)(!1),x=(0,B.useCallback)(n=>{g(`saving`),s({chatId:e,filename:t,text:n,...r!==null&&(b.current||!a)?{sourceStorageId:r}:{}}).then(e=>{if(e.applied===!1){u.error(Qn()),g(`idle`);return}g(`saved`)}).catch(e=>{console.error(`[docviewer] draft save failed:`,e),u.error(_t()),g(`idle`)})},[s,e,t,r,a,u]),C=e=>{b.current=!0,m(e),window.clearTimeout(_.current),_.current=window.setTimeout(()=>x(e),800)};return(0,B.useEffect)(()=>{try{localStorage.getItem(d)!==null&&(b.current=!0,s({chatId:e,filename:t,text:v.current,...r===null?{}:{sourceStorageId:r}}).then(()=>localStorage.removeItem(d)))}catch{}let n=()=>{if(!(!b.current||y.current))try{localStorage.setItem(d,v.current)}catch{}};return window.addEventListener(`pagehide`,n),()=>{if(window.removeEventListener(`pagehide`,n),window.clearTimeout(_.current),!y.current&&b.current){try{localStorage.setItem(d,v.current)}catch{}s({chatId:e,filename:t,text:v.current,...r===null?{}:{sourceStorageId:r}}).then(()=>{try{localStorage.removeItem(d)}catch{}}).catch(()=>{})}}},[]),(0,V.jsxs)(`div`,{className:`oc-docviewer__editor`,children:[(0,V.jsx)(`textarea`,{className:`oc-docviewer__editarea`,value:f,onChange:e=>C(e.target.value),spellCheck:!1,"aria-label":rt()}),(0,V.jsxs)(`div`,{className:`oc-docviewer__editbar`,children:[(0,V.jsx)(`span`,{className:`oc-docviewer__savestate`,role:`status`,children:h===`saving`?qi():h===`saved`?vi():`\xA0`}),(0,V.jsx)(Ep,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{y.current=!0,window.clearTimeout(_.current);try{localStorage.removeItem(d)}catch{}c({chatId:e,filename:t}).then(e=>{if(e.applied===!1){y.current=!1,u.error(Qn());return}o()}).catch(e=>{console.error(`[docviewer] draft discard failed:`,e),y.current=!1,u.error(Gc())})},children:ji()}),(0,V.jsx)(Ep,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>{let e=l?.current??null;if(e===null){u.error(Mt());return}if(window.clearTimeout(_.current),x(f),e.canAttach){let r=(n??`text/plain`).split(`;`)[0].trim(),i=new File([f],t,{type:`${r}; charset=utf-8`});e.attachFile(i).catch(e=>{console.error(`[docviewer] attach failed:`,e),u.error(bn())})}else{if(f.length>8e3){u.error(S());return}e.insertText(Hve(t,f,Ic()))}},children:j()})]})]})}function bye({text:e,textTruncated:t,delimiter:n}){let r=(0,B.useMemo)(()=>dye(e,void 0,n),[e,n]),[i,a]=(0,B.useState)(null),o=(0,B.useMemo)(()=>i?[...r.rows].sort((e,t)=>fye(e[i.col]??``,t[i.col]??``)*i.dir):r.rows,[r.rows,i]);if(r.header.length===0)return(0,V.jsx)(`pre`,{className:`oc-docviewer__text`,children:e});let s=r.header.slice(0,100),c=r.header.length>s.length;return(0,V.jsxs)(`div`,{className:`oc-docviewer__csvwrap`,children:[r.truncatedRows?(0,V.jsx)(`p`,{className:`oc-docviewer__truncated`,children:t?ve({shown:r.rows.length}):df({shown:r.rows.length,total:r.totalRows})}):null,c?(0,V.jsx)(`p`,{className:`oc-docviewer__truncated`,children:ni({shown:s.length,total:r.header.length})}):null,(0,V.jsxs)(`table`,{className:`oc-docviewer__csv`,children:[(0,V.jsx)(`thead`,{children:(0,V.jsx)(`tr`,{children:s.map((e,t)=>(0,V.jsx)(`th`,{children:(0,V.jsxs)(`button`,{type:`button`,className:`oc-docviewer__csvsort`,onClick:()=>a(e=>e?.col===t?e.dir===1?{col:t,dir:-1}:null:{col:t,dir:1}),"aria-label":Tf({column:e}),children:[e,i?.col===t?i.dir===1?` ▲`:` ▼`:``]})},t))})}),(0,V.jsx)(`tbody`,{children:o.map((e,t)=>(0,V.jsx)(`tr`,{children:s.map((t,n)=>(0,V.jsx)(`td`,{children:e[n]??``},n))},t))})]})]})}function xye({text:e,textTruncated:t}){let n=(0,B.useMemo)(()=>{let t=e.split(`
227
227
  `);return t.length>1&&t[t.length-1]===``&&t.pop(),t},[e]),r=(0,B.useMemo)(()=>n.slice(0,cye),[n]);return(0,V.jsxs)(V.Fragment,{children:[n.length>r.length?(0,V.jsx)(`p`,{className:`oc-docviewer__truncated`,children:t?Hf({shown:r.length}):Po({shown:r.length,total:n.length})}):null,(0,V.jsx)(`pre`,{className:`oc-docviewer__text oc-docviewer__logview`,children:r.map((e,t)=>(0,V.jsxs)(`span`,{className:`oc-logline oc-logline--${pye(e)}`,children:[e,`
228
- `]},t))})]})}function Sye({text:e}){let t=(0,B.useMemo)(()=>{try{return{ok:!0,value:JSON.parse(e,(e,t,n)=>{if(typeof t==`number`&&Number.isInteger(t)&&!Number.isSafeInteger(t)&&typeof n?.source==`string`&&/^-?\d+$/.test(n.source))try{return BigInt(n.source)}catch{return t}return t})}}catch{return{ok:!1}}},[e]);return t.ok?(0,V.jsx)(`div`,{className:`oc-docviewer__jsonwrap`,children:(0,V.jsx)(p8,{value:t.value,depth:0})}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`oc-docviewer__truncated`,children:Qd()}),(0,V.jsx)(`pre`,{className:`oc-docviewer__text`,children:e})]})}function Cye(e){if(Array.isArray(e))return e.length;let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function wye(e,t){if(Array.isArray(e))return e.slice(0,t).map((e,t)=>[String(t),e]);let n=[];for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(n.length>=t)break;n.push([r,e[r]])}return n}function p8({value:e,depth:t,name:n}){let r=typeof e==`object`&&!!e,i=r?Cye(e):0,[a,o]=(0,B.useState)(t<2&&i<=100),s=n===void 0?null:(0,V.jsxs)(`span`,{className:`oc-json__key`,children:[n,`: `]});if(!r)return(0,V.jsxs)(`div`,{className:`oc-json__leaf`,children:[s,(0,V.jsx)(`span`,{className:`oc-json__val oc-json__val--${e===null?`null`:typeof e==`bigint`?`number`:typeof e}`,children:typeof e==`bigint`?e.toString():JSON.stringify(e)})]});let c=a?wye(e,500):[];return(0,V.jsxs)(`details`,{className:`oc-json__node`,open:a,onToggle:e=>o(e.target.open),children:[(0,V.jsxs)(`summary`,{children:[s,(0,V.jsx)(`span`,{className:`oc-json__summary`,children:Array.isArray(e)?`[${i}]`:`{${i}}`})]}),a?(0,V.jsxs)(`div`,{className:`oc-json__children`,children:[c.map(([e,n])=>(0,V.jsx)(p8,{name:e,value:n,depth:t+1},e)),i>c.length?(0,V.jsx)(`div`,{className:`oc-json__more`,children:ro({count:i-c.length})}):null]}):null]})}function Tye({mimeType:e,data:t,filename:n,storageId:r}){let i=e??``,a=t??``,o=n??`attachment`;return a?i.startsWith(`audio/`)?(0,V.jsxs)(`div`,{className:`oc-media oc-media--audio`,children:[(0,V.jsx)(`audio`,{controls:!0,preload:`metadata`,src:a,className:`oc-media__audio`,children:(0,V.jsx)(`a`,{href:a,download:o,children:vr()})}),(0,V.jsx)(`span`,{className:`oc-media__name`,children:o})]}):i.startsWith(`image/`)?(0,V.jsx)(Dye,{url:a,name:o}):i.startsWith(`video/`)?(0,V.jsxs)(`div`,{className:`oc-media oc-media--video`,children:[(0,V.jsx)(`video`,{controls:!0,preload:`metadata`,src:a,className:`oc-media__video`}),(0,V.jsx)(`span`,{className:`oc-media__name`,children:o})]}):(0,V.jsx)(Eye,{url:a,name:o,mime:i,storageId:r}):null}function Eye({url:e,name:t,mime:n,storageId:r}){let i=l8(),a=n8(n,t)!==`none`,o=!!r&&e8(n,t),s=a||o,c=n=>{n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||n.button!==0||(n.preventDefault(),(async()=>{try{let n=await fetch(e);if(!n.ok)throw Error(`HTTP ${n.status}`);let r=URL.createObjectURL(await n.blob()),i=document.createElement(`a`);i.href=r,i.download=t,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),3e4)}catch{let t=window.open(``,`_blank`);t?(t.opener=null,t.location.href=e):window.location.href=e}})())};return(0,V.jsxs)(`span`,{className:`oc-media oc-media--file oc-filechip`,title:t,children:[(0,V.jsxs)(`a`,{className:`oc-filechip__main`,href:e,target:`_blank`,rel:`noopener noreferrer`,onClick:c,"aria-label":Sn({name:t}),children:[(0,V.jsx)(`span`,{className:`oc-media__icon`,"aria-hidden":!0,children:`📄`}),(0,V.jsx)(`span`,{className:`oc-media__name`,children:t})]}),(0,V.jsx)(`a`,{className:`oc-filechip__btn`,href:e,target:`_blank`,rel:`noopener noreferrer`,onClick:c,title:Sn({name:t}),"aria-label":Sn({name:t}),children:(0,V.jsx)(CS,{size:14,"aria-hidden":!0})}),s?(0,V.jsx)(`button`,{type:`button`,className:`oc-filechip__btn`,onClick:()=>i.openFor({url:e,filename:t,mimeType:n||null,storageId:r,sourceStorageId:o?r:void 0}),title:Xn({name:t}),"aria-label":Xn({name:t}),children:(0,V.jsx)(Vne,{size:14,"aria-hidden":!0})}):null]})}function Dye({url:e,name:t}){let{open:n}=Lve();return(0,V.jsx)(`button`,{type:`button`,className:`oc-media oc-media--thumb`,onClick:()=>n({url:e,name:t}),title:t,"aria-label":t,children:(0,V.jsx)(`img`,{src:e,alt:t,className:`oc-media__thumbimg`,loading:`lazy`,decoding:`async`})})}var m8=1e3;function Oye(){return[{id:`incorrect`,label:cr()},{id:`incoherence`,label:Me()},{id:`altered_words`,label:Ue()},{id:`formatting`,label:_i()},{id:`latency`,label:mf()},{id:`api_error`,label:xe()},{id:`other`,label:ai()}]}function kye(){return[{id:`altered_words`,label:kf()},{id:`formatting`,label:Ro()},{id:`other`,label:ai()}]}function Aye(e){return e===`user`?kye():Oye()}var jye=[{name:`Grammarly`,selector:`grammarly-desktop-integration, grammarly-extension, [data-grammarly-shadow-root]`},{name:`LanguageTool`,selector:`[data-lt-installed], .lt-toolbar`},{name:`DeepL`,selector:`deepl-inline-translate, .deepl-translator`},{name:`ProWritingAad`,selector:`pwa-shadow-host, .pwa-tag`}];function Mye(){let e=[];try{e=Array.from(navigator.plugins??[]).map(e=>e.name).slice(0,40)}catch{e=[]}let t=[];for(let{name:e,selector:n}of jye)try{document.querySelector(n)&&t.push(e)}catch{}return{plugins:e,extensionsDetected:t}}var h8=B.createContext(null);function Nye(){let e=B.useContext(h8);if(!e)throw Error(`useFeedback must be used within <FeedbackProvider>`);return e}function Pye({children:e}){let t=p(L.feedback.submitFeedback),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(``),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(null),[f,m]=(0,B.useState)(null),[h,g]=(0,B.useState)(!1),_=B.useCallback(e=>{a(``),s(``),l(!1),d(null),m(null),g(!1),r(e)},[]);function v(e){e||r(null)}async function y(){if(!(!n||!i||c)){l(!0);try{let e=await t({chatId:n.chatId,messageId:n.messageId,category:i,comment:o.trim()||void 0,client:{displayedText:n.displayedText,sourceWasOpen:n.sourceWasOpen,userAgent:navigator.userAgent,language:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,theme:document.documentElement.classList.contains(`dark`)?`dark`:`light`,...Mye()}});d(e.displayedMatchesStored),m(String(e.reference??e.feedbackId))}catch{l(!1)}}}let b=u!==null,x=n?.role===`user`;return(0,V.jsxs)(h8.Provider,{value:_,children:[e,(0,V.jsx)(WB,{open:n!==null,onOpenChange:v,children:n?(0,V.jsxs)(qB,{className:`sm:max-w-md`,children:[(0,V.jsxs)(JB,{children:[(0,V.jsx)(XB,{children:Kf()}),(0,V.jsx)(ZB,{children:b?tf():x?oo():rc()})]}),b?(0,V.jsxs)(`div`,{className:`oc-feedback__result`,role:`status`,children:[n.sourceWasOpen?u===!0?(0,V.jsx)(`p`,{className:`oc-feedback__fidelity is-ok`,children:yc()}):(0,V.jsx)(`p`,{className:`oc-feedback__fidelity is-warn`,children:kl()}):(0,V.jsx)(`p`,{className:`oc-feedback__fidelity`,children:bu()}),f?(0,V.jsxs)(`div`,{className:`oc-feedback__ref`,children:[(0,V.jsx)(`span`,{className:`oc-feedback__ref-label`,children:Da()}),(0,V.jsx)(`code`,{className:`oc-feedback__ref-id`,title:f,children:f}),(0,V.jsx)(`button`,{type:`button`,className:`oc-iconbtn`,title:Qt(),"aria-label":Qt(),onClick:()=>{navigator.clipboard.writeText(f).then(()=>{g(!0),window.setTimeout(()=>g(!1),1500)})},children:h?(0,V.jsx)(cp,{size:14}):(0,V.jsx)(SS,{size:14})})]}):null]}):(0,V.jsxs)(`div`,{className:`oc-feedback__form`,children:[(0,V.jsx)(`label`,{className:`oc-feedback__label`,children:Vs()}),(0,V.jsxs)(X3,{value:i,onValueChange:a,children:[(0,V.jsx)(Q3,{children:(0,V.jsx)(Z3,{placeholder:ms()})}),(0,V.jsx)($3,{children:Aye(n.role).map(e=>(0,V.jsx)(e6,{value:e.id,children:e.label},e.id))})]}),(0,V.jsx)(`label`,{className:`oc-feedback__label`,htmlFor:`oc-feedback-comment`,children:Bd()}),(0,V.jsx)(`textarea`,{id:`oc-feedback-comment`,className:`oc-feedback__textarea`,placeholder:hl(),value:o,maxLength:m8,onChange:e=>s(e.target.value.slice(0,m8)),rows:4}),(0,V.jsxs)(`div`,{className:`oc-feedback__count`,children:[o.length,`/`,m8]})]}),(0,V.jsx)(YB,{children:b?(0,V.jsx)(Ep,{onClick:()=>v(!1),children:$o()}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ep,{variant:`outline`,onClick:()=>v(!1),children:dd()}),(0,V.jsx)(Ep,{onClick:()=>void y(),disabled:!i||c,children:c?au():So()})]})})]}):null})]})}function Fye(e,t){let n=e.closest(`.oc-msg`)?.querySelector(`.oc-msg__source-pre`),r=n?.textContent;return n&&r!=null&&r!==`(aucun texte)`?{displayedText:r,sourceWasOpen:!0}:{displayedText:t,sourceWasOpen:!1}}function g8(){let e=Nye(),t=Yk(e=>e.metadata?.custom?.messageId),n=Yk(e=>e.metadata?.custom?.chatId),r=Yk(e=>e.role),i=Yk(e=>e.metadata?.custom?.rawText??``),a=R(L.feedback.myReportedMessageIds,n?{chatId:n}:`skip`);if(!t||!n)return null;let o=(a??[]).includes(t);function s(a){e({chatId:n,messageId:t,role:r,...Fye(a.currentTarget,i)})}return(0,V.jsx)(`button`,{type:`button`,className:`oc-iconbtn${o?` is-on`:``}`,title:o?Fc():Xu(),"aria-label":Wl(),onClick:s,children:(0,V.jsx)(OS,{size:15,"aria-hidden":!0})})}function _8(e,t){return e!=null&&e[t]!==void 0}var Iye=[`inherit`,`fast`,`standard`];function Lye(e){return e==null||e.fastMode===void 0?`inherit`:e.fastMode?`fast`:`standard`}function Rye(e){return e===`inherit`?fs():e===`fast`?Rd():pl()}function zye(e){return e===`inherit`?null:e===`fast`}function v8(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function y8(e){return e.length?e[0].toUpperCase()+e.slice(1):e}var Bye={off:`Off`,minimal:`Min`,low:`Low`,medium:`Med`,high:`High`,xhigh:`XHigh`};function Vye(e,t){return Bye[e]??t}function b8(e){return e?e.activeTokens==null?e.totalTokens==null||e.contextTokens&&e.totalTokens>e.contextTokens?null:e.totalTokens:e.activeTokens:null}function x8(e,t){return e==null||!t||t<=0?null:Math.round(e/t*100)}function Hye(e,t){let n=x8(e,t);return n===null?null:Dr({pct:n,used:v8(e),total:v8(t)})}function Uye(e){return ma({level:e??`full`})}function Wye(e,t){let n=typeof e==`number`,r=typeof t==`number`;return n&&r?Ou({cost:e.toFixed(2),tokens:v8(t)}):n?pn({cost:e.toFixed(2)}):r?ut({tokens:v8(t)}):null}function Gye(e){let t=e.filter(e=>typeof e==`string`&&e.length>0);return t.length>0?t.join(` · `):null}function Kye(e){let t=p(L.chats.setSessionKnob),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(null);return{apply:(0,B.useCallback)(async(n,i)=>{r(n),a(null);let o={chatId:e};n===`fastMode`?o.fastMode=i:o[n]=i;try{await t(o)}catch{a({field:n,value:i})}finally{r(null)}},[e,t]),pending:n,error:i}}function S8({label:e,overridden:t,onReset:n,pending:r,error:i,onRetry:a,help:o,children:s,resettable:c=!0}){return(0,V.jsxs)(`div`,{className:`oc-spanel__row${t?` is-overridden`:``}`,children:[(0,V.jsxs)(`div`,{className:`oc-spanel__rowhead`,children:[(0,V.jsx)(`span`,{className:`oc-spanel__label`,children:e}),r?(0,V.jsx)(MS,{size:13,className:`oc-spanel__spin`,"aria-label":tc()}):t?c?(0,V.jsx)(`button`,{type:`button`,className:`oc-spanel__reset`,title:ao(),"aria-label":ao(),onClick:n,children:(0,V.jsx)(US,{size:12,"aria-hidden":!0})}):null:(0,V.jsx)(`span`,{className:`oc-spanel__badge`,children:ef()})]}),(0,V.jsx)(`div`,{className:`oc-spanel__ctl`,children:s}),o?(0,V.jsx)(`p`,{className:`oc-spanel__help`,children:o}):null,i?(0,V.jsxs)(`p`,{className:`oc-spanel__error`,role:`alert`,children:[_c(),(0,V.jsx)(`button`,{type:`button`,className:`oc-spanel__retry`,onClick:a,children:Dl()})]}):null]})}function C8({options:e,value:t,onChange:n,disabled:r}){return(0,V.jsx)(`div`,{className:`oc-spanel__seg`,role:`group`,children:e.map(e=>(0,V.jsx)(`button`,{type:`button`,className:`oc-spanel__seg-btn${t===e.id?` is-active`:``}`,"aria-pressed":t===e.id,title:e.title??e.label,"aria-label":e.title??e.label,disabled:r,onClick:()=>{e.id!==t&&n(e.id)},children:e.label},e.id))})}function qye({options:e,value:t,onChange:n,disabled:r,ariaLabel:i}){let a=t===null||e.some(e=>e.id===t);return(0,V.jsxs)(`select`,{className:`oc-spanel__select`,value:t??``,disabled:r,"aria-label":i,onChange:e=>{e.target.value&&e.target.value!==t&&n(e.target.value)},children:[t===null?(0,V.jsx)(`option`,{value:``,disabled:!0,hidden:!0}):null,a?null:(0,V.jsx)(`option`,{value:t,children:t}),e.map(e=>(0,V.jsx)(`option`,{value:e.id,children:e.label},e.id))]})}function w8({chatId:e,sm:t,settings:n}){let{apply:r,pending:i,error:a}=Kye(e),{can:o}=p6(e),s=i!==null,c=(0,B.useCallback)(()=>{a&&r(a.field,a.value)},[r,a]),l=t.thinkingLevels??[],u=t.availableModels??[],d=Lye(n),f=Tve(o,{hasModels:u.length>0,hasLevels:l.length>0});return(0,V.jsxs)(V.Fragment,{children:[f.model?(0,V.jsx)(S8,{label:as(),overridden:_8(n,`model`),onReset:()=>void r(`model`,null),pending:i===`model`,error:a?.field===`model`,onRetry:c,resettable:f.reset,children:u.length<=4?(0,V.jsx)(C8,{options:u,value:t.model??null,onChange:e=>void r(`model`,e),disabled:s}):(0,V.jsx)(qye,{options:u,value:t.model??null,onChange:e=>void r(`model`,e),disabled:s,ariaLabel:as()})}):null,f.thinking?(0,V.jsx)(S8,{label:vu(),overridden:_8(n,`thinkingLevel`),onReset:()=>void r(`thinkingLevel`,null),pending:i===`thinkingLevel`,error:a?.field===`thinkingLevel`,onRetry:c,resettable:f.reset,children:(0,V.jsx)(C8,{options:l.map(e=>({id:e.id,label:Vye(e.id,y8(e.label)),title:y8(e.label)})),value:t.thinkingLevel??null,onChange:e=>void r(`thinkingLevel`,e),disabled:s})}):null,f.speed?(0,V.jsx)(S8,{label:zs(),overridden:_8(n,`fastMode`),onReset:()=>void r(`fastMode`,null),pending:i===`fastMode`,error:a?.field===`fastMode`,onRetry:c,resettable:f.reset,children:(0,V.jsx)(C8,{options:Iye.map(e=>({id:e,label:Rye(e)})),value:d,onChange:e=>void r(`fastMode`,zye(e)),disabled:s})}):null]})}function T8(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function E8({label:e,state:t,destructive:n,onClick:r,onRetry:i}){return(0,V.jsxs)(`div`,{className:`oc-spanel__action`,children:[(0,V.jsxs)(Ep,{variant:n?`destructive`:`outline`,size:`sm`,disabled:t===`pending`,onClick:r,children:[t===`pending`?(0,V.jsx)(MS,{className:`oc-spanel__spin`,"aria-hidden":!0}):null,e]}),t===`done`?(0,V.jsx)(`p`,{className:`oc-spanel__action-note`,role:`status`,children:Bt()}):null,t===`error`?(0,V.jsxs)(`p`,{className:`oc-spanel__error`,role:`alert`,children:[Ze(),(0,V.jsx)(`button`,{type:`button`,className:`oc-spanel__retry`,onClick:i,children:Dl()})]}):null]})}function Jye({chatId:e,open:t,onOpenChange:n}){let r=R(L.messages.getSessionMeta,t?{chatId:e}:`skip`),i=R(L.chatSummaries.getChatSummary,t?{chatId:e}:`skip`),a=R(L.agents.getChatAgent,t?{chatId:e}:`skip`),o=r?.sessionMeta??null,s=r?.sessionSettings??null,{can:c}=p6(t?e:null),l=XV(),u=La(L.agentFiles.compactSession),d=p(L.chats.resetSession),f=p(L.chatSummaries.requestSummarize),[m,h]=(0,B.useState)(`idle`),[g,v]=(0,B.useState)(`idle`),[y,b]=(0,B.useState)(`idle`),[x,S]=(0,B.useState)(null),[C,w]=(0,B.useState)(!1),[E,D]=(0,B.useState)(!1),[O,k]=(0,B.useState)(null),[A,j]=(0,B.useState)(`idle`),M=p(L.chatSummaries.updateSummary);(0,B.useEffect)(()=>{k(null),j(`idle`),D(!1),w(!1),S(null),b(`idle`)},[e]);async function N(){if(i?.summary)try{await navigator.clipboard.writeText(i.summary),w(!0),window.setTimeout(()=>w(!1),2e3)}catch{}}async function ee(){if(!(O===null||O.trim().length===0)){j(`saving`);try{await M({chatId:e,summary:O}),k(null),j(`idle`)}catch{j(`error`)}}}let[P,te]=(0,B.useState)(()=>Date.now()),re=i?.jobInFlight===!0;(0,B.useEffect)(()=>{if(!re)return;let e=window.setInterval(()=>te(Date.now()),1e3);return()=>window.clearInterval(e)},[re]);async function ie(){h(`pending`);try{await u({chatId:e}),h(`done`)}catch{h(`error`)}}async function ae(){b(`pending`),S(null);try{let{outcome:t}=await f({chatId:e});S(({dispatched:wn,in_flight:Lt,nothing_to_do:Je,scanning:Kd,bridge_outdated:sl,engine_off:pr,no_agent:Kn,backoff:Je}[t]??Je)()),b(t===`dispatched`||t===`scanning`?`done`:`idle`)}catch{b(`error`)}}async function oe(){v(`pending`);try{await d({chatId:e}),v(`done`)}catch{v(`error`)}}async function se(){await l({title:Ci(),description:wt(),confirmLabel:zi(),cancelLabel:it()})&&await ie()}async function ce(){await l({title:tp(),description:zr(),confirmLabel:En(),cancelLabel:it(),destructive:!0})&&await oe()}let le=b8(o),ue=x8(le??void 0,o?.contextTokens),de=ue==null?``:ue>=90?`is-critical`:ue>=75?`is-warn`:`is-ok`,fe=Hye(le??void 0,o?.contextTokens),pe=Wye(o?.estimatedCostUsd,o?.totalTokens),me=a?.agent??null,he=Gye([me?me.displayName??me.agentId:null,o?.agentRuntime,o?.model]);return(0,V.jsx)(J6,{open:t,onOpenChange:n,children:(0,V.jsxs)(Y6,{side:`right`,className:`oc-spanel`,children:[(0,V.jsxs)(X6,{children:[(0,V.jsx)(Q6,{children:ld()}),(0,V.jsx)($6,{children:ru()})]}),(0,V.jsx)(`div`,{className:`oc-spanel__body`,children:r===void 0?(0,V.jsx)(`p`,{className:`oc-spanel__loading`,children:st()}):(0,V.jsxs)(V.Fragment,{children:[o?(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`oc-spanel__cat`,children:bo()}),(0,V.jsx)(w8,{chatId:e,sm:o,settings:s})]}):null,(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`oc-spanel__cat`,children:Nc()}),fe!==null&&ue!==null?(0,V.jsxs)(`div`,{className:`oc-spanel__static`,children:[(0,V.jsx)(`span`,{className:`oc-spanel__label`,children:_()}),(0,V.jsxs)(`span`,{className:`oc-meter oc-spanel__meter ${de}`,children:[(0,V.jsx)(`span`,{className:`oc-meter__track`,children:(0,V.jsx)(`span`,{className:`oc-meter__fill`,style:{width:`${Math.min(ue,100)}%`}})}),(0,V.jsx)(`span`,{className:`oc-meter__label`,children:fe})]})]}):null,(0,V.jsxs)(`div`,{className:`oc-spanel__static`,children:[(0,V.jsx)(`span`,{className:`oc-spanel__label`,children:Ba()}),(0,V.jsx)(`span`,{className:`oc-spanel__value`,children:Uye(o?.verboseLevel)}),(0,V.jsx)(`p`,{className:`oc-spanel__help`,children:Oa()})]}),pe===null?null:(0,V.jsxs)(`div`,{className:`oc-spanel__static`,children:[(0,V.jsx)(`span`,{className:`oc-spanel__label`,children:$t()}),(0,V.jsx)(`span`,{className:`oc-spanel__value`,children:pe})]})]}),he!==null||o?(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`oc-spanel__cat`,children:wd()}),(0,V.jsxs)(`dl`,{className:`oc-spanel__kv`,children:[me?(0,V.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,V.jsx)(`dt`,{children:At()}),(0,V.jsxs)(`dd`,{children:[me.emoji?`${me.emoji} `:``,me.displayName??me.agentId]})]}):null,me?.instanceName?(0,V.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,V.jsx)(`dt`,{children:Ju()}),(0,V.jsx)(`dd`,{children:me.instanceName})]}):null,o?.model?(0,V.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,V.jsx)(`dt`,{children:id()}),(0,V.jsx)(`dd`,{children:o.model})]}):null,o?.modelProvider?(0,V.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,V.jsx)(`dt`,{children:Ql()}),(0,V.jsx)(`dd`,{children:o.modelProvider})]}):null,o?.agentRuntime?(0,V.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,V.jsx)(`dt`,{children:aa()}),(0,V.jsx)(`dd`,{children:o.agentRuntime})]}):null,o?.thinkingLevel?(0,V.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,V.jsx)(`dt`,{children:ho()}),(0,V.jsx)(`dd`,{children:o.thinkingLevel})]}):null,o?.thinkingDefault?(0,V.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,V.jsx)(`dt`,{children:Hl()}),(0,V.jsx)(`dd`,{children:o.thinkingDefault})]}):null]})]}):null,(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`oc-spanel__cat`,children:St()}),i?(0,V.jsxs)(`div`,{className:`oc-spanel__static`,children:[(0,V.jsx)(`span`,{className:`oc-spanel__label`,children:zc()}),(0,V.jsxs)(`span`,{className:`oc-meter oc-spanel__meter is-ok`,children:[(0,V.jsx)(`span`,{className:`oc-meter__track`,children:(0,V.jsx)(`span`,{className:`oc-meter__fill`,style:{width:`${Math.min(i.pendingChars/Math.max(i.thresholdChars,1)*100,100)}%`}})}),(0,V.jsx)(`span`,{className:`oc-meter__label`,children:T({pending:`${T8(i.pendingChars)}${i.pendingApprox?`+`:``}`,threshold:T8(i.thresholdChars)})})]})]}):null,i&&!i.jobInFlight&&i.pendingChars>=i.thresholdChars?(0,V.jsx)(`p`,{className:`oc-spanel__hint`,children:Jc()}):null,i?.jobInFlight?(0,V.jsxs)(`p`,{className:`oc-spanel__hint oc-spanel__job`,role:`status`,children:[(0,V.jsx)(MS,{size:13,className:`oc-spanel__job-spin`,"aria-hidden":!0}),i.jobStreaming?Js():Za(),i.jobStartedAt?` · ${Math.max(0,Math.round((P-i.jobStartedAt)/1e3))} s`:``]}):null,i&&i.summary.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`p`,{className:`oc-spanel__hint`,children:[Ii({count:String(i.coveredCount),date:kV(i.updatedAt,{dateStyle:`short`,timeStyle:`short`})}),i.lastAgentId?` ${In({agent:i.lastInstanceName?`${i.lastAgentId} (${i.lastInstanceName})`:i.lastAgentId})}`:``]}),i.failureCount>0?(0,V.jsx)(`p`,{className:`oc-spanel__hint oc-spanel__hint--warn`,children:F({count:String(i.failureCount)})}):null,(0,V.jsxs)(`div`,{className:`oc-spanel__summary-tools`,children:[(0,V.jsx)(Ep,{variant:`ghost`,size:`sm`,className:`oc-spanel__summary-tool`,onClick:()=>void N(),title:uc(),"aria-label":uc(),children:C?(0,V.jsx)(cp,{size:14,"aria-hidden":!0}):(0,V.jsx)(SS,{size:14,"aria-hidden":!0})}),(0,V.jsx)(Ep,{variant:`ghost`,size:`sm`,className:`oc-spanel__summary-tool`,onClick:()=>D(!0),title:bl(),"aria-label":bl(),children:(0,V.jsx)(FS,{size:14,"aria-hidden":!0})}),i.jobInFlight?null:(0,V.jsx)(Ep,{variant:`ghost`,size:`sm`,className:`oc-spanel__summary-tool`,onClick:()=>{k(i.summary),D(!0)},title:fu(),"aria-label":fu(),children:(0,V.jsx)(BS,{size:14,"aria-hidden":!0})})]}),(0,V.jsx)(`div`,{className:`oc-spanel__summary`,children:i.summary})]}):i&&i.failureCount>0?(0,V.jsx)(`p`,{className:`oc-spanel__hint oc-spanel__hint--warn`,children:F({count:String(i.failureCount)})}):i?.jobInFlight?null:(0,V.jsx)(`p`,{className:`oc-spanel__hint`,children:Qf()})]})]})}),(0,V.jsx)(WB,{open:E,onOpenChange:e=>{D(e),e||(k(null),j(`idle`))},children:(0,V.jsxs)(qB,{className:`oc-summary-dialog`,children:[(0,V.jsxs)(JB,{children:[(0,V.jsx)(XB,{children:St()}),(0,V.jsx)(ZB,{children:O===null?i&&i.summary.length>0?Ii({count:String(i.coveredCount),date:kV(i.updatedAt,{dateStyle:`short`,timeStyle:`short`})}):``:Nd()})]}),O===null?(0,V.jsx)(`div`,{className:`oc-summary-dialog__body`,children:i?.summary??``}):(0,V.jsx)(`textarea`,{className:`oc-summary-dialog__body oc-summary-dialog__edit`,value:O,onChange:e=>k(e.target.value)}),A===`error`?(0,V.jsx)(`p`,{className:`oc-spanel__hint oc-spanel__hint--warn`,children:ss()}):null,(0,V.jsx)(`div`,{className:`oc-summary-dialog__actions`,children:O===null?(0,V.jsxs)(V.Fragment,{children:[i&&i.summary.length>0&&!i.jobInFlight?(0,V.jsxs)(Ep,{variant:`outline`,size:`sm`,onClick:()=>k(i.summary),children:[(0,V.jsx)(BS,{size:14,"aria-hidden":!0}),fu()]}):null,(0,V.jsxs)(Ep,{variant:`outline`,size:`sm`,onClick:()=>void N(),children:[C?(0,V.jsx)(cp,{size:14,"aria-hidden":!0}):(0,V.jsx)(SS,{size:14,"aria-hidden":!0}),uc()]})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ep,{variant:`ghost`,size:`sm`,onClick:()=>{k(null),j(`idle`)},children:it()}),(0,V.jsx)(Ep,{size:`sm`,disabled:O.trim().length===0||A===`saving`,onClick:()=>void ee(),children:A===`saving`?tc():Ns()})]})})]})}),(0,V.jsxs)(Z6,{className:`oc-spanel__actions`,children:[(0,V.jsx)(`h3`,{className:`oc-spanel__cat`,children:Ts()}),c(`sessionCompact`)?(0,V.jsx)(E8,{label:$i(),state:m,onClick:()=>void se(),onRetry:()=>void ie()}):null,(0,V.jsx)(E8,{label:Lr(),state:re?`pending`:y,onClick:()=>void ae(),onRetry:()=>void ae()}),x===null?null:(0,V.jsx)(`p`,{className:`oc-spanel__hint`,children:x}),(0,V.jsx)(E8,{label:ne(),state:g,destructive:!0,onClick:()=>void ce(),onRetry:()=>void oe()})]})]})})}var D8={showSource:!0,showReport:!0,copyAssistant:!0,copyUser:!0,showDelete:!0,showTools:!1,voiceInput:!1,showUsage:!0,autoReadAloud:!0},O8=(0,B.createContext)({enabled:!1,lang:`auto`,rate:1,autoRead:!1,engine:`browser`,loaded:!1}),k8=(0,B.createContext)({active:null,setActive:()=>{},clearIf:()=>{}}),A8=0;function j8(){A8++,PH(),BH()}var M8=(0,B.createContext)(D8);function N8(){return(0,B.useContext)(M8)}var P8=(0,B.createContext)(null),F8=(0,B.createContext)(null),I8=(0,B.createContext)(null),L8=(0,B.createContext)(null),R8=(0,B.createContext)(null);function z8(){return(0,B.useContext)(R8)}function B8({className:e}){let t=VB();return(0,V.jsx)(`div`,{className:e,"aria-hidden":!0,children:t.logoUrl?t.logoMasked?(0,V.jsx)(`span`,{className:`oc-avatar__img oc-avatar__img--mask`,style:{"--oc-logo-url":`url("${t.logoUrl}")`}}):(0,V.jsx)(`img`,{className:`oc-avatar__img`,src:t.logoUrl,alt:``}):t.isDefault?(0,V.jsx)(zB,{className:`oc-avatar__mark`}):t.initials})}function V8({chatId:e,focusMessageId:t}){let{runtime:n,turnGate:r,queueSend:i,abortTurn:a,routing:o,lastUserTurnQueued:s,initialLoading:c}=FU({chatId:e}),l=R(L.me.getMe,{host:aB}),u=l?.ui?.effective??D8,d=u.showTools,f=EB(l?.resolvedThemeMode),m=l?.resolvedChartBrand,h=l?.resolvedChartTokens,g=R(L.agents.getChatAgent,e?{chatId:e}:`skip`),_=g?.multiAgent?g.agent:null,v=(0,B.useMemo)(()=>{let e=m?.label??`Atrium`,t=h?.colors?.[f],n=PB(m,LB(t?.primary,t?.[`primary-foreground`],f));return{label:e,logoUrl:n?.url??null,logoMasked:n?.masked??!1,isDefault:m?.isDefault??!0,initials:RB(e),agentName:_?.displayName??_?.agentId??null,agentEmoji:_?.emoji??null}},[m,f,h,_]),y=p(L.me.setUiPref).withOptimisticUpdate(IU),b=R(L.messages.getSessionMeta,e?{chatId:e}:`skip`),x=e!==null&&b===null,S=G6(),{width:C,startResize:w,columnRef:T}=K6({storageKey:`oc.sources.width`,defaultWidth:380,min:300,max:680,edge:`right`}),[E,D]=(0,B.useState)(null);(0,B.useEffect)(()=>{D(null)},[e]);let{width:O,startResize:k,columnRef:A}=K6({storageKey:`oc.subagent.width`,defaultWidth:460,min:320,max:720,edge:`right`}),[j,M]=(0,B.useState)(null);(0,B.useEffect)(()=>{M(null)},[e]);let{width:N,startResize:ee,columnRef:P}=K6({storageKey:`oc.docviewer.width`,defaultWidth:560,min:380,max:1800,maxViewportFraction:.72,edge:`right`}),[F,te]=(0,B.useState)(null);(0,B.useEffect)(()=>{te(null)},[e]);let ne=(0,B.useMemo)(()=>({activeMessageId:E,openFor:e=>{D(e),M(null),te(null),se(null)},close:()=>D(null)}),[E]),re=(0,B.useMemo)(()=>({activeChildKey:j,openFor:e=>{M(e),D(null),te(null),se(null)},close:()=>M(null)}),[j]),ie=(0,B.useRef)(null),ae=(0,B.useMemo)(()=>({activeDoc:F,openFor:e=>{te(e),D(null),M(null),se(null)},close:()=>te(null)}),[F]),[oe,se]=(0,B.useState)(null);(0,B.useEffect)(()=>{se(null)},[e]);let ce=g?.agent?.instanceName??null,le=(0,B.useMemo)(()=>({active:oe,openFor:(e,t)=>{let n=t??ce;n!==null&&(se({instanceName:n,jobId:e.jobId??null,part:e}),D(null),M(null),te(null))},close:()=>se(null)}),[oe,ce]),ue=E!==null,de=j!==null,fe=F!==null,pe=oe!==null,me=R(L.voice.voiceConfigForChat,e?{chatId:e}:`skip`),[he,ge]=(0,B.useState)(null),_e=(0,B.useMemo)(()=>({active:he,setActive:ge,clearIf:e=>ge(t=>t?.messageId===e?null:t)}),[he]);(0,B.useEffect)(()=>{j8(),ge(null)},[e]);let ve=(0,B.useMemo)(()=>me?{...me,loaded:!0}:{enabled:!1,lang:`auto`,rate:1,autoRead:!1,engine:`browser`,loaded:!1},[me]);return(0,V.jsx)(zk,{runtime:n,children:(0,V.jsx)(O8.Provider,{value:ve,children:(0,V.jsx)(k8.Provider,{value:_e,children:(0,V.jsx)(P8.Provider,{value:r,children:(0,V.jsx)(I8.Provider,{value:i,children:(0,V.jsx)(L8.Provider,{value:a,children:(0,V.jsx)(ZU.Provider,{value:s,children:(0,V.jsx)(R8.Provider,{value:o,children:(0,V.jsx)(M8.Provider,{value:u,children:(0,V.jsx)(BB.Provider,{value:v,children:(0,V.jsx)(R6.Provider,{value:ne,children:(0,V.jsx)(l6.Provider,{value:re,children:(0,V.jsx)(fH.Provider,{value:le,children:(0,V.jsx)(w6.Provider,{value:ie,children:(0,V.jsx)(c8.Provider,{value:ae,children:(0,V.jsxs)(Rve,{children:[(0,V.jsxs)(`div`,{className:`oc-chat`,children:[(0,V.jsx)(`div`,{className:`oc-chat__convo`,children:e?x?(0,V.jsx)(Yye,{}):(0,V.jsx)($ye,{chatId:e,showTools:d,onToggleTools:()=>void y({key:`showTools`,value:!d}),focusMessageId:t??null,initialLoading:c}):(0,V.jsx)(`div`,{className:`oc-empty`,children:tr()})}),(ue||de||fe||pe)&&!S?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`oc-sources-resizer`,onPointerDown:fe?ee:de?k:w,role:`separator`,"aria-orientation":`vertical`,"aria-label":xc()}),(0,V.jsx)(`aside`,{className:`oc-sources-col`,ref:e=>{T.current=e,A.current=e,P.current=e},style:{width:fe?N:de?O:C,flex:`0 0 ${fe?N:de?O:C}px`},children:pe?(0,V.jsx)(kH,{instanceName:oe.instanceName,part:oe.part,onClose:le.close}):fe?(0,V.jsx)(u8,{doc:F,chatId:e,onClose:ae.close}):de?(0,V.jsx)(d6,{chatId:e,childKey:j,onClose:re.close,parentAgentLabel:HB(v)}):(0,V.jsx)(z6,{messageId:E,onClose:ne.close})})]}):null]}),ue&&S?(0,V.jsx)(J6,{open:!0,onOpenChange:e=>{e||ne.close()},children:(0,V.jsx)(Y6,{side:`right`,className:`oc-sources-panel-sheet`,children:(0,V.jsx)(z6,{messageId:E,onClose:ne.close})})}):null,de&&S?(0,V.jsx)(J6,{open:!0,onOpenChange:e=>{e||re.close()},children:(0,V.jsx)(Y6,{side:`right`,className:`oc-sources-panel-sheet`,children:(0,V.jsx)(d6,{chatId:e,childKey:j,onClose:re.close,parentAgentLabel:HB(v)})})}):null,pe&&S?(0,V.jsx)(J6,{open:!0,onOpenChange:e=>{e||le.close()},children:(0,V.jsx)(Y6,{side:`right`,className:`oc-sources-panel-sheet`,children:(0,V.jsx)(kH,{instanceName:oe.instanceName,part:oe.part,onClose:le.close})})}):null,fe&&S?(0,V.jsx)(J6,{open:!0,onOpenChange:e=>{e||ae.close()},children:(0,V.jsx)(Y6,{side:`right`,className:`oc-sources-panel-sheet oc-docviewer-sheet`,children:(0,V.jsx)(u8,{doc:F,chatId:e,onClose:ae.close})})}):null]})})})})})})})})})})})})})})})})}function Yye(){let e=Fg();return(0,V.jsxs)(`div`,{className:`oc-notfound`,role:`status`,children:[(0,V.jsx)(`div`,{className:`oc-notfound__icon`,"aria-hidden":!0,children:(0,V.jsx)(WS,{size:28})}),(0,V.jsx)(`h2`,{className:`oc-notfound__title`,children:we()}),(0,V.jsx)(`p`,{className:`oc-notfound__body`,children:Fe()}),(0,V.jsxs)(`button`,{type:`button`,className:`oc-notfound__cta`,onClick:()=>void e({to:`/`}),children:[(0,V.jsx)(HS,{size:16,"aria-hidden":!0}),li()]})]})}function Xye(e,t){let n=CSS.highlights,r=window.Highlight;if(!n||!r)return null;let i=t.map(e=>e.toLowerCase()).filter(e=>e.length>=2);if(i.length===0)return null;let a=[],o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=o.nextNode();e;e=o.nextNode()){let t=(e.textContent??``).toLowerCase();for(let n of i){let r=t.indexOf(n);for(;r!==-1;){let i=document.createRange();if(i.setStart(e,r),i.setEnd(e,r+n.length),a.push(i),a.length>=200)break;r=t.indexOf(n,r+n.length)}if(a.length>=200)break}if(a.length>=200)break}return a.length===0?null:(n.set(`oc-search-terms`,new r(...a)),()=>n.delete(`oc-search-terms`))}function Zye(e,t){(0,B.useEffect)(()=>{if(!t)return;let e=!1,n=0,r=0,i=null,a=()=>{if(e)return;let o=document.querySelector(`[data-message-id="${CSS.escape(t)}"]`);if(o){o.scrollIntoView({block:`center`,behavior:`smooth`}),o.classList.remove(`oc-msg--highlight`),o.offsetWidth,o.classList.add(`oc-msg--highlight`),window.setTimeout(()=>o.classList.remove(`oc-msg--highlight`),2400);let e=Wve(t);e&&(i=Xye(o,e.split(/\s+/).filter(Boolean)));return}n++<40&&(r=window.setTimeout(a,150))};return r=window.setTimeout(a,0),()=>{e=!0,window.clearTimeout(r),i?.()}},[e,t])}function Qye(){return(0,V.jsx)(`div`,{className:`oc-thread-skeleton`,role:`status`,"aria-label":Ce(),children:[72,38,84,56,64].map((e,t)=>(0,V.jsx)(`div`,{className:`oc-thread-skeleton__row${t%2?` oc-thread-skeleton__row--user`:``}`,children:(0,V.jsx)(`span`,{className:`oc-thread-skeleton__bubble`,style:{width:`${e}%`}})},t))})}function $ye({chatId:e,showTools:t,onToggleTools:n,focusMessageId:r,initialLoading:i}){let a=R(L.bridgeHealth.getBridgeAvailability,{chatId:e}),o=z8()?.selected??null,s=R(L.bridgeHealth.getBridgeAvailability,{chatId:e,...o?{routedAgent:{instanceName:o.instanceName,agentId:o.agentId}}:{}}),c=s&&!s.available?s:null,l=a?.available===!0&&a.degraded===!0,u=s?.available===!0&&s.degraded===!0,d=R(L.agents.getChatAgent,{chatId:e})?.readOnly===!0,f=R(L.subAgents.listSubAgents,{chatId:e}),p=rve(f??[]),m=La(L.subAgents.reconcileTaskEngagements),h=(f??[]).some(e=>e.kind===`task`&&e.status===`running`),g=4*6e4,_=(f??[]).reduce((e,t)=>t.kind===`task`&&t.updatedAt>e?t.updatedAt:e,0),v=(0,B.useRef)({chatId:null,seenStamp:0,armedAtLocal:0});if(v.current.chatId!==(e??null)&&(v.current={chatId:e??null,seenStamp:0,armedAtLocal:0}),_>0&&v.current.seenStamp!==_){let t=v.current.seenStamp===0,n=Date.now()-_<10*6e4;v.current={chatId:e??null,seenStamp:_,armedAtLocal:t&&!n?0:Date.now()}}let y=v.current.armedAtLocal>0&&Date.now()-v.current.armedAtLocal<g;(0,B.useEffect)(()=>{if(!h&&!y||!e)return;let t=!1,n=!1,r,i=()=>{if(t||n)return;let r=v.current.armedAtLocal+g;!h&&Date.now()>r||(n=!0,m({chatId:e}).catch(()=>{}).finally(()=>{n=!1}))};return i(),r=window.setInterval(i,3e4),()=>{t=!0,window.clearInterval(r)}},[h,y,e,m]);let b=R(L.subAgents.turnActivity,{chatId:e}),x=(R(L.messages.getStreamingText,{chatId:e})?.length??0)>0,S=b?.deliveringSince??null,C=b!==void 0,w=(0,B.useRef)(null),[T,E]=(0,B.useState)(null);(0,B.useEffect)(()=>{if(!C)return;if(w.current?.chatId!==e){w.current={chatId:e,key:S},E(null);return}if(S==null||S===w.current.key){S??(w.current={chatId:e,key:null},E(null));return}w.current={chatId:e,key:S},E(S);let t=window.setTimeout(()=>E(null),45e3);return()=>window.clearTimeout(t)},[C,S,e]);let D=S!=null&&T===S,O=!x&&(b?.running===!0||D),k=b?.anchorMessageId??null,[A,j]=(0,B.useState)(!1);(0,B.useEffect)(()=>{if(!O||k===null){j(!1);return}let e=()=>j(document.querySelector(`[data-message-id="${CSS.escape(k)}"]`)!==null);e();let t=window.setInterval(e,2e3);return()=>window.clearInterval(t)},[O,k]);let M=O&&k!==null&&A?{messageId:k,running:b?.running===!0}:null;return Zye(e,r),(0,V.jsx)(YU.Provider,{value:l,children:(0,V.jsx)(F8.Provider,{value:M,children:(0,V.jsx)(sW,{chatId:e,focusMessageId:r,children:(0,V.jsxs)(iB.Root,{className:`oc-thread`,children:[(0,V.jsx)(abe,{chatId:e}),(0,V.jsx)(rbe,{chatId:e}),i?(0,V.jsx)(Qye,{}):null,(0,V.jsxs)(iB.Viewport,{className:`oc-thread__viewport`,style:i?{display:`none`}:void 0,children:[(0,V.jsx)(iB.Empty,{children:(0,V.jsx)(ibe,{})}),(0,V.jsx)(iB.Messages,{components:{UserMessage:Sbe,AssistantMessage:Tbe,SystemMessage:Ebe}}),O&&M===null?(0,V.jsx)(H8,{running:b?.running===!0}):null]}),(0,V.jsx)(uW,{}),(0,V.jsx)(`div`,{className:`oc-scrolldown-anchor`,children:(0,V.jsx)(iB.If,{empty:!1,children:(0,V.jsxs)(iB.ScrollToBottom,{className:`oc-scrolldown`,children:[(0,V.jsx)(ube,{}),(0,V.jsx)(`span`,{children:of()})]})})}),d?(0,V.jsx)(nbe,{}):c?(0,V.jsx)(tbe,{reason:c.reason}):u?(0,V.jsx)(ebe,{}):null,(0,V.jsx)(Nbe,{chatId:e,showTools:t,onToggleTools:n,unavailable:c!==null||d,subAgentBusy:p})]})})})})}function H8({running:e,anchored:t=!1}){return(0,V.jsxs)(`div`,{className:`oc-turn-activity${t?` oc-turn-activity--anchored`:``}`,role:`status`,children:[(0,V.jsxs)(`span`,{className:`oc-dots`,"aria-hidden":!0,children:[(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{})]}),(0,V.jsx)(`span`,{children:e?$u():Jl()})]})}function ebe(){return(0,V.jsxs)(`div`,{className:`oc-chat-banner oc-chat-banner--warn`,role:`status`,children:[(0,V.jsx)(_S,{size:16,"aria-hidden":!0}),(0,V.jsx)(`span`,{children:fe()})]})}function tbe({reason:e}){let t=e===`instance_unreachable`?fl():Xr();return(0,V.jsxs)(`div`,{className:`oc-chat-banner oc-chat-banner--error`,role:`status`,children:[(0,V.jsx)(_S,{size:16,"aria-hidden":!0}),(0,V.jsx)(`span`,{children:t})]})}function nbe(){return(0,V.jsxs)(`div`,{className:`oc-chat-banner oc-chat-banner--error`,role:`status`,children:[(0,V.jsx)(NS,{size:16,"aria-hidden":!0}),(0,V.jsx)(`span`,{children:yf()})]})}function rbe({chatId:e}){let t=R(L.messages.listByChat,{chatId:e}),[n,r]=(0,B.useState)(``),i=(0,B.useRef)(null);return(0,B.useEffect)(()=>{i.current=null,r(``)},[e]),(0,B.useEffect)(()=>{if(!t)return;let e;for(let n of t)n.role===`assistant`&&(e=n);if(!(!e||e.status!==`complete`)){if(i.current===null){i.current=e._id;return}i.current!==e._id&&(i.current=e._id,r(e=>e===Do()?`${Do()} `:Do()))}},[t]),(0,V.jsx)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,className:`oc-sr-only`,children:n})}function ibe(){return(0,V.jsxs)(`div`,{className:`oc-emptystate`,children:[(0,V.jsx)(B8,{className:`oc-emptystate__avatar`}),(0,V.jsx)(`h2`,{className:`oc-emptystate__title`,children:Pf()})]})}function U8({chatId:e}){let t=z8()?.selected??null,n=S6(R(L.agents.usageForChat,{chatId:e,...t?{routedAgent:{instanceName:t.instanceName,agentId:t.agentId}}:{}})?.usage??null,Date.now());if(!n)return null;let r=n.windows.map(e=>`${e.provider} ${e.label}: ${e.percentLeft}%`+(e.resetText?` ⏱${e.resetText}`:``)).join(` · `);return(0,V.jsxs)(`span`,{className:`oc-meter ${n.level}`,title:zu({detail:r}),children:[(0,V.jsx)(`span`,{className:`oc-meter__track`,children:(0,V.jsx)(`span`,{className:`oc-meter__fill`,style:{width:`${100-n.percentLeft}%`}})}),(0,V.jsx)(`span`,{className:`oc-meter__label`,children:wc({pct:n.percentLeft})})]})}function W8({sm:e,detail:t=!0}){let n=b8(e),r=n!=null&&e.contextTokens&&e.contextTokens>0?Math.round(n/e.contextTokens*100):null;return r==null||n==null?null:(0,V.jsxs)(`span`,{className:`oc-meter ${r>=90?`is-critical`:r>=75?`is-warn`:`is-ok`}`,title:po({pct:r,used:v8(n),total:v8(e.contextTokens)}),children:[(0,V.jsx)(`span`,{className:`oc-meter__track`,children:(0,V.jsx)(`span`,{className:`oc-meter__fill`,style:{width:`${Math.min(r,100)}%`}})}),(0,V.jsxs)(`span`,{className:`oc-meter__label`,children:[r,`%`,t?(0,V.jsxs)(`span`,{className:`oc-meter__detail`,children:[` · `,v8(n),`/`,v8(e.contextTokens)]}):null]})]})}function abe({chatId:e}){let t=R(L.messages.getSessionMeta,{chatId:e}),n=t?.sessionMeta??null,r=t?.sessionSettings??null,i=N8(),[a,o]=(0,B.useState)(!1),s=(0,B.useRef)(null),c=(0,B.useRef)(null),l=(0,B.useRef)(null),[d,f]=(0,B.useState)(!1),p=!_8(r,`thinkingLevel`),m=(a,s)=>(0,V.jsxs)(V.Fragment,{children:[i.showTools&&!a&&n?.model?(0,V.jsxs)(`span`,{className:`oc-chip oc-chip--info`,title:n.modelProvider?jd({provider:n.modelProvider}):as(),children:[(0,V.jsx)(cbe,{}),(0,V.jsx)(`span`,{className:`oc-chip__label`,children:n.model})]}):null,i.showTools&&!a&&n?.thinkingLevel?(0,V.jsxs)(`span`,{className:`oc-chip oc-chip--info`,title:p?al():Uo(),children:[(0,V.jsx)(lbe,{}),(0,V.jsxs)(`span`,{className:`oc-chip__label`,children:[td(),`\xA0: `,y8(n.thinkingLevel)]}),p?(0,V.jsx)(`span`,{className:`oc-chip__hint`,children:Xl()}):null]}):null,i.showTools&&n?(0,V.jsx)(W8,{sm:n,detail:!a}):null,i.showUsage&&!n?(0,V.jsx)(U8,{chatId:e}):null,(0,V.jsx)(obe,{chatId:e,title:t?.title??null,compact:a,ghost:s}),n?(0,V.jsx)(sbe,{chatId:e,sm:n,settings:r,onOpenPanel:()=>o(!0),compact:a,ghost:s,showUsage:i.showUsage}):null]});return(0,B.useLayoutEffect)(()=>{let e=s.current;if(!e)return;let t=()=>{let t=l.current?.offsetWidth??0;if(t===0)return;let n=Math.min(c.current?.scrollWidth??0,360),r=e.clientWidth-n-16<t;f(e=>e===r?e:r)};t();let n=new ResizeObserver(t);return n.observe(e),l.current&&n.observe(l.current),()=>n.disconnect()},[[u(),xa(),n?.model??``,n?.thinkingLevel??``,t?.title??``,i.showTools?`1`:`0`].join(`|`)]),(0,V.jsxs)(`header`,{className:`oc-chathead`,ref:s,children:[(0,V.jsx)(`div`,{className:`oc-chathead__title`,title:t?.title??void 0,ref:c,children:t?.title||Wd()}),(0,V.jsx)(`div`,{className:`oc-chathead__meta`,children:m(d,!1)}),(0,V.jsx)(`div`,{className:`oc-chathead-ghost`,"aria-hidden":!0,ref:l,children:m(!1,!0)}),(0,V.jsx)(Jye,{chatId:e,open:a,onOpenChange:o})]})}function G8(e,t,n){let r=new Blob([e],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}function obe({chatId:e,title:t,compact:n=!1,ghost:r=!1}){let i=wr();async function a(n){let[r,a]=await Promise.all([i.query(L.messages.listByChat,{chatId:e}),i.query(L.messages.getStreamingText,{chatId:e})]),o=new Map(a.map(e=>[e.messageId,e.text])),s=r.map(e=>({role:e.role,text:e.status===`streaming`?o.get(e._id)??e.text:e.text,createdAt:e.updatedAt??e._creationTime,parts:e.parts.map(e=>({kind:e.kind,filename:`filename`in e?e.filename:void 0,name:`name`in e?e.name:void 0}))})),c=r.length>=200,l={title:t??void 0,truncated:c,exportedAt:Date.now()},u=bV(t);n===`md`?G8(vV(s,l),`${u}.md`,`text/markdown`):G8(yV(s,l),`${u}.json`,`application/json`)}let o=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(CS,{size:13,"aria-hidden":!0}),n?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`oc-chip__label`,children:u()}),(0,V.jsx)(up,{size:13,className:`oc-chip__chev`,"aria-hidden":!0})]})]});return r?(0,V.jsx)(`span`,{className:`oc-chip oc-chip--btn`,children:o}):(0,V.jsxs)(xV,{children:[(0,V.jsx)(SV,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`oc-chip oc-chip--btn`,title:_s(),children:o})}),(0,V.jsxs)(CV,{align:`end`,className:`w-44`,children:[(0,V.jsx)(TV,{children:u()}),(0,V.jsx)(wV,{onClick:()=>void a(`md`),children:xr()}),(0,V.jsx)(wV,{onClick:()=>void a(`json`),children:Pa()})]})]})}function sbe({chatId:e,sm:t,settings:n,onOpenPanel:r,compact:i=!1,ghost:a=!1,showUsage:o=!1}){let[s,c]=(0,B.useState)(!1),l=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(KS,{size:13,"aria-hidden":!0}),i?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`oc-chip__label`,children:xa()}),(0,V.jsx)(up,{size:13,className:`oc-chip__chev`,"aria-hidden":!0})]})]});return a?(0,V.jsx)(`span`,{className:`oc-chip oc-chip--btn`,children:l}):(0,V.jsxs)(PV,{open:s,onOpenChange:c,children:[(0,V.jsx)(FV,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`oc-chip oc-chip--btn`,title:ca(),children:l})}),(0,V.jsxs)(IV,{align:`end`,className:`oc-spanel-pop w-80 p-2`,children:[b8(t)!=null&&t.contextTokens?(0,V.jsxs)(`div`,{className:`oc-spanel-pop__usage`,children:[(0,V.jsx)(`span`,{className:`oc-spanel-pop__usage-label`,children:gd()}),(0,V.jsx)(W8,{sm:t})]}):null,o?(0,V.jsxs)(`div`,{className:`oc-spanel-pop__usage`,children:[(0,V.jsx)(`span`,{className:`oc-spanel-pop__usage-label`,children:pi()}),(0,V.jsx)(U8,{chatId:e})]}):null,(0,V.jsx)(w8,{chatId:e,sm:t,settings:n}),(0,V.jsxs)(`button`,{type:`button`,className:`oc-spanel-pop__all`,onClick:()=>{c(!1),r()},children:[(0,V.jsx)(KS,{size:13,"aria-hidden":!0}),Zo(),(0,V.jsx)(gS,{size:13,"aria-hidden":!0})]})]})]})}function cbe(){return(0,V.jsxs)(`svg`,{className:`oc-chip__icon`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,V.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`}),(0,V.jsx)(`rect`,{x:`9`,y:`9`,width:`6`,height:`6`}),(0,V.jsx)(`path`,{d:`M9 1v3M15 1v3M9 20v3M15 20v3M20 9h3M20 14h3M1 9h3M1 14h3`})]})}function lbe(){return(0,V.jsxs)(`svg`,{className:`oc-chip__icon`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,V.jsx)(`path`,{d:`M12 5a3 3 0 1 0-5.997.142 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`}),(0,V.jsx)(`path`,{d:`M12 5a3 3 0 1 1 5.997.142 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z`})]})}function K8({children:e}){return(0,V.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:e})}function ube(){return(0,V.jsx)(K8,{children:(0,V.jsx)(`path`,{d:`M12 5v14M19 12l-7 7-7-7`})})}var dbe=`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md`,q8=`focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`;function fbe({sourceShown:e,sourceActive:t,onToggleSource:n}){let r=Yk(e=>e.metadata?.custom?.messageId),i=Yk(e=>e.metadata?.custom?.sentAt),a=Yk(e=>e.metadata?.custom?.generationMs??null),o=Yk(e=>e.metadata?.custom?.status===`streaming`),s=p(L.chatFork.forkChat),c=ZV(),l=uH(),[u,d]=(0,B.useState)(!1);if(!r)return null;let f=async()=>{let e=await c({title:bi(),description:N(),label:Vc(),placeholder:Yf(),confirmLabel:yt(),allowEmpty:!0});if(e!==null){d(!0);try{let{chatId:t}=await s({branchMessageId:r,...e.trim()?{title:e.trim()}:{}});rH(t,{expand:!0}),l.success(Ni())}catch(e){l.error(Pr(),e)}finally{d(!1)}}};return(0,V.jsxs)(UI.Root,{children:[(0,V.jsx)(UI.Trigger,{className:`oc-iconbtn`,title:Pt(),"aria-label":Pt(),disabled:u,children:(0,V.jsx)(Gne,{size:15})}),(0,V.jsxs)(UI.Content,{align:`end`,sideOffset:4,className:dbe,children:[i===void 0?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`oc-msgmenu__when px-2 py-1.5 text-sm`,children:[kV(i,{dateStyle:`medium`,timeStyle:`short`}),(()=>{let e=a===null?null:NV(a);return e===null?null:(0,V.jsxs)(`span`,{className:`oc-msgmenu__duration`,children:[(0,V.jsx)(mre,{size:12,"aria-hidden":!0}),ya({duration:e})]})})()]}),(0,V.jsx)(UI.Separator,{className:`bg-border -mx-1 my-1 h-px`})]}),e?(0,V.jsxs)(UI.Item,{className:q8,onSelect:n,children:[(0,V.jsx)(xS,{size:14,"aria-hidden":!0}),t?Sr():Fa()]}):null,(0,V.jsxs)(UI.Item,{className:q8,disabled:u||o,onSelect:()=>void f(),children:[(0,V.jsx)(qne,{size:14,"aria-hidden":!0}),bi()]}),(0,V.jsx)(pbe,{})]})]})}function pbe(){let e=aW(),t=Yk(e=>e.id);if(!e)return null;let n=e.byMessage.get(t)?.some(e=>e.blockIndex===null)??!1;return(0,V.jsxs)(UI.Item,{className:q8,onSelect:()=>e.toggle(t,null),children:[(0,V.jsx)(dS,{size:14,"aria-hidden":!0}),n?cd():Xo()]})}function mbe(){let[e,t]=(0,B.useState)(!1),n=Yk(e=>e.content.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(`
228
+ `]},t))})]})}function Sye({text:e}){let t=(0,B.useMemo)(()=>{try{return{ok:!0,value:JSON.parse(e,(e,t,n)=>{if(typeof t==`number`&&Number.isInteger(t)&&!Number.isSafeInteger(t)&&typeof n?.source==`string`&&/^-?\d+$/.test(n.source))try{return BigInt(n.source)}catch{return t}return t})}}catch{return{ok:!1}}},[e]);return t.ok?(0,V.jsx)(`div`,{className:`oc-docviewer__jsonwrap`,children:(0,V.jsx)(p8,{value:t.value,depth:0})}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`oc-docviewer__truncated`,children:Qd()}),(0,V.jsx)(`pre`,{className:`oc-docviewer__text`,children:e})]})}function Cye(e){if(Array.isArray(e))return e.length;let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function wye(e,t){if(Array.isArray(e))return e.slice(0,t).map((e,t)=>[String(t),e]);let n=[];for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(n.length>=t)break;n.push([r,e[r]])}return n}function p8({value:e,depth:t,name:n}){let r=typeof e==`object`&&!!e,i=r?Cye(e):0,[a,o]=(0,B.useState)(t<2&&i<=100),s=n===void 0?null:(0,V.jsxs)(`span`,{className:`oc-json__key`,children:[n,`: `]});if(!r)return(0,V.jsxs)(`div`,{className:`oc-json__leaf`,children:[s,(0,V.jsx)(`span`,{className:`oc-json__val oc-json__val--${e===null?`null`:typeof e==`bigint`?`number`:typeof e}`,children:typeof e==`bigint`?e.toString():JSON.stringify(e)})]});let c=a?wye(e,500):[];return(0,V.jsxs)(`details`,{className:`oc-json__node`,open:a,onToggle:e=>o(e.target.open),children:[(0,V.jsxs)(`summary`,{children:[s,(0,V.jsx)(`span`,{className:`oc-json__summary`,children:Array.isArray(e)?`[${i}]`:`{${i}}`})]}),a?(0,V.jsxs)(`div`,{className:`oc-json__children`,children:[c.map(([e,n])=>(0,V.jsx)(p8,{name:e,value:n,depth:t+1},e)),i>c.length?(0,V.jsx)(`div`,{className:`oc-json__more`,children:ro({count:i-c.length})}):null]}):null]})}function Tye({mimeType:e,data:t,filename:n,storageId:r}){let i=e??``,a=t??``,o=n??`attachment`;return a?i.startsWith(`audio/`)?(0,V.jsxs)(`div`,{className:`oc-media oc-media--audio`,children:[(0,V.jsx)(`audio`,{controls:!0,preload:`metadata`,src:a,className:`oc-media__audio`,children:(0,V.jsx)(`a`,{href:a,download:o,children:vr()})}),(0,V.jsx)(`span`,{className:`oc-media__name`,children:o})]}):i.startsWith(`image/`)?(0,V.jsx)(Dye,{url:a,name:o}):i.startsWith(`video/`)?(0,V.jsxs)(`div`,{className:`oc-media oc-media--video`,children:[(0,V.jsx)(`video`,{controls:!0,preload:`metadata`,src:a,className:`oc-media__video`}),(0,V.jsx)(`span`,{className:`oc-media__name`,children:o})]}):(0,V.jsx)(Eye,{url:a,name:o,mime:i,storageId:r}):null}function Eye({url:e,name:t,mime:n,storageId:r}){let i=l8(),a=n8(n,t)!==`none`,o=!!r&&e8(n,t),s=a||o,c=n=>{n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||n.button!==0||(n.preventDefault(),(async()=>{try{let n=await fetch(e);if(!n.ok)throw Error(`HTTP ${n.status}`);let r=URL.createObjectURL(await n.blob()),i=document.createElement(`a`);i.href=r,i.download=t,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),3e4)}catch{let t=window.open(``,`_blank`);t?(t.opener=null,t.location.href=e):window.location.href=e}})())};return(0,V.jsxs)(`span`,{className:`oc-media oc-media--file oc-filechip`,title:t,children:[(0,V.jsxs)(`a`,{className:`oc-filechip__main`,href:e,target:`_blank`,rel:`noopener noreferrer`,onClick:c,"aria-label":Sn({name:t}),children:[(0,V.jsx)(`span`,{className:`oc-media__icon`,"aria-hidden":!0,children:`📄`}),(0,V.jsx)(`span`,{className:`oc-media__name`,children:t})]}),(0,V.jsx)(`a`,{className:`oc-filechip__btn`,href:e,target:`_blank`,rel:`noopener noreferrer`,onClick:c,title:Sn({name:t}),"aria-label":Sn({name:t}),children:(0,V.jsx)(CS,{size:14,"aria-hidden":!0})}),s?(0,V.jsx)(`button`,{type:`button`,className:`oc-filechip__btn`,onClick:()=>i.openFor({url:e,filename:t,mimeType:n||null,storageId:r,sourceStorageId:o?r:void 0}),title:Xn({name:t}),"aria-label":Xn({name:t}),children:(0,V.jsx)(Vne,{size:14,"aria-hidden":!0})}):null]})}function Dye({url:e,name:t}){let{open:n}=Lve();return(0,V.jsx)(`button`,{type:`button`,className:`oc-media oc-media--thumb`,onClick:()=>n({url:e,name:t}),title:t,"aria-label":t,children:(0,V.jsx)(`img`,{src:e,alt:t,className:`oc-media__thumbimg`,loading:`lazy`,decoding:`async`})})}var m8=1e3;function Oye(){return[{id:`incorrect`,label:cr()},{id:`incoherence`,label:Me()},{id:`altered_words`,label:Ue()},{id:`formatting`,label:_i()},{id:`latency`,label:mf()},{id:`api_error`,label:xe()},{id:`other`,label:ai()}]}function kye(){return[{id:`altered_words`,label:kf()},{id:`formatting`,label:Ro()},{id:`other`,label:ai()}]}function Aye(e){return e===`user`?kye():Oye()}var jye=[{name:`Grammarly`,selector:`grammarly-desktop-integration, grammarly-extension, [data-grammarly-shadow-root]`},{name:`LanguageTool`,selector:`[data-lt-installed], .lt-toolbar`},{name:`DeepL`,selector:`deepl-inline-translate, .deepl-translator`},{name:`ProWritingAad`,selector:`pwa-shadow-host, .pwa-tag`}];function Mye(){let e=[];try{e=Array.from(navigator.plugins??[]).map(e=>e.name).slice(0,40)}catch{e=[]}let t=[];for(let{name:e,selector:n}of jye)try{document.querySelector(n)&&t.push(e)}catch{}return{plugins:e,extensionsDetected:t}}var h8=B.createContext(null);function Nye(){let e=B.useContext(h8);if(!e)throw Error(`useFeedback must be used within <FeedbackProvider>`);return e}function Pye({children:e}){let t=p(L.feedback.submitFeedback),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(``),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(null),[f,m]=(0,B.useState)(null),[h,g]=(0,B.useState)(!1),_=B.useCallback(e=>{a(``),s(``),l(!1),d(null),m(null),g(!1),r(e)},[]);function v(e){e||r(null)}async function y(){if(!(!n||!i||c)){l(!0);try{let e=await t({chatId:n.chatId,messageId:n.messageId,category:i,comment:o.trim()||void 0,client:{displayedText:n.displayedText,sourceWasOpen:n.sourceWasOpen,userAgent:navigator.userAgent,language:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,theme:document.documentElement.classList.contains(`dark`)?`dark`:`light`,...Mye()}});d(e.displayedMatchesStored),m(String(e.reference??e.feedbackId))}catch{l(!1)}}}let b=u!==null,x=n?.role===`user`;return(0,V.jsxs)(h8.Provider,{value:_,children:[e,(0,V.jsx)(WB,{open:n!==null,onOpenChange:v,children:n?(0,V.jsxs)(qB,{className:`sm:max-w-md`,children:[(0,V.jsxs)(JB,{children:[(0,V.jsx)(XB,{children:Kf()}),(0,V.jsx)(ZB,{children:b?tf():x?oo():rc()})]}),b?(0,V.jsxs)(`div`,{className:`oc-feedback__result`,role:`status`,children:[n.sourceWasOpen?u===!0?(0,V.jsx)(`p`,{className:`oc-feedback__fidelity is-ok`,children:yc()}):(0,V.jsx)(`p`,{className:`oc-feedback__fidelity is-warn`,children:kl()}):(0,V.jsx)(`p`,{className:`oc-feedback__fidelity`,children:bu()}),f?(0,V.jsxs)(`div`,{className:`oc-feedback__ref`,children:[(0,V.jsx)(`span`,{className:`oc-feedback__ref-label`,children:Da()}),(0,V.jsx)(`code`,{className:`oc-feedback__ref-id`,title:f,children:f}),(0,V.jsx)(`button`,{type:`button`,className:`oc-iconbtn`,title:Qt(),"aria-label":Qt(),onClick:()=>{navigator.clipboard.writeText(f).then(()=>{g(!0),window.setTimeout(()=>g(!1),1500)})},children:h?(0,V.jsx)(cp,{size:14}):(0,V.jsx)(SS,{size:14})})]}):null]}):(0,V.jsxs)(`div`,{className:`oc-feedback__form`,children:[(0,V.jsx)(`label`,{className:`oc-feedback__label`,children:Vs()}),(0,V.jsxs)(X3,{value:i,onValueChange:a,children:[(0,V.jsx)(Q3,{children:(0,V.jsx)(Z3,{placeholder:ms()})}),(0,V.jsx)($3,{children:Aye(n.role).map(e=>(0,V.jsx)(e6,{value:e.id,children:e.label},e.id))})]}),(0,V.jsx)(`label`,{className:`oc-feedback__label`,htmlFor:`oc-feedback-comment`,children:Bd()}),(0,V.jsx)(`textarea`,{id:`oc-feedback-comment`,className:`oc-feedback__textarea`,placeholder:hl(),value:o,maxLength:m8,onChange:e=>s(e.target.value.slice(0,m8)),rows:4}),(0,V.jsxs)(`div`,{className:`oc-feedback__count`,children:[o.length,`/`,m8]})]}),(0,V.jsx)(YB,{children:b?(0,V.jsx)(Ep,{onClick:()=>v(!1),children:$o()}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ep,{variant:`outline`,onClick:()=>v(!1),children:dd()}),(0,V.jsx)(Ep,{onClick:()=>void y(),disabled:!i||c,children:c?au():So()})]})})]}):null})]})}function Fye(e,t){let n=e.closest(`.oc-msg`)?.querySelector(`.oc-msg__source-pre`),r=n?.textContent;return n&&r!=null&&r!==`(aucun texte)`?{displayedText:r,sourceWasOpen:!0}:{displayedText:t,sourceWasOpen:!1}}function g8(){let e=Nye(),t=Yk(e=>e.metadata?.custom?.messageId),n=Yk(e=>e.metadata?.custom?.chatId),r=Yk(e=>e.role),i=Yk(e=>e.metadata?.custom?.rawText??``),a=R(L.feedback.myReportedMessageIds,n?{chatId:n}:`skip`);if(!t||!n)return null;let o=(a??[]).includes(t);function s(a){e({chatId:n,messageId:t,role:r,...Fye(a.currentTarget,i)})}return(0,V.jsx)(`button`,{type:`button`,className:`oc-iconbtn${o?` is-on`:``}`,title:o?Fc():Xu(),"aria-label":Wl(),onClick:s,children:(0,V.jsx)(OS,{size:15,"aria-hidden":!0})})}function _8(e,t){return e!=null&&e[t]!==void 0}var Iye=[`inherit`,`fast`,`standard`];function Lye(e){return e==null||e.fastMode===void 0?`inherit`:e.fastMode?`fast`:`standard`}function Rye(e){return e===`inherit`?fs():e===`fast`?Rd():pl()}function zye(e){return e===`inherit`?null:e===`fast`}function v8(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function y8(e){return e.length?e[0].toUpperCase()+e.slice(1):e}var Bye={off:`Off`,minimal:`Min`,low:`Low`,medium:`Med`,high:`High`,xhigh:`XHigh`};function Vye(e,t){return Bye[e]??t}function b8(e){return e?e.activeTokens==null?e.totalTokens==null||e.contextTokens&&e.totalTokens>e.contextTokens?null:e.totalTokens:e.activeTokens:null}function x8(e,t){return e==null||!t||t<=0?null:Math.round(e/t*100)}function Hye(e,t){let n=x8(e,t);return n===null?null:Dr({pct:n,used:v8(e),total:v8(t)})}function Uye(e){return ma({level:e??`full`})}function Wye(e,t){let n=typeof e==`number`,r=typeof t==`number`;return n&&r?Ou({cost:e.toFixed(2),tokens:v8(t)}):n?pn({cost:e.toFixed(2)}):r?ut({tokens:v8(t)}):null}function Gye(e){let t=e.filter(e=>typeof e==`string`&&e.length>0);return t.length>0?t.join(` · `):null}function Kye(e){let t=p(L.chats.setSessionKnob),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(null);return{apply:(0,B.useCallback)(async(n,i)=>{r(n),a(null);let o={chatId:e};n===`fastMode`?o.fastMode=i:o[n]=i;try{await t(o)}catch{a({field:n,value:i})}finally{r(null)}},[e,t]),pending:n,error:i}}function S8({label:e,overridden:t,onReset:n,pending:r,error:i,onRetry:a,help:o,children:s,resettable:c=!0}){return(0,V.jsxs)(`div`,{className:`oc-spanel__row${t?` is-overridden`:``}`,children:[(0,V.jsxs)(`div`,{className:`oc-spanel__rowhead`,children:[(0,V.jsx)(`span`,{className:`oc-spanel__label`,children:e}),r?(0,V.jsx)(MS,{size:13,className:`oc-spanel__spin`,"aria-label":tc()}):t?c?(0,V.jsx)(`button`,{type:`button`,className:`oc-spanel__reset`,title:ao(),"aria-label":ao(),onClick:n,children:(0,V.jsx)(US,{size:12,"aria-hidden":!0})}):null:(0,V.jsx)(`span`,{className:`oc-spanel__badge`,children:ef()})]}),(0,V.jsx)(`div`,{className:`oc-spanel__ctl`,children:s}),o?(0,V.jsx)(`p`,{className:`oc-spanel__help`,children:o}):null,i?(0,V.jsxs)(`p`,{className:`oc-spanel__error`,role:`alert`,children:[_c(),(0,V.jsx)(`button`,{type:`button`,className:`oc-spanel__retry`,onClick:a,children:Dl()})]}):null]})}function C8({options:e,value:t,onChange:n,disabled:r}){return(0,V.jsx)(`div`,{className:`oc-spanel__seg`,role:`group`,children:e.map(e=>(0,V.jsx)(`button`,{type:`button`,className:`oc-spanel__seg-btn${t===e.id?` is-active`:``}`,"aria-pressed":t===e.id,title:e.title??e.label,"aria-label":e.title??e.label,disabled:r,onClick:()=>{e.id!==t&&n(e.id)},children:e.label},e.id))})}function qye({options:e,value:t,onChange:n,disabled:r,ariaLabel:i}){let a=t===null||e.some(e=>e.id===t);return(0,V.jsxs)(`select`,{className:`oc-spanel__select`,value:t??``,disabled:r,"aria-label":i,onChange:e=>{e.target.value&&e.target.value!==t&&n(e.target.value)},children:[t===null?(0,V.jsx)(`option`,{value:``,disabled:!0,hidden:!0}):null,a?null:(0,V.jsx)(`option`,{value:t,children:t}),e.map(e=>(0,V.jsx)(`option`,{value:e.id,children:e.label},e.id))]})}function w8({chatId:e,sm:t,settings:n}){let{apply:r,pending:i,error:a}=Kye(e),{can:o}=p6(e),s=i!==null,c=(0,B.useCallback)(()=>{a&&r(a.field,a.value)},[r,a]),l=t.thinkingLevels??[],u=t.availableModels??[],d=Lye(n),f=Tve(o,{hasModels:u.length>0,hasLevels:l.length>0});return(0,V.jsxs)(V.Fragment,{children:[f.model?(0,V.jsx)(S8,{label:as(),overridden:_8(n,`model`),onReset:()=>void r(`model`,null),pending:i===`model`,error:a?.field===`model`,onRetry:c,resettable:f.reset,children:u.length<=4?(0,V.jsx)(C8,{options:u,value:t.model??null,onChange:e=>void r(`model`,e),disabled:s}):(0,V.jsx)(qye,{options:u,value:t.model??null,onChange:e=>void r(`model`,e),disabled:s,ariaLabel:as()})}):null,f.thinking?(0,V.jsx)(S8,{label:vu(),overridden:_8(n,`thinkingLevel`),onReset:()=>void r(`thinkingLevel`,null),pending:i===`thinkingLevel`,error:a?.field===`thinkingLevel`,onRetry:c,resettable:f.reset,children:(0,V.jsx)(C8,{options:l.map(e=>({id:e.id,label:Vye(e.id,y8(e.label)),title:y8(e.label)})),value:t.thinkingLevel??null,onChange:e=>void r(`thinkingLevel`,e),disabled:s})}):null,f.speed?(0,V.jsx)(S8,{label:zs(),overridden:_8(n,`fastMode`),onReset:()=>void r(`fastMode`,null),pending:i===`fastMode`,error:a?.field===`fastMode`,onRetry:c,resettable:f.reset,children:(0,V.jsx)(C8,{options:Iye.map(e=>({id:e,label:Rye(e)})),value:d,onChange:e=>void r(`fastMode`,zye(e)),disabled:s})}):null]})}function T8(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function E8({label:e,state:t,destructive:n,onClick:r,onRetry:i}){return(0,V.jsxs)(`div`,{className:`oc-spanel__action`,children:[(0,V.jsxs)(Ep,{variant:n?`destructive`:`outline`,size:`sm`,disabled:t===`pending`,onClick:r,children:[t===`pending`?(0,V.jsx)(MS,{className:`oc-spanel__spin`,"aria-hidden":!0}):null,e]}),t===`done`?(0,V.jsx)(`p`,{className:`oc-spanel__action-note`,role:`status`,children:Bt()}):null,t===`error`?(0,V.jsxs)(`p`,{className:`oc-spanel__error`,role:`alert`,children:[Ze(),(0,V.jsx)(`button`,{type:`button`,className:`oc-spanel__retry`,onClick:i,children:Dl()})]}):null]})}function Jye({chatId:e,open:t,onOpenChange:n}){let r=R(L.messages.getSessionMeta,t?{chatId:e}:`skip`),i=R(L.chatSummaries.getChatSummary,t?{chatId:e}:`skip`),a=R(L.agents.getChatAgent,t?{chatId:e}:`skip`),o=r?.sessionMeta??null,s=r?.sessionSettings??null,{can:c}=p6(t?e:null),l=XV(),u=La(L.agentFiles.compactSession),d=p(L.chats.resetSession),f=p(L.chatSummaries.requestSummarize),[m,h]=(0,B.useState)(`idle`),[g,v]=(0,B.useState)(`idle`),[y,b]=(0,B.useState)(`idle`),[x,S]=(0,B.useState)(null),[C,w]=(0,B.useState)(!1),[E,D]=(0,B.useState)(!1),[O,k]=(0,B.useState)(null),[A,j]=(0,B.useState)(`idle`),M=p(L.chatSummaries.updateSummary);(0,B.useEffect)(()=>{k(null),j(`idle`),D(!1),w(!1),S(null),b(`idle`)},[e]);async function N(){if(i?.summary)try{await navigator.clipboard.writeText(i.summary),w(!0),window.setTimeout(()=>w(!1),2e3)}catch{}}async function ee(){if(!(O===null||O.trim().length===0)){j(`saving`);try{await M({chatId:e,summary:O}),k(null),j(`idle`)}catch{j(`error`)}}}let[P,te]=(0,B.useState)(()=>Date.now()),re=i?.jobInFlight===!0;(0,B.useEffect)(()=>{if(!re)return;let e=window.setInterval(()=>te(Date.now()),1e3);return()=>window.clearInterval(e)},[re]);async function ie(){h(`pending`);try{await u({chatId:e}),h(`done`)}catch{h(`error`)}}async function ae(){b(`pending`),S(null);try{let{outcome:t}=await f({chatId:e});S(({dispatched:wn,in_flight:Lt,nothing_to_do:Je,scanning:Kd,bridge_outdated:sl,engine_off:pr,no_agent:Kn,backoff:Je}[t]??Je)()),b(t===`dispatched`||t===`scanning`?`done`:`idle`)}catch{b(`error`)}}async function oe(){v(`pending`);try{await d({chatId:e}),v(`done`)}catch{v(`error`)}}async function se(){await l({title:Ci(),description:wt(),confirmLabel:zi(),cancelLabel:it()})&&await ie()}async function ce(){await l({title:tp(),description:zr(),confirmLabel:En(),cancelLabel:it(),destructive:!0})&&await oe()}let le=b8(o),ue=x8(le??void 0,o?.contextTokens),de=ue==null?``:ue>=90?`is-critical`:ue>=75?`is-warn`:`is-ok`,fe=Hye(le??void 0,o?.contextTokens),pe=Wye(o?.estimatedCostUsd,o?.totalTokens),me=a?.agent??null,he=Gye([me?me.displayName??me.agentId:null,o?.agentRuntime,o?.model]);return(0,V.jsx)(J6,{open:t,onOpenChange:n,children:(0,V.jsxs)(Y6,{side:`right`,className:`oc-spanel`,children:[(0,V.jsxs)(X6,{children:[(0,V.jsx)(Q6,{children:ld()}),(0,V.jsx)($6,{children:ru()})]}),(0,V.jsx)(`div`,{className:`oc-spanel__body`,children:r===void 0?(0,V.jsx)(`p`,{className:`oc-spanel__loading`,children:st()}):(0,V.jsxs)(V.Fragment,{children:[o?(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`oc-spanel__cat`,children:bo()}),(0,V.jsx)(w8,{chatId:e,sm:o,settings:s})]}):null,(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`oc-spanel__cat`,children:Nc()}),fe!==null&&ue!==null?(0,V.jsxs)(`div`,{className:`oc-spanel__static`,children:[(0,V.jsx)(`span`,{className:`oc-spanel__label`,children:_()}),(0,V.jsxs)(`span`,{className:`oc-meter oc-spanel__meter ${de}`,children:[(0,V.jsx)(`span`,{className:`oc-meter__track`,children:(0,V.jsx)(`span`,{className:`oc-meter__fill`,style:{width:`${Math.min(ue,100)}%`}})}),(0,V.jsx)(`span`,{className:`oc-meter__label`,children:fe})]})]}):null,(0,V.jsxs)(`div`,{className:`oc-spanel__static`,children:[(0,V.jsx)(`span`,{className:`oc-spanel__label`,children:Ba()}),(0,V.jsx)(`span`,{className:`oc-spanel__value`,children:Uye(o?.verboseLevel)}),(0,V.jsx)(`p`,{className:`oc-spanel__help`,children:Oa()})]}),pe===null?null:(0,V.jsxs)(`div`,{className:`oc-spanel__static`,children:[(0,V.jsx)(`span`,{className:`oc-spanel__label`,children:$t()}),(0,V.jsx)(`span`,{className:`oc-spanel__value`,children:pe})]})]}),he!==null||o?(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`oc-spanel__cat`,children:wd()}),(0,V.jsxs)(`dl`,{className:`oc-spanel__kv`,children:[me?(0,V.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,V.jsx)(`dt`,{children:At()}),(0,V.jsxs)(`dd`,{children:[me.emoji?`${me.emoji} `:``,me.displayName??me.agentId]})]}):null,me?.instanceName?(0,V.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,V.jsx)(`dt`,{children:Ju()}),(0,V.jsx)(`dd`,{children:me.instanceName})]}):null,o?.model?(0,V.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,V.jsx)(`dt`,{children:id()}),(0,V.jsx)(`dd`,{children:o.model})]}):null,o?.modelProvider?(0,V.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,V.jsx)(`dt`,{children:Ql()}),(0,V.jsx)(`dd`,{children:o.modelProvider})]}):null,o?.agentRuntime?(0,V.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,V.jsx)(`dt`,{children:aa()}),(0,V.jsx)(`dd`,{children:o.agentRuntime})]}):null,o?.thinkingLevel?(0,V.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,V.jsx)(`dt`,{children:ho()}),(0,V.jsx)(`dd`,{children:o.thinkingLevel})]}):null,o?.thinkingDefault?(0,V.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,V.jsx)(`dt`,{children:Hl()}),(0,V.jsx)(`dd`,{children:o.thinkingDefault})]}):null]})]}):null,(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`oc-spanel__cat`,children:St()}),i?(0,V.jsxs)(`div`,{className:`oc-spanel__static`,children:[(0,V.jsx)(`span`,{className:`oc-spanel__label`,children:zc()}),(0,V.jsxs)(`span`,{className:`oc-meter oc-spanel__meter is-ok`,children:[(0,V.jsx)(`span`,{className:`oc-meter__track`,children:(0,V.jsx)(`span`,{className:`oc-meter__fill`,style:{width:`${Math.min(i.pendingChars/Math.max(i.thresholdChars,1)*100,100)}%`}})}),(0,V.jsx)(`span`,{className:`oc-meter__label`,children:T({pending:`${T8(i.pendingChars)}${i.pendingApprox?`+`:``}`,threshold:T8(i.thresholdChars)})})]})]}):null,i&&!i.jobInFlight&&i.pendingChars>=i.thresholdChars?(0,V.jsx)(`p`,{className:`oc-spanel__hint`,children:Jc()}):null,i?.jobInFlight?(0,V.jsxs)(`p`,{className:`oc-spanel__hint oc-spanel__job`,role:`status`,children:[(0,V.jsx)(MS,{size:13,className:`oc-spanel__job-spin`,"aria-hidden":!0}),i.jobStreaming?Js():Za(),i.jobStartedAt?` · ${Math.max(0,Math.round((P-i.jobStartedAt)/1e3))} s`:``]}):null,i&&i.summary.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`p`,{className:`oc-spanel__hint`,children:[Ii({count:String(i.coveredCount),date:kV(i.updatedAt,{dateStyle:`short`,timeStyle:`short`})}),i.lastAgentId?` ${In({agent:i.lastInstanceName?`${i.lastAgentId} (${i.lastInstanceName})`:i.lastAgentId})}`:``]}),i.failureCount>0?(0,V.jsx)(`p`,{className:`oc-spanel__hint oc-spanel__hint--warn`,children:F({count:String(i.failureCount)})}):null,(0,V.jsxs)(`div`,{className:`oc-spanel__summary-tools`,children:[(0,V.jsx)(Ep,{variant:`ghost`,size:`sm`,className:`oc-spanel__summary-tool`,onClick:()=>void N(),title:uc(),"aria-label":uc(),children:C?(0,V.jsx)(cp,{size:14,"aria-hidden":!0}):(0,V.jsx)(SS,{size:14,"aria-hidden":!0})}),(0,V.jsx)(Ep,{variant:`ghost`,size:`sm`,className:`oc-spanel__summary-tool`,onClick:()=>D(!0),title:bl(),"aria-label":bl(),children:(0,V.jsx)(FS,{size:14,"aria-hidden":!0})}),i.jobInFlight?null:(0,V.jsx)(Ep,{variant:`ghost`,size:`sm`,className:`oc-spanel__summary-tool`,onClick:()=>{k(i.summary),D(!0)},title:fu(),"aria-label":fu(),children:(0,V.jsx)(BS,{size:14,"aria-hidden":!0})})]}),(0,V.jsx)(`div`,{className:`oc-spanel__summary`,children:i.summary})]}):i&&i.failureCount>0?(0,V.jsx)(`p`,{className:`oc-spanel__hint oc-spanel__hint--warn`,children:F({count:String(i.failureCount)})}):i?.jobInFlight?null:(0,V.jsx)(`p`,{className:`oc-spanel__hint`,children:Qf()})]})]})}),(0,V.jsx)(WB,{open:E,onOpenChange:e=>{D(e),e||(k(null),j(`idle`))},children:(0,V.jsxs)(qB,{className:`oc-summary-dialog`,children:[(0,V.jsxs)(JB,{children:[(0,V.jsx)(XB,{children:St()}),(0,V.jsx)(ZB,{children:O===null?i&&i.summary.length>0?Ii({count:String(i.coveredCount),date:kV(i.updatedAt,{dateStyle:`short`,timeStyle:`short`})}):``:Nd()})]}),O===null?(0,V.jsx)(`div`,{className:`oc-summary-dialog__body`,children:i?.summary??``}):(0,V.jsx)(`textarea`,{className:`oc-summary-dialog__body oc-summary-dialog__edit`,value:O,onChange:e=>k(e.target.value)}),A===`error`?(0,V.jsx)(`p`,{className:`oc-spanel__hint oc-spanel__hint--warn`,children:ss()}):null,(0,V.jsx)(`div`,{className:`oc-summary-dialog__actions`,children:O===null?(0,V.jsxs)(V.Fragment,{children:[i&&i.summary.length>0&&!i.jobInFlight?(0,V.jsxs)(Ep,{variant:`outline`,size:`sm`,onClick:()=>k(i.summary),children:[(0,V.jsx)(BS,{size:14,"aria-hidden":!0}),fu()]}):null,(0,V.jsxs)(Ep,{variant:`outline`,size:`sm`,onClick:()=>void N(),children:[C?(0,V.jsx)(cp,{size:14,"aria-hidden":!0}):(0,V.jsx)(SS,{size:14,"aria-hidden":!0}),uc()]})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ep,{variant:`ghost`,size:`sm`,onClick:()=>{k(null),j(`idle`)},children:it()}),(0,V.jsx)(Ep,{size:`sm`,disabled:O.trim().length===0||A===`saving`,onClick:()=>void ee(),children:A===`saving`?tc():Ns()})]})})]})}),(0,V.jsxs)(Z6,{className:`oc-spanel__actions`,children:[(0,V.jsx)(`h3`,{className:`oc-spanel__cat`,children:Ts()}),c(`sessionCompact`)?(0,V.jsx)(E8,{label:$i(),state:m,onClick:()=>void se(),onRetry:()=>void ie()}):null,(0,V.jsx)(E8,{label:Lr(),state:re?`pending`:y,onClick:()=>void ae(),onRetry:()=>void ae()}),x===null?null:(0,V.jsx)(`p`,{className:`oc-spanel__hint`,children:x}),(0,V.jsx)(E8,{label:ne(),state:g,destructive:!0,onClick:()=>void ce(),onRetry:()=>void oe()})]})]})})}var D8={showSource:!0,showReport:!0,copyAssistant:!0,copyUser:!0,showDelete:!0,showTools:!1,voiceInput:!1,showUsage:!0,autoReadAloud:!0},O8=(0,B.createContext)({enabled:!1,lang:`auto`,rate:1,autoRead:!1,engine:`browser`,loaded:!1}),k8=(0,B.createContext)({active:null,setActive:()=>{},clearIf:()=>{}}),A8=0;function j8(){A8++,PH(),BH()}var M8=(0,B.createContext)(D8);function N8(){return(0,B.useContext)(M8)}var P8=(0,B.createContext)(null),F8=(0,B.createContext)(null),I8=(0,B.createContext)(null),L8=(0,B.createContext)(null),R8=(0,B.createContext)(null);function z8(){return(0,B.useContext)(R8)}function B8({className:e}){let t=VB();return(0,V.jsx)(`div`,{className:e,"aria-hidden":!0,children:t.logoUrl?t.logoMasked?(0,V.jsx)(`span`,{className:`oc-avatar__img oc-avatar__img--mask`,style:{"--oc-logo-url":`url("${t.logoUrl}")`}}):(0,V.jsx)(`img`,{className:`oc-avatar__img`,src:t.logoUrl,alt:``}):t.isDefault?(0,V.jsx)(zB,{className:`oc-avatar__mark`}):t.initials})}function V8({chatId:e,focusMessageId:t}){let{runtime:n,turnGate:r,queueSend:i,abortTurn:a,routing:o,lastUserTurnQueued:s,initialLoading:c}=FU({chatId:e}),l=R(L.me.getMe,{host:aB}),u=l?.ui?.effective??D8,d=u.showTools,f=EB(l?.resolvedThemeMode),m=l?.resolvedChartBrand,h=l?.resolvedChartTokens,g=R(L.agents.getChatAgent,e?{chatId:e}:`skip`),_=g?.multiAgent?g.agent:null,v=(0,B.useMemo)(()=>{let e=m?.label??`Atrium`,t=h?.colors?.[f],n=PB(m,LB(t?.primary,t?.[`primary-foreground`],f));return{label:e,logoUrl:n?.url??null,logoMasked:n?.masked??!1,isDefault:m?.isDefault??!0,initials:RB(e),agentName:_?.displayName??_?.agentId??null,agentEmoji:_?.emoji??null}},[m,f,h,_]),y=p(L.me.setUiPref).withOptimisticUpdate(IU),b=R(L.messages.getSessionMeta,e?{chatId:e}:`skip`),x=e!==null&&b===null,S=G6(),{width:C,startResize:w,columnRef:T}=K6({storageKey:`oc.sources.width`,defaultWidth:380,min:300,max:680,edge:`right`}),[E,D]=(0,B.useState)(null);(0,B.useEffect)(()=>{D(null)},[e]);let{width:O,startResize:k,columnRef:A}=K6({storageKey:`oc.subagent.width`,defaultWidth:460,min:320,max:720,edge:`right`}),[j,M]=(0,B.useState)(null);(0,B.useEffect)(()=>{M(null)},[e]);let{width:N,startResize:ee,columnRef:P}=K6({storageKey:`oc.docviewer.width`,defaultWidth:560,min:380,max:1800,maxViewportFraction:.72,edge:`right`}),[F,te]=(0,B.useState)(null);(0,B.useEffect)(()=>{te(null)},[e]);let ne=(0,B.useMemo)(()=>({activeMessageId:E,openFor:e=>{D(e),M(null),te(null),se(null)},close:()=>D(null)}),[E]),re=(0,B.useMemo)(()=>({activeChildKey:j,openFor:e=>{M(e),D(null),te(null),se(null)},close:()=>M(null)}),[j]),ie=(0,B.useRef)(null),ae=(0,B.useMemo)(()=>({activeDoc:F,openFor:e=>{te(e),D(null),M(null),se(null)},close:()=>te(null)}),[F]),[oe,se]=(0,B.useState)(null);(0,B.useEffect)(()=>{se(null)},[e]);let ce=g?.agent?.instanceName??null,le=(0,B.useMemo)(()=>({active:oe,openFor:(e,t)=>{let n=t??ce;n!==null&&(se({instanceName:n,jobId:e.jobId??null,part:e}),D(null),M(null),te(null))},close:()=>se(null)}),[oe,ce]),ue=E!==null,de=j!==null,fe=F!==null,pe=oe!==null,me=R(L.voice.voiceConfigForChat,e?{chatId:e}:`skip`),[he,ge]=(0,B.useState)(null),_e=(0,B.useMemo)(()=>({active:he,setActive:ge,clearIf:e=>ge(t=>t?.messageId===e?null:t)}),[he]);(0,B.useEffect)(()=>{j8(),ge(null)},[e]);let ve=(0,B.useMemo)(()=>me?{...me,loaded:!0}:{enabled:!1,lang:`auto`,rate:1,autoRead:!1,engine:`browser`,loaded:!1},[me]);return(0,V.jsx)(zk,{runtime:n,children:(0,V.jsx)(O8.Provider,{value:ve,children:(0,V.jsx)(k8.Provider,{value:_e,children:(0,V.jsx)(P8.Provider,{value:r,children:(0,V.jsx)(I8.Provider,{value:i,children:(0,V.jsx)(L8.Provider,{value:a,children:(0,V.jsx)(ZU.Provider,{value:s,children:(0,V.jsx)(R8.Provider,{value:o,children:(0,V.jsx)(M8.Provider,{value:u,children:(0,V.jsx)(BB.Provider,{value:v,children:(0,V.jsx)(R6.Provider,{value:ne,children:(0,V.jsx)(l6.Provider,{value:re,children:(0,V.jsx)(fH.Provider,{value:le,children:(0,V.jsx)(w6.Provider,{value:ie,children:(0,V.jsx)(c8.Provider,{value:ae,children:(0,V.jsxs)(Rve,{children:[(0,V.jsxs)(`div`,{className:`oc-chat`,children:[(0,V.jsx)(`div`,{className:`oc-chat__convo`,children:e?x?(0,V.jsx)(Yye,{}):(0,V.jsx)($ye,{chatId:e,showTools:d,onToggleTools:()=>void y({key:`showTools`,value:!d}),focusMessageId:t??null,initialLoading:c}):(0,V.jsx)(`div`,{className:`oc-empty`,children:tr()})}),(ue||de||fe||pe)&&!S?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`oc-sources-resizer`,onPointerDown:fe?ee:de?k:w,role:`separator`,"aria-orientation":`vertical`,"aria-label":xc()}),(0,V.jsx)(`aside`,{className:`oc-sources-col`,ref:e=>{T.current=e,A.current=e,P.current=e},style:{width:fe?N:de?O:C,flex:`0 0 ${fe?N:de?O:C}px`},children:pe?(0,V.jsx)(kH,{instanceName:oe.instanceName,part:oe.part,onClose:le.close}):fe?(0,V.jsx)(u8,{doc:F,chatId:e,onClose:ae.close}):de?(0,V.jsx)(d6,{chatId:e,childKey:j,onClose:re.close,parentAgentLabel:HB(v)}):(0,V.jsx)(z6,{messageId:E,onClose:ne.close})})]}):null]}),ue&&S?(0,V.jsx)(J6,{open:!0,onOpenChange:e=>{e||ne.close()},children:(0,V.jsx)(Y6,{side:`right`,className:`oc-sources-panel-sheet`,children:(0,V.jsx)(z6,{messageId:E,onClose:ne.close})})}):null,de&&S?(0,V.jsx)(J6,{open:!0,onOpenChange:e=>{e||re.close()},children:(0,V.jsx)(Y6,{side:`right`,className:`oc-sources-panel-sheet`,children:(0,V.jsx)(d6,{chatId:e,childKey:j,onClose:re.close,parentAgentLabel:HB(v)})})}):null,pe&&S?(0,V.jsx)(J6,{open:!0,onOpenChange:e=>{e||le.close()},children:(0,V.jsx)(Y6,{side:`right`,className:`oc-sources-panel-sheet`,children:(0,V.jsx)(kH,{instanceName:oe.instanceName,part:oe.part,onClose:le.close})})}):null,fe&&S?(0,V.jsx)(J6,{open:!0,onOpenChange:e=>{e||ae.close()},children:(0,V.jsx)(Y6,{side:`right`,className:`oc-sources-panel-sheet oc-docviewer-sheet`,children:(0,V.jsx)(u8,{doc:F,chatId:e,onClose:ae.close})})}):null]})})})})})})})})})})})})})})})})}function Yye(){let e=Fg();return(0,V.jsxs)(`div`,{className:`oc-notfound`,role:`status`,children:[(0,V.jsx)(`div`,{className:`oc-notfound__icon`,"aria-hidden":!0,children:(0,V.jsx)(WS,{size:28})}),(0,V.jsx)(`h2`,{className:`oc-notfound__title`,children:we()}),(0,V.jsx)(`p`,{className:`oc-notfound__body`,children:Fe()}),(0,V.jsxs)(`button`,{type:`button`,className:`oc-notfound__cta`,onClick:()=>void e({to:`/`}),children:[(0,V.jsx)(HS,{size:16,"aria-hidden":!0}),li()]})]})}function Xye(e,t){let n=CSS.highlights,r=window.Highlight;if(!n||!r)return null;let i=t.map(e=>e.toLowerCase()).filter(e=>e.length>=2);if(i.length===0)return null;let a=[],o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=o.nextNode();e;e=o.nextNode()){let t=(e.textContent??``).toLowerCase();for(let n of i){let r=t.indexOf(n);for(;r!==-1;){let i=document.createRange();if(i.setStart(e,r),i.setEnd(e,r+n.length),a.push(i),a.length>=200)break;r=t.indexOf(n,r+n.length)}if(a.length>=200)break}if(a.length>=200)break}return a.length===0?null:(n.set(`oc-search-terms`,new r(...a)),()=>n.delete(`oc-search-terms`))}function Zye(e,t){(0,B.useEffect)(()=>{if(!t)return;let e=!1,n=0,r=0,i=null,a=()=>{if(e)return;let o=document.querySelector(`[data-message-id="${CSS.escape(t)}"]`);if(o){o.scrollIntoView({block:`center`,behavior:`smooth`}),o.classList.remove(`oc-msg--highlight`),o.offsetWidth,o.classList.add(`oc-msg--highlight`),window.setTimeout(()=>o.classList.remove(`oc-msg--highlight`),2400);let e=Wve(t);e&&(i=Xye(o,e.split(/\s+/).filter(Boolean)));return}n++<40&&(r=window.setTimeout(a,150))};return r=window.setTimeout(a,0),()=>{e=!0,window.clearTimeout(r),i?.()}},[e,t])}function Qye(){return(0,V.jsx)(`div`,{className:`oc-thread-skeleton`,role:`status`,"aria-label":Ce(),children:[72,38,84,56,64].map((e,t)=>(0,V.jsx)(`div`,{className:`oc-thread-skeleton__row${t%2?` oc-thread-skeleton__row--user`:``}`,children:(0,V.jsx)(`span`,{className:`oc-thread-skeleton__bubble`,style:{width:`${e}%`}})},t))})}function $ye({chatId:e,showTools:t,onToggleTools:n,focusMessageId:r,initialLoading:i}){let a=R(L.bridgeHealth.getBridgeAvailability,{chatId:e}),o=z8()?.selected??null,s=R(L.bridgeHealth.getBridgeAvailability,{chatId:e,...o?{routedAgent:{instanceName:o.instanceName,agentId:o.agentId}}:{}}),c=s&&!s.available?s:null,l=a?.available===!0&&a.degraded===!0,u=s?.available===!0&&s.degraded===!0,d=R(L.agents.getChatAgent,{chatId:e})?.readOnly===!0,f=R(L.subAgents.listSubAgents,{chatId:e}),p=rve(f??[]),m=La(L.subAgents.reconcileTaskEngagements),h=(f??[]).some(e=>e.kind===`task`&&e.status===`running`),g=4*6e4,_=(f??[]).reduce((e,t)=>t.kind===`task`&&t.updatedAt>e?t.updatedAt:e,0),v=(0,B.useRef)({chatId:null,seenStamp:0,armedAtLocal:0});if(v.current.chatId!==(e??null)&&(v.current={chatId:e??null,seenStamp:0,armedAtLocal:0}),_>0&&v.current.seenStamp!==_){let t=v.current.seenStamp===0,n=Date.now()-_<10*6e4;v.current={chatId:e??null,seenStamp:_,armedAtLocal:t&&!n?0:Date.now()}}let y=v.current.armedAtLocal>0&&Date.now()-v.current.armedAtLocal<g;(0,B.useEffect)(()=>{if(!h&&!y||!e)return;let t=!1,n=!1,r,i=()=>{if(t||n)return;let r=v.current.armedAtLocal+g;!h&&Date.now()>r||(n=!0,m({chatId:e}).catch(()=>{}).finally(()=>{n=!1}))};return i(),r=window.setInterval(i,3e4),()=>{t=!0,window.clearInterval(r)}},[h,y,e,m]);let b=R(L.subAgents.turnActivity,{chatId:e}),x=(R(L.messages.getStreamingText,{chatId:e})?.length??0)>0,S=b?.deliveringSince??null,C=b!==void 0,w=(0,B.useRef)(null),[T,E]=(0,B.useState)(null);(0,B.useEffect)(()=>{if(!C)return;if(w.current?.chatId!==e){w.current={chatId:e,key:S},E(null);return}if(S==null||S===w.current.key){S??(w.current={chatId:e,key:null},E(null));return}w.current={chatId:e,key:S},E(S);let t=window.setTimeout(()=>E(null),45e3);return()=>window.clearTimeout(t)},[C,S,e]);let D=S!=null&&T===S,O=b?.runningTtlRemainingMs??null,[k,A]=(0,B.useState)(!1);(0,B.useEffect)(()=>{if(A(!1),b?.running!==!0||O===null)return;let e=window.setTimeout(()=>A(!0),O);return()=>window.clearTimeout(e)},[b?.running,O,e]);let j=b?.running===!0&&!k,M=!x&&(j||D),N=b?.anchorMessageId??null,[ee,P]=(0,B.useState)(!1);(0,B.useEffect)(()=>{if(!M||N===null){P(!1);return}let e=()=>P(document.querySelector(`[data-message-id="${CSS.escape(N)}"]`)!==null);e();let t=window.setInterval(e,2e3);return()=>window.clearInterval(t)},[M,N]);let F=M&&N!==null&&ee?{messageId:N,running:j}:null;return Zye(e,r),(0,V.jsx)(YU.Provider,{value:l,children:(0,V.jsx)(F8.Provider,{value:F,children:(0,V.jsx)(sW,{chatId:e,focusMessageId:r,children:(0,V.jsxs)(iB.Root,{className:`oc-thread`,children:[(0,V.jsx)(abe,{chatId:e}),(0,V.jsx)(rbe,{chatId:e}),i?(0,V.jsx)(Qye,{}):null,(0,V.jsxs)(iB.Viewport,{className:`oc-thread__viewport`,style:i?{display:`none`}:void 0,children:[(0,V.jsx)(iB.Empty,{children:(0,V.jsx)(ibe,{})}),(0,V.jsx)(iB.Messages,{components:{UserMessage:Sbe,AssistantMessage:Tbe,SystemMessage:Ebe}}),M&&F===null?(0,V.jsx)(H8,{running:j}):null]}),(0,V.jsx)(uW,{}),(0,V.jsx)(`div`,{className:`oc-scrolldown-anchor`,children:(0,V.jsx)(iB.If,{empty:!1,children:(0,V.jsxs)(iB.ScrollToBottom,{className:`oc-scrolldown`,children:[(0,V.jsx)(ube,{}),(0,V.jsx)(`span`,{children:of()})]})})}),d?(0,V.jsx)(nbe,{}):c?(0,V.jsx)(tbe,{reason:c.reason}):u?(0,V.jsx)(ebe,{}):null,(0,V.jsx)(Nbe,{chatId:e,showTools:t,onToggleTools:n,unavailable:c!==null||d,subAgentBusy:p})]})})})})}function H8({running:e,anchored:t=!1}){return(0,V.jsxs)(`div`,{className:`oc-turn-activity${t?` oc-turn-activity--anchored`:``}`,role:`status`,children:[(0,V.jsxs)(`span`,{className:`oc-dots`,"aria-hidden":!0,children:[(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{}),(0,V.jsx)(`span`,{})]}),(0,V.jsx)(`span`,{children:e?$u():Jl()})]})}function ebe(){return(0,V.jsxs)(`div`,{className:`oc-chat-banner oc-chat-banner--warn`,role:`status`,children:[(0,V.jsx)(_S,{size:16,"aria-hidden":!0}),(0,V.jsx)(`span`,{children:fe()})]})}function tbe({reason:e}){let t=e===`instance_unreachable`?fl():Xr();return(0,V.jsxs)(`div`,{className:`oc-chat-banner oc-chat-banner--error`,role:`status`,children:[(0,V.jsx)(_S,{size:16,"aria-hidden":!0}),(0,V.jsx)(`span`,{children:t})]})}function nbe(){return(0,V.jsxs)(`div`,{className:`oc-chat-banner oc-chat-banner--error`,role:`status`,children:[(0,V.jsx)(NS,{size:16,"aria-hidden":!0}),(0,V.jsx)(`span`,{children:yf()})]})}function rbe({chatId:e}){let t=R(L.messages.listByChat,{chatId:e}),[n,r]=(0,B.useState)(``),i=(0,B.useRef)(null);return(0,B.useEffect)(()=>{i.current=null,r(``)},[e]),(0,B.useEffect)(()=>{if(!t)return;let e;for(let n of t)n.role===`assistant`&&(e=n);if(!(!e||e.status!==`complete`)){if(i.current===null){i.current=e._id;return}i.current!==e._id&&(i.current=e._id,r(e=>e===Do()?`${Do()} `:Do()))}},[t]),(0,V.jsx)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,className:`oc-sr-only`,children:n})}function ibe(){return(0,V.jsxs)(`div`,{className:`oc-emptystate`,children:[(0,V.jsx)(B8,{className:`oc-emptystate__avatar`}),(0,V.jsx)(`h2`,{className:`oc-emptystate__title`,children:Pf()})]})}function U8({chatId:e}){let t=z8()?.selected??null,n=S6(R(L.agents.usageForChat,{chatId:e,...t?{routedAgent:{instanceName:t.instanceName,agentId:t.agentId}}:{}})?.usage??null,Date.now());if(!n)return null;let r=n.windows.map(e=>`${e.provider} ${e.label}: ${e.percentLeft}%`+(e.resetText?` ⏱${e.resetText}`:``)).join(` · `);return(0,V.jsxs)(`span`,{className:`oc-meter ${n.level}`,title:zu({detail:r}),children:[(0,V.jsx)(`span`,{className:`oc-meter__track`,children:(0,V.jsx)(`span`,{className:`oc-meter__fill`,style:{width:`${100-n.percentLeft}%`}})}),(0,V.jsx)(`span`,{className:`oc-meter__label`,children:wc({pct:n.percentLeft})})]})}function W8({sm:e,detail:t=!0}){let n=b8(e),r=n!=null&&e.contextTokens&&e.contextTokens>0?Math.round(n/e.contextTokens*100):null;return r==null||n==null?null:(0,V.jsxs)(`span`,{className:`oc-meter ${r>=90?`is-critical`:r>=75?`is-warn`:`is-ok`}`,title:po({pct:r,used:v8(n),total:v8(e.contextTokens)}),children:[(0,V.jsx)(`span`,{className:`oc-meter__track`,children:(0,V.jsx)(`span`,{className:`oc-meter__fill`,style:{width:`${Math.min(r,100)}%`}})}),(0,V.jsxs)(`span`,{className:`oc-meter__label`,children:[r,`%`,t?(0,V.jsxs)(`span`,{className:`oc-meter__detail`,children:[` · `,v8(n),`/`,v8(e.contextTokens)]}):null]})]})}function abe({chatId:e}){let t=R(L.messages.getSessionMeta,{chatId:e}),n=t?.sessionMeta??null,r=t?.sessionSettings??null,i=N8(),[a,o]=(0,B.useState)(!1),s=(0,B.useRef)(null),c=(0,B.useRef)(null),l=(0,B.useRef)(null),[d,f]=(0,B.useState)(!1),p=!_8(r,`thinkingLevel`),m=(a,s)=>(0,V.jsxs)(V.Fragment,{children:[i.showTools&&!a&&n?.model?(0,V.jsxs)(`span`,{className:`oc-chip oc-chip--info`,title:n.modelProvider?jd({provider:n.modelProvider}):as(),children:[(0,V.jsx)(cbe,{}),(0,V.jsx)(`span`,{className:`oc-chip__label`,children:n.model})]}):null,i.showTools&&!a&&n?.thinkingLevel?(0,V.jsxs)(`span`,{className:`oc-chip oc-chip--info`,title:p?al():Uo(),children:[(0,V.jsx)(lbe,{}),(0,V.jsxs)(`span`,{className:`oc-chip__label`,children:[td(),`\xA0: `,y8(n.thinkingLevel)]}),p?(0,V.jsx)(`span`,{className:`oc-chip__hint`,children:Xl()}):null]}):null,i.showTools&&n?(0,V.jsx)(W8,{sm:n,detail:!a}):null,i.showUsage&&!n?(0,V.jsx)(U8,{chatId:e}):null,(0,V.jsx)(obe,{chatId:e,title:t?.title??null,compact:a,ghost:s}),n?(0,V.jsx)(sbe,{chatId:e,sm:n,settings:r,onOpenPanel:()=>o(!0),compact:a,ghost:s,showUsage:i.showUsage}):null]});return(0,B.useLayoutEffect)(()=>{let e=s.current;if(!e)return;let t=()=>{let t=l.current?.offsetWidth??0;if(t===0)return;let n=Math.min(c.current?.scrollWidth??0,360),r=e.clientWidth-n-16<t;f(e=>e===r?e:r)};t();let n=new ResizeObserver(t);return n.observe(e),l.current&&n.observe(l.current),()=>n.disconnect()},[[u(),xa(),n?.model??``,n?.thinkingLevel??``,t?.title??``,i.showTools?`1`:`0`].join(`|`)]),(0,V.jsxs)(`header`,{className:`oc-chathead`,ref:s,children:[(0,V.jsx)(`div`,{className:`oc-chathead__title`,title:t?.title??void 0,ref:c,children:t?.title||Wd()}),(0,V.jsx)(`div`,{className:`oc-chathead__meta`,children:m(d,!1)}),(0,V.jsx)(`div`,{className:`oc-chathead-ghost`,"aria-hidden":!0,ref:l,children:m(!1,!0)}),(0,V.jsx)(Jye,{chatId:e,open:a,onOpenChange:o})]})}function G8(e,t,n){let r=new Blob([e],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}function obe({chatId:e,title:t,compact:n=!1,ghost:r=!1}){let i=wr();async function a(n){let[r,a]=await Promise.all([i.query(L.messages.listByChat,{chatId:e}),i.query(L.messages.getStreamingText,{chatId:e})]),o=new Map(a.map(e=>[e.messageId,e.text])),s=r.map(e=>({role:e.role,text:e.status===`streaming`?o.get(e._id)??e.text:e.text,createdAt:e.updatedAt??e._creationTime,parts:e.parts.map(e=>({kind:e.kind,filename:`filename`in e?e.filename:void 0,name:`name`in e?e.name:void 0}))})),c=r.length>=200,l={title:t??void 0,truncated:c,exportedAt:Date.now()},u=bV(t);n===`md`?G8(vV(s,l),`${u}.md`,`text/markdown`):G8(yV(s,l),`${u}.json`,`application/json`)}let o=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(CS,{size:13,"aria-hidden":!0}),n?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`oc-chip__label`,children:u()}),(0,V.jsx)(up,{size:13,className:`oc-chip__chev`,"aria-hidden":!0})]})]});return r?(0,V.jsx)(`span`,{className:`oc-chip oc-chip--btn`,children:o}):(0,V.jsxs)(xV,{children:[(0,V.jsx)(SV,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`oc-chip oc-chip--btn`,title:_s(),children:o})}),(0,V.jsxs)(CV,{align:`end`,className:`w-44`,children:[(0,V.jsx)(TV,{children:u()}),(0,V.jsx)(wV,{onClick:()=>void a(`md`),children:xr()}),(0,V.jsx)(wV,{onClick:()=>void a(`json`),children:Pa()})]})]})}function sbe({chatId:e,sm:t,settings:n,onOpenPanel:r,compact:i=!1,ghost:a=!1,showUsage:o=!1}){let[s,c]=(0,B.useState)(!1),l=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(KS,{size:13,"aria-hidden":!0}),i?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`oc-chip__label`,children:xa()}),(0,V.jsx)(up,{size:13,className:`oc-chip__chev`,"aria-hidden":!0})]})]});return a?(0,V.jsx)(`span`,{className:`oc-chip oc-chip--btn`,children:l}):(0,V.jsxs)(PV,{open:s,onOpenChange:c,children:[(0,V.jsx)(FV,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:`oc-chip oc-chip--btn`,title:ca(),children:l})}),(0,V.jsxs)(IV,{align:`end`,className:`oc-spanel-pop w-80 p-2`,children:[b8(t)!=null&&t.contextTokens?(0,V.jsxs)(`div`,{className:`oc-spanel-pop__usage`,children:[(0,V.jsx)(`span`,{className:`oc-spanel-pop__usage-label`,children:gd()}),(0,V.jsx)(W8,{sm:t})]}):null,o?(0,V.jsxs)(`div`,{className:`oc-spanel-pop__usage`,children:[(0,V.jsx)(`span`,{className:`oc-spanel-pop__usage-label`,children:pi()}),(0,V.jsx)(U8,{chatId:e})]}):null,(0,V.jsx)(w8,{chatId:e,sm:t,settings:n}),(0,V.jsxs)(`button`,{type:`button`,className:`oc-spanel-pop__all`,onClick:()=>{c(!1),r()},children:[(0,V.jsx)(KS,{size:13,"aria-hidden":!0}),Zo(),(0,V.jsx)(gS,{size:13,"aria-hidden":!0})]})]})]})}function cbe(){return(0,V.jsxs)(`svg`,{className:`oc-chip__icon`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,V.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`}),(0,V.jsx)(`rect`,{x:`9`,y:`9`,width:`6`,height:`6`}),(0,V.jsx)(`path`,{d:`M9 1v3M15 1v3M9 20v3M15 20v3M20 9h3M20 14h3M1 9h3M1 14h3`})]})}function lbe(){return(0,V.jsxs)(`svg`,{className:`oc-chip__icon`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,V.jsx)(`path`,{d:`M12 5a3 3 0 1 0-5.997.142 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`}),(0,V.jsx)(`path`,{d:`M12 5a3 3 0 1 1 5.997.142 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z`})]})}function K8({children:e}){return(0,V.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:e})}function ube(){return(0,V.jsx)(K8,{children:(0,V.jsx)(`path`,{d:`M12 5v14M19 12l-7 7-7-7`})})}var dbe=`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md`,q8=`focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`;function fbe({sourceShown:e,sourceActive:t,onToggleSource:n}){let r=Yk(e=>e.metadata?.custom?.messageId),i=Yk(e=>e.metadata?.custom?.sentAt),a=Yk(e=>e.metadata?.custom?.generationMs??null),o=Yk(e=>e.metadata?.custom?.status===`streaming`),s=p(L.chatFork.forkChat),c=ZV(),l=uH(),[u,d]=(0,B.useState)(!1);if(!r)return null;let f=async()=>{let e=await c({title:bi(),description:N(),label:Vc(),placeholder:Yf(),confirmLabel:yt(),allowEmpty:!0});if(e!==null){d(!0);try{let{chatId:t}=await s({branchMessageId:r,...e.trim()?{title:e.trim()}:{}});rH(t,{expand:!0}),l.success(Ni())}catch(e){l.error(Pr(),e)}finally{d(!1)}}};return(0,V.jsxs)(UI.Root,{children:[(0,V.jsx)(UI.Trigger,{className:`oc-iconbtn`,title:Pt(),"aria-label":Pt(),disabled:u,children:(0,V.jsx)(Gne,{size:15})}),(0,V.jsxs)(UI.Content,{align:`end`,sideOffset:4,className:dbe,children:[i===void 0?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`oc-msgmenu__when px-2 py-1.5 text-sm`,children:[kV(i,{dateStyle:`medium`,timeStyle:`short`}),(()=>{let e=a===null?null:NV(a);return e===null?null:(0,V.jsxs)(`span`,{className:`oc-msgmenu__duration`,children:[(0,V.jsx)(mre,{size:12,"aria-hidden":!0}),ya({duration:e})]})})()]}),(0,V.jsx)(UI.Separator,{className:`bg-border -mx-1 my-1 h-px`})]}),e?(0,V.jsxs)(UI.Item,{className:q8,onSelect:n,children:[(0,V.jsx)(xS,{size:14,"aria-hidden":!0}),t?Sr():Fa()]}):null,(0,V.jsxs)(UI.Item,{className:q8,disabled:u||o,onSelect:()=>void f(),children:[(0,V.jsx)(qne,{size:14,"aria-hidden":!0}),bi()]}),(0,V.jsx)(pbe,{})]})]})}function pbe(){let e=aW(),t=Yk(e=>e.id);if(!e)return null;let n=e.byMessage.get(t)?.some(e=>e.blockIndex===null)??!1;return(0,V.jsxs)(UI.Item,{className:q8,onSelect:()=>e.toggle(t,null),children:[(0,V.jsx)(dS,{size:14,"aria-hidden":!0}),n?cd():Xo()]})}function mbe(){let[e,t]=(0,B.useState)(!1),n=Yk(e=>e.content.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(`
229
229
  `)),r=qU(Yk(e=>e.metadata?.custom?.error??null),Yk(e=>e.metadata?.custom?.errorCode??null)),i=n.trim()||[r.headline,r.detail].filter(Boolean).join(`
230
230
  `),a=i.length===0;return(0,V.jsx)(`button`,{type:`button`,className:`oc-iconbtn`,title:Yi(),"aria-label":Yi(),disabled:a,onClick:()=>{navigator.clipboard.writeText(i).then(()=>{t(!0),window.setTimeout(()=>t(!1),1500)})},children:e?(0,V.jsx)(Y8,{}):(0,V.jsx)(J8,{})})}function hbe(e){let t=(0,B.useContext)(O8),n=(0,B.useContext)(k8),r=Yk(e=>e.metadata?.custom?.messageId??e.id),i=N8().autoReadAloud,a=Yk(e=>e.metadata?.custom?.status??``),o=(0,B.useRef)(null);(0,B.useEffect)(()=>{if(!t.loaded)return;let s=o.current;o.current=a,!(!t.enabled||!t.autoRead||t.engine===`gateway`||!i||!MH())&&(a!==`complete`||s===null||s===`complete`||e.trim()&&NH(jH(e),{lang:AH(t.lang,Tu()),rate:t.rate,onEnd:()=>n.clearIf(r)})&&n.setActive({messageId:r,phase:`playing`}))},[a,e,t,n,r,i])}function gbe(){let e=(0,B.useContext)(O8),t=(0,B.useContext)(k8),n=La(L.voice.gatewayTts),r=uH(),i=Yk(e=>e.metadata?.custom?.messageId??e.id),a=Yk(e=>e.metadata?.custom?.chatId??null),o=Yk(e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
231
231
  `)),s=e.engine!==`gateway`;if(!e.enabled||!o.trim()||s&&!MH())return null;let c=AH(e.lang,Tu()),l=t.active?.messageId===i,u=l&&t.active?.phase===`loading`,d=l&&t.active?.phase===`playing`,f=()=>{j8();let l=jH(o);if(s){let n=NH(l,{lang:c,rate:e.rate,onEnd:()=>t.clearIf(i)});t.setActive(n?{messageId:i,phase:`playing`}:null);return}if(!a)return;let u=A8;t.setActive({messageId:i,phase:`loading`}),n({chatId:a,text:l.slice(0,1500)}).then(({mime:n,audioBase64:r})=>{if(u!==A8)return;let a=zH(r,n,{rate:e.rate,onEnd:()=>t.clearIf(i)});t.setActive(a?{messageId:i,phase:`playing`}:null)}).catch(e=>{u===A8&&(r.error(Df(),e),t.setActive(null))})};return(0,V.jsx)(`button`,{type:`button`,className:`oc-iconbtn${l?` oc-iconbtn--reading`:``}`,title:l?Ai():oa(),"aria-label":l?Ai():oa(),"aria-pressed":l,"aria-busy":u,onClick:()=>{if(l){j8(),t.setActive(null);return}f()},children:u?(0,V.jsx)(MS,{size:16,className:`oc-actrow__spin`,"aria-hidden":!0}):d?(0,V.jsx)(ybe,{}):(0,V.jsx)(vbe,{})})}function _be(){let e=(0,B.useContext)(k8);if(!e.active)return null;let t=e.active.phase===`loading`;return(0,V.jsxs)(`div`,{className:`oc-reading-banner`,role:`status`,children:[t?(0,V.jsx)(MS,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,V.jsx)(ZS,{size:14,className:`oc-reading-banner__pulse`,"aria-hidden":!0}),(0,V.jsx)(`span`,{children:t?Io():Wf()}),(0,V.jsx)(`button`,{type:`button`,className:`oc-reading-banner__stop`,onClick:()=>{j8(),e.setActive(null)},children:Ai()})]})}function vbe(){return(0,V.jsxs)(K8,{children:[(0,V.jsx)(`path`,{d:`M11 5 6 9H2v6h4l5 4V5z`}),(0,V.jsx)(`path`,{d:`M15.5 8.5a5 5 0 0 1 0 7`})]})}function ybe(){return(0,V.jsxs)(K8,{children:[(0,V.jsx)(`path`,{d:`M11 5 6 9H2v6h4l5 4V5z`}),(0,V.jsx)(`line`,{x1:`22`,y1:`9`,x2:`16`,y2:`15`}),(0,V.jsx)(`line`,{x1:`16`,y1:`9`,x2:`22`,y2:`15`})]})}function J8(){return(0,V.jsxs)(K8,{children:[(0,V.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`}),(0,V.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})}function Y8(){return(0,V.jsx)(K8,{children:(0,V.jsx)(`path`,{d:`M20 6 9 17l-5-5`})})}var X8={File:Tye},bbe={...X8,Text:K_e};function Z8({kind:e}){let t=Yk(e=>e.metadata?.custom?.messageId),n=p(L.messages.deleteMessage).withOptimisticUpdate(LU),r=XV(),i=uH(),a=(0,B.useContext)(P8),[o,s]=(0,B.useState)(!1),c=Zk(e=>e.isRunning);if(!t)return null;async function l(){if(await r(e===`assistant`?{title:qt(),description:Su(),confirmLabel:sn(),cancelLabel:it(),destructive:!0}:{title:Ji(),description:yi(),confirmLabel:vt(),cancelLabel:it(),destructive:!0})){s(!0),e===`assistant`&&a?.begin();try{await n({messageId:t})}catch(t){e===`assistant`&&a?.cancel(),i.error(Nr(),t)}finally{s(!1)}}}return(0,V.jsx)(`button`,{type:`button`,className:`oc-iconbtn oc-iconbtn--danger`,title:c?Ct():e===`assistant`?Mi():M(),"aria-label":Jf(),"aria-busy":o,disabled:o||c,onClick:()=>void l(),children:o?(0,V.jsx)(MS,{size:15,className:`oc-iconbtn__spin`,"aria-hidden":!0}):(0,V.jsx)(YS,{size:15,"aria-hidden":!0})})}function Q8(){let e=Yk(e=>e.metadata?.custom?.rawText??``),t=Yk(e=>e.metadata?.custom?.chatId),n=Yk(e=>e.metadata?.custom?.messageId),r=Yk(e=>e.metadata?.custom?.toolParts??$8),i=R(L.subAgents.listSubAgents,e===``&&t?{chatId:t}:`skip`),a=e===``?i6(i??[],h6(r),n).find(e=>e.status===`done`&&e.resultText)?.resultText??``:``,o=e===``&&a!==``,s=e===``?a:e,[c,l]=(0,B.useState)(!1),u=[...s].length;return(0,V.jsxs)(`div`,{className:`oc-msg__source`,children:[(0,V.jsxs)(`div`,{className:`oc-msg__source-head`,children:[(0,V.jsx)(`span`,{className:`oc-msg__source-label`,children:o?pd({count:u}):u>1?jl({count:u}):Iu({count:u})}),(0,V.jsx)(`button`,{type:`button`,className:`oc-iconbtn`,title:hs(),"aria-label":hs(),onClick:()=>{navigator.clipboard?.writeText(s).then(()=>{l(!0),window.setTimeout(()=>l(!1),1200)})},children:c?(0,V.jsx)(Y8,{}):(0,V.jsx)(J8,{})})]}),(0,V.jsx)(`pre`,{className:`oc-msg__source-pre`,children:s.length>0?s:d()})]})}function xbe({active:e,onToggle:t}){return(0,V.jsx)(`button`,{type:`button`,className:`oc-iconbtn${e?` is-on`:``}`,onClick:t,"aria-pressed":e,title:e?Sr():Fa(),"aria-label":la(),children:(0,V.jsx)(xS,{size:15,"aria-hidden":!0})})}function Sbe(){let[e,t]=(0,B.useState)(!1),n=N8(),r=Yk(e=>e.id.startsWith(`optimistic-`)),i=Yk(e=>e.metadata?.custom?.queued===!0),a=Yk(e=>e.id);return(0,V.jsx)(Sz.Root,{className:`oc-msg oc-msg--user${r?` is-sending`:``}${i?` is-queued`:``}`,"data-message-id":a,children:(0,V.jsxs)(`div`,{className:`oc-msg__col oc-msg__col--user`,children:[(0,V.jsx)(dW,{}),(0,V.jsx)(`div`,{className:`oc-msg__bubble`,children:e?(0,V.jsx)(Q8,{}):(0,V.jsx)(Sz.Parts,{components:X8})}),r?(0,V.jsxs)(`span`,{className:`oc-msg__sending`,role:`status`,children:[(0,V.jsx)(`span`,{className:`oc-msg__sending-spin`,"aria-hidden":!0}),Jt()]}):i?(0,V.jsxs)(`span`,{className:`oc-msg__queued`,role:`status`,children:[(0,V.jsx)(bS,{size:12,"aria-hidden":!0}),Cu()]}):(0,V.jsxs)(AA.Root,{className:`oc-msg__actions oc-msg__actions--user`,autohide:`not-last`,children:[(0,V.jsx)(mW,{}),n.copyUser?(0,V.jsxs)(AA.Copy,{className:`oc-iconbtn`,title:Sa(),children:[(0,V.jsx)(Sz.If,{copied:!0,children:(0,V.jsx)(Y8,{})}),(0,V.jsx)(Sz.If,{copied:!1,children:(0,V.jsx)(J8,{})})]}):null,n.showSource?(0,V.jsx)(xbe,{active:e,onToggle:()=>t(e=>!e)}):null,n.showReport?(0,V.jsx)(g8,{}):null,n.showDelete?(0,V.jsx)(Z8,{kind:`user`}):null]})]})})}function Cbe({pool:e,agent:t}){let n=fV(e,t),r=n?.displayName??t.agentId;return(0,V.jsxs)(`span`,{className:`oc-chip oc-chip--agent oc-msg__agent`,title:Ks({name:r}),children:[n?.emoji?(0,V.jsx)(`span`,{className:`oc-chip__emoji`,"aria-hidden":!0,children:n.emoji}):(0,V.jsx)(fS,{size:13,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-chip__label`,children:r})]})}var $8=[];function wbe({show:e}){let t=Yk(e=>e.metadata?.custom?.status),n=Yk(e=>e.metadata?.custom?.chatId),r=Yk(e=>JU(e.content)),i=Yk(e=>e.content.some(e=>e?.type===`file`)),a=Yk(e=>e.metadata?.custom?.toolParts??$8),o=R(L.subAgents.listSubAgents,n?{chatId:n}:`skip`),s=Yk(e=>e.metadata?.custom?.messageId),c=Ave({status:t,hasText:r,hasMedia:i},a,o??[],s);return c.kind===`none`?null:c.kind===`failed`?e?null:(0,V.jsxs)(`div`,{className:`oc-empty-answer oc-empty-answer--failed`,role:`status`,children:[(0,V.jsx)(fS,{size:15,className:`oc-empty-answer__icon`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-empty-answer__text`,children:c.taskName?gc({task:c.taskName,reason:c.reason}):ec({reason:c.reason})})]}):c.kind===`waiting`?e?null:(0,V.jsxs)(`div`,{className:`oc-empty-answer oc-empty-answer--waiting`,role:`status`,children:[(0,V.jsx)(MS,{size:15,className:`oc-empty-answer__spin`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-empty-answer__text`,children:c.taskName?io({task:c.taskName}):$d()})]}):c.kind===`done`?c.resultText?(0,V.jsx)(Y3,{text:c.resultText}):null:(0,V.jsxs)(`div`,{className:`oc-empty-answer oc-empty-answer--generic`,role:`status`,children:[(0,V.jsx)(fS,{size:15,className:`oc-empty-answer__icon`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-empty-answer__text`,children:El()})]})}function Tbe(){let[e,t]=(0,B.useState)(!1),n=N8(),r=VB(),i=Yk(e=>e.id),a=(0,B.useContext)(F8),o=a!==null&&a.messageId===i?a:null,s=Yk(e=>e.metadata?.custom?.status),c=(0,B.useContext)(ZU);hbe(Yk(e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
@@ -235,4 +235,4 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
235
235
  To pick up a draggable item, press the space bar.
236
236
  While dragging, use the arrow keys to move the item.
237
237
  Press space again to drop the item in its new position, or press escape to cancel.
238
- `},qbe={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function Jbe(e){let{announcements:t=qbe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Kbe}=e,{announce:a,announcement:o}=Ube(),s=h5(`DndLiveRegion`),[c,l]=(0,B.useState)(!1);if((0,B.useEffect)(()=>{l(!0)},[]),Wbe((0,B.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=B.createElement(B.Fragment,null,B.createElement(Vbe,{id:r,value:i.draggable}),B.createElement(Hbe,{id:s,announcement:o}));return n?(0,Lg.createPortal)(u,n):u}var w5;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(w5||={});function T5(){}function E5(e,t){return(0,B.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function D5(){var e=[...arguments];return(0,B.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var O5=Object.freeze({x:0,y:0});function k5(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Ybe(e,t){let n=b5(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function A5(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Xbe(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function j5(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function M5(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function N5(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var Zbe=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=N5(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=k5(N5(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(A5)},P5=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=j5(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=j5(r),o=i.reduce((e,t,r)=>e+k5(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(A5)};function Qbe(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var $be=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=Qbe(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Xbe)};function exe(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function F5(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:O5}function txe(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var nxe=txe(1);function I5(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function rxe(e,t,n){let r=I5(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var ixe={ignoreTransform:!1};function L5(e,t){t===void 0&&(t=ixe);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=r5(e).getComputedStyle(e);t&&(n=rxe(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function R5(e){return L5(e,{ignoreTransform:!0})}function axe(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function oxe(e,t){return t===void 0&&(t=r5(e).getComputedStyle(e)),t.position===`fixed`}function sxe(e,t){t===void 0&&(t=r5(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function z5(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(i5(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!a5(i)||o5(i)||n.includes(i))return n;let a=r5(e).getComputedStyle(i);return i!==e&&sxe(i,a)&&n.push(i),oxe(i,a)?n:r(i.parentNode)}return e?r(e):n}function B5(e){let[t]=z5(e,1);return t??null}function V5(e){return!e5||!e?null:t5(e)?e:n5(e)?i5(e)||e===s5(e).scrollingElement?window:a5(e)?e:null:null}function H5(e){return t5(e)?e.scrollX:e.scrollLeft}function U5(e){return t5(e)?e.scrollY:e.scrollTop}function W5(e){return{x:H5(e),y:U5(e)}}var G5;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(G5||={});function K5(e){return!e5||!e?!1:e===document.scrollingElement}function q5(e){let t={x:0,y:0},n=K5(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var cxe={x:.2,y:.2};function lxe(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=cxe);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=q5(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=G5.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=G5.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=G5.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=G5.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function uxe(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function J5(e){return e.reduce((e,t)=>_5(e,W5(t)),O5)}function dxe(e){return e.reduce((e,t)=>e+H5(t),0)}function fxe(e){return e.reduce((e,t)=>e+U5(t),0)}function Y5(e,t){if(t===void 0&&(t=L5),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);B5(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var pxe=[[`x`,[`left`,`right`],dxe],[`y`,[`top`,`bottom`],fxe]],X5=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=z5(t),r=J5(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of pxe)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},Z5=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function mxe(e){let{EventTarget:t}=r5(e);return e instanceof t?e:s5(e)}function Q5(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var $5;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})($5||={});function e7(e){e.preventDefault()}function hxe(e){e.stopPropagation()}var t7;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(t7||={});var n7={start:[t7.Space,t7.Enter],cancel:[t7.Esc],end:[t7.Space,t7.Enter,t7.Tab]},gxe=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case t7.Right:return{...n,x:n.x+25};case t7.Left:return{...n,x:n.x-25};case t7.Down:return{...n,y:n.y+25};case t7.Up:return{...n,y:n.y-25}}},r7=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Z5(s5(t)),this.windowListeners=new Z5(r5(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add($5.Resize,this.handleCancel),this.windowListeners.add($5.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add($5.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Y5(n),t(O5)}handleKeyDown(e){if(y5(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=n7,coordinateGetter:a=gxe,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:O5;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=v5(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=q5(n),p=uxe(n),m={x:Math.min(i===t7.Right?p.right-p.width/2:p.right,Math.max(i===t7.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===t7.Down?p.bottom-p.height/2:p.bottom,Math.max(i===t7.Down?p.top:p.top+p.height/2,u.y))},h=i===t7.Right&&!s||i===t7.Left&&!c,g=i===t7.Down&&!l||i===t7.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===t7.Right&&e<=d.x||i===t7.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===t7.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===t7.Down&&e<=d.y||i===t7.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===t7.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,_5(v5(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};r7.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=n7,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function i7(e){return!!(e&&`distance`in e)}function a7(e){return!!(e&&`delay`in e)}var o7=class{constructor(e,t,n){n===void 0&&(n=mxe(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=s5(i),this.documentListeners=new Z5(this.document),this.listeners=new Z5(n),this.windowListeners=new Z5(r5(i)),this.initialCoordinates=b5(r)??O5,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add($5.Resize,this.handleCancel),this.windowListeners.add($5.DragStart,e7),this.windowListeners.add($5.VisibilityChange,this.handleCancel),this.windowListeners.add($5.ContextMenu,e7),this.documentListeners.add($5.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(a7(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(i7(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add($5.Click,hxe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add($5.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=b5(e)??O5,s=v5(n,o);if(!t&&a){if(i7(a)){if(a.tolerance!=null&&Q5(s,a.tolerance))return this.handleCancel();if(Q5(s,a.distance))return this.handleStart()}if(a7(a)&&Q5(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===t7.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},_xe={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},s7=class extends o7{constructor(e){let{event:t}=e,n=s5(t.target);super(e,_xe,n)}};s7.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var vxe={move:{name:`mousemove`},end:{name:`mouseup`}},c7;(function(e){e[e.RightClick=2]=`RightClick`})(c7||={});var l7=class extends o7{constructor(e){super(e,vxe,s5(e.event.target))}};l7.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===c7.RightClick?!1:(r?.({event:n}),!0)}}];var u7={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},d7=class extends o7{constructor(e){super(e,u7)}static setup(){return window.addEventListener(u7.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(u7.move.name,e)};function e(){}}};d7.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var f7;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(f7||={});var p7;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(p7||={});function yxe(e){let{acceleration:t,activator:n=f7.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=p7.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=xxe({delta:d,disabled:!a}),[m,h]=Ibe(),g=(0,B.useRef)({x:0,y:0}),_=(0,B.useRef)({x:0,y:0}),v=(0,B.useMemo)(()=>{switch(n){case f7.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case f7.DraggableRect:return i}},[n,i,c]),y=(0,B.useRef)(null),b=(0,B.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,B.useMemo)(()=>s===p7.TreeOrder?[...l].reverse():l,[s,l]);(0,B.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=lxe(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var bxe={x:{[G5.Backward]:!1,[G5.Forward]:!1},y:{[G5.Backward]:!1,[G5.Forward]:!1}};function xxe(e){let{delta:t,disabled:n}=e,r=p5(t);return d5(e=>{if(n||!r||!e)return bxe;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[G5.Backward]:e.x[G5.Backward]||i.x===-1,[G5.Forward]:e.x[G5.Forward]||i.x===1},y:{[G5.Backward]:e.y[G5.Backward]||i.y===-1,[G5.Forward]:e.y[G5.Forward]||i.y===1}}},[n,t,r])}function Sxe(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return d5(e=>t==null?null:r??e??null,[r,t])}function Cxe(e,t){return(0,B.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var m7;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(m7||={});var h7;(function(e){e.Optimized=`optimized`})(h7||={});var g7=new Map;function wxe(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,B.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,B.useRef)(e),d=g(),f=u5(d),p=(0,B.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,B.useRef)(null),h=d5(t=>{if(d&&!n)return g7;if(!t||t===g7||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new X5(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,B.useEffect)(()=>{u.current=e},[e]),(0,B.useEffect)(()=>{d||p()},[n,d]),(0,B.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,B.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case m7.Always:return!1;case m7.BeforeDragging:return n;default:return!n}}}function _7(e,t){return d5(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function Txe(e,t){return _7(e,t)}function Exe(e){let{callback:t,disabled:n}=e,r=l5(t),i=(0,B.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,B.useEffect)(()=>()=>i?.disconnect(),[i]),i}function v7(e){let{callback:t,disabled:n}=e,r=l5(t),i=(0,B.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,B.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Dxe(e){return new X5(L5(e),e)}function y7(e,t,n){t===void 0&&(t=Dxe);let[r,i]=(0,B.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=Exe({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=v7({callback:a});return c5(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function Oxe(e){return F5(e,_7(e))}var b7=[];function kxe(e){let t=(0,B.useRef)(e),n=d5(n=>e?n&&n!==b7&&e&&t.current&&e.parentNode===t.current.parentNode?n:z5(e):b7,[e]);return(0,B.useEffect)(()=>{t.current=e},[e]),n}function Axe(e){let[t,n]=(0,B.useState)(null),r=(0,B.useRef)(e),i=(0,B.useCallback)(e=>{let t=V5(e.target);t&&n(e=>e?(e.set(t,W5(t)),new Map(e)):null)},[]);return(0,B.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=V5(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,W5(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{V5(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,B.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>_5(e,t),O5):J5(e):O5,[e,t])}function x7(e,t){t===void 0&&(t=[]);let n=(0,B.useRef)(null);return(0,B.useEffect)(()=>{n.current=null},t),(0,B.useEffect)(()=>{let t=e!==O5;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?v5(e,n.current):O5}function jxe(e){(0,B.useEffect)(()=>{if(!e5)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function Mxe(e,t){return(0,B.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function S7(e){return(0,B.useMemo)(()=>e?axe(e):null,[e])}var C7=[];function Nxe(e,t){t===void 0&&(t=L5);let[n]=e,r=S7(n?r5(n):null),[i,a]=(0,B.useState)(C7);function o(){a(()=>e.length?e.map(e=>K5(e)?r:new X5(t(e),e)):C7)}let s=v7({callback:o});return c5(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function w7(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return a5(t)?t:e}function Pxe(e){let{measure:t}=e,[n,r]=(0,B.useState)(null),i=v7({callback:(0,B.useCallback)(e=>{for(let{target:n}of e)if(a5(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=f5((0,B.useCallback)(e=>{let n=w7(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,B.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var Fxe=[{sensor:s7,options:{}},{sensor:r7,options:{}}],Ixe={current:{}},T7={draggable:{measure:R5},droppable:{measure:R5,strategy:m7.WhileDragging,frequency:h7.Optimized},dragOverlay:{measure:L5}},E7=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},Lxe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new E7,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:T5},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:T7,measureDroppableContainers:T5,windowRect:null,measuringScheduled:!1},D7={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:T5,draggableNodes:new Map,over:null,measureDroppableContainers:T5},O7=(0,B.createContext)(D7),k7=(0,B.createContext)(Lxe);function Rxe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new E7}}}function zxe(e,t){switch(t.type){case w5.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case w5.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case w5.DragEnd:case w5.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case w5.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new E7(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case w5.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new E7(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case w5.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new E7(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Bxe(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,B.useContext)(O7),a=p5(r),o=p5(n?.id);return(0,B.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!y5(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=zbe(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function A7(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Vxe(e){return(0,B.useMemo)(()=>({draggable:{...T7.draggable,...e?.draggable},droppable:{...T7.droppable,...e?.droppable},dragOverlay:{...T7.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Hxe(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,B.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;c5(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=F5(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=B5(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var j7=(0,B.createContext)({...O5,scaleX:1,scaleY:1}),M7;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(M7||={});var N7=(0,B.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=Fxe,collisionDetection:o=$be,measuring:s,modifiers:c,...l}=e,[u,d]=(0,B.useReducer)(zxe,void 0,Rxe),[f,p]=Gbe(),[m,h]=(0,B.useState)(M7.Uninitialized),g=m===M7.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,B.useRef)({initial:null,translated:null}),C=(0,B.useMemo)(()=>_==null?null:{id:_,data:x?.data??Ixe,rect:S},[_,x]),w=(0,B.useRef)(null),[T,E]=(0,B.useState)(null),[D,O]=(0,B.useState)(null),k=u5(l,Object.values(l)),A=h5(`DndDescribedBy`,t),j=(0,B.useMemo)(()=>b.getEnabled(),[b]),M=Vxe(s),{droppableRects:N,measureDroppableContainers:ee,measuringScheduled:P}=wxe(j,{dragging:g,dependencies:[y.x,y.y],config:M.droppable}),F=Sxe(v,_),te=(0,B.useMemo)(()=>D?b5(D):null,[D]),ne=Me(),re=Txe(F,M.draggable.measure);Hxe({activeNode:_==null?null:v.get(_),config:ne.layoutShiftCompensation,initialRect:re,measure:M.draggable.measure});let ie=y7(F,M.draggable.measure,re),ae=y7(F?F.parentElement:null),oe=(0,B.useRef)({activatorEvent:null,active:null,activeNode:F,collisionRect:null,collisions:null,droppableRects:N,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),se=b.getNodeFor(oe.current.over?.id),ce=Pxe({measure:M.dragOverlay.measure}),le=ce.nodeRef.current??F,ue=g?ce.rect??ie:null,de=!!(ce.nodeRef.current&&ce.rect),fe=Oxe(de?null:ie),pe=S7(le?r5(le):null),me=kxe(g?se??F:null),he=Nxe(me),ge=A7(c,{transform:{x:y.x-fe.x,y:y.y-fe.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:ie,containerNodeRect:ae,draggingNodeRect:ue,over:oe.current.over,overlayNodeRect:ce.rect,scrollableAncestors:me,scrollableAncestorRects:he,windowRect:pe}),_e=te?_5(te,y):null,ve=Axe(me),ye=x7(ve),be=x7(ve,[ie]),xe=_5(ge,ye),I=ue?nxe(ue,ge):null,Se=C&&I?o({active:C,collisionRect:I,droppableRects:N,droppableContainers:j,pointerCoordinates:_e}):null,Ce=M5(Se,`id`),[we,Te]=(0,B.useState)(null),Ee=exe(de?ge:_5(ge,be),we?.rect??null,ie),De=(0,B.useRef)(null),Oe=(0,B.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent;De.current=new n({active:w.current,activeNode:i,event:a,options:r,context:oe,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,Lg.unstable_batchedUpdates)(()=>{r?.(i),h(M7.Initializing),d({type:w5.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(De.current),O(a)})},onMove(e){d({type:w5.DragMove,coordinates:e})},onEnd:o(w5.DragEnd),onCancel:o(w5.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=oe.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===w5.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=w5.DragCancel)}w.current=null,(0,Lg.unstable_batchedUpdates)(()=>{d({type:e}),h(M7.Uninitialized),Te(null),E(null),O(null),De.current=null;let t=e===w5.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),ke=Cxe(a,(0,B.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,Oe(n,t))},[v,Oe]));jxe(a),c5(()=>{ie&&m===M7.Initializing&&h(M7.Initialized)},[ie,m]),(0,B.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=oe.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:xe.x,y:xe.y},over:i};(0,Lg.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[xe.x,xe.y]),(0,B.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=oe.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(Ce),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,Lg.unstable_batchedUpdates)(()=>{Te(s),a?.(c),f({type:`onDragOver`,event:c})})},[Ce]),c5(()=>{oe.current={activatorEvent:D,active:C,activeNode:F,collisionRect:I,collisions:Se,droppableRects:N,draggableNodes:v,draggingNode:le,draggingNodeRect:ue,droppableContainers:b,over:we,scrollableAncestors:me,scrollAdjustedTranslate:xe},S.current={initial:ue,translated:I}},[C,F,Se,I,v,le,ue,N,b,we,me,xe]),yxe({...ne,delta:y,draggingRect:I,pointerCoordinates:_e,scrollableAncestors:me,scrollableAncestorRects:he});let Ae=(0,B.useMemo)(()=>({active:C,activeNode:F,activeNodeRect:ie,activatorEvent:D,collisions:Se,containerNodeRect:ae,dragOverlay:ce,draggableNodes:v,droppableContainers:b,droppableRects:N,over:we,measureDroppableContainers:ee,scrollableAncestors:me,scrollableAncestorRects:he,measuringConfiguration:M,measuringScheduled:P,windowRect:pe}),[C,F,ie,D,Se,ae,ce,v,b,N,we,ee,me,he,M,P,pe]),je=(0,B.useMemo)(()=>({activatorEvent:D,activators:ke,active:C,activeNodeRect:ie,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:we,measureDroppableContainers:ee}),[D,ke,C,ie,d,A,v,we,ee]);return B.createElement(C5.Provider,{value:p},B.createElement(O7.Provider,{value:je},B.createElement(k7.Provider,{value:Ae},B.createElement(j7.Provider,{value:Ee},i)),B.createElement(Bxe,{disabled:n?.restoreFocus===!1})),B.createElement(Jbe,{...n,hiddenTextDescribedById:A}));function Me(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),Uxe=(0,B.createContext)(null),P7=`button`,Wxe=`Draggable`;function Gxe(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=h5(Wxe),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,B.useContext)(O7),{role:p=P7,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,B.useContext)(g?j7:Uxe),[v,y]=f5(),[b,x]=f5(),S=Mxe(o,t),C=u5(n);return c5(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,B.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===P7?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function F7(){return(0,B.useContext)(k7)}var Kxe=`Droppable`,qxe={timeout:25};function I7(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=h5(Kxe),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,B.useContext)(O7),u=(0,B.useRef)({disabled:n}),d=(0,B.useRef)(!1),f=(0,B.useRef)(null),p=(0,B.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...qxe,...i},_=u5(h??r),v=v7({callback:(0,B.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=f5((0,B.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=u5(t);return(0,B.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,B.useEffect)(()=>(s({type:w5.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:w5.UnregisterDroppable,key:a,id:r})),[r]),(0,B.useEffect)(()=>{n!==u.current.disabled&&(s({type:w5.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function Jxe(e){let{animation:t,children:n}=e,[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(null),s=p5(n);return!n&&!r&&s&&i(s),c5(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),B.createElement(B.Fragment,null,n,r?(0,B.cloneElement)(r,{ref:o}):null)}var Yxe={x:0,y:0,scaleX:1,scaleY:1};function Xxe(e){let{children:t}=e;return B.createElement(O7.Provider,{value:D7},B.createElement(j7.Provider,{value:Yxe},t))}var Zxe={position:`fixed`,touchAction:`none`},Qxe=e=>y5(e)?`transform 250ms ease`:void 0,$xe=(0,B.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=Qxe}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...Zxe,width:s.width,height:s.height,top:s.top,left:s.left,transform:x5.Transform.toString(d),transformOrigin:i&&r?Ybe(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return B.createElement(n,{className:o,style:f,ref:t},a)}),eSe={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:x5.Transform.toString(t)},{transform:x5.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function tSe(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return l5((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=w7(a);if(!c)return;let{transform:l}=r5(a).getComputedStyle(a),u=I5(l);if(!u)return;let d=typeof t==`function`?t:nSe(t);return Y5(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function nSe(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...eSe,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var L7=0;function rSe(e){return(0,B.useMemo)(()=>{if(e!=null)return L7++,L7},[e])}var iSe=B.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=F7(),S=(0,B.useContext)(j7),C=rSe(d?.id),w=A7(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=_7(f),E=tSe({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return B.createElement(Xxe,null,B.createElement(Jxe,{animation:E},d&&C?B.createElement($xe,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))}),aSe=e=>{let{transform:t}=e;return{...t,y:0}};function oSe(e,t,n){let r={...e};return t.top+e.y<=n.top?r.y=n.top-t.top:t.bottom+e.y>=n.top+n.height&&(r.y=n.top+n.height-t.bottom),t.left+e.x<=n.left?r.x=n.left-t.left:t.right+e.x>=n.left+n.width&&(r.x=n.left+n.width-t.right),r}var sSe=e=>{let{draggingNodeRect:t,transform:n,scrollableAncestorRects:r}=e,i=r[0];return!t||!i?n:oSe(n,t,i)},cSe=e=>{let{transform:t}=e;return{...t,x:0}};function R7(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function lSe(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function z7(e){return e!==null&&e>=0}function uSe(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function dSe(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var B7={scaleX:1,scaleY:1},fSe=e=>{let{rects:t,activeNodeRect:n,activeIndex:r,overIndex:i,index:a}=e,o=t[r]??n;if(!o)return null;let s=pSe(t,a,r);if(a===r){let e=t[i];return e?{x:r<i?e.left+e.width-(o.left+o.width):e.left-o.left,y:0,...B7}:null}return a>r&&a<=i?{x:-o.width-s,y:0,...B7}:a<r&&a>=i?{x:o.width+s,y:0,...B7}:{x:0,y:0,...B7}};function pSe(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return!r||!i&&!a?0:n<t?i?r.left-(i.left+i.width):a.left-(r.left+r.width):a?a.left-(r.left+r.width):r.left-(i.left+i.width)}var V7=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=R7(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},H7={scaleX:1,scaleY:1},U7=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...H7}:null}let s=mSe(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...H7}:r<t&&r>=a?{x:0,y:o.height+s,...H7}:{x:0,y:0,...H7}};function mSe(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var W7=`Sortable`,G7=B.createContext({activeIndex:-1,containerId:W7,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:V7,disabled:{draggable:!1,droppable:!1}});function K7(e){let{children:t,id:n,items:r,strategy:i=V7,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=F7(),d=h5(W7,n),f=s.rect!==null,p=(0,B.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,B.useRef)(p),v=!uSe(p,_.current),y=g!==-1&&h===-1||v,b=dSe(a);c5(()=>{v&&m&&u(p)},[v,p,m,u]),(0,B.useEffect)(()=>{_.current=p},[p]);let x=(0,B.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:lSe(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return B.createElement(G7.Provider,{value:x},t)}var hSe=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return R7(n,r,i).indexOf(t)},gSe=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},_Se={duration:200,easing:`ease`},q7=`transform`,vSe=x5.Transition.toString({property:q7,duration:0,easing:`linear`}),ySe={roleDescription:`sortable`};function bSe(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,B.useState)(null),s=(0,B.useRef)(n);return c5(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=L5(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,B.useEffect)(()=>{a&&o(null)},[a]),a}function J7(e){let{animateLayoutChanges:t=gSe,attributes:n,disabled:r,data:i,getNewIndex:a=hSe,id:o,strategy:s,resizeObserverConfig:c,transition:l=_Se}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,B.useContext)(G7),y=xSe(r,p),b=u.indexOf(o),x=(0,B.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,B.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:C,node:w,isOver:T,setNodeRef:E}=I7({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:D,activatorEvent:O,activeNodeRect:k,attributes:A,setNodeRef:j,listeners:M,isDragging:N,over:ee,setActivatorNodeRef:P,transform:F}=Gxe({id:o,data:x,attributes:{...ySe,...n},disabled:y.draggable}),te=Fbe(E,j),ne=!!D,re=ne&&!m&&z7(f)&&z7(g),ie=!_&&N,ae=re?(ie&&re?F:null)??(s??v)({rects:h,activeNodeRect:k,activeIndex:f,overIndex:g,index:b}):null,oe=z7(f)&&z7(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,se=D?.id,ce=(0,B.useRef)({activeId:se,items:u,newIndex:oe,containerId:d}),le=u!==ce.current.items,ue=t({active:D,containerId:d,isDragging:N,isSorting:ne,id:o,index:b,items:u,newIndex:ce.current.newIndex,previousItems:ce.current.items,previousContainerId:ce.current.containerId,transition:l,wasDragging:ce.current.activeId!=null}),de=bSe({disabled:!ue,index:b,node:w,rect:C});return(0,B.useEffect)(()=>{ne&&ce.current.newIndex!==oe&&(ce.current.newIndex=oe),d!==ce.current.containerId&&(ce.current.containerId=d),u!==ce.current.items&&(ce.current.items=u)},[ne,oe,d,u]),(0,B.useEffect)(()=>{if(se===ce.current.activeId)return;if(se!=null&&ce.current.activeId==null){ce.current.activeId=se;return}let e=setTimeout(()=>{ce.current.activeId=se},50);return()=>clearTimeout(e)},[se]),{active:D,activeIndex:f,attributes:A,data:x,rect:C,index:b,newIndex:oe,items:u,isOver:T,isSorting:ne,isDragging:N,listeners:M,node:w,overIndex:g,over:ee,setNodeRef:te,setActivatorNodeRef:P,setDroppableNodeRef:E,setDraggableNodeRef:j,transform:de??ae,transition:fe()};function fe(){if(de||le&&ce.current.newIndex===b)return vSe;if(!(ie&&!y5(O)||!l)&&(ne||ue))return x5.Transition.toString({...l,property:q7})}}function xSe(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}function Y7(e){if(!e)return!1;let t=e.data.current;return!!(t&&`sortable`in t&&typeof t.sortable==`object`&&`containerId`in t.sortable&&`items`in t.sortable&&`index`in t.sortable)}var SSe=[t7.Down,t7.Right,t7.Up,t7.Left],X7=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(SSe.includes(e.code)){if(e.preventDefault(),!n||!r)return;let t=[];a.getEnabled().forEach(n=>{if(!n||n!=null&&n.disabled)return;let a=i.get(n.id);if(a)switch(e.code){case t7.Down:r.top<a.top&&t.push(n);break;case t7.Up:r.top>a.top&&t.push(n);break;case t7.Left:r.left>a.left&&t.push(n);break;case t7.Right:r.left<a.left&&t.push(n);break}});let c=P5({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=M5(c,`id`);if(l===o?.id&&c.length>1&&(l=c[1].id),l!=null){let e=a.get(n.id),t=a.get(l),o=t?i.get(t.id):null,c=t?.node.current;if(c&&o&&e&&t){let n=z5(c).some((e,t)=>s[t]!==e),i=Z7(e,t),a=CSe(e,t),l=n||!i?{x:0,y:0}:{x:a?r.width-o.width:0,y:a?r.height-o.height:0},u={x:o.left,y:o.top};return l.x&&l.y?u:v5(u,l)}}}};function Z7(e,t){return!Y7(e)||!Y7(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function CSe(e,t){return!Y7(e)||!Y7(t)||!Z7(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function Q7({open:e,onOpenChange:t,title:n,description:r,children:i,onSubmit:a,submitLabel:o,submitting:s=!1,canSubmit:c=!0}){let[l,u]=(0,B.useState)(!1),d=s||l;async function f(){if(!(!c||d))try{u(!0),await a()}finally{u(!1)}}return(0,V.jsx)(J6,{open:e,onOpenChange:t,children:(0,V.jsxs)(Y6,{side:`right`,className:`w-4/5 sm:max-w-none gap-0 p-0`,children:[(0,V.jsxs)(X6,{className:`border-b px-6 py-4`,children:[(0,V.jsx)(Q6,{children:n}),r?(0,V.jsx)($6,{children:r}):null]}),(0,V.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),f()},children:[(0,V.jsx)(`div`,{className:`oc-sheet__body flex-1 overflow-y-auto px-6 py-4`,children:i}),(0,V.jsxs)(Z6,{className:`border-t px-6 py-4`,children:[(0,V.jsxs)(Ep,{type:`submit`,disabled:!c||d,children:[d?(0,V.jsx)(MS,{className:`size-4 animate-spin`}):null,o??ap()]}),(0,V.jsx)(Ep,{type:`button`,variant:`ghost`,onClick:()=>t(!1),children:Ur()})]})]})]})})}var $7=6e4,e9=60*$7,t9=24*e9,n9=7*t9,r9=30*t9,i9=365*t9;function wSe(e,t){let n=t-e;if(n<$7)return`maintenant`;if(n<e9)return`${Math.floor(n/$7)}min`;if(n<t9)return`${Math.floor(n/e9)}h`;if(n<n9)return`${Math.floor(n/t9)}j`;if(n<r9)return`${Math.floor(n/n9)}sem`;if(n<i9)return`${Math.floor(n/r9)}mois`;let r=Math.floor(n/i9);return`${r}an${r>1?`s`:``}`}var a9=[{value:`red`,hue:`var(--oc-accent-red, oklch(0.63 0.21 25))`},{value:`orange`,hue:`var(--oc-accent-orange, oklch(0.7 0.17 50))`},{value:`amber`,hue:`var(--oc-accent-amber, oklch(0.8 0.15 85))`},{value:`green`,hue:`var(--oc-accent-green, oklch(0.7 0.16 150))`},{value:`teal`,hue:`var(--oc-accent-teal, oklch(0.7 0.12 190))`},{value:`blue`,hue:`var(--oc-accent-blue, oklch(0.62 0.19 250))`},{value:`violet`,hue:`var(--oc-accent-violet, oklch(0.6 0.2 300))`},{value:`pink`,hue:`var(--oc-accent-pink, oklch(0.7 0.2 350))`}],o9=e=>a9.find(t=>t.value===e)?.hue??null;function TSe(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)>>>0;return a9[t%a9.length].hue}var s9=e=>o9(e.color)??TSe(e._id),c9=`project:none`,ESe=e=>`project:${e}`,l9=`projhead:`,u9=e=>`${l9}${e}`,d9=`oc.noproject.collapsed`;function f9(){return(0,V.jsx)(`div`,{className:`oc-sidebar__skeleton`,"aria-hidden":`true`,children:Array.from({length:7}).map((e,t)=>(0,V.jsx)(`div`,{className:`oc-skel oc-skel--row`},t))})}function DSe({activeChatId:e,onSelect:t,onNewChat:n,newChatShortcut:r}){let i=R(L.messages.listChats,{}),a=R(L.projects.listProjects,{}),o=R(L.me.getMe,{host:aB})?.ui?.effective?.showChatAge??!0,s=R(L.chatReads.myChatReads,{}),c=(0,B.useMemo)(()=>{let e=new Map;for(let t of s??[])e.set(t.chatId,t.lastSeenAt);return e},[s]),l=R(L.chatReads.myBusyChats,{}),u=(0,B.useMemo)(()=>new Set(l??[]),[l]),d=R(L.chatBookmarks.myBookmarkedChats,{}),f=R(L.chatExport.referenceLabel,{}),m=(0,B.useMemo)(()=>new Set(d??[]),[d]),h=(0,B.useMemo)(()=>{let t=new Set;for(let n of i??[]){if(n._id===e)continue;let r=c.get(n._id);r!==void 0&&n.lastAssistantAt!==null&&n.lastAssistantAt>r&&t.add(n._id)}return t},[i,c,e]),[g,_]=(0,B.useState)(0);(0,B.useEffect)(()=>{if(!o)return;let e=window.setInterval(()=>_(e=>e+1),6e4);return()=>window.clearInterval(e)},[o]);let v=p(L.projects.createProject),y=p(L.projects.setProjectCollapsed),b=p(L.chats.reorderChat),x=p(L.projects.reorderProject),S=p(L.chats.moveChatToProject),C=ZV(),w=ul(),T=(0,B.useRef)(null),E=(0,B.useRef)(null),D=(0,B.useRef)(null),[O,k]=(0,B.useState)(`full`);(0,B.useLayoutEffect)(()=>{let e=T.current;if(!e)return;let t=()=>{let t=e.clientWidth,n=E.current?.offsetWidth??0,r=D.current?.offsetWidth??0,i=n===0||t>=n?`full`:t>=r?`label`:`icon`;k(e=>e===i?e:i)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[w,r]);let[A,j]=(0,B.useState)(null),M=(0,B.useRef)(!1);(0,B.useEffect)(()=>{!M.current&&i&&j(i)},[i]);let N=A??i??[],ee=i===void 0&&A===null,[P,F]=(0,B.useState)(null),[te,ne]=(0,B.useState)(()=>localStorage.getItem(d9)===`1`);function re(){ne(e=>(localStorage.setItem(d9,e?`0`:`1`),!e))}let ie=aH();(0,B.useEffect)(()=>{if(!ie?.expand)return;let e=N.find(e=>e._id===ie.chatId);if(!e)return;let t=e.projectId??null;if(t===null){te&&(localStorage.setItem(d9,`0`),ne(!1));return}(a??[]).find(e=>e._id===t)?.collapsed&&y({projectId:t,collapsed:!1})},[ie,N,a,te,y]);let ae=D5(E5(l7,{activationConstraint:{distance:4}}),E5(d7,{activationConstraint:{delay:250,tolerance:8}}),E5(r7,{coordinateGetter:X7})),oe=(0,B.useRef)(!1),se=()=>{oe.current=!0,setTimeout(()=>{oe.current=!1},0)},ce=(0,B.useCallback)(e=>String(e.active.id).startsWith(l9)?P5({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(l9))}):P5(e),[]),le=N.filter(e=>e.pinned),ue=N.filter(e=>!e.pinned),de=e=>ue.filter(t=>(t.projectId??null)===e);function fe(e){return N.find(t=>t._id===e)}async function pe(e){F(null),se();let{active:t,over:n}=e;if(!n)return;let r=String(t.id),i=String(n.id);if(r.startsWith(l9)){let e=r.slice(9),t=a??[],n=null;if(i.startsWith(l9))n=i.slice(9);else if(i.startsWith(`project:`)&&i!==c9)n=i.slice(8);else{let e=fe(i);n=e&&!e.pinned?e.projectId??null:null}if(n===null||n===e)return;let o=t.findIndex(t=>t._id===e),s=t.findIndex(e=>e._id===n);if(o<0||s<0)return;let c=[...t],[l]=c.splice(o,1);c.splice(s,0,l);let u=c[s-1]??null,d=c[s+1]??null;await x({projectId:e,prevKey:u?u.sortKey:null,nextKey:d?d.sortKey:null});return}let o=fe(r);if(!o)return;if(i.startsWith(l9)){let e=i.slice(9);if((o.projectId??null)===e)return;M.current=!0,j(t=>(t??N).map(t=>t._id===o._id?{...t,projectId:e}:t));try{await S({chatId:o._id,projectId:e})}finally{M.current=!1}return}if(i.startsWith(`project:`)){let e=i===c9?null:i.slice(8);if((o.projectId??null)===e)return;M.current=!0,j(t=>(t??N).map(t=>t._id===o._id?{...t,projectId:e}:t));try{await S({chatId:o._id,projectId:e})}finally{M.current=!1}return}let s=fe(i);if(!s||t.id===n.id)return;if((s.projectId??null)!==(o.projectId??null)||s.pinned!==o.pinned){if(o.pinned||s.pinned)return;M.current=!0,j(e=>(e??N).map(e=>e._id===o._id?{...e,projectId:s.projectId??null}:e));try{await S({chatId:o._id,projectId:s.projectId??null})}finally{M.current=!1}return}let c=s.pinned?le:de(s.projectId??null),l=c.map(e=>e._id),u=l.indexOf(o._id),d=l.indexOf(s._id);if(u<0||d<0)return;let f=[...c];f.splice(u,1),f.splice(d,0,o);let p=f[d-1]??null,m=f[d+1]??null;M.current=!0,j(e=>[...(e??N).filter(e=>!c.some(t=>t._id===e._id)),...f]);try{await b({chatId:o._id,prevKey:p?p.sortKey:null,nextKey:m?m.sortKey:null})}finally{M.current=!1}}let me=P?fe(P):null;return(0,V.jsxs)(`aside`,{className:`oc-sidebar`,children:[(0,V.jsxs)(`div`,{className:`oc-sidebar__top`,ref:T,children:[(0,V.jsxs)(Ep,{className:O===`icon`?`oc-newchat flex-1 justify-center`:`oc-newchat flex-1 justify-start`,onClick:n,title:`${w} (${r})`,"aria-label":w,children:[(0,V.jsx)(HS,{}),O===`icon`?null:(0,V.jsx)(`span`,{className:`oc-newchat__label`,children:w}),O===`full`?(0,V.jsx)(`kbd`,{className:`oc-newchat__kbd`,"aria-hidden":!0,children:r}):null]}),(0,V.jsx)(`div`,{className:`oc-newchat-ghost`,"aria-hidden":!0,children:(0,V.jsxs)(`div`,{className:`oc-newchat-ghost__row`,ref:E,children:[(0,V.jsxs)(Ep,{className:`oc-newchat justify-start`,tabIndex:-1,children:[(0,V.jsx)(HS,{}),(0,V.jsx)(`span`,{className:`oc-newchat__label`,children:w}),(0,V.jsx)(`kbd`,{className:`oc-newchat__kbd`,children:r})]}),(0,V.jsx)(Ep,{variant:`outline`,size:`icon`,tabIndex:-1,children:(0,V.jsx)(kS,{})})]})}),(0,V.jsx)(`div`,{className:`oc-newchat-ghost`,"aria-hidden":!0,children:(0,V.jsxs)(`div`,{className:`oc-newchat-ghost__row`,ref:D,children:[(0,V.jsxs)(Ep,{className:`oc-newchat justify-start`,tabIndex:-1,children:[(0,V.jsx)(HS,{}),(0,V.jsx)(`span`,{className:`oc-newchat__label`,children:w})]}),(0,V.jsx)(Ep,{variant:`outline`,size:`icon`,tabIndex:-1,children:(0,V.jsx)(kS,{})})]})}),(0,V.jsx)(Ep,{className:`oc-newproject`,variant:`outline`,size:`icon`,"aria-label":Jo(),title:Jo(),onClick:async()=>{let e=await C({title:Jo(),label:od(),placeholder:eu(),confirmLabel:_o()});e&&await v({name:e})},children:(0,V.jsx)(kS,{})})]}),(0,V.jsxs)(N7,{sensors:ae,collisionDetection:ce,modifiers:[cSe,sSe],onDragStart:e=>F(String(e.active.id)),onDragCancel:()=>{F(null),se()},onDragEnd:pe,children:[(0,V.jsx)(`div`,{className:`oc-sidebar__scroll`,children:ee?(0,V.jsx)(f9,{}):(0,V.jsxs)(V.Fragment,{children:[le.length>0?(0,V.jsx)(p9,{label:Oc(),chats:le,children:le.map(n=>(0,V.jsx)(m9,{chat:n,active:n._id===e,unread:h.has(n._id),busy:u.has(n._id),bookmarked:m.has(n._id),referenceLabel:f,ageTick:g,suppressClick:oe,onSelect:t},n._id))}):null,(0,V.jsx)(K7,{items:(a??[]).map(e=>u9(e._id)),strategy:U7,children:(a??[]).map(n=>{let r=de(n._id);return(0,V.jsx)(p9,{label:n.name,dropId:ESe(n._id),sortId:u9(n._id),suppressClick:oe,projectId:n._id,project:n,chats:r,collapsible:!0,collapsed:n.collapsed,busy:r.some(e=>u.has(e._id)),unread:r.some(e=>h.has(e._id)),onToggle:()=>void y({projectId:n._id,collapsed:!n.collapsed}),children:n.collapsed?null:r.length===0?(0,V.jsx)(`div`,{className:`oc-sidebar__empty`,children:Uu()}):r.map(n=>(0,V.jsx)(m9,{chat:n,active:n._id===e,unread:h.has(n._id),busy:u.has(n._id),bookmarked:m.has(n._id),referenceLabel:f,ageTick:g,suppressClick:oe,onSelect:t},n._id))},n._id)})}),(0,V.jsx)(p9,{label:Rl(),dropId:c9,chats:de(null),collapsible:!0,collapsed:te,busy:de(null).some(e=>u.has(e._id)),unread:de(null).some(e=>h.has(e._id)),onToggle:re,children:te?null:de(null).map(n=>(0,V.jsx)(m9,{chat:n,active:n._id===e,unread:h.has(n._id),busy:u.has(n._id),bookmarked:m.has(n._id),referenceLabel:f,ageTick:g,suppressClick:oe,onSelect:t},n._id))})]})}),(0,V.jsxs)(iSe,{children:[P?.startsWith(l9)?(()=>{let e=(a??[]).find(e=>u9(e._id)===P);return e?(0,V.jsxs)(`div`,{className:`oc-sidebar__group-head oc-chatitem--overlay`,style:{"--proj-hue":s9(e)},children:[(0,V.jsx)(up,{className:`size-3.5 shrink-0 oc-sidebar__group-chev`}),(0,V.jsx)(`span`,{className:`oc-sidebar__group-label`,children:e.name})]}):null})():null,me?(0,V.jsxs)(`div`,{className:`oc-chatitem oc-chatitem--overlay`,children:[o9(me.color)?(0,V.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:o9(me.color)}}):(0,V.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,V.jsx)(`span`,{className:`oc-chatitem__label`,children:me.title||bd()})]}):null]})]})]})}function p9({label:e,dropId:t,sortId:n,suppressClick:r,projectId:i,project:a,chats:o,collapsible:s,collapsed:c,busy:l,unread:u,onToggle:d,children:f}){let m=p(L.projects.deleteProject),h=p(L.projects.renameProject),g=p(L.projects.setProjectColor),_=XV(),[v,y]=(0,B.useState)(!1),[b,x]=(0,B.useState)(e),S=R(L.projects.projectChatCount,i?{projectId:i}:`skip`),{setNodeRef:C,isOver:w}=I7({id:t??`static:${e}`}),T=J7({id:n??`static-sort:${e}`,disabled:!n}),{onKeyDown:E,...D}=T.listeners??{},O=e=>{e.target===e.currentTarget&&s&&d&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d())},k=a?s9(a):null;return(0,V.jsxs)(`div`,{ref:e=>{t&&C(e),n&&T.setNodeRef(e)},className:`oc-sidebar__group`+(w?` oc-sidebar__group--over`:``)+(a?` oc-sidebar__group--project`:``),style:{...k?{"--proj-hue":k}:{},...n?{transform:x5.Transform.toString(T.transform),transition:T.transition,opacity:T.isDragging?.35:1}:{}},children:[(0,V.jsxs)(`div`,{className:`oc-sidebar__group-head group/head`+(s?` oc-sidebar__group-head--btn`:``),...s?{role:`button`,tabIndex:0,onClick:()=>{r?.current||d?.()},onKeyDown:O}:{},...n?D:{},children:[s?c?(0,V.jsx)(gS,{className:`size-3.5 shrink-0`+(a?` oc-sidebar__group-chev`:``)}):(0,V.jsx)(up,{className:`size-3.5 shrink-0`+(a?` oc-sidebar__group-chev`:``)}):null,(0,V.jsx)(`span`,{className:`oc-sidebar__group-label`,children:e}),n?(0,V.jsx)(`button`,{className:`oc-drag-a11y`,"aria-label":Bi(),onClick:e=>e.stopPropagation(),...T.attributes,onKeyDown:E,children:(0,V.jsx)(jS,{className:`size-3.5`})}):null,c&&l?(0,V.jsx)(`span`,{className:`oc-chatitem__busy`,title:xs(),"aria-label":xs()}):null,c&&u?(0,V.jsx)(`span`,{className:`oc-chatitem__unread`,title:en(),"aria-label":en()}):null,i?(0,V.jsxs)(xV,{children:[(0,V.jsx)(SV,{asChild:!0,children:(0,V.jsx)(Ep,{variant:`ghost`,size:`icon-xs`,"aria-label":Or(),className:`oc-sidebar__group-menu opacity-0 group-hover/head:opacity-100 group-focus-within/head:opacity-100 aria-expanded:opacity-100`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:(0,V.jsx)(wS,{})})}),(0,V.jsxs)(CV,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(wV,{onSelect:()=>{x(e),y(!0)},children:[(0,V.jsx)(BS,{}),` `,np()]}),(0,V.jsx)(TV,{children:Vt()}),(0,V.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,V.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void g({projectId:i,color:null}),"aria-label":Qe(),children:`✕`}),a9.map(e=>(0,V.jsx)(`button`,{className:`oc-colorgrid__dot`+(a?.color===e.value?` is-selected`:``),style:{background:e.hue},"aria-label":e.value,onClick:()=>void g({projectId:i,color:e.value})},e.value))]}),(0,V.jsx)(EV,{}),(0,V.jsxs)(wV,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let t=S??0;await _({title:dt({name:e}),description:t>0?ea({count:t}):wi(),confirmWord:Tt(),confirmLabel:mn(),destructive:!0})&&await m({projectId:i})})},children:[(0,V.jsx)(YS,{}),` `,Tt()]})]})]}):null]}),(0,V.jsx)(`div`,{className:a&&!c?`oc-sidebar__group-body`:void 0,children:(0,V.jsx)(K7,{items:o.map(e=>e._id),strategy:U7,children:f})}),i?(0,V.jsx)(Q7,{open:v,onOpenChange:y,title:Va(),canSubmit:b.trim().length>0,onSubmit:async()=>{await h({projectId:i,name:b.trim()}),y(!1)},children:(0,V.jsx)(`div`,{className:`oc-form`,children:(0,V.jsxs)(`label`,{className:`oc-field`,children:[(0,V.jsx)(`span`,{className:`oc-field__label`,children:Vc()}),(0,V.jsx)(QB,{value:b,onChange:e=>x(e.target.value),autoFocus:!0})]})})}):null]})}var m9=(0,B.memo)(function({chat:e,active:t,unread:n,busy:r,bookmarked:i,referenceLabel:a,suppressClick:o,onSelect:s}){let{attributes:c,listeners:l,setNodeRef:u,transform:d,transition:f,isDragging:m}=J7({id:e._id}),{onKeyDown:h,...g}=l??{},_=p(L.chats.renameChat),y=uH(),b=()=>{if(a===void 0)return;let t=Pbe(a,e._id);navigator.clipboard.writeText(t).then(()=>y.success(ba({reference:t})),()=>y.error(Kt()))},x=p(L.chats.deleteChat),S=p(L.chats.pinChat),C=p(L.chats.setChatColor),w=R(L.me.getMe,{host:aB})?.ui?.effective?.showChatAge??!0,T=XV(),[E,D]=(0,B.useState)(!1),[O,k]=(0,B.useState)(e.title??``),A=aH()?.chatId===e._id,j=(0,B.useRef)(null);(0,B.useEffect)(()=>{if(!A)return;let t=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;j.current?.scrollIntoView({block:`nearest`,behavior:t?`auto`:`smooth`});let n=setTimeout(()=>iH(e._id),2600);return()=>clearTimeout(n)},[A,e._id]);let M={transform:x5.Transform.toString(d),transition:f,opacity:+!m},N=o9(e.color);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{ref:e=>{u(e),j.current=e},style:M,className:`oc-chatitem group/row`+(t?` oc-chatitem--active`:``)+(A?` oc-chatitem--flash`:``),onClick:()=>{o.current||s(e._id)},...g,onAnimationEnd:t=>{A&&t.animationName===`oc-chatitem-flash`&&iH(e._id)},children:[(0,V.jsx)(`button`,{className:`oc-drag-a11y`,"aria-label":Bi(),onClick:e=>e.stopPropagation(),...c,onKeyDown:h,children:(0,V.jsx)(jS,{className:`size-3.5`})}),N?(0,V.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:N}}):(0,V.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,V.jsx)(`button`,{className:`oc-chatitem__label`,onClick:t=>{t.stopPropagation(),!o.current&&s(e._id)},children:e.title||bd()}),r?(0,V.jsx)(`span`,{className:`oc-chatitem__busy`,title:v(),"aria-label":v()}):null,n?(0,V.jsx)(`span`,{className:`oc-chatitem__unread`,title:en(),"aria-label":en()}):null,e.readOnly?(0,V.jsx)(`span`,{className:`oc-chatitem__readonly`,title:ku(),children:(0,V.jsx)(NS,{size:12,"aria-label":ku()})}):null,i?(0,V.jsx)(`span`,{className:`oc-chatitem__bookmark group-hover/row:opacity-0 group-focus-within/row:opacity-0`,title:br(),children:(0,V.jsx)(dS,{size:12,"aria-label":br()})}):null,w?(0,V.jsx)(`span`,{className:`oc-chatitem__age group-hover/row:opacity-0 group-focus-within/row:opacity-0`,title:kV(e.updatedAt),children:wSe(e.updatedAt,Date.now())}):null,(0,V.jsxs)(xV,{children:[(0,V.jsx)(SV,{asChild:!0,children:(0,V.jsx)(Ep,{variant:`ghost`,size:`icon-xs`,"aria-label":re(),className:`opacity-0 group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:(0,V.jsx)(wS,{})})}),(0,V.jsxs)(CV,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(wV,{onSelect:()=>{k(e.title??``),D(!0)},children:[(0,V.jsx)(BS,{}),` `,np()]}),(0,V.jsxs)(wV,{onSelect:()=>void S({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,V.jsx)(cre,{}):(0,V.jsx)(sre,{}),e.pinned?Br():Dn()]}),(0,V.jsxs)(wV,{onSelect:b,disabled:a===void 0,children:[(0,V.jsx)(Zne,{}),` `,sa()]}),(0,V.jsx)(TV,{children:Vt()}),(0,V.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,V.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void C({chatId:e._id,color:null}),"aria-label":Qe(),children:`✕`}),a9.map(t=>(0,V.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void C({chatId:e._id,color:t.value})},t.value))]}),(0,V.jsx)(EV,{}),(0,V.jsxs)(wV,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await T({title:gr(),description:Jn(),confirmLabel:Tt(),destructive:!0})&&await x({chatId:e._id})})},children:[(0,V.jsx)(YS,{}),` `,Tt()]})]})]})]}),(0,V.jsx)(Q7,{open:E,onOpenChange:D,title:Rn(),canSubmit:O.trim().length>0,onSubmit:async()=>{await _({chatId:e._id,title:O.trim()}),D(!1)},children:(0,V.jsx)(`div`,{className:`oc-form`,children:(0,V.jsxs)(`label`,{className:`oc-field`,children:[(0,V.jsx)(`span`,{className:`oc-field__label`,children:Vc()}),(0,V.jsx)(QB,{value:O,onChange:e=>k(e.target.value),autoFocus:!0})]})})})]})}),h9=null,g9=0,OSe=400;function kSe(){if(typeof window>`u`)return null;let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;if(!h9)try{h9=new e}catch{return null}return h9}function _9(e,t,n,r,i){let a=e.createOscillator(),o=e.createGain();a.type=`sine`,a.frequency.value=t;let s=e.currentTime+n;o.gain.setValueAtTime(1e-4,s),o.gain.linearRampToValueAtTime(i,s+.015),o.gain.exponentialRampToValueAtTime(1e-4,s+r),a.connect(o).connect(e.destination),a.start(s),a.stop(s+r+.02)}function v9(e){let t=Date.now();if(t-g9<OSe)return;let n=kSe();if(!n)return;g9=t;let r=()=>{try{e(n)}catch{}};n.state===`suspended`?n.resume().then(r,()=>{}):r()}function ASe(){v9(e=>{_9(e,660,0,.16,.12),_9(e,440,.14,.2,.1)})}function jSe(){v9(e=>{_9(e,880,0,.14,.08)})}function MSe({activeChatId:e}){let t=R(L.messages.listChats,{}),n=p(L.chatReads.markChatSeen),r=R(L.me.getMe,{host:aB}),i=r?.ui?.effective?.replySound===!0,a=r?.userId??null,o=(0,B.useRef)(null),s=(0,B.useRef)(null);return(0,B.useEffect)(()=>{if(!t)return;s.current!==String(a)&&(s.current=String(a),o.current=null);let r=new Map;for(let e of t)e.lastAssistantAt!==null&&r.set(e._id,e.lastAssistantAt);let c=o.current;if(o.current=r,c===null)return;let l=!1;for(let[t,i]of r){let r=c.get(t);r!==void 0&&i<=r||r===void 0&&Date.now()-i>3e4||(l=!0,t===e&&document.visibilityState===`visible`?n({chatId:t}):t!==e&&rH(t))}l&&i&&jSe()},[t,e,i,n,a]),(0,B.useEffect)(()=>{e&&document.visibilityState===`visible`&&n({chatId:e})},[e,n]),(0,B.useEffect)(()=>{let t=()=>{document.visibilityState===`visible`&&e&&n({chatId:e})};return document.addEventListener(`visibilitychange`,t),()=>document.removeEventListener(`visibilitychange`,t)},[e,n]),null}function NSe(e){let t=p(L.chats.createChat),n=R(L.agents.listMyAgents),[r,i]=(0,B.useState)(!1),a=(0,B.useCallback)(async(n,r)=>{e(await t({instanceName:n,agentId:r}))},[t,e]);return{startNewChat:(0,B.useCallback)(async()=>{let e=n;if(e&&e.length===1&&e[0].state!==`deleted`){await a(e[0].instanceName,e[0].agentId);return}i(!0)},[n,a]),picker:(0,V.jsx)(rV,{open:r,onOpenChange:i,agents:n,onPick:(e,t)=>{i(!1),a(e,t)}})}}var y9=[`admin`,`user`,`pending`];function b9(){let e=R(L.me.authProviders)?.anonymous===!0,[t,n]=(0,B.useState)(!1),r=R(L.dev.listUsersDev,e?{}:`skip`),i=R(L.me.getImpersonation),a=p(L.dev.setMyRole),o=p(L.dev.setRole),s=p(L.admin.startImpersonation),c=p(L.admin.stopImpersonation);if(!e)return null;let l=r?.find(e=>e.isMe),u=l?.role===`admin`,d=i?.impersonating===!0,f=(r??[]).filter(e=>!e.isMe);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`button`,{type:`button`,className:`oc-devfab`,onClick:()=>n(!0),title:ge(),children:[(0,V.jsx)(QS,{size:13}),`DEV`]}),(0,V.jsx)(WB,{open:t,onOpenChange:n,children:(0,V.jsxs)(qB,{children:[(0,V.jsxs)(JB,{children:[(0,V.jsx)(XB,{children:ei()}),(0,V.jsx)(ZB,{children:Cf()})]}),(0,V.jsxs)(`div`,{className:`oc-devsw__me`,children:[(0,V.jsxs)(`span`,{className:`oc-devsw__melabel`,children:[Mo({canonical:l?.canonical??`…`}),` `,(0,V.jsx)(eV,{variant:`outline`,children:l?.role??`…`})]}),(0,V.jsx)(`div`,{className:`oc-devsw__roles`,children:y9.map(e=>(0,V.jsx)(Ep,{type:`button`,size:`xs`,variant:l?.role===e?`secondary`:`ghost`,disabled:l?.role===e,onClick:()=>void a({role:e}),children:e===`admin`?zf():e===`user`?Yd():eo()},e))})]}),d?(0,V.jsxs)(`div`,{className:`oc-devsw__imp`,children:[Zs(),` `,(0,V.jsx)(`strong`,{children:i.targetLabel}),`.`,(0,V.jsx)(Ep,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>void c(),children:pc()})]}):null,(0,V.jsx)(`div`,{className:`oc-devsw__list`,children:f.length===0?(0,V.jsx)(`p`,{className:`oc-devsw__empty`,children:Cl()}):f.map(e=>(0,V.jsxs)(`div`,{className:`oc-devsw__row`,children:[(0,V.jsx)(`span`,{className:`oc-devsw__label`,children:e.name||e.email||e.canonical||e.userId.slice(0,8)}),(0,V.jsx)(`select`,{className:`oc-devsw__select`,value:e.role,disabled:!e.canonical,onChange:t=>e.canonical&&void o({canonical:e.canonical,role:t.target.value}),children:y9.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))}),(0,V.jsx)(Ep,{type:`button`,size:`xs`,variant:`ghost`,disabled:!u||e.role===`pending`,title:u?e.role===`pending`?Is():us():hu(),onClick:()=>{s({profileId:e.profileId}),n(!1)},children:Id()})]},e.profileId))})]})})]})}function x9({label:e,mode:t,minimal:n=!1}){let{signOut:r}=im(),i=p(L.me.setThemeMode).withOptimisticUpdate((e,{mode:t})=>{let n=e.getQuery(L.me.getMe,{host:aB});if(!n)return;let r=t===null?n.defaultThemeMode??`system`:t;e.setQuery(L.me.getMe,{host:aB},{...n,themeMode:t,resolvedThemeMode:r})}),a=t??`default`;return(0,V.jsxs)(xV,{children:[(0,V.jsx)(SV,{asChild:!0,children:(0,V.jsxs)(Ep,{variant:`ghost`,size:`sm`,className:`gap-1.5`,children:[e,(0,V.jsx)(up,{className:`opacity-60`})]})}),(0,V.jsx)(CV,{align:`end`,className:`w-52`,children:n?(0,V.jsxs)(wV,{onClick:()=>void r(),children:[(0,V.jsx)(PS,{}),` `,Zf()]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(TV,{children:Zi()}),(0,V.jsxs)(DV,{value:a,onValueChange:e=>void i({mode:e==="default"?null:e}),children:[(0,V.jsxs)(OV,{value:`light`,children:[(0,V.jsx)(pre,{}),` `,Si()]}),(0,V.jsxs)(OV,{value:`dark`,children:[(0,V.jsx)(rre,{}),` `,xt()]}),(0,V.jsxs)(OV,{value:`system`,children:[(0,V.jsx)(nre,{}),` `,Fi()]}),(0,V.jsx)(OV,{value:`default`,children:P()})]}),(0,V.jsx)(EV,{}),(0,V.jsxs)(wV,{onClick:()=>void r(),children:[(0,V.jsx)(PS,{}),` `,Zf()]})]})})]})}var PSe={altered_words:()=>Jd(),incorrect:()=>$a(),incoherence:()=>Xs(),formatting:()=>fc(),latency:()=>Sl(),api_error:()=>mu(),other:()=>Fs()},S9=e=>PSe[e]?.()??e,FSe={anomaly_open:XS,anomaly_resolved:vS,feedback_reply:IS,feedback_resolved:IS,feedback_new:IS,curation:DS},ISe={notif_feedback_reply_admin:()=>({title:$r(),body:Sf()}),notif_feedback_reply:()=>({title:$r(),body:Sf()}),notif_feedback_resolved:()=>({title:zt(),body:Xe()}),notif_feedback_new:e=>({title:Ao(),body:Rf({reference:e.reference??`?`,category:S9(e.category??`other`)})}),notif_curation_proposed:e=>({title:tn(),body:Au({name:e.name??`?`,agentId:e.agentId??`?`})}),notif_curation_failed:e=>({title:hn(),body:ft({name:e.name??`?`,reason:e.reason??`unknown`})}),notif_curation_relaunch_refused:e=>({title:ta(),body:Ti({name:e.name??`?`,reason:e.reason??`unknown`})}),notif_anomaly_open:(e,t)=>({title:Et({kind:e.kind??`?`}),body:t.body}),notif_anomaly_resolved:(e,t)=>({title:Vi({kind:e.kind??`?`}),body:t.body})};function C9(e){let t=e.messageKey?ISe[e.messageKey]:void 0;return t?t(e.params??{},e):e.kind===`feedback_reply`?{title:$r(),body:Sf()}:e.kind===`feedback_resolved`?{title:zt(),body:Xe()}:{title:e.title,body:e.body}}function LSe(){let e=R(L.notifications.myUnreadCount)??0,t=R(L.notifications.myNotifications),n=R(L.feedback.myFeedback),r=p(L.notifications.markRead),i=p(L.notifications.markAllRead),a=p(L.notifications.clearOne),o=p(L.notifications.clearAll),s=p(L.feedback.closeMyFeedback),c=Fg(),[l,u]=(0,B.useState)(!1),d=R(L.me.getMe,{host:aB}),f=d?.ui?.effective?.notifSound===!0,m=d?.ui?.effective?.notifSystem===!0,h=d?.userId??null,g=(0,B.useRef)(null),_=(0,B.useRef)(0),v=(0,B.useRef)(null);(0,B.useEffect)(()=>{if(!t)return;v.current!==String(h)&&(v.current=String(h),g.current=null,_.current=0);let e=t.reduce((e,t)=>Math.max(e,t.creationTime??0),0);if(g.current===null){g.current=new Set(t.map(e=>String(e._id))),_.current=e;return}let n=g.current,r=t.filter(e=>!n.has(String(e._id))&&(e.creationTime??0)>_.current);for(let e of t)n.add(String(e._id));if(_.current=Math.max(_.current,e),n.size>500){let e=new Set(t.map(e=>String(e._id)));for(let t of n)e.has(t)||n.delete(t)}if(r.length!==0&&(f&&ASe(),m&&typeof Notification<`u`&&Notification.permission===`granted`&&document.visibilityState!==`visible`)){let e=r[0],{title:t,body:n}=C9(e);try{let r=new Notification(t,{body:n,tag:String(e._id)});r.onclick=()=>window.focus()}catch{}}},[t,f,m,h]);let y=e=>{if(e.unread&&r({notificationId:e._id}),!e.href)return;if(u(!1),e.href.startsWith(`/chat/`)){c({to:`/chat/$chatId`,params:{chatId:e.href.slice(6)}});return}let[t,n]=e.href.split(`?`);c({to:t,search:Object.fromEntries(new URLSearchParams(n??``))})};return(0,V.jsxs)(xV,{open:l,onOpenChange:u,children:[(0,V.jsx)(SV,{asChild:!0,children:(0,V.jsxs)(`button`,{type:`button`,className:`oc-bell`,"aria-label":e>0?Li({count:e}):te(),children:[(0,V.jsx)(uS,{size:18,"aria-hidden":!0}),e>0?(0,V.jsx)(`span`,{className:`oc-bell__badge`,"aria-hidden":!0,children:e>9?`9+`:e}):null]})}),(0,V.jsxs)(CV,{align:`end`,className:`oc-notif`,children:[(0,V.jsxs)(`div`,{className:`oc-notif__head`,children:[(0,V.jsx)(`span`,{children:$f()}),t&&t.length>0?(0,V.jsxs)(`span`,{className:`oc-notif__bulk`,children:[(0,V.jsx)(`button`,{type:`button`,className:`oc-notif__act`,disabled:e===0,onClick:()=>void i({}),children:Rr()}),(0,V.jsx)(`button`,{type:`button`,className:`oc-notif__act`,onClick:()=>void o({}),children:Tn()})]}):null]}),t===void 0?(0,V.jsx)(`div`,{className:`oc-notif__empty`,children:st()}):t.length===0?(0,V.jsx)(`div`,{className:`oc-notif__empty`,children:Rt()}):(0,V.jsx)(`div`,{className:`oc-notif__list`,children:t.map(e=>{let t=FSe[e.kind]??uS,{title:n,body:i}=C9(e);return(0,V.jsxs)(`div`,{className:`oc-notif__item${e.unread?` is-unread`:``}${e.href?` is-link`:``}`,role:e.href?`button`:void 0,tabIndex:e.href?0:void 0,onClick:e.href?()=>y(e):void 0,children:[(0,V.jsxs)(`div`,{className:`oc-notif__item-head`,children:[(0,V.jsx)(t,{size:14,className:`oc-notif__kind oc-notif__kind--${e.kind}`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-notif__title`,children:n}),(0,V.jsxs)(`span`,{className:`oc-notif__row-actions`,children:[e.unread?(0,V.jsx)(`button`,{type:`button`,title:Ye(),"aria-label":Ye(),onClick:t=>{t.stopPropagation(),r({notificationId:e._id})},children:(0,V.jsx)(cp,{size:13})}):null,(0,V.jsx)(`button`,{type:`button`,title:mr(),"aria-label":mr(),onClick:t=>{t.stopPropagation(),a({notificationId:e._id})},children:(0,V.jsx)(mp,{size:13})})]})]}),(0,V.jsx)(`p`,{className:`oc-notif__body`,children:i}),(0,V.jsx)(`div`,{className:`oc-notif__when`,children:new Date(e.createdAt).toLocaleString(Tu())})]},e._id)})}),n&&n.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`oc-notif__head oc-notif__head--sub`,children:qn()}),(0,V.jsx)(`div`,{className:`oc-notif__list`,children:n.map(e=>(0,V.jsx)(RSe,{it:e,onClose:t=>s({feedbackId:e._id,reason:t}),onNavigate:()=>u(!1)},e._id))})]}):null]})]})}function RSe({it:e,onClose:t,onNavigate:n}){let r=uH(),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(``),[u,d]=(0,B.useState)(!1);async function f(){d(!0);try{await t(c.trim()||void 0)}catch(e){r.error(Le(),e)}finally{d(!1)}}return(0,V.jsxs)(`div`,{className:`oc-notif__item`,children:[(0,V.jsxs)(`div`,{className:`oc-notif__item-head`,children:[(0,V.jsx)(`span`,{className:`oc-notif__title`,children:S9(e.category)}),(0,V.jsx)(`span`,{className:`oc-notif__status${e.answered||e.resolvedAt?` is-answered`:``}`,children:e.resolvedAt?ep():e.answered?Ln():Bc()})]}),(0,V.jsx)(`div`,{className:`oc-notif__when`,children:new Date(e.at).toLocaleString(Tu())}),e.thread.length>0?(0,V.jsx)(`div`,{className:`oc-notif__thread`,children:e.thread.map((e,t)=>(0,V.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,V.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?E():e.authorRole===`agent`?Ri():Yc()}),(0,V.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):null,e.messageText?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`button`,{type:`button`,className:`oc-notif__report-toggle`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[i?(0,V.jsx)(up,{size:13,"aria-hidden":!0}):(0,V.jsx)(gS,{size:13,"aria-hidden":!0}),Ee()]}),i?(0,V.jsx)(`div`,{className:`oc-notif__report-msg`,children:e.messageText}):null]}):null,(0,V.jsxs)(`div`,{className:`oc-notif__report-actions`,children:[(0,V.jsx)(Yg,{to:`/chat/$chatId`,params:{chatId:e.chatId},search:{m:e.messageId},className:`oc-notif__link`,onClick:n,children:rr()}),o?null:(0,V.jsx)(`button`,{type:`button`,className:`oc-notif__link oc-notif__link--muted`,onClick:()=>s(!0),children:Le()})]}),o?(0,V.jsxs)(`div`,{className:`oc-notif__close-form`,children:[(0,V.jsx)(`textarea`,{className:`oc-notif__close-input`,rows:2,value:c,onChange:e=>l(e.target.value),placeholder:di()}),(0,V.jsxs)(`div`,{className:`oc-notif__close-actions`,children:[(0,V.jsx)(`button`,{type:`button`,className:`oc-notif__close-confirm`,disabled:u,onClick:()=>void f(),children:lf()}),(0,V.jsx)(`button`,{type:`button`,className:`oc-notif__close-cancel`,onClick:()=>{s(!1),l(``)},children:he()})]})]}):null]})}var w9=2,zSe=180;function BSe(){let e=Fg(),t=(0,B.useRef)(null),n=(0,B.useRef)(null),[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(``),[s,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(0),d=(0,B.useMemo)(()=>yB(uB,_B()),[]);(0,B.useEffect)(()=>{let e=setTimeout(()=>c(a),zSe);return()=>clearTimeout(e)},[a]);let f=s.trim(),p=R(L.search.searchConversations,f.length>=w9?{query:f}:`skip`),m=p??[],h=f.length>=w9&&p===void 0;(0,B.useEffect)(()=>{let e=e=>{bB(e,uB)&&(e.preventDefault(),i(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,B.useEffect)(()=>{r&&(o(``),c(``),u(0))},[r]),(0,B.useEffect)(()=>{u(0)},[p]),(0,B.useEffect)(()=>{(n.current?.querySelector(`[data-index="${l}"]`))?.scrollIntoView({block:`nearest`})},[l]);let g=(0,B.useCallback)((t,n)=>{i(!1),n&&a.trim()&&Uve(n,a.trim()),e({to:`/chat/$chatId`,params:{chatId:t},...n?{search:{m:n}}:{}})},[e,a]);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`button`,{type:`button`,className:`oc-search-trigger`,onClick:()=>i(!0),"aria-label":rn(),children:[(0,V.jsx)(WS,{className:`oc-search-trigger__icon`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-search-trigger__label`,children:Mu()}),(0,V.jsx)(`kbd`,{className:`oc-search-trigger__kbd`,children:d})]}),(0,V.jsx)(WB,{open:r,onOpenChange:i,children:(0,V.jsxs)(qB,{showCloseButton:!1,className:`oc-search-palette top-[12vh] translate-y-0 max-w-xl gap-0 overflow-hidden p-0`,onOpenAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:[(0,V.jsx)(XB,{className:`sr-only`,children:_n()}),(0,V.jsxs)(`div`,{className:`oc-search-palette__head`,children:[(0,V.jsx)(WS,{className:`oc-search-palette__head-icon`,"aria-hidden":!0}),(0,V.jsx)(`input`,{ref:t,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),u(e=>Math.min(e+1,m.length-1));else if(e.key===`ArrowUp`)e.preventDefault(),u(e=>Math.max(e-1,0));else if(e.key===`Enter`){e.preventDefault();let t=m[l];t&&g(t.chatId,t.messageId)}},placeholder:mt(),className:`oc-search-palette__field`,autoComplete:`off`,spellCheck:!1,"aria-label":ra()})]}),(0,V.jsx)(`div`,{className:`oc-search-palette__results`,ref:n,role:`listbox`,children:f.length<w9?(0,V.jsx)(`div`,{className:`oc-search-palette__hint`,children:Di({count:w9})}):h?(0,V.jsx)(`div`,{className:`oc-search-palette__hint`,children:Ot()}):m.length===0?(0,V.jsx)(`div`,{className:`oc-search-palette__hint`,children:Ui({term:f})}):m.map((e,t)=>(0,V.jsxs)(`button`,{type:`button`,"data-index":t,role:`option`,"aria-selected":t===l,className:Al(`oc-search-result`,t===l&&`is-active`),onMouseMove:()=>u(t),onClick:()=>g(e.chatId,e.messageId),children:[(0,V.jsx)(`span`,{className:`oc-search-result__icon`,"aria-hidden":!0,children:e.matchedIn===`title`?(0,V.jsx)(Jne,{size:15}):(0,V.jsx)(IS,{size:15})}),(0,V.jsxs)(`span`,{className:`oc-search-result__body`,children:[(0,V.jsx)(`span`,{className:`oc-search-result__title`,children:e.title||ae()}),e.snippet?(0,V.jsx)(`span`,{className:`oc-search-result__snippet`,children:e.snippet}):null]}),(0,V.jsx)(`span`,{className:`oc-search-result__tag`,children:e.matchedIn===`title`?ip():Hr()})]},e.chatId))}),(0,V.jsxs)(`div`,{className:`oc-search-palette__footer`,children:[(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`kbd`,{children:`↑`}),(0,V.jsx)(`kbd`,{children:`↓`}),` `,kn()]}),(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`kbd`,{children:`↵`}),` `,Ut()]}),(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`kbd`,{children:et()}),` `,_r()]})]})]})})]})}var T9=[`users`,`groups`,`instances`,`bridge`,`injections`,`serviceAccounts`,`roles`,`access`,`traces`,`kpi`,`anomalies`,`files`,`scheduled`,`agentFiles`,`preferences`,`integrations`,`theme`,`chatDefaults`,`audit`,`feedbacks`,`subagentReports`,`voice`],E9=[`groups`,`access`,`roles`,`integrations`,`instances`,`injections`,`theme`,`feedbacks`,`subagentReports`,`files`,`scheduled`,`agentFiles`,`preferences`,`chatDefaults`],D9={users:()=>ls(),groups:()=>bs(),instances:()=>Fd(),bridge:()=>ll(),injections:()=>Ea(),serviceAccounts:()=>qo(),roles:()=>ad(),access:()=>h(),traces:()=>$l(),kpi:()=>go(),anomalies:()=>Dc(),files:()=>Ff(),scheduled:()=>It(),agentFiles:()=>hr(),preferences:()=>Ir(),integrations:()=>Hu(),theme:()=>uo(),chatDefaults:()=>Wu(),audit:()=>Ll(),feedbacks:()=>yd(),subagentReports:()=>jc(),voice:()=>no()},O9={users:`admin.manage`,groups:`groups.manage`,instances:`admin.manage`,bridge:`bridge.read`,injections:`admin.manage`,serviceAccounts:`admin.manage`,roles:`admin.manage`,access:`admin.manage`,traces:`traces.read`,kpi:`kpi.read`,anomalies:`anomalies.read`,files:`chats.read`,scheduled:`chats.read`,agentFiles:`agents.files.read`,preferences:`chats.read`,integrations:`admin.manage`,theme:`chats.read`,chatDefaults:`admin.manage`,audit:`admin.manage`,feedbacks:`admin.manage`,subagentReports:`admin.manage`,voice:`admin.manage`},VSe=[`traces`,`kpi`,`anomalies`,`bridge`,`agentFiles`,`groups`];function k9(e){let t=new Set(e);return T9.filter(e=>t.has(O9[e]))}function A9(e){return`/settings/${e}`}function j9(e){let t=e.split(`/`)[2];return T9.includes(t)?t:void 0}var HSe={uiprefs:`preferences`},M9=[{id:`personal`,label:()=>be(),tabs:[`preferences`,`theme`,`files`,`scheduled`]},{id:`agents`,label:()=>ii(),tabs:[`instances`,`agentFiles`,`chatDefaults`,`voice`,`bridge`,`injections`]},{id:`access`,label:()=>Of(),tabs:[`users`,`groups`,`access`,`roles`,`serviceAccounts`]},{id:`observability`,label:()=>Lo(),tabs:[`traces`,`kpi`,`anomalies`,`audit`,`feedbacks`,`subagentReports`,`integrations`]}],USe=new Map(M9.flatMap(e=>e.tabs.map(t=>[t,e.id])));function N9(e){let t=USe.get(e);if(!t)throw Error(`Settings tab "${e}" belongs to no group`);return t}function WSe(e,t){return e.find(e=>N9(e)===t)}M9.flatMap(e=>[...e.tabs]);function GSe(){let e=R(L.bridgeHealth.getBridgeAvailability,{});if(e===void 0)return null;let t=e.gatewaysUnreachable??0,n=e.known?e.available?t>0?`warn`:`ok`:`error`:`idle`,r=e.known?e.available?t>0?jo({count:t}):`${Gu()}${e.checkedAt?zl({time:jV(e.checkedAt)}):``}`:xd({reason:e.reason??`?`}):kc();return(0,V.jsx)(v6,{delayDuration:150,children:(0,V.jsxs)(y6,{children:[(0,V.jsx)(b6,{asChild:!0,children:(0,V.jsx)(`span`,{className:`oc-bridge-dot oc-bridge-dot--${n}`,role:`img`,"aria-label":r})}),(0,V.jsx)(x6,{children:r})]})})}function P9(e){let t=new Set(T9),n=new Set,r=[];for(let i of e??[])t.has(i)&&!n.has(i)&&(r.push(i),n.add(i));for(let e of T9)n.has(e)||r.push(e);return r}function KSe(e,t){let n=new Set(t),r=[...t];return e.map(e=>n.has(e)?r.shift():e)}function qSe({tab:e,active:t}){let n=D9[e](),r=`oc-settings-tabs__tab`+(t?` is-active`:``),i=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`oc-settings-tabs__label`,children:n}),e===`bridge`?(0,V.jsx)(GSe,{}):null]});return E9.includes(e)?(0,V.jsx)(Yg,{to:`/settings/$tab`,params:{tab:e},className:r,role:`tab`,"aria-selected":t,children:i}):(0,V.jsx)(Yg,{to:`/settings/${e}`,className:r,role:`tab`,"aria-selected":t,children:i})}function JSe({tab:e,active:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=J7({id:e});return(0,V.jsxs)(`div`,{ref:i,style:{transform:x5.Transform.toString(a),transition:o,opacity:s?.5:1},className:`oc-settings-tabs__item`,role:`presentation`,children:[(0,V.jsx)(`button`,{type:`button`,className:`oc-settings-tabs__grip`,"aria-label":je(),...n,...r,children:(0,V.jsx)(jS,{size:14,"aria-hidden":!0})}),(0,V.jsx)(qSe,{tab:e,active:t})]})}function YSe(){let e=R(L.me.getMe,{host:aB}),t=p(L.me.setSettingsTabOrder),n=j9(b_({select:e=>e.pathname})),r=n===void 0?void 0:N9(n),i=(0,B.useMemo)(()=>P9(e?.settingsTabOrder??null),[e?.settingsTabOrder]),[a,o]=(0,B.useState)(i);(0,B.useEffect)(()=>o(i),[i]);let s=(0,B.useMemo)(()=>new Set(k9(e?.permissions??[])),[e?.permissions]),c=(0,B.useMemo)(()=>r===void 0?[]:a.filter(e=>s.has(e)&&N9(e)===r),[a,s,r]),l=D5(E5(s7,{activationConstraint:{distance:5}}),E5(r7,{coordinateGetter:X7}));if(r===void 0||c.length===0)return null;let u=M9.find(e=>e.id===r);function d(e){let{active:n,over:r}=e;if(!r||n.id===r.id)return;let i=c.indexOf(n.id),s=c.indexOf(r.id);if(i<0||s<0)return;let l=KSe(a,R7(c,i,s));o(l),t({order:l})}return(0,V.jsx)(`div`,{className:`oc-settings-tabs`,role:`tablist`,"aria-label":u?.label(),children:(0,V.jsx)(N7,{sensors:l,collisionDetection:Zbe,modifiers:[aSe],onDragEnd:d,children:(0,V.jsx)(K7,{items:c,strategy:fSe,children:c.map(e=>(0,V.jsx)(JSe,{tab:e,active:e===n},e))})})})}function XSe(){let e=R(L.me.getMe,{host:aB}),t=Fg(),n=j9(b_({select:e=>e.pathname})),r=n===void 0?void 0:N9(n),i=(0,B.useMemo)(()=>new Set(k9(e?.permissions??[])),[e?.permissions]),a=(0,B.useMemo)(()=>P9(e?.settingsTabOrder??null).filter(e=>i.has(e)),[e?.settingsTabOrder,i]),o=M9.filter(e=>e.tabs.some(e=>i.has(e)));function s(e){let n=WSe(a,e.id);n&&t({to:A9(n)})}return(0,V.jsxs)(`nav`,{className:`oc-settings-nav`,"aria-label":He(),children:[(0,V.jsx)(Yg,{to:`/`,className:`oc-settings-nav__back`,children:gi()}),(0,V.jsx)(`div`,{className:`oc-settings-nav__title`,children:pf()}),(0,V.jsx)(`div`,{className:`oc-settings-nav__list`,children:o.map(e=>(0,V.jsx)(`button`,{type:`button`,className:`oc-settings-nav__group`+(e.id===r?` is-active`:``),"aria-current":e.id===r?`true`:void 0,onClick:()=>s(e),children:e.label()},e.id))})]})}var ZSe=[`eq`,`neq`,`contains`,`gt`,`gte`,`lt`,`lte`],F9=[50,100,200,500],I9=`now-30d`,QSe=`now-24h`;function $Se(e,t,n=I9,r=`now`){let i=e??n,a=t??r,o=Number(i),s=Number(a);return i!==``&&a!==``&&Number.isFinite(o)&&Number.isFinite(s)?{kind:`absolute`,from:o,to:s}:{kind:`relative`,from:i,to:a}}function eCe(e){return e.kind===`absolute`?{from:String(e.from),to:String(e.to)}:{from:e.from,to:e.to}}function tCe(e){if(e.length!==0)return JSON.stringify(e)}function nCe(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e,r=t.field,i=t.op,a=t.value;typeof r!=`string`||r===``||typeof i!=`string`||!ZSe.includes(i)||typeof a!=`string`&&typeof a!=`number`&&typeof a!=`boolean`||n.push({field:r,op:i,value:a})}return n}var L9=Kx().optional(),R9=Kx().optional(),z9=Kx().optional(),B9=Kx().optional().catch(void 0),rCe=$x({q:L9,section:nS([`latency`,`events`]).default(`events`).catch(`events`),kind:Kx().default(`all`).catch(`all`),limit:zne().pipe(eS([rS(F9[0]),rS(F9[1]),rS(F9[2]),rS(F9[3])])).catch(100),statusClass:nS([`2xx`,`4xx`,`5xx`]).optional().catch(void 0),principalType:nS([`user`,`service`,`system`]).optional().catch(void 0),direction:nS([`inbound`,`outbound`,`internal`]).optional().catch(void 0),roleKey:B9,from:R9,to:R9,adv:z9}),iCe=$x({q:L9,action:B9,impersonated:nS([`yes`,`no`]).optional().catch(void 0),resource:B9,from:R9,to:R9,adv:z9}),aCe=$x({q:L9,status:nS([`open`,`acknowledged`,`resolved`,`all`]).default(`open`).catch(`open`),severity:nS([`info`,`warn`,`critical`]).optional().catch(void 0),kind:B9,from:R9,to:R9}),oCe=$x({from:R9,to:R9}),sCe=$x({q:L9,status:nS([`active`,`disabled`]).optional().catch(void 0)}),cCe=$x({q:L9,role:B9});$x({q:L9,mode:nS([`per-user`,`shared`]).optional().catch(void 0)});var lCe=$x({section:nS([`readaloud`,`dictation`,`talk`]).default(`readaloud`).catch(`readaloud`)}),uCe=$x({section:Kx().max(32).default(`openclaw`).catch(`openclaw`)}),V9=`oc.theme`;function H9(e){let t=e===`dark`||e===`system`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;document.documentElement.classList.toggle(`dark`,t)}function U9(e){(0,B.useEffect)(()=>{let t=e??localStorage.getItem(V9)??`system`;if(localStorage.setItem(V9,t),H9(t),t===`system`){let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>H9(`system`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}},[e])}var W9=`oc.fontScale`,dCe={sm:`87.5%`,md:``,lg:`112.5%`,xl:`125%`},G9=[`sm`,`md`,`lg`,`xl`];function fCe(e){return e!==null&&G9.includes(e)}function pCe(e){document.documentElement.style.fontSize=dCe[e]}function K9(e){(0,B.useEffect)(()=>{let t=localStorage.getItem(W9),n=e??(fCe(t)?t:`md`);localStorage.setItem(W9,n),pCe(n)},[e])}function mCe(e){(0,B.useEffect)(()=>{if(!e)return;document.documentElement.lang=e;let t;try{t=Tu()}catch{t=void 0}t!==e&&Xt(e)},[e])}var hCe=(0,B.lazy)(()=>g4(()=>import(`./RolesTab-rgpFvkKx.js`).then(e=>({default:e.RolesTab})),__vite__mapDeps([2,1,3,4,5]))),gCe=(0,B.lazy)(()=>g4(()=>import(`./InstancesTab-ZJeQ4rRg.js`).then(e=>({default:e.InstancesTab})),__vite__mapDeps([6,1,3,7,8,9,10,11,12,13,14,15,16,5,17,18,19]))),_Ce=(0,B.lazy)(()=>g4(()=>import(`./PromptInjectionsTab-H8zrJADs.js`).then(e=>({default:e.PromptInjectionsTab})),__vite__mapDeps([20,1,3,7,8,9,21,5,22]))),vCe=(0,B.lazy)(()=>g4(()=>import(`./GroupsTab-BJWQQexi.js`).then(e=>({default:e.GroupsTab})),__vite__mapDeps([23,1,3,13,12,24,19,14,5,17,25,15,16]))),yCe=(0,B.lazy)(()=>g4(()=>import(`./IntegrationsTab-CSOlJvFa.js`).then(e=>({default:e.IntegrationsTab})),__vite__mapDeps([26,1,3,5]))),bCe=(0,B.lazy)(()=>g4(()=>import(`./FeedbacksTab-BdYRB-_C.js`).then(e=>({default:e.FeedbacksTab})),__vite__mapDeps([27,1,3,19,12,14,5,17]))),xCe=(0,B.lazy)(()=>g4(()=>import(`./SubAgentReportsTab-BgM9O4QZ.js`).then(e=>({default:e.SubAgentReportsTab})),__vite__mapDeps([28,1,3,19,12,14,5,17]))),SCe=(0,B.lazy)(()=>g4(()=>import(`./FilesTab-h10yjTHp.js`).then(e=>({default:e.FilesTab})),__vite__mapDeps([29,1,3,5,17]))),CCe=(0,B.lazy)(()=>g4(()=>import(`./ScheduledTab-DbMIc4wG.js`).then(e=>({default:e.ScheduledTab})),__vite__mapDeps([30,1,3,5,17]))),wCe=(0,B.lazy)(()=>g4(()=>import(`./AgentFilesTab-BjPywJ7Q.js`).then(e=>({default:e.AgentFilesTab})),__vite__mapDeps([31,1,3,11,8,5,22]))),TCe=(0,B.lazy)(()=>g4(()=>import(`./PreferencesTab-Bd-GUi0T.js`).then(e=>({default:e.PreferencesTab})),__vite__mapDeps([32,1,3,21,9,5]))),ECe=(0,B.lazy)(()=>g4(()=>import(`./ChatDefaultsTab-STVjXTAX.js`).then(e=>({default:e.ChatDefaultsTab})),__vite__mapDeps([33,1,3,11,5,22]))),DCe=(0,B.lazy)(()=>g4(()=>import(`./AccessTab-BBYqbyQz.js`).then(e=>({default:e.AccessTab})),__vite__mapDeps([34,1,3]))),OCe=(0,B.lazy)(()=>g4(()=>import(`./ThemeShowroom-BjDGGE3i.js`).then(e=>({default:e.ThemeShowroom})),__vite__mapDeps([35,1,3,36,24,37,12,16,5,15,21,9,38,17])));function kCe(){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Up,{children:(0,V.jsx)(`div`,{className:`oc-boot`,children:nc()})}),(0,V.jsx)(Hp,{children:(0,V.jsx)(jCe,{})}),(0,V.jsx)(Vp,{children:(0,V.jsx)(lH,{children:(0,V.jsx)(NCe,{})})})]})}function ACe(){return(0,V.jsxs)(`svg`,{className:`oc-provider__logo`,viewBox:`0 0 48 48`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{fill:`#EA4335`,d:`M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z`}),(0,V.jsx)(`path`,{fill:`#4285F4`,d:`M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z`}),(0,V.jsx)(`path`,{fill:`#FBBC05`,d:`M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z`}),(0,V.jsx)(`path`,{fill:`#34A853`,d:`M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z`})]})}function jCe(){let{signIn:e}=im();U9(void 0),K9(void 0);let t=R(L.charts.brandForHost,{host:aB}),n=cB(aB),r=t??n??null,i=EB(void 0);OB(r?.tokens??null,i),(0,B.useEffect)(()=>{t&&lB(aB,t)},[t]);let a=r?.brand,o=a&&!a.isDefault?FB(a,i):null,s=a?.label??`Atrium`,c=R(L.me.authProviders),[l,u]=(0,B.useState)(null);async function d(t){u(null);try{await e(t)}catch{u(vc())}}let f=c!==void 0&&!c.google&&!c.microsoft&&!c.anonymous;return(0,V.jsxs)(`div`,{className:`oc-signin`,children:[(0,V.jsxs)(`svg`,{className:`oc-signin__motif`,viewBox:`0 0 1200 1000`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:[(0,V.jsx)(`polyline`,{className:`oc-signin__line`,points:`0,860 470,860 522,790 574,940 626,810 678,860 1200,860`,vectorEffect:`non-scaling-stroke`}),(0,V.jsx)(`polyline`,{className:`oc-signin__pulse`,points:`0,860 470,860 522,790 574,940 626,810 678,860 1200,860`,pathLength:`100`,vectorEffect:`non-scaling-stroke`})]}),(0,V.jsxs)(`div`,{className:`oc-signin__brand`,children:[o?(0,V.jsx)(`img`,{className:`oc-signin__brandlogo`,src:o,alt:``}):null,(0,V.jsx)(`span`,{className:`oc-signin__wordmark`,children:s})]}),(0,V.jsxs)(`div`,{className:`oc-signin__card`,children:[(0,V.jsx)(`h1`,{className:`oc-signin__title`,children:Ol()}),(0,V.jsx)(`p`,{className:`oc-signin__subtitle`,children:yu()}),(0,V.jsx)(`div`,{className:`oc-signin__providers`,children:c?.google?(0,V.jsxs)(`button`,{type:`button`,className:`oc-provider oc-provider--google`,onClick:()=>void d(`google`),children:[(0,V.jsx)(ACe,{}),(0,V.jsx)(`span`,{children:Bs()})]}):null}),l?(0,V.jsx)(`p`,{className:`oc-signin__error`,children:l}):null,f?(0,V.jsx)(`p`,{className:`oc-signin__error`,children:ps()}):null,c?.anonymous?(0,V.jsx)(`button`,{type:`button`,className:`oc-signin__dev`,onClick:()=>void e(`anonymous`),children:zd()}):null]})]})}function MCe(){let{width:e,collapsed:t,isMobile:n}=q6();return(0,V.jsxs)(`div`,{className:`oc-shell`,children:[(0,V.jsxs)(`header`,{className:`oc-topbar`,children:[(0,V.jsxs)(`div`,{className:`oc-topbar__left`,children:[(0,V.jsx)(`div`,{className:`oc-skel`,style:{width:`1.75rem`,height:`1.75rem`}}),(0,V.jsx)(`div`,{className:`oc-skel`,style:{width:`5.5rem`,height:`1.1rem`}})]}),(0,V.jsx)(`div`,{className:`oc-topbar__search`,children:(0,V.jsx)(`div`,{className:`oc-skel`,style:{width:`100%`,height:`2.25rem`}})}),(0,V.jsx)(`div`,{className:`oc-topbar__actions`,children:(0,V.jsx)(`div`,{className:`oc-skel`,style:{width:`1.75rem`,height:`1.75rem`,borderRadius:`999px`}})})]}),(0,V.jsxs)(`div`,{className:n?`oc-workspace oc-workspace--mobile`:`oc-workspace`,children:[!t&&!n?(0,V.jsx)(`div`,{className:`oc-sidebar-col`,style:{width:e,flex:`0 0 ${e}px`},children:(0,V.jsxs)(`aside`,{className:`oc-sidebar`,children:[(0,V.jsx)(`div`,{className:`oc-skel`,style:{height:`2.25rem`,margin:`0.25rem 0.25rem 0`}}),(0,V.jsx)(f9,{})]})}):null,(0,V.jsx)(`main`,{className:`oc-main`})]})]})}function NCe(){let e=R(L.me.getMe,{host:aB}),t=p(L.me.bootstrap),n=Fg();(0,B.useEffect)(()=>{e&&!e.hasProfile&&t()},[e,t]),U9(e?.resolvedThemeMode),K9(e?.resolvedFontScale);let r=EB(e?.resolvedThemeMode);OB(e?.resolvedChartTokens,r),mCe(e?.resolvedLocale);let i=(0,B.useRef)(null);if((0,B.useEffect)(()=>{e&&(i.current!==null&&i.current!==e.userId&&n({to:`/`}),i.current=e.userId)},[e,n]),e===void 0)return(0,V.jsx)(MCe,{});let a=e.name||e.email||ml();return e.role===`pending`?(0,V.jsxs)(`div`,{className:`oc-shell`,children:[(0,V.jsx)(q9,{}),(0,V.jsx)(b9,{}),(0,V.jsxs)(`header`,{className:`oc-topbar`,children:[(0,V.jsx)(`span`,{className:`oc-topbar__brand`,children:(0,V.jsx)(J9,{brand:e.resolvedChartBrand,resolvedThemeMode:e.resolvedThemeMode})}),(0,V.jsx)(`div`,{className:`oc-topbar__actions`,children:(0,V.jsx)(x9,{label:a,mode:e.themeMode,minimal:!0})})]}),(0,V.jsxs)(`div`,{className:`oc-pending`,children:[(0,V.jsx)(`h1`,{className:`oc-pending__title`,children:Qo()}),(0,V.jsx)(`p`,{className:`oc-pending__body`,children:ud()})]})]}):(0,V.jsx)(FCe,{canOpenSettings:k9(e.permissions??[]).length>0,userLabel:a,themeMode:e.themeMode,resolvedThemeMode:e.resolvedThemeMode,brand:e.resolvedChartBrand},e.userId)}function q9(){let e=R(L.me.getImpersonation),t=p(L.admin.stopImpersonation);return!e||!e.impersonating?null:(0,V.jsxs)(`div`,{className:`oc-imp`,role:`alert`,children:[(0,V.jsx)(ES,{className:`size-4 shrink-0`}),(0,V.jsxs)(`span`,{className:`oc-imp__text`,children:[iu(),` `,(0,V.jsx)(`strong`,{children:e.targetLabel}),xo(),(0,V.jsx)(`strong`,{children:e.realLabel}),Pc()]}),(0,V.jsx)(Ep,{size:`sm`,variant:`outline`,className:`oc-imp__exit`,onClick:()=>void t(),children:Yu()})]})}function J9({brand:e,resolvedThemeMode:t}){let n=EB(t),r=e?.label??`Atrium`,i=e?.isDefault??!0,a=FB(e,n),[o,s]=(0,B.useState)(!1);return(0,B.useEffect)(()=>s(!1),[a]),(0,V.jsxs)(V.Fragment,{children:[a!==null&&!o?(0,V.jsx)(`img`,{className:`oc-brand__logo`,src:a,alt:``,"aria-hidden":`true`,onError:()=>s(!0)}):i?(0,V.jsx)(zB,{className:`oc-brand__logo`}):null,(0,V.jsx)(`span`,{className:`oc-brand__label`,children:r})]})}function PCe({userLabel:e,themeMode:t,resolvedThemeMode:n,brand:r,collapsed:i,onToggleSidebar:a}){return(0,V.jsxs)(`header`,{className:`oc-topbar`,children:[(0,V.jsxs)(`div`,{className:`oc-topbar__left`,children:[(0,V.jsx)(Ep,{variant:`ghost`,size:`icon-sm`,"aria-label":i?Ul():Td(),onClick:a,children:i?(0,V.jsx)(ore,{}):(0,V.jsx)(are,{})}),(0,V.jsx)(Yg,{to:`/`,className:`oc-topbar__brand`,children:(0,V.jsx)(J9,{brand:r,resolvedThemeMode:n})})]}),(0,V.jsx)(`div`,{className:`oc-topbar__search`,children:(0,V.jsx)(BSe,{})}),(0,V.jsxs)(`div`,{className:`oc-topbar__actions`,children:[(0,V.jsx)(LSe,{}),(0,V.jsx)(x9,{label:e,mode:t})]})]})}function FCe({canOpenSettings:e,userLabel:t,themeMode:n,resolvedThemeMode:r,brand:i}){let{width:a,columnRef:o,collapsed:s,toggleCollapsed:c,collapse:l,startResize:u,isMobile:d}=q6(),f=m_(),p=Ng({strict:!1}),h=Fg(),g=!!f({to:`/settings`,fuzzy:!0});(0,B.useEffect)(()=>{d&&l()},[b_({select:e=>e.pathname}),d,l]);let _=(0,B.useCallback)(e=>{h({to:`/chat/$chatId`,params:{chatId:e}})},[h]),{startNewChat:v,picker:y}=NSe(_),b=(0,B.useMemo)(()=>yB(dB,_B()),[]);return(0,B.useEffect)(()=>{let e=e=>{bB(e,dB)&&(e.preventDefault(),v())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[v]),(0,V.jsxs)(`div`,{className:`oc-shell`,children:[y,(0,V.jsx)(MSe,{activeChatId:p.chatId??null}),(0,V.jsx)(q9,{}),(0,V.jsx)(b9,{}),(0,V.jsx)(PCe,{userLabel:t,themeMode:n,resolvedThemeMode:r,brand:i,collapsed:s,onToggleSidebar:c}),(0,V.jsxs)(`div`,{className:d?`oc-workspace oc-workspace--mobile`:`oc-workspace`,children:[d&&!s?(0,V.jsx)(`div`,{className:`oc-sidebar-backdrop`,onClick:l,"aria-hidden":!0}):null,s?null:(0,V.jsxs)(`div`,{className:`oc-sidebar-col`,ref:e=>{o.current=d?null:e},style:d?void 0:{width:a,flex:`0 0 ${a}px`},children:[g?(0,V.jsx)(XSe,{}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(DSe,{activeChatId:p.chatId??null,onSelect:_,onNewChat:()=>void v(),newChatShortcut:b}),(0,V.jsx)(Ep,{variant:`ghost`,className:`mx-2 justify-start`,asChild:!0,children:(0,V.jsxs)(Yg,{to:`/settings/$tab`,params:{tab:`scheduled`},children:[(0,V.jsx)(mS,{"aria-hidden":!0}),ka()]})}),(0,V.jsx)(Ep,{variant:`ghost`,className:`mx-2 justify-start`,asChild:!0,children:(0,V.jsxs)(Yg,{to:`/settings/$tab`,params:{tab:`files`},children:[(0,V.jsx)(Xne,{"aria-hidden":!0}),ha()]})}),e?(0,V.jsx)(Ep,{variant:`ghost`,className:`mx-2 mb-2 justify-start`,asChild:!0,children:(0,V.jsxs)(Yg,{to:`/settings`,children:[(0,V.jsx)(ure,{"aria-hidden":!0}),Es()]})}):null]}),(0,V.jsx)(`div`,{className:`oc-sidebar-resizer`,onPointerDown:u,role:`separator`,"aria-orientation":`vertical`,"aria-label":m()})]}),(0,V.jsx)(`main`,{className:`oc-main`,children:(0,V.jsx)(u_,{})})]})]})}function ICe(){let e=R(L.me.getMe,{host:aB}),t=Fg(),n=b_({select:e=>e.pathname}),r=(0,B.useMemo)(()=>e?k9(e.permissions??[]):[],[e]),i=e!==void 0&&r.length===0;if((0,B.useEffect)(()=>{i&&t({to:`/`})},[i,t]),e===void 0)return(0,V.jsx)(`div`,{className:`oc-admin__hint`,style:{padding:16},children:nc()});if(i)return null;let a=j9(n),o=a!==void 0&&!r.includes(a);return(0,V.jsxs)(`div`,{className:`oc-admin`,children:[(0,V.jsx)(YSe,{}),(0,V.jsx)(`div`,{className:`oc-admin__body`,children:o?(0,V.jsx)(LCe,{}):(0,V.jsx)(u_,{})})]})}function LCe(){return(0,V.jsxs)(`div`,{className:`oc-route-error`,role:`alert`,children:[(0,V.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,V.jsx)(XS,{size:28})}),(0,V.jsx)(`h2`,{className:`oc-route-error__title`,children:Tr()}),(0,V.jsx)(`p`,{className:`oc-route-error__body`,children:Ra()})]})}function RCe(){let e=R(L.me.getMe,{host:aB}),t=Fg();return(0,B.useEffect)(()=>{if(e===void 0)return;let n=k9(e.permissions??[]);t({to:n.includes(`files`)?A9(`files`):n.length>0?A9(n[0]):`/`,replace:!0})},[e,t]),(0,V.jsx)(`div`,{className:`oc-admin__hint`,style:{padding:16},children:nc()})}function zCe(e){switch(e){case`groups`:return(0,V.jsx)(vCe,{});case`integrations`:return(0,V.jsx)(yCe,{});case`instances`:return(0,V.jsx)(gCe,{});case`injections`:return(0,V.jsx)(_Ce,{});case`theme`:return(0,V.jsx)(OCe,{});case`feedbacks`:return(0,V.jsx)(bCe,{});case`subagentReports`:return(0,V.jsx)(xCe,{});case`files`:return(0,V.jsx)(SCe,{});case`scheduled`:return(0,V.jsx)(CCe,{});case`agentFiles`:return(0,V.jsx)(wCe,{});case`preferences`:return(0,V.jsx)(TCe,{});case`chatDefaults`:return(0,V.jsx)(ECe,{});case`access`:return(0,V.jsx)(DCe,{});default:return(0,V.jsx)(hCe,{})}}function BCe(){let{tab:e}=Ng({from:`/settings/$tab`});return(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(`div`,{className:`oc-settings__tab-loading`,"aria-busy":`true`}),children:zCe(e)})}function VCe(){let{chatId:e}=Ng({from:`/chat/$chatId`}),{m:t}=Pg({from:`/chat/$chatId`});return(0,B.useEffect)(()=>{_re(e)},[e]),(0,V.jsx)(V8,{chatId:e,focusMessageId:t??null})}function HCe(){let e=Fg(),t=vre(),n=R(L.messages.listChats,{}),r=t!==null&&n!==void 0&&n.some(e=>e._id===t);return(0,B.useEffect)(()=>{r&&t&&e({to:`/chat/$chatId`,params:{chatId:t},replace:!0})},[r,t,e]),t!==null&&(n===void 0||r)?(0,V.jsx)(`div`,{className:`oc-boot`,children:nc()}):(0,V.jsx)(V8,{chatId:null})}var Y9=e_({component:kCe}),UCe=Qg({getParentRoute:()=>Y9,path:`/`,component:HCe}),WCe=Qg({getParentRoute:()=>Y9,path:`chat/$chatId`,component:VCe,validateSearch:e=>({m:typeof e.m==`string`?e.m:void 0})}),X9=Qg({getParentRoute:()=>Y9,path:`settings`,component:ICe}),GCe=Qg({getParentRoute:()=>X9,path:`/`,component:RCe}),KCe=Qg({getParentRoute:()=>X9,path:`traces`,validateSearch:rCe,component:t_(()=>g4(()=>import(`./TracesTab-Cb65hpku.js`),__vite__mapDeps([39,1,3,13,12,36,24,19,14,5,17,37,16,15])),`TracesTab`)}),qCe=Qg({getParentRoute:()=>X9,path:`bridge`,validateSearch:uCe,component:t_(()=>g4(()=>import(`./BridgeTab-C_I81PZ8.js`),__vite__mapDeps([10,1,3,11,7,8,9,12,13,14,15,16,5,17,18])),`BridgeTab`)}),JCe=Qg({getParentRoute:()=>X9,path:`voice`,validateSearch:lCe,component:t_(()=>g4(()=>import(`./VoiceTab-tgovFfm-.js`),__vite__mapDeps([40,1,3,13,12,5,22])),`VoiceTab`)}),YCe=Qg({getParentRoute:()=>X9,path:`audit`,validateSearch:iCe,component:t_(()=>g4(()=>import(`./AuditTab-NnWwJHq_.js`),__vite__mapDeps([41,1,3,19,12,14,5,17,37,24,16,15])),`AuditTab`)}),XCe=Qg({getParentRoute:()=>X9,path:`anomalies`,validateSearch:aCe,component:t_(()=>g4(()=>import(`./AnomaliesTab-CYpcTOYy.js`),__vite__mapDeps([42,1,3,19,12,14,5,17,15,16,18])),`AnomaliesTab`)}),ZCe=Qg({getParentRoute:()=>X9,path:`kpi`,validateSearch:oCe,component:t_(()=>g4(()=>import(`./KpiTab-Dz5IcL9k.js`),__vite__mapDeps([43,1,3,16,5,38])),`KpiTab`)}),QCe=Qg({getParentRoute:()=>X9,path:`serviceAccounts`,validateSearch:sCe,component:t_(()=>g4(()=>import(`./ServiceAccountsTab-BeEdMciQ.js`),__vite__mapDeps([44,1,3,12,36,19,14,5,17,15,16,4])),`ServiceAccountsTab`)}),$Ce=Qg({getParentRoute:()=>X9,path:`users`,validateSearch:cCe,component:t_(()=>g4(()=>import(`./UsersTab-BPRPmEOS.js`),__vite__mapDeps([45,1,3,19,12,14,5,17,25,15,16])),`UsersTab`)}),ewe=Qg({getParentRoute:()=>X9,path:`uiprefs`,beforeLoad:()=>{throw nh({to:`/settings/$tab`,params:{tab:HSe.uiprefs},replace:!0})}}),twe=Qg({getParentRoute:()=>X9,path:`$tab`,parseParams:e=>({tab:nS([...E9]).catch(`roles`).parse(e.tab)}),component:BCe});function nwe({error:e,reset:t}){let n=Fg(),r=yre(e),[i]=(0,B.useState)(()=>r&&Sre(Date.now()));return(0,B.useEffect)(()=>{i&&window.location.reload()},[i]),i?(0,V.jsx)(`div`,{className:`oc-route-error`,role:`status`,children:(0,V.jsx)(`p`,{className:`oc-route-error__body`,children:fa()})}):(0,V.jsxs)(`div`,{className:`oc-route-error`,role:`alert`,children:[(0,V.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,V.jsx)(XS,{size:28})}),(0,V.jsx)(`h2`,{className:`oc-route-error__title`,children:Ta()}),(0,V.jsx)(`p`,{className:`oc-route-error__body`,children:Zt()}),(0,V.jsxs)(`div`,{className:`oc-route-error__actions`,children:[(0,V.jsx)(`button`,{type:`button`,className:`oc-route-error__cta`,onClick:()=>{r?window.location.reload():t()},children:Eu()}),(0,V.jsx)(`button`,{type:`button`,className:`oc-route-error__cta oc-route-error__cta--ghost`,onClick:()=>void n({to:`/`}),children:dn()})]})]})}function rwe(){let e=Fg();return(0,V.jsxs)(`div`,{className:`oc-route-error`,role:`status`,children:[(0,V.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,V.jsx)(Une,{size:28})}),(0,V.jsx)(`h2`,{className:`oc-route-error__title`,children:ct()}),(0,V.jsx)(`p`,{className:`oc-route-error__body`,children:Qi()}),(0,V.jsx)(`div`,{className:`oc-route-error__actions`,children:(0,V.jsx)(`button`,{type:`button`,className:`oc-route-error__cta`,onClick:()=>void e({to:`/`}),children:dn()})})]})}var Z9=g_({routeTree:Y9.addChildren([UCe,WCe,X9.addChildren([GCe,KCe,JCe,qCe,YCe,XCe,ZCe,QCe,$Ce,ewe,twe])]),defaultPreload:`intent`,defaultErrorComponent:nwe,defaultNotFoundComponent:rwe}),iwe=()=>null;function Q9({children:e}){return(0,V.jsx)(`div`,{style:{display:`flex`,minHeight:`100vh`,alignItems:`center`,justifyContent:`center`,padding:`2rem`,textAlign:`center`,font:`14px system-ui, sans-serif`,opacity:.6},children:e})}var $9=Wp.createRoot(document.getElementById(`root`));$9.render((0,V.jsx)(B.StrictMode,{children:(0,V.jsx)(Q9,{children:st()})})),_U().then(e=>{let t=new da(e);$9.render((0,V.jsx)(B.StrictMode,{children:(0,V.jsx)(oee,{client:t,children:(0,V.jsxs)(JV,{children:[(0,V.jsx)(Pye,{children:(0,V.jsx)(y_,{router:Z9})}),(0,V.jsx)(B.Suspense,{fallback:null,children:(0,V.jsx)(iwe,{router:Z9,position:`bottom-right`})})]})})}))}).catch(e=>{console.error(`Boot failed:`,e),$9.render((0,V.jsx)(B.StrictMode,{children:(0,V.jsxs)(Q9,{children:[tt(),` `,e instanceof Error?e.message:String(e)]})}))});export{PV as $,vS as $t,g4 as A,GN as At,EH as B,HS as Bt,e6 as C,yB as Ct,Jge as D,SF as Dt,w4 as E,wF as Et,AH as F,YS as Ft,LV as G,NS as Gt,uH as H,BS as Ht,NH as I,JS as It,BV as J,ES as Jt,GV as K,MS as Kt,BH as L,GS as Lt,EU as M,$S as Mt,IH as N,ZS as Nt,U3 as O,CF as Ot,zH as P,XS as Pt,UV as Q,bS as Qt,PH as R,WS as Rt,$3 as S,CB as St,Z3 as T,TF as Tt,XV as U,zS as Ut,TH as V,VS as Vt,ZV as W,LS as Wt,HV as X,CS as Xt,WV as Y,wS as Yt,VV as Z,SS as Zt,x6 as _,JB as _t,tCe as a,xV as at,Eve as b,TB as bt,VSe as c,TV as ct,Q7 as d,eV as dt,gS as en,IV as et,C8 as f,QB as ft,y6 as g,YB as gt,S6 as h,ZB as ht,$Se as i,jV as it,IU as j,BN as jt,K3 as k,KN as kt,D9 as l,EV as lt,E6 as m,qB as mt,I9 as n,Fg as nn,AV as nt,eCe as o,CV as ot,y8 as p,WB as pt,KV as q,AS as qt,QSe as r,Pg as rn,kV as rt,nCe as s,wV as st,G9 as t,hS as tn,FV as tt,O9 as u,SV as ut,v6 as v,XB as vt,Q3 as w,aB as wt,X3 as x,_B as xt,b6 as y,EB as yt,MH as z,US as zt};
238
+ `},qbe={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function Jbe(e){let{announcements:t=qbe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Kbe}=e,{announce:a,announcement:o}=Ube(),s=h5(`DndLiveRegion`),[c,l]=(0,B.useState)(!1);if((0,B.useEffect)(()=>{l(!0)},[]),Wbe((0,B.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=B.createElement(B.Fragment,null,B.createElement(Vbe,{id:r,value:i.draggable}),B.createElement(Hbe,{id:s,announcement:o}));return n?(0,Lg.createPortal)(u,n):u}var w5;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(w5||={});function T5(){}function E5(e,t){return(0,B.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function D5(){var e=[...arguments];return(0,B.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var O5=Object.freeze({x:0,y:0});function k5(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Ybe(e,t){let n=b5(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function A5(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Xbe(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function j5(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function M5(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function N5(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var Zbe=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=N5(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=k5(N5(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(A5)},P5=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=j5(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=j5(r),o=i.reduce((e,t,r)=>e+k5(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(A5)};function Qbe(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var $be=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=Qbe(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Xbe)};function exe(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function F5(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:O5}function txe(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var nxe=txe(1);function I5(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function rxe(e,t,n){let r=I5(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var ixe={ignoreTransform:!1};function L5(e,t){t===void 0&&(t=ixe);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=r5(e).getComputedStyle(e);t&&(n=rxe(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function R5(e){return L5(e,{ignoreTransform:!0})}function axe(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function oxe(e,t){return t===void 0&&(t=r5(e).getComputedStyle(e)),t.position===`fixed`}function sxe(e,t){t===void 0&&(t=r5(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function z5(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(i5(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!a5(i)||o5(i)||n.includes(i))return n;let a=r5(e).getComputedStyle(i);return i!==e&&sxe(i,a)&&n.push(i),oxe(i,a)?n:r(i.parentNode)}return e?r(e):n}function B5(e){let[t]=z5(e,1);return t??null}function V5(e){return!e5||!e?null:t5(e)?e:n5(e)?i5(e)||e===s5(e).scrollingElement?window:a5(e)?e:null:null}function H5(e){return t5(e)?e.scrollX:e.scrollLeft}function U5(e){return t5(e)?e.scrollY:e.scrollTop}function W5(e){return{x:H5(e),y:U5(e)}}var G5;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(G5||={});function K5(e){return!e5||!e?!1:e===document.scrollingElement}function q5(e){let t={x:0,y:0},n=K5(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var cxe={x:.2,y:.2};function lxe(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=cxe);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=q5(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=G5.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=G5.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=G5.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=G5.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function uxe(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function J5(e){return e.reduce((e,t)=>_5(e,W5(t)),O5)}function dxe(e){return e.reduce((e,t)=>e+H5(t),0)}function fxe(e){return e.reduce((e,t)=>e+U5(t),0)}function Y5(e,t){if(t===void 0&&(t=L5),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);B5(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var pxe=[[`x`,[`left`,`right`],dxe],[`y`,[`top`,`bottom`],fxe]],X5=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=z5(t),r=J5(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of pxe)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},Z5=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function mxe(e){let{EventTarget:t}=r5(e);return e instanceof t?e:s5(e)}function Q5(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var $5;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})($5||={});function e7(e){e.preventDefault()}function hxe(e){e.stopPropagation()}var t7;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(t7||={});var n7={start:[t7.Space,t7.Enter],cancel:[t7.Esc],end:[t7.Space,t7.Enter,t7.Tab]},gxe=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case t7.Right:return{...n,x:n.x+25};case t7.Left:return{...n,x:n.x-25};case t7.Down:return{...n,y:n.y+25};case t7.Up:return{...n,y:n.y-25}}},r7=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Z5(s5(t)),this.windowListeners=new Z5(r5(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add($5.Resize,this.handleCancel),this.windowListeners.add($5.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add($5.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Y5(n),t(O5)}handleKeyDown(e){if(y5(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=n7,coordinateGetter:a=gxe,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:O5;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=v5(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=q5(n),p=uxe(n),m={x:Math.min(i===t7.Right?p.right-p.width/2:p.right,Math.max(i===t7.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===t7.Down?p.bottom-p.height/2:p.bottom,Math.max(i===t7.Down?p.top:p.top+p.height/2,u.y))},h=i===t7.Right&&!s||i===t7.Left&&!c,g=i===t7.Down&&!l||i===t7.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===t7.Right&&e<=d.x||i===t7.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===t7.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===t7.Down&&e<=d.y||i===t7.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===t7.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,_5(v5(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};r7.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=n7,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function i7(e){return!!(e&&`distance`in e)}function a7(e){return!!(e&&`delay`in e)}var o7=class{constructor(e,t,n){n===void 0&&(n=mxe(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=s5(i),this.documentListeners=new Z5(this.document),this.listeners=new Z5(n),this.windowListeners=new Z5(r5(i)),this.initialCoordinates=b5(r)??O5,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add($5.Resize,this.handleCancel),this.windowListeners.add($5.DragStart,e7),this.windowListeners.add($5.VisibilityChange,this.handleCancel),this.windowListeners.add($5.ContextMenu,e7),this.documentListeners.add($5.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(a7(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(i7(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add($5.Click,hxe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add($5.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=b5(e)??O5,s=v5(n,o);if(!t&&a){if(i7(a)){if(a.tolerance!=null&&Q5(s,a.tolerance))return this.handleCancel();if(Q5(s,a.distance))return this.handleStart()}if(a7(a)&&Q5(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===t7.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},_xe={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},s7=class extends o7{constructor(e){let{event:t}=e,n=s5(t.target);super(e,_xe,n)}};s7.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var vxe={move:{name:`mousemove`},end:{name:`mouseup`}},c7;(function(e){e[e.RightClick=2]=`RightClick`})(c7||={});var l7=class extends o7{constructor(e){super(e,vxe,s5(e.event.target))}};l7.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===c7.RightClick?!1:(r?.({event:n}),!0)}}];var u7={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},d7=class extends o7{constructor(e){super(e,u7)}static setup(){return window.addEventListener(u7.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(u7.move.name,e)};function e(){}}};d7.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var f7;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(f7||={});var p7;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(p7||={});function yxe(e){let{acceleration:t,activator:n=f7.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=p7.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=xxe({delta:d,disabled:!a}),[m,h]=Ibe(),g=(0,B.useRef)({x:0,y:0}),_=(0,B.useRef)({x:0,y:0}),v=(0,B.useMemo)(()=>{switch(n){case f7.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case f7.DraggableRect:return i}},[n,i,c]),y=(0,B.useRef)(null),b=(0,B.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,B.useMemo)(()=>s===p7.TreeOrder?[...l].reverse():l,[s,l]);(0,B.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=lxe(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var bxe={x:{[G5.Backward]:!1,[G5.Forward]:!1},y:{[G5.Backward]:!1,[G5.Forward]:!1}};function xxe(e){let{delta:t,disabled:n}=e,r=p5(t);return d5(e=>{if(n||!r||!e)return bxe;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[G5.Backward]:e.x[G5.Backward]||i.x===-1,[G5.Forward]:e.x[G5.Forward]||i.x===1},y:{[G5.Backward]:e.y[G5.Backward]||i.y===-1,[G5.Forward]:e.y[G5.Forward]||i.y===1}}},[n,t,r])}function Sxe(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return d5(e=>t==null?null:r??e??null,[r,t])}function Cxe(e,t){return(0,B.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var m7;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(m7||={});var h7;(function(e){e.Optimized=`optimized`})(h7||={});var g7=new Map;function wxe(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,B.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,B.useRef)(e),d=g(),f=u5(d),p=(0,B.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,B.useRef)(null),h=d5(t=>{if(d&&!n)return g7;if(!t||t===g7||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new X5(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,B.useEffect)(()=>{u.current=e},[e]),(0,B.useEffect)(()=>{d||p()},[n,d]),(0,B.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,B.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case m7.Always:return!1;case m7.BeforeDragging:return n;default:return!n}}}function _7(e,t){return d5(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function Txe(e,t){return _7(e,t)}function Exe(e){let{callback:t,disabled:n}=e,r=l5(t),i=(0,B.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,B.useEffect)(()=>()=>i?.disconnect(),[i]),i}function v7(e){let{callback:t,disabled:n}=e,r=l5(t),i=(0,B.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,B.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Dxe(e){return new X5(L5(e),e)}function y7(e,t,n){t===void 0&&(t=Dxe);let[r,i]=(0,B.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=Exe({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=v7({callback:a});return c5(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function Oxe(e){return F5(e,_7(e))}var b7=[];function kxe(e){let t=(0,B.useRef)(e),n=d5(n=>e?n&&n!==b7&&e&&t.current&&e.parentNode===t.current.parentNode?n:z5(e):b7,[e]);return(0,B.useEffect)(()=>{t.current=e},[e]),n}function Axe(e){let[t,n]=(0,B.useState)(null),r=(0,B.useRef)(e),i=(0,B.useCallback)(e=>{let t=V5(e.target);t&&n(e=>e?(e.set(t,W5(t)),new Map(e)):null)},[]);return(0,B.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=V5(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,W5(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{V5(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,B.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>_5(e,t),O5):J5(e):O5,[e,t])}function x7(e,t){t===void 0&&(t=[]);let n=(0,B.useRef)(null);return(0,B.useEffect)(()=>{n.current=null},t),(0,B.useEffect)(()=>{let t=e!==O5;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?v5(e,n.current):O5}function jxe(e){(0,B.useEffect)(()=>{if(!e5)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function Mxe(e,t){return(0,B.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function S7(e){return(0,B.useMemo)(()=>e?axe(e):null,[e])}var C7=[];function Nxe(e,t){t===void 0&&(t=L5);let[n]=e,r=S7(n?r5(n):null),[i,a]=(0,B.useState)(C7);function o(){a(()=>e.length?e.map(e=>K5(e)?r:new X5(t(e),e)):C7)}let s=v7({callback:o});return c5(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function w7(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return a5(t)?t:e}function Pxe(e){let{measure:t}=e,[n,r]=(0,B.useState)(null),i=v7({callback:(0,B.useCallback)(e=>{for(let{target:n}of e)if(a5(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=f5((0,B.useCallback)(e=>{let n=w7(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,B.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var Fxe=[{sensor:s7,options:{}},{sensor:r7,options:{}}],Ixe={current:{}},T7={draggable:{measure:R5},droppable:{measure:R5,strategy:m7.WhileDragging,frequency:h7.Optimized},dragOverlay:{measure:L5}},E7=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},Lxe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new E7,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:T5},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:T7,measureDroppableContainers:T5,windowRect:null,measuringScheduled:!1},D7={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:T5,draggableNodes:new Map,over:null,measureDroppableContainers:T5},O7=(0,B.createContext)(D7),k7=(0,B.createContext)(Lxe);function Rxe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new E7}}}function zxe(e,t){switch(t.type){case w5.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case w5.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case w5.DragEnd:case w5.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case w5.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new E7(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case w5.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new E7(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case w5.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new E7(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Bxe(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,B.useContext)(O7),a=p5(r),o=p5(n?.id);return(0,B.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!y5(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=zbe(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function A7(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Vxe(e){return(0,B.useMemo)(()=>({draggable:{...T7.draggable,...e?.draggable},droppable:{...T7.droppable,...e?.droppable},dragOverlay:{...T7.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Hxe(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,B.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;c5(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=F5(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=B5(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var j7=(0,B.createContext)({...O5,scaleX:1,scaleY:1}),M7;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(M7||={});var N7=(0,B.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=Fxe,collisionDetection:o=$be,measuring:s,modifiers:c,...l}=e,[u,d]=(0,B.useReducer)(zxe,void 0,Rxe),[f,p]=Gbe(),[m,h]=(0,B.useState)(M7.Uninitialized),g=m===M7.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,B.useRef)({initial:null,translated:null}),C=(0,B.useMemo)(()=>_==null?null:{id:_,data:x?.data??Ixe,rect:S},[_,x]),w=(0,B.useRef)(null),[T,E]=(0,B.useState)(null),[D,O]=(0,B.useState)(null),k=u5(l,Object.values(l)),A=h5(`DndDescribedBy`,t),j=(0,B.useMemo)(()=>b.getEnabled(),[b]),M=Vxe(s),{droppableRects:N,measureDroppableContainers:ee,measuringScheduled:P}=wxe(j,{dragging:g,dependencies:[y.x,y.y],config:M.droppable}),F=Sxe(v,_),te=(0,B.useMemo)(()=>D?b5(D):null,[D]),ne=Me(),re=Txe(F,M.draggable.measure);Hxe({activeNode:_==null?null:v.get(_),config:ne.layoutShiftCompensation,initialRect:re,measure:M.draggable.measure});let ie=y7(F,M.draggable.measure,re),ae=y7(F?F.parentElement:null),oe=(0,B.useRef)({activatorEvent:null,active:null,activeNode:F,collisionRect:null,collisions:null,droppableRects:N,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),se=b.getNodeFor(oe.current.over?.id),ce=Pxe({measure:M.dragOverlay.measure}),le=ce.nodeRef.current??F,ue=g?ce.rect??ie:null,de=!!(ce.nodeRef.current&&ce.rect),fe=Oxe(de?null:ie),pe=S7(le?r5(le):null),me=kxe(g?se??F:null),he=Nxe(me),ge=A7(c,{transform:{x:y.x-fe.x,y:y.y-fe.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:ie,containerNodeRect:ae,draggingNodeRect:ue,over:oe.current.over,overlayNodeRect:ce.rect,scrollableAncestors:me,scrollableAncestorRects:he,windowRect:pe}),_e=te?_5(te,y):null,ve=Axe(me),ye=x7(ve),be=x7(ve,[ie]),xe=_5(ge,ye),I=ue?nxe(ue,ge):null,Se=C&&I?o({active:C,collisionRect:I,droppableRects:N,droppableContainers:j,pointerCoordinates:_e}):null,Ce=M5(Se,`id`),[we,Te]=(0,B.useState)(null),Ee=exe(de?ge:_5(ge,be),we?.rect??null,ie),De=(0,B.useRef)(null),Oe=(0,B.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent;De.current=new n({active:w.current,activeNode:i,event:a,options:r,context:oe,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,Lg.unstable_batchedUpdates)(()=>{r?.(i),h(M7.Initializing),d({type:w5.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(De.current),O(a)})},onMove(e){d({type:w5.DragMove,coordinates:e})},onEnd:o(w5.DragEnd),onCancel:o(w5.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=oe.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===w5.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=w5.DragCancel)}w.current=null,(0,Lg.unstable_batchedUpdates)(()=>{d({type:e}),h(M7.Uninitialized),Te(null),E(null),O(null),De.current=null;let t=e===w5.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),ke=Cxe(a,(0,B.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,Oe(n,t))},[v,Oe]));jxe(a),c5(()=>{ie&&m===M7.Initializing&&h(M7.Initialized)},[ie,m]),(0,B.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=oe.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:xe.x,y:xe.y},over:i};(0,Lg.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[xe.x,xe.y]),(0,B.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=oe.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(Ce),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,Lg.unstable_batchedUpdates)(()=>{Te(s),a?.(c),f({type:`onDragOver`,event:c})})},[Ce]),c5(()=>{oe.current={activatorEvent:D,active:C,activeNode:F,collisionRect:I,collisions:Se,droppableRects:N,draggableNodes:v,draggingNode:le,draggingNodeRect:ue,droppableContainers:b,over:we,scrollableAncestors:me,scrollAdjustedTranslate:xe},S.current={initial:ue,translated:I}},[C,F,Se,I,v,le,ue,N,b,we,me,xe]),yxe({...ne,delta:y,draggingRect:I,pointerCoordinates:_e,scrollableAncestors:me,scrollableAncestorRects:he});let Ae=(0,B.useMemo)(()=>({active:C,activeNode:F,activeNodeRect:ie,activatorEvent:D,collisions:Se,containerNodeRect:ae,dragOverlay:ce,draggableNodes:v,droppableContainers:b,droppableRects:N,over:we,measureDroppableContainers:ee,scrollableAncestors:me,scrollableAncestorRects:he,measuringConfiguration:M,measuringScheduled:P,windowRect:pe}),[C,F,ie,D,Se,ae,ce,v,b,N,we,ee,me,he,M,P,pe]),je=(0,B.useMemo)(()=>({activatorEvent:D,activators:ke,active:C,activeNodeRect:ie,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:we,measureDroppableContainers:ee}),[D,ke,C,ie,d,A,v,we,ee]);return B.createElement(C5.Provider,{value:p},B.createElement(O7.Provider,{value:je},B.createElement(k7.Provider,{value:Ae},B.createElement(j7.Provider,{value:Ee},i)),B.createElement(Bxe,{disabled:n?.restoreFocus===!1})),B.createElement(Jbe,{...n,hiddenTextDescribedById:A}));function Me(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),Uxe=(0,B.createContext)(null),P7=`button`,Wxe=`Draggable`;function Gxe(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=h5(Wxe),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,B.useContext)(O7),{role:p=P7,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,B.useContext)(g?j7:Uxe),[v,y]=f5(),[b,x]=f5(),S=Mxe(o,t),C=u5(n);return c5(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,B.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===P7?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function F7(){return(0,B.useContext)(k7)}var Kxe=`Droppable`,qxe={timeout:25};function I7(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=h5(Kxe),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,B.useContext)(O7),u=(0,B.useRef)({disabled:n}),d=(0,B.useRef)(!1),f=(0,B.useRef)(null),p=(0,B.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...qxe,...i},_=u5(h??r),v=v7({callback:(0,B.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=f5((0,B.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=u5(t);return(0,B.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,B.useEffect)(()=>(s({type:w5.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:w5.UnregisterDroppable,key:a,id:r})),[r]),(0,B.useEffect)(()=>{n!==u.current.disabled&&(s({type:w5.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function Jxe(e){let{animation:t,children:n}=e,[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(null),s=p5(n);return!n&&!r&&s&&i(s),c5(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),B.createElement(B.Fragment,null,n,r?(0,B.cloneElement)(r,{ref:o}):null)}var Yxe={x:0,y:0,scaleX:1,scaleY:1};function Xxe(e){let{children:t}=e;return B.createElement(O7.Provider,{value:D7},B.createElement(j7.Provider,{value:Yxe},t))}var Zxe={position:`fixed`,touchAction:`none`},Qxe=e=>y5(e)?`transform 250ms ease`:void 0,$xe=(0,B.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=Qxe}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...Zxe,width:s.width,height:s.height,top:s.top,left:s.left,transform:x5.Transform.toString(d),transformOrigin:i&&r?Ybe(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return B.createElement(n,{className:o,style:f,ref:t},a)}),eSe={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:x5.Transform.toString(t)},{transform:x5.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function tSe(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return l5((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=w7(a);if(!c)return;let{transform:l}=r5(a).getComputedStyle(a),u=I5(l);if(!u)return;let d=typeof t==`function`?t:nSe(t);return Y5(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function nSe(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...eSe,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var L7=0;function rSe(e){return(0,B.useMemo)(()=>{if(e!=null)return L7++,L7},[e])}var iSe=B.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=F7(),S=(0,B.useContext)(j7),C=rSe(d?.id),w=A7(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=_7(f),E=tSe({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return B.createElement(Xxe,null,B.createElement(Jxe,{animation:E},d&&C?B.createElement($xe,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))}),aSe=e=>{let{transform:t}=e;return{...t,y:0}};function oSe(e,t,n){let r={...e};return t.top+e.y<=n.top?r.y=n.top-t.top:t.bottom+e.y>=n.top+n.height&&(r.y=n.top+n.height-t.bottom),t.left+e.x<=n.left?r.x=n.left-t.left:t.right+e.x>=n.left+n.width&&(r.x=n.left+n.width-t.right),r}var sSe=e=>{let{draggingNodeRect:t,transform:n,scrollableAncestorRects:r}=e,i=r[0];return!t||!i?n:oSe(n,t,i)},cSe=e=>{let{transform:t}=e;return{...t,x:0}};function R7(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function lSe(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function z7(e){return e!==null&&e>=0}function uSe(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function dSe(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var B7={scaleX:1,scaleY:1},fSe=e=>{let{rects:t,activeNodeRect:n,activeIndex:r,overIndex:i,index:a}=e,o=t[r]??n;if(!o)return null;let s=pSe(t,a,r);if(a===r){let e=t[i];return e?{x:r<i?e.left+e.width-(o.left+o.width):e.left-o.left,y:0,...B7}:null}return a>r&&a<=i?{x:-o.width-s,y:0,...B7}:a<r&&a>=i?{x:o.width+s,y:0,...B7}:{x:0,y:0,...B7}};function pSe(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return!r||!i&&!a?0:n<t?i?r.left-(i.left+i.width):a.left-(r.left+r.width):a?a.left-(r.left+r.width):r.left-(i.left+i.width)}var V7=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=R7(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},H7={scaleX:1,scaleY:1},U7=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...H7}:null}let s=mSe(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...H7}:r<t&&r>=a?{x:0,y:o.height+s,...H7}:{x:0,y:0,...H7}};function mSe(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var W7=`Sortable`,G7=B.createContext({activeIndex:-1,containerId:W7,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:V7,disabled:{draggable:!1,droppable:!1}});function K7(e){let{children:t,id:n,items:r,strategy:i=V7,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=F7(),d=h5(W7,n),f=s.rect!==null,p=(0,B.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,B.useRef)(p),v=!uSe(p,_.current),y=g!==-1&&h===-1||v,b=dSe(a);c5(()=>{v&&m&&u(p)},[v,p,m,u]),(0,B.useEffect)(()=>{_.current=p},[p]);let x=(0,B.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:lSe(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return B.createElement(G7.Provider,{value:x},t)}var hSe=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return R7(n,r,i).indexOf(t)},gSe=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},_Se={duration:200,easing:`ease`},q7=`transform`,vSe=x5.Transition.toString({property:q7,duration:0,easing:`linear`}),ySe={roleDescription:`sortable`};function bSe(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,B.useState)(null),s=(0,B.useRef)(n);return c5(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=L5(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,B.useEffect)(()=>{a&&o(null)},[a]),a}function J7(e){let{animateLayoutChanges:t=gSe,attributes:n,disabled:r,data:i,getNewIndex:a=hSe,id:o,strategy:s,resizeObserverConfig:c,transition:l=_Se}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,B.useContext)(G7),y=xSe(r,p),b=u.indexOf(o),x=(0,B.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,B.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:C,node:w,isOver:T,setNodeRef:E}=I7({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:D,activatorEvent:O,activeNodeRect:k,attributes:A,setNodeRef:j,listeners:M,isDragging:N,over:ee,setActivatorNodeRef:P,transform:F}=Gxe({id:o,data:x,attributes:{...ySe,...n},disabled:y.draggable}),te=Fbe(E,j),ne=!!D,re=ne&&!m&&z7(f)&&z7(g),ie=!_&&N,ae=re?(ie&&re?F:null)??(s??v)({rects:h,activeNodeRect:k,activeIndex:f,overIndex:g,index:b}):null,oe=z7(f)&&z7(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,se=D?.id,ce=(0,B.useRef)({activeId:se,items:u,newIndex:oe,containerId:d}),le=u!==ce.current.items,ue=t({active:D,containerId:d,isDragging:N,isSorting:ne,id:o,index:b,items:u,newIndex:ce.current.newIndex,previousItems:ce.current.items,previousContainerId:ce.current.containerId,transition:l,wasDragging:ce.current.activeId!=null}),de=bSe({disabled:!ue,index:b,node:w,rect:C});return(0,B.useEffect)(()=>{ne&&ce.current.newIndex!==oe&&(ce.current.newIndex=oe),d!==ce.current.containerId&&(ce.current.containerId=d),u!==ce.current.items&&(ce.current.items=u)},[ne,oe,d,u]),(0,B.useEffect)(()=>{if(se===ce.current.activeId)return;if(se!=null&&ce.current.activeId==null){ce.current.activeId=se;return}let e=setTimeout(()=>{ce.current.activeId=se},50);return()=>clearTimeout(e)},[se]),{active:D,activeIndex:f,attributes:A,data:x,rect:C,index:b,newIndex:oe,items:u,isOver:T,isSorting:ne,isDragging:N,listeners:M,node:w,overIndex:g,over:ee,setNodeRef:te,setActivatorNodeRef:P,setDroppableNodeRef:E,setDraggableNodeRef:j,transform:de??ae,transition:fe()};function fe(){if(de||le&&ce.current.newIndex===b)return vSe;if(!(ie&&!y5(O)||!l)&&(ne||ue))return x5.Transition.toString({...l,property:q7})}}function xSe(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}function Y7(e){if(!e)return!1;let t=e.data.current;return!!(t&&`sortable`in t&&typeof t.sortable==`object`&&`containerId`in t.sortable&&`items`in t.sortable&&`index`in t.sortable)}var SSe=[t7.Down,t7.Right,t7.Up,t7.Left],X7=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(SSe.includes(e.code)){if(e.preventDefault(),!n||!r)return;let t=[];a.getEnabled().forEach(n=>{if(!n||n!=null&&n.disabled)return;let a=i.get(n.id);if(a)switch(e.code){case t7.Down:r.top<a.top&&t.push(n);break;case t7.Up:r.top>a.top&&t.push(n);break;case t7.Left:r.left>a.left&&t.push(n);break;case t7.Right:r.left<a.left&&t.push(n);break}});let c=P5({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=M5(c,`id`);if(l===o?.id&&c.length>1&&(l=c[1].id),l!=null){let e=a.get(n.id),t=a.get(l),o=t?i.get(t.id):null,c=t?.node.current;if(c&&o&&e&&t){let n=z5(c).some((e,t)=>s[t]!==e),i=Z7(e,t),a=CSe(e,t),l=n||!i?{x:0,y:0}:{x:a?r.width-o.width:0,y:a?r.height-o.height:0},u={x:o.left,y:o.top};return l.x&&l.y?u:v5(u,l)}}}};function Z7(e,t){return!Y7(e)||!Y7(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function CSe(e,t){return!Y7(e)||!Y7(t)||!Z7(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function Q7({open:e,onOpenChange:t,title:n,description:r,children:i,onSubmit:a,submitLabel:o,submitting:s=!1,canSubmit:c=!0}){let[l,u]=(0,B.useState)(!1),d=s||l;async function f(){if(!(!c||d))try{u(!0),await a()}finally{u(!1)}}return(0,V.jsx)(J6,{open:e,onOpenChange:t,children:(0,V.jsxs)(Y6,{side:`right`,className:`w-4/5 sm:max-w-none gap-0 p-0`,children:[(0,V.jsxs)(X6,{className:`border-b px-6 py-4`,children:[(0,V.jsx)(Q6,{children:n}),r?(0,V.jsx)($6,{children:r}):null]}),(0,V.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),f()},children:[(0,V.jsx)(`div`,{className:`oc-sheet__body flex-1 overflow-y-auto px-6 py-4`,children:i}),(0,V.jsxs)(Z6,{className:`border-t px-6 py-4`,children:[(0,V.jsxs)(Ep,{type:`submit`,disabled:!c||d,children:[d?(0,V.jsx)(MS,{className:`size-4 animate-spin`}):null,o??ap()]}),(0,V.jsx)(Ep,{type:`button`,variant:`ghost`,onClick:()=>t(!1),children:Ur()})]})]})]})})}var $7=6e4,e9=60*$7,t9=24*e9,n9=7*t9,r9=30*t9,i9=365*t9;function wSe(e,t){let n=t-e;if(n<$7)return`maintenant`;if(n<e9)return`${Math.floor(n/$7)}min`;if(n<t9)return`${Math.floor(n/e9)}h`;if(n<n9)return`${Math.floor(n/t9)}j`;if(n<r9)return`${Math.floor(n/n9)}sem`;if(n<i9)return`${Math.floor(n/r9)}mois`;let r=Math.floor(n/i9);return`${r}an${r>1?`s`:``}`}var a9=[{value:`red`,hue:`var(--oc-accent-red, oklch(0.63 0.21 25))`},{value:`orange`,hue:`var(--oc-accent-orange, oklch(0.7 0.17 50))`},{value:`amber`,hue:`var(--oc-accent-amber, oklch(0.8 0.15 85))`},{value:`green`,hue:`var(--oc-accent-green, oklch(0.7 0.16 150))`},{value:`teal`,hue:`var(--oc-accent-teal, oklch(0.7 0.12 190))`},{value:`blue`,hue:`var(--oc-accent-blue, oklch(0.62 0.19 250))`},{value:`violet`,hue:`var(--oc-accent-violet, oklch(0.6 0.2 300))`},{value:`pink`,hue:`var(--oc-accent-pink, oklch(0.7 0.2 350))`}],o9=e=>a9.find(t=>t.value===e)?.hue??null;function TSe(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)>>>0;return a9[t%a9.length].hue}var s9=e=>o9(e.color)??TSe(e._id),c9=`project:none`,ESe=e=>`project:${e}`,l9=`projhead:`,u9=e=>`${l9}${e}`,d9=`oc.noproject.collapsed`;function f9(){return(0,V.jsx)(`div`,{className:`oc-sidebar__skeleton`,"aria-hidden":`true`,children:Array.from({length:7}).map((e,t)=>(0,V.jsx)(`div`,{className:`oc-skel oc-skel--row`},t))})}function DSe({activeChatId:e,onSelect:t,onNewChat:n,newChatShortcut:r}){let i=R(L.messages.listChats,{}),a=R(L.projects.listProjects,{}),o=R(L.me.getMe,{host:aB})?.ui?.effective?.showChatAge??!0,s=R(L.chatReads.myChatReads,{}),c=(0,B.useMemo)(()=>{let e=new Map;for(let t of s??[])e.set(t.chatId,t.lastSeenAt);return e},[s]),l=R(L.chatReads.myBusyChats,{}),u=(0,B.useMemo)(()=>new Set(l??[]),[l]),d=R(L.chatBookmarks.myBookmarkedChats,{}),f=R(L.chatExport.referenceLabel,{}),m=(0,B.useMemo)(()=>new Set(d??[]),[d]),h=(0,B.useMemo)(()=>{let t=new Set;for(let n of i??[]){if(n._id===e)continue;let r=c.get(n._id);r!==void 0&&n.lastAssistantAt!==null&&n.lastAssistantAt>r&&t.add(n._id)}return t},[i,c,e]),[g,_]=(0,B.useState)(0);(0,B.useEffect)(()=>{if(!o)return;let e=window.setInterval(()=>_(e=>e+1),6e4);return()=>window.clearInterval(e)},[o]);let v=p(L.projects.createProject),y=p(L.projects.setProjectCollapsed),b=p(L.chats.reorderChat),x=p(L.projects.reorderProject),S=p(L.chats.moveChatToProject),C=ZV(),w=ul(),T=(0,B.useRef)(null),E=(0,B.useRef)(null),D=(0,B.useRef)(null),[O,k]=(0,B.useState)(`full`);(0,B.useLayoutEffect)(()=>{let e=T.current;if(!e)return;let t=()=>{let t=e.clientWidth,n=E.current?.offsetWidth??0,r=D.current?.offsetWidth??0,i=n===0||t>=n?`full`:t>=r?`label`:`icon`;k(e=>e===i?e:i)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[w,r]);let[A,j]=(0,B.useState)(null),M=(0,B.useRef)(!1);(0,B.useEffect)(()=>{!M.current&&i&&j(i)},[i]);let N=A??i??[],ee=i===void 0&&A===null,[P,F]=(0,B.useState)(null),[te,ne]=(0,B.useState)(()=>localStorage.getItem(d9)===`1`);function re(){ne(e=>(localStorage.setItem(d9,e?`0`:`1`),!e))}let ie=aH();(0,B.useEffect)(()=>{if(!ie?.expand)return;let e=N.find(e=>e._id===ie.chatId);if(!e)return;let t=e.projectId??null;if(t===null){te&&(localStorage.setItem(d9,`0`),ne(!1));return}(a??[]).find(e=>e._id===t)?.collapsed&&y({projectId:t,collapsed:!1})},[ie,N,a,te,y]);let ae=D5(E5(l7,{activationConstraint:{distance:4}}),E5(d7,{activationConstraint:{delay:250,tolerance:8}}),E5(r7,{coordinateGetter:X7})),oe=(0,B.useRef)(!1),se=()=>{oe.current=!0,setTimeout(()=>{oe.current=!1},0)},ce=(0,B.useCallback)(e=>String(e.active.id).startsWith(l9)?P5({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(l9))}):P5(e),[]),le=N.filter(e=>e.pinned),ue=N.filter(e=>!e.pinned),de=e=>ue.filter(t=>(t.projectId??null)===e);function fe(e){return N.find(t=>t._id===e)}async function pe(e){F(null),se();let{active:t,over:n}=e;if(!n)return;let r=String(t.id),i=String(n.id);if(r.startsWith(l9)){let e=r.slice(9),t=a??[],n=null;if(i.startsWith(l9))n=i.slice(9);else if(i.startsWith(`project:`)&&i!==c9)n=i.slice(8);else{let e=fe(i);n=e&&!e.pinned?e.projectId??null:null}if(n===null||n===e)return;let o=t.findIndex(t=>t._id===e),s=t.findIndex(e=>e._id===n);if(o<0||s<0)return;let c=[...t],[l]=c.splice(o,1);c.splice(s,0,l);let u=c[s-1]??null,d=c[s+1]??null;await x({projectId:e,prevKey:u?u.sortKey:null,nextKey:d?d.sortKey:null});return}let o=fe(r);if(!o)return;if(i.startsWith(l9)){let e=i.slice(9);if((o.projectId??null)===e)return;M.current=!0,j(t=>(t??N).map(t=>t._id===o._id?{...t,projectId:e}:t));try{await S({chatId:o._id,projectId:e})}finally{M.current=!1}return}if(i.startsWith(`project:`)){let e=i===c9?null:i.slice(8);if((o.projectId??null)===e)return;M.current=!0,j(t=>(t??N).map(t=>t._id===o._id?{...t,projectId:e}:t));try{await S({chatId:o._id,projectId:e})}finally{M.current=!1}return}let s=fe(i);if(!s||t.id===n.id)return;if((s.projectId??null)!==(o.projectId??null)||s.pinned!==o.pinned){if(o.pinned||s.pinned)return;M.current=!0,j(e=>(e??N).map(e=>e._id===o._id?{...e,projectId:s.projectId??null}:e));try{await S({chatId:o._id,projectId:s.projectId??null})}finally{M.current=!1}return}let c=s.pinned?le:de(s.projectId??null),l=c.map(e=>e._id),u=l.indexOf(o._id),d=l.indexOf(s._id);if(u<0||d<0)return;let f=[...c];f.splice(u,1),f.splice(d,0,o);let p=f[d-1]??null,m=f[d+1]??null;M.current=!0,j(e=>[...(e??N).filter(e=>!c.some(t=>t._id===e._id)),...f]);try{await b({chatId:o._id,prevKey:p?p.sortKey:null,nextKey:m?m.sortKey:null})}finally{M.current=!1}}let me=P?fe(P):null;return(0,V.jsxs)(`aside`,{className:`oc-sidebar`,children:[(0,V.jsxs)(`div`,{className:`oc-sidebar__top`,ref:T,children:[(0,V.jsxs)(Ep,{className:O===`icon`?`oc-newchat flex-1 justify-center`:`oc-newchat flex-1 justify-start`,onClick:n,title:`${w} (${r})`,"aria-label":w,children:[(0,V.jsx)(HS,{}),O===`icon`?null:(0,V.jsx)(`span`,{className:`oc-newchat__label`,children:w}),O===`full`?(0,V.jsx)(`kbd`,{className:`oc-newchat__kbd`,"aria-hidden":!0,children:r}):null]}),(0,V.jsx)(`div`,{className:`oc-newchat-ghost`,"aria-hidden":!0,children:(0,V.jsxs)(`div`,{className:`oc-newchat-ghost__row`,ref:E,children:[(0,V.jsxs)(Ep,{className:`oc-newchat justify-start`,tabIndex:-1,children:[(0,V.jsx)(HS,{}),(0,V.jsx)(`span`,{className:`oc-newchat__label`,children:w}),(0,V.jsx)(`kbd`,{className:`oc-newchat__kbd`,children:r})]}),(0,V.jsx)(Ep,{variant:`outline`,size:`icon`,tabIndex:-1,children:(0,V.jsx)(kS,{})})]})}),(0,V.jsx)(`div`,{className:`oc-newchat-ghost`,"aria-hidden":!0,children:(0,V.jsxs)(`div`,{className:`oc-newchat-ghost__row`,ref:D,children:[(0,V.jsxs)(Ep,{className:`oc-newchat justify-start`,tabIndex:-1,children:[(0,V.jsx)(HS,{}),(0,V.jsx)(`span`,{className:`oc-newchat__label`,children:w})]}),(0,V.jsx)(Ep,{variant:`outline`,size:`icon`,tabIndex:-1,children:(0,V.jsx)(kS,{})})]})}),(0,V.jsx)(Ep,{className:`oc-newproject`,variant:`outline`,size:`icon`,"aria-label":Jo(),title:Jo(),onClick:async()=>{let e=await C({title:Jo(),label:od(),placeholder:eu(),confirmLabel:_o()});e&&await v({name:e})},children:(0,V.jsx)(kS,{})})]}),(0,V.jsxs)(N7,{sensors:ae,collisionDetection:ce,modifiers:[cSe,sSe],onDragStart:e=>F(String(e.active.id)),onDragCancel:()=>{F(null),se()},onDragEnd:pe,children:[(0,V.jsx)(`div`,{className:`oc-sidebar__scroll`,children:ee?(0,V.jsx)(f9,{}):(0,V.jsxs)(V.Fragment,{children:[le.length>0?(0,V.jsx)(p9,{label:Oc(),chats:le,children:le.map(n=>(0,V.jsx)(m9,{chat:n,active:n._id===e,unread:h.has(n._id),busy:u.has(n._id),bookmarked:m.has(n._id),referenceLabel:f,ageTick:g,suppressClick:oe,onSelect:t},n._id))}):null,(0,V.jsx)(K7,{items:(a??[]).map(e=>u9(e._id)),strategy:U7,children:(a??[]).map(n=>{let r=de(n._id);return(0,V.jsx)(p9,{label:n.name,dropId:ESe(n._id),sortId:u9(n._id),suppressClick:oe,projectId:n._id,project:n,chats:r,collapsible:!0,collapsed:n.collapsed,busy:r.some(e=>u.has(e._id)),unread:r.some(e=>h.has(e._id)),onToggle:()=>void y({projectId:n._id,collapsed:!n.collapsed}),children:n.collapsed?null:r.length===0?(0,V.jsx)(`div`,{className:`oc-sidebar__empty`,children:Uu()}):r.map(n=>(0,V.jsx)(m9,{chat:n,active:n._id===e,unread:h.has(n._id),busy:u.has(n._id),bookmarked:m.has(n._id),referenceLabel:f,ageTick:g,suppressClick:oe,onSelect:t},n._id))},n._id)})}),(0,V.jsx)(p9,{label:Rl(),dropId:c9,chats:de(null),collapsible:!0,collapsed:te,busy:de(null).some(e=>u.has(e._id)),unread:de(null).some(e=>h.has(e._id)),onToggle:re,children:te?null:de(null).map(n=>(0,V.jsx)(m9,{chat:n,active:n._id===e,unread:h.has(n._id),busy:u.has(n._id),bookmarked:m.has(n._id),referenceLabel:f,ageTick:g,suppressClick:oe,onSelect:t},n._id))})]})}),(0,V.jsxs)(iSe,{children:[P?.startsWith(l9)?(()=>{let e=(a??[]).find(e=>u9(e._id)===P);return e?(0,V.jsxs)(`div`,{className:`oc-sidebar__group-head oc-chatitem--overlay`,style:{"--proj-hue":s9(e)},children:[(0,V.jsx)(up,{className:`size-3.5 shrink-0 oc-sidebar__group-chev`}),(0,V.jsx)(`span`,{className:`oc-sidebar__group-label`,children:e.name})]}):null})():null,me?(0,V.jsxs)(`div`,{className:`oc-chatitem oc-chatitem--overlay`,children:[o9(me.color)?(0,V.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:o9(me.color)}}):(0,V.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,V.jsx)(`span`,{className:`oc-chatitem__label`,children:me.title||bd()})]}):null]})]})]})}function p9({label:e,dropId:t,sortId:n,suppressClick:r,projectId:i,project:a,chats:o,collapsible:s,collapsed:c,busy:l,unread:u,onToggle:d,children:f}){let m=p(L.projects.deleteProject),h=p(L.projects.renameProject),g=p(L.projects.setProjectColor),_=XV(),[v,y]=(0,B.useState)(!1),[b,x]=(0,B.useState)(e),S=R(L.projects.projectChatCount,i?{projectId:i}:`skip`),{setNodeRef:C,isOver:w}=I7({id:t??`static:${e}`}),T=J7({id:n??`static-sort:${e}`,disabled:!n}),{onKeyDown:E,...D}=T.listeners??{},O=e=>{e.target===e.currentTarget&&s&&d&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d())},k=a?s9(a):null;return(0,V.jsxs)(`div`,{ref:e=>{t&&C(e),n&&T.setNodeRef(e)},className:`oc-sidebar__group`+(w?` oc-sidebar__group--over`:``)+(a?` oc-sidebar__group--project`:``),style:{...k?{"--proj-hue":k}:{},...n?{transform:x5.Transform.toString(T.transform),transition:T.transition,opacity:T.isDragging?.35:1}:{}},children:[(0,V.jsxs)(`div`,{className:`oc-sidebar__group-head group/head`+(s?` oc-sidebar__group-head--btn`:``),...s?{role:`button`,tabIndex:0,onClick:()=>{r?.current||d?.()},onKeyDown:O}:{},...n?D:{},children:[s?c?(0,V.jsx)(gS,{className:`size-3.5 shrink-0`+(a?` oc-sidebar__group-chev`:``)}):(0,V.jsx)(up,{className:`size-3.5 shrink-0`+(a?` oc-sidebar__group-chev`:``)}):null,(0,V.jsx)(`span`,{className:`oc-sidebar__group-label`,children:e}),n?(0,V.jsx)(`button`,{className:`oc-drag-a11y`,"aria-label":Bi(),onClick:e=>e.stopPropagation(),...T.attributes,onKeyDown:E,children:(0,V.jsx)(jS,{className:`size-3.5`})}):null,c&&l?(0,V.jsx)(`span`,{className:`oc-chatitem__busy`,title:xs(),"aria-label":xs()}):null,c&&u?(0,V.jsx)(`span`,{className:`oc-chatitem__unread`,title:en(),"aria-label":en()}):null,i?(0,V.jsxs)(xV,{children:[(0,V.jsx)(SV,{asChild:!0,children:(0,V.jsx)(Ep,{variant:`ghost`,size:`icon-xs`,"aria-label":Or(),className:`oc-sidebar__group-menu opacity-0 group-hover/head:opacity-100 group-focus-within/head:opacity-100 aria-expanded:opacity-100`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:(0,V.jsx)(wS,{})})}),(0,V.jsxs)(CV,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(wV,{onSelect:()=>{x(e),y(!0)},children:[(0,V.jsx)(BS,{}),` `,np()]}),(0,V.jsx)(TV,{children:Vt()}),(0,V.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,V.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void g({projectId:i,color:null}),"aria-label":Qe(),children:`✕`}),a9.map(e=>(0,V.jsx)(`button`,{className:`oc-colorgrid__dot`+(a?.color===e.value?` is-selected`:``),style:{background:e.hue},"aria-label":e.value,onClick:()=>void g({projectId:i,color:e.value})},e.value))]}),(0,V.jsx)(EV,{}),(0,V.jsxs)(wV,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let t=S??0;await _({title:dt({name:e}),description:t>0?ea({count:t}):wi(),confirmWord:Tt(),confirmLabel:mn(),destructive:!0})&&await m({projectId:i})})},children:[(0,V.jsx)(YS,{}),` `,Tt()]})]})]}):null]}),(0,V.jsx)(`div`,{className:a&&!c?`oc-sidebar__group-body`:void 0,children:(0,V.jsx)(K7,{items:o.map(e=>e._id),strategy:U7,children:f})}),i?(0,V.jsx)(Q7,{open:v,onOpenChange:y,title:Va(),canSubmit:b.trim().length>0,onSubmit:async()=>{await h({projectId:i,name:b.trim()}),y(!1)},children:(0,V.jsx)(`div`,{className:`oc-form`,children:(0,V.jsxs)(`label`,{className:`oc-field`,children:[(0,V.jsx)(`span`,{className:`oc-field__label`,children:Vc()}),(0,V.jsx)(QB,{value:b,onChange:e=>x(e.target.value),autoFocus:!0})]})})}):null]})}var m9=(0,B.memo)(function({chat:e,active:t,unread:n,busy:r,bookmarked:i,referenceLabel:a,suppressClick:o,onSelect:s}){let{attributes:c,listeners:l,setNodeRef:u,transform:d,transition:f,isDragging:m}=J7({id:e._id}),{onKeyDown:h,...g}=l??{},_=p(L.chats.renameChat),y=uH(),b=()=>{if(a===void 0)return;let t=Pbe(a,e._id);navigator.clipboard.writeText(t).then(()=>y.success(ba({reference:t})),()=>y.error(Kt()))},x=p(L.chats.deleteChat),S=p(L.chats.pinChat),C=p(L.chats.setChatColor),w=R(L.me.getMe,{host:aB})?.ui?.effective?.showChatAge??!0,T=XV(),[E,D]=(0,B.useState)(!1),[O,k]=(0,B.useState)(e.title??``),A=aH()?.chatId===e._id,j=(0,B.useRef)(null);(0,B.useEffect)(()=>{if(!A)return;let t=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;j.current?.scrollIntoView({block:`nearest`,behavior:t?`auto`:`smooth`});let n=setTimeout(()=>iH(e._id),2600);return()=>clearTimeout(n)},[A,e._id]);let M={transform:x5.Transform.toString(d),transition:f,opacity:+!m},N=o9(e.color);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{ref:e=>{u(e),j.current=e},style:M,className:`oc-chatitem group/row`+(t?` oc-chatitem--active`:``)+(A?` oc-chatitem--flash`:``),onClick:()=>{o.current||s(e._id)},...g,onAnimationEnd:t=>{A&&t.animationName===`oc-chatitem-flash`&&iH(e._id)},children:[(0,V.jsx)(`button`,{className:`oc-drag-a11y`,"aria-label":Bi(),onClick:e=>e.stopPropagation(),...c,onKeyDown:h,children:(0,V.jsx)(jS,{className:`size-3.5`})}),N?(0,V.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:N}}):(0,V.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,V.jsx)(`button`,{className:`oc-chatitem__label`,onClick:t=>{t.stopPropagation(),!o.current&&s(e._id)},children:e.title||bd()}),r?(0,V.jsx)(`span`,{className:`oc-chatitem__busy`,title:v(),"aria-label":v()}):null,n?(0,V.jsx)(`span`,{className:`oc-chatitem__unread`,title:en(),"aria-label":en()}):null,e.readOnly?(0,V.jsx)(`span`,{className:`oc-chatitem__readonly`,title:ku(),children:(0,V.jsx)(NS,{size:12,"aria-label":ku()})}):null,i?(0,V.jsx)(`span`,{className:`oc-chatitem__bookmark group-hover/row:opacity-0 group-focus-within/row:opacity-0`,title:br(),children:(0,V.jsx)(dS,{size:12,"aria-label":br()})}):null,w?(0,V.jsx)(`span`,{className:`oc-chatitem__age group-hover/row:opacity-0 group-focus-within/row:opacity-0`,title:kV(e.updatedAt),children:wSe(e.updatedAt,Date.now())}):null,(0,V.jsxs)(xV,{children:[(0,V.jsx)(SV,{asChild:!0,children:(0,V.jsx)(Ep,{variant:`ghost`,size:`icon-xs`,"aria-label":re(),className:`opacity-0 group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:(0,V.jsx)(wS,{})})}),(0,V.jsxs)(CV,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,V.jsxs)(wV,{onSelect:()=>{k(e.title??``),D(!0)},children:[(0,V.jsx)(BS,{}),` `,np()]}),(0,V.jsxs)(wV,{onSelect:()=>void S({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,V.jsx)(cre,{}):(0,V.jsx)(sre,{}),e.pinned?Br():Dn()]}),(0,V.jsxs)(wV,{onSelect:b,disabled:a===void 0,children:[(0,V.jsx)(Zne,{}),` `,sa()]}),(0,V.jsx)(TV,{children:Vt()}),(0,V.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,V.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void C({chatId:e._id,color:null}),"aria-label":Qe(),children:`✕`}),a9.map(t=>(0,V.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void C({chatId:e._id,color:t.value})},t.value))]}),(0,V.jsx)(EV,{}),(0,V.jsxs)(wV,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await T({title:gr(),description:Jn(),confirmLabel:Tt(),destructive:!0})&&await x({chatId:e._id})})},children:[(0,V.jsx)(YS,{}),` `,Tt()]})]})]})]}),(0,V.jsx)(Q7,{open:E,onOpenChange:D,title:Rn(),canSubmit:O.trim().length>0,onSubmit:async()=>{await _({chatId:e._id,title:O.trim()}),D(!1)},children:(0,V.jsx)(`div`,{className:`oc-form`,children:(0,V.jsxs)(`label`,{className:`oc-field`,children:[(0,V.jsx)(`span`,{className:`oc-field__label`,children:Vc()}),(0,V.jsx)(QB,{value:O,onChange:e=>k(e.target.value),autoFocus:!0})]})})})]})}),h9=null,g9=0,OSe=400;function kSe(){if(typeof window>`u`)return null;let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;if(!h9)try{h9=new e}catch{return null}return h9}function _9(e,t,n,r,i){let a=e.createOscillator(),o=e.createGain();a.type=`sine`,a.frequency.value=t;let s=e.currentTime+n;o.gain.setValueAtTime(1e-4,s),o.gain.linearRampToValueAtTime(i,s+.015),o.gain.exponentialRampToValueAtTime(1e-4,s+r),a.connect(o).connect(e.destination),a.start(s),a.stop(s+r+.02)}function v9(e){let t=Date.now();if(t-g9<OSe)return;let n=kSe();if(!n)return;g9=t;let r=()=>{try{e(n)}catch{}};n.state===`suspended`?n.resume().then(r,()=>{}):r()}function ASe(){v9(e=>{_9(e,660,0,.16,.12),_9(e,440,.14,.2,.1)})}function jSe(){v9(e=>{_9(e,880,0,.14,.08)})}function MSe({activeChatId:e}){let t=R(L.messages.listChats,{}),n=p(L.chatReads.markChatSeen),r=R(L.me.getMe,{host:aB}),i=r?.ui?.effective?.replySound===!0,a=r?.userId??null,o=(0,B.useRef)(null),s=(0,B.useRef)(null);return(0,B.useEffect)(()=>{if(!t)return;s.current!==String(a)&&(s.current=String(a),o.current=null);let r=new Map;for(let e of t)e.lastAssistantAt!==null&&r.set(e._id,e.lastAssistantAt);let c=o.current;if(o.current=r,c===null)return;let l=!1;for(let[t,i]of r){let r=c.get(t);r!==void 0&&i<=r||r===void 0&&Date.now()-i>3e4||(l=!0,t===e&&document.visibilityState===`visible`?n({chatId:t}):t!==e&&rH(t))}l&&i&&jSe()},[t,e,i,n,a]),(0,B.useEffect)(()=>{e&&document.visibilityState===`visible`&&n({chatId:e})},[e,n]),(0,B.useEffect)(()=>{let t=()=>{document.visibilityState===`visible`&&e&&n({chatId:e})};return document.addEventListener(`visibilitychange`,t),()=>document.removeEventListener(`visibilitychange`,t)},[e,n]),null}function NSe(e){let t=p(L.chats.createChat),n=R(L.agents.listMyAgents),[r,i]=(0,B.useState)(!1),a=(0,B.useCallback)(async(n,r)=>{e(await t({instanceName:n,agentId:r}))},[t,e]);return{startNewChat:(0,B.useCallback)(async()=>{let e=n;if(e&&e.length===1&&e[0].state!==`deleted`){await a(e[0].instanceName,e[0].agentId);return}i(!0)},[n,a]),picker:(0,V.jsx)(rV,{open:r,onOpenChange:i,agents:n,onPick:(e,t)=>{i(!1),a(e,t)}})}}var y9=[`admin`,`user`,`pending`];function b9(){let e=R(L.me.authProviders)?.anonymous===!0,[t,n]=(0,B.useState)(!1),r=R(L.dev.listUsersDev,e?{}:`skip`),i=R(L.me.getImpersonation),a=p(L.dev.setMyRole),o=p(L.dev.setRole),s=p(L.admin.startImpersonation),c=p(L.admin.stopImpersonation);if(!e)return null;let l=r?.find(e=>e.isMe),u=l?.role===`admin`,d=i?.impersonating===!0,f=(r??[]).filter(e=>!e.isMe);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`button`,{type:`button`,className:`oc-devfab`,onClick:()=>n(!0),title:ge(),children:[(0,V.jsx)(QS,{size:13}),`DEV`]}),(0,V.jsx)(WB,{open:t,onOpenChange:n,children:(0,V.jsxs)(qB,{children:[(0,V.jsxs)(JB,{children:[(0,V.jsx)(XB,{children:ei()}),(0,V.jsx)(ZB,{children:Cf()})]}),(0,V.jsxs)(`div`,{className:`oc-devsw__me`,children:[(0,V.jsxs)(`span`,{className:`oc-devsw__melabel`,children:[Mo({canonical:l?.canonical??`…`}),` `,(0,V.jsx)(eV,{variant:`outline`,children:l?.role??`…`})]}),(0,V.jsx)(`div`,{className:`oc-devsw__roles`,children:y9.map(e=>(0,V.jsx)(Ep,{type:`button`,size:`xs`,variant:l?.role===e?`secondary`:`ghost`,disabled:l?.role===e,onClick:()=>void a({role:e}),children:e===`admin`?zf():e===`user`?Yd():eo()},e))})]}),d?(0,V.jsxs)(`div`,{className:`oc-devsw__imp`,children:[Zs(),` `,(0,V.jsx)(`strong`,{children:i.targetLabel}),`.`,(0,V.jsx)(Ep,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>void c(),children:pc()})]}):null,(0,V.jsx)(`div`,{className:`oc-devsw__list`,children:f.length===0?(0,V.jsx)(`p`,{className:`oc-devsw__empty`,children:Cl()}):f.map(e=>(0,V.jsxs)(`div`,{className:`oc-devsw__row`,children:[(0,V.jsx)(`span`,{className:`oc-devsw__label`,children:e.name||e.email||e.canonical||e.userId.slice(0,8)}),(0,V.jsx)(`select`,{className:`oc-devsw__select`,value:e.role,disabled:!e.canonical,onChange:t=>e.canonical&&void o({canonical:e.canonical,role:t.target.value}),children:y9.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))}),(0,V.jsx)(Ep,{type:`button`,size:`xs`,variant:`ghost`,disabled:!u||e.role===`pending`,title:u?e.role===`pending`?Is():us():hu(),onClick:()=>{s({profileId:e.profileId}),n(!1)},children:Id()})]},e.profileId))})]})})]})}function x9({label:e,mode:t,minimal:n=!1}){let{signOut:r}=im(),i=p(L.me.setThemeMode).withOptimisticUpdate((e,{mode:t})=>{let n=e.getQuery(L.me.getMe,{host:aB});if(!n)return;let r=t===null?n.defaultThemeMode??`system`:t;e.setQuery(L.me.getMe,{host:aB},{...n,themeMode:t,resolvedThemeMode:r})}),a=t??`default`;return(0,V.jsxs)(xV,{children:[(0,V.jsx)(SV,{asChild:!0,children:(0,V.jsxs)(Ep,{variant:`ghost`,size:`sm`,className:`gap-1.5`,children:[e,(0,V.jsx)(up,{className:`opacity-60`})]})}),(0,V.jsx)(CV,{align:`end`,className:`w-52`,children:n?(0,V.jsxs)(wV,{onClick:()=>void r(),children:[(0,V.jsx)(PS,{}),` `,Zf()]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(TV,{children:Zi()}),(0,V.jsxs)(DV,{value:a,onValueChange:e=>void i({mode:e==="default"?null:e}),children:[(0,V.jsxs)(OV,{value:`light`,children:[(0,V.jsx)(pre,{}),` `,Si()]}),(0,V.jsxs)(OV,{value:`dark`,children:[(0,V.jsx)(rre,{}),` `,xt()]}),(0,V.jsxs)(OV,{value:`system`,children:[(0,V.jsx)(nre,{}),` `,Fi()]}),(0,V.jsx)(OV,{value:`default`,children:P()})]}),(0,V.jsx)(EV,{}),(0,V.jsxs)(wV,{onClick:()=>void r(),children:[(0,V.jsx)(PS,{}),` `,Zf()]})]})})]})}var PSe={altered_words:()=>Jd(),incorrect:()=>$a(),incoherence:()=>Xs(),formatting:()=>fc(),latency:()=>Sl(),api_error:()=>mu(),other:()=>Fs()},S9=e=>PSe[e]?.()??e,FSe={anomaly_open:XS,anomaly_resolved:vS,feedback_reply:IS,feedback_resolved:IS,feedback_new:IS,curation:DS},ISe={notif_feedback_reply_admin:()=>({title:$r(),body:Sf()}),notif_feedback_reply:()=>({title:$r(),body:Sf()}),notif_feedback_resolved:()=>({title:zt(),body:Xe()}),notif_feedback_new:e=>({title:Ao(),body:Rf({reference:e.reference??`?`,category:S9(e.category??`other`)})}),notif_curation_proposed:e=>({title:tn(),body:Au({name:e.name??`?`,agentId:e.agentId??`?`})}),notif_curation_failed:e=>({title:hn(),body:ft({name:e.name??`?`,reason:e.reason??`unknown`})}),notif_curation_relaunch_refused:e=>({title:ta(),body:Ti({name:e.name??`?`,reason:e.reason??`unknown`})}),notif_anomaly_open:(e,t)=>({title:Et({kind:e.kind??`?`}),body:t.body}),notif_anomaly_resolved:(e,t)=>({title:Vi({kind:e.kind??`?`}),body:t.body})};function C9(e){let t=e.messageKey?ISe[e.messageKey]:void 0;return t?t(e.params??{},e):e.kind===`feedback_reply`?{title:$r(),body:Sf()}:e.kind===`feedback_resolved`?{title:zt(),body:Xe()}:{title:e.title,body:e.body}}function LSe(){let e=R(L.notifications.myUnreadCount)??0,t=R(L.notifications.myNotifications),n=R(L.feedback.myFeedback),r=p(L.notifications.markRead),i=p(L.notifications.markAllRead),a=p(L.notifications.clearOne),o=p(L.notifications.clearAll),s=p(L.feedback.closeMyFeedback),c=Fg(),[l,u]=(0,B.useState)(!1),d=R(L.me.getMe,{host:aB}),f=d?.ui?.effective?.notifSound===!0,m=d?.ui?.effective?.notifSystem===!0,h=d?.userId??null,g=(0,B.useRef)(null),_=(0,B.useRef)(0),v=(0,B.useRef)(null);(0,B.useEffect)(()=>{if(!t)return;v.current!==String(h)&&(v.current=String(h),g.current=null,_.current=0);let e=t.reduce((e,t)=>Math.max(e,t.creationTime??0),0);if(g.current===null){g.current=new Set(t.map(e=>String(e._id))),_.current=e;return}let n=g.current,r=t.filter(e=>!n.has(String(e._id))&&(e.creationTime??0)>_.current);for(let e of t)n.add(String(e._id));if(_.current=Math.max(_.current,e),n.size>500){let e=new Set(t.map(e=>String(e._id)));for(let t of n)e.has(t)||n.delete(t)}if(r.length!==0&&(f&&ASe(),m&&typeof Notification<`u`&&Notification.permission===`granted`&&document.visibilityState!==`visible`)){let e=r[0],{title:t,body:n}=C9(e);try{let r=new Notification(t,{body:n,tag:String(e._id)});r.onclick=()=>window.focus()}catch{}}},[t,f,m,h]);let y=e=>{if(e.unread&&r({notificationId:e._id}),!e.href)return;if(u(!1),e.href.startsWith(`/chat/`)){c({to:`/chat/$chatId`,params:{chatId:e.href.slice(6)}});return}let[t,n]=e.href.split(`?`);c({to:t,search:Object.fromEntries(new URLSearchParams(n??``))})};return(0,V.jsxs)(xV,{open:l,onOpenChange:u,children:[(0,V.jsx)(SV,{asChild:!0,children:(0,V.jsxs)(`button`,{type:`button`,className:`oc-bell`,"aria-label":e>0?Li({count:e}):te(),children:[(0,V.jsx)(uS,{size:18,"aria-hidden":!0}),e>0?(0,V.jsx)(`span`,{className:`oc-bell__badge`,"aria-hidden":!0,children:e>9?`9+`:e}):null]})}),(0,V.jsxs)(CV,{align:`end`,className:`oc-notif`,children:[(0,V.jsxs)(`div`,{className:`oc-notif__head`,children:[(0,V.jsx)(`span`,{children:$f()}),t&&t.length>0?(0,V.jsxs)(`span`,{className:`oc-notif__bulk`,children:[(0,V.jsx)(`button`,{type:`button`,className:`oc-notif__act`,disabled:e===0,onClick:()=>void i({}),children:Rr()}),(0,V.jsx)(`button`,{type:`button`,className:`oc-notif__act`,onClick:()=>void o({}),children:Tn()})]}):null]}),t===void 0?(0,V.jsx)(`div`,{className:`oc-notif__empty`,children:st()}):t.length===0?(0,V.jsx)(`div`,{className:`oc-notif__empty`,children:Rt()}):(0,V.jsx)(`div`,{className:`oc-notif__list`,children:t.map(e=>{let t=FSe[e.kind]??uS,{title:n,body:i}=C9(e);return(0,V.jsxs)(`div`,{className:`oc-notif__item${e.unread?` is-unread`:``}${e.href?` is-link`:``}`,role:e.href?`button`:void 0,tabIndex:e.href?0:void 0,onClick:e.href?()=>y(e):void 0,children:[(0,V.jsxs)(`div`,{className:`oc-notif__item-head`,children:[(0,V.jsx)(t,{size:14,className:`oc-notif__kind oc-notif__kind--${e.kind}`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-notif__title`,children:n}),(0,V.jsxs)(`span`,{className:`oc-notif__row-actions`,children:[e.unread?(0,V.jsx)(`button`,{type:`button`,title:Ye(),"aria-label":Ye(),onClick:t=>{t.stopPropagation(),r({notificationId:e._id})},children:(0,V.jsx)(cp,{size:13})}):null,(0,V.jsx)(`button`,{type:`button`,title:mr(),"aria-label":mr(),onClick:t=>{t.stopPropagation(),a({notificationId:e._id})},children:(0,V.jsx)(mp,{size:13})})]})]}),(0,V.jsx)(`p`,{className:`oc-notif__body`,children:i}),(0,V.jsx)(`div`,{className:`oc-notif__when`,children:new Date(e.createdAt).toLocaleString(Tu())})]},e._id)})}),n&&n.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`oc-notif__head oc-notif__head--sub`,children:qn()}),(0,V.jsx)(`div`,{className:`oc-notif__list`,children:n.map(e=>(0,V.jsx)(RSe,{it:e,onClose:t=>s({feedbackId:e._id,reason:t}),onNavigate:()=>u(!1)},e._id))})]}):null]})]})}function RSe({it:e,onClose:t,onNavigate:n}){let r=uH(),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(``),[u,d]=(0,B.useState)(!1);async function f(){d(!0);try{await t(c.trim()||void 0)}catch(e){r.error(Le(),e)}finally{d(!1)}}return(0,V.jsxs)(`div`,{className:`oc-notif__item`,children:[(0,V.jsxs)(`div`,{className:`oc-notif__item-head`,children:[(0,V.jsx)(`span`,{className:`oc-notif__title`,children:S9(e.category)}),(0,V.jsx)(`span`,{className:`oc-notif__status${e.answered||e.resolvedAt?` is-answered`:``}`,children:e.resolvedAt?ep():e.answered?Ln():Bc()})]}),(0,V.jsx)(`div`,{className:`oc-notif__when`,children:new Date(e.at).toLocaleString(Tu())}),e.thread.length>0?(0,V.jsx)(`div`,{className:`oc-notif__thread`,children:e.thread.map((e,t)=>(0,V.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,V.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?E():e.authorRole===`agent`?Ri():Yc()}),(0,V.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):null,e.messageText?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`button`,{type:`button`,className:`oc-notif__report-toggle`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[i?(0,V.jsx)(up,{size:13,"aria-hidden":!0}):(0,V.jsx)(gS,{size:13,"aria-hidden":!0}),Ee()]}),i?(0,V.jsx)(`div`,{className:`oc-notif__report-msg`,children:e.messageText}):null]}):null,(0,V.jsxs)(`div`,{className:`oc-notif__report-actions`,children:[(0,V.jsx)(Yg,{to:`/chat/$chatId`,params:{chatId:e.chatId},search:{m:e.messageId},className:`oc-notif__link`,onClick:n,children:rr()}),o?null:(0,V.jsx)(`button`,{type:`button`,className:`oc-notif__link oc-notif__link--muted`,onClick:()=>s(!0),children:Le()})]}),o?(0,V.jsxs)(`div`,{className:`oc-notif__close-form`,children:[(0,V.jsx)(`textarea`,{className:`oc-notif__close-input`,rows:2,value:c,onChange:e=>l(e.target.value),placeholder:di()}),(0,V.jsxs)(`div`,{className:`oc-notif__close-actions`,children:[(0,V.jsx)(`button`,{type:`button`,className:`oc-notif__close-confirm`,disabled:u,onClick:()=>void f(),children:lf()}),(0,V.jsx)(`button`,{type:`button`,className:`oc-notif__close-cancel`,onClick:()=>{s(!1),l(``)},children:he()})]})]}):null]})}var w9=2,zSe=180;function BSe(){let e=Fg(),t=(0,B.useRef)(null),n=(0,B.useRef)(null),[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(``),[s,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(0),d=(0,B.useMemo)(()=>yB(uB,_B()),[]);(0,B.useEffect)(()=>{let e=setTimeout(()=>c(a),zSe);return()=>clearTimeout(e)},[a]);let f=s.trim(),p=R(L.search.searchConversations,f.length>=w9?{query:f}:`skip`),m=p??[],h=f.length>=w9&&p===void 0;(0,B.useEffect)(()=>{let e=e=>{bB(e,uB)&&(e.preventDefault(),i(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,B.useEffect)(()=>{r&&(o(``),c(``),u(0))},[r]),(0,B.useEffect)(()=>{u(0)},[p]),(0,B.useEffect)(()=>{(n.current?.querySelector(`[data-index="${l}"]`))?.scrollIntoView({block:`nearest`})},[l]);let g=(0,B.useCallback)((t,n)=>{i(!1),n&&a.trim()&&Uve(n,a.trim()),e({to:`/chat/$chatId`,params:{chatId:t},...n?{search:{m:n}}:{}})},[e,a]);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`button`,{type:`button`,className:`oc-search-trigger`,onClick:()=>i(!0),"aria-label":rn(),children:[(0,V.jsx)(WS,{className:`oc-search-trigger__icon`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`oc-search-trigger__label`,children:Mu()}),(0,V.jsx)(`kbd`,{className:`oc-search-trigger__kbd`,children:d})]}),(0,V.jsx)(WB,{open:r,onOpenChange:i,children:(0,V.jsxs)(qB,{showCloseButton:!1,className:`oc-search-palette top-[12vh] translate-y-0 max-w-xl gap-0 overflow-hidden p-0`,onOpenAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:[(0,V.jsx)(XB,{className:`sr-only`,children:_n()}),(0,V.jsxs)(`div`,{className:`oc-search-palette__head`,children:[(0,V.jsx)(WS,{className:`oc-search-palette__head-icon`,"aria-hidden":!0}),(0,V.jsx)(`input`,{ref:t,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),u(e=>Math.min(e+1,m.length-1));else if(e.key===`ArrowUp`)e.preventDefault(),u(e=>Math.max(e-1,0));else if(e.key===`Enter`){e.preventDefault();let t=m[l];t&&g(t.chatId,t.messageId)}},placeholder:mt(),className:`oc-search-palette__field`,autoComplete:`off`,spellCheck:!1,"aria-label":ra()})]}),(0,V.jsx)(`div`,{className:`oc-search-palette__results`,ref:n,role:`listbox`,children:f.length<w9?(0,V.jsx)(`div`,{className:`oc-search-palette__hint`,children:Di({count:w9})}):h?(0,V.jsx)(`div`,{className:`oc-search-palette__hint`,children:Ot()}):m.length===0?(0,V.jsx)(`div`,{className:`oc-search-palette__hint`,children:Ui({term:f})}):m.map((e,t)=>(0,V.jsxs)(`button`,{type:`button`,"data-index":t,role:`option`,"aria-selected":t===l,className:Al(`oc-search-result`,t===l&&`is-active`),onMouseMove:()=>u(t),onClick:()=>g(e.chatId,e.messageId),children:[(0,V.jsx)(`span`,{className:`oc-search-result__icon`,"aria-hidden":!0,children:e.matchedIn===`title`?(0,V.jsx)(Jne,{size:15}):(0,V.jsx)(IS,{size:15})}),(0,V.jsxs)(`span`,{className:`oc-search-result__body`,children:[(0,V.jsx)(`span`,{className:`oc-search-result__title`,children:e.title||ae()}),e.snippet?(0,V.jsx)(`span`,{className:`oc-search-result__snippet`,children:e.snippet}):null]}),(0,V.jsx)(`span`,{className:`oc-search-result__tag`,children:e.matchedIn===`title`?ip():Hr()})]},e.chatId))}),(0,V.jsxs)(`div`,{className:`oc-search-palette__footer`,children:[(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`kbd`,{children:`↑`}),(0,V.jsx)(`kbd`,{children:`↓`}),` `,kn()]}),(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`kbd`,{children:`↵`}),` `,Ut()]}),(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`kbd`,{children:et()}),` `,_r()]})]})]})})]})}var T9=[`users`,`groups`,`instances`,`bridge`,`injections`,`serviceAccounts`,`roles`,`access`,`traces`,`kpi`,`anomalies`,`files`,`scheduled`,`agentFiles`,`preferences`,`integrations`,`theme`,`chatDefaults`,`audit`,`feedbacks`,`subagentReports`,`voice`],E9=[`groups`,`access`,`roles`,`integrations`,`instances`,`injections`,`theme`,`feedbacks`,`subagentReports`,`files`,`scheduled`,`agentFiles`,`preferences`,`chatDefaults`],D9={users:()=>ls(),groups:()=>bs(),instances:()=>Fd(),bridge:()=>ll(),injections:()=>Ea(),serviceAccounts:()=>qo(),roles:()=>ad(),access:()=>h(),traces:()=>$l(),kpi:()=>go(),anomalies:()=>Dc(),files:()=>Ff(),scheduled:()=>It(),agentFiles:()=>hr(),preferences:()=>Ir(),integrations:()=>Hu(),theme:()=>uo(),chatDefaults:()=>Wu(),audit:()=>Ll(),feedbacks:()=>yd(),subagentReports:()=>jc(),voice:()=>no()},O9={users:`admin.manage`,groups:`groups.manage`,instances:`admin.manage`,bridge:`bridge.read`,injections:`admin.manage`,serviceAccounts:`admin.manage`,roles:`admin.manage`,access:`admin.manage`,traces:`traces.read`,kpi:`kpi.read`,anomalies:`anomalies.read`,files:`chats.read`,scheduled:`chats.read`,agentFiles:`agents.files.read`,preferences:`chats.read`,integrations:`admin.manage`,theme:`chats.read`,chatDefaults:`admin.manage`,audit:`admin.manage`,feedbacks:`admin.manage`,subagentReports:`admin.manage`,voice:`admin.manage`},VSe=[`traces`,`kpi`,`anomalies`,`bridge`,`agentFiles`,`groups`];function k9(e){let t=new Set(e);return T9.filter(e=>t.has(O9[e]))}function A9(e){return`/settings/${e}`}function j9(e){let t=e.split(`/`)[2];return T9.includes(t)?t:void 0}var HSe={uiprefs:`preferences`},M9=[{id:`personal`,label:()=>be(),tabs:[`preferences`,`theme`,`files`,`scheduled`]},{id:`agents`,label:()=>ii(),tabs:[`instances`,`agentFiles`,`chatDefaults`,`voice`,`bridge`,`injections`]},{id:`access`,label:()=>Of(),tabs:[`users`,`groups`,`access`,`roles`,`serviceAccounts`]},{id:`observability`,label:()=>Lo(),tabs:[`traces`,`kpi`,`anomalies`,`audit`,`feedbacks`,`subagentReports`,`integrations`]}],USe=new Map(M9.flatMap(e=>e.tabs.map(t=>[t,e.id])));function N9(e){let t=USe.get(e);if(!t)throw Error(`Settings tab "${e}" belongs to no group`);return t}function WSe(e,t){return e.find(e=>N9(e)===t)}M9.flatMap(e=>[...e.tabs]);function GSe(){let e=R(L.bridgeHealth.getBridgeAvailability,{});if(e===void 0)return null;let t=e.gatewaysUnreachable??0,n=e.known?e.available?t>0?`warn`:`ok`:`error`:`idle`,r=e.known?e.available?t>0?jo({count:t}):`${Gu()}${e.checkedAt?zl({time:jV(e.checkedAt)}):``}`:xd({reason:e.reason??`?`}):kc();return(0,V.jsx)(v6,{delayDuration:150,children:(0,V.jsxs)(y6,{children:[(0,V.jsx)(b6,{asChild:!0,children:(0,V.jsx)(`span`,{className:`oc-bridge-dot oc-bridge-dot--${n}`,role:`img`,"aria-label":r})}),(0,V.jsx)(x6,{children:r})]})})}function P9(e){let t=new Set(T9),n=new Set,r=[];for(let i of e??[])t.has(i)&&!n.has(i)&&(r.push(i),n.add(i));for(let e of T9)n.has(e)||r.push(e);return r}function KSe(e,t){let n=new Set(t),r=[...t];return e.map(e=>n.has(e)?r.shift():e)}function qSe({tab:e,active:t}){let n=D9[e](),r=`oc-settings-tabs__tab`+(t?` is-active`:``),i=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`oc-settings-tabs__label`,children:n}),e===`bridge`?(0,V.jsx)(GSe,{}):null]});return E9.includes(e)?(0,V.jsx)(Yg,{to:`/settings/$tab`,params:{tab:e},className:r,role:`tab`,"aria-selected":t,children:i}):(0,V.jsx)(Yg,{to:`/settings/${e}`,className:r,role:`tab`,"aria-selected":t,children:i})}function JSe({tab:e,active:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=J7({id:e});return(0,V.jsxs)(`div`,{ref:i,style:{transform:x5.Transform.toString(a),transition:o,opacity:s?.5:1},className:`oc-settings-tabs__item`,role:`presentation`,children:[(0,V.jsx)(`button`,{type:`button`,className:`oc-settings-tabs__grip`,"aria-label":je(),...n,...r,children:(0,V.jsx)(jS,{size:14,"aria-hidden":!0})}),(0,V.jsx)(qSe,{tab:e,active:t})]})}function YSe(){let e=R(L.me.getMe,{host:aB}),t=p(L.me.setSettingsTabOrder),n=j9(b_({select:e=>e.pathname})),r=n===void 0?void 0:N9(n),i=(0,B.useMemo)(()=>P9(e?.settingsTabOrder??null),[e?.settingsTabOrder]),[a,o]=(0,B.useState)(i);(0,B.useEffect)(()=>o(i),[i]);let s=(0,B.useMemo)(()=>new Set(k9(e?.permissions??[])),[e?.permissions]),c=(0,B.useMemo)(()=>r===void 0?[]:a.filter(e=>s.has(e)&&N9(e)===r),[a,s,r]),l=D5(E5(s7,{activationConstraint:{distance:5}}),E5(r7,{coordinateGetter:X7}));if(r===void 0||c.length===0)return null;let u=M9.find(e=>e.id===r);function d(e){let{active:n,over:r}=e;if(!r||n.id===r.id)return;let i=c.indexOf(n.id),s=c.indexOf(r.id);if(i<0||s<0)return;let l=KSe(a,R7(c,i,s));o(l),t({order:l})}return(0,V.jsx)(`div`,{className:`oc-settings-tabs`,role:`tablist`,"aria-label":u?.label(),children:(0,V.jsx)(N7,{sensors:l,collisionDetection:Zbe,modifiers:[aSe],onDragEnd:d,children:(0,V.jsx)(K7,{items:c,strategy:fSe,children:c.map(e=>(0,V.jsx)(JSe,{tab:e,active:e===n},e))})})})}function XSe(){let e=R(L.me.getMe,{host:aB}),t=Fg(),n=j9(b_({select:e=>e.pathname})),r=n===void 0?void 0:N9(n),i=(0,B.useMemo)(()=>new Set(k9(e?.permissions??[])),[e?.permissions]),a=(0,B.useMemo)(()=>P9(e?.settingsTabOrder??null).filter(e=>i.has(e)),[e?.settingsTabOrder,i]),o=M9.filter(e=>e.tabs.some(e=>i.has(e)));function s(e){let n=WSe(a,e.id);n&&t({to:A9(n)})}return(0,V.jsxs)(`nav`,{className:`oc-settings-nav`,"aria-label":He(),children:[(0,V.jsx)(Yg,{to:`/`,className:`oc-settings-nav__back`,children:gi()}),(0,V.jsx)(`div`,{className:`oc-settings-nav__title`,children:pf()}),(0,V.jsx)(`div`,{className:`oc-settings-nav__list`,children:o.map(e=>(0,V.jsx)(`button`,{type:`button`,className:`oc-settings-nav__group`+(e.id===r?` is-active`:``),"aria-current":e.id===r?`true`:void 0,onClick:()=>s(e),children:e.label()},e.id))})]})}var ZSe=[`eq`,`neq`,`contains`,`gt`,`gte`,`lt`,`lte`],F9=[50,100,200,500],I9=`now-30d`,QSe=`now-24h`;function $Se(e,t,n=I9,r=`now`){let i=e??n,a=t??r,o=Number(i),s=Number(a);return i!==``&&a!==``&&Number.isFinite(o)&&Number.isFinite(s)?{kind:`absolute`,from:o,to:s}:{kind:`relative`,from:i,to:a}}function eCe(e){return e.kind===`absolute`?{from:String(e.from),to:String(e.to)}:{from:e.from,to:e.to}}function tCe(e){if(e.length!==0)return JSON.stringify(e)}function nCe(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e,r=t.field,i=t.op,a=t.value;typeof r!=`string`||r===``||typeof i!=`string`||!ZSe.includes(i)||typeof a!=`string`&&typeof a!=`number`&&typeof a!=`boolean`||n.push({field:r,op:i,value:a})}return n}var L9=Kx().optional(),R9=Kx().optional(),z9=Kx().optional(),B9=Kx().optional().catch(void 0),rCe=$x({q:L9,section:nS([`latency`,`events`]).default(`events`).catch(`events`),kind:Kx().default(`all`).catch(`all`),limit:zne().pipe(eS([rS(F9[0]),rS(F9[1]),rS(F9[2]),rS(F9[3])])).catch(100),statusClass:nS([`2xx`,`4xx`,`5xx`]).optional().catch(void 0),principalType:nS([`user`,`service`,`system`]).optional().catch(void 0),direction:nS([`inbound`,`outbound`,`internal`]).optional().catch(void 0),roleKey:B9,from:R9,to:R9,adv:z9}),iCe=$x({q:L9,action:B9,impersonated:nS([`yes`,`no`]).optional().catch(void 0),resource:B9,from:R9,to:R9,adv:z9}),aCe=$x({q:L9,status:nS([`open`,`acknowledged`,`resolved`,`all`]).default(`open`).catch(`open`),severity:nS([`info`,`warn`,`critical`]).optional().catch(void 0),kind:B9,from:R9,to:R9}),oCe=$x({from:R9,to:R9}),sCe=$x({q:L9,status:nS([`active`,`disabled`]).optional().catch(void 0)}),cCe=$x({q:L9,role:B9});$x({q:L9,mode:nS([`per-user`,`shared`]).optional().catch(void 0)});var lCe=$x({section:nS([`readaloud`,`dictation`,`talk`]).default(`readaloud`).catch(`readaloud`)}),uCe=$x({section:Kx().max(32).default(`openclaw`).catch(`openclaw`)}),V9=`oc.theme`;function H9(e){let t=e===`dark`||e===`system`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;document.documentElement.classList.toggle(`dark`,t)}function U9(e){(0,B.useEffect)(()=>{let t=e??localStorage.getItem(V9)??`system`;if(localStorage.setItem(V9,t),H9(t),t===`system`){let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>H9(`system`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}},[e])}var W9=`oc.fontScale`,dCe={sm:`87.5%`,md:``,lg:`112.5%`,xl:`125%`},G9=[`sm`,`md`,`lg`,`xl`];function fCe(e){return e!==null&&G9.includes(e)}function pCe(e){document.documentElement.style.fontSize=dCe[e]}function K9(e){(0,B.useEffect)(()=>{let t=localStorage.getItem(W9),n=e??(fCe(t)?t:`md`);localStorage.setItem(W9,n),pCe(n)},[e])}function mCe(e){(0,B.useEffect)(()=>{if(!e)return;document.documentElement.lang=e;let t;try{t=Tu()}catch{t=void 0}t!==e&&Xt(e)},[e])}var hCe=(0,B.lazy)(()=>g4(()=>import(`./RolesTab-DbSxOWRh.js`).then(e=>({default:e.RolesTab})),__vite__mapDeps([2,1,3,4,5]))),gCe=(0,B.lazy)(()=>g4(()=>import(`./InstancesTab-bbthnf8h.js`).then(e=>({default:e.InstancesTab})),__vite__mapDeps([6,1,3,7,8,9,10,11,12,13,14,15,16,5,17,18,19]))),_Ce=(0,B.lazy)(()=>g4(()=>import(`./PromptInjectionsTab-Df6PKtxv.js`).then(e=>({default:e.PromptInjectionsTab})),__vite__mapDeps([20,1,3,7,8,9,21,5,22]))),vCe=(0,B.lazy)(()=>g4(()=>import(`./GroupsTab-BjjiPSDY.js`).then(e=>({default:e.GroupsTab})),__vite__mapDeps([23,1,3,13,12,24,19,14,5,17,25,15,16]))),yCe=(0,B.lazy)(()=>g4(()=>import(`./IntegrationsTab-DQt4Kllc.js`).then(e=>({default:e.IntegrationsTab})),__vite__mapDeps([26,1,3,5]))),bCe=(0,B.lazy)(()=>g4(()=>import(`./FeedbacksTab-CqJ8NDLb.js`).then(e=>({default:e.FeedbacksTab})),__vite__mapDeps([27,1,3,19,12,14,5,17]))),xCe=(0,B.lazy)(()=>g4(()=>import(`./SubAgentReportsTab-xgRtphLV.js`).then(e=>({default:e.SubAgentReportsTab})),__vite__mapDeps([28,1,3,19,12,14,5,17]))),SCe=(0,B.lazy)(()=>g4(()=>import(`./FilesTab-lytzpFwp.js`).then(e=>({default:e.FilesTab})),__vite__mapDeps([29,1,3,5,17]))),CCe=(0,B.lazy)(()=>g4(()=>import(`./ScheduledTab-km3Zx4dq.js`).then(e=>({default:e.ScheduledTab})),__vite__mapDeps([30,1,3,5,17]))),wCe=(0,B.lazy)(()=>g4(()=>import(`./AgentFilesTab-tYeG81Bo.js`).then(e=>({default:e.AgentFilesTab})),__vite__mapDeps([31,1,3,11,8,5,22]))),TCe=(0,B.lazy)(()=>g4(()=>import(`./PreferencesTab-B1JSLFVE.js`).then(e=>({default:e.PreferencesTab})),__vite__mapDeps([32,1,3,21,9,5]))),ECe=(0,B.lazy)(()=>g4(()=>import(`./ChatDefaultsTab-DYVQXktp.js`).then(e=>({default:e.ChatDefaultsTab})),__vite__mapDeps([33,1,3,11,5,22]))),DCe=(0,B.lazy)(()=>g4(()=>import(`./AccessTab-BlTwl2Uk.js`).then(e=>({default:e.AccessTab})),__vite__mapDeps([34,1,3]))),OCe=(0,B.lazy)(()=>g4(()=>import(`./ThemeShowroom-DxcANzhZ.js`).then(e=>({default:e.ThemeShowroom})),__vite__mapDeps([35,1,3,36,24,37,12,16,5,15,21,9,38,17])));function kCe(){return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Up,{children:(0,V.jsx)(`div`,{className:`oc-boot`,children:nc()})}),(0,V.jsx)(Hp,{children:(0,V.jsx)(jCe,{})}),(0,V.jsx)(Vp,{children:(0,V.jsx)(lH,{children:(0,V.jsx)(NCe,{})})})]})}function ACe(){return(0,V.jsxs)(`svg`,{className:`oc-provider__logo`,viewBox:`0 0 48 48`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{fill:`#EA4335`,d:`M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z`}),(0,V.jsx)(`path`,{fill:`#4285F4`,d:`M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z`}),(0,V.jsx)(`path`,{fill:`#FBBC05`,d:`M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z`}),(0,V.jsx)(`path`,{fill:`#34A853`,d:`M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z`})]})}function jCe(){let{signIn:e}=im();U9(void 0),K9(void 0);let t=R(L.charts.brandForHost,{host:aB}),n=cB(aB),r=t??n??null,i=EB(void 0);OB(r?.tokens??null,i),(0,B.useEffect)(()=>{t&&lB(aB,t)},[t]);let a=r?.brand,o=a&&!a.isDefault?FB(a,i):null,s=a?.label??`Atrium`,c=R(L.me.authProviders),[l,u]=(0,B.useState)(null);async function d(t){u(null);try{await e(t)}catch{u(vc())}}let f=c!==void 0&&!c.google&&!c.microsoft&&!c.anonymous;return(0,V.jsxs)(`div`,{className:`oc-signin`,children:[(0,V.jsxs)(`svg`,{className:`oc-signin__motif`,viewBox:`0 0 1200 1000`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:[(0,V.jsx)(`polyline`,{className:`oc-signin__line`,points:`0,860 470,860 522,790 574,940 626,810 678,860 1200,860`,vectorEffect:`non-scaling-stroke`}),(0,V.jsx)(`polyline`,{className:`oc-signin__pulse`,points:`0,860 470,860 522,790 574,940 626,810 678,860 1200,860`,pathLength:`100`,vectorEffect:`non-scaling-stroke`})]}),(0,V.jsxs)(`div`,{className:`oc-signin__brand`,children:[o?(0,V.jsx)(`img`,{className:`oc-signin__brandlogo`,src:o,alt:``}):null,(0,V.jsx)(`span`,{className:`oc-signin__wordmark`,children:s})]}),(0,V.jsxs)(`div`,{className:`oc-signin__card`,children:[(0,V.jsx)(`h1`,{className:`oc-signin__title`,children:Ol()}),(0,V.jsx)(`p`,{className:`oc-signin__subtitle`,children:yu()}),(0,V.jsx)(`div`,{className:`oc-signin__providers`,children:c?.google?(0,V.jsxs)(`button`,{type:`button`,className:`oc-provider oc-provider--google`,onClick:()=>void d(`google`),children:[(0,V.jsx)(ACe,{}),(0,V.jsx)(`span`,{children:Bs()})]}):null}),l?(0,V.jsx)(`p`,{className:`oc-signin__error`,children:l}):null,f?(0,V.jsx)(`p`,{className:`oc-signin__error`,children:ps()}):null,c?.anonymous?(0,V.jsx)(`button`,{type:`button`,className:`oc-signin__dev`,onClick:()=>void e(`anonymous`),children:zd()}):null]})]})}function MCe(){let{width:e,collapsed:t,isMobile:n}=q6();return(0,V.jsxs)(`div`,{className:`oc-shell`,children:[(0,V.jsxs)(`header`,{className:`oc-topbar`,children:[(0,V.jsxs)(`div`,{className:`oc-topbar__left`,children:[(0,V.jsx)(`div`,{className:`oc-skel`,style:{width:`1.75rem`,height:`1.75rem`}}),(0,V.jsx)(`div`,{className:`oc-skel`,style:{width:`5.5rem`,height:`1.1rem`}})]}),(0,V.jsx)(`div`,{className:`oc-topbar__search`,children:(0,V.jsx)(`div`,{className:`oc-skel`,style:{width:`100%`,height:`2.25rem`}})}),(0,V.jsx)(`div`,{className:`oc-topbar__actions`,children:(0,V.jsx)(`div`,{className:`oc-skel`,style:{width:`1.75rem`,height:`1.75rem`,borderRadius:`999px`}})})]}),(0,V.jsxs)(`div`,{className:n?`oc-workspace oc-workspace--mobile`:`oc-workspace`,children:[!t&&!n?(0,V.jsx)(`div`,{className:`oc-sidebar-col`,style:{width:e,flex:`0 0 ${e}px`},children:(0,V.jsxs)(`aside`,{className:`oc-sidebar`,children:[(0,V.jsx)(`div`,{className:`oc-skel`,style:{height:`2.25rem`,margin:`0.25rem 0.25rem 0`}}),(0,V.jsx)(f9,{})]})}):null,(0,V.jsx)(`main`,{className:`oc-main`})]})]})}function NCe(){let e=R(L.me.getMe,{host:aB}),t=p(L.me.bootstrap),n=Fg();(0,B.useEffect)(()=>{e&&!e.hasProfile&&t()},[e,t]),U9(e?.resolvedThemeMode),K9(e?.resolvedFontScale);let r=EB(e?.resolvedThemeMode);OB(e?.resolvedChartTokens,r),mCe(e?.resolvedLocale);let i=(0,B.useRef)(null);if((0,B.useEffect)(()=>{e&&(i.current!==null&&i.current!==e.userId&&n({to:`/`}),i.current=e.userId)},[e,n]),e===void 0)return(0,V.jsx)(MCe,{});let a=e.name||e.email||ml();return e.role===`pending`?(0,V.jsxs)(`div`,{className:`oc-shell`,children:[(0,V.jsx)(q9,{}),(0,V.jsx)(b9,{}),(0,V.jsxs)(`header`,{className:`oc-topbar`,children:[(0,V.jsx)(`span`,{className:`oc-topbar__brand`,children:(0,V.jsx)(J9,{brand:e.resolvedChartBrand,resolvedThemeMode:e.resolvedThemeMode})}),(0,V.jsx)(`div`,{className:`oc-topbar__actions`,children:(0,V.jsx)(x9,{label:a,mode:e.themeMode,minimal:!0})})]}),(0,V.jsxs)(`div`,{className:`oc-pending`,children:[(0,V.jsx)(`h1`,{className:`oc-pending__title`,children:Qo()}),(0,V.jsx)(`p`,{className:`oc-pending__body`,children:ud()})]})]}):(0,V.jsx)(FCe,{canOpenSettings:k9(e.permissions??[]).length>0,userLabel:a,themeMode:e.themeMode,resolvedThemeMode:e.resolvedThemeMode,brand:e.resolvedChartBrand},e.userId)}function q9(){let e=R(L.me.getImpersonation),t=p(L.admin.stopImpersonation);return!e||!e.impersonating?null:(0,V.jsxs)(`div`,{className:`oc-imp`,role:`alert`,children:[(0,V.jsx)(ES,{className:`size-4 shrink-0`}),(0,V.jsxs)(`span`,{className:`oc-imp__text`,children:[iu(),` `,(0,V.jsx)(`strong`,{children:e.targetLabel}),xo(),(0,V.jsx)(`strong`,{children:e.realLabel}),Pc()]}),(0,V.jsx)(Ep,{size:`sm`,variant:`outline`,className:`oc-imp__exit`,onClick:()=>void t(),children:Yu()})]})}function J9({brand:e,resolvedThemeMode:t}){let n=EB(t),r=e?.label??`Atrium`,i=e?.isDefault??!0,a=FB(e,n),[o,s]=(0,B.useState)(!1);return(0,B.useEffect)(()=>s(!1),[a]),(0,V.jsxs)(V.Fragment,{children:[a!==null&&!o?(0,V.jsx)(`img`,{className:`oc-brand__logo`,src:a,alt:``,"aria-hidden":`true`,onError:()=>s(!0)}):i?(0,V.jsx)(zB,{className:`oc-brand__logo`}):null,(0,V.jsx)(`span`,{className:`oc-brand__label`,children:r})]})}function PCe({userLabel:e,themeMode:t,resolvedThemeMode:n,brand:r,collapsed:i,onToggleSidebar:a}){return(0,V.jsxs)(`header`,{className:`oc-topbar`,children:[(0,V.jsxs)(`div`,{className:`oc-topbar__left`,children:[(0,V.jsx)(Ep,{variant:`ghost`,size:`icon-sm`,"aria-label":i?Ul():Td(),onClick:a,children:i?(0,V.jsx)(ore,{}):(0,V.jsx)(are,{})}),(0,V.jsx)(Yg,{to:`/`,className:`oc-topbar__brand`,children:(0,V.jsx)(J9,{brand:r,resolvedThemeMode:n})})]}),(0,V.jsx)(`div`,{className:`oc-topbar__search`,children:(0,V.jsx)(BSe,{})}),(0,V.jsxs)(`div`,{className:`oc-topbar__actions`,children:[(0,V.jsx)(LSe,{}),(0,V.jsx)(x9,{label:e,mode:t})]})]})}function FCe({canOpenSettings:e,userLabel:t,themeMode:n,resolvedThemeMode:r,brand:i}){let{width:a,columnRef:o,collapsed:s,toggleCollapsed:c,collapse:l,startResize:u,isMobile:d}=q6(),f=m_(),p=Ng({strict:!1}),h=Fg(),g=!!f({to:`/settings`,fuzzy:!0});(0,B.useEffect)(()=>{d&&l()},[b_({select:e=>e.pathname}),d,l]);let _=(0,B.useCallback)(e=>{h({to:`/chat/$chatId`,params:{chatId:e}})},[h]),{startNewChat:v,picker:y}=NSe(_),b=(0,B.useMemo)(()=>yB(dB,_B()),[]);return(0,B.useEffect)(()=>{let e=e=>{bB(e,dB)&&(e.preventDefault(),v())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[v]),(0,V.jsxs)(`div`,{className:`oc-shell`,children:[y,(0,V.jsx)(MSe,{activeChatId:p.chatId??null}),(0,V.jsx)(q9,{}),(0,V.jsx)(b9,{}),(0,V.jsx)(PCe,{userLabel:t,themeMode:n,resolvedThemeMode:r,brand:i,collapsed:s,onToggleSidebar:c}),(0,V.jsxs)(`div`,{className:d?`oc-workspace oc-workspace--mobile`:`oc-workspace`,children:[d&&!s?(0,V.jsx)(`div`,{className:`oc-sidebar-backdrop`,onClick:l,"aria-hidden":!0}):null,s?null:(0,V.jsxs)(`div`,{className:`oc-sidebar-col`,ref:e=>{o.current=d?null:e},style:d?void 0:{width:a,flex:`0 0 ${a}px`},children:[g?(0,V.jsx)(XSe,{}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(DSe,{activeChatId:p.chatId??null,onSelect:_,onNewChat:()=>void v(),newChatShortcut:b}),(0,V.jsx)(Ep,{variant:`ghost`,className:`mx-2 justify-start`,asChild:!0,children:(0,V.jsxs)(Yg,{to:`/settings/$tab`,params:{tab:`scheduled`},children:[(0,V.jsx)(mS,{"aria-hidden":!0}),ka()]})}),(0,V.jsx)(Ep,{variant:`ghost`,className:`mx-2 justify-start`,asChild:!0,children:(0,V.jsxs)(Yg,{to:`/settings/$tab`,params:{tab:`files`},children:[(0,V.jsx)(Xne,{"aria-hidden":!0}),ha()]})}),e?(0,V.jsx)(Ep,{variant:`ghost`,className:`mx-2 mb-2 justify-start`,asChild:!0,children:(0,V.jsxs)(Yg,{to:`/settings`,children:[(0,V.jsx)(ure,{"aria-hidden":!0}),Es()]})}):null]}),(0,V.jsx)(`div`,{className:`oc-sidebar-resizer`,onPointerDown:u,role:`separator`,"aria-orientation":`vertical`,"aria-label":m()})]}),(0,V.jsx)(`main`,{className:`oc-main`,children:(0,V.jsx)(u_,{})})]})]})}function ICe(){let e=R(L.me.getMe,{host:aB}),t=Fg(),n=b_({select:e=>e.pathname}),r=(0,B.useMemo)(()=>e?k9(e.permissions??[]):[],[e]),i=e!==void 0&&r.length===0;if((0,B.useEffect)(()=>{i&&t({to:`/`})},[i,t]),e===void 0)return(0,V.jsx)(`div`,{className:`oc-admin__hint`,style:{padding:16},children:nc()});if(i)return null;let a=j9(n),o=a!==void 0&&!r.includes(a);return(0,V.jsxs)(`div`,{className:`oc-admin`,children:[(0,V.jsx)(YSe,{}),(0,V.jsx)(`div`,{className:`oc-admin__body`,children:o?(0,V.jsx)(LCe,{}):(0,V.jsx)(u_,{})})]})}function LCe(){return(0,V.jsxs)(`div`,{className:`oc-route-error`,role:`alert`,children:[(0,V.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,V.jsx)(XS,{size:28})}),(0,V.jsx)(`h2`,{className:`oc-route-error__title`,children:Tr()}),(0,V.jsx)(`p`,{className:`oc-route-error__body`,children:Ra()})]})}function RCe(){let e=R(L.me.getMe,{host:aB}),t=Fg();return(0,B.useEffect)(()=>{if(e===void 0)return;let n=k9(e.permissions??[]);t({to:n.includes(`files`)?A9(`files`):n.length>0?A9(n[0]):`/`,replace:!0})},[e,t]),(0,V.jsx)(`div`,{className:`oc-admin__hint`,style:{padding:16},children:nc()})}function zCe(e){switch(e){case`groups`:return(0,V.jsx)(vCe,{});case`integrations`:return(0,V.jsx)(yCe,{});case`instances`:return(0,V.jsx)(gCe,{});case`injections`:return(0,V.jsx)(_Ce,{});case`theme`:return(0,V.jsx)(OCe,{});case`feedbacks`:return(0,V.jsx)(bCe,{});case`subagentReports`:return(0,V.jsx)(xCe,{});case`files`:return(0,V.jsx)(SCe,{});case`scheduled`:return(0,V.jsx)(CCe,{});case`agentFiles`:return(0,V.jsx)(wCe,{});case`preferences`:return(0,V.jsx)(TCe,{});case`chatDefaults`:return(0,V.jsx)(ECe,{});case`access`:return(0,V.jsx)(DCe,{});default:return(0,V.jsx)(hCe,{})}}function BCe(){let{tab:e}=Ng({from:`/settings/$tab`});return(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(`div`,{className:`oc-settings__tab-loading`,"aria-busy":`true`}),children:zCe(e)})}function VCe(){let{chatId:e}=Ng({from:`/chat/$chatId`}),{m:t}=Pg({from:`/chat/$chatId`});return(0,B.useEffect)(()=>{_re(e)},[e]),(0,V.jsx)(V8,{chatId:e,focusMessageId:t??null})}function HCe(){let e=Fg(),t=vre(),n=R(L.messages.listChats,{}),r=t!==null&&n!==void 0&&n.some(e=>e._id===t);return(0,B.useEffect)(()=>{r&&t&&e({to:`/chat/$chatId`,params:{chatId:t},replace:!0})},[r,t,e]),t!==null&&(n===void 0||r)?(0,V.jsx)(`div`,{className:`oc-boot`,children:nc()}):(0,V.jsx)(V8,{chatId:null})}var Y9=e_({component:kCe}),UCe=Qg({getParentRoute:()=>Y9,path:`/`,component:HCe}),WCe=Qg({getParentRoute:()=>Y9,path:`chat/$chatId`,component:VCe,validateSearch:e=>({m:typeof e.m==`string`?e.m:void 0})}),X9=Qg({getParentRoute:()=>Y9,path:`settings`,component:ICe}),GCe=Qg({getParentRoute:()=>X9,path:`/`,component:RCe}),KCe=Qg({getParentRoute:()=>X9,path:`traces`,validateSearch:rCe,component:t_(()=>g4(()=>import(`./TracesTab-ColoY1Nx.js`),__vite__mapDeps([39,1,3,13,12,36,24,19,14,5,17,37,16,15])),`TracesTab`)}),qCe=Qg({getParentRoute:()=>X9,path:`bridge`,validateSearch:uCe,component:t_(()=>g4(()=>import(`./BridgeTab-s6Ggg8Zu.js`),__vite__mapDeps([10,1,3,11,7,8,9,12,13,14,15,16,5,17,18])),`BridgeTab`)}),JCe=Qg({getParentRoute:()=>X9,path:`voice`,validateSearch:lCe,component:t_(()=>g4(()=>import(`./VoiceTab-qZ5tMxmC.js`),__vite__mapDeps([40,1,3,13,12,5,22])),`VoiceTab`)}),YCe=Qg({getParentRoute:()=>X9,path:`audit`,validateSearch:iCe,component:t_(()=>g4(()=>import(`./AuditTab-D_mhJO5w.js`),__vite__mapDeps([41,1,3,19,12,14,5,17,37,24,16,15])),`AuditTab`)}),XCe=Qg({getParentRoute:()=>X9,path:`anomalies`,validateSearch:aCe,component:t_(()=>g4(()=>import(`./AnomaliesTab-C94n-0pQ.js`),__vite__mapDeps([42,1,3,19,12,14,5,17,15,16,18])),`AnomaliesTab`)}),ZCe=Qg({getParentRoute:()=>X9,path:`kpi`,validateSearch:oCe,component:t_(()=>g4(()=>import(`./KpiTab-qUWozfhc.js`),__vite__mapDeps([43,1,3,16,5,38])),`KpiTab`)}),QCe=Qg({getParentRoute:()=>X9,path:`serviceAccounts`,validateSearch:sCe,component:t_(()=>g4(()=>import(`./ServiceAccountsTab-Bcd88LfG.js`),__vite__mapDeps([44,1,3,12,36,19,14,5,17,15,16,4])),`ServiceAccountsTab`)}),$Ce=Qg({getParentRoute:()=>X9,path:`users`,validateSearch:cCe,component:t_(()=>g4(()=>import(`./UsersTab-B0IdN_hl.js`),__vite__mapDeps([45,1,3,19,12,14,5,17,25,15,16])),`UsersTab`)}),ewe=Qg({getParentRoute:()=>X9,path:`uiprefs`,beforeLoad:()=>{throw nh({to:`/settings/$tab`,params:{tab:HSe.uiprefs},replace:!0})}}),twe=Qg({getParentRoute:()=>X9,path:`$tab`,parseParams:e=>({tab:nS([...E9]).catch(`roles`).parse(e.tab)}),component:BCe});function nwe({error:e,reset:t}){let n=Fg(),r=yre(e),[i]=(0,B.useState)(()=>r&&Sre(Date.now()));return(0,B.useEffect)(()=>{i&&window.location.reload()},[i]),i?(0,V.jsx)(`div`,{className:`oc-route-error`,role:`status`,children:(0,V.jsx)(`p`,{className:`oc-route-error__body`,children:fa()})}):(0,V.jsxs)(`div`,{className:`oc-route-error`,role:`alert`,children:[(0,V.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,V.jsx)(XS,{size:28})}),(0,V.jsx)(`h2`,{className:`oc-route-error__title`,children:Ta()}),(0,V.jsx)(`p`,{className:`oc-route-error__body`,children:Zt()}),(0,V.jsxs)(`div`,{className:`oc-route-error__actions`,children:[(0,V.jsx)(`button`,{type:`button`,className:`oc-route-error__cta`,onClick:()=>{r?window.location.reload():t()},children:Eu()}),(0,V.jsx)(`button`,{type:`button`,className:`oc-route-error__cta oc-route-error__cta--ghost`,onClick:()=>void n({to:`/`}),children:dn()})]})]})}function rwe(){let e=Fg();return(0,V.jsxs)(`div`,{className:`oc-route-error`,role:`status`,children:[(0,V.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,V.jsx)(Une,{size:28})}),(0,V.jsx)(`h2`,{className:`oc-route-error__title`,children:ct()}),(0,V.jsx)(`p`,{className:`oc-route-error__body`,children:Qi()}),(0,V.jsx)(`div`,{className:`oc-route-error__actions`,children:(0,V.jsx)(`button`,{type:`button`,className:`oc-route-error__cta`,onClick:()=>void e({to:`/`}),children:dn()})})]})}var Z9=g_({routeTree:Y9.addChildren([UCe,WCe,X9.addChildren([GCe,KCe,JCe,qCe,YCe,XCe,ZCe,QCe,$Ce,ewe,twe])]),defaultPreload:`intent`,defaultErrorComponent:nwe,defaultNotFoundComponent:rwe}),iwe=()=>null;function Q9({children:e}){return(0,V.jsx)(`div`,{style:{display:`flex`,minHeight:`100vh`,alignItems:`center`,justifyContent:`center`,padding:`2rem`,textAlign:`center`,font:`14px system-ui, sans-serif`,opacity:.6},children:e})}var $9=Wp.createRoot(document.getElementById(`root`));$9.render((0,V.jsx)(B.StrictMode,{children:(0,V.jsx)(Q9,{children:st()})})),_U().then(e=>{let t=new da(e);$9.render((0,V.jsx)(B.StrictMode,{children:(0,V.jsx)(oee,{client:t,children:(0,V.jsxs)(JV,{children:[(0,V.jsx)(Pye,{children:(0,V.jsx)(y_,{router:Z9})}),(0,V.jsx)(B.Suspense,{fallback:null,children:(0,V.jsx)(iwe,{router:Z9,position:`bottom-right`})})]})})}))}).catch(e=>{console.error(`Boot failed:`,e),$9.render((0,V.jsx)(B.StrictMode,{children:(0,V.jsxs)(Q9,{children:[tt(),` `,e instanceof Error?e.message:String(e)]})}))});export{PV as $,vS as $t,g4 as A,GN as At,EH as B,HS as Bt,e6 as C,yB as Ct,Jge as D,SF as Dt,w4 as E,wF as Et,AH as F,YS as Ft,LV as G,NS as Gt,uH as H,BS as Ht,NH as I,JS as It,BV as J,ES as Jt,GV as K,MS as Kt,BH as L,GS as Lt,EU as M,$S as Mt,IH as N,ZS as Nt,U3 as O,CF as Ot,zH as P,XS as Pt,UV as Q,bS as Qt,PH as R,WS as Rt,$3 as S,CB as St,Z3 as T,TF as Tt,XV as U,zS as Ut,TH as V,VS as Vt,ZV as W,LS as Wt,HV as X,CS as Xt,WV as Y,wS as Yt,VV as Z,SS as Zt,x6 as _,JB as _t,tCe as a,xV as at,Eve as b,TB as bt,VSe as c,TV as ct,Q7 as d,eV as dt,gS as en,IV as et,C8 as f,QB as ft,y6 as g,YB as gt,S6 as h,ZB as ht,$Se as i,jV as it,IU as j,BN as jt,K3 as k,KN as kt,D9 as l,EV as lt,E6 as m,qB as mt,I9 as n,Fg as nn,AV as nt,eCe as o,CV as ot,y8 as p,WB as pt,KV as q,AS as qt,QSe as r,Pg as rn,kV as rt,nCe as s,wV as st,G9 as t,hS as tn,FV as tt,O9 as u,SV as ut,v6 as v,XB as vt,Q3 as w,aB as wt,X3 as x,_B as xt,b6 as y,EB as yt,MH as z,US as zt};