@fabiofiorita/porcelain 0.65.2 → 0.65.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -7
- package/package.json +1 -1
- package/server/src/cli/main.mjs +2699 -2564
- package/web/dist/assets/_paired-BGQByqTx.js +1 -0
- package/web/dist/assets/_paired-C-OPMHd_.js +1 -0
- package/web/dist/assets/_paired-DR1ndZmE.js +1 -0
- package/web/dist/assets/_paired-qSHXbKkl.js +1 -0
- package/web/dist/assets/_section-D25X_IP_.js +1 -0
- package/web/dist/assets/_worktreeId-2AckLnuR.js +1 -0
- package/web/dist/assets/_worktreeId-Cfr9rr3q.js +1 -0
- package/web/dist/assets/_worktreeId-DR1ndZmE.js +1 -0
- package/web/dist/assets/_worktreeId-qSHXbKkl.js +1 -0
- package/web/dist/assets/access-CnKxJMA6.js +1 -0
- package/web/dist/assets/connected-workspace-DDQUa7Bv.js +1 -0
- package/web/dist/assets/desktop-actions-C6IPObdg.js +11 -0
- package/web/dist/assets/{edit-file-DOZdUUk9.js → edit-file-CqSI_R_G.js} +35 -35
- package/web/dist/assets/{file-editor-DvHSzrST.js → file-editor-CY822nHE.js} +14 -14
- package/web/dist/assets/files-Dq4t9_xQ.js +17 -0
- package/web/dist/assets/git-actions-BrTzG9I2.js +1345 -0
- package/web/dist/assets/{index-Cia9YleJ.js → index-D5KKCKKt.js} +4 -4
- package/web/dist/assets/index-DddS8Xzd.css +2 -0
- package/web/dist/assets/lazyRouteComponent-BpzFu5o7.js +1 -0
- package/web/dist/assets/link-B0k0Dw1r.js +1 -0
- package/web/dist/assets/pair-D3O7jbtO.js +1 -0
- package/web/dist/assets/pair-DR1ndZmE.js +1 -0
- package/web/dist/assets/search-CVF8YG8C.js +1 -0
- package/web/dist/assets/useRouterState-GGrtXzjn.js +1 -0
- package/web/dist/assets/workspace-error-CpgoRLTX.js +1 -0
- package/web/dist/assets/workspace-pending-CSj0ENeH.js +1 -0
- package/web/dist/index.html +10 -13
- package/web/dist/assets/_paired-B3CMUVff.js +0 -1
- package/web/dist/assets/_paired-B8xCvrtN.js +0 -1
- package/web/dist/assets/_paired-YiNqIqrL.js +0 -1
- package/web/dist/assets/_paired-rl3uQlkr.js +0 -1
- package/web/dist/assets/_section-DJ3o28t3.js +0 -1
- package/web/dist/assets/_worktreeId-B3CMUVff.js +0 -1
- package/web/dist/assets/_worktreeId-B8xCvrtN.js +0 -1
- package/web/dist/assets/_worktreeId-DS7C0JfB.js +0 -1
- package/web/dist/assets/_worktreeId-DzWffY3l.js +0 -1
- package/web/dist/assets/access-yiNkcsHW.js +0 -1
- package/web/dist/assets/connected-workspace-HwRJynH2.js +0 -1
- package/web/dist/assets/desktop-UhAM-aem.js +0 -14
- package/web/dist/assets/desktop-actions-_GPqaBVU.js +0 -12
- package/web/dist/assets/files-DGG-rGAk.js +0 -4
- package/web/dist/assets/git-actions-PSyqF5Ms.js +0 -1345
- package/web/dist/assets/index-DUPxq0qw.css +0 -2
- package/web/dist/assets/lazyRouteComponent-C0cxtC0x.js +0 -1
- package/web/dist/assets/link-Cr7ETqcH.js +0 -1
- package/web/dist/assets/pair-B3CMUVff.js +0 -1
- package/web/dist/assets/pair-pADUBfPY.js +0 -1
- package/web/dist/assets/preferences-gCf_-ng1.js +0 -1
- package/web/dist/assets/review-diagram-CK76VybL.js +0 -7
- package/web/dist/assets/review-diagram-DLioOiRN.css +0 -1
- package/web/dist/assets/search-YI2tNMg7.js +0 -1
- package/web/dist/assets/server-CO1nBw31.js +0 -1
- package/web/dist/assets/useRouterState-DpORzQ8V.js +0 -1
- package/web/dist/assets/workspace-error-DILP6VTh.js +0 -1
- package/web/dist/assets/workspace-pending-6RKmflS9.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,$c as n,$i as r,$l as i,$n as a,$o as o,$r as s,$s as c,Aa as l,Ac as u,Ai as d,Al as f,An as p,Ao as m,Ar as h,As as g,At as _,Ba as v,Bc as y,Bi as b,Bl as x,Bn as S,Bo as C,Br as w,Bs as T,C as E,Ca as D,Cc as ee,Ci as O,Cl as k,Cn as A,Cr as j,Cs as M,Ct as N,Da as P,Dc as F,Di as I,Dl as L,Dn as R,Dr as te,Ds as z,Dt as B,Ea as ne,Ec as re,Ei as ie,El as V,En as ae,Eo as oe,Er as se,Es as ce,Fa as le,Fc as ue,Fi as de,Fl as fe,Fn as pe,Fo as me,Fr as he,Fs as ge,Ft as _e,G as ve,Ga as ye,Gl as H,Go as be,Gr as U,Gs as xe,H as Se,Ha as Ce,Hc as we,Hl as Te,Hn as Ee,Ho as De,Hs as Oe,Ht as ke,Ia as Ae,Ic as je,Ii as Me,Il as Ne,In as Pe,Ir as Fe,Is as Ie,It as Le,J as Re,Jc as ze,Ji as Be,Jl as Ve,Jn as He,Jo as Ue,Jr as We,Js as Ge,Jt as Ke,Ka as qe,Kc as Je,Ki as Ye,Kl as Xe,Kn as Ze,Ko as Qe,Kr as $e,Ks as et,La as tt,Lc as nt,Li as rt,Ll as it,Ln as at,Lr as ot,Ls as st,Lt as ct,Ma as lt,Mc as ut,Mi as dt,Ml as ft,Mo as pt,Mr as mt,Ms as ht,N as gt,Na as _t,Nc as vt,No as yt,Nr as bt,Ns as xt,Nt as St,O as Ct,Oa as wt,Oc as Tt,Oi as Et,Ol as Dt,On as Ot,Or as kt,Os as At,Ot as jt,P as Mt,Pa as Nt,Pc as Pt,Pi as Ft,Pl as It,Pn as Lt,Po as Rt,Pr as zt,Ps as Bt,Pt as Vt,Q as Ht,Qa as Ut,Qc as Wt,Qi as Gt,Qn as Kt,Qo as qt,Qt as Jt,R as Yt,Ra as Xt,Rc as Zt,Rl as Qt,Rn as $t,Rr as en,Rs as tn,Rt as W,Sa as nn,Sc as rn,Si as an,Sl as on,Sn as sn,Sr as cn,Ss as ln,St as un,T as dn,Ta as fn,Tc as pn,Ti as mn,Tl as hn,Tn as gn,To as _n,Tr as vn,Ts as yn,U as bn,Ua as xn,Uc as Sn,Ui as Cn,Ul as wn,Un as Tn,Uo as En,Us as Dn,Ut as On,Va as kn,Vc as An,Vi as jn,Vl as Mn,Vn as Nn,Vo as Pn,Vr as G,Vs as Fn,Vt as In,Wa as Ln,Wc as Rn,Wi as zn,Wl as Bn,Wn as Vn,Wo as Hn,Wr as Un,Ws as Wn,Wt as Gn,Xa as Kn,Xc as qn,Xi as Jn,Xl as Yn,Xr as Xn,Xs as Zn,Y as Qn,Ya as $n,Yc as er,Yl as tr,Yn as nr,Yo as rr,Yr as ir,Ys as ar,Z as or,Za as sr,Zc as cr,Zl as lr,Zn as ur,Zo as dr,Zr as fr,Zs as pr,Zt as mr,_a as hr,_c as gr,_i as _r,_l as vr,_o as yr,_r as br,_s as xr,_t as Sr,_u as Cr,aa as wr,ac as Tr,ai as Er,al as Dr,an as Or,ao as kr,ar as Ar,as as jr,at as Mr,au as Nr,ba as Pr,bc as Fr,bi as Ir,bl as Lr,bn as Rr,br as zr,bs as Br,bt as Vr,cc as Hr,cl as Ur,cn as Wr,co as Gr,cr as K,cs as Kr,ct as qr,cu as Jr,da as Yr,dc as Xr,di as Zr,dl as Qr,dn as $r,do as ei,dr as ti,ds as ni,du as ri,ea as ii,ec as ai,el as oi,en as si,eo as ci,er as li,es as ui,eu as di,fa as fi,fc as pi,fi as mi,fl as hi,fo as gi,fr as _i,fs as vi,ft as yi,fu as bi,ga as xi,gc as Si,gi as Ci,gl as wi,go as Ti,gr as Ei,gs as Di,gt as Oi,gu as ki,ha as Ai,hc as ji,hi as Mi,hl as Ni,hn as Pi,ho as Fi,hr as Ii,hs as Li,ht as Ri,hu as zi,ia as Bi,ic as Vi,il as Hi,io as Ui,ir as Wi,is as Gi,it as Ki,iu as qi,ja as Ji,jc as Yi,jl as Xi,jn as Zi,jo as Qi,jr as $i,js as ea,jt as ta,k as na,ka as ra,kc as ia,ki as q,kl as aa,kn as oa,ko as sa,kr as ca,ks as la,kt as ua,la as da,lc as fa,ll as pa,lo as ma,lr as ha,ls as ga,lt as _a,mc as va,mi as ya,ml as ba,mn as xa,ms as Sa,mt as Ca,mu as wa,na as Ta,nc as Ea,nl as Da,no as Oa,nr as ka,ns as Aa,nu as ja,oa as Ma,oc as J,oi as Na,ol as Pa,on as Fa,or as Ia,os as La,ot as Ra,ou as za,pa as Ba,pc as Va,pi as Ha,pl as Ua,pr as Wa,ps as Ga,pt as Ka,pu as qa,q as Ja,qc as Ya,qi as Xa,ql as Za,qs as Qa,qt as $a,ra as eo,rc as to,ri as no,rl as ro,rr as io,rs as ao,rt as oo,ru as so,sa as co,sc as lo,sl as uo,sn as fo,sr as po,ss as mo,st as ho,su as go,ta as _o,tc as vo,ti as yo,tl as bo,tn as xo,to as So,tr as Co,ts as wo,tt as To,ua as Eo,uc as Do,ui as Oo,ul as ko,uo as Ao,ur as jo,us as Mo,ut as No,uu as Po,va as Fo,vc as Io,vi as Lo,vl as Ro,vn as zo,vr as Bo,vs as Vo,vt as Ho,w as Uo,wa as Wo,wc as Go,wi as Ko,wl as qo,wo as Jo,wr as Yo,ws as Xo,xa as Zo,xc as Qo,xi as $o,xl as es,xn as ts,xo as ns,xr as rs,xs as Y,xt as is,ya as as,yc as os,yi as ss,yl as cs,yo as ls,yr as us,ys as X,yt as ds,za as fs,zc as ps,zi as ms,zl as hs,zn as gs,zo as _s,zr as vs,zs as ys,zt as bs}from"./files-Dq4t9_xQ.js";var xs=e=>t=>!Mn(e(t)),Ss=e=>t=>t.has(e)?wn(t):x(t),Cs=ki(2,(e,t)=>n=>{let r=e(n);return Mn(r)?r:t(r.success)}),ws=(e,t,n)=>{let r=n*(t-e)+e;if(r!==t||e>=t||!Number.isFinite(t))return r;if(t===0)return-Number.MIN_VALUE;let i=new DataView(new ArrayBuffer(8));i.setFloat64(0,t);let a=i.getBigUint64(0);return i.setBigUint64(0,t>0?a-BigInt(1):a+BigInt(1)),i.getFloat64(0)},Ts=`~effect/PlatformError`,Es=class extends V(`BadArgument`){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:``}`}},Ds=class extends hn{get message(){return`${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor===void 0?``:` (${this.pathOrDescriptor})`}${this.description?`: ${this.description}`:``}`}},Os=class extends V(`PlatformError`){constructor(e){`cause`in e?super({reason:e,cause:e.cause}):super({reason:e})}[Ts]=Ts;get message(){return this.reason.message}},ks=e=>new Os(new Ds(e)),As=e=>new Os(new Es(e)),js=`~effect/socket/Socket`,Ms=H(`effect/socket/Socket`),Ns=e=>Ms.of({[js]:js,reader:e.reader,writer:e.writer}),Ps=new TextEncoder,Fs=`~effect/socket/Socket/CloseEvent`,Is=e=>wa(e,Fs),Ls=`~effect/socket/Socket/SocketError`,Rs=e=>wa(e,Ls),zs=class extends So(`effect/socket/Socket/SocketReadError`)({_tag:Rt(`SocketReadError`),cause:ci()}){message=`An error occurred during Read`},Bs=class extends So(`effect/socket/Socket/SocketWriteError`)({_tag:Rt(`SocketWriteError`),cause:ci()}){message=`An error occurred during Write`},Vs=class extends So(`effect/socket/Socket/SocketOpenError`)({_tag:Rt(`SocketOpenError`),kind:Ui([`Unknown`,`Timeout`]),cause:ci()}){get message(){return this.kind===`Timeout`?`timeout waiting for "open"`:`An error occurred during Open`}},Hs=class e extends So(`effect/socket/Socket/SocketUpgradeError`)({_tag:Rt(`SocketUpgradeError`),cause:yt(ci())}){static unsupported=()=>X(new Gs({reason:new e({})}));get message(){return this.cause===void 0?`Socket does not support TLS upgrade`:`An error occurred during TLS upgrade`}},Us=class extends So(`effect/socket/Socket/SocketCloseError`)({_tag:Rt(`SocketCloseError`),code:Oa,closeReason:yt(Ao)}){get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},Ws=Ti([zs,Bs,Vs,Hs,Us]),Gs=class extends gi(Ls)(`SocketError`,{_tag:Rt(`SocketError`),reason:Ws}){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[Ls]=Ls;static is(e){return Rs(e)}message=this.reason.message},Ks=(e,t)=>new Gs({reason:new Us({code:e,closeReason:t})}),qs=class extends H()(`@effect/platform/Socket/WebSocketConstructor`){},Js=(e,t)=>qs.use(n=>Xs(wo((typeof e==`string`?Vi(e):e).pipe(Bt(e=>n(e,t?.protocols))),e=>J(()=>e.close(1e3))),t)),Ys=e=>`pause`in e&&typeof e.pause==`function`,Xs=(e,t)=>Qo(n=>{let r,i=Nt(!1),a=n.context,o=z(function*(){let n=yield*ai,a=yield*Je(e,n);`binaryType`in a&&(a.binaryType=`arraybuffer`);let o=Ys(a),s=t?.highWaterMark??(o?Zs:void 0),c=a.readyState===1,l=o&&`isPaused`in a&&a.isPaused===!0,u=[],d=0,f,p,m;function h(){o&&!l&&(a.pause(),l=!0)}function g(){o&&l&&(a.resume(),l=!1)}function _(){let e=u;return u=[],d=0,f===void 0&&g(),e}function v(){if(p===void 0||u.length===0)return;let e=p;p=void 0,e(Vi(_()))}function y(e){u.push(e),s!==void 0&&(d+=typeof e==`string`?Ps.encode(e).byteLength:e.byteLength),p!==void 0&&v(),o&&d>=s?h():!o&&!p&&s!==void 0&&d>s&&b(new Gs({reason:new zs({cause:Error(`Socket highWaterMark of ${s} bytes exceeded`)})}))}function b(e){if(f===void 0&&(f=e),m!==void 0){let{cleanup:e,resume:t}=m;m=void 0,e(),t(X(f))}if(p!==void 0){let e=p;p=void 0,e(u.length>0?Vi(_()):X(f))}}function x(e){let t=e.data;if(typeof Blob<`u`&&t instanceof Blob){t.arrayBuffer().then(e=>y(new Uint8Array(e)),e=>{b(new Gs({reason:new zs({cause:e})}))});return}y(t instanceof ArrayBuffer?new Uint8Array(t):t)}function S(e){b(new Gs({reason:c?new zs({cause:e}):new Vs({kind:`Unknown`,cause:e})}))}function C(e){b(Ks(typeof e.code==`number`?e.code:1006,e.reason))}return a.addEventListener(`message`,x),a.addEventListener(`error`,S,{once:!0}),a.addEventListener(`close`,C,{once:!0}),yield*An(n,J(()=>{if(b(Ks(1006)),a.removeEventListener(`message`,x),a.removeEventListener(`error`,S),a.removeEventListener(`close`,C),o)try{g()}catch{}i.closeUnsafe(),r=void 0})),a.readyState>=2?yield*X(f??Ks(1006)):(c||=(yield*Kr(e=>{let t=()=>{m?.resume===e&&(m=void 0,a.removeEventListener(`open`,t),e(os))},n=()=>a.removeEventListener(`open`,t);return m={resume:e,cleanup:n},a.addEventListener(`open`,t,{once:!0}),J(()=>{m?.resume===e&&(m=void 0),n()})}).pipe(pi({duration:t?.openTimeout??1e4,orElse:()=>X(new Gs({reason:new Vs({kind:`Timeout`,cause:Error(`timeout waiting for "open"`)})}))})),!0),f===void 0&&d<s&&g(),r=a,i.openUnsafe(),{pull:Kr(e=>u.length>0?e(Vi(_())):f===void 0?(p=e,J(()=>{p===e&&(p=void 0)})):e(X(f))),upgrade:Hs.unsupported})}).pipe(gr(e=>lr(a,e))),s=e=>Tr(()=>{let t=r;if(t===void 0)return i.whenOpen(s(e));try{return Is(e)?t.close(e.code,e.reason):t.send(e),os}catch(e){return X(new Gs({reason:new Bs({cause:e})}))}}),c=e=>Tr(()=>{let t=r;if(t===void 0)return i.whenOpen(c(e));try{for(let n=0;n<e.length;n++)t.send(e[n]);return os}catch(e){return X(new Gs({reason:new Bs({cause:e})}))}}),l=Vi({write:s,writeAll:c});return Vi(Ns({reader:o,writer:l}))}),Zs=65536,Qs=class extends H()(`effect/workers/Transferable/Collector`){},$s=()=>{let e=[],t=t=>{e.push(...t)},n=()=>e,r=()=>{let t=e;return e=[],t};return Qs.of({addAllUnsafe:t,addAll:e=>J(()=>t(e)),readUnsafe:n,read:J(n),clearUnsafe:r,clear:J(r)})},ec=Ti([class extends So(`effect/workers/WorkerError/WorkerSpawnError`)({_tag:Rt(`WorkerSpawnError`),message:Ao,cause:yt(ci())}){},class extends So(`effect/workers/WorkerError/WorkerSendError`)({_tag:Rt(`WorkerSendError`),message:Ao,cause:yt(ci())}){},class extends So(`effect/workers/WorkerError/WorkerReceiveError`)({_tag:Rt(`WorkerReceiveError`),message:Ao,cause:yt(ci())}){},class extends So(`effect/workers/WorkerError/WorkerUnknownError`)({_tag:Rt(`WorkerUnknownError`),message:Ao,cause:yt(ci())}){}]),tc=`~effect/rpc/RpcClientError`,nc=class extends So(`effect/rpc/RpcClientError/RpcClientDefect`)({_tag:Rt(`RpcClientDefect`),message:Ao,cause:ci()}){},rc=class extends So(tc)({_tag:Rt(`RpcClientError`),reason:Ti([ec,Ws,an,nc])}){[tc]=tc;get message(){return`${this.reason._tag}: ${this.reason.message}`}},ic=e=>e,ac={_tag:`Ping`},oc=me,sc,cc=e=>(sc??=new TextDecoder).decode(e),lc=class extends H()(`effect/rpc/RpcSerialization`){},uc=lc.of({contentType:`application/json`,includesFraming:!1,codecFor:oc,makeUnsafe:()=>({decode:e=>{let t=JSON.parse(typeof e==`string`?e:cc(e));return Array.isArray(t)?t:[t]},encode:e=>JSON.stringify(e)})}),dc=e=>Tr(()=>{let t=new Set,n=new Map,r=new Map,i=(e,t)=>Sa(r=>{let i=n.get(e);return i||(i=[],n.set(e,i)),i.push([t,r]),os});return Bt(e((e,t)=>{let n=r.get(e);return n?n(t):i(e,t)},t),e=>({...e,run(e,i){return z(function*(){t.add(e),r.set(e,i);let a=n.get(e);if(a){n.delete(e);for(let[e,t]of a)yield*xe(Tr(()=>i(e)),t)}return yield*T(tn,()=>(t.delete(e),r.delete(e),os))})}}))}),fc=0,pc=ln(function*(e,t){let r=t?.spanPrefix??`RpcClient`,i=t?.supportsAck??!0,a=t?.disableTracing??!1,o=t?.generateRequestId??(()=>fc++),s=yield*Ga(),c=Ve(s,y),l=new Map,u=!1;yield*An(c,Qo(e=>(u=!0,d(Da(e.id)))));let d=ln(function*(e){for(let[t,n]of l)l.delete(t),n._tag===`Queue`?yield*e._tag===`Success`?ne(n.queue):P(n.queue,e.cause):n.resume(e)}),f=e=>{let n=ya(e.successSchema),i=h(e);return(o,s)=>{let c=s?.headers?C(s.headers):_s,l=s?.context??Za();if(!n){let n=t=>p(e,i,t,e.payloadSchema.make(o),c,l,s?.discard??!1);return a?n(void 0):Io(`${r}.${e._tag}`,{attributes:t.spanAttributes},n)}let u=m(e,i,e.payloadSchema.make(o),c,s?.streamBufferSize??16,l);return s?.asQueue?u:Ba(Bt(u,Bi))}},p=(e,n,r,i,a,s,c)=>Qo(d=>{if(u)return g;let f=o(),p=n(e=>t.onFromClient({message:e,context:s,discard:c}),{_tag:`Request`,id:f,tag:e._tag,payload:i,...r?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{},headers:Pn(d.getRef(_c),a)});if(c)return p;let m;return Fn(Kr(t=>{let n={_tag:`Effect`,rpc:e,context:s,resume(e){t(e),m&&!m.pollUnsafe()&&d.currentDispatcher.scheduleTask(()=>{m.interruptUnsafe(d.id)},0)}};l.set(f,n),m=p.pipe(r?rn(r,{captureStackTrace:!1}):Cr,pr(d.context)),m.addObserver(e=>{if(e._tag===`Failure`)return t(e)})}),e=>(l.delete(f),jr(tt(m),_(f,Array.from(e),s))))}),m=ln(function*(e,n,i,s,c,d){if(u)return yield*g;let f=a?void 0:yield*xt(`${r}.${e._tag}`,{attributes:t.spanAttributes}),p=Ae(),m=o(),h=Yn(p.context,y),v=yield*fn(c);return yield*we(h,e=>(Ji(v),l.has(m)?(l.delete(m),_(m,ro(e)?Array.from(Qr(e.cause)):[],d)):os)),l.set(m,{_tag:`Queue`,rpc:e,queue:v,scope:h,context:d}),yield*n(e=>t.onFromClient({message:e,context:d,discard:!1}),{_tag:`Request`,id:m,tag:e._tag,payload:i,...f?{traceId:f.traceId,spanId:f.spanId,sampled:f.sampled}:{},headers:Pn(p.getRef(_c),s)}).pipe(f?rn(f,{captureStackTrace:!1}):Cr,ys(e=>P(v,e)),ea,yn(h,{startImmediately:!0})),v}),h=e=>{let t=[];for(let n of e.middlewares.values()){let e=tr(s,`${n.key}/Client`);e&&t.push(e)}return t.length===0?(e,t)=>e(t):function n(r,i,a=t.length-1){return a===-1?r(i):t[a]({rpc:e,request:i,next(e){return n(r,e,a-1)}})}},_=(e,n,r)=>Kr(i=>{let a=Ae();t.onFromClient({message:{_tag:`Interrupt`,requestId:e,interruptors:n},context:r,discard:!1}).pipe(Do(1e3),pr(a.context)).addObserver(()=>{i(os)})}),v=e=>{switch(e._tag){case`Chunk`:{let n=e.requestId,r=l.get(n);return!r||r._tag!==`Queue`?os:wt(r.queue,e.values).pipe(i?Br(()=>t.onFromClient({message:{_tag:`Ack`,requestId:e.requestId},context:r.context,discard:!1})):Cr,ga(e=>P(r.queue,e)))}case`Exit`:{let t=e.requestId,n=l.get(t);return n?(l.delete(t),n._tag===`Effect`?(n.resume(e.exit),os):e.exit._tag===`Success`?ne(n.queue):P(n.queue,e.exit.cause)):os}case`Defect`:return d(n(e.defect));case`ClientEnd`:return os}},b;if(t.flatten){let t=new Map;b=function(n,r,i){let a=t.get(n);return a||(a=f(e.requests.get(n)),t.set(n,a)),a(r,i)}}else b={},e.requests.forEach(e=>{bi(b,e._tag,f(e))});return{client:b,write:v}}),mc=0,hc=ln(function*(e,t){let n=mc++,{codecFor:r,run:i,send:a,supportsAck:o,supportsTransferables:s}=yield*vc,c=gc(r),l=ls(r(ci())),u=new Map,d=e=>u.has(e)?(u.delete(e),a(n,{_tag:`Interrupt`,requestId:e})):os,{client:f,write:p}=yield*pc(e,{...t,supportsAck:o,onFromClient({message:t}){switch(t._tag){case`Request`:{let r=e.requests.get(t.tag),i=s?$s():void 0,o=Ae(),l={rpc:r,context:i?Xe(o.context,Qs,i):o.context,schemas:c(r)};return u.set(t.id,l),l.schemas.encodePayload(t.payload).pipe(xe(l.context),Oe,Br(e=>a(n,{...t,id:t.id,payload:e,headers:Object.entries(t.headers)},i&&i.readUnsafe())))}case`Ack`:return u.get(t.requestId)?a(n,{_tag:`Ack`,requestId:t.requestId}):os;case`Interrupt`:return d(t.requestId);case`Eof`:return os}}});return yield*i(n,e=>{switch(e._tag){case`Chunk`:{let t=ic(e.requestId),n=u.get(t);if(!n||so(n.schemas.decodeChunk))return os;let r=n.schemas.decodeChunk.value;return Si(i=>i(r(e.values).pipe(xe(n.context),Oe,Br(e=>p({_tag:`Chunk`,clientId:0,requestId:t,values:e})))).pipe(ys(e=>p({_tag:`Exit`,clientId:0,requestId:t,exit:bo(e)}).pipe(jr(pa(e)?os:At(d(t))))),Mo(e=>!pa(e),()=>os)))}case`Exit`:{let t=ic(e.requestId),n=u.get(t);return n?(u.delete(t),n.schemas.decodeExit(e.exit).pipe(xe(n.context),Oe,Ie({onSuccess:e=>p({_tag:`Exit`,clientId:0,requestId:t,exit:e}),onFailure:e=>p({_tag:`Exit`,clientId:0,requestId:t,exit:bo(e)})}))):os}case`Defect`:return p({_tag:`Defect`,clientId:0,defect:l(e.defect)});case`ClientProtocolError`:{let t=oi(e.error);return M(Array.from(u.keys()),e=>p({_tag:`Exit`,clientId:0,requestId:e,exit:t}))}default:return os}}).pipe(ga(ht),ea,ce),f}),gc=e=>{let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=Ha(n.successSchema);return r={decodeChunk:Nr(i,t=>ns(e(kr(t.success)))),encodePayload:Jo(e(n.payloadSchema)),decodeExit:ns(e(mi(n)))},t.set(n,r),r}},_c=Bn(`effect/rpc/RpcClient/CurrentHeaders`,{defaultValue:()=>_s}),vc=class extends H()(`effect/rpc/RpcClient/Protocol`){static make=dc},yc=e=>vc.make(ln(function*(t,n){let r=yield*Ms,i=yield*lc,a=yield*Ea(Sc),o=new Map,s=yield*r.writer,c=i.makeUnsafe(),l=yield*xc(Tr(()=>s.write(c.encode(ac)))),u,d=e=>M(n,n=>t(n,e)),f=e=>(u=e,d({_tag:`ClientProtocolError`,error:e})),p=e=>{try{let n=c.decode(e);if(n.length===0)return os;let r=0;return Fr({while:()=>r<n.length,body:()=>{let e=n[r++];if(e._tag===`Pong`)return l.onPong(),os;if(Object.hasOwn(e,`requestId`)){let n=e.requestId,r=o.get(n);if(r!==void 0)return e._tag===`Exit`&&o.delete(n),t(r,e)}return d(e)},step:zi})}catch(e){return d({_tag:`ClientProtocolError`,error:new rc({reason:new nc({message:`Error decoding message`,cause:e})})})}};return yield*Tr(()=>(c=i.makeUnsafe(),l.reset(),z(function*(){let{pull:e}=yield*r.reader;for(u=void 0,qi(a)&&(yield*a.value.onConnect);;){let t=yield*e;for(let e=0;e<t.length;e++)yield*p(t[e])}}).pipe(vo,Qa(Br(l.timeout,()=>X(new Gs({reason:new zs({cause:Error(`ping timeout`)})}))))))).pipe(qi(a)?xr(a.value.onDisconnect):Cr,Hr(t=>{let n=Ur(t),r=Te(n),i=new rc({reason:r?n.success.reason:new nc({message:`Unknown socket error`,cause:hi(t)})});return e?.retryTransientErrors&&r&&n.success.reason._tag===`SocketOpenError`?(e.onTransientError?.(i)??os).pipe(la({log:!0,message:`RpcClient onTransientError hook failed`})):f(i)}),ar(e?.retryPolicy??bc,e=>f(new rc({reason:e.reason}))),La({module:`RpcClient`,method:`makeProtocolSocket`}),ce),{send(e,t){if(u)return X(u);t._tag===`Request`&&o.set(t.id,e);let n=c.encode(t);return n===void 0?os:Oe(s.write(n))},supportsAck:!0,supportsTransferables:!1,codecFor:i.codecFor}})),bc=re([Go(500,1.5),Tt(5e3)]),xc=ln(function*(e){let t=!0,n=Nt();return yield*Tr(()=>t?(t=!1,e):n.open).pipe(Li(`5 seconds`),At,Xo,ea,ce),{timeout:n.await,reset:()=>{t=!0,n.closeUnsafe()},onPong:()=>{t=!0}}}),Sc=class extends H()(`effect/rpc/RpcClient/ConnectionHooks`){},Z=e(Zr(),1),Cc=Z.createContext(null);function wc(e){return Z.useContext(Cc)}var Q=Oo(),Tc=e(Na(),1),Ec=`data-open`,Dc=`data-closed`,Oc=Co,kc=li,Ac=`data-anchor-hidden`,jc={[ur]:``},Mc={[ur]:``,[Kt]:``},Nc={[Ec]:``},Pc={[Dc]:``},Fc={[Ac]:``},Ic={open(e){return e?jc:null}},Lc={open(e){return e?Mc:null}},Rc={open(e){return e?Nc:Pc},anchorHidden(e){return e?Fc:null}},zc={...Rc,...a};function Bc(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...Bc(e,t.id,n)])}function Vc(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function Hc(e){e.preventDefault(),e.stopPropagation()}function Uc(e){return`nativeEvent`in e}function Wc(e){return e.pointerType===``&&e.isTrusted?!0:_i&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function Gc(e){return jo?!1:!_i&&e.width===0&&e.height===0||_i&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function Kc(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function qc(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}var Jc=Math.min,Yc=Math.max,Xc=Math.round,Zc=Math.floor,Qc=e=>({x:e,y:e}),$c={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function el(e,t,n){return Yc(e,Jc(t,n))}function tl(e,t){return typeof e==`function`?e(t):e}function nl(e){return e.split(`-`)[0]}function rl(e){return e.split(`-`)[1]}function il(e){return e===`x`?`y`:`x`}function al(e){return e===`y`?`height`:`width`}function ol(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function sl(e){return il(ol(e))}function cl(e,t,n){n===void 0&&(n=!1);let r=rl(e),i=sl(e),a=al(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=_l(o)),[o,_l(o)]}function ll(e){let t=_l(e);return[ul(e),t,ul(t)]}function ul(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var dl=[`left`,`right`],fl=[`right`,`left`],pl=[`top`,`bottom`],ml=[`bottom`,`top`];function hl(e,t,n){switch(e){case`top`:case`bottom`:return n?t?fl:dl:t?dl:fl;case`left`:case`right`:return t?pl:ml;default:return[]}}function gl(e,t,n,r){let i=rl(e),a=hl(nl(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(ul)))),a}function _l(e){let t=nl(e);return $c[t]+e.slice(t.length)}function vl(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function yl(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:vl(e)}function bl(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function xl(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}function Sl(e){let t=$e(Cl,e).current;return t.next=e,U(t.effect),t}function Cl(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var wl=0;function Tl(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(wl);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),Xn;let o=requestAnimationFrame(a);return wl=o,()=>{wl===o&&(cancelAnimationFrame(o),wl=0)}}var El={inert:new WeakMap,"aria-hidden":new WeakMap},Dl=`data-base-ui-inert`,Ol={inert:new WeakSet,"aria-hidden":new WeakSet},kl=new WeakMap,Al=0;function jl(e){return Ol[e]}function Ml(e){return e?Fe(e)?e.host:Ml(e.parentNode):null}var Nl=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=Ml(t);return e.contains(n)?n:null}).filter(e=>e!=null),Pl=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},Fl=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{se(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function Il(e,t,n,r,{mark:i=!0}){let a=null;r?a=`inert`:n&&(a=`aria-hidden`);let o=null,s=null,c=Nl(t,e),l=i?Fl(t,Pl(c),new Set(c)):[],u=[],d=[];if(a){let e=El[a],n=jl(a);s=n,o=e;let r=Nl(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=c.concat(r);Fl(t,Pl(i),new Set(i)).forEach(t=>{let r=t.getAttribute(a),i=r!==null&&r!==`false`,o=(e.get(t)||0)+1;e.set(t,o),u.push(t),o===1&&i&&n.add(t),i||t.setAttribute(a,a===`inert`?``:`true`)})}return i&&l.forEach(e=>{let t=(kl.get(e)||0)+1;kl.set(e,t),d.push(e),t===1&&e.setAttribute(Dl,``)}),Al+=1,()=>{o&&u.forEach(e=>{let t=(o.get(e)||0)-1;o.set(e,t),t||(!s?.has(e)&&a&&e.removeAttribute(a),s?.delete(e))}),i&&d.forEach(e=>{let t=(kl.get(e)||0)-1;kl.set(e,t),t||e.removeAttribute(Dl)}),--Al,Al||(El.inert=new WeakMap,El[`aria-hidden`]=new WeakMap,Ol.inert=new WeakSet,Ol[`aria-hidden`]=new WeakSet,kl=new WeakMap)}}function Ll(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,a=zr(e[0]).body;return Il(e,a,n,r,{mark:i})}function Rl(){let e=new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var zl=class{nodesRef={current:[]};events=Rl();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}},Bl=Z.createContext(null),Vl=Z.createContext(null),Hl=()=>Z.useContext(Bl)?.id||null,Ul=e=>{let t=Z.useContext(Vl);return e??t};function Wl(e){let t=$r(),n=Ul(e),r=Hl();return U(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function Gl(e){let{children:t,id:n}=e,r=Hl();return(0,Q.jsx)(Bl.Provider,{value:Z.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Kl(e){let{children:t,externalTree:n}=e,r=$e(()=>n??new zl).current;return(0,Q.jsx)(Vl.Provider,{value:r,children:t})}function ql(e,t){let n=h(ha(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var Jl=20,Yl=[];function Xl(){Yl=Yl.filter(e=>e.deref()?.isConnected)}function Zl(e){Xl(),e&&se(e)!==`body`&&(Yl.push(new WeakRef(e)),Yl.length>Jl&&(Yl=Yl.slice(-20)))}function Ql(){return Xl(),Yl[Yl.length-1]?.deref()}function $l(e){return e?pe(e)?e:Pe(e)[0]||e:null}function eu(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=oa(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return pe(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function tu(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:o=!1,modal:s=!0,closeOnFocusOut:c=!0,openInteractionType:l=``,nextFocusableElement:u,previousFocusableElement:d,beforeContentFocusGuardRef:f,externalTree:m,getInsideElements:h}=e,g=`rootStore`in t?t.rootStore:t,_=g.useState(`open`),v=g.useState(`domReferenceElement`),y=g.useState(`floatingElement`),{events:b,dataRef:x}=g.context,C=G(()=>x.current.floatingContext?.nodeId),w=i===!1,T=He(v)&&w,E=Sl(i),D=Sl(a),ee=Sl(l),O=Sl(_),k=Ul(m),A=In(),j=Z.useRef(!1),M=Z.useRef(!1),N=Z.useRef(!1),P=Z.useRef(null),F=Z.useRef(``),I=Z.useRef(``),L=Z.useRef(null),R=Z.useRef(null),te=gn(L,f,A?.beforeInsideRef),z=gn(R,A?.afterInsideRef),B=Ei(),ne=Ei(),re=Bo(),ie=A!=null,V=Tn(y),oe=G((e=V)=>e?Pe(e):[]),ce=G(()=>h?.().filter(e=>e!=null)??[]);Z.useEffect(()=>{if(r||!s)return;function e(e){e.key===`Tab`&&K(V,po(zr(V)))&&oe().length===0&&!T&&Hc(e)}let t=zr(V);return us(t,`keydown`,e)},[r,V,s,T,oe]),Z.useEffect(()=>{if(r||!_)return;let e=zr(V);function t(){N.current=!1}function n(e){let t=ha(e),n=ce(),r=K(y,t)||K(v,t)||K(A?.portalNode,t)||n.some(e=>e===t||K(e,t));N.current=!r,I.current=e.pointerType||`keyboard`,t?.closest(`[data-base-ui-click-trigger]`)&&(M.current=!0,ne.start(0,()=>{M.current=!1}))}function i(){I.current=`keyboard`}return rs(us(e,`pointerdown`,n,!0),us(e,`pointerup`,t,!0),us(e,`pointercancel`,t,!0),us(e,`keydown`,i,!0),t)},[r,y,v,V,_,A,ne,ce]),Z.useEffect(()=>{if(r||!c)return;let e=zr(V);function t(){M.current=!0,ne.start(0,()=>{M.current=!1})}function n(e){let t=ha(e);pe(t)&&(P.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=ha(t);s&&n==null&&i!=null&&K(y,i)&&Zl(i),queueMicrotask(()=>{let a=C(),c=g.context.triggerElements,l=ce(),f=n?.hasAttribute(ke(`focus-guard`))&&[L.current,R.current,A?.beforeInsideRef.current,A?.afterInsideRef.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,Rr(d),Rr(u)].includes(n),p=!(K(v,n)||K(y,n)||K(n,y)||K(A?.portalNode,n)||l.some(e=>e===n||K(e,n))||c.hasMatchingElement(e=>K(e,n))||f||k&&(Bc(k.nodesRef.current,a).find(e=>K(e.context?.elements.floating,n)||K(e.context?.elements.domReference,n))||Vc(k.nodesRef.current,a).find(e=>[e.context?.elements.floating,Tn(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===v&&V&&eu(V),o&&r!==v&&!S(i)&&po(e)===e.body){if(bt(V)&&(V.focus(),o===`popup`)){re.request(()=>{V.focus()});return}let e=oe(),t=P.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||V;bt(n)&&n.focus()}if(x.current.insideReactTree){x.current.insideReactTree=!1;return}(T||!s)&&n&&p&&!M.current&&(T||n!==Ql())&&(j.current=!0,g.setOpen(!1,On(Ke,t)))})}function a(){N.current||(x.current.insideReactTree=!0,B.start(0,()=>{x.current.insideReactTree=!1}))}let l=bt(v)?v:null;if(y||l)return rs(l&&us(l,`focusout`,i),l&&us(l,`pointerdown`,t),y&&us(y,`focusin`,n),y&&us(y,`focusout`,i),y&&A&&us(y,`focusout`,a,!0))},[r,v,y,V,s,k,A,g,c,o,oe,T,C,x,B,ne,re,u,d,ce]),Z.useEffect(()=>{if(r||!y||!_)return;let e=Array.from(A?.portalNode?.querySelectorAll(`[${ke(`portal`)}]`)||[]),t=(k?Vc(k.nodesRef.current,C()):[]).find(e=>He(e.context?.elements.domReference||null))?.context?.elements.domReference,n=Ll([y,...e,L.current,R.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,...ce(),t,Rr(d),Rr(u),T?v:null].filter(e=>e!=null),{ariaHidden:s||T,mark:!1}),i=Ll([y,...e].filter(e=>e!=null));return()=>{i(),n()}},[_,r,v,y,s,A,T,k,C,u,d,ce]),U(()=>{if(!_||r||!bt(V))return;F.current=``,I.current=``;let e=zr(V),t=po(e);queueMicrotask(()=>{let n=E.current,r=typeof n==`function`?n(ee.current||``):n;if(r===void 0||r===!1||K(V,t))return;let i=null,a=()=>(i??=oe(V),i[0]||V),o;o=r===!0||r===null?a():Rr(r),o||=a();let s=K(V,po(e));Tl(o,{preventScroll:o===V,shouldFocus(){if(!O.current)return!1;if(s)return!0;let t=po(e);return!(t!==o&&K(V,t))}})})},[r,_,V,oe,E,ee,O]),U(()=>{if(r||!V)return;let e=zr(V),t=po(e),n=ee.current==null;Zl(t);function i(e){if(e.open||(F.current=ql(e.nativeEvent,I.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(j.current=!0),e.reason===`outside-press`){if(e.nested)j.current=!1;else if(Wc(e.nativeEvent)||Gc(e.nativeEvent))j.current=!1;else{let e=!1;zr(V).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?j.current=!1:j.current=!0}}}b.on(`openchange`,i);function a(e){let r=D.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=v?.isConnected?v:null,o=t?.isConnected&&se(t)!==`body`?t:null,s=n?o||a:a||o;return s||=Ql()||null,typeof i==`boolean`?s:Rr(i)||s||null}return()=>{b.off(`openchange`,i);let t=po(e),n=ce(),r=K(y,t)||n.some(e=>e===t||K(e,t))||k&&Bc(k.nodesRef.current,C(),!1).some(e=>K(e.context?.elements.floating,t)),o=D.current,s=F.current,c=a(s);queueMicrotask(()=>{let n=$l(c),i=typeof o!=`boolean`;if(o&&!j.current&&bt(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}j.current=!1})}},[r,y,V,D,ee,b,k,v,C,ce]),U(()=>{if(!ti||_||!y)return;let e=po(zr(y));bt(e)&&nr(e)&&K(y,e)&&e.blur()},[_,y]),U(()=>{if(!r&&A)return A.setFocusManagerState({modal:s,closeOnFocusOut:c,open:_,onOpenChange:g.setOpen,domReference:v}),()=>{A.setFocusManagerState(null)}},[r,A,s,_,g,c,v]),U(()=>{if(!r&&V)return eu(V),()=>{queueMicrotask(Xl)}},[r,V]);let le=!r&&(!s||!T)&&(ie||s);return(0,Q.jsxs)(Z.Fragment,{children:[le&&(0,Q.jsx)(ae,{"data-type":`inside`,ref:te,onFocus:e=>{if(s){let e=oe();Tl(e[e.length-1])}else A?.portalNode&&(j.current=!1,Lt(e,A.portalNode)?p(v)?.focus():Rr(d??A.beforeOutsideRef)?.focus())}}),n,le&&(0,Q.jsx)(ae,{"data-type":`inside`,ref:z,onFocus:e=>{s?Tl(oe()[0]):A?.portalNode&&(c&&(j.current=!0),Lt(e,A.portalNode)?Zi(v)?.focus():Rr(u??A.afterOutsideRef)?.focus())}})]})}function nu(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=Or}=t,l=`rootStore`in e?e.rootStore:e,u=l.context.dataRef,d=Z.useRef(void 0),f=Bo(),p=Ei(),m=Z.useMemo(()=>{function e(e,t,n,r){let i=On(c,t,n);e&&r===`touch`&&s>0?p.start(s,()=>{l.setOpen(!0,i)}):l.setOpen(e,i)}function t(e,t,n){let r=u.current.openEvent,a=l.select(`domReferenceElement`)!==t;return e&&a||!e||!i?!0:r&&o?!n(r.type):!1}return{onPointerDown(e){d.current=Kc(e.pointerType,!0)&&Gc(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(n){let i=d.current,o=n.nativeEvent,s=l.select(`open`);if(n.button!==0||r===`click`||Kc(i,!0)&&a)return;let c=t(s,n.currentTarget,e=>e===`click`||e===`mousedown`),u=ha(o);if(nr(u)){e(c,o,u,i);return}let p=n.currentTarget;f.request(()=>{e(c,o,p,i)})},onClick(n){if(r===`mousedown-only`)return;let i=d.current;if(r===`mousedown`&&i){d.current=void 0;return}Kc(i,!0)&&a||e(t(l.select(`open`),n.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),n.nativeEvent,n.currentTarget,i)},onKeyDown(){d.current=void 0}}},[u,r,a,c,l,o,i,f,p,s]);return Z.useMemo(()=>n?{reference:m}:ir,[n,m])}function ru(){return!1}function iu(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function au(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=ru,bubbles:s,externalTree:c}=t,l=`rootStore`in e?e.rootStore:e,u=l.useState(`open`),d=l.useState(`floatingElement`),{dataRef:f,events:p}=l.context,m=Ul(c),h=G(typeof i==`function`?i:()=>!1),g=typeof i==`function`?h:i,_=g!==!1,v=G(()=>a),{escapeKey:y,outsidePress:b}=iu(s),x=Z.useRef(!1),S=Z.useRef(!1),C=Z.useRef(!1),w=Z.useRef(!1),T=Z.useRef(!1),E=Z.useRef(``),D=Z.useRef(null),ee=Ei(),O=Ei(),k=G(()=>{O.clear(),f.current.insideReactTree=!1}),A=G(e=>{let t=f.current.floatingContext?.nodeId;return(m?Bc(m.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),j=G(e=>Vn(e,l.select(`floatingElement`))||Vn(e,l.select(`domReferenceElement`))),M=G(e=>{o()&&l.setOpen(!1,On(Or,e.nativeEvent))}),N=G(e=>{if(!u||!n||!r||e.key!==`Escape`||T.current||!y&&A(`__escapeKeyBubbles`))return;let t=Uc(e)?e.nativeEvent:e,i=On($a,t);l.setOpen(!1,i),i.isCanceled||e.preventDefault(),!y&&!i.isPropagationAllowed&&e.stopPropagation()}),P=G(()=>{f.current.insideReactTree=!0,O.start(0,k)}),F=G(e=>{if(!u||!n||e.button!==0)return;let t=ha(e.nativeEvent);K(l.select(`floatingElement`),t)&&(x.current||(x.current=!0,S.current=!1))}),I=G(e=>{u&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&x.current&&(S.current=!0)});Z.useEffect(()=>{function e(e){e.open||(w.current=!1)}return p.on(`openchange`,e),()=>{p.off(`openchange`,e)}},[p]),Z.useEffect(()=>{if(!u||!n)return u||(w.current=!1),k;f.current.__escapeKeyBubbles=y,f.current.__outsidePressBubbles=b;let e=new Ii,t=new Ii,i=zr(d);function a(){e.clear(),T.current=!0}function o(){e.start(ti?5:0,()=>{T.current=!1})}function s(){C.current=!0,t.start(0,()=>{C.current=!1})}function c(){x.current=!1,S.current=!1}function p(){let e=E.current,t=e===`pen`||!e?`mouse`:e,n=v(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function h(e){let t=p();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function O(e){let t=f.current.floatingContext?.nodeId,n=m&&Bc(m.nodesRef.current,t).some(t=>Vn(e,t.context?.elements.floating));return j(e)||n}function M(e){if(h(e)){e.type!==`click`&&!j(e)&&(t.clear(),C.current=!1),k();return}if(f.current.insideReactTree){k();return}let n=ha(e),r=`[${ke(`inert`)}]`,i=mt(n)?n.getRootNode():null,a=Array.from((Fe(i)?i:zr(l.select(`floatingElement`))).querySelectorAll(r)),o=l.context.triggerElements;if(n&&(o.hasElement(n)||o.hasMatchingElement(e=>K(e,n))))return;let s=mt(n)?n:null;for(;s&&!zt(s);){let e=ca(s);if(zt(e)||!mt(e))break;s=e}if(!(a.length&&mt(n)&&!Ze(n)&&!K(n,l.select(`floatingElement`))&&a.every(e=>!K(s,e)))){if(bt(n)&&!(`touches`in e)){let t=zt(n),r=cn(n),i=/auto|scroll/,a=t||i.test(r.overflowX),o=t||i.test(r.overflowY),s=a&&n.clientWidth>0&&n.scrollWidth>n.clientWidth,c=o&&n.clientHeight>0&&n.scrollHeight>n.clientHeight,l=r.direction===`rtl`,u=c&&(l?e.offsetX<=n.offsetWidth-n.clientWidth:e.offsetX>n.clientWidth),d=s&&e.offsetY>n.clientHeight;if(u||d)return}if(!O(e)){if(p()===`intentional`){if(e.detail!==0&&!Wc(e)&&!w.current)return;if(C.current){t.clear(),C.current=!1;return}}(typeof g!=`function`||g(e))&&(A(`__outsidePressBubbles`)||(l.setOpen(!1,On(xo,e)),k()))}}}function P(e){p()===`sloppy`&&e.pointerType!==`touch`&&l.select(`open`)&&n&&!j(e)&&M(e)}function F(e){if(p()!==`sloppy`||!l.select(`open`)||!n||j(e))return;let t=e.touches[0];t&&(D.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},ee.start(1e3,()=>{D.current&&(D.current.dismissOnTouchEnd=!1,D.current.dismissOnMouseDown=!1)}))}function I(e,t){let n=ha(e);if(!n)return;let r=us(n,e.type,()=>{t(e),r()})}function L(e){E.current=`touch`,I(e,F)}function R(e){ee.clear(),e.type===`pointerdown`&&(e.button===0&&(w.current=!0),E.current=e.pointerType),(e.type!==`mousedown`||!D.current||D.current.dismissOnMouseDown)&&I(e,e=>{e.type===`pointerdown`?P(e):M(e)})}function te(e){if(e.type===`pointercancel`&&(w.current=!1),!x.current)return;let n=S.current;if(c(),p()===`intentional`){if(e.type===`pointercancel`){n&&s();return}if(!O(e)){if(n){s();return}(typeof g!=`function`||g(e))&&(t.clear(),C.current=!0,k())}}}function z(e){if(p()!==`sloppy`||!D.current||j(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-D.current.startX),r=Math.abs(t.clientY-D.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(D.current.dismissOnTouchEnd=!0),i>10&&(M(e),ee.clear(),D.current=null)}function B(e){I(e,z)}function ne(e){p()===`sloppy`&&D.current&&!j(e)&&(D.current.dismissOnTouchEnd&&M(e),ee.clear(),D.current=null)}function re(e){I(e,ne)}let ie=rs(r&&rs(us(i,`keydown`,N),us(i,`compositionstart`,a),us(i,`compositionend`,o)),_&&rs(us(i,`click`,R,!0),us(i,`pointerdown`,R,!0),us(i,`pointerup`,te,!0),us(i,`pointercancel`,te,!0),us(i,`mousedown`,R,!0),us(i,`mouseup`,te,!0),us(i,`touchstart`,L,{capture:!0,passive:!0}),us(i,`touchmove`,B,{capture:!0,passive:!0}),us(i,`touchend`,re,{capture:!0,passive:!0})));return()=>{ie(),e.clear(),t.clear(),c(),C.current=!1,k()}},[f,d,r,_,g,u,n,y,b,N,k,v,A,j,m,l,ee]);let L=Z.useMemo(()=>({onKeyDown:N,onPointerDown:M,onClick:M}),[N,M]),R=Z.useMemo(()=>({onKeyDown:N,onPointerDown:I,onMouseDown:I,onClickCapture:P,onMouseDownCapture(e){P(),F(e)},onPointerDownCapture(e){P(),F(e)},onMouseUpCapture:P,onTouchEndCapture:P,onTouchMoveCapture:P}),[N,P,F,I]);return Z.useMemo(()=>n?{reference:L,floating:R,trigger:L}:{},[n,L,R])}function ou(e,t,n){let{reference:r,floating:i}=e,a=ol(t),o=sl(t),s=al(o),c=nl(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=rl(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function su(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=tl(t,e),p=yl(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=bl(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=bl(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var cu=50,lu=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:su},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ou(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<cu&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=ou(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},uu=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=tl(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=nl(r),_=ol(o),v=nl(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[_l(o)]:ll(o)),x=p!==`none`;!d&&x&&b.push(...gl(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=cl(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===ol(t)||T.every(e=>ol(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=ol(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},du=new Set([`left`,`top`]);async function fu(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=nl(n),s=rl(n),c=ol(n)===`y`,l=du.has(o)?-1:1,u=a&&c?-1:1,d=tl(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var pu=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await fu(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},mu=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=tl(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=ol(i),p=il(f),m=u[p],h=u[f],g=(e,t)=>el(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},hu=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=tl(e,t),u={x:n,y:r},d=ol(i),f=il(d),p=u[f],m=u[d],h=tl(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=du.has(nl(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},gu=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=tl(e,t),c=await i.detectOverflow(t,s),l=nl(n),u=rl(n),d=ol(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Jc(p-c[m],g),y=Jc(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Yc(c.left,c.right):S=p-2*Yc(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function _u(e){let t=cn(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=bt(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Xc(n)!==a||Xc(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function vu(e){return mt(e)?e:e.contextElement}function yu(e){let t=vu(e);if(!bt(t))return Qc(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=_u(t),o=(a?Xc(n.width):n.width)/r,s=(a?Xc(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var bu=Qc(0);function xu(e){let t=h(e);return!vs()||!t.visualViewport?bu:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Su(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===h(e)}function Cu(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=vu(e),o=Qc(1);t&&(r?mt(r)&&(o=yu(r)):o=yu(e));let s=Su(a,n,r)?xu(a):Qc(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=h(a),t=mt(r)?h(r):r,n=e,i=vn(n);for(;i&&t!==n;){let e=yu(i),t=i.getBoundingClientRect(),r=cn(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=h(i),i=vn(n)}}return bl({width:u,height:d,x:c,y:l})}function wu(e,t){let n=te(e).scrollLeft;return t?t.left+n:Cu(Yo(e)).left+n}function Tu(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-wu(e,n),y:n.top+t.scrollTop}}function Eu(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Yo(r),s=t?en(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Qc(1),u=Qc(0),d=bt(r);if((d||!a)&&((se(r)!==`body`||he(o))&&(c=te(r)),d)){let e=Cu(r);l=yu(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Tu(o,c):Qc(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Du(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Ou(e){let t=te(e),n=e.ownerDocument.body,r=Yc(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Yc(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+wu(e),o=-t.scrollTop;return cn(n).direction===`rtl`&&(a+=Yc(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var ku=25;function Au(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=h(e),a=Yo(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!vs()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(wu(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=ku&&(s-=o)}return{width:s,height:c,x:l,y:u}}function ju(e,t){let n=Cu(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=yu(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Mu(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Au(e,n,t);else if(t===`document`)r=Ou(Yo(e));else if(mt(t))r=ju(t,n);else{let n=xu(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return bl(r)}function Nu(e,t){let n=t.get(e);if(n)return n;let r=kt(e,[],!1).filter(e=>mt(e)&&se(e)!==`body`),i=null,a=cn(e).position===`fixed`,o=a?ca(e):e;for(;mt(o)&&!zt(o);){let e=cn(o),t=$i(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=ca(o)}return t.set(e,r),r}function Pu(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?en(t)?[]:Nu(t,this._c):[].concat(n),r],o=Mu(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Mu(t,a[e],i);s=Yc(n.top,s),c=Jc(n.right,c),l=Jc(n.bottom,l),u=Yc(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Fu(e){let{width:t,height:n}=_u(e);return{width:t,height:n}}function Iu(e,t,n){let r=bt(t),i=Yo(t),a=n===`fixed`,o=Cu(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Qc(0);if((r||!a)&&((se(t)!==`body`||he(i))&&(s=te(t)),r)){let e=Cu(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=wu(i));let l=i&&!r&&!a?Tu(i,s):Qc(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Lu(e){return cn(e).position===`static`}function Ru(e,t){if(!bt(e)||cn(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Yo(e)===n&&(n=n.ownerDocument.body),n}function zu(e,t){let n=h(e);if(en(e))return n;if(!bt(e)){let t=ca(e);for(;t&&!zt(t);){if(mt(t)&&!Lu(t))return t;t=ca(t)}return n}let r=Ru(e,t);for(;r&&ot(r)&&Lu(r);)r=Ru(r,t);return r&&zt(r)&&Lu(r)&&!$i(r)?n:r||j(e)||n}var Bu=async function(e){let t=this.getOffsetParent||zu,n=this.getDimensions,r=await n(e.floating);return{reference:Iu(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Vu(e){return cn(e).direction===`rtl`}var Hu={convertOffsetParentRelativeRectToViewportRelativeRect:Eu,getDocumentElement:Yo,getClippingRect:Pu,getOffsetParent:zu,getElementRects:Bu,getClientRects:Du,getDimensions:Fu,getScale:yu,isElement:mt,isRTL:Vu};function Uu(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Wu(e,t,n){let r=null,i,a=Yo(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Zc(d),h=Zc(a.clientWidth-(u+f)),g=Zc(a.clientHeight-(d+p)),_=Zc(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Yc(0,Jc(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Uu(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=h(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Gu(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=vu(e),u=i||a?[...l?kt(l):[],...t?kt(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Wu(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Cu(e):null;c&&g();function g(){let t=Cu(e);h&&!Uu(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Ku=pu,qu=mu,Ju=uu,Yu=gu,Xu=hu,Zu=(e,t,n)=>{let r=new Map,i=n??{},a={...Hu,...i.platform,_c:r};return lu(e,t,{...i,platform:a})},Qu=typeof document<`u`?Z.useLayoutEffect:function(){};function $u(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!$u(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!$u(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function ed(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function td(e,t){let n=ed(e);return Math.round(t*n)/n}function nd(e){let t=Z.useRef(e);return Qu(()=>{t.current=e}),t}function rd(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=Z.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=Z.useState(r);$u(f,r)||p(r);let[m,h]=Z.useState(null),[g,_]=Z.useState(null),v=Z.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=Z.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=Z.useRef(null),C=Z.useRef(null),w=Z.useRef(u),T=c!=null,E=nd(c),D=nd(i),ee=nd(l),O=Z.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Zu(S.current,C.current,e).then(e=>{let t={...e,isPositioned:ee.current!==!1};k.current&&!$u(w.current,t)&&(w.current=t,Tc.flushSync(()=>{d(t)}))})},[f,t,n,D,ee]);Qu(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let k=Z.useRef(!1);Qu(()=>(k.current=!0,()=>{k.current=!1}),[]),Qu(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,O);O()}},[b,x,O,E,T]);let A=Z.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),j=Z.useMemo(()=>({reference:b,floating:x}),[b,x]),M=Z.useMemo(()=>{let e={position:n,left:0,top:0};if(!j.floating)return e;let t=td(j.floating,u.x),r=td(j.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...ed(j.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,j.floating,u.x,u.y]);return Z.useMemo(()=>({...u,update:O,refs:A,elements:j,floatingStyles:M}),[u,O,A,j,M])}var id=(e,t)=>{let n=Ku(e);return{name:n.name,fn:n.fn,options:[e,t]}},ad=(e,t)=>{let n=qu(e);return{name:n.name,fn:n.fn,options:[e,t]}},od=(e,t)=>({fn:Xu(e).fn,options:[e,t]}),sd=(e,t)=>{let n=Ju(e);return{name:n.name,fn:n.fn,options:[e,t]}},cd=(e,t)=>{let n=Yu(e);return{name:n.name,fn:n.fn,options:[e,t]}},ld={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},ud=class extends w{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:Rl(),nested:n,triggerElements:i},ld),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&qc(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{if(this.syncOnly){this.context.onOpenChange?.(e,t);return}this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function dd(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),l=t.useState(n?`popupElement`:`positionerElement`),u=t.context.triggerElements,d=o,f=Z.useRef(null);r===void 0&&f.current===null&&(f.current=new ud({open:s,transitionStatus:void 0,referenceElement:c,floatingElement:l,triggerElements:u,onOpenChange:d,floatingId:i,syncOnly:!0,nested:a}));let p=r??f.current;return t.useSyncedValue(`floatingId`,i),U(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};mt(c)&&(e.domReferenceElement=c),p.state.positionReference===p.state.referenceElement&&(e.positionReference=c),p.update(e)},[s,i,c,l,p]),p.context.onOpenChange=d,p.context.nested=a,p}function fd(e,t=!1,n=!1,r=!1){let[i,a]=Z.useState(e&&t?`idle`:void 0),[o,s]=Z.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),U(()=>{if(!e&&o&&i!==`ending`&&n){let e=br.request(()=>{a(`ending`)});return()=>{br.cancel(e)}}},[e,o,i,n]),U(()=>{if(!e||t)return;let n=br.request(()=>{a(void 0)});return()=>{br.cancel(n)}},[t,e]),U(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=br.request(()=>{a(`idle`)});return()=>{br.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}var pd={tabIndex:-1,[Ia]:``};function md(e){return t=>t!==`touch`||e.current}function hd(e,t=!1){let n=$r(),r=Hl()!=null,i=$e(()=>e(n,r)).current;return dd({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function gd({handle:e,store:t}){return U(()=>e.attachStore(t),[e,t]),null}function _d(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function vd(e,t){let n=Z.useRef(null);return G(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),_d(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),_d(t))})}function yd(e,t,n,r=!1){let i=e.preventUnmountingOnClose;t?i=!1:r&&(i=!0);let a=n?.id??null,o=e.activeTriggerId,s=e.activeTriggerElement;return(a||t)&&(o=a,s=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:o,activeTriggerElement:s}}function bd(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function xd(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=vd(e,n),o=G(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e);return}if(a==null&&i){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=G(e=>{a(e),e&&o(e)});return U(()=>(s(t.current),()=>s(null)),[s,t,n,e]),U(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function Sd(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=Z.useRef(null),i=e.useState(`open`),a=e.useState(`triggerCount`),o=e.useState(`activeTriggerId`),s=e.useState(`activeTriggerElement`);U(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=On(si);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,a,o,s,n])}function Cd(e,t,n,r){let{mounted:i,setMounted:a,transitionStatus:o}=fd(e,!1,!1,r),s=t.useState(`preventUnmountingOnClose`),c=!e&&s;t.useSyncedValues({mounted:i,transitionStatus:o,preventUnmountingOnClose:c});let l=G(()=>{a(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return zo({enabled:i&&!e&&!c,open:e,ref:t.context.popupRef,onComplete(){e||l()}}),{forceUnmount:l,transitionStatus:o}}function wd(e,t){e.useSyncedValues(t),U(()=>()=>{e.update({activeTriggerProps:ir,inactiveTriggerProps:ir,popupProps:ir})},[e])}function Td(e,t){U(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),U(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var Ed=class{constructor(){this.idMap=new Map}add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}};function Dd(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=$r(),a=Hl()!=null,o=$e(()=>new ud({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Ed,floatingId:i,syncOnly:!1,nested:a})).current;return U(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=mt(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}function Od(e){return kd(e,e.rootContext)}function kd(e,t){let{nodeId:n,externalTree:r}=e,i=t.useState(`referenceElement`),a=t.useState(`floatingElement`),o=t.useState(`domReferenceElement`),s=t.useState(`open`),c=t.useState(`floatingId`),[l,u]=Z.useState(null),[d,f]=Z.useState(void 0),[p,m]=Z.useState(void 0),h=Z.useRef(null),g=Ul(r),_=Z.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),v=rd({...e,elements:{..._,...l&&{reference:l}}}),y=mt(d)?d:null,b=p===void 0?t.state.floatingElement:p;t.useSyncedValue(`referenceElement`,d??null),t.useSyncedValue(`domReferenceElement`,d===void 0?o:y),t.useSyncedValue(`floatingElement`,b);let x=Z.useCallback(e=>{let t=mt(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),v.refs.setReference(t)},[v.refs]),S=Z.useCallback(e=>{(mt(e)||e===null)&&(h.current=e,f(e)),(mt(v.refs.reference.current)||v.refs.reference.current===null||e!==null&&!mt(e))&&v.refs.setReference(e)},[v.refs,f]),C=Z.useCallback(e=>{m(e),v.refs.setFloating(e)},[v.refs]),w=Z.useMemo(()=>({...v.refs,setReference:S,setFloating:C,setPositionReference:x,domReference:h}),[v.refs,S,C,x]),T=Z.useMemo(()=>({...v.elements,domReference:o}),[v.elements,o]),E=Z.useMemo(()=>({...v,dataRef:t.context.dataRef,open:s,onOpenChange:t.setOpen,events:t.context.events,floatingId:c,refs:w,elements:T,nodeId:n,rootStore:t}),[v,w,T,n,t,s,c]);return U(()=>{o&&(h.current=o)},[o]),U(()=>{t.context.dataRef.current.floatingContext=E;let e=g?.nodesRef.current.find(e=>e.id===n);e&&(e.context=E)}),Z.useMemo(()=>({...v,context:E,refs:w,elements:T,rootStore:t}),[v,w,T,E,t])}var Ad=`Escape`;function jd(e){return ti&&e.movementX===0&&e.movementY===0}function Md(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function Nd(e,t){return Md(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function Pd(e,t,n){return Md(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Fd(e,t,n){return Md(t,n?e===io:e===Wi,e===ka)}function Id(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===Ad:Md(t,n?e===Wi:e===io,e===Ar)}function Ld(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,parentOrientation:_,id:v,resetOnPointerLeave:y=!0,externalTree:b,grid:x}=t,S=x!=null,C=`rootStore`in e?e.rootStore:e,w=C.useState(`open`),T=C.useState(`floatingElement`),E=C.useState(`domReferenceElement`),D=C.context.dataRef,ee=Tn(T),O=He(E),k=Sl(ee),A=Hl(),j=Ul(b),M=Z.useRef(f),N=Z.useRef(o??-1),P=Z.useRef(null),F=Z.useRef(!0),I=G(e=>{i(N.current===-1?null:N.current,e)}),L=Z.useRef(!!T),R=Z.useRef(w),te=Z.useRef(!1),z=Z.useRef(!1),B=Z.useRef(null),ne=Sl(h),re=Sl(w),ie=Sl(o),V=Sl(y),ae=Bo(),oe=Bo(),se=G(()=>{function e(e){d?j?.events.emit(`virtualfocus`,e):B.current=Tl(e,{sync:te.current,preventScroll:!0})}let t=n.current[N.current],r=z.current;t&&e(t),(te.current?e=>e():e=>ae.request(e))(()=>{let i=n.current[N.current]||t;i&&(t||e(i),pe&&(r||!F.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});U(()=>{D.current.orientation=g},[D,g]),U(()=>{a&&(w&&T?(N.current=o??-1,M.current&&o!=null&&(z.current=!0,I())):L.current&&(N.current=-1,I()))},[a,w,T,o,I]),U(()=>{if(a){if(!w){te.current=!1;return}if(T){if(r==null){if(te.current=!1,ie.current!=null)return;if(L.current&&(N.current=-1,se()),(!R.current||!L.current)&&M.current&&(P.current!=null||M.current===!0&&P.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>oe.request(e):queueMicrotask)(t),e+=1):(N.current=P.current==null||Pd(P.current,g,u)||l?gs(n):$t(n),P.current=null,I())};t()}}else Nn(n.current,r)||(N.current=r,se(),z.current=!1)}}},[a,w,T,r,ie,l,n,g,u,I,se,oe]),U(()=>{if(!a||T||!j||d||!L.current)return;let e=j.nodesRef.current,t=e.find(e=>e.id===A)?.context?.elements.floating,n=po(zr(E??t??null)),r=e.some(e=>e.context&&K(e.context.elements.floating,n));t&&!r&&F.current&&t.focus({preventScroll:!0})},[a,T,E,j,A,d]),U(()=>{R.current=w,L.current=!!T}),U(()=>{w||(P.current=null,M.current=f)},[w,f]);let ce=r!=null,le=G(e=>{if(!re.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(N.current!==t||r!==t)&&(N.current=t,I(e))}),ue=G(()=>_??j?.nodesRef.current.find(e=>e.id===A)?.context?.dataRef?.current.orientation),de=G(()=>gs(n,ne.current)),fe=G(e=>{if(F.current=!1,te.current=!0,e.which===229||!re.current&&e.currentTarget===k.current)return;if(l&&Id(e.key,g,u,S)){Nd(e.key,ue())||Hc(e),C.setOpen(!1,On(Jt,e.nativeEvent)),bt(E)&&(d?j?.events.emit(`virtualfocus`,E):E.focus());return}let t=N.current,r=gs(n,h),i=$t(n,h);if(O||(e.key===`Home`&&(Hc(e),N.current=r,I(e)),e.key===`End`&&(Hc(e),N.current=i,I(e))),x!=null){let t=x(e,N.current,n,g,c,u,h,r,i);if(t!=null&&(N.current=t,I(e)),g===`both`)return}if(Nd(e.key,g)){if(Hc(e),w&&!d&&po(e.currentTarget.ownerDocument)===e.currentTarget){N.current=Pd(e.key,g,u)?r:i,I(e);return}Pd(e.key,g,u)?c?t>=i?s&&t!==n.current.length?N.current=-1:(te.current=!1,N.current=r):N.current=at(n.current,{startingIndex:t,disabledIndices:h}):N.current=Math.min(i,at(n.current,{startingIndex:t,disabledIndices:h})):c?t<=r?s&&t!==-1?N.current=n.current.length:(te.current=!1,N.current=i):N.current=at(n.current,{startingIndex:t,decrement:!0,disabledIndices:h}):N.current=Math.max(r,at(n.current,{startingIndex:t,decrement:!0,disabledIndices:h})),Nn(n.current,N.current)&&(N.current=-1),I(e)}}),pe=Z.useMemo(()=>({onFocus(e){te.current=!0,le(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){jd(e)||(te.current=!0,z.current=!1,p&&le(e))},onPointerLeave(e){if(!re.current||!F.current||e.pointerType===`touch`)return;te.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&V.current&&(B.current?.(),B.current=null,N.current=-1,I(e),!d)){let e=k.current,t=po(zr(e));e&&K(e,t)&&e.focus({preventScroll:!0})}}}),[le,re,k,p,n,I,V,d]),me=Z.useMemo(()=>d&&w&&ce&&{"aria-activedescendant":`${v}-${r}`},[d,w,ce,v,r]),he=Z.useMemo(()=>({...O?{}:me,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&w&&!d){let t=ha(e.nativeEvent);if(t&&!K(k.current,t))return;Hc(e),C.setOpen(!1,On(Ke,e.nativeEvent)),bt(E)&&E.focus();return}fe(e)},onPointerMove(e){jd(e)||(F.current=!0)}}),[me,fe,k,O,C,w,d,E]),ge=Z.useMemo(()=>{function e(e){C.setOpen(!0,On(Jt,e.nativeEvent,e.currentTarget))}function t(e){f===`auto`&&Wc(e.nativeEvent)&&(M.current=!d)}function n(e){M.current=f,f===`auto`&&Gc(e.nativeEvent)&&(M.current=!0)}return{onKeyDown(t){let n=C.select(`open`);F.current=!1;let r=t.key.startsWith(`Arrow`),i=Fd(t.key,ue(),u),a=Nd(t.key,g),o=(l?i:a)||t.key===`Enter`||t.key.trim()===``;if(d&&n)return fe(t);if(n||m||!r){if(o){let e=Nd(t.key,ue());P.current=l&&e?null:t.key}if(l){i&&(Hc(t),n?(N.current=de(),I(t)):e(t));return}a&&(ie.current!=null&&(N.current=ie.current),Hc(t),!n&&m?e(t):fe(t),n&&I(t))}},onFocus(e){C.select(`open`)&&!d&&(N.current=-1,I(e))},onPointerDown:n,onPointerEnter:n,onMouseDown:t,onClick:t}},[fe,f,de,l,I,C,m,g,ue,u,ie,d]),_e=Z.useMemo(()=>({...me,...ge}),[me,ge]);return Z.useMemo(()=>a?{reference:_e,floating:he,item:pe,trigger:ge}:{},[a,_e,he,ge,pe])}function Rd(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=`rootStore`in e?e.rootStore:e,f=d.useState(`open`),p=Ei(),m=Z.useRef(``),h=Z.useRef(u??i??-1),g=Z.useRef(null),_=G(e=>{function t(e){return r?.current[e]}function c(e){let n=t(e);return n&&!S(n)||n?.matches(`:disabled`)?!1:o==null||!Ee(We,e,o)}function d(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&c(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(Hc(e),s?.(!0)),m.current.length>0&&m.current[0]!==` `&&d(_,m.current)===-1&&e.key!==` `&&s?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(Hc(e),s?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&c(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,s?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=d(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,s?.(!1)):(a?.(b),g.current=b)}),v=G(e=>{let t=e.relatedTarget,n=d.select(`domReferenceElement`),r=d.select(`floatingElement`);K(n,t)||K(r,t)||(p.clear(),m.current=``,h.current=g.current,s?.(!1))});U(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``))},[f,u,p]);let y=Z.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return Z.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var zd=Z.createContext(void 0);function Bd(){return Z.useContext(zd)?.direction??`ltr`}var Vd=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0,offsetParent:d=`real`}=tl(e,t)||{};if(l==null)return{};let f=yl(u),p={x:n,y:r},m=sl(i),h=al(m),g=await o.getDimensions(l),_=m===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,x=a.reference[h]+a.reference[m]-p[m]-a.floating[h],S=p[m]-a.reference[m],C=d===`real`?await o.getOffsetParent?.(l):s.floating,w=s.floating[b]||a.floating[h];(!w||!await o.isElement?.(C))&&(w=s.floating[b]||a.floating[h]);let T=x/2-S/2,E=w/2-g[h]/2-1,D=Math.min(f[v],E),ee=Math.min(f[y],E),O=D,k=w-g[h]-ee,A=w/2-g[h]/2+T,j=el(O,A,k),M=!c.arrow&&rl(i)!=null&&A!==j&&a.reference[h]/2-(A<O?D:ee)-g[h]/2<0,N=M?A<O?A-O:A-k:0;return{[m]:p[m]+N,data:{[m]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),Hd=(e,t)=>{let{name:n,fn:r}=Vd(e);return{name:n,fn:r,options:[e,t]}},Ud={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},Wd={sideX:`left`,sideY:`top`},Gd=`--available-width`,Kd=`--available-height`,qd=`--anchor-width`,Jd=`--anchor-height`,Yd=`--transform-origin`,Xd=Gd,Zd=Kd;function Qd(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function $d(e,t,n){let{rects:r,placement:i}=e;return{side:Qd(t,nl(i),n),align:rl(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function ef(e){return tf(e,Od)}function tf(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:g,mounted:_,collisionAvoidance:v,shift:y,nodeId:b,adaptiveOrigin:x,lazyFlip:S=!1,externalTree:C}=e,[w,T]=Z.useState(null);!_&&w!==null&&T(null);let E=v.side||`flip`,D=v.align||`flip`,ee=v.fallbackAxisSide||`end`,O=y?.crossAxis??!1,k=y?.rootBoundary,A=typeof n==`function`?n:void 0,j=G(A),M=A?j:n,N=Sl(n),P=Sl(_),F=Bd()===`rtl`,I=w||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":F?`left`:`right`,"inline-start":F?`right`:`left`}[i],L=o===`center`?I:`${I}-${o}`,R=l;typeof R==`number`?R={top:R,right:R,bottom:R,left:R}:R&&={top:R.top||0,right:R.right||0,bottom:R.bottom||0,left:R.left||0};let te=+(i===`bottom`),z=+(i===`top`),B=+(i===`right`),ne=+(i===`left`),re={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:R},ie=Z.useRef(null),V=Sl(a),ae=Sl(s),oe=typeof a==`function`?0:a,se=typeof s==`function`?0:s,ce=[];p&&ce.push(p),ce.push(id(e=>{let t=$d(e,i,F),n=typeof V.current==`function`?V.current(t):V.current,r=typeof ae.current==`function`?ae.current(t):ae.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[oe,se,F,i]));let le=D===`none`&&E!==`shift`,ue=!le&&(u||O||E===`shift`),de=E===`none`?null:sd({...re,padding:{top:R.top+1+te,right:R.right+1+ne,bottom:R.bottom+1+z,left:R.left+1+B},mainAxis:!O&&E===`flip`,crossAxis:D===`flip`&&`alignment`,fallbackAxisSideDirection:ee}),fe=le?null:ad({...re,rootBoundary:k,mainAxis:D!==`none`,crossAxis:ue,limiter:u||O?void 0:od(e=>{if(!ie.current)return{};let{width:t,height:n}=ie.current.getBoundingClientRect(),r=ol(nl(e.placement)),i=r===`y`?t:n,a=r===`y`?R.left+R.right:R.top+R.bottom;return{offset:i/2+a/2}})},[re,u,O,k,R,D]);E===`shift`||D===`shift`||o===`center`?ce.push(fe,de):ce.push(de,fe),ce.push(cd({...re,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!P.current)return;let i=e.style;i.setProperty(Xd,`${t}px`),i.setProperty(Zd,`${n}px`);let a=h(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(qd,`${u}px`),i.setProperty(Jd,`${d}px`)}}),Hd(e=>({element:ie.current||zr(e.elements.floating).createElement(`div`),padding:ie.current?d:0,offsetParent:`floating`}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=nl(r),u=rl(r),d=ol(l)===`y`,f=ie.current,p=typeof a==`function`?a($d(e,i,F)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return ue&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(Yd,d?`${m} ${h}`:`${h} ${m}`),{}}},Ud,x),U(()=>{!_&&g&&g.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[_,g]);let pe=Z.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:me,elements:he,x:ge,y:_e,middlewareData:ve,update:ye,placement:H,context:be,isPositioned:xe,floatingStyles:Se}=t({rootContext:g,open:m?_:void 0,placement:L,middleware:ce,strategy:r,whileElementsMounted:m?void 0:(...e)=>Gu(...e,pe),nodeId:b,externalTree:C}),{sideX:Ce,sideY:we}=ve.adaptiveOrigin||Wd,Te=xe?r:`fixed`,Ee=Z.useMemo(()=>{let e;return e=xe?x?{position:Te,[Ce]:ge,[we]:_e}:{...Se,position:Te}:{position:Te,top:0,left:0},e[Xd]=`100vw`,e[Zd]=`100vh`,xe||(e.opacity=0),e},[x,Te,Ce,ge,we,_e,Se,xe]),De=Z.useRef(null);U(()=>{if(!_)return;let e=N.current,t=typeof e==`function`?e():e,n=(nf(t)?t.current:t)||null;n!==De.current&&(me.setPositionReference(n),De.current=n)},[_,me,M,N]),Z.useEffect(()=>{if(!_)return;let e=N.current;typeof e!=`function`&&nf(e)&&e.current!==De.current&&(me.setPositionReference(e.current),De.current=e.current)},[_,me,M,N]),Z.useEffect(()=>{if(m&&_&&he.reference&&he.floating)return Gu(he.reference,he.floating,ye,pe)},[m,_,he,ye,pe]);let Oe=nl(H),ke=Qd(i,Oe,F),Ae=rl(H)||`center`,je=!!ve.hide?.referenceHidden;U(()=>{S&&_&&xe&&Oe!==I&&T(Oe)},[S,_,xe,Oe,I]);let Me=Z.useMemo(()=>({position:`absolute`,top:ve.arrow?.y,left:ve.arrow?.x}),[ve.arrow]),Ne=ve.arrow?.centerOffset!==0;return Z.useMemo(()=>({positionerStyles:Ee,arrowStyles:Me,arrowRef:ie,arrowUncentered:Ne,side:ke,align:Ae,physicalSide:Oe,anchorHidden:je,refs:me,context:be,isPositioned:xe,update:ye}),[Ee,Me,ie,Ne,ke,Ae,Oe,je,me,be,xe,ye])}function nf(e){return e!=null&&`current`in e}function rf(e){return e===`starting`?xa:ir}function af(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),sn(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},rf(r),i],stateAttributesMapping:Rc})}var of={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};of.node;var sf=_e(of),cf={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};cf.node;var lf=_e(cf),uf={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};uf.node;var df=_e(uf),ff={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};ff.node;var pf=_e(ff),mf={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};mf.node;var hf=_e(mf),gf={name:`monitor`,size:24,node:[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]};gf.node;var _f=_e(gf),vf={name:`server-off`,size:24,node:[[`path`,{d:`M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5`,key:`bt2siv`}],[`path`,{d:`M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z`,key:`1hjrv1`}],[`path`,{d:`M22 17v-1a2 2 0 0 0-2-2h-1`,key:`1iynyr`}],[`path`,{d:`M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z`,key:`161ggg`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};vf.node;var yf=_e(vf),bf={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};bf.node;var xf=_e(bf),Sf={name:`shield-alert`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]};Sf.node;var Cf=_e(Sf),wf={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};wf.node;var Tf=_e(wf),Ef={name:`unplug`,size:24,node:[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]};Ef.node;var Df=_e(Ef);function Of(e){return $r(e,`base-ui`)}function kf(e){let[t,n]=Z.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}var $=Er();function Af(e){let t=(0,$.c)(3),n,r;t[0]===e?(n=t[1],r=t[2]):(n=()=>(window.addEventListener(`focus`,e),window.addEventListener(`online`,e),window.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),window.removeEventListener(`online`,e),window.removeEventListener(`visibilitychange`,e)}),r=[e],t[0]=e,t[1]=n,t[2]=r),(0,Z.useEffect)(n,r)}var jf=`~effect/Cache`,Mf=(e,t)=>ba(n=>{let r=Object.create(Pf);return r.lookup=t=>on(e(t),e=>lr(n,e)),r.map=Fo(),r.capacity=t.capacity,r.timeToLive=t.timeToLive?(e,n)=>Dt(t.timeToLive(e,n)):Ff,Lr(r)}),Nf=e=>Mf(e.lookup,{...e,timeToLive:e.timeToLive===void 0?Ff:()=>e.timeToLive}),Pf={...Po,[jf]:jf,toJSON(){return{_id:`Cache`,capacity:this.capacity,map:this.map}}},Ff=(e,t)=>f,If=ki(2,(e,t)=>ri(n=>{let r=xi(e.map,t);if(qi(r)&&(as(e.map,t),!zf(r.value,n)))return Pr(e.map,t,r.value),r.value.await();let i=new Lf(n,e.lookup(t));i.onInterrupt=()=>Rf(e,t,i);let a=!1;i.fiber.addObserver(r=>{if(i.onInterrupt=void 0,Ni(r)){Rf(e,t,i);return}let o=e.timeToLive(r,t);ft(o)?(a=!0,Rf(e,t,i)):Xi(o)&&(i.expiresAt=n.getRef(Ua).currentTimeMillisUnsafe()+Ne(o))});let o=i.fiber.pollUnsafe();return!a&&(o===void 0||!Ni(o))&&Pr(e.map,t,i),Number.isFinite(e.capacity)&&Bf(e),i.await()})),Lf=class{expiresAt;awaiters;fiber;onInterrupt;constructor(e,t){this.fiber=Ro(e,t,!0,!0),this.awaiters=0,this.expiresAt=void 0}await(){return this.fiber.pollUnsafe()||(this.awaiters++,cs(vr(this.fiber),()=>(this.awaiters--,this.awaiters>0||this.fiber.pollUnsafe()?k:(this.onInterrupt?.(),wi(this.fiber)))))}},Rf=(e,t,n)=>{let r=xi(e.map,t);qi(r)&&r.value===n&&as(e.map,t)},zf=(e,t)=>e.expiresAt!==void 0&&t.getRef(Ua).currentTimeMillisUnsafe()>=e.expiresAt,Bf=e=>{let t=Zo(e.map)-e.capacity;if(!(t<=0)){for(let[n]of e.map)if(as(e.map,n),t--,t===0)return}},Vf=ki(2,(e,t)=>es(()=>{as(e.map,t)})),Hf=2**48-1,Uf=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`,Wf=(e,t)=>{if(t.length!==10)throw Error(`ULID randomness must be exactly 10 bytes, received ${t.length}`);let n=Math.min(Math.max(0,Math.trunc(e)),Hf),r=``;for(let e=45;e>=0;e-=5)r+=Uf[Math.floor(n/2**e)&31];let i=0,a=0;for(let e of t){for(i=i<<8|e,a+=8;a>=5;)a-=5,r+=Uf[i>>>a&31];i&=(1<<a)-1}return r},Gf=e=>e.toString(16).padStart(2,`0`),Kf=e=>[e.subarray(0,4),e.subarray(4,6),e.subarray(6,8),e.subarray(8,10),e.subarray(10,16)].map(e=>Array.from(e,Gf).join(``)).join(`-`),qf=()=>globalThis.crypto.getRandomValues(new Uint8Array(16));function Jf(e=qf()){return e[6]=e[6]&15|64,e[8]=e[8]&63|128,e}var Yf=e=>Kf(e===void 0?Jf():Jf(e)),Xf=2**48-1;function Zf(e,t=qf()){let n=Math.min(Math.max(0,Math.trunc(e)),Xf);return t[0]=Math.floor(n/2**40),t[1]=Math.floor(n/2**32)&255,t[2]=Math.floor(n/2**24)&255,t[3]=Math.floor(n/2**16)&255,t[4]=Math.floor(n/256)&255,t[5]=n&255,t[6]=t[6]&15|112,t[8]=t[8]&63|128,t}var Qf=(e,t)=>Kf(t===void 0?Zf(e):Zf(e,t)),$f=`~effect/Crypto`,ep=H(`effect/Crypto`),tp=e=>{let t=e.randomBytes,n=e=>Bt(np(`randomBytes`,e),t),r=e=>(e[0]&31)*2**48+e[1]*2**40+e[2]*2**32+e[3]*2**24+e[4]*2**16+e[5]*256+e[6],i=()=>r(t(7))/2**53,a=()=>{for(;;){let e=t(7),n=r(e);if(!(e[0]&32))return n+-(2**53-1);if(n<2**53-1)return n+1}};return ep.of({[$f]:$f,randomBytes:n,nextDoubleUnsafe:i,nextIntUnsafe:a,digest:e.digest,random:J(()=>i()),randomBoolean:J(()=>i()>.5),randomInt:J(()=>a()),randomBetween:(e,t)=>J(()=>ws(e,t,i())),randomIntBetween(e,t,n){let r=n?.halfOpen===!0?0:1;return J(()=>{let n=Math.ceil(e),a=Math.floor(t);return Math.floor(i()*(a-n+r))+n})},randomShuffle:e=>J(()=>{let t=Array.from(e);for(let e=t.length-1;e>=1;--e){let n=Math.min(e,Math.floor(i()*(e+1))),r=t[e];t[e]=t[n],t[n]=r}return t}),randomUUIDv4:J(()=>Yf(t(16))),randomUUIDv7:vi(e=>Vi(Qf(e.currentTimeMillisUnsafe(),t(16)))),randomULID:vi(e=>Vi(Wf(e.currentTimeMillisUnsafe(),t(10))))})},np=(e,t)=>Number.isSafeInteger(t)&&t>=0?Vi(t):X(As({module:`Crypto`,method:e,description:`size must be a non-negative safe integer`})),rp=`~effect/FiberMap`,ip=e=>wa(e,rp),ap={[rp]:rp,[Symbol.iterator](){return this.state._tag===`Closed`?hs():this.state.backing[Symbol.iterator]()},...Po,toJSON(){return{_id:`FiberMap`,state:this.state}}},op=(e,t)=>{let n=Object.create(ap);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},sp=()=>wo(J(()=>op(Ai(),Wt())),e=>Tr(()=>{let t=e.state;return t._tag===`Closed`?os:(e.state={_tag:`Closed`},Xt(nn(t.backing)).pipe(qn(e.deferred)))})),cp=-1,lp=xs(Cs(uo,Ss(cp))),up=ki(e=>ip(e[0]),(e,t,n,r)=>{if(e.state._tag===`Closed`){n.interruptUnsafe(cp);return}let i=xi(e.state.backing,t);if(i._tag===`Some`){if(i.value===n)return;if(r?.onlyIfMissing===!0){n.interruptUnsafe(cp);return}}Pr(e.state.backing,t,n),i._tag===`Some`&&i.value.interruptUnsafe(cp),n.addObserver(i=>{if(e.state._tag===`Closed`)return;let a=xi(e.state.backing,t);qi(a)&&n===a.value&&as(e.state.backing,t),ro(i)&&(r?.propagateInterruption===!0?!lp(i.cause):!ko(i.cause))&&ze(e.deferred,i)})}),dp=ki(2,(e,t)=>e.state._tag!==`Closed`&&hr(e.state.backing,t)),fp=function(){let e;return()=>(e===void 0&&(e=Zn(g)),e)}(),pp=e=>()=>Bt(Ga(),t=>{let n=pr(t);return(t,r,i)=>{if(e.state._tag===`Closed`||i?.onlyIfMissing===!0&&dp(e,t))return fp();let a=n(r,i);return up(e,t,a,i),a}}),mp=class extends H()(`@porcelain/client/EnvironmentStorage`){},hp=class extends H()(`@porcelain/client/AccessPlatform`){},gp=ei({environmentId:Ao,name:Ao,address:Ao,credential:ma(Ao),deviceId:yt(Ao)});function _p(e){return JSON.stringify(_n(Ut(gp))(e))}function vp(e,t){if(t===void 0)return{kind:`checking`};if(t.kind===`unauthorized`)return{kind:`needs-pairing`};if(t.kind===`unreachable`)return{kind:`offline`};let{environment:n}=t;return n.environmentId===e.environmentId?n.protocol===2?{kind:`online`,name:n.name,version:n.version}:{kind:`incompatible`}:{kind:`other-server`}}function yp(e,t){let n=Reflect.get(e,t);return typeof n==`string`?n:void 0}function bp(e){if(!e||typeof e!=`object`)return[];let t=yp(e,`environmentId`),n=yp(e,`name`),r=yp(e,`address`),i=yp(e,`credential`),a=yp(e,`deviceId`);return t&&n!==void 0&&r&&i?[{environmentId:t,name:n,address:r,credential:De(i),...a?{deviceId:a}:{}}]:[]}function xp(e){return Array.isArray(e)?e.flatMap(bp):[]}function Sp(e,t){return[...e.filter(e=>e.environmentId!==t.environmentId),t]}var Cp=En((e,t)=>e===t);function wp(e,t){return e.environmentId===t.environmentId&&e.address===t.address&&Cp(e.credential,t.credential)&&e.deviceId===t.deviceId}function Tp(e){switch(e.kind){case`checking`:return`Checking`;case`online`:return`Online`;case`offline`:return`Offline`;case`needs-pairing`:return`Needs pairing`;case`other-server`:return`Another server`;case`incompatible`:return`Update needed`}}function Ep(e){switch(e.kind){case`offline`:return`It did not answer. Check that it runs and that this computer reaches its address.`;case`needs-pairing`:return`It no longer accepts this app. Run porcelain pair on it and add the new link.`;case`other-server`:return`Another Porcelain answers at this address now, so this app stays away from it.`;case`incompatible`:return`It runs a Porcelain this app cannot talk to. Update both to the same version.`;default:return}}var Dp=class e extends H()(`@porcelain/client/AccessStore`){static layer=Yi(e,z(function*(){let e=yield*mp,t=Mi({remotes:[],status:`loading`,error:void 0}),n=yield*jt.make,r=Y(`AccessStore.write`)(function*(r){yield*n.enqueue(z(function*(){if(t.value.status!==`ready`)return yield*X(new B({message:`Saved environments must be read before changing them.`}));let n=r(t.value.remotes),i=`The saved environments could not be updated. Read them again before making changes.`;yield*e.write(n).pipe(ge(({cause:e})=>new B({message:i,cause:e})),fa(()=>J(()=>t.update(e=>({...e,status:`unreadable`,error:i})))),lo(()=>J(()=>t.update(e=>({...e,remotes:n})))),ji)}))});return{state:t,load:Y(`AccessStore.load`)(function*(){yield*n.enqueue(z(function*(){t.update(e=>({...e,status:`loading`,error:void 0})),yield*e.read().pipe(st({onSuccess:e=>J(()=>t.set({remotes:e,status:`ready`,error:void 0})),onFailure:()=>J(()=>t.update(e=>({...e,status:`unreadable`,error:`Saved environments could not be read. Try reading them again.`})))}),ji)}))}),save:Y(`AccessStore.save`)(e=>r(t=>Sp(t,e))),forget:Y(`AccessStore.forget`)(e=>r(t=>t.filter(t=>t.environmentId!==e)))}}))},Op=class extends H()(`@porcelain/client/ConnectionFactory`){},kp=class extends H()(`@porcelain/client/RemoteConnectionFactory`){},Ap=class e extends H()(`@porcelain/client/AccessSession`){static layer=Yi(e,z(function*(){let e=yield*Op,t=yield*y,n,r=Mi({connection:null,generation:0,writerIdentity:void 0});return{state:r,beginConnection:Y(`AccessSession.beginConnection`)((i=!1)=>J(()=>{if(i&&r.value.generation!==0)return null;let a=r.value.generation;return Y(`AccessSession.completeConnection`)(function*(i){if(a!==r.value.generation)return!1;let o=JSON.stringify(i.principal),s=r.value.connection?.environmentId===i.inventory.environmentId&&r.value.writerIdentity===o,c=n,l=r.value.connection;if(s||(c=yield*Rn(t,`sequential`),l=yield*e.local(i).pipe(et(y,c))),a!==r.value.generation)return!s&&c&&(yield*Sn(c,Dr)),!1;let u=n;return n=c,r.update(e=>({...e,connection:l,writerIdentity:o,generation:a+1})),u&&u!==n&&(yield*Sn(u,Dr)),!0},ji)})),clear:Y(`AccessSession.clear`)(function*(){let e=n;n=void 0,r.update(e=>({...e,connection:null,writerIdentity:void 0,generation:e.generation+1})),e&&(yield*Sn(e,Dr))},ji)}}))},jp=class e extends H()(`@porcelain/client/RemoteConnections`){static layer=Yi(e,z(function*(){let e=yield*kp,t=yield*y,n=yield*D(1),r=[],i=Mi([]);return{state:i,synchronize:Y(`RemoteConnections.synchronize`)(a=>z(function*(){let n=yield*M(a,n=>z(function*(){let i=r.find(e=>wp(e.remote,n));if(i)return{...i,remote:n};let a=yield*Rn(t,`sequential`);return{remote:n,connection:yield*e.open(n).pipe(et(y,a)),scope:a}})),o=r.filter(e=>!n.some(t=>t.scope===e.scope));r=n,i.set(n.map(({remote:e,connection:t})=>({remote:e,connection:t}))),yield*M(o,e=>Sn(e.scope,Dr),{discard:!0})}).pipe(Wo(n),ji))}}))},Mp=vt(z(function*(){let e=yield*Dp,t=yield*jp;yield*t.synchronize(e.state.value.remotes),yield*ii(Y(`RemoteConnections.subscribe`)(function*(t){yield*wo(J(()=>e.state.subscribe(({remotes:e})=>{ra(t,e)})),e=>J(e))})).pipe(Eo(t.synchronize),ce({startImmediately:!0}))}));function Np(e,t,n){return(r,i)=>{let a=new Headers(i?.headers);return t&&a.set(`authorization`,`Bearer ${Hn(t)}`),n(new URL(r,e),{...i,headers:a,mode:`cors`,credentials:`omit`,redirect:`error`,cache:`no-store`})}}var Pp=class extends H()(`@porcelain/client/PairingPlatform`){};function Fp(e){let t;try{t=new URL(e.trim())}catch{return}if(t.protocol!==`http:`&&t.protocol!==`https:`||t.pathname!==`/pair`)return;let n=Ip(t.hash);return n?{address:t.origin,...n}:void 0}function Ip(e){let t=new URLSearchParams(e.replace(/^#/,``)),n=t.get(`c`),r=t.get(`e`);return n&&r?{code:n,environmentId:r}:null}var Lp=Ci(No),Rp=class e extends H()(`@porcelain/client/BootstrapClient`){static layer=q(t=>nt(Yi(e,Lp),qr(t)))},zp=q(e=>ms(Rp.layer(e)));function Bp(e,t){return z(function*(){let e=yield*Rp,n=yield*ho(e.publicAccess.readEnvironment());return n.environmentId===t&&n.protocol===2&&(yield*ho(e.session.readSession())),{kind:`described`,environment:n}}).pipe(Wn(Rp.layer(e)),ni(e=>Vi(e instanceof _a&&e.status===401?{kind:`unauthorized`}:{kind:`unreachable`})),Xr(Mr),Bt(e=>di(e,()=>({kind:`unreachable`}))))}var Vp=q(({send:e,remote:t})=>Ft(eo(Bp(Np(t.address,t.credential,e),t.environmentId)).pipe(da(Tt(Ki)),fi(e=>vp(t,e).kind===`other-server`))).pipe(b(0)));function Hp(e,t){return Vp({send:e.send,remote:t})}function Up(e){return e instanceof _a?!0:e instanceof B?!1:e._tag===`InvalidPairingError`||e._tag===`InvalidDeviceDetailsError`}function Wp(e,t){return z(function*(){let n=Fp(t);if(!n)return yield*X(new B({message:`Paste the whole link porcelain pair printed, starting with http.`}));let r=Np(n.address,void 0,e.send),i=yield*ho(z(function*(){return yield*(yield*Rp).pairing.redeemPairing({payload:{code:n.code,platform:e.name()}})}).pipe(Wn(Rp.layer(r)))).pipe(ge(e=>Up(e)?new B({message:`That link was not accepted. It works once, for a few minutes; run porcelain pair again.`}):e instanceof B?new B({message:`Could not reach ${n.address}. Check that Porcelain runs there and that this computer reaches it.`,cause:e.cause}):e));if(!i.credential)return yield*X(new B({message:`The remote paired but sent no credential.`}));let a=De(i.credential),o=vp(n,yield*Bp(Np(n.address,a,e.send),n.environmentId));return o.kind===`online`?{environmentId:n.environmentId,address:n.address,name:o.name,credential:a,deviceId:i.device.id}:yield*X(new B({message:o.kind===`other-server`?`Another Porcelain answered at that address than the one that made the link.`:o.kind===`incompatible`?`That Porcelain runs a version this app cannot talk to. Update both to the same version.`:`The remote paired but did not answer afterwards. Try again.`}))})}var Gp=Y(`Environments.pairAndSave`)(function*(e){let t=yield*Dp,n=yield*hp;if(t.state.value.status!==`ready`)return yield*X(new B({message:`Read saved environments before pairing.`}));let r=yield*Wp(n,e);return yield*t.save(r),r}),Kp=Y(`BrowserSession.pair`)(function*(e){let t=yield*Pp,n=yield*Rp;if((yield*ho(n.publicAccess.readHealth()).pipe(ge(e=>!(e instanceof B)&&!(e instanceof _a)&&e._tag!==`MissingEnvironmentIdentityError`?new B({message:`That address answered, but it is not a Porcelain server.`}):new B({message:`Could not reach Porcelain. Check that the server is running, then open the link again.`,cause:e})))).environmentId!==e.environmentId)return yield*X(new B({message:`This link was made for a different Porcelain installation.`}));let r=yield*ho(n.pairing.redeemPairing({payload:{code:e.code,platform:t.name()}})).pipe(ge(e=>Up(e)?new B({message:`This pairing link is not usable. Ask for a new one.`}):e));return{inventory:yield*ho(n.projects.readInventory()).pipe(ge(e=>e instanceof _a?new B({message:`Pairing succeeded but the workspace could not be loaded. Reload the page.`}):e)),principal:{kind:`device`,deviceId:r.device.id}}}),qp=q(({transport:e,platform:t})=>ms(ue(Rp.layer(e),ps(Pp,t))).fn(e=>Kp(e))),Jp=class e extends H()(`@porcelain/client/AccessSnapshots`){static layer=Yi(e,z(function*(){return{remote:yield*Ko(go()),update:yield*Ko(go())}}))},Yp=q(e=>e.atoms(t=>Zt(Jp.layer,t(or(e).layer)))),Xp=yr,Zp=Fi,Qp=class extends Sr.add(Vr(`live`).add(Lo(`liveUpdates`,`/api/live`,{disableCodecs:!0,query:Ri.fields,success:Oi.pipe(Ir({decode:()=>void 0}),$o(`SwitchingProtocols`))})).middleware(Ho)){};Sr.add(Vr(`reviewMcp`).add(ss(`reviewMcp`,`/mcp`,{disableCodecs:!0,payload:Xp,success:[Xp,Zp.pipe(Ir({decode:()=>void 0}),$o(`Accepted`))]})).middleware(Ho));var $p=[`lan`,`tailnet`,`cloudflare`],em={lan:`Local network`,tailnet:`Tailscale`,cloudflare:`Cloudflare tunnel`},tm={loopback:`This computer`,lan:`Local network`,tailnet:`Tailscale`,tunnel:`Cloudflare tunnel`};function nm(e){return`${e.subnet} on ${e.interfaceName}`}function rm(e){let{lan:t}=e.routes,n=e.localNetwork,r=e.lanNetwork,i=`Porcelain cannot tell this network from another one yet, because the hardware address of its router is not known.`;return t.enabled?t.status.kind===`paused`?n?n.gatewayHardware?r?nm(r)===nm(n)?`Paused on this network. It looks like ${nm(r)}, but its router is another one, so this is another network; turn it on for this network to listen here.`:`Paused on this network. It was turned on for ${nm(r)}, and listens again there, or here once you turn it on for this network.`:`Paused on this network. It was turned on before Porcelain kept the network it was turned on for; turn it on for this network to listen here.`:`Paused. ${i}`:r?`Paused: this computer is not on a local network. Porcelain listens again when it is back on ${nm(r)}.`:`Paused: this computer is not on a local network.`:r?`Listening on ${nm(r)} only.`:`Listening on this network only.`:n?n.gatewayHardware?`Turning it on listens on ${nm(n)} only, and pauses on any other network.`:`${i} Try again in a moment.`:`This computer is not on a local network right now.`}function im(e){return e?$p.some(t=>{let n=e.routes[t];return n.enabled?n.status.kind===`starting`||n.status.kind===`off`:n.status.kind!==`off`}):!1}function am(e){return e===void 0?[]:$p.flatMap(t=>{let{status:n}=e.routes[t];return n.kind===`on`?n.urls.map(e=>({route:t,url:e})):[]})}function om(e){let[t]=e.grants;return t?{label:t.grant.label,link:ds(t.link),expiresAt:t.grant.expiresAt}:null}function sm(e){return`tailscale serve --bg --https=443 ${e}`}function cm(e,t){let n=`Your devices may reach that program instead of Porcelain: run tailscale serve --https=443 off now, then turn Tailscale off and on here to pick a free port and run the new command Porcelain names.`;switch(t){case`address-in-use`:return e===`tailnet`?`Another program already listens on the port Tailscale forwards to. ${n}`:`Another program already listens on this port.`;case`address-unavailable`:return e===`tailnet`?`Porcelain could not open the local listener Tailscale forwards to. ${n}`:`This computer could not listen at its address.`;case`unreachable`:return e===`tailnet`?`Nothing answered at this Tailscale name yet. Check that you ran the command below, that Tailscale is connected on this computer and uses MagicDNS, and that MagicDNS and HTTPS Certificates are on in the Tailscale admin console. Porcelain keeps checking.`:`Nothing answered at this hostname. Check that cloudflared is running and routes it here.`;case`other-server`:return e===`tailnet`?`Another server answered at this Tailscale name. Run the command below so Tailscale forwards to this Porcelain; Porcelain keeps checking.`:`Another server answered at this hostname.`}}function lm(e,t,n){return z(function*(){let r=yield*Vo(n.pipe(lo(()=>Re(e))));return ro(r)&&pa(r.cause)?yield*g:(Hi(r)&&(yield*mn(t,Jr(r.value))),Ce(r,Nr(yield*O(t),$n)))})}function um(e,t,n,r){return Me(e.atom(eo(t).pipe(da(Tt(n)),fi(e=>!r(ja(Kn(e)))))).pipe(de(e=>kn(e,e=>e)))).pipe(b(0))}var dm=q(e=>or(e).atom(z(function*(){return yield*(yield*Ht(e)).request(e=>e.administration.listAccess())})).pipe(b(0))),fm=q(e=>um(Yp(e),z(function*(){let t=yield*Ht(e);return yield*lm(e,(yield*Jp).remote,t.request(e=>e.administration.readRemoteAccess()).pipe(ni(e=>e instanceof _a&&e.status===403?Vi(null):X(e))))}),oo,im)),pm=q(e=>um(Yp(e),z(function*(){let t=yield*Ht(e);return yield*lm(e,(yield*Jp).update,t.request(e=>e.serviceUpdates.readServiceUpdate()))}),Ra,e=>e?.running===!0));function mm(e){return z(function*(){let t=yield*Ht(e),n=yield*ua,r=yield*Jp,i=yield*Cn;function a(t,r){return n.run([t],z(function*(){yield*Re(e);let t=yield*r;return yield*Re(e),t}))}function o(t){return J(()=>{e.isClosed()||i.refresh(t)})}function s(e,t,n){return Aa(J(()=>{let t=i.mount(e),n=Ft($n(i.get(e),{waiting:!0}));return i.set(e,n),{transition:n,unmount:t}}),({transition:e})=>n.pipe(lo(n=>z(function*(){yield*mn(t,Jr(n)),i.set(e,$n($n(n),{waiting:!0}))}))),({transition:e,unmount:t},n)=>J(()=>{i.set(e,Hi(n)?$n($n(n.value)):v(n.cause)),t()}))}return{issue:n=>a(`paired-access`,t.request(e=>e.administration.issuePairing({payload:{labels:[n.label],addresses:n.addresses,...n.trusted?{trusted:!0}:{}}})).pipe(lo(()=>o(dm(e))))),revoke:n=>a(`paired-access`,t.request(e=>e.administration.revokeAccess({payload:{id:n}})).pipe(xr(o(dm(e))))),trust:n=>a(`paired-access`,t.request(e=>e.administration.setDeviceTrust({payload:n})).pipe(xr(o(dm(e))))),setRemote:n=>a(`remote-access`,s(fm(e),r.remote,t.request(e=>e.administration.setRemoteAccess({payload:n})).pipe(lo(()=>Re(e))))),startUpdate:n=>a(`service-update`,s(pm(e),r.update,t.request(e=>e.serviceUpdates.startServiceUpdate({payload:{version:n}})).pipe(lo(()=>Re(e)),fa(()=>o(pm(e))))))}})}var hm=class e extends H()(`@porcelain/client/AccessCommands`){static layer(t){return Yi(e,mm(t))}},gm=q(e=>e.atoms(t=>Zt(hm.layer(e),t(Yp(e).layer)))),_m=q(e=>gm(e).fn(e=>hm.use(t=>t.issue(e)).pipe(Bt(om)),{concurrent:!0})),vm=q(({connection:e,id:t})=>gm(e).fn(()=>hm.use(e=>e.revoke(t)),{concurrent:!0})),ym=q(({connection:e,id:t})=>gm(e).fn(e=>hm.use(n=>n.trust({id:t,trusted:e})),{concurrent:!0})),bm=q(e=>gm(e).fn(e=>hm.use(t=>t.setRemote(e)),{concurrent:!0})),xm=q(e=>gm(e).fn(e=>hm.use(t=>t.startUpdate(e)),{concurrent:!0}));function Sm(e,t,n,r=go(),i=[t,Ja.environment(e.environmentId)]){return z(function*(){let a=yield*ua,o=yield*Gt,s=yield*Be({epoch:0,result:za(r,{onNone:()=>xn(),onSome:e=>$n(e)})}),c=z(function*(){let t=(yield*Xa(s)).epoch;yield*Jn(s,e=>({...e,result:sr(e.result)}));let r=yield*Vo(n.pipe(lo(()=>Re(e))));yield*Jn(s,e=>e.epoch===t?{...e,result:Ce(r,Jr(e.result))}:e)});function l(n,r){return a.run(Ja.withIdentity(t,e),z(function*(){yield*Re(e),yield*Jn(s,e=>({...e,epoch:e.epoch+1}));let t=yield*n;return yield*Re(e),yield*Jn(s,e=>({epoch:e.epoch+1,result:za(r(Kn(e.result),t),{onNone:()=>e.result,onSome:e=>$n(e)})})),t}).pipe(xr(o.invalidate([t]))))}return{confirm:l,stream:co(Ye(s).pipe(wr(e=>e.result)),o.stream(i,c).pipe(_o))}})}var Cm=Bn(`@porcelain/client/InventorySeed`,{defaultValue:()=>go()}),wm=class e extends H()(`@porcelain/client/InventoryState`){static layer(t){return Yi(e,z(function*(){let e=yield*Cm,n=yield*Ht(t),r=yield*Sm(t,Ja.inventory(t.environmentId),n.request(e=>e.projects.readInventory()).pipe(lo(e=>Re(t,e.environmentId===t.environmentId))),e);function i(e,t){return r.confirm(e,(e,n)=>Nr(e,e=>t(e,n)))}return{stream:r.stream,confirm:i}}))}},Tm=q(e=>e.atoms(t=>Zt(wm.layer(e),t(or(e).layer)))),Em=q(e=>Tm(e).fn(t=>z(function*(){let n=yield*Ht(e);return yield*(yield*wm).confirm(n.request(e=>e.environmentName.renameEnvironment({payload:{name:t}})),(e,t)=>({...e,environment:t}))}),{concurrent:!0})),Dm=Y(`BrowserSession.restore`)(function*(){let e=yield*Rp;return{principal:yield*ho(e.session.readSession()),inventory:yield*ho(e.projects.readInventory())}},ni(e=>e instanceof _a&&e.status===401?Vi(null):X(e instanceof _a||Qi(e)?new B({message:`Could not reach Porcelain to restore this browser session.`,cause:e}):e))),Om=q(e=>zp(e).atom(Dm())),km=`Save or discard unsaved file drafts before disconnecting.`;function Am(e){return e instanceof Error&&(e.name===`ConnectionError`||e.name===`RequestError`)?e.message:`Could not connect to the environment. Try again.`}var jm=q(e=>e.atoms(t=>ue(t(Ht(e).runtime.layer),ve.layer)).fn(Y(`BrowserSession.disconnect`)(function*(){let t=yield*ve,n=yield*Ht(e);if(!(yield*t.save(e.environmentId)))return yield*X(new B({message:km}));yield*n.request(e=>e.browserAccess.clearBrowserSession())},ge(e=>e instanceof B?e:new B({message:`Could not disconnect. Check the connection and try again.`,cause:e}))))),Mm=Y(`BrowserSession.connect`)(function*(e,t,n,r){let i=yield*Ap,a=yield*i.beginConnection(),o=yield*Aa(J(()=>e.set(t,n)),()=>zn(e,t,{suspendOnWaiting:!0}),()=>J(()=>e.set(t,ie))).pipe(pi({duration:r,orElse:()=>g}),ga(e=>X(new B({message:Am(hi(e)),cause:hi(e)}))));if(a&&(yield*a(o)),i.state.value.connection?.environmentId!==o.inventory.environmentId)return yield*X(new B({message:`Could not connect to the environment. Try again.`}))}),Nm=Y(`BrowserSession.restoreConnection`)(function*(e,t){let n=yield*Ap;if(n.state.value.connection)return!0;let r=yield*n.beginConnection(!0);if(!r)return!1;let i=e.get(t);Ln(i)&&!i.waiting&&e.refresh(t);let a=yield*zn(e,t,{suspendOnWaiting:!0});return a!==null&&(yield*r(a),n.state.value.connection!==null)}),Pm=class e extends H()(`@porcelain/client/EnvironmentMutations`){static layer=Yi(e,z(function*(){let e=yield*D(1),t=Mi(0);return{pendingSelections:t,run:(n,r)=>Aa(J(()=>{n===`selection`&&t.update(e=>e+1)}),()=>e.withPermit(r),()=>J(()=>{n===`selection`&&t.update(e=>e-1)}))}}))},Fm=class extends H()(`@porcelain/client/WorkspaceSelectionCleanup`){},Im=z(function*(){let e=yield*Dp,t=yield*hp,n=yield*Pm,r=yield*ve,i=yield*Fm;return{read:Y(`Environments.read`)(()=>n.run(`access`,e.load())),pair:Y(`Environments.pair`)(r=>n.run(`access`,z(function*(){return r.localEnvironmentId&&Fp(r.value)?.environmentId===r.localEnvironmentId?yield*X(new B({message:`That link is for this computer.`})):yield*Gp(r.value).pipe(et(Dp,e),et(hp,t))}))),forget:Y(`Environments.forget`)(t=>n.run(`selection`,z(function*(){if(!(yield*r.save(t)))return yield*X(new B({message:km}));yield*z(function*(){yield*e.forget(t),yield*i.forgetEnvironment(t),yield*r.drop(t)}).pipe(ji)})))}}),Lm=class e extends H()(`@porcelain/client/EnvironmentCommands`){static layer=Yi(e,Im)},Rm=_r(Qp).live.liveUpdates,zm=_r(Ka).pairing.redeemPairing,Bm=new Set;function Vm(e){return Bm.add(e),()=>Bm.delete(e)}function Hm(){for(let e of[...Bm])e()}function Um(e,t={}){return async(n,r)=>{let i=new Headers(r?.headers);i.delete(`authorization`),i.set(`x-porcelain-browser`,`1`);let a=await e(n,{...r,headers:i,credentials:`same-origin`});return a.status===401&&n!==zm()&&t.reportUnauthorized!==!1&&Hm(),a}}var Wm=q(e=>Tm(e).atom(Ba(Bt(wm,e=>e.stream))).pipe(de(e=>kn(e,e=>e)),b(0)));q(e=>rt(t=>e.map(e=>({connection:e,result:t(Wm(e))})),t=>{for(let n of e)t(Wm(n))}));var Gm=class extends H()(`@porcelain/client/ProjectSelectionStorage`){},Km=class e extends H()(`@porcelain/client/ProjectSelectionStore`){static layer=Yi(e,z(function*(){let e=yield*Gm,t=Mi({currentEnvironmentId:void 0,selections:{},status:`loading`,error:void 0}),n=yield*jt.make,r=Y(`ProjectSelectionStore.write`)(function*(r){yield*n.enqueue(z(function*(){if(t.value.status!==`ready`)return yield*X(new B({message:`Saved workspace selections must be read before changing them.`}));let n=yield*r(t.value),i=`Saved workspace selections could not be updated. Read them again before making changes.`;yield*e.write(n).pipe(ge(({cause:e})=>new B({message:i,cause:e})),fa(()=>J(()=>t.update(e=>({...e,status:`unreadable`,error:i})))),lo(()=>J(()=>t.update(e=>({...e,...n})))),ji)}))});return{state:t,load:Y(`ProjectSelectionStore.load`)(function*(){yield*n.enqueue(z(function*(){t.update(e=>({...e,status:`loading`,error:void 0})),yield*e.read().pipe(st({onSuccess:e=>J(()=>t.set({...e,status:`ready`,error:void 0})),onFailure:()=>J(()=>t.update(e=>({...e,status:`unreadable`,error:`Saved workspace selections could not be read. Try reading them again.`})))}),ji)}))}),selectWorkspace:Y(`ProjectSelectionStore.selectWorkspace`)((e,t,n)=>r(({selections:r})=>Vi({currentEnvironmentId:e,selections:{...r,[e]:{projectId:t,worktreeId:n}}}))),forgetEnvironment:Y(`ProjectSelectionStore.forgetEnvironment`)(e=>r(({currentEnvironmentId:t,selections:n})=>Vi({currentEnvironmentId:t===e?void 0:t,selections:Object.fromEntries(Object.entries(n).filter(([t])=>t!==e))})))}}))};function qm(e){return z(function*(){let t=yield*Ht(e),n=yield*wm,r=yield*ve;return{register:e=>n.confirm(t.request(t=>t.projects.registerProject({payload:{path:e}})),(e,t)=>({...e,projects:e.projects.some(e=>e.id===t.id)?e.projects.map(e=>e.id===t.id?t:e):[...e.projects,t]})),rename:e=>n.confirm(t.request(t=>t.projects.renameProject({params:{projectId:e.projectId},payload:{name:e.name}})),(e,t)=>({...e,projects:e.projects.map(e=>e.id===t.id?{...e,name:t.name}:e)})),remove:i=>n.confirm(z(function*(){let n=`[${JSON.stringify(i)},`;for(let[t,i]of r.entries(e))if(t.startsWith(n)&&!(yield*i.save()))return yield*X(new B({message:`Save or discard unsaved file drafts before removing this project.`}));return yield*t.request(e=>e.projects.removeProject({params:{projectId:i}}))}),e=>({...e,projects:e.projects.filter(e=>e.id!==i)}))}})}var Jm=class extends H()(`@porcelain/client/ProjectCommands`){},Ym=q(e=>e.atoms(t=>Zt(Yi(Jm,qm(e)),ue(t(Tm(e).layer),ve.layer)))),Xm=q(e=>Ym(e).fn(e=>Jm.use(t=>t.register(e)),{concurrent:!0})),Zm=q(e=>Ym(e).fn(e=>Jm.use(t=>t.rename(e)),{concurrent:!0})),Qm=q(e=>Ym(e).fn(e=>Jm.use(t=>t.remove(e)),{concurrent:!0})),$m=class e extends H()(`@porcelain/client/FilePreferencesState`){static layer(t,n){return Yi(e,z(function*(){let e=yield*Ht(t);return yield*Sm(t,Ja.filePreferences(t.environmentId,n),e.request(e=>e.projects.listFilePreferences({params:{projectId:n}})))}))}},eh=q(({connection:e,projectId:t})=>e.atoms(n=>Zt($m.layer(e,t),n(or(e).layer)))),th=q(({connection:e,projectId:t})=>eh({connection:e,projectId:t}).fn(n=>z(function*(){let r=yield*Ht(e);return yield*(yield*$m).confirm(r.request(e=>e.projects.setFilePreference({params:{projectId:t},payload:n})),(e,t)=>Jr(t))}),{concurrent:!0})),nh=q(e=>eh(e).atom(Ba(Bt($m,e=>e.stream))).pipe(de(e=>kn(e,e=>e)),b(0))),rh=q(({connection:e,path:t})=>or(e).atom(z(function*(){return yield*(yield*Ht(e)).request(e=>e.projects.browseProjectFolders({query:t===void 0?{}:{path:t}}))})));function ih(e,t){return rh({connection:e,path:t})}ei({currentEnvironmentId:yt(un),selections:Gr(Ao,ei({projectId:un,worktreeId:N})).check(m(un))});var ah=z(function*(){let e=yield*Dp,t=yield*Km,n=yield*Pm;return{pending:n.pendingSelections,execute:Y(`WorkspaceSelection.execute`)(r=>n.run(`selection`,z(function*(){if(r.kind===`read`){if(yield*t.load(),e.state.value.status!==`ready`||t.state.value.status!==`ready`)return;let n=new Set(e.state.value.remotes.map(e=>e.environmentId)),r=new Set(Object.keys(t.state.value.selections));t.state.value.currentEnvironmentId&&r.add(t.state.value.currentEnvironmentId);for(let e of r)n.has(e)||(yield*t.forgetEnvironment(e));return}if(e.state.value.status!==`ready`||!e.state.value.remotes.some(e=>e.environmentId===r.environmentId))return yield*X(new B({message:`That environment is no longer paired. Open the workspace picker again.`}));yield*t.selectWorkspace(r.environmentId,r.projectId,r.worktreeId)})))}});(class e extends H()(`@porcelain/client/ProjectSelectionCommands`){static layer=Yi(e,ah)});var oh=q(e=>d((t,n)=>z(function*(){let r=yield*n.setResult(Xm(e),t.path.trim()),i=r.worktrees.find(e=>e.available);t.complete(),i&&(yield*t.select({remote:t.remote,projectId:r.id,worktreeId:i.id}))})));function sh(e,t){if(!e.running)return null;let n=e.last?.target??e.latest??`the new version`;return t||e.last?.stage===`restarting`?`Restarting Porcelain on ${n}. This page reconnects when it is back.`:e.last?.stage===`installing`?`Installing ${n}…`:`Downloading ${n}…`}function ch(e){let{last:t}=e;return e.running||t==null?null:t.stage===`updated`&&t.target===e.version?{kind:`updated`,from:t.from,target:t.target}:t.stage===`failed`?{kind:`failed`,target:t.target,reason:t.reason??`The updater gave no reason.`}:null}function lh(e){return e.kind===`online`?`secondary`:e.kind===`checking`?`outline`:`destructive`}function uh(e,t){return t&&e.kind===`online`}function dh(e){if(e.status===`unreadable`)return{kind:`unreadable`,message:e.message};if(e.status===`empty`)return{kind:`readable`,remotes:void 0};try{return{kind:`readable`,remotes:xp(JSON.parse(e.value))}}catch{return{kind:`unreadable`,message:`The saved remote computers are not in a form this app reads.`}}}var fh=mp.of({read:()=>Va({try:async()=>{let e=Ct();if(!e){let e=localStorage.getItem(`porcelain.remotes`);return e===null?[]:xp(JSON.parse(e))}let t=dh(await e.read());if(t.kind===`unreadable`)throw Error(t.message);return t.remotes??[]},catch:e=>new Pa(e)}),write:e=>Va({try:async()=>{let t=Ct(),n=_p(e);t?await t.write(n):localStorage.setItem(`porcelain.remotes`,n)},catch:e=>new Pa(e)})}),ph=class extends H()(`@porcelain/client/OperationStore`){},mh=class extends H()(`@porcelain/client/OperationStorage`){},hh=oe(Ut(ei({requestId:yi.fields.requestId,projectId:Ao.check(sa(1)),worktreeId:is.fields.worktreeId,request:yi}).check(pt(e=>e.requestId===e.request.requestId))));function gh(e){return e.state!==`running`}var _h=(e,t)=>JSON.stringify([e.projectId,e.worktreeId,t]),vh=Yi(ph,z(function*(){let e=yield*mh,t=yield*D(1),n=yield*Be(0),r=yield*e.read().pipe(Br(e=>ns(hh)(e??`[]`)),Ge),i=Mi({operations:Te(r)?new Map(r.success.map(e=>[_h(e,e.request.input.action),e])):new Map,closed:!1,restorationError:Mn(r)?new B({message:`Could not restore pending Git operations. Check the previous operation before starting another.`,cause:r.failure}):void 0}),a=Y(`OperationStore.publish`)(function*(e){i.set(e),yield*Jn(n,e=>e+1)});yield*ao(()=>t.withPermit(a({...i.value,operations:new Map,closed:!0})));let o=Y(`OperationStore.persist`)(function*(t){if(i.value.restorationError)return yield*X(i.value.restorationError);let n=[...t.values()].filter(e=>!e.receipt||!gh(e.receipt)).map(({receipt:e,...t})=>t),r=yield*Jo(hh)(n).pipe(ge(e=>new B({message:`Could not save the Git operation. Check device storage before trying again.`,cause:e})));yield*(n.length?e.write(r):e.clear()).pipe(ge(({cause:e})=>new B({message:`Could not save the Git operation. Check device storage before trying again.`,cause:e}))),yield*a({...i.value,operations:t})}),s=e=>t.withPermit(z(function*(){return i.value.closed?yield*g:yield*e().pipe(ji)}));return{state:i,set:Y(`OperationStore.set`)((e,t)=>s(()=>z(function*(){let n=new Map(i.value.operations);t?n.set(e,t):n.delete(e),yield*o(n)}))),accept:Y(`OperationStore.accept`)(e=>s(()=>z(function*(){let t=_h(e,e.action),n=i.value.operations.get(t);if(!n||n.requestId!==e.requestId||n.receipt&&gh(n.receipt))return!1;let r=new Map(i.value.operations);return r.set(t,{...n,receipt:e}),yield*o(r),!0}))),wait:Y(`OperationStore.wait`)(function*(e,t){let r=yield*Ye(n).pipe(Ma(()=>z(function*(){let n=i.value.operations.get(e);return yield*Qn(!i.value.closed&&n?.requestId===t),n?.receipt&&gh(n.receipt)?Jr(n.receipt):go()})),Ta(qi),wr(e=>e.value),Yr);return yield*za(r,{onSome:Vi,onNone:()=>Qn(!1).pipe(jr(tn))})})}}));function yh(e,t){return z(function*(){let n=yield*(yield*Ht(e)).request(e=>e.gitActions.readGitActionReceipt({params:{worktreeId:t.worktreeId,requestId:t.requestId}}));return yield*Re(e,n.projectId===t.projectId&&n.worktreeId===t.worktreeId&&n.requestId===t.requestId),n})}var bh=class extends qo{},xh=class e extends H()(`@porcelain/client/GitReceiptRefresh`){static layer(t){return Yi(e,z(function*(){let e=yield*ai,n=yield*Gt,r=yield*Mt,i=yield*Nf({capacity:1/0,timeToLive:f,lookup:a=>z(function*(){let o=new Set(Uo(t.environmentId,a).map(e=>String(e[4]))),s=[...be(yield*r.snapshot)].filter(e=>e.projectId===a.projectId&&e.worktreeId===a.worktreeId&&o.has(e.surface)),c=yield*yn(z(function*(){n.invalidateUnsafe([Ja.inventory(t.environmentId),...Uo(t.environmentId,a)]),yield*M(s,e=>e.settled,{concurrency:`unbounded`,discard:!0})}),e);return yield*yn(le(c).pipe(jr(Vf(i,a))),e),c})});return{refresh:Y(`GitReceiptRefresh.refresh`)(function*(e){if(e.state===`running`||e.state===`rejected`||e.state===`no-change`)return;let t=new bh({projectId:e.projectId,worktreeId:e.worktreeId,requestId:e.requestId,action:e.action,state:e.state}),n=yield*If(i,t);n.pollUnsafe()&&(yield*Vf(i,t)),yield*fs(n)})}}))}},Sh=q(e=>e.atoms(t=>Zt(xh.layer(e),t(or(e).layer))));function Ch(e,t,n){let r=new Map;for(let t of[...e.state.value.operations.values()])t.receipt&&gh(t.receipt)||r.set(JSON.stringify([t.projectId,t.worktreeId]),{projectId:t.projectId,worktreeId:t.worktreeId,paths:new Set});for(let e of n){let t=JSON.stringify([e.projectId,e.worktreeId]),n=r.get(t)??{projectId:e.projectId,worktreeId:e.worktreeId,paths:new Set};for(let t of e.paths)t!==``&&n.paths.add(t);r.set(t,n)}return{projects:t?.projects.map(e=>e.id).slice(0,128)??[],worktrees:[...r.values()].slice(0,32).map(e=>({projectId:e.projectId,worktreeId:e.worktreeId,paths:[...e.paths].slice(0,64)}))}}var wh=Y(`Live.connect`)(function*(e,t){let n=yield*Cn,r=yield*Mt,i=yield*ph,a=yield*xh,o=yield*Gt,s=yield*wo(Rn(e.scope,`sequential`),e=>Sn(e,Dr)),c=yield*pp(yield*sp().pipe(et(y,s)))(),l=yield*Ga(),u=Y(`Live.applyNotice`)(function*(t){if(t.type===`git-action`)return yield*a.refresh(t.receipt);(t.type===`inventory`||t.type===`worktree`)&&(yield*o.invalidate([Ja.inventory(e.environmentId)])),t.type===`project`&&t.change===`preferences`&&(yield*o.invalidate([Ja.filePreferences(e.environmentId,t.projectId)])),yield*o.invalidate(E(e.environmentId,t))}),d=()=>{for(let t of i.state.value.operations.values())t.receipt&&gh(t.receipt)||c(Symbol(),z(function*(){let n=yield*yh(e,{...t}).pipe(xe(l));yield*Re(e),yield*a.refresh(n),yield*i.accept(n)}).pipe(At,mo))},f=yield*e.liveUpdates.connect({onNotice:t=>{e.isClosed()||s.state._tag===`Closed`||(t.type===`ready`&&d(),c(Symbol(),z(function*(){yield*u(t),t.type===`git-action`&&!e.isClosed()&&s.state._tag!==`Closed`&&(yield*i.accept(t.receipt))}).pipe(ga(()=>J(()=>{!e.isClosed()&&s.state._tag!==`Closed`&&d()})),mo)))},onReconnect:()=>{!e.isClosed()&&s.state._tag!==`Closed`&&c(Symbol(),o.invalidate([Ja.environment(e.environmentId)]))},onUnauthorized:()=>{e.isClosed()||s.state._tag===`Closed`||(t?t():c(Symbol(),o.invalidate([Ja.inventory(e.environmentId)])))}}).pipe(et(y,s)),p=``,m=z(function*(){if(e.isClosed()||s.state._tag===`Closed`)return;let t=Ch(i,ja(Kn(n.get(Wm(e)))),be(yield*r.snapshot)),a=JSON.stringify(t);a!==p&&(p=a,f.subscribe(t))}),h=()=>{!e.isClosed()&&s.state._tag!==`Closed`&&c(`subscription`,jr(ee,m),{onlyIfMissing:!0})};yield*wo(J(()=>n.subscribe(Wm(e),h)),e=>J(e)).pipe(et(y,s)),yield*wo(J(()=>i.state.subscribe(h)),e=>J(()=>e?.())).pipe(et(y,s)),c(Symbol(),Eo(r.changes,()=>J(h))),h()}),Th=q(e=>e.atoms(t=>je(t(Tm(e).layer),t(Sh(e).layer),ut(e.runtime.contextEffect)))),Eh=q(({connection:e,onUnauthorized:t})=>Th(e).atom(wh(e,t)).pipe(b(0))),Dh=Ft($n(void 0));function Oh(e){return e instanceof _a?e.status===401:e instanceof rc||Rs(e)?e.reason._tag===`SocketCloseError`&&e.reason.code===4001:!1}function kh(e,t=Za()){return{connect:Y(`LiveUpdates.connect`)(function*({onNotice:n,onReconnect:r,onUnauthorized:i}){let a=yield*Ko({projects:[],worktrees:[]}),o=yield*lt(1),s=0,d=500,f=vo(z(function*(){let t=yield*e,i=yield*cr(),c=yield*yc({retryPolicy:pn.pipe(F(),ia(({input:e})=>er(i,e)),u({times:0}))}).pipe(et(Ms,t),et(lc,uc)),l=yield*hc(Ca,{disableTracing:!0}).pipe(et(vc,c)),f=l.notices(void 0).pipe(Eo(e=>z(function*(){e.type===`ready`&&(s>0&&r(),s+=1,d=500,yield*l.follow(yield*O(a))),n(e)}))),p=Xo(Br(_t(o),e=>l.follow(e)));yield*Gi([f,p],{concurrency:`unbounded`}).pipe(Qa(Ya(i)))}));return yield*vo(z(function*(){for(yield*ao(()=>l(o));;){let e=yield*Vo(f);if(ro(e)&&Oh(hi(e.cause))){i();return}yield*to(d),d=Math.min(d*2,To)}})).pipe(xe(t),ga(e=>pa(e)?os:ht(`Live updates stopped unexpectedly`)),ce),{subscribe(e){o.state._tag!==`Done`&&(c(mn(a,e)),ra(o,e))}}})}}function Ah(e,t,n){return kh(z(function*(){let t=yield*Rp,{ticket:r}=yield*ho(t.session.issueLiveTicket()),i=new URL(e);return yield*n(`${i.protocol===`https:`?`wss:`:`ws:`}//${i.host}${Rm({query:{ticket:r}})}`)}).pipe(Wn(Rp.layer(t))))}function jh(e,t,n){let r=ue(Pt(vh),ve.layer).pipe(Zt(t)),{connection:i}=gt(e,n,r),a=qa({...i,address:e.address,liveUpdates:e.liveUpdates,operations:i.runtime.runSync(ph)});return i.runtime.runSync(ve).adopt(a),a}function Mh(e,t,n){let r=Np(e.address,e.credential,e.send);return jh({environmentId:e.environmentId,address:e.address,transport:r,cacheIdentity:[e.address,e.deviceId??``],liveUpdates:Ah(e.address,r,e.socket),timeoutMs:e.timeoutMs},t,n)}function Nh(e){return Js(e).pipe(et(qs,e=>new WebSocket(e)))}function Ph(){let e=location.protocol===`https:`?`wss:`:`ws:`;return kh(Nh(na()??`${e}//${location.host}${Rm({query:{}})}`))}var Fh=q(e=>or(e).atom(z(function*(){return yield*(yield*Ht(e)).request(e=>e.gitActions.listCommitModels())})).pipe(b(t),jn({staleTime:t,revalidateOnFocus:!1})));function Ih(e){return Fh(e)}var Lh=q(({connection:e,scope:t})=>or(e).fn(Y(`GitActions.generateCommitDraft`)(function*({lifetime:n,...r}){let i=yield*(yield*Ht(e)).request(e=>e.gitActions.generateCommitDraft({params:{worktreeId:t.worktreeId},payload:r}),n);return yield*Re(e),i}),{concurrent:!0})),Rh=q(({connection:e,scope:t})=>or(e).fn(Y(`GitActions.dismissInterrupted`)(function*(n){yield*(yield*Ht(e)).request(e=>e.gitActions.dismissInterruptedGitAction({params:{worktreeId:t.worktreeId,requestId:n}})),yield*Re(e),yield*r([Ja.reviewSurface(e.environmentId,t,[`changes`])])}))),zh=q(e=>Ft(z(function*(){let t=yield*Cn,n=Lh(e);return Y(`CommitDraft.submit`)(function*(e,r){return t.set(n,{...e,lifetime:r}),yield*zn(t,n,{suspendOnWaiting:!0})})}))),Bh=class extends gi()(`GitOperationStateError`,{reason:Ui([`pending`,`missing`,`mismatch`])}){get message(){switch(this.reason){case`pending`:return`Check the existing receipt before starting another operation.`;case`missing`:return`No operation to recover`;case`mismatch`:return`Action mismatch`}}},Vh=Y(`GitActionController.make`)(function*({connection:e,scope:t,action:n}){let r=yield*Ht(e),i=yield*ph,a=yield*ep,o=yield*xh,s=yield*D(1),c=_h(t,n),l=Y(`GitActionController.accept`)(function*(t){yield*Re(e,t.requestId===i.state.value.operations.get(c)?.requestId),yield*o.refresh(t),yield*Re(e,t.requestId===i.state.value.operations.get(c)?.requestId),yield*i.accept(t)}),u=Y(`GitActionController.send`)(function*(a){let o=yield*r.request(e=>e.gitActions.runGitAction({params:{worktreeId:t.worktreeId},payload:a}));return`requestId`in o?(yield*Re(e,o.projectId===t.projectId&&o.worktreeId===t.worktreeId&&o.requestId===a.requestId&&o.action===n),yield*l(o),yield*i.wait(c,a.requestId)):yield*X(new _a({status:o.statusCode,message:o.message}))});return{execute:Y(`GitActionController.execute`)(function*(r){return yield*e.request(z(function*(){let o=yield*s.withPermit(z(function*(){yield*Re(e);let o=i.state.value.operations.get(c);if(o&&(!o.receipt||!gh(o.receipt)))return yield*X(new Bh({reason:`pending`}));if(r.input.action!==n)return yield*X(new Bh({reason:`mismatch`}));let s={...r,requestId:yield*a.randomUUIDv4.pipe(ge(e=>new B({message:`Could not create a Git recovery identity.`,cause:e})))};return yield*i.set(c,{...t,requestId:s.requestId,request:s}),s}));return yield*u(o)}))}),recover:Y(`GitActionController.recover`)(function*(){return yield*e.request(z(function*(){yield*Re(e);let t=i.state.value.operations.get(c);return t?yield*u(t.request):yield*X(new Bh({reason:`missing`}))}))}),startNew:Y(`GitActionController.startNew`)(function*(){return yield*s.withPermit(z(function*(){let e=i.state.value.operations.get(c)?.receipt;return!e||!gh(e)?!1:(yield*i.set(c,null),!0)}))})}}),Hh=class e extends H()(`@porcelain/client/GitActionController`){static layer(t){return Yi(e,Vh(t))}},Uh=q(e=>e.connection.atoms(t=>Zt(Hh.layer(e),je(t(Sh(e.connection).layer),ut(e.connection.runtime.contextEffect))))),Wh=q(e=>Uh(e).fn(e=>Hh.use(t=>t.execute(e)),{concurrent:!0})),Gh=q(e=>Uh(e).fn(e=>Hh.use(e=>e.recover()),{concurrent:!0})),Kh=q(e=>Uh(e).fn(e=>Hh.use(e=>e.startNew())));function qh(e,t){let n=Wh(e),r=Gh(e),i=Kh(e),a=()=>{t.set(n,I),t.set(r,I)};return{run:Y(`GitActions.run`)(function*(e,r){return t.set(n,{input:e,expected:r}),yield*zn(t,n,{suspendOnWaiting:!0})}),recover:Y(`GitActions.recover`)(function*(){return t.set(r,void 0),yield*zn(t,r,{suspendOnWaiting:!0})}),startNew:Y(`GitActions.startNew`)(function*(){t.set(i,void 0),(yield*zn(t,i,{suspendOnWaiting:!0}))&&a()}),reset:a}}var Jh=q(e=>Ft(z(function*(){return qh(e,yield*Cn)})));function Yh(e,t,n){return{mode:e===`amend`?`amend`:`single`,message:e===`commit`?t:``,amendMessage:e===`amend`?t:n,excluded:new Set,added:new Set,groups:null}}function Xh(e,t,n=new Set){return t.some(t=>!n.has(t.path)&&e.files?.find(e=>e.path===t.path)?.fingerprint!==t.fingerprint)}function Zh(e,t=[],n,r=t.length>0){let i=new Set(t);return{headOid:e.headOid??void 0,inProgress:e.inProgress??void 0,mergeHeadOid:e.mergeHeadOid??void 0,branch:e.branch?.name?.replace(/^refs\/heads\//,``)??void 0,...n===void 0?{}:{upstreamOid:n},...r?{files:(e.files??[]).flatMap(e=>i.has(e.path)&&e.fingerprint!==null&&e.fingerprint!==void 0?[{path:e.path,fingerprint:e.fingerprint}]:[])}:{}}}var Qh=e=>![`succeeded`,`no-change`].includes(e.state),$h=e=>e.message??(e.reason?e.reason.replaceAll(`_`,` `).toLowerCase():`Git ${e.state}`),eg=e=>e.state===`rejected`&&e.reason===`CHANGED_SINCE_LOOKED`;function tg(e){return e instanceof Error?e.message:`Git could not complete this action. Check the current state and try again.`}var ng=e=>t=>J(()=>{pa(t)||e.setError(hi(t))}),rg=Y(`CommitForm.generate`)(function*(e,t,n=e.paths){let{model:r,working:i,setBusy:a,setError:o,generator:s,status:c,setDrafted:l,setDone:u,setActiveGroup:d,setMessage:f,setGroups:p}=e;if(!r||!n.length||i)return;a(!0),o(null),yield*ao(()=>J(()=>a(!1)));let m=yield*s.submit({mode:t,model:r,paths:n,expectedStatusToken:c.statusToken});l(t,m.expectedFiles),u(new Set),d(null),t===`message`?(f(m.groups[0]?.message??``),p(null)):p(m.groups.map(t=>({...t,id:e.createId()})))},vo,(e,t)=>e.pipe(ga(ng(t)))),ig=Y(`CommitForm.commit`)(function*(e){let{working:t,uncertain:n,setBusy:r,setError:i,currentMessage:a,mode:o,commitAction:s,model:c,paths:l,generator:u,status:d,setMessage:f,setDrafted:p,groups:m,done:h,ownHead:g,onBusy:_,setActiveGroup:v,git:y,setOwnHead:b,setDone:x}=e;if(t||n)return;r(!0),i(null),yield*ao(()=>J(()=>r(!1)));let S=a;if(o!==`groups`&&!S.trim()){if(s===`amend`)return yield*X(new Pa(void 0,`Give the amended commit a message.`));if(!c||!l.length)return yield*X(new Pa(void 0,`Give every commit a message and at least one file.`));let e=yield*u.submit({mode:`message`,model:c,paths:l,expectedStatusToken:d.statusToken});if(S=e.groups[0]?.message??``,f(S),p(`message`,e.expectedFiles),Xh(d,e.expectedFiles))return}let C=s===`amend`?[{id:`single`,message:S,paths:l}]:o===`groups`&&m?m.filter(e=>!h.has(e.id)):[{id:`single`,message:S,paths:l}],w=g??d.headOid??null;_(!0),yield*ao(()=>J(()=>_(!1)));for(let e of C){if(!e.message.trim()||s!==`amend`&&d.inProgress!==`merge`&&!e.paths.length)return yield*X(new Pa(void 0,`Give every commit a message and at least one file.`));v(e.id);let t=yield*y.run({action:s,message:e.message,paths:e.paths},Zh({...d,headOid:w},d.inProgress===`merge`?d.files?.map(e=>e.path)??[]:e.paths,void 0,!0));if(Qh(t))return yield*X(new Pa(void 0,$h(t)));t.result?.headOid&&(w=t.result.headOid,b(w)),x(t=>new Set([...t,e.id])),v(null)}},vo,(e,t)=>e.pipe(ga(ng(t)))),ag=Y(`CommitForm.lookAgain`)(function*(e){let{onLookAgain:t,working:n,setBusy:r,setError:i,git:a,setOwnHead:o}=e;t&&!n&&(r(!0),i(null),yield*ao(()=>J(()=>r(!1))),yield*t,yield*a.startNew(),o(null))},vo,(e,t)=>e.pipe(ga(ng(t)))),og=Y(`CommitForm.recover`)(function*(e){let{setError:t,git:n,activeGroup:r,setDone:i,setActiveGroup:a}=e;t(null);let o=yield*n.recover();r&&[`succeeded`,`no-change`].includes(o.state)&&(i(e=>new Set([...e,r])),a(null))},(e,t)=>e.pipe(ga(ng(t))));function sg(e){return{statusToken:e.statusToken,inProgress:e.inProgress,mergeHeadOid:e.mergeHeadOid,headOid:e.headOid,branch:e.branch,changes:e.changes.flatMap(e=>e.comparisons),files:e.changes.map(({path:e,fingerprint:t})=>({path:e,fingerprint:t}))}}function cg(e,t){return e==null?t:t==null||t.name!==e.name||t.upstream!==e.upstream?e:{...t,name:e.name,upstream:e.upstream,ahead:e.ahead,behind:e.behind}}function lg(e){return e.branch??null}function ug(e){return e.changes.some(e=>e.scope===`unmerged`)}function dg(e,t){let n=lg(t);if(t.inProgress===`rebase`)return`Continue or abort the rebase in a terminal.`;if(t.inProgress===`merge`&&e!==`commit`)return`Finish or abort the merge first.`;if(t.inProgress===`merge`&&!t.mergeHeadOid)return`Finish this merge in a terminal.`;switch(e){case`commit`:return ug(t)&&t.inProgress!==`merge`?`Resolve the conflicts before committing.`:null;case`amend`:return ug(t)?`Resolve the conflicts before amending.`:t.headOid===null||t.headOid===void 0?`There is no commit to amend.`:null;case`push`:return n?n.name===null||n.name===void 0?`Detached HEAD: check out a branch before pushing.`:n.behind>0?`Pull the upstream changes before pushing.`:n.ahead>0||n.upstream===null||n.upstream===void 0?null:`No local commits to push.`:null;case`pull`:return n?.upstream===null||n?.upstream===void 0?`No upstream branch to pull from.`:t.changes.length?`Commit or stash local changes before pulling.`:n?.name===null?`Detached HEAD: check out a branch before pulling.`:null;case`fetch`:return n?.upstream===null||n?.upstream===void 0?`No upstream branch to fetch.`:null;case`stash-create`:return null;case`stash-apply`:case`stash-pop`:return n?.stashes&&n.stashes.length===0?`No stash is available.`:null;case`discard`:return null}}function fg(e,t){let n=lg(t);if(t.inProgress===`rebase`)return`Continue or abort the rebase in a terminal.`;if(t.inProgress===`merge`&&e!==`commit`)return`Finish or abort the merge first.`;switch(e){case`commit`:return t.changes.length?null:`Nothing to commit.`;case`amend`:return t.changes.length?`Choose which changed files to add to the last commit.`:`Change the last commit message.`;case`push`:return n==null?`Enter the configured remote and full branch ref.`:null;case`pull`:case`fetch`:return n==null?`Enter the configured remote and full branch ref.`:null;case`stash-create`:return t.changes.length===0?`Nothing changed; the server will report no change.`:null;case`stash-apply`:case`stash-pop`:return n?.stashes===null||n?.stashes===void 0?`Enter a full stash object ID.`:null;case`discard`:return null}}function pg(e,t){let n=lg(t);return e.kind!==`run`||n==null?null:e.action===`pull`?n.behind:n.ahead}function mg(e){if(e.inProgress===`rebase`||e.inProgress===`merge`&&!e.mergeHeadOid)return{kind:`hint`,label:`Git recovery`,hint:`Finish or abort this operation in a terminal.`};if(e.inProgress===`merge`||e.changes.length>0)return{kind:`commit`,label:`Commit`};let t=lg(e);return t==null?{kind:`hint`,label:`Commit`,hint:`Nothing to commit. Choose a Git action to continue.`}:t.name===null||t.name===void 0?{kind:`hint`,label:`Commit`,hint:`Detached HEAD: check out a branch before pushing.`}:t.behind>0?{kind:`run`,action:`pull`,label:`Pull`}:t.ahead>0?{kind:`run`,action:`push`,label:`Push`}:(t.stashes?.length??0)>0?{kind:`stash`,label:`Apply stash`}:{kind:`hint`,label:`Commit`,hint:`Nothing to commit, pull or push.`}}var hg=Y(`GitActions.restoreStash`)(function*(e,t,n,r,i){let a=yield*e.run({action:`stash-apply`,...t},n).pipe(Bt(e=>Qh(e)?$h(e):null),ni(e=>Vi(tg(e))));r(a===null?{title:i.restored,type:`success`}:{title:i.failed,description:a,type:`error`})}),gg=Y(`Discard.restore`)(function*({what:e,readChanges:t,notify:n,dismissNotice:r,restore:i},a,o,s){let c=yield*t().pipe(Bt(sg),ni(t=>J(()=>(n({title:`Could not restore ${e}`,description:tg(t),type:`error`}),null))));if(!c)return;let l=c.files?.filter(e=>e.fingerprint!==null&&e.fingerprint!==void 0).map(e=>e.path)??[];r(s),yield*hg(i,{stashOid:a,restoreIndex:o},Zh(c,l,void 0,!0),n,{restored:`Restored ${e}`,failed:`Could not restore ${e}`})});function _g(e,t){let{what:n,notify:r,close:i}=e;if(Qh(t))return{text:$h(t),moved:eg(t)};i();let a=t.result?.restoreStashOid;if(t.state===`no-change`)return r({title:`Nothing to discard`,description:`${n} already matches the last commit.`,type:`info`}),null;let o=t.result?.restoreIndex??!1,s=r({title:`Discarded ${n}`,type:`success`,timeout:e.restoreTimeoutMs,...a?{actionProps:{children:`Restore`,onClick:()=>e.run(gg(e,a,o,s))}}:{}});return null}var vg=Y(`Discard.finish`)(function*(e,t){return _g(t,yield*e)});function yg(e){return e===`fetch`||e===`pull`||e===`push`}function bg(e,t,n){return e?n&&(e.branch?.name!==t?.name||e.branch?.upstream!==t?.upstream)?{ready:!1,reason:`The branch target changed. Review it and try again.`}:{ready:!0,looked:e}:{ready:!1,reason:`The branch target is still loading. Try again.`}}function xg(e,t,n){if(!t?.name)throw Error(`Check out a branch before using the remote.`);let r=t.name.replace(/^refs\/heads\//,``);if(e===`fetch`||e===`pull`){if(!t?.upstream||!t.remoteName||!t.sourceRef)throw Error(`Configure an upstream branch first.`);if(`${t.remoteName}/${t.sourceRef.replace(/^refs\/heads\//,``)}`!==t.upstream)throw Error(`The configured upstream changed. Review it and try again.`);return e===`fetch`?{action:e,remoteName:t.remoteName,sourceRef:t.sourceRef}:{action:e,remoteName:t.remoteName,sourceRef:t.sourceRef,strategy:n}}let i=t.sourceRef??`refs/heads/${r}`;return{action:e,remoteName:t.remoteName??`origin`,destinationRef:i,allowCreate:t?.upstream===null||t?.upstream===void 0}}var Sg=e=>e===`fetch`?`Fetch`:e===`pull`?`Pull`:`Push`,Cg=e=>e===`fetch`?`Fetching`:e===`pull`?`Pulling`:`Pushing`,wg=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function Tg(e,t){if(e.kind===`hint`)return e.hint;if(e.kind===`commit`)return`Commit ${wg(t.changes.length,`changed file`)}`;let n=lg(t);if(e.kind===`stash`){let e=n?.stashes?.[0]?.message;return e?`Apply the stash “${e}”`:`Apply the latest stash`}let r=n?.upstream??`the configured remote`;return e.action===`pull`?`Pull from ${r}`:`Push ${wg(n?.ahead??0,`commit`)} to ${r}`}var Eg=Y(`GitMenu.runNetwork`)(function*(e,t,n,r){let{details:i}=e,a=e.onResult,o=Sg(n),s=qe(i.result)?i.result.value:void 0,c=!s;c&&e.enableDetails();let l=bg(s??(yield*i.read()),r,c);if(!l.ready){a({title:`${o} did not run`,description:l.reason,type:`error`});return}let{looked:u}=l,d=xg(n,u.branch,e.pullStrategy),f=yield*Aa(J(()=>e.onProgress(!0)),()=>t.run(d,Zh(u,[],u.branch?.upstreamOid??null)),()=>J(()=>e.onProgress(!1)));a({title:Qh(f)?`${o} did not run`:o,description:$h(f),type:Qh(f)?`error`:`success`})},(e,t,n,r)=>e.pipe(ni(e=>J(()=>t.onResult({title:`${Sg(r)} did not run`,description:tg(e),type:`error`}))))),Dg=Y(`GitMenu.restoreDiscarded`)(function*(e,t,n){let{details:r,notify:i}=e,a=n.kind===`rename`?`rename of ${n.path}`:`hunk of ${n.path}`,o=ja(Kn(r.result));(!o||Ln(r.result))&&(e.enableDetails(),o=yield*r.read()),yield*hg(t,{stashOid:n.oid,restoreIndex:n.kind===`rename`},Zh(o,[n.path],void 0,!0),i,{restored:`Restored the discarded ${a}`,failed:`Could not restore the discarded ${a}`})},(e,t,n,r)=>e.pipe(ni(e=>J(()=>t.notify({title:`Could not restore the discarded ${r.kind===`rename`?`rename of ${r.path}`:`hunk of ${r.path}`}`,description:tg(e),type:`error`}))))),Og=Y(`GitActions.lookAgain`)(function*(e,t){yield*e,yield*t}),kg=Y(`GitActions.refreshLook`)(function*(e,t){t(sg(yield*e))});function Ag(e){return mh.of({read:()=>va(()=>{if(!e)throw Error(`Pair this environment again to identify its pending Git operations.`);return window.sessionStorage.getItem(e)}),write:t=>va(()=>{if(!e)throw Error(`Pending Git operations require an identified connection.`);window.sessionStorage.setItem(e,t)}),clear:()=>va(()=>{if(!e)throw Error(`Pending Git operations require an identified connection.`);window.sessionStorage.removeItem(e)})})}var jg=Bn(`@effect/platform-browser/Crypto/WebCrypto`,{defaultValue:()=>globalThis.crypto}),Mg=Yi(ep,z(function*(){let e=yield*jg;return e?tp({randomBytes:t=>{let n=new Uint8Array(t);for(let t=0;t<n.length;t+=65536)e.getRandomValues(n.subarray(t,t+65536));return n},digest:(t,n)=>typeof e.subtle?.digest==`function`?Bt(Va({try:()=>e.subtle.digest(t,new Uint8Array(n)),catch:e=>ks({module:`Crypto`,method:`digest`,_tag:`Unknown`,description:`Could not compute digest`,cause:e})}),e=>new Uint8Array(e)):X(ks({module:`Crypto`,method:`digest`,_tag:`Unknown`,description:`crypto.subtle.digest is not available`}))}):yield*Di(Error(`Web Crypto API is not available`))}));function Ng(e){if(!e)throw Error(`A connected environment is required`);return e}var Pg={name:()=>typeof navigator>`u`?`Browser`:navigator.userAgent.slice(0,120)||`Browser`,send:fetch};function Fg(e,t){return jh({environmentId:e,address:t.address,transport:t.transport,liveUpdates:t.liveUpdates,timeoutMs:bn},ue(Mg,ps(mh,Ag(t.operationsKey))),Vg.memoMap)}function Ig({inventory:e,principal:t}){let n=t.kind===`owner`?`owner`:t.deviceId,r=Fg(e.environmentId,{address:window.location.href,transport:Um(fetch),liveUpdates:Ph(),operationsKey:`porcelain-git-requests:${JSON.stringify([e.environmentId,t.kind,n])}`});return r.atoms.addGlobalLayer(ps(Cm,Jr(e))),r}function Lg(e){return Mh({...e,send:fetch,socket:Nh,timeoutMs:bn},ue(Mg,ps(mh,Ag(e.deviceId?`porcelain-git-requests:${JSON.stringify([e.environmentId,e.address,e.deviceId])}`:void 0))),Vg.memoMap)}var Rg=ue(Dp.layer,Pm.layer).pipe(nt(ps(mp,fh))),zg=je(Rg,ps(hp,Pg),ve.layer,ps(Op,{local:e=>wo(J(()=>Ig(e)),e=>Dn(()=>e.close()))}),ps(kp,{open:e=>wo(J(()=>Lg(e)),e=>Dn(()=>e.close()))}),ps(Fm,{forgetEnvironment:()=>os})),Bg=Mp.pipe(Zt(je(Lm.layer,Ap.layer,jp.layer).pipe(Zt(zg)))),Vg=_(Bg),Hg=Et({memoMap:Vg.memoMap})(Bg),Ug=Vg.runSync(Dp),Wg=Vg.runSync(Ap),Gg=Vg.runSync(jp),Kg=Hg.atom(z(function*(){yield*(yield*Lm).read()}));function qg(){no(Kg)}function Jg(){return s(Ug.state)}function Yg(){return s(Wg.state).connection}function Xg(){return s(Gg.state)}function Zg(e){let t=(0,$.c)(5),n=s(Gg.state),r;if(t[0]!==e||t[1]!==n){let i;t[3]===e?i=t[4]:(i=t=>t.remote.environmentId===e,t[3]=e,t[4]=i),r=n.find(i),t[0]=e,t[1]=n,t[2]=r}else r=t[2];return r}function Qg(e){let t=(0,$.c)(6),n=Yg();if(e){let n;return t[0]===e?n=t[1]:(n={connection:e},t[0]=e,t[1]=n),n}let r;t[2]===n?r=t[3]:(r=Ng(n),t[2]=n,t[3]=r);let i;return t[4]===r?i=t[5]:(i={connection:r},t[4]=r,t[5]=i),i}var $g=qp({transport:Um(fetch),platform:Pg});function e_(e,t,n){return Vg.runPromise(Mm(e,$g,t,bn),{signal:n})}var t_=Om(Um(fetch,{reportUnauthorized:!1}));function n_(e){return Vg.runPromise(Nm(e,t_))}var r_=q(e=>Hg.fn((e,t)=>z(function*(){let n=yield*(yield*Lm).pair({value:e,localEnvironmentId:Wg.state.value.connection?.environmentId}).pipe(Do(bn));return t.registry.refresh(Hp(Pg,n)),n}))),i_=q(e=>Hg.fn(t=>z(function*(){yield*(yield*Lm).forget(e.environmentId)}))),a_=Hg.fn(e=>z(function*(){yield*(yield*Lm).read()})),o_=d((e,t)=>J(()=>{t.registry.refresh(Hp(Pg,e))}));function s_(e){let t=(0,$.c)(12),[n]=(0,Z.useState)(Symbol),r;t[0]===n?r=t[1]:(r=r_(n),t[0]=n,t[1]=r);let i=r,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a={mode:`promiseExit`},t[2]=a):a=t[2];let[o,s]=fr(i,a),c=yo(i),l;t[3]!==e||t[4]!==s?(l=async t=>{let n=await s(t);Hi(n)&&e()},t[3]=e,t[4]=s,t[5]=l):l=t[5];let u;t[6]===c?u=t[7]:(u=()=>c(I),t[6]=c,t[7]=u);let d;return t[8]!==o||t[9]!==l||t[10]!==u?(d={result:o,submit:l,reset:u},t[8]=o,t[9]=l,t[10]=u,t[11]=d):d=t[11],d}function c_(e){let t=(0,$.c)(7),n;t[0]===e?n=t[1]:(n=i_(e),t[0]=e,t[1]=n);let[r,i]=fr(n),a;t[2]===i?a=t[3]:(a=()=>i(void 0),t[2]=i,t[3]=a);let o;return t[4]!==r||t[5]!==a?(o={result:r,submit:a},t[4]=r,t[5]=a,t[6]=o):o=t[6],o}function l_(){return yo(o_)}function u_(){let e=(0,$.c)(5),[t,n]=fr(a_),r;e[0]===n?r=e[1]:(r=()=>n(void 0),e[0]=n,e[1]=r);let i;return e[2]!==t||e[3]!==r?(i={result:t,read:r},e[2]=t,e[3]=r,e[4]=i):i=e[4],i}function d_(){let e=(0,$.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Z.useEffect)(f_,t),Hm}function f_(){return Vm(p_)}function p_(){Vg.runFork(Wg.clear())}function m_(e){let t=(0,$.c)(5),n;t[0]===e?n=t[1]:(n=Hp(Pg,e),t[0]=e,t[1]=n);let r=no(n),i;return t[2]!==e||t[3]!==r?(i=vp(e,ja(Kn(r))),t[2]=e,t[3]=r,t[4]=i):i=t[4],i}var h_=ct(`group/alert relative grid w-full gap-0.5 rounded-2xl border px-4 py-3 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2.5 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current`}},defaultVariants:{variant:`default`}});function g_({className:e,variant:t,...n}){return(0,Q.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:W(h_({variant:t}),e),...n})}function __({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`alert-title`,className:W(`font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground`,e),...t})}function v_({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`alert-description`,className:W(`text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4`,e),...t})}function y_({className:e,...t}){return(0,Q.jsx)(St,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:W(`size-4 animate-spin`,e),...t})}var b_=q(e=>Hg.fn((t,n)=>z(function*(){yield*n.setResult(jm(e),void 0),yield*(yield*Ap).clear()})));function x_(e){let t=(0,$.c)(8),n;t[0]===e?n=t[1]:(n=b_(e),t[0]=e,t[1]=n);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r={mode:`promiseExit`},t[2]=r):r=t[2];let[i,a]=fr(n,r),o;t[3]===a?o=t[4]:(o=()=>{a()},t[3]=a,t[4]=o);let s;return t[5]!==i||t[6]!==o?(s={result:i,submit:o},t[5]=i,t[6]=o,t[7]=s):s=t[7],s}function S_(){let e=(0,$.c)(12),{connection:t}=Qg(),{result:n,submit:r}=x_(t),i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:`This browser`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Ends its session here. Pair it again with a new link.`})]}),e[0]=i):i=e[0];let a;e[1]===n.waiting?a=e[2]:(a=n.waiting?(0,Q.jsx)(y_,{}):(0,Q.jsx)(Df,{}),e[1]=n.waiting,e[2]=a);let o;e[3]!==n.waiting||e[4]!==r||e[5]!==a?(o=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-6`,children:[i,(0,Q.jsxs)(Le,{variant:`outline`,className:`shrink-0`,disabled:n.waiting,onClick:r,children:[a,`Disconnect this browser`]})]}),e[3]=n.waiting,e[4]=r,e[5]=a,e[6]=o):o=e[6];let s;e[7]===n?s=e[8]:(s=Ln(n)&&(0,Q.jsx)(g_,{variant:`destructive`,children:(0,Q.jsx)(v_,{children:Am(hi(n.cause))})}),e[7]=n,e[8]=s);let c;return e[9]!==o||e[10]!==s?(c=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[o,s]}),e[9]=o,e[10]=s,e[11]=c):c=e[11],c}function C_(e){let t=(0,$.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsx)(`div`,{className:`absolute right-4 top-3`,children:(0,Q.jsx)(`h1`,{className:`font-medium`,children:`Porcelain`})}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,Q.jsxs)(Q.Fragment,{children:[r,(0,Q.jsx)(`main`,{className:`mx-auto flex min-h-svh max-w-6xl flex-col items-start gap-6 px-6 py-24`,children:n})]}),t[1]=n,t[2]=i),i}function w_(){return typeof window>`u`?`http://127.0.0.1:3000`:window.location.origin}function T_(e){let t=(0,$.c)(9),{reason:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-medium`,children:`This browser is not paired`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Run this on the machine hosting Porcelain, then open the link it prints on this device.`})]}),t[0]=r):r=t[0];let i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(`pre`,{className:`overflow-x-auto rounded-md border bg-muted p-3 text-sm`,children:(0,Q.jsx)(`code`,{children:`porcelain pair "This browser" --address ${w_()}`})}),t[1]=i):i=t[1];let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(`code`,{children:`porcelain devices`}),t[2]=a):a=t[2];let o,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`The link works once and expires. Revoke this device at any time with`,` `,a,` and `,(0,Q.jsx)(`code`,{children:`porcelain revoke`}),`.`]}),s=!1,t[3]=o,t[4]=s):(o=t[3],s=t[4]);let c;t[5]===n?c=t[6]:(c=n&&(0,Q.jsx)(g_,{variant:`destructive`,children:(0,Q.jsx)(v_,{children:n})}),t[5]=n,t[6]=c);let l;return t[7]===c?l=t[8]:(l=(0,Q.jsxs)(`section`,{className:`mx-auto flex w-full max-w-md flex-col gap-6`,children:[r,i,o,s,c]}),t[7]=c,t[8]=l),l}function E_(e){let t=(0,$.c)(2),{reason:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Q.jsx)(C_,{children:n?(0,Q.jsx)(T_,{reason:n}):(0,Q.jsxs)(`section`,{className:`mx-auto flex w-full max-w-md flex-col gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-medium`,children:`Pairing this browser…`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Checking that the link belongs to this Porcelain installation.`})]})}),t[0]=n,t[1]=r),r}function D_(e){let t=(0,$.c)(3),n;t[0]===e?n=t[1]:(n=_m(e),t[0]=e,t[1]=n);let r;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r={mode:`promise`},t[2]=r):r=t[2],fr(n,r)}function O_(e,t){let n=(0,$.c)(3),r;return n[0]!==e||n[1]!==t?(r=vm({connection:e,id:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2],fr(r)}function k_(e,t){let n=(0,$.c)(3),r;return n[0]!==e||n[1]!==t?(r=ym({connection:e,id:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2],fr(r)}function A_(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=bm(e),t[0]=e,t[1]=n),fr(n)}function j_(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=xm(e),t[0]=e,t[1]=n),fr(n)}function M_(e){let t=(0,$.c)(3),n;t[0]===e?n=t[1]:(n=Em(e),t[0]=e,t[1]=n);let r;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r={mode:`promise`},t[2]=r):r=t[2],fr(n,r)}function N_(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=dm(e),t[0]=e,t[1]=n),no(n)}function P_(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=fm(e),t[0]=e,t[1]=n),no(n)}function F_(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=pm(e),t[0]=e,t[1]=n),no(n)}function I_(e){return e.kind===`local`?`Only a browser on the computer that runs Porcelain, or a device its owner trusts, can update it.`:e.deviceId?`Trust this app on ${e.name} to update it from here: run porcelain trust ${e.deviceId} there.`:`Trust this app on ${e.name} to update it from here: run porcelain devices there, then porcelain trust with this app's id.`}function L_(e){let t=(0,$.c)(17),{state:n,started:r}=e,i;t[0]===n?i=t[1]:(i=ch(n),t[0]=n,t[1]=i);let a=i;if(a?.kind===`updated`){let e=`Updated from ${a.from} to ${a.target}.${r?` Reload to use the new version here.`:``}`,n;t[2]===e?n=t[3]:(n=(0,Q.jsx)(g_,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(v_,{children:e})}),t[2]=e,t[3]=n);let i;t[4]===r?i=t[5]:(i=r&&(0,Q.jsx)(Le,{size:`sm`,variant:`outline`,onClick:R_,children:`Reload`}),t[4]=r,t[5]=i);let o;return t[6]!==n||t[7]!==i?(o=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[n,i]}),t[6]=n,t[7]=i,t[8]=o):o=t[8],o}if(a?.kind===`failed`){let e=n.version??`the version it had`,r;t[9]!==a.target||t[10]!==e?(r=(0,Q.jsxs)(`p`,{children:[`The update to `,a.target,` failed, so Porcelain still runs`,` `,e,`.`]}),t[9]=a.target,t[10]=e,t[11]=r):r=t[11];let i;t[12]===a.reason?i=t[13]:(i=(0,Q.jsx)(`p`,{children:a.reason}),t[12]=a.reason,t[13]=i);let o;return t[14]!==r||t[15]!==i?(o=(0,Q.jsx)(g_,{variant:`destructive`,children:(0,Q.jsxs)(v_,{children:[r,i]})}),t[14]=r,t[15]=i,t[16]=o):o=t[16],o}return null}function R_(){return window.location.reload()}function z_(e){let t=(0,$.c)(22),{connection:n,target:r,state:i,onStart:a}=e,[o,s]=j_(n),{latest:c}=i;if(!i.available||c==null){let e=c==null?`Could not check for a newer version.`:`This is the newest version.`,n;return t[0]===e?n=t[1]:(n=(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e}),t[0]=e,t[1]=n),n}let l;t[2]===c?l=t[3]:(l=(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Porcelain `,c,` is available.`]}),t[2]=c,t[3]=l);let u;t[4]!==c||t[5]!==a||t[6]!==o||t[7]!==s||t[8]!==i.canUpdate?(u=i.canUpdate&&(0,Q.jsxs)(Le,{size:`sm`,disabled:o.waiting,onClick:()=>{a(),s(c)},children:[o.waiting&&(0,Q.jsx)(y_,{}),`Update to `,c]}),t[4]=c,t[5]=a,t[6]=o,t[7]=s,t[8]=i.canUpdate,t[9]=u):u=t[9];let d;t[10]!==l||t[11]!==u?(d=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[l,u]}),t[10]=l,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==i.canUpdate||t[14]!==r?(f=!i.canUpdate&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I_(r)}),t[13]=i.canUpdate,t[14]=r,t[15]=f):f=t[15];let p;t[16]===o?p=t[17]:(p=Ln(o)&&(0,Q.jsx)(g_,{variant:`destructive`,children:(0,Q.jsx)(v_,{children:Am(hi(o.cause))})}),t[16]=o,t[17]=p);let m;return t[18]!==d||t[19]!==f||t[20]!==p?(m=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[d,f,p]}),t[18]=d,t[19]=f,t[20]=p,t[21]=m):m=t[21],m}function B_(e){let t=(0,$.c)(15),{connection:n,target:r}=e,i=F_(n),[a,o]=(0,Z.useState)(!1),s,c,l;if(t[0]!==i){l=Symbol.for(`react.early_return_sentinel`);bb0:{if(s=ja(Kn(i)),!s){l=Ln(i)?(0,Q.jsx)(g_,{variant:`destructive`,children:(0,Q.jsx)(v_,{children:Am(hi(i.cause))})}):(0,Q.jsx)(y_,{});break bb0}c=sh(s,Ln(i))}t[0]=i,t[1]=s,t[2]=c,t[3]=l}else s=t[1],c=t[2],l=t[3];if(l!==Symbol.for(`react.early_return_sentinel`))return l;let u=c,d=s.version??`development build`,f;t[4]===d?f=t[5]:(f=(0,Q.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Porcelain `,d]}),t[4]=d,t[5]=f);let p;t[6]!==n||t[7]!==u||t[8]!==a||t[9]!==s||t[10]!==r?(p=s.managed?u?(0,Q.jsxs)(`div`,{"aria-live":`polite`,className:`flex items-center gap-2 text-sm`,children:[(0,Q.jsx)(y_,{}),(0,Q.jsx)(`p`,{children:u})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L_,{state:s,started:a&&r.kind===`local`}),(0,Q.jsx)(z_,{connection:n,target:r,state:s,onStart:()=>o(!0)})]}):(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This server runs outside the installed service. Update it with npm, then run porcelain service update.`}),t[6]=n,t[7]=u,t[8]=a,t[9]=s,t[10]=r,t[11]=p):p=t[11];let m;return t[12]!==f||t[13]!==p?(m=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14],m}function V_(){let e=(0,$.c)(2),t=Yg(),n;return e[0]===t?n=e[1]:(n=t&&(0,Q.jsx)(B_,{connection:t,target:{kind:`local`}}),e[0]=t,e[1]=n),n}function H_(e){let t=(0,$.c)(6),{connection:n,name:r,deviceId:i}=e,a;t[0]!==i||t[1]!==r?(a={kind:`remote`,name:r,deviceId:i},t[0]=i,t[1]=r,t[2]=a):a=t[2];let o;return t[3]!==n||t[4]!==a?(o=(0,Q.jsx)(B_,{connection:n,target:a}),t[3]=n,t[4]=a,t[5]=o):o=t[5],o}function U_({className:e,...t}){return(0,Q.jsx)(`label`,{"data-slot":`label`,className:W(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function W_({className:e,...t}){return(0,Q.jsx)(`fieldset`,{"data-slot":`field-set`,className:W(`flex flex-col gap-6 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3`,e),...t})}function G_({className:e,variant:t=`legend`,...n}){return(0,Q.jsx)(`legend`,{"data-slot":`field-legend`,"data-variant":t,className:W(`mb-3 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base`,e),...n})}function K_({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`field-group`,className:W(`group/field-group @container/field-group flex w-full flex-col gap-6 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4`,e),...t})}var q_=ct(`group/field flex w-full gap-3 data-[invalid=true]:text-destructive`,{variants:{orientation:{vertical:`flex-col *:w-full [&>.sr-only]:w-auto`,horizontal:`flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`,responsive:`flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`}},defaultVariants:{orientation:`vertical`}});function J_({className:e,orientation:t=`vertical`,...n}){return(0,Q.jsx)(`div`,{role:`group`,"data-slot":`field`,"data-orientation":t,className:W(q_({orientation:t}),e),...n})}function Y_({className:e,...t}){return(0,Q.jsx)(U_,{"data-slot":`field-label`,className:W(`group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:bg-input/30 has-[>[data-slot=field]]:rounded-2xl has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-input/40 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-4`,`has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col`,e),...t})}function X_({className:e,...t}){return(0,Q.jsx)(`p`,{"data-slot":`field-description`,className:W(`text-left text-sm leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5`,`last:mt-0 nth-last-2:-mt-1`,`[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function Z_({className:e,children:t,errors:n,...r}){let i=(0,Z.useMemo)(()=>{if(t)return t;if(!n?.length)return null;let e=[...new Map(n.map(e=>[e?.message,e])).values()];return e?.length==1?e[0]?.message:(0,Q.jsx)(`ul`,{className:`ml-4 flex list-disc flex-col gap-1`,children:e.map((e,t)=>e?.message&&(0,Q.jsx)(`li`,{children:e.message},t))})},[t,n]);return i?(0,Q.jsx)(`div`,{role:`alert`,"data-slot":`field-error`,className:W(`text-sm font-normal text-destructive`,e),...r,children:i}):null}function Q_(e){return sn(e.defaultTagName??`div`,e,e)}function $_({className:e,...t}){return(0,Q.jsx)(`div`,{role:`list`,"data-slot":`item-group`,className:W(`group/item-group flex w-full flex-col gap-4 has-data-[size=sm]:gap-2.5 has-data-[size=xs]:gap-2`,e),...t})}var ev=ct(`group/item flex w-full flex-wrap items-center rounded-2xl border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted`,{variants:{variant:{default:`border-transparent`,outline:`border-border`,muted:`border-transparent bg-muted/50`},size:{default:`gap-3.5 px-4 py-3.5`,sm:`gap-3.5 px-3.5 py-3`,xs:`gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0`}},defaultVariants:{variant:`default`,size:`default`}});function tv({className:e,variant:t=`default`,size:n=`default`,render:r,...i}){return Q_({defaultTagName:`div`,props:A({className:W(ev({variant:t,size:n,className:e}))},i),render:r,state:{slot:`item`,variant:t,size:n}})}var nv=ct(`flex shrink-0 items-center justify-center gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start [&_svg]:pointer-events-none`,{variants:{variant:{default:`bg-transparent`,icon:`[&_svg:not([class*='size-'])]:size-4`,image:`size-10 overflow-hidden rounded-xl group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 group-data-[size=xs]/item:rounded-lg [&_img]:size-full [&_img]:object-cover`}},defaultVariants:{variant:`default`}});function rv({className:e,variant:t=`default`,...n}){return(0,Q.jsx)(`div`,{"data-slot":`item-media`,"data-variant":t,className:W(nv({variant:t,className:e})),...n})}function iv({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`item-content`,className:W(`flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0.5 [&+[data-slot=item-content]]:flex-none`,e),...t})}function av({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`item-title`,className:W(`line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4`,e),...t})}function ov({className:e,...t}){return(0,Q.jsx)(`p`,{"data-slot":`item-description`,className:W(`line-clamp-2 text-left text-sm font-normal text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function sv({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`item-actions`,className:W(`flex items-center gap-2`,e),...t})}function cv({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`item-footer`,className:W(`flex basis-full items-center justify-between gap-2`,e),...t})}var lv=ms(dn.layer),uv=lv.atom(z(function*(){return(yield*dn).hasAppUpdater})),dv=lv.atom(z(function*(){return yield*(yield*dn).checkUpdate})).pipe(dt),fv=lv.atom(Ba(z(function*(){return(yield*dn).updateStates}))).pipe(b(0));function pv(){return no(dv)}function mv(){let e=(0,$.c)(2),t=no(fv),n;return e[0]===t?n=e[1]:(n=di(Kn(t),hv),e[0]=t,e[1]=n),n}function hv(){return{status:`idle`}}function gv(){return no(uv)}var _v=`data-valid`,vv=`data-invalid`,yv={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},bv={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},xv={valid(e){return e===null?null:e?{[_v]:``}:{[vv]:``}}},Sv={invalid:void 0,name:void 0,validityData:{state:yv,errors:[],error:``,value:``,initialValue:null},setValidityData:Xn,disabled:void 0,setTouched:Xn,setDirty:Xn,setFilled:Xn,setFocused:Xn,validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:bv,registerFieldControl:Xn,validation:{getValidationProps:(e,t=ir)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:Xn,getInputControl:()=>null,commit:async()=>{},change:Xn}},Cv=Z.createContext(Sv);function wv(e=!0){let t=Z.useContext(Cv);if(t.setValidityData===Xn&&!e)throw Error(Un(28));return t}var Tv=Z.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:Xn,validationMode:`onSubmit`,submitCountRef:{current:0}});function Ev(){return Z.useContext(Tv)}var Dv=Z.createContext({controlId:void 0,registerControlId:Xn,resetControlId:Xn,labelId:void 0,setLabelId:Xn,messageIds:[],setMessageIds:Xn,getDescriptionProps:e=>e});function Ov(){return Z.useContext(Dv)}function kv(e,t,n,r=!0,i){let[a,o]=Z.useState(),s=Of(i?`${i}-label`:void 0),c=e??t??a;return U(()=>{let i=e||t||!r?void 0:Av(n.current,s);a!==i&&o(i)}),c}function Av(e,t){let n=jv(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function jv(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}function Mv(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=Ov(),o=Of(),s=$e(()=>Symbol()),c=Z.useRef(!1),l=Z.useRef(!1),u=G(()=>{c.current&&i!==Xn&&(c.current=!1,i(s.current,void 0))});return U(()=>{if(!n||i===Xn){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}if(e===void 0){u();return}c.current=!0,i(s.current,e)},[t,n,i,a,o,s,u]),U(()=>u,[u]),(n?r:void 0)??t??o}function Nv({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=Z.useRef(e!==void 0),[a,o]=Z.useState(t);return[i&&e!==void 0?e:a,Z.useCallback(e=>{i||o(e)},[])]}function Pv(e,t,n,r,i=!0,a){let{registerFieldControl:o}=wv(),s=$e(()=>Symbol());U(()=>{let c=s.current;if(!i){o(c,void 0);return}o(c,{controlRef:e,getValue:r,id:t,name:a,value:n})},[e,i,r,t,a,o,s,n]),U(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}function Fv(e,t){let n=Z.useRef(e),r=G(t);U(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}var Iv=Z.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFocused:y,setFilled:b,validationMode:x,validation:S}=wv(),{clearErrors:C,elementRef:w,submitCountRef:T}=Ev(),E=h||s,D=m??a,ee={...p,disabled:E},{labelId:O}=Ov(),k=Mv({id:i}),[A]=Nv({controlled:o,default:l,name:`FieldControl`,state:`value`}),j=o!==void 0,M=j?A:void 0,N=M==null?void 0:String(M),P=G(()=>S.inputRef.current?.value);Pv(S.inputRef,k,N,P,!E,a),U(()=>{let e=N??S.inputRef.current?.value;e!==void 0&&b(e!==``)},[N,S.inputRef,b]),Fv(N,()=>{N!==void 0&&(C(D),_(N!==(v.initialValue??``)),S.change(N))});let F=Z.useRef(null),I=Ei();return U(()=>{u&&F.current===po(zr(F.current))&&y(!0)},[u,y]),sn(`input`,e,{ref:[t,F],state:ee,props:[{id:k,disabled:E,name:D,ref:S.inputRef,"aria-labelledby":O,autoFocus:u,...j?{value:M}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=On(si,e.nativeEvent);c?.(t,n),!j&&(_(t!==(v.initialValue??``)),b(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(C(D),S.change(t)))},onFocus(){y(!0)},onBlur(e){if(g(!0),y(!1),x===`onBlur`){let t=e.currentTarget.value;S.commit(t),j&&queueMicrotask(()=>{let e=S.inputRef.current?.value;e!==void 0&&e!==t&&e!==(v.initialValue??``)&&S.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){g(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===w.current&&!e.defaultPrevented){let t=e.currentTarget,n=T.current;I.start(0,()=>{T.current===n&&S.commit(t.value)})}else S.commit(t)}}},f,e=>S.getValidationProps(E,e)],stateAttributesMapping:xv})}),Lv=Z.forwardRef(function(e,t){return(0,Q.jsx)(Iv,{ref:t,...e})});function Rv({className:e,type:t,...n}){return(0,Q.jsx)(Lv,{type:t,"data-slot":`input`,className:W(`h-8 w-full min-w-0 rounded-2xl border border-transparent bg-input/50 px-2.5 py-1 text-base transition-[color,box-shadow] duration-200 outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n})}function zv(e){e.catch(()=>void 0)}function Bv(e,t){e.preventDefault(),zv(t())}function Vv(e){let t=(0,$.c)(25),{connection:n,environment:r}=e,[i,a]=(0,Z.useState)(null),[o,s]=M_(n),c=i??(r.custom?r.name:``),l;t[0]===c?l=t[1]:(l=c.trim(),t[0]=c,t[1]=l);let u=l,d=r.custom?u===r.name:u===``,f;t[2]!==u||t[3]!==s?(f=e=>Bv(e,async()=>s(u===``?null:u)),t[2]=u,t[3]=s,t[4]=f):f=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(U_,{htmlFor:`environment-name`,children:`Name of this computer`}),t[5]=p):p=t[5];let m=r.custom?`Host name`:r.name,h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>a(e.target.value),t[6]=h):h=t[6];let g;t[7]!==m||t[8]!==c?(g=(0,Q.jsx)(Rv,{id:`environment-name`,className:`min-w-0 flex-1`,placeholder:m,maxLength:Yt,value:c,onChange:h}),t[7]=m,t[8]=c,t[9]=g):g=t[9];let _=d||o.waiting,v=o.waiting?`Saving…`:`Save`,y;t[10]!==_||t[11]!==v?(y=(0,Q.jsx)(Le,{type:`submit`,variant:`outline`,disabled:_,children:v}),t[10]=_,t[11]=v,t[12]=y):y=t[12];let b;t[13]!==g||t[14]!==y?(b=(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[g,y]}),t[13]=g,t[14]=y,t[15]=b):b=t[15];let x;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(X_,{children:`Paired devices show it so you know where they are connected. Leave it empty to use the host name.`}),t[16]=x):x=t[16];let S;t[17]===b?S=t[18]:(S=(0,Q.jsxs)(J_,{children:[p,b,x]}),t[17]=b,t[18]=S);let C;t[19]===o?C=t[20]:(C=Ln(o)&&(0,Q.jsx)(g_,{variant:`destructive`,children:(0,Q.jsx)(v_,{children:Am(hi(o.cause))})}),t[19]=o,t[20]=C);let w;return t[21]!==S||t[22]!==C||t[23]!==f?(w=(0,Q.jsxs)(`form`,{className:`flex flex-col gap-2`,onSubmit:f,children:[S,C]}),t[21]=S,t[22]=C,t[23]=f,t[24]=w):w=t[24],w}var Hv=ms(dn.layer).fn(e=>z(function*(){yield*(yield*dn).installUpdate}));function Uv(){let e=(0,$.c)(5),[t,n]=fr(Hv),r;e[0]===n?r=e[1]:(r=()=>n(void 0),e[0]=n,e[1]=r);let i;return e[2]!==t||e[3]!==r?(i={result:t,install:r},e[2]=t,e[3]=r,e[4]=i):i=e[4],i}function Wv(e){switch(e.status){case`checking`:return`Checking for a new version…`;case`downloading`:return`Downloading ${e.version}…`;case`verifying`:return`Verifying ${e.version}…`;case`ready`:return`${e.version} is ready; the app restarts to finish.`;case`installing`:return`Installing ${e.version}; the app restarts in a moment.`;default:return}}function Gv(e){return e.status===`unavailable`?`This build updates by reinstalling; there is no update feed yet.`:`This is the newest version of the app.`}function Kv(){let e=(0,$.c)(21),t=pv(),n=Uv(),r=mv(),a;e[0]===t?a=e[1]:(a=ja(i(Kn(t))),e[0]=t,e[1]=a);let o=a;if(!o){let n;return e[2]===t?n=e[3]:(n=ye(t)?(0,Q.jsx)(y_,{}):null,e[2]=t,e[3]=n),n}let s;e[4]===r?s=e[5]:(s=Wv(r),e[4]=r,e[5]=s);let c=s,l;e[6]===o.current?l=e[7]:(l=(0,Q.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Porcelain app `,o.current]}),e[6]=o.current,e[7]=l);let u;e[8]!==o.available||e[9]!==n||e[10]!==c||e[11]!==r?(u=c?(0,Q.jsxs)(`div`,{"aria-live":`polite`,className:`flex items-center gap-2 text-sm`,children:[(0,Q.jsx)(y_,{}),(0,Q.jsx)(`p`,{children:c})]}):o.available?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Porcelain app `,o.available,` is available.`]}),(0,Q.jsxs)(Le,{size:`sm`,disabled:n.result.waiting,onClick:()=>n.install(),children:[`Update to `,o.available]})]}):(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Gv(r)}),e[8]=o.available,e[9]=n,e[10]=c,e[11]=r,e[12]=u):u=e[12];let d;e[13]!==n||e[14]!==r.message||e[15]!==r.status?(d=(r.status===`error`||Ln(n.result))&&(0,Q.jsx)(g_,{variant:`destructive`,children:(0,Q.jsx)(v_,{children:r.status===`error`?r.message:Ln(n.result)?Am(hi(n.result.cause)):void 0})}),e[13]=n,e[14]=r.message,e[15]=r.status,e[16]=d):d=e[16];let f;return e[17]!==l||e[18]!==u||e[19]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[l,u,d]}),e[17]=l,e[18]=u,e[19]=d,e[20]=f):f=e[20],f}var qv=Z.createContext(void 0);function Jv(){let e=Z.useContext(qv);if(e===void 0)throw Error(Un(63));return e}var Yv=`data-checked`,Xv=`data-unchecked`,Zv={...xv,checked(e){return e?{[Yv]:``}:{[Xv]:``}}},Qv=Z.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,"aria-labelledby":a,form:o,id:s,inputRef:c,name:l,nativeButton:u=!1,onCheckedChange:d,readOnly:f=!1,required:p=!1,disabled:m=!1,render:h,uncheckedValue:g,value:_,style:v,...y}=e,{clearErrors:b}=Ev(),{state:x,setTouched:S,setDirty:C,validityData:w,setFilled:T,setFocused:E,validationMode:D,disabled:ee,name:O,validation:k}=wv(),{labelId:A}=Ov(),j=ee||m,M=O??l,N=Z.useRef(null),P=gn(N,c,k.inputRef),F=Z.useRef(null),I=Of(),L=Mv({id:s}),te=u?void 0:L,[z,B]=Nv({controlled:n,default:!!i,name:`Switch`,state:`checked`});Pv(F,I,z,void 0,!j,l),U(()=>{T(z)},[z,T]),Fv(z,()=>{b(M),C(z!==w.initialValue),k.change(z)});let{getButtonProps:ne,buttonRef:re}=fo({disabled:j,native:u}),ie=kv(a,A,N,!u,te),V={id:u?L:I,role:`switch`,"aria-checked":z,"aria-readonly":f||void 0,"aria-required":p||void 0,"aria-labelledby":ie,onFocus(){j||E(!0)},onBlur(){let e=N.current;e&&!j&&(S(!0),E(!1),D===`onBlur`&&k.commit(e.checked))},onClick(e){if(f||j)return;e.preventDefault();let t=N.current;t&&Wr(t,e)}},ae={...k.getValidationProps(j),checked:z,disabled:j,form:o,id:te,name:M,required:p,style:M?Ot:R,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:P,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(f){e.preventDefault();return}let t=e.currentTarget.checked,n=On(si,e.nativeEvent);d?.(t,n),!n.isCanceled&&B(t)},onClick(e){e.stopPropagation()},onFocus(){F.current?.focus()},..._===void 0?ir:{value:_}},oe=Z.useMemo(()=>({...x,checked:z,disabled:j,readOnly:f,required:p}),[x,z,j,f,p]),se=sn(`span`,e,{state:oe,ref:[t,F,re],props:[V,y,ne,e=>k.getValidationProps(j,e)],stateAttributesMapping:Zv});return(0,Q.jsxs)(qv.Provider,{value:oe,children:[se,!z&&M&&g!==void 0&&(0,Q.jsx)(`input`,{type:`hidden`,form:o,name:M,value:g,disabled:j}),(0,Q.jsx)(`input`,{...ae,suppressHydrationWarning:!0})]})}),$v=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Jv();return sn(`span`,e,{state:o,ref:t,stateAttributesMapping:Zv,props:a})});function ey({className:e,size:t=`default`,...n}){return(0,Q.jsx)(Qv,{"data-slot":`switch`,"data-size":t,className:W(`peer group/switch relative inline-flex shrink-0 items-center rounded-2xl border-2 transition-all outline-none group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-5 data-[size=default]:w-8 data-[size=sm]:h-4 data-[size=sm]:w-6 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary group-has-[:focus-visible]/field-label:data-checked:border-primary data-unchecked:border-transparent data-unchecked:bg-input/90 group-has-[:focus-visible]/field-label:data-unchecked:border-transparent data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,Q.jsx)($v,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-2xl bg-background shadow-sm ring-0 transition-transform not-dark:bg-clip-padding group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-checked:translate-x-[calc(100%-4px)] dark:data-checked:bg-primary-foreground data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}function ty(e){let t=Z.useRef(!0);t.current&&(t.current=!1,e())}function ny(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var ry=Z.createContext(void 0),iy=Z.createContext(void 0),ay=Z.createContext(void 0);function oy(){let e=Z.useContext(ry);if(e===void 0)throw Error(Un(60));return e}function sy(){let e=Z.useContext(iy);if(e===void 0)throw Error(Un(101));return e}function cy(){let e=Z.useContext(ay);if(e===void 0)throw Error(Un(61));return e}function ly(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var uy=(e,t)=>Object.is(e,t);function dy(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function fy(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!ly(e,t,(e,t)=>dy(e,t,n)):e!==t}function py(e,t,n){return e?e.some(e=>e!==void 0&&dy(t,e,n)):!1}function my(e,t,n){return e?e.findIndex(e=>e!==void 0&&dy(e,t,n)):-1}function hy(e,t){if(t!==uy)return n=>py(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function gy(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(hy(t,n)):my(e,t,n);return i===-1?null:i}function _y(e,t,n,r,i,a){return py(r,t,i)?a!=null&&e>a&&py(r,n[a],i)?a:e:e===a?gy(n,r,i,!0):a}function vy(e,t,n){return e.filter(e=>!dy(t,e,n))}function yy(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function by(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function xy(e){return by(e?.[0])}function Sy(e){return xy(e)?e.flatMap(e=>e.items):e}function Cy(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(xy(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function wy(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return yy(e)}function Ty(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?yy(e.value):yy(e)}function Ey(e,t,n){function r(){return wy(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){let n=Sy(t);if(typeof e!=`object`||!e){let t=n.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=n.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function Dy(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,Q.jsx)(Z.Fragment,{children:Ey(r,t,n)},i)),e),[])}var Oy={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:Ty(t,r)!==``},hasNullItemLabel:(e,t)=>t?Cy(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>dy(t,e,n)):dy(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function ky(e){let t=Z.useRef(``),n=Z.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:Z.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function Ay(e,t){let{onClick:n,onPointerDown:r}=ky(G((n,r)=>{(typeof e==`function`?e():e)||t(r||(Wa?`touch`:``))}));return Z.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function jy(e){let[t,n]=Z.useState(null),r=Ay(e,n);return Fv(e,t=>{t&&!e&&n(null)}),Z.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function My(e,t){return Math.max(0,e-t)}function Ny(e,t){if(t<=0)return 0;let n=xl(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}function Py(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:p=!1,modal:m=!0,actionsRef:h,inputRef:g,onOpenChangeComplete:_,items:v,multiple:y=!1,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S=uy,highlightItemOnHover:C=!0,children:T}=e,{clearErrors:E}=Ev(),{setDirty:D,setTouched:ee,setFocused:O,validityData:k,setFilled:j,name:M,disabled:N,validation:P,validationMode:F}=wv(),I=Mv({id:t}),L=N||d,te=M??c,[z,B]=Nv({controlled:n,default:y?r??We:r,name:`Select`,state:`value`}),[ne,re]=Nv({controlled:a,default:o,name:`Select`,state:`open`}),ie=Z.useRef([]),V=Z.useRef([]),ae=Z.useRef(null),oe=Z.useRef(null),se=Z.useRef(0),ce=Z.useRef(null),le=Z.useRef([]),ue=Z.useRef(!1),de=Z.useRef(null),fe=Z.useRef(null),pe=Z.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),me=Z.useRef(!1),he=Z.useRef(z),{mounted:ge,setMounted:_e,transitionStatus:ve}=fd(ne),{openMethod:ye,triggerProps:H}=jy(ne),be=$e(()=>new w({id:I,labelId:void 0,modal:m,multiple:y,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,value:z,open:ne,mounted:ge,transitionStatus:ve,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:ir,triggerProps:ir,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:Xn,setOpen:Xn,handleScrollArrowVisibility:Xn,onOpenChangeComplete:Xn,listRef:ie,popupRef:ae,scrollHandlerRef:oe,scrollArrowsMountedCountRef:se,valueRef:ce,valuesRef:le,labelsRef:V,typingRef:ue,selectionRef:pe,firstItemTextRef:de,selectedItemTextRef:fe,alignItemWithTriggerActiveRef:me,initialValueRef:he},Oy)).current,xe=be.useState(`activeIndex`),Se=be.useState(`selectedIndex`),Ce=be.useState(`triggerElement`),we=be.useState(`positionerElement`),Te=kf(ye),Ee=ye??Te,De=Z.useMemo(()=>y?``:Ty(z,x),[y,z,x]),Oe=Z.useMemo(()=>y&&Array.isArray(z)?z.map(e=>Ty(e,x)):Ty(z,x),[y,z,x]);Pv(Sl(Ce),I,z,G(()=>Oe),!L,c);let ke=y?Array.isArray(z)&&z.length>0:z!=null&&De!==``;U(()=>{j(ke)},[ke,j]),U(function(){let e=gy(le.current,z,S,y);e===null&&(fe.current=null),!ne&&be.set(`selectedIndex`,e)},[y,ne,z,S,be]),Fv(z,()=>{E(te),D(fy(z,k.initialValue,S)),P.change(z)});let Ae=G((e,t)=>{s?.(e,t),!t.isCanceled&&(re(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(ee(!0),O(!1),F===`onBlur`&&P.commit(z)))}),je=G(()=>{_e(!1),be.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)});zo({enabled:!h,open:ne,ref:ae,onComplete(){ne||je()}}),Z.useImperativeHandle(h,()=>({unmount:je}),[je]);let Me=G((e,t)=>{i?.(e,t),!t.isCanceled&&B(e)}),Ne=G(e=>{let t=My(e.scrollHeight,e.clientHeight),n=Ny(e.scrollTop,t),r=n>0,i=n<t;be.set(`scrollUpArrowVisible`,r),be.set(`scrollDownArrowVisible`,i)}),Pe=Dd({open:ne,onOpenChange:Ae,elements:{reference:Ce,floating:we}}),Fe=nu(Pe,{enabled:!L,event:`mousedown`}),Ie=au(Pe),Le=Ld(Pe,{enabled:!L,listRef:ie,activeIndex:xe,selectedIndex:Se,disabledIndices:We,onNavigate(e){(e!==null||ne)&&be.set(`activeIndex`,e)},focusItemOnHover:C}),Re=Rd(Pe,{enabled:!L&&(ne||!f&&!y),listRef:V,activeIndex:xe,selectedIndex:Se,disabledIndices:e=>ny(ie.current[e]),onMatch(e){ne?be.set(`activeIndex`,e):Me(le.current[e],On(si))},onTyping(e){ue.current=e}}),ze=Z.useMemo(()=>A(Re.reference,Le.reference,Ie.reference,Fe.reference,H),[Fe.reference,Re.reference,Le.reference,Ie.reference,H]),Be=Z.useMemo(()=>A(pd,Re.floating,Le.floating,Ie.floating),[Re.floating,Le.floating,Ie.floating]),Ve=Le.item??ir;be.useContextCallback(`setValue`,Me),be.useContextCallback(`setOpen`,Ae),be.useContextCallback(`handleScrollArrowVisibility`,Ne),be.useContextCallback(`onOpenChangeComplete`,_),ty(()=>{be.update({popupProps:Be,triggerProps:ze})}),be.useSyncedValues({id:I,modal:m,multiple:y,value:z,open:ne,mounted:ge,transitionStatus:ve,popupProps:Be,triggerProps:ze,items:v,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,openMethod:Ee});let He=Z.useMemo(()=>({disabled:L,readOnly:f,required:p,multiple:y,highlightItemOnHover:C,itemProps:Ve}),[L,f,p,y,C,Ve]),Ue=gn(g,P.inputRef),Ge=y?void 0:te,Ke=Z.useMemo(()=>!y||!Array.isArray(z)||!te?null:z.map(e=>{let t=Ty(e,x);return(0,Q.jsx)(`input`,{type:`hidden`,form:l,name:te,value:t,disabled:L},t)}),[y,z,l,te,x,L]);return(0,Q.jsxs)(ry.Provider,{value:be,children:[(0,Q.jsx)(iy.Provider,{value:He,children:(0,Q.jsx)(ay.Provider,{value:Pe,children:T})}),(0,Q.jsx)(`input`,{...P.getValidationProps(L,{onFocus(){be.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||L||f)return;let t=e.currentTarget.value,n=On(si,e.nativeEvent);function r(){if(y)return;let e=t.toLowerCase(),r=le.current.findIndex(t=>Ty(t,x).toLowerCase()===e||wy(t,b).toLowerCase()===e);r===-1&&(r=le.current.findIndex((t,n)=>{let r=V.current[n];return r!=null&&r.toLowerCase()===e}));let i=le.current[r];i!=null&&Me(i,n)}be.set(`forceMount`,!0),queueMicrotask(r)}}),id:I&&Ge==null?`${I}-hidden-input`:void 0,form:l,name:Ge,autoComplete:u,value:De,disabled:L,required:p&&!(y&&ke),readOnly:f,ref:Ue,style:te?Ot:R,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Ke]})}function Fy(e,t){return e??t}var Iy=5;function Ly(e,t){let n=Ry(t);return e.clientX>=n.left-Iy&&e.clientX<=n.right+Iy&&e.clientY>=n.top-Iy&&e.clientY<=n.bottom+Iy}function Ry(e){let t=e.getBoundingClientRect(),n=h(e);if(jo)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}var zy=`data-popup-side`,By=400,Vy={...Lc,...xv,popupSide:e=>e?{[zy]:e}:null,value:()=>null},Hy=Z.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,setFocused:u,validationMode:d,validation:f,state:p,disabled:m}=wv(),{labelId:h}=Ov(),g=oy(),{readOnly:_,required:v,disabled:y}=sy(),b=m||y||a,x=g.useState(`open`),S=g.useState(`mounted`),C=g.useState(`value`),w=g.useState(`triggerProps`),T=g.useState(`positionerElement`),E=g.useState(`listElement`),D=g.useState(`popupSide`),ee=g.useState(`id`),O=g.useState(`labelId`),k=g.useState(`hasSelectedValue`),j=S&&T?D:null,M=i??ee,N=Fy(h,O);Mv({id:i});let P=Sl(T),F=Z.useRef(null),{getButtonProps:I,buttonRef:L}=fo({disabled:b,native:o}),R=g.useStateSetter(`triggerElement`),te=Ei(),z=Ei(),B=Ei();Z.useEffect(()=>{if(x)return B.start(By,()=>{g.context.selectionRef.current.allowUnselectedMouseUp=!0,g.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{B.clear()};g.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},z.clear()},[x,g,z,B]);let ne=A(w,{id:M,role:`combobox`,"aria-expanded":x,"aria-haspopup":`listbox`,"aria-controls":x?E?.id??Tn(T)?.id:void 0,"aria-labelledby":N,"aria-readonly":_||void 0,"aria-required":v||void 0,tabIndex:b?-1:0,onFocus(e){u(!0),x&&g.context.alignItemWithTriggerActiveRef.current&&g.context.setOpen(!1,On(si,e.nativeEvent)),te.start(0,()=>{g.set(`forceMount`,!0)})},onBlur(e){K(T,e.relatedTarget)||(l(!0),u(!1),d===`onBlur`&&f.commit(C))},onMouseDown(e){if(x)return;let t=zr(e.currentTarget);function n(e){if(!F.current)return;let t=e.target;K(F.current,t)||K(P.current,t)||Ly(e,F.current)||g.context.setOpen(!1,On(Gn,e))}z.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,I),re=f.getValidationProps(b,ne);re.role=`combobox`;let ie={...p,open:x,disabled:b,value:C,readOnly:_,popupSide:j,placeholder:!k};return sn(`button`,e,{ref:[t,F,L,R],state:ie,stateAttributesMapping:Vy,props:re})}),Uy={value:()=>null},Wy=Z.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=oy(),l=c.useState(`value`),u=c.useState(`items`),d=c.useState(`itemToStringLabel`),f=c.useState(`hasSelectedValue`),p=!f&&a!=null&&i==null,m=c.useState(`hasNullItemLabel`,p),h={value:l,placeholder:!f},g=null;return g=typeof i==`function`?i(l):i??(p&&!m?a:Array.isArray(l)?Dy(l,u,d):Ey(l,u,d)),sn(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:Uy})}),Gy=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o={open:oy().useState(`open`)};return sn(`span`,e,{state:o,ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:Ic})}),Ky=Z.forwardRef(function(e,t){let n=oy(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,Q.jsx)(bs,{ref:t,...e}):null}),qy=Z.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Jy(){return Z.useContext(qy)}function Yy(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=G(i),[,o]=Z.useState(!1),s=$e(Zy).current,c=$e(Xy).current,l=Z.useRef(0),u=Z.useRef(!0),d=Z.useRef(null),f=Z.useRef(null),p=G(()=>{u.current||(u.current=!0,o(e=>!e))}),m=G((e,t)=>{c.set(e,t),p()}),h=G(e=>{c.delete(e),p()}),g=G(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!eb(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&tb(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=$y(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=G(()=>{let[e,t]=Qy(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});U(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),U(()=>{u.current&&v()}),U(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=G(e=>(s.add(e),()=>{s.delete(e)})),b=Z.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,Q.jsx)(qy.Provider,{value:b,children:t})}function Xy(){return new Map}function Zy(){return new Set}function Qy(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>tb(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function $y(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function eb(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function tb(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var nb=Z.createContext(void 0);function rb(){let e=Z.useContext(nb);if(!e)throw Error(Un(59));return e}var ib=Z.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,Q.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});function ab(e,t){e&&Object.assign(e.style,t)}var ob={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},sb={},cb={},lb=``;function ub(e,t){return he(e)?e:t}function db(e,t,n){return/hidden|clip/.test(e.getComputedStyle(ub(t,n)).overflowY)}function fb(e){if(typeof document>`u`)return!1;let t=zr(e);return h(t).innerWidth-t.documentElement.clientWidth>0}function pb(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=zr(e),n=t.documentElement,r=t.body,i=ub(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function mb(e){let t=zr(e),n=t.documentElement,r=t.body,i=ub(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function hb(e){let t=zr(e),n=t.documentElement,r=t.body,i=h(n),a=0,o=0,s=!1,c=br.create();if(ti&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,sb={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},lb=n.style.scrollBehavior,cb={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=ub(n,r);if(s=pb(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,sb),Object.assign(r.style,cb),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=lb)}function d(){u(),c.request(l)}l();let f=us(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var gb=new class{lockCount=0;restore=null;timeoutLock=Ii.create();timeoutUnlock=Ii.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=zr(e),n=t.documentElement,r=t.body,i=h(n);if(db(i,n,r)){let t=new i.MutationObserver(()=>{db(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=Wa||!fb(e);this.restore=a?mb(e):hb(e)}};function _b(e=!0,t=null){U(()=>{if(e)return gb.acquire(t)},[e,t])}var vb=20;function yb(e,t,n,r){let[i,a]=Z.useState(!1);U(()=>{if(!e||!t||n==null){a(!1);return}let r=zr(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-vb)},[e,t,n]),_b(e&&(!t||i),r)}var bb={position:`fixed`},xb=Z.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=Pi,style:_,...v}=e,y=oy(),b=cy(),x=y.useState(`open`),S=y.useState(`mounted`),C=y.useState(`modal`),w=y.useState(`value`),T=y.useState(`openMethod`),E=y.useState(`positionerElement`),D=y.useState(`triggerElement`),ee=y.useState(`isItemEqualToValue`),O=y.useState(`transitionStatus`),k=Z.useRef(null),A=Z.useRef(null),[j,M]=Z.useState(h),N=S&&j&&T!==`touch`;!S&&j!==h&&M(h),Z.useImperativeHandle(y.context.alignItemWithTriggerActiveRef,()=>N),yb((N||C)&&x,T===`touch`,E,D);let P=ef({anchor:n,floatingRootContext:b,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??N,collisionAvoidance:g,keepMounted:!0}),F=N?`none`:P.side,I=N?bb:P.positionerStyles,L={open:x,side:F,align:P.align,anchorHidden:P.anchorHidden};U(()=>{y.set(`popupSide`,P.side)},[y,P.side]);let R=af(e,L,{styles:I,transitionStatus:O,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!S,inert:!x}),te=Z.useRef(0),z=G(e=>{if(y.context.valuesRef.current.length===0)return;let t=te.current;te.current=e.size;let n=On(si);if(t!==0&&!y.state.multiple&&w!==null&&my(y.context.valuesRef.current,w,ee)===-1){let e=y.context.initialValueRef.current,t=e!=null&&my(y.context.valuesRef.current,e,ee)!==-1?e:null;y.context.setValue(t,n),t===null&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null)}if(t!==0&&y.state.multiple&&Array.isArray(w)){let e=w.filter(e=>my(y.context.valuesRef.current,e,ee)!==-1);e.length!==w.length&&(y.context.setValue(e,n),e.length===0&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null))}if(x&&N){y.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};ab(E,e),ab(y.context.popupRef.current,e)}}),B=Z.useMemo(()=>({...P,side:F,alignItemWithTriggerActive:N,setControlledAlignItemWithTrigger:M,scrollUpArrowRef:k,scrollDownArrowRef:A}),[P,F,N,M]);return(0,Q.jsx)(Yy,{elementsRef:y.context.listRef,labelsRef:y.context.labelsRef,onMapChange:z,children:(0,Q.jsxs)(nb.Provider,{value:B,children:[S&&C&&(0,Q.jsx)(ib,{inert:ts(!x),cutout:D}),R]})})}),Sb=`base-ui-disable-scrollbar`,Cb={className:Sb,getElement(e){return(0,Q.jsx)(`style`,{nonce:e,href:Sb,precedence:`base-ui:low`,children:`.${Sb}{scrollbar-width:none}.${Sb}::-webkit-scrollbar{display:none}`})}},wb=Z.createContext(void 0);function Tb(e){let t=Z.useContext(wb);if(t===void 0&&!e)throw Error(Un(69));return t}var Eb=`ArrowUp`,Db=`ArrowDown`,Ob=`ArrowLeft`,kb=`ArrowRight`,Ab=`Home`,jb=new Set([Eb,Db,Ob,kb,Ab,`End`]),Mb=[`Shift`,`Control`,`Alt`,`Meta`];function Nb(e){return bt(e)&&e.tagName===`INPUT`}function Pb(e){return!!(Nb(e)&&e.selectionStart!=null||bt(e)&&e.tagName===`TEXTAREA`)}function Fb(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=Ib(e,t,`left`),a=Lb(e),o=Lb(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=Ib(e,t,`top`),r=Lb(e),i=Lb(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function Ib(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function Lb(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}var Rb=Z.createContext(void 0),zb={disableStyleElements:!1};function Bb(){return Z.useContext(Rb)??zb}var Vb=`--transform-origin`,Hb={...Rc,...a},Ub=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=oy(),{multiple:c,readOnly:l,highlightItemOnHover:u}=sy(),d=cy(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:g,setControlledAlignItemWithTrigger:_}=rb(),v=Tb(!0)!=null,y=Bd(),{nonce:b,disableStyleElements:x}=Bb(),S=s.useState(`id`),C=s.useState(`open`),w=s.useState(`openMethod`),T=s.useState(`mounted`),E=s.useState(`popupProps`),D=s.useState(`transitionStatus`),ee=s.useState(`triggerElement`),O=s.useState(`positionerElement`),k=s.useState(`listElement`),A=Z.useRef(!1),j=Z.useRef(!1),M=Z.useRef({}),N=Bo(),P=G(e=>{if(!O||!s.context.popupRef.current||!j.current)return;let t=O.style.top===`0px`,n=O.style.bottom===`0px`;if(A.current||!m||!t&&!n){s.context.handleScrollArrowVisibility(e);return}let r=Kb(O),i=qb(O.getBoundingClientRect().height,`y`,r),a=zr(O),o=h(O),c=o.getComputedStyle(O),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=Wb(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,g=Gb(e),_=null,v=e=>{O.style.height=`${e}px`},y=t?g-p:p,b=Math.min(i+y,f);if(y<=1){let n=xl(y,0,f-i);n>0&&v(i+n),e.scrollTop=t?g:0,f-(i+n)<=1&&(A.current=!0),s.context.handleScrollArrowVisibility(e);return}f-b>1?_=t?1/0:0:n&&p<g&&(_=p-(y-(i+y-f)));let x=Math.ceil(b);if(x!==0&&v(x),_!=null){let t=xl(_,0,Gb(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}x>=f-1&&(A.current=!0),s.context.handleScrollArrowVisibility(e)});Z.useImperativeHandle(s.context.scrollHandlerRef,()=>P,[P]),zo({open:C,ref:s.context.popupRef,onComplete(){C&&s.context.onOpenChangeComplete(!0)}});let F={open:C,transitionStatus:D,side:f,align:p};U(()=>{O&&s.context.popupRef.current&&!Object.keys(M.current).length&&(M.current={top:O.style.top||`0`,left:O.style.left||`0`,right:O.style.right,height:O.style.height,bottom:O.style.bottom,minHeight:O.style.minHeight,maxHeight:O.style.maxHeight,marginTop:O.style.marginTop,marginBottom:O.style.marginBottom})},[s,O]),U(()=>{C||m||(j.current=!1,A.current=!1,ab(O,M.current))},[C,m,O]),U(()=>{let e=s.context.popupRef.current;if(!C||!ee||!O||!e||m&&!g||s.state.transitionStatus===`ending`)return;if(j.current=!0,e.style.removeProperty(Vb),!m){N.request(()=>s.context.handleScrollArrowVisibility(k||e));return}let t=Xb(e);try{let t=s.context.selectedItemTextRef.current;t?.isConnected||(t=!s.select(`hasSelectedValue`)&&s.context.firstItemTextRef.current?.isConnected?s.context.firstItemTextRef.current:null);let n=s.context.valueRef.current,r=h(O),i=r.getComputedStyle(O),a=r.getComputedStyle(e),o=zr(ee),c=Kb(ee),l=Jb(ee.getBoundingClientRect(),c),d=Jb(O.getBoundingClientRect(),c),f=l.height,p=k||e,m=p.scrollHeight,g=parseFloat(a.borderBottomWidth),v=parseFloat(i.marginTop)||10,b=parseFloat(i.marginBottom)||10,x=parseFloat(i.minHeight)||100,S=Wb(a),C=o.documentElement.clientHeight-v-b,w=o.documentElement.clientWidth,T=C-l.bottom+f,E,D=y===`rtl`?l.right-d.width:l.left,j=0;if(t&&n){let e=Jb(n.getBoundingClientRect(),c);E=Jb(t.getBoundingClientRect(),c),D=d.left+(y===`rtl`?e.right-E.right:e.left-E.left);let r=e.top-l.top+e.height/2;j=E.top-d.top+E.height/2-r}let N=T+j+b+g,P=Math.min(C,N),F=C-v-b,I=N-P,L=w-5;O.style.left=`${xl(D,5,L-d.width)}px`,O.style.height=`${P}px`,O.style.maxHeight=`none`,O.style.marginTop=`${v}px`,O.style.marginBottom=`${b}px`,e.style.height=`100%`;let R=Gb(p),te=I>=R-1;te&&(P=Math.min(C,d.height)-(I-R));let z=l.top<20||l.bottom>C-20||Math.ceil(P)+1<Math.min(m,x),B=(r.visualViewport?.scale??1)!==1&&ti;if(z||B){ab(O,M.current),_(!1);return}let ne=Math.max(x,P);if(te){let e=Math.max(0,C-N);O.style.top=d.height>=F?`0`:`${e}px`,O.style.height=`${P}px`,p.scrollTop=Gb(p)}else O.style.bottom=`0`,p.scrollTop=I;if(E){let t=d.top,n=d.height,r=E.top+E.height/2,i=xl(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(Vb,`50% ${i}%`)}(ne===C||P>=S)&&(A.current=!0),s.context.handleScrollArrowVisibility(p),u&&s.state.selectedIndex===null&&s.state.activeIndex===null&&s.context.listRef.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,C,O,ee,m,_,N,k,u,y,g]),Z.useEffect(()=>{if(!m||!O||!C)return;let e=h(O);function t(e){s.context.setOpen(!1,On(Fa,e))}return us(e,`resize`,t)},[s,m,O,C]);let I={...k?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":c||void 0,"aria-readonly":l||void 0,id:`${S}-list`},onKeyDown(e){v&&jb.has(e.key)&&e.stopPropagation()},onScroll(e){k||P(e.currentTarget)},...m&&{style:k?{height:`100%`}:ob},className:!k&&m?Cb.className:void 0},L=sn(`div`,e,{ref:[t,s.context.popupRef],state:F,stateAttributesMapping:Hb,props:[E,I,rf(D),o]});return(0,Q.jsxs)(Z.Fragment,{children:[!x&&Cb.getElement(b),(0,Q.jsx)(tu,{context:d,modal:!1,disabled:!T,openInteractionType:w,returnFocus:a,restoreFocus:!0,children:L})]})});function Wb(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function Gb(e){return My(e.scrollHeight,e.clientHeight)}function Kb(e){return Hu.getScale(e)}function qb(e,t,n){return e/n[t]}function Jb(e,t){return bl({x:qb(e.x,`x`,t),y:qb(e.y,`y`,t),width:qb(e.width,`x`,t),height:qb(e.height,`y`,t)})}var Yb=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function Xb(e){let{style:t}=e,n={};for(let[e,r]of Yb)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of Yb){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var Zb=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=oy(),{multiple:s,readOnly:c}=sy(),{alignItemWithTriggerActive:l}=rb(),u=o.useState(`hasScrollArrows`),d=o.useState(`openMethod`),f={id:`${o.useState(`id`)}-list`,role:`listbox`,"aria-multiselectable":s||void 0,"aria-readonly":c||void 0,onScroll(e){o.context.scrollHandlerRef.current?.(e.currentTarget)},...l&&{style:ob},className:u&&d!==`touch`?Cb.className:void 0},p=o.useStateSetter(`listElement`);return sn(`div`,e,{ref:[t,p],props:[f,a]})});function Qb(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=Jy(),u=Z.useRef(-1),[d,f]=Z.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=Z.useRef(null),h=Z.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return U(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}var $b=Z.createContext(void 0);function ex(){let e=Z.useContext($b);if(!e)throw Error(Un(57));return e}var tx=Z.memo(Z.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=Z.useRef(null),d=Qb({guess:!0,label:o,textRef:u}),f=oy(),{itemProps:p,multiple:m,disabled:h,readOnly:g}=sy(),_=h||s,v=f.useState(`isActive`,d.index),y=f.useState(`open`),b=f.useState(`isSelected`,a),x=f.useState(`isSelectedByFocus`,d.index),S=f.useState(`isItemEqualToValue`),C=d.index,w=Z.useRef(null);U(()=>{let e=f.context.valuesRef.current;return e[C]=a,()=>{delete e[C]}},[C,a,f]),U(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=_y(C,a,f.context.valuesRef.current,e,S,t),r=n===C,C===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&dy(a,e,S),r&&(n=C)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[C,m,S,f,a]);let T=Z.useRef(`mouse`),E=Z.useRef(!1),{getButtonProps:D,buttonRef:ee}=fo({disabled:_,focusableWhenDisabled:!0,native:c,composite:!0}),O={disabled:_,selected:b,highlighted:v};function k(e){if(h||g)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=b?vy(n,a,S):[...n,a];f.context.setValue(r,On(mr,e))}else f.context.setValue(a,On(mr,e)),f.context.setOpen(!1,On(mr,e))}function A(){f.context.selectionRef.current.dragY=0}let j={role:`option`,"aria-selected":b,tabIndex:y&&v?0:-1,onKeyDown(e){f.set(`activeIndex`,C),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=T.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&Wc(e.nativeEvent)&&(n!==void 0||v),i=t&&!r&&!E.current;E.current=!1,!(_||i)&&k(e.nativeEvent)},onPointerEnter(e){T.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){T.current=e.pointerType,E.current=!0,A()},onMouseUp(){if(A(),_||T.current===`touch`||E.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&b,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!b;e||t||(E.current=!0,w.current?.click(),E.current=!1)}},M=sn(`div`,e,{ref:[ee,t,d.ref,w],state:O,props:[p,j,l,D]}),N=Z.useMemo(()=>({selected:b,index:C,textRef:u,selectedByFocus:x}),[b,C,u,x]);return(0,Q.jsx)($b.Provider,{value:N,children:M})})),nx=Z.forwardRef(function(e,t){let{selected:n}=ex();return e.keepMounted||n?(0,Q.jsx)(rx,{...e,ref:t}):null}),rx=Z.memo(Z.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:o,...s}=e,{selected:c}=ex(),l=Z.useRef(null),{transitionStatus:u,setMounted:d}=fd(c),f=sn(`span`,e,{ref:[t,l],state:{selected:c,transitionStatus:u},props:[{"aria-hidden":!0,children:`✔️`},s],stateAttributesMapping:a});return zo({batch:!0,enabled:!c,open:c,ref:l,onComplete(){c||d(!1)}}),f})),ix=Z.memo(Z.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=ex(),a=oy(),{render:o,className:s,style:c,...l}=e,u=Z.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]);return sn(`div`,e,{ref:[u,t,r],props:l})})),ax=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,direction:o,keepMounted:s,...c}=e,l=o===`up`,u=oy(),{side:d,scrollDownArrowRef:f,scrollUpArrowRef:p}=rb(),m=l?`scrollUpArrowVisible`:`scrollDownArrowVisible`,h=u.useState(m),g=u.useState(`openMethod`),_=h&&g!==`touch`,v=Ei(),y=l?p:f,{mounted:b,transitionStatus:x,setMounted:S}=fd(_);U(()=>(u.context.scrollArrowsMountedCountRef.current+=1,u.set(`hasScrollArrows`,!0),()=>{u.context.scrollArrowsMountedCountRef.current=Math.max(0,u.context.scrollArrowsMountedCountRef.current-1),u.context.scrollArrowsMountedCountRef.current===0&&u.set(`hasScrollArrows`,!1)}),[u]),zo({open:_,ref:y,onComplete(){_||S(!1)}});let C=sn(`div`,e,{ref:[t,y],state:{direction:o,visible:_,side:d,transitionStatus:x},props:[{"aria-hidden":!0,children:l?`▲`:`▼`,style:{position:`absolute`},onMouseMove(e){if(e.movementX===0&&e.movementY===0||v.isStarted())return;u.set(`activeIndex`,null);function t(){let e=u.state.listElement??u.context.popupRef.current;if(!e)return;u.set(`activeIndex`,null),u.context.handleScrollArrowVisibility(e);let n=My(e.scrollHeight,e.clientHeight),r=Ny(e.scrollTop,n),i=r===(l?0:n),a=u.context.listRef.current;if(r!==e.scrollTop&&(e.scrollTop=r),i){v.clear();return}if(a.length>0){let t=y.current?.offsetHeight||0;e.scrollTop=ox(a,l,r,e.clientHeight,t,n)}v.start(40,t)}v.start(40,t)},onMouseLeave(){v.clear()}},c],stateAttributesMapping:a});return b||s?C:null});function ox(e,t,n,r,i,a){if(t){let t=0,r=n+i-1;for(let n=0;n<e.length;n+=1){let i=e[n];if(i&&i.offsetTop>=r){t=n;break}}let o=Math.max(0,t-1),s=e[o];return o<t&&s?Ny(s.offsetTop-i,a):0}let o=e.length-1,s=n+r-i+1;for(let t=0;t<e.length;t+=1){let n=e[t];if(n&&n.offsetTop+n.offsetHeight>s){o=Math.max(0,t-1);break}}let c=Math.min(e.length-1,o+1),l=e[c];return c>o&&l?Ny(l.offsetTop+l.offsetHeight-r+i,a):a}var sx=Z.forwardRef(function(e,t){return(0,Q.jsx)(ax,{...e,ref:t,direction:`down`})}),cx=Z.forwardRef(function(e,t){return(0,Q.jsx)(ax,{...e,ref:t,direction:`up`})}),lx=Z.createContext(void 0);function ux(){let e=Z.useContext(lx);if(e===void 0)throw Error(Un(56));return e}var dx=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=Z.useState(),c=Z.useMemo(()=>({labelId:o,setLabelId:s}),[o,s]),l=sn(`div`,e,{ref:t,props:[{role:`group`,"aria-labelledby":o},a]});return(0,Q.jsx)(lx.Provider,{value:c,children:l})}),fx=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{setLabelId:s}=ux(),c=Of(a);return U(()=>(s(c),()=>{s(e=>e===c?void 0:e)}),[c,s]),sn(`div`,e,{ref:t,props:[{id:c,"aria-hidden":!0},o]})}),px=Py;function mx({className:e,...t}){return(0,Q.jsx)(dx,{"data-slot":`select-group`,className:W(`scroll-my-1.5 p-1`,e),...t})}function hx({className:e,...t}){return(0,Q.jsx)(Wy,{"data-slot":`select-value`,className:W(`flex flex-1 text-left`,e),...t})}function gx({className:e,size:t=`default`,children:n,...r}){return(0,Q.jsxs)(Hy,{"data-slot":`select-trigger`,"data-size":t,className:W(`flex w-fit items-center justify-between gap-1.5 rounded-2xl border border-transparent bg-input/50 px-3 py-2 text-sm whitespace-nowrap transition-[color,box-shadow] duration-200 outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,Q.jsx)(Gy,{render:(0,Q.jsx)(sf,{className:`pointer-events-none size-4 text-muted-foreground`})})]})}function _x({className:e,children:t,side:n=`bottom`,sideOffset:r=4,align:i=`center`,alignOffset:a=0,alignItemWithTrigger:o=!0,...s}){return(0,Q.jsx)(Ky,{children:(0,Q.jsx)(xb,{side:n,sideOffset:r,align:i,alignOffset:a,alignItemWithTrigger:o,className:`isolate z-50`,children:(0,Q.jsxs)(Ub,{"data-slot":`select-content`,"data-align-trigger":o,className:W(`isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-2xl text-popover-foreground shadow-lg ring-1 ring-foreground/5 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 dark:ring-foreground/10 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 animate-none! relative bg-popover/70 before:pointer-events-none before:absolute before:inset-0 before:-z-1 before:rounded-[inherit] before:backdrop-blur-2xl before:backdrop-saturate-150 **:data-[slot$=-item]:focus:bg-foreground/10 **:data-[slot$=-item]:data-highlighted:bg-foreground/10 **:data-[slot$=-separator]:bg-foreground/5 **:data-[slot$=-trigger]:focus:bg-foreground/10 **:data-[slot$=-trigger]:aria-expanded:bg-foreground/10! **:data-[variant=destructive]:focus:bg-foreground/10! **:data-[variant=destructive]:text-accent-foreground! **:data-[variant=destructive]:**:text-accent-foreground!`,e),...s,children:[(0,Q.jsx)(bx,{}),(0,Q.jsx)(Zb,{children:t}),(0,Q.jsx)(xx,{})]})})})}function vx({className:e,...t}){return(0,Q.jsx)(fx,{"data-slot":`select-label`,className:W(`px-2 py-1 text-xs text-muted-foreground`,e),...t})}function yx({className:e,children:t,...n}){return(0,Q.jsxs)(tx,{"data-slot":`select-item`,className:W(`relative flex min-h-7 w-full cursor-default items-center gap-2 rounded-xl py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,Q.jsx)(ix,{className:`flex flex-1 shrink-0 gap-2 whitespace-nowrap`,children:t}),(0,Q.jsx)(nx,{render:(0,Q.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`}),children:(0,Q.jsx)(Vt,{className:`pointer-events-none`})})]})}function bx({className:e,...t}){return(0,Q.jsx)(cx,{"data-slot":`select-scroll-up-button`,className:W(`top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,Q.jsx)(lf,{})})}function xx({className:e,...t}){return(0,Q.jsx)(sx,{"data-slot":`select-scroll-down-button`,className:W(`bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,Q.jsx)(sf,{})})}var Sx=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(Sx||{}),Cx=[0,1],wx=[1,0],Tx=[2,3],Ex=[3,2],Dx={L:Cx,M:wx,Q:Tx,H:Ex},Ox=/^\d*$/,kx=/^[A-Z0-9 $%*+./:-]*$/,Ax=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,jx=1,Mx=40,Nx=3,Px=3,Fx=40,Ix=10,Lx=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],Rx=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],zx=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<jx||e>Mx)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size}).fill(!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,Sx.Timing),this.setFunctionModule(e,6,e%2==0,Sx.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,Vx(r,e));this.setFunctionModule(8,7,Vx(r,6)),this.setFunctionModule(8,8,Vx(r,7)),this.setFunctionModule(7,8,Vx(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,Vx(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,Vx(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,Vx(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=Vx(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,Sx.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,Sx.Alignment)}setFunctionModule(e,t,n,r=Sx.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==nS(t,n))throw RangeError(`Invalid argument`);let r=Rx[n[0]][t],i=Lx[n[0]][t],a=Math.floor(tS(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=rS(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=iS(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(tS(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=Vx(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=Nx:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Fx),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Fx}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=Nx:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*Fx),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*Fx}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=Px)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*Ix,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function Bx(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function Vx(e,t){return!!(e>>>t&1)}var Hx=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},Ux=[1,10,12,14],Wx=[2,9,11,13],Gx=[4,8,16,16];function Kx(e,t){return e[Math.floor((t+7)/17)+1]}function qx(e){let t=[];for(let n of e)Bx(n,8,t);return new Hx(Gx,e.length,t)}function Jx(e){if(!Zx(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);Bx(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new Hx(Ux,e.length,t)}function Yx(e){if(!Qx(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=Ax.indexOf(e.charAt(n))*45;r+=Ax.indexOf(e.charAt(n+1)),Bx(r,11,t)}return n<e.length&&Bx(Ax.indexOf(e.charAt(n)),6,t),new Hx(Wx,e.length,t)}function Xx(e){return e===``?[]:Zx(e)?[Jx(e)]:Qx(e)?[Yx(e)]:[qx(eS(e))]}function Zx(e){return Ox.test(e)}function Qx(e){return kx.test(e)}function $x(e,t){let n=0;for(let r of e){let e=Kx(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function eS(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function tS(e){if(e<jx||e>Mx)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function nS(e,t){return Math.floor(tS(e)/8)-Lx[t[0]][e]*Rx[t[0]][e]}function rS(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=aS(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=aS(n,2)}return t}function iS(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=aS(t,e))}return n}function aS(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function oS(e,t,n=1,r=40,i=-1,a=!0){if(!(jx<=n&&n<=r&&r<=Mx)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=nS(o,t)*8,i=$x(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[wx,Tx,Ex])a&&s<=nS(o,e)*8&&(t=e);let c=[];for(let t of e){Bx(t.mode[0],4,c),Bx(t.numChars,Kx(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=nS(o,t)*8;Bx(0,Math.min(4,l-c.length),c),Bx(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)Bx(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new zx(o,t,u,i)}function sS(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?Xx(e):Array.isArray(e)?[qx(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=oS(c,Dx[n],i,a,o,r),u=cS({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function cS(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=Sx.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}function lS(e){let t=(0,$.c)(8),{link:n}=e,r,i;if(t[0]!==n){let{size:e,data:a}=sS(n,{ecc:`M`,border:2});r=e,i=a.flatMap(uS).join(``),t[0]=n,t[1]=r,t[2]=i}else r=t[1],i=t[2];let a=i,o=`0 0 ${r} ${r}`,s;t[3]===a?s=t[4]:(s=(0,Q.jsx)(`path`,{d:a,fill:`currentColor`}),t[3]=a,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,Q.jsx)(`svg`,{role:`img`,"aria-label":`Pairing QR code`,viewBox:o,shapeRendering:`crispEdges`,className:`size-40 shrink-0 rounded-md bg-white text-black`,children:s}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function uS(e,t){return e.flatMap((e,n)=>e?[`M${n} ${t}h1v1h-1z`]:[])}function dS(e){let t=(0,$.c)(38),{connection:n,remote:r}=e,i=am(r),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,f]=D_(n),p;t[0]===d?p=t[1]:(p=qe(d)?d.value:null,t[0]=d,t[1]=p);let m=p,h=i.find(e=>{let{url:t}=e;return t===s})??i[0];if(h===void 0){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Turn on a way in under Ways in to pair a phone or another computer.`}),t[2]=e):e=t[2],e}let g=e=>Bv(e,async()=>f({label:a.trim(),addresses:[h.url],trusted:l})),_;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(U_,{htmlFor:`pairing-label`,children:`Device name`}),t[3]=_):_=t[3];let v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>o(e.target.value),t[4]=v):v=t[4];let y;t[5]===a?y=t[6]:(y=(0,Q.jsxs)(J_,{className:`min-w-0 flex-1`,children:[_,(0,Q.jsx)(Rv,{id:`pairing-label`,placeholder:`My phone`,maxLength:Se,value:a,onChange:v})]}),t[5]=a,t[6]=y);let b=i.length>1&&(0,Q.jsxs)(J_,{className:`min-w-0 sm:w-56`,children:[(0,Q.jsx)(U_,{htmlFor:`pairing-address`,children:`Opens through`}),(0,Q.jsxs)(px,{items:i.map(pS),value:h.url,onValueChange:e=>{e&&c(e)},children:[(0,Q.jsx)(gx,{id:`pairing-address`,className:`w-full`,children:(0,Q.jsx)(hx,{})}),(0,Q.jsx)(_x,{children:i.map(fS)})]})]}),x;t[7]!==d.waiting||t[8]!==a?(x=d.waiting||a.trim()===``,t[7]=d.waiting,t[8]=a,t[9]=x):x=t[9];let S;t[10]===d.waiting?S=t[11]:(S=d.waiting?(0,Q.jsx)(y_,{}):(0,Q.jsx)(hf,{}),t[10]=d.waiting,t[11]=S);let C;t[12]!==x||t[13]!==S?(C=(0,Q.jsxs)(Le,{type:`submit`,className:`shrink-0`,disabled:x,children:[S,`Create pairing link`]}),t[12]=x,t[13]=S,t[14]=C):C=t[14];let w;t[15]!==C||t[16]!==g||t[17]!==y||t[18]!==b?(w=(0,Q.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:g,children:[y,b,C]}),t[15]=C,t[16]=g,t[17]=y,t[18]=b,t[19]=w):w=t[19];let T;t[20]!==u||t[21]!==l?(T=(0,Q.jsx)(ey,{id:`pairing-trusted`,checked:l,onCheckedChange:u}),t[20]=u,t[21]=l,t[22]=T):T=t[22];let E;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Q.jsx)(U_,{htmlFor:`pairing-trusted`,children:`The paired device can update Porcelain`}),t[23]=E):E=t[23];let D;t[24]===T?D=t[25]:(D=(0,Q.jsxs)(J_,{orientation:`horizontal`,children:[T,E]}),t[24]=T,t[25]=D);let ee=em[h.route],O;t[26]===ee?O=t[27]:(O=(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`The link opens through `,ee,`. The device will work only through the way in it pairs over. To use it through another way in too, pair it again through that one.`]}),t[26]=ee,t[27]=O);let k;t[28]===d?k=t[29]:(k=Ln(d)&&(0,Q.jsx)(g_,{variant:`destructive`,children:(0,Q.jsx)(v_,{children:Am(hi(d.cause))})}),t[28]=d,t[29]=k);let A;t[30]===m?A=t[31]:(A=m&&(0,Q.jsxs)(tv,{variant:`muted`,children:[(0,Q.jsx)(rv,{children:(0,Q.jsx)(lS,{link:m.link})}),(0,Q.jsxs)(iv,{children:[(0,Q.jsxs)(av,{children:[`Scan on `,m.label]}),(0,Q.jsx)(`p`,{"aria-label":`Pairing link`,className:`font-mono text-xs break-all text-muted-foreground`,children:m.link}),(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Works once, until`,` `,new Date(m.expiresAt).toLocaleTimeString(),`.`]}),(0,Q.jsxs)(Le,{variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>ta(m?.link??``,`pairing link`),children:[(0,Q.jsx)(df,{}),`Copy link`]})]})]}),t[30]=m,t[31]=A);let j;return t[32]!==w||t[33]!==D||t[34]!==O||t[35]!==k||t[36]!==A?(j=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[w,D,O,k,A]}),t[32]=w,t[33]=D,t[34]=O,t[35]=k,t[36]=A,t[37]=j):j=t[37],j}function fS(e){let{route:t,url:n}=e;return(0,Q.jsx)(yx,{value:n,children:`${em[t]} · ${n}`},n)}function pS(e){let{route:t,url:n}=e;return{value:n,label:`${em[t]} · ${n}`}}var mS=new Intl.RelativeTimeFormat(`en`,{numeric:`always`});function hS(e,t=dr()){let n=rr(e),r=Ue(n,t),[i,a]=r?[t,n]:[n,t],s=Qe(i,a),c=Ne(s),l=o(),u=(c+ui(qt(a,l))-ui(qt(i,l)))/Ne(L(1)),d,f;return c<Ne(It(1))?(d=`second`,f=Math.round(Qt(s))):c<Ne(aa(1))?(d=`minute`,f=Math.round(it(s))):c<Ne(L(1))?(d=`hour`,f=Math.round(fe(s))):u<30?(d=`day`,f=Math.round(u)):u<365?(f=Math.round(u/30),d=f===12?`year`:`month`,d===`year`&&(f=1)):(d=`year`,f=Math.round(u/365)),mS.format(r?f:-f,d)}var gS=ct(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-2xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function _S({className:e,variant:t=`default`,render:n,...r}){return Q_({defaultTagName:`span`,props:A({className:W(gS({variant:t}),e)},r),render:n,state:{slot:`badge`,variant:t}})}function vS(e){let t=(0,$.c)(28),{connection:n}=e,r=N_(n),i,a,o,s,c,l,u;if(t[0]!==r||t[1]!==n){u=Symbol.for(`react.early_return_sentinel`);bb0:{let e=ja(Kn(r));if(Ln(r)){let e;t[9]===r.cause?e=t[10]:(e=Am(hi(r.cause)),t[9]=r.cause,t[10]=e);let n;t[11]===e?n=t[12]:(n=(0,Q.jsx)(g_,{variant:`destructive`,children:(0,Q.jsx)(v_,{children:e})}),t[11]=e,t[12]=n),u=n;break bb0}if(!e){let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(y_,{}),t[13]=e):e=t[13],u=e;break bb0}l=`flex flex-col gap-2`,i=$_,a=`list`,o=`Paired devices and links`;let d;t[14]===n?d=t[15]:(d=e=>(0,Q.jsxs)(tv,{variant:`outline`,size:`sm`,role:`listitem`,"aria-label":e.label,children:[(0,Q.jsxs)(iv,{className:`min-w-0`,children:[(0,Q.jsxs)(av,{children:[e.label,e.current&&(0,Q.jsx)(_S,{variant:`secondary`,children:`This browser`}),(0,Q.jsx)(_S,{variant:`outline`,children:tm[e.route]})]}),(0,Q.jsxs)(ov,{children:[`Last seen `,hS(e.lastSeenAt),` · `,e.platform]}),e.routeInferred&&(0,Q.jsxs)(ov,{children:[`Paired before each device was tied to one way in, so it now works only through `,tm[e.route],`, where it was last seen. Pair it again to use another way in.`]})]}),(0,Q.jsxs)(sv,{children:[(0,Q.jsx)(yS,{connection:n,id:e.id,label:e.label,trusted:e.trusted}),!e.current&&(0,Q.jsx)(bS,{connection:n,id:e.id,label:e.label,cancelLink:!1})]})]},e.id),t[14]=n,t[15]=d),s=e.devices.map(d);let f;t[16]===n?f=t[17]:(f=e=>(0,Q.jsxs)(tv,{variant:`outline`,size:`sm`,role:`listitem`,"aria-label":e.label,children:[(0,Q.jsxs)(iv,{className:`min-w-0`,children:[(0,Q.jsxs)(av,{children:[e.label,(0,Q.jsx)(_S,{variant:`outline`,children:`Pending link`})]}),(0,Q.jsxs)(ov,{children:[`Works once, until`,` `,new Date(e.expiresAt).toLocaleTimeString()]})]}),(0,Q.jsx)(sv,{children:(0,Q.jsx)(bS,{connection:n,id:e.id,label:e.label,cancelLink:!0})})]},e.id),t[16]=n,t[17]=f),c=e.grants.map(f)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8];if(u!==Symbol.for(`react.early_return_sentinel`))return u;let d;t[18]!==i||t[19]!==a||t[20]!==o||t[21]!==s||t[22]!==c?(d=(0,Q.jsxs)(i,{role:a,"aria-label":o,children:[s,c]}),t[18]=i,t[19]=a,t[20]=o,t[21]=s,t[22]=c,t[23]=d):d=t[23];let f;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Each device has its own credential, which works only through the way in it was paired over, so a credential seen on one network cannot be used through another. A phone that uses two ways in is paired once through each. Revoking a device signs it out at once and leaves the others alone.`}),t[24]=f):f=t[24];let p;return t[25]!==l||t[26]!==d?(p=(0,Q.jsxs)(`div`,{className:l,children:[d,f]}),t[25]=l,t[26]=d,t[27]=p):p=t[27],p}function yS(e){let t=(0,$.c)(11),{connection:n,id:r,label:i,trusted:a}=e,[o,s]=k_(n,r),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(U_,{"aria-hidden":!0,children:`Can update`}),t[0]=c):c=t[0];let l=`${i} can update Porcelain`,u;t[1]!==s||t[2]!==l||t[3]!==o.waiting||t[4]!==a?(u=(0,Q.jsx)(ey,{"aria-label":l,checked:a,disabled:o.waiting,onCheckedChange:s}),t[1]=s,t[2]=l,t[3]=o.waiting,t[4]=a,t[5]=u):u=t[5];let d;t[6]===o?d=t[7]:(d=Ln(o)&&(0,Q.jsx)(g_,{variant:`destructive`,children:(0,Q.jsx)(v_,{children:Am(hi(o.cause))})}),t[6]=o,t[7]=d);let f;return t[8]!==u||t[9]!==d?(f=(0,Q.jsxs)(Q.Fragment,{children:[c,u,d]}),t[8]=u,t[9]=d,t[10]=f):f=t[10],f}function bS(e){let t=(0,$.c)(12),{connection:n,id:r,label:i,cancelLink:a}=e,[o,s]=O_(n,r),c=a?`Cancel the link for ${i}`:`Revoke ${i}`,l;t[0]===s?l=t[1]:(l=()=>s(),t[0]=s,t[1]=l);let u=a?`Cancel`:`Revoke`,d;t[2]!==o.waiting||t[3]!==c||t[4]!==l||t[5]!==u?(d=(0,Q.jsx)(Le,{size:`sm`,variant:`outline`,"aria-label":c,disabled:o.waiting,onClick:l,children:u}),t[2]=o.waiting,t[3]=c,t[4]=l,t[5]=u,t[6]=d):d=t[6];let f;t[7]===o?f=t[8]:(f=Ln(o)&&(0,Q.jsx)(g_,{variant:`destructive`,children:(0,Q.jsx)(v_,{children:Am(hi(o.cause))})}),t[7]=o,t[8]=f);let p;return t[9]!==d||t[10]!==f?(p=(0,Q.jsxs)(Q.Fragment,{children:[d,f]}),t[9]=d,t[10]=f,t[11]=p):p=t[11],p}var xS={lan:`Phones and computers on the same Wi-Fi or wired network as this computer, on that one network only.`,tailnet:`Your devices signed in to Tailscale, from anywhere, encrypted and over HTTPS at this computer’s Tailscale name. You set up tailscale serve once; Porcelain checks that it reaches here.`,cloudflare:`Your own Cloudflare tunnel and hostname, over HTTPS from anywhere.`},SS={lan:`Starting`,tailnet:`Checking the Tailscale name`,cloudflare:`Checking the tunnel`};function CS(e){let t=(0,$.c)(19),{name:n,route:r}=e,{status:i}=r;if(i.kind===`off`){let e;return t[0]===r.enabled?e=t[1]:(e=r.enabled?(0,Q.jsxs)(_S,{variant:`outline`,children:[(0,Q.jsx)(y_,{}),`Starting`]}):null,t[0]=r.enabled,t[1]=e),e}if(i.kind===`starting`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(y_,{}),t[2]=e):e=t[2];let r=SS[n],i;return t[3]===r?i=t[4]:(i=(0,Q.jsxs)(_S,{variant:`outline`,children:[e,r]}),t[3]=r,t[4]=i),i}if(i.kind===`paused`){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(_S,{variant:`outline`,children:`Paused on this network`}),t[5]=e):e=t[5],e}if(i.kind===`failed`){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(_S,{variant:`destructive`,children:`Failed`}),t[6]=e):e=t[6];let r;t[7]!==n||t[8]!==i.reason?(r=cm(n,i.reason),t[7]=n,t[8]=i.reason,t[9]=r):r=t[9];let a;return t[10]===r?a=t[11]:(a=(0,Q.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[e,(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r})]}),t[10]=r,t[11]=a),a}let a=r.enabled?`On`:`Stopping`,o;t[12]===a?o=t[13]:(o=(0,Q.jsx)(_S,{variant:`secondary`,children:a}),t[12]=a,t[13]=o);let s;t[14]===i.urls?s=t[15]:(s=i.urls.map(wS),t[14]=i.urls,t[15]=s);let c;return t[16]!==o||t[17]!==s?(c=(0,Q.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[o,s]}),t[16]=o,t[17]=s,t[18]=c):c=t[18],c}function wS(e){return(0,Q.jsxs)(`div`,{className:`flex max-w-full items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`truncate font-mono text-xs text-muted-foreground`,children:e}),(0,Q.jsx)(Le,{size:`icon-xs`,variant:`ghost`,"aria-label":`Copy ${e}`,onClick:()=>ta(e,`address`),children:(0,Q.jsx)(df,{})})]},e)}function TS(e){let t=(0,$.c)(24),{name:n,route:r,disabled:i,onChange:a,children:o}=e,s=em[n],c;t[0]===s?c=t[1]:(c=(0,Q.jsx)(av,{children:s}),t[0]=s,t[1]=c);let l=xS[n],u;t[2]===l?u=t[3]:(u=(0,Q.jsx)(ov,{children:l}),t[2]=l,t[3]=u);let d;t[4]!==c||t[5]!==u?(d=(0,Q.jsxs)(iv,{children:[c,u]}),t[4]=c,t[5]=u,t[6]=d):d=t[6];let f;t[7]===a?f=t[8]:(f=e=>a(e),t[7]=a,t[8]=f);let p;t[9]!==i||t[10]!==r.enabled||t[11]!==f||t[12]!==s?(p=(0,Q.jsx)(sv,{children:(0,Q.jsx)(ey,{"aria-label":s,checked:r.enabled,disabled:i,onCheckedChange:f})}),t[9]=i,t[10]=r.enabled,t[11]=f,t[12]=s,t[13]=p):p=t[13];let m;t[14]!==n||t[15]!==r?(m=(0,Q.jsx)(CS,{name:n,route:r}),t[14]=n,t[15]=r,t[16]=m):m=t[16];let h;t[17]!==o||t[18]!==m?(h=(0,Q.jsx)(cv,{children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[m,o]})}),t[17]=o,t[18]=m,t[19]=h):h=t[19];let g;return t[20]!==d||t[21]!==p||t[22]!==h?(g=(0,Q.jsxs)(tv,{variant:`outline`,children:[d,p,h]}),t[20]=d,t[21]=p,t[22]=h,t[23]=g):g=t[23],g}function ES(e){let t=(0,$.c)(13),{remote:n,disabled:r,onTurnOn:i}=e,{lan:a}=n.routes,o=n.localNetwork,s=a.enabled&&a.status.kind===`paused`,c;t[0]!==r||t[1]!==o||t[2]!==i||t[3]!==s?(c=s&&o&&(0,Q.jsxs)(Le,{variant:`outline`,size:`sm`,className:`self-start`,disabled:r,onClick:i,children:[`Turn on for `,nm(o)]}),t[0]=r,t[1]=o,t[2]=i,t[3]=s,t[4]=c):c=t[4];let l;t[5]===n?l=t[6]:(l=rm(n),t[5]=n,t[6]=l);let u;t[7]===l?u=t[8]:(u=(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l}),t[7]=l,t[8]=u);let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsxs)(g_,{role:`note`,"aria-label":`Local network warning`,children:[(0,Q.jsx)(Cf,{}),(0,Q.jsx)(__,{children:`Not encrypted`}),(0,Q.jsx)(v_,{children:`Anyone on the same network can read what Porcelain shows and the device credentials it sends. For an encrypted connection, use Tailscale.`})]}),t[9]=d):d=t[9];let f;return t[10]!==c||t[11]!==u?(f=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[c,u,d]}),t[10]=c,t[11]=u,t[12]=f):f=t[12],f}function DS(e){let t=(0,$.c)(25),{label:n,saveLabel:r,placeholder:i,saved:a,failed:o,disabled:s,onSave:c,onCheck:l}=e,[u,d]=(0,Z.useState)(null),f=u??a,p;t[0]!==f||t[1]!==c?(p=e=>Bv(e,async()=>{c(f.trim()),d(null)}),t[0]=f,t[1]=c,t[2]=p):p=t[2];let m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=e=>d(e.target.value),t[3]=m):m=t[3];let h;t[4]!==s||t[5]!==f||t[6]!==n||t[7]!==i?(h=(0,Q.jsx)(Rv,{"aria-label":n,placeholder:i,value:f,disabled:s,onChange:m}),t[4]=s,t[5]=f,t[6]=n,t[7]=i,t[8]=h):h=t[8];let g;t[9]!==s||t[10]!==f||t[11]!==a?(g=s||f.trim()===``||f.trim()===a,t[9]=s,t[10]=f,t[11]=a,t[12]=g):g=t[12];let _;t[13]!==r||t[14]!==g?(_=(0,Q.jsx)(Le,{type:`submit`,variant:`outline`,className:`shrink-0`,disabled:g,children:r}),t[13]=r,t[14]=g,t[15]=_):_=t[15];let v;t[16]!==s||t[17]!==o||t[18]!==l?(v=o&&(0,Q.jsx)(Le,{type:`button`,variant:`outline`,className:`shrink-0`,disabled:s,onClick:l,children:`Check again`}),t[16]=s,t[17]=o,t[18]=l,t[19]=v):v=t[19];let y;return t[20]!==p||t[21]!==h||t[22]!==_||t[23]!==v?(y=(0,Q.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:p,children:[h,_,v]}),t[20]=p,t[21]=h,t[22]=_,t[23]=v,t[24]=y):y=t[24],y}function OS(e){let t=(0,$.c)(20),{remote:n,disabled:r,onSave:i,onCheck:a}=e,o=n.routes.tailnet,s;t[0]===n.tailnetTarget?s=t[1]:(s=n.tailnetTarget===void 0?void 0:sm(n.tailnetTarget),t[0]=n.tailnetTarget,t[1]=s);let c=s,l=n.tailnetHostname??``,u=o.enabled&&o.status.kind===`failed`,d;t[2]!==r||t[3]!==a||t[4]!==i||t[5]!==l||t[6]!==u?(d=(0,Q.jsx)(DS,{label:`Tailscale name`,saveLabel:`Save name`,placeholder:`laptop.tail1234.ts.net`,saved:l,failed:u,disabled:r,onSave:i,onCheck:a}),t[2]=r,t[3]=a,t[4]=i,t[5]=l,t[6]=u,t[7]=d):d=t[7];let f;t[8]===n.tailnetHostname?f=t[9]:(f=n.tailnetHostname===void 0&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Save this computer’s name on your tailnet, as tailscale status or the Tailscale admin console shows it, to turn this on. Porcelain then names the one command to run.`}),t[8]=n.tailnetHostname,t[9]=f);let p;t[10]!==n.tailnetHostname||t[11]!==o.enabled?(p=n.tailnetHostname!==void 0&&!o.enabled&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`If you set up tailscale serve for Porcelain, remove it with tailscale serve --https=443 off, or Tailscale keeps forwarding to a port Porcelain no longer holds.`}),t[10]=n.tailnetHostname,t[11]=o.enabled,t[12]=p):p=t[12];let m;t[13]===c?m=t[14]:(m=c!==void 0&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Run this once on this computer. Tailscale keeps it across restarts; remove it with tailscale serve --https=443 off.`}),(0,Q.jsxs)(`div`,{className:`flex max-w-full items-center gap-1`,children:[(0,Q.jsx)(`code`,{className:`truncate rounded bg-muted px-1.5 py-0.5 font-mono text-xs`,children:c}),(0,Q.jsx)(Le,{size:`icon-xs`,variant:`ghost`,"aria-label":`Copy the tailscale serve command`,onClick:()=>ta(c,`command`),children:(0,Q.jsx)(df,{})})]})]}),t[13]=c,t[14]=m);let h;return t[15]!==d||t[16]!==f||t[17]!==p||t[18]!==m?(h=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[d,f,p,m]}),t[15]=d,t[16]=f,t[17]=p,t[18]=m,t[19]=h):h=t[19],h}function kS(e){let t=(0,$.c)(11),{remote:n,disabled:r,onSave:i,onCheck:a}=e,o=n.routes.cloudflare,s=n.cloudflareHostname??``,c=o.enabled&&o.status.kind===`failed`,l;t[0]!==r||t[1]!==a||t[2]!==i||t[3]!==s||t[4]!==c?(l=(0,Q.jsx)(DS,{label:`Public hostname`,saveLabel:`Save hostname`,placeholder:`porcelain.example.com`,saved:s,failed:c,disabled:r,onSave:i,onCheck:a}),t[0]=r,t[1]=a,t[2]=i,t[3]=s,t[4]=c,t[5]=l):l=t[5];let u;t[6]===n.serviceUrl?u=t[7]:(u=(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`In Cloudflare, publish this hostname from your tunnel to`,` `,(0,Q.jsx)(`span`,{className:`font-mono`,children:n.serviceUrl}),`, and run cloudflared on this computer as a service. Porcelain answers to the hostname only while this is on.`]}),t[6]=n.serviceUrl,t[7]=u);let d;return t[8]!==l||t[9]!==u?(d=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10],d}function AS(e){let t=(0,$.c)(54),{connection:n,remote:r}=e,[i,a]=A_(n),o=i.waiting,s=o||!r.routes.lan.enabled&&r.localNetwork===void 0,c;t[0]===a?c=t[1]:(c=e=>a({lan:e}),t[0]=a,t[1]=c);let l;t[2]===a?l=t[3]:(l=()=>a({lan:!0}),t[2]=a,t[3]=l);let u;t[4]!==o||t[5]!==r||t[6]!==l?(u=(0,Q.jsx)(ES,{remote:r,disabled:o,onTurnOn:l}),t[4]=o,t[5]=r,t[6]=l,t[7]=u):u=t[7];let d;t[8]!==r.routes.lan||t[9]!==s||t[10]!==c||t[11]!==u?(d=(0,Q.jsx)($_,{children:(0,Q.jsx)(TS,{name:`lan`,route:r.routes.lan,disabled:s,onChange:c,children:u})}),t[8]=r.routes.lan,t[9]=s,t[10]=c,t[11]=u,t[12]=d):d=t[12];let f=o||r.tailnetHostname===void 0,p;t[13]===a?p=t[14]:(p=e=>a({tailnet:e}),t[13]=a,t[14]=p);let m;t[15]!==r.tailnetHostname||t[16]!==a?(m=e=>a({tailnetHostname:e,...r.tailnetHostname===void 0?{tailnet:!0}:{}}),t[15]=r.tailnetHostname,t[16]=a,t[17]=m):m=t[17];let h;t[18]===a?h=t[19]:(h=()=>a({tailnet:!0}),t[18]=a,t[19]=h);let g;t[20]!==o||t[21]!==r||t[22]!==m||t[23]!==h?(g=(0,Q.jsx)(OS,{remote:r,disabled:o,onSave:m,onCheck:h}),t[20]=o,t[21]=r,t[22]=m,t[23]=h,t[24]=g):g=t[24];let _;t[25]!==r.routes.tailnet||t[26]!==g||t[27]!==f||t[28]!==p?(_=(0,Q.jsx)($_,{children:(0,Q.jsx)(TS,{name:`tailnet`,route:r.routes.tailnet,disabled:f,onChange:p,children:g})}),t[25]=r.routes.tailnet,t[26]=g,t[27]=f,t[28]=p,t[29]=_):_=t[29];let v=o||r.cloudflareHostname===void 0,y;t[30]===a?y=t[31]:(y=e=>a({cloudflare:e}),t[30]=a,t[31]=y);let b;t[32]!==r.cloudflareHostname||t[33]!==a?(b=e=>a({cloudflareHostname:e,...r.cloudflareHostname===void 0?{cloudflare:!0}:{}}),t[32]=r.cloudflareHostname,t[33]=a,t[34]=b):b=t[34];let x;t[35]===a?x=t[36]:(x=()=>a({cloudflare:!0}),t[35]=a,t[36]=x);let S;t[37]!==o||t[38]!==r||t[39]!==b||t[40]!==x?(S=(0,Q.jsx)(kS,{remote:r,disabled:o,onSave:b,onCheck:x}),t[37]=o,t[38]=r,t[39]=b,t[40]=x,t[41]=S):S=t[41];let C;t[42]!==r.routes.cloudflare||t[43]!==v||t[44]!==y||t[45]!==S?(C=(0,Q.jsx)($_,{children:(0,Q.jsx)(TS,{name:`cloudflare`,route:r.routes.cloudflare,disabled:v,onChange:y,children:S})}),t[42]=r.routes.cloudflare,t[43]=v,t[44]=y,t[45]=S,t[46]=C):C=t[46];let w;t[47]===i?w=t[48]:(w=Ln(i)&&(0,Q.jsx)(g_,{variant:`destructive`,children:(0,Q.jsx)(v_,{children:Am(hi(i.cause))})}),t[47]=i,t[48]=w);let T;return t[49]!==_||t[50]!==C||t[51]!==w||t[52]!==d?(T=(0,Q.jsxs)(Q.Fragment,{children:[d,_,C,w]}),t[49]=_,t[50]=C,t[51]=w,t[52]=d,t[53]=T):T=t[53],T}function jS(e){let t=(0,$.c)(10),{connection:n,children:r}=e,i=P_(n),a,o;if(t[0]!==r||t[1]!==i){o=Symbol.for(`react.early_return_sentinel`);bb0:{let e=ja(Kn(i));if(e===null){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Sharing is managed from a browser on the computer that runs Porcelain.`}),t[4]=e):e=t[4],o=e;break bb0}if(Ln(i)){let e;t[5]===i.cause?e=t[6]:(e=Am(hi(i.cause)),t[5]=i.cause,t[6]=e);let n;t[7]===e?n=t[8]:(n=(0,Q.jsx)(g_,{variant:`destructive`,children:(0,Q.jsx)(v_,{children:e})}),t[7]=e,t[8]=n),o=n;break bb0}if(!e){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(y_,{}),t[9]=e):e=t[9],o=e;break bb0}a=r(e)}t[0]=r,t[1]=i,t[2]=a,t[3]=o}else a=t[2],o=t[3];return o===Symbol.for(`react.early_return_sentinel`)?a:o}function MS(){return Yg(),null}function NS(e){let t=(0,$.c)(4),{environment:n}=e,r=MS(),i=ja(Kn(gv())),a;return t[0]!==r||t[1]!==i||t[2]!==n?(a=r&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($_,{children:(0,Q.jsx)(tv,{variant:`outline`,children:(0,Q.jsx)(iv,{children:(0,Q.jsx)(Vv,{connection:r,environment:n})})})}),(0,Q.jsxs)(W_,{children:[(0,Q.jsx)(G_,{variant:`label`,children:`Updates`}),(0,Q.jsx)($_,{children:(0,Q.jsx)(tv,{variant:`outline`,children:(0,Q.jsx)(iv,{children:i===!0?(0,Q.jsx)(Kv,{}):i===!1?(0,Q.jsx)(V_,{}):(0,Q.jsx)(y_,{})})})})]}),(0,Q.jsx)(FS,{})]}),t[0]=r,t[1]=i,t[2]=n,t[3]=a):a=t[3],a}function PS(e){let t=(0,$.c)(13),{entry:n}=e,r=m_(n.remote),i=r.kind===`online`?r.name:n.remote.name,a;t[0]===i?a=t[1]:(a=(0,Q.jsx)(av,{children:i}),t[0]=i,t[1]=a);let o;t[2]!==n.connection||t[3]!==n.remote||t[4]!==i||t[5]!==r?(o=r.kind===`online`?(0,Q.jsx)(H_,{connection:n.connection,name:i,deviceId:n.remote.deviceId}):(0,Q.jsxs)(ov,{children:[Tp(r),`. Its update shows here once it answers.`]}),t[2]=n.connection,t[3]=n.remote,t[4]=i,t[5]=r,t[6]=o):o=t[6];let s;t[7]!==a||t[8]!==o?(s=(0,Q.jsxs)(iv,{children:[a,o]}),t[7]=a,t[8]=o,t[9]=s):s=t[9];let c;return t[10]!==i||t[11]!==s?(c=(0,Q.jsx)(tv,{variant:`outline`,role:`listitem`,"aria-label":i,children:s}),t[10]=i,t[11]=s,t[12]=c):c=t[12],c}function FS(){let e=(0,$.c)(2),t=Xg(),n;return e[0]===t?n=e[1]:(n=t.length>0&&(0,Q.jsxs)(W_,{children:[(0,Q.jsx)(G_,{variant:`label`,children:`Remote computers`}),(0,Q.jsx)($_,{"aria-label":`Remote computer updates`,children:t.map(IS)})]}),e[0]=t,e[1]=n),n}function IS(e){return(0,Q.jsx)(PS,{entry:e},e.remote.environmentId)}function LS(){let e=(0,$.c)(2),t=MS(),n;return e[0]===t?n=e[1]:(n=t&&(0,Q.jsx)(jS,{connection:t,children:e=>(0,Q.jsx)(AS,{connection:t,remote:e})}),e[0]=t,e[1]=n),n}function RS(e){let t=(0,$.c)(3),{environment:n}=e,r=MS(),i;return t[0]!==r||t[1]!==n?(i=r&&(0,Q.jsx)(jS,{connection:r,children:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(W_,{children:[(0,Q.jsx)(G_,{variant:`label`,children:`Pair a device`}),(0,Q.jsx)($_,{children:(0,Q.jsx)(tv,{variant:`outline`,children:(0,Q.jsxs)(iv,{children:[(0,Q.jsxs)(ov,{children:[`Open the link or scan the code on the other device to connect it to `,n.name,`. Each link works once, for a few minutes.`]}),(0,Q.jsx)(dS,{connection:r,remote:e})]})})})]}),(0,Q.jsxs)(W_,{children:[(0,Q.jsx)(G_,{variant:`label`,children:`Paired devices`}),(0,Q.jsx)(vS,{connection:r})]})]})}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function zS({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`empty`,className:W(`flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-3xl border-dashed p-12 text-center text-balance`,e),...t})}function BS({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`empty-header`,className:W(`flex max-w-sm flex-col items-center gap-2`,e),...t})}var VS=ct(`mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{default:`bg-transparent`,icon:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-muted text-foreground [&_svg:not([class*='size-'])]:size-5`}},defaultVariants:{variant:`default`}});function HS({className:e,variant:t=`default`,...n}){return(0,Q.jsx)(`div`,{"data-slot":`empty-icon`,"data-variant":t,className:W(VS({variant:t,className:e})),...n})}function US({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`empty-title`,className:W(`font-heading text-lg font-medium tracking-tight`,e),...t})}function WS({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`empty-description`,className:W(`text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function GS({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`empty-content`,className:W(`flex w-full max-w-sm min-w-0 flex-col items-center gap-4 text-sm text-balance`,e),...t})}function KS(e){let t=(0,$.c)(36),{remote:n}=e,r=m_(n),i=c_(n),a;t[0]===r?a=t[1]:(a=Ep(r),t[0]=r,t[1]=a);let o=a,s=r.kind===`online`?r.name:n.name,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(rv,{variant:`icon`,children:(0,Q.jsx)(xf,{})}),t[2]=c):c=t[2];let l;t[3]===s?l=t[4]:(l=(0,Q.jsx)(av,{children:s}),t[3]=s,t[4]=l);let u=r.kind===`online`&&r.version?` · Porcelain ${r.version}`:``,d;t[5]!==n.address||t[6]!==u?(d=(0,Q.jsxs)(ov,{children:[n.address,u]}),t[5]=n.address,t[6]=u,t[7]=d):d=t[7];let f;t[8]!==l||t[9]!==d?(f=(0,Q.jsxs)(iv,{children:[l,d]}),t[8]=l,t[9]=d,t[10]=f):f=t[10];let p;t[11]===r?p=t[12]:(p=lh(r),t[11]=r,t[12]=p);let m;t[13]===r?m=t[14]:(m=Tp(r),t[13]=r,t[14]=m);let h;t[15]!==p||t[16]!==m?(h=(0,Q.jsx)(_S,{variant:p,children:m}),t[15]=p,t[16]=m,t[17]=h):h=t[17];let g=`Remove ${s}`,_;t[18]===i?_=t[19]:(_=()=>i.submit(),t[18]=i,t[19]=_);let v;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(Tf,{}),t[20]=v):v=t[20];let y;t[21]!==i.result.waiting||t[22]!==g||t[23]!==_?(y=(0,Q.jsx)(Le,{variant:`ghost`,size:`icon-sm`,"aria-label":g,disabled:i.result.waiting,onClick:_,children:v}),t[21]=i.result.waiting,t[22]=g,t[23]=_,t[24]=y):y=t[24];let b;t[25]!==y||t[26]!==h?(b=(0,Q.jsxs)(sv,{children:[h,y]}),t[25]=y,t[26]=h,t[27]=b):b=t[27];let x;t[28]!==i.result||t[29]!==o?(x=(o||Ln(i.result))&&(0,Q.jsx)(cv,{children:(0,Q.jsx)(ov,{children:Ln(i.result)?Am(hi(i.result.cause)):o})}),t[28]=i.result,t[29]=o,t[30]=x):x=t[30];let S;return t[31]!==s||t[32]!==b||t[33]!==x||t[34]!==f?(S=(0,Q.jsxs)(tv,{variant:`outline`,role:`listitem`,"aria-label":s,children:[c,f,b,x]}),t[31]=s,t[32]=b,t[33]=x,t[34]=f,t[35]=S):S=t[35],S}function qS(){let e=(0,$.c)(27),[t,n]=(0,Z.useState)(``),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>n(``),e[0]=r):r=e[0];let i=s_(r),{status:a}=Jg(),o;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsx)(ov,{children:`On the other computer, run porcelain pair and paste the link it prints. This app keeps its own credential for that computer.`}),e[1]=o):o=e[1];let s;e[2]!==i||e[3]!==t?(s=e=>Bv(e,()=>i.submit(t)),e[2]=i,e[3]=t,e[4]=s):s=e[4];let c=i.result.waiting||a!==`ready`,l;e[5]===i?l=e[6]:(l=e=>{i.reset(),n(e.target.value)},e[5]=i,e[6]=l);let u;e[7]!==t||e[8]!==c||e[9]!==l?(u=(0,Q.jsx)(Rv,{"aria-label":`Pairing link`,placeholder:`http://192.168.1.20:4738/pair#c=…`,value:t,disabled:c,onChange:l}),e[7]=t,e[8]=c,e[9]=l,e[10]=u):u=e[10];let d;e[11]!==i.result.waiting||e[12]!==t||e[13]!==a?(d=i.result.waiting||a!==`ready`||t.trim()===``,e[11]=i.result.waiting,e[12]=t,e[13]=a,e[14]=d):d=e[14];let f=i.result.waiting?`Pairing…`:`Add`,p;e[15]!==d||e[16]!==f?(p=(0,Q.jsx)(Le,{type:`submit`,className:`shrink-0`,disabled:d,children:f}),e[15]=d,e[16]=f,e[17]=p):p=e[17];let m;e[18]!==s||e[19]!==u||e[20]!==p?(m=(0,Q.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row`,onSubmit:s,children:[u,p]}),e[18]=s,e[19]=u,e[20]=p,e[21]=m):m=e[21];let h;e[22]===i.result?h=e[23]:(h=Ln(i.result)&&(0,Q.jsx)(g_,{variant:`destructive`,children:(0,Q.jsx)(v_,{children:Am(hi(i.result.cause))})}),e[22]=i.result,e[23]=h);let g;return e[24]!==h||e[25]!==m?(g=(0,Q.jsx)(tv,{variant:`outline`,children:(0,Q.jsxs)(iv,{children:[o,m,h]})}),e[24]=h,e[25]=m,e[26]=g):g=e[26],g}function JS(){let e=(0,$.c)(11),{remotes:t,error:n}=Jg(),r=u_(),i;e[0]!==r||e[1]!==n?(i=n!==void 0&&(0,Q.jsxs)(g_,{variant:`destructive`,children:[(0,Q.jsx)(pf,{}),(0,Q.jsx)(__,{children:`Saved remote computers could not be read`}),(0,Q.jsxs)(v_,{children:[`Porcelain keeps them as they are and saves no change over them. Allow Porcelain to read its saved credentials, then try again.`,` `,n,(0,Q.jsx)(Le,{variant:`outline`,disabled:r.result.waiting,onClick:()=>r.read(),children:`Read saved environments`})]})]}),e[0]=r,e[1]=n,e[2]=i):i=e[2];let a;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(G_,{variant:`label`,children:`Add a remote computer`}),e[3]=a):a=e[3];let o;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Q.jsxs)(W_,{children:[a,(0,Q.jsx)($_,{children:(0,Q.jsx)(qS,{})})]}),e[4]=o):o=e[4];let s;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(G_,{variant:`label`,children:`Remote computers`}),e[5]=s):s=e[5];let c;e[6]===t?c=e[7]:(c=(0,Q.jsxs)(W_,{children:[s,t.length===0?(0,Q.jsx)(zS,{children:(0,Q.jsxs)(BS,{children:[(0,Q.jsx)(HS,{variant:`icon`,children:(0,Q.jsx)(_f,{})}),(0,Q.jsx)(US,{children:`No remote computers yet`}),(0,Q.jsx)(WS,{children:`Add one to review its projects from this app, next to the projects on this computer.`})]})}):(0,Q.jsx)($_,{"aria-label":`Remote computers`,children:t.map(YS)})]}),e[6]=t,e[7]=c);let l;return e[8]!==i||e[9]!==c?(l=(0,Q.jsxs)(Q.Fragment,{children:[i,o,c]}),e[8]=i,e[9]=c,e[10]=l):l=e[10],l}function YS(e){return(0,Q.jsx)(KS,{remote:e},e.environmentId)}function XS(e){let t=(0,$.c)(18),{name:n,status:r,onOpenRemotes:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Q.jsx)(HS,{variant:`icon`,children:(0,Q.jsx)(yf,{})}),t[0]=a):a=t[0];let o;t[1]===r?o=t[2]:(o=Tp(r),t[1]=r,t[2]=o);let s;t[3]!==n||t[4]!==o?(s=(0,Q.jsxs)(US,{children:[n,`: `,o]}),t[3]=n,t[4]=o,t[5]=s):s=t[5];let c;t[6]===r?c=t[7]:(c=Ep(r),t[6]=r,t[7]=c);let l;t[8]===c?l=t[9]:(l=(0,Q.jsx)(WS,{children:c}),t[8]=c,t[9]=l);let u;t[10]!==s||t[11]!==l?(u=(0,Q.jsxs)(BS,{children:[a,s,l]}),t[10]=s,t[11]=l,t[12]=u):u=t[12];let d;t[13]===i?d=t[14]:(d=(0,Q.jsx)(GS,{children:(0,Q.jsx)(Le,{variant:`outline`,onClick:i,children:`Open Remote computers`})}),t[13]=i,t[14]=d);let f;return t[15]!==u||t[16]!==d?(f=(0,Q.jsxs)(zS,{children:[u,d]}),t[15]=u,t[16]=d,t[17]=f):f=t[17],f}export{Q_ as $,nu as $n,Wh as $t,Fb as A,sf as An,yg as At,Ay as B,bd as Bn,pg as Bt,Ob as C,Of as Cn,Zg as Ct,Ab as D,_f as Dn,kg as Dt,jb as E,xf as En,Og as Et,ib as F,Rd as Fn,dg as Ft,Rv as G,wd as Gn,eg as Gt,ey as H,yd as Hn,rg as Ht,Yy as I,Ld as In,fg as It,sv as J,xd as Jn,Qh as Jt,Nv as K,hd as Kn,Zh as Kt,Ly as L,Ed as Ln,mg as Lt,Cb as M,rf as Mn,Tg as Mt,yb as N,ef as Nn,vg as Nt,Mb as O,df as On,Dg as Ot,_b as P,Bd as Pn,lg as Pt,av as Q,au as Qn,Gh as Qt,Ny as R,pd as Rn,cg as Rt,Db as S,Af as Sn,Yg as St,Eb as T,Tf as Tn,qg as Tt,zv as U,Sd as Un,ag as Ut,ny as V,md as Vn,ig as Vt,Bv as W,Cd as Wn,og as Wt,ov as X,dd as Xn,Xh as Xt,iv as Y,fd as Yn,Yh as Yt,$_ as Z,ud as Zn,Jh as Zt,vx as _,Am as _n,kc as _r,d_ as _t,BS as a,Eh as an,Ul as ar,W_ as at,Qb as b,Ep as bn,wc as br,e_ as bt,NS as c,uh as cn,xl as cr,E_ as ct,_S as d,ih as dn,Bc as dr,S_ as dt,Rh as en,tu as er,J_ as et,hS as f,nh as fn,Rc as fr,y_ as ft,yx as g,Wm as gn,Dc as gr,m_ as gt,mx as h,Zm as hn,Ic as hr,__ as ht,WS as i,Dh as in,Hl as ir,G_ as it,Tb as j,af as jn,Cg as jt,Pb as k,lf as kn,Eg as kt,RS as l,lh as ln,Kc as lr,T_ as lt,_x as m,Qm as mn,Lc as mr,v_ as mt,JS as n,zh as nn,Kl as nr,K_ as nt,HS as o,gh as on,zl as or,U_ as ot,px as p,th as pn,zc as pr,g_ as pt,tv as q,Td as qn,tg as qt,zS as r,Ih as rn,Wl as rr,Y_ as rt,US as s,_h as sn,Sl as sr,V_ as st,XS as t,Lh as tn,Gl as tr,Z_ as tt,LS as u,oh as un,Hc as ur,C_ as ut,gx as v,Sm as vn,Ec as vr,l_ as vt,kb as w,Df as wn,Xg as wt,Bb as x,Tp as xn,Cc as xr,Qg as xt,hx as y,Ip as yn,Oc as yr,n_ as yt,jy as z,gd as zn,sg as zt};
|