@deslop/auth 0.1.1246 → 0.1.1249
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 +1 -1
- package/dist/client/apple-touch-icon.png +0 -0
- package/dist/client/assets/(home)-7LcIsBQ-.js +20 -0
- package/dist/client/assets/Check.es-CQarv9s5.js +1 -0
- package/dist/client/assets/components-BY_sC06M.js +1 -0
- package/dist/client/assets/dialog-C7fAOB6e.js +1 -0
- package/dist/client/assets/effect-CKR-Y9J0.js +17 -0
- package/dist/client/assets/icon-CPvsBESP.svg +1 -0
- package/dist/client/assets/index-3r_PkLDE.css +2 -0
- package/dist/client/assets/index-DzL4Am0X.js +2 -0
- package/dist/client/assets/people-BRho5o7I.js +1 -0
- package/dist/client/assets/{react-BUjtWCUj.js → react-COyt-gOi.js} +1 -1
- package/dist/client/assets/route-CHxFp7zX.js +41 -0
- package/dist/client/assets/toast-BKQ798Jo.js +2 -0
- package/dist/client/index.html +6 -6
- package/dist/server.js +16873 -16322
- package/package.json +2 -2
- package/dist/client/assets/(home)-C4sL4HaQ.js +0 -20
- package/dist/client/assets/check-BtSvmjNl.js +0 -1
- package/dist/client/assets/components-C-jjTr_K.js +0 -1
- package/dist/client/assets/dialog-CD_0r6p4.js +0 -1
- package/dist/client/assets/effect-BQO-L9eB.js +0 -17
- package/dist/client/assets/icon-3Ql0zGr9.svg +0 -1
- package/dist/client/assets/index-Bl4kPiWk.css +0 -2
- package/dist/client/assets/index-Cpa5BVzH.js +0 -2
- package/dist/client/assets/people-B7MMr56H.js +0 -1
- package/dist/client/assets/route-4mqKE4it.js +0 -41
- package/dist/client/assets/toast-ChLqRem_.js +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{$ as t,$a as n,$i as r,$n as i,$r as a,$t as o,A as s,Aa as c,Ai as l,An as u,Ar as d,B as f,Ba as p,Bi as m,Br as h,Bt as g,C as _,Ca as v,Cn as y,Cr as b,Ct as x,D as S,Da as C,Di as w,Dn as T,Dr as E,Dt as D,E as O,Ea as k,Ei as A,Er as j,Et as M,Fa as ee,Fi as te,Fn as N,Fr as P,Ft as F,Ga as I,Gn as ne,Gr as re,Gt as L,H as R,Ha as ie,Hi as ae,Hr as z,I as B,Ia as oe,Ii as se,In as ce,Ir as le,It as ue,J as de,Ji as fe,Jn as pe,Jr as me,Jt as he,Ka as ge,Ki as _e,Kn as ve,Kr as ye,Kt as be,L as xe,La as Se,Li as Ce,Ln as we,Lt as Te,M as Ee,Mi as De,Mn as Oe,Mr as ke,Mt as Ae,N as je,Na as Me,Ni as Ne,Nn as Pe,Nr as V,Nt as Fe,O as Ie,Oa as Le,Oi as Re,On as ze,Or as Be,Ot as H,P as Ve,Pa as He,Pi as Ue,Pn as We,Pr as U,Pt as Ge,Qa as Ke,Qi as qe,Qn as Je,Qr as Ye,Qt as Xe,R as Ze,Ra as Qe,Ri as $e,Rn as et,Rr as tt,Rt as nt,S as rt,Sn as it,Sr as at,St as ot,T as st,Ta as ct,Ti as lt,Tn as ut,Tr as dt,Tt as ft,U as pt,Ua as mt,Ui as ht,Ur as gt,Ut as _t,V as vt,Va as yt,Vi as bt,Vr as xt,Vt as St,Wi as Ct,Wn as wt,Wr as Tt,X as Et,Xa as Dt,Xi as Ot,Xn as kt,Xt as At,Y as jt,Ya as Mt,Yi as Nt,Yn as Pt,Yr as Ft,Yt as It,Zi as Lt,Zn as Rt,Zt as zt,_ as Bt,_a as Vt,_n as Ht,_r as Ut,_t as Wt,a as Gt,ai as Kt,an as qt,ar as Jt,b as Yt,ba as Xt,bn as Zt,br as Qt,bt as $t,c as en,ci as tn,cn as nn,co as rn,cr as an,ct as on,d as sn,da as cn,di as ln,dn as un,dr as dn,dt as fn,ea as pn,ei as mn,en as hn,eo as gn,er as _n,et as vn,fa as yn,fi as bn,fn as xn,fr as Sn,ft as Cn,g as wn,ga as Tn,gn as En,h as Dn,ha as On,hn as kn,ht as An,i as jn,ia as Mn,ii as Nn,in as Pn,ir as Fn,it as In,j as Ln,ja as Rn,ji as zn,jn as Bn,jr as Vn,jt as Hn,k as Un,ki as Wn,kn as Gn,kr as Kn,kt as W,la as qn,li as Jn,lo as Yn,lr as Xn,lt as Zn,m as Qn,mn as $n,mr as er,mt as tr,n as nr,na as rr,nn as ir,no as ar,nr as or,nt as sr,o as cr,oa as lr,oi as ur,on as dr,or as fr,ot as pr,pa as mr,pi as hr,pn as gr,pr as _r,pt as vr,qa as yr,qi as br,qn as G,qr as xr,qt as Sr,r as Cr,ra as wr,ri as Tr,rn as Er,ro as K,rr as Dr,rt as Or,s as kr,sa as Ar,si as jr,sn as Mr,so as Nr,sr as q,st as Pr,t as Fr,ta as Ir,ti as Lr,tn as Rr,to as zr,tr as Br,tt as Vr,ua as Hr,ui as Ur,un as Wr,ur as Gr,ut as Kr,v as qr,va as Jr,vn as Yr,vr as Xr,vt as Zr,w as Qr,wa as $r,wi as ei,wn as ti,wr as ni,wt as ri,x as ii,xa as ai,xn as oi,xt as si,y as ci,ya as li,yn as ui,yr as di,yt as fi,za as pi,zi as mi,zn as hi,zr as gi}from"./effect-CKR-Y9J0.js";import{a as _i,i as vi,n as yi,o as bi,t as xi}from"./react-COyt-gOi.js";import{$ as Si,$t as Ci,A as wi,An as Ti,At as Ei,B as Di,Bt as Oi,C as ki,Cn as Ai,Ct as ji,Dn as Mi,Dt as Ni,E as Pi,En as Fi,Et as Ii,F as Li,G as Ri,Gt as zi,H as Bi,Ht as Vi,I as Hi,J as Ui,Jt as Wi,K as Gi,L as Ki,Lt as qi,M as Ji,Mn as Yi,Mt as Xi,N as Zi,Nn as Qi,Nt as $i,O as ea,On as ta,Ot as na,P as ra,Pt as ia,Q as aa,Qt as oa,R as sa,Rn as ca,Rt as la,S as ua,Sn as da,St as fa,T as pa,Tn as ma,Tt as ha,U as ga,V as _a,Vt as va,W as ya,X as ba,Xt as xa,Y as Sa,Z as Ca,Zt as wa,_ as Ta,_n as Ea,_t as Da,a as Oa,an as ka,at as Aa,b as ja,bn as Ma,bt as J,cn as Na,ct as Pa,d as Fa,dn as Y,dt as Ia,en as La,et as Ra,f as za,fn as Ba,ft as Va,g as Ha,gn as Ua,gt as Wa,h as Ga,hn as Ka,ht as qa,i as Ja,in as Ya,it as Xa,j as Za,jt as Qa,k as $a,kn as eo,kt as to,ln as no,lt as ro,m as io,mn as ao,mt as oo,n as so,nn as co,nt as lo,o as uo,on as fo,ot as po,p as mo,pn as ho,pt as go,q as _o,qt as vo,rn as yo,rt as bo,s as xo,sn as So,tn as Co,tt as wo,u as To,un as X,ut as Eo,v as Do,vn as Oo,vt as ko,w as Ao,wn as jo,wt as Mo,x as No,xn as Po,xt as Fo,y as Io,yn as Lo,yt as Ro,z as zo,zt as Bo}from"./toast-BKQ798Jo.js";var Z=e(bi(),1),Vo=new Map([[`bold`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M216,36H40A20,20,0,0,0,20,56V200a20,20,0,0,0,20,20H216a20,20,0,0,0,20-20V56A20,20,0,0,0,216,36Zm-4,160H44V60H212ZM60,92a16,16,0,1,1,16,16A16,16,0,0,1,60,92Zm48,0a16,16,0,1,1,16,16A16,16,0,0,1,108,92Z`}))],[`duotone`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M224,56V200a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H216A8,8,0,0,1,224,56Z`,opacity:`0.2`}),Z.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,160H40V56H216V200ZM80,84A12,12,0,1,1,68,72,12,12,0,0,1,80,84Zm40,0a12,12,0,1,1-12-12A12,12,0,0,1,120,84Z`}))],[`fill`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM68,96A12,12,0,1,1,80,84,12,12,0,0,1,68,96Zm40,0a12,12,0,1,1,12-12A12,12,0,0,1,108,96Z`}))],[`light`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M216,42H40A14,14,0,0,0,26,56V200a14,14,0,0,0,14,14H216a14,14,0,0,0,14-14V56A14,14,0,0,0,216,42Zm2,158a2,2,0,0,1-2,2H40a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2H216a2,2,0,0,1,2,2ZM78,84A10,10,0,1,1,68,74,10,10,0,0,1,78,84Zm40,0a10,10,0,1,1-10-10A10,10,0,0,1,118,84Z`}))],[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,160H40V56H216V200ZM80,84A12,12,0,1,1,68,72,12,12,0,0,1,80,84Zm40,0a12,12,0,1,1-12-12A12,12,0,0,1,120,84Z`}))],[`thin`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M216,44H40A12,12,0,0,0,28,56V200a12,12,0,0,0,12,12H216a12,12,0,0,0,12-12V56A12,12,0,0,0,216,44Zm4,156a4,4,0,0,1-4,4H40a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4H216a4,4,0,0,1,4,4ZM76,84a8,8,0,1,1-8-8A8,8,0,0,1,76,84Zm40,0a8,8,0,1,1-8-8A8,8,0,0,1,116,84Z`}))]]),Ho=Z.forwardRef((e,t)=>Z.createElement(Qi,{ref:t,...e,weights:Vo}));Ho.displayName=`AppWindowIcon`;var Uo=new Map([[`bold`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z`}))],[`duotone`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M176,128,96,208V48Z`,opacity:`0.2`}),Z.createElement(`path`,{d:`M181.66,122.34l-80-80A8,8,0,0,0,88,48V208a8,8,0,0,0,13.66,5.66l80-80A8,8,0,0,0,181.66,122.34ZM104,188.69V67.31L164.69,128Z`}))],[`fill`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M181.66,133.66l-80,80A8,8,0,0,1,88,208V48a8,8,0,0,1,13.66-5.66l80,80A8,8,0,0,1,181.66,133.66Z`}))],[`light`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M180.24,132.24l-80,80a6,6,0,0,1-8.48-8.48L167.51,128,91.76,52.24a6,6,0,0,1,8.48-8.48l80,80A6,6,0,0,1,180.24,132.24Z`}))],[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z`}))],[`thin`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M178.83,130.83l-80,80a4,4,0,0,1-5.66-5.66L170.34,128,93.17,50.83a4,4,0,0,1,5.66-5.66l80,80A4,4,0,0,1,178.83,130.83Z`}))]]),Wo=Z.forwardRef((e,t)=>Z.createElement(Qi,{ref:t,...e,weights:Uo}));Wo.displayName=`CaretRightIcon`;var Go=new Map([[`bold`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,187a113.4,113.4,0,0,1-20.39-35h40.82a116.94,116.94,0,0,1-10,20.77A108.61,108.61,0,0,1,128,207Zm-26.49-59a135.42,135.42,0,0,1,0-40h53a135.42,135.42,0,0,1,0,40ZM44,128a83.49,83.49,0,0,1,2.43-20H77.25a160.63,160.63,0,0,0,0,40H46.43A83.49,83.49,0,0,1,44,128Zm84-79a113.4,113.4,0,0,1,20.39,35H107.59a116.94,116.94,0,0,1,10-20.77A108.61,108.61,0,0,1,128,49Zm50.73,59h30.82a83.52,83.52,0,0,1,0,40H178.75a160.63,160.63,0,0,0,0-40Zm20.77-24H173.71a140.82,140.82,0,0,0-15.5-34.36A84.51,84.51,0,0,1,199.52,84ZM97.79,49.64A140.82,140.82,0,0,0,82.29,84H56.48A84.51,84.51,0,0,1,97.79,49.64ZM56.48,172H82.29a140.82,140.82,0,0,0,15.5,34.36A84.51,84.51,0,0,1,56.48,172Zm101.73,34.36A140.82,140.82,0,0,0,173.71,172h25.81A84.51,84.51,0,0,1,158.21,206.36Z`}))],[`duotone`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),Z.createElement(`path`,{d:`M128,24h0A104,104,0,1,0,232,128,104.12,104.12,0,0,0,128,24Zm88,104a87.61,87.61,0,0,1-3.33,24H174.16a157.44,157.44,0,0,0,0-48h38.51A87.61,87.61,0,0,1,216,128ZM102,168H154a115.11,115.11,0,0,1-26,45A115.27,115.27,0,0,1,102,168Zm-3.9-16a140.84,140.84,0,0,1,0-48h59.88a140.84,140.84,0,0,1,0,48ZM40,128a87.61,87.61,0,0,1,3.33-24H81.84a157.44,157.44,0,0,0,0,48H43.33A87.61,87.61,0,0,1,40,128ZM154,88H102a115.11,115.11,0,0,1,26-45A115.27,115.27,0,0,1,154,88Zm52.33,0H170.71a135.28,135.28,0,0,0-22.3-45.6A88.29,88.29,0,0,1,206.37,88ZM107.59,42.4A135.28,135.28,0,0,0,85.29,88H49.63A88.29,88.29,0,0,1,107.59,42.4ZM49.63,168H85.29a135.28,135.28,0,0,0,22.3,45.6A88.29,88.29,0,0,1,49.63,168Zm98.78,45.6a135.28,135.28,0,0,0,22.3-45.6h35.66A88.29,88.29,0,0,1,148.41,213.6Z`}))],[`fill`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M128,24h0A104,104,0,1,0,232,128,104.12,104.12,0,0,0,128,24Zm78.36,64H170.71a135.28,135.28,0,0,0-22.3-45.6A88.29,88.29,0,0,1,206.37,88ZM216,128a87.61,87.61,0,0,1-3.33,24H174.16a157.44,157.44,0,0,0,0-48h38.51A87.61,87.61,0,0,1,216,128ZM128,43a115.27,115.27,0,0,1,26,45H102A115.11,115.11,0,0,1,128,43ZM102,168H154a115.11,115.11,0,0,1-26,45A115.27,115.27,0,0,1,102,168Zm-3.9-16a140.84,140.84,0,0,1,0-48h59.88a140.84,140.84,0,0,1,0,48Zm50.35,61.6a135.28,135.28,0,0,0,22.3-45.6h35.66A88.29,88.29,0,0,1,148.41,213.6Z`}))],[`light`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm81.57,64H169.19a132.58,132.58,0,0,0-25.73-50.67A90.29,90.29,0,0,1,209.57,90ZM218,128a89.7,89.7,0,0,1-3.83,26H171.81a155.43,155.43,0,0,0,0-52h42.36A89.7,89.7,0,0,1,218,128Zm-90,87.83a110,110,0,0,1-15.19-19.45A124.24,124.24,0,0,1,99.35,166h57.3a124.24,124.24,0,0,1-13.46,30.38A110,110,0,0,1,128,215.83ZM96.45,154a139.18,139.18,0,0,1,0-52h63.1a139.18,139.18,0,0,1,0,52ZM38,128a89.7,89.7,0,0,1,3.83-26H84.19a155.43,155.43,0,0,0,0,52H41.83A89.7,89.7,0,0,1,38,128Zm90-87.83a110,110,0,0,1,15.19,19.45A124.24,124.24,0,0,1,156.65,90H99.35a124.24,124.24,0,0,1,13.46-30.38A110,110,0,0,1,128,40.17Zm-15.46-.84A132.58,132.58,0,0,0,86.81,90H46.43A90.29,90.29,0,0,1,112.54,39.33ZM46.43,166H86.81a132.58,132.58,0,0,0,25.73,50.67A90.29,90.29,0,0,1,46.43,166Zm97,50.67A132.58,132.58,0,0,0,169.19,166h40.38A90.29,90.29,0,0,1,143.46,216.67Z`}))],[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M128,24h0A104,104,0,1,0,232,128,104.12,104.12,0,0,0,128,24Zm88,104a87.61,87.61,0,0,1-3.33,24H174.16a157.44,157.44,0,0,0,0-48h38.51A87.61,87.61,0,0,1,216,128ZM102,168H154a115.11,115.11,0,0,1-26,45A115.27,115.27,0,0,1,102,168Zm-3.9-16a140.84,140.84,0,0,1,0-48h59.88a140.84,140.84,0,0,1,0,48ZM40,128a87.61,87.61,0,0,1,3.33-24H81.84a157.44,157.44,0,0,0,0,48H43.33A87.61,87.61,0,0,1,40,128ZM154,88H102a115.11,115.11,0,0,1,26-45A115.27,115.27,0,0,1,154,88Zm52.33,0H170.71a135.28,135.28,0,0,0-22.3-45.6A88.29,88.29,0,0,1,206.37,88ZM107.59,42.4A135.28,135.28,0,0,0,85.29,88H49.63A88.29,88.29,0,0,1,107.59,42.4ZM49.63,168H85.29a135.28,135.28,0,0,0,22.3,45.6A88.29,88.29,0,0,1,49.63,168Zm98.78,45.6a135.28,135.28,0,0,0,22.3-45.6h35.66A88.29,88.29,0,0,1,148.41,213.6Z`}))],[`thin`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M128,28h0A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,190.61c-6.33-6.09-23-24.41-31.27-54.61h62.54C151,194.2,134.33,212.52,128,218.61ZM94.82,156a140.42,140.42,0,0,1,0-56h66.36a140.42,140.42,0,0,1,0,56ZM128,37.39c6.33,6.09,23,24.41,31.27,54.61H96.73C105,61.8,121.67,43.48,128,37.39ZM169.41,100h46.23a92.09,92.09,0,0,1,0,56H169.41a152.65,152.65,0,0,0,0-56Zm43.25-8h-45a129.39,129.39,0,0,0-29.19-55.4A92.25,92.25,0,0,1,212.66,92ZM117.54,36.6A129.39,129.39,0,0,0,88.35,92h-45A92.25,92.25,0,0,1,117.54,36.6ZM40.36,100H86.59a152.65,152.65,0,0,0,0,56H40.36a92.09,92.09,0,0,1,0-56Zm3,64h45a129.39,129.39,0,0,0,29.19,55.4A92.25,92.25,0,0,1,43.34,164Zm95.12,55.4A129.39,129.39,0,0,0,167.65,164h45A92.25,92.25,0,0,1,138.46,219.4Z`}))]]),Ko=Z.forwardRef((e,t)=>Z.createElement(Qi,{ref:t,...e,weights:Go}));Ko.displayName=`GlobeIcon`;var qo=new Map([[`bold`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M200,152a35.77,35.77,0,0,0-16.46,4l-21.39-16.64A35.49,35.49,0,0,0,164,128.65l10.35-3.44A36,36,0,1,0,164,100c0,1.11.06,2.21.16,3.3l-7.78,2.59A36,36,0,0,0,128,92c-1,0-1.88,0-2.81.12l-4.45-10A36,36,0,1,0,96,92c1,0,1.88,0,2.81-.12l4.45,10a35.91,35.91,0,0,0-8.59,39.7L73.39,160.49a36,36,0,1,0,15.94,17.93l21.28-18.91a35.91,35.91,0,0,0,36.8-1.21L167,173.56A36,36,0,1,0,200,152Zm0-64a12,12,0,1,1-12,12A12,12,0,0,1,200,88ZM84,56A12,12,0,1,1,96,68,12,12,0,0,1,84,56ZM56,204a12,12,0,1,1,12-12A12,12,0,0,1,56,204Zm60-76a12,12,0,1,1,12,12A12,12,0,0,1,116,128Zm84,72a12,12,0,1,1,12-12A12,12,0,0,1,200,200Z`}))],[`duotone`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M152,128a24,24,0,1,1-24-24A24,24,0,0,1,152,128Z`,opacity:`0.2`}),Z.createElement(`path`,{d:`M200,152a31.84,31.84,0,0,0-19.53,6.68l-23.11-18A31.65,31.65,0,0,0,160,128c0-.74,0-1.48-.08-2.21l13.23-4.41A32,32,0,1,0,168,104c0,.74,0,1.48.08,2.21l-13.23,4.41A32,32,0,0,0,128,96a32.59,32.59,0,0,0-5.27.44L115.89,81A32,32,0,1,0,96,88a32.59,32.59,0,0,0,5.27-.44l6.84,15.4a31.92,31.92,0,0,0-8.57,39.64L73.83,165.44a32.06,32.06,0,1,0,10.63,12l25.71-22.84a31.91,31.91,0,0,0,37.36-1.24l23.11,18A31.65,31.65,0,0,0,168,184a32,32,0,1,0,32-32Zm0-64a16,16,0,1,1-16,16A16,16,0,0,1,200,88ZM80,56A16,16,0,1,1,96,72,16,16,0,0,1,80,56ZM56,208a16,16,0,1,1,16-16A16,16,0,0,1,56,208Zm56-80a16,16,0,1,1,16,16A16,16,0,0,1,112,128Zm88,72a16,16,0,1,1,16-16A16,16,0,0,1,200,200Z`}))],[`fill`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M200,152a31.84,31.84,0,0,0-19.53,6.68l-23.11-18A31.65,31.65,0,0,0,160,128c0-.74,0-1.48-.08-2.21l13.23-4.41A32,32,0,1,0,168,104c0,.74,0,1.48.08,2.21l-13.23,4.41A32,32,0,0,0,128,96a32.59,32.59,0,0,0-5.27.44L115.89,81A32,32,0,1,0,96,88a32.59,32.59,0,0,0,5.27-.44l6.84,15.4a31.92,31.92,0,0,0-8.57,39.64L73.83,165.44a32.06,32.06,0,1,0,10.63,12l25.71-22.84a31.91,31.91,0,0,0,37.36-1.24l23.11,18A31.65,31.65,0,0,0,168,184a32,32,0,1,0,32-32Zm0-64a16,16,0,1,1-16,16A16,16,0,0,1,200,88ZM80,56A16,16,0,1,1,96,72,16,16,0,0,1,80,56ZM56,208a16,16,0,1,1,16-16A16,16,0,0,1,56,208Zm144-8a16,16,0,1,1,16-16A16,16,0,0,1,200,200Z`}))],[`light`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M200,154a29.87,29.87,0,0,0-19.5,7.23L154.88,141.3A29.83,29.83,0,0,0,158,128a30.52,30.52,0,0,0-.22-3.6L174,119a30,30,0,1,0-4-15,30.52,30.52,0,0,0,.22,3.6L154,113a29.91,29.91,0,0,0-32.42-14.31l-8.14-18.3a30,30,0,1,0-11,4.88l8.14,18.3A29.92,29.92,0,0,0,102.06,143L74,168a30.08,30.08,0,1,0,8,9L110,152a29.91,29.91,0,0,0,37.47-1.23l25.62,19.93A30,30,0,1,0,200,154Zm0-68a18,18,0,1,1-18,18A18,18,0,0,1,200,86ZM78,56A18,18,0,1,1,96,74,18,18,0,0,1,78,56ZM56,210a18,18,0,1,1,18-18A18,18,0,0,1,56,210Zm72-64a18,18,0,1,1,18-18A18,18,0,0,1,128,146Zm72,56a18,18,0,1,1,18-18A18,18,0,0,1,200,202Z`}))],[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M200,152a31.84,31.84,0,0,0-19.53,6.68l-23.11-18A31.65,31.65,0,0,0,160,128c0-.74,0-1.48-.08-2.21l13.23-4.41A32,32,0,1,0,168,104c0,.74,0,1.48.08,2.21l-13.23,4.41A32,32,0,0,0,128,96a32.59,32.59,0,0,0-5.27.44L115.89,81A32,32,0,1,0,96,88a32.59,32.59,0,0,0,5.27-.44l6.84,15.4a31.92,31.92,0,0,0-8.57,39.64L73.83,165.44a32.06,32.06,0,1,0,10.63,12l25.71-22.84a31.91,31.91,0,0,0,37.36-1.24l23.11,18A31.65,31.65,0,0,0,168,184a32,32,0,1,0,32-32Zm0-64a16,16,0,1,1-16,16A16,16,0,0,1,200,88ZM80,56A16,16,0,1,1,96,72,16,16,0,0,1,80,56ZM56,208a16,16,0,1,1,16-16A16,16,0,0,1,56,208Zm56-80a16,16,0,1,1,16,16A16,16,0,0,1,112,128Zm88,72a16,16,0,1,1,16-16A16,16,0,0,1,200,200Z`}))],[`thin`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M200,156a27.87,27.87,0,0,0-19.4,7.84l-28.28-22A27.78,27.78,0,0,0,156,128a28.09,28.09,0,0,0-.45-5L175,116.55a28.07,28.07,0,1,0-2.53-7.58L153,115.45A28,28,0,0,0,128,100a27.68,27.68,0,0,0-7.6,1.06l-9.5-21.37A28,28,0,1,0,96,84a27.68,27.68,0,0,0,7.6-1.06l9.5,21.37a27.95,27.95,0,0,0-8.46,39.1L74,170.61a28,28,0,1,0,5.32,6l30.6-27.2a27.92,27.92,0,0,0,37.44-1.23l28.28,22A28,28,0,1,0,200,156Zm0-72a20,20,0,1,1-20,20A20,20,0,0,1,200,84ZM76,56A20,20,0,1,1,96,76,20,20,0,0,1,76,56ZM56,212a20,20,0,1,1,20-20A20,20,0,0,1,56,212Zm72-64a20,20,0,1,1,20-20A20,20,0,0,1,128,148Zm72,56a20,20,0,1,1,20-20A20,20,0,0,1,200,204Z`}))]]),Jo=Z.forwardRef((e,t)=>Z.createElement(Qi,{ref:t,...e,weights:qo}));Jo.displayName=`GraphIcon`;var Yo=new Map([[`bold`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M208,36H48A20,20,0,0,0,28,56V200a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V56A20,20,0,0,0,208,36Zm-4,24v56H52V60ZM52,196V140H204v56ZM160,88a16,16,0,1,1,16,16A16,16,0,0,1,160,88Zm32,80a16,16,0,1,1-16-16A16,16,0,0,1,192,168Z`}))],[`duotone`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M216,152v48a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V152a8,8,0,0,1,8-8H208A8,8,0,0,1,216,152ZM208,48H48a8,8,0,0,0-8,8v48a8,8,0,0,0,8,8H208a8,8,0,0,0,8-8V56A8,8,0,0,0,208,48Z`,opacity:`0.2`}),Z.createElement(`path`,{d:`M208,136H48a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V152A16,16,0,0,0,208,136Zm0,64H48V152H208v48Zm0-160H48A16,16,0,0,0,32,56v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V56A16,16,0,0,0,208,40Zm0,64H48V56H208v48ZM192,80a12,12,0,1,1-12-12A12,12,0,0,1,192,80Zm0,96a12,12,0,1,1-12-12A12,12,0,0,1,192,176Z`}))],[`fill`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M208,40H48A16,16,0,0,0,32,56v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V56A16,16,0,0,0,208,40ZM180,92a12,12,0,1,1,12-12A12,12,0,0,1,180,92Z`}),Z.createElement(`path`,{d:`M208,136H48a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V152A16,16,0,0,0,208,136Zm-28,52a12,12,0,1,1,12-12A12,12,0,0,1,180,188Z`}))],[`light`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M208,138H48a14,14,0,0,0-14,14v48a14,14,0,0,0,14,14H208a14,14,0,0,0,14-14V152A14,14,0,0,0,208,138Zm2,62a2,2,0,0,1-2,2H48a2,2,0,0,1-2-2V152a2,2,0,0,1,2-2H208a2,2,0,0,1,2,2ZM208,42H48A14,14,0,0,0,34,56v48a14,14,0,0,0,14,14H208a14,14,0,0,0,14-14V56A14,14,0,0,0,208,42Zm2,62a2,2,0,0,1-2,2H48a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2H208a2,2,0,0,1,2,2ZM190,80a10,10,0,1,1-10-10A10,10,0,0,1,190,80Zm0,96a10,10,0,1,1-10-10A10,10,0,0,1,190,176Z`}))],[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M208,136H48a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V152A16,16,0,0,0,208,136Zm0,64H48V152H208v48Zm0-160H48A16,16,0,0,0,32,56v48a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V56A16,16,0,0,0,208,40Zm0,64H48V56H208v48ZM192,80a12,12,0,1,1-12-12A12,12,0,0,1,192,80Zm0,96a12,12,0,1,1-12-12A12,12,0,0,1,192,176Z`}))],[`thin`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M208,140H48a12,12,0,0,0-12,12v48a12,12,0,0,0,12,12H208a12,12,0,0,0,12-12V152A12,12,0,0,0,208,140Zm4,60a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V152a4,4,0,0,1,4-4H208a4,4,0,0,1,4,4ZM208,44H48A12,12,0,0,0,36,56v48a12,12,0,0,0,12,12H208a12,12,0,0,0,12-12V56A12,12,0,0,0,208,44Zm4,60a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4H208a4,4,0,0,1,4,4Zm-24,72a8,8,0,1,1-8-8A8,8,0,0,1,188,176Zm0-96a8,8,0,1,1-8-8A8,8,0,0,1,188,80Z`}))]]),Xo=Z.forwardRef((e,t)=>Z.createElement(Qi,{ref:t,...e,weights:Yo}));Xo.displayName=`HardDrivesIcon`;var Q=_i(),Zo=ca(),Qo=e(vi(),1),$o=yi(),es=`data-open`,ts=`data-closed`,ns=Va,rs=Ia,is=`data-anchor-hidden`,as={[Pa]:``},os={[Pa]:``,[ro]:``},ss={[es]:``},cs={[ts]:``},ls={[is]:``},us={open(e){return e?as:null}},ds={open(e){return e?os:null}},fs={open(e){return e?ss:cs},anchorHidden(e){return e?ls:null}},ps={...fs,...Eo};function ms(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...ms(e,t.id,n)])}function hs(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 gs(e){e.preventDefault(),e.stopPropagation()}function _s(e){return`nativeEvent`in e}function vs(e){return e.pointerType===``&&e.isTrusted?!0:ha&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function ys(e){return fa?!1:!ha&&e.width===0&&e.height===0||e.type===`pointerdown`&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`&&(ha||e.buttons===0)||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function bs(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function xs(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}var Ss=Math.min,Cs=Math.max,ws=Math.round,Ts=Math.floor,Es=e=>({x:e,y:e}),Ds={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Os(e,t,n){return Cs(e,Ss(t,n))}function ks(e,t){return typeof e==`function`?e(t):e}function As(e){return e.split(`-`)[0]}function js(e){return e.split(`-`)[1]}function Ms(e){return e===`x`?`y`:`x`}function Ns(e){return e===`y`?`height`:`width`}function Ps(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Fs(e){return Ms(Ps(e))}function Is(e,t,n){n===void 0&&(n=!1);let r=js(e),i=Fs(e),a=Ns(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Gs(o)),[o,Gs(o)]}function Ls(e){let t=Gs(e);return[Rs(e),t,Rs(t)]}function Rs(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var zs=[`left`,`right`],Bs=[`right`,`left`],Vs=[`top`,`bottom`],Hs=[`bottom`,`top`];function Us(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Bs:zs:t?zs:Bs;case`left`:case`right`:return t?Vs:Hs;default:return[]}}function Ws(e,t,n,r){let i=js(e),a=Us(As(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Rs)))),a}function Gs(e){let t=As(e);return Ds[t]+e.slice(t.length)}function Ks(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function qs(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Ks(e)}function Js(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 Ys(e){let t=Ba(Xs,e).current;return t.next=e,X(t.effect),t}function Xs(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function Zs(e,t){return t!=null&&!bs(t)?0:typeof e==`function`?e():e}function Qs(e,t,n){let r=Zs(e,n);return typeof r==`number`?r:r?.[t]}function $s(e){return typeof e==`function`?e():e}function ec(e,t){return t||e===`click`||e===`mousedown`}function tc(e){return e?.includes(`mouse`)&&e!==`mousedown`}var nc=0;function rc(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(nc);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),co;let o=requestAnimationFrame(a);return nc=o,()=>{nc===o&&(cancelAnimationFrame(o),nc=0)}}var ic=`data-base-ui-inert`,ac=new WeakMap,oc=new WeakSet,sc=new WeakMap,cc=0;function lc(e){return e?Mi(e)?e.host:lc(e.parentNode):null}var uc=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=lc(t);return e.contains(n)?n:null}).filter(e=>e!=null),dc=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},fc=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{Ea(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function pc(e,t,n,{mark:r=!0}){let i=uc(t,e),a=r?fc(t,dc(i),new Set(i)):[],o=[],s=[];if(n){let e=uc(t,Array.from(t.querySelectorAll(`[aria-live]`))),n=i.concat(e);fc(t,dc(n),new Set(n)).forEach(e=>{let t=e.getAttribute(`aria-hidden`),n=t!==null&&t!==`false`,r=(ac.get(e)||0)+1;ac.set(e,r),o.push(e),r===1&&n&&oc.add(e),n||e.setAttribute(`aria-hidden`,`true`)})}return r&&a.forEach(e=>{let t=(sc.get(e)||0)+1;sc.set(e,t),s.push(e),t===1&&e.setAttribute(ic,``)}),cc+=1,()=>{o.forEach(e=>{let t=(ac.get(e)||0)-1;ac.set(e,t),t||(oc.has(e)||e.removeAttribute(`aria-hidden`),oc.delete(e))}),r&&s.forEach(e=>{let t=(sc.get(e)||0)-1;sc.set(e,t),t||e.removeAttribute(ic)}),--cc,cc||(ac=new WeakMap,oc=new WeakSet,sc=new WeakMap)}}function mc(e,t={}){let{ariaHidden:n=!1,mark:r=!0}=t,i=fo(e[0]).body;return pc(e,i,n,{mark:r})}function hc(){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 gc=class{nodesRef={current:[]};events=hc();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)}},_c=Z.createContext(null),vc=Z.createContext(null),yc=()=>Z.useContext(_c)?.id||null,bc=e=>{let t=Z.useContext(vc);return e??t};function xc(e){let t=pa(),n=bc(e),r=yc();return X(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function Sc(e){let{children:t,id:n}=e,r=yc();return(0,Q.jsx)(_c.Provider,{value:Z.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Cc(e){let{children:t,externalTree:n}=e,r=Ba(()=>n??new gc).current;return(0,Q.jsx)(vc.Provider,{value:r,children:t})}function wc(e,t){let n=Po(Fo(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||(vs(e)?`keyboard`:t||`mouse`):`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var Tc=20,Ec=[];function Dc(){Ec=Ec.filter(e=>e.deref()?.isConnected)}function Oc(e){Dc(),e&&Ea(e)!==`body`&&(Ec.push(new WeakRef(e)),Ec.length>Tc&&(Ec=Ec.slice(-20)))}function kc(){return Dc(),Ec[Ec.length-1]?.deref()}function Ac(e){return e?Ri(e)?e:Gi(e)[0]||e:null}function jc(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=Di(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return Ri(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 Mc(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,explicitReturnFocus:o,restoreFocus:s=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:u=``,nextFocusableElement:d,previousFocusableElement:f,beforeContentFocusGuardRef:p,externalTree:m,getInsideElements:h}=e,g=t.useState(`open`),_=t.useState(`domReferenceElement`),v=t.useState(`floatingElement`),{events:y,dataRef:b}=t.context,x=Y(()=>b.current.floatingContext?.nodeId),S=i===!1,C=Xa(_)&&S,w=Ys(i),T=Ys(a),E=Ys(o),D=Ys(u),O=Ys(g),k=bc(m),A=Oa(),j=Z.useRef(!1),M=Z.useRef(!1),ee=Z.useRef(!1),te=Z.useRef(null),N=Z.useRef(``),P=Z.useRef(``),F=Z.useRef(null),I=Z.useRef(null),ne=yo(F,p,A?.beforeInsideRef),re=yo(I,A?.afterInsideRef),L=to(),R=to(),ie=Li(),ae=A!=null,z=Si(v),B=Y((e=z)=>e?Gi(e):[]),oe=Y(()=>h?.().filter(e=>e!=null)??[]);Z.useEffect(()=>{if(r||!c)return;function e(e){e.key===`Tab`&&J(z,ko(fo(z)))&&B().length===0&&!C&&gs(e)}let t=fo(z);return zo(t,`keydown`,e)},[r,z,c,C,B]),Z.useEffect(()=>{if(r||!g)return;let e=fo(z);function t(){ee.current=!1}function n(e){let t=Fo(e),n=oe(),r=J(v,t)||J(_,t)||J(A?.portalNode,t)||n.some(e=>e===t||J(e,t));ee.current=!r,P.current=e.pointerType||`keyboard`,Ro(t,`[data-base-ui-click-trigger]`)&&(M.current=!0,R.start(0,()=>{M.current=!1}))}function i(){P.current=`keyboard`}return sa(zo(e,`pointerdown`,n,!0),zo(e,`pointerup`,t,!0),zo(e,`pointercancel`,t,!0),zo(e,`keydown`,i,!0),t)},[r,v,_,z,g,A,R,oe]),Z.useEffect(()=>{if(r||!l)return;let e=fo(z);function n(){M.current=!0,R.start(0,()=>{M.current=!1})}function i(e){let t=Fo(e);Ri(t)&&(te.current=t)}function a(n){let r=n.relatedTarget,i=n.currentTarget,a=Fo(n);c&&r==null&&a!=null&&J(v,a)&&Oc(a),queueMicrotask(()=>{let o=x(),l=t.context.triggerElements,u=oe(),p=r?.hasAttribute(uo(`focus-guard`))&&[F.current,I.current,A?.beforeInsideRef.current,A?.afterInsideRef.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,Zi(f),Zi(d)].includes(r),m=!(J(_,r)||J(v,r)||J(r,v)||J(A?.portalNode,r)||u.some(e=>e===r||J(e,r))||l.hasMatchingElement(e=>J(e,r))||p||k&&(ms(k.nodesRef.current,o).find(e=>J(e.context?.elements.floating,r)||J(e.context?.elements.domReference,r))||hs(k.nodesRef.current,o).find(e=>[e.context?.elements.floating,Si(e.context?.elements.floating)].includes(r)||e.context?.elements.domReference===r)));if(i===_&&z&&jc(z),s&&i!==_&&!ba(a)&&ko(e)===e.body){if(jo(z)&&(z.focus(),s===`popup`)){ie.request(()=>{z.focus()});return}let e=B(),t=te.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||z;jo(n)&&n.focus()}b.current.insideReactTree?b.current.insideReactTree=!1:(C||!c)&&r&&m&&!M.current&&(C||r!==kc())&&(j.current=!0,t.setOpen(!1,ki(Fa,n)))})}function o(){ee.current||(b.current.insideReactTree=!0,L.start(0,()=>{b.current.insideReactTree=!1}))}let u=jo(_)?_:null;if(v||u)return sa(u&&zo(u,`focusout`,a),u&&zo(u,`pointerdown`,n),v&&zo(v,`focusin`,i),v&&zo(v,`focusout`,a),v&&A&&zo(v,`focusout`,o,!0))},[r,_,v,z,c,k,A,t,l,s,B,C,x,b,L,R,ie,d,f,oe]),Z.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(A?.portalNode?.querySelectorAll(`[${uo(`portal`)}]`)||[]),t=(k?hs(k.nodesRef.current,x()):[]).find(e=>Xa(e.context?.elements.domReference||null))?.context?.elements.domReference,n=mc([v,...e,F.current,I.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,...oe(),t,Zi(f),Zi(d),C?_:null].filter(e=>e!=null),{ariaHidden:c||C,mark:!1}),i=mc([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,c,A,C,k,x,d,f,oe]),X(()=>{if(!g||r||!jo(z))return;N.current=``,P.current=``;let e=fo(z),t=ko(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(D.current||``):n;if(r===void 0||r===!1||J(z,t))return;let i=null,a=()=>(i??=B(z),i[0]||z),o;o=r===!0||r===null?a():Zi(r),o||=a();let s=J(z,ko(e)),c=b.current.openEvent,l=c?.type===`mousedown`&&vs(c);rc(o,{sync:l,preventScroll:o===z,shouldFocus(){if(!O.current)return!1;if(s)return!0;let t=ko(e);return!(t!==o&&J(z,t))}})})},[r,g,z,B,w,D,O,b]);let se=Z.useRef(null);X(()=>{if(r||!z){se.current=null;return}se.current&&=(se.current.cancelled=!0,null);let e=fo(z),t=ko(e),n=D.current==null;Oc(t);function i(e){if(e.open||(N.current=wc(e.nativeEvent,P.current)),(e.reason===`focus-out`&&e.triggerElement?.hasAttribute(uo(`focus-guard`))||e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`)&&(j.current=!0),e.reason===`outside-press`){if(e.nested)j.current=!1;else if(vs(e.nativeEvent)||ys(e.nativeEvent))j.current=!1;else{let e=!1;fo(z).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?j.current=!1:j.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&Ea(t)!==`body`?t:null,s=n?o||a:a||o;return s||=kc()||null,typeof i==`boolean`?s:Zi(i)||s||null}return()=>{y.off(`openchange`,i);let t=ko(e),n=oe(),r=J(v,t)||n.some(e=>e===t||J(e,t))||k&&ms(k.nodesRef.current,x(),!1).some(e=>J(e.context?.elements.floating,t)),o=T.current,s=N.current,c=a(s),l={cancelled:!1};se.current=l,queueMicrotask(()=>{se.current===l&&(se.current=null);let n=Ac(c),i=E.current??typeof o!=`boolean`;if(!l.cancelled&&o&&!j.current&&jo(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}j.current=!1})}},[r,v,z,T,E,D,y,k,_,x,oe]),X(()=>{if(!Mo||g||!v)return;let e=ko(fo(v));jo(e)&&Aa(e)&&J(v,e)&&e.blur()},[g,v]),X(()=>{if(!r&&A)return A.setFocusManagerState({modal:c,closeOnFocusOut:l,open:g,onOpenChange:t.setOpen,domReference:_}),()=>{A.setFocusManagerState(null)}},[r,A,c,g,t,l,_]),X(()=>{if(!r&&z)return jc(z),()=>{queueMicrotask(Dc)}},[r,z]);let ce=!r&&(!c||!C)&&(ae||c);return(0,Q.jsxs)(Z.Fragment,{children:[ce&&(0,Q.jsx)(Ki,{"data-type":`inside`,ref:ne,onFocus:e=>{if(c){let e=B();rc(e[e.length-1])}else A?.portalNode&&(j.current=!1,ya(e,A.portalNode)?_a(_)?.focus():Zi(f??A.beforeOutsideRef)?.focus())}}),n,ce&&(0,Q.jsx)(Ki,{"data-type":`inside`,ref:re,onFocus:e=>{c?rc(B()[0]):A?.portalNode&&(l&&(j.current=!0),ya(e,A.portalNode)?Bi(_)?.focus():Zi(d??A.afterOutsideRef)?.focus())}})]})}function Nc(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=ua}=t,l=e.context.dataRef,u=Z.useRef(void 0),d=Li(),f=to(),p=Z.useMemo(()=>{function t(t,n,r,i){let a=ki(c,n,r);t&&i===`touch`&&s>0?f.start(s,()=>{e.setOpen(!0,a)}):e.setOpen(t,a)}function n(t,n,r){let a=l.current.openEvent,s=e.select(`domReferenceElement`)!==n;return t&&s||!t||!i?!0:a&&(typeof o==`function`?o():o)?!r(a.type):!1}return{onPointerDown(e){u.current=bs(e.pointerType,!0)&&ys(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(i){let o=u.current,s=i.nativeEvent,c=e.select(`open`);if(i.button!==0||r===`click`||bs(o,!0)&&a)return;let l=n(c,i.currentTarget,e=>e===`click`||e===`mousedown`),f=Fo(s),p=Aa(f);if(p||o===`virtual`){t(l,s,p?f:i.currentTarget,o);return}let m=i.currentTarget;d.request(()=>{t(l,s,m,o)})},onClick(i){if(r===`mousedown-only`)return;let o=u.current;r===`mousedown`&&o?u.current=void 0:bs(o,!0)&&a||t(n(e.select(`open`),i.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),i.nativeEvent,i.currentTarget,o)},onKeyDown(){u.current=void 0}}},[l,r,a,c,e,o,i,d,f,s]);return Z.useMemo(()=>n?{reference:p}:Co,[n,p])}function Pc(){return!1}function Fc(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function Ic(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=Pc,bubbles:s,externalTree:c}=t,l=e.useState(`open`),u=e.useState(`floatingElement`),{dataRef:d,events:f}=e.context,p=bc(c),m=Y(typeof i==`function`?i:()=>!1),h=typeof i==`function`?m:i,g=h!==!1,_=Y(()=>a),{escapeKey:v,outsidePress:y}=Fc(s),b=Z.useRef(!1),x=Z.useRef(!1),S=Z.useRef(!1),C=Z.useRef(!1),w=Z.useRef(!1),T=Z.useRef(``),E=Z.useRef(null),D=to(),O=to(),k=to(),A=Y(()=>{O.clear(),d.current.insideReactTree=!1}),j=Y(e=>{let t=d.current.floatingContext?.nodeId;return(p?ms(p.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),M=Y(t=>Ra(t,e.select(`floatingElement`))||Ra(t,e.select(`domReferenceElement`))),ee=Y(t=>{o()&&e.setOpen(!1,ki(ua,t.nativeEvent))}),te=Y(t=>{if(!l||!n||!r||t.key!==`Escape`)return;let i=_s(t)?t.nativeEvent:t;if(w.current||i.isComposing||!v&&j(`__escapeKeyBubbles`))return;let a=ki(To,i);e.setOpen(!1,a),a.isCanceled||t.preventDefault(),!v&&!a.isPropagationAllowed&&t.stopPropagation()}),N=Y(()=>{d.current.insideReactTree=!0,O.start(0,A)}),P=Y(t=>{if(!l||!n||t.button!==0)return;let r=Fo(t.nativeEvent);J(e.select(`floatingElement`),r)&&(b.current||(b.current=!0,x.current=!1))}),F=Y(e=>{l&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&b.current&&(x.current=!0)});Z.useEffect(()=>{function e(e){e.open||(C.current=!1)}return f.on(`openchange`,e),()=>{f.off(`openchange`,e)}},[f]),Z.useEffect(()=>A,[A]),Z.useEffect(()=>{if(!l||!n)return l||(C.current=!1,w.current=!1,T.current=``,E.current=null),A;d.current.__escapeKeyBubbles=v,d.current.__outsidePressBubbles=y;let t=new na,i=fo(u);function a(){k.clear(),w.current=!0}function o(){w.current=!0,k.start(Mo?5:0,()=>{w.current=!1})}function s(){S.current=!0,t.start(0,()=>{S.current=!1})}function c(){b.current=!1,x.current=!1}function f(){let e=T.current,t=e===`pen`||!e?`mouse`:e,n=_(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function m(e){let t=f();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function O(e){let t=d.current.floatingContext?.nodeId,n=p&&ms(p.nodesRef.current,t).some(t=>Ra(e,t.context?.elements.floating));return M(e)||n}function ee(n){if(m(n)){n.type!==`click`&&!M(n)&&(t.clear(),S.current=!1),A();return}if(d.current.insideReactTree){A();return}let r=Fo(n),i=`[${uo(`inert`)}]`,a=Ai(r)?r.getRootNode():null,o=Array.from((Mi(a)?a:fo(e.select(`floatingElement`))).querySelectorAll(i)),s=e.context.triggerElements;if(r&&(s.hasElement(r)||s.hasMatchingElement(e=>J(e,r))))return;let c=Ai(r)?r:null;for(;c&&!ma(c);){let e=Ma(c);if(ma(e)||!Ai(e))break;c=e}if(!(o.length&&Ai(r)&&!lo(r)&&!J(r,e.select(`floatingElement`))&&o.every(e=>!J(c,e)))){if(jo(r)&&!(`touches`in n)){let e=ma(r),t=ho(r),i=/auto|scroll/,a=e||i.test(t.overflowX),o=e||i.test(t.overflowY),s=a&&r.clientWidth>0&&r.scrollWidth>r.clientWidth,c=o&&r.clientHeight>0&&r.scrollHeight>r.clientHeight,l=t.direction===`rtl`,u=c&&(l?n.offsetX<=r.offsetWidth-r.clientWidth:n.offsetX>r.clientWidth),d=s&&n.offsetY>r.clientHeight;if(u||d)return}if(!O(n)){if(f()===`intentional`){if(n.detail!==0&&!vs(n)&&!C.current)return;if(S.current){t.clear(),S.current=!1;return}}typeof h==`function`&&!h(n)||j(`__outsidePressBubbles`)||(e.setOpen(!1,ki(Ta,n)),A())}}}function N(t){f()===`sloppy`&&t.pointerType!==`touch`&&e.select(`open`)&&n&&!M(t)&&ee(t)}function P(t){if(f()!==`sloppy`||!e.select(`open`)||!n||M(t))return;let r=t.touches[0];r&&(E.current={startTime:Date.now(),startX:r.clientX,startY:r.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},D.start(1e3,()=>{E.current&&(E.current.dismissOnTouchEnd=!1,E.current.dismissOnMouseDown=!1)}))}function F(e,t){let n=Fo(e);if(!n)return;let r=zo(n,e.type,()=>{t(e),r()})}function I(e){T.current=`touch`,F(e,P)}function ne(e){D.clear(),e.type===`pointerdown`&&(e.button===0&&(C.current=!0),T.current=e.pointerType),(e.type!==`mousedown`||!E.current||E.current.dismissOnMouseDown)&&F(e,e=>{e.type===`pointerdown`?N(e):ee(e)})}function re(e){if(e.type===`pointercancel`&&(C.current=!1),!b.current)return;let n=x.current;c(),f()===`intentional`&&(e.type===`pointercancel`?n&&s():O(e)||(n?s():(typeof h!=`function`||h(e))&&(t.clear(),S.current=!0,A())))}function L(e){if(f()!==`sloppy`||!E.current||M(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-E.current.startX),r=Math.abs(t.clientY-E.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(E.current.dismissOnTouchEnd=!0),i>10&&(ee(e),D.clear(),E.current=null)}function R(e){F(e,L)}function ie(e){f()===`sloppy`&&E.current&&!M(e)&&(E.current.dismissOnTouchEnd&&ee(e),D.clear(),E.current=null)}function ae(e){F(e,ie)}let z=sa(r&&sa(zo(i,`keydown`,te),zo(i,`compositionstart`,a),zo(i,`compositionend`,o)),g&&sa(zo(i,`click`,ne,!0),zo(i,`pointerdown`,ne,!0),zo(i,`pointerup`,re,!0),zo(i,`pointercancel`,re,!0),zo(i,`mousedown`,ne,!0),zo(i,`mouseup`,re,!0),zo(i,`touchstart`,I,{capture:!0,passive:!0}),zo(i,`touchmove`,R,{capture:!0,passive:!0}),zo(i,`touchend`,ae,{capture:!0,passive:!0})));return()=>{z(),t.clear(),c(),S.current=!1}},[d,u,r,g,h,l,n,v,y,te,A,_,j,M,p,e,D,k]);let I=Z.useMemo(()=>({onKeyDown:te,onPointerDown:ee,onClick:ee}),[te,ee]),ne=Z.useMemo(()=>({onKeyDown:te,onPointerDown:F,onMouseDown:F,onClickCapture:N,onMouseDownCapture(e){N(),P(e)},onPointerDownCapture(e){N(),P(e)},onMouseUpCapture:N,onTouchEndCapture:N,onTouchMoveCapture:N}),[te,N,P,F]);return Z.useMemo(()=>n?{reference:I,floating:ne,trigger:I}:{},[n,I,ne])}function Lc(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=o;return t.useSyncedValue(`floatingId`,i),X(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};Ai(c)&&(e.domReferenceElement=c),r.state.positionReference===r.state.referenceElement&&(e.positionReference=c),r.update(e)},[s,i,c,l,r]),r.context.onOpenChange=u,r.context.nested=a,r}function Rc(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),X(()=>{if(!e&&o&&i!==`ending`&&n){let e=ra.request(()=>{a(`ending`)});return()=>{ra.cancel(e)}}},[e,o,i,n]),X(()=>{if(!e||t||i===void 0)return;let n=ra.request(()=>{a(void 0)});return()=>{ra.cancel(n)}},[t,e,i]),X(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=ra.request(()=>{a(`idle`)});return()=>{ra.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}function zc(e){let{open:t,ref:n,preventUnmountOnClose:r,setPreventUnmountOnClose:i,onUnmount:a,animateInitialOpen:o}=e,s=Y(i),{mounted:c,setMounted:l,transitionStatus:u}=Rc(t,!1,!1,o),d=!t&&r;X(()=>{t&&s(!1)},[t,s]);let f=Z.useRef(c),p=Z.useRef(!1),m=Pi(),h=()=>{f.current=!1,l(!1),a()};X(()=>{f.current=c,p.current&&(p.current=!1,!t&&c&&h())});let g=Y(()=>{f.current&&(t?(p.current=!0,m()):h())});return Za({enabled:c&&!t&&!d,open:t,ref:n,onComplete(){t||g()}}),{mounted:c,transitionStatus:u,preventUnmountingOnClose:d,forceUnmount:g}}var Bc={tabIndex:-1,[Da]:``};function Vc(e){return t=>t!==`touch`||e.current}function Hc(e,t=!1){let n=pa(),r=yc()!=null,i=Ba(()=>e(n,r)).current;return Lc({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function Uc({handle:e,store:t}){return X(()=>e.attachStore(t),[e,t]),null}function Wc(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function Gc(e,t){let n=Z.useRef(null);return Y(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),Wc(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),Wc(t))})}function Kc(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,openedWithoutTrigger:t?n==null:e.openedWithoutTrigger}}function qc(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function Jc(e,t,n,r={}){let i=n.reason,a=i===No,o=t&&i===`trigger-focus`,s=!t&&(i===`trigger-press`||i===`escape-key`),c=qc(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);let l=()=>{let i=Kc(e.state,t,n.trigger,c()),l={...r.extraState,...i};o?l.instantType=`focus`:s?l.instantType=`dismiss`:a&&(l.instantType=void 0),e.update(l)};a?Qo.flushSync(l):l()}function Yc(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=Gc(e,n),o=Y(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e)}else if(a==null&&i&&!n.state.openedWithoutTrigger){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=Y(e=>{a(e),e&&o(e)});return X(()=>(s(t.current),()=>s(null)),[s,t,n,e]),X(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function Xc(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`);X(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0),e.state.openedWithoutTrigger&&e.set(`openedWithoutTrigger`,!1);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&&!e.state.openedWithoutTrigger&&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=ki(Ha);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,a,o,s,n])}function Zc(e,t,n,r){let{mounted:i,transitionStatus:a,forceUnmount:o}=zc({open:e,ref:t.context.popupRef,preventUnmountOnClose:t.useState(`preventUnmountingOnClose`),setPreventUnmountOnClose:e=>t.set(`preventUnmountingOnClose`,e),animateInitialOpen:r,onUnmount(){t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}});return Ba(()=>(t.set(`mounted`,i),null)),t.useSyncedValues({mounted:i,transitionStatus:a}),{forceUnmount:o,transitionStatus:a}}function Qc(e,t){e.useSyncedValues(t),X(()=>()=>{e.update({activeTriggerProps:Co,inactiveTriggerProps:Co,popupProps:Co})},[e])}function $c(e,t){X(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),X(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var el=class{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}},tl={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},nl=class extends Ei{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:hc(),nested:n,triggerElements:i},tl),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&xs(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)=>{this.syncOnly||this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function rl(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new nl({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,openedWithoutTrigger:!1,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:Co,inactiveTriggerProps:Co,popupProps:Co}}var il=e=>e.triggerIdProp??e.activeTriggerId,al=e=>e.openProp??e.open,ol=e=>(e.popupElement?.id??e.floatingId)||void 0;function sl(e,t){return t!==void 0&&al(e)&&il(e)===t}function cl(e,t){return sl(e,t)?!0:t!==void 0&&al(e)&&il(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}var ll={open:al,mounted:e=>e.mounted,transitionStatus:e=>al(e)&&!e.mounted?`starting`:e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:il,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:ol,isTriggerActive:(e,t)=>t!==void 0&&il(e)===t,isOpenedByTrigger:(e,t)=>sl(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&il(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>cl(e,t)?ol(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function ul(e){let t=Z.useCallback(t=>e===void 0?co:e.subscribeStore(t),[e]),n=Z.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,Zo.useSyncExternalStore)(t,n,()=>e?.serverStore)}var dl=Ni&&Mo;function fl(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=Z.useRef(!1),s=Z.useRef(null),c=Z.useRef(!0),l=to();Z.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=Po(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&jo(t)&&t===ko(fo(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return sa(zo(r,`blur`,i),dl&&zo(r,`keydown`,a,!0),dl&&zo(r,`pointerdown`,l,!0))},[e,n]),Z.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);Ai(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let u=Z.useMemo(()=>{function t(){o.current=!1,s.current=null}return{onMouseLeave(){t()},onFocus(n){let i=n.currentTarget;if(o.current){if(s.current===i)return;t()}let a=Fo(n.nativeEvent);if(Ai(a)){if(dl&&!n.relatedTarget){if(!c.current&&!Aa(a))return}else if(!po(a))return}let u=bo(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:f}=n;e.select(`open`)&&u||!r?e.setOpen(!0,ki(ja,d,f)):l.start(r,()=>{o.current||e.setOpen(!0,ki(ja,d,f))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=Ai(r)&&r.hasAttribute(uo(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=ko(fo(t));!r&&n===t||J(a.current.floatingContext?.refs.floating.current,n)||J(t,n)||o||bo(r??n,e.context.triggerElements)||e.setOpen(!1,ki(ja,i))})}}},[a,r,e,l]);return Z.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}var pl=class e{pointerType=void 0;interactedInside=!1;handler=void 0;blockMouseMove=!0;performedPointerEventsMutation=!1;pointerEventsScopeElement=null;pointerEventsReferenceElement=null;pointerEventsFloatingElement=null;restTimeoutPending=!1;openChangeTimeout=new na;restTimeout=new na;handleCloseOptions=void 0;static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},ml=new WeakMap;function hl(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&ml.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),ml.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function gl(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=ml.get(n);a&&a!==e&&hl(a),hl(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,ml.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function _l(e){let t=e.context.dataRef.current,n=Ba(()=>t.hoverInteractionState??pl.create()).current;return t.hoverInteractionState||=n,$i(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function vl(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=e.useState(`open`),o=e.useState(`floatingElement`),s=e.useState(`domReferenceElement`),{dataRef:c}=e.context,l=bc(),u=yc(),d=_l(e),f=to(),p=Y(()=>ec(c.current.openEvent?.type,d.interactedInside)),m=Y(()=>tc(c.current.openEvent?.type)),h=Y(()=>{hl(d)});X(()=>{a||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,h())},[a,d,h]),Z.useEffect(()=>h,[h]),X(()=>{if(n&&a&&d.handleCloseOptions?.blockPointerEvents&&m()&&Ai(s)&&o){let e=s,t=o,n=fo(o),r=l?.nodesRef.current.find(e=>e.id===u)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=d.pointerEventsScopeElement===t?null:d.pointerEventsScopeElement,a=r===t?null:r,c=d.handleCloseOptions?.getScope?.()??i??a??Ro(e,`[data-rootownerid]`)??n.body;return gl(d,{scopeElement:c,referenceElement:e,floatingElement:t}),()=>{h()}}},[n,a,s,o,d,m,l,u,h]),Z.useEffect(()=>{if(!n)return;function t(){return!!(l&&u&&ms(l.nodesRef.current,u).length>0)}function a(t){let n=Qs(r,`close`,d.pointerType),i=()=>{e.setOpen(!1,ki(No,t)),l?.events.emit(`floating.closed`,t)};n?d.openChangeTimeout.start(n,i):(d.openChangeTimeout.clear(),i())}function s(e){let t=Fo(e);wo(t)?d.interactedInside=Ro(t,`[aria-haspopup]`)!=null:d.interactedInside=!1}function g(){d.openChangeTimeout.clear(),f.clear(),l?.events.off(`floating.closed`,v),h()}function _(n){if(t()&&l){l.events.on(`floating.closed`,v);return}if(bo(n.relatedTarget,e.context.triggerElements))return;let r=c.current.floatingContext?.nodeId??i,o=n.relatedTarget;l&&r&&Ai(o)&&ms(l.nodesRef.current,r,!1).some(e=>J(e.context?.elements.floating,o))||(d.handler?d.handler(n):(h(),m()&&!p()&&a(n)))}function v(n){l&&u&&!t()&&f.start(0,()=>{l.events.off(`floating.closed`,v),e.setOpen(!1,ki(No,n)),l.events.emit(`floating.closed`,n)})}let y=o;return sa(y&&zo(y,`mouseenter`,g),y&&zo(y,`mouseleave`,_),y&&zo(y,`pointerdown`,s,!0),()=>{l?.events.off(`floating.closed`,v)})},[n,o,e,c,r,i,m,p,h,d,l,u,f])}var yl={current:null};function bl(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=yl,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,{dataRef:h,events:g}=e.context,_=bc(l),v=_l(e),y=Z.useRef(!1),b=Ys(i),x=Ys(r),S=Ys(o),C=Ys(n),w=Ys(p),T=Ys(f),E=Y(()=>ec(h.current.openEvent?.type,v.interactedInside)),D=Y(()=>w.current?.()!==!1),O=Y((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!J(t,n);if(!Ai(r))return!1;let a=r;return i.hasMatchingElement(e=>J(e,a))&&(!t||!J(t,a))}),k=Y(()=>{v.handler&&=(fo(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,v.handler),void 0)}),A=Y(()=>{hl(v)});return u&&(v.handleCloseOptions=i?.__options),Z.useEffect(()=>k,[k]),Z.useEffect(()=>{if(!n)return;function e(e){e.open?y.current=!1:(y.current=e.reason===No,k(),v.openChangeTimeout.clear(),v.restTimeout.clear(),v.blockMouseMove=!0,v.restTimeoutPending=!1)}return g.on(`openchange`,e),()=>{g.off(`openchange`,e)}},[n,g,v,k]),Z.useEffect(()=>{if(!n)return;function t(t,n=!0){let r=Qs(x.current,`close`,v.pointerType);r?v.openChangeTimeout.start(r,()=>{e.setOpen(!1,ki(No,t)),_?.events.emit(`floating.closed`,t)}):n&&(v.openChangeTimeout.clear(),e.setOpen(!1,ki(No,t)),_?.events.emit(`floating.closed`,t))}let r=c.current??(u?e.select(`domReferenceElement`):null);if(!Ai(r))return;function i(t){if(v.openChangeTimeout.clear(),v.blockMouseMove=!1,a&&!bs(v.pointerType))return;let n=$s(S.current),r=Qs(x.current,`open`,v.pointerType),i=Fo(t),o=t.currentTarget??null,s=e.select(`domReferenceElement`),c=o;if(Ai(i)&&!e.context.triggerElements.hasElement(i)){for(let t of e.context.triggerElements.elements())if(J(t,i)){c=t;break}}Ai(o)&&Ai(s)&&!e.context.triggerElements.hasElement(o)&&J(o,s)&&(c=s);let l=c!=null&&O(s,c,i),u=e.select(`open`),d=T.current?.()??e.select(`transitionStatus`)===`ending`,f=!u&&d&&y.current,p=!l&&Ai(c)&&Ai(s)&&J(s,c)&&f,m=n>0&&!r,h=l&&(u||f)||p,g=!u||l;h?D()&&e.setOpen(!0,ki(No,t,c)):m||(r?v.openChangeTimeout.start(r,()=>{g&&D()&&e.setOpen(!0,ki(No,t,c))}):g&&D()&&e.setOpen(!0,ki(No,t,c)))}function o(n){if(E()){A();return}k();let r=e.select(`domReferenceElement`),i=fo(r);v.restTimeout.clear(),v.restTimeoutPending=!1;let a=h.current.floatingContext??d?.();if(!bo(n.relatedTarget,e.context.triggerElements)){if(b.current&&a){e.select(`open`)||v.openChangeTimeout.clear();let r=c.current;v.handler=b.current({...a,tree:_,x:n.clientX,y:n.clientY,onClose(){A(),k(),C.current&&!E()&&r===e.select(`domReferenceElement`)&&t(n,!0)}}),i.addEventListener(`mousemove`,v.handler),v.handler(n)}else v.pointerType===`touch`&&J(e.select(`floatingElement`),n.relatedTarget)||t(n)}}function l(e){J(r,e.relatedTarget)||(v.openChangeTimeout.clear(),v.restTimeout.clear(),v.restTimeoutPending=!1)}let f=m?zo(r,`mouseout`,l):void 0;return s?sa(zo(r,`mousemove`,i,{once:!0}),zo(r,`mouseenter`,i),zo(r,`mouseleave`,o),f):sa(zo(r,`mouseenter`,i),zo(r,`mouseleave`,o),f)},[k,A,h,x,e,n,b,v,u,O,E,a,s,S,c,_,C,d,T,D,m]),Z.useMemo(()=>{if(!n)return;function t(e){v.pointerType=e.pointerType}return{onPointerDown:t,onPointerEnter:t,onMouseMove(t){let{nativeEvent:n}=t,r=t.currentTarget,i=e.select(`domReferenceElement`),o=e.select(`open`),s=O(i,r,t.target);if(a&&!bs(v.pointerType))return;if(o&&s&&v.handleCloseOptions?.blockPointerEvents){let t=e.select(`floatingElement`);if(t){let e=v.handleCloseOptions?.getScope?.()??r.ownerDocument.body;gl(v,{scopeElement:e,referenceElement:r,floatingElement:t})}}let c=$s(S.current);if(o&&!s||c===0||!s&&v.restTimeoutPending&&t.movementX**2+t.movementY**2<2)return;v.restTimeout.clear();function l(){if(v.restTimeoutPending=!1,E())return;let t=e.select(`open`);!v.blockMouseMove&&(!t||s)&&D()&&e.setOpen(!0,ki(No,n,r))}v.pointerType===`touch`?Qo.flushSync(()=>{l()}):s&&o?l():(v.restTimeoutPending=!0,v.restTimeout.start(c,l))}}},[n,v,E,O,a,e,S,D])}function xl(e){return Mo&&e.movementX===0&&e.movementY===0}function Sl(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function Cl(e,t){return Sl(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function wl(e,t,n){return Sl(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Tl(e,t,n){return Sl(t,n?e===oo:e===qa,e===go)}function El(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:Sl(t,n?e===qa:e===oo,e===Wa)}function Dl(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`,triggerOrientation:_=g,parentOrientation:v,id:y,resetOnPointerLeave:b=!0,externalTree:x,nestedReturnFocusRef:S,grid:C}=t,w=C!=null,T=e.useState(`open`),E=e.useState(`floatingElement`),D=e.useState(`domReferenceElement`),O=e.context.dataRef,k=Si(E),A=Xa(D),j=Ys(k),M=yc(),ee=bc(x),te=Z.useRef(f),N=Z.useRef(o??-1),P=Z.useRef(null),F=Z.useRef(!0),I=Y(e=>{i(N.current===-1?null:N.current,e)}),ne=Z.useRef(!!E),re=Z.useRef(T),L=Z.useRef(!1),R=Z.useRef(!1),ie=Z.useRef(null),ae=Ys(h),z=Ys(T),B=Ys(o),oe=Ys(b),se=Li(),ce=Li(),le=Y(()=>{se.cancel();function e(e){d||(ie.current=rc(e,{sync:L.current,preventScroll:!0}))}let t=n.current[N.current],r=R.current;t&&e(t),(L.current?e=>e():e=>se.request(e))(()=>{let i=n.current[N.current]||t;i&&(t||e(i),he&&(r||!F.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});X(()=>{O.current.orientation=g},[O,g]),X(()=>{T||(P.current=null),T&&f===`auto`||(te.current=f)},[T,f]),X(()=>{a&&(T&&E?(N.current=o??-1,te.current&&o!=null&&(R.current=!0,I())):ne.current&&(N.current=-1,I()))},[a,T,E,o,I]),X(()=>{if(a){if(!T)L.current=!1;else if(E){if(r==null){if(L.current=!1,B.current!=null)return;if(ne.current&&(N.current=-1,le()),(!re.current||!ne.current)&&te.current&&(P.current!=null||te.current===!0&&P.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>ce.request(e):queueMicrotask)(t),e+=1):(N.current=P.current==null||wl(P.current,_,u)||l?Ui(n):_o(n),P.current=null,I())};t()}}else Ca(n.current,r)||(N.current=r,le(),R.current=!1)}}},[a,T,E,r,B,l,n,_,u,I,le,ce]),X(()=>{if(!a||E||!ee||d||!ne.current)return;let e=ee.nodesRef.current,t=e.find(e=>e.id===M)?.context?.elements.floating,n=ko(fo(D??t??null)),r=e.some(e=>e.context&&J(e.context.elements.floating,n));t&&!r&&F.current&&t.focus({preventScroll:!0})},[a,E,D,ee,M,d]),X(()=>{re.current=T,ne.current=!!E});let ue=r!=null,de=Y(e=>{if(!z.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(N.current!==t||r!==t)&&(N.current=t,I(e))}),fe=Y(()=>v??ee?.nodesRef.current.find(e=>e.id===M)?.context?.dataRef?.current.orientation),pe=Y(()=>Ui(n,ae.current)),me=Y(t=>{if(F.current=!1,L.current=!0,t.which===229||!z.current&&t.currentTarget===j.current)return;if(l&&El(t.key,g,u,w)){Cl(t.key,fe())||gs(t),e.setOpen(!1,ki(Ga,t.nativeEvent));let n=S?.current??D;jo(n)&&n.focus();return}r!=null&&r!==N.current&&!Ca(n.current,r)&&(N.current=r);let i=N.current,a=Ui(n,h),o=_o(n,h);if(A||(t.key===`Home`&&(gs(t),N.current=a,I(t)),t.key===`End`&&(gs(t),N.current=o,I(t))),C!=null){let e=C(t,N.current,n,g,c,u,h,a,o);if(e!=null&&e!==N.current&&(N.current=e,I(t)),g===`both`)return}if(Cl(t.key,g)){gs(t);let e=ko(t.currentTarget.ownerDocument);if(T&&!d&&J(t.currentTarget,e)&&!n.current.some(t=>t!=null&&J(t,e))){N.current=wl(t.key,g,u)?a:o,I(t),r===N.current&&le();return}let{index:l,wrapped:f}=Sa(n.current,i,{decrement:!wl(t.key,g,u),loopFocus:c,allowEscape:s,disabledIndices:h,minIndex:a,maxIndex:o});f&&(L.current=!1),N.current=l,I(t)}}),he=Z.useMemo(()=>({onFocus(e){L.current=!0,de(e)},onClick({currentTarget:e}){d||e.focus({preventScroll:!0})},onMouseMove(e){xl(e)||(L.current=!0,R.current=!1,p&&de(e))},onPointerLeave(e){if(!z.current||!F.current||e.pointerType===`touch`)return;L.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&oe.current&&(ie.current?.(),ie.current=null,N.current=-1,I(e),!d)){let e=j.current,t=ko(fo(e));e&&J(e,t)&&e.focus({preventScroll:!0})}}}),[de,z,j,p,n,I,oe,d]),ge=Z.useMemo(()=>d&&T&&ue&&{"aria-activedescendant":`${y}-${r}`},[d,T,ue,y,r]),_e=Z.useMemo(()=>({...A?{}:ge,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&T&&!d){let n=Fo(t.nativeEvent);if(n&&!J(j.current,n))return;gs(t);let r=ki(Fa,t.nativeEvent);e.setOpen(!1,r);let i=S?.current??D;!r.isCanceled&&jo(i)&&i.focus()}else me(t)},onPointerMove(e){xl(e)||(F.current=!0)}}),[ge,me,j,A,e,T,d,D,S]),ve=Z.useMemo(()=>{function t(t){e.setOpen(!0,ki(Ga,t.nativeEvent,t.currentTarget))}function n(e){f===`auto`&&vs(e.nativeEvent)&&(te.current=!d)}function r(e){te.current=f,f===`auto`&&ys(e.nativeEvent)&&(te.current=!0)}return{onKeyDown(n){let r=e.select(`open`);F.current=!1;let i=n.key.startsWith(`Arrow`),a=Tl(n.key,fe(),u),o=Cl(n.key,r?g:_),s=(l?a:o)||n.key===`Enter`||n.key.trim()===``;if(d&&r&&(!l||Aa(n.currentTarget)))return me(n);if(r||m||!i){if(s){let e=Cl(n.key,fe());P.current=l&&e?null:n.key}l?a&&(gs(n),r?(N.current=pe(),I(n),d&&j.current?.focus()):t(n)):o&&(B.current!=null&&(N.current=B.current),gs(n),!r&&m?t(n):me(n),r&&I(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!d&&(N.current=-1,I(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[me,f,pe,l,I,e,m,g,_,fe,u,B,d,j]),ye=Z.useMemo(()=>({...ge,...ve}),[ge,ve]);return Z.useMemo(()=>a?{reference:ye,floating:_e,item:he,trigger:ve}:{},[a,ye,_e,ve,he])}function Ol(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=Y(s),f=e.useState(`open`),p=to(),m=Z.useRef(``),h=Z.useRef(u??i??-1),g=Z.useRef(null),_=Y(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!ba(n)||n?.matches(`:disabled`)?!1:o==null||!aa(La,e,o)}function c(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)&&s(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(gs(e),d?.(!0)),m.current.length>0&&m.current[0]!==` `&&c(_,m.current)===-1&&e.key!==` `&&d?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(gs(e),d?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&s(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,d?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=c(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,d?.(!1)):(a?.(b,e),g.current=b)}),v=Y(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);J(r,n)||J(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});X(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``,d?.(!1)))},[f,u,p,d]);let y=Z.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return Z.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var kl=.1,Al=kl*kl,jl=.5;function Ml(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function Nl(e,t,n,r,i,a,o,s,c,l){let u=!1;return Ml(e,t,n,r,i,a)&&(u=!u),Ml(e,t,i,a,o,s)&&(u=!u),Ml(e,t,o,s,c,l)&&(u=!u),Ml(e,t,c,l,n,r)&&(u=!u),u}function Pl(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function Fl(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function Il(e={}){let{blockPointerEvents:t=!1}=e,n=new na,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*Al;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=Fo(r),g=r.type===`mouseleave`,_=J(u,h),v=J(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&Ai(r.relatedTarget)&&J(u,r.relatedTarget))return;function y(){return!!(s&&ms(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=Fl(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=Fl(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=Fl(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=Fl(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Pl(d,f,x)||!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?jl/2:jl*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+jl+1,o=C||T?S.bottom-jl:S.top,s=C?T?S.bottom-jl:S.top:S.bottom-jl;M=Nl(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?jl/2:jl*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-jl,o=C||T?S.top+jl:S.bottom,s=C?T?S.top+jl:S.bottom:S.top+jl;M=Nl(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?jl/2:jl*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+jl+1,o=w||E?S.right-jl:S.left,s=w?E?S.right-jl:S.left:S.right-jl;M=Nl(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?jl/2:jl*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-jl,o=w||E?S.left+jl:S.right,s=w?E?S.left+jl:S.right:S.left+jl;M=Nl(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function Ll(e,t,n){let{reference:r,floating:i}=e,a=Ps(t),o=Fs(t),s=Ns(o),c=As(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=js(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Rl(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}=ks(t,e),p=qs(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Js(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=Js(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 zl=50,Bl=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Rl},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Ll(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<zl&&(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}=Ll(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Vl=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}=ks(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=As(r),_=Ps(o),v=As(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Gs(o)]:Ls(o)),x=p!==`none`;!d&&x&&b.push(...Ws(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=Is(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`||_===Ps(t)||T.every(e=>Ps(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=Ps(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{}}}},Hl=new Set([`left`,`top`]);async function Ul(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=As(n),s=js(n),c=Ps(n)===`y`,l=Hl.has(o)?-1:1,u=a&&c?-1:1,d=ks(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 Wl=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 Ul(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}}}}},Gl=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}=ks(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Ps(i),p=Ms(f),m=u[p],h=u[f],g=(e,t)=>Os(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}}}}}},Kl=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}=ks(e,t),u={x:n,y:r},d=Ps(i),f=Ms(d),p=u[f],m=u[d],h=ks(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=Hl.has(As(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}}}},ql=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}=ks(e,t),c=await i.detectOverflow(t,s),l=As(n),u=js(n),d=Ps(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=Ss(p-c[m],g),y=Ss(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*Cs(c.left,c.right):S=p-2*Cs(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 Jl(e){let t=ho(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=jo(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=ws(n)!==a||ws(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Yl(e){return Ai(e)?e:e.contextElement}function Xl(e){let t=Yl(e);if(!jo(t))return Es(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Jl(t),o=(a?ws(n.width):n.width)/r,s=(a?ws(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var Zl=Es(0);function Ql(e){let t=Po(e);return!Ti()||!t.visualViewport?Zl:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $l(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Po(e)}function eu(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Yl(e),o=Es(1);t&&(r?Ai(r)&&(o=Xl(r)):o=Xl(e));let s=$l(a,n,r)?Ql(a):Es(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=Po(a),t=Ai(r)?Po(r):r,n=e,i=Ua(n);for(;i&&t!==n;){let e=Xl(i),t=i.getBoundingClientRect(),r=ho(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=Po(i),i=Ua(n)}}return Js({width:u,height:d,x:c,y:l})}function tu(e,t){let n=Oo(e).scrollLeft;return t?t.left+n:eu(Ka(e)).left+n}function nu(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-tu(e,n),y:n.top+t.scrollTop}}function ru(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Ka(r),s=t?eo(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Es(1),u=Es(0),d=jo(r);if((d||!a)&&((Ea(r)!==`body`||Fi(o))&&(c=Oo(r)),d)){let e=eu(r);l=Xl(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?nu(o,c):Es(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 iu(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function au(e){let t=Oo(e),n=e.ownerDocument.body,r=Cs(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Cs(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+tu(e),o=-t.scrollTop;return ho(n).direction===`rtl`&&(a+=Cs(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var ou=25;function su(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Po(e),a=Ka(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Ti()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(tu(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<=ou&&(s-=o)}return{width:s,height:c,x:l,y:u}}function cu(e,t){let n=eu(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Xl(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function lu(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=su(e,n,t);else if(t===`document`)r=au(Ka(e));else if(Ai(t))r=cu(t,n);else{let n=Ql(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Js(r)}function uu(e,t){let n=t.get(e);if(n)return n;let r=Lo(e,[],!1).filter(e=>Ai(e)&&Ea(e)!==`body`),i=null,a=ho(e).position===`fixed`,o=a?Ma(e):e;for(;Ai(o)&&!ma(o);){let e=ho(o),t=da(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Ma(o)}return t.set(e,r),r}function du(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?eo(t)?[]:uu(t,this._c):[].concat(n),r],o=lu(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=lu(t,a[e],i);s=Cs(n.top,s),c=Ss(n.right,c),l=Ss(n.bottom,l),u=Cs(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function fu(e){let{width:t,height:n}=Jl(e);return{width:t,height:n}}function pu(e,t,n){let r=jo(t),i=Ka(t),a=n===`fixed`,o=eu(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Es(0);if((r||!a)&&((Ea(t)!==`body`||Fi(i))&&(s=Oo(t)),r)){let e=eu(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=tu(i));let l=i&&!r&&!a?nu(i,s):Es(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 mu(e){return ho(e).position===`static`}function hu(e,t){if(!jo(e)||ho(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Ka(e)===n&&(n=n.ownerDocument.body),n}function gu(e,t){let n=Po(e);if(eo(e))return n;if(!jo(e)){let t=Ma(e);for(;t&&!ma(t);){if(Ai(t)&&!mu(t))return t;t=Ma(t)}return n}let r=hu(e,t);for(;r&&ta(r)&&mu(r);)r=hu(r,t);return r&&ma(r)&&mu(r)&&!da(r)?n:r||ao(e)||n}var _u=async function(e){let t=this.getOffsetParent||gu,n=this.getDimensions,r=await n(e.floating);return{reference:pu(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function vu(e){return ho(e).direction===`rtl`}var yu={convertOffsetParentRelativeRectToViewportRelativeRect:ru,getDocumentElement:Ka,getClippingRect:du,getOffsetParent:gu,getElementRects:_u,getClientRects:iu,getDimensions:fu,getScale:Xl,isElement:Ai,isRTL:vu};function bu(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function xu(e,t,n){let r=null,i,a=Ka(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=Ts(d),h=Ts(a.clientWidth-(u+f)),g=Ts(a.clientHeight-(d+p)),_=Ts(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Cs(0,Ss(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!bu(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=Po(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Su(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=Yl(e),u=i||a?[...l?Lo(l):[],...t?Lo(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?xu(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?eu(e):null;c&&g();function g(){let t=eu(e);h&&!bu(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 Cu=Wl,wu=Gl,Tu=Vl,Eu=ql,Du=Kl,Ou=(e,t,n)=>{let r=new Map,i=n??{},a={...yu,...i.platform,_c:r};return Bl(e,t,{...i,platform:a})},ku=typeof document<`u`?Z.useLayoutEffect:function(){};function Au(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(!Au(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)&&!Au(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function ju(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Mu(e,t){let n=ju(e);return Math.round(t*n)/n}function Nu(e){let t=Z.useRef(e);return ku(()=>{t.current=e}),t}function Pu(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);Au(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=Nu(c),D=Nu(i),O=Nu(l),k=Z.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Ou(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!Au(w.current,t)&&(w.current=t,Qo.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);ku(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=Z.useRef(!1);ku(()=>(A.current=!0,()=>{A.current=!1}),[]),ku(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=Z.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=Z.useMemo(()=>({reference:b,floating:x}),[b,x]),ee=Z.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=Mu(M.floating,u.x),r=Mu(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...ju(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return Z.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:ee}),[u,k,j,M,ee])}var Fu=(e,t)=>{let n=Cu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Iu=(e,t)=>{let n=wu(e);return{name:n.name,fn:n.fn,options:[e,t]}},Lu=(e,t)=>({fn:Du(e).fn,options:[e,t]}),Ru=(e,t)=>{let n=Tu(e);return{name:n.name,fn:n.fn,options:[e,t]}},zu=(e,t)=>{let n=Eu(e);return{name:n.name,fn:n.fn,options:[e,t]}};function Bu(e){let{nodeId:t,externalTree:n,rootContext:r}=e,i=r.useState(`referenceElement`),a=r.useState(`floatingElement`),o=r.useState(`domReferenceElement`),s=r.useState(`open`),c=r.useState(`floatingId`),[l,u]=Z.useState(null),d=Z.useRef(null),f=bc(n),p=Z.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=Pu({...e,elements:{...p,...l&&{reference:l}}}),h=Z.useCallback(e=>{let t=Ai(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=Z.useMemo(()=>({...m.refs,setPositionReference:h,domReference:d}),[m.refs,h]),_=Z.useMemo(()=>({...m.elements,domReference:o}),[m.elements,o]),v=Z.useMemo(()=>({...m,dataRef:r.context.dataRef,open:s,onOpenChange:r.setOpen,events:r.context.events,floatingId:c,refs:g,elements:_,nodeId:t,rootStore:r}),[m,g,_,t,r,s,c]);return X(()=>{o&&(d.current=o)},[o]),X(()=>{r.context.dataRef.current.floatingContext=v;let e=f?.nodesRef.current.find(e=>e.id===t);e&&(e.context=v)}),Z.useMemo(()=>({...m,context:v,refs:g,elements:_,rootStore:r}),[m,g,_,v,r])}var Vu=Z.createContext(void 0);function Hu(){return Z.useContext(Vu)?.direction??`ltr`}var Uu=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}=ks(e,t)||{};if(l==null)return{};let d=qs(u),f={x:n,y:r},p=Fs(i),m=Ns(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=s.floating[y]||a.floating[m],C=b/2-x/2,w=S/2-h[m]/2-1,T=Math.min(d[_],w),E=Math.min(d[v],w),D=T,O=S-h[m]-E,k=S/2-h[m]/2+C,A=Os(D,k,O),j=!c.arrow&&js(i)!=null&&k!==A&&a.reference[m]/2-(k<D?T:E)-h[m]/2<0,M=j?k<D?k-D:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Wu=(e,t)=>{let{name:n,fn:r}=Uu(e);return{name:n,fn:r,options:[e,t]}},Gu={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}}}},Ku={sideX:`left`,sideY:`top`},qu=`--available-width`,Ju=`--available-height`,Yu=`--anchor-width`,Xu=`--anchor-height`,Zu=`--transform-origin`,Qu=qu,$u=Ju;function ed(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 td(e,t,n){let{rects:r,placement:i}=e;return{side:ed(t,As(i),n),align:js(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function nd(e){return rd(e,Bu)}function rd(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:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,C=_.side||`flip`,w=_.align||`flip`,T=_.fallbackAxisSide||`end`,E=v?.crossAxis??!1,D=v?.rootBoundary,O=typeof n==`function`?n:void 0,k=Y(O),A=O?k:n,j=Ys(n),M=Ys(g),ee=Hu()===`rtl`,[te,N]=Z.useState(null);!g&&te!==null&&N(null);let P=x===`placement`,F=te?As(te):null,I=te&&P?js(te)||`center`:null,ne=F||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":ee?`left`:`right`,"inline-start":ee?`right`:`left`}[i],re=I||o,L=re===`center`?ne:`${ne}-${re}`,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 ie=+(i===`bottom`),ae=+(i===`top`),z=+(i===`right`),B=+(i===`left`),oe={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:R},se=Z.useRef(null),ce=Ys(a),le=Ys(s),ue=typeof a==`function`?0:a,de=typeof s==`function`?0:s,fe=[];p&&fe.push(p),fe.push(Fu(e=>{let t=td(e,i,ee),n=typeof ce.current==`function`?ce.current(t):ce.current,r=typeof le.current==`function`?le.current(t):le.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[ue,de,ee,i]));let pe=w===`none`&&C!==`shift`,me=!pe&&(u||E||C===`shift`),he=C===`none`?null:Ru({...oe,padding:{top:R.top+1+ie,right:R.right+1+B,bottom:R.bottom+1+ae,left:R.left+1+z},mainAxis:!E&&C===`flip`,crossAxis:w===`flip`&&`alignment`,fallbackAxisSideDirection:T}),ge=pe?null:Iu({...oe,rootBoundary:D,mainAxis:w!==`none`,crossAxis:me,limiter:u||E?void 0:Lu(e=>{if(!se.current)return{};let{width:t,height:n}=se.current.getBoundingClientRect(),r=Ps(As(e.placement)),i=r===`y`?t:n,a=r===`y`?R.left+R.right:R.top+R.bottom;return{offset:i/2+a/2}})},[oe,u,E,D,R,w]);C===`shift`||w===`shift`||re===`center`?fe.push(ge,he):fe.push(he,ge),fe.push(zu({...oe,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!M.current)return;let i=e.style;i.setProperty(Qu,`${t}px`),i.setProperty($u,`${n}px`);let a=Po(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(Yu,`${u}px`),i.setProperty(Xu,`${d}px`)}}),Wu(e=>({element:se.current||fo(e.elements.floating).createElement(`div`),padding:se.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=As(r),u=js(r),d=Ps(l)===`y`,f=se.current,p=typeof a==`function`?a(td(e,i,ee)):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 me&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(Zu,d?`${m} ${h}`:`${h} ${m}`),{}}},Gu,b),X(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let _e=Z.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:ve,elements:ye,x:be,y:xe,middlewareData:Se,update:Ce,placement:we,context:Te,isPositioned:Ee,floatingStyles:De}=t({rootContext:h,open:m?g:void 0,placement:L,middleware:fe,strategy:r,whileElementsMounted:m?void 0:(...e)=>Su(...e,_e),nodeId:y,externalTree:S}),{sideX:Oe,sideY:ke}=Se.adaptiveOrigin||Ku,Ae=Ee?r:`fixed`,je=Z.useMemo(()=>{let e;return e=Ee?b?{position:Ae,[Oe]:be,[ke]:xe}:{...De,position:Ae}:{position:Ae,top:0,left:0},e[Qu]=`100vw`,e[$u]=`100vh`,Ee||(e.opacity=0),e},[b,Ae,Oe,be,ke,xe,De,Ee]),Me=Z.useRef(null);X(()=>{if(!g)return;let e=j.current,t=typeof e==`function`?e():e,n=(id(t)?t.current:t)||null;n!==Me.current&&(ve.setPositionReference(n),Me.current=n)},[g,ve,A,j]),Z.useEffect(()=>{if(!g)return;let e=j.current;typeof e!=`function`&&id(e)&&e.current!==Me.current&&(ve.setPositionReference(e.current),Me.current=e.current)},[g,ve,A,j]),Z.useEffect(()=>{if(m&&g&&ye.reference&&ye.floating)return Su(ye.reference,ye.floating,Ce,_e)},[m,g,ye,Ce,_e]);let Ne=As(we),Pe=ed(i,Ne,ee),V=js(we)||`center`,Fe=!!Se.hide?.referenceHidden;X(()=>{x&&g&&Ee&&(Ne!==ne||P&&V!==re)&&N(we)},[x,P,g,Ee,we,Ne,V,ne,re]);let Ie=Z.useMemo(()=>({position:`absolute`,top:Se.arrow?.y,left:Se.arrow?.x}),[Se.arrow]),Le=Se.arrow?.centerOffset!==0;return Z.useMemo(()=>({positionerStyles:je,arrowStyles:Ie,arrowRef:se,arrowUncentered:Le,side:Pe,align:V,physicalSide:Ne,anchorHidden:Fe,refs:ve,context:Te,isPositioned:Ee,update:Ce}),[je,Ie,se,Le,Pe,V,Ne,Fe,ve,Te,Ee,Ce])}function id(e){return e!=null&&`current`in e}function ad(e){return e===`starting`?ea:Co}function od(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),Ci(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},ad(r),i],stateAttributesMapping:fs})}var sd=e(xi(),1);function cd(e){let t=sd.unstable_scheduleCallback(4,e);return()=>sd.unstable_cancelCallback(t)}var ld=Z.createContext(s({scheduleTask:cd,defaultIdleTTL:400})),ud=new WeakMap,dd=0,fd=new Set;function pd(e){dd++;try{return e()}finally{dd--}}function md(e){if(dd===0)return e();fd.size===0&&queueMicrotask(hd),fd.add(e)}function hd(){for(let e of fd)fd.delete(e),e()}function gd(e,t){let n=ud.get(e);n===void 0&&(n=new WeakMap,ud.set(e,n));let r=n.get(t);if(r!==void 0)return r;let i=0,a,o={subscribe(n){i++;let r=e.subscribe(t,()=>md(n));return()=>{i--,fd.delete(n),r()}},snapshot(){return pd(()=>e.get(t))},getServerSnapshot(){return(i===0||a===void 0)&&(a={value:pd(()=>Bt(t,e))}),a.value}};return n.set(t,o),o}function _d(e,t){let n=gd(e,t);return Z.useEffect(hd),Z.useSyncExternalStore(n.subscribe,n.snapshot,n.getServerSnapshot)}function vd(e,t,n){let r=gd(e,t),i=Z.useMemo(()=>{let e;return t=>(e!==void 0&&Object.is(e.source,t)||(e={source:t,value:n(t)}),e.value)},[n]);return Z.useEffect(hd),Z.useSyncExternalStore(r.subscribe,()=>i(r.snapshot()),()=>i(r.getServerSnapshot()))}var yd=(e,t)=>{let n=Z.useContext(ld);return t?vd(n,e,t):_d(n,e)};function bd(e,t){Z.useEffect(()=>e.mount(t),[t,e])}function xd(e,t,n){return n?.mode===`promise`||n?.mode===`promiseExit`?Z.useCallback(r=>{e.set(t,r);let i=j(Un(e,t,{suspendOnWaiting:!0}));return n.mode===`promise`?i.then(Sd):i},[e,t,n.mode]):Z.useCallback(n=>{e.set(t,typeof n==`function`?n(e.get(t)):n)},[e,t])}var Sd=e=>{if(bt(e))return e.value;throw pn(e.cause)},Cd=e=>{bd(Z.useContext(ld),e)},wd=(e,t)=>{let n=Z.useContext(ld);return bd(n,e),xd(n,e,t)},Td=(e,t)=>{let n=Z.useContext(ld);return[_d(n,e),xd(n,e,t)]},Ed={suspendOnWaiting:new WeakMap,default:new WeakMap};function Dd(e,t,n){let r=n?Ed.suspendOnWaiting:Ed.default,i=r.get(e);i===void 0&&(i=new WeakMap,r.set(e,i));let a=i.get(t);return a===void 0&&(a=new Promise(r=>{let a=e.subscribe(t,e=>{e._tag===`Initial`||n&&e.waiting||(setTimeout(a,1e3),r(),i.delete(t))})}),i.set(t,a)),a}function Od(e,t,n){let r=_d(e,t);if(r._tag===`Initial`||n&&r.waiting)throw Dd(e,t,n);return r}var kd=(e,t)=>{let n=Od(Z.useContext(ld),e,t?.suspendOnWaiting??!1);if(n._tag===`Failure`&&!t?.includeFailure)throw pn(n.cause);return n};Ir(`MachineSchemaEncodeError`);var Ad=class extends Ir(`MachineSchemaDecodeError`){},jd=class extends Ir(`InfiniteTransitionError`){},Md=class extends Ir(`StartupError`){},Nd=class extends Ir(`ChildAlreadyExistsError`){};Ir(`ProcessLocalError`);var Pd=class extends Ir(`StoppedError`){},Fd=e=>e instanceof jd||e instanceof Ad,Id=e=>Fd(e)?Jt(e):or(e),Ld=e=>Fd(e)||e instanceof Md?e:new Md({cause:_e(e)}),Rd=e=>e,zd=`~effect/Machine/Target`,Bd=Symbol(`effect/Machine/TargetSnapshot`),Vd=Symbol(`effect/Machine/StateInput`),Hd=Symbol(`effect/Machine/HistoryTarget`),Ud=Symbol(`effect/Machine/InitialTarget`),Wd=Symbol(`effect/Machine/ChoiceTarget`),Gd=Symbol(`effect/Machine/NoTarget`),Kd=Symbol(`effect/Machine/Declined`),qd=Symbol(`effect/Machine/TargetSelection`),Jd=Symbol(`effect/Machine/StateUpdate`),Yd=Symbol(`effect/Machine/CombinedTarget`),Xd=Symbol(`effect/Machine/SelectedBranch`),Zd=(e,t,n,r)=>Object.freeze({[qd]:qd,kind:e,scope:n,path:t,...r===void 0?{}:{updatePath:r}}),Qd=Zd(`none`,void 0,`local`),$d=e=>K(e,qd),ef=(e,t)=>Object.freeze({[Jd]:Jd,path:e,value:t}),tf=e=>K(e,Jd),nf=(e,t)=>Object.freeze({[Yd]:Yd,target:e,update:t}),rf=e=>K(e,Yd),af=(e,t,n,r)=>Object.freeze({[Xd]:Xd,owner:e,branchIndex:t,branchKey:n,result:r}),of=e=>K(e,Xd),sf=Object.freeze({[Gd]:Gd}),cf=()=>sf,lf=e=>K(e,Gd),uf=Object.freeze({[Kd]:Kd}),df=()=>uf,ff=e=>K(e,Kd),pf=(e,t)=>({[Hd]:Hd,path:e,parent:t}),mf=e=>K(e,Hd),hf=(e,t,n)=>({[Ud]:Ud,_tag:`InitialTarget`,path:e,value:t,...n===void 0?{}:{values:n}}),gf=e=>K(e,Ud),_f=(e,t,n)=>({[Wd]:Wd,path:e,parent:t,...n===void 0?{}:{values:n}}),vf=e=>K(e,Wd),yf=(e,t)=>{if(!g(t)&&t.type===`history`)return{schema:void 0,output:void 0,annotations:t.annotations,type:`history`,history:t.history===`deep`?`deep`:`shallow`,initial:void 0,states:void 0};if(!g(t)&&t.type===`choice`)return{schema:void 0,output:void 0,annotations:t.annotations,type:`choice`,history:void 0,initial:void 0,states:void 0};if(g(t))return{schema:t,output:void 0,annotations:be(t),type:`atomic`,history:void 0,initial:void 0,states:void 0};let n=K(t,`schema`)&&g(t.schema)?t.schema:void 0,r=n===void 0?t.annotations:be(n);if(t.type===`parallel`&&!K(t,`states`))throw Error(`Machine.make expected parallel state "${e}" to declare child regions`);if(K(t,`states`)){if(t.type===`final`)throw Error(`Machine.make expected compound state "${e}" to be active`);if(t.type===`parallel`)return{schema:n,output:g(t.output)?t.output:void 0,annotations:r,type:`parallel`,history:void 0,initial:void 0,states:t.states};let i=`initial`in t?t.initial:void 0;if(typeof i!=`string`)throw Error(`Machine.make expected compound state "${e}" to declare an initial child`);return{schema:n,output:void 0,annotations:r,type:`compound`,history:void 0,initial:i,states:t.states}}let i=g(t.output)?t.output:void 0;return t.type===`final`?{schema:n,output:i,annotations:r,type:`final`,history:void 0,initial:void 0,states:void 0}:{schema:n,output:void 0,annotations:r,type:`atomic`,history:void 0,initial:void 0,states:void 0}},bf=e=>{let t=new Map,n=0,r=(e,i)=>{let a=[];for(let o of Object.keys(e)){if(o.includes(`.`))throw Error(`Machine state keys cannot contain ".": "${o}"`);let s=i===void 0||i===``?o:`${i}.${o}`,c=yf(s,e[o]),l,u,d={path:s,key:o,annotations:c.annotations,order:n};switch(c.type){case`atomic`:l={...d,type:`atomic`,schema:c.schema,output:void 0,history:void 0,parent:i,children:[],initial:void 0};break;case`compound`:l={...d,type:`compound`,schema:c.schema,output:void 0,history:void 0,parent:i,children:[],initial:s===``?c.initial:`${s}.${c.initial}`},u=c.states;break;case`parallel`:l={...d,type:`parallel`,schema:c.schema,output:c.output,history:void 0,parent:i,children:[],initial:void 0},u=c.states;break;case`final`:l={...d,type:`final`,schema:c.schema,output:c.output,history:void 0,parent:i,children:[],initial:void 0};break;case`history`:if(i===void 0)throw Error(`Machine history state "${s}" must belong to a parent state`);l={...d,type:`history`,schema:void 0,output:void 0,history:c.history,parent:i,children:[],initial:void 0};break;case`choice`:if(i===void 0)throw Error(`Machine choice state "${s}" must belong to a parent state`);l={...d,type:`choice`,schema:void 0,output:void 0,history:void 0,parent:i,children:[],initial:void 0}}if(t.set(s,l),n+=1,c.type!==`history`&&c.type!==`choice`&&(a.push(s),u!==void 0)){let e=r(u,s);if(l.type===`compound`){if(!e.includes(l.initial)&&t.get(l.initial)?.type!==`choice`)throw Error(`Machine.make expected compound state "${s}" initial child to exist`);l={...l,children:e}}else if(l.type===`parallel`)l={...l,children:e};else throw Error(`Machine state "${s}" cannot declare child states`);t.set(s,l)}}return a};return{byPath:t,roots:r(e,void 0)}},xf=e=>typeof e==`object`&&e&&`branches`in e&&Array.isArray(e.branches)?Array.from(e.branches):[],Sf=e=>typeof e==`object`&&e&&`declinable`in e&&e.declinable===!0?`declinable`:`required`,Cf=e=>{let t=[];for(let n of e.stateNodes.byPath.values()){let r=Rd(e).handlers[n.path];if(r===void 0)continue;if(n.type===`choice`){let e=r.choice;e!==void 0&&t.push({source:n.path,trigger:{type:`choice`},reenter:!1,acceptance:`required`,branches:xf(e)});continue}for(let e of Reflect.ownKeys(r.on??{})){let i=r.on?.[e];t.push({source:n.path,trigger:{type:`event`,event:e},reenter:K(i,`reenter`)&&i.reenter===!0,acceptance:Sf(i),branches:xf(i)})}r.always!==void 0&&t.push({source:n.path,trigger:{type:`always`},reenter:!1,acceptance:Sf(r.always),branches:xf(r.always)}),r.onDone!==void 0&&t.push({source:n.path,trigger:{type:`done`},reenter:!1,acceptance:Sf(r.onDone),branches:xf(r.onDone)});let i=r.invoke===void 0?[]:Array.isArray(r.invoke)?r.invoke:[r.invoke];for(let e of i){let r=`child`in e?String(e.child.id):String(e.id);for(let i of[`element`,`done`,`failure`,`snapshot`]){let a=i===`element`?e.onElement:i===`done`?e.onDone:i===`failure`?e.onFailure:e.onSnapshot;a!==void 0&&t.push({source:n.path,trigger:{type:`invoke`,id:r,outcome:i},reenter:typeof a==`object`&&!!a&&a.reenter===!0,acceptance:Sf(a),branches:xf(a)})}}}return t},wf=(e,t,n)=>({[zd]:zd,[Bd]:n?.snapshot,path:e,value:t,values:n?.values}),Tf=e=>K(e,zd),Ef=e=>({[Vd]:Vd,input:e}),Df=e=>K(e,Vd),Of=e=>K(e,`path`)&&K(e,`value`),kf=(e,t,n)=>{if(e.path===t)return Mt(e);if(e.path!==``&&!t.startsWith(`${e.path}.`))return yr();if(n!==void 0&&e.value!==void 0&&(n[e.path]=e.value),K(e,`state`)&&Of(e.state))return kf(e.state,t,n);if(K(e,`states`)&&typeof e.states==`object`&&e.states!==null){for(let r of Object.values(e.states))if(Of(r)){let e=kf(r,t,n);if(mt(e))return e}}return yr()},$=(e,t)=>{let n=e.stateNodes.byPath.get(t);if(n===void 0)throw Error(`Machine expected state path "${t}" to exist`);return n},Af=e=>{if(e.schema===void 0)throw Error(`Machine state "${e.path}" has no value schema`);return e.schema},jf=new WeakMap,Mf=Symbol(`effect/Machine/EventConstruction`),Nf=new WeakMap,Pf=new WeakMap,Ff=new WeakMap,If=e=>{let t=e,n=Pf.get(t);if(n!==void 0)return n;let r=Ge(he(e));return Pf.set(t,r),r},Lf=e=>{let t=e,n=Ff.get(t);if(n!==void 0)return n;let r=F(he(e));return Ff.set(t,r),r},Rf=Symbol.for(`effect/Machine/protocol`),zf=e=>{let t=e[Rf];if(t===void 0)throw Error(`Machine protocol is unavailable`);return t},Bf=(e,t)=>{Object.defineProperty(e,Rf,{value:t,enumerable:!1})},Vf=e=>{let t=new Set,n=e=>{let r=e;if(!t.has(r)&&(t.add(r),K(e,`cases`)&&typeof e.cases==`object`&&e.cases!==null))for(let t of Object.values(e.cases))(typeof t==`object`&&t||typeof t==`function`)&&K(t,`make`)&&n(t)};for(let t of e)n(t);return t},Hf=(e,t)=>{let n=jf.get(e);if(n===void 0)throw Error(`Machine expected an event protocol created with Machine.events, Machine.internalEvents, or Machine.emittedEvents`);if(t!==void 0&&n.kind!==t)throw Error(`Machine expected a ${t} event protocol`);return n},Uf=e=>Hf(e.events,`public`).schemas,Wf=e=>Hf(e.internalEvents,`internal`).schemas,Gf=e=>Hf(e.emittedEvents,`emitted`).schemas,Kf=e=>{let t=Uf(e),n=Wf(e),r=Gf(e),i=new Set(Reflect.ownKeys(e.events));for(let t of Reflect.ownKeys(e.internalEvents))if(i.has(t))throw Error(`Public and internal machine event tags must be disjoint: ${String(t)}`);let a=[...t,...n];Bf(e,{event:Fe(a),emit:Fe(r),eventConstructors:Vf(a),emissionConstructors:Vf(r)})},qf=(e,t)=>Bf(t,zf(e)),Jf=e=>K(e,`_tag`)?String(e._tag):void 0,Yf=(e,t,n,r)=>{let i=r,a;if(typeof r==`object`&&r)try{i={...r}}catch(e){i=void 0,a=e}let o={[Mf]:Mf,_tag:n};return Nf.set(o,{kind:e,schema:t,input:i,...a===void 0?{}:{inputError:a}}),Object.freeze(o)},Xf=e=>typeof e==`object`&&!!e&&Nf.has(e),Zf=(e,t)=>{let n=[],r=e=>{if(K(e,`cases`)&&typeof e.cases==`object`&&e.cases!==null)for(let t of Reflect.ownKeys(e.cases))r(Reflect.get(e.cases,t));else if(K(e,`members`)&&Array.isArray(e.members))for(let t of e.members)r(t);else n.push(e)};for(let e of t)r(e);let i=Object.create(null),a=e=>Xe(e)?typeof e.literal==`string`||typeof e.literal==`number`?[e.literal]:[]:Mr(e)?[e.symbol]:zt(e)?e.enums.map(([,e])=>e):dr(e)?e.types.flatMap(a):Er(e)?a(e.thunk()):[],o=e=>{let t=nn(e.ast);if(hn(t)){let e=t.propertySignatures.find(({name:e})=>e===`_tag`),n=e===void 0?[]:a(e.type);if(n.length>0)return n}try{return Fe([e]).pipe(Sr(`_tag`)).discriminants}catch{return[]}};for(let t of n){let n=o(t);if(n.length!==0)for(let r of n){if(K(i,r))throw Error(`Duplicate machine event constructor tag: ${String(r)}`);Object.defineProperty(i,r,{value:(...n)=>Yf(e,t,r,n.length===0?{}:n[0]),enumerable:!0})}}return i},Qf=(e,t)=>{let n=Object.freeze(Array.from(t)),r=Zf(e,n);return jf.set(r,{kind:e,schemas:n}),Object.freeze(r)},$f=(e,t,n,r)=>If(t)(n).pipe(Xr(t=>new Ad({machineId:e.id,boundary:r.boundary,cause:t,...r.state===void 0?{}:{state:r.state},...r.event===void 0?{}:{event:r.event}}))),ep=(e,t,n,r)=>{let i=Lf(t)(n);if(Me(i))throw new Ad({machineId:e.id,boundary:r.boundary,cause:i.failure,...r.state===void 0?{}:{state:r.state},...r.event===void 0?{}:{event:r.event}});return i.success},tp=(e,t,n,r)=>{try{return t.make(n)}catch(t){let n=t instanceof Error?t.cause:void 0;throw new Ad({machineId:e.id,boundary:r.boundary,cause:St(t)?t:K(n,`~effect/SchemaIssue/Issue`)?new D(n):_e(t),...r.state===void 0?{}:{state:r.state},...r.event===void 0?{}:{event:r.event}})}},np=(e,t,n)=>new Ad({machineId:e.id,boundary:n,event:String(t._tag),cause:_e(Error(`Constructed ${n} schema does not belong to the machine ${n} protocol`))}),rp=(e,t)=>{if(t.inputError!==void 0)throw t.inputError;return typeof t.input==`object`&&t.input!==null?{...t.input,_tag:e._tag}:{_tag:e._tag}},ip=(e,t,n,r)=>new Ad({machineId:e.id,boundary:n,event:String(t._tag),cause:_e(r)}),ap=(e,t,n,r)=>{let i=Nf.get(n),a=r===`event`?t.eventConstructors:t.emissionConstructors;return i===void 0||(r===`emission`?i.kind!==`emitted`:i.kind===`emitted`)||!a.has(i.schema)?Jt(np(e,n,r)):gi({try:()=>rp(n,i),catch:t=>ip(e,n,r,t)}).pipe(q(t=>i.schema.makeEffect(t).pipe(Xr(t=>new Ad({machineId:e.id,boundary:r,event:String(n._tag),cause:new D(t)})))))},op=(e,t,n,r)=>{let i=Nf.get(n),a=r===`event`?t.eventConstructors:t.emissionConstructors;if(i===void 0||(r===`emission`?i.kind!==`emitted`:i.kind===`emitted`)||!a.has(i.schema))throw np(e,n,r);let o;try{o=rp(n,i)}catch(t){throw ip(e,n,r,t)}return tp(e,i.schema,o,{boundary:r,event:String(n._tag)})},sp=(e,t)=>{let n=zf(e);if(Xf(t))return ap(e,n,t,`event`);let r=Jf(t);return $f(e,n.event,t,r===void 0?{boundary:`event`}:{boundary:`event`,event:r})},cp=(e,t)=>{let n=zf(e);if(Xf(t))return op(e,n,t,`event`);let r=Jf(t);return ep(e,n.event,t,r===void 0?{boundary:`event`}:{boundary:`event`,event:r})},lp=(e,t)=>{let n=zf(e);if(Xf(t))return ap(e,n,t,`emission`);let r=Jf(t);return $f(e,n.emit,t,r===void 0?{boundary:`emission`}:{boundary:`emission`,event:r})},up=(e,t)=>{let n=zf(e);if(Xf(t))return op(e,n,t,`emission`);let r=Jf(t);return ep(e,n.emit,t,r===void 0?{boundary:`emission`}:{boundary:`emission`,event:r})},dp=(e,t,n)=>ep(e,t,n,{boundary:`input`}),fp=(e,t,n)=>Df(n)?Af(t).makeEffect(n.input).pipe(Xr(n=>new Ad({machineId:e.id,boundary:`state`,state:t.path,cause:new D(n)}))):$f(e,Af(t),n,{boundary:`state`,state:t.path}),pp=(e,t,n)=>Df(n)?tp(e,Af(t),n.input,{boundary:`state`,state:t.path}):ep(e,Af(t),n,{boundary:`state`,state:t.path}),mp=(e,t,n)=>t.output===void 0?ke(n):$f(e,t.output,n,{boundary:`output`,state:t.path}),hp=(e,t,n)=>t.output===void 0?n:ep(e,t.output,n,{boundary:`output`,state:t.path}),gp=(e,t)=>{let n=new Set(Ep(e,t.parent)),r=n=>{let i=$(e,n);if(i.type===`compound`){let e=i.children.filter(e=>t.active.has(e));if(e.length!==1)throw Error(`Machine history expected compound state "${n}" to retain one active child`);t.mode===`deep`&&r(e[0])}else if(i.type===`parallel`)for(let e of i.children){if(!t.active.has(e))throw Error(`Machine history expected parallel state "${n}" to retain region "${e}"`);t.mode===`deep`&&r(e)}};r(t.parent);for(let r of t.active){if(!n.has(r)&&!Tp(r,t.parent))throw Error(`Machine history contains state "${r}" outside parent "${t.parent}"`);if(t.mode===`shallow`&&wp(r,t.parent)&&$(e,r).parent!==t.parent)throw Error(`Machine shallow history contains deep descendant "${r}"`)}},_p=(e,t)=>{let n=new Map;for(let[r,i]of Object.entries(t.history??{})){let t=$(e,r);if(t.type!==`history`||t.parent===void 0||t.history!==i.mode)throw Error(`Machine snapshot contains invalid history record "${r}"`);let a=new Set,o=new Map;for(let n of i.active){if(a.has(n))throw Error(`Machine snapshot contains invalid remembered state "${n}"`);let r=$(e,n);if(r.type===`history`||r.type===`choice`||!(Tp(n,t.parent)||Ep(e,t.parent).includes(n)))throw Error(`Machine snapshot contains invalid remembered value for "${n}"`);a.add(n);let s=Object.prototype.hasOwnProperty.call(i.values,n);if(r.schema===void 0){if(s)throw Error(`Machine snapshot contains a value for structural state "${n}"`)}else{if(!s)throw Error(`Machine snapshot omits remembered value for "${n}"`);o.set(n,pp(e,r,i.values[n]))}}if(!a.has(t.parent)||Object.keys(i.values).length!==o.size)throw Error(`Machine snapshot contains incomplete history record "${r}"`);n.set(r,{mode:i.mode,parent:t.parent,active:a,values:o}),gp(e,n.get(r))}return n},vp=an(function*(e,t){let n=new Map;for(let[r,i]of Object.entries(t.history??{})){let t=e.stateNodes.byPath.get(r);if(t===void 0||t.type!==`history`||t.parent===void 0||t.history!==i.mode)return yield*Jt(new Ad({machineId:e.id,boundary:`history`,state:r,cause:_e(Error(`Machine snapshot contains invalid history record "${r}"`))}));let a=new Set,o=new Map;for(let n of i.active){let r=e.stateNodes.byPath.get(n);if(a.has(n)||r===void 0||r.type===`history`||r.type===`choice`||!(Tp(n,t.parent)||Ep(e,t.parent).includes(n)))return yield*Jt(new Ad({machineId:e.id,boundary:`history`,state:n,cause:_e(Error(`Machine snapshot contains invalid remembered state "${n}"`))}));a.add(n);let s=Object.prototype.hasOwnProperty.call(i.values,n);if(r.schema===void 0){if(s)return yield*Jt(new Ad({machineId:e.id,boundary:`history`,state:n,cause:_e(Error(`Machine snapshot contains a value for structural state "${n}"`))}))}else{if(!s)return yield*Jt(new Ad({machineId:e.id,boundary:`history`,state:n,cause:_e(Error(`Machine snapshot omits remembered value for "${n}"`))}));o.set(n,yield*$f(e,Af(r),i.values[n],{boundary:`history`,state:n}))}}if(!a.has(t.parent)||Object.keys(i.values).length!==o.size)return yield*Jt(new Ad({machineId:e.id,boundary:`history`,state:r,cause:_e(Error(`Machine snapshot contains incomplete history record "${r}"`))}));n.set(r,{mode:i.mode,parent:t.parent,active:a,values:o});try{gp(e,n.get(r))}catch(t){return yield*Jt(new Ad({machineId:e.id,boundary:`history`,state:r,cause:_e(t)}))}}return n}),yp=(e,t)=>{let n={};for(let[r,i]of t){let t=Array.from(i.active).sort((t,n)=>Op(e,t,n));n[r]={mode:i.mode,active:t,values:Object.fromEntries(i.values)}}return n},bp=(e,t)=>({...e,machineReferences:{self:t.self,parent:t.parent}}),xp=e=>e.machineReferences,Sp=new WeakMap,Cp=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),wp=(e,t)=>e!==t&&(t===``||e.startsWith(`${t}.`)),Tp=(e,t)=>e===t||wp(e,t),Ep=(e,t)=>{let n=Sp.get(e.stateNodes);n===void 0&&(n=new Map,Sp.set(e.stateNodes,n));let r=n.get(t);if(r!==void 0)return r;let i=[],a=t;for(;a!==void 0;)i.unshift(a),a=$(e,a).parent;return n.set(t,i),i},Dp=(e,t)=>Ep(e,t).length,Op=(e,t,n)=>$(e,t).order-$(e,n).order,kp=(e,t,n)=>$(e,n).children.some(e=>t.active.has(e)),Ap=(e,t)=>{let n=Array.from(t.active).filter(n=>!kp(e,t,n)).sort((t,n)=>Op(e,t,n));if(n.length===0)throw Error(`Machine expected an active leaf state`);return n},jp=(e,t)=>Ap(e,t)[0],Mp=(e,t,n)=>{let r=Ap(e,t).filter(e=>Tp(e,n));if(r.length===0)throw Error(`Machine expected state "${n}" to have an active leaf state`);return r[0]},Np=(e,t)=>{for(let n of t.active)if($(e,n).parent===void 0)return n;throw Error(`Machine expected an active root state`)},Pp=(e,t,n)=>{let r={},i=Ep(e,n);for(let e=0;e<i.length-1;e++){let n=i[e];t.values.has(n)&&(r[n]=t.values.get(n))}return r},Fp=(e,t,n)=>{let r=$(e,n).parent;return r===void 0?void 0:t.values.get(r)},Ip=(e,t)=>{let n=r=>t.active.has(r)?[r,...$(e,r).children.flatMap(n)]:[];return e.stateNodes.roots.flatMap(n)},Lp=(e,t,n)=>{let r=$(e,n),i={path:n,value:t.values.get(n)};if(r.type===`compound`){let a=r.children.find(e=>t.active.has(e));if(a===void 0)throw Error(`Machine expected compound state "${n}" to have an active child`);i.state=Lp(e,t,a)}if(r.type===`parallel`){let a={};for(let i of r.children){if(!t.active.has(i))throw Error(`Machine expected parallel state "${n}" to have active child region "${i}"`);let r=$(e,i);a[r.key]=Lp(e,t,i)}i.states=a}return i},Rp=(e,t)=>{let n=Lp(e,t,Np(e,t)),r=Array.from(t.outputs).map(([e,t])=>({path:e,output:t}));return r.length>0&&(n.completed=r),t.history.size>0&&Object.assign(n,{history:yp(e,t.history)}),n},zp=(e,t,n)=>{let r=Lp(e,t,n);return t.history.size>0&&Object.assign(r,{history:yp(e,t.history)}),r},Bp=(e,t,n)=>{if(!K(n,`state`)||!Of(n.state))throw Error(`Machine expected compound snapshot "${t.path}" to include an active child state`);let r=$(e,String(n.state.path));if(r.parent!==t.path)throw Error(`Machine expected snapshot "${r.path}" to be a child of "${t.path}"`);return n.state},Vp=(e,t)=>{if(!K(t,`states`)||typeof t.states!=`object`||t.states===null)throw Error(`Machine expected parallel snapshot "${e.path}" to include active child regions`);return t.states},Hp=(e,t,n,r)=>{let i=$(e,n),a=r[i.key];if(!Cp(r,i.key)||!Of(a))throw Error(`Machine expected parallel snapshot "${t.path}" to include region "${i.key}"`);let o=$(e,String(a.path));if(o.path!==i.path)throw Error(`Machine expected snapshot "${o.path}" to be region "${i.path}"`);return a},Up=(e,t)=>{let n=new Set,r=new Map,i=t.completed,a=t=>{let i=$(e,String(t.path));if(n.add(i.path),i.schema===void 0){if(t.value!==void 0)throw Error(`Machine structural snapshot "${i.path}" cannot contain a value`)}else r.set(i.path,pp(e,i,t.value));if(i.type===`compound`&&a(Bp(e,i,t)),i.type===`parallel`){let n=Vp(i,t);for(let t of i.children)a(Hp(e,i,t,n))}};a(t);let o=new Map;if(i!==void 0)for(let{output:e,path:t}of i)n.has(t)&&o.set(t,e);return{active:n,values:r,outputs:o,history:_p(e,t)}},Wp=(e,t)=>Up(e,t),Gp=(e,t)=>{try{return Up(e,t)}catch(t){throw t instanceof Ad?t:new Ad({machineId:e.id,boundary:`configuration`,cause:_e(t)})}},Kp=an(function*(e,t){let n=new Set,r=new Map,i=t.completed,a=an(function*(t){let i=$(e,String(t.path));if(n.add(i.path),i.schema===void 0){if(t.value!==void 0)throw Error(`Machine structural snapshot "${i.path}" cannot contain a value`)}else r.set(i.path,yield*fp(e,i,t.value));if(i.type===`compound`&&(yield*a(Bp(e,i,t))),i.type===`parallel`){let n=Vp(i,t);for(let t of i.children)yield*a(Hp(e,i,t,n))}});yield*a(t);let o=new Map;if(i!==void 0)for(let{output:e,path:t}of i)n.has(t)&&o.set(t,e);return{active:n,values:r,outputs:o,history:yield*vp(e,t)}}),qp=(e,t)=>Kp(e,t).pipe(Je(t=>{if(Nt(t))return fr(r(t,t=>t instanceof Ad?t:new Ad({machineId:e.id,boundary:`configuration`,cause:br(t)})));let n=fe(t);return mt(n)&&n.value instanceof Ad?Jt(n.value):Jt(new Ad({machineId:e.id,boundary:`configuration`,cause:t}))})),Jp=(e,t,n,r)=>{if(r.length===0)return n;let i=new Set(r),a=new Map(n.history);for(let n of e.stateNodes.byPath.values()){if(n.type!==`history`||n.parent===void 0||!i.has(n.parent))continue;let r=n.history===`deep`?`deep`:`shallow`,o=new Set;for(let r of Ep(e,n.parent))t.active.has(r)&&o.add(r);for(let i of t.active)(i===n.parent||r===`deep`&&wp(i,n.parent)||r===`shallow`&&$(e,i).parent===n.parent)&&o.add(i);let s=new Map;for(let e of o)t.values.has(e)&&s.set(e,t.values.get(e));a.set(n.path,{mode:r,parent:n.parent,active:o,values:s})}return{active:n.active,values:n.values,outputs:n.outputs,history:a}},Yp=(e,t)=>e.history.get(t),Xp=(e,t,n)=>{let r=new Set(n.active),i=new Map(n.values),a=new Map,o=Ep(e,n.parent),s=new Set(o);for(let c of o){let o=$(e,c);if(o.type===`parallel`){for(let e of o.children)if(!(s.has(e)||n.active.has(e)||!t.active.has(e)))for(let n of t.active)Tp(n,e)&&(r.add(n),t.values.has(n)&&i.set(n,t.values.get(n)),t.outputs.has(n)&&a.set(n,t.outputs.get(n)))}}return{active:r,values:i,outputs:a,history:t.history}};an(function*(e,t,n,r,i){let a=$(e,n),o=new Set,s=new Map,c=new Map,l=Ep(e,a.path),u=new Set(l);for(let n of l){let c=$(e,n);if(o.add(n),c.schema===void 0){if((n===a.path?r:i!==void 0&&Cp(i,n)?i[n]:void 0)!==void 0)throw Error(`Machine structural target "${n}" cannot contain a value`)}else if(n===a.path)s.set(n,yield*fp(e,c,r));else if(i!==void 0&&Cp(i,n))s.set(n,yield*fp(e,c,i[n]));else if(t.values.has(n))s.set(n,t.values.get(n));else throw Error(`Machine target "${a.path}" requires a value for ancestor state "${n}"`)}for(let n of l){let r=$(e,n);if(r.type===`parallel`){for(let e of r.children)if(!u.has(e)&&t.active.has(e))for(let n of t.active)Tp(n,e)&&(o.add(n),t.values.has(n)&&s.set(n,t.values.get(n)),t.outputs.has(n)&&c.set(n,t.outputs.get(n)))}}if(a.type===`compound`||a.type===`parallel`)throw Error(`Machine target "${a.path}" must include an active child state`);return{active:o,values:s,outputs:c,history:t.history}}),an(function*(e,t,n,r){let i=yield*Kp(e,n),a=new Set(i.active),o=new Map(i.values),s=new Map(i.outputs),c=Ep(e,String(n.path)),l=new Set(c);for(let i of c.slice(0,-1)){let s=$(e,i);if(a.add(i),s.schema===void 0){if(r!==void 0&&Cp(r,i))throw Error(`Machine structural target "${i}" cannot contain a value`)}else if(r!==void 0&&Cp(r,i))o.set(i,yield*fp(e,s,r[i]));else if(t.values.has(i))o.set(i,t.values.get(i));else throw Error(`Machine target "${n.path}" requires a value for ancestor state "${i}"`)}for(let n of c.slice(0,-1)){let i=$(e,n);if(i.type===`parallel`){for(let n of i.children)if(!l.has(n)){if(t.active.has(n))for(let e of t.active)Tp(e,n)&&(a.add(e),t.values.has(e)&&o.set(e,t.values.get(e)),t.outputs.has(e)&&s.set(e,t.outputs.get(e)));else if(r!==void 0&&Cp(r,n))for(let[t,i]of Object.entries(r)){if(!Tp(t,n))continue;let r=$(e,t);if(a.add(t),r.schema===void 0)throw Error(`Machine structural target "${t}" cannot contain a value`);o.set(t,yield*fp(e,r,i))}}}}return{active:a,values:o,outputs:s,history:new Map([...t.history,...i.history])}});var Zp=(e,t,n,r,i,a=!1)=>{let o=$(e,n),s=new Set,c=new Map,l=new Map,u=Ep(e,o.path),d=new Set(u);for(let n of u){let a=$(e,n);if(s.add(n),a.schema===void 0){if((n===o.path?r:i!==void 0&&Cp(i,n)?i[n]:void 0)!==void 0)throw Error(`Machine structural target "${n}" cannot contain a value`)}else if(n===o.path)c.set(n,pp(e,a,r));else if(i!==void 0&&Cp(i,n))c.set(n,pp(e,a,i[n]));else if(t.values.has(n))c.set(n,t.values.get(n));else throw Error(`Machine target "${o.path}" requires a value for ancestor state "${n}"`)}for(let n of u){let r=$(e,n);if(r.type===`parallel`&&n!==o.path){for(let e of r.children)if(!d.has(e)&&t.active.has(e))for(let n of t.active)Tp(n,e)&&(s.add(n),t.values.has(n)&&c.set(n,t.values.get(n)),t.outputs.has(n)&&l.set(n,t.outputs.get(n)))}}if(!a&&(o.type===`compound`||o.type===`parallel`))throw Error(`Machine target "${o.path}" must include an active child state`);return{active:s,values:c,outputs:l,history:t.history}},Qp=(e,t,n)=>{let r=Zp(e,t,n.path,n.value,n.values,!0);if(n.children===void 0)return r;let i=new Set(r.active),a=new Map(r.values);for(let[t,r]of n.children){let n=$(e,t);i.add(t),n.schema!==void 0&&a.set(t,pp(e,n,r))}return{...r,active:i,values:a}},$p=(e,t,n,r)=>{let i=Up(e,n),a=new Set(i.active),o=new Map(i.values),s=new Map(i.outputs),c=Ep(e,String(n.path)),l=new Set(c);for(let i of c.slice(0,-1)){let s=$(e,i);if(a.add(i),s.schema===void 0){if(r!==void 0&&Cp(r,i))throw Error(`Machine structural target "${i}" cannot contain a value`)}else if(r!==void 0&&Cp(r,i))o.set(i,pp(e,s,r[i]));else if(t.values.has(i))o.set(i,t.values.get(i));else throw Error(`Machine target "${n.path}" requires a value for ancestor state "${i}"`)}for(let n of c.slice(0,-1)){let i=$(e,n);if(i.type===`parallel`){for(let n of i.children)if(!l.has(n)){if(t.active.has(n))for(let e of t.active)Tp(e,n)&&(a.add(e),t.values.has(e)&&o.set(e,t.values.get(e)),t.outputs.has(e)&&s.set(e,t.outputs.get(e)));else if(r!==void 0&&Cp(r,n))for(let[t,i]of Object.entries(r)){if(!Tp(t,n))continue;let r=$(e,t);if(a.add(t),r.schema===void 0)throw Error(`Machine structural target "${t}" cannot contain a value`);o.set(t,pp(e,r,i))}}}}return{active:a,values:o,outputs:s,history:new Map([...t.history,...i.history])}},em=(e,t,n)=>{if(Tf(n)){let r=n[Bd];if(r!==void 0){if(String(r.path)!==String(n.path))throw Error(`Machine expected target snapshot path to be "${n.path}"`);return $p(e,t,r,n.values)}return Zp(e,t,n.path,n.value,n.values)}if(Of(n)){let r=Gp(e,n);return{...r,history:new Map([...t.history,...r.history])}}throw Error(`Machine expected transition target to be a snapshot or target builder result`)},tm=(e,t)=>Rd(e).handlers[t],nm=(e,t,n)=>$(e,n).children.find(e=>t.active.has(e)),rm=(e,t)=>$(e,t).type===`final`,im=(e,t)=>tm(e,t)?.onDone!==void 0,am=(e,t,n)=>{if(!t.active.has(n))return!1;let r=$(e,n);if(r.type===`compound`){let r=nm(e,t,n);return r!==void 0&&(n===``?!im(e,r)&&am(e,t,r):rm(e,r))}if(r.type===`parallel`){for(let n of r.children)if(!am(e,t,n))return!1;return!0}return rm(e,n)},om=(e,t)=>{let n=Np(e,t);return am(e,t,n)&&!im(e,n)},sm=(e,t,n)=>e.has(t)?{path:t,output:e.get(t),isNew:!1}:(e.set(t,n),{path:t,output:n,isNew:!0}),cm=an(function*(e,t,n,r,i){let a=$(e,n),o=tm(e,n)?.output?.({state:t.values.get(n),containingState:Fp(e,t,n),ancestors:Pp(e,t,n),event:r,outputs:i});return yield*mp(e,a,o)}),lm=an(function*(e,t,n,r,i,a){if(!t.active.has(n))return;if(i.has(n))return{path:n,output:i.get(n),isNew:!1};let o=$(e,n);if(o.type===`compound`){let o=nm(e,t,n);if(o===void 0||(n===``?im(e,o):!rm(e,o)))return;let s=yield*lm(e,t,o,r,i,a);if(s===void 0)return;let c=sm(i,n,s.output);return c.isNew&&a.push(c),c}if(o.type===`parallel`){let s={},c=!0;for(let n of o.children){let o=yield*lm(e,t,n,r,i,a);o===void 0?c=!1:s[$(e,n).key]=o.output}if(!c)return;let l=sm(i,n,yield*cm(e,t,n,r,s));return l.isNew&&a.push(l),l}if(!rm(e,n))return;let s=sm(i,n,yield*cm(e,t,n,r));return s.isNew&&a.push(s),s}),um=an(function*(e,t,n){let r=new Map(t.outputs),i=[],a={active:t.active,values:t.values,outputs:r,history:t.history};for(let t of Array.from(a.active).sort((t,n)=>{let r=Dp(e,n)-Dp(e,t);return r===0?Op(e,t,n):r}))yield*lm(e,a,t,n,r,i);return{configuration:a,completions:i}}),dm=(e,t,n,r,i)=>{let a=$(e,n),o=tm(e,n)?.output?.({state:t.values.get(n),containingState:Fp(e,t,n),ancestors:Pp(e,t,n),event:r,outputs:i});return hp(e,a,o)},fm=(e,t,n,r,i,a)=>{if(!t.active.has(n))return;if(i.has(n))return{path:n,output:i.get(n),isNew:!1};let o=$(e,n);if(o.type===`compound`){let o=nm(e,t,n);if(o===void 0||(n===``?im(e,o):!rm(e,o)))return;let s=fm(e,t,o,r,i,a);if(s===void 0)return;let c=sm(i,n,s.output);return c.isNew&&a.push(c),c}if(o.type===`parallel`){let s={},c=!0;for(let n of o.children){let o=fm(e,t,n,r,i,a);o===void 0?c=!1:s[$(e,n).key]=o.output}if(!c)return;let l=sm(i,n,dm(e,t,n,r,s));return l.isNew&&a.push(l),l}if(!rm(e,n))return;let s=sm(i,n,dm(e,t,n,r));return s.isNew&&a.push(s),s},pm=(e,t,n)=>{let r=new Map(t.outputs),i=[],a={active:t.active,values:t.values,outputs:r,history:t.history};for(let t of Array.from(a.active).sort((t,n)=>{let r=Dp(e,n)-Dp(e,t);return r===0?Op(e,t,n):r}))fm(e,a,t,n,r,i);return{configuration:a,completions:i}},mm=e=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Machine construction must be an object`);return e},hm=(e,t)=>{if(t.decoded!==void 0&&typeof t.decoded!=`boolean`)throw Error(`Machine decoded construction flag must be a boolean`);if(e.schema===void 0){if(Object.hasOwn(t,`data`)||Object.hasOwn(t,`decoded`))throw Error(`Machine structural state "${e.path}" cannot construct data`)}else{if(t.decoded===!0){if(!Object.hasOwn(t,`data`))throw Error(`Machine decoded construction requires data`);return t.data}return Ef(Object.hasOwn(t,`data`)?t.data:{})}},gm=(e,t,n={},r)=>{let i=e.byPath.get(t);if(i?.type===`atomic`||i?.type===`final`){let e=mm(n);if(Reflect.ownKeys(e).some(e=>e!==`data`&&e!==`decoded`))throw Error(`Machine leaf construction accepts only data and decoded`);return wf(t,hm(i,e))}let a=new Map,o=(t,n)=>{let i=mm(n);if(Reflect.ownKeys(i).some(e=>e!==`data`&&e!==`decoded`&&e!==`states`))throw Error(`Machine state construction accepts only data, decoded, and states`);let s=e.byPath.get(t);if(s===void 0||s.type===`history`)throw Error(`Machine invalid construction state "${t}"`);let c=hm(s,i);if(Object.hasOwn(i,`states`)){if(s.type!==`compound`&&s.type!==`parallel`)throw Error(`Machine state "${t}" has no child construction`);let n=mm(i.states),c=Reflect.ownKeys(n),l=s.children.filter(t=>e.byPath.get(t)?.type!==`history`);if(s.type===`compound`?c.length!==1:c.length!==l.length&&(c.length!==1||r===void 0||r!==t&&!r.startsWith(`${t}.`)))throw Error(`Machine explicit states for "${t}" must select ${s.type===`compound`?`one child`:`every region`}`);for(let r of c){let i=t===``?String(r):`${t}.${String(r)}`;if(typeof r!=`string`||e.byPath.get(i)?.parent!==t||e.byPath.get(i)?.type===`history`)throw Error(`Machine unknown child "${String(r)}"`);a.set(i,o(i,n[r]))}}return c},s=o(t,n),c=new Map(a);c.set(t,s);let l=t,u=mm(n);for(;u.states!==void 0;){let t=e.byPath.get(l),n=mm(u.states),i=Object.keys(n);if(i.length!==1||t.type===`parallel`&&(r===void 0||r!==l&&!r.startsWith(`${l}.`)))break;let a=i[0];l=l===``?a:`${l}.${a}`,u=mm(n[a])}let d=e.byPath.get(l),f=c.get(l),p=Object.fromEntries([...c].filter(([e,t])=>t!==void 0&&e!==l&&!e.startsWith(`${l}.`)));if(d.type===`choice`)return _f(l,d.parent??``,p);if(d.type===`atomic`||d.type===`final`)return wf(l,f,{values:p});let m=new Map([...a].filter(([e])=>e.startsWith(`${l}.`)));return{...hf(l,f,p),...m.size===0?{}:{children:m}}},_m=(e,t,n)=>{let r=mm(n);if(Reflect.ownKeys(r).some(e=>e!==`data`&&e!==`decoded`))throw Error(`Machine update construction accepts only data and decoded`);let i=e.byPath.get(t);if(i?.schema===void 0)throw Error(`Machine update requires a valued state`);return ef(t,hm(i,r))},vm=(e,t,n=``)=>{let r=mm(t),i=e.byPath.get(n);gm(e,n,r);let a=hm(i,r);if(i.type===`choice`)return _f(n,i.parent);if(i.type===`atomic`||i.type===`final`)return{path:n,value:a};if(r.states===void 0)throw Error(`Machine history fallback requires a complete explicit tree`);let o=mm(r.states),s=Object.fromEntries(Object.entries(o).map(([t,r])=>[t,vm(e,r,n===``?t:`${n}.${t}`)]));return i.type===`parallel`?{path:n,value:a,states:s}:{path:n,value:a,state:Object.values(s)[0]}},ym=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(t);return e},bm=`root`,xm=e=>{let t=new Map,n=(e,r)=>{let i=!g(e)&&`type`in e?e.type:void 0;if(t.set(r,i===`history`||i===`choice`?i:`state`),!g(e)&&`states`in e)for(let[t,i]of Object.entries(e.states))n(i,r===``?t:`${r}.${t}`)};if(n(e.node,``),t.has(`root`))throw Error(`Machine top-level state name "${bm}" is reserved for the root`);return t},Sm=(e,t)=>{let n=xm(e),r=t.input!==void 0,i=new Map;for(let e of[`effects`,`streams`,`timers`,`logic`,`children`])if(t[e]!==void 0)for(let[n,r]of Object.entries(ym(t[e],`Machine ${e} must be a source map`))){if(i.has(n))throw Error(`Machine source name "${n}" is registered more than once`);i.set(n,Object.freeze({kind:e,value:r}))}let a=new Map;if(t.branches!==void 0)for(let[o,s]of Object.entries(ym(t.branches,`Machine branches must be a map`))){let t=ym(s,`Machine branches "${o}" must be a branch record`);for(let e of Reflect.ownKeys(t)){if(typeof e!=`string`)throw Error(`Machine branches cannot use symbol keys`);if(e.length===0||String(Number(e))===e)throw Error(`Machine branches require non-index string branch keys`)}let c=Object.entries(t);if(c.length===0)throw Error(`Machine branches "${o}" requires a branch`);a.set(o,Object.freeze(Object.fromEntries(c.map(([t,s])=>{let c={...ym(s,`Machine branch "${o}.${t}" must be a declaration`)};for(let e of Reflect.ownKeys(c))if(typeof e!=`string`||![`target`,`update`,`history`,`none`,`initialize`,`title`].includes(e))throw Error(`Machine branch "${o}.${t}" contains an unknown declaration field`);if(c.initialize!==void 0&&c.initialize!==!0)throw Error(`Machine branch "${o}.${t}" declares initialize: true; its resolver supplies input`);if(c.title!==void 0&&(typeof c.title!=`string`||c.title.length===0))throw Error(`Machine branch title must be a non-empty string`);return wm({root:e,input:r,paths:n,sources:i,branches:a},c),[t,Object.freeze(c)]}))))}return{root:e,input:r,paths:n,sources:i,branches:a}},Cm=(e,t)=>{let n=e===`root`?``:typeof e==`string`&&e!==``?e:void 0,r=n===void 0?void 0:t.paths.get(n);if(n===void 0||r===void 0)throw Error(`Machine target ${String(e)} is not a declared state path`);return{path:n,kind:r}},wm=(e,t)=>{let n=[`target`,`history`,`none`,`initialize`].filter(e=>t[e]!==void 0);if(n.length===0&&t.update!==void 0){let n=Cm(t.update,e);if(n.kind!==`state`)throw Error(`Machine update requires an active state reference`);return Zd(`update`,n.path,`branch`)}if(n.length!==1)throw Error(`Machine transition must declare exactly one destination operation`);let r=n[0];if(r===`none`){if(t.none!==!0||t.update!==void 0)throw Error(`Machine targetless transition requires none: true`);return Qd}if(r===`initialize`){if(t.update!==void 0)throw Error(`Machine initialize cannot update a retained owner`);return Zd(`state`,``,`branch`)}let i=Cm(t[r],e);if(r===`target`&&i.path===``)throw Error(`Machine root is not a destination; use initialize to reconstruct it from machine input`);if(r===`history`!=(i.kind===`history`))throw Error(`Machine history references require a history transition`);let a=t.update===void 0?void 0:Cm(t.update,e).path;if(a!==void 0&&r!==`target`)throw Error(`Machine owner updates require an ordinary destination`);return Zd(i.kind,i.path,r===`history`?`full`:`branch`,a)},Tm=(e,t,n,r)=>{let i=ym(t,`Machine invocation for "${n}" must be an object`),a=typeof i.src==`string`?e.sources.get(i.src):void 0;if(a===void 0)throw Error(`Machine invocation for "${n}" names an unknown source`);let{src:o,input:s,...c}=i,l=typeof s==`function`?e=>s(r(e)):s;if(a.kind===`children`)return{...c,child:a.value,...l===void 0?{}:{input:l}};let u=typeof a.value==`function`&&!(a.kind===`effects`&&er(a.value))&&!(a.kind===`streams`&&Zt(a.value));if(u!==(typeof l==`function`))throw Error(`Machine invocation "${o}" requires input exactly when its source takes an argument`);let d=u?e=>a.value(l(e)):()=>a.value,f={effects:`effect`,streams:`stream`,timers:`after`,logic:`logic`}[a.kind];return{...c,sourceName:o,id:c.id??o,[f]:!u&&(a.kind===`timers`||a.kind===`logic`)?a.value:d}},Em=Symbol(`effect/Machine/InitialEvent`),Dm=Symbol(`effect/Machine/SnapshotBuilderState`),Om=Symbol(`effect/Machine/ChildMachineLogic`),km=new WeakSet,Am=e=>km.has(e),jm=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Machine ${t} must be an object`);return e},Mm=e=>typeof e==`function`?e:()=>e,Nm=e=>{if(typeof e==`object`&&e&&K(e,`decoded`)&&e.decoded===!0&&K(e,`data`)){let t=jm(e,`decoded construction`);if(Reflect.ownKeys(t).some(e=>e!==`decoded`&&e!==`data`))throw Error(`Machine decoded construction accepts only decoded and data`);return Mm(t.data)}let t=Mm(e);return n=>Ef(e===void 0?{}:t(n))},Pm=e=>{if(e.decoded!==void 0&&typeof e.decoded!=`boolean`)throw Error(`Machine decoded construction flag must be a boolean`);if(e.decoded===!0){if(!K(e,`data`))throw Error(`Machine decoded construction requires data`);return Mm(e.data)}let t=Mm(e.data);return n=>Ef(K(e,`data`)?t(n):{})},Fm=(e,t)=>{let n=(e,t,r)=>{if(K(t,`initialize`))throw Error(`Machine child construction belongs in initial declarations`);if(r!==``&&K(t,`root`))throw Error(`Machine root construction belongs at the root handler`);let{initial:i,root:a,states:o,...s}=t;if(g(e)||!(`states`in e)){if(i!==void 0)throw Error(`Machine state "${r}" cannot declare initial children`);if(o!==void 0)throw Error(`Machine state "${r}" has no children`);return{node:e,handlers:s}}let c=o===void 0?{}:jm(o,`child handlers`);for(let t of Object.keys(c))if(!Object.prototype.hasOwnProperty.call(e.states,t))throw Error(`Machine unknown child "${t}"`);let l=Object.create(null),u=Object.create(null),d=Object.create(null),f=e.type===`parallel`,p;if(f){let t=i===void 0?{}:jm(i,`parallel initial regions`);for(let[n,r]of Object.entries(t)){let t=e.states[n];if(t===void 0||!g(t)&&(t.type===`history`||t.type===`choice`))throw Error(`Machine invalid initial region "${n}"`);if(!g(t)&&(!(`schema`in t)||t.schema===void 0))throw Error(`Machine schema-less region "${n}" cannot construct data`);d[n]=Nm(r)}}else{let t=jm(i,`initial edge for "${r}"`);if(Reflect.ownKeys(t).some(e=>![`target`,`data`,`decoded`].includes(String(e))))throw Error(`Machine initial edge accepts only target, data, and decoded`);let n=r===``?``:`${r}.`,a=typeof t.target==`string`&&t.target.startsWith(n)?t.target.slice(n.length):void 0,o=a===void 0||!Object.hasOwn(e.states,a)?void 0:e.states[a],s=o===void 0||g(o)?`state`:o.type;if(a===void 0||o===void 0||s===`history`)throw Error(`Machine initial target must be a direct child of "${r===``?`root`:r}"`);if(p=a,s===`choice`&&(K(t,`data`)||K(t,`decoded`)))throw Error(`Machine choice initial edges cannot construct data`);let c=Pm(t),l=e.states[a];if(K(t,`data`)&&!g(l)&&(!(`schema`in l)||l.schema===void 0))throw Error(`Machine schema-less initial child "${a}" cannot construct data`);K(t,`data`)&&(d[a]=c)}for(let[t,i]of Object.entries(e.states)){let e=r===``?t:`${r}.${t}`,a=n(i,c[t]===void 0?{}:jm(c[t],`state handler`),e);l[t]=a.node,(g(i)||i.type!==`history`)&&(c[t]!==void 0||!g(i)&&`states`in i)&&(u[t]=a.handlers)}let m=Object.freeze({...e,states:Object.freeze(l),...f?{}:{initial:p}}),h=Object.entries(d),_=e=>{let t=typeof e.ancestors==`object`&&e.ancestors!==null?e.ancestors:{},n={...e,root:r===``?e.state:t[``]},i=Object.fromEntries(h.map(([e,t])=>[e,t(n)]));return{[Dm]:i}};return km.add(_),{node:m,handlers:{...s,...h.length===0?{}:{initialize:_},states:u}}};return n(e.node,t,``)},Im=(e,t)=>{let n=[`effect`,`stream`,`after`,`logic`,`child`].filter(t=>t in e);if(n.length!==1)throw Error(`Machine invocation for state "${t}" must define exactly one source`);if(n[0]!==`child`&&typeof e.id!=`string`)throw Error(`Machine invocation for state "${t}" requires a string id`);if((n[0]===`effect`||n[0]===`stream`)&&typeof e[n[0]]!=`function`)throw Error(`Machine invocation for state "${t}" requires a source callback`);return Object.freeze(e)},Lm=e=>`child`in e?e.child.id:e.id,Rm=(e,t)=>{let n=new Set;for(let r of e){let e=Lm(r);if(n.has(e))throw Error(`Machine invocations for state "${t}" must have distinct ids; "${e}" is declared twice`);n.add(e)}},zm=e=>e===void 0?[]:Array.isArray(e)?e:[e],Bm=e=>{let t=[],n=[],r=[];return{commands:t,raisedEvents:n,emittedEvents:r,enqueue:{raise:t=>{n.push(cp(e,t))},emit:t=>{r.push(up(e,t))},sendTo:(e,n)=>{t.push({_tag:`SendTo`,target:e,event:n})},stop:e=>{t.push({_tag:`Stop`,child:e})}}}},Vm=(e,t)=>{let n=e.stateNodes.byPath.get(t);if(n===void 0)throw Error(`Machine expected state path "${t}" to exist`);return n},Hm=e=>{let t={};return Object.defineProperty(t,"decoded",{value:e,enumerable:!1}),Object.defineProperty(t,"from",{value:(...t)=>e(Ef(t.length===0?{}:t[0])),enumerable:!1}),t},Um=e=>{let t={};return Object.defineProperty(t,Dm,{value:e,enumerable:!1}),t},Wm=(e,t,n)=>{let r=Um(n);for(let i of t.children){let a=Vm(e,i);a.schema===void 0||K(n,a.key)||(r[a.key]=Hm(r=>{let i=Object.assign({},n);return i[a.key]=r,Wm(e,t,i)}))}return r},Gm=(e,t)=>{let n=Vm(e,t);if(n.type===`parallel`)return Wm(e,n,{});if(n.type!==`compound`)throw Error(`Machine state "${t}" cannot initialize child states`);let r=Vm(e,n.initial);if(r.schema===void 0)throw Error(`Machine state "${t}" has no schema-valued initial child`);return Hm(e=>Um({[r.key]:e}))},Km=(e,t)=>{if(typeof t!=`object`||!t||!K(t,Dm))throw Error(`Machine initialize handler for "${e}" must return its builder result`);return t[Dm]},qm=Symbol(`effect/Machine/InvocationEvent`),Jm=(e,t,n)=>({[qm]:!0,path:e,id:t,type:`done`,output:n}),Ym=(e,t,n)=>({[qm]:!0,path:e,id:t,type:`element`,element:n}),Xm=(e,t,n)=>({[qm]:!0,path:e,id:t,type:`failure`,error:n}),Zm=(e,t,n)=>({[qm]:!0,path:e,id:t,type:`snapshot`,snapshot:n}),Qm=e=>typeof e==`object`&&!!e&&qm in e,$m=new WeakMap,eh=new WeakMap,th=(e,t)=>e.parent===void 0?{self:t.self}:{self:t.self,parent:t.parent},nh=(e,t)=>{let n=Object.create(e);return eh.set(n,th(e,t)),n},rh=(e,t)=>{let n=t.machineReferences;if(n!==void 0)return th(e,n);let r=eh.get(e);if(r!==void 0)return r;let i=$m.get(e);if(i!==void 0)return i;let a=th(e,{self:{id:e.id??`Machine`,sessionId:`Machine.plan`,send:()=>Jt(new Pd)},parent:void 0});return $m.set(e,a),a},ih=e=>{if(e!==void 0)return typeof e==`function`?{reenter:!1,declinable:!1,targets:void 0,transition:e,evaluate:void 0}:{reenter:e.reenter===!0,declinable:e.declinable===!0,targets:e.targets,transition:e.transition,evaluate:e.evaluate}},ah=(e,t,n)=>{let r=Bm(e);return t===void 0||t(n,r.enqueue),{commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents}},oh=(e,t,n,r)=>{let i=Bm(e),a=r===void 0?{result:t(n,i.enqueue),branchIndex:0,branchKey:void 0}:r(n,i.enqueue);return ff(a.result)?{declined:!0}:{declined:!1,state:lf(a.result)?void 0:a.result,branchIndex:a.branchIndex,branchKey:a.branchKey,commands:i.commands,raisedEvents:i.raisedEvents,emittedEvents:i.emittedEvents}},sh=(e,t,n)=>{let r=Bm(e);return{value:t(n,r.enqueue),commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents}},ch=(e,t,n,r)=>{let i=new Set(t.active),a=new Map(t.values),o=[],s=[],c=[],l=[],u=!0;for(;u;){u=!1;for(let d of Array.from(i).sort((t,n)=>Op(e,t,n))){let f=$(e,d);if(f.type===`compound`&&!f.children.some(e=>i.has(e))){if(f.initial===void 0)throw Error(`Machine shallow history expected compound state "${d}" to have an initial child`);let p=$(e,f.initial),m={active:i,values:a,outputs:t.outputs,history:t.history,machineReferences:t.machineReferences};if(p.type===`choice`){let t=Rh(e,m,_f(p.path,d,Object.fromEntries(a)),n),r=m;for(let i of[t.target,...t.additionalTargets]){if(i===void 0)throw Error(`Machine initial choice "${p.path}" must resolve to an active state target`);let t=gf(i)?uh(e,r,i,n):mf(i)?dh(e,r,i,n):void 0;r=em(e,r,t?.target??i),t!==void 0&&(o.push(...t.commands),s.push(...t.raisedEvents),c.push(...t.emittedEvents),l.push(...t.transitions))}i.clear(),a.clear();for(let e of r.active)i.add(e);for(let[e,t]of r.values)a.set(e,t);o.push(...t.commands),s.push(...t.raisedEvents),c.push(...t.emittedEvents),l.push(...t.transitions),u=!0;continue}if(i.add(p.path),p.schema!==void 0){let t=Rd(e).handlers[d]?.initialize;if(t===void 0){a.set(p.path,pp(e,p,Ef({}))),u=!0;continue}let i=sh(e,t,{...rh(e,m),state:m.values.get(d),containingState:Fp(e,m,d),ancestors:Pp(e,m,d),event:n,...d===``&&r!==void 0?{input:r.value}:{},...Am(t)?{}:{builder:Gm(e,d)}}),l=Km(d,i.value);a.set(p.path,pp(e,p,l[p.key])),o.push(...i.commands),s.push(...i.raisedEvents),c.push(...i.emittedEvents)}u=!0}if(f.type===`parallel`){let l=f.children.filter(e=>!i.has(e));if(l.length>0){let f=l.filter(t=>$(e,t).schema!==void 0),p={active:i,values:a,outputs:t.outputs,history:t.history,machineReferences:t.machineReferences},m=f.length===0?void 0:Rd(e).handlers[d]?.initialize,h=m===void 0?void 0:sh(e,m,{...rh(e,p),state:p.values.get(d),containingState:Fp(e,p,d),ancestors:Pp(e,p,d),event:n,...d===``&&r!==void 0?{input:r.value}:{},...Am(m)?{}:{builder:Gm(e,d)}}),g=h===void 0?void 0:Km(d,h.value);for(let t of l){let n=$(e,t);if(i.add(n.path),n.schema!==void 0){if(h===void 0){a.set(n.path,pp(e,n,Ef({})));continue}if(g===void 0||!Object.prototype.hasOwnProperty.call(g,n.key)){if(m!==void 0&&Am(m)){a.set(n.path,pp(e,n,Ef({})));continue}throw Error(`Machine parallel state initializer for "${d}" must return region "${n.key}"`)}a.set(n.path,pp(e,n,g[n.key]))}}h!==void 0&&(o.push(...h.commands),s.push(...h.raisedEvents),c.push(...h.emittedEvents)),u=!0}}}}return{configuration:{active:i,values:a,outputs:new Map,history:t.history},commands:o,raisedEvents:s,emittedEvents:c,transitions:l}};function lh(e,t,n,r){let i=Qp(e,t,n);if(n.children===void 0||![...n.children.keys()].some(t=>$(e,t).type===`choice`))return ch(e,i,r,n.input);let a=[],o=[],s=[],c=[];for(let t of n.children?.keys()??[]){let n=$(e,t);if(n.type!==`choice`)continue;let l=Rh(e,i,_f(t,n.parent),r);for(let t of[l.target,...l.additionalTargets]){let n=gf(t)?uh(e,i,t,r):mf(t)?dh(e,i,t,r):void 0;i=em(e,i,n?.target??t),n!==void 0&&(a.push(...n.commands),o.push(...n.raisedEvents),s.push(...n.emittedEvents),c.push(...n.transitions))}a.push(...l.commands),o.push(...l.raisedEvents),s.push(...l.emittedEvents),c.push(...l.transitions)}let l=ch(e,i,r,n.input);return c.length===0?l:{...l,commands:[...a,...l.commands],raisedEvents:[...o,...l.raisedEvents],emittedEvents:[...s,...l.emittedEvents],transitions:[...c,...l.transitions]}}function uh(e,t,n,r){let i=lh(e,t,n,r),a=zp(e,i.configuration,n.path);return{target:wf(n.path,a.value,{snapshot:a,values:n.values}),commands:i.commands,raisedEvents:i.raisedEvents,emittedEvents:i.emittedEvents,transitions:i.transitions}}function dh(e,t,n,r){let i=$(e,n.path);if(i.type!==`history`||i.parent!==n.parent)throw Error(`Machine expected history target "${n.path}" to resolve to its declared parent`);let a=Yp(t,n.path);if(a!==void 0){let i=ch(e,Xp(e,t,a),r),o=zp(e,i.configuration,n.parent),s=Object.fromEntries(i.configuration.values);return n.parent!==``&&t.active.has(``)&&delete s[``],{target:wf(n.parent,o.value,{snapshot:o,values:s}),commands:i.commands,raisedEvents:i.raisedEvents,emittedEvents:i.emittedEvents,transitions:i.transitions}}let o=i.key,s=Rd(e).handlers[n.parent]?.history?.[o]?.default;if(s===void 0)throw Error(`Machine history state "${n.path}" requires a default implementation`);let c=oh(e,s,{event:r,target:t=>vm(e.stateNodes,t),owner:n.parent});if(c.state===void 0||mf(c.state)||!Of(c.state))throw Error(`Machine history default for "${n.path}" must return a complete snapshot containing its owner`);let l=Ih(c.state)===void 0?void 0:Rh(e,{active:new Set,values:new Map,outputs:new Map,history:t.history},c.state,r),u=l===void 0?Gp(e,c.state):em(e,{active:new Set,values:new Map,outputs:new Map,history:t.history},l.target);for(let t of l?.additionalTargets??[])u=em(e,u,t);if(!u.active.has(n.parent))throw Error(`Machine history default for "${n.path}" returned a configuration that does not contain owner state "${n.parent}"`);let d=zp(e,u,n.parent),f=Object.fromEntries(u.values);return n.parent!==``&&t.active.has(``)&&delete f[``],{target:wf(n.parent,d.value,{snapshot:d,values:f}),commands:[...c.commands,...l?.commands??[]],raisedEvents:[...c.raisedEvents,...l?.raisedEvents??[]],emittedEvents:[...c.emittedEvents,...l?.emittedEvents??[]],transitions:l?.transitions??[]}}var fh=(e,t)=>{if(!t.transition.declinable)return t;let n=oh(e,t.transition.transition,t.context,t.transition.evaluate);return n.declined?void 0:{...t,collected:n}},ph=(e,t)=>[...Ep(e,t)].reverse(),mh=(e,t,n)=>{let r=Ep(e,t),i=Ep(e,n),a,o=Math.min(r.length,i.length);for(let e=0;e<o&&r[e]===i[e];e++)a=r[e];return a},hh=(e,t)=>{if(e!==void 0&&t!==void 0)return e===t||wp(e,t)?t:e},gh=(e,t,n)=>yh(e,Array.from(t.active).filter(e=>n===void 0||wp(e,n))),_h=(e,t,n)=>bh(e,Array.from(t.active).filter(e=>n===void 0||wp(e,n))),vh=(e,t)=>e.active.size===t.active.size&&Array.from(e.active).every(e=>t.active.has(e)),yh=(e,t)=>Array.from(new Set(t)).sort((t,n)=>{let r=Ep(e,n).length-Ep(e,t).length;return r===0?$(e,n).order-$(e,t).order:r}),bh=(e,t)=>Array.from(new Set(t)).sort((t,n)=>{let r=Ep(e,t).length-Ep(e,n).length;return r===0?Op(e,t,n):r}),xh=(e,t,n,r)=>({...rh(e,t),state:t.values.get(n),containingState:Fp(e,t,n),ancestors:Pp(e,t,n),event:r}),Sh=(e,t,n,r,i)=>({...rh(e,t),state:t.values.get(n),containingState:Fp(e,t,n),ancestors:Pp(e,t,n),event:r,snapshot:i}),Ch=(e,t,n,r,i,a)=>({...rh(e,t),state:t.values.get(n),containingState:Fp(e,t,n),ancestors:Pp(e,t,n),event:r,output:i,snapshot:a}),wh=(e,t,n,r,i)=>{let a=[],o=[],s=[];for(let c of n){let n=ah(e,Rd(e).handlers[c]?.[i],xh(e,t,c,r));a.push(...n.commands),o.push(...n.raisedEvents),s.push(...n.emittedEvents)}return{commands:a,emittedEvents:s,raisedEvents:o}},Th=(e,t,n)=>{let r=[],i=new Set,a=new Map,o,s=()=>o??=Rp(e,t);for(let o of Ap(e,t))for(let c of ph(e,o)){let l=ih(Rd(e).handlers[c]?.always);if(l!==void 0){let u=a.get(c);if(a.has(c)||(u=fh(e,{sourcePath:c,leafPath:o,trigger:{type:`always`},transition:l,context:{...rh(e,t),state:t.values.get(c),containingState:Fp(e,t,c),ancestors:Pp(e,t,c),event:n,snapshot:s()}}),a.set(c,u)),u===void 0)continue;i.has(c)||(i.add(c),r.push(u));break}}return r},Eh=(e,t,n,r)=>{let i=[],a=new Set,o,s=()=>o??=Rp(e,t);for(let o of r){let r=ih(Rd(e).handlers[o.path]?.onDone);if(r!==void 0&&!a.has(o.path)){a.add(o.path);let c=fh(e,{sourcePath:o.path,leafPath:Mp(e,t,o.path),trigger:{type:`done`},transition:r,context:Ch(e,t,o.path,n,o.output,s())});c!==void 0&&i.push(c)}}return i},Dh=(e,t,n)=>{let r=[],i=new Set,a=new Map,o,s=()=>o??=Rp(e,t);for(let o of Ap(e,t))for(let c of ph(e,o)){let l=ih(Rd(e).handlers[c]?.on?.[n._tag]);if(l!==void 0){let u=a.get(c);if(a.has(c)||(u=fh(e,{sourcePath:c,leafPath:o,trigger:{type:`event`,event:n._tag},transition:l,context:Sh(e,t,c,n,s())}),a.set(c,u)),u===void 0)continue;i.has(c)||(i.add(c),r.push(u));break}}return r},Oh=(e,t,n)=>{if(!t.active.has(n.path))return[];let r=Rd(e).handlers[n.path],i=zm(r?.invoke).find(e=>{let t=`child`in e?e.child?.id:e.id;return String(t)===n.id});if(i===void 0)return[];let a=ih(n.type===`element`?i.onElement:n.type===`done`?i.onDone:n.type===`failure`?i.onFailure:i.onSnapshot);if(a===void 0)return[];let o=Rp(e,t),s={...rh(e,t),state:t.values.get(n.path),containingState:Fp(e,t,n.path),ancestors:Pp(e,t,n.path),snapshot:o,id:n.id,...n.type===`element`?{element:n.element}:n.type===`done`?{output:n.output}:n.type===`failure`?{error:n.error}:{snapshot:n.snapshot}},c=fh(e,{sourcePath:n.path,leafPath:Mp(e,t,n.path),trigger:{type:`invoke`,id:n.id,outcome:n.type},transition:a,context:s});return c===void 0?[]:[c]},kh=e=>{if(mf(e)||vf(e)||Tf(e)||Of(e))return String(e.path);throw Error(`Machine expected transition target to be a snapshot or target builder result`)},Ah=(e,t,n,r)=>{if(n===void 0||r===void 0)return;let i=typeof r==`object`&&r&&`path`in r?String(r.path):`<unknown>`;if(!n.some(e=>i===e||e===``||i.startsWith(`${e}.`))){let r=t.type===`event`?String(t.event):t.type;throw Error(`Machine transition from "${e}" on "${r}" returned target "${i}" outside declared targets: ${n.length===0?`none`:n.map(e=>`"${e}"`).join(`, `)}`)}},jh=(e,t)=>{for(let n of e)if(t.includes(n))return!0;return!1},Mh=(e,t)=>Array.from(t).sort((t,n)=>Op(e,t.selection.sourcePath,n.selection.sourcePath)),Nh=e=>e.filter(t=>!e.some(e=>e.sourcePath!==t.sourcePath&&wp(e.sourcePath,t.sourcePath))),Ph=(e,t)=>{let n=[];for(let r of Mh(e,t)){let e=!1,t=new Set;for(let i of n){let n=r.update!==void 0&&i.update!==void 0&&r.update.path===i.update.path;if(jh(r.exitPaths,i.exitPaths)||n){if(wp(r.selection.sourcePath,i.selection.sourcePath))t.add(i);else{e=!0;break}}}if(!e){for(let e of t){let t=n.indexOf(e);t>=0&&n.splice(t,1)}n.push(r)}}return n},Fh=(e,t={})=>{let n={...t},r=[],i=e=>{if(vf(e))Object.assign(n,e.values??{}),r.push(e);else if(typeof e==`object`&&e&&`path`in e&&`value`in e&&(e.value!==void 0&&(n[String(e.path)]=e.value),`state`in e&&i(e.state),`states`in e&&typeof e.states==`object`&&e.states!==null))for(let t of Object.values(e.states))i(t)};return i(e),r.map(e=>({target:_f(e.path,e.parent,n),values:n}))},Ih=(e,t={})=>Fh(e,t)[0],Lh=(e,t)=>{if(vf(e))return _f(e.path,e.parent,{...t,...e.values??{}});if(gf(e))return{...e,values:{...t,...e.values}};if(!Tf(e)||Object.keys(t).length===0)return e;let n=e[Bd];return wf(e.path,e.value,{...n===void 0?{}:{snapshot:n},values:{...t,...e.values??{}}})};function Rh(e,t,n,r){let i=[n],a=[],o=[],s=[],c=[],l=[],u=0;for(;i.length>0;){let n=i.shift();for(;;){let a=Fh(n),d=a[0];if(d===void 0)break;if(i.unshift(...a.slice(1).map(({target:e})=>e)),u+=1,u>1e3)throw new jd({machineId:e.id,state:d.target.path,maxIterations:Bh});let f=$(e,d.target.path);if(f.type!==`choice`||f.parent!==d.target.parent)throw Error(`Machine expected choice target "${d.target.path}" to resolve to its declared parent`);let p=Rd(e).handlers[f.path]?.choice;if(p===void 0||typeof p.transition!=`function`)throw Error(`Machine choice state "${f.path}" requires an implementation`);let m=new Map(t.values);for(let[t,n]of Object.entries(d.values)){let r=$(e,t);r.schema!==void 0&&m.set(t,pp(e,r,n))}let h={active:new Set([...t.active,...Object.keys(d.values)]),values:m,outputs:t.outputs,history:t.history,...t.machineReferences===void 0?{}:{machineReferences:t.machineReferences}},g=oh(e,p.transition,{...rh(e,h),containingState:Fp(e,h,f.path),ancestors:Pp(e,h,f.path),event:r},p.evaluate);if(g.state===void 0)throw Error(`Machine choice resolver for "${f.path}" must return a target`);Ah(f.path,{type:`choice`},p.targets,g.state);let _=kh(g.state);n=Lh(g.state,d.values);let v=Ih(n);l.push({source:f.path,trigger:{type:`choice`},reenter:!1,branchIndex:g.branchIndex,branchKey:g.branchKey,target:_,resolvedTarget:v?.target.path??_,updates:[]}),o.push(...g.commands),s.push(...g.raisedEvents),c.push(...g.emittedEvents)}if(!Tf(n)&&!Of(n)&&!mf(n)&&!gf(n))throw Error(`Machine choice resolver must return a concrete typed target`);a.push(n)}return{target:a[0],additionalTargets:a.slice(1),commands:o,raisedEvents:s,emittedEvents:c,transitions:l}}var zh=(e,t,n)=>{let r=n.leafPath,i=n.collected??oh(e,n.transition.transition,n.context,n.transition.evaluate);if(i.declined)throw Error(`Machine transition returned decline without declaring declinable: true`);let a=rf(i.state)?i.state:void 0,o=a?.target??i.state,s=o===void 0||tf(o)?void 0:o;Ah(n.sourcePath,n.trigger,n.transition.targets,s);let c=a?.update??(tf(o)?o:void 0),l=c===void 0?void 0:(()=>{let n=$(e,c.path);if(!t.active.has(n.path)||n.schema===void 0)throw Error(`Machine state update owner "${n.path}" must be an active valued state`);return{path:n.path,value:pp(e,n,c.value)}})(),u=l!==void 0&&(gf(s)||vf(s))?{...t,values:new Map(t.values).set(l.path,l.value)}:t,d=s===void 0?void 0:Rh(e,u,s,n.context.event),f=d?.target??s,p=f!==void 0&&gf(f)?uh(e,u,f,n.context.event):void 0,m=p?.target??f,h,g=mf(m)&&n.transition.reenter&&t.active.has(m.parent)?m:void 0;if(m!==void 0&&mf(m)){let i=n.transition.reenter?$(e,n.sourcePath).parent:mh(e,r,m.parent),a=g===void 0?gh(e,t,i):yh(e,Array.from(t.active).filter(e=>Tp(e,m.parent)));h=dh(e,a.includes(m.parent)?Jp(e,t,t,a):t,m,n.context.event)}let _=h===void 0?m:h.target,v=[],y=[],b=[],x=[],S=[];for(let r of d?.additionalTargets??[]){if(gf(r)){let i=uh(e,t,r,n.context.event);S.push(i.target),v.push(...i.commands),y.push(...i.raisedEvents),b.push(...i.emittedEvents),x.push(...i.transitions);continue}if(!mf(r)){S.push(r);continue}let i=dh(e,t,r,n.context.event);S.push(i.target),v.push(...i.commands),y.push(...i.raisedEvents),b.push(...i.emittedEvents),x.push(...i.transitions)}let C=_===void 0?void 0:S.length===0||s===void 0?kh(_):kh(s),w=_===void 0?l===void 0?t:{...t,values:new Map(t.values).set(l.path,l.value)}:em(e,t,_);for(let t of S)w=em(e,w,t);if(a!==void 0&&l!==void 0&&!w.active.has(l.path))throw Error(`Machine combined target exited its updating owner "${l.path}"`);l!==void 0&&(w={...w,values:new Map(w.values).set(l.path,l.value)});let T=n.transition.reenter||!vh(t,w),E=T||l!==void 0;if(!T)return{selection:n,branchIndex:i.branchIndex,branchKey:i.branchKey,unresolvedTarget:s,target:_,update:l,commands:[...i.commands,...d?.commands??[],...p?.commands??[],...h?.commands??[],...v],raisedEvents:[...i.raisedEvents,...d?.raisedEvents??[],...p?.raisedEvents??[],...h?.raisedEvents??[],...y],emittedEvents:[...i.emittedEvents,...d?.emittedEvents??[],...p?.emittedEvents??[],...h?.emittedEvents??[],...b],changed:T,stabilize:E,exitPaths:[],entryPaths:[],choiceTransitions:[...d?.transitions??[],...p?.transitions??[],...h?.transitions??[],...x]};let D=C===void 0?$(e,n.sourcePath).parent:mh(e,r,C),O=$(e,n.sourcePath).parent,k=n.transition.reenter?hh(D,O):D;return{selection:n,branchIndex:i.branchIndex,branchKey:i.branchKey,unresolvedTarget:s,target:_,update:l,commands:[...i.commands,...d?.commands??[],...p?.commands??[],...h?.commands??[],...v],raisedEvents:[...i.raisedEvents,...d?.raisedEvents??[],...p?.raisedEvents??[],...h?.raisedEvents??[],...y],emittedEvents:[...i.emittedEvents,...d?.emittedEvents??[],...p?.emittedEvents??[],...h?.emittedEvents??[],...b],changed:T,stabilize:E,exitPaths:g===void 0?gh(e,t,k):yh(e,Array.from(t.active).filter(e=>Tp(e,g.parent))),entryPaths:g===void 0?_h(e,w,k):bh(e,Array.from(w.active).filter(e=>Tp(e,g.parent))),choiceTransitions:[...d?.transitions??[],...p?.transitions??[],...h?.transitions??[],...x]}},Bh=1e3,Vh={_tag:Em},Hh=(e,t)=>om(e,Wp(e,t)),Uh=(e,t,n)=>qp(e,t).pipe(q(t=>um(e,t,n)),q(t=>{let n=Np(e,t.configuration);return!om(e,t.configuration)||!t.configuration.outputs.has(n)?or(Error(`Machine attempted to read terminal output from a non-terminal configuration`)):ke(t.configuration.outputs.get(n))})),Wh=(e,...t)=>{let n=e.input===void 0?t:t.length===0?(dp(e,e.input,void 0),t):[dp(e,e.input,t[0])],r=e.initial(...n),i={active:new Set,values:new Map,outputs:new Map,history:new Map},a=uh(e,i,r,Vh),o=em(e,i,a.target),s=Rp(e,o),c=Ip(e,o),l=a.commands,u=a.raisedEvents,d=a.emittedEvents,f=wh(e,o,c,Vh,`entry`),p=Kh(e,o,Vh,[...f.commands],[...u,...f.raisedEvents],[...d,...f.emittedEvents],a.transitions.length===0?[]:[{next:o,event:Vh,transitions:a.transitions,commands:l,raisedEvents:[...u],emittedEvents:d,exitPaths:[],entryPaths:[],changed:!1,stabilize:!1}]),m={startingState:s,initialEntryPaths:c,state:Rp(e,p.next),commands:[...l,...p.commands],emittedEvents:p.emittedEvents,microsteps:p.microsteps.map(t=>({next:Rp(e,t.next),event:t.event,transitions:t.transitions,commands:t.commands,raisedEvents:t.raisedEvents,emittedEvents:t.emittedEvents,exitPaths:t.exitPaths,entryPaths:t.entryPaths,changed:t.changed}))};return p.done?{...m,done:!0,output:p.output}:{...m,done:!1,output:void 0}},Gh=(e,t,n,r)=>{if(r.length===0)return{next:t,event:n,transitions:[],commands:[],raisedEvents:[],emittedEvents:[],exitPaths:[],entryPaths:[],changed:!1,stabilize:!1};let i=Nh(r),a=[];for(let n of i)a.push(zh(e,t,n));let o=Ph(e,a),s=Mh(e,o),c=s.flatMap(e=>[{source:e.selection.sourcePath,trigger:e.selection.trigger,reenter:e.selection.transition.reenter,branchIndex:e.branchIndex,branchKey:e.branchKey,target:e.unresolvedTarget===void 0?void 0:kh(e.unresolvedTarget),resolvedTarget:e.target===void 0?void 0:kh(e.target),updates:e.update===void 0?[]:[e.update.path]},...e.choiceTransitions]),l=t;for(let e of s)e.update!==void 0&&(l={...l,values:new Map(l.values).set(e.update.path,e.update.value)});let u=[...s.filter(e=>!e.changed),...s.filter(e=>e.changed)];for(let t of u)t.target!==void 0&&(l=em(e,l,t.target));let d=o.some(e=>e.changed),f=o.some(e=>e.stabilize),p=s.flatMap(e=>e.commands),m=s.flatMap(e=>e.raisedEvents),h=s.flatMap(e=>e.emittedEvents);if(!d)return{next:l,event:n,transitions:c,commands:p,raisedEvents:m,emittedEvents:h,exitPaths:[],entryPaths:[],changed:!1,stabilize:f};let g=yh(e,s.flatMap(e=>e.exitPaths)),_=bh(e,s.flatMap(e=>e.entryPaths));l=Jp(e,t,l,g);let v=wh(e,t,g,n,`exit`),y=wh(e,l,_,n,`entry`);return{next:l,event:n,transitions:c,commands:[...v.commands,...p,...y.commands],raisedEvents:[...v.raisedEvents,...m,...y.raisedEvents],emittedEvents:[...v.emittedEvents,...h,...y.emittedEvents],exitPaths:g,entryPaths:_,changed:!0,stabilize:f}},Kh=(e,t,n,r,i,a,o)=>{let s=t,c=n,l=!0,u=0,d=0,f=!1,p,m=[];for(;;){if(u+=1,u>1e3)throw new jd({machineId:e.id,state:String(jp(e,s)),maxIterations:Bh});let t=pm(e,s,c);for(s=t.configuration,m.push(...t.completions.filter(t=>Rd(e).handlers[t.path]?.onDone!==void 0));m.length>0&&!s.active.has(m[0].path);)m.shift();let n=Eh(e,s,c,m.length===0?[]:[m.shift()]);if(n.length>0){let t=Gh(e,s,c,n);r.push(...t.commands),i.push(...t.raisedEvents),a.push(...t.emittedEvents),o.push(t),s=t.next,l=t.stabilize;continue}if(om(e,s)){let t=Np(e,s);if(!s.outputs.has(t))throw Error(`Machine reached a terminal configuration without a completed root output`);f=!0,p=s.outputs.get(t);break}let h=l?Th(e,s,c):[];if(h.length>0){let t=Gh(e,s,c,h);r.push(...t.commands),i.push(...t.raisedEvents),a.push(...t.emittedEvents),o.push(t),s=t.next,l=t.stabilize;continue}let g=i[d];if(g===void 0)break;d+=1;let _=g;c=_;let v=Dh(e,s,_);if(v.length===0){l=!0;continue}let y=Gh(e,s,_,v);r.push(...y.commands),i.push(...y.raisedEvents),a.push(...y.emittedEvents),o.push(y),s=y.next,l=!0}let h={next:s,commands:r,emittedEvents:a,microsteps:o};return f?{...h,done:!0,output:p}:{...h,done:!1,output:void 0}},qh=(e,t,n)=>{let r=Qm(n)?n:cp(e,n);if(om(e,t)){let n=pm(e,t,r),i=Np(e,n.configuration);if(!n.configuration.outputs.has(i))throw Error(`Machine reached a terminal configuration without a completed root output`);return{event:r,next:n.configuration,commands:[],emittedEvents:[],microsteps:[],done:!0,output:n.configuration.outputs.get(i)}}let i=Qm(r)?Oh(e,t,r):Dh(e,t,r);if(i.length===0)return{event:r,next:t,commands:[],emittedEvents:[],microsteps:[],done:!1,output:void 0};let a=Gh(e,t,r,i),o=[...a.commands],s=[...a.raisedEvents],c=[...a.emittedEvents],l=[a];return{...Kh(e,a.next,r,o,s,c,l),event:r}},Jh=(e,...t)=>gi({try:()=>Wh(e,...t),catch:Ld}),Yh=(e,t)=>({raise:n=>sp(e,n).pipe(q(e=>t.sendTo(t.self,e))),emit:n=>lp(e,n).pipe(q(e=>t.emit(e)))}),Xh=(e,t)=>Xn(e,e=>e._tag===`SendTo`?t.sendTo(e.target,e.event):t.stopChild(e.child),{discard:!0}),Zh=(e,t)=>ve(Array.from(e,e=>t.emit(e)),{discard:!0}),Qh=new WeakMap,$h=e=>{let t=Qh.get(e);if(t!==void 0)return t;let n={self:{id:e.id??`Machine`,sessionId:`Machine.plan`,send:()=>Jt(new Pd)},parent:void 0};return Qh.set(e,n),n},eg=(e,t)=>{let n=t===void 0?$h(e):t;return e.parent===void 0?{self:n.self}:{self:n.self,parent:n.parent}},tg=new Set([`initialize`,`invoke`,`on`,`output`]),ng=e=>{if(e===void 0)return!0;for(let t of Reflect.ownKeys(e))if(!tg.has(t))return!1;return!0},rg=e=>{let t=[],n=[],r=[],i=new Map;for(let a of e.stateNodes.byPath.values()){if(t.push(a),a.type===`choice`||a.type===`history`)return;(a.type===`atomic`||a.type===`final`)&&n.push(a.path),a.type===`final`&&r.push(a.path);let o=Rd(e).handlers[a.path];if(!ng(o))return;if(o?.on===void 0)continue;let s=new Map;for(let e of Reflect.ownKeys(o.on)){let t=ih(o.on[e]);if(t!==void 0){if(t.declinable)return;s.set(e,t)}}s.size>0&&i.set(a.path,s)}n.sort((t,n)=>Op(e,t,n)),r.sort((t,n)=>Op(e,t,n)),t.sort((e,t)=>e.order-t.order);let a=new Map(t.map((e,t)=>[e.path,t])),o=e=>{let t=a.get(e);if(t===void 0)throw Error(`Machine expected compiled state path "${e}"`);return t},s=n.map(o),c=t.map(e=>e.parent===void 0?-1:o(e.parent)),l=t.map(e=>e.children.map(o)),u=t.map(t=>Ep(e,t.path).slice(0,-1).map(o)),d=t.map(e=>i.get(e.path)),f=new Map;for(let e of s){let t=new Map,n=[e,...u[e].slice().reverse()];for(let e of n)for(let[n,r]of d[e]??[])t.has(n)||t.set(n,{sourceIndex:e,transition:r});f.set(e,t)}return{valued:Object.freeze(t.map(e=>e.schema!==void 0)),flat:t.every(e=>e.parent===void 0&&(e.type===`atomic`||e.type===`final`))||t[0]?.path===``&&t[0].type===`compound`&&t[0].schema===void 0&&(Rd(e).handlers[``]===void 0||Reflect.ownKeys(Rd(e).handlers[``]).every(e=>e===`initialize`))&&t.slice(1).every(e=>e.parent===``&&(e.type===`atomic`||e.type===`final`))&&[...i.values()].every(e=>[...e.values()].every(e=>e.targets!==void 0&&e.targets.every(e=>e!==``))),nodes:t,indexByPath:a,parentIndices:c,childIndices:l,ancestorIndices:u,rootIndices:t.flatMap((e,t)=>e.parent===void 0?[t]:[]),leafIndices:s,finalIndices:r.map(o),dispatchByLeaf:f}},ig=e=>({active:e.active.slice(),activeLeaves:e.activeLeaves.slice(),values:e.values.slice(),completed:e.completed.slice(),outputs:e.outputs.slice(),completedOrder:e.completedOrder.slice()}),ag=(e,t)=>t?{...e,next:ig(e.next)}:e,og=(e,t,n)=>{e.values[t]=n},sg=(e,t)=>{let n=new Uint8Array(e.nodes.length),r=Array(e.nodes.length),i=new Uint8Array(e.nodes.length),a=Array(e.nodes.length),o=[];for(let i of t.active){let a=e.indexByPath.get(i);if(a===void 0)throw Error(`Machine expected indexed active path "${i}"`);n[a]=1,e.valued[a]&&(r[a]=t.values.get(i))}for(let[n,r]of t.outputs){let t=e.indexByPath.get(n);if(t===void 0)throw Error(`Machine expected indexed completed path "${n}"`);i[t]=1,a[t]=r,o.push(t)}return{active:n,activeLeaves:e.leafIndices.filter(e=>n[e]===1),values:r,completed:i,outputs:a,completedOrder:o}},cg=(e,t)=>{let n=new Set,r=new Map,i=new Map;for(let i=0;i<e.nodes.length;i++){if(t.active[i]!==1)continue;let a=e.nodes[i].path;n.add(a),e.valued[i]&&r.set(a,t.values[i])}for(let n of t.completedOrder)t.completed[n]===1&&i.set(e.nodes[n].path,t.outputs[n]);return{active:n,values:r,outputs:i,history:new Map}},lg=(e,t,n)=>{let r=e.nodes[n],i={path:r.path,value:e.valued[n]?t.values[n]:void 0};if(r.type===`compound`){let a=e.childIndices[n].find(e=>t.active[e]===1);if(a===void 0)throw Error(`Machine expected indexed compound state "${r.path}" to have an active child`);i.state=lg(e,t,a)}else if(r.type===`parallel`){let a={};for(let i of e.childIndices[n]){if(t.active[i]!==1)throw Error(`Machine expected indexed parallel state "${r.path}" to have active region "${e.nodes[i].path}"`);a[e.nodes[i].key]=lg(e,t,i)}i.states=a}return i},ug=(e,t)=>{let n=e.rootIndices.find(e=>t.active[e]===1);if(n===void 0)throw Error(`Machine expected an active indexed root state`);let r=lg(e,t,n);return t.completedOrder.length>0&&(r.completed=t.completedOrder.map(n=>({path:e.nodes[n].path,output:t.outputs[n]}))),r},dg=(e,t,n,r,i,a)=>{let o=t.parentIndices[r],s={};for(let e of t.ancestorIndices[r])t.valued[e]&&(s[t.nodes[e].path]=n.values[e]);return{...eg(e,a),state:n.values[r],containingState:o<0?void 0:n.values[o],ancestors:s,event:i,snapshot:ug(t,n)}},fg=Object.freeze([]),pg=(e,t,n,r)=>{let i,a,o,s={raise:t=>{(a??=[]).push(cp(e,t))},emit:t=>{(o??=[]).push(up(e,t))},sendTo:(e,t)=>{(i??=[]).push({_tag:`SendTo`,target:e,event:t})},stop:e=>{(i??=[]).push({_tag:`Stop`,child:e})}},c=r===void 0?{result:t(n,s),branchIndex:0,branchKey:void 0}:r(n,s);return{state:lf(c.result)?void 0:c.result,branchIndex:c.branchIndex,branchKey:c.branchKey,commands:i??fg,raisedEvents:a??fg,emittedEvents:o??fg}},mg=(e,t,n,r,i)=>{let a=[];for(let o of n.activeLeaves){let s=t.dispatchByLeaf.get(o).get(r._tag);if(s!==void 0){let{sourceIndex:c,transition:l}=s;if(!a.some(e=>e.sourceIndex===c)){let s=t.nodes[c].path;a.push({sourceIndex:c,leafIndex:o,sourcePath:s,leafPath:t.nodes[o].path,trigger:{type:`event`,event:r._tag},transition:l,context:dg(e,t,n,c,r,i)})}}}return a},hg=(e,t)=>{if(e.active===t.active)return!0;for(let n=0;n<e.active.length;n++)if(e.active[n]!==t.active[n])return!1;return!0},gg=(e,t,n,r,i)=>{if((Tf(r)?t.indexByPath.get(String(r.path)):void 0)===i&&n.active[i]===1&&Tf(r)&&r[Bd]===void 0&&r.values===void 0&&n.completedOrder.length===0&&t.valued[i]){let a=n.values.slice();return a[i]=pp(e,t.nodes[i],r.value),{...n,values:a}}return sg(t,em(e,cg(t,n),r))},_g=(e,t,n,r)=>{let i=pg(e,r.transition.transition,r.context,r.transition.evaluate),a=rf(i.state)?i.state:void 0,o=a?.target??i.state,s=a?.update??(tf(o)?o:void 0),c=s===void 0?void 0:(()=>{let r=t.indexByPath.get(s.path),i=r===void 0?void 0:t.nodes[r];if(r===void 0||i===void 0||n.active[r]!==1||i.schema===void 0)throw Error(`Machine state update owner "${s.path}" must be an active valued state`);return{path:i.path,value:pp(e,i,s.value)}})(),l=o===void 0||tf(o)?void 0:o;Ah(r.sourcePath,r.trigger,r.transition.targets,l);let u=l!==void 0&&gf(l)?uh(e,(()=>{let e=cg(t,n);return c===void 0?e:{...e,values:new Map(e.values).set(c.path,c.value)}})(),l,r.context.event):void 0,d=u?.target??l;if(d!==void 0&&!Tf(d)&&!Of(d))throw Error(`Machine expected indexed transition target to be a snapshot or target builder result`);let f=d===void 0?c===void 0?n:(()=>{let e=ig(n);return e.values[t.indexByPath.get(c.path)]=c.value,e})():gg(e,t,n,d,r.leafIndex);if(a!==void 0&&c!==void 0){let e=t.indexByPath.get(c.path);if(f.active[e]!==1)throw Error(`Machine combined target exited its updating owner "${c.path}"`);let n=f.values.slice();n[e]=c.value,f={...f,values:n}}let p=r.transition.reenter||!hg(n,f),m=p||c!==void 0;if(!p)return{selection:r,branchIndex:i.branchIndex,branchKey:i.branchKey,unresolvedTarget:l,target:d,update:c,next:f,commands:[...i.commands,...u?.commands??[]],raisedEvents:[...i.raisedEvents,...u?.raisedEvents??[]],emittedEvents:[...i.emittedEvents,...u?.emittedEvents??[]],changed:!1,stabilize:m,exitPaths:[],entryPaths:[],choiceTransitions:u?.transitions??[]};let h=d===void 0?void 0:kh(d),g=h===void 0?t.nodes[r.sourceIndex].parent:mh(e,r.leafPath,h),_=t.nodes[r.sourceIndex].parent,v=r.transition.reenter?hh(g,_):g;return{selection:r,branchIndex:i.branchIndex,branchKey:i.branchKey,unresolvedTarget:l,target:d,update:c,next:f,commands:[...i.commands,...u?.commands??[]],raisedEvents:[...i.raisedEvents,...u?.raisedEvents??[]],emittedEvents:[...i.emittedEvents,...u?.emittedEvents??[]],changed:!0,stabilize:m,exitPaths:gh(e,cg(t,n),v),entryPaths:_h(e,cg(t,f),v),choiceTransitions:u?.transitions??[]}},vg=(e,t,n,r,i,a)=>{let o=e=>({source:e.selection.sourcePath,trigger:e.selection.trigger,reenter:e.selection.transition.reenter,branchIndex:e.branchIndex,branchKey:e.branchKey,target:e.unresolvedTarget===void 0?void 0:kh(e.unresolvedTarget),resolvedTarget:e.target===void 0?void 0:kh(e.target),updates:e.update===void 0?[]:[e.update.path]});if(i.length===1){let s=_g(e,t,n,i[0]);return{next:s.next,event:r,...a?{transitions:[o(s)]}:void 0,commands:s.commands,raisedEvents:s.raisedEvents,emittedEvents:s.emittedEvents,exitPaths:s.exitPaths,entryPaths:s.entryPaths,changed:s.changed}}let s=Mh(e,Ph(e,i.filter(e=>!i.some(t=>t.sourceIndex!==e.sourceIndex&&wp(t.sourcePath,e.sourcePath))).map(r=>_g(e,t,n,r)))),c=n;if(s.length===1)c=s[0].next;else{for(let e of s)if(e.update!==void 0){let n=c.values.slice();n[t.indexByPath.get(e.update.path)]=e.update.value,c={...c,values:n}}let n=[...s.filter(e=>!e.changed),...s.filter(e=>e.changed)];for(let r of n)r.target!==void 0&&(c=gg(e,t,c,r.target,r.selection.leafIndex))}let l=s.flatMap(e=>e.commands),u=s.flatMap(e=>e.raisedEvents),d=s.flatMap(e=>e.emittedEvents),f=s.some(e=>e.changed);return{next:c,event:r,...a?{transitions:s.map(o)}:void 0,commands:l,raisedEvents:u,emittedEvents:d,exitPaths:f?yh(e,s.flatMap(e=>e.exitPaths)):[],entryPaths:f?bh(e,s.flatMap(e=>e.entryPaths)):[],changed:f}},yg=(e,t,n,r,i,a)=>{let o=n,s=r,c,l,u,d,f=0,p=0;for(;;){if(p+=1,p>1e3)throw new jd({machineId:e.id,state:t.nodes[o.activeLeaves[0]].path,maxIterations:Bh});let n=o.activeLeaves[0];if(n===void 0)throw Error(`Machine expected an active indexed root state`);if(t.nodes[n].type===`final`){let n=pm(e,cg(t,o),s).configuration,i=Np(e,n);if(!n.outputs.has(i))throw Error(`Machine reached a terminal indexed configuration without a completed root output`);return{event:r,next:sg(t,n),commands:c??fg,emittedEvents:u??fg,microsteps:d??fg,done:!0,output:n.outputs.get(i)}}let m=t.nodes[n].path,h=ih(Rd(e).handlers[m]?.on?.[s._tag]);if(h!==void 0){let r=pg(e,h.transition,{...eg(e,a),state:o.values[n],containingState:void 0,ancestors:{},event:s,snapshot:ug(t,o)},h.evaluate),f=tf(r.state)?r.state:void 0,p=f===void 0?r.state:void 0;if(f!==void 0){let r=t.nodes[n];if(f.path!==m||r.schema===void 0)throw Error(`Machine state update owner "${f.path}" must be the active valued state`);og(o,n,pp(e,r,f.value))}if(Ah(m,{type:`event`,event:s._tag},h.targets,p),p!==void 0&&!Tf(p)&&!Of(p))throw Error(`Machine expected indexed transition target to be a snapshot or target builder result`);let g=o;if(p!==void 0){let r=t.indexByPath.get(String(p.path)),i=Tf(p)?p[Bd]===void 0&&p.values===void 0:!(`state`in p)&&!(`states`in p)&&!(`completed`in p)&&!(`history`in p);r===n&&i&&o.completedOrder.length===0&&t.valued[n]?og(o,n,pp(e,t.nodes[n],p.value)):g=gg(e,t,o,p,n)}let _=h.reenter||!hg(o,g),v=g.activeLeaves[0];if(v===void 0)throw Error(`Machine expected an active indexed transition target`);let y={next:g,event:s,...i?{transitions:[{source:m,trigger:{type:`event`,event:s._tag},reenter:h.reenter,branchIndex:r.branchIndex,branchKey:r.branchKey,target:p===void 0?void 0:kh(p),resolvedTarget:p===void 0?void 0:kh(p),updates:f===void 0?[]:[f.path]}]}:void 0,commands:r.commands,raisedEvents:r.raisedEvents,emittedEvents:r.emittedEvents,exitPaths:_?[m]:fg,entryPaths:_?[t.nodes[v].path]:fg,changed:_};o=g,(d??=[]).push(ag(y,i)),r.commands.length>0&&(c??=[]).push(...r.commands),r.raisedEvents.length>0&&(l??=[]).push(...r.raisedEvents),r.emittedEvents.length>0&&(u??=[]).push(...r.emittedEvents)}if(t.nodes[o.activeLeaves[0]].type===`final`)continue;let g=l?.[f];if(g===void 0)return{event:r,next:o,commands:c??fg,emittedEvents:u??fg,microsteps:d??fg,done:!1,output:void 0};f+=1,s=g}},bg=(e,t,n,r,i,a)=>{if(Qm(r)){let i=qh(e,a===void 0?cg(t,n):bp(cg(t,n),a),r);return{event:i.event,next:sg(t,i.next),commands:i.commands,emittedEvents:i.emittedEvents,microsteps:i.microsteps.map(e=>({next:sg(t,e.next),event:e.event,transitions:e.transitions,commands:e.commands,raisedEvents:e.raisedEvents,emittedEvents:e.emittedEvents,exitPaths:e.exitPaths,entryPaths:e.entryPaths,changed:e.changed})),done:i.done,output:i.output}}let o=cp(e,r);if(t.flat)return yg(e,t,n,o,i,a);if(t.finalIndices.some(e=>n.active[e]===1)){let r=cg(t,n);if(om(e,r)){let n=pm(e,r,o).configuration,i=Np(e,n);if(!n.outputs.has(i))throw Error(`Machine reached a terminal indexed configuration without a completed root output`);return{event:o,next:sg(t,n),commands:[],emittedEvents:[],microsteps:[],done:!0,output:n.outputs.get(i)}}}let s=mg(e,t,n,o,a);if(s.length===0)return{event:o,next:n,commands:[],emittedEvents:[],microsteps:[],done:!1,output:void 0};let c=vg(e,t,n,o,s,i),l=c.next,u=o,d=[...c.commands],f=[...c.raisedEvents],p=[...c.emittedEvents],m=[ag(c,i)],h=0,g=0;for(;;){if(g+=1,g>1e3)throw new jd({machineId:e.id,state:t.nodes[t.leafIndices.find(e=>l.active[e]===1)].path,maxIterations:Bh});if(t.finalIndices.some(e=>l.active[e]===1)){let n=pm(e,cg(t,l),u).configuration;if(l=sg(t,n),om(e,n)){let t=Np(e,n);if(!n.outputs.has(t))throw Error(`Machine reached a terminal indexed configuration without a completed root output`);return{event:o,next:l,commands:d,emittedEvents:p,microsteps:m,done:!0,output:n.outputs.get(t)}}}let n=f[h];if(n===void 0)return{event:o,next:l,commands:d,emittedEvents:p,microsteps:m,done:!1,output:void 0};h+=1,u=n;let r=mg(e,t,l,n,a);if(r.length===0)continue;let s=vg(e,t,l,n,r,i);l=s.next,d.push(...s.commands),f.push(...s.raisedEvents),p.push(...s.emittedEvents),m.push(ag(s,i))}},xg=new WeakMap,Sg=e=>({fromConfiguration:e=>e,toConfiguration:e=>e,snapshot:t=>Rp(e,t),plan:(t,n,r,i)=>qh(e,i===void 0?t:bp(t,i),n)}),Cg=(e,t)=>({fromConfiguration:e=>sg(t,e),toConfiguration:e=>cg(t,e),snapshot:e=>ug(t,e),plan:(n,r,i=!1,a)=>bg(e,t,n,r,i,a),...Object.values(Rd(e).handlers).some(e=>e.initialize!==void 0&&!Am(e.initialize))?{}:{initial:(n,r)=>{let i=e.input===void 0?n:n.length===0?(dp(e,e.input,void 0),n):[dp(e,e.input,n[0])],a=e.initial(...i),o=gf(a)?lh(e,{active:new Set,values:new Map,outputs:new Map,history:new Map,...r===void 0?{}:{machineReferences:r}},a,Vh).configuration:Gp(e,a),s=pm(e,r===void 0?o:bp(o,r),Vh).configuration,c=sg(t,s),l=ug(t,c);if(!om(e,s))return{state:l,configuration:c,activeConfiguration:s,initialEntryPaths:Ip(e,s),done:!1,output:void 0};let u=Np(e,s);if(!s.outputs.has(u))throw Error(`Machine reached a terminal configuration without a completed root output`);return{state:l,configuration:c,activeConfiguration:s,initialEntryPaths:Ip(e,s),done:!0,output:s.outputs.get(u)}}}}),wg=e=>{let t=xg.get(e);if(t!==void 0)return t;let n=rg(e),r=n===void 0?Sg(e):Cg(e,n);return xg.set(e,r),r},Tg=`Machine.invocation:`,Eg=e=>e.startsWith(Tg),Dg=(e,t)=>{if(e.values===void 0?e.values=[t]:e.values.push(t),e.waiter!==void 0){let t=e.waiter;e.waiter=void 0,zn(t,z)}},Og=e=>V(()=>{if(e.values!==void 0){let t=e.values;return e.values=void 0,ke(t)}let t=te();return e.waiter=t,Wn(t).pipe(G(Og(e)))}),kg=(e,t)=>e._tag===`Started`&&(typeof t==`string`||e.descriptor!==void 0&&e.descriptor.id===t.id&&e.descriptor.machine===t.machine),Ag=(e,t,n)=>{if(e.closed)return yr();let r=e.children.get(t);return r!==void 0&&kg(r,n)?Mt(r.ref):yr()},jg=e=>{if(e.observers!==void 0)for(let t of e.observers)Dg(t,Ag(e,t.id,t.child))},Mg=(e,t,n)=>{let r=e.children.get(t);r!==void 0&&r.token===n&&(e.children.delete(t),typeof t==`string`&&jg(e))},Ng=(e,t,n,r,i)=>{let a=e.children.get(t);if(e.closed||a===void 0||a._tag!==`Starting`||a.token!==n)return!1;e.children.delete(t);let o=a.ownerKey===void 0?{_tag:`Started`,token:n,descriptor:i,ref:r}:{_tag:`Started`,token:n,descriptor:i,ref:r,ownerKey:a.ownerKey,ownerPath:a.ownerPath,ownerActive:a.ownerActive===!0};return e.children.set(t,o),typeof t==`string`&&jg(e),!0},Pg=e=>Sn(function*(){let t=yield*hi(),n=0,r=0,i=0,a=0;return{rootSessionId:e,stream:ui(t).pipe(ut(U(()=>{n+=1})),En(U(()=>{--n}))),isActive:()=>n>0,nextDeliveryId:()=>i++,nextMacrostepId:()=>a++,publishUnsafe:i=>{n!==0&&N(t,{...i,sequence:r++,rootSessionId:e})},close:ce(t)}}),Fg=e=>({id:e.id,sessionId:e.sessionId}),Ig=e=>e.flatMap(e=>{if(typeof e!=`object`||!e||!(`_tag`in e))return[];if(e._tag===`SendTo`&&`target`in e&&`event`in e){let t=e.target;return typeof t==`object`&&t&&`id`in t?[{_tag:`SendTo`,target:`sessionId`in t?Fg(t):{id:String(t.id)},event:e.event}]:[]}if(e._tag===`Stop`&&`child`in e){let t=e.child;return typeof t==`string`?[{_tag:`Stop`,target:{id:t}}]:typeof t==`object`&&t&&`id`in t?[{_tag:`Stop`,target:`sessionId`in t?Fg(t):{id:String(t.id)}}]:[]}return[]}),Lg=e=>typeof e!=`object`||!e||!(`microsteps`in e)||!Array.isArray(e.microsteps)?[]:e.microsteps.map(e=>({event:e.event,transitions:Array.isArray(e.transitions)?e.transitions:[],raisedEvents:Array.isArray(e.raisedEvents)?e.raisedEvents:[],emittedEvents:Array.isArray(e.emittedEvents)?e.emittedEvents:[],commands:Ig(Array.isArray(e.commands)?e.commands:[]),exitPaths:Array.isArray(e.exitPaths)?e.exitPaths:[],entryPaths:Array.isArray(e.entryPaths)?e.entryPaths:[],changed:e.changed===!0})),Rg=Symbol.for(`effect/Machine/activeSnapshotObserver`),zg=Symbol.for(`effect/Machine/snapshotObserver`),Bg=e=>typeof e==`object`&&!!e&&zg in e,Vg=Symbol.for(`effect/Machine/sendParentOverride`),Hg=Symbol.for(`effect/Machine/acknowledgedSend`),Ug=Symbol(`effect/Machine/AcknowledgedMessage`),Wg=e=>typeof e==`object`&&!!e&&Ug in e,Gg=e=>Wg(e)?e.event:e,Kg=(e,t)=>{e!==void 0&&Wg(e)&&(e.deferred!==void 0&&zn(e.deferred,ke(t)),e.inspection?.complete(t))},qg=(e,t)=>{e!==void 0&&Wg(e)&&e.deferred!==void 0&&zn(e.deferred,fr(t))},Jg=e=>{e!==void 0&&Wg(e)&&e.deferred!==void 0&&zn(e.deferred,Jt(new Pd))},Yg=e=>typeof e==`object`&&!!e&&`send`in e&&typeof e.send==`function`,Xg=(e,t,n,r)=>`inspectionSubject`in e&&`sendInspected`in e&&typeof e.sendInspected==`function`?e.sendInspected(t,n,r):e.send(t),Zg=e=>e?._tag===`Childless`||e?.childless===!0,Qg=(e,t)=>{let n=e.items??[];e.items=n,n.push(t)},$g=e=>{if(e.items===void 0)return yr();let t=e.items[e.index];return e.index+=1,e.index===e.items.length&&(e.items=void 0,e.index=0),Mt(t)},e_=e=>{if(e.items!==void 0)for(let t=e.index;t<e.items.length;t+=1)Jg(e.items[t]);e.closed=!0,e.items=void 0,e.index=0},t_=()=>({items:void 0,index:0,closed:!1,receivers:new Set}),n_=(e,t,n)=>{if(e.closed)return!1;for(Qg(e,t),n?.();e.items!==void 0&&e.receivers.size>0;){let t=e.receivers.values().next().value;e.receivers.delete(t),t(z)}return!0},r_=e=>V(()=>{let t=$g(e);return mt(t)?ke(t.value):e.closed?_r:Rt(t=>(e.receivers.add(t),U(()=>{e.receivers.delete(t)}))).pipe(G(r_(e)))}),i_=e=>{e_(e);let t=Array.from(e.receivers);e.receivers.clear();for(let e of t)e(_r)},a_=class extends wr()(`effect/Machine/MachineRuntime`){},o_=(e,t)=>b(e,a_,t),s_=e=>{switch(e.status){case`active`:return;case`done`:return{_tag:`Done`,output:e.output,snapshot:e};case`error`:{let t=e.cause.reasons.find(Lt);if(t!==void 0)return{_tag:`Failure`,error:t.error,cause:e.cause,snapshot:e};let n=e.cause.reasons.find(Ot);return n===void 0?e.cause.reasons.find(qe)===void 0?{_tag:`Cause`,cause:e.cause,snapshot:e}:{_tag:`Interrupted`,cause:e.cause,snapshot:e}:{_tag:`Defect`,defect:n.defect,cause:e.cause,snapshot:e}}case`stopped`:return{_tag:`Stopped`,snapshot:e}}},c_=(e,t)=>V(()=>e(t)).pipe(Fn,Pt),l_=(e,t)=>{class n{nextSessionId;constructor(){let e=0;this.nextSessionId=U(()=>`machine:${e++}`)}get start(){return e}get startCompiledSync(){return t}}return U(()=>new n)},u_=(e,t,n)=>({id:t,sessionId:n,kind:e.inspection?.kind??`Logic`}),d_=(e,t)=>t?{_tag:`Initialization`}:e!==void 0&&Wg(e)&&e.inspection!==void 0?{_tag:`Macrostep`,macrostepId:e.inspection.macrostepId}:void 0,f_=(e,t,n,r,i,a)=>{let o=e.nextDeliveryId(),s=e.nextMacrostepId(),c={deliveryId:o,macrostepId:s,source:r,event:n,causedBy:i,complete:i=>{let a=Lg(i.plan);e.publishUnsafe({_tag:`EventProcessed`,subject:t,macrostepId:s,deliveryId:o,source:r,event:n,before:{status:`active`,state:i.before},after:{status:`active`,state:i.after},handled:a.some(e=>e.transitions.length>0),configurationChanged:a.some(e=>e.changed),microsteps:a})}};return{[Ug]:!0,event:n,...a===void 0?void 0:{deferred:a},inspection:c}},p_=(e,t,n)=>{if(!Wg(n)||n.inspection===void 0)return;let r=n.inspection;e.publishUnsafe({_tag:`EventSent`,subject:t,deliveryId:r.deliveryId,source:r.source,target:Fg(t),event:r.event,causedBy:r.causedBy})},m_=class{registry;self;runtime;services;sendAcknowledged;scopedServices;constructor(e,t,n,r,i){this.registry=e,this.self=t,this.runtime=n,this.services=r,this.sendAcknowledged=i}has(e){for(let t of this.registry.children.values())if(t.ownerActive&&t.ownerKey===e)return!0;return!1}stopEntry(e){return e.ownerActive=!1,e._tag===`Started`?e.ref.stop:z}spawn(e,t){let n=Symbol(),r,i=()=>{let e=this.registry.children.get(t.id);return e?.token===n&&e.ownerKey===t.key&&e.ownerActive===!0};return V(()=>{if(this.registry.closed)return _r;if(this.has(t.key)||this.registry.children.has(t.id))return Jt(new Nd({id:t.duplicateId}));let a=e(),o=this.registry.scope??=w(`parallel`);this.registry.children.set(t.id,{_tag:`Starting`,token:n,ownerKey:t.key,ownerPath:t.path,ownerActive:!0});let s={...this.self,send:e=>t.sendParent(i,e),sendInspected:(e,t,n)=>i()?Xg(this.self,e,t,n):z,...this.sendAcknowledged===void 0?void 0:{[Hg]:e=>i()?this.sendAcknowledged(e):_r}},c={detached:!0,id:t.id,sendParent:e=>t.sendParent(i,e),onOutcome:e=>t.onOutcome(i,e,r?.sessionId),...t.onSnapshot===void 0?void 0:{onSnapshot:e=>t.onSnapshot(i,e)},onReadySync:e=>(r=e,Ng(this.registry,t.id,n,e,t.descriptor)),onStopSync:()=>Mg(this.registry,t.id,n),skipStoppedOutcome:!0,parent:s,runtime:this.runtime,origin:{_tag:`Invoke`,ownerPath:t.path,invokeId:t.duplicateId},...t.activityKind===void 0||this.runtime.inspection===void 0||this.self.inspectionSubject===void 0?void 0:{activity:{id:t.duplicateId,owner:this.self.inspectionSubject,ownerPath:t.path,kind:t.activityKind}}},l=a.execution,u=this.services!==void 0&&t.onSnapshot===void 0&&l?._tag===`Compiled`&&l.childless&&l.drain._tag===`Owned`&&l.initialSync!==void 0,d=(u?q(this.runtime.nextSessionId,e=>this.runtime.startCompiledSync(a,c,this.scopedServices??=Mn(this.services,ei,o),e)):this.runtime.start(a,c)).pipe(Qt(e=>bt(e)?z:(Mg(this.registry,t.id,n),r===void 0?z:r.stop)));return(u?d:Re(d,o)).pipe(Pt)})}stopAll(){return V(()=>{let e=[];for(let t of this.registry.children.values())t.ownerActive&&e.push(this.stopEntry(t));return e.length===0?z:e.length===1?e[0]:ve(e,{concurrency:`unbounded`,discard:!0})})}stopPaths(e){if(e.length===0)return;let t=new Set(e),n=[];for(let e of this.registry.children.values())e.ownerActive&&e.ownerPath!==void 0&&t.has(e.ownerPath)&&n.push(this.stopEntry(e));return n.length===0?void 0:n.length===1?n[0]:ve(n,{concurrency:`unbounded`,discard:!0})}},h_=ze(yr()).pipe($n(ti)),g_=e=>z,__=(e,t)=>{},v_=()=>void 0,y_=Symbol(`effect/Machine/EmissionsClosed`),b_=()=>{let e,t=V(()=>{let t=e;return t===y_?ke(void 0):t===void 0?hi().pipe(q(t=>U(()=>{let n=e;return n===y_?[void 0,!0]:n===void 0?(e=t,[t,!1]):[n,!0]}).pipe(q(([e,n])=>n?ce(t).pipe(pe(e)):ke(e))))):ke(t)});return{emit:t=>V(()=>e===void 0||e===y_?z:We(e,t).pipe(Pt)),close:()=>{let t=e;return e=y_,t===void 0||t===y_?z:ce(t)},stream:Bn(t.pipe(Ut(e=>e===void 0?kn:ui(e))))}},x_={close:()=>z,spawn:(()=>or(Error(`Childless machine logic cannot spawn a process`))),get:()=>ke(yr()),changes:()=>h_,sendTo:()=>z,stop:()=>z,owned:{spawn:()=>or(Error(`Childless machine logic cannot spawn an owned process`)),stopAll:()=>z,stopPaths:()=>void 0}},S_=(e,t,n,r)=>{let i={closed:!1,children:new Map,observers:void 0,scope:void 0},a=e=>V(()=>{if(i.closed||(i.closed=!0,i.scope===void 0))return z;let t=A(i.scope,e),n,r;for(let e of i.children.values())e._tag===`Started`&&(n===void 0?n=e.ref.stop:(r??=[n],r.push(e.ref.stop)));t!==void 0&&(n===void 0?n=t:(r??=[n],r.push(t)));let a=r??n;return a===void 0?z:Array.isArray(a)?ve(a,{concurrency:`unbounded`,discard:!0}):a}),o=(e,t)=>U(()=>Mg(i,e,t)),s=(e,t,n,r)=>U(()=>Ng(i,e,t,n,r)),c=e=>{let t=typeof e==`string`?e:e.id;return U(()=>{if(i.closed)return yr();let n=i.children.get(t);return n!==void 0&&kg(n,e)?Mt(n.ref):yr()})},l=e=>{let t=typeof e==`string`?e:e.id;return Yr(Pe((n,r)=>U(()=>({child:e,id:t,values:void 0,waiter:void 0})).pipe(q(n=>{let a=U(()=>{i.observers!==void 0&&(i.observers.delete(n),i.observers.size===0&&(i.observers=void 0)),n.values=void 0,n.waiter=void 0});return lt(r,a).pipe(G(U(()=>{!i.closed&&r.state._tag!==`Closed`&&(i.observers??=new Set,i.observers.add(n)),Dg(n,Ag(i,t,e))})),pe(Og(n)))}))))},u=(e,t,n,r)=>{let a=typeof e==`string`?e:e.id;return V(()=>{if(i.closed)return z;let o=i.children.get(a);return o!==void 0&&kg(o,e)?Xg(o.ref,t,n,r):z})},d=e=>{let t=typeof e==`string`?e:e.id;return V(()=>{if(i.closed)return z;let n=i.children.get(t);return n!==void 0&&kg(n,e)?n.ref.stop:z})};function f(n,r){let a=typeof n==`object`&&n&&Om in n?n:void 0,c=a===void 0?n:a[Om](r?.input),l=a===void 0?r:{id:a.id,descriptor:a},u=Symbol(),d=l?.id??u,f;return V(()=>i.closed?_r:typeof d==`string`&&(i.children.has(d)||Eg(d))?Jt(new Nd({id:d})):(i.scope??=w(`parallel`),i.children.set(d,{_tag:`Starting`,token:u}),t.start(c,{detached:!0,...l?.id===void 0?void 0:{id:l.id},...l?.onOutcome===void 0?void 0:{onOutcome:l.onOutcome},...l?.[Rg]===void 0?void 0:{onSnapshot:l[Rg]},...l?.[Vg]===void 0?void 0:{sendParent:l[Vg]},onReady:(e,t)=>U(()=>{f=e}).pipe(G(s(d,u,e,l?.descriptor)),q(e=>e?z:t)),onStop:o(d,u),parent:e,runtime:t,origin:{_tag:`Spawn`,address:l?.id}}).pipe(Qt(e=>m(e)?o(d,u).pipe(G(f===void 0?z:f.stop)):z),Re(i.scope))))}return{close:a,spawn:f,get:c,changes:l,sendTo:u,stop:d,owned:new m_(i,e,t,n,r)}},C_=(e,t,n,r)=>U(()=>S_(e,t,n,r)),w_=(e,t)=>`${e.length}:${e}${t}`,T_=(e,t)=>`${Tg}${w_(e,t)}`,E_=e=>({initial:()=>z,run:()=>e}),D_=(e,t,n)=>({initial:()=>z,run:({parent:r})=>{let i=r?.[Hg];return i===void 0?or(Error(`Stream invocation requires an acknowledged parent machine`)):T(e,e=>i(Ym(t,n,e)).pipe(Pt,Je(()=>_r)))}}),O_=(e,t)=>typeof e==`function`?e(t):e,k_=e=>({spawn:((t,n)=>e.spawn(t,n)),sendTo:((t,n)=>e.sendTo(t,n)),stop:(t=>e.stopChild(t))}),A_=(e,t,n)=>{if(`effect`in e)return{id:String(e.id),sourceName:e.sourceName,src:()=>E_(e.effect(t)),onDone:e.onDone,onFailure:e.onFailure,onSnapshot:e.onSnapshot,activityKind:`Effect`};if(`after`in e)return{id:String(e.id),sourceName:e.sourceName,src:()=>E_(Vn(O_(e.after,t))),onDone:e.onDone,activityKind:`Timer`};if(`stream`in e){let r=String(e.id);return{id:r,sourceName:e.sourceName,src:()=>D_(e.stream(t),n,r),onDone:e.onDone,onFailure:e.onFailure,activityKind:`Stream`}}if(`logic`in e)return{id:String(e.id),address:String(e.address),src:()=>O_(e.logic,t),onDone:e.onDone,onFailure:e.onFailure,onSnapshot:e.onSnapshot};if(`child`in e){let n=e.child;return{id:n.id,address:n.id,descriptor:n,src:()=>n[Om](`input`in e?O_(e.input,t):void 0),onDone:e.onDone,onFailure:e.onFailure,onSnapshot:e.onSnapshot}}throw Error(`Unsupported captured machine invocation: ${String(e)}`)},j_=e=>e.length===0?z:e.length===1?e[0]:ve(e,{discard:!0}),M_=(e,t,n)=>(n===void 0||e.self.sendInspected===void 0?e.self.send(t):e.self.sendInspected(t,e.self.inspectionSubject,{_tag:`Activity`,activitySessionId:n})).pipe(_n(`StoppedError`,()=>z)),N_=e=>e instanceof jd||e instanceof Ad||e instanceof Pd,P_=(e,t,n,r,i,a,o,s,c,l,u,d)=>V(()=>{let f=w_(n,r),p=u===void 0?o:()=>{let t=o();return{...t,run:i=>Tt(V(()=>t.run(i)),`Machine.invoke`,{attributes:{"machine.id":e.self.id,"machine.sessionId":e.self.sessionId,"machine.state.path":n,"machine.invoke.id":r,"machine.invoke.source":d??r,"machine.invoke.kind":u,"machine.invoke.sessionId":i.self.sessionId},captureStackTrace:!1})}};return t.spawn(p,{key:f,path:n,id:i,duplicateId:r,...a===void 0?void 0:{descriptor:a},...u===void 0?void 0:{activityKind:u},sendParent:(t,n)=>t()?e.self.send(n):z,onOutcome:(t,i,o)=>G(re,V(()=>i._tag===`Stopped`||!t()?z:i._tag===`Done`?s===void 0?e.failCause(_e(Error(`Invocation "${r}" completed without the required onDone handler`))):M_(e,Jm(n,r,i.output),u===void 0?void 0:o):i._tag===`Failure`&&c!==void 0&&(a===void 0||!N_(i.error))?M_(e,Xm(n,r,i.error),u===void 0?void 0:o):e.failCause(i.cause))),...l===void 0?void 0:{onSnapshot:(t,i)=>t()?M_(e,Zm(n,r,i)):z}})}),F_=(e,t)=>Eg(e)?Jt(new Nd({id:t})):void 0,I_=(e,t,n,r)=>{let i=String(r.id),a=r.address===void 0?void 0:F_(String(r.address),i);return a===void 0?P_(e,t,n,i,r.address===void 0?T_(n,i):String(r.address),r.descriptor,r.src,r.onDone,r.onFailure,r.onSnapshot,r.activityKind,r.sourceName):a},L_=(e,t,n,r)=>{let i=r.child,a=F_(i.id,i.id);return a===void 0?P_(e,t,n,i.id,i.id,i,i[Om],r.onDone,r.onFailure,r.onSnapshot,void 0):a},R_=(e,t,n,r,i,a)=>{let o=k_(t),s=bh(e,i).filter(e=>r.active.has(e)).flatMap(i=>{let s={...xp(r)??{self:t.self,parent:t.parent},children:o,state:r.values.get(i),containingState:Fp(e,r,i),ancestors:Pp(e,r,i),event:a};return zm(tm(e,i)?.invoke).map(e=>`child`in e&&!(`input`in e)?L_(t,n,i,e):I_(t,n,i,A_(e,s,i)))});return s.length===0?void 0:j_(s)},z_=Symbol(`effect/Machine/CompiledStoppedCompletion`),B_=class{logic;options;services;id;sessionId;inspectionSubject;send;sendInspected(e,t,n){return this.offerEvent(e,t,n)}[Hg](e){return this.sendAcknowledgedEffect(e)}[zg](e){let t=this.snapshotObservers??=new Set;return t.add(e),()=>{t.delete(e)}}mailbox={items:void 0,index:0,closed:!1};address;childRuntime=x_;processScope;processContext;compiledContext;current;lifecycle=`Active`;runState=`Initializing`;completion;waiter;termination;terminationSnapshot;worker;interruptRequested=!1;offerRevision=0;snapshotObservers;changesFlushScheduled=!1;inFlightMessage;externalEmissions;emissionsPubSub;activity;initialEntryPaths;initialMicrosteps;initializing;constructor(e,t,n,r){this.logic=e,this.options=t,this.services=n,this.sessionId=r,this.id=t.id??r;let i=t.runtime.inspection;i!==void 0&&(this.inspectionSubject=u_(e,this.id,r),this.initializing=!0,t.activity!==void 0&&(this.activity={...t.activity,sessionId:r})),this.externalEmissions=t.emissions,this.send=i===void 0?e=>this.offerMessage(e):e=>this.offerEvent(e,void 0,void 0),this.address={id:this.id,sessionId:r,stop:V(()=>this.stopFromProcess()),send:this.send,...i===void 0?void 0:{inspectionSubject:this.inspectionSubject,sendInspected:(e,t,n)=>this.offerEvent(e,t,n)}}}get inspector(){return this.options.runtime.inspection}causation(){return d_(this.inFlightMessage,this.initializing===!0)}publishCreated(){let e=this.inspector,t=this.inspectionSubject;e!==void 0&&t!==void 0&&e.publishUnsafe(this.activity===void 0?{_tag:`Created`,subject:t,parent:this.options.parent?.inspectionSubject,origin:this.options.origin??{_tag:`Root`},definition:this.logic.inspection?.definition}:{_tag:`ActivityStarted`,subject:this.activity.owner,activity:this.activity})}publishInitialized(e){if(this.initializing=!1,this.activity!==void 0)return;let t=this.inspector,n=this.inspectionSubject;t!==void 0&&n!==void 0&&t.publishUnsafe({_tag:`Initialized`,subject:n,snapshot:{status:`active`,state:e},initialEntryPaths:this.initialEntryPaths??[],microsteps:Lg({microsteps:this.initialMicrosteps??[]})})}publishStartFailed(e){this.initializing=!1;let t=this.inspector,n=this.inspectionSubject;t!==void 0&&n!==void 0&&t.publishUnsafe(this.activity===void 0?{_tag:`StartFailed`,subject:n,cause:e}:{_tag:`ActivityStopped`,subject:this.activity.owner,activity:this.activity,exit:$e(e)})}get execution(){return this.logic.execution}initializeCompiledSync(){this.publishCreated(),this.execution.childless||(this.childRuntime=S_(this.address,this.options.runtime,this.services,e=>this.sendAcknowledgedEffect(e)));let e=this.options.parent,t=this.options.sendParent??(e===void 0?g_:this.inspector===void 0?e.send:t=>Xg(e,t,this.inspectionSubject,this.causation()));this.processScope={self:this.address,parent:e,spawn:this.childRuntime.spawn,sendParent:t,emit:e=>this.emitEvent(e),sendTo:((e,t)=>Yg(e)?this.inspector===void 0?e.send(t):Xg(e,t,this.inspectionSubject,this.causation()):this.childRuntime.sendTo(e,t,this.inspectionSubject,this.causation())),stopChild:this.childRuntime.stop,failCause:e=>this.failCause(e),inspectInitial:this.inspector===void 0?__:(e,t=[])=>{this.initialEntryPaths=e,this.initialMicrosteps=t}};let n=this.execution.initialSync,r;try{r=n(this.processScope)}catch(e){return this.runState=`Idle`,this.publishStartFailed(br(e)),Jt(e)}return this.runState=`Idle`,this.current={revision:0,terminalizing:!1,changes:void 0,snapshot:{status:`active`,state:r.state}},this.publishInitialized(r.state),this.compiledContext=new V_(this.processScope,this.childRuntime.owned,this),`executionState`in r&&(this.compiledContext.executionState=r.executionState),this.options.onReadySync!==void 0&&!this.options.onReadySync(this)&&this.requestTerminationSync({_tag:`Stopped`}),r.done===!0&&this.lifecycle===`Active`&&this.requestTerminationSync({_tag:`Done`,output:r.output}),r.done===!1&&this.execution.childless&&this.lifecycle===`Active`&&this.mailbox.items===void 0?ke(this):(this.runState=`Draining`,at(this.drainRuntime(),this.services).pipe(pe(this)))}initialize(){let e=this;return Sn(function*(){e.publishCreated(),e.execution.childless||(e.childRuntime=yield*C_(e.address,e.options.runtime,e.services,t=>e.sendAcknowledgedEffect(t)));let t=e.options.parent,n=e.options.sendParent??(t===void 0?g_:e.inspector===void 0?t.send:n=>Xg(t,n,e.inspectionSubject,e.causation()));e.processScope={self:e.address,parent:t,spawn:e.childRuntime.spawn,sendParent:n,emit:t=>e.emitEvent(t),sendTo:((t,n)=>Yg(t)?e.inspector===void 0?t.send(n):Xg(t,n,e.inspectionSubject,e.causation()):e.childRuntime.sendTo(t,n,e.inspectionSubject,e.causation())),stopChild:e.childRuntime.stop,failCause:t=>e.failCause(t),inspectInitial:e.inspector===void 0?__:(t,n=[])=>{e.initialEntryPaths=t,e.initialMicrosteps=n}};let r=t=>m(t)?e.childRuntime.close(t):z,i=e.execution.initial,a=yield*(i===void 0?e.logic.initial(e.processScope).pipe(Ut(e=>({state:e,done:void 0,output:void 0}))):i(e.processScope)).pipe(Qt(t=>(m(t)&&e.publishStartFailed(t.cause),r(t))),Dr(U(()=>{e.runState=`Idle`}))),o=a.state;return e.current={revision:0,terminalizing:!1,changes:void 0,snapshot:{status:`active`,state:o}},e.publishInitialized(o),e.execution.drain._tag===`Process`?e.processContext={...e.processScope,receive:di,poll:U(()=>I($g(e.mailbox),Gg)),receiveMessage:di,pollMessage:U(()=>e.pollCompiledMessage()),completeMessage:t=>e.completeCompiledMessage(t),state:U(()=>e.current.snapshot.state),setState:t=>e.setActiveState(t),updateState:t=>e.updateState(t)}:(e.compiledContext=new V_(e.processScope,e.childRuntime.owned,e),`executionState`in a&&(e.compiledContext.executionState=a.executionState)),e.options.onReadySync!==void 0&&!e.options.onReadySync(e)?yield*e.requestTermination({_tag:`Stopped`}):e.options.onReady!==void 0&&(yield*e.options.onReady(e,e.requestTermination({_tag:`Stopped`}).pipe(Pt))),e.options.onSnapshot!==void 0&&(yield*c_(e.options.onSnapshot,{status:`active`,state:o})),a.done===!0&&e.lifecycle===`Active`&&(yield*e.requestTermination({_tag:`Done`,output:a.output})),a.done===!1&&e.execution.childless&&e.lifecycle===`Active`&&e.mailbox.items===void 0||(e.runState=`Draining`,yield*e.drainRuntime()),e})}get state(){return U(()=>this.current.snapshot.state)}get snapshot(){return U(()=>this.current.snapshot)}get changes(){return this.changesStream()}get emissions(){return this.externalEmissions?.stream??this.emissionsStream()}get join(){return V(()=>this.lifecycle===`Completed`?this.resolveCompletion(this.completion):(this.waiter??=te(),Wn(this.waiter)))}get stop(){return h(this.stopEffect())}child(e){return this.childRuntime.get(e)}childChanges(e){return this.childRuntime.changes(e)}requestTermination(e){return U(()=>this.requestTerminationSync(e))}hasTerminationRequest(){return this.lifecycle===`TerminationRequested`}requestTerminationSync(e){return this.lifecycle===`Active`&&(this.lifecycle=`TerminationRequested`,this.termination=e,this.terminationSnapshot=this.reserveTermination(e),!0)}reserveTermination(e){let t=this.current;if(t===void 0||t.terminalizing||t.snapshot.status!==`active`)return;let n=e._tag===`Stopped`?{status:`stopped`,state:t.snapshot.state}:e._tag===`Done`?{status:`done`,state:t.snapshot.state,output:e.output}:{status:`error`,state:t.snapshot.state,cause:e.cause};return this.current={...t,terminalizing:!0},n}stopFromProcess(){let e=this.requestTermination({_tag:`Stopped`}).pipe(Pt);return this.runState===`Initializing`?e:e.pipe(G(_r))}failCause(e){let t={_tag:`Failure`,cause:e};return this.requestTermination(t).pipe(q(e=>e?dn(this.settleRequestedTermination()).pipe(Pt):z))}sendAcknowledgedEffect(e){return xt(t=>Ue().pipe(q(n=>this.offerEvent(e,void 0,void 0,n).pipe(G(t(Wn(n)))))))}offerEvent(e,t,n,r){return V(()=>{let i=this.inspector,a=this.inspectionSubject,o=i?.isActive()===!0&&a!==void 0?f_(i,a,e,t,n,r):r===void 0?e:{[Ug]:!0,event:e,deferred:r};return this.offerMessage(o)})}offerMessage(e){return h(gt(t=>{if(this.mailbox.closed||this.lifecycle!==`Active`)return Jt(new Pd);let n=this.inspector,r=this.inspectionSubject;n!==void 0&&r!==void 0&&p_(n,r,e),this.offerRevision+=1;let i=this.execution.drain,a=this.compiledContext,o=this.runState===`Idle`&&a!==void 0&&i._tag===`Owned`?i.runSync:void 0;if(o===void 0&&Qg(this.mailbox,e),this.runState!==`Idle`)return z;if(this.runState=`Draining`,o!==void 0){let n;try{n=o(a,e)}catch(e){n=or(e)}return n!==void 0||this.hasTerminationRequest()?this.startWorker(n):(this.runState=`Idle`,this.scheduleChangesFlush(t.currentDispatcher),z)}return this.startWorker(void 0)}))}startWorker(e){let t=at(this.drainRuntime(e),this.services);return(this.options.detached===!0?dn(t,{startImmediately:!0}):Gr(t,{startImmediately:!0})).pipe(q(e=>U(()=>(e.pollUnsafe()===void 0&&(this.worker=e),this.interruptRequested?(this.interruptRequested=!1,!0):!1)).pipe(q(t=>t?dn(this.interruptAndFinish(e)):z))),Pt)}stopEffect(){return V(()=>this.lifecycle===`Completed`||this.finishIdleChildlessStop()?z:this.requestTermination({_tag:`Stopped`}).pipe(q(e=>e?this.settleRequestedTermination():this.awaitCompletion())))}finishIdleChildlessStop(){if(!this.execution.childless||this.runState!==`Idle`||this.worker!==void 0||this.lifecycle!==`Active`||this.options.onOutcome!==void 0&&this.options.skipStoppedOutcome!==!0||this.options.onStop!==void 0||this.inspector!==void 0||this.current.changes!==void 0||this.externalEmissions!==void 0||this.emissionsPubSub!==void 0&&this.emissionsPubSub!==y_||this.current.terminalizing||this.current.snapshot.status!==`active`)return!1;this.emissionsPubSub=y_;let e={status:`stopped`,state:this.current.snapshot.state};return this.lifecycle=`TerminationRequested`,this.termination={_tag:`Stopped`},this.terminationSnapshot=e,e_(this.mailbox),this.current={revision:this.current.revision+1,terminalizing:!0,changes:void 0,snapshot:e},this.notifySnapshotObservers(),Jg(this.inFlightMessage),this.inFlightMessage=void 0,this.interruptRequested=!1,this.compiledContext!==void 0&&(this.compiledContext.executionState=void 0),this.options.onStopSync?.(this),this.completion=z_,this.lifecycle=`Completed`,this.waiter!==void 0&&(zn(this.waiter,this.resolveCompletion(z_)),this.waiter=void 0),!0}settleRequestedTermination(){return V(()=>this.runState===`Draining`?this.worker===void 0?(this.interruptRequested=!0,this.awaitCompletion()):this.interruptAndFinish(this.worker).pipe(G(this.awaitCompletion())):this.finishRequestedTermination())}interruptAndFinish(e){return wt(e).pipe(G(V(()=>this.lifecycle===`Completed`?z:this.finishRequestedTermination())))}awaitCompletion(){return this.lifecycle===`Completed`?z:this.join.pipe(Fn,Pt)}resolveCompletion(e){if(e!==z_)return e;let t=Jt(new Pd);return this.completion=t,t}drainRuntime(e){let t=this;return xt(n=>Sn(function*(){let r=t.offerRevision,i=e;for(;;){if(t.hasTerminationRequest())return yield*t.finishRequestedTermination();let e=yield*n(V(()=>{if(i!==void 0){let e=i;return i=void 0,e}let e=t.execution.drain;return e._tag===`Process`?e.run(t.processContext):e.run(t.compiledContext)})).pipe(Fn);if(t.flushPendingChanges(),m(e))return t.lifecycle===`Active`&&(yield*t.requestTermination({_tag:`Failure`,cause:e.cause})),yield*t.finishRequestedTermination();if(mt(e.value))return yield*t.requestTermination({_tag:`Done`,output:e.value.value}),yield*t.finishRequestedTermination();if(t.hasTerminationRequest())return yield*t.finishRequestedTermination();if(t.offerRevision!==r)r=t.offerRevision;else{t.runState=`Idle`,t.worker=void 0;return}}}))}finishRequestedTermination(){return V(()=>{if(this.lifecycle!==`TerminationRequested`)return z;let e=this.termination;if(e===void 0)return z;let t=this.terminationSnapshot??this.reserveTermination(e);if(t===void 0)return this.awaitCompletion();let n=e._tag===`Stopped`?ht:e._tag===`Done`?ae(e.output):$e(e.cause),r=e._tag===`Stopped`?z_:e._tag===`Done`?ke(e.output):fr(e.cause),i=this.options.onOutcome===void 0||e._tag===`Stopped`&&this.options.skipStoppedOutcome===!0?z:V(()=>this.options.onOutcome(s_(t))).pipe(Fn,Pt),a=this.inspector,o=this.inspectionSubject,s=a===void 0||o===void 0?this.closeEmissions():this.closeEmissions().pipe(G(U(()=>a.publishUnsafe(this.activity===void 0?{_tag:`Terminated`,subject:o,snapshot:t}:{_tag:`ActivityStopped`,subject:this.activity.owner,activity:this.activity,exit:t.status===`stopped`?mi():n}))));return h(U(()=>{e_(this.mailbox)}).pipe(G(this.childRuntime.close(n)),G(this.setAndPublishSnapshot(t)),G(s),G(U(()=>{e._tag===`Failure`?qg(this.inFlightMessage,e.cause):Jg(this.inFlightMessage),this.inFlightMessage=void 0})),G(i),G(this.options.onStop??z),G(this.options.inspectionRoot===!0&&this.inspector!==void 0?this.inspector.close:z),G(U(()=>{this.options.onStopSync?.(this),this.runState=`Idle`,this.worker=void 0,this.interruptRequested=!1,this.compiledContext!==void 0&&(this.compiledContext.executionState=void 0),this.completion=r,this.lifecycle=`Completed`,this.waiter!==void 0&&(zn(this.waiter,this.resolveCompletion(r)),this.waiter=void 0)}))))})}publishSnapshot(e){let t=e.changes===void 0?ke(e):We(e.changes,[e]).pipe(pe(e)),n=e.snapshot;return this.options.onSnapshot===void 0||n.status!==`active`?t:t.pipe(P(()=>c_(this.options.onSnapshot,n)))}completeChanges(e){return e.changes===void 0?z:We(e.changes,ae(void 0)).pipe(Pt)}emitEvent(e){let t=this.externalEmissions===void 0?V(()=>this.emissionsPubSub===void 0||this.emissionsPubSub===y_?z:We(this.emissionsPubSub,e).pipe(Pt)):this.externalEmissions.emit(e),n=this.inspector,r=this.inspectionSubject;return n===void 0||r===void 0?t:t.pipe(P(()=>U(()=>n.publishUnsafe({_tag:`Emitted`,subject:r,emission:e,causedBy:this.causation()}))))}shutdownEmissions(){return this.closeEmissions()}closeEmissions(){if(this.externalEmissions!==void 0)return this.externalEmissions.close();let e=this.emissionsPubSub;return this.emissionsPubSub=y_,e===void 0||e===y_?z:ce(e)}getOrCreateEmissions(){return V(()=>{let e=this.emissionsPubSub;return e===y_?ke(void 0):e===void 0?hi().pipe(q(e=>U(()=>{let t=this.emissionsPubSub;return t===y_?[void 0,!0]:t===void 0?(this.emissionsPubSub=e,[e,!1]):[t,!0]}).pipe(q(([t,n])=>n?ce(e).pipe(pe(t)):ke(t))))):ke(e)})}emissionsStream(){return Bn(this.getOrCreateEmissions().pipe(Ut(e=>e===void 0?kn:ui(e))))}setAndPublishSnapshot(e){return V(()=>{this.flushPendingChanges();let t={revision:this.current.revision+1,snapshot:e,terminalizing:!0,changes:this.current.changes};return this.current=t,this.notifySnapshotObservers(),this.publishSnapshot(t).pipe(q(e=>this.completeChanges(e)),Pt)})}setActiveState(e){return V(()=>this.commitActiveState(e)??z)}pollCompiledMessage(){let e=$g(this.mailbox);return mt(e)&&(this.inFlightMessage=Wg(e.value)?e.value:void 0),e}beginCompiledMessage(e){this.inFlightMessage=Wg(e)?e:void 0}completeCompiledMessage(e){Kg(this.inFlightMessage,e),this.inFlightMessage=void 0}compiledState(){return this.current.snapshot.state}commitCompiledState(e){return this.commitActiveState(e,!0)}commitActiveState(e,t=!1){let n=this.current;if(n.terminalizing||n.snapshot.status!==`active`)return;let r=n.pendingChanges;r!==void 0&&(n.pendingChanges=void 0);let i={status:`active`,state:e},a={revision:n.revision+1,snapshot:i,terminalizing:!1,changes:n.changes};return this.current=a,a.changes!==void 0&&(r===void 0?t?a.pendingChanges=[a]:N(a.changes,[a]):(r.push(a),t?a.pendingChanges=r:N(a.changes,r))),this.notifySnapshotObservers(),this.options.onSnapshot===void 0?void 0:c_(this.options.onSnapshot,i)}notifySnapshotObservers(){if(this.snapshotObservers!==void 0)for(let e of this.snapshotObservers)e()}scheduleChangesFlush(e){this.changesFlushScheduled||this.current.pendingChanges===void 0||(this.changesFlushScheduled=!0,e.scheduleTask(()=>{this.changesFlushScheduled=!1,this.flushPendingChanges()},0))}flushPendingChanges(){let e=this.current,t=e?.pendingChanges;t!==void 0&&e.changes!==void 0&&(e.pendingChanges=void 0,N(e.changes,t))}updateState(e){return V(()=>{let t=this.current;return t.terminalizing||t.snapshot.status!==`active`?z:e(t.snapshot.state).pipe(q(e=>{let n=this.current;return n.terminalizing||n.revision!==t.revision?z:this.setActiveState(e)}))})}getOrCreateChanges(){return V(()=>{let e=this.current;return e.snapshot.status===`active`?e.changes===void 0?hi({replay:1}).pipe(q(e=>U(()=>{let t=this.current;return t.snapshot.status===`active`?t.changes===void 0?(this.current={...t,changes:e},[e,!1]):[t.changes,!0]:[void 0,!0]}).pipe(q(([t,n])=>n?ce(e).pipe(pe(t)):ke(t))))):ke(e.changes):ke(void 0)})}changesStream(){let e=this;return Bn(Sn(function*(){let t=yield*e.getOrCreateChanges();if(t===void 0)return ze(e.current.snapshot);let n=yield*we(t),r=e.current;return r.snapshot.status===`active`?ze(r.snapshot).pipe($n(Yr(Oe(et(n))).pipe(Ht(e=>e.revision>r.revision),it(e=>e.snapshot)))):ze(r.snapshot)}))}},V_=class{scope;ownedChildren;process;executionState;constructor(e,t,n){this.scope=e,this.ownedChildren=t,this.process=n}poll(){return I(this.process.pollCompiledMessage(),Gg)}pollMessage(){return this.process.pollCompiledMessage()}beginMessage(e){this.process.beginCompiledMessage(e)}state(){return this.process.compiledState()}completeMessage(e){this.process.completeCompiledMessage(e)}commit(e){return this.process.commitCompiledState(e)}runAfterChanges(e){return this.process.flushPendingChanges(),e}},H_=an(function*(e,t){let n=t.sessionId??(yield*t.runtime.nextSessionId),r=yield*Br(),i=e.execution,a=new B_(e,t,r,n);return yield*(i.initialSync!==void 0&&t.onReady===void 0&&t.onSnapshot===void 0?a.initializeCompiledSync():a.initialize()).pipe(Qt(e=>m(e)?a.shutdownEmissions().pipe(G(t.inspectionRoot===!0&&t.runtime.inspection!==void 0?t.runtime.inspection.close:z)):z))}),U_=(e,t,n,r)=>new B_(e,t,n,r).initializeCompiledSync(),W_=an(function*(e,t){let{detached:n,id:r,onOutcome:i,onReady:a,onReadySync:o,onSnapshot:s,onStop:c,onStopSync:l,parent:u,runtime:d,sendParent:f}=t,p=t.sessionId??(yield*d.nextSessionId),g=r??p,_=d.inspection,v=_===void 0?void 0:u_(e,g,p),y=_===void 0||t.activity===void 0?void 0:{...t.activity,sessionId:p},b,x,S=t_(),C=t.emissions??b_(),w=yield*Ue(),T=yield*Ue(),E=Wn(T).pipe(Fn,Pt),D=!0,O,k=Ce(w,{_tag:`Stopped`}).pipe(Pt),A=(e,t)=>V(()=>n_(S,e,t)?z:Jt(new Pd)),j=_===void 0?void 0:(e,t,n,r)=>V(()=>{let i=_.isActive()?f_(_,v,e,t,n,r):r===void 0?e:{[Ug]:!0,event:e,deferred:r};return A(i,()=>p_(_,v,i))}),M=e.execution?._tag===`Compiled`?e=>xt(t=>Ue().pipe(q(n=>(_===void 0?A({[Ug]:!0,event:e,deferred:n}):j(e,void 0,void 0,n)).pipe(G(t(Wn(n))))),Ut(e=>e))):void 0,ee={id:g,sessionId:p,stop:V(()=>D?k:k.pipe(G(di))),send:_===void 0?e=>A(e):e=>j(e,void 0,void 0),..._===void 0?void 0:{inspectionSubject:v,sendInspected:j}},{changes:te,close:N,get:F,owned:ne,sendTo:re,spawn:L,stop:R}=x_;Zg(e.execution)||({changes:te,close:N,get:F,owned:ne,sendTo:re,spawn:L,stop:R}=yield*C_(ee,d,void 0,M===void 0?void 0:e=>M(e)));let B=e=>bt(e)?z:(_!==void 0&&_.publishUnsafe(y===void 0?{_tag:`StartFailed`,subject:v,cause:e.cause}:{_tag:`ActivityStopped`,subject:y.owner,activity:y,exit:e}),N(e).pipe(G(C.close()),G(t.inspectionRoot===!0&&_!==void 0?_.close:z))),oe=l===void 0?c??z:U(()=>l(Ke)),ce=_===void 0?v_:()=>d_(O,D),le=f??(u===void 0?g_:_===void 0?u.send:e=>Xg(u,e,v,ce())),ue=_===void 0?C.emit:e=>C.emit(e).pipe(P(()=>U(()=>_.publishUnsafe({_tag:`Emitted`,subject:v,emission:e,causedBy:ce()})))),de={self:ee,parent:u,spawn:L,sendParent:le,emit:ue,sendTo:_===void 0?((e,t)=>Yg(e)?e.send(t):re(e,t)):((e,t)=>Yg(e)?Xg(e,t,v,ce()):re(e,t,v,ce())),stopChild:R,failCause:e=>Ce(w,{_tag:`Failure`,cause:e}).pipe(Pt),inspectInitial:_===void 0?__:(e,t=[])=>{b=e,x=t}};_!==void 0&&_.publishUnsafe(y===void 0?{_tag:`Created`,subject:v,parent:u?.inspectionSubject,origin:t.origin??{_tag:`Root`},definition:e.inspection?.definition}:{_tag:`ActivityStarted`,subject:y.owner,activity:y});let fe=yield*e.initial(de).pipe(Qt(B),Dr(U(()=>{D=!1}))),me=yield*nr({revision:0,terminalizing:!1,changes:void 0,snapshot:{status:`active`,state:fe}});y===void 0&&_?.publishUnsafe({_tag:`Initialized`,subject:v,snapshot:{status:`active`,state:fe},initialEntryPaths:b??[],microsteps:Lg({microsteps:x??[]})});let he=s===void 0?e=>e.changes===void 0?ke(e):We(e.changes,[e]).pipe(pe(e)):e=>{let t=e.changes===void 0?ke(e):We(e.changes,[e]).pipe(pe(e)),n=e.snapshot;return n.status===`active`?t.pipe(P(()=>c_(s,n))):t},ge=e=>e.changes===void 0?z:We(e.changes,ae(void 0)).pipe(Pt),_e=e=>e.snapshot.status===`active`?ke(e):ge(e).pipe(pe(e)),ve=e=>Fr(me).pipe(q(t=>t.revision===e.revision?he(e).pipe(q(_e)):ke(void 0))),ye=e=>jn(me,t=>t.terminalizing?ke([void 0,t]):Ut(e(t.snapshot),e=>{if(e===void 0)return[void 0,t];let n={revision:t.revision+1,snapshot:e,terminalizing:!1,changes:t.changes};return[n,n]})).pipe(q(e=>e===void 0?ke(void 0):ve(e)),Ut(e=>e?.snapshot)),be=e=>Cr(me,t=>t.terminalizing||t.snapshot.status!==`active`?[void 0,t]:[{revision:t.revision+1,snapshot:e(t.snapshot),terminalizing:!0,changes:t.changes},{...t,terminalizing:!0}]).pipe(Ut(e=>e?.snapshot)),xe=e=>Gt(me,t=>({revision:t.revision+1,snapshot:e,terminalizing:!0,changes:t.changes})).pipe(q(he),q(_e),Pt),Se=_===void 0?e=>ye(t=>ke(t.status===`active`?{status:`active`,state:e}:void 0)).pipe(Pt):t=>Fr(me).pipe(q(n=>ye(e=>ke(e.status===`active`?{status:`active`,state:t}:void 0)).pipe(P(r=>U(()=>{e.inspection?.kind!==`Machine`&&r!==void 0&&_.publishUnsafe({_tag:`StateChanged`,subject:v,before:n.snapshot.state,after:t,causedByDeliveryId:O!==void 0&&Wg(O)?O.inspection?.deliveryId:void 0})})))),Pt),Te=(e,n,r)=>{let a=i===void 0||e.status===`stopped`&&t.skipStoppedOutcome===!0?z:V(()=>i(s_(e))).pipe(Fn,Pt),o=_===void 0?C.close():C.close().pipe(G(U(()=>_.publishUnsafe(y===void 0?{_tag:`Terminated`,subject:v,snapshot:e}:{_tag:`ActivityStopped`,subject:y.owner,activity:y,exit:e.status===`stopped`?mi():n}))));return h(U(()=>i_(S)).pipe(G(N(n)),G(xe(e)),G(o),G(U(()=>{m(n)?qg(O,n.cause):Jg(O),O=void 0})),G(a),G(oe),G(t.inspectionRoot===!0&&_!==void 0?_.close:z),G(r)))},Ee=be(e=>({status:`stopped`,state:e.state})),Ae=e=>be(t=>({status:`error`,state:t.state,cause:e})),je=e=>be(t=>({status:`done`,state:t.state,output:e})),Me=e=>Te(e,ht,De(T,new Pd)),Pe=(e,t)=>{let n=$e(t);return Te(e,n,Ne(T,t))},Fe=(e,t)=>{let n=ae(t);return Te(e,n,Ce(T,t))},Ie=h(k.pipe(G(E))),Le=e.execution?._tag===`Compiled`?{receiveMessage:r_(S).pipe(P(e=>U(()=>{O=Wg(e)?e:void 0}))),pollMessage:U(()=>$g(S)).pipe(P(e=>U(()=>{mt(e)&&(O=Wg(e.value)?e.value:void 0)}))),completeMessage:e=>{Kg(O,e),O=void 0}}:void 0,Re=_===void 0||e.execution?._tag===`Compiled`?r_(S).pipe(Ut(Gg)):r_(S).pipe(P(e=>U(()=>{O=e})),Ut(Gg)),Be=_===void 0||e.execution?._tag===`Compiled`?U(()=>$g(S)).pipe(Ut(I(Gg))):U(()=>$g(S)).pipe(P(e=>U(()=>{mt(e)&&(O=e.value)})),Ut(I(Gg))),H=_===void 0?e=>ye(t=>t.status===`active`?e(t.state).pipe(Ut(e=>({status:`active`,state:e}))):ke(void 0)).pipe(Pt):t=>Fr(me).pipe(q(n=>ye(e=>e.status===`active`?t(e.state).pipe(Ut(e=>({status:`active`,state:e}))):ke(void 0)).pipe(P(t=>U(()=>{e.inspection?.kind!==`Machine`&&t?.status===`active`&&_.publishUnsafe({_tag:`StateChanged`,subject:v,before:n.snapshot.state,after:t.state,causedByDeliveryId:O!==void 0&&Wg(O)?O.inspection?.deliveryId:void 0})})))),Pt),Ve={...de,...e.execution?._tag===`Compiled`&&!e.execution.childless?{ownedChildren:ne}:void 0,...Le,receive:Re,poll:Be,state:Fr(me).pipe(Ut(e=>e.snapshot.state)),setState:Se,updateState:H},He=jn(me,e=>e.snapshot.status===`active`?e.changes===void 0?hi({replay:1}).pipe(Ut(t=>[t,{...e,changes:t}])):ke([e.changes,e]):ke([void 0,e])),Ge=Bn(Sn(function*(){let e=yield*He;if(e===void 0)return ze((yield*Fr(me)).snapshot);let t=yield*we(e),n=yield*Fr(me);return n.snapshot.status===`active`?ze(n.snapshot).pipe($n(Yr(Oe(et(t))).pipe(Ht(e=>e.revision>n.revision),it(e=>e.snapshot)))):ze(n.snapshot)})),Ke={id:g,sessionId:p,..._===void 0?void 0:{inspectionSubject:v,sendInspected:j},state:Fr(me).pipe(Ut(e=>e.snapshot.state)),snapshot:Fr(me).pipe(Ut(e=>e.snapshot)),changes:Ge,emissions:C.stream,join:Wn(T),stop:Ie,send:ee.send,...M===void 0?void 0:{[Hg]:M},child:F,childChanges:te};o!==void 0&&!o(Ke)?yield*k:a!==void 0&&(yield*a(Ke,k)),s!==void 0&&(yield*c_(s,{status:`active`,state:fe}));let qe=e=>{switch(e._tag){case`Stopped`:return Ee;case`Done`:return je(e.output);case`Failure`:return Ae(e.cause)}},Je=(e,t)=>{switch(e._tag){case`Stopped`:return Me(t);case`Done`:return Fe(t,e.output);case`Failure`:return Pe(t,e.cause)}},Ye=e=>n===!0?dn(e,{startImmediately:!0}):Gr(e,{startImmediately:!0}),Xe=yield*se(w),Ze=ie(Xe)?yield*xt(t=>t(V(()=>e.run(Ve))).pipe(Fn,q(e=>Ce(w,m(e)?{_tag:`Failure`,cause:e.cause}:{_tag:`Done`,output:e.value})))).pipe(Ye):void 0;return yield*Ye(xt(e=>Sn(function*(){let t=mt(Xe)?yield*Xe.value:yield*e(Wn(w)),n=yield*qe(t);return Ze!==void 0&&(yield*wt(Ze)),n===void 0?yield*E:yield*Je(t,n)}))),Ke}),G_=((e,t)=>e.execution?._tag===`Compiled`?H_(e,t):W_(e,t)),K_=l_(G_,U_),q_=new WeakMap,J_=e=>V(()=>{e.closed=!0;let t=Array.from(e.live).reverse();return e.live.clear(),Xn(t,e=>e.stop,{discard:!0})}),Y_=()=>{let e=new Set,t={live:e,hooks:{onReadySync:n=>!t.closed&&(e.add(n),!0),onStopSync:t=>{e.delete(t)}},closed:!1};return t},X_=e=>q(Kn,t=>{let n=q_.get(t);if(n!==void 0)return e(n.hooks);let r=Y_();return q_.set(t,r),G(lt(t,J_(r)),e(r.hooks))});an(function*(e,t,n){let r=yield*K_,i=n===void 0?{detached:!0,runtime:r}:{...n,detached:!0,runtime:r};return t===`generic`?yield*X_(t=>W_(e,{...i,...t})):t===`compiled`?e.execution?._tag===`Compiled`?yield*X_(t=>H_(e,{...i,...t})):yield*or(Error(`Machine cannot force the compiled runtime for generic process logic`)):yield*X_(t=>G_(e,{...i,...t}))});var Z_=an(function*(e,t){let n=yield*K_;return yield*X_(r=>G_(e,t===void 0?{detached:!0,runtime:n,...r}:{...t,detached:!0,runtime:n,...r}))}),Q_=an(function*(e,t,n){let r=yield*K_,i=yield*r.nextSessionId,a=yield*Pg(i);r.inspection=a;let o=b_(),s=yield*Ue(),c=n===void 0?{detached:!0,emissions:o,runtime:r,sessionId:i,inspectionRoot:!0,origin:{_tag:`Root`}}:{...n,detached:!0,emissions:o,runtime:r,sessionId:i,inspectionRoot:!0,origin:{_tag:`Root`}},u=yield*kt(X_(n=>{let r={...c,...n};return t===`generic`?W_(e,r):t===`compiled`?e.execution?._tag===`Compiled`?H_(e,r):or(Error(`Machine cannot force the compiled runtime for generic process logic`)):G_(e,r)}).pipe(Qt(e=>l(s,e))));return{id:n?.id??i,sessionId:i,changes:Bn(Wn(s).pipe(Ut(e=>e.changes))),emissions:o.stream,inspection:a.stream,start:u}}),$_=((e,t)=>Q_(e,`auto`,t));W({_tag:$t(`MachineSnapshot`),version:$t(2),active:tr(W({path:H,value:L(fi)})),completed:L(tr(W({path:H,output:L(fi)}))),history:L(M(H,W({mode:si([`shallow`,`deep`]),active:tr(H),values:M(H,fi)})))});var ev=(e,t,n)=>{let r=$(e,n);if(r.type===`compound`){let r=nm(e,t,n);if(r===void 0)throw Error(`Machine expected completed state "${n}" to have an active child`);return ev(e,t,r)}return r.output},tv=(e,t)=>Sn(function*(){let n=yield*qp(e,t),r=new Map,i=new Set,a=t.completed??[];if(!Array.isArray(a))throw Error(`Machine snapshot completion metadata must be an array`);for(let t of a){if(typeof t!=`object`||!t||typeof t.path!=`string`)throw Error(`Machine snapshot contains malformed completion metadata`);let a=t.path;if(i.has(a))throw Error(`Machine snapshot contains duplicate completion "${a}"`);if(!n.active.has(a)||!am(e,n,a))throw Error(`Machine snapshot contains invalid completion "${a}"`);i.add(a);let o=ev(e,n,a);if(o===void 0){if(t.output!==void 0)throw Error(`Machine snapshot contains an output for state "${a}" without an output schema`);r.set(a,void 0)}else r.set(a,yield*$f(e,o,t.output,{boundary:`output`,state:a}))}return Rp(e,{...n,outputs:r})}).pipe(Je(t=>nv(e,t))),nv=(e,t)=>{if(Nt(t))return fr(r(t,t=>t instanceof Ad?t:new Ad({machineId:e.id,boundary:`configuration`,cause:br(t)})));let n=fe(t);return mt(n)&&n.value instanceof Ad?Jt(n.value):Jt(new Ad({machineId:e.id,boundary:`configuration`,cause:t}))},rv=e=>e.length===0?z:e.length===1?e[0]:ve(e,{discard:!0}),iv=(e,t)=>({event:e.event,next:t(e.next),commands:e.commands,emittedEvents:e.emittedEvents,microsteps:e.microsteps.map(e=>({...e,transitions:e.transitions??[],next:t(e.next)})),done:e.done,output:e.output}),av=new WeakMap,ov=e=>{let t=av.get(e);if(t!==void 0)return t;let n=Object.values(Rd(e).handlers).some(e=>e.invoke!==void 0);return av.set(e,n),n},sv=ke(yr()),cv=(e,t)=>{let n=wg(e),r=new WeakMap,i=t=>{let n=r.get(t.scope);return n===void 0&&(n=Yh(e,t.scope),r.set(t.scope,n)),n},a=n=>{if(!t)return;let r=n.state();return Hh(e,r)?Uh(e,r,Vh).pipe(Ut(Mt)):void 0},o=e=>V(()=>c(e)??sv),s=(e,t,r,a,s)=>{let c=a.commands.length===0?void 0:Xh(a.commands,e.scope),l=a.emittedEvents.length===0?void 0:Zh(a.emittedEvents,i(e)),u=()=>{let i=V(()=>(t&&e.completeMessage({before:r,plan:iv(a,n.snapshot),after:s}),a.done?ke(Mt(a.output)):o(e)));return l===void 0?i:l.pipe(G(i))},d=()=>{let t=e.commit(s),n=u(),r=t===void 0?n:t.pipe(G(n));return t===void 0&&l===void 0?r:e.runAfterChanges(r)};return c===void 0?d():e.runAfterChanges(c.pipe(G(V(d))))},c=(t,r)=>{let i=r;for(;;){let r;if(i!==void 0)r=i,i=void 0,t.beginMessage(r);else{let e=t.pollMessage();if(ie(e))return;r=e.value}let a=Wg(r),c=a?r.event:r,l=t.state(),u;try{u=n.plan(t.executionState??n.fromConfiguration(Gp(e,l)),c,a,t.scope)}catch(e){return Id(e)}if(t.executionState=u.next,u.microsteps.length===0){a&&t.completeMessage({before:l,plan:iv(u,n.snapshot),after:l});continue}let d=n.snapshot(u.next);if(u.commands.length>0||u.emittedEvents.length>0||u.done)return s(t,a,l,u,d);let f=t.commit(d);if(f!==void 0)return t.runAfterChanges(f.pipe(G(V(()=>(a&&t.completeMessage({before:l,plan:iv(u,n.snapshot),after:d}),o(t))))));a&&t.completeMessage({before:l,plan:iv(u,n.snapshot),after:d})}};return{run:e=>o_(a(e)??o(e),e.scope),runSync:(e,t)=>{let n=a(e);n!==void 0&&e.beginMessage(t);let r=n??c(e,t);return r===void 0?void 0:o_(r,e.scope)}}},lv=class{initialized=!1;initial;constructor(e){this.initial=e}},uv=(e,t)=>{let n=wg(e);return r=>{let i=r.state();if(t&&Hh(e,i))return Uh(e,i,Vh).pipe(Ut(Mt));let a=r.scope,o=r.executionState,s=o instanceof lv?o:new lv;r.executionState=s;let c,l,u;return u=V(()=>{let t=r.pollMessage();if(ie(t))return l=void 0,ke(yr());let o=t.value,s=Wg(o),d=s?o.event:o,f=i,p;try{p=n.plan(l??n.fromConfiguration(Gp(e,i)),d,s,a)}catch(e){return Id(e)}if(l=p.next,p.microsteps.length===0)return s&&r.completeMessage({before:f,plan:iv(p,n.snapshot),after:i}),u;let m=p.microsteps.some(e=>e.changed),h=m?p.microsteps.flatMap(e=>e.exitPaths):[],g=new Map;if(m){for(let e of p.microsteps)if(e.changed)for(let t of e.entryPaths)g.set(t,e.event)}let _=n.toConfiguration(p.next),v=n.snapshot(p.next),y=[];if(p.commands.length>0&&y.push(Xh(p.commands,a)),m){let e=r.ownedChildren.stopPaths(h);e!==void 0&&y.push(e)}let b=[];if(p.emittedEvents.length>0&&b.push(Zh(p.emittedEvents,c??=Yh(e,a))),p.done)b.push(r.ownedChildren.stopAll());else if(m)for(let[t,n]of g){let i=R_(e,a,r.ownedChildren,_,[t],n);i!==void 0&&b.push(i)}let x=()=>{let e=r.commit(v);return i=v,e},S=()=>{let e=V(()=>(s&&r.completeMessage({before:f,plan:iv(p,n.snapshot),after:v}),p.done?ke(Mt(p.output)):u));return b.length===0?e:rv(b).pipe(G(e))},C=()=>{let e=x(),t=S(),n=e===void 0?t:e.pipe(G(t));return e===void 0&&b.length===0?n:r.runAfterChanges(n)};return y.length===0?C():r.runAfterChanges(rv(y).pipe(G(V(C))))}),o_(V(()=>{if(s.initialized)return u;let t=s.initial,o=t?.activeConfiguration??Gp(e,i);l=t?.configuration??n.fromConfiguration(o);let c=R_(e,a,r.ownedChildren,o,t?.entryPaths??Ip(e,o),Vh);return s.initial=void 0,s.initialized=!0,c===void 0?u:c.pipe(G(u))}),a)}},dv=e=>e.done?{state:e.state,done:!0,output:e.output}:{state:e.state,done:!1,output:void 0},fv=(e,t)=>{let n=ov(e),r=wg(e),i=t._tag===`Initial`?t.args:[],a=t._tag===`Initial`?r.initial:void 0,o=a===void 0?void 0:e=>{try{let t=a(i,e);e.inspectInitial(t.initialEntryPaths);let r=dv(t);return n?{...r,executionState:new lv({configuration:t.configuration,activeConfiguration:t.activeConfiguration,entryPaths:t.initialEntryPaths})}:r}catch(e){throw Ld(e)}},s=t=>a===void 0?o_(Jh(nh(e,t),...i).pipe(q(n=>{t.inspectInitial(n.initialEntryPaths,n.microsteps);let r=n.commands.length===0?void 0:Xh(n.commands,t),i=n.emittedEvents.length===0?void 0:Zh(n.emittedEvents,Yh(e,t)),a=ke(dv(n));return r===void 0?i===void 0?a:i.pipe(G(a)):i===void 0?r.pipe(G(a)):r.pipe(G(i),G(a))})),t):gi({try:()=>o(t),catch:Ld});return{inspection:{kind:`Machine`,definition:e},execution:{_tag:`Compiled`,childless:!n,...t._tag===`Initial`?{initial:s}:{},...o===void 0?{}:{initialSync:o},drain:n?{_tag:`Owned`,run:uv(e,t._tag===`Resume`)}:{_tag:`Owned`,...cv(e,t._tag===`Resume`)}},initial:n=>t._tag===`Resume`?o_(tv(e,t.snapshot),n):s(n).pipe(Ut(e=>e.state)),run:t=>o_(Sn(function*(){let{completeMessage:r,pollMessage:i,receiveMessage:a,state:o,setState:s}=t;if(r===void 0||i===void 0||a===void 0)return yield*or(Error(`Machine statechart started without acknowledged mailbox access`));let c,l=yield*o;if(Hh(e,l))return yield*Uh(e,l,Vh);if(!n){let n,o=yr(),u;for(;c===void 0;){let d=mt(o)?o.value:yield*a;o=yr();let f=Wg(d),p=f?d.event:d,m=l,h;try{h=qh(e,bp(n??Gp(e,l),t),p)}catch(e){return yield*Id(e)}if(n=h.next,h.microsteps.length>0){let n=Rp(e,h.next);yield*Xh(h.commands,t),yield*s(n),l=n,h.emittedEvents.length>0&&(yield*Zh(h.emittedEvents,u??=Yh(e,t))),h.done&&(c={output:h.output})}f&&r({before:m,plan:iv(h,t=>Rp(e,t)),after:l}),c===void 0&&(o=yield*i,ie(o)&&(n=void 0))}return c===void 0?yield*or(Error(`Machine process stopped receiving events before reaching a terminal configuration`)):c.output}let u=t.ownedChildren;if(u===void 0)return yield*or(Error(`Invoking statechart started without an owned child runtime`));let d=(n,r,i)=>R_(e,t,u,n,r,i)??z,f=e=>u.stopPaths(e)??z;return yield*Sn(function*(){let n=yield*qp(e,l);yield*d(n,Ip(e,n),Vh),n=void 0;let o=yr(),p;for(;c===void 0;){let m=mt(o)?o.value:yield*a;o=yr();let h=Wg(m),g=h?m.event:m,_=l,v;try{v=qh(e,bp(n??Gp(e,l),t),g)}catch(e){return yield*Id(e)}if(n=v.next,v.microsteps.length>0){let n=v.microsteps.some(e=>e.changed),r=v.microsteps.flatMap(e=>e.exitPaths),i=new Map;for(let e of v.microsteps)if(e.changed)for(let t of e.entryPaths)i.set(t,e.event);let a=Rp(e,v.next);if(yield*Xh(v.commands,t),n&&(yield*f(r)),yield*s(a),l=a,v.emittedEvents.length>0&&(yield*Zh(v.emittedEvents,p??=Yh(e,t))),v.done)c={output:v.output},yield*u.stopAll();else if(n)for(let[e,t]of i)yield*d(v.next,[e],t)}h&&r({before:_,plan:iv(v,t=>Rp(e,t)),after:l}),c===void 0&&(o=yield*i,ie(o)&&(n=void 0))}return c===void 0?yield*or(Error(`Machine process stopped receiving events before reaching a terminal configuration`)):c.output}).pipe(Qt(()=>u.stopAll()))}),t)}},pv=new WeakMap,mv=(e,...t)=>{if(t.length>0)return fv(e,{_tag:`Initial`,args:t});let n=pv.get(e);if(n!==void 0)return n;let r=fv(e,{_tag:`Initial`,args:t});return pv.set(e,r),r},hv=(e,t)=>fv(e,{_tag:`Resume`,snapshot:t}),gv=(e,...t)=>$_(mv(e,...t),e.id===void 0?void 0:{id:e.id}),_v=(e,t)=>Z_(hv(e,t),e.id===void 0?void 0:{id:e.id}),vv={atomic:[`schema`,`type`,`annotations`],final:[`schema`,`type`,`output`,`annotations`],compound:[`schema`,`type`,`states`,`annotations`],parallel:[`schema`,`type`,`output`,`states`,`annotations`],history:[`type`,`history`,`annotations`],choice:[`type`,`annotations`]},yv=[`title`,`description`,`documentation`],bv=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),xv=(e,t)=>{let n=typeof t==`symbol`?`[${String(t)}]`:t===``?`<empty>`:String(t);return e===``?n:`${e}.${n}`},Sv=(e,t,n)=>{throw Error(`${e} invalid state definition at "${t}": ${n}`)},Cv=e=>Number.isFinite(Number(e)),wv=e=>e.length===0||e.some(e=>e===`untagged`)?`untagged`:e.every(e=>e===`tagged`)?`tagged`:`opaque`,Tv=(e,t)=>{if(t.has(e))return`opaque`;if(ir(e)||o(e)||Pn(e)||qt(e)||Mr(e)||zt(e))return`tagged`;if(Xe(e))return typeof e.literal==`string`||typeof e.literal==`number`?`tagged`:`untagged`;let n=new Set(t).add(e);return dr(e)?wv(e.types.map(e=>Tv(e,n))):Er(e)?Tv(e.thunk(),n):At(e)?`opaque`:`untagged`},Ev=(e,t=new Set)=>{if(t.has(e))return`opaque`;if(hn(e)){let n=e.propertySignatures.find(({name:e})=>e===`_tag`)?.type;return n===void 0||Rr(n)?`untagged`:Tv(n,new Set(t).add(e))}let n=new Set(t).add(e);return dr(e)?wv(e.types.map(e=>Ev(e,n))):Er(e)?Ev(e.thunk(),n):At(e)?`opaque`:`untagged`},Dv=e=>g(e)&&Ev(nn(e.ast))!==`untagged`,Ov=(e,t,n)=>{let r=xv(t,n);return typeof n==`symbol`?Sv(e,r,`state keys must be strings, not symbols`):typeof n==`number`?Sv(e,r,`state keys cannot use numeric forms`):n===``?Sv(e,r,`state keys cannot be empty`):n===`__proto__`?Sv(e,r,`the state key "__proto__" is not allowed`):n.includes(`.`)?Sv(e,r,`state keys cannot contain "."`):Cv(n)?Sv(e,r,`state keys cannot use numeric forms`):r},kv=(e,t,n,r)=>{(typeof n!=`object`||!n||Array.isArray(n))&&Sv(e,t,`${r} must be a plain record`);let i=Object.getPrototypeOf(n);i!==Object.prototype&&i!==null&&Sv(e,xv(t===`<root>`?``:t,`__proto__`),`${r} must not declare an implicit "__proto__" state key`)},Av=(e,t,n,r,i)=>{if(typeof n!=`object`||!n||Array.isArray(n)||!bv(n,r))return;let a=n[r];(typeof a!=`object`||!a||g(a)||a.type!==`history`)&&Sv(e,`${t}.${r}`,i)},jv=(e,t,n,r)=>{let i=vv[r];for(let a of Reflect.ownKeys(n))i.includes(a)||Sv(e,t,`${r} states cannot declare property "${String(a)}"`)},Mv=(e,t,n)=>{kv(e,`${t}.annotations`,n,`schema-less state annotations`);for(let r of Reflect.ownKeys(n))yv.includes(r)||Sv(e,`${t}.annotations`,`schema-less state annotations cannot declare property "${String(r)}"`),typeof n[r]!=`string`&&Sv(e,`${t}.annotations.${String(r)}`,`schema-less state annotation values must be strings`)},Nv=(e,t,n,r,i=!1)=>{kv(e,n===``?`<root>`:n,t,`state trees`);for(let a of Reflect.ownKeys(t)){let o=i&&a===``?``:Ov(e,n,a),s=t[a];if(g(s)){Dv(s)||Sv(e,o,`state schemas must decode to an object with a required PropertyKey _tag`);continue}kv(e,o,s,`state nodes`);let c=s.type,l=c===`history`?`history`:c===`choice`?`choice`:c===`parallel`?`parallel`:c===`final`?`final`:bv(s,`states`)?`compound`:`atomic`;if(jv(e,o,s,l),l===`history`||l===`choice`){r||Sv(e,o,`${l} states must be declared below an active parent state`),bv(s,`annotations`)&&Mv(e,o,s.annotations),l===`history`&&bv(s,`history`)&&s.history!==`shallow`&&s.history!==`deep`&&Sv(e,`${o}.history`,`history must be "shallow" or "deep"`);continue}let u=bv(s,`schema`);u&&!Dv(s.schema)&&Sv(e,`${o}.schema`,`state schemas must decode to an object with a required PropertyKey _tag`),u&&bv(s,`annotations`)&&Sv(e,`${o}.annotations`,`schema-backed states must declare annotations on their schema`),!u&&bv(s,`annotations`)&&Mv(e,o,s.annotations),l===`atomic`&&bv(s,`type`)&&s.type!==`active`&&Sv(e,`${o}.type`,`atomic state type must be "active"`),l===`final`&&s.type!==`final`&&Sv(e,`${o}.type`,`final state type must be "final"`),l===`compound`&&bv(s,`type`)&&s.type!==`active`&&Sv(e,`${o}.type`,`compound state type must be "active"`),l===`parallel`&&s.type!==`parallel`&&Sv(e,`${o}.type`,`parallel state type must be "parallel"`),(l===`final`||l===`parallel`)&&bv(s,`output`)&&!g(s.output)&&Sv(e,`${o}.output`,`state output must be an Effect Schema`),l===`compound`?(Av(e,o,s.states,`initial`,`active and choice child states cannot use the reserved target selector key "initial"`),u&&Av(e,o,s.states,`with`,`schema-backed compound child states cannot use the reserved local target selector key "with"`),Nv(e,s.states,o,!0)):l===`parallel`&&(bv(s,`states`)||Sv(e,`${o}.states`,`parallel states must declare child regions`),Av(e,o,s.states,`initial`,`active and choice child states cannot use the reserved target selector key "initial"`),Nv(e,s.states,o,!0))}},Pv=e=>typeof e==`object`&&e?Object.freeze({...e}):e,Fv=e=>{let t={};for(let n of Object.keys(e)){let r=e[n];if(g(r)){Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!1,writable:!1});continue}let i=r,a={...i};`states`in i&&(a.states=Fv(i.states)),`annotations`in i&&(a.annotations=Pv(i.annotations)),Object.defineProperty(t,n,{value:Object.freeze(a),enumerable:!0,configurable:!1,writable:!1})}return Object.freeze(t)},Iv=e=>Fv(e),Lv=(e,t=``)=>{if(g(e)||typeof e!=`object`||!e)return e;if(`~effect/Machine/State`in e&&e[`~effect/Machine/State`]===`~effect/Machine/State`&&`node`in e)return e.node;let n=e,r={...n};if(bv(n,`fields`)&&(bv(n,`schema`)&&Sv(`Machine.state`,t,`declare fields or schema, not both`),kv(`Machine.state`,t,n.fields,`state fields`),bv(n.fields,`_tag`)&&Sv(`Machine.state`,t,`state fields cannot declare _tag`),r.schema=Hn(t,n.fields),delete r.fields),bv(n,`states`)){kv(`Machine.state`,t,n.states,`child states`);let e=Object.create(null);for(let r of Reflect.ownKeys(n.states))Ov(`Machine.state`,t,r),e[r]=Lv(n.states[r],r);r.states=e}return t===``?(Nv(`Machine.state`,{"":r},``,!1,!0),Iv({"":r})[``]):r},Rv=`~effect/Machine`,zv=`~effect/Machine/ChildMachine`,Bv={...zr,...Yn,[Rv]:Rv,toJSON(){return{_id:`Machine`}}},Vv=(e,t)=>{let n=Object.create(Bv);return n.states=e.states,n.root=e.root,n.events=e.events,n.internalEvents=e.internalEvents,n.emittedEvents=e.emittedEvents,n.parent=e.parent,n.input=e.input,n.id=e.id,n.initial=e.initial,n.initialDefinition=e.initialDefinition,n.stateNodes=e.stateNodes,n.handlers=t,qf(e,n),n},Hv=e=>e.kind===`none`?Qd:Zd(e.kind,e.path,e.scope,e.updatePath),Uv=e=>Object.freeze({path:e.path,kind:e.kind,scope:e.scope}),Wv=e=>e.updatePath===void 0?e.kind===`update`&&e.path!==void 0?[e.path]:[]:[e.updatePath],Gv=(e,t,n,r,i)=>{if(typeof e!=`object`||!e||!K(e,`target`)||typeof e.target!=`function`)throw Error(`Machine transition for state "${r}" on "${String(i)}" requires a target selector`);let a=e.target(t);if(!$d(a))throw Error(`Machine transition for state "${r}" on "${String(i)}" must select exactly one target`);if(a.updatePath!==void 0){let e=n.byPath.get(a.updatePath);if(a.kind!==`state`&&a.kind!==`choice`||a.scope!==`local`&&a.scope!==`branch`||a.path===void 0||e===void 0||e.schema===void 0||e.type!==`compound`&&e.type!==`parallel`||!wp(r,e.path)||!wp(a.path,e.path))throw Error(`Machine updating owner "${a.updatePath}" must be a valued ancestor retained by source "${r}" and target "${a.path}"`)}return{...e,selection:a}},Kv=(e,t,n)=>{if(t.kind===`none`){if(e!==void 0)throw Error(`Machine targetless transition resolver must return undefined`);return}if(t.kind===`update`){if(!tf(e)||e.path!==t.path)throw Error(`Machine state update for "${t.path}" must return its selected update builder`);return}if(t.updatePath!==void 0){if(!rf(e)||e.update.path!==t.updatePath)throw Error(`Machine target updating "${t.updatePath}" must return target construction .update(...)`)}else if(rf(e))throw Error(`Machine combined target requires an updating owner declaration`);if(e===void 0)return;let r=rf(e)?e.target:e,i=typeof r==`object`&&r&&K(r,`path`)&&typeof r.path==`string`?r.path:void 0,a=t.path===void 0?void 0:n.byPath.get(t.path),o=(t.scope===`local`||t.scope===`branch`)&&(a?.type===`compound`||a?.type===`parallel`);if(i===void 0||i!==t.path&&!(o&&wp(i,t.path)))throw Error(`Machine transition resolver selected "${t.path}" but constructed "${i??`<invalid>`}"`)},qv=(e,t,n,r,i)=>{let a={...t,root:i===``?t.state:t.ancestors[``],decline:df};delete a.target;let o=e.resolve(a,n);if(ff(o)){if(e.declinable!==!0)throw Error(`Machine transition for state "${i}" returned decline without declaring declinable: true`);return o}return Kv(o,e.selection,r),o},Jv=e=>e.kind===`update`?void 0:e.path,Yv=e=>{let t=Number(e);return Number.isInteger(t)&&t>=0&&t<4294967295&&String(t)===e},Xv=(e,t,n)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Machine branching transition for state "${t}" on "${String(n)}" requires a branch record`);if(Object.getOwnPropertySymbols(e).length>0)throw Error(`Machine branching transition for state "${t}" on "${String(n)}" cannot use symbol keys`);let r=Object.keys(e);if(r.length===0)throw Error(`Machine branching transition for state "${t}" on "${String(n)}" requires a branch`);return Object.freeze(r.map(r=>{if(r.length===0||Yv(r))throw Error(`Machine branching transition for state "${t}" on "${String(n)}" requires non-index string branch keys`);let i=e[r];if(typeof i!=`object`||!i||!K(i,`target`))throw Error(`Machine transition branch "${r}" requires a target selection`);let{target:a,title:o}=i;if(!$d(a))throw Error(`Machine transition branch "${r}" must select exactly one target`);if(o!==void 0&&(typeof o!=`string`||o.length===0))throw Error(`Machine transition branch "${r}" title must be a non-empty string`);return Object.freeze({key:r,title:o??r,selection:Hv(a)})}))},Zv=(e,t,n,r={},i)=>{let a=mm(r);if(e.kind===`choice`&&e.updatePath!==void 0){let{update:n,...r}=a;if(Reflect.ownKeys(r).length>0)throw Error(`Machine pseudo-state construction accepts no data`);let i=t.byPath.get(e.path);return nf(_f(i.path,i.parent),_m(t,e.updatePath,n))}if(e.kind===`none`||e.kind===`history`||e.kind===`choice`){if(Reflect.ownKeys(a).length>0)throw Error(`Machine pseudo-state construction accepts no data`);if(e.kind===`none`)return;let n=t.byPath.get(e.path);return e.kind===`history`?pf(n.path,n.parent):_f(n.path,n.parent)}if(e.kind===`update`)return _m(t,e.path,a);if(e.path===``){if(Reflect.ownKeys(a).some(e=>e!==`input`))throw Error(`Machine initialize branches accept input only`);if(n.initialize===void 0)throw Error(`Machine root initialization is unavailable`);return n.initialize(a.input)}if(e.updatePath!==void 0){let{update:n,...r}=a;return nf(gm(t,e.path,r,i),_m(t,e.updatePath,n))}return gm(t,e.path,a,i)},Qv=(e,t,n,r,i)=>Object.freeze(Object.fromEntries(e.map((e,a)=>[e.key,o=>af(t,a,e.key,e.selection.kind===`none`?cf():Zv(e.selection,n,r,o,i))]))),$v=(e,t,n)=>{if(t.kind===`none`){if(!lf(e))throw Error(`Machine targetless branch must return its selected targetless builder`)}else{if(e===void 0)throw Error(`Machine transition branch selected "${t.path}" without constructing its target`);Kv(e,t,n)}},ey=(e,t)=>({...e,root:t===``?e.state:e.ancestors[``]}),ty=(e,t,n,r)=>{if(typeof e!=`object`||!e)throw Error(`Machine transition for "${n}" must be an object`);let i={...e},a=[`target`,`update`,`initialize`,`history`,`none`,`branches`,`data`,`decoded`,`resolve`,`guard`,`reenter`,`declinable`];for(let e of Reflect.ownKeys(i))if(typeof e!=`string`||!a.includes(e))throw Error(`Machine transition contains an unknown field`);for(let e of[`resolve`,`guard`])if(i[e]!==void 0&&typeof i[e]!=`function`)throw Error(`Machine transition ${e} must be a function`);let o=typeof i.guard==`function`?i.guard:void 0,s=typeof i.resolve==`function`?i.resolve:void 0;if(i.decoded!==void 0&&typeof i.decoded!=`boolean`)throw Error(`Machine decoded must be a boolean construction flag`);let c=Object.prototype.hasOwnProperty.call(i,`data`);if(i.decoded===!0&&!c)throw Error(`Machine decoded construction requires data`);if(c&&s!==void 0)throw Error(`Machine data and resolve are mutually exclusive`);let l=i.data,u=typeof l==`function`?l:()=>l,d=o!==void 0,f=d||i.declinable===!0;if(typeof i.branches==`string`){let e=t.branches.get(i.branches);if(e===void 0||s===void 0)throw Error(`Machine branching transition requires a registered group and resolver`);if([`target`,`update`,`initialize`,`history`,`none`,`data`,`decoded`].some(e=>i[e]!==void 0))throw Error(`Machine branching transition cannot redeclare its destination`);let a=Object.fromEntries(Object.entries(e).map(([e,i])=>[e,{title:i.title,target:Gv({target:()=>wm(t,i)},void 0,r,n,e).selection}]));return{branches:()=>a,reenter:i.reenter,declinable:f,resolve:(e,t)=>d&&!o(e)?df():s(e,t)}}let p=wm(t,i);if(s!==void 0&&p.kind!==`none`)throw Error(`Machine advanced construction requires a declared branch group`);let m=i.initialize,h=m!==void 0;if(h&&(c||i.decoded!==void 0))throw Error(`Machine initialize accepts machine input instead of data`);if(h&&!t.input&&m!==!0)throw Error(`Machine initialize requires true when the machine declares no input`);let g=t.input?typeof m==`function`?m:()=>m:()=>void 0;return{target:()=>p,reenter:i.reenter,declinable:f,resolve:(e,a)=>{if(d&&!o(e))return df();if(s!==void 0)return s(e,a);if(h)return Zv(p,r,t,{input:g(e)});let l=u(e);return Zv(p,r,t,p.updatePath===void 0?{...c?{data:l}:{},...i.decoded===void 0?{}:{decoded:i.decoded}}:p.kind===`choice`?{update:{data:l,decoded:i.decoded}}:{...l.target===void 0?{}:{data:l.target,decoded:i.decoded},update:{data:l.update,decoded:i.decoded}},n)}}},ny=(e,t,n,r,i)=>{let a=ty(e,r,n,t);if(typeof a!=`object`||!a)throw Error(`Machine transition for state "${n}" on "${String(i)}" must be an object`);let o=a,s=o.reenter===!0,c=o.declinable===!0;if(K(o,`branches`)){let e=o;if(typeof e.branches!=`function`||typeof e.resolve!=`function`)throw Error(`Machine branching transition for state "${n}" on "${String(i)}" requires branches and resolve`);let a=e.resolve,l=Xv(e.branches(),n,i),u=Object.freeze({}),d=(e,o)=>{let s={...e,root:n===``?e.state:e.ancestors[``],decline:df};delete s.target,s.select=Qv(l,u,t,r,n);let d=a(s,o);if(ff(d)){if(!c)throw Error(`Machine branching transition for state "${n}" on "${String(i)}" returned decline without declaring declinable: true`);return{result:d,branchIndex:-1,branchKey:void 0}}if(!of(d)||d.owner!==u)throw Error(`Machine branching transition for state "${n}" on "${String(i)}" must select one declared branch`);let f=l[d.branchIndex];if(f===void 0||d.branchKey!==f.key)throw Error(`Machine branching transition returned invalid branch evidence`);return $v(d.result,f.selection,t),{result:d.result,branchIndex:d.branchIndex,branchKey:d.branchKey}};return{reenter:s,declinable:c,targets:[...new Set(l.flatMap(e=>Jv(e.selection)===void 0?[]:[e.selection.path]))],branches:l.map(e=>Object.freeze({type:`branch`,key:e.key,title:e.title,target:Jv(e.selection),selection:Uv(e.selection),updates:Wv(e.selection)})),evaluate:d,transition:(e,t)=>d(e,t).result}}let l=Gv(a,void 0,t,n,i),u=(e,r)=>({result:qv(l,e,r,t,n),branchIndex:0,branchKey:void 0});return{reenter:s,declinable:c,targets:Jv(l.selection)===void 0?[]:[l.selection.path],branches:[{type:`direct`,target:Jv(l.selection),selection:Uv(l.selection),updates:Wv(l.selection)}],evaluate:u,transition:(e,t)=>u(e,t).result}},ry=(e,t,n,r)=>{let i=Object.create(null);for(let a of Reflect.ownKeys(e))i[a]=ny(e[a],t,n,r,a);return i},iy=(e,t,n,r)=>{let i=(Array.isArray(e)?e:[e]).map(e=>{let i=Tm(r,e,n,e=>ey(e,n));for(let e of[`onElement`,`onDone`,`onFailure`,`onSnapshot`])i[e]!==void 0&&(i[e]=ny(i[e],t,n,r,e));return Im(i,n)});return Rm(i,n),Array.isArray(e)?Object.freeze(i):i[0]},ay=(e,t,n,r,i,a)=>{for(let o of Object.keys(a)){let s=r===``?o:`${r}.${o}`;if(!K(n,o))throw Error(`Machine received handler for unknown state "${s}"`);let c=a[o];if(typeof c!=`object`||!c)throw Error(`Machine expected state "${s}" handler to be an object`);let{states:l,...u}=c;typeof u.history==`object`&&u.history!==null&&(u.history=Object.freeze(Object.fromEntries(Object.entries(u.history).map(([e,t])=>[e,typeof t==`object`&&t?Object.freeze({...t}):t]))));let d=u.on;if(typeof d==`object`&&d&&(u.on=ry(d,t,s,i)),u.always!==void 0&&(u.always=ny(u.always,t,s,i,`always`)),u.onDone!==void 0&&(u.onDone=ny(u.onDone,t,s,i,`done`)),u.choice!==void 0&&(u.choice=ny(u.choice,t,s,i,`choice`)),u.invoke!==void 0&&(u.invoke=iy(u.invoke,t,s,i)),t.byPath.get(s)?.type===`choice`&&(typeof u.choice!=`object`||u.choice===null||!K(u.choice,`transition`)||typeof u.choice.transition!=`function`||!K(u.choice,`targets`)||!Array.isArray(u.choice.targets)||u.choice.targets.length===0))throw Error(`Machine choice state "${s}" requires a transition`);if(e[s]=u,l!==void 0){let r=yf(s,n[o]);if(r.states===void 0)throw Error(`Machine expected state "${s}" to declare child states`);if(typeof l!=`object`||!l)throw Error(`Machine expected state "${s}" child handlers to be an object`);ay(e,t,r.states,s,i,l)}}},oy=e=>e===``?bm:e,sy=e=>{let t=!1;for(let n of e.stateNodes.byPath.values())if(n.type===`choice`){t=!0;break}if(!t)return;let n=Cf(e),r=new Map;for(let e of n)e.trigger.type===`choice`&&r.set(e.source,e);for(let e of n)for(let t of e.branches){let n=t.updates[0],i=t.selection.path;if(t.selection.kind!==`choice`||n===void 0||i===void 0)continue;let a=[i],o=new Set;for(;a.length>0;){let t=a.shift();if(!o.has(t)){o.add(t);for(let i of r.get(t)?.branches??[]){let{kind:r,path:o}=i.selection;if(o!==void 0&&r!==`none`&&r!==`update`){if(r===`choice`)a.push(o);else if(!wp(o,n)){let r=i.type===`branch`?`branch "${i.key}"`:`transition`;throw Error(`Machine transition from "${oy(e.source)}" updates "${oy(n)}" before choice "${t}", whose ${r} targets "${oy(o)}" outside that owner`)}}}}}}},cy=(e,t)=>(n=>{let r=Fm(t.root,n),i=Object.assign(Object.create(Bv),e);if(qf(e,i),i.states=Object.freeze({"":r.node}),i.stateNodes=bf(i.states),i.stateNodes.byPath.get(``).schema===void 0&&n.root!==void 0)throw Error(`Machine schema-less root cannot construct data`);let a=i.stateNodes.byPath.get(``).schema===void 0?()=>void 0:Nm(n.root);i.initial=e=>({...hf(``,a({input:e})),input:{value:e}}),i.initialDefinition=Object.freeze({target:``,selection:Object.freeze({path:``,kind:`initial`,scope:`initial`})});let o=Object.create(null);ay(o,i.stateNodes,i.states,``,{...t,initialize:e=>i.initial(i.input===void 0?void 0:dp(i,i.input,e))},{"":r.handlers});let s=Vv(i,o);return sy(s),s}),ly=e=>{let t=Lv(e),n=uy();return Object.freeze({...n,"~effect/Machine/State":`~effect/Machine/State`,node:t})},uy=()=>({path:(e=>e),get:((e,t)=>kf(e,t).pipe(I(e=>e.value))),getWithParents:((e,t)=>{let n={};return kf(e,t,n).pipe(I(e=>({value:e.value,parents:n})))}),getSnapshot:kf,matches:((e,t)=>mt(kf(e,t)))}),dy=e=>{if(Object.hasOwn(e,`initial`)||Object.hasOwn(e,`initialConfiguration`))throw Error(`Machine initial edges and root data belong in handle`);let t=Object.freeze({"":e.root.node}),n=Object.create(Yn);return n.states=t,n.root=e.root,n.events=e.events,n.internalEvents=e.internalEvents??Qf(`internal`,[]),n.emittedEvents=e.emittedEvents??Qf(`emitted`,[]),n.parent=e.parent,n.input=e.input,n.id=e.id,n.handlers=Object.create(null),n.handle=cy(n,Sm(e.root,e)),Kf(n),n},fy=e=>{for(let[t,n]of Object.entries(e))if(Object.hasOwn(n,`_tag`))throw Error(`Machine event "${t}" fields cannot declare _tag`);return Object.keys(e).length===0?[]:[Ae(e)]},py=e=>Qf(`public`,fy(e)),my=(e,t)=>hy(e,t,e=>t.input===void 0?mv(t):mv(t,e)),hy=(e,t,n)=>({[zv]:zv,id:e,machine:t,[Om]:n}),gy=gv,_y=_v,vy=(e,t)=>{try{let n=Wh(e,...t);return{machine:e,snapshot:n.done?{status:`done`,state:n.state,output:n.output}:{status:`active`,state:n.state}}}catch{return}},yy=(e,t)=>{try{let n=Be(tv(e,t));if(n._tag===`Failure`)return;let r=n.value;if(!Hh(e,r))return{machine:e,snapshot:{status:`active`,state:r}};let i=Be(Uh(e,r,Vh));return i._tag===`Success`?{machine:e,snapshot:{status:`done`,state:r,output:i.value}}:void 0}catch{return}},by={spawn:()=>or(Error(`Child operations are unavailable in a planned snapshot`)),sendTo:()=>Jt(new Pd),stop:()=>z},xy=(e,t)=>{if(e.snapshot.status!==`active`)return yr();try{let n=e.machine,r=Gp(n,e.snapshot.state);for(let e of Ip(n,r)){let i=tm(n,e);for(let a of zm(i?.invoke)){if(!(`child`in a)||a.child.id!==t.id||a.child.machine!==t.machine)continue;let i=t.machine,o;`input`in a&&(o=typeof a.input==`function`?a.input({...xp(r)??rh(n,r),children:by,state:r.values.get(e),containingState:Fp(n,r,e),ancestors:Pp(n,r,e),event:Vh}):a.input);let s=vy(i,i.input===void 0?[]:[o]);return s===void 0?void 0:Mt(s)}}return yr()}catch{return}},Sy=class extends Ir(`ChildNotActiveError`){},Cy=new WeakMap,wy=new WeakMap,Ty=e=>typeof e==`object`&&!!e&&wy.has(e),Ey=e=>{if(typeof WeakRef>`u`||typeof FinalizationRegistry>`u`)return Dn(e);let t=ye(),n=new FinalizationRegistry(({entry:e,key:n})=>{let r=xr(t,n);mt(r)&&r.value===e&&me(t,n)});return r=>{let i=xr(t,r);if(mt(i)){let e=i.value.ref.deref();if(e!==void 0)return e}let a=e(r),o={ref:new WeakRef(a)};return Ft(t,r,o),n.register(a,{key:r,entry:o}),a}},Dy=(e,t)=>d(ne(t,e=>e.stop).pipe(P(t=>U(()=>e.setSelf(R(t)))),q(()=>di))),Oy=(e,t)=>Dy(e,e.result(t).pipe(q(e=>e.start))),ky=(e,t,n)=>Dy(e,_y(t,n)),Ay=(e,t)=>`~effect-atom/atom/Atom/ServerValue`in e?e[Qn](t):t(e),jy=(e,t)=>{let n;return r=>{let i=e(r);return n!==void 0&&n.inputs.length===i.length&&n.inputs.every((e,t)=>Object.is(e,i[t]))||(n={inputs:i,value:t(...i)}),n.value}},My=e=>{let t;return()=>(t===void 0&&(t={value:e()}),t.value)},Ny=e=>e.snapshot,Py=ii(e=>e.registry).pipe(qr),Fy=e=>V(()=>{let t=e.pending.shift();return t===void 0?(e.draining=!1,z):G(t,Fy(e))}),Iy=(e,t)=>{let n=e.get(t);return n===void 0&&(n={pending:[],draining:!1},e.set(t,n)),n},Ly=(e,t,n)=>Ie(n=>{let r=vt(n(e),()=>void 0),i=t.get(n.registry);return i===void 0||!i.draining?r:p(I(n.self(),pt),()=>B(!0))},(r,i)=>{let a=r.get(e),o=r.get(Py),s=Iy(t,o);Ze(a)||s.draining?(r.setSelf(B(!0)),s.pending.push(Un(o,e).pipe(q(e=>n(e,i)),Fn,Ut(e=>{let t=Ve(e);r.setSelf(s.pending.length===0?t:pt(t))}))),s.draining||(s.draining=!0,dt(Fy(s)))):xe(a)?r.setSelf(vt(a,()=>void 0)):ni(n(a.value,i),{onExit:e=>r.setSelf(Ve(e))})}).pipe(S),Ry=e=>ii(t=>{let n=t(e);return Ze(n)?B(n.waiting):xe(n)?je(n.cause,{previous:t.self(),waiting:n.waiting}):n.value.status===`error`?je(n.value.cause,{previous:t.self(),waiting:n.waiting}):R(n.value.state,{waiting:n.waiting})}).pipe(Qr(ar),O(jy(t=>[Ay(e,t)],e=>vt(e,e=>e.state)))),zy=e=>ii(t=>{let n=t(e);if(Ze(n))return B(n.waiting);if(xe(n))return je(n.cause,{previous:t.self(),waiting:n.waiting});if(ie(n.value)){let e=t.self();return mt(e)&&xe(e.value)?e.value:R(yr(),{waiting:n.waiting})}return n.value.value.status===`error`?je(n.value.value.cause,{previous:t.self(),waiting:n.waiting}):R(Mt(n.value.value.state),{waiting:n.waiting})}).pipe(Qr(ar),O(jy(t=>[Ay(e,t)],e=>vt(e,I(e=>e.state))))),By=(e,t)=>ii(n=>{let r=n(e);if(Ze(r))return B(r.waiting);if(xe(r))return je(r.cause,{previous:n.self(),waiting:r.waiting});if(ie(r.value))return R(yr());let i=r.value.value,a=E(i.child(t)),o=ni(re.pipe(G(i.childChanges(t).pipe(T(e=>U(()=>n.setSelf(R(e))))))));return n.addFinalizer(o),R(a)}).pipe(S),Vy=(e,t)=>Bg(e)?e[zg](()=>t(E(e.snapshot))):ni(e.changes.pipe(T(e=>U(()=>t(e))))),Hy=(e,t,n)=>{let r=ii(t=>{let n=t(e);if(Ze(n))return B(n.waiting);if(xe(n))return je(n.cause,{previous:t.self(),waiting:n.waiting});if(ie(n.value))return R(yr());let r=n.value.value;return t.addFinalizer(Vy(r,e=>t.setSelf(R(Mt(e))))),R(Mt(E(r.snapshot)))}).pipe(O(jy(()=>[],()=>{let e=n();return e===void 0?B(!0):R(I(e,Ny),{waiting:!0})}))),i=new WeakMap,a=e=>mt(e)?ke(e.value):Jt(new Sy({id:t.id})),o=Ly(e,i,(e,t)=>q(a(e),e=>e.send(t))),s=Ly(e,i,(e,t)=>q(a(e),e=>e.stop)),c=Uy(e,n);return{ref:e,snapshot:r,result:zy(r),send:o,stop:s,child:c}},Uy=(e,t)=>{let n=new WeakMap;return r=>{let i=n.get(r.machine);if(i===void 0){let a=r.machine,o=Dn(n=>{let r=my(n,a);return Hy(By(e,r),r,My(()=>{let e=t();return e===void 0||ie(e)?e:xy(e.value,r)}))});i=e=>o(e),n.set(a,i)}return i(r.id)}},Wy=(e,t,n)=>{let r=S(e),i=ii(e=>{let t=e(r);if(Ze(t))return B(t.waiting);if(xe(t))return je(t.cause,{previous:e.self(),waiting:t.waiting});let n=t.value;e.addFinalizer(Vy(n,t=>e.setSelf(R(t,{waiting:t.status===`active`}))));let i=E(n.snapshot);return R(i,{waiting:i.status===`active`})}).pipe(O(jy(()=>[],()=>{let e=n();return e===void 0?B(!0):R(Ny(e),{waiting:!0})}))),a=new WeakMap,o=Ly(r,a,(e,t)=>e.send(t)),s=Ly(r,a,(e,t)=>e.stop),c=Uy(Yt(r,Mt),()=>{let e=n();return e===void 0?void 0:Mt(e)}),l={ref:r,snapshot:i,result:Ry(i),send:o,stop:s,child:c};return wy.set(l,t),l},Gy=(e,t)=>kf(e,t).pipe(I(e=>e.value)),Ky=(e,t)=>kf(e,t),qy=(e,t)=>Yt(e,t).pipe(Qr(ar),O(jy(t=>[Ay(e,t)],e=>vt(e,t)))),Jy=new WeakMap,Yy=(e,t,n,r)=>{let i=Jy.get(e);i===void 0&&(i=new Map,Jy.set(e,i));let a=i.get(t);a===void 0&&(a=new Map,i.set(t,a));let o=a.get(n);if(o!==void 0)return o;let s=r();return a.set(n,s),s},Xy=(e,t)=>Yy(e,`select`,t,()=>qy(e.result,e=>Gy(e,t))),Zy=(e,t)=>Yy(e,`selectSnapshot`,t,()=>qy(e.result,e=>Ky(e,t))),Qy=(e,t)=>Yy(e,`selectChild`,t,()=>qy(e.result,Se(e=>Gy(e,t)))),$y=(e,t)=>Yy(e,`selectSnapshotChild`,t,()=>qy(e.result,Se(e=>Ky(e,t)))),eb=(e,t)=>Yy(e,`matches`,t,()=>qy(e.result,e=>mt(kf(e,t)))),tb=(e,t)=>Yy(e,`matchesChild`,t,()=>qy(e.result,ee(e=>mt(kf(e,t))))),nb=(e,t,n)=>{let r=e.atom(()=>gy(t,...n)),i=Wy(e.atom(e=>Oy(e,r)),t,My(()=>vy(t,n)));return Cy.set(i,r),i},rb=(e,t,n)=>Wy(e.atom(e=>ky(e,t,n)),t,My(()=>yy(t,n))),ib=(e,t,n)=>{let r={owner:e,source:t},i=_(t,e=>e(r.source),{initialValueTarget:t}).pipe(Qr((e,t)=>r.source.equals(e,t)),O(e=>Ay(r.source,e)));return n!==void 0&&(i=i.pipe(st(n))),i},ab=(e,t)=>{let n=Ey(t=>({bridge:e(t)})),r={};for(let e of Object.keys(t.atoms)){let i=t.atoms[e];r[e]=Ey(r=>{let a=n(r);return ib(a,i(a.bridge),t.label?.(r,e))})}return r},ob=e=>{let t=((t,...n)=>nb(e,t,n));return{make:t,factory:(e=>(...n)=>t(e,...n)),resume:((t,n)=>rb(e,t,n)),family:((t,n)=>ab(n=>nb(e,t,[n]),n))}},sb=Ty;Nr(2,Xy);var cb=Nr(2,Zy);Nr(2,Qy);var lb=Nr(2,$y);Nr(2,eb),Nr(2,tb);var ub=ob;function db(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=xa(`animate-pulse rounded-md bg-muted`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`skeleton`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function fb(e){let t=(0,$o.c)(12),n=e.label,r;if(t[0]!==e.media||t[1]!==e.mediaClassName||t[2]!==e.rowClassName||t[3]!==e.rows){let n;t[5]!==e.media||t[6]!==e.mediaClassName||t[7]!==e.rowClassName?(n=t=>(0,Q.jsxs)(`div`,{"aria-hidden":!0,className:xa(`list-row flex h-8 items-center gap-3 px-1 max-sm:h-11`,e.rowClassName),children:[e.media===!0&&(0,Q.jsx)(db,{className:xa(`size-5 shrink-0`,e.mediaClassName)}),(0,Q.jsx)(db,{className:`h-4 w-1/3`})]},t),t[5]=e.media,t[6]=e.mediaClassName,t[7]=e.rowClassName,t[8]=n):n=t[8],r=v(ct(1,e.rows),n),t[0]=e.media,t[1]=e.mediaClassName,t[2]=e.rowClassName,t[3]=e.rows,t[4]=r}else r=t[4];let i;return t[9]!==e.label||t[10]!==r?(i=(0,Q.jsx)(`div`,{"aria-busy":`true`,"aria-label":n,role:`status`,children:r}),t[9]=e.label,t[10]=r,t[11]=i):i=t[11],i}var pb=Z.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Ci(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),mb=wa(`group/field flex w-full gap-2 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 hb(e){let t=(0,$o.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`vertical`:i,o;t[4]!==n||t[5]!==a?(o=xa(mb({orientation:a}),n),t[4]=n,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,Q.jsx)(`div`,{role:`group`,"data-slot":`field`,"data-orientation":a,className:o,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function gb(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=xa(`flex w-fit items-center gap-2 text-xs/relaxed font-medium group-data-[disabled=true]/field:opacity-50`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`field-label`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function _b(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=xa(`text-left text-xs/relaxed 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`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`p`,{"data-slot":`field-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function vb(e){let t=(0,$o.c)(15),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,children:n,errors:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;bb0:{if(n){o=n;break bb0}if(!i?.length){o=null;break bb0}let e;t[5]===i?e=t[6]:(e=[...new Map(i.map(bb)).values()],t[5]=i,t[6]=e);let r=e;if(r?.length==1){o=r[0]?.message;break bb0}let a;t[7]===r?a=t[8]:(a=(0,Q.jsx)(`ul`,{className:`ml-4 flex list-disc flex-col gap-1`,children:r.map(yb)}),t[7]=r,t[8]=a),o=a}let s=o;if(!s)return null;let c;t[9]===r?c=t[10]:(c=xa(`text-xs/relaxed font-normal text-destructive`,r),t[9]=r,t[10]=c);let l;return t[11]!==s||t[12]!==a||t[13]!==c?(l=(0,Q.jsx)(`div`,{role:`alert`,"data-slot":`field-error`,className:c,...a,children:s}),t[11]=s,t[12]=a,t[13]=c,t[14]=l):l=t[14],l}function yb(e,t){return e?.message&&(0,Q.jsx)(`li`,{children:e.message},t)}function bb(e){return[e?.message,e]}function xb(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=xa(`size-4 animate-spin`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Yi,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Sb=new Uint8Array(512),Cb=new Uint8Array(256);for(let e=0,t=1;e<255;e++)Sb[e]=t,Cb[t]=e,t<<=1,256&t&&(t^=285);for(let e=255;e<512;e++)Sb[e]=Sb[e-255];var wb=(e,t)=>e>0&&t>0?Sb[Cb[e]+Cb[t]]:0,Tb=(e,t)=>Sb[t*Cb[e]%255],Eb=e=>{let t=new Uint8Array(e+2),n=new Uint8Array(e+1);n[0]=1;for(let r=0;r<e;r++){let e=Tb(2,r);t.fill(0,0,r+2);for(let i=0;i<r+1;i++)t[i]^=n[i],t[i+1]^=wb(n[i],e);for(let e=0;e<r+2;e++)n[e]=t[e]}return n},Db=(e,t)=>{let n=Eb(t),r=new Uint8Array(e.byteLength+n.byteLength-1);r.set(e);for(let t=0;t<e.byteLength;t++){let e=r[t];if(e)for(let i=1;i<n.byteLength;i++)r[t+i]^=wb(n[i],e)}return r.subarray(e.byteLength)},Ob=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706],kb=[[0,0,0,0],[10,7,17,13],[16,10,28,22],[26,15,44,36],[36,20,64,52],[48,26,88,72],[64,36,112,96],[72,40,130,108],[88,48,156,132],[110,60,192,160],[130,72,224,192],[150,80,264,224],[176,96,308,260],[198,104,352,288],[216,120,384,320],[240,132,432,360],[280,144,480,408],[308,168,532,448],[338,180,588,504],[364,196,650,546],[416,224,700,600],[442,224,750,644],[476,252,816,690],[504,270,900,750],[560,300,960,810],[588,312,1050,870],[644,336,1110,952],[700,360,1200,1020],[728,390,1260,1050],[784,420,1350,1140],[812,450,1440,1200],[868,480,1530,1290],[924,510,1620,1350],[980,540,1710,1440],[1036,570,1800,1530],[1064,570,1890,1590],[1120,600,1980,1680],[1204,630,2100,1770],[1260,660,2220,1860],[1316,720,2310,1950],[1372,750,2430,2040]],Ab=[[0,0,0,0],[1,1,1,1],[1,1,1,1],[1,1,2,2],[2,1,4,2],[2,1,4,4],[4,2,4,4],[4,2,5,6],[4,2,6,6],[5,2,8,8],[5,4,8,8],[5,4,11,8],[8,4,11,10],[9,4,16,12],[9,4,16,16],[10,6,18,12],[10,6,16,17],[11,6,19,16],[13,6,21,18],[14,7,25,21],[16,8,25,20],[17,8,25,23],[17,9,34,23],[18,9,30,25],[20,10,32,27],[21,12,35,29],[23,12,37,34],[25,12,40,34],[26,13,42,35],[28,14,45,38],[29,15,48,40],[31,16,51,43],[33,17,54,45],[35,18,57,48],[37,19,60,51],[38,19,63,53],[40,20,66,56],[43,21,70,59],[45,22,74,62],[47,24,77,65],[49,25,81,68]],jb=[0,21,25,29,33,37,41,45,49,53,57,61,65,69,73,77,81,85,89,93,97,101,105,109,113,117,121,125,129,133,137,141,145,149,153,157,161,165,169,173,177],Mb=[[],[],[4,16],[4,20],[4,24],[4,28],[4,32],[4,20,36],[4,22,40],[4,24,44],[4,26,48],[4,28,52],[4,30,56],[4,32,60],[4,24,44,64],[4,24,46,68],[4,24,48,72],[4,28,52,76],[4,28,54,80],[4,28,56,84],[4,32,60,88],[4,26,48,70,92],[4,24,48,72,96],[4,28,52,76,100],[4,26,52,78,104],[4,30,56,82,108],[4,28,56,84,112],[4,32,60,88,116],[4,24,48,72,96,120],[4,28,52,76,100,124],[4,24,50,76,102,128],[4,28,54,80,106,132],[4,32,58,84,110,136],[4,28,56,84,112,140],[4,32,60,88,116,144],[4,28,52,76,100,124,148],[4,22,48,74,100,126,152],[4,26,52,78,104,130,156],[4,30,56,82,108,134,160],[4,24,52,80,108,136,164],[4,28,56,84,112,140,168]],Nb=(e,t,n)=>{let r=Ob[t]-kb[t][n],i=new Uint8Array(r),a=0,o=0;if(t>9){let t=65535&e.byteLength;i[0]=64|t>>>12&15,i[1]=t>>>4&255,a=(15&t)<<4,o=2}else{let t=255&e.byteLength;i[0]=64|t>>>4&15,a=(15&t)<<4,o=1}let s=0;for(;s+1<e.byteLength;){let t=e[s++]<<8|e[s++];i[o++]=a|t>>>12,i[o++]=t>>>4&255,a=t<<4&240}s<e.byteLength&&(i[o++]=a|e[s]>>>4,a=e[s]<<4&240),i[o++]=a;for(let e=0;o<r;e++)i[o++]=1&e?17:236;return i},Pb=(e,t)=>{for(let n=1;n<=40;n++){let r=Ob[n]-kb[n][t];if(r-=n>9?3:2,r>=e.byteLength)return n}throw RangeError(`Bytes exceed max length`)},Fb=(e,t,n)=>{let r=e.byteLength+kb[t][n],i=Ab[t][n],a=i-r%i,o=e.byteLength/i|0,s=(r/i|0)-o,c=e.byteLength,l=new Uint8Array(r);for(let t=0,n=0;t<i;t++){let r=t<a?o:o+1,u=Db(e.subarray(n,n+r),s);for(let s=0;s<r;s++)l[s<o?s*i+t:o*i+(t-a)]=e[n+s];for(let e=0;e<s;e++)l[c+e*i+t]=u[e];n+=r}return l},Ib=(e,t,n,r,i)=>{let a=(n+i)*t;for(let o=n*t;o<a;o+=t)e.fill(1,o+r,o+r+i)},Lb=(e,t,n,r,i)=>{let a=n*t+r;for(let n=0;n<i;n++)for(let r=0;r<i;r++){let o=r<i-1-r?r:i-1-r,s=n<i-1-n?n:i-1-n;e[a+n*t+r]=(o<s?o:s)===1?0:1}},Rb=(e,t,n)=>{let r=n-7;Lb(e,n,0,0,7),Lb(e,n,r,0,7),Lb(e,n,0,r,7),Ib(t,n,0,0,8),Ib(t,n,r-1,0,8),Ib(t,n,0,r-1,8)},zb=(e,t,n,r)=>{let i=Mb[r];for(let r=0;r<i.length;r++){let a=i[r];for(let o=0;o<i.length;o++)if((r||o%(i.length-1))&&(o||r%(i.length-1))){let r=i[o];Lb(e,n,a,r,5),Ib(t,n,a,r,5)}}},Bb=(e,t,n)=>{let r=n-7;for(let i=8;i<r;i++){let r=i*n+6;t[r]||(t[r]=1,e[r]=(i+1)%2);let a=6*n+i;t[a]||(t[a]=1,e[a]=(i+1)%2)}},Vb=(e,t)=>{let n=t-7-1;e[8*t+8]=1;for(let r=0;r<8;r++)e[r*t+8]=1,e[8*t+r]=1,e[(n+r)*t+8]=1,e[8*t+n+r]=1},Hb=(e,t,n)=>{if(n>=7){let n=t-7-4;for(let r=0;r<6;r++)for(let i=0;i<3;i++)e[(n+i)*t+r]=1,e[r*t+n+i]=1}},Ub=(e,t,n,r)=>{let i=0,a=n-1,o=-1,s=7;for(;i<r.byteLength;){a===6&&a--;for(let c=0;c<n;c++)for(let l=0;l<2;l++){let u=a-l,d=o===-1?n-c-1:c;if(!t[d*n+u]&&(e[d*n+u]=r[i]>>>s&1,s--===0&&(s=7,++i>=r.byteLength)))return}o=-o,a-=2}},Wb=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n)for(let a=0;a<n;a++){let n=i+a;t[n]||r+a&1||(e[n]^=1)}},Gb=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n)for(let a=0;a<n;a++){let n=i+a;t[n]||1&r||(e[n]^=1)}},Kb=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n)for(let r=0;r<n;r++){let n=i+r;!t[n]&&r%3==0&&(e[n]^=1)}},qb=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n)for(let a=0;a<n;a++){let n=i+a;!t[n]&&(r+a)%3==0&&(e[n]^=1)}},Jb=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n){let a=r/2|0;for(let r=0;r<n;r++){let n=i+r;t[n]||a+(r/3|0)&1||(e[n]^=1)}}},Yb=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n)for(let a=0;a<n;a++){let n=i+a,o=r*a;!t[n]&&(1&o)+o%3==0&&(e[n]^=1)}},Xb=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n)for(let a=0;a<n;a++){let n=i+a,o=r*a;!t[n]&&((1&o)+o%3)%2==0&&(e[n]^=1)}},Zb=(e,t,n)=>{for(let r=0,i=0;r<n;r++,i+=n)for(let a=0;a<n;a++){let n=i+a;t[n]||r*a%3+(r+a&1)&1||(e[n]^=1)}},Qb=(e,t,n,r)=>{switch(r){case 0:return Wb(e,t,n);case 1:return Gb(e,t,n);case 2:return Kb(e,t,n);case 3:return qb(e,t,n);case 4:return Jb(e,t,n);case 5:return Yb(e,t,n);case 6:return Xb(e,t,n);case 7:return Zb(e,t,n)}},$b=(e,t)=>{let n=0,r=0;for(let i=0;i<t;i++){let a=1,o=1,s=0,c=0;for(let l=0;l<t;l++){let u=i*t+l,d=l*t+i;r+=e[u],l>0&&(e[u-1]===e[u]?a++:(a>=5&&(n+=a-5+3),a=1),e[d-t]===e[d]?o++:(o>=5&&(n+=o-5+3),o=1)),i<t-1&&l<t-1&&e[u]===e[u+1]&&e[u]===e[u+t]&&e[u]===e[u+t+1]&&(n+=3),s=s<<1&2047|e[u],c=c<<1&2047|e[d],l>=10&&((s===1488||s===93)&&(n+=40),(c===1488||c===93)&&(n+=40))}a>=5&&(n+=a-5+3),o>=5&&(n+=o-5+3)}let i=100*Math.abs(r/e.byteLength-.5);return n+=10*Math.floor(i/5),n},ex=(e,t,n)=>{let r=0,i=0,a=new Uint8Array(e.byteLength);for(let o=0;o<=7;o+=1){a.set(e),Qb(a,t,n,o);let s=$b(a,n);(o===0||s<r)&&(r=s,i=o)}return Qb(e,t,n,i),i},tx=(e,t)=>{let n=(e<<3|t)<<10,r=n;for(let e=0;e<5;e++)r&1<<14-e&&(r^=1335<<4-e);return 21522^(r|n)},nx=(e,t,n,r)=>{let i=tx(n,r),a=14;for(let n=0;n<6;n++)e[8*t+n]=i>>a--&1;e[8*t+7]=i>>a--&1,e[8*t+8]=i>>a--&1,e[7*t+8]=i>>a--&1;for(let n=0;n<6;n++)e[(5-n)*t+8]=i>>a--&1;a=14;for(let n=0;n<7;n++)e[(t-1-n)*t+8]=i>>a--&1;e[(t-8)*t+8]=1;for(let n=0;n<8;n++)e[8*t+t-8+n]=i>>a--&1},rx=e=>{let t=e<<12,n=t;for(let e=0;e<6;e++)n&1<<17-e&&(n^=7973<<5-e);return n|t},ix=(e,t,n)=>{if(n>=7){let r=rx(n);for(let n=0;n<6;n++)for(let i=0;i<3;i++){let a=r>>>3*n+i&1;e[(t-11+i)*t+n]=a,e[n*t+t-11+i]=a}}},ax=(e,t)=>{let n=Pb(e,t),r=Fb(Nb(e,n,t),n,t),i=jb[n],a=new Uint8Array(i*i),o=new Uint8Array(i*i);return Rb(a,o,i),zb(a,o,i,n),Bb(a,o,i),Vb(o,i),Hb(o,i,n),Ub(a,o,i,r),nx(a,i,t,ex(a,o,i)),ix(a,i,n),a},ox=new TextEncoder,sx=(e,t=1)=>ax(typeof e==`string`?ox.encode(e):e,t);function cx(e){let t=(0,$o.c)(5),n=e.className,r;t[0]===e.result?r=t[1]:(r=yt(I(Ee(e.result),lx)),t[0]=e.result,t[1]=r);let i;return t[2]!==e.className||t[3]!==r?(i=(0,Q.jsx)(vb,{className:n,children:r}),t[2]=e.className,t[3]=r,t[4]=i):i=t[4],i}function lx(e){return e.message}var ux=wa(`inline-block size-1.5 shrink-0 rounded-full`,{defaultVariants:{status:`live`},variants:{status:{error:`bg-destructive`,live:`bg-primary`,off:`border-muted-foreground border`,quiet:`bg-muted-foreground/50`,warning:`bg-warning`}}});function dx(e){let t=(0,$o.c)(6),n;t[0]!==e.className||t[1]!==e.status||t[2]!==e.waiting?(n=xa(ux({status:e.status}),e.waiting===!0&&`motion-safe:animate-pulse`,e.className),t[0]=e.className,t[1]=e.status,t[2]=e.waiting,t[3]=n):n=t[3];let r;return t[4]===n?r=t[5]:(r=(0,Q.jsx)(`span`,{"data-slot":`status-dot`,"aria-hidden":`true`,className:n}),t[4]=n,t[5]=r),r}var fx=Z.createContext(void 0);function px(){let e=Z.useContext(fx);if(e===void 0)throw Error(Na(13));return e}var mx={imageLoadingStatus:()=>null},hx=Z.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,[o,s]=Z.useState(`idle`),c={imageLoadingStatus:o},l=Z.useMemo(()=>({imageLoadingStatus:o,setImageLoadingStatus:s}),[o,s]),u=Ci(`span`,e,{state:c,ref:t,props:a,stateAttributesMapping:mx});return(0,Q.jsx)(fx.Provider,{value:l,children:u})});function gx(e,{referrerPolicy:t,crossOrigin:n,sizes:r,srcSet:i},a){let o=Z.useState(`idle`),s=o[1];return X(()=>{if(!a)return co;if(!e&&!i)return s(`error`),co;let o=!0,c=new window.Image,l=e=>()=>{o&&s(e)};return s(`loading`),c.onload=l(`loaded`),c.onerror=l(`error`),t&&(c.referrerPolicy=t),c.crossOrigin=n??null,r&&(c.sizes=r),i&&(c.srcset=i),e&&(c.src=e),c.complete&&s(c.naturalWidth>0?`loaded`:`error`),()=>{o=!1}},[a,e,i,r,n,t,s]),o}var _x={...mx,...Eo},vx=Z.forwardRef(function(e,t){let{className:n,render:r,onLoadingStatusChange:i,keepMounted:a=!1,style:o,sizes:s,srcSet:c,src:l,...u}=e,{setImageLoadingStatus:d}=px(),[f,p]=gx(l,e,!a),m=f===`loaded`,{mounted:h,transitionStatus:g,setMounted:_}=Rc(m),v=Z.useRef(null),y=Z.useRef(!0);X(()=>{if(!a)return;let e=y.current;y.current=!1;let t=v.current;if(!t)return;if(!t.complete){p(`loading`);return}let n=t.naturalWidth>0?`loaded`:`error`;p(n),n===`loaded`&&e&&_(!0)},[a,l,c,s,u.crossOrigin,u.referrerPolicy,r,p,_]);let b=a?{"data-loading":f===`loading`?``:void 0,"data-error":f===`error`?``:void 0,"aria-hidden":f!==`loaded`||void 0,onLoad(){p(`loaded`)},onError(){p(`error`)}}:void 0,x=Y(e=>{i?.(e),d(e)});X(()=>{f!==`idle`&&x(f)},[f,x]),X(()=>()=>d(`idle`),[d]),Za({enabled:!m,open:m,ref:v,onComplete(){m||_(!1)}});let S={imageLoadingStatus:f,transitionStatus:a&&g===`ending`?void 0:g},C=a||h,w={};s!==void 0&&(w.sizes=s),c!==void 0&&(w.srcSet=c),l!==void 0&&(w.src=l);let T=Ci(`img`,e,{state:S,ref:[t,v],props:[b,u,w],stateAttributesMapping:_x,enabled:C});return C?T:null}),yx=Z.forwardRef(function(e,t){let{className:n,render:r,delay:i=0,style:a,...o}=e,{imageLoadingStatus:s}=px(),[c,l]=Z.useState(i===0),u=to();return Z.useEffect(()=>(i>0?u.start(i,()=>l(!0)):l(!0),u.clear),[u,i]),Ci(`span`,e,{state:{imageLoadingStatus:s},ref:t,props:o,stateAttributesMapping:mx,enabled:s!==`loaded`&&(i===0||c)})});function bx(e){let t=(0,$o.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,size:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,o;t[4]===n?o=t[5]:(o=xa(`group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten`,n),t[4]=n,t[5]=o);let s;return t[6]!==r||t[7]!==a||t[8]!==o?(s=(0,Q.jsx)(hx,{"data-slot":`avatar`,"data-size":a,className:o,...r}),t[6]=r,t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function xx(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=xa(`aspect-square size-full rounded-full object-cover`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(vx,{"data-slot":`avatar-image`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Sx(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=xa(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(yx,{"data-slot":`avatar-fallback`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Cx=Z.createContext(void 0);function wx(e){let t=Z.useContext(Cx);if(t===void 0&&!e)throw Error(Na(33));return t}var Tx=Z.createContext(void 0);function Ex(e){let t=Z.useContext(Tx);if(t===void 0&&!e)throw Error(Na(36));return t}var Dx=Z.createContext(void 0);function Ox(e=!0){let t=Z.useContext(Dx);if(t===void 0&&!e)throw Error(Na(25));return t}var kx=Z.createContext(null);function Ax(e=`root`){let t=Z.useContext(kx),n=Z.useContext(Tx);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var jx={visible:!0,ref:null};function Mx(){return jx}function Nx(e,t,n=`root`){let r=Ax(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??Mx)({label:e.label,children:e.children,render:e.render}),a=yo(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}function Px(e){e.preventDefault()}function Fx(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=Ex(),u=Ox(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),h=a.useState(`open`),g=u!==void 0,_=!f&&h&&n?0:-1;return Z.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?Px:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:mo})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,g&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||g&&!Ni&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&ka(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var Ix={type:`regular-item`};function Lx(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=Z.useRef(null),{getButtonProps:d,buttonRef:f}=Ya({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=Fx({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=Z.useCallback(e=>no(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=yo(u,f);return Z.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Rx=Z.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function zx(){return Z.useContext(Rx)}function Bx(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=zx(),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 X(()=>{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}}function Vx(e){return pa(e,`base-ui`)}var Hx=Z.createContext(void 0);function Ux(){let e=Z.useContext(Hx);if(e===void 0)throw Error(Na(31));return e}var Wx=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=Z.useState(void 0),c=Ci(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,Q.jsx)(Hx.Provider,{value:s,children:c})}),Gx=Z.forwardRef(function(e,t){let n=Ax()?.Group??Wx;return(0,Q.jsx)(n,{...e,ref:t})}),Kx=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Vx(a),c=Ux();return X(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),Ci(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),qx=Z.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=Ex(),f=Bx({guess:!0,label:a}),p=Vx(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=Lx({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:Ix});return Ci(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),Jx=Z.forwardRef(function(e,t){let n=Nx(e,t);return n.visible?(0,Q.jsx)(qx,{...e,ref:n.ref}):null}),Yx=Z.createContext(void 0);function Xx(e){let t=Z.useContext(Yx);if(t===void 0&&!e)throw Error(Na(69));return t}var Zx=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),Qx=Z.createContext(void 0);function $x(){return Z.useContext(Qx)}function eS(e,t){let n=oa(e.render);if(Z.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function tS(e,t,n){let r=eS(e,t),i=r===t?void 0:r;return[r,Z.useCallback(e=>n?.(e?i:void 0),[i,n])]}function nS(e,t,n){let r=oa(e.render),i=Z.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}var rS=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=Ex(),m=$x(),{side:h,align:g}=wx(),_=Xx(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),S=l.useState(`instantType`),C=l.useState(`activeTriggerElement`),w=l.useState(`parent`),T=l.useState(`lastOpenChangeReason`),E=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),k=l.useState(`closeDelay`),A=l.useState(`hoverEnabled`),j=l.useState(`disabled`),M=l.useState(`openMethod`),ee=l.useState(`activeTriggerId`),te=l.useState(`listElement`),[N,P]=tS(e,u,d),F=nS(e,C,ee),I=w.type===`menu`?m:void 0,ne=w.type===`context-menu`,re=s??w.type!==`menu`;s===void 0&&te&&w.type!==`menu`&&(re=()=>l.state.activeIndex===null&&te),Za({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),Z.useEffect(()=>{function e(e){l.setOpen(!1,ki(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),vl(D,{enabled:A&&!j&&!ne&&w.type!==`menubar`,closeDelay:k});let L=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:R,handleFocus:ie}=(Z.useContext(kx)?.useParentHandoff??aS)(l,w,v,f),ae={transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},z=Ci(`div`,e,{state:ae,ref:[t,l.context.popupRef,L,P],stateAttributesMapping:ps,props:[b,{id:N,...te?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":F},onKeyDown(e){I?.onPopupKeyDown?.(e),_&&Zx.has(e.key)&&e.stopPropagation()},onFocus:ie},ad(y),c,{"data-rootownerid":E}]}),B=w.type===void 0||ne;(C||w.type===`menubar`&&T!==`outside-press`)&&(B=!0);let oe=I?.getReturnElement??R;return(0,Q.jsx)(Mc,{context:D,openInteractionType:M,modal:ne,disabled:!x,returnFocus:a??oe??B,explicitReturnFocus:a===void 0&&oe?!1:void 0,initialFocus:re,restoreFocus:!0,getInsideElements:w.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:w.type===`menubar`?void 0:O,previousFocusableElement:C,nextFocusableElement:w.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:z})}),iS={parentVirtualFocusRef:void 0,handleFocus:void 0};function aS(){return iS}var oS=Z.forwardRef(function(e,t){let n=Ax()?.Popup??rS;return(0,Q.jsx)(n,{...e,ref:t})}),sS=Z.createContext(void 0);function cS(){let e=Z.useContext(sS);if(e===void 0)throw Error(Na(32));return e}var lS=Z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=Ex();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Q.jsx)(sS.Provider,{value:n,children:(0,Q.jsx)(Ja,{ref:t,...r,portalOwnerRole:o})})});function uS(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Y(i),[,o]=Z.useState(0),s=Ba(fS).current,c=Ba(dS).current,l=Z.useRef(0),u=Z.useRef(!0),d=Z.useRef(null),f=Z.useRef(null),p=Y(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=Y((e,t)=>{c.set(e,t),p()}),h=Y(e=>{c.delete(e),p()}),g=Y(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(!hS(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&gS(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=mS(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=Y(()=>{let[e,t]=pS(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))});X(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),X(()=>{u.current&&v()}),X(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=Y(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)(Rx.Provider,{value:b,children:t})}function dS(){return new Map}function fS(){return new Set}function pS(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)=>gS(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 mS(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function hS(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 gS(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var _S=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 vS(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=Z.useRef(null),o=Z.useRef(null),s=Ji(r);X(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),X(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}var yS={},bS={},xS=``;function SS(e,t){return Fi(e)?e:t}function CS(e,t,n){return/hidden|clip/.test(e.getComputedStyle(SS(t,n)).overflowY)}function wS(e){if(typeof document>`u`)return!1;let t=fo(e);return Po(t).innerWidth-t.documentElement.clientWidth>0}function TS(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=fo(e),n=t.documentElement,r=t.body,i=SS(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 ES(e){let t=fo(e),n=t.documentElement,r=t.body,i=SS(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 DS(e){let t=fo(e),n=t.documentElement,r=t.body,i=Po(n),a=0,o=0,s=!1,c=ra.create();if(Mo&&(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,yS={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},xS=n.style.scrollBehavior,bS={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=SS(n,r);s=TS(e),s?(n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`):(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,yS),Object.assign(r.style,bS),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=xS)}function d(){u(),c.request(l)}l();let f=zo(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var OS=new class{lockCount=0;restore=null;timeoutLock=na.create();timeoutUnlock=na.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=fo(e),n=t.documentElement,r=t.body,i=Po(n);if(CS(i,n,r)){let t=new i.MutationObserver(()=>{CS(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=Ii||!wS(e);this.restore=a?ES(e):DS(e)}};function kS(e=!0,t=null){X(()=>{if(e)return OS.acquire(t)},[e,t])}var AS=20;function jS(e,t,n,r){let[i,a]=Z.useState(!1);X(()=>{if(!e||!t||n==null){a(!1);return}let r=fo(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-AS)},[e,t,n]),kS(e&&(!t||i),r)}var MS=Z.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=$a,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=Ex(),x=cS(),S=Ox(!0),C=v.useState(`parent`),w=v.useState(`floatingRootContext`),T=v.useState(`floatingTreeRoot`),E=v.useState(`mounted`),D=v.useState(`open`),O=v.useState(`modal`),k=v.useState(`openMethod`),A=v.useState(`activeTriggerElement`),j=v.useState(`transitionStatus`),M=v.useState(`positionerElement`),ee=v.useState(`instantType`),te=v.useState(`adaptiveOrigin`),N=v.useState(`lastOpenChangeReason`),P=v.useState(`floatingNodeId`),F=v.useState(`floatingParentNodeId`),I=w.useState(`domReferenceElement`),ne=n,re=c,L=l,R=s,ie=h;C.type===`context-menu`&&(ne=n??C.context?.anchor,R??=`start`,!o&&R!==`center`&&(L=e.alignOffset??2,re=e.sideOffset??-5));let ae=o,z=R;C.type===`menu`?(ae??=`inline-end`,z??=`start`,ie=e.collisionAvoidance??wi):C.type===`menubar`&&(ae??=C.context.orientation===`vertical`?`inline-end`:`bottom`,z??=`start`);let B=C.type===`context-menu`,oe=nd({anchor:ne,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:ae,sideOffset:re,align:z,alignOffset:L,arrowPadding:B?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:P,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:ie,shift:B?{crossAxis:!(`side`in ie&&ie.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:te,lazyFlip:y?`placement`:!1});Z.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===P&&v.set(`hoverEnabled`,!1),e.nodeId!==P&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,ki(Io)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,P]),Z.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,ki(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let se=to();Z.useEffect(()=>{D||se.clear()},[D,se]),Z.useEffect(()=>{function e(e){if(D&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&A&&A!==e.target){let e=v.select(`closeDelay`);e>0?se.isStarted()||se.start(e,()=>{v.setOpen(!1,ki(Io))}):v.setOpen(!1,ki(Io))}else se.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,se]),Z.useEffect(()=>{let e={open:D,nodeId:P,parentNodeId:F,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,P,F]),vS({store:v,domReference:I,positionerElement:M,open:D});let ce={open:D,side:oe.side,align:oe.align,anchorHidden:oe.anchorHidden,nested:C.type===`menu`,instant:ee},le=C.type===`menubar`&&C.context.modal;jS(D&&(le||O&&N!==`trigger-hover`),k===`touch`,M,A);let ue=od(e,ce,{styles:oe.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),de=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&N!==`trigger-hover`||C.type===`menubar`&&C.context.modal),fe=null;return C.type===`menubar`?fe=C.context.contentElement:C.type===void 0&&(fe=A),(0,Q.jsxs)(Cx.Provider,{value:oe,children:[de&&(0,Q.jsx)(_S,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:Hi(!D),cutout:fe}),(0,Q.jsx)(Sc,{id:P,children:(0,Q.jsx)(uS,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:ue})})]})}),NS=Z.createContext(null);function PS(e){let t=Z.useContext(NS);if(t===null&&!e)throw Error(Na(5));return t}function FS(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=>{n.detail===0?e(n,`keyboard`):(`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``)},[e]),onPointerDown:n}}function IS(e,t){let n=Z.useRef(e),r=Y(t);X(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function LS(e,t){let{onClick:n,onPointerDown:r}=FS(Y((n,r)=>{(typeof e==`function`?e():e)||t(r||(Ii?`touch`:``))}));return Z.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function RS(e){let[t,n]=Z.useState(null),r=LS(e,n);return IS(e,t=>{t&&!e&&n(null)}),Z.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function zS(e){return e==null?Ha:e.type.startsWith(`key`)?io:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?Do:Ha}var BS={...ll,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=ll.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>Mo&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!ll.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},VS=class extends Ei{constructor(e,t,n=!1){let r=new el,i=US(r,t,n,e);super(i,HS(r),BS),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function HS(e){return{positionerRef:Z.createRef(),popupRef:Z.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:Z.createRef(),beforeTriggerFocusGuardRef:Z.createRef(),beforeContentFocusGuardRef:Z.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function US(e,t,n=!1,r){return{...rl(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:Co,inputProps:Co,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new gc,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Co,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var WS=Z.createContext(null);function GS(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function KS(e,t){return e===`list-navigation`||GS(e,t)}var qS=Qa(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:y,allowEscape:b=!0,resetOnPointerLeave:x=!0}=e,S=Ox(!0),C=Ex(!0),w=PS(!0),T=C?.store,E=C?.virtualFocus??!1,D=Z.useMemo(()=>_&&T?{type:`menu`,store:T}:w?{type:`menubar`,context:w}:S&&!T?{type:`context-menu`,context:S}:{type:void 0},[S,T,w,_]),O=Vx(),k=Vx(),[A,j]=Z.useState(void 0),M=(A??k)||void 0,ee=yc(),te=D.type===`menu`?D.store:void 0,N=(n??o)&&te?.state.transitionStatus===`starting`,P=Ba(()=>N?te?.state.instantType:void 0).current,F=Ba(()=>{let e=new VS({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:D,disabled:s,highlightItemOnHover:g,modal:D.type===void 0?c:void 0,rootId:O,instantType:P},M,ee!=null);return e.context.virtualFocusRef=y,e}).current;F.useControlledProp(`openProp`,n),F.useControlledProp(`triggerIdProp`,m),F.useContextCallback(`onOpenChangeComplete`,i);let I=F.useState(`floatingTreeRoot`),ne=xc(I),re=F.useState(`open`),L=F.useState(`activeTriggerElement`),R=F.useState(`positionerElement`),ie=F.useState(`hoverEnabled`),ae=F.useState(`disabled`),z=F.useState(`lastOpenChangeReason`),B=F.useState(`parent`),oe=F.useState(`activeIndex`),se=F.useState(`keyboardOpen`),ce=F.useState(`payload`),le=F.useState(`floatingParentNodeId`),ue=Z.useRef(null),de=Z.useRef(B.type!==`context-menu`),fe=to(),pe=Z.useRef(!0),me=to(),he=le!=null,{openMethod:ge,triggerProps:_e}=RS(re);F.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:B.type===void 0?c:void 0,openMethod:ge,rootId:O}),Xc(F);let{forceUnmount:ve,transitionStatus:ye}=Zc(re,F,()=>{F.set(`allowMouseEnter`,!1)},N),be=Ji(F.context.popupRef);Z.useEffect(()=>{if(P===void 0)return;let e=()=>{F.state.instantType===P&&F.set(`instantType`,void 0)};if(!re){e();return}if(ye!==void 0)return;if(F.context.popupRef.current==null){e();return}let t=new AbortController;return be(e,t.signal),()=>{t.abort()}},[P,re,ye,be,F]),X(()=>{S&&!C?F.update({parent:{type:`context-menu`,context:S},floatingNodeId:ne,floatingParentNodeId:ee}):(C||!F.select(`activeTriggerElement`))&&F.update({floatingNodeId:ne,floatingParentNodeId:ee})},[S,C,ne,ee,L,F]),Z.useEffect(()=>{re||(ue.current=null),B.type===`context-menu`&&(re?fe.start(500,()=>{de.current=!0}):(fe.clear(),de.current=!1))},[fe,re,B.type]),X(()=>{!re&&!ie&&F.set(`hoverEnabled`,!0)},[re,ie,F]);let xe=Y((e,t)=>{let n=t.reason;if(!e&&!F.select(`open`)||re===e&&t.trigger===L&&z===n)return;let i=qc(t);if(!e&&t.trigger==null&&(t.trigger=L??void 0),r?.(e,t),t.isCanceled)return;F.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!pe.current)return;e&&n===`trigger-focus`?(pe.current=!1,me.start(300,()=>{pe.current=!0})):(pe.current=!0,me.clear());let o=!e&&(n===`escape-key`||n==null);ue.current=t.event;let s=Kc(F.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&KS(n,a),s.instantType=B.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:GS(n,a)?`click`:o?`dismiss`:void 0,F.update(s)}),Se=Lc({popupStore:F,floatingRootContext:F.state.floatingRootContext,floatingId:M,nested:ee!=null,onOpenChange:xe}),Ce=Se.context.events;X(()=>{let e=({open:e,eventDetails:t})=>xe(e,t);return Ce.on(`setOpen`,e),()=>{Ce?.off(`setOpen`,e)}},[Ce,xe]),X(()=>F.subscribeToParentMenu(),[F]);let we=Z.useCallback(()=>{F.setOpen(!1,ki(za))},[F]);Z.useImperativeHandle(d,()=>({unmount:ve,close:we}),[ve,we]);let Te;B.type===`context-menu`&&(Te=B.context),Z.useImperativeHandle(Te?.positionerRef,()=>R,[R]),Z.useImperativeHandle(Te?.actionsRef,()=>({setOpen:xe}),[xe]);let Ee=Ic(Se,{enabled:!ae,bubbles:{escapeKey:f&&B.type===`menu`},outsidePress(){return B.type!==`context-menu`||ue.current?.type===`contextmenu`||de.current},externalTree:he?I:void 0}),De=Hu(),Oe=Dl(Se,{enabled:!ae,listRef:F.context.itemDomElements,activeIndex:oe,virtual:v,nested:B.type===`menubar`||!v&&B.type!==void 0,parentOrientation:B.type===`menubar`?B.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?se:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:De===`rtl`,disabledIndices:La,onNavigate(e,t){F.setActiveIndex(e,zS(t),t?.nativeEvent)},openOnArrowKeyDown:B.type!==`context-menu`&&!(v&&_),externalTree:!v&&he?I:void 0,nestedReturnFocusRef:te?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),ke=Z.useCallback(e=>{F.context.typingRef.current=e},[F]),Ae=Ol(Se,{enabled:!ae&&!v,listRef:F.context.itemLabels,elementsRef:F.context.itemDomElements,activeIndex:oe,resetMs:500,onMatch:(e,t)=>{re&&e!==oe&&F.setActiveIndex(e,io,t.nativeEvent)},onTyping:ke}),je=Y(a),Me=Z.useRef(-1),Ne=Y(()=>{let e=F.state.activeIndex,t=e===null?void 0:F.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Me.current===n&&F.context.reportedItem===t)return;Me.current=n,F.context.reportedItem=t,v&&F.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=F.context;F.context.highlightReason=Ha,F.context.highlightEvent=void 0,a&&je(t,Ao(r,i,{label:t===void 0?void 0:F.context.itemLabels.current[n]??void 0}))});X(()=>{Ne()},[oe,Ne]);let Pe=Z.useMemo(()=>{if(!v)return Oe.reference;if(!Oe.trigger)return Co;let{onFocus:e,...t}=Oe.trigger;return t},[v,Oe.reference,Oe.trigger]);F.useSyncedValue(`inputProps`,v?Oe.reference??Co:Co);let V=Z.useMemo(()=>{let e=no(Ae.reference,Pe,Ee.reference,{onMouseMove(){F.set(`allowMouseEnter`,!0)}},_e);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=re,e},[F,Ae.reference,Pe,Ee.reference,_e,re]),Fe=Z.useMemo(()=>{let e=no(Oe.trigger,Ee.trigger,_e);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[Oe.trigger,Ee.trigger,_e]);Ba(()=>(F.update({inactiveTriggerProps:Fe}),null)),Qc(F,{floatingRootContext:Se,activeTriggerProps:V,inactiveTriggerProps:Fe,popupProps:Z.useMemo(()=>no(Bc,{onMouseMove(){F.set(`allowMouseEnter`,!0),B.type===`menu`&&F.set(`hoverEnabled`,!1)},onClick(){F.select(`hoverEnabled`)&&F.set(`hoverEnabled`,!1)},onKeyDown(e){let t=F.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Ae.floating,Oe.floating,Ee.floating),[B.type,F,Ae.floating,Oe.floating,Ee.floating]),itemProps:Oe.item??Co});let Ie=Z.useMemo(()=>({store:F,parent:D,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:k,setRenderedFloatingId:j,virtualFocus:v,parentVirtualFocus:E,syncHighlightedItem:Ne}),[F,D,u,l,b,k,v,E,Ne]),Le=typeof t==`function`?t({payload:ce}):t,Re=(0,Q.jsxs)(Tx.Provider,{value:Ie,children:[p&&(0,Q.jsx)(Uc,{handle:p,store:F}),Le]});return(B.type===void 0||B.type===`context-menu`)&&(Re=(0,Q.jsx)(Cc,{externalTree:I,children:Re})),Re});function JS(e){let t=Z.useContext(WS);if(t===null)return(0,Q.jsx)(qS,{...e});let n=t.Root;return(0,Q.jsx)(WS.Provider,{value:null,children:(0,Q.jsx)(n,{...t.options,...e})})}var YS={};function XS(e){Ex();let t=Z.useContext(WS);if(t!==null){let n=t.SubmenuRoot;return(0,Q.jsx)(WS.Provider,{value:null,children:(0,Q.jsx)(n,{...t.options,...e})})}return(0,Q.jsx)(Qx.Provider,{value:YS,children:(0,Q.jsx)(qS,{...e,isSubmenu:!0})})}var ZS=5;function QS(e,t){let n=$S(t);return e.clientX>=n.left-ZS&&e.clientX<=n.right+ZS&&e.clientY>=n.top-ZS&&e.clientY<=n.bottom+ZS}function $S(e){let t=e.getBoundingClientRect(),n=Po(e);if(fa)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}}function eC(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=So(),{ref:i,index:a}=Bx(e),o=n===a,s=Z.useRef(null),c=yo(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function tC(e){let{render:t,className:n,style:r,state:i=Co,props:a=La,refs:o=La,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=eC({metadata:s});return Ci(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function nC(e){if(jo(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!ma(e))return nC(Ma(e))}function rC(e,t){function n(n,r,i){let a=n.currentTarget;Qo.flushSync(()=>{e.setOpen(!1,ki(Fa,n.nativeEvent,a))}),ga(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&ya(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function iC(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=Z.useRef(!1);return Z.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,fo(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:Co,[t,n,r])}var aC=Xi(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=Ex(!0),h=ul(d)??m?.store;if(!h)throw Error(Na(85));let g=Vx(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerControlsId`,g),x=Z.useRef(null),S=sC(),C=So(!0),w=bc(),T=Z.useMemo(()=>w??new gc,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=Yc(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:xc(T),floatingParentNodeId:yc(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=Ya({disabled:A,native:o});Z.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let ee=Z.useRef(null),te=to(),N=Y(e=>{if(!ee.current)return;te.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;J(ee.current,t)||J(h.select(`positionerElement`),t)||t===ee.current||t!=null&&nC(t)===h.select(`rootId`)||QS(e,ee.current)||T.events.emit(`close`,{domEvent:e,reason:xo})});Z.useEffect(()=>{let e=fo(ee.current);if(y&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,N,{once:!0}),()=>{e.removeEventListener(`mouseup`,N)}},[y,N,h]);let P=O&&S.context.hasSubmenuOpen,F=bl(v,{enabled:(c??P)&&!A&&(!O||P&&!D),handleClose:Il({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),I=oC(y,h.select(`lastOpenChangeReason`)),ne=Nc(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&I}),re=fl(v,{enabled:!A&&P}),L=iC({open:y,enabled:O,mouseDownAction:`open`}),R=Z.useMemo(()=>no(re.reference,ne.reference),[re.reference,ne.reference]),ie=h.useState(`triggerProps`,D),ae=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:z,handleFocusTargetFocus:B}=rC(h,x),oe={disabled:A,open:y},se=[ee,t,M,E,x],ce=[R,F??Co,ie,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(te.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),fo(e.currentTarget).addEventListener(`mouseup`,N,{once:!0}))}},ae,O?{role:`menuitem`}:{},L,p,j],le=Ci(`button`,e,{enabled:!O,stateAttributesMapping:ds,state:oe,ref:se,props:ce});return O?(0,Q.jsx)(tC,{tag:`button`,render:n,className:r,style:i,state:oe,refs:se,props:ce,stateAttributesMapping:ds}):y?(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(Ki,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:z},`${g}-pre-focus-guard`),(0,Q.jsx)(Z.Fragment,{children:le},g),(0,Q.jsx)(Ki,{ref:h.context.triggerFocusTargetRef,onFocus:B},`${g}-post-focus-guard`)]}):(0,Q.jsx)(Z.Fragment,{children:le},g)});function oC(e,t){let n=to(),[r,i]=Z.useState(!1);return X(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function sC(){let e=PS(!0);return Z.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var cC={"aria-expanded":void 0},lC=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,label:a,id:o,nativeButton:s=!1,openOnHover:c=!0,delay:l=100,closeDelay:u=0,disabled:d=!1,...f}=e,p=Ex(!0);if(p?.parent.type!==`menu`)throw Error(Na(37));let m=wx(),h=$x(),{store:g,parentVirtualFocus:_}=p,v=p.parent.store,y=Bx({guess:!0,label:a}),b=Vx(o),x=g.useState(`open`),S=Z.useRef(!1),C=g.useState(`positionerElement`),w=g.useState(`floatingRootContext`),T=g.useState(`floatingTreeRoot`),E=g.useState(`triggerPopupId`,b),D=Gc(b,g),O=Y(e=>{D(e);let t=g.select(`activeTriggerElement`);e!==null&&g.select(`open`)&&(t===e||g.select(`activeTriggerId`)==null)&&g.update({activeTriggerId:b??null,activeTriggerElement:e,closeDelay:u})}),k=Z.useRef(null),A=Z.useCallback(e=>{k.current=e,g.set(`activeTriggerElement`,e)},[g]);X(()=>(O(k.current),()=>O(null)),[O,b,g]),X(()=>{if(!x||!C)return;function e(e){Fo(e)===g.context.beforeContentFocusGuardRef.current&&(S.current=e.relatedTarget===k.current)}return C.addEventListener(`focusout`,e,!0),()=>{S.current=!1,C.removeEventListener(`focusout`,e,!0)}},[x,C,g]),g.useSyncedValue(`closeDelay`,u);let j=g.useState(`disabled`),M=v.useState(`disabled`),ee=d||j||M,te=v.useState(`itemProps`),N=v.useState(`isActive`,y.index),P=Z.useMemo(()=>({type:`submenu-trigger`,setActive(e){v.select(`highlightItemOnHover`)&&v.setActiveIndex(y.index,Do,e)}}),[v,y.index]),{getItemProps:F,itemRef:I}=Lx({closeOnClick:!1,disabled:ee,highlighted:N,id:b,store:g,typingRef:v.context.typingRef,nativeButton:s,itemMetadata:P,nodeId:m?.context.nodeId}),ne=bl(w,{enabled:g.useState(`hoverEnabled`)&&c&&!ee,handleClose:Il({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:l,delay:{open:l,close:u},shouldOpen:l>0?()=>v.select(`allowMouseEnter`):void 0,triggerElementRef:k,externalTree:T,isClosing:()=>g.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),re=Nc(w,{enabled:!ee,event:`mousedown`,toggle:!0,ignoreMouse:c,stickIfOpen:c}).reference??Co,L=g.useState(`triggerProps`,!0);delete L.id;let R={disabled:ee,highlighted:N,open:x},ie=g.useState(`openMethod`),ae=g.useState(`lastOpenChangeReason`)===`list-navigation`||ie===`keyboard`,z=x&&ae&&ji,B=h?.onTriggerKeyDown?{onKeyDown:h.onTriggerKeyDown}:void 0;return Ci(`div`,e,{state:R,stateAttributesMapping:us,props:[re,ne,L,B,te,z?cC:void 0,{"aria-controls":E,tabIndex:_||!(x||N)?-1:0,onFocus(e){g.select(`open`)&&S.current&&(S.current=!1,g.setOpen(!1,ki(Fa,e.nativeEvent)))},onBlur(){N&&v.setActiveIndex(null,Ha)}},f,F],ref:[t,y.ref,I,O,A]})}),uC=Z.forwardRef(function(e,t){let n=Nx(e,t,`submenu-trigger`);if(!n.visible)return null;let r=n.props?no(n.props,e):e;return(0,Q.jsx)(lC,{...r,ref:n.ref})});function dC(e){let t=(0,$o.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(JS,{"data-slot":`dropdown-menu`,...n}),t[2]=n,t[3]=r),r}function fC(e){let t=(0,$o.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(aC,{"data-slot":`dropdown-menu-trigger`,...n}),t[2]=n,t[3]=r),r}function pC(e){let t=(0,$o.c)(18),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({align:i,alignOffset:a,side:o,sideOffset:s,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=i===void 0?`start`:i,l=a===void 0?0:a,u=o===void 0?`bottom`:o,d=s===void 0?4:s,f;t[7]===n?f=t[8]:(f=xa(`z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95`,n),t[7]=n,t[8]=f);let p;t[9]!==r||t[10]!==f?(p=(0,Q.jsx)(oS,{"data-slot":`dropdown-menu-content`,className:f,...r}),t[9]=r,t[10]=f,t[11]=p):p=t[11];let m;return t[12]!==c||t[13]!==l||t[14]!==u||t[15]!==d||t[16]!==p?(m=(0,Q.jsx)(lS,{children:(0,Q.jsx)(MS,{className:`isolate z-50 outline-none`,align:c,alignOffset:l,side:u,sideOffset:d,children:p})}),t[12]=c,t[13]=l,t[14]=u,t[15]=d,t[16]=p,t[17]=m):m=t[17],m}function mC(e){let t=(0,$o.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(Gx,{"data-slot":`dropdown-menu-group`,...n}),t[2]=n,t[3]=r),r}function hC(e){let t=(0,$o.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,inset:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=xa(`px-2 py-1.5 text-xs text-muted-foreground data-inset:pl-7.5`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==i||t[8]!==a?(o=(0,Q.jsx)(Kx,{"data-slot":`dropdown-menu-label`,"data-inset":r,className:a,...i}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function gC(e){let t=(0,$o.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,inset:r,variant:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`default`:a,s;t[5]===n?s=t[6]:(s=xa(`group/dropdown-menu-item relative flex min-h-7 cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs/relaxed outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7.5 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5 data-[variant=destructive]:*:[svg]:text-destructive`,n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o?(c=(0,Q.jsx)(Jx,{"data-slot":`dropdown-menu-item`,"data-inset":r,"data-variant":o,className:s,...i}),t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=c):c=t[11],c}function _C(e){let t=(0,$o.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(XS,{"data-slot":`dropdown-menu-sub`,...n}),t[2]=n,t[3]=r),r}function vC(e){let t=(0,$o.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=xa(`flex min-h-7 cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7.5 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,Q.jsx)(Wo,{className:`ml-auto`}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,Q.jsxs)(uC,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":i,className:o,...a,children:[n,s]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function yC(e){let t=(0,$o.c)(16),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({align:i,alignOffset:a,side:o,sideOffset:s,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=i===void 0?`start`:i,l=a===void 0?-3:a,u=o===void 0?`right`:o,d=s===void 0?0:s,f;t[7]===n?f=t[8]:(f=xa(`w-auto min-w-32 rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-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`,n),t[7]=n,t[8]=f);let p;return t[9]!==c||t[10]!==l||t[11]!==r||t[12]!==u||t[13]!==d||t[14]!==f?(p=(0,Q.jsx)(pC,{"data-slot":`dropdown-menu-sub-content`,className:f,align:c,alignOffset:l,side:u,sideOffset:d,...r}),t[9]=c,t[10]=l,t[11]=r,t[12]=u,t[13]=d,t[14]=f,t[15]=p):p=t[15],p}function bC(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=xa(`-mx-1 my-1 h-px bg-border/50`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(pb,{"data-slot":`dropdown-menu-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function xC(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=xa(`w-full caption-bottom text-xs`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,Q.jsx)(`table`,{"data-slot":`table`,className:i,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function SC(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=xa(`[&_tr]:border-b`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`thead`,{"data-slot":`table-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function CC(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=xa(`[&_tr:last-child]:border-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`tbody`,{"data-slot":`table-body`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function wC(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=xa(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`tr`,{"data-slot":`table-row`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function TC(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=xa(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`th`,{"data-slot":`table-head`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function EC(e){let t=(0,$o.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=xa(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(`td`,{"data-slot":`table-cell`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var DC=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='256'%20height='150'%20preserveAspectRatio='xMidYMid'%20viewBox='0%200%20256%20150'%3e%3cpath%20fill='%2334a853'%20d='m255.3%20143.5-.3-1.6a128%20128%200%200%200-12.8-38.3%20129%20129%200%200%200-23.4-31.8%20129%20129%200%200%200-22.7-18l.1-.3%207.8-13.4%207.5-13%205.5-9.4a12%2012%200%200%200%20.6-10.5%2012%2012%200%200%200-4.8-5.5%2012%2012%200%200%200-5-1.7h-2.2a12%2012%200%200%200-9%205.9l-5.4%209.3-7.6%2013.1-7.7%2013.4-.9%201.5-1.2-.5a128%20128%200%200%200-45.8-8.4h-1.3q-21.7.3-41%207.1l-4.5%201.7-.7-1.4-7.8-13.4-7.6-13-5.4-9.4A12%2012%200%200%200%2048.5%200a12%2012%200%200%200-5%201.7%2012%2012%200%200%200-4%204q-.6.8-.8%201.5a12%2012%200%200%200-.4%208.2l1%202.3%205.5%209.4%207.5%2013%207.8%2013.4v.1a129%20129%200%200%200-14.8%2010.8%20130%20130%200%200%200-22.2%2024%20128%20128%200%200%200-9.3%2015.2%20128%20128%200%200%200-10.9%2028.8l-2%209.5-.2%201.6L0%20149h256z'/%3e%3cpath%20fill='%23202124'%20d='M194.6%20113.7c5.1-3.4%205.9-11.3%201.7-17.6s-11.8-8.7-17-5.3c-5%203.4-5.8%2011.3-1.6%2017.6s11.8%208.7%2016.9%205.3m-116-5.2c4.1-6.4%203.4-14.2-1.7-17.7-5.2-3.4-12.7-1-17%205.3-4.1%206.3-3.4%2014.2%201.7%2017.6%205.2%203.4%2012.7%201%2017-5.2'/%3e%3c/svg%3e`,OC=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%20width='209'%20height='256'%20viewBox='0%200%20814%201000'%3e%3cpath%20d='M788.1%20340.9c-5.8%204.5-108.2%2062.2-108.2%20190.5%200%20148.4%20130.3%20200.9%20134.2%20202.2-.6%203.2-20.7%2071.9-68.7%20141.9-42.8%2061.6-87.5%20123.1-155.5%20123.1s-85.5-39.5-164-39.5c-76.5%200-103.7%2040.8-165.9%2040.8s-105.6-57-155.5-127C46.7%20790.7%200%20663%200%20541.8c0-194.4%20126.4-297.5%20250.8-297.5%2066.1%200%20121.2%2043.4%20162.7%2043.4%2039.5%200%20101.1-46%20176.3-46%2028.5%200%20130.9%202.6%20198.3%2099.2m-234-181.5c31.1-36.9%2053.1-88.1%2053.1-139.3A96%2096%200%200%200%20605.3%200c-50.6%201.9-110.8%2033.7-147.1%2075.8-28.5%2032.4-55.1%2083.6-55.1%20135.5%200%207.8%201.3%2015.6%201.9%2018.1%203.2.6%208.4%201.3%2013.6%201.3%2045.4%200%20102.5-30.4%20135.5-71.3'/%3e%3c/svg%3e`,kC=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20preserveAspectRatio='xMidYMid'%20viewBox='0%200%20190.5%20190.5'%3e%3cpath%20fill='%23fff'%20d='M95.3%20142.9a47.6%2047.6%200%201%200%200-95.3%2047.6%2047.6%200%200%200%200%2095.3'/%3e%3cpath%20fill='%23229342'%20d='M54%20119%2012.8%2047.7a95%2095%200%200%200%200%2095.3%2095%2095%200%200%200%2082.5%2047.6l41.2-71.4a48%2048%200%200%201-17.4%2017.4%2048%2048%200%200%201-47.7%200A48%2048%200%200%201%2054%20119.1'/%3e%3cpath%20fill='%23fbc116'%20d='m136.5%20119-41.2%2071.5a95%2095%200%200%200%2082.4-47.6%2095%2095%200%200%200%2012.8-47.7%2095%2095%200%200%200-12.8-47.6H95.2a48%2048%200%200%201%2023.9%206.4%2048%2048%200%200%201%2017.4%2017.4%2048%2048%200%200%201%200%2047.7'/%3e%3cpath%20fill='%231a73e8'%20d='M95.3%20133a37.7%2037.7%200%201%200%200-75.4%2037.7%2037.7%200%200%200%200%2075.4'/%3e%3cpath%20fill='%23e33b2e'%20d='M95.3%2047.6h82.4A95%2095%200%200%200%20143%2012.8%2095%2095%200%200%200%2095.2%200a95%2095%200%200%200-47.6%2012.8%2095%2095%200%200%200-34.8%2034.8L54%20119.1a48%2048%200%200%201%200-47.7%2048%2048%200%200%201%2041.3-23.8'/%3e%3c/svg%3e`,AC=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='256'%20height='257'%20preserveAspectRatio='xMidYMid'%20viewBox='0%200%20256%20257'%3e%3cpath%20fill='%23d97757'%20d='m50.2%20170.3%2050.4-28.2.8-2.5-.8-1.4H98l-8.4-.5-28.8-.8-25-1-24.1-1.3-6.1-1.3-5.7-7.5.6-3.8%205.1-3.4%207.3.7%2016.2%201%2024.3%201.7%2017.7%201%2026%202.8h4.2l.6-1.7-1.4-1-1.1-1L74.3%20105%2047.1%2087%2033%2076.6l-8-5.2-3.8-5-1.7-10.7%207-7.7%209.4.6%202.4.7%209.5%207.3%2020.3%2015.7L94.8%2092l4%203.2%201.5-1%20.2-.8-1.8-3-14.4-26-15.5-26.6-6.8-11-2-6.8c-.6-2.7-1-5-1-7.8l8-10.8L71.3%200%2082%201.4l4.5%204%206.6%2015%2010.7%2023.8%2016.6%2032.3%204.9%209.6%202.6%209%201%202.6h1.6v-1.5L132%2078l2.5-22.4%202.5-28.8.8-8%204-9.8%208-5.2%206.2%203%205.2%207.3-.8%204.7-3%2019.8-6%2031-3.9%2020.7h2.3l2.6-2.6%2010.5-14%2017.6-22%207.8-8.7%209-9.7%206-4.6h11l8%2012-3.6%2012.5-11.3%2014.4-9.4%2012.2-13.5%2018.1-8.4%2014.5.7%201.2%202-.2%2030.5-6.5%2016.5-3%2019.6-3.3%208.9%204.1%201%204.2-3.5%208.7-21%205.1-24.7%205-36.7%208.7-.4.3.5.6L186%20139l7.1.4h17.3l32.2%202.4%208.4%205.5%205.1%206.9-.8%205.1-13%206.6-17.5-4.1-40.8-9.7-14-3.5h-2v1.1l11.7%2011.5%2021.4%2019.3%2026.7%2024.9%201.4%206.1-3.4%204.9-3.7-.5-23.5-17.7-9-8-20.6-17.3h-1.4v1.8l4.8%207%2025%2037.5%201.3%2011.6-1.8%203.7-6.5%202.3-7.1-1.3-14.7-20.6-15-23-12.3-20.8-1.5.8-7.2%2077.5-3.3%204-7.8%202.9-6.5-5-3.4-7.9%203.4-15.8%204.2-20.5%203.3-16.3%203-20.3%201.9-6.8-.1-.4-1.5.2-15.3%2021L87%20215.8l-18.4%2019.7-4.4%201.8-7.7-4%20.8-7%204.2-6.3L87%20187.6l15.4-20.1%209.9-11.6v-1.7h-.7l-67.6%2044-12%201.5-5.3-4.9.7-8%202.4-2.5z'/%3e%3c/svg%3e`,jC=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='1em'%20height='1em'%20fill='%23111'%20fill-rule='evenodd'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20d='M8%20.5a6%206%200%200%201%203.1-.5q2.1.3%203.6%201.7h.1a6%206%200%200%201%204%20.4h.1l.2.1a6%206%200%200%201%203.3%205.4l-.2%201.6v.2a6%206%200%200%201%201.7%202.8%206%206%200%200%201-1.2%205.2l-.2.2a6%206%200%200%201-3%201.9l-1%202a6%206%200%200%201-5%202.5%206%206%200%200%201-4.2-1.7h-.1l-1.6.1a6%206%200%200%201-2.6-.6A6%206%200%200%201%202.8%2020l-.5-.8-.5-1.3a6%206%200%200%201%200-3v-.1a6%206%200%200%201-1.5-2.3L0%2011l.2-2.1a6%206%200%200%201%204.2-4.3h.1a6%206%200%200%201%201.1-2.2A6%206%200%200%201%208.1.5m-.7%207.8a.8.8%200%200%200-1.5.8l1.7%203L5.8%2015a.8.8%200%200%200%201.5.8l2-3.2a1%201%200%200%200%200-.9zm5.4%206.2a.8.8%200%200%200%200%201.7h4.9a.8.8%200%200%200%200-1.7z'%20clip-rule='evenodd'/%3e%3c/svg%3e`,MC=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20256%20256'%3e%3cdefs%3e%3cradialGradient%20id='b'%20cx='161.8'%20cy='68.9'%20r='95.4'%20gradientTransform='matrix(1%200%200%20-.95%200%20248.8)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='.7'%20stop-opacity='0'/%3e%3cstop%20offset='.9'%20stop-opacity='.5'/%3e%3cstop%20offset='1'/%3e%3c/radialGradient%3e%3cradialGradient%20id='d'%20cx='-340.3'%20cy='63'%20r='143.2'%20gradientTransform='rotate(98.6%20142.3%2013.2)scale(-1%20.8)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='.8'%20stop-opacity='0'/%3e%3cstop%20offset='.9'%20stop-opacity='.5'/%3e%3cstop%20offset='1'/%3e%3c/radialGradient%3e%3cradialGradient%20id='e'%20cx='113.4'%20cy='570.2'%20r='202.4'%20gradientTransform='rotate(92.2%20-538%20-620.8)scale(1%20-2.13)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%2335c1f1'/%3e%3cstop%20offset='.1'%20stop-color='%2334c1ed'/%3e%3cstop%20offset='.2'%20stop-color='%232fc2df'/%3e%3cstop%20offset='.3'%20stop-color='%232bc3d2'/%3e%3cstop%20offset='.7'%20stop-color='%2336c752'/%3e%3c/radialGradient%3e%3cradialGradient%20id='f'%20cx='376.5'%20cy='568'%20r='97.3'%20gradientTransform='matrix(.28%20.96%20.78%20-.23%20-303.8%20-148.5)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%2366eb6e'/%3e%3cstop%20offset='1'%20stop-color='%2366eb6e'%20stop-opacity='0'/%3e%3c/radialGradient%3e%3clinearGradient%20id='a'%20x1='63.3'%20x2='241.7'%20y1='84'%20y2='84'%20gradientTransform='matrix(1%200%200%20-1%200%20266)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%230c59a4'/%3e%3cstop%20offset='1'%20stop-color='%23114a8b'/%3e%3c/linearGradient%3e%3clinearGradient%20id='c'%20x1='157.3'%20x2='46'%20y1='161.4'%20y2='40.1'%20gradientTransform='matrix(1%200%200%20-1%200%20266)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%231b9de2'/%3e%3cstop%20offset='.2'%20stop-color='%231595df'/%3e%3cstop%20offset='.7'%20stop-color='%230680d7'/%3e%3cstop%20offset='1'%20stop-color='%230078d4'/%3e%3c/linearGradient%3e%3c/defs%3e%3cpath%20fill='url(%23a)'%20d='M235.7%20195.5a94%2094%200%200%201-10.6%204.7%20102%20102%200%200%201-35.9%206.4c-47.3%200-88.5-32.5-88.5-74.3a32%2032%200%200%201%2016.4-27.3c-42.8%201.8-53.8%2046.4-53.8%2072.5%200%2074%2068.1%2081.4%2082.8%2081.4%207.9%200%2019.8-2.3%2027-4.6l1.3-.4a128%20128%200%200%200%2066.6-52.8%204%204%200%200%200-5.3-5.6'%20transform='translate(-4.6%20-5)'/%3e%3cpath%20fill='url(%23b)'%20d='M235.7%20195.5a94%2094%200%200%201-10.6%204.7%20102%20102%200%200%201-35.9%206.4c-47.3%200-88.5-32.5-88.5-74.3a32%2032%200%200%201%2016.4-27.3c-42.8%201.8-53.8%2046.4-53.8%2072.5%200%2074%2068.1%2081.4%2082.8%2081.4%207.9%200%2019.8-2.3%2027-4.6l1.3-.4a128%20128%200%200%200%2066.6-52.8%204%204%200%200%200-5.3-5.6'%20opacity='.3'%20style='isolation:isolate'%20transform='translate(-4.6%20-5)'/%3e%3cpath%20fill='url(%23c)'%20d='M110.3%20246.3A79%2079%200%200%201%2087.6%20225a80.7%2080.7%200%200%201%2029.5-120c3.2-1.5%208.5-4.1%2015.6-4a32%2032%200%200%201%2025.7%2013%2032%2032%200%200%201%206.3%2018.7c0-.2%2024.5-79.6-80-79.6-43.9%200-80%2041.6-80%2078.2a130%20130%200%200%200%2012.1%2056%20128%20128%200%200%200%20156.4%2067%2076%2076%200%200%201-62.8-8Z'%20transform='translate(-4.6%20-5)'/%3e%3cpath%20fill='url(%23d)'%20d='M110.3%20246.3A79%2079%200%200%201%2087.6%20225a80.7%2080.7%200%200%201%2029.5-120c3.2-1.5%208.5-4.1%2015.6-4a32%2032%200%200%201%2025.7%2013%2032%2032%200%200%201%206.3%2018.7c0-.2%2024.5-79.6-80-79.6-43.9%200-80%2041.6-80%2078.2a130%20130%200%200%200%2012.1%2056%20128%20128%200%200%200%20156.4%2067%2076%2076%200%200%201-62.8-8Z'%20opacity='.4'%20style='isolation:isolate'%20transform='translate(-4.6%20-5)'/%3e%3cpath%20fill='url(%23e)'%20d='M157%20153.8c-.9%201-3.4%202.5-3.4%205.6q0%204%204.8%207.3c14.3%2010%2041.4%208.6%2041.5%208.6a60%2060%200%200%200%2030.3-8.3%2061%2061%200%200%200%2030.4-52.9c.3-22.4-8-37.3-11.3-43.9C228%2028.8%20182.3%205%20132.6%205a128%20128%200%200%200-128%20126.2c.5-36.5%2036.8-66%2080-66%203.5%200%2023.5.3%2042%2010a73%2073%200%200%201%2030.9%2029.3c6.1%2010.6%207.2%2024.1%207.2%2029.5s-2.7%2013.3-7.8%2019.9Z'%20transform='translate(-4.6%20-5)'/%3e%3cpath%20fill='url(%23f)'%20d='M157%20153.8c-.9%201-3.4%202.5-3.4%205.6q0%204%204.8%207.3c14.3%2010%2041.4%208.6%2041.5%208.6a60%2060%200%200%200%2030.3-8.3%2061%2061%200%200%200%2030.4-52.9c.3-22.4-8-37.3-11.3-43.9C228%2028.8%20182.3%205%20132.6%205a128%20128%200%200%200-128%20126.2c.5-36.5%2036.8-66%2080-66%203.5%200%2023.5.3%2042%2010a73%2073%200%200%201%2030.9%2029.3c6.1%2010.6%207.2%2024.1%207.2%2029.5s-2.7%2013.3-7.8%2019.9Z'%20transform='translate(-4.6%20-5)'/%3e%3c/svg%3e`,NC=`/assets/firefox-5m8yovBp.svg`,PC=`/assets/safari-DgmPRf57.svg`;function FC(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function IC(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function LC(){return RC.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var RC={stubThis:e=>e};function zC(e){let{id:t}=e;return{...e,id:IC(t),transports:e.transports,type:e.type}}function BC(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var VC=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function HC({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new VC({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new VC({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new VC({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new VC({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new VC({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new VC({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new VC({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new VC({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!BC(t))return new VC({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new VC({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new VC({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new VC({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var UC=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},WC=[`cross-platform`,`platform`];function GC(e){if(e&&!(WC.indexOf(e)<0))return e}async function KC(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!LC())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:IC(t.challenge),user:{...t.user,id:IC(t.user.id)},excludeCredentials:t.excludeCredentials?.map(zC)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=UC.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw HC({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){qC(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=FC(e))}catch(e){qC(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=FC(c.getAuthenticatorData())}catch(e){qC(`getAuthenticatorData()`,e)}return{id:o,rawId:FC(s),response:{attestationObject:FC(c.attestationObject),clientDataJSON:FC(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:GC(a.authenticatorAttachment)}}function qC(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function JC(){if(!LC())return YC.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?YC.stubThis(new Promise(e=>e(!1))):YC.stubThis(e.isConditionalMediationAvailable())}var YC={stubThis:e=>e};function XC({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new VC({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new VC({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!BC(t))return new VC({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new VC({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new VC({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function ZC(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!LC())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(zC));let a={...t,challenge:IC(t.challenge),allowCredentials:i},o={};if(n){if(!await JC())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=UC.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw XC({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=FC(u.userHandle)),{id:c,rawId:FC(l),response:{authenticatorData:FC(u.authenticatorData),clientDataJSON:FC(u.clientDataJSON),signature:FC(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:GC(s.authenticatorAttachment)}}var QC=ly,$C=dy,ew=py,tw=`https://auth.mp281x.xyz`,nw=Kr(fn(Zn(`AUTH_URL`)),ie);Sn(function*(){let e=on(H,`GITHUB_ADMINS`);return(yield*nw)?yield*Cn(e,[`0`]):yield*e}),wr()(`@deslop/runtime/auth/lib/utils/CurrentUser`);var rw=class extends cr()(`@deslop/runtime/auth/lib/utils/RpcAuth`,{error:Bo}){},iw=W({name:x,open:x,origin:la}),aw=tr(iw);W({origin:la});var ow=W({incarnation:x,user:va});wr()(`@deslop/auth/services/tokens/schema/CurrentOwner`);var sw=W({...ow.fields,incarnation:rn(x,It(ke(`legacy`)))}),cw=W({client_name:L(H.check(Te(100))),redirect_uris:ot(x.check(Te(200))).check(Te(4)),token_endpoint_auth_method:L($t(`none`))});W({name:H,redirects:cw.fields.redirect_uris}),W({client_id:x.check(Te(2048)),redirect_uri:L(H),state:L(H)}),W({code_challenge:L(x),code_challenge_method:L(H),resource:L(vr(H)),response_type:L(H),scope:L(H)});var lw=W({challenge:x,clientId:x,clientName:H,redirectUri:x,resources:ot(Oi),state:L(x)});W({grant_type:H});var uw=L(vr(Oi).check(nt(1)));Fe([W({client_id:x,code:x,code_verifier:x,grant_type:$t(`authorization_code`),redirect_uri:L(H),resource:uw}),W({client_id:L(H),grant_type:$t(`refresh_token`),refresh_token:x,resource:uw})]);var dw=W({access_token:x,expires_in:Wt,refresh_token:x,scope:$t(`deslop`),token_type:$t(`Bearer`)});Ae({Granted:{tokens:dw},Replayed:{message:H}});var fw=W({address:L(H),userAgent:L(H)}),pw=W({expiresAt:Wt,hash:H,resources:tr(Oi)}),mw=si([`Code`,`GitHub`,`Passkey`]),hw=W({...sw.fields,client:H,createdAt:Wt,credential:Ae({App:{access:tr(pw),clientId:x,expiresAt:Wt,generation:Zr,hash:H,replaced:L(Fe([H,tr(H)])),resources:tr(Oi)},Browser:{expiresAt:Wt,hash:H,via:L(mw)}}),device:H,lastActive:Wt,origin:fw});M(H,hw);var gw=W({address:L(H),client:H,createdAt:Wt,device:H,expiresAt:Wt,family:x,kind:si([`App`,`Browser`]),lastActive:Wt,resources:tr(Oi)}),_w=W({family:x});W({client_id:x,token:x}),W({resource:Oi});var vw=si([`ble`,`cable`,`hybrid`,`internal`,`nfc`,`smart-card`,`usb`]),yw=$t(`public-key`),bw=si([`required`,`preferred`,`discouraged`]),xw=W({id:H,transports:L(_t(tr(vw))),type:yw}),Sw=W({attestation:L(si([`direct`,`enterprise`,`indirect`,`none`])),authenticatorSelection:L(W({authenticatorAttachment:L(si([`cross-platform`,`platform`])),requireResidentKey:L(An),residentKey:L(si([`discouraged`,`preferred`,`required`])),userVerification:L(bw)})),challenge:H,excludeCredentials:L(_t(tr(xw))),pubKeyCredParams:_t(tr(W({alg:Wt,type:yw}))),rp:W({id:L(H),name:H}),timeout:L(Wt),user:W({displayName:H,id:H,name:H})}),Cw=W({allowCredentials:L(_t(tr(xw))),challenge:H,rpId:L(H),timeout:L(Wt),userVerification:L(bw)}),ww=L(si([`cross-platform`,`platform`])),Tw=W({authenticatorAttachment:ww,clientExtensionResults:W({}),id:H,rawId:H,response:W({attestationObject:H,clientDataJSON:H,transports:L(tr(H))}),type:yw}),Ew=W({authenticatorAttachment:ww,clientExtensionResults:W({}),id:H,rawId:H,response:W({authenticatorData:H,clientDataJSON:H,signature:H,userHandle:L(H)}),type:yw});W({challenge:H});var Dw=W({...sw.fields,addedFrom:H,counter:Zr,createdAt:Wt,id:x,lastUsed:Wt,publicKey:x,synced:An,transports:tr(vw)});tr(Dw);var Ow=W({addedFrom:H,createdAt:Wt,id:x,lastUsed:Wt,synced:An}),kw=W({id:x}),Aw=W({response:Tw}),jw=W({next:L(x.check(Te(2048))),response:Ew}),Mw=si([`Admin`,`Member`,`Waiting`]),Nw=W({...va.fields,fullName:L(H),role:Mw}),Pw=W({...Nw.fields,via:mw}),Fw=W({...Nw.fields,since:Wt}),Iw=si([`Waiting`,`Allowed`]),Lw=W({fullName:H,id:x,incarnation:sw.fields.incarnation,name:x,since:Wt,status:Iw});tr(Lw),W({id:Zr,login:x,name:L(ri(H))});var Rw=W({allow:An,id:x}),zw=W({id:x}),Bw=si([`App`,`Browser`]),Vw=W({address:L(H),clientName:H,createdAt:Wt,device:H,expiresAt:Wt,id:x,kind:Bw,resources:tr(Oi)}),Hw=Ae({Decided:{},Expired:{},Waiting:{request:Vw}}),Uw=Ae({Browser:{next:L(H)},Client:{request:lw}});Ae({Redirect:{url:x},Session:{next:L(H),seconds:Zr,token:x},Waiting:{}}),W({delivery:Uw,origin:fw}),W({next:L(x.check(Te(2048)))});var Ww=W({request:x.check(Te(20))}),Gw=W({code:x.check(Te(20))}),Kw=W({...Ww.fields,accept:An}),qw=class extends cr()(`@deslop/auth/rpcs/RpcOwner`,{error:Bo}){},Jw=class extends kr(sn(`auth.lookup`,{error:Bo,payload:Gw,stream:!0,success:ft(Vw)}),sn(`auth.answer`,{error:Bo,payload:Kw}),sn(`auth.people`,{error:Bo,stream:!0,success:tr(Fw)}),sn(`auth.admit`,{error:Bo,payload:Rw,success:Fw}),sn(`auth.remove`,{error:Bo,payload:zw,success:Fw}),sn(`auth.apps`,{error:Bo,stream:!0,success:tr(gw)}),sn(`auth.catalog`,{error:Bo,stream:!0,success:aw}),sn(`auth.disconnect`,{error:Bo,payload:_w}),sn(`auth.passkeys`,{error:Bo,stream:!0,success:tr(Ow)}),sn(`auth.passkeyOptions`,{error:Bo,success:Sw}),sn(`auth.addPasskey`,{error:Bo,payload:Aw}),sn(`auth.removePasskey`,{error:Bo,payload:kw})).middleware(rw).middleware(qw).merge(kr(sn(`auth.account`,{error:Bo,stream:!0,success:Pw}),sn(`auth.wait`,{error:Bo,payload:Ww,stream:!0,success:Hw}))){};function Yw(e){return bn(jr(/[^a-z]/giu,``)(e))}function Xw(e){return oe(pi(e),Lr)}an(function*(e,t,n){if(ie(Xw(n.response_type)))return yield*Bo.make({message:`Send response_type=code`});if(n.response_type!==`code`)return yield*Bo.make({error:`unsupported_response_type`,message:`Only response_type=code is supported`});if(n.code_challenge===void 0||n.code_challenge_method!==`S256`)return yield*Bo.make({message:`Send a PKCE code_challenge with code_challenge_method=S256`});if(!cn(yn(Jn(n.scope??``,` `),Lr),e=>e===`deslop`||e===`offline_access`))return yield*Bo.make({error:`invalid_scope`,message:`Only the deslop scope is supported`});let r=yield*rn(Ge(ot(Oi))(n.resource??[]),Xr(e=>Bo.make({cause:e,error:`invalid_target`,message:`Name a Deslop app with the resource parameter`})));return lw.make({challenge:n.code_challenge,clientId:e.client_id,clientName:t.clientName,redirectUri:t.redirectUri,resources:r,...ge(Xw(e.state),{onNone:()=>({}),onSome:e=>({state:e})})})});function Zw(e){return rn(new URL(e).hostname,Jn(`.`),Hr(1),ai(`.`))}function Qw(e,t){let n=Zw(t);return He(sr(e),{onFailure:()=>!1,onSuccess:e=>e.protocol===`https:`&&(e.hostname===n||a(`.${n}`)(e.hostname))&&mn(e.username)&&mn(e.password)})}var $w=rt(de),eT=class extends en()(`@deslop/auth/lib/utils/RpcClient`,{group:Jw,protocol:ia(`@deslop/auth`)}){},tT=qr(eT.runtime.atom(rn(eT,Ut(e=>e(`auth.account`,void 0)),Bn,qi,it(Mt),gr(`AuthError`,()=>oi(yr()))))),nT={accept:An,request:Vw},rT=ub(eT.runtime).make($C({branches:{looked:{found:{target:`Code.Found`},missing:{target:`Code.Missing`}}},events:ew({Answered:nT,Typed:{typed:H}}),root:QC({states:{Code:{fields:{code:H},states:{Failed:{fields:{message:H}},Found:{fields:{request:Vw}},Looking:{},Missing:{}}},Typing:{fields:{answered:L(W(nT)),typed:H}}}}),streams:{lookup:e=>qi(Bn(Ut(eT,t=>t(`auth.lookup`,{code:e}))))}}).handle({initial:{data:{typed:``},target:`Typing`},on:{Answered:{data:e=>({answered:{accept:e.event.accept,request:e.event.request},typed:``}),target:`Typing`},Typed:{data:e=>({typed:e.event.typed}),target:`Typing`}},states:{Code:{initial:{target:`Code.Looking`},invoke:{input:e=>e.state.code,onDone:{none:!0},onElement:{branches:`looked`,resolve:e=>ge(e.element,{onNone:()=>e.select.missing(),onSome:t=>e.select.found({data:{request:t}})})},onFailure:{data:e=>({message:e.error.message}),target:`Code.Failed`},src:`lookup`},states:{Failed:{},Found:{},Looking:{},Missing:{}}},Typing:{always:{data:e=>({code:e.state.typed}),guard:e=>Tr(e.state.typed)>=8,target:`Code`}}}})),iT=ci(e=>{e.set(rT.send,{_tag:`Typed`,typed:Yw(new URLSearchParams(location.search).get(`code`)??``)})}),aT=qr(eT.runtime.atom(rn(eT,Ut(e=>e(`auth.people`,void 0)),Bn,qi))),oT=qr(eT.runtime.atom(rn(eT,Ut(e=>e(`auth.apps`,void 0)),Bn,qi)));function sT(e){return t=>le(t,t=>U(()=>so.add({description:t.message,title:e,type:`error`})))}var cT=eT.runtime.fn(e=>rn(q(eT,t=>Xn(e,e=>t(`auth.disconnect`,{family:e}),{concurrency:`unbounded`,discard:!0})),sT(`Cannot sign out`))),lT=Dn(e=>eT.runtime.fn(t=>q(eT,n=>n(`auth.admit`,{allow:t,id:e})))),uT=Dn(e=>eT.runtime.fn(()=>q(eT,t=>t(`auth.remove`,{id:e})))),dT=Qe(new URLSearchParams(location.search).get(`request`)),fT=Dn(e=>eT.runtime.atom(rn(eT,Ut(t=>t(`auth.wait`,{request:e})),Bn,qi,Gn(t=>rn(pr(t),In(`Decided`,()=>U(()=>location.assign(`/auth/continue?${new URLSearchParams({request:e})}`))),Or(()=>z))))));function pT(e){return`${tn(0,4)(e)}-${tn(4)(e)}`}function mT(e){return`${location.origin}/?code=${e}`}var hT=qr(eT.runtime.atom(rn(eT,Ut(e=>e(`auth.catalog`,void 0)),Bn,qi)));function gT(e){return li(e)?[`browser`]:qn(v(e,e=>new URL(e).origin))}function _T(e){return rn(xn(e),un({hour:`2-digit`,minute:`2-digit`}))}var vT=ci(rn(u(`1 minute`),y(()=>Ct))),yT=ci(rn(u(`1 second`),y(()=>Ct)));function bT(e,t){let n=hr(0,Math.ceil((e-t)/1e3));return`${Math.floor(n/60)}:${Kt(2,`0`)(`${n%60}`)}`}var xT=wn(e=>rn(tt({catch:e=>Bo.make({cause:e,message:`Cannot copy the code; type it in instead`}),try:()=>navigator.clipboard.writeText(e)}),G(Vn(`1200 millis`))));function ST(e,t){return Math.floor(rr(Wr(xn(e),xn(t))))}function CT(e){return e<1?`now`:e<60?`${e}m`:e<1440?`${Math.floor(e/60)}h`:`${Math.floor(e/1440)}d`}function wT(e,t){return`${e} · ${t}`}function TT(e){return k(e,0,(e,t)=>hr(e,t.lastActive))}function ET(e){return rn(xn(e),un({day:`numeric`,month:`short`}))}function DT(e){return`https://avatars.githubusercontent.com/u/${ur(`github:`,``)(e)}?s=96`}var OT=eT.runtime.fn((e,t)=>rn(eT,q(t=>t(`auth.answer`,{accept:e.accept,request:e.request.id})),G(U(()=>t.set(rT.send,{_tag:`Answered`,...e}))))),kT=Qe(new URLSearchParams(location.search).get(`next`));function AT(e){return K(e.cause,`name`)&&e.cause.name===`NotAllowedError`}var jT=an(function*(e){return e.status===429?yield*Bo.make({message:`Too many tries; wait a minute and try again`}):yield*Bo.make({message:(yield*t(W({error_description:H}))(e)).error_description})}),MT=$w.fn(()=>rn(Sn(function*(){let e=yield*jt,n=yield*e.get(`/auth/passkey`);if(n.status!==200)return yield*jT(n);let r=yield*t(Cw)(n),a=yield*i(tt({catch:e=>Bo.make({cause:e,message:`No passkey was used`}),try:()=>ZC({optionsJSON:r})}),AT,()=>_r),o=yield*rn(vn(`/auth/passkey`),Vr(jw)({...ge(kT,{onNone:()=>({}),onSome:e=>({next:e})}),response:a}),q(t=>e.execute(t)),q(an(function*(e){return e.status===200?yield*t(W({next:L(H)}))(e):yield*jT(e)})));yield*U(()=>ge(pi(o.next),{onNone:()=>location.reload(),onSome:e=>location.assign(e)}))}),Xr(e=>ue(Bo)(e)?e:Bo.make({cause:e,message:`Cannot sign in with a passkey`})))),NT=qr(eT.runtime.atom(rn(eT,Ut(e=>e(`auth.passkeys`,void 0)),Bn,qi))),PT=qr(eT.runtime.fn(an(function*(){let e=yield*eT,t=yield*e(`auth.passkeyOptions`,void 0);yield*e(`auth.addPasskey`,{response:yield*rn(tt({catch:e=>Bo.make({cause:e,message:`No passkey was added`}),try:()=>KC({optionsJSON:t})}),i(AT,()=>_r),q(Ge(Tw)))}),so.add({title:`Passkey added`})},sT(`Cannot add a passkey`)))),FT=`adding-passkey`,IT=wn(()=>gi({catch:e=>Bo.make({cause:e,message:`Cannot start GitHub sign-in`}),try:()=>{sessionStorage.setItem(FT,`true`),location.assign(`/auth/github`)}})),LT=qr(eT.runtime.fn(e=>rn(q(eT,t=>t(`auth.removePasskey`,{id:e})),sT(`Cannot remove the passkey`)))),RT=wn(()=>gi({catch:e=>Bo.make({cause:e,message:`Cannot start GitHub sign-in`}),try:()=>location.assign(`/auth/github${location.search}`)})),zT=wn(()=>gi({catch:e=>Bo.make({cause:e,message:`Cannot start the sign-in`}),try:()=>location.assign(ge(kT,{onNone:()=>`/auth/code`,onSome:e=>`/auth/code?${new URLSearchParams({next:e})}`}))})),BT=new URLSearchParams(location.search).has(`sign-out`),VT=rn(Qe(new URLSearchParams(location.search).get(`next`)),oe(e=>Qw(e,tw)),p(()=>location.pathname)),HT=rn(jt.use(e=>Et(e).post(`/auth/sign-out`)),G(U(()=>location.replace(VT))),Xr(e=>Bo.make({cause:e,message:`Cannot sign out: ${e.message}`}))),UT=$w.fn(()=>HT),WT=$w.fn(()=>sT(`Cannot sign out`)(HT));function GT(e){let t=(0,$o.c)(17),n,r,i,a,o,s;if(t[0]!==e.className||t[1]!==e.text){let c=Tn(sx(e.text)),l=Math.sqrt(c.length);r=`-2 -2 ${l+4} ${l+4}`,i=`crispEdges`,a=`currentColor`,o=e.className,s=`true`,n=rn(c,v((e,t)=>({dark:e,x:t%l,y:Math.floor(t/l)})),yn(qT),v(KT),ai(``)),t[0]=e.className,t[1]=e.text,t[2]=n,t[3]=r,t[4]=i,t[5]=a,t[6]=o,t[7]=s}else n=t[2],r=t[3],i=t[4],a=t[5],o=t[6],s=t[7];let c;t[8]===n?c=t[9]:(c=(0,Q.jsx)(`path`,{d:n}),t[8]=n,t[9]=c);let l;return t[10]!==r||t[11]!==i||t[12]!==a||t[13]!==o||t[14]!==s||t[15]!==c?(l=(0,Q.jsx)(`svg`,{viewBox:r,shapeRendering:i,fill:a,className:o,"aria-hidden":s,children:c}),t[10]=r,t[11]=i,t[12]=a,t[13]=o,t[14]=s,t[15]=c,t[16]=l):l=t[16],l}function KT(e){return`M${e.x} ${e.y}h1v1h-1z`}function qT(e){return e.dark===1}function JT(e){let t=(0,$o.c)(12),n;t[0]===e.id?n=t[1]:(n=DT(e.id),t[0]=e.id,t[1]=n);let r;t[2]!==e.name||t[3]!==n?(r=(0,Q.jsx)(xx,{src:n,alt:e.name}),t[2]=e.name,t[3]=n,t[4]=r):r=t[4];let i;t[5]===e.name?i=t[6]:(i=bn(tn(0,1)(e.name)),t[5]=e.name,t[6]=i);let a;t[7]===i?a=t[8]:(a=(0,Q.jsx)(Sx,{children:i}),t[7]=i,t[8]=a);let o;return t[9]!==r||t[10]!==a?(o=(0,Q.jsxs)(bx,{size:`sm`,children:[r,a]}),t[9]=r,t[10]=a,t[11]=o):o=t[11],o}function YT(e){let t=(0,$o.c)(11),[n,r]=(0,Z.useState)(`loading`),i;t[0]===e.small?i=t[1]:(i=xa(`text-muted-foreground relative flex shrink-0 items-center justify-center`,lr(e.small===!0,{onFalse:ZT,onTrue:XT})),t[0]=e.small,t[1]=i);let a;t[2]===n?a=t[3]:(a=n!==`loaded`&&(0,Q.jsx)(Ho,{className:`size-4`}),t[2]=n,t[3]=a);let o;t[4]!==e.origin||t[5]!==n?(o=n!==`failed`&&(0,Q.jsx)(`img`,{src:`${e.origin}/icon`,alt:``,className:xa(`pixelated absolute inset-0 size-full`,n===`loading`&&`invisible`),onLoad:()=>r(`loaded`),onError:()=>r(`failed`)}),t[4]=e.origin,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==i||t[8]!==a||t[9]!==o?(s=(0,Q.jsxs)(`span`,{className:i,children:[a,o]}),t[7]=i,t[8]=a,t[9]=o,t[10]=s):s=t[10],s}function XT(){return`size-4`}function ZT(){return`size-5`}var QT={Chrome:kC,Edge:MC,Firefox:NC,Safari:PC};function $T(e){return e.kind===`Browser`?I(c(QT,e.name),e=>({mono:!1,src:e})):mt(Nn(/claude/iu)(e.name))?Mt({mono:!1,src:AC}):mt(Nn(/codex/iu)(e.name))?Mt({mono:!0,src:jC}):mt(Nn(/gateway/iu)(e.name))?yr():Ar([`iPhone`,`iPad`],e.device)?Mt({mono:!0,src:OC}):e.device===`Android`?Mt({mono:!1,src:DC}):yr()}function eE(e){return ge($T(e.client),{onNone:()=>rn(pr(e.client),Pr({kind:`Browser`},()=>(0,Q.jsx)(Ko,{})),Pr(e=>mt(Nn(/gateway/iu)(e.name)),()=>(0,Q.jsx)(Jo,{})),Or(()=>(0,Q.jsx)(Xo,{}))),onSome:e=>(0,Q.jsx)(`img`,{src:e.src,alt:``,className:xa(`size-3.5`,e.mono&&`dark:invert`)})})}function tE(e){return ge(e.client.app,{onNone:()=>(0,Q.jsx)(eE,{client:e.client}),onSome:e=>(0,Q.jsx)(YT,{origin:e,small:!0})})}function nE(e){let t=(0,$o.c)(33),[n,r]=Td(cT),i;if(t[0]!==e.column.address||t[1]!==e.column.client||t[2]!==e.column.lastActive||t[3]!==e.column.pending||t[4]!==e.now){let n;t[6]!==e.column.lastActive||t[7]!==e.now?(n=()=>{let t=ST(e.column.lastActive,e.now);return`active ${lr(t<1,{onFalse:()=>`${CT(t)} ago`,onTrue:iE})}`},t[6]=e.column.lastActive,t[7]=e.now,t[8]=n):n=t[8];let r;t[9]===e.column.client?r=t[10]:(r=t=>t!==e.column.client.device,t[9]=e.column.client,t[10]=r),i=ai([lr(e.column.pending,{onFalse:n,onTrue:rE}),...Dt(oe(e.column.address,r))],` · `),t[0]=e.column.address,t[1]=e.column.client,t[2]=e.column.lastActive,t[3]=e.column.pending,t[4]=e.now,t[5]=i}else i=t[5];let a=i,o=`${e.column.label}, ${a}`,s;if(t[11]!==a||t[12]!==r||t[13]!==n||t[14]!==o||t[15]!==e.column.client||t[16]!==e.column.families||t[17]!==e.column.label||t[18]!==e.column.pending){let i;t[20]!==a||t[21]!==r||t[22]!==n||t[23]!==o||t[24]!==e.column.client||t[25]!==e.column.families||t[26]!==e.column.label?(i=()=>(0,Q.jsxs)(dC,{children:[(0,Q.jsx)(fC,{render:(0,Q.jsx)(Wi,{variant:`ghost`,size:`icon-sm`,className:`max-sm:size-11`,title:o,"aria-label":o}),children:(0,Q.jsx)(tE,{client:e.column.client})}),(0,Q.jsxs)(pC,{align:`end`,className:`w-auto min-w-48`,children:[(0,Q.jsx)(mC,{children:(0,Q.jsxs)(hC,{children:[(0,Q.jsx)(`span`,{className:`text-foreground block text-sm`,children:e.column.label}),(0,Q.jsx)(`span`,{className:`font-mono tabular-nums`,children:a})]})}),(0,Q.jsx)(gC,{variant:`destructive`,disabled:f(n),onClick:()=>r(e.column.families),children:`Sign out`})]})]}),t[20]=a,t[21]=r,t[22]=n,t[23]=o,t[24]=e.column.client,t[25]=e.column.families,t[26]=e.column.label,t[27]=i):i=t[27];let c;t[28]!==o||t[29]!==e.column.client?(c=()=>(0,Q.jsx)(`span`,{title:o,"aria-label":o,role:`img`,className:`ring-primary flex size-7 items-center justify-center rounded-sm ring-1`,children:(0,Q.jsx)(tE,{client:e.column.client})}),t[28]=o,t[29]=e.column.client,t[30]=c):c=t[30],s=lr(e.column.pending,{onFalse:i,onTrue:c}),t[11]=a,t[12]=r,t[13]=n,t[14]=o,t[15]=e.column.client,t[16]=e.column.families,t[17]=e.column.label,t[18]=e.column.pending,t[19]=s}else s=t[19];let c;return t[31]===s?c=t[32]:(c=(0,Q.jsx)(TC,{className:`px-0.5`,children:(0,Q.jsx)(`span`,{className:`flex flex-col items-center gap-0.5`,children:s})}),t[31]=s,t[32]=c),c}function rE(){return`waiting for an answer`}function iE(){return`now`}function aE(e,t,n){let r=gT(e);return Ar(r,t)||Ar(r,`browser`)&&n}function oE(e,t){return C(e.resources,e=>aE(e,t.origin,t.web))}function sE(e){let t=(0,$o.c)(21),n,r,i,a,o,s;if(t[0]!==e.column||t[1]!==e.row){let c=oE(e.column,e.row);n=EC,s=`w-7 px-0 max-sm:w-14`,a=`flex justify-center`;let l;t[8]===e.column.pending?l=t[9]:(l=()=>(0,Q.jsx)(dx,{waiting:e.column.pending}),t[8]=e.column.pending,t[9]=l),o=lr(c,{onFalse:dE,onTrue:l}),r=`sr-only`,i=rn(pr({held:c,pending:e.column.pending}),Pr({held:!1},uE),Pr({pending:!0},lE),Or(cE)),t[0]=e.column,t[1]=e.row,t[2]=n,t[3]=r,t[4]=i,t[5]=a,t[6]=o,t[7]=s}else n=t[2],r=t[3],i=t[4],a=t[5],o=t[6],s=t[7];let c;t[10]!==r||t[11]!==i?(c=(0,Q.jsx)(`span`,{className:r,children:i}),t[10]=r,t[11]=i,t[12]=c):c=t[12];let l;t[13]!==a||t[14]!==o||t[15]!==c?(l=(0,Q.jsxs)(`span`,{className:a,children:[o,c]}),t[13]=a,t[14]=o,t[15]=c,t[16]=l):l=t[16];let u;return t[17]!==n||t[18]!==s||t[19]!==l?(u=(0,Q.jsx)(n,{className:s,children:l}),t[17]=n,t[18]=s,t[19]=l,t[20]=u):u=t[20],u}function cE(){return`signed in`}function lE(){return`asked for`}function uE(){return`not signed in`}function dE(){return(0,Q.jsx)(dx,{status:`off`})}function fE(e){let t=(0,$o.c)(60),[n,r]=Td(OT),[i,a]=(0,Z.useState)(),o,s,c,l,u,d,p,m,h,g;if(t[0]!==i||t[1]!==n||t[2]!==e.request||t[3]!==r){g=f(n);let _;if(t[14]!==e.request.clientName||t[15]!==e.request.device||t[16]!==e.request.kind){let n,r;t[18]!==e.request.clientName||t[19]!==e.request.device?(r=()=>`${wT(e.request.clientName,e.request.device)} asks for the apps its column marks`,n=()=>`Signs in ${wT(e.request.clientName,e.request.device)} as you to every mp281x.xyz app for 30 days, including approving sign-ins`,t[18]=e.request.clientName,t[19]=e.request.device,t[20]=n,t[21]=r):(n=t[20],r=t[21]),_=lr(e.request.kind===`Browser`,{onFalse:r,onTrue:n}),t[14]=e.request.clientName,t[15]=e.request.device,t[16]=e.request.kind,t[17]=_}else _=t[17];let v;t[22]===e.request.address?v=t[23]:(v=ge(pi(e.request.address),{onNone:vE,onSome:_E}),t[22]=e.request.address,t[23]=v),t[24]!==_||t[25]!==v?(m=(0,Q.jsxs)(_b,{children:[_,v,`. Approve only a code you started yourself.`]}),t[24]=_,t[25]=v,t[26]=m):m=t[26],t[27]===n?h=t[28]:(h=(0,Q.jsx)(cx,{result:n}),t[27]=n,t[28]=h),p=`grid grid-cols-2 gap-2`,o=Wi,s=`lg`;let y;t[29]!==e.request.clientName||t[30]!==e.request.device?(y=wT(e.request.clientName,e.request.device),t[29]=e.request.clientName,t[30]=e.request.device,t[31]=y):y=t[31],c=`Approve ${y}`,l=g,t[32]!==e.request||t[33]!==r?(u=()=>{a(!0),r({accept:!0,request:e.request})},t[32]=e.request,t[33]=r,t[34]=u):u=t[34],d=lr(g&&i===!0,{onFalse:gE,onTrue:hE}),t[0]=i,t[1]=n,t[2]=e.request,t[3]=r,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=p,t[11]=m,t[12]=h,t[13]=g}else o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],p=t[10],m=t[11],h=t[12],g=t[13];let _;t[35]!==o||t[36]!==s||t[37]!==c||t[38]!==l||t[39]!==u||t[40]!==d?(_=(0,Q.jsxs)(o,{size:s,"aria-label":c,disabled:l,onClick:u,children:[d,`Approve`]}),t[35]=o,t[36]=s,t[37]=c,t[38]=l,t[39]=u,t[40]=d,t[41]=_):_=t[41];let v;t[42]!==e.request||t[43]!==r?(v=()=>{a(!1),r({accept:!1,request:e.request})},t[42]=e.request,t[43]=r,t[44]=v):v=t[44];let y;t[45]!==i||t[46]!==g?(y=lr(g&&i===!1,{onFalse:mE,onTrue:pE}),t[45]=i,t[46]=g,t[47]=y):y=t[47];let b;t[48]!==y||t[49]!==v||t[50]!==g?(b=(0,Q.jsxs)(Wi,{size:`lg`,variant:`outline`,disabled:g,onClick:v,children:[y,`Deny`]}),t[48]=y,t[49]=v,t[50]=g,t[51]=b):b=t[51];let x;t[52]!==b||t[53]!==p||t[54]!==_?(x=(0,Q.jsxs)(`div`,{className:p,children:[_,b]}),t[52]=b,t[53]=p,t[54]=_,t[55]=x):x=t[55];let S;return t[56]!==x||t[57]!==m||t[58]!==h?(S=(0,Q.jsxs)(Q.Fragment,{children:[m,h,x]}),t[56]=x,t[57]=m,t[58]=h,t[59]=S):S=t[59],S}function pE(){return(0,Q.jsx)(xb,{})}function mE(){return null}function hE(){return(0,Q.jsx)(xb,{})}function gE(){return null}function _E(e){return` · from ${e}`}function vE(){return``}function yE(e,t,r){function i(e,t,n){return{app:I(mr(r,t=>n===`App`&&ln(t.name)===ln(e)),e=>e.origin),device:t,kind:n,name:e}}return[...ge(e,{onNone:()=>[],onSome:e=>[{address:pi(e.address),client:i(e.clientName,e.device,e.kind),families:[],key:`pending`,label:wT(e.clientName,e.device),lastActive:0,pending:!0,resources:[e.resources]}]}),...rn(Vt(t,e=>wT(e.client,e.device)),Rn,yn(Xt),Le(n(gn(Ke,TT))),v(e=>({address:rn(mr(e,t=>t.lastActive===TT(e)),Se(e=>pi(e.address))),client:i(e[0].client,e[0].device,e[0].kind),families:v(e,e=>e.family),key:wT(e[0].client,e[0].device),label:wT(e[0].client,e[0].device),lastActive:TT(e),pending:!1,resources:v(e,e=>e.resources)})))]}var bE=ci(e=>Ln({catalog:e(hT),now:e(vT),signIns:e(oT)}));function xE(e){let t=(0,$o.c)(17),n=kd(bE).value,r,i,a,o;if(t[0]!==n.catalog||t[1]!==n.now||t[2]!==n.signIns||t[3]!==e.pending){let s;t[8]===n.catalog?s=t[9]:(s=e=>e!==`browser`&&!C(n.catalog,t=>t.origin===e),t[8]=n.catalog,t[9]=s);let c=[...v(n.catalog,kE),...rn([...On(n.signIns,OE),...ge(e.pending,{onNone:DE,onSome:EE})],qn,yn(s),Le(Ye),v(TE))],l=yn(yE(e.pending,n.signIns,n.catalog),e=>C(c,t=>oE(e,t)));r=`flex flex-1 flex-col gap-3`,i=`Apps`,t[10]===e.pending?a=t[11]:(a=ge(e.pending,{onNone:wE,onSome:CE}),t[10]=e.pending,t[11]=a),o=$r(c,{onEmpty:SE,onNonEmpty:()=>(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,Q.jsxs)(xC,{"aria-label":`Apps and the clients signed in to them`,className:`w-auto border-b`,children:[(0,Q.jsx)(SC,{children:(0,Q.jsxs)(wC,{className:`max-sm:h-11`,children:[(0,Q.jsx)(TC,{className:`bg-background sticky left-0 z-10 w-40`,children:(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`App`})}),v(l,e=>(0,Q.jsx)(nE,{column:e,now:n.now},e.key))]})}),(0,Q.jsx)(CC,{children:v(c,e=>(0,Q.jsxs)(wC,{className:`max-sm:h-11`,children:[(0,Q.jsx)(TC,{scope:`row`,className:`bg-background sticky left-0 z-10 w-40`,children:ge(e.open,{onNone:()=>(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Q.jsx)(YT,{origin:e.origin}),e.name]}),onSome:t=>(0,Q.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`flex h-full w-full items-center gap-2 text-sm font-medium hover:underline`,children:[(0,Q.jsx)(YT,{origin:e.origin}),e.name]})})}),v(l,t=>(0,Q.jsx)(sE,{column:t,row:e},t.key))]},e.origin))})]})})}),t[0]=n.catalog,t[1]=n.now,t[2]=n.signIns,t[3]=e.pending,t[4]=r,t[5]=i,t[6]=a,t[7]=o}else r=t[4],i=t[5],a=t[6],o=t[7];let s;return t[12]!==r||t[13]!==i||t[14]!==a||t[15]!==o?(s=(0,Q.jsxs)(`section`,{className:r,"aria-label":i,children:[a,o]}),t[12]=r,t[13]=i,t[14]=a,t[15]=o,t[16]=s):s=t[16],s}function SE(){return(0,Q.jsx)(Vi,{children:(0,Q.jsx)(zi,{children:(0,Q.jsx)(vo,{children:`No apps yet`})})})}function CE(e){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(fE,{request:e}),(0,Q.jsxs)(`p`,{className:`text-muted-foreground font-mono text-xs`,children:[`open until `,_T(e.expiresAt)]})]})}function wE(){return null}function TE(e){return{name:p(Jr(Jn(new URL(e).hostname,`.`)),()=>e),open:yr(),origin:e,web:!1}}function EE(e){return gT(e.resources)}function DE(){return[]}function OE(e){return gT(e.resources)}function kE(e){return{name:e.name,open:Mt(e.open),origin:e.origin,web:Ur(`https://`)(e.open)}}export{Vx as $,gs as $t,wT as A,vl as At,_C as B,Vc as Bt,uT as C,yd as Ct,dT as D,nd as Dt,pT as E,ad as Et,pC as F,ll as Ft,JS as G,Hc as Gt,vC as H,Xc as Ht,mC as I,el as It,_S as J,Ic as Jt,MS as K,$c as Kt,gC as L,Bc as Lt,BT as M,fl as Mt,Yw as N,ul as Nt,yT as O,Il as Ot,dC as P,rl as Pt,Jx as Q,bs as Qt,hC as R,Uc as Rt,aT as S,kd as St,fT as T,od as Tt,fC as U,Zc as Ut,yC as V,Kc as Vt,nC as W,Qc as Wt,oS as X,Qs as Xt,lS as Y,Mc as Yt,Zx as Z,Ys as Zt,bT as _,cb as _t,FT as a,rs as an,Sx as at,MT as b,Cd as bt,lT as c,cx as ct,rT as d,_b as dt,fs as en,Dx as et,zT as f,vb as ft,ET as g,sb as gt,xT as h,db as ht,GT as i,ts as in,bx as it,UT as j,_l as jt,RT as k,bl as kt,mT as l,xb as lt,OT as m,fb as mt,YT as n,ds as nn,Tx as nt,tT as o,es as on,xx as ot,IT as p,gb as pt,kS as q,Yc as qt,xE as r,us as rn,Ex as rt,PT as s,ns as sn,dx as st,JT as t,ps as tn,Ox as tt,hT as u,hb as ut,iT as v,lb as vt,LT as w,ld as wt,NT as x,wd as xt,WT as y,Td as yt,bC as z,Jc as zt};
|