1import"../chunks/CWj6FrbW.js";import"../chunks/69_IOA4Y.js";import{w as Po,h as Ue,i as Ce,a as w,E as Dt,p as yt,c as v,r as f,t as we,b as wt,f as ne,m as z,o as kt,k as s,l as t,x as pe,B as c,bH as Co,y as $t,z as u,n as R,q as me,e as he,s as Tt,D as ht,d as se,aJ as Bt,A as Gt,u as it,aD as Oo,b6 as No,g as Lo,v as Bo,j as Mo,$ as Do}from"../chunks/7a2fV5I9.js";import{i as ke}from"../chunks/Dw-yaK-_.js";import{s as at}from"../chunks/CiyEWm25.js";import{h as $o}from"../chunks/DKaByr9K.js";import{a as ye,c as bt,s as lt,d as xt,h as Ro,S as Uo,r as zo,j as Fo}from"../chunks/3tOhmI7k.js";import{i as Et}from"../chunks/CWFN-V6k.js";import{l as Ho}from"../chunks/dm1FmSOd.js";import{r as eo,l as Wo}from"../chunks/SSgOjjKL.js";import{c as jo}from"../chunks/CFrvYhlc.js";import{e as Mt,i as Jt}from"../chunks/CDs8OzhH.js";import{p as N,l as qt,b as Xt,s as Ut}from"../chunks/DPBuKmzL.js";import{u as Yo,c as ot,a as ho,t as ut}from"../chunks/B1RxOmHW.js";import{c as Ct}from"../chunks/Cl6Xka7r.js";import{F as At,e as yo,G as Lt,H as qo,I as to,J as Vo,K as oo,L as Ko,N as zt,m as Ft,u as It,c as Ht,W as ao,O as no,l as ro,P as Go,Q as Jo,R as Xo,o as Ot,S as so,T as io,U as lo,i as Zo,V as Wt,X as Qo,Y as ea,E as ta,Z as oa,_ as aa,$ as na,a0 as ra}from"../chunks/C33EP41Y.js";import{b as sa}from"../chunks/Bj-uvTK_.js";import{s as ia,u as la,b as ca,g as pt}from"../chunks/BnvOT63w.js";import{p as da}from"../chunks/BewnZnAa.js";import{i as co,a as ua,g as fa,c as ga}from"../chunks/DKxluP3e.js";import{b as Vt,a as uo,g as ma,e as va}from"../chunks/BIMfEMVU.js";import{g as pa,a as ha,c as ya}from"../chunks/gfHH1kxe.js";import{b as wo,u as _o,c as wa}from"../chunks/CyHtxK_t.js";import{i as _a}from"../chunks/Cojxxu7g.js";import{a as bo,s as xo}from"../chunks/DN4pFdL0.js";import{d as ft,p as jt,q as fo,a0 as ba,h as xa,D as ka,b as go,a1 as Ea,a2 as Sa,a3 as Ia}from"../chunks/DKKyCjZm.js";import{h as Aa}from"../chunks/Dxy4iZ9H.js";import{s as Ta,p as Pa}from"../chunks/Bfc47y5P.js";import{b as Ca}from"../chunks/YoyIeg0L.js";import{X as ko}from"../chunks/IqCUZuIq.js";import{T as Eo}from"../chunks/WwSz7SIr.js";import{M as Oa}from"../chunks/C7eVKYlM.js";import{S as So}from"../chunks/2p5Upk8k.js";import{g as Na}from"../chunks/__7d91Lc.js";import{g as mo}from"../chunks/BviHjP5J.js";const La=!1,Ba="ignore",gr=Object.freeze(Object.defineProperty({__proto__:null,ssr:La,trailingSlash:Ba},Symbol.toStringTag,{value:"Module"}));function vo(P){return Object.prototype.toString.call(P)==="[object Date]"}function Kt(P,r,o,S){if(typeof o=="number"||vo(o)){const A=S-o,M=(o-r)/(P.dt||1/60),W=P.opts.stiffness*A,j=P.opts.damping*M,D=(W-j)*P.inv_mass,ie=(M+D)*P.dt;return Math.abs(ie)<P.opts.precision&&Math.abs(A)<P.opts.precision?S:(P.settled=!1,vo(o)?new Date(o.getTime()+ie):o+ie)}else{if(Array.isArray(o))return o.map((A,M)=>Kt(P,r[M],o[M],S[M]));if(typeof o=="object"){const A={};for(const M in o)A[M]=Kt(P,r[M],o[M],S[M]);return A}else throw new Error(`Cannot spring ${typeof o} values`)}}function Ma(P,r={}){const o=Po(P),{stiffness:S=.15,damping:A=.8,precision:M=.01}=r;let W,j,D,ie=P,k=P,L=1,T=0,te=!1;function Z(Q,Ee={}){k=Q;const Ne=D={};return P==null||Ee.hard||Y.stiffness>=1&&Y.damping>=1?(te=!0,W=eo.now(),ie=Q,o.set(P=k),Promise.resolve()):(Ee.soft&&(T=1/((Ee.soft===!0?.5:+Ee.soft)*60),L=0),j||(W=eo.now(),te=!1,j=Wo(ge=>{if(te)return te=!1,j=null,!1;L=Math.min(L+T,1);const _e=Math.min(ge-W,1e3/30),F={inv_mass:L,opts:Y,settled:!0,dt:_e*60/1e3},De=Kt(F,ie,P,k);return W=ge,ie=P,o.set(P=De),F.settled&&(j=null),!F.settled})),new Promise(ge=>{j.promise.then(()=>{Ne===D&&ge()})}))}const Y={set:Z,update:(Q,Ee)=>Z(Q(k,P),Ee),subscribe:o.subscribe,stiffness:S,damping:A,precision:M};return Y}var Da=Dt('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd"></path></svg>'),$a=Dt('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd"></path></svg>'),Ra=Dt('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z" clip-rule="evenodd"></path></svg>'),Ua=Dt('<svg viewBox="0 0 64 64" fill="currentColor" height="20" width="20" xmlns="http://www.w3.org/2000/svg"><path d="M32.427,7.987c2.183,0.124 4,1.165 5.096,3.281l17.936,36.208c1.739,3.66 -0.954,8.585 -5.373,8.656l-36.119,0c-4.022,-0.064 -7.322,-4.631 -5.352,-8.696l18.271,-36.207c0.342,-0.65 0.498,-0.838 0.793,-1.179c1.186,-1.375 2.483,-2.111 4.748,-2.063Zm-0.295,3.997c-0.687,0.034 -1.316,0.419 -1.659,1.017c-6.312,11.979 -12.397,24.081 -18.301,36.267c-0.546,1.225 0.391,2.797 1.762,2.863c12.06,0.195 24.125,0.195 36.185,0c1.325,-0.064 2.321,-1.584 1.769,-2.85c-5.793,-12.184 -11.765,-24.286 -17.966,-36.267c-0.366,-0.651 -0.903,-1.042 -1.79,-1.03Z"></path><path d="M33.631,40.581l-3.348,0l-0.368,-16.449l4.1,0l-0.384,16.449Zm-3.828,5.03c0,-0.609 0.197,-1.113 0.592,-1.514c0.396,-0.4 0.935,-0.601 1.618,-0.601c0.684,0 1.223,0.201 1.618,0.601c0.395,0.401 0.593,0.905 0.593,1.514c0,0.587 -0.193,1.078 -0.577,1.473c-0.385,0.395 -0.929,0.593 -1.634,0.593c-0.705,0 -1.249,-0.198 -1.634,-0.593c-0.384,-0.395 -0.576,-0.886 -0.576,-1.473Z"></path></svg>');function Nt(P,r){let o=N(r,"type",8,"success");var S=Ue(),A=Ce(S);{var M=k=>{var L=Da();w(k,L)},W=k=>{var L=$a();w(k,L)},j=k=>{var L=Ra();w(k,L)},D=k=>{var L=Ua();w(k,L)},ie=k=>{};ke(A,k=>{o()==="success"?k(M):o()==="error"?k(W,1):o()==="info"?k(j,2):o()==="warning"?k(D,3):k(ie,-1)})}w(P,S)}var za=ne('<div class="sonner-loading-bar"></div>'),Fa=ne('<div class="sonner-loading-wrapper"><div class="sonner-spinner"></div></div>');function Ha(P,r){yt(r,!1);let o=N(r,"visible",8);const S=Array(12).fill(0);Et();var A=Fa(),M=v(A);Mt(M,5,()=>S,Jt,(W,j)=>{var D=za();w(W,D)}),f(M),f(A),we(()=>ye(A,"data-visible",o())),w(P,A),wt()}var Wa=ne('<button aria-label="Close toast" data-close-button=""><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></button>'),ja=ne('<div data-icon=""><!> <!></div>
1'),Ya=ne('<div data-title=""><!></div>'),qa=ne('<div data-description=""><!></div>'),Va=ne('<button data-button="" data-cancel=""> </button>'),Ka=ne('<button data-button=""> </button>'),Ga=ne('<!> <div data-content=""><!> <!></div> <!> <!>',1),Ja=ne('<li aria-atomic="true" role="status" data-sonner-toast=""><!> <!></li>');function Xa(P,r){const o=qt(r,["children","$$slots","$$events","$$legacy"]);yt(r,!1);const S=()=>he(le,"$heights",W),A=()=>he(t(de),"$effect",W),M=()=>he(q,"$toasts",W),[W,j]=Tt(),D=z(void 0,!0),ie=z(void 0,!0),k=z(void 0,!0),L=z(void 0,!0),T=z(void 0,!0),te=z(void 0,!0),Z=z(void 0,!0),Y=z(void 0,!0),Q=z(void 0,!0),Ee=z(void 0,!0),Ne=z(void 0,!0),ge=z(void 0,!0),_e=4e3,F=14,De=20,Qe=200,Ve=.05,$e={toast:"",title:"",description:"",loader:"",closeButton:"",cancelButton:"",actionButton:"",action:"",warning:"",error:"",success:"",default:"",info:"",loading:""},{toasts:q,heights:le,removeHeight:I,setHeight:be,remove:B}=ho;let n=N(r,"toast",9),C=N(r,"index",9),ee=N(r,"expanded",9),re=N(r,"invert",13),ve=N(r,"position",9),Te=N(r,"visibleToasts",9),ue=N(r,"expandByDefault",9),oe=N(r,"closeButton",9),ce=N(r,"interacting",9),Oe=N(r,"cancelButtonStyle",9,""),xe=N(r,"actionButtonStyle",9,""),Fe=N(r,"duration",9,4e3),Re=N(r,"descriptionClass",9,""),Se=N(r,"classes",29,()=>({})),H=N(r,"unstyled",9,!1),fe=z(!1,!0),je=z(!1,!0),Le=z(!1,!0),Ye=z(!1,!0),et=z(0,!0),Ae=z(0,!0),Ie=z(void 0,!0),He=z(0,!0),Ge=0,Ke=0,tt=null;async function ct(){if(!t(fe))return;await ht();let O;ee()||ue()?O=1:O=1-C()*Ve,t(Ie).style.setProperty("height","auto");const e=t(Ie).offsetHeight,a=t(Ie).getBoundingClientRect().height,g=Math.round((a/O+Number.EPSILON)*100)/100;t(Ie).style.removeProperty("height");let d;Math.abs(g-e)<1?d=g:d=e,s(Ae,d),be({toastId:n().id,height:d})}function Je(){s(je,!0),s(et,t(He)),I(n().id),setTimeout(()=>{B(n().id)},Qe)}let Xe=z(void 0,!0),nt=z(n().duration||Fe()||_e,!0);function dt(){if(Ke<Ge){const O=new Date().getTime()-Ge;s(nt,t(nt)-O)}Ke=new Date().getTime()}function rt(){Ge=new Date().getTime(),s(Xe,setTimeout(()=>{var O,e;(e=(O=n()).onAutoClose)==null||e.call(O,n()),Je()},t(nt)))}let de=z(void 0,!0);kt(()=>{s(fe,!0);const O=t(Ie).getBoundingClientRect().height;return s(Ae,O),be({toastId:n().id,height:O}),()=>I(n().id)});function Ze(O){if(t(Ne))return;s(et,t(He));const e=O.target;e.setPointerCapture(O.pointerId),e.tagName!=="BUTTON"&&(s(Le,!0),tt={x:O.clientX,y:O.clientY})}function Be(){var e,a,g;if(t(Ye))return;tt=null;const O=Number(((e=t(Ie))==null?void 0:e.style.getPropertyValue("--swipe-amount").replace("px",""))||0);if(Math.abs(O)>=De){s(et,t(He)),(g=(a=n()).onDismiss)==null||g.call(a,n()),Je(),s(Ye,!0);return}t(Ie).style.setProperty("--swipe-amount","0px"),s(Le,!1)}function ze(O){if(!tt)return;const e=O.clientY-tt.y,a=O.clientX-tt.x,d=(t(Q)[0]==="top"?Math.min:Math.max)(0,e),x=O.pointerType==="touch"?10:2;Math.abs(d)>x?t(Ie).style.setProperty("--swipe-amount",`${e}px`):Math.abs(a)>x&&(tt=null)}pe(()=>c(Se()),()=>{Se({...$e,...Se()})}),pe(()=>c(C()),()=>{s(D,C()===0)}),pe(()=>(c(C()),c(Te())),()=>{s(ie,C()+1<=Te())}),pe(()=>c(n()),()=>{s(k,n().title)}),pe(()=>c(n()),()=>{s(L,n().description)}),pe(()=>c(n()),()=>{s(T,n().type)}),pe(()=>c(n()),()=>{s(te,n().class||"")}),pe(()=>c(n()),()=>{s(Z,n().descriptionClass||"")}),pe(()=>(S(),c(n())),()=>{s(Y,S().findIndex(O=>O.toastId===n().id)||0)}),pe(()=>c(ve()),()=>{s(Q,ve().split("-"))}),pe(()=>(S(),t(Y)),()=>{s(Ee,S().reduce((O,e,a)=>a>=t(Y)?O:O+e.height,0))}),pe(()=>(c(re()),c(n())),()=>{re(n().invert||re())}),pe(()=>t(T),()=>{s(Ne,t(T)==="loading")}),pe(()=>(t(Y),t(Ee)),()=>{s(He,Math.round(t(Y)*F+t(Ee)))}),pe(()=>(t(k),t(L)),()=>{t(k),t(L),ct()}),pe(()=>(c(n()),t(Xe),c(Fe())),()=>{n().updated&&(clearTimeout(t(Xe)),s(nt,n().duration||Fe()||_e),rt())}),pe(()=>(c(n()),t(T)),()=>{s(ge,n().promise&&t(T)==="loading"||n().duration===Number.POSITIVE_INFINITY)}),pe(()=>(t(ge),c(ee()),c(ce()),t(Xe)),()=>{Co(s(de,Yo(()=>(t(ge)||(ee()||ce()?dt():rt()),()=>clearTimeout(t(Xe))))),"$effect",W)}),pe(()=>A(),()=>{A()}),pe(()=>c(n()),()=>{n().delete&&Je()}),$t(),Et(!0);var G=Ja();ye(G,"tabindex",0);let st;var _t=v(G);{var gt=O=>{var e=Wa();we(a=>{ye(e,"data-disabled",t(Ne)),lt(e,1,a)},[()=>bt((c(ot),c(Se()),c(n()),u(()=>{var a,g,d;return ot((a=Se())==null?void 0:a.closeButton,(d=(g=n())==null?void 0:g.classes)==null?void 0:d.closeButton)})))]),me("click",e,function(...a){var g;(g=t(Ne)?void 0:()=>{var d,x;
1Je(),(x=(d=n()).onDismiss)==null||x.call(d,n())})==null||g.apply(this,a)}),w(O,e)};ke(_t,O=>{c(oe()),c(n()),u(()=>oe()&&!n().component)&&O(gt)})}var St=R(_t,2);{var mt=O=>{var e=Ue(),a=Ce(e);Ct(a,()=>n().component,(g,d)=>{d(g,Ut(()=>n().componentProps,{$$events:{closeToast:Je}}))}),w(O,e)},vt=O=>{var e=Ga(),a=Ce(e);{var g=U=>{var y=ja(),p=v(y);{var l=ae=>{var Me=Ue(),We=Ce(Me);at(We,r,"loading-icon",{},null),w(ae,Me)};ke(p,ae=>{c(n()),t(T),u(()=>(n().promise||t(T)==="loading")&&!n().icon)&&ae(l)})}var h=R(p,2);{var i=ae=>{var Me=Ue(),We=Ce(Me);Ct(We,()=>n().icon,(Rt,Zt)=>{Zt(Rt,{})}),w(ae,Me)},b=ae=>{var Me=Ue(),We=Ce(Me);at(We,r,"success-icon",{},null),w(ae,Me)},K=ae=>{var Me=Ue(),We=Ce(Me);at(We,r,"error-icon",{},null),w(ae,Me)},Pe=ae=>{var Me=Ue(),We=Ce(Me);at(We,r,"warning-icon",{},null),w(ae,Me)},qe=ae=>{var Me=Ue(),We=Ce(Me);at(We,r,"info-icon",{},null),w(ae,Me)};ke(h,ae=>{c(n()),u(()=>n().icon)?ae(i):t(T)==="success"?ae(b,1):t(T)==="error"?ae(K,2):t(T)==="warning"?ae(Pe,3):t(T)==="info"&&ae(qe,4)})}f(y),w(U,y)};ke(a,U=>{t(T),c(n()),u(()=>t(T)!=="default"||n().icon||n().promise)&&U(g)})}var d=R(a,2),x=v(d);{var _=U=>{var y=Ya(),p=v(y);{var l=i=>{var b=Ue(),K=Ce(b);Ct(K,()=>n().title,(Pe,qe)=>{qe(Pe,Ut(()=>n().componentProps))}),w(i,b)},h=i=>{var b=Bt();we(()=>se(b,(c(n()),u(()=>n().title)))),w(i,b)};ke(p,i=>{c(n()),u(()=>typeof n().title!="string")?i(l):i(h,-1)})}f(y),we(i=>lt(y,1,i),[()=>bt((c(ot),c(Se()),c(n()),u(()=>{var i,b,K;return ot((i=Se())==null?void 0:i.title,(K=(b=n())==null?void 0:b.classes)==null?void 0:K.title)})))]),w(U,y)};ke(x,U=>{c(n()),u(()=>n().title)&&U(_)})}var J=R(x,2);{var m=U=>{var y=qa(),p=v(y);{var l=i=>{var b=Ue(),K=Ce(b);Ct(K,()=>n().description,(Pe,qe)=>{qe(Pe,Ut(()=>n().componentProps))}),w(i,b)},h=i=>{var b=Bt();we(()=>se(b,(c(n()),u(()=>n().description)))),w(i,b)};ke(p,i=>{c(n()),u(()=>typeof n().description!="string")?i(l):i(h,-1)})}f(y),we(i=>lt(y,1,i),[()=>bt((c(ot),c(Re()),t(Z),c(Se()),c(n()),u(()=>{var i,b;return ot(Re(),t(Z),(i=Se())==null?void 0:i.description,(b=n().classes)==null?void 0:b.description)})))]),w(U,y)};ke(J,U=>{c(n()),u(()=>n().description)&&U(m)})}f(d);var $=R(d,2);{var E=U=>{var y=Va(),p=v(y,!0);f(y),we(l=>{xt(y,Oe()),lt(y,1,l),se(p,(c(n()),u(()=>n().cancel.label)))},[()=>bt((c(ot),c(Se()),c(n()),u(()=>{var l,h,i;return ot((l=Se())==null?void 0:l.cancelButton,(i=(h=n())==null?void 0:h.classes)==null?void 0:i.cancelButton)})))]),me("click",y,()=>{var l;Je(),(l=n().cancel)!=null&&l.onClick&&n().cancel.onClick()}),w(U,y)};ke($,U=>{c(n()),u(()=>n().cancel)&&U(E)})}var V=R($,2);{var X=U=>{var y=Ka(),p=v(y,!0);f(y),we(l=>{xt(y,xe()),lt(y,1,l),se(p,(c(n()),u(()=>n().action.label)))},[()=>bt((c(ot),c(Se()),c(n()),u(()=>{var l,h,i;return ot((l=Se())==null?void 0:l.actionButton,(i=(h=n())==null?void 0:h.classes)==null?void 0:i.actionButton)})))]),me("click",y,l=>{var h;(h=n().action)==null||h.onClick(l),!l.defaultPrevented&&Je()}),w(U,y)};ke(V,U=>{c(n()),u(()=>n().action)&&U(X)})}w(O,e)};ke(St,O=>{c(n()),u(()=>n().component)?O(mt):O(vt,-1)})}f(G),Xt(G,O=>s(Ie,O),()=>t(Ie)),we((O,e,a)=>{ye(G,"aria-live",(c(n()),u(()=>n().important?"assertive":"polite"))),lt(G,1,O),ye(G,"data-styled",(c(n()),c(H()),u(()=>{var g;return!(n().component||(g=n())!=null&&g.unstyled||H())}))),ye(G,"data-mounted",t(fe)),ye(G,"data-promise",e),ye(G,"data-removed",t(je)),ye(G,"data-visible",t(ie)),ye(G,"data-y-position",(t(Q),u(()=>t(Q)[0]))),ye(G,"data-x-position",(t(Q),u(()=>t(Q)[1]))),ye(G,"data-index",C()),ye(G,"data-front",t(D)),ye(G,"data-swiping",t(Le)),ye(G,"data-type",t(T)),ye(G,"data-invert",re()),ye(G,"data-swipe-out",t(Ye)),ye(G,"data-expanded",a),st=xt(G,(c(o),c(n()),u(()=>`${o.style} ${n().style}`)),st,{"--index":C(),"--toasts-before":C(),"--z-index":(M(),c(C()),u(()=>M().length-C())),"--offset":`${t(je)?t(et):t(He)}px`,"--initial-height":`${t(Ae)}px`})},[()=>bt((c(ot),c(o),t(te),c(Se()),c(n()),t(T),u(()=>{var O,e,a,g,d,x;return ot(o.class,t(te),(O=Se())==null?void 0:O.toast,(a=(e=n())==null?void 0:e.classes)==null?void 0:a.toast,(g=Se())==null?void 0:g[t(T)],(x=(d=n())==null?void 0:d.classes)==null?void 0:x[t(T)])}))),()=>(c(n()),u(()=>!!n().promise)),()=>(c(ee()),c(ue()),t(fe),u(()=>!!(ee()||ue()&&t(fe))))]),me("pointerdown",G,Ze),me("pointerup",G,Be),me("pointermove",G,ze),w(P,G),wt(),j()}var Za=ne("<ol></ol>"),Qa=ne('<section class="svelte-nbs0zk"></section>');function en(P,r){const o=qt(r,["children","$$slots","$$events","$$legacy"]),S=qt(o,["invert","theme","position","hotkey","containerAriaLabel","richColors","expand","duration","visibleToasts","closeButton","toastOptions","offset","dir"]);yt(r,!1);const A=()=>he(n,"$toasts",W),M=()=>he(C,"$heights",W),[W,j]=Tt(),D=z(),ie=z(),k=3,L="32px",T=356,te=14,Z="dark",Y="light";function Q(H){return H!=="system"?H:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Z:Y}function Ee(){if(typeof window>"u"||typeof document>"u")return"ltr";const H=document.documentElement.getAttribute("dir");return H==="auto"||!H?window.getComputedStyle(document.documentElement).direction:H}let Ne=N(r,"invert",8,!1),ge=N(r,"theme",8,"light"),_e=N(r,"position",8,"bottom-right"),F=N(r,"hotkey",24,()=>["altKey","KeyT"]),De=N(r,"containerAriaLabel",8,"Notifications"),Qe=N(r,"richColors",8,!1),Ve=N(r,"expand",8,!1),$e=N(r,"duration",8,4e3),q=N(r,"visibleToasts",8,k),le=N(r,"closeButton",8,!1),I=N(r,"toastOptions",24,()=>({})),be=N(r,"offset",8,null),B=N(r,"dir",24,Ee);const{toasts:n,heights:C,reset:ee}=ho;let re=z(!1),ve=z(!1),Te=z(Q(ge())),ue=z(),oe=null,ce=!1;Gt(()=>{t(ue)&&oe&&(oe.focus({preventScroll:!0}),oe=null,ce=!1)}),kt(()=>{ee();const H=fe=>{var Le,Ye;F().every(et=>
1fe[et]||fe.code===et)&&(s(re,!0),(Le=t(ue))==null||Le.focus()),fe.code==="Escape"&&(document.activeElement===t(ue)||(Ye=t(ue))!=null&&Ye.contains(document.activeElement))&&s(re,!1)};return document.addEventListener("keydown",H),()=>{document.removeEventListener("keydown",H)}});function Oe(H){ce&&!H.currentTarget.contains(H.relatedTarget)&&(ce=!1,oe&&(oe.focus({preventScroll:!0}),oe=null))}function xe(H){ce||(ce=!0,oe=H.relatedTarget)}pe(()=>(c(_e()),A()),()=>{s(D,Array.from(new Set([_e(),...A().filter(H=>H.position).map(H=>H.position)].filter(Boolean))))}),pe(()=>c(F()),()=>{s(ie,F().join("+").replace(/Key/g,"").replace(/Digit/g,""))}),pe(()=>A(),()=>{A().length<=1&&s(re,!1)}),pe(()=>A(),()=>{const H=A().filter(fe=>fe.dismiss&&!fe.delete);if(H.length>0){const fe=A().map(je=>H.find(Ye=>Ye.id===je.id)?{...je,delete:!0}:je);n.set(fe)}}),pe(()=>c(ge()),()=>{if(ge()!=="system"&&s(Te,ge()),typeof window<"u"){ge()==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?s(Te,Z):s(Te,Y));const H=window.matchMedia("(prefers-color-scheme: dark)"),fe=({matches:je})=>{s(Te,je?Z:Y)};"addEventListener"in H?H.addEventListener("change",fe):H.addListener(fe)}}),$t(),Et();var Fe=Ue(),Re=Ce(Fe);{var Se=H=>{var fe=Qa();ye(fe,"tabindex",-1),Mt(fe,5,()=>t(D),Jt,(je,Le,Ye,et)=>{var Ae=Za();Ro(Ae,(Ie,He,Ge)=>({tabIndex:-1,class:(c(o),u(()=>o.class)),"data-sonner-toaster":!0,"data-theme":t(Te),"data-rich-colors":Qe(),dir:Ie,"data-y-position":He,"data-x-position":Ge,style:(c(o),u(()=>o.style)),...S,[Uo]:{"--front-toast-height":(M(),u(()=>{var Ke;return`${(Ke=M()[0])==null?void 0:Ke.height}px`})),"--offset":typeof be()=="number"?`${be()}px`:be()||L,"--width":`${T}px`,"--gap":`${te}px`}}),[()=>(c(B()),u(()=>B()==="auto"?Ee():B())),()=>(t(Le),u(()=>t(Le).split("-")[0])),()=>(t(Le),u(()=>t(Le).split("-")[1]))],void 0,void 0,"svelte-nbs0zk"),Mt(Ae,7,()=>(A(),t(Le),u(()=>A().filter(Ie=>!Ie.position&&Ye===0||Ie.position===t(Le)))),Ie=>Ie.id,(Ie,He,Ge,Ke)=>{{let tt=it(()=>(c(I()),u(()=>{var de;return((de=I())==null?void 0:de.actionButtonStyle)||""}))),ct=it(()=>(c(I()),u(()=>{var de;return((de=I())==null?void 0:de.cancelButtonStyle)||""}))),Je=it(()=>(c(I()),u(()=>{var de;return((de=I())==null?void 0:de.class)||""}))),Xe=it(()=>(c(I()),u(()=>{var de;return((de=I())==null?void 0:de.descriptionClass)||""}))),nt=it(()=>(c(I()),u(()=>I().classes||{}))),dt=it(()=>(c(I()),c($e()),u(()=>{var de;return((de=I())==null?void 0:de.duration)??$e()}))),rt=it(()=>(c(I()),u(()=>I().unstyled||!1)));Xa(Ie,{get index(){return t(Ge)},get toast(){return t(He)},get invert(){return Ne()},get visibleToasts(){return q()},get closeButton(){return le()},get interacting(){return t(ve)},get position(){return t(Le)},get expandByDefault(){return Ve()},get expanded(){return t(re)},get actionButtonStyle(){return t(tt)},get cancelButtonStyle(){return t(ct)},get class(){return t(Je)},get descriptionClass(){return t(Xe)},get classes(){return t(nt)},get duration(){return t(dt)},get unstyled(){return t(rt)},$$slots:{"loading-icon":(de,Ze)=>{var Be=Ue(),ze=Ce(Be);at(ze,r,"loading-icon",{},G=>{{let st=it(()=>(t(He),u(()=>t(He).type==="loading")));Ha(G,{get visible(){return t(st)}})}}),w(de,Be)},"success-icon":(de,Ze)=>{var Be=Ue(),ze=Ce(Be);at(ze,r,"success-icon",{},G=>{Nt(G,{type:"success"})}),w(de,Be)},"error-icon":(de,Ze)=>{var Be=Ue(),ze=Ce(Be);at(ze,r,"error-icon",{},G=>{Nt(G,{type:"error"})}),w(de,Be)},"warning-icon":(de,Ze)=>{var Be=Ue(),ze=Ce(Be);at(ze,r,"warning-icon",{},G=>{Nt(G,{type:"warning"})}),w(de,Be)},"info-icon":(de,Ze)=>{var Be=Ue(),ze=Ce(Be);at(ze,r,"info-icon",{},G=>{Nt(G,{type:"info"})}),w(de,Be)}}})}}),f(Ae),Xt(Ae,Ie=>s(ue,Ie),()=>t(ue)),we(()=>Ae.dir=Ae.dir),me("blur",Ae,Oe),me("focus",Ae,xe),me("mouseenter",Ae,()=>s(re,!0)),me("mousemove",Ae,()=>s(re,!0)),me("mouseleave",Ae,()=>{t(ve)||s(re,!1)}),me("pointerdown",Ae,()=>s(ve,!0)),me("pointerup",Ae,()=>s(ve,!1)),w(je,Ae)}),f(fe),we(()=>ye(fe,"aria-label",`${De()} ${t(ie)}`)),w(H,fe)};ke(Re,H=>{A(),u(()=>A().length>0)&&H(Se)})}w(P,Fe),wt(),j()}const tn={get current(){return la.current},check:ia.updated.check},on=tn,an=async(P,r)=>{const o=await wo(P),S=(o==null?void 0:o.OPENAI_API_BASE_URLS)??[],A=(o==null?void 0:o.OPENAI_API_KEYS)??[],M=(o==null?void 0:o.OPENAI_API_CONFIGS)??{},W=r.url.replace(/\/$/,"");return S.map(j=>j.replace(/\/$/,"")).includes(W)?o:(S.push(W),A.push(r.key??""),r.config&&(M[(S.length-1).toString()]=r.config),await _o(P,{ENABLE_OPENAI_API:(o==null?void 0:o.ENABLE_OPENAI_API)??!0,OPENAI_API_BASE_URLS:S,OPENAI_API_KEYS:A,OPENAI_API_CONFIGS:M}))},nn=async(P,r)=>{const o=await wo(P),S=(o==null?void 0:o.OPENAI_API_BASE_URLS)??[],A=(o==null?void 0:o.OPENAI_API_KEYS)??[],M=(o==null?void 0:o.OPENAI_API_CONFIGS)??{},W=r.replace(/\/$/,""),j=S.findIndex(L=>L.replace(/\/$/,"")===W);if(j===-1)return o;const D=S.filter((L,T)=>T!==j),ie=A.filter((L,T)=>T!==j),k={};return D.forEach((L,T)=>{k[T]=M[T<j?T:T+1]}),await _o(P,{ENABLE_OPENAI_API:(o==null?void 0:o.ENABLE_OPENAI_API)??!0,OPENAI_API_BASE_URLS:D,OPENAI_API_KEYS:ie,OPENAI_API_CONFIGS:k})},rn=async(P,r)=>{const o=await bo(P),S=(o==null?void 0:o.TERMINAL_SERVER_CONNECTIONS)??[];return S.find(A=>A.url===r.url)?o:(S.push({url:r.url,key:r.key??"",auth_type:r.auth_type??"bearer",n
1ame:r.name??"Open Terminal",enabled:!0}),await xo(P,{TERMINAL_SERVER_CONNECTIONS:S}))},sn=async(P,r)=>{const o=await bo(P),S=(o==null?void 0:o.TERMINAL_SERVER_CONNECTIONS)??[],A=S.filter(M=>M.url!==r);return A.length===S.length?o:await xo(P,{TERMINAL_SERVER_CONNECTIONS:A})};var ln=ne('<div class=" text-[0.8125rem] font-normal mb-0.5 line-clamp-1"> </div>'),cn=ne('<div role="status" aria-live="polite" class="group relative flex gap-2.5 text-left min-w-[var(--width)] w-full dark:bg-gray-850 dark:text-white bg-white text-black border border-gray-100 dark:border-gray-800 rounded-3xl px-4 py-3.5 cursor-pointer select-none"><button class="absolute -top-0.5 -left-0.5 p-0.5 rounded-full opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-opacity z-10" aria-label="Dismiss notification"><!></button> <div class="shrink-0 self-top -translate-y-0.5"><img alt="favicon" class="size-6 rounded-full"/></div> <div><!> <div class=" line-clamp-2 text-xs self-center dark:text-gray-300 font-normal"></div></div></div>');function Yt(P,r){yt(r,!1);const o=()=>he(yo,"$settings",M),S=()=>he(At,"$playingNotificationSound",M),A=()=>he(Lt,"$isLastActiveTab",M),[M,W]=Tt(),j=Oo();let D=N(r,"onClick",8,()=>{}),ie=N(r,"title",8,"HI"),k=N(r,"content",8),L=0,T=0,te=z(!1),Z=z();const Y=6,Q=()=>{D()(),j("closeToast")},Ee=()=>{j("closeToast")};function Ne(B){var n,C;L=B.clientX,T=B.clientY,s(te,!1),(C=(n=B.currentTarget).setPointerCapture)==null||C.call(n,B.pointerId)}function ge(B){if(t(te))return;const n=B.clientX-L,C=B.clientY-T;n*n+C*C>Y*Y&&s(te,!0)}function _e(B){var n,C;(C=(n=B.currentTarget).releasePointerCapture)==null||C.call(n,B.pointerId),!(t(Z)&&(B.target===t(Z)||t(Z).contains(B.target)))&&(t(te)||Q())}kt(()=>{var B;navigator.userActivation.hasBeenActive&&(((B=o())==null?void 0:B.notificationSound)??!0)&&!S()&&A()&&(At.set(!0),new Audio("/audio/notification.mp3").play().finally(()=>{At.set(!1)}))}),Et();var F=cn(),De=v(F),Qe=v(De);ko(Qe,{className:"size-3"}),f(De),Xt(De,B=>s(Z,B),()=>t(Z));var Ve=R(De,2),$e=v(Ve);f(Ve);var q=R(Ve,2),le=v(q);{var I=B=>{var n=ln(),C=v(n,!0);f(n),we(()=>se(C,ie())),w(B,n)};ke(le,B=>{ie()&&B(I)})}var be=R(le,2);Aa(be,()=>(c(jt),c(fo),c(k()),u(()=>jt.sanitize(fo(jt.sanitize(k(),{ALLOWED_TAGS:[]}))))),!0),f(be),f(q),f(F),we(()=>ye($e,"src",`${ft}/static/favicon.png`)),me("click",De,Ta(Ee)),me("dragstart",F,Pa(function(B){Ca.call(this,r,B)})),me("pointerdown",F,Ne),me("pointermove",F,ge),me("pointerup",F,_e),me("pointercancel",F,()=>s(te,!0)),me("keydown",F,B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),Q())}),w(P,F),wt(),W()}var po=ne('<div class="absolute top-0 left-0 flex h-full"><div class="my-auto rounded-r-lg w-1 h-8 bg-black dark:bg-white"></div></div>'),dn=ne('<button aria-label="Home"><img class="size-11 dark:invert p-0.5" alt="logo" draggable="false"/></button>'),un=ne('<nav aria-label="App navigation" class="min-w-[4.5rem] bg-gray-50 dark:bg-gray-950 flex gap-2.5 flex-col pt-8"><div class="flex justify-center relative"><!> <!></div> <div class=" -mt-1 border-[1.5px] border-gray-100 dark:border-gray-900 mx-4"></div> <div class="flex justify-center relative group"><!> <button aria-label="Chat" class=" cursor-pointer bg-transparent"><img alt="logo" draggable="false"/></button></div></nav>');function fn(P){let r=z("");var o=un(),S=v(o),A=v(S);{var M=T=>{var te=po();w(T,te)};ke(A,T=>{t(r)==="home"&&T(M)})}var W=R(A,2);Eo(W,{content:"Home",placement:"right",children:(T,te)=>{var Z=dn(),Y=v(Z);f(Z),we(()=>{lt(Z,1,` cursor-pointer ${t(r)==="home"?"rounded-2xl":"rounded-full"}`),ye(Y,"src",`${ft}/static/splash.png`)}),me("click",Z,()=>{s(r,"home"),window.electronAPI&&window.electronAPI.load("home")}),w(T,Z)},$$slots:{default:!0}}),f(S);var j=R(S,4),D=v(j);{var ie=T=>{var te=po();w(T,te)};ke(D,T=>{t(r)===""&&T(ie)})}var k=R(D,2),L=v(k);f(k),f(j),f(o),we(()=>{ye(L,"src",`${ft}/static/favicon.png`),lt(L,1,`size-10 ${t(r)===""?"rounded-2xl":"rounded-full"}`)}),me("click",k,()=>{s(r,"")}),w(P,o)}var gn=ne('<div class="confetti svelte-rtt661"></div>'),mn=ne("<div></div>");function vn(P,r){yt(r,!0);const o=N(r,"size",3,10),S=N(r,"x",19,()=>[-.5,.5]),A=N(r,"y",19,()=>[.25,1]),M=N(r,"duration",3,2e3),W=N(r,"infinite",3,!1),j=N(r,"delay",19,()=>[0,50]),D=N(r,"colorRange",19,()=>[0,360]),ie=N(r,"colorArray",19,()=>[]),k=N(r,"amount",3,50),L=N(r,"iterationCount",3,1),T=N(r,"fallDistance",3,"100px"),te=N(r,"rounded",3,!1),Z=N(r,"cone",3,!1),Y=N(r,"noGravity",3,!1),Q=N(r,"xSpread",3,.15),Ee=N(r,"de
1stroyOnComplete",3,!0),Ne=N(r,"disableForReducedMotion",3,!1);let ge=No(!1);kt(()=>{!Ee()||W()||typeof L()=="string"||setTimeout(()=>s(ge,!0),(M()+j()[1])*L())});function _e($e,q){return Math.random()*(q-$e)+$e}function F(){return ie().length?ie()[Math.round(Math.random()*(ie().length-1))]:`hsl(${Math.round(_e(D()[0],D()[1]))}, 75%, 50%)`}var De=Ue(),Qe=Ce(De);{var Ve=$e=>{var q=mn();let le;Mt(q,21,()=>({length:k()}),Jt,(I,be)=>{var B=gn();we((n,C,ee,re,ve,Te,ue,oe,ce,Oe,xe)=>xt(B,` 2 --color: ${n??""}; 3 --skew: ${C??""}deg,${ee??""}deg; 4 --rotation-xyz: ${re??""}, ${ve??""}, ${Te??""}; 5 --rotation-deg: ${ue??""}deg; 6 --translate-y-multiplier: ${oe??""}; 7 --translate-x-multiplier: ${ce??""}; 8 --scale: ${Oe??""}; 9 --transition-delay: ${xe??""}ms; 10 --transition-duration: ${W()?`calc(${M()}ms * var(--scale))`:`${M()}ms`};`),[()=>F(),()=>_e(-45,45),()=>_e(-45,45),()=>_e(-10,10),()=>_e(-10,10),()=>_e(-10,10),()=>_e(0,360),()=>_e(A()[0],A()[1]),()=>_e(S()[0],S()[1]),()=>.1*_e(2,10),()=>_e(j()[0],j()[1])]),w(I,B)}),f(q),we(()=>{le=lt(q,1,"confetti-holder svelte-rtt661",null,le,{rounded:te(),cone:Z(),"no-gravity":Y(),"reduced-motion":Ne()}),xt(q,` 11 --fall-distance: ${T()??""}; 12 --size: ${o()??""}px; 13 --x-spread: ${1-Q()}; 14 --transition-iteration-count: ${(W()?"infinite":L())??""};`)}),w($e,q)};ke(Qe,$e=>{t(ge)||$e(Ve)})}w(P,De),wt()}var pn=ne('<div class="px-5.5 py-5"><div class="mb-1 text-xl font-normal"> </div> <div class="mb-3 text-xs text-gray-500"> </div> <!> <div class="flex justify-end"><button class="flex items-center justify-center gap-2 rounded-full bg-black px-4 py-2 text-sm text-white transition hover:bg-gray-900 dark:bg-white dark:text-black dark:hover:bg-gray-100"> </button></div></div>'),hn=ne('<div class="px-5.5 py-5"><div class="mb-1 text-xl font-normal"> </div> <div class="mb-3 text-xs text-gray-500"> </div> <div class="flex justify-end"><button class="flex items-center justify-center gap-2 rounded-full bg-black px-4 py-2 text-sm text-white transition hover:bg-gray-900 dark:bg-white dark:text-black dark:hover:bg-gray-100"> </button></div></div>'),yn=ne('<label class="flex items-center gap-2 text-xs cursor-pointer"><input type="checkbox" class="w-4 h-4 rounded border-gray-300 dark:border-gray-600"/> <span class="text-gray-700 dark:text-gray-300"> </span></label>'),wn=ne('<div class="mt-3"><!></div>'),_n=ne('<div class="bg-gray-900 dark:bg-gray-100 h-1.5 rounded-full transition-all duration-300"></div>'),bn=ne('<div class="bg-gray-900 dark:bg-gray-100 h-1.5 w-0 rounded-full animate-pulse"></div>'),xn=ne('<div class="mt-3 mx-1.5"><div class="text-xs text-gray-500 mb-1 flex justify-between"><div> </div> <div><!></div></div> <div class="w-full bg-gray-200 rounded-full h-1.5 dark:bg-gray-700 overflow-hidden"><!></div></div>'),kn=ne('<div class="flex items-center gap-2"><!> <span> </span></div>'),En=ne('<div class="flex justify-between px-4 pt-3 pb-1"><div class="text-sm font-medium self-center"> </div>
14 <button class="self-center rounded-lg p-1 text-gray-500 transition hover:bg-gray-50 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200"><!></button></div> <div class="px-5 pt-2 pb-5"><div class="text-sm text-gray-500 dark:text-gray-400"> </div> <div class="mt-2 text-xs text-gray-500"> </div> <div class="mt-3 text-xs text-gray-500"><div class="mb-1 font-normal text-gray-600 dark:text-gray-400"> </div> <ul class="list-disc list-inside space-y-0.5 ml-1 mb-2"><li> </li> <li> </li> <li> </li> <li> </li> <li> </li></ul> <div class="mb-1 font-normal text-gray-600 dark:text-gray-400"> </div> <ul class="list-disc list-inside space-y-0.5 ml-1"><li> </li> <li> </li> <li> </li></ul></div> <!> <!> <div class="mt-4 flex items-center justify-between gap-2"><div class="text-xs text-gray-400 text-center mr-auto"><button class="hover:underline px-2" type="button"> </button></div> <button class="rounded-full bg-gray-100 px-4 py-2 text-sm font-normal text-gray-600 transition hover:bg-gray-200 disabled:cursor-not-allowed dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700"> </button> <button class="px-3.5 py-1.5 text-sm font-normal bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition-colors rounded-full"><!></button></div></div>',1),Sn=ne('<div class="w-full"><!></div>');function In(P,r){yt(r,!1);const o=()=>he(W,"$i18n",S),[S,A]=Tt(),M=z(),W=Lo("i18n");let j=N(r,"show",12,!1),D=N(r,"eventData",8,null);const ie=async q=>{var I,be,B,n;const le=((be=(I=q.data)==null?void 0:I.data)==null?void 0:be.id)??((B=q.data)==null?void 0:B.id);if(((n=q.data)==null?void 0:n.type)==="verify:chat"&&le)try{const C=await qo(localStorage.token,le);C&&window.opener&&window.opener.postMessage({type:"verify:chat:response",data:C,chatId:le,requestId:q.data.requestId??null},"*")}catch(C){window.opener&&window.opener.postMessage({type:"verify:chat:error",error:(C==null?void 0:C.detail)||(C==null?void 0:C.message)||"Failed to verify chat",chatId:le,requestId:q.data.requestId??null},"*")}};kt(()=>{window.addEventListener("message",ie)}),Gt(()=>{window.removeEventListener("message",ie)});let k=z(!1),L=z(!1),T=z(!1),te=z(!1),Z=z(""),Y=z(0),Q=z(0),Ee=null,Ne=z("incremental");const ge=q=>{var le;window.opener&&window.opener.postMessage({...q,requestId:((le=D())==null?void 0:le.requestId)??null},"*")},_e=()=>{s(k,!1),s(L,!1),s(T,!1),s(te,!1),s(Z,""),s(Y,0),s(Q,0),Ee=null},F=q=>{s(Z,q),s(te,!0),s(k,!1),s(L,!1),ge({type:"sync:error",error:q})},De=()=>{Ee&&(Ee.abort(),Ee=null),s(k,!1),s(L,!1),ge({type:"sync:error",error:"User cancelled the operation"})},Qe=async()=>{var q,le;window.opener&&window.opener.focus(),ge({type:"sync:start"}),s(k,!0),s(te,!1),s(Z,""),s(Y,0),s(Q,0);try{const I=await Vt(localStorage.token).catch(n=>null);I&&ge({type:"sync:version",data:I});let be=1,B=!1;for(;!B;){const n={...((q=D())==null?void 0:q.searchParams)??{}};t(Ne)==="incremental"&&((le=D())!=null&&le.lastSyncedChatUpdatedAt)&&(n.updated_at=D().lastSyncedChatUpdatedAt);const C=await to(localStorage.token,be,n).catch(ee=>{throw new Error((ee==null?void 0:ee.detail)||(ee==null?void 0:ee.message)||"Failed to export chat stats")});if(!C)throw new Error("Failed to fetch stats data");s(Y,t(Y)+C.items.length),s(Q,C.total),await ht(),window.opener&&C.items.length>0&&ge({type:"sync:stats:chats",data:C}),t(Y)>=t(Q)||C.items.length===0?B=!0:be+=1}ge({type:"sync:complete"}),s(k,!1),s(T,!0)}catch(I){F((I==null?void 0:I.message)||"An unexpected error occurred")}},Ve=async()=>{var q,le;if(t(L)){De();return}s(L,!0),s(k,!0),s(te,!1),s(Z,""),s(Y,0),s(Q,0);try{const I=await to(localStorage.token,1,{}).catch(()=>null);I!=null&&I.total&&s(Q,I.total),await ht();const be=await Vt(localStorage.token).catch(()=>null),n=`open-webui-stats-${(be==null?void 0:be.version)??"0.0.0"}-${Date.now()}.json`,C=((q=D())==null?void 0:q.searchParams)??{},[ee,re]=await Vo(localStorage.token,C.updated_at).catch(ce=>{throw new Error((ce==null?void 0:ce.detail)||"Failed to connect to the server. Please check your connection.")});if(!ee)throw new Error("Failed to start download. The server may be unavailable.");Ee=re;const ve=ee.body.getReader(),Te=new TextDecoder,ue=[];let oe="";for(;;){const{done:ce,value:Oe}=await ve.read();if(ce)break;oe+=Te.decode(Oe,{stream:!0});const xe=oe.split(` 15`);oe=xe.pop()||"";for(const Fe of xe)if(Fe.trim()!=="")try{ue.push(JSON.parse(Fe)),s(Y,t(Y)+1)}catch(Re){}await ht()}if(oe.trim()!=="")try{ue.push(JSON.parse(oe)),s(Y,t(Y)+1)}catch(ce){}if(t(L)){const ce=new Blob([JSON.stringify(ue)],{type:"application/json"}),Oe=window.URL.createObjectURL(ce),xe=document.createElement("a");xe.href=Oe,xe.download=n,document.body.appendChild(xe),xe.click(),document.body.removeChild(xe),window.URL.revokeObjectURL(Oe)}}catch(I){(I==null?void 0:I.name)==="AbortError"||(le=I==null?void 0:I.message)!=null&&le.includes("aborted")||(F((I==null?void 0:I.message)||"Download failed. Please try again."),ut.error(t(Z)))}finally{s(L,!1),s(k,!1),Ee=null}},$e=()=>{j(!1),_e()};pe(()=>c(j()),()=>{j()&&window.opener&&window.opener.postMessage("loaded","*")}),pe(()=>(t(Q),t(Y)),()=>{s(M,t(Q)>0?Math.min(Math.round(t(Y)/t(Q)*100),100):0)}),$t(),Et(),Oa(P,{size:"md",className:"bg-white dark:bg-gray-900 rounded-4xl",get show(){return j()},set show(q){j(q)},children:(q,le)=>{var I=Sn(),be=v(I);{var B=ee=>{var re=pn(),ve=v(re),Te=v(ve,!0);f(ve);var ue=R(ve,2),oe=v(ue,!0);f(ue);var ce=R(ue,2);vn(ce,{x:[-.5,.5],y:[.25,1]});var Oe=R(ce,2),xe=v(Oe),Fe=v(xe,!0);f(xe),f(Oe),f(re),we((Re,Se,H)=>{se(Te,Re),se(oe,Se),se(Fe,H)},[()=>(o(),u(()=>o().t("Sync Complete!"))),()=>(o(),u(()=>o().t("Your usage stats have been successfully synced."))),()=>(o(),u(()=>o().t("Done")))]),me("click",xe,$e),w(ee,re)},n=ee=>{var re=hn(),ve=v(re),Te=v(ve,!0);f(ve);var ue=R(ve,2),oe=v(ue,!0);f(ue);var ce=R(ue,2),Oe=v(ce),xe=v(Oe,!0);f(Oe),f(ce),f(re),we((Fe,Re,Se)=>{se(Te,Fe),se(oe,Re),se(xe,Se)},[()=>(o(),u(()=>o().t("Sync Failed"))),()=>(t(Z),o(),u(()=>t(Z)||o().t("There was an error syncing your stats. Please try again."))),()=>(o(),u(()=>o().t("Try Again")))]),me("click",Oe,()=>{s(te,!1),s(Z,"")}),w(ee,re)},C=ee=>{var re=En(),ve=Ce(re),Te=v(ve),ue=v(Te,!0);f(Te);var oe=R(Te,2),ce=v(oe);ko(ce,{className:"size-4"}),f(oe),f(ve);var Oe=R(ve,2),xe=v(Oe),Fe=v(xe,!0);f(xe);var Re=R(xe,2),Se=v(Re,!0);f(Re);var H=R(Re,2),fe=v(H),je=v(fe,!0);f(fe);var Le=R(fe,2),Ye=v(Le),et=v(Ye,!0);f(Ye);var Ae=R(Ye,2),Ie=v(Ae,!0);f(Ae);var He=R(Ae,2),Ge=v(He,!0);f(He);var Ke=R(He,2),tt=v(Ke,!0);f(Ke);var ct=R(Ke,2),Je=v(ct,!0);f(ct),f(Le);var Xe=R(Le,2),nt=v(Xe,!0);f(Xe);var dt=R(Xe,2),rt=v(dt),de=v(rt,!0);f(rt);var Ze=R(rt,2),Be=v(Ze,!0);f(Ze);var ze=R(Ze,2),G=v(ze,!0);f(ze),f(dt),f(H);var st=R(H,2);{var _t=m=>{var $=wn(),E=v($);{let V=it(()=>(o(),u(()=>o().t("Syncs only chats with updates after your last sync timestamp. Disable to re-sync all chats."))));Eo(E,{get content(){return t(V)},placement:"top-start",children:(X,U)=>{var y=yn(),p=v(y);zo(p);var l=R(p,2),h=v(l,!0);f(l),f(y),we(i=>{Fo(p,t(Ne)==="incremental"),p.disabled=t(k),se(h,i)},[()=>(o(),u(()=>o().t("Only sync new/updated chats")))]),me("change",p,i=>s(Ne,i.target.checked?"incremental":"full")),w(X,y)},$$slots:{default:!0}})}f($),w(m,$)};ke(st,m=>{c(D()),u(()=>{var $;return($=D())==null?void 0:$.lastSyncedChatUpdatedAt})&&m(_t)})}var gt=R(st,2);{var St=m=>{var $=xn(),E=v($),V=v(E),X=v(V,!0);f(V);var U=R(V,2),y=v(U);{var p=K=>{var Pe=Bt();we(()=>se(Pe,`${t(Y)??""}/${t(Q)??""}`)),w(K,Pe)}
15;ke(y,K=>{t(Q)>0&&K(p)})}f(U),f(E);var l=R(E,2),h=v(l);{var i=K=>{var Pe=_n();we(()=>xt(Pe,`width: ${t(M)??""}%`)),w(K,Pe)},b=K=>{var Pe=bn();w(K,Pe)};ke(h,K=>{t(Q)>0?K(i):K(b,-1)})}f(l),f($),we(K=>se(X,K),[()=>(t(L),o(),u(()=>t(L)?o().t("Downloading stats..."):o().t("Syncing stats...")))]),w(m,$)};ke(gt,m=>{t(k)&&m(St)})}var mt=R(gt,2),vt=v(mt),O=v(vt),e=v(O,!0);f(O),f(vt);var a=R(vt,2),g=v(a,!0);f(a);var d=R(a,2),x=v(d);{var _=m=>{var $=kn(),E=v($);So(E,{className:"size-3"});var V=R(E,2),X=v(V,!0);f(V),f($),we(U=>se(X,U),[()=>(o(),u(()=>o().t("Syncing...")))]),w(m,$)},J=m=>{var $=Bt();we(E=>se($,E),[()=>(o(),u(()=>o().t("Sync")))]),w(m,$)};ke(x,m=>{t(k)&&!t(L)?m(_):m(J,-1)})}f(d),f(mt),f(Oe),we((m,$,E,V,X,U,y,p,l,h,i,b,K,Pe,qe,ae)=>{se(ue,m),ye(oe,"aria-label",$),oe.disabled=t(k),se(Fe,E),se(Se,V),se(je,X),se(et,U),se(Ie,y),se(Ge,p),se(tt,l),se(Je,h),se(nt,i),se(de,b),se(Be,K),se(G,Pe),O.disabled=t(k)&&!t(L),se(e,qe),se(g,ae),d.disabled=t(k)},[()=>(o(),u(()=>o().t("Sync Usage Stats"))),()=>(o(),u(()=>o().t("Close modal"))),()=>(o(),u(()=>o().t("Do you want to sync your usage stats with Open WebUI Community?"))),()=>(o(),u(()=>o().t("Participate in community leaderboards and evaluations! Syncing aggregated usage stats helps drive research and improvements to Open WebUI. Your privacy is paramount: no message content is ever shared."))),()=>(o(),u(()=>o().t("What is shared:"))),()=>(o(),u(()=>o().t("Open WebUI version"))),()=>(o(),u(()=>o().t("Model names and usage frequency"))),()=>(o(),u(()=>o().t("Message counts and response timestamps"))),()=>(o(),u(()=>o().t("Content lengths (character counts only)"))),()=>(o(),u(()=>o().t("User ratings (thumbs up/down)"))),()=>(o(),u(()=>o().t("What is NOT shared:"))),()=>(o(),u(()=>o().t("Your message text or inputs"))),()=>(o(),u(()=>o().t("Model responses or outputs"))),()=>(o(),u(()=>o().t("Uploaded files or images"))),()=>(t(L),o(),u(()=>t(L)?o().t("Stop Download"):o().t("Download as JSON"))),()=>(o(),u(()=>o().t("Cancel")))]),me("click",oe,()=>{j(!1)}),me("click",O,Ve),me("click",a,()=>{t(k)?De():j(!1)}),me("click",d,Qe),w(ee,re)};ke(be,ee=>{t(T)?ee(B):t(te)?ee(n,1):ee(C,-1)})}f(I),w(q,I)},$$slots:{default:!0},$$legacy:!0}),wt(),A()}var An=ne('<link crossorigin="anonymous" rel="icon"/> <meta name="apple-mobile-web-app-title"/> <meta name="description"/> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" crossorigin="use-credentials"/>',1),Tn=ne('<div class=" py-5"><!></div>'),Pn=ne('<div class="flex flex-row h-screen"><!> <div class="w-full flex-1 max-w-[calc(100%-4.5rem)]"><!></div></div>'),Cn=ne('<a href="#main-content" class="sr-only focus:not-sr-only focus:absolute focus:top-2 focus:left-2 focus:z-[9999] focus:rounded-lg focus:bg-white focus:px-4 focus:py-2 focus:text-sm focus:font-medium focus:text-gray-900 focus:shadow-lg dark:focus:bg-gray-800 dark:focus:text-gray-100"> </a> <!> <!> <!> <!>',1);function mr(P,r){yt(r,!1);const o=()=>he(ro,"$socket",F),S=()=>he(co,"$i18n",F),A=()=>he(io,"$WEBUI_VERSION",F),M=()=>he(so,"$WEBUI_DEPLOYMENT_ID",F),W=()=>he(Ht,"$config",F),j=()=>he(Wt,"$pyodideWorker",F),D=()=>he(yo,"$settings",F),ie=()=>he(oa,"$toolServers",F),k=()=>he(aa,"$terminalServers",F),L=()=>he(da,"$page",F),T=()=>he(Zo,"$chatId",F),te=()=>he(Lt,"$isLastActiveTab",F),Z=()=>he(ea,"$temporaryChatEnabled",F),Y=()=>he(It,"$user",F),Q=()=>he(Ot,"$channels",F),Ee=()=>he(ta,"$channelId",F),Ne=()=>he(ao,"$WEBUI_NAME",F),ge=()=>he(oo,"$isApp",F),_e=()=>he(zt,"$theme",F),[F,De]=Tt();let Qe=Ma(0,{stiffness:.05});const Ve=async()=>{if("serviceWorker"in navigator)try{const e=await navigator.serviceWorker.getRegistrations();return await Promise.all(e.map(a=>a.unregister())),!0}catch(e){return!1}return!1};ca(async({willUnload:e,to:a})=>{on.current&&!e&&(a!=null&&a.url)&&(await Ve(),location.href=a.url.href)}),Bo("i18n",co);const $e=new BroadcastChannel("active-tab-channel");let q=z(!1),le=null,I=!1,be=z(!1),B=z(!1),n=z(null),C=null,ee=null,re=!1,ve=!0,Te=!1,ue=Date.now(),oe=null;const ce=768,Oe=2e3,xe=8e3,Fe=new Set(["ping timeout","transport close","transport error"]),Re=()=>{ee&&(clearTimeout(ee),ee=null)},Se=()=>Te&&Date.now()-ue<xe,H=e=>(!ve||Se())&&Fe.has(e),fe=()=>{Re();const e=H(oe)?Math.max(xe-(Date.now()-ue),0):0;ee=setTimeout(()=>{var a;ee=null,!((a=o())!=null&&a.connected||!ve||H(oe))&&(re=!0,ut.warning(S().t("Connection lost. Reconnecting...")))},e+Oe)},je=async e=>{const a=Ho(`${ft}`||void 0,{reconnection:!0,reconnectionDelay:1e3,reconnectionDelayMax:5e3,randomizationFactor:.5,path:"/ws/socket.io",transports:e?["websocket"]:["polling","websocket"],auth:{token:localStorage.token}});await ro.set(a),a.on("connect_error",d=>{});let g=!1;a.on("connect",async()=>{var J,m;a.id,Re(),g&&(lo.set(!0),re&&ut.success(S().t("Reconnected"))),re=!1,oe=null,g=!0;const d=await Vt(localStorage.token),x=(d==null?void 0:d.deployment_id)??null,_=(d==null?void 0:d.version)??null;if((_!==null||x!==null)&&(A()!==null&&_!==A()||M()!==null&&x!==M())){await Ve(),location.href=location.href;return}C=setInterval(()=>{a.connected&&a.emit("heartbeat",{})},(((m=(J=W())==null?void 0:J.features)==null?void 0:m.websocket_heartbeat_interval)??30)*1e3),x!==null&&so.set(
15x),_!==null&&(io.set(_),window.WEBUI_VERSION=_),localStorage.getItem("token")?a.emit("user-join",{auth:{token:localStorage.token}}):console.warn("No token found in localStorage, user-join event not emitted")}),a.on("reconnect_attempt",d=>{}),a.on("reconnect_failed",()=>{}),a.on("disconnect",(d,x)=>{`${a.id}${d}`,lo.set(!1),oe=d,re=!1,H(d)?Re():fe(),C&&(clearInterval(C),C=null),d==="io server disconnect"&&a.connect()})},Le=()=>{let e=j();return e||(e=jo(),Wt.set(e)),e},Ye=async(e,a,g,d=[])=>{let x=null,_=null,J=null,m=!0,$=[/\bimport\s+requests\b|\bfrom\s+requests\b/.test(a)?"requests":null,/\bimport\s+bs4\b|\bfrom\s+bs4\b/.test(a)?"beautifulsoup4":null,/\bimport\s+numpy\b|\bfrom\s+numpy\b/.test(a)?"numpy":null,/\bimport\s+pandas\b|\bfrom\s+pandas\b/.test(a)?"pandas":null,/\bimport\s+matplotlib\b|\bfrom\s+matplotlib\b/.test(a)?"matplotlib":null,/\bimport\s+seaborn\b|\bfrom\s+seaborn\b/.test(a)?"seaborn":null,/\bimport\s+sklearn\b|\bfrom\s+sklearn\b/.test(a)?"scikit-learn":null,/\bimport\s+scipy\b|\bfrom\s+scipy\b/.test(a)?"scipy":null,/\bimport\s+re\b|\bfrom\s+re\b/.test(a)?"regex":null,/\bimport\s+seaborn\b|\bfrom\s+seaborn\b/.test(a)?"seaborn":null,/\bimport\s+sympy\b|\bfrom\s+sympy\b/.test(a)?"sympy":null,/\bimport\s+tiktoken\b|\bfrom\s+tiktoken\b/.test(a)?"tiktoken":null,/\bimport\s+pytz\b|\bfrom\s+pytz\b/.test(a)?"pytz":null].filter(Boolean);const E=Le();let V=[];if(d&&d.length>0)for(const p of d)try{const l=p==null?void 0:p.id,h=(p==null?void 0:p.filename)||(p==null?void 0:p.name)||"file";if(l){const i=await sa(l);i&&V.push({name:h,data:i})}}catch(l){}E.postMessage({type:"execute",id:e,code:a,packages:$,files:V.length>0?V:void 0});let X=setTimeout(()=>{m&&(m=!1,J="Execution Time Limit Exceeded",E.terminate(),Wt.set(null),g&&g(JSON.parse(JSON.stringify({stdout:_,stderr:J,result:x},(p,l)=>typeof l=="bigint"?l.toString():l))))},6e4);const U=p=>{const{id:l,...h}=p.data;l===e&&(h.type&&h.type.startsWith("fs:")||(clearTimeout(X),E.removeEventListener("message",U),E.removeEventListener("error",y),h.stdout&&(_=h.stdout),h.stderr&&(J=h.stderr),h.result&&(x=h.result),g&&g(JSON.parse(JSON.stringify({stdout:_,stderr:J,result:x},(i,b)=>typeof b=="bigint"?b.toString():b))),m=!1))},y=p=>{clearTimeout(X),E.removeEventListener("message",U),E.removeEventListener("error",y),g&&g(JSON.parse(JSON.stringify({stdout:_,stderr:J,result:x},(l,h)=>typeof h=="bigint"?h.toString():h))),m=!1};E.addEventListener("message",U),E.addEventListener("error",y)},et=e=>{var x,_,J,m,$;let a=(_=(x=D())==null?void 0:x.toolServers)==null?void 0:_.find(E=>E.url===e);if(!a){const E=(((J=D())==null?void 0:J.terminalServers)??[]).find(V=>V.url===e);E&&(a={url:E.url,auth_type:E.auth_type??"bearer",key:E.key??"",path:E.path??"/openapi.json"})}let g=((m=ie())==null?void 0:m.find(E=>E.url===e))??(($=k())==null?void 0:$.find(E=>E.url===e)),d=null;if(a){const E=(a==null?void 0:a.auth_type)??"bearer";E==="bearer"?d=a==null?void 0:a.key:E==="session"&&(d=localStorage.token)}return{toolServer:a,toolServerData:g,token:d}},Ae=e=>{var a;return!!e&&((((a=D())==null?void 0:a.terminalServers)??[]).some(g=>g.url===e)||(k()??[]).some(g=>!g.id&&g.url===e))},Ie=(e,a,g,d)=>{const x=(e==null?void 0:e.path)??(a==null?void 0:a.path),_=(e==null?void 0:e.name)??String(x??"").split("/").filter(Boolean).at(-1)??"file",J=(e==null?void 0:e.content_type)??(e==null?void 0:e.mime_type)??"application/octet-stream";return{...e??{},type:"file",source:"open_terminal",displayed:!0,terminal_selector:g,terminal_url:g,session_id:d,path:x,full_path:(e==null?void 0:e.full_path)??x,name:_,mime_type:J,content_type:J,page:(e==null?void 0:e.page)??(a==null?void 0:a.page)}},He=async(e,a,g)=>{var E,V,X,U,y;const{toolServer:d,toolServerData:x,token:_}=et((E=e.server)==null?void 0:E.url),m=(e==null?void 0:e.name)==="display_file"&&((V=e==null?void 0:e.params)==null?void 0:V.path)&&((X=e==null?void 0:e.params)==null?void 0:X.inline)===void 0&&((U=D())==null?void 0:U.terminalFileDisplay)==="inline"&&Ae((y=e.server)==null?void 0:y.url)?{...e.params,inline:!0}:e==null?void 0:e.params,$=(e==null?void 0:e.name)==="display_file"&&m?{...m}:m;if($&&(e==null?void 0:e.name)==="display_file"&&delete $.page,d){const p=await va(_,d.url,e==null?void 0:e.name,$,x,g),l=Array.isArray(p)?p[0]:p,h=(e==null?void 0:e.name)==="display_file"&&(m==null?void 0:m.path)&&(m==null?void 0:m.inline)===!0,i=h&&(l==null?void 0:l.exists)!==!1?Array.isArray(p)?[Ie(l,m,d.url,g)]:Ie(l,m,d.url,g):p;(e==null?void 0:e.name)==="display_file"&&(m!=null&&m.path)&&!h&&(l==null?void 0:l.exists)!==!1&&Ia(m.path,{showControls:na,showFileNavPath:ra},{page:m==null?void 0:m.page}),["write_file"].includes(e==null?void 0:e.name)&&(m!=null&&m.path)&&Qo.set((l==null?void 0:l.path)??m.path),a&&a(structuredClone(i))}else a&&a({error:"Tool Server Not Found"})},Ge=async(e,a)=>{var J,m,$,E,V,X,U;if(L().url.pathname.includes(`/c/${e.chat_id}`),_a(e.chat_id)&&e.chat_id!==T())return;let d=document.visibilityState!=="visible";if(window.electronAPI){const y=await window.electronAPI.send({type:"window:isF
15ocused"});y&&(d=!y.isFocused)}await ht();const x=((J=e==null?void 0:e.data)==null?void 0:J.type)??null,_=((m=e==null?void 0:e.data)==null?void 0:m.data)??null;if(x==="calendar:alert"&&_){const y=_.minutes_until<=0?S().t("Starting now"):_.minutes_until===1?S().t("Starting in 1 minute"):S().t("Starting in {{count}} minutes",{count:_.minutes_until});ut.custom(Yt,{componentProps:{onClick:()=>{pt("/calendar")},title:_.title,content:y},duration:3e4,unstyled:!0}),te()&&((($=D())==null?void 0:$.notificationEnabled)??!1)&&new Notification(`${_.title} / Open WebUI`,{body:y,icon:`${ft}/static/favicon.png`});return}if((_==null?void 0:_.session_id)===o().id){if(x==="execute:python"){Ye(_.id,_.code,a,_.files||[]);return}else if(x==="execute:tool"){He(_,a,e.chat_id);return}else if(x==="request:chat:completion"){o().id;const{session_id:y,channel:p,form_data:l,model:h}=_;try{const i=((E=D())==null?void 0:E.directConnections)??{};if(i){const b=h==null?void 0:h.urlIdx,K=i.OPENAI_API_BASE_URLS[b],Pe=i.OPENAI_API_KEYS[b],qe=i.OPENAI_API_CONFIGS[b];try{if(qe!=null&&qe.prefix_id){const We=qe.prefix_id;l.model=l.model.replace(`${We}.`,"")}const[ae,Me]=await wa(Pe,l,K);if(ae){if(!ae.ok)throw await ae.json();if((l==null?void 0:l.stream)??!1){a({status:!0});const We=ae.body.getReader(),Rt=new TextDecoder;await(async()=>{var Qt;for(;;){const{done:Io,value:Ao}=await We.read();if(Io)break;const To=Rt.decode(Ao,{stream:!0}).split(` 16`).filter(Pt=>Pt.trim()!=="");for(const Pt of To)(Qt=o())==null||Qt.emit(p,Pt)}})()}else{const We=await ae.json();a(We)}}else throw new Error("An error occurred while fetching the completion")}catch(ae){a(ae)}}}catch(i){a(i)}finally{o().emit(p,{done:!0})}return}}if(!(e!=null&&e.internal)&&(e.chat_id!==T()&&!Z()||d))if(x==="chat:completion"){const{done:y,content:p,output:l,title:h}=_,i=h||S().t("New Chat"),b=Ea(Sa(Na(l)||p||""));y&&((((V=D())==null?void 0:V.notificationSound)??!0)&&(((X=D())==null?void 0:X.notificationSoundAlways)??!1)&&(At.set(!0),new Audio("/audio/notification.mp3").play().finally(()=>{At.set(!1)})),te()&&(((U=D())==null?void 0:U.notificationEnabled)??!1)&&new Notification(`${i} / Open WebUI`,{body:b,icon:`${ft}/static/favicon.png`}),ut.custom(Yt,{componentProps:{onClick:()=>{pt(`/c/${e.chat_id}`)},content:b,title:i},duration:15e3,unstyled:!0}))}else x==="chat:title"?await Go(localStorage.token):x==="chat:tags"&&Jo.set(await Xo(localStorage.token))},Ke=async e=>{var d,x,_,J,m,$,E,V,X,U,y;if(((d=e.data)==null?void 0:d.type)==="typing")return;if(((x=e.data)==null?void 0:x.type)==="channel:created"){const p=await mo(localStorage.token).catch(async l=>null);p&&await Ot.set(p.sort((l,h)=>["",null,"group","dm"].indexOf(l.type)-["",null,"group","dm"].indexOf(h.type)));return}const a=L().url.pathname.includes(`/channels/${e.channel_id}`);let g=document.visibilityState!=="visible";if(window.electronAPI){const p=await window.electronAPI.send({type:"window:isFocused"});p&&(g=!p.isFocused)}if((!a||g)&&((_=e==null?void 0:e.user)==null?void 0:_.id)!==((J=Y())==null?void 0:J.id)){await ht();const p=((m=e==null?void 0:e.data)==null?void 0:m.type)??null,l=(($=e==null?void 0:e.data)==null?void 0:$.data)??null;if(Q())if(Q().find(h=>h.id===e.channel_id)&&Ee()!==e.channel_id)Ot.set(Q().map(h=>h.id===e.channel_id&&p==="message"?{...h,unread_count:(h.unread_count??0)+1,last_message_at:e.created_at}:h));else{const h=await mo(localStorage.token).catch(async i=>null);h&&await Ot.set(h.sort((i,b)=>["",null,"group","dm"].indexOf(i.type)-["",null,"group","dm"].indexOf(b.type)))}if(p==="message"){const h=`${(E=l==null?void 0:l.user)==null?void 0:E.name}${((V=e==null?void 0:e.channel)==null?void 0:V.type)!=="dm"?` (#${(X=e==null?void 0:e.channel)==null?void 0:X.name})`:""}`;te()&&(((U=D())==null?void 0:U.notificationEnabled)??!1)&&new Notification(`${h} / Open WebUI`,{body:l==null?void 0:l.content,icon:`${go}/users/${(y=l==null?void 0:l.user)==null?void 0:y.id}/profile/image`}),ut.custom(Yt,{componentProps:{onClick:()=>{pt(`/channels/${e.channel_id}`)},content:l==null?void 0:l.content,title:`${h}`},duration:15e3,unstyled:!0})}}},tt=60,ct=e=>e instanceof Request?new URL(e.url,window.location.origin):new URL(e,window.location.origin),Je=(e,a)=>a!=null&&a.headers?new Headers(a.headers):e instanceof Request?e.headers:new Headers,Xe=(e,a)=>{try{const g=ct(e),d=new URL(ft||"/",window.location.origin).origin;return g.origin===d&&Je(e,a).has("authorization")}catch{return!1}},nt=()=>{I||(I=!0,le&&(clearInterval(le),le=null),It.set(null),localStorage.removeItem("token"),document.cookie="token=; Max-Age=0; path=/",ya().catch(e=>{}),ut.error(S().t("Session expired. Please sign in again.")),I=!1)},dt=async e=>e(`${go}/auths/`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.token}`},credentials:"include"}).then(a=>a.status===401).catch(()=>!1),rt=async()=>{var g;const e=(g=Y())==null?void 0:g.expires_at,a=Math.floor(Date.now()/1e3);e&&a>=e-tt&&nt()},de=async e=>{var g,d,x,_,J,m,$,E,V;if(e.type==="page:reload"){location.reload();return}if(e.type==="page:navigate"&&((g=e.data)!=null&&g.path)){await pt(e.data.path);return}if(e.type==="query"&&((d=e.data)!=null&&d.query||(_=(x=e.data)==null?void 0:x.files)!=null&&_.length)){no.set(e),await pt("/");return}if(e.type==="call"){no.set(e),await pt("/");return}if(e.type==="theme:update"&&((J=e.data)!=null&&J.theme)){const X=e.data.theme;localStorage.setItem("theme",X),zt.set(X);const U=["dark","light","oled-dark"];let y=X==="oled-dark"?"dark":X==="her"?"light":X;X==="system"&&(y=window.matchMedia("(prefers-color-scheme: dark)").matches?"dar
16k":"light"),U.filter(p=>p!==y).forEach(p=>{p.split(" ").forEach(l=>document.documentElement.classList.remove(l))}),y.split(" ").forEach(p=>document.documentElement.classList.add(p));return}if(e.type==="models:refresh"){const X=localStorage.token;X&&models.set(await ma(X,($=(m=W())==null?void 0:m.features)!=null&&$.enable_direct_connections?((E=D())==null?void 0:E.directConnections)??null:null));return}const a=localStorage.token;if(a&&((V=Y())==null?void 0:V.role)==="admin")try{e.type==="connections:terminal"?e.data.action==="add"?await rn(a,{url:e.data.url,key:e.data.key,name:"Local Open Terminal"}):e.data.action==="remove"&&await sn(a,e.data.url):e.type==="connections:openai"&&(e.data.action==="add"?await an(a,{url:e.data.url,key:e.data.key,config:e.data.config}):e.data.action==="remove"&&await nn(a,e.data.url))}catch(X){}},Ze=async e=>{var a;["https://openwebui.com","https://www.openwebui.com","http://localhost:9999"].includes(e.origin)&&(e.data==="export:stats"||((a=e.data)==null?void 0:a.type)==="export:stats")&&(s(n,e.data),s(B,!0))};kt(async()=>{var X,U,y,p,l,h;const e=window.fetch.bind(window);window.fetch=async(i,b)=>{const K=await e(i,b);return K.status===401&&localStorage.token&&Xe(i,b)&&await dt(e)&&nt(),K},window.addEventListener("message",Ze);let a=0;function g(i){const b=document.querySelector("nav");return b&&(i===b||b.contains(i))}const d=i=>{g(i.target)&&(a=i.touches[0].clientY)},x=i=>{if(!g(i.target))return;i.touches[0].clientY-a>50&&window.scrollY===0&&(s(be,!0),i.preventDefault())},_=i=>{g(i.target)&&t(be)&&(s(be,!1),location.reload())};if(document.addEventListener("touchstart",d),document.addEventListener("touchmove",x,{passive:!1}),document.addEventListener("touchend",_),typeof window<"u"&&window.applyTheme&&window.applyTheme(),window!=null&&window.electronAPI){const i=await window.electronAPI.send({type:"app:info"});if(i){oo.set(!0),Ko.set(i);const b=await window.electronAPI.send({type:"app:data"});b&&appData.set(b)}window.electronAPI.onEvent&&window.electronAPI.onEvent(de)}$e.onmessage=i=>{i.data==="active"&&Lt.set(!1)};const J=()=>{ve=!1,Te=!0,Re()},m=()=>{ve=!0,ue=Date.now(),Lt.set(!0),$e.postMessage("active"),rt(),o()&&!o().connected&&fe()},$=()=>{document.visibilityState==="visible"?m():J()};document.addEventListener("visibilitychange",$),window.addEventListener("pagehide",J),window.addEventListener("pageshow",m),$(),zt.set(localStorage.theme),Ft.set(window.innerWidth<ce);const E=()=>{window.innerWidth<ce?Ft.set(!0):Ft.set(!1)};window.addEventListener("resize",E),It.subscribe(async i=>{var b,K,Pe,qe,ae,Me;i?((b=o())==null||b.off("events",Ge),(K=o())==null||K.off("events:channel",Ke),(Pe=o())==null||Pe.on("events",Ge),(qe=o())==null||qe.on("events:channel",Ke),le&&clearInterval(le),le=setInterval(rt,15e3)):((ae=o())==null||ae.off("events",Ge),(Me=o())==null||Me.off("events:channel",Ke))});let V=null;try{V=await uo()}catch(i){if(i!=null&&i.authRedirect){window.location.href="/";return}}if(ua(localStorage==null?void 0:localStorage.locale),!localStorage.locale){const i=await fa(),b=navigator.languages?navigator.languages:[navigator.language||navigator.userLanguage],K=V!=null&&V.default_locale?V.default_locale:ba(i,b,"en-US");ga(K),xa.locale(K)}if(V){if(await Ht.set(V),await ao.set(V.name),W()&&(await je(((X=W().features)==null?void 0:X.enable_websocket)??!0),localStorage.token)){const i=await pa(localStorage.token).catch(b=>(ut.error(`${b}`),null));if(i){await It.set(i);try{await Ht.set(await uo())}catch(K){}const b=ka();b&&ha(localStorage.token,b),(U=window.electronAPI)!=null&&U.send&&window.electronAPI.send({type:"token:update",token:localStorage.token}).catch(()=>{})}else localStorage.removeItem("token"),await It.set(null)}}else await pt("/error");if(await ht(),document.documentElement.classList.contains("her")&&document.getElementById("progress-bar")){Qe.subscribe(K=>{const Pe=document.getElementById("progress-bar");Pe&&(Pe.style.width=`${K}%`)}),await Qe.set(100),(y=document.getElementById("splash-screen"))==null||y.remove();const i=new Audio("/audio/greeting.mp3"),b=()=>{i.play(),document.removeEventListener("click",b)};document.addEventListener("click",b),s(q,!0)}else(p=document.getElementById("splash-screen"))==null||p.remove(),s(q,!0);return(window.opener??!1)&&L().url.searchParams.get("sync")==="true"&&(((h=(l=W())==null?void 0:l.features)==null?void 0:h.enable_community_sharing)??!1)&&s(B,!0),()=>{window.removeEventListener("resize",E),window.removeEventListener("message",Ze),document.removeEventListener("touchstart",d),document.removeEventListener("touchmove",x),document.removeEventListener("touchend",_),document.removeEventListener("visibilitychange",$),window.removeEventListener("pagehide",J),window.removeEventListener("pageshow",m)}}),Gt(()=>{$e.close()}),pe(()=>D(),()=>{var e;typeof document<"u"&&document.documentElement.classList.toggle("high-contrast",((e=D())==null?void 0:e.highContrastMode)??!1)}),$t(),Et();var Be=Cn();$o("12qhfyh",e=>{var a=An(),g=Ce(a),d=R(g,2),x=R(d,2),_=R(x,2);we(()=>{ye(g,"href",`${ft}/static/favicon.png`),ye(d,"content",Ne()),ye(x,"content",Ne()),ye(_,"title",Ne())}),Mo(()=>{Do.title=Ne()??""}),w(e,a)});var ze=Ce(Be),G=v(ze,!0);f(ze);var st=R(ze,2);{var _t=e=>{var a=Tn(),g=v(a);So(g,{className:"size-5"}),f(a),w(e,a)};ke(st,e=>{t(be)&&e(_t)})}var gt=R(st,2);{var St=e=>{var a=Ue(),g=Ce(a);{var d=_=>{var J=Pn(),m=v(J);fn(m);var $=R(m,2),E=v($);at(E,r,"default",{},null),f($),f(J),w(_,J)},x=_=>{var J=Ue(),m=Ce(J);at(m,r,"default",{},null),w(_,J)};ke(g,_=>{ge()?_(d):_(x,-1)})}w(e,a)};ke(gt,e=>{t(q)&&e(St)})}var mt=R(gt,2);{var vt=e=>{In(e,{get eventData(){return t(n)},get show(){return t(B)},set show(a){s(B,a)},$$legacy:!0})};ke(mt,e=>{W(),u(()=>{var a;return(a=W())==null?void 0:a.features.enable_community_sharing})&&e(vt)})}var O=R(mt,2);{let e=it(()=>
16(_e(),u(()=>_e().includes("dark")||_e()==="system"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")));en(O,{get theme(){return t(e)},richColors:!0,position:"top-right",closeButton:!0,toastOptions:{classes:{closeButton:"!bg-white/80 !text-gray-500 !border-gray-200 hover:!bg-gray-50 hover:!text-gray-700 dark:!bg-gray-850 dark:!text-gray-400 dark:!border-gray-700 dark:hover:!bg-gray-800 dark:hover:!text-gray-200"}}})}we(e=>se(G,e),[()=>(S(),u(()=>S().t("Skip to main content")))]),w(P,Be),wt(),De()}export{mr as component,gr as universal}; 17//# sourceMappingURL=0.DZcySmbN.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.