diff --git a/packages/engine/src/ui.html b/packages/engine/src/ui.html
index 53d6fe1..ea00c41 100644
--- a/packages/engine/src/ui.html
+++ b/packages/engine/src/ui.html
@@ -4,7 +4,7 @@
OGraph UI
-
+ */var op;function gy(){if(op)return Qa;op=1;var n=Mi();function l(h,v){return h===v&&(h!==0||1/h===1/v)||h!==h&&v!==v}var o=typeof Object.is=="function"?Object.is:l,s=n.useSyncExternalStore,a=n.useRef,c=n.useEffect,f=n.useMemo,p=n.useDebugValue;return Qa.useSyncExternalStoreWithSelector=function(h,v,x,E,w){var b=a(null);if(b.current===null){var S={hasValue:!1,value:null};b.current=S}else S=b.current;b=f(function(){function j(A){if(!I){if(I=!0,L=A,A=E(A),w!==void 0&&S.hasValue){var H=S.value;if(w(H,A))return P=H}return P=A}if(H=P,o(L,A))return H;var q=E(A);return w!==void 0&&w(H,q)?(L=A,H):(L=A,P=q)}var I=!1,L,P,M=x===void 0?null:x;return[function(){return j(v())},M===null?void 0:function(){return j(M())}]},[v,x,E,w]);var C=s(h,b[0],b[1]);return c(function(){S.hasValue=!0,S.value=C},[C]),p(C),C},Qa}var lp;function vy(){return lp||(lp=1,Ka.exports=gy()),Ka.exports}var yy=vy();function je(n,l,o=Sm){return yy.useSyncExternalStoreWithSelector(xe(s=>n.subscribe(xy,s)),xe(()=>n.state),xe(()=>n.state),xe(l),o)}function xy(n){return n}function km(n,l){let o=y.useId(),s=Zo.get(l),[a,c]=je(s,y.useCallback(f=>[s.selectors.isTop(f,o),s.selectors.inStack(f,o)],[s,o]));return Le(()=>{if(n)return s.actions.push(o),()=>s.actions.pop(o)},[s,n,o]),n?c?a:!0:!1}let du=new Map,Ho=new Map;function ip(n){var l;let o=(l=Ho.get(n))!=null?l:0;return Ho.set(n,o+1),o!==0?()=>sp(n):(du.set(n,{"aria-hidden":n.getAttribute("aria-hidden"),inert:n.inert}),n.setAttribute("aria-hidden","true"),n.inert=!0,()=>sp(n))}function sp(n){var l;let o=(l=Ho.get(n))!=null?l:1;if(o===1?Ho.delete(n):Ho.set(n,o-1),o!==1)return;let s=du.get(n);s&&(s["aria-hidden"]===null?n.removeAttribute("aria-hidden"):n.setAttribute("aria-hidden",s["aria-hidden"]),n.inert=s.inert,du.delete(n))}function Cm(n,{allowed:l,disallowed:o}={}){let s=km(n,"inert-others");Le(()=>{var a,c;if(!s)return;let f=gt();for(let h of(a=o?.())!=null?a:[])h&&f.add(ip(h));let p=(c=l?.())!=null?c:[];for(let h of p){if(!h)continue;let v=Go(h);if(!v)continue;let x=h.parentElement;for(;x&&x!==v.body;){for(let E of x.children)p.some(w=>E.contains(w))||f.add(ip(E));x=x.parentElement}}return f.dispose},[s,l,o])}function Nm(n,l,o){let s=Dn(a=>{let c=a.getBoundingClientRect();c.x===0&&c.y===0&&c.width===0&&c.height===0&&o()});y.useEffect(()=>{if(!n)return;let a=l===null?null:Gt(l)?l:l.current;if(!a)return;let c=gt();if(typeof ResizeObserver<"u"){let f=new ResizeObserver(()=>s.current(a));f.observe(a),c.add(()=>f.disconnect())}if(typeof IntersectionObserver<"u"){let f=new IntersectionObserver(()=>s.current(a));f.observe(a),c.add(()=>f.disconnect())}return()=>c.dispose()},[l,s,n])}let Oi=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","details>summary","textarea:not([disabled])"].map(n=>`${n}:not([tabindex='-1'])`).join(","),wy=["[data-autofocus]"].map(n=>`${n}:not([tabindex='-1'])`).join(",");var fu=(n=>(n[n.First=1]="First",n[n.Previous=2]="Previous",n[n.Next=4]="Next",n[n.Last=8]="Last",n[n.WrapAround=16]="WrapAround",n[n.NoScroll=32]="NoScroll",n[n.AutoFocus=64]="AutoFocus",n))(fu||{}),by=(n=>(n[n.Error=0]="Error",n[n.Overflow=1]="Overflow",n[n.Success=2]="Success",n[n.Underflow=3]="Underflow",n))(by||{}),Sy=(n=>(n[n.Previous=-1]="Previous",n[n.Next=1]="Next",n))(Sy||{});function jm(n=document.body){return n==null?[]:Array.from(n.querySelectorAll(Oi)).sort((l,o)=>Math.sign((l.tabIndex||Number.MAX_SAFE_INTEGER)-(o.tabIndex||Number.MAX_SAFE_INTEGER)))}function Ey(n=document.body){return n==null?[]:Array.from(n.querySelectorAll(wy)).sort((l,o)=>Math.sign((l.tabIndex||Number.MAX_SAFE_INTEGER)-(o.tabIndex||Number.MAX_SAFE_INTEGER)))}var Ou=(n=>(n[n.Strict=0]="Strict",n[n.Loose=1]="Loose",n))(Ou||{});function Om(n,l=0){var o;return n===((o=Go(n))==null?void 0:o.body)?!1:tt(l,{0(){return n.matches(Oi)},1(){let s=n;for(;s!==null;){if(s.matches(Oi))return!0;s=s.parentElement}return!1}})}var ky=(n=>(n[n.Keyboard=0]="Keyboard",n[n.Mouse=1]="Mouse",n))(ky||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",n=>{n.metaKey||n.altKey||n.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",n=>{n.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:n.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));let Cy=["textarea","input"].join(",");function Ny(n){var l,o;return(o=(l=n?.matches)==null?void 0:l.call(n,Cy))!=null?o:!1}function Pu(n,l=o=>o){return n.slice().sort((o,s)=>{let a=l(o),c=l(s);if(a===null||c===null)return 0;let f=a.compareDocumentPosition(c);return f&Node.DOCUMENT_POSITION_FOLLOWING?-1:f&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function jy(n,l,o=n===null?document.body:Ni(n)){return Oy(jm(o),l,{relativeTo:n})}function Oy(n,l,{sorted:o=!0,relativeTo:s=null,skipElements:a=[]}={}){let c=Array.isArray(n)?n.length>0?Ni(n[0]):document:Ni(n),f=Array.isArray(n)?o?Pu(n):n:l&64?Ey(n):jm(n);a.length>0&&f.length>1&&(f=f.filter(b=>!a.some(S=>S!=null&&"current"in S?S?.current===b:S===b))),s=s??c?.activeElement;let p=(()=>{if(l&5)return 1;if(l&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),h=(()=>{if(l&1)return 0;if(l&2)return Math.max(0,f.indexOf(s))-1;if(l&4)return Math.max(0,f.indexOf(s))+1;if(l&8)return f.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),v=l&32?{preventScroll:!0}:{},x=0,E=f.length,w;do{if(x>=E||x+E<=0)return 0;let b=h+x;if(l&16)b=(b+E)%E;else{if(b<0)return 3;if(b>=E)return 1}w=f[b],w?.focus(v),x+=p}while(w!==qp(w));return l&6&&Ny(w)&&w.select(),2}function Pm(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function Py(){return/Android/gi.test(window.navigator.userAgent)}function pu(){return Pm()||Py()}function Fr(n,l,o,s){let a=Dn(o);y.useEffect(()=>{if(!n)return;function c(f){a.current(f)}return document.addEventListener(l,c,s),()=>document.removeEventListener(l,c,s)},[n,l,s])}function Ty(n,l,o,s){let a=Dn(o);y.useEffect(()=>{if(!n)return;function c(f){a.current(f)}return window.addEventListener(l,c,s),()=>window.removeEventListener(l,c,s)},[n,l,s])}const ap=30;function Tm(n,l,o){let s=Dn(o),a=y.useCallback(function(p,h){if(p.defaultPrevented)return;let v=h(p);if(v===null||!v.getRootNode().contains(v)||!v.isConnected)return;let x=(function E(w){return typeof w=="function"?E(w()):Array.isArray(w)||w instanceof Set?w:[w]})(l);for(let E of x)if(E!==null&&(E.contains(v)||p.composed&&p.composedPath().includes(E)))return;return!Om(v,Ou.Loose)&&v.tabIndex!==-1&&p.preventDefault(),s.current(p,v)},[s,l]),c=y.useRef(null);Fr(n,"pointerdown",p=>{var h,v;pu()||(c.current=((v=(h=p.composedPath)==null?void 0:h.call(p))==null?void 0:v[0])||p.target)},!0),Fr(n,"pointerup",p=>{if(pu()||!c.current)return;let h=c.current;return c.current=null,a(p,()=>h)},!0);let f=y.useRef({x:0,y:0});Fr(n,"touchstart",p=>{f.current.x=p.touches[0].clientX,f.current.y=p.touches[0].clientY},!0),Fr(n,"touchend",p=>{let h={x:p.changedTouches[0].clientX,y:p.changedTouches[0].clientY};if(!(Math.abs(h.x-f.current.x)>=ap||Math.abs(h.y-f.current.y)>=ap))return a(p,()=>rr(p.target)?p.target:null)},!0),Ty(n,"blur",p=>a(p,()=>Av(window.document.activeElement)?window.document.activeElement:null),!0)}function Uo(...n){return y.useMemo(()=>Go(...n),[...n])}var Ry=(n=>(n[n.Ignore=0]="Ignore",n[n.Select=1]="Select",n[n.Close=2]="Close",n))(Ry||{});const sn={Ignore:{kind:0},Select:n=>({kind:1,target:n}),Close:{kind:2}},$y=200,up=5;function Rm(n,{trigger:l,action:o,close:s,select:a}){let c=y.useRef(null),f=y.useRef(null),p=y.useRef(null);Fr(n&&l!==null,"pointerdown",h=>{um(h?.target)&&l!=null&&l.contains(h.target)&&(f.current=h.x,p.current=h.y,c.current=h.timeStamp)}),Fr(n&&l!==null,"pointerup",h=>{var v,x;let E=c.current;if(E===null||(c.current=null,!rr(h.target))||Math.abs(h.x-((v=f.current)!=null?v:h.x))$y&&(a(w.target),s());break}case 2:{s();break}}},{capture:!0})}function My(n,l,o,s){let a=Dn(o);y.useEffect(()=>{n=n??window;function c(f){a.current(f)}return n.addEventListener(l,c,s),()=>n.removeEventListener(l,c,s)},[n,l,s])}function $m(n){let l=y.useRef({value:"",selectionStart:null,selectionEnd:null});return My(n,"blur",o=>{let s=o.target;ji(s)&&(l.current={value:s.value,selectionStart:s.selectionStart,selectionEnd:s.selectionEnd})}),xe(()=>{if(!bu(n)&&ji(n)&&n.isConnected){if(n.focus({preventScroll:!0}),n.value!==l.current.value)n.setSelectionRange(n.value.length,n.value.length);else{let{selectionStart:o,selectionEnd:s}=l.current;o!==null&&s!==null&&n.setSelectionRange(o,s)}l.current={value:"",selectionStart:null,selectionEnd:null}}})}function Mm(n,l){return y.useMemo(()=>{var o;if(n.type)return n.type;let s=(o=n.as)!=null?o:"button";if(typeof s=="string"&&s.toLowerCase()==="button"||l?.tagName==="BUTTON"&&!l.hasAttribute("type"))return"button"},[n.type,n.as,l])}function _y(n){return y.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot)}function Ly(n,l){let o=n(),s=new Set;return{getSnapshot(){return o},subscribe(a){return s.add(a),()=>s.delete(a)},dispatch(a,...c){let f=l[a].call(o,...c);f&&(o=f,s.forEach(p=>p()))}}}function Iy(){let n;return{before({doc:l}){var o;let s=l.documentElement,a=(o=l.defaultView)!=null?o:window;n=Math.max(0,a.innerWidth-s.clientWidth)},after({doc:l,d:o}){let s=l.documentElement,a=Math.max(0,s.clientWidth-s.offsetWidth),c=Math.max(0,n-a);o.style(s,"paddingRight",`${c}px`)}}}function Fy(){return Pm()?{before({doc:n,d:l,meta:o}){function s(a){for(let c of o().containers)for(let f of c())if(f.contains(a))return!0;return!1}l.microTask(()=>{var a;if(window.getComputedStyle(n.documentElement).scrollBehavior!=="auto"){let p=gt();p.style(n.documentElement,"scrollBehavior","auto"),l.add(()=>l.microTask(()=>p.dispose()))}let c=(a=window.scrollY)!=null?a:window.pageYOffset,f=null;l.addEventListener(n,"click",p=>{if(rr(p.target))try{let h=p.target.closest("a");if(!h)return;let{hash:v}=new URL(h.href),x=n.querySelector(v);rr(x)&&!s(x)&&(f=x)}catch{}},!0),l.group(p=>{l.addEventListener(n,"touchstart",h=>{if(p.dispose(),rr(h.target)&&Dv(h.target))if(s(h.target)){let v=h.target;for(;v.parentElement&&s(v.parentElement);)v=v.parentElement;p.style(v,"overscrollBehavior","contain")}else p.style(h.target,"touchAction","none")})}),l.addEventListener(n,"touchmove",p=>{if(rr(p.target)){if(ji(p.target))return;if(s(p.target)){let h=p.target;for(;h.parentElement&&h.dataset.headlessuiPortal!==""&&!(h.scrollHeight>h.clientHeight||h.scrollWidth>h.clientWidth);)h=h.parentElement;h.dataset.headlessuiPortal===""&&p.preventDefault()}else p.preventDefault()}},{passive:!1}),l.add(()=>{var p;let h=(p=window.scrollY)!=null?p:window.pageYOffset;c!==h&&window.scrollTo(0,c),f&&f.isConnected&&(f.scrollIntoView({block:"nearest"}),f=null)})})}}:{}}function Dy(){return{before({doc:n,d:l}){l.style(n.documentElement,"overflow","hidden")}}}function cp(n){let l={};for(let o of n)Object.assign(l,o(l));return l}let or=Ly(()=>new Map,{PUSH(n,l){var o;let s=(o=this.get(n))!=null?o:{doc:n,count:0,d:gt(),meta:new Set,computedMeta:{}};return s.count++,s.meta.add(l),s.computedMeta=cp(s.meta),this.set(n,s),this},POP(n,l){let o=this.get(n);return o&&(o.count--,o.meta.delete(l),o.computedMeta=cp(o.meta)),this},SCROLL_PREVENT(n){let l={doc:n.doc,d:n.d,meta(){return n.computedMeta}},o=[Fy(),Iy(),Dy()];o.forEach(({before:s})=>s?.(l)),o.forEach(({after:s})=>s?.(l))},SCROLL_ALLOW({d:n}){n.dispose()},TEARDOWN({doc:n}){this.delete(n)}});or.subscribe(()=>{let n=or.getSnapshot(),l=new Map;for(let[o]of n)l.set(o,o.documentElement.style.overflow);for(let o of n.values()){let s=l.get(o.doc)==="hidden",a=o.count!==0;(a&&!s||!a&&s)&&or.dispatch(o.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",o),o.count===0&&or.dispatch("TEARDOWN",o)}});function Ay(n,l,o=()=>({containers:[]})){let s=_y(or),a=l?s.get(l):void 0,c=a?a.count>0:!1;return Le(()=>{if(!(!l||!n))return or.dispatch("PUSH",l,o),()=>or.dispatch("POP",l,o)},[n,l]),c}function _m(n,l,o=()=>[document.body]){let s=km(n,"scroll-lock");Ay(s,l,a=>{var c;return{containers:[...(c=a.containers)!=null?c:[],o]}})}function dp(n){return[n.screenX,n.screenY]}function Lm(){let n=y.useRef([-1,-1]);return{wasMoved(l){let o=dp(l);return n.current[0]===o[0]&&n.current[1]===o[1]?!1:(n.current=o,!0)},update(l){n.current=dp(l)}}}function zy(n=0){let[l,o]=y.useState(n),s=y.useCallback(h=>o(h),[]),a=y.useCallback(h=>o(v=>v|h),[]),c=y.useCallback(h=>(l&h)===h,[l]),f=y.useCallback(h=>o(v=>v&~h),[]),p=y.useCallback(h=>o(v=>v^h),[]);return{flags:l,setFlag:s,addFlag:a,hasFlag:c,removeFlag:f,toggleFlag:p}}var Wy={},fp,pp;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((fp=process==null?void 0:Wy)==null?void 0:fp.NODE_ENV)==="test"&&typeof((pp=Element?.prototype)==null?void 0:pp.getAnimations)>"u"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
+`)),[]});var Hy=(n=>(n[n.None=0]="None",n[n.Closed=1]="Closed",n[n.Enter=2]="Enter",n[n.Leave=4]="Leave",n))(Hy||{});function Im(n){let l={};for(let o in n)n[o]===!0&&(l[`data-${o}`]="");return l}function Fm(n,l,o,s){let[a,c]=y.useState(o),{hasFlag:f,addFlag:p,removeFlag:h}=zy(n&&a?3:0),v=y.useRef(!1),x=y.useRef(!1),E=cr();return Le(()=>{var w;if(n){if(o&&c(!0),!l){o&&p(3);return}return(w=void 0)==null||w.call(s,o),Vy(l,{inFlight:v,prepare(){x.current?x.current=!1:x.current=v.current,v.current=!0,!x.current&&(o?(p(3),h(4)):(p(4),h(2)))},run(){x.current?o?(h(3),p(4)):(h(4),p(3)):o?h(1):p(1)},done(){var b;x.current&&Ky(l)||(v.current=!1,h(7),o||c(!1),(b=void 0)==null||b.call(s,o))}})}},[n,o,l,E]),n?[a,{closed:f(1),enter:f(2),leave:f(4),transition:f(2)||f(4)}]:[o,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function Vy(n,{prepare:l,run:o,done:s,inFlight:a}){let c=gt();return Uy(n,{prepare:l,inFlight:a}),c.nextFrame(()=>{o(),c.requestAnimationFrame(()=>{c.add(By(n,s))})}),c.dispose}function By(n,l){var o,s;let a=gt();if(!n)return a.dispose;let c=!1;a.add(()=>{c=!0});let f=(s=(o=n.getAnimations)==null?void 0:o.call(n).filter(p=>p instanceof CSSTransition))!=null?s:[];return f.length===0?(l(),a.dispose):(Promise.allSettled(f.map(p=>p.finished)).then(()=>{c||l()}),a.dispose)}function Uy(n,{inFlight:l,prepare:o}){if(l!=null&&l.current){o();return}let s=n.style.transition;n.style.transition="none",o(),n.offsetHeight,n.style.transition=s}function Ky(n){var l,o;return((o=(l=n.getAnimations)==null?void 0:l.call(n))!=null?o:[]).some(s=>s instanceof CSSTransition&&s.playState!=="finished")}function Qy(n,{container:l,accept:o,walk:s}){let a=y.useRef(o),c=y.useRef(s);y.useEffect(()=>{a.current=o,c.current=s},[o,s]),Le(()=>{if(!l||!n)return;let f=Go(l);if(!f)return;let p=a.current,h=c.current,v=Object.assign(E=>p(E),{acceptNode:p}),x=f.createTreeWalker(l,NodeFilter.SHOW_ELEMENT,v,!1);for(;x.nextNode();)h(x.currentNode)},[l,n,a,c])}function mp(n,l){let o=y.useRef([]),s=xe(n);y.useEffect(()=>{let a=[...o.current];for(let[c,f]of l.entries())if(o.current[c]!==f){let p=s(l,a);return o.current=l,p}},[s,...l])}function Di(){return typeof window<"u"}function Ur(n){return Dm(n)?(n.nodeName||"").toLowerCase():"#document"}function Et(n){var l;return(n==null||(l=n.ownerDocument)==null?void 0:l.defaultView)||window}function qt(n){var l;return(l=(Dm(n)?n.ownerDocument:n.document)||window.document)==null?void 0:l.documentElement}function Dm(n){return Di()?n instanceof Node||n instanceof Et(n).Node:!1}function ut(n){return Di()?n instanceof Element||n instanceof Et(n).Element:!1}function pn(n){return Di()?n instanceof HTMLElement||n instanceof Et(n).HTMLElement:!1}function hp(n){return!Di()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Et(n).ShadowRoot}function el(n){const{overflow:l,overflowX:o,overflowY:s,display:a}=zt(n);return/auto|scroll|overlay|hidden|clip/.test(l+s+o)&&a!=="inline"&&a!=="contents"}function Yy(n){return/^(table|td|th)$/.test(Ur(n))}function Ai(n){try{if(n.matches(":popover-open"))return!0}catch{}try{return n.matches(":modal")}catch{return!1}}const Xy=/transform|translate|scale|rotate|perspective|filter/,Gy=/paint|layout|strict|content/,Jn=n=>!!n&&n!=="none";let Ya;function Tu(n){const l=ut(n)?zt(n):n;return Jn(l.transform)||Jn(l.translate)||Jn(l.scale)||Jn(l.rotate)||Jn(l.perspective)||!Ru()&&(Jn(l.backdropFilter)||Jn(l.filter))||Xy.test(l.willChange||"")||Gy.test(l.contain||"")}function qy(n){let l=_n(n);for(;pn(l)&&!Hr(l);){if(Tu(l))return l;if(Ai(l))return null;l=_n(l)}return null}function Ru(){return Ya==null&&(Ya=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ya}function Hr(n){return/^(html|body|#document)$/.test(Ur(n))}function zt(n){return Et(n).getComputedStyle(n)}function zi(n){return ut(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function _n(n){if(Ur(n)==="html")return n;const l=n.assignedSlot||n.parentNode||hp(n)&&n.host||qt(n);return hp(l)?l.host:l}function Am(n){const l=_n(n);return Hr(l)?n.ownerDocument?n.ownerDocument.body:n.body:pn(l)&&el(l)?l:Am(l)}function Ko(n,l,o){var s;l===void 0&&(l=[]),o===void 0&&(o=!0);const a=Am(n),c=a===((s=n.ownerDocument)==null?void 0:s.body),f=Et(a);if(c){const p=mu(f);return l.concat(f,f.visualViewport||[],el(a)?a:[],p&&o?Ko(p):[])}else return l.concat(a,Ko(a,[],o))}function mu(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function Jy(){const n=navigator.userAgentData;return n&&Array.isArray(n.brands)?n.brands.map(l=>{let{brand:o,version:s}=l;return o+"/"+s}).join(" "):navigator.userAgent}const sr=Math.min,Ze=Math.max,Qo=Math.round,vi=Math.floor,Yt=n=>({x:n,y:n}),Zy={left:"right",right:"left",bottom:"top",top:"bottom"};function gp(n,l,o){return Ze(n,sr(l,o))}function Kr(n,l){return typeof n=="function"?n(l):n}function Ln(n){return n.split("-")[0]}function tl(n){return n.split("-")[1]}function zm(n){return n==="x"?"y":"x"}function Wm(n){return n==="y"?"height":"width"}function un(n){const l=n[0];return l==="t"||l==="b"?"y":"x"}function Hm(n){return zm(un(n))}function ex(n,l,o){o===void 0&&(o=!1);const s=tl(n),a=Hm(n),c=Wm(a);let f=a==="x"?s===(o?"end":"start")?"right":"left":s==="start"?"bottom":"top";return l.reference[c]>l.floating[c]&&(f=Pi(f)),[f,Pi(f)]}function tx(n){const l=Pi(n);return[hu(n),l,hu(l)]}function hu(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}const vp=["left","right"],yp=["right","left"],nx=["top","bottom"],rx=["bottom","top"];function ox(n,l,o){switch(n){case"top":case"bottom":return o?l?yp:vp:l?vp:yp;case"left":case"right":return l?nx:rx;default:return[]}}function lx(n,l,o,s){const a=tl(n);let c=ox(Ln(n),o==="start",s);return a&&(c=c.map(f=>f+"-"+a),l&&(c=c.concat(c.map(hu)))),c}function Pi(n){const l=Ln(n);return Zy[l]+n.slice(l.length)}function ix(n){return{top:0,right:0,bottom:0,left:0,...n}}function sx(n){return typeof n!="number"?ix(n):{top:n,right:n,bottom:n,left:n}}function Ti(n){const{x:l,y:o,width:s,height:a}=n;return{width:s,height:a,top:o,left:l,right:l+s,bottom:o+a,x:l,y:o}}function xp(n,l,o){let{reference:s,floating:a}=n;const c=un(l),f=Hm(l),p=Wm(f),h=Ln(l),v=c==="y",x=s.x+s.width/2-a.width/2,E=s.y+s.height/2-a.height/2,w=s[p]/2-a[p]/2;let b;switch(h){case"top":b={x,y:s.y-a.height};break;case"bottom":b={x,y:s.y+s.height};break;case"right":b={x:s.x+s.width,y:E};break;case"left":b={x:s.x-a.width,y:E};break;default:b={x:s.x,y:s.y}}switch(tl(l)){case"start":b[f]-=w*(o&&v?-1:1);break;case"end":b[f]+=w*(o&&v?-1:1);break}return b}async function Vm(n,l){var o;l===void 0&&(l={});const{x:s,y:a,platform:c,rects:f,elements:p,strategy:h}=n,{boundary:v="clippingAncestors",rootBoundary:x="viewport",elementContext:E="floating",altBoundary:w=!1,padding:b=0}=Kr(l,n),S=sx(b),j=p[w?E==="floating"?"reference":"floating":E],I=Ti(await c.getClippingRect({element:(o=await(c.isElement==null?void 0:c.isElement(j)))==null||o?j:j.contextElement||await(c.getDocumentElement==null?void 0:c.getDocumentElement(p.floating)),boundary:v,rootBoundary:x,strategy:h})),L=E==="floating"?{x:s,y:a,width:f.floating.width,height:f.floating.height}:f.reference,P=await(c.getOffsetParent==null?void 0:c.getOffsetParent(p.floating)),M=await(c.isElement==null?void 0:c.isElement(P))?await(c.getScale==null?void 0:c.getScale(P))||{x:1,y:1}:{x:1,y:1},A=Ti(c.convertOffsetParentRelativeRectToViewportRelativeRect?await c.convertOffsetParentRelativeRectToViewportRelativeRect({elements:p,rect:L,offsetParent:P,strategy:h}):L);return{top:(I.top-A.top+S.top)/M.y,bottom:(A.bottom-I.bottom+S.bottom)/M.y,left:(I.left-A.left+S.left)/M.x,right:(A.right-I.right+S.right)/M.x}}const ax=50,ux=async(n,l,o)=>{const{placement:s="bottom",strategy:a="absolute",middleware:c=[],platform:f}=o,p=f.detectOverflow?f:{...f,detectOverflow:Vm},h=await(f.isRTL==null?void 0:f.isRTL(l));let v=await f.getElementRects({reference:n,floating:l,strategy:a}),{x,y:E}=xp(v,s,h),w=s,b=0;const S={};for(let C=0;Cue<=0)){var Q,z;const ue=(((Q=c.flip)==null?void 0:Q.index)||0)+1,G=q[ue];if(G&&(!(E==="alignment"?L!==un(G):!1)||J.every(D=>un(D.placement)===L?D.overflows[0]>0:!0)))return{data:{index:ue,overflows:J},reset:{placement:G}};let ce=(z=J.filter(ve=>ve.overflows[0]<=0).sort((ve,D)=>ve.overflows[1]-D.overflows[1])[0])==null?void 0:z.placement;if(!ce)switch(b){case"bestFit":{var ae;const ve=(ae=J.filter(D=>{if(H){const X=un(D.placement);return X===L||X==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(X=>X>0).reduce((X,K)=>X+K,0)]).sort((D,X)=>D[1]-X[1])[0])==null?void 0:ae[0];ve&&(ce=ve);break}case"initialPlacement":ce=p;break}if(a!==ce)return{reset:{placement:ce}}}return{}}}},dx=new Set(["left","top"]);async function fx(n,l){const{placement:o,platform:s,elements:a}=n,c=await(s.isRTL==null?void 0:s.isRTL(a.floating)),f=Ln(o),p=tl(o),h=un(o)==="y",v=dx.has(f)?-1:1,x=c&&h?-1:1,E=Kr(l,n);let{mainAxis:w,crossAxis:b,alignmentAxis:S}=typeof E=="number"?{mainAxis:E,crossAxis:0,alignmentAxis:null}:{mainAxis:E.mainAxis||0,crossAxis:E.crossAxis||0,alignmentAxis:E.alignmentAxis};return p&&typeof S=="number"&&(b=p==="end"?S*-1:S),h?{x:b*x,y:w*v}:{x:w*v,y:b*x}}const px=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(l){var o,s;const{x:a,y:c,placement:f,middlewareData:p}=l,h=await fx(l,n);return f===((o=p.offset)==null?void 0:o.placement)&&(s=p.arrow)!=null&&s.alignmentOffset?{}:{x:a+h.x,y:c+h.y,data:{...h,placement:f}}}}},mx=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(l){const{x:o,y:s,placement:a,platform:c}=l,{mainAxis:f=!0,crossAxis:p=!1,limiter:h={fn:I=>{let{x:L,y:P}=I;return{x:L,y:P}}},...v}=Kr(n,l),x={x:o,y:s},E=await c.detectOverflow(l,v),w=un(Ln(a)),b=zm(w);let S=x[b],C=x[w];if(f){const I=b==="y"?"top":"left",L=b==="y"?"bottom":"right",P=S+E[I],M=S-E[L];S=gp(P,S,M)}if(p){const I=w==="y"?"top":"left",L=w==="y"?"bottom":"right",P=C+E[I],M=C-E[L];C=gp(P,C,M)}const j=h.fn({...l,[b]:S,[w]:C});return{...j,data:{x:j.x-o,y:j.y-s,enabled:{[b]:f,[w]:p}}}}}},hx=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(l){var o,s;const{placement:a,rects:c,platform:f,elements:p}=l,{apply:h=()=>{},...v}=Kr(n,l),x=await f.detectOverflow(l,v),E=Ln(a),w=tl(a),b=un(a)==="y",{width:S,height:C}=c.floating;let j,I;E==="top"||E==="bottom"?(j=E,I=w===(await(f.isRTL==null?void 0:f.isRTL(p.floating))?"start":"end")?"left":"right"):(I=E,j=w==="end"?"top":"bottom");const L=C-x.top-x.bottom,P=S-x.left-x.right,M=sr(C-x[j],L),A=sr(S-x[I],P),H=!l.middlewareData.shift;let q=M,ee=A;if((o=l.middlewareData.shift)!=null&&o.enabled.x&&(ee=P),(s=l.middlewareData.shift)!=null&&s.enabled.y&&(q=L),H&&!w){const J=Ze(x.left,0),Q=Ze(x.right,0),z=Ze(x.top,0),ae=Ze(x.bottom,0);b?ee=S-2*(J!==0||Q!==0?J+Q:Ze(x.left,x.right)):q=C-2*(z!==0||ae!==0?z+ae:Ze(x.top,x.bottom))}await h({...l,availableWidth:ee,availableHeight:q});const he=await f.getDimensions(p.floating);return S!==he.width||C!==he.height?{reset:{rects:!0}}:{}}}};function Bm(n){const l=zt(n);let o=parseFloat(l.width)||0,s=parseFloat(l.height)||0;const a=pn(n),c=a?n.offsetWidth:o,f=a?n.offsetHeight:s,p=Qo(o)!==c||Qo(s)!==f;return p&&(o=c,s=f),{width:o,height:s,$:p}}function $u(n){return ut(n)?n:n.contextElement}function zr(n){const l=$u(n);if(!pn(l))return Yt(1);const o=l.getBoundingClientRect(),{width:s,height:a,$:c}=Bm(l);let f=(c?Qo(o.width):o.width)/s,p=(c?Qo(o.height):o.height)/a;return(!f||!Number.isFinite(f))&&(f=1),(!p||!Number.isFinite(p))&&(p=1),{x:f,y:p}}const gx=Yt(0);function Um(n){const l=Et(n);return!Ru()||!l.visualViewport?gx:{x:l.visualViewport.offsetLeft,y:l.visualViewport.offsetTop}}function vx(n,l,o){return l===void 0&&(l=!1),!o||l&&o!==Et(n)?!1:l}function ar(n,l,o,s){l===void 0&&(l=!1),o===void 0&&(o=!1);const a=n.getBoundingClientRect(),c=$u(n);let f=Yt(1);l&&(s?ut(s)&&(f=zr(s)):f=zr(n));const p=vx(c,o,s)?Um(c):Yt(0);let h=(a.left+p.x)/f.x,v=(a.top+p.y)/f.y,x=a.width/f.x,E=a.height/f.y;if(c){const w=Et(c),b=s&&ut(s)?Et(s):s;let S=w,C=mu(S);for(;C&&s&&b!==S;){const j=zr(C),I=C.getBoundingClientRect(),L=zt(C),P=I.left+(C.clientLeft+parseFloat(L.paddingLeft))*j.x,M=I.top+(C.clientTop+parseFloat(L.paddingTop))*j.y;h*=j.x,v*=j.y,x*=j.x,E*=j.y,h+=P,v+=M,S=Et(C),C=mu(S)}}return Ti({width:x,height:E,x:h,y:v})}function Wi(n,l){const o=zi(n).scrollLeft;return l?l.left+o:ar(qt(n)).left+o}function Km(n,l){const o=n.getBoundingClientRect(),s=o.left+l.scrollLeft-Wi(n,o),a=o.top+l.scrollTop;return{x:s,y:a}}function yx(n){let{elements:l,rect:o,offsetParent:s,strategy:a}=n;const c=a==="fixed",f=qt(s),p=l?Ai(l.floating):!1;if(s===f||p&&c)return o;let h={scrollLeft:0,scrollTop:0},v=Yt(1);const x=Yt(0),E=pn(s);if((E||!E&&!c)&&((Ur(s)!=="body"||el(f))&&(h=zi(s)),E)){const b=ar(s);v=zr(s),x.x=b.x+s.clientLeft,x.y=b.y+s.clientTop}const w=f&&!E&&!c?Km(f,h):Yt(0);return{width:o.width*v.x,height:o.height*v.y,x:o.x*v.x-h.scrollLeft*v.x+x.x+w.x,y:o.y*v.y-h.scrollTop*v.y+x.y+w.y}}function xx(n){return Array.from(n.getClientRects())}function wx(n){const l=qt(n),o=zi(n),s=n.ownerDocument.body,a=Ze(l.scrollWidth,l.clientWidth,s.scrollWidth,s.clientWidth),c=Ze(l.scrollHeight,l.clientHeight,s.scrollHeight,s.clientHeight);let f=-o.scrollLeft+Wi(n);const p=-o.scrollTop;return zt(s).direction==="rtl"&&(f+=Ze(l.clientWidth,s.clientWidth)-a),{width:a,height:c,x:f,y:p}}const wp=25;function bx(n,l){const o=Et(n),s=qt(n),a=o.visualViewport;let c=s.clientWidth,f=s.clientHeight,p=0,h=0;if(a){c=a.width,f=a.height;const x=Ru();(!x||x&&l==="fixed")&&(p=a.offsetLeft,h=a.offsetTop)}const v=Wi(s);if(v<=0){const x=s.ownerDocument,E=x.body,w=getComputedStyle(E),b=x.compatMode==="CSS1Compat"&&parseFloat(w.marginLeft)+parseFloat(w.marginRight)||0,S=Math.abs(s.clientWidth-E.clientWidth-b);S<=wp&&(c-=S)}else v<=wp&&(c+=v);return{width:c,height:f,x:p,y:h}}function Sx(n,l){const o=ar(n,!0,l==="fixed"),s=o.top+n.clientTop,a=o.left+n.clientLeft,c=pn(n)?zr(n):Yt(1),f=n.clientWidth*c.x,p=n.clientHeight*c.y,h=a*c.x,v=s*c.y;return{width:f,height:p,x:h,y:v}}function bp(n,l,o){let s;if(l==="viewport")s=bx(n,o);else if(l==="document")s=wx(qt(n));else if(ut(l))s=Sx(l,o);else{const a=Um(n);s={x:l.x-a.x,y:l.y-a.y,width:l.width,height:l.height}}return Ti(s)}function Qm(n,l){const o=_n(n);return o===l||!ut(o)||Hr(o)?!1:zt(o).position==="fixed"||Qm(o,l)}function Ex(n,l){const o=l.get(n);if(o)return o;let s=Ko(n,[],!1).filter(p=>ut(p)&&Ur(p)!=="body"),a=null;const c=zt(n).position==="fixed";let f=c?_n(n):n;for(;ut(f)&&!Hr(f);){const p=zt(f),h=Tu(f);!h&&p.position==="fixed"&&(a=null),(c?!h&&!a:!h&&p.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||el(f)&&!h&&Qm(n,f))?s=s.filter(x=>x!==f):a=p,f=_n(f)}return l.set(n,s),s}function kx(n){let{element:l,boundary:o,rootBoundary:s,strategy:a}=n;const f=[...o==="clippingAncestors"?Ai(l)?[]:Ex(l,this._c):[].concat(o),s],p=bp(l,f[0],a);let h=p.top,v=p.right,x=p.bottom,E=p.left;for(let w=1;w{f(!1,1e-7)},1e3)}q===1&&!Xm(v,n.getBoundingClientRect())&&f(),M=!1}try{o=new IntersectionObserver(A,{...P,root:a.ownerDocument})}catch{o=new IntersectionObserver(A,P)}o.observe(n)}return f(!0),c}function Rx(n,l,o,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:c=!0,elementResize:f=typeof ResizeObserver=="function",layoutShift:p=typeof IntersectionObserver=="function",animationFrame:h=!1}=s,v=$u(n),x=a||c?[...v?Ko(v):[],...l?Ko(l):[]]:[];x.forEach(I=>{a&&I.addEventListener("scroll",o,{passive:!0}),c&&I.addEventListener("resize",o)});const E=v&&p?Tx(v,o):null;let w=-1,b=null;f&&(b=new ResizeObserver(I=>{let[L]=I;L&&L.target===v&&b&&l&&(b.unobserve(l),cancelAnimationFrame(w),w=requestAnimationFrame(()=>{var P;(P=b)==null||P.observe(l)})),o()}),v&&!h&&b.observe(v),l&&b.observe(l));let S,C=h?ar(n):null;h&&j();function j(){const I=ar(n);C&&!Xm(C,I)&&o(),C=I,S=requestAnimationFrame(j)}return o(),()=>{var I;x.forEach(L=>{a&&L.removeEventListener("scroll",o),c&&L.removeEventListener("resize",o)}),E?.(),(I=b)==null||I.disconnect(),b=null,h&&cancelAnimationFrame(S)}}const Ga=Vm,$x=px,Mx=mx,_x=cx,Lx=hx,Ix=(n,l,o)=>{const s=new Map,a={platform:Px,...o},c={...a.platform,_c:s};return ux(n,l,{...a,platform:c})};var Fx=typeof document<"u",Dx=function(){},wi=Fx?y.useLayoutEffect:Dx;function Ri(n,l){if(n===l)return!0;if(typeof n!=typeof l)return!1;if(typeof n=="function"&&n.toString()===l.toString())return!0;let o,s,a;if(n&&l&&typeof n=="object"){if(Array.isArray(n)){if(o=n.length,o!==l.length)return!1;for(s=o;s--!==0;)if(!Ri(n[s],l[s]))return!1;return!0}if(a=Object.keys(n),o=a.length,o!==Object.keys(l).length)return!1;for(s=o;s--!==0;)if(!{}.hasOwnProperty.call(l,a[s]))return!1;for(s=o;s--!==0;){const c=a[s];if(!(c==="_owner"&&n.$$typeof)&&!Ri(n[c],l[c]))return!1}return!0}return n!==n&&l!==l}function Gm(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function Ep(n,l){const o=Gm(n);return Math.round(l*o)/o}function qa(n){const l=y.useRef(n);return wi(()=>{l.current=n}),l}function Ax(n){n===void 0&&(n={});const{placement:l="bottom",strategy:o="absolute",middleware:s=[],platform:a,elements:{reference:c,floating:f}={},transform:p=!0,whileElementsMounted:h,open:v}=n,[x,E]=y.useState({x:0,y:0,strategy:o,placement:l,middlewareData:{},isPositioned:!1}),[w,b]=y.useState(s);Ri(w,s)||b(s);const[S,C]=y.useState(null),[j,I]=y.useState(null),L=y.useCallback(D=>{D!==H.current&&(H.current=D,C(D))},[]),P=y.useCallback(D=>{D!==q.current&&(q.current=D,I(D))},[]),M=c||S,A=f||j,H=y.useRef(null),q=y.useRef(null),ee=y.useRef(x),he=h!=null,J=qa(h),Q=qa(a),z=qa(v),ae=y.useCallback(()=>{if(!H.current||!q.current)return;const D={placement:l,strategy:o,middleware:w};Q.current&&(D.platform=Q.current),Ix(H.current,q.current,D).then(X=>{const K={...X,isPositioned:z.current!==!1};ue.current&&!Ri(ee.current,K)&&(ee.current=K,Ye.flushSync(()=>{E(K)}))})},[w,l,o,Q,z]);wi(()=>{v===!1&&ee.current.isPositioned&&(ee.current.isPositioned=!1,E(D=>({...D,isPositioned:!1})))},[v]);const ue=y.useRef(!1);wi(()=>(ue.current=!0,()=>{ue.current=!1}),[]),wi(()=>{if(M&&(H.current=M),A&&(q.current=A),M&&A){if(J.current)return J.current(M,A,ae);ae()}},[M,A,ae,J,he]);const G=y.useMemo(()=>({reference:H,floating:q,setReference:L,setFloating:P}),[L,P]),ce=y.useMemo(()=>({reference:M,floating:A}),[M,A]),ve=y.useMemo(()=>{const D={position:o,left:0,top:0};if(!ce.floating)return D;const X=Ep(ce.floating,x.x),K=Ep(ce.floating,x.y);return p?{...D,transform:"translate("+X+"px, "+K+"px)",...Gm(ce.floating)>=1.5&&{willChange:"transform"}}:{position:o,left:X,top:K}},[o,p,ce.floating,x.x,x.y]);return y.useMemo(()=>({...x,update:ae,refs:G,elements:ce,floatingStyles:ve}),[x,ae,G,ce,ve])}const qm=(n,l)=>{const o=$x(n);return{name:o.name,fn:o.fn,options:[n,l]}},zx=(n,l)=>{const o=Mx(n);return{name:o.name,fn:o.fn,options:[n,l]}},Wx=(n,l)=>{const o=_x(n);return{name:o.name,fn:o.fn,options:[n,l]}},Hx=(n,l)=>{const o=Lx(n);return{name:o.name,fn:o.fn,options:[n,l]}},Jm={...ru},Vx=Jm.useInsertionEffect,Bx=Vx||(n=>n());function Zm(n){const l=y.useRef(()=>{});return Bx(()=>{l.current=n}),y.useCallback(function(){for(var o=arguments.length,s=new Array(o),a=0;a"floating-ui-"+Math.random().toString(36).slice(2,6)+Ux++;function Kx(){const[n,l]=y.useState(()=>kp?Cp():void 0);return gu(()=>{n==null&&l(Cp())},[]),y.useEffect(()=>{kp=!0},[]),n}const Qx=Jm.useId,Yx=Qx||Kx;function Xx(){const n=new Map;return{emit(l,o){var s;(s=n.get(l))==null||s.forEach(a=>a(o))},on(l,o){n.set(l,[...n.get(l)||[],o])},off(l,o){var s;n.set(l,((s=n.get(l))==null?void 0:s.filter(a=>a!==o))||[])}}}const Gx=y.createContext(null),qx=y.createContext(null),Jx=()=>{var n;return((n=y.useContext(Gx))==null?void 0:n.id)||null},Zx=()=>y.useContext(qx),e1="data-floating-ui-focusable";function t1(n){const{open:l=!1,onOpenChange:o,elements:s}=n,a=Yx(),c=y.useRef({}),[f]=y.useState(()=>Xx()),p=Jx()!=null,[h,v]=y.useState(s.reference),x=Zm((b,S,C)=>{c.current.openEvent=b?S:void 0,f.emit("openchange",{open:b,event:S,reason:C,nested:p}),o?.(b,S,C)}),E=y.useMemo(()=>({setPositionReference:v}),[]),w=y.useMemo(()=>({reference:h||s.reference||null,floating:s.floating||null,domReference:s.reference}),[h,s.reference,s.floating]);return y.useMemo(()=>({dataRef:c,open:l,onOpenChange:x,elements:w,events:f,floatingId:a,refs:E}),[l,x,w,f,a,E])}function n1(n){n===void 0&&(n={});const{nodeId:l}=n,o=t1({...n,elements:{reference:null,floating:null,...n.elements}}),s=n.rootContext||o,a=s.elements,[c,f]=y.useState(null),[p,h]=y.useState(null),x=a?.domReference||c,E=y.useRef(null),w=Zx();gu(()=>{x&&(E.current=x)},[x]);const b=Ax({...n,elements:{...a,...p&&{reference:p}}}),S=y.useCallback(P=>{const M=ut(P)?{getBoundingClientRect:()=>P.getBoundingClientRect(),contextElement:P}:P;h(M),b.refs.setReference(M)},[b.refs]),C=y.useCallback(P=>{(ut(P)||P===null)&&(E.current=P,f(P)),(ut(b.refs.reference.current)||b.refs.reference.current===null||P!==null&&!ut(P))&&b.refs.setReference(P)},[b.refs]),j=y.useMemo(()=>({...b.refs,setReference:C,setPositionReference:S,domReference:E}),[b.refs,C,S]),I=y.useMemo(()=>({...b.elements,domReference:x}),[b.elements,x]),L=y.useMemo(()=>({...b,...s,refs:j,elements:I,nodeId:l}),[b,j,I,l,s]);return gu(()=>{s.dataRef.current.floatingContext=L;const P=w?.nodesRef.current.find(M=>M.id===l);P&&(P.context=L)}),y.useMemo(()=>({...b,context:L,refs:j,elements:I}),[b,j,I,L])}const Np="active",jp="selected";function Ja(n,l,o){const s=new Map,a=o==="item";let c=n;if(a&&n){const{[Np]:f,[jp]:p,...h}=n;c=h}return{...o==="floating"&&{tabIndex:-1,[e1]:""},...c,...l.map(f=>{const p=f?f[o]:null;return typeof p=="function"?n?p(n):null:p}).concat(n).reduce((f,p)=>(p&&Object.entries(p).forEach(h=>{let[v,x]=h;if(!(a&&[Np,jp].includes(v)))if(v.indexOf("on")===0){if(s.has(v)||s.set(v,[]),typeof x=="function"){var E;(E=s.get(v))==null||E.push(x),f[v]=function(){for(var w,b=arguments.length,S=new Array(b),C=0;Cj(...S)).find(j=>j!==void 0)}}}else f[v]=x}),f),{})}}function r1(n){n===void 0&&(n=[]);const l=n.map(p=>p?.reference),o=n.map(p=>p?.floating),s=n.map(p=>p?.item),a=y.useCallback(p=>Ja(p,n,"reference"),l),c=y.useCallback(p=>Ja(p,n,"floating"),o),f=y.useCallback(p=>Ja(p,n,"item"),s);return y.useMemo(()=>({getReferenceProps:a,getFloatingProps:c,getItemProps:f}),[a,c,f])}function Op(n,l){return{...n,rects:{...n.rects,floating:{...n.rects.floating,height:l}}}}const o1=n=>({name:"inner",options:n,async fn(l){const{listRef:o,overflowRef:s,onFallbackChange:a,offset:c=0,index:f=0,minItemsVisible:p=4,referenceOverflowThreshold:h=0,scrollRef:v,...x}=Kr(n,l),{rects:E,elements:{floating:w}}=l,b=o.current[f],S=v?.current||w,C=w.clientTop||S.clientTop,j=w.clientTop!==0,I=S.clientTop!==0,L=w===S;if(!b)return{};const P={...l,...await qm(-b.offsetTop-w.clientTop-E.reference.height/2-b.offsetHeight/2-c).fn(l)},M=await Ga(Op(P,S.scrollHeight+C+w.clientTop),x),A=await Ga(P,{...x,elementContext:"reference"}),H=Ze(0,M.top),q=P.y+H,J=(S.scrollHeight>S.clientHeight?Q=>Q:Qo)(Ze(0,S.scrollHeight+(j&&L||I?C*2:0)-H-Ze(0,M.bottom)));if(S.style.maxHeight=J+"px",S.scrollTop=H,a){const Q=S.offsetHeight=-h||A.bottom>=-h;Ye.flushSync(()=>a(Q))}return s&&(s.current=await Ga(Op({...P,y:q},S.offsetHeight+C+w.clientTop),x)),{y:q}}});function l1(n,l){const{open:o,elements:s}=n,{enabled:a=!0,overflowRef:c,scrollRef:f,onChange:p}=l,h=Zm(p),v=y.useRef(!1),x=y.useRef(null),E=y.useRef(null);y.useEffect(()=>{if(!a)return;function b(C){if(C.ctrlKey||!S||c.current==null)return;const j=C.deltaY,I=c.current.top>=-.5,L=c.current.bottom>=-.5,P=S.scrollHeight-S.clientHeight,M=j<0?-1:1,A=j<0?"max":"min";S.scrollHeight<=S.clientHeight||(!I&&j>0||!L&&j<0?(C.preventDefault(),Ye.flushSync(()=>{h(H=>H+Math[A](j,P*M))})):/firefox/i.test(Jy())&&(S.scrollTop+=j))}const S=f?.current||s.floating;if(o&&S)return S.addEventListener("wheel",b),requestAnimationFrame(()=>{x.current=S.scrollTop,c.current!=null&&(E.current={...c.current})}),()=>{x.current=null,E.current=null,S.removeEventListener("wheel",b)}},[a,o,s.floating,c,f,h]);const w=y.useMemo(()=>({onKeyDown(){v.current=!0},onWheel(){v.current=!1},onPointerMove(){v.current=!1},onScroll(){const b=f?.current||s.floating;if(!(!c.current||!b||!v.current)){if(x.current!==null){const S=b.scrollTop-x.current;(c.current.bottom<-.5&&S<-1||c.current.top<-.5&&S>1)&&Ye.flushSync(()=>h(C=>C+S))}requestAnimationFrame(()=>{x.current=b.scrollTop})}}}),[s.floating,h,c,f]);return y.useMemo(()=>a?{floating:w}:{},[a,w])}let Qr=y.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});Qr.displayName="FloatingContext";let Mu=y.createContext(null);Mu.displayName="PlacementContext";function eh(n){return y.useMemo(()=>n?typeof n=="string"?{to:n}:n:null,[n])}function th(){return y.useContext(Qr).setReference}function i1(){return y.useContext(Qr).getReferenceProps}function nh(){let{getFloatingProps:n,slot:l}=y.useContext(Qr);return y.useCallback((...o)=>Object.assign({},n(...o),{"data-anchor":l.anchor}),[n,l])}function rh(n=null){n===!1&&(n=null),typeof n=="string"&&(n={to:n});let l=y.useContext(Mu),o=y.useMemo(()=>n,[JSON.stringify(n,(a,c)=>{var f;return(f=c?.outerHTML)!=null?f:c})]);Le(()=>{l?.(o??null)},[l,o]);let s=y.useContext(Qr);return y.useMemo(()=>[s.setFloating,n?s.styles:{}],[s.setFloating,n,s.styles])}let Pp=4;function oh({children:n,enabled:l=!0}){let[o,s]=y.useState(null),[a,c]=y.useState(0),f=y.useRef(null),[p,h]=y.useState(null);s1(p);let v=l&&o!==null&&p!==null,{to:x="bottom",gap:E=0,offset:w=0,padding:b=0,inner:S}=a1(o,p),[C,j="center"]=x.split(" ");Le(()=>{v&&c(0)},[v]);let{refs:I,floatingStyles:L,context:P}=n1({open:v,placement:C==="selection"?j==="center"?"bottom":`bottom-${j}`:j==="center"?`${C}`:`${C}-${j}`,strategy:"absolute",transform:!1,middleware:[qm({mainAxis:C==="selection"?0:E,crossAxis:w}),zx({padding:b}),C!=="selection"&&Wx({padding:b}),C==="selection"&&S?o1({...S,padding:b,overflowRef:f,offset:a,minItemsVisible:Pp,referenceOverflowThreshold:b,onFallbackChange(Q){var z,ae;if(!Q)return;let ue=P.elements.floating;if(!ue)return;let G=parseFloat(getComputedStyle(ue).scrollPaddingBottom)||0,ce=Math.min(Pp,ue.childElementCount),ve=0,D=0;for(let X of(ae=(z=P.elements.floating)==null?void 0:z.childNodes)!=null?ae:[])if(Gt(X)){let K=X.offsetTop,T=K+X.clientHeight+G,R=ue.scrollTop,re=R+ue.clientHeight;if(K>=R&&T<=re)ce--;else{D=Math.max(0,Math.min(T,re)-Math.max(K,R)),ve=X.clientHeight;break}}ce>=1&&c(X=>{let K=ve*ce-D+G;return X>=K?X:K})}}):null,Hx({padding:b,apply({availableWidth:Q,availableHeight:z,elements:ae}){Object.assign(ae.floating.style,{overflow:"auto",maxWidth:`${Q}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${z}px)`})}})].filter(Boolean),whileElementsMounted:Rx}),[M=C,A=j]=P.placement.split("-");C==="selection"&&(M="selection");let H=y.useMemo(()=>({anchor:[M,A].filter(Boolean).join(" ")}),[M,A]),q=l1(P,{overflowRef:f,onChange:c}),{getReferenceProps:ee,getFloatingProps:he}=r1([q]),J=xe(Q=>{h(Q),I.setFloating(Q)});return y.createElement(Mu.Provider,{value:s},y.createElement(Qr.Provider,{value:{setFloating:J,setReference:I.setReference,styles:L,getReferenceProps:ee,getFloatingProps:he,slot:H}},n))}function s1(n){Le(()=>{if(!n)return;let l=new MutationObserver(()=>{let o=window.getComputedStyle(n).maxHeight,s=parseFloat(o);if(isNaN(s))return;let a=parseInt(o);isNaN(a)||s!==a&&(n.style.maxHeight=`${Math.ceil(s)}px`)});return l.observe(n,{attributes:!0,attributeFilter:["style"]}),()=>{l.disconnect()}},[n])}function a1(n,l){var o,s,a;let c=Za((o=n?.gap)!=null?o:"var(--anchor-gap, 0)",l),f=Za((s=n?.offset)!=null?s:"var(--anchor-offset, 0)",l),p=Za((a=n?.padding)!=null?a:"var(--anchor-padding, 0)",l);return{...n,gap:c,offset:f,padding:p}}function Za(n,l,o=void 0){let s=cr(),a=xe((h,v)=>{if(h==null)return[o,null];if(typeof h=="number")return[h,null];if(typeof h=="string"){if(!v)return[o,null];let x=Tp(h,v);return[x,E=>{let w=lh(h);{let b=w.map(S=>window.getComputedStyle(v).getPropertyValue(S));s.requestAnimationFrame(function S(){s.nextFrame(S);let C=!1;for(let[I,L]of w.entries()){let P=window.getComputedStyle(v).getPropertyValue(L);if(b[I]!==P){b[I]=P,C=!0;break}}if(!C)return;let j=Tp(h,v);x!==j&&(E(j),x=j)})}return s.dispose}]}return[o,null]}),c=y.useMemo(()=>a(n,l)[0],[n,l]),[f=c,p]=y.useState();return Le(()=>{let[h,v]=a(n,l);if(p(h),!!v)return v(p)},[n,l]),f}function lh(n){let l=/var\((.*)\)/.exec(n);if(l){let o=l[1].indexOf(",");if(o===-1)return[l[1]];let s=l[1].slice(0,o).trim(),a=l[1].slice(o+1).trim();return a?[s,...lh(a)]:[s]}return[]}function Tp(n,l){let o=document.createElement("div");l.appendChild(o),o.style.setProperty("margin-top","0px","important"),o.style.setProperty("margin-top",n,"important");let s=parseFloat(window.getComputedStyle(o).marginTop)||0;return l.removeChild(o),s}function u1({children:n,freeze:l},o){let s=$i(l,n);return y.isValidElement(s)?y.cloneElement(s,{ref:o}):ye.createElement(ye.Fragment,null,s)}const c1=ye.forwardRef(u1);function $i(n,l){let[o,s]=y.useState(l);return!n&&o!==l&&s(l),n?o:l}let _u=y.createContext(null);_u.displayName="OpenClosedContext";var dn=(n=>(n[n.Open=1]="Open",n[n.Closed=2]="Closed",n[n.Closing=4]="Closing",n[n.Opening=8]="Opening",n))(dn||{});function ih(){return y.useContext(_u)}function sh({value:n,children:l}){return ye.createElement(_u.Provider,{value:n},l)}function d1(n){function l(){document.readyState!=="loading"&&(n(),document.removeEventListener("DOMContentLoaded",l))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",l),l())}let er=[];d1(()=>{function n(l){if(!rr(l.target)||l.target===document.body||er[0]===l.target)return;let o=l.target;o=o.closest(Oi),er.unshift(o??l.target),er=er.filter(s=>s!=null&&s.isConnected),er.splice(10)}window.addEventListener("click",n,{capture:!0}),window.addEventListener("mousedown",n,{capture:!0}),window.addEventListener("focus",n,{capture:!0}),document.body.addEventListener("click",n,{capture:!0}),document.body.addEventListener("mousedown",n,{capture:!0}),document.body.addEventListener("focus",n,{capture:!0})});function f1(n){throw new Error("Unexpected object: "+n)}var we=(n=>(n[n.First=0]="First",n[n.Previous=1]="Previous",n[n.Next=2]="Next",n[n.Last=3]="Last",n[n.Specific=4]="Specific",n[n.Nothing=5]="Nothing",n))(we||{});function Dr(n,l){let o=l.resolveItems();if(o.length<=0)return null;let s=l.resolveActiveIndex(),a=s??-1;switch(n.focus){case 0:{for(let c=0;c=0;--c)if(!l.resolveDisabled(o[c],c,o))return c;return s}case 2:{for(let c=a+1;c=0;--c)if(!l.resolveDisabled(o[c],c,o))return c;return s}case 4:{for(let c=0;c(o.current=!1,()=>{o.current=!0,Jp(()=>{o.current&&l()})}),[l])}function p1(){let n=typeof document>"u";return"useSyncExternalStore"in ru?(l=>l.useSyncExternalStore)(ru)(()=>()=>{},()=>!1,()=>!n):!1}function m1(){let n=p1(),[l,o]=y.useState(Qt.isHandoffComplete);return l&&Qt.isHandoffComplete===!1&&o(!1),y.useEffect(()=>{l!==!0&&o(!0)},[l]),y.useEffect(()=>Qt.handoff(),[]),n?!1:l}let h1=y.createContext(!1);function g1(){return y.useContext(h1)}function v1(n){let l=g1(),o=y.useContext(uh),[s,a]=y.useState(()=>{var c;if(!l&&o!==null)return(c=o.current)!=null?c:null;if(Qt.isServer)return null;let f=n?.getElementById("headlessui-portal-root");if(f)return f;if(n===null)return null;let p=n.createElement("div");return p.setAttribute("id","headlessui-portal-root"),n.body.appendChild(p)});return y.useEffect(()=>{s!==null&&(n!=null&&n.body.contains(s)||n==null||n.body.appendChild(s))},[s,n]),y.useEffect(()=>{l||o!==null&&a(o.current)},[o,a,l]),s}let ah=y.Fragment,y1=ot(function(n,l){let{ownerDocument:o=null,...s}=n,a=y.useRef(null),c=vt(Vv(b=>{a.current=b}),l),f=Uo(a.current),p=o??f,h=v1(p),v=y.useContext(S1),x=cr(),E=m1(),w=rt();return Lu(()=>{var b;h&&h.childNodes.length<=0&&((b=h.parentElement)==null||b.removeChild(h))}),!h||!E?null:Ye.createPortal(ye.createElement("div",{"data-headlessui-portal":"",ref:b=>{x.dispose(),v&&b&&x.add(v.register(b))}},w({ourProps:{ref:c},theirProps:s,slot:{},defaultTag:ah,name:"Portal"})),h)});function x1(n,l){let o=vt(l),{enabled:s=!0,ownerDocument:a,...c}=n,f=rt();return s?ye.createElement(y1,{...c,ownerDocument:a,ref:o}):f({ourProps:{ref:o},theirProps:c,slot:{},defaultTag:ah,name:"Portal"})}let w1=y.Fragment,uh=y.createContext(null);function b1(n,l){let{target:o,...s}=n,a={ref:vt(l)},c=rt();return ye.createElement(uh.Provider,{value:o},c({ourProps:a,theirProps:s,defaultTag:w1,name:"Popover.Group"}))}let S1=y.createContext(null),E1=ot(x1),k1=ot(b1),ch=Object.assign(E1,{Group:k1});const cn={Idle:{kind:"Idle"},Tracked:n=>({kind:"Tracked",position:n}),Moved:{kind:"Moved"}};function Iu(n){let l=n.getBoundingClientRect();return`${l.x},${l.y}`}function dh(n,l,o){let s=gt();if(l.kind==="Tracked"){let a=function(){c!==Iu(n)&&(s.dispose(),o())},{position:c}=l,f=new ResizeObserver(a);f.observe(n),s.add(()=>f.disconnect()),s.addEventListener(window,"scroll",a,{passive:!0}),s.addEventListener(window,"resize",a)}return()=>s.dispose()}var C1=Object.defineProperty,N1=(n,l,o)=>l in n?C1(n,l,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[l]=o,Rp=(n,l,o)=>(N1(n,typeof l!="symbol"?l+"":l,o),o),Se=(n=>(n[n.Open=0]="Open",n[n.Closed=1]="Closed",n))(Se||{}),St=(n=>(n[n.Single=0]="Single",n[n.Multi=1]="Multi",n))(St||{}),Xt=(n=>(n[n.Pointer=0]="Pointer",n[n.Focus=1]="Focus",n[n.Other=2]="Other",n))(Xt||{}),fh=(n=>(n[n.OpenCombobox=0]="OpenCombobox",n[n.CloseCombobox=1]="CloseCombobox",n[n.GoToOption=2]="GoToOption",n[n.SetTyping=3]="SetTyping",n[n.RegisterOption=4]="RegisterOption",n[n.UnregisterOption=5]="UnregisterOption",n[n.DefaultToFirstOption=6]="DefaultToFirstOption",n[n.SetActivationTrigger=7]="SetActivationTrigger",n[n.UpdateVirtualConfiguration=8]="UpdateVirtualConfiguration",n[n.SetInputElement=9]="SetInputElement",n[n.SetButtonElement=10]="SetButtonElement",n[n.SetOptionsElement=11]="SetOptionsElement",n[n.MarkInputAsMoved=12]="MarkInputAsMoved",n))(fh||{});function eu(n,l=o=>o){let o=n.activeOptionIndex!==null?n.options[n.activeOptionIndex]:null,s=l(n.options.slice()),a=s.length>0&&s[0].dataRef.current.order!==null?s.sort((f,p)=>f.dataRef.current.order-p.dataRef.current.order):Pu(s,f=>f.dataRef.current.domRef.current),c=o?a.indexOf(o):null;return c===-1&&(c=null),{options:a,activeOptionIndex:c}}let j1={1(n){var l;if((l=n.dataRef.current)!=null&&l.disabled||n.comboboxState===1)return n;let o=n.inputElement?cn.Tracked(Iu(n.inputElement)):n.inputPositionState;return{...n,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:o,__demoMode:!1}},0(n){var l,o;if((l=n.dataRef.current)!=null&&l.disabled||n.comboboxState===0)return n;if((o=n.dataRef.current)!=null&&o.value){let s=n.dataRef.current.calculateIndex(n.dataRef.current.value);if(s!==-1)return{...n,activeOptionIndex:s,comboboxState:0,__demoMode:!1,inputPositionState:cn.Idle}}return{...n,comboboxState:0,inputPositionState:cn.Idle,__demoMode:!1}},3(n,l){return n.isTyping===l.isTyping?n:{...n,isTyping:l.isTyping}},2(n,l){var o,s,a,c;if((o=n.dataRef.current)!=null&&o.disabled||n.optionsElement&&!((s=n.dataRef.current)!=null&&s.optionsPropsRef.current.static)&&n.comboboxState===1)return n;if(n.virtual){let{options:v,disabled:x}=n.virtual,E=l.focus===we.Specific?l.idx:Dr(l,{resolveItems:()=>v,resolveActiveIndex:()=>{var b,S;return(S=(b=n.activeOptionIndex)!=null?b:v.findIndex(C=>!x(C)))!=null?S:null},resolveDisabled:x,resolveId(){throw new Error("Function not implemented.")}}),w=(a=l.trigger)!=null?a:2;return n.activeOptionIndex===E&&n.activationTrigger===w?n:{...n,activeOptionIndex:E,activationTrigger:w,isTyping:!1,__demoMode:!1}}let f=eu(n);if(f.activeOptionIndex===null){let v=f.options.findIndex(x=>!x.dataRef.current.disabled);v!==-1&&(f.activeOptionIndex=v)}let p=l.focus===we.Specific?l.idx:Dr(l,{resolveItems:()=>f.options,resolveActiveIndex:()=>f.activeOptionIndex,resolveId:v=>v.id,resolveDisabled:v=>v.dataRef.current.disabled}),h=(c=l.trigger)!=null?c:2;return n.activeOptionIndex===p&&n.activationTrigger===h?n:{...n,...f,isTyping:!1,activeOptionIndex:p,activationTrigger:h,__demoMode:!1}},4:(n,l)=>{var o,s,a,c;if((o=n.dataRef.current)!=null&&o.virtual)return{...n,options:[...n.options,l.payload]};let f=l.payload,p=eu(n,v=>(v.push(f),v));n.activeOptionIndex===null&&(a=(s=n.dataRef.current).isSelected)!=null&&a.call(s,l.payload.dataRef.current.value)&&(p.activeOptionIndex=p.options.indexOf(f));let h={...n,...p,activationTrigger:2};return(c=n.dataRef.current)!=null&&c.__demoMode&&n.dataRef.current.value===void 0&&(h.activeOptionIndex=0),h},5:(n,l)=>{var o;if((o=n.dataRef.current)!=null&&o.virtual)return{...n,options:n.options.filter(a=>a.id!==l.id)};let s=eu(n,a=>{let c=a.findIndex(f=>f.id===l.id);return c!==-1&&a.splice(c,1),a});return{...n,...s,activationTrigger:2}},6:(n,l)=>n.defaultToFirstOption===l.value?n:{...n,defaultToFirstOption:l.value},7:(n,l)=>n.activationTrigger===l.trigger?n:{...n,activationTrigger:l.trigger},8:(n,l)=>{var o,s;if(n.virtual===null)return{...n,virtual:{options:l.options,disabled:(o=l.disabled)!=null?o:()=>!1}};if(n.virtual.options===l.options&&n.virtual.disabled===l.disabled)return n;let a=n.activeOptionIndex;if(n.activeOptionIndex!==null){let c=l.options.indexOf(n.virtual.options[n.activeOptionIndex]);c!==-1?a=c:a=null}return{...n,activeOptionIndex:a,virtual:{options:l.options,disabled:(s=l.disabled)!=null?s:()=>!1}}},9:(n,l)=>n.inputElement===l.element?n:{...n,inputElement:l.element},10:(n,l)=>n.buttonElement===l.element?n:{...n,buttonElement:l.element},11:(n,l)=>n.optionsElement===l.element?n:{...n,optionsElement:l.element},12(n){return n.inputPositionState.kind!=="Tracked"?n:{...n,inputPositionState:cn.Moved}}},O1=class ph extends Nu{constructor(l){super(l),Rp(this,"actions",{onChange:o=>{let{onChange:s,compare:a,mode:c,value:f}=this.state.dataRef.current;return tt(c,{0:()=>s?.(o),1:()=>{let p=f.slice(),h=p.findIndex(v=>a(v,o));return h===-1?p.push(o):p.splice(h,1),s?.(p)}})},registerOption:(o,s)=>(this.send({type:4,payload:{id:o,dataRef:s}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(s.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:o})}),goToOption:(o,s)=>(this.send({type:6,value:!1}),this.send({type:2,...o,trigger:s})),setIsTyping:o=>{this.send({type:3,isTyping:o})},closeCombobox:()=>{var o,s;this.send({type:1}),this.send({type:6,value:!1}),(s=(o=this.state.dataRef.current).onClose)==null||s.call(o)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:o=>{this.send({type:7,trigger:o})},selectActiveOption:()=>{let o=this.selectors.activeOptionIndex(this.state);if(o!==null){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[o]);else{let{dataRef:s}=this.state.options[o];this.actions.onChange(s.current.value)}this.actions.goToOption({focus:we.Specific,idx:o})}},setInputElement:o=>{this.send({type:9,element:o})},setButtonElement:o=>{this.send({type:10,element:o})},setOptionsElement:o=>{this.send({type:11,element:o})}}),Rp(this,"selectors",{activeDescendantId:o=>{var s,a;let c=this.selectors.activeOptionIndex(o);if(c!==null)return o.virtual?(a=o.options.find(f=>!f.dataRef.current.disabled&&o.dataRef.current.compare(f.dataRef.current.value,o.virtual.options[c])))==null?void 0:a.id:(s=o.options[c])==null?void 0:s.id},activeOptionIndex:o=>{if(o.defaultToFirstOption&&o.activeOptionIndex===null&&(o.virtual?o.virtual.options.length>0:o.options.length>0)){if(o.virtual){let{options:a,disabled:c}=o.virtual,f=a.findIndex(p=>{var h;return!((h=c?.(p))!=null&&h)});if(f!==-1)return f}let s=o.options.findIndex(a=>!a.dataRef.current.disabled);if(s!==-1)return s}return o.activeOptionIndex},activeOption:o=>{var s,a;let c=this.selectors.activeOptionIndex(o);return c===null?null:o.virtual?o.virtual.options[c??0]:(a=(s=o.options[c])==null?void 0:s.dataRef.current.value)!=null?a:null},isActive:(o,s,a)=>{var c;let f=this.selectors.activeOptionIndex(o);return f===null?!1:o.virtual?f===o.dataRef.current.calculateIndex(s):((c=o.options[f])==null?void 0:c.id)===a},shouldScrollIntoView:(o,s,a)=>!(o.virtual||o.__demoMode||o.comboboxState!==0||o.activationTrigger===0||!this.selectors.isActive(o,s,a)),didInputMove(o){return o.inputPositionState.kind==="Moved"}});{let o=this.state.id,s=Zo.get(null);this.disposables.add(s.on(ju.Push,a=>{!s.selectors.isTop(a,o)&&this.state.comboboxState===0&&this.actions.closeCombobox()})),this.on(0,()=>s.actions.push(o)),this.on(1,()=>s.actions.pop(o))}this.disposables.group(o=>{this.on(1,s=>{s.inputElement&&(o.dispose(),o.add(dh(s.inputElement,s.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:l,virtual:o=null,__demoMode:s=!1}){var a;return new ph({id:l,dataRef:{current:{}},comboboxState:s?0:1,isTyping:!1,options:[],virtual:o?{options:o.options,disabled:(a=o.disabled)!=null?a:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:s,inputPositionState:cn.Idle})}reduce(l,o){return tt(o.type,j1,l,o)}};const mh=y.createContext(null);function nl(n){let l=y.useContext(mh);if(l===null){let o=new Error(`<${n} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,hh),o}return l}function hh({id:n,virtual:l=null,__demoMode:o=!1}){let s=y.useMemo(()=>O1.new({id:n,virtual:l,__demoMode:o}),[]);return Lu(()=>s.dispose()),s}let Yo=y.createContext(null);Yo.displayName="ComboboxDataContext";function Yr(n){let l=y.useContext(Yo);if(l===null){let o=new Error(`<${n} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,Yr),o}return l}let gh=y.createContext(null);function P1(n){let l=nl("VirtualProvider"),o=Yr("VirtualProvider"),{options:s}=o.virtual,a=je(l,b=>b.optionsElement),[c,f]=y.useMemo(()=>{let b=a;if(!b)return[0,0];let S=window.getComputedStyle(b);return[parseFloat(S.paddingBlockStart||S.paddingTop),parseFloat(S.paddingBlockEnd||S.paddingBottom)]},[a]),p=sy({enabled:s.length!==0,scrollPaddingStart:c,scrollPaddingEnd:f,count:s.length,estimateSize(){return 40},getScrollElement(){return l.state.optionsElement},overscan:12}),[h,v]=y.useState(0);Le(()=>{v(b=>b+1)},[s]);let x=p.getVirtualItems(),E=je(l,b=>b.activationTrigger===Xt.Pointer),w=je(l,l.selectors.activeOptionIndex);return x.length===0?null:ye.createElement(gh.Provider,{value:p},ye.createElement("div",{style:{position:"relative",width:"100%",height:`${p.getTotalSize()}px`},ref:b=>{b&&(E||w!==null&&s.length>w&&p.scrollToIndex(w))}},x.map(b=>{var S;return ye.createElement(y.Fragment,{key:b.key},ye.cloneElement((S=n.children)==null?void 0:S.call(n,{...n.slot,option:s[b.index]}),{key:`${h}-${b.key}`,"data-index":b.index,"aria-setsize":s.length,"aria-posinset":b.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${b.start}px)`,overflowAnchor:"none"}}))})))}let T1=y.Fragment;function R1(n,l){let o=y.useId(),s=Li(),{value:a,defaultValue:c,onChange:f,form:p,name:h,by:v,invalid:x=!1,disabled:E=s||!1,onClose:w,__demoMode:b=!1,multiple:S=!1,immediate:C=!1,virtual:j=null,nullable:I,...L}=n,P=rm(c),[M=S?[]:void 0,A]=nm(a,f,P),H=hh({id:o,virtual:j,__demoMode:b}),q=y.useRef({static:!1,hold:!1}),ee=ym(v),he=xe(ie=>j?v===null?j.options.indexOf(ie):j.options.findIndex(Ee=>ee(Ee,ie)):H.state.options.findIndex(Ee=>ee(Ee.dataRef.current.value,ie))),J=y.useCallback(ie=>tt(ae.mode,{[St.Multi]:()=>M.some(Ee=>ee(Ee,ie)),[St.Single]:()=>ee(M,ie)}),[M]),Q=je(H,ie=>ie.virtual),z=xe(()=>w?.()),ae=y.useMemo(()=>({__demoMode:b,immediate:C,optionsPropsRef:q,value:M,defaultValue:P,disabled:E,invalid:x,mode:S?St.Multi:St.Single,virtual:j?Q:null,onChange:A,isSelected:J,calculateIndex:he,compare:ee,onClose:z}),[b,C,q,M,P,E,x,S,j,Q,A,J,he,ee,z]);Le(()=>{var ie;j&&H.send({type:fh.UpdateVirtualConfiguration,options:j.options,disabled:(ie=j.disabled)!=null?ie:null})},[j,j?.options,j?.disabled]),Le(()=>{H.state.dataRef.current=ae},[ae]);let[ue,G,ce,ve]=je(H,ie=>[ie.comboboxState,ie.buttonElement,ie.inputElement,ie.optionsElement]),D=Zo.get(null),X=je(D,y.useCallback(ie=>D.selectors.isTop(ie,o),[D,o]));Tm(X,[G,ce,ve],()=>H.actions.closeCombobox());let K=je(H,H.selectors.activeOptionIndex),T=je(H,H.selectors.activeOption),R=kt({open:ue===Se.Open,disabled:E,invalid:x,activeIndex:K,activeOption:T,value:M}),[re,le]=hm(),pe=l===null?{}:{ref:l},U=y.useCallback(()=>{if(P!==void 0)return A?.(P)},[A,P]),me=rt();return ye.createElement(le,{value:re,props:{htmlFor:ce?.id},slot:{open:ue===Se.Open,disabled:E}},ye.createElement(oh,null,ye.createElement(Yo.Provider,{value:ae},ye.createElement(mh.Provider,{value:H},ye.createElement(sh,{value:tt(ue,{[Se.Open]:dn.Open,[Se.Closed]:dn.Closed})},h!=null&&ye.createElement(am,{disabled:E,data:M!=null?{[h]:M}:{},form:p,onReset:U}),me({ourProps:pe,theirProps:L,slot:R,defaultTag:T1,name:"Combobox"}))))))}let $1="input";function M1(n,l){var o,s;let a=nl("Combobox.Input"),c=Yr("Combobox.Input"),f=y.useId(),p=Eu(),{id:h=p||`headlessui-combobox-input-${f}`,onChange:v,displayValue:x,disabled:E=c.disabled||!1,autoFocus:w=!1,type:b="text",...S}=n,C=y.useRef(null),j=vt(C,l,th(),a.actions.setInputElement),[I,L]=je(a,R=>[R.comboboxState,R.isTyping]),P=cr(),M=xe(()=>{a.actions.onChange(null),a.state.optionsElement&&(a.state.optionsElement.scrollTop=0),a.actions.goToOption({focus:we.Nothing})}),A=y.useMemo(()=>{var R;return typeof x=="function"&&c.value!==void 0?(R=x(c.value))!=null?R:"":typeof c.value=="string"?c.value:""},[c.value,x]);mp(([R,re],[le,pe])=>{if(a.state.isTyping)return;let U=C.current;U&&((pe===Se.Open&&re===Se.Closed||R!==le)&&(U.value=R),requestAnimationFrame(()=>{if(a.state.isTyping||!U||bu(U))return;let{selectionStart:me,selectionEnd:ie}=U;Math.abs((ie??0)-(me??0))===0&&me===0&&U.setSelectionRange(U.value.length,U.value.length)}))},[A,I,L]),mp(([R],[re])=>{if(R===Se.Open&&re===Se.Closed){if(a.state.isTyping)return;let le=C.current;if(!le)return;let pe=le.value,{selectionStart:U,selectionEnd:me,selectionDirection:ie}=le;le.value="",le.value=pe,ie!==null?le.setSelectionRange(U,me,ie):le.setSelectionRange(U,me)}},[I]);let H=y.useRef(!1),q=xe(()=>{H.current=!0}),ee=xe(()=>{P.nextFrame(()=>{H.current=!1})}),he=xe(R=>{switch(a.actions.setIsTyping(!0),R.key){case Ne.Enter:if(a.state.comboboxState!==Se.Open||H.current)return;if(R.preventDefault(),R.stopPropagation(),a.selectors.activeOptionIndex(a.state)===null){a.actions.closeCombobox();return}a.actions.selectActiveOption(),c.mode===St.Single&&a.actions.closeCombobox();break;case Ne.ArrowDown:return R.preventDefault(),R.stopPropagation(),tt(a.state.comboboxState,{[Se.Open]:()=>a.actions.goToOption({focus:we.Next}),[Se.Closed]:()=>a.actions.openCombobox()});case Ne.ArrowUp:return R.preventDefault(),R.stopPropagation(),tt(a.state.comboboxState,{[Se.Open]:()=>a.actions.goToOption({focus:we.Previous}),[Se.Closed]:()=>{Ye.flushSync(()=>a.actions.openCombobox()),c.value||a.actions.goToOption({focus:we.Last})}});case Ne.Home:if(a.state.comboboxState===Se.Closed||R.shiftKey)break;return R.preventDefault(),R.stopPropagation(),a.actions.goToOption({focus:we.First});case Ne.PageUp:return R.preventDefault(),R.stopPropagation(),a.actions.goToOption({focus:we.First});case Ne.End:if(a.state.comboboxState===Se.Closed||R.shiftKey)break;return R.preventDefault(),R.stopPropagation(),a.actions.goToOption({focus:we.Last});case Ne.PageDown:return R.preventDefault(),R.stopPropagation(),a.actions.goToOption({focus:we.Last});case Ne.Escape:return a.state.comboboxState!==Se.Open?void 0:(R.preventDefault(),a.state.optionsElement&&!c.optionsPropsRef.current.static&&R.stopPropagation(),c.mode===St.Single&&c.value===null&&M(),a.actions.closeCombobox());case Ne.Tab:if(a.actions.setIsTyping(!1),a.state.comboboxState!==Se.Open)return;c.mode===St.Single&&a.state.activationTrigger!==Xt.Focus&&a.actions.selectActiveOption(),a.actions.closeCombobox();break}}),J=xe(R=>{v?.(R),c.mode===St.Single&&R.target.value===""&&M(),a.actions.openCombobox()}),Q=xe(R=>{var re,le,pe;let U=(re=R.relatedTarget)!=null?re:er.find(me=>me!==R.currentTarget);if(!((le=a.state.optionsElement)!=null&&le.contains(U))&&!((pe=a.state.buttonElement)!=null&&pe.contains(U))&&a.state.comboboxState===Se.Open)return R.preventDefault(),c.mode===St.Single&&c.value===null&&M(),a.actions.closeCombobox()}),z=xe(R=>{var re,le,pe;let U=(re=R.relatedTarget)!=null?re:er.find(me=>me!==R.currentTarget);(le=a.state.buttonElement)!=null&&le.contains(U)||(pe=a.state.optionsElement)!=null&&pe.contains(U)||c.disabled||c.immediate&&a.state.comboboxState!==Se.Open&&P.microTask(()=>{Ye.flushSync(()=>a.actions.openCombobox()),a.actions.setActivationTrigger(Xt.Focus)})}),ae=Jo(),ue=pm(),{isFocused:G,focusProps:ce}=wu({autoFocus:w}),{isHovered:ve,hoverProps:D}=xu({isDisabled:E}),X=je(a,R=>R.optionsElement),K=kt({open:I===Se.Open,disabled:E,invalid:c.invalid,hover:ve,focus:G,autofocus:w}),T=qo({ref:j,id:h,role:"combobox",type:b,"aria-controls":X?.id,"aria-expanded":I===Se.Open,"aria-activedescendant":je(a,a.selectors.activeDescendantId),"aria-labelledby":ae,"aria-describedby":ue,"aria-autocomplete":"list",defaultValue:(s=(o=n.defaultValue)!=null?o:c.defaultValue!==void 0?x?.(c.defaultValue):null)!=null?s:c.defaultValue,disabled:E||void 0,autoFocus:w,onCompositionStart:q,onCompositionEnd:ee,onKeyDown:he,onChange:J,onFocus:z,onBlur:Q},ce,D);return rt()({ourProps:T,theirProps:S,slot:K,defaultTag:$1,name:"Combobox.Input"})}let _1="button";function L1(n,l){let o=nl("Combobox.Button"),s=Yr("Combobox.Button"),[a,c]=y.useState(null),f=vt(l,c,o.actions.setButtonElement),p=y.useId(),{id:h=`headlessui-combobox-button-${p}`,disabled:v=s.disabled||!1,autoFocus:x=!1,...E}=n,[w,b,S]=je(o,z=>[z.comboboxState,z.inputElement,z.optionsElement]),C=$m(b),j=w===Se.Open;Rm(j,{trigger:a,action:y.useCallback(z=>{if(a!=null&&a.contains(z.target)||b!=null&&b.contains(z.target))return sn.Ignore;let ae=z.target.closest('[role="option"]:not([data-disabled])');return Gt(ae)?sn.Select(ae):S!=null&&S.contains(z.target)?sn.Ignore:sn.Close},[a,b,S]),close:o.actions.closeCombobox,select:o.actions.selectActiveOption});let I=xe(z=>{switch(z.key){case Ne.Space:case Ne.Enter:z.preventDefault(),z.stopPropagation(),o.state.comboboxState===Se.Closed&&Ye.flushSync(()=>o.actions.openCombobox()),C();return;case Ne.ArrowDown:z.preventDefault(),z.stopPropagation(),o.state.comboboxState===Se.Closed&&(Ye.flushSync(()=>o.actions.openCombobox()),o.state.dataRef.current.value||o.actions.goToOption({focus:we.First})),C();return;case Ne.ArrowUp:z.preventDefault(),z.stopPropagation(),o.state.comboboxState===Se.Closed&&(Ye.flushSync(()=>o.actions.openCombobox()),o.state.dataRef.current.value||o.actions.goToOption({focus:we.Last})),C();return;case Ne.Escape:if(o.state.comboboxState!==Se.Open)return;z.preventDefault(),o.state.optionsElement&&!s.optionsPropsRef.current.static&&z.stopPropagation(),Ye.flushSync(()=>o.actions.closeCombobox()),C();return;default:return}}),L=xm(()=>{o.state.comboboxState===Se.Open?o.actions.closeCombobox():o.actions.openCombobox(),C()}),P=Jo([h]),{isFocusVisible:M,focusProps:A}=wu({autoFocus:x}),{isHovered:H,hoverProps:q}=xu({isDisabled:v}),{pressed:ee,pressProps:he}=Zp({disabled:v}),J=kt({open:w===Se.Open,active:ee||w===Se.Open,disabled:v,invalid:s.invalid,value:s.value,hover:H,focus:M}),Q=qo({ref:f,id:h,type:Mm(n,a),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":S?.id,"aria-expanded":w===Se.Open,"aria-labelledby":P,disabled:v||void 0,autoFocus:x,onKeyDown:I},L,A,q,he);return rt()({ourProps:Q,theirProps:E,slot:J,defaultTag:_1,name:"Combobox.Button"})}let I1="div",F1=Bo.RenderStrategy|Bo.Static;function D1(n,l){var o,s,a;let c=y.useId(),{id:f=`headlessui-combobox-options-${c}`,hold:p=!1,anchor:h,portal:v=!1,modal:x=!0,transition:E=!1,...w}=n,b=nl("Combobox.Options"),S=Yr("Combobox.Options"),C=eh(h);C&&(v=!0);let[j,I]=rh(C),[L,P]=y.useState(null),M=nh(),A=vt(l,C?j:null,b.actions.setOptionsElement,P),[H,q,ee,he,J]=je(b,Ie=>[Ie.comboboxState,Ie.inputElement,Ie.buttonElement,Ie.optionsElement,Ie.activationTrigger]),Q=Uo(q||ee),z=Uo(he),ae=ih(),[ue,G]=Fm(E,L,ae!==null?(ae&dn.Open)===dn.Open:H===Se.Open);Nm(ue,q,b.actions.closeCombobox);let ce=S.__demoMode?!1:x&&H===Se.Open;_m(ce,z);let ve=S.__demoMode?!1:x&&H===Se.Open;Cm(ve,{allowed:y.useCallback(()=>[q,ee,he],[q,ee,he])});let D=je(b,b.selectors.didInputMove)?!1:ue;Le(()=>{var Ie;S.optionsPropsRef.current.static=(Ie=n.static)!=null?Ie:!1},[S.optionsPropsRef,n.static]),Le(()=>{S.optionsPropsRef.current.hold=p},[S.optionsPropsRef,p]),Qy(H===Se.Open,{container:he,accept(Ie){return Ie.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:Ie.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(Ie){Ie.setAttribute("role","none")}});let X=Jo([ee?.id]),K=kt({open:H===Se.Open,option:void 0}),T=xe(()=>{b.actions.setActivationTrigger(Xt.Pointer)}),R=xe(Ie=>{Ie.preventDefault(),b.actions.setActivationTrigger(Xt.Pointer)}),re=qo(C?M():{},{"aria-labelledby":X,role:"listbox","aria-multiselectable":S.mode===St.Multi?!0:void 0,id:f,ref:A,style:{...w.style,...I,"--input-width":cu(ue,q,!0).width,"--button-width":cu(ue,ee,!0).width},onWheel:J===Xt.Pointer?void 0:T,onMouseDown:R,...Im(G)}),le=ue&&H===Se.Closed&&!n.static,pe=$i(le,(o=S.virtual)==null?void 0:o.options),U=$i(le,S.value),me=y.useCallback(Ie=>S.compare(U,Ie),[S.compare,U]),ie=y.useMemo(()=>{if(!S.virtual)return S;if(pe===void 0)throw new Error("Missing `options` in virtual mode");return pe!==S.virtual.options?{...S,virtual:{...S.virtual,options:pe}}:S},[S,pe,(s=S.virtual)==null?void 0:s.options]);S.virtual&&Object.assign(w,{children:ye.createElement(Yo.Provider,{value:ie},ye.createElement(P1,{slot:K},w.children))});let Ee=rt(),lt=y.useMemo(()=>S.mode===St.Multi?S:{...S,isSelected:me},[S,me]);return ye.createElement(ch,{enabled:v?n.static||ue:!1,ownerDocument:Q},ye.createElement(Yo.Provider,{value:lt},Ee({ourProps:re,theirProps:{...w,children:ye.createElement(c1,{freeze:le},typeof w.children=="function"?(a=w.children)==null?void 0:a.call(w,K):w.children)},slot:K,defaultTag:I1,features:F1,visible:D,name:"Combobox.Options"})))}let A1="div";function z1(n,l){var o,s,a;let c=Yr("Combobox.Option"),f=nl("Combobox.Option"),p=y.useId(),{id:h=`headlessui-combobox-option-${p}`,value:v,disabled:x=(a=(s=(o=c.virtual)==null?void 0:o.disabled)==null?void 0:s.call(o,v))!=null?a:!1,order:E=null,...w}=n,[b]=je(f,G=>[G.inputElement]),S=$m(b),C=je(f,y.useCallback(G=>f.selectors.isActive(G,v,h),[v,h])),j=c.isSelected(v),I=y.useRef(null),L=Dn({disabled:x,value:v,domRef:I,order:E}),P=y.useContext(gh),M=vt(l,I,P?P.measureElement:null),A=xe(()=>{f.actions.setIsTyping(!1),f.actions.onChange(v)});Le(()=>f.actions.registerOption(h,L),[L,h]);let H=je(f,y.useCallback(G=>f.selectors.shouldScrollIntoView(G,v,h),[v,h]));Le(()=>{if(H)return gt().requestAnimationFrame(()=>{var G,ce;(ce=(G=I.current)==null?void 0:G.scrollIntoView)==null||ce.call(G,{block:"nearest"})})},[H,I]);let q=xe(G=>{G.preventDefault(),G.button===Cu.Left&&(x||(A(),pu()||requestAnimationFrame(()=>S()),c.mode===St.Single&&f.actions.closeCombobox()))}),ee=xe(()=>{if(x)return f.actions.goToOption({focus:we.Nothing});let G=c.calculateIndex(v);f.actions.goToOption({focus:we.Specific,idx:G})}),he=Lm(),J=xe(G=>he.update(G)),Q=xe(G=>{if(!he.wasMoved(G)||x||C&&f.state.activationTrigger===Xt.Pointer)return;let ce=c.calculateIndex(v);f.actions.goToOption({focus:we.Specific,idx:ce},Xt.Pointer)}),z=xe(G=>{he.wasMoved(G)&&(x||C&&(c.optionsPropsRef.current.hold||f.state.activationTrigger===Xt.Pointer&&f.actions.goToOption({focus:we.Nothing})))}),ae=kt({active:C,focus:C,selected:j,disabled:x}),ue={id:h,ref:M,role:"option",tabIndex:x===!0?void 0:-1,"aria-disabled":x===!0?!0:void 0,"aria-selected":j,disabled:void 0,onMouseDown:q,onFocus:ee,onPointerEnter:J,onMouseEnter:J,onPointerMove:Q,onMouseMove:Q,onPointerLeave:z,onMouseLeave:z};return rt()({ourProps:ue,theirProps:w,slot:ae,defaultTag:A1,name:"Combobox.Option"})}let W1=ot(R1),H1=ot(L1),V1=ot(M1),B1=gm,U1=ot(D1),K1=ot(z1),Io=Object.assign(W1,{Input:V1,Button:H1,Label:B1,Options:U1,Option:K1}),$p=/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g;function Mp(n){var l,o;let s=(l=n.innerText)!=null?l:"",a=n.cloneNode(!0);if(!Gt(a))return s;let c=!1;for(let p of a.querySelectorAll('[hidden],[aria-hidden],[role="img"]'))p.remove(),c=!0;let f=c?(o=a.innerText)!=null?o:"":s;return $p.test(f)&&(f=f.replace($p,"")),f}function Q1(n){let l=n.getAttribute("aria-label");if(typeof l=="string")return l.trim();let o=n.getAttribute("aria-labelledby");if(o){let s=o.split(" ").map(a=>{let c=document.getElementById(a);if(c){let f=c.getAttribute("aria-label");return typeof f=="string"?f.trim():Mp(c).trim()}return null}).filter(Boolean);if(s.length>0)return s.join(", ")}return Mp(n).trim()}function Y1(n){let l=y.useRef(""),o=y.useRef("");return xe(()=>{let s=n.current;if(!s)return"";let a=s.innerText;if(l.current===a)return o.current;let c=Q1(s).trim().toLowerCase();return l.current=a,o.current=c,c})}var X1=Object.defineProperty,G1=(n,l,o)=>l in n?X1(n,l,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[l]=o,_p=(n,l,o)=>(G1(n,typeof l!="symbol"?l+"":l,o),o),et=(n=>(n[n.Open=0]="Open",n[n.Closed=1]="Closed",n))(et||{}),Mn=(n=>(n[n.Single=0]="Single",n[n.Multi=1]="Multi",n))(Mn||{}),bi=(n=>(n[n.Pointer=0]="Pointer",n[n.Other=1]="Other",n))(bi||{}),vh=(n=>(n[n.OpenListbox=0]="OpenListbox",n[n.CloseListbox=1]="CloseListbox",n[n.GoToOption=2]="GoToOption",n[n.Search=3]="Search",n[n.ClearSearch=4]="ClearSearch",n[n.SelectOption=5]="SelectOption",n[n.RegisterOptions=6]="RegisterOptions",n[n.UnregisterOptions=7]="UnregisterOptions",n[n.SetButtonElement=8]="SetButtonElement",n[n.SetOptionsElement=9]="SetOptionsElement",n[n.SortOptions=10]="SortOptions",n[n.MarkButtonAsMoved=11]="MarkButtonAsMoved",n))(vh||{});function Lp(n,l=o=>o){let o=n.activeOptionIndex!==null?n.options[n.activeOptionIndex]:null,s=Pu(l(n.options.slice()),c=>c.dataRef.current.domRef.current),a=o?s.indexOf(o):null;return a===-1&&(a=null),{options:s,activeOptionIndex:a}}let q1={1(n){if(n.dataRef.current.disabled||n.listboxState===1)return n;let l=n.buttonElement?cn.Tracked(Iu(n.buttonElement)):n.buttonPositionState;return{...n,activeOptionIndex:null,pendingFocus:{focus:we.Nothing},listboxState:1,__demoMode:!1,buttonPositionState:l}},0(n,l){if(n.dataRef.current.disabled||n.listboxState===0)return n;let o=n.activeOptionIndex,{isSelected:s}=n.dataRef.current,a=n.options.findIndex(c=>s(c.dataRef.current.value));return a!==-1&&(o=a),{...n,frozenValue:!1,pendingFocus:l.focus,listboxState:0,activeOptionIndex:o,__demoMode:!1,buttonPositionState:cn.Idle}},2(n,l){var o,s,a,c,f;if(n.dataRef.current.disabled||n.listboxState===1)return n;let p={...n,searchQuery:"",activationTrigger:(o=l.trigger)!=null?o:1,__demoMode:!1};if(l.focus===we.Nothing)return{...p,activeOptionIndex:null};if(l.focus===we.Specific)return{...p,activeOptionIndex:n.options.findIndex(x=>x.id===l.id)};if(l.focus===we.Previous){let x=n.activeOptionIndex;if(x!==null){let E=n.options[x].dataRef.current.domRef,w=Dr(l,{resolveItems:()=>n.options,resolveActiveIndex:()=>n.activeOptionIndex,resolveId:b=>b.id,resolveDisabled:b=>b.dataRef.current.disabled});if(w!==null){let b=n.options[w].dataRef.current.domRef;if(((s=E.current)==null?void 0:s.previousElementSibling)===b.current||((a=b.current)==null?void 0:a.previousElementSibling)===null)return{...p,activeOptionIndex:w}}}}else if(l.focus===we.Next){let x=n.activeOptionIndex;if(x!==null){let E=n.options[x].dataRef.current.domRef,w=Dr(l,{resolveItems:()=>n.options,resolveActiveIndex:()=>n.activeOptionIndex,resolveId:b=>b.id,resolveDisabled:b=>b.dataRef.current.disabled});if(w!==null){let b=n.options[w].dataRef.current.domRef;if(((c=E.current)==null?void 0:c.nextElementSibling)===b.current||((f=b.current)==null?void 0:f.nextElementSibling)===null)return{...p,activeOptionIndex:w}}}}let h=Lp(n),v=Dr(l,{resolveItems:()=>h.options,resolveActiveIndex:()=>h.activeOptionIndex,resolveId:x=>x.id,resolveDisabled:x=>x.dataRef.current.disabled});return{...p,...h,activeOptionIndex:v}},3:(n,l)=>{if(n.dataRef.current.disabled||n.listboxState===1)return n;let o=n.searchQuery!==""?0:1,s=n.searchQuery+l.value.toLowerCase(),a=(n.activeOptionIndex!==null?n.options.slice(n.activeOptionIndex+o).concat(n.options.slice(0,n.activeOptionIndex+o)):n.options).find(f=>{var p;return!f.dataRef.current.disabled&&((p=f.dataRef.current.textValue)==null?void 0:p.startsWith(s))}),c=a?n.options.indexOf(a):-1;return c===-1||c===n.activeOptionIndex?{...n,searchQuery:s}:{...n,searchQuery:s,activeOptionIndex:c,activationTrigger:1}},4(n){return n.dataRef.current.disabled||n.listboxState===1||n.searchQuery===""?n:{...n,searchQuery:""}},5(n){return n.dataRef.current.mode===0?{...n,frozenValue:!0}:{...n}},6:(n,l)=>{let o=n.options.concat(l.options),s=n.activeOptionIndex;if(n.pendingFocus.focus!==we.Nothing&&(s=Dr(n.pendingFocus,{resolveItems:()=>o,resolveActiveIndex:()=>n.activeOptionIndex,resolveId:a=>a.id,resolveDisabled:a=>a.dataRef.current.disabled})),n.activeOptionIndex===null){let{isSelected:a}=n.dataRef.current;if(a){let c=o.findIndex(f=>a?.(f.dataRef.current.value));c!==-1&&(s=c)}}return{...n,options:o,activeOptionIndex:s,pendingFocus:{focus:we.Nothing},pendingShouldSort:!0}},7:(n,l)=>{let o=n.options,s=[],a=new Set(l.options);for(let[c,f]of o.entries())if(a.has(f.id)&&(s.push(c),a.delete(f.id),a.size===0))break;if(s.length>0){o=o.slice();for(let c of s.reverse())o.splice(c,1)}return{...n,options:o,activationTrigger:1}},8:(n,l)=>n.buttonElement===l.element?n:{...n,buttonElement:l.element},9:(n,l)=>n.optionsElement===l.element?n:{...n,optionsElement:l.element},10:n=>n.pendingShouldSort?{...n,...Lp(n),pendingShouldSort:!1}:n,11(n){return n.buttonPositionState.kind!=="Tracked"?n:{...n,buttonPositionState:cn.Moved}}};class Fu extends Nu{constructor(l){super(l),_p(this,"actions",{onChange:o=>{let{onChange:s,compare:a,mode:c,value:f}=this.state.dataRef.current;return tt(c,{0:()=>s?.(o),1:()=>{let p=f.slice(),h=p.findIndex(v=>a(v,o));return h===-1?p.push(o):p.splice(h,1),s?.(p)}})},registerOption:Ua(()=>{let o=[],s=new Set;return[(a,c)=>{s.has(c)||(s.add(c),o.push({id:a,dataRef:c}))},()=>(s.clear(),this.send({type:6,options:o.splice(0)}))]}),unregisterOption:Ua(()=>{let o=[];return[s=>o.push(s),()=>{this.send({type:7,options:o.splice(0)})}]}),goToOption:Ua(()=>{let o=null;return[(s,a)=>{o={type:2,...s,trigger:a}},()=>o&&this.send(o)]}),closeListbox:()=>{this.send({type:1})},openListbox:o=>{this.send({type:0,focus:o})},selectActiveOption:()=>{var o;if(this.state.activeOptionIndex!==null){let{dataRef:s}=this.state.options[this.state.activeOptionIndex];this.actions.selectOption(s.current.value)}else this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(o=this.state.buttonElement)==null||o.focus({preventScroll:!0}))},selectOption:o=>{this.send({type:5,value:o})},search:o=>{this.send({type:3,value:o})},clearSearch:()=>{this.send({type:4})},setButtonElement:o=>{this.send({type:8,element:o})},setOptionsElement:o=>{this.send({type:9,element:o})}}),_p(this,"selectors",{activeDescendantId(o){var s;let a=o.activeOptionIndex,c=o.options;return a===null||(s=c[a])==null?void 0:s.id},isActive(o,s){var a;let c=o.activeOptionIndex,f=o.options;return c!==null?((a=f[c])==null?void 0:a.id)===s:!1},hasFrozenValue(o){return o.frozenValue},shouldScrollIntoView(o,s){return o.__demoMode||o.listboxState!==0||o.activationTrigger===0?!1:this.isActive(o,s)},didButtonMove(o){return o.buttonPositionState.kind==="Moved"}}),this.on(6,()=>{requestAnimationFrame(()=>{this.send({type:10})})});{let o=this.state.id,s=Zo.get(null);this.disposables.add(s.on(ju.Push,a=>{!s.selectors.isTop(a,o)&&this.state.listboxState===0&&this.actions.closeListbox()})),this.on(0,()=>s.actions.push(o)),this.on(1,()=>s.actions.pop(o))}this.disposables.group(o=>{this.on(1,s=>{s.buttonElement&&(o.dispose(),o.add(dh(s.buttonElement,s.buttonPositionState,()=>{this.send({type:11})})))})}),this.on(5,(o,s)=>{var a;this.actions.onChange(s.value),this.state.dataRef.current.mode===0&&(this.actions.closeListbox(),(a=this.state.buttonElement)==null||a.focus({preventScroll:!0}))})}static new({id:l,__demoMode:o=!1}){return new Fu({id:l,dataRef:{current:{}},listboxState:o?0:1,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1,buttonElement:null,optionsElement:null,pendingShouldSort:!1,pendingFocus:{focus:we.Nothing},frozenValue:!1,__demoMode:o,buttonPositionState:cn.Idle})}reduce(l,o){return tt(o.type,q1,l,o)}}const yh=y.createContext(null);function Du(n){let l=y.useContext(yh);if(l===null){let o=new Error(`<${n} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,xh),o}return l}function xh({id:n,__demoMode:l=!1}){let o=y.useMemo(()=>Fu.new({id:n,__demoMode:l}),[]);return Lu(()=>o.dispose()),o}let Hi=y.createContext(null);Hi.displayName="ListboxDataContext";function rl(n){let l=y.useContext(Hi);if(l===null){let o=new Error(`<${n} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,rl),o}return l}let J1=y.Fragment;function Z1(n,l){let o=y.useId(),s=Li(),{value:a,defaultValue:c,form:f,name:p,onChange:h,by:v,invalid:x=!1,disabled:E=s||!1,horizontal:w=!1,multiple:b=!1,__demoMode:S=!1,...C}=n;const j=w?"horizontal":"vertical";let I=vt(l),L=rm(c),[P=b?[]:void 0,M]=nm(a,h,L),A=xh({id:o,__demoMode:S}),H=y.useRef({static:!1,hold:!1}),q=y.useRef(new Map),ee=ym(v),he=y.useCallback(R=>tt(J.mode,{[Mn.Multi]:()=>P.some(re=>ee(re,R)),[Mn.Single]:()=>ee(P,R)}),[P]),J=kt({value:P,disabled:E,invalid:x,mode:b?Mn.Multi:Mn.Single,orientation:j,onChange:M,compare:ee,isSelected:he,optionsPropsRef:H,listRef:q});Le(()=>{A.state.dataRef.current=J},[J]);let Q=je(A,R=>R.listboxState),z=Zo.get(null),ae=je(z,y.useCallback(R=>z.selectors.isTop(R,o),[z,o])),[ue,G]=je(A,R=>[R.buttonElement,R.optionsElement]);Tm(ae,[ue,G],(R,re)=>{A.send({type:vh.CloseListbox}),Om(re,Ou.Loose)||(R.preventDefault(),ue?.focus())});let ce=kt({open:Q===et.Open,disabled:E,invalid:x,value:P}),[ve,D]=hm({inherit:!0}),X={ref:I},K=y.useCallback(()=>{if(L!==void 0)return M?.(L)},[M,L]),T=rt();return ye.createElement(D,{value:ve,props:{htmlFor:ue?.id},slot:{open:Q===et.Open,disabled:E}},ye.createElement(oh,null,ye.createElement(yh.Provider,{value:A},ye.createElement(Hi.Provider,{value:J},ye.createElement(sh,{value:tt(Q,{[et.Open]:dn.Open,[et.Closed]:dn.Closed})},p!=null&&P!=null&&ye.createElement(am,{disabled:E,data:{[p]:P},form:f,onReset:K}),T({ourProps:X,theirProps:C,slot:ce,defaultTag:J1,name:"Listbox"}))))))}let ew="button";function tw(n,l){let o=y.useId(),s=Eu(),a=rl("Listbox.Button"),c=Du("Listbox.Button"),{id:f=s||`headlessui-listbox-button-${o}`,disabled:p=a.disabled||!1,autoFocus:h=!1,...v}=n,x=vt(l,th(),c.actions.setButtonElement),E=i1(),[w,b,S]=je(c,G=>[G.listboxState,G.buttonElement,G.optionsElement]),C=w===et.Open;Rm(C,{trigger:b,action:y.useCallback(G=>{if(b!=null&&b.contains(G.target))return sn.Ignore;let ce=G.target.closest('[role="option"]:not([data-disabled])');return Gt(ce)?sn.Select(ce):S!=null&&S.contains(G.target)?sn.Ignore:sn.Close},[b,S]),close:c.actions.closeListbox,select:c.actions.selectActiveOption});let j=xe(G=>{switch(G.key){case Ne.Enter:Tv(G.currentTarget);break;case Ne.Space:case Ne.ArrowDown:G.preventDefault(),c.actions.openListbox({focus:a.value?we.Nothing:we.First});break;case Ne.ArrowUp:G.preventDefault(),c.actions.openListbox({focus:a.value?we.Nothing:we.Last});break}}),I=xe(G=>{switch(G.key){case Ne.Space:G.preventDefault();break}}),L=xm(G=>{var ce;c.state.listboxState===et.Open?(Ye.flushSync(()=>c.actions.closeListbox()),(ce=c.state.buttonElement)==null||ce.focus({preventScroll:!0})):(G.preventDefault(),c.actions.openListbox({focus:we.Nothing}))}),P=xe(G=>G.preventDefault()),M=Jo([f]),A=pm(),{isFocusVisible:H,focusProps:q}=wu({autoFocus:h}),{isHovered:ee,hoverProps:he}=xu({isDisabled:p}),{pressed:J,pressProps:Q}=Zp({disabled:p}),z=kt({open:w===et.Open,active:J||w===et.Open,disabled:p,invalid:a.invalid,value:a.value,hover:ee,focus:H,autofocus:h}),ae=je(c,G=>G.listboxState===et.Open),ue=qo(E(),{ref:x,id:f,type:Mm(n,b),"aria-haspopup":"listbox","aria-controls":S?.id,"aria-expanded":ae,"aria-labelledby":M,"aria-describedby":A,disabled:p||void 0,autoFocus:h,onKeyDown:j,onKeyUp:I,onKeyPress:P},L,q,he,Q);return rt()({ourProps:ue,theirProps:v,slot:z,defaultTag:ew,name:"Listbox.Button"})}let wh=y.createContext(!1),nw="div",rw=Bo.RenderStrategy|Bo.Static;function ow(n,l){let o=y.useId(),{id:s=`headlessui-listbox-options-${o}`,anchor:a,portal:c=!1,modal:f=!0,transition:p=!1,...h}=n,v=eh(a),[x,E]=y.useState(null);v&&(c=!0);let w=rl("Listbox.Options"),b=Du("Listbox.Options"),[S,C,j,I]=je(b,U=>[U.listboxState,U.buttonElement,U.optionsElement,U.__demoMode]),L=Uo(C),P=Uo(j),M=ih(),[A,H]=Fm(p,x,M!==null?(M&dn.Open)===dn.Open:S===et.Open);Nm(A,C,b.actions.closeListbox);let q=I?!1:f&&S===et.Open;_m(q,P);let ee=I?!1:f&&S===et.Open;Cm(ee,{allowed:y.useCallback(()=>[C,j],[C,j])});let he=je(b,b.selectors.didButtonMove)?!1:A,J=je(b,b.selectors.hasFrozenValue)&&!n.static,Q=$i(J,w.value),z=y.useCallback(U=>w.compare(Q,U),[w.compare,Q]),ae=je(b,U=>{var me;if(v==null||!((me=v?.to)!=null&&me.includes("selection")))return null;let ie=U.options.findIndex(Ee=>z(Ee.dataRef.current.value));return ie===-1&&(ie=0),ie}),ue=(()=>{if(v==null)return;if(ae===null)return{...v,inner:void 0};let U=Array.from(w.listRef.current.values());return{...v,inner:{listRef:{current:U},index:ae}}})(),[G,ce]=rh(ue),ve=nh(),D=vt(l,v?G:null,b.actions.setOptionsElement,E),X=cr();y.useEffect(()=>{let U=j;U&&S===et.Open&&(bu(U)||U==null||U.focus({preventScroll:!0}))},[S,j]);let K=xe(U=>{var me;switch(X.dispose(),U.key){case Ne.Space:if(b.state.searchQuery!=="")return U.preventDefault(),U.stopPropagation(),b.actions.search(U.key);case Ne.Enter:U.preventDefault(),U.stopPropagation(),b.actions.selectActiveOption();break;case tt(w.orientation,{vertical:Ne.ArrowDown,horizontal:Ne.ArrowRight}):return U.preventDefault(),U.stopPropagation(),b.actions.goToOption({focus:we.Next});case tt(w.orientation,{vertical:Ne.ArrowUp,horizontal:Ne.ArrowLeft}):return U.preventDefault(),U.stopPropagation(),b.actions.goToOption({focus:we.Previous});case Ne.Home:case Ne.PageUp:return U.preventDefault(),U.stopPropagation(),b.actions.goToOption({focus:we.First});case Ne.End:case Ne.PageDown:return U.preventDefault(),U.stopPropagation(),b.actions.goToOption({focus:we.Last});case Ne.Escape:U.preventDefault(),U.stopPropagation(),Ye.flushSync(()=>b.actions.closeListbox()),(me=b.state.buttonElement)==null||me.focus({preventScroll:!0});return;case Ne.Tab:U.preventDefault(),U.stopPropagation(),Ye.flushSync(()=>b.actions.closeListbox()),jy(b.state.buttonElement,U.shiftKey?fu.Previous:fu.Next);break;default:U.key.length===1&&(b.actions.search(U.key),X.setTimeout(()=>b.actions.clearSearch(),350));break}}),T=je(b,U=>{var me;return(me=U.buttonElement)==null?void 0:me.id}),R=kt({open:S===et.Open}),re=qo(v?ve():{},{id:s,ref:D,"aria-activedescendant":je(b,b.selectors.activeDescendantId),"aria-multiselectable":w.mode===Mn.Multi?!0:void 0,"aria-labelledby":T,"aria-orientation":w.orientation,onKeyDown:K,role:"listbox",tabIndex:S===et.Open?0:void 0,style:{...h.style,...ce,"--button-width":cu(A,C,!0).width},...Im(H)}),le=rt(),pe=y.useMemo(()=>w.mode===Mn.Multi?w:{...w,isSelected:z},[w,z]);return ye.createElement(ch,{enabled:c?n.static||A:!1,ownerDocument:L},ye.createElement(Hi.Provider,{value:pe},le({ourProps:re,theirProps:h,slot:R,defaultTag:nw,features:rw,visible:he,name:"Listbox.Options"})))}let lw="div";function iw(n,l){let o=y.useId(),{id:s=`headlessui-listbox-option-${o}`,disabled:a=!1,value:c,...f}=n,p=y.useContext(wh)===!0,h=rl("Listbox.Option"),v=Du("Listbox.Option"),x=je(v,J=>v.selectors.isActive(J,s)),E=h.isSelected(c),w=y.useRef(null),b=Y1(w),S=Dn({disabled:a,value:c,domRef:w,get textValue(){return b()}}),C=vt(l,w,J=>{J?h.listRef.current.set(s,J):h.listRef.current.delete(s)}),j=je(v,J=>v.selectors.shouldScrollIntoView(J,s));Le(()=>{if(j)return gt().requestAnimationFrame(()=>{var J,Q;(Q=(J=w.current)==null?void 0:J.scrollIntoView)==null||Q.call(J,{block:"nearest"})})},[j,w]),Le(()=>{if(!p)return v.actions.registerOption(s,S),()=>v.actions.unregisterOption(s)},[S,s,p]);let I=xe(J=>{if(a)return J.preventDefault();v.actions.selectOption(c)}),L=xe(()=>{if(a)return v.actions.goToOption({focus:we.Nothing});v.actions.goToOption({focus:we.Specific,id:s})}),P=Lm(),M=xe(J=>P.update(J)),A=xe(J=>{P.wasMoved(J)&&(a||x&&v.state.activationTrigger===bi.Pointer||v.actions.goToOption({focus:we.Specific,id:s},bi.Pointer))}),H=xe(J=>{P.wasMoved(J)&&(a||x&&v.state.activationTrigger===bi.Pointer&&v.actions.goToOption({focus:we.Nothing}))}),q=kt({active:x,focus:x,selected:E,disabled:a,selectedOption:E&&p}),ee=p?{}:{id:s,ref:C,role:"option",tabIndex:a===!0?void 0:-1,"aria-disabled":a===!0?!0:void 0,"aria-selected":E,disabled:void 0,onClick:I,onFocus:L,onPointerEnter:M,onMouseEnter:M,onPointerMove:A,onMouseMove:A,onPointerLeave:H,onMouseLeave:H},he=rt();return!E&&p?null:he({ourProps:ee,theirProps:f,slot:q,defaultTag:lw,name:"Listbox.Option"})}let sw=y.Fragment;function aw(n,l){let{options:o,placeholder:s,...a}=n,c={ref:vt(l)},f=rl("ListboxSelectedOption"),p=kt({}),h=f.value===void 0||f.value===null||f.mode===Mn.Multi&&Array.isArray(f.value)&&f.value.length===0,v=rt();return ye.createElement(wh.Provider,{value:!0},v({ourProps:c,theirProps:{...a,children:ye.createElement(ye.Fragment,null,s&&h?s:o)},slot:p,defaultTag:sw,name:"ListboxSelectedOption"}))}let uw=ot(Z1),cw=ot(tw),dw=gm,fw=ot(ow),pw=ot(iw),mw=ot(aw),an=Object.assign(uw,{Button:cw,Label:dw,Options:fw,Option:pw,SelectedOption:mw});const yi=43200,Ip=1440,Fp=Symbol.for("constructDateFrom");function Au(n,l){return typeof n=="function"?n(l):n&&typeof n=="object"&&Fp in n?n[Fp](l):n instanceof Date?new n.constructor(l):new Date(l)}function In(n,l){return Au(n,n)}let hw={};function gw(){return hw}function Dp(n){const l=In(n),o=new Date(Date.UTC(l.getFullYear(),l.getMonth(),l.getDate(),l.getHours(),l.getMinutes(),l.getSeconds(),l.getMilliseconds()));return o.setUTCFullYear(l.getFullYear()),+n-+o}function zu(n,...l){const o=Au.bind(null,n||l.find(s=>typeof s=="object"));return l.map(o)}function Si(n,l){const o=+In(n)-+In(l);return o<0?-1:o>0?1:o}function vw(n){return Au(n,Date.now())}function yw(n,l,o){const[s,a]=zu(o?.in,n,l),c=s.getFullYear()-a.getFullYear(),f=s.getMonth()-a.getMonth();return c*12+f}function xw(n){return l=>{const s=(n?Math[n]:Math.trunc)(l);return s===0?0:s}}function ww(n,l){return+In(n)-+In(l)}function bw(n,l){const o=In(n);return o.setHours(23,59,59,999),o}function Sw(n,l){const o=In(n),s=o.getMonth();return o.setFullYear(o.getFullYear(),s+1,0),o.setHours(23,59,59,999),o}function Ew(n,l){const o=In(n);return+bw(o)==+Sw(o)}function kw(n,l,o){const[s,a,c]=zu(o?.in,n,n,l),f=Si(a,c),p=Math.abs(yw(a,c));if(p<1)return 0;a.getMonth()===1&&a.getDate()>27&&a.setDate(30),a.setMonth(a.getMonth()-f*p);let h=Si(a,c)===-f;Ew(s)&&p===1&&Si(s,c)===1&&(h=!1);const v=f*(p-+h);return v===0?0:v}function Cw(n,l,o){const s=ww(n,l)/1e3;return xw(o?.roundingMethod)(s)}const Nw={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},jw=(n,l,o)=>{let s;const a=Nw[n];return typeof a=="string"?s=a:l===1?s=a.one:s=a.other.replace("{{count}}",l.toString()),o?.addSuffix?o.comparison&&o.comparison>0?"in "+s:s+" ago":s};function tu(n){return(l={})=>{const o=l.width?String(l.width):n.defaultWidth;return n.formats[o]||n.formats[n.defaultWidth]}}const Ow={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Pw={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Tw={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Rw={date:tu({formats:Ow,defaultWidth:"full"}),time:tu({formats:Pw,defaultWidth:"full"}),dateTime:tu({formats:Tw,defaultWidth:"full"})},$w={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Mw=(n,l,o,s)=>$w[n];function Fo(n){return(l,o)=>{const s=o?.context?String(o.context):"standalone";let a;if(s==="formatting"&&n.formattingValues){const f=n.defaultFormattingWidth||n.defaultWidth,p=o?.width?String(o.width):f;a=n.formattingValues[p]||n.formattingValues[f]}else{const f=n.defaultWidth,p=o?.width?String(o.width):n.defaultWidth;a=n.values[p]||n.values[f]}const c=n.argumentCallback?n.argumentCallback(l):l;return a[c]}}const _w={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Lw={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Iw={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Fw={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Dw={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Aw={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},zw=(n,l)=>{const o=Number(n),s=o%100;if(s>20||s<10)switch(s%10){case 1:return o+"st";case 2:return o+"nd";case 3:return o+"rd"}return o+"th"},Ww={ordinalNumber:zw,era:Fo({values:_w,defaultWidth:"wide"}),quarter:Fo({values:Lw,defaultWidth:"wide",argumentCallback:n=>n-1}),month:Fo({values:Iw,defaultWidth:"wide"}),day:Fo({values:Fw,defaultWidth:"wide"}),dayPeriod:Fo({values:Dw,defaultWidth:"wide",formattingValues:Aw,defaultFormattingWidth:"wide"})};function Do(n){return(l,o={})=>{const s=o.width,a=s&&n.matchPatterns[s]||n.matchPatterns[n.defaultMatchWidth],c=l.match(a);if(!c)return null;const f=c[0],p=s&&n.parsePatterns[s]||n.parsePatterns[n.defaultParseWidth],h=Array.isArray(p)?Vw(p,E=>E.test(f)):Hw(p,E=>E.test(f));let v;v=n.valueCallback?n.valueCallback(h):h,v=o.valueCallback?o.valueCallback(v):v;const x=l.slice(f.length);return{value:v,rest:x}}}function Hw(n,l){for(const o in n)if(Object.prototype.hasOwnProperty.call(n,o)&&l(n[o]))return o}function Vw(n,l){for(let o=0;o{const s=l.match(n.matchPattern);if(!s)return null;const a=s[0],c=l.match(n.parsePattern);if(!c)return null;let f=n.valueCallback?n.valueCallback(c[0]):c[0];f=o.valueCallback?o.valueCallback(f):f;const p=l.slice(a.length);return{value:f,rest:p}}}const Uw=/^(\d+)(th|st|nd|rd)?/i,Kw=/\d+/i,Qw={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Yw={any:[/^b/i,/^(a|c)/i]},Xw={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Gw={any:[/1/i,/2/i,/3/i,/4/i]},qw={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Jw={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Zw={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},eb={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},tb={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},nb={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},rb={ordinalNumber:Bw({matchPattern:Uw,parsePattern:Kw,valueCallback:n=>parseInt(n,10)}),era:Do({matchPatterns:Qw,defaultMatchWidth:"wide",parsePatterns:Yw,defaultParseWidth:"any"}),quarter:Do({matchPatterns:Xw,defaultMatchWidth:"wide",parsePatterns:Gw,defaultParseWidth:"any",valueCallback:n=>n+1}),month:Do({matchPatterns:qw,defaultMatchWidth:"wide",parsePatterns:Jw,defaultParseWidth:"any"}),day:Do({matchPatterns:Zw,defaultMatchWidth:"wide",parsePatterns:eb,defaultParseWidth:"any"}),dayPeriod:Do({matchPatterns:tb,defaultMatchWidth:"any",parsePatterns:nb,defaultParseWidth:"any"})},ob={code:"en-US",formatDistance:jw,formatLong:Rw,formatRelative:Mw,localize:Ww,match:rb,options:{weekStartsOn:0,firstWeekContainsDate:1}};function lb(n,l,o){const s=gw(),a=o?.locale??s.locale??ob,c=2520,f=Si(n,l);if(isNaN(f))throw new RangeError("Invalid time value");const p=Object.assign({},o,{addSuffix:o?.addSuffix,comparison:f}),[h,v]=zu(o?.in,...f>0?[l,n]:[n,l]),x=Cw(v,h),E=(Dp(v)-Dp(h))/1e3,w=Math.round((x-E)/60);let b;if(w<2)return o?.includeSeconds?x<5?a.formatDistance("lessThanXSeconds",5,p):x<10?a.formatDistance("lessThanXSeconds",10,p):x<20?a.formatDistance("lessThanXSeconds",20,p):x<40?a.formatDistance("halfAMinute",0,p):x<60?a.formatDistance("lessThanXMinutes",1,p):a.formatDistance("xMinutes",1,p):w===0?a.formatDistance("lessThanXMinutes",1,p):a.formatDistance("xMinutes",w,p);if(w<45)return a.formatDistance("xMinutes",w,p);if(w<90)return a.formatDistance("aboutXHours",1,p);if(w{Wp().then(Q=>s(Q.object_defs.map(z=>z.name))).catch(()=>{})},[]),y.useEffect(()=>{v(!0),ou(a||void 0,w,S).then(Q=>{l(Q.objects),E(Q.total)}).catch(Q=>p(Q.message)).finally(()=>v(!1))},[a,w,S]);const ee=Q=>{c(Q),C(0)},he=()=>{v(!0),ou(a||void 0,w,S).then(Q=>{l(Q.objects),E(Q.total)}).catch(Q=>p(Q.message)).finally(()=>v(!1))},J=async()=>{if(L){A(!0),q(null);try{const Q=await M0(L);q({ok:!0,text:`Created object #${Q.id} (${Q.type})`}),I(!1),P(""),he(),setTimeout(()=>q(null),3e3)}catch(Q){q({ok:!1,text:Q.message||"Failed to create object"})}finally{A(!1)}}};return h?m.jsx($t,{}):f?m.jsxs("div",{className:"text-red-500",children:["Error: ",f]}):m.jsxs("div",{className:"max-w-6xl mx-auto",children:[m.jsxs("div",{className:"flex items-center justify-between mb-6",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("h2",{className:"text-2xl font-bold",children:"Objects"}),j?m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("select",{value:L,onChange:Q=>P(Q.target.value),className:"px-3 py-1.5 bg-gray-800 border border-gray-700 rounded-lg text-sm text-gray-100 focus:border-blue-500 focus:outline-none",children:o.map(Q=>m.jsx("option",{value:Q,children:Q},Q))}),m.jsx("button",{onClick:J,disabled:M||!L,className:"px-3 py-1.5 bg-blue-600 hover:bg-blue-500 disabled:bg-gray-700 text-white text-sm rounded-lg transition-colors",children:M?"...":"✓"}),m.jsx("button",{onClick:()=>{I(!1),q(null)},className:"px-3 py-1.5 bg-gray-700 hover:bg-gray-600 text-gray-300 text-sm rounded-lg transition-colors",children:"✕"})]}):m.jsx("button",{onClick:()=>{I(!0),P(o[0]||"")},className:"px-3 py-1.5 bg-green-600 hover:bg-green-500 text-white text-sm rounded-lg transition-colors",disabled:o.length===0,children:"+ Create"}),H&&m.jsx("span",{className:`text-sm ${H.ok?"text-green-400":"text-red-400"}`,children:H.text})]}),m.jsx(an,{value:a,onChange:ee,children:m.jsxs("div",{className:"relative w-64",children:[m.jsxs(an.Button,{className:"w-full px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg text-left focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 transition-all",children:[m.jsx("span",{className:a?"text-gray-100":"text-gray-500",children:a||"All Types"}),m.jsx("span",{className:"absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none",children:m.jsx("svg",{className:"h-5 w-5 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:m.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),m.jsxs(an.Options,{className:"absolute z-10 mt-1 w-full bg-gray-800 border border-gray-700 rounded-lg shadow-lg max-h-60 overflow-auto focus:outline-none",children:[m.jsx(an.Option,{value:"",className:({active:Q})=>`cursor-pointer select-none px-4 py-2 transition-colors ${Q?"bg-blue-600 text-white":"text-gray-100"}`,children:({selected:Q})=>m.jsx("span",{className:Q?"font-semibold":"font-normal",children:"All Types"})}),o.map(Q=>m.jsx(an.Option,{value:Q,className:({active:z})=>`cursor-pointer select-none px-4 py-2 transition-colors ${z?"bg-blue-600 text-white":"text-gray-100"}`,children:({selected:z})=>m.jsx("span",{className:z?"font-semibold":"font-normal",children:Q})},Q))]})]})})]}),m.jsxs("div",{className:"bg-gray-900/50 backdrop-blur rounded-lg overflow-hidden border border-gray-800",children:[n.length===0?m.jsx(fn,{message:"No objects found"}):m.jsxs("table",{className:"w-full",children:[m.jsx("thead",{className:"bg-gray-800/80 border-b border-gray-700",children:m.jsxs("tr",{children:[m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"ID"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Type"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Created"})]})}),m.jsx("tbody",{className:"divide-y divide-gray-800",children:n.map((Q,z)=>m.jsxs("tr",{className:`transition-colors ${z%2===0?"bg-gray-900/30":"bg-gray-850/30"} hover:bg-gray-800/60`,children:[m.jsx("td",{className:"px-4 py-3 font-mono text-sm text-gray-300",children:Q.id}),m.jsx("td",{className:"px-4 py-3 text-gray-100",children:m.jsx("span",{className:"inline-block px-2 py-1 bg-blue-900/30 text-blue-300 rounded text-sm",children:Q.type})}),m.jsx("td",{className:"px-4 py-3 text-sm text-gray-400",children:ur(Q.created_at)})]},z))})]}),m.jsx(Vr,{total:x,limit:w,offset:S,onPageChange:C,onLimitChange:b})]})]})}function ab({eventDef:n,onClose:l,onSuccess:o}){const s=n.schema?.properties||{},a=Object.keys(s),[c,f]=y.useState(()=>{const C={};for(const[j,I]of Object.entries(s))I.type==="boolean"?C[j]=!1:(I.type==="number"||I.type,C[j]="");return C}),[p,h]=y.useState(!1),[v,x]=y.useState(""),[E,w]=y.useState(null),b=async C=>{C.preventDefault(),h(!0),x(""),w(null);try{const j={};for(const[L,P]of Object.entries(s)){const M=c[L];P.type==="number"||P.type==="ref"?j[L]=M===""?0:Number(M):P.type==="boolean"?j[L]=!!M:j[L]=String(M)}const I=await W0(n.name,j);w({eventId:I.event?.id??"?",reactionsFired:I.reactions_fired??0}),setTimeout(()=>{o(),l()},2e3)}catch(j){x(j.message||"Failed to emit event")}finally{h(!1)}},S=(C,j)=>{if(j.type==="boolean")return m.jsxs("label",{className:"flex items-center gap-3 py-2",children:[m.jsx("input",{type:"checkbox",checked:!!c[C],onChange:P=>f(M=>({...M,[C]:P.target.checked})),className:"w-4 h-4 rounded border-gray-600 bg-gray-800 text-blue-500 focus:ring-blue-500 focus:ring-offset-0"}),m.jsx("span",{className:"text-sm text-gray-200 font-mono",children:C})]},C);const I=j.type==="number"||j.type==="ref",L=j.type==="ref"?`${C} (Object ID)`:C;return m.jsxs("div",{className:"space-y-1",children:[m.jsx("label",{className:"block text-sm text-gray-300 font-mono",children:L}),m.jsx("input",{type:I?"number":"text",value:c[C],onChange:P=>f(M=>({...M,[C]:P.target.value})),className:"w-full px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-gray-100 text-sm font-mono placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:j.type==="ref"?"Enter object ID":`Enter ${j.type}`})]},C)};return m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:l,children:m.jsxs("div",{className:"bg-gray-900 border border-gray-700 rounded-xl shadow-2xl w-full max-w-md mx-4",onClick:C=>C.stopPropagation(),children:[m.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-800",children:[m.jsxs("h3",{className:"text-lg font-semibold text-gray-100",children:["Emit ",m.jsx("span",{className:"text-blue-400 font-mono",children:n.name})]}),m.jsx("button",{onClick:l,className:"text-gray-400 hover:text-gray-200 transition-colors",children:m.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),m.jsxs("form",{onSubmit:b,className:"px-6 py-4 space-y-4",children:[a.length===0?m.jsx("p",{className:"text-sm text-gray-500 italic",children:"No payload fields — event will be emitted with empty payload."}):a.map(C=>S(C,s[C])),E&&m.jsxs("div",{className:"p-3 bg-green-900/40 border border-green-700 rounded-lg text-sm text-green-300",children:["✓ Event ",m.jsx("span",{className:"font-mono font-bold",children:E.eventId})," emitted",E.reactionsFired>0&&m.jsxs("span",{children:[" — ",E.reactionsFired," reaction",E.reactionsFired>1?"s":""," fired"]})]}),v&&m.jsxs("div",{className:"p-3 bg-red-900/40 border border-red-700 rounded-lg text-sm text-red-300",children:["✗ ",v]}),m.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[m.jsx("button",{type:"button",onClick:l,className:"px-4 py-2 text-sm text-gray-400 hover:text-gray-200 transition-colors",children:"Cancel"}),m.jsxs("button",{type:"submit",disabled:p||!!E,className:"px-4 py-2 bg-blue-600 hover:bg-blue-500 disabled:bg-blue-800 disabled:cursor-not-allowed text-white text-sm font-medium rounded-lg transition-colors flex items-center gap-2",children:[p&&m.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white/30 border-t-white"}),p?"Emitting…":"▶ Emit"]})]})]})]})})}function ub(){const[n,l]=y.useState([]),[o,s]=y.useState(new Set),[a,c]=y.useState(""),[f,p]=y.useState(!0),[h,v]=y.useState(null),x=()=>{p(!0),_0().then(w=>l(w.event_defs)).catch(w=>c(w.message)).finally(()=>p(!1))};y.useEffect(()=>{x()},[]);const E=w=>{s(b=>{const S=new Set(b);return S.has(w)?S.delete(w):S.add(w),S})};return f?m.jsx($t,{}):a?m.jsxs("div",{className:"text-red-500 text-center p-8",children:["Error: ",a]}):m.jsxs("div",{className:"max-w-6xl mx-auto",children:[m.jsx("h2",{className:"text-2xl font-bold mb-6",children:"Event Definitions"}),m.jsx("div",{className:"bg-gray-900/50 backdrop-blur rounded-lg overflow-hidden border border-gray-800",children:n.length===0?m.jsx(fn,{message:"No event definitions found"}):m.jsxs("table",{className:"w-full",children:[m.jsx("thead",{className:"bg-gray-800/80 border-b border-gray-700",children:m.jsxs("tr",{children:[m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Name"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Hash"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Parent"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Schema"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Actions"})]})}),m.jsx("tbody",{className:"divide-y divide-gray-800",children:n.map((w,b)=>m.jsxs("tr",{className:`transition-colors ${b%2===0?"bg-gray-900/30":"bg-gray-850/30"} hover:bg-gray-800/60`,children:[m.jsx("td",{className:"px-4 py-3 font-mono text-gray-100",children:w.name}),m.jsx("td",{className:"px-4 py-3",children:m.jsx(lr,{hash:w.hash})}),m.jsx("td",{className:"px-4 py-3",children:w.parent_hash?m.jsx(lr,{hash:w.parent_hash}):m.jsx("span",{className:"text-gray-600",children:"-"})}),m.jsxs("td",{className:"px-4 py-3",children:[m.jsx("button",{onClick:()=>E(w.hash),className:"text-blue-400 hover:text-blue-300 text-sm font-medium transition-colors",children:o.has(w.hash)?"Hide":"Show"}),o.has(w.hash)&&m.jsx("pre",{className:"mt-2 p-3 bg-gray-950 rounded-lg text-xs overflow-x-auto border border-gray-800",children:JSON.stringify(w.schema,null,2).split(`
+`).map((S,C)=>{if(S.includes(":")){const[j,...I]=S.split(":");return m.jsxs("div",{children:[m.jsxs("span",{className:"text-blue-400",children:[j,":"]}),m.jsx("span",{className:"text-green-300",children:I.join(":")})]},C)}return m.jsx("div",{className:"text-gray-300",children:S},C)})})]}),m.jsx("td",{className:"px-4 py-3",children:m.jsx("button",{onClick:()=>v({name:w.name,schema:w.schema}),className:"px-3 py-1.5 bg-green-700/30 hover:bg-green-600/40 text-green-300 hover:text-green-200 border border-green-700/50 rounded-lg text-sm font-medium transition-colors",children:"▶ Emit"})})]},b))})]})}),h&&m.jsx(ab,{eventDef:h,onClose:()=>v(null),onSuccess:()=>{}})]})}function cb(){const[n,l]=y.useState([]),[o,s]=y.useState(new Set),[a,c]=y.useState(""),[f,p]=y.useState(""),[h,v]=y.useState(!0),[x,E]=y.useState(0),[w,b]=y.useState(50),[S,C]=y.useState(0),j=()=>{v(!0),L0(a||void 0,w,S).then(P=>{l(P.events),E(P.total)}).catch(P=>p(P.message)).finally(()=>v(!1))};y.useEffect(()=>{j()},[w,S]);const I=()=>{C(0),j()},L=P=>{s(M=>{const A=new Set(M);return A.has(P)?A.delete(P):A.add(P),A})};return h?m.jsx($t,{}):f?m.jsxs("div",{className:"text-red-500",children:["Error: ",f]}):m.jsxs("div",{className:"max-w-6xl mx-auto",children:[m.jsxs("div",{className:"flex items-center justify-between mb-6",children:[m.jsx("h2",{className:"text-2xl font-bold",children:"Events"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx("input",{type:"text",className:"px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 transition-all",placeholder:"Filter by ref...",value:a,onChange:P=>c(P.target.value)}),m.jsx("button",{onClick:I,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 rounded-lg font-semibold transition-all shadow-lg shadow-blue-500/20 hover:shadow-blue-500/40",children:"Search"})]})]}),m.jsxs("div",{className:"bg-gray-900/50 backdrop-blur rounded-lg overflow-hidden border border-gray-800",children:[n.length===0?m.jsx(fn,{message:"No events yet"}):m.jsxs("table",{className:"w-full",children:[m.jsx("thead",{className:"bg-gray-800/80 border-b border-gray-700",children:m.jsxs("tr",{children:[m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"ID"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Type Hash"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Created"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Payload"})]})}),m.jsx("tbody",{className:"divide-y divide-gray-800",children:n.map((P,M)=>m.jsxs("tr",{className:`transition-colors ${M%2===0?"bg-gray-900/30":"bg-gray-850/30"} hover:bg-gray-800/60`,children:[m.jsx("td",{className:"px-4 py-3 font-mono text-sm text-gray-300",children:P.id}),m.jsx("td",{className:"px-4 py-3",children:m.jsx(lr,{hash:P.type_hash})}),m.jsx("td",{className:"px-4 py-3 text-sm text-gray-400",children:ur(P.created_at)}),m.jsxs("td",{className:"px-4 py-3",children:[m.jsx("button",{onClick:()=>L(P.id),className:"text-blue-400 hover:text-blue-300 text-sm font-medium transition-colors",children:o.has(P.id)?"Hide":"Show"}),o.has(P.id)&&m.jsx("pre",{className:"mt-2 p-3 bg-gray-950 rounded-lg text-xs overflow-x-auto border border-gray-800",children:JSON.stringify(P.payload,null,2).split(`
+`).map((A,H)=>{if(A.includes(":")){const[q,...ee]=A.split(":");return m.jsxs("div",{children:[m.jsxs("span",{className:"text-blue-400",children:[q,":"]}),m.jsx("span",{className:"text-green-300",children:ee.join(":")})]},H)}return m.jsx("div",{className:"text-gray-300",children:A},H)})})]})]},M))})]}),m.jsx(Vr,{total:x,limit:w,offset:S,onPageChange:C,onLimitChange:b})]})]})}function db(){const[n,l]=y.useState([]),[o,s]=y.useState(new Set),[a,c]=y.useState(""),[f,p]=y.useState(!0);y.useEffect(()=>{Hp().then(v=>l(v.projection_defs)).catch(v=>c(v.message)).finally(()=>p(!1))},[]);const h=v=>{s(x=>{const E=new Set(x);return E.has(v)?E.delete(v):E.add(v),E})};return f?m.jsx($t,{}):a?m.jsxs("div",{className:"text-red-500 text-center p-8",children:["Error: ",a]}):m.jsxs("div",{className:"max-w-5xl mx-auto",children:[m.jsx("h2",{className:"text-2xl font-bold mb-6",children:"Projection Definitions"}),n.length===0?m.jsx(fn,{message:"No projection definitions found"}):m.jsx("div",{className:"space-y-4",children:n.map((v,x)=>m.jsxs("div",{className:"bg-gray-900/50 backdrop-blur rounded-lg p-5 border border-gray-800 hover:border-gray-700 transition-colors",children:[m.jsxs("div",{className:"flex items-start justify-between mb-3",children:[m.jsxs("div",{children:[m.jsx("h3",{className:"font-mono text-lg text-gray-100",children:v.name}),m.jsx("div",{className:"mt-1",children:m.jsx(lr,{hash:v.hash||"unknown",short:!1})})]}),m.jsx("button",{onClick:()=>h(v.hash||x),className:"text-blue-400 hover:text-blue-300 text-sm font-medium transition-colors",children:o.has(v.hash||x)?"Hide Details":"Show Details"})]}),o.has(v.hash||x)&&m.jsxs("div",{className:"mt-4 space-y-3 text-sm bg-gray-800/30 rounded-lg p-4 border border-gray-700/50",children:[v.sources&&m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-400 font-medium",children:"Sources:"}),m.jsx("div",{className:"mt-2 space-y-3",children:v.sources.map((E,w)=>m.jsxs("div",{className:"pl-3 border-l-2 border-gray-600",children:[m.jsx("div",{className:"text-gray-200 font-mono text-xs",children:E.event_def_hash}),m.jsxs("div",{className:"mt-1",children:[m.jsx("span",{className:"text-gray-500 text-xs",children:"bindings:"})," ",m.jsx("span",{className:"text-yellow-400 text-xs",children:JSON.stringify(E.bindings)})]}),m.jsxs("div",{className:"mt-0.5",children:[m.jsx("span",{className:"text-gray-500 text-xs",children:"expression:"})," ",m.jsx("code",{className:"text-green-400 text-xs",children:E.expression})]})]},w))})]}),v.params&&m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-400 font-medium",children:"Params:"}),m.jsx("pre",{className:"mt-1.5 p-3 bg-gray-950 rounded-lg text-xs overflow-x-auto border border-gray-800",children:JSON.stringify(v.params,null,2).split(`
+`).map((E,w)=>{if(E.includes(":")){const[b,...S]=E.split(":");return m.jsxs("div",{children:[m.jsxs("span",{className:"text-blue-400",children:[b,":"]}),m.jsx("span",{className:"text-green-300",children:S.join(":")})]},w)}return m.jsx("div",{className:"text-gray-300",children:E},w)})})]}),v.value_schema&&m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-400 font-medium",children:"Value Schema:"}),m.jsx("pre",{className:"mt-1.5 p-3 bg-gray-950 rounded-lg text-xs overflow-x-auto border border-gray-800 text-purple-300",children:JSON.stringify(v.value_schema,null,2)})]}),v.initial_value!==void 0&&m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-400 font-medium",children:"Initial Value:"}),m.jsx("pre",{className:"mt-1.5 p-3 bg-gray-950 rounded-lg text-xs overflow-x-auto border border-gray-800 text-blue-300",children:JSON.stringify(v.initial_value,null,2)})]})]})]},x))})]})}function fb(){const[n,l]=y.useState([]),[o,s]=y.useState(null),[a,c]=y.useState({}),[f,p]=y.useState([]),[h,v]=y.useState(null),[x,E]=y.useState(""),[w,b]=y.useState(!1),[S,C]=y.useState(!0);y.useEffect(()=>{Promise.all([Hp(),ou()]).then(([P,M])=>{l(P.projection_defs),p(M.objects.map(A=>({...A,id:String(A.id)})))}).catch(()=>{}).finally(()=>C(!1))},[]);const j=P=>{if(s(P),v(null),E(""),P){const M={};for(const A of Object.keys(P.params))M[A]="";c(M)}else c({})},I=async()=>{if(!o)return;b(!0),E(""),v(null);const P=new URLSearchParams;for(const[M,A]of Object.entries(a))A.trim()&&P.set(M,A.trim());try{const M=await nt(`/projections/${o.name}?${P.toString()}`);v(M.value)}catch(M){E(M.message)}finally{b(!1)}},L=y.useMemo(()=>{const P={};for(const M of f)P[M.type]||(P[M.type]=[]),P[M.type].push(String(M.id));return P},[f]);return S?m.jsx($t,{}):m.jsxs("div",{className:"max-w-4xl mx-auto",children:[m.jsx("h2",{className:"text-2xl font-bold mb-6",children:"Query Projections"}),m.jsxs("div",{className:"bg-gray-900/50 backdrop-blur rounded-lg p-6 space-y-6 border border-gray-800",children:[m.jsxs("div",{children:[m.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Projection"}),m.jsx(an,{value:o,onChange:j,children:m.jsxs("div",{className:"relative",children:[m.jsxs(an.Button,{className:"w-full px-4 py-2.5 bg-gray-800 border border-gray-700 rounded-lg text-left focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 transition-all",children:[m.jsx("span",{className:o?"text-gray-100":"text-gray-500",children:o?.name||"Select a projection..."}),m.jsx("span",{className:"absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none",children:m.jsx("svg",{className:"h-5 w-5 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:m.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),m.jsx(an.Options,{className:"absolute z-10 mt-1 w-full bg-gray-800 border border-gray-700 rounded-lg shadow-lg max-h-60 overflow-auto focus:outline-none",children:n.map(P=>m.jsx(an.Option,{value:P,className:({active:M})=>`cursor-pointer select-none px-4 py-2.5 transition-colors ${M?"bg-blue-600 text-white":"text-gray-100"}`,children:({selected:M})=>m.jsx("span",{className:M?"font-semibold":"font-normal",children:P.name})},P.name))})]})})]}),o&&m.jsxs("div",{className:"space-y-4",children:[m.jsxs("div",{className:"flex items-baseline gap-2",children:[m.jsx("label",{className:"block text-sm font-medium text-gray-400",children:"Parameters"}),m.jsxs("span",{className:"text-xs text-gray-600",children:["→ ",o.value_schema?.type||"any",o.initial_value!==void 0&&m.jsxs("span",{className:"ml-1",children:["(initial: ",JSON.stringify(o.initial_value),")"]})]})]}),m.jsx("div",{className:"space-y-3 bg-gray-800/30 rounded-lg p-4 border border-gray-700/50",children:Object.entries(o.params).map(([P,M])=>m.jsxs("div",{children:[m.jsxs("label",{className:"block text-xs font-medium text-gray-500 mb-1.5",children:[P,m.jsxs("span",{className:"ml-2 px-1.5 py-0.5 bg-gray-700 rounded text-xs text-gray-400",children:[M.type,M.object_type?` → ${M.object_type}`:""]})]}),M.type==="ref"?m.jsx(pb,{value:a[P]||"",onChange:A=>c({...a,[P]:A}),objects:f,objectsByType:L,objectType:M.object_type}):m.jsx("input",{type:M.type==="number"?"number":"text",className:"w-full px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 transition-all",placeholder:`Enter ${M.type} value...`,value:a[P]||"",onChange:A=>c({...a,[P]:A.target.value})})]},P))})]}),o&&m.jsx("div",{className:"text-xs space-y-2 bg-gray-800/20 rounded-lg p-4 border border-gray-700/30",children:m.jsxs("div",{children:[m.jsx("span",{className:"text-gray-500 font-medium",children:"sources:"}),m.jsx("div",{className:"mt-1 space-y-2",children:o.sources?.map((P,M)=>m.jsxs("div",{className:"pl-3 border-l border-gray-700",children:[m.jsx("div",{className:"flex items-center gap-2",children:m.jsx(lr,{hash:P.event_def_hash,short:!1})}),m.jsxs("div",{className:"text-xs mt-1",children:[m.jsx("span",{className:"text-gray-500",children:"bindings:"})," ",Object.keys(P.bindings).length===0?m.jsx("span",{className:"text-gray-500 italic",children:"none"}):m.jsx("span",{className:"text-yellow-400",children:Object.entries(P.bindings).map(([A,H])=>`${A}=${H}`).join(", ")})]}),m.jsxs("div",{className:"text-xs mt-0.5",children:[m.jsx("span",{className:"text-gray-500",children:"expression:"})," ",m.jsx("code",{className:"text-green-400",children:P.expression})]})]},M))})]})}),m.jsx("button",{onClick:I,disabled:!o||w,className:"w-full px-4 py-3 bg-blue-600 hover:bg-blue-700 rounded-lg font-semibold disabled:opacity-50 disabled:cursor-not-allowed transition-all shadow-lg shadow-blue-500/20 hover:shadow-blue-500/40",children:w?"Querying...":"Query Projection"}),x&&m.jsx("div",{className:"p-4 bg-red-900/20 border border-red-800 rounded-lg text-red-400 text-sm",children:x}),h!==null&&m.jsxs("div",{children:[m.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-2",children:"Result"}),m.jsx("pre",{className:"p-4 bg-gray-950 rounded-lg overflow-x-auto text-sm text-green-300 border border-gray-800",children:JSON.stringify(h,null,2)})]})]})]})}function pb({value:n,onChange:l,objects:o,objectsByType:s,objectType:a}){const[c,f]=y.useState(""),p=y.useMemo(()=>a?o.filter(x=>x.type===a):o,[o,a]),h=y.useMemo(()=>{if(!a)return s;const x={};return s[a]&&(x[a]=s[a]),x},[s,a]),v=y.useMemo(()=>{if(!c)return p;const x=c.toLowerCase();return p.filter(E=>String(E.id).toLowerCase().includes(x)||E.type.toLowerCase().includes(x))},[p,c]);return m.jsx(Io,{value:n,onChange:x=>l(x||""),children:m.jsxs("div",{className:"relative",children:[m.jsxs("div",{className:"relative",children:[m.jsx(Io.Input,{className:"w-full px-3 py-2 pr-10 bg-gray-800 border border-gray-700 rounded-lg focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 transition-all",placeholder:"Type object ID or select...",onChange:x=>f(x.target.value),displayValue:x=>x}),m.jsx(Io.Button,{className:"absolute inset-y-0 right-0 flex items-center pr-3",children:m.jsx("svg",{className:"h-5 w-5 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:m.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),m.jsxs(Io.Options,{className:"absolute z-10 mt-1 w-full bg-gray-800 border border-gray-700 rounded-lg shadow-lg max-h-60 overflow-auto focus:outline-none",children:[Object.entries(h).map(([x,E])=>{const w=E.filter(b=>!c||b.toLowerCase().includes(c.toLowerCase()));return w.length===0?null:m.jsxs("div",{children:[m.jsx("div",{className:"sticky top-0 px-3 py-1.5 text-xs font-medium text-gray-500 bg-gray-850 border-b border-gray-700",children:x}),w.map(b=>m.jsx(Io.Option,{value:b,className:({active:S})=>`cursor-pointer select-none px-3 py-2 text-sm transition-colors ${S?"bg-blue-600 text-white":"text-gray-100"}`,children:({selected:S})=>m.jsx("span",{className:S?"font-semibold":"font-normal",children:b})},b))]},x)}),v.length===0&&m.jsx("div",{className:"px-3 py-2 text-sm text-gray-500",children:"No objects found"})]})]})})}function mb(){const[n,l]=y.useState([]),[o,s]=y.useState(""),[a,c]=y.useState(!0),[f,p]=y.useState(0),[h,v]=y.useState(50),[x,E]=y.useState(0),w=()=>{c(!0),I0(h,x).then(S=>{l(S.reactions),p(S.total)}).catch(S=>s(S.message)).finally(()=>c(!1))};y.useEffect(()=>{w()},[h,x]);const b=async S=>{if(confirm("Delete this reaction?"))try{await F0(S),w()}catch(C){s(C.message)}};return a?m.jsx($t,{}):o?m.jsxs("div",{className:"text-red-500 text-center p-8",children:["Error: ",o]}):m.jsxs("div",{className:"max-w-7xl mx-auto",children:[m.jsx("h2",{className:"text-2xl font-bold mb-6",children:"Reactions"}),m.jsxs("div",{className:"bg-gray-900/50 backdrop-blur rounded-lg overflow-hidden border border-gray-800",children:[n.length===0?m.jsx(fn,{message:"No reactions found"}):m.jsxs("table",{className:"w-full",children:[m.jsx("thead",{className:"bg-gray-800/80 border-b border-gray-700",children:m.jsxs("tr",{children:[m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"ID"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Projection Def"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Params Hash"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Action"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Target"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Created"}),m.jsx("th",{className:"px-4 py-3"})]})}),m.jsx("tbody",{className:"divide-y divide-gray-800",children:n.map((S,C)=>m.jsxs("tr",{className:`transition-colors ${C%2===0?"bg-gray-900/30":"bg-gray-850/30"} hover:bg-gray-800/60`,children:[m.jsx("td",{className:"px-4 py-3 font-mono text-sm text-gray-300",children:S.id}),m.jsx("td",{className:"px-4 py-3",children:m.jsx(lr,{hash:S.projection_def_hash||"unknown"})}),m.jsx("td",{className:"px-4 py-3",children:m.jsx(lr,{hash:S.params_hash||"unknown"})}),m.jsx("td",{className:"px-4 py-3",children:m.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${S.action==="emit_event"?"bg-purple-500/20 text-purple-300 border border-purple-500/30":"bg-blue-500/20 text-blue-300 border border-blue-500/30"}`,children:S.action||"webhook"})}),m.jsx("td",{className:"px-4 py-3 text-sm truncate max-w-xs font-mono",children:S.action==="emit_event"?m.jsxs("div",{children:[m.jsxs("span",{className:"text-purple-400",children:["→ ",S.emit_event_type]}),S.emit_payload_template&&m.jsxs("div",{className:"text-gray-500 text-xs mt-1 truncate",children:["template: ",m.jsx("code",{className:"text-green-400",children:S.emit_payload_template})]})]}):m.jsx("span",{className:"text-blue-400",children:S.webhook_url})}),m.jsx("td",{className:"px-4 py-3 text-sm text-gray-400",children:ur(S.created_at)}),m.jsx("td",{className:"px-4 py-3",children:m.jsx("button",{onClick:()=>b(S.id),className:"px-3 py-1.5 bg-red-600 hover:bg-red-700 rounded text-sm font-medium transition-colors shadow-lg shadow-red-500/20 hover:shadow-red-500/40",children:"Delete"})})]},C))})]}),m.jsx(Vr,{total:f,limit:h,offset:x,onPageChange:E,onLimitChange:v})]})]})}function hb(){const[n,l]=y.useState([]),[o,s]=y.useState(""),[a,c]=y.useState(!0),[f,p]=y.useState(0),[h,v]=y.useState(50),[x,E]=y.useState(0),[w,b]=y.useState(""),[S,C]=y.useState(""),[j,I]=y.useState(""),[L,P]=y.useState(!1),[M,A]=y.useState(""),[H,q]=y.useState(!1),ee=()=>{c(!0),D0(h,x).then(z=>{l(z.api_keys),p(z.total)}).catch(z=>s(z.message)).finally(()=>c(!1))};y.useEffect(()=>{ee()},[h,x]);const he=async()=>{if(w.trim()){P(!0);try{const z={name:w.trim()};S.trim()&&(z.allowed_events=S.split(",").map(ue=>ue.trim()).filter(Boolean)),j.trim()&&(z.rate_limit=parseInt(j,10));const ae=await A0(z);A(ae.plaintext_key),q(!1),b(""),C(""),I(""),ee()}catch(z){s(z.message)}finally{P(!1)}}},J=async z=>{if(confirm("Delete this API key?"))try{await z0(z),ee()}catch(ae){s(ae.message)}},Q=()=>{navigator.clipboard.writeText(M),q(!0)};return a?m.jsx($t,{}):o?m.jsxs("div",{className:"text-red-500 text-center p-8",children:["Error: ",o]}):m.jsxs("div",{className:"max-w-7xl mx-auto",children:[m.jsx("h2",{className:"text-2xl font-bold mb-6",children:"API Keys"}),M&&m.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50",children:m.jsxs("div",{className:"bg-gray-900 border border-gray-700 rounded-xl p-6 max-w-lg w-full mx-4 shadow-2xl",children:[m.jsx("h3",{className:"text-lg font-bold text-yellow-400 mb-2",children:"Save your API key"}),m.jsx("p",{className:"text-sm text-gray-400 mb-4",children:"This key will only be shown once. Copy it now and store it securely."}),m.jsx("div",{className:"bg-gray-800 rounded-lg p-3 font-mono text-sm text-green-400 break-all mb-4",children:M}),m.jsxs("div",{className:"flex gap-3 justify-end",children:[m.jsx("button",{onClick:Q,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 rounded-lg text-sm font-medium transition-colors",children:H?"Copied!":"Copy"}),m.jsx("button",{onClick:()=>A(""),className:"px-4 py-2 bg-gray-700 hover:bg-gray-600 rounded-lg text-sm font-medium transition-colors",children:"Close"})]})]})}),m.jsx("div",{className:"bg-gray-900/50 backdrop-blur rounded-lg border border-gray-800 p-4 mb-6",children:m.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[m.jsxs("div",{children:[m.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Name"}),m.jsx("input",{type:"text",value:w,onChange:z=>b(z.target.value),placeholder:"my-service",className:"px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),m.jsxs("div",{children:[m.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Allowed Events (comma-separated)"}),m.jsx("input",{type:"text",value:S,onChange:z=>C(z.target.value),placeholder:"order.created, user.signed_up",className:"px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 w-64"})]}),m.jsxs("div",{children:[m.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Rate Limit"}),m.jsx("input",{type:"number",value:j,onChange:z=>I(z.target.value),placeholder:"1000",className:"px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 w-24"})]}),m.jsx("button",{onClick:he,disabled:L||!w.trim(),className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 rounded-lg text-sm font-medium transition-colors shadow-lg shadow-blue-500/20",children:L?"Creating...":"Create"})]})}),m.jsxs("div",{className:"bg-gray-900/50 backdrop-blur rounded-lg overflow-hidden border border-gray-800",children:[n.length===0?m.jsx(fn,{message:"No API keys found"}):m.jsxs("table",{className:"w-full",children:[m.jsx("thead",{className:"bg-gray-800/80 border-b border-gray-700",children:m.jsxs("tr",{children:[m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"ID"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Name"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Allowed Events"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Rate Limit"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Last Used"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Created"}),m.jsx("th",{className:"px-4 py-3"})]})}),m.jsx("tbody",{className:"divide-y divide-gray-800",children:n.map((z,ae)=>m.jsxs("tr",{className:`transition-colors ${ae%2===0?"bg-gray-900/30":"bg-gray-850/30"} hover:bg-gray-800/60`,children:[m.jsx("td",{className:"px-4 py-3 font-mono text-sm text-gray-300",children:z.id}),m.jsx("td",{className:"px-4 py-3 text-sm text-gray-200 font-medium",children:z.name}),m.jsx("td",{className:"px-4 py-3",children:m.jsx("div",{className:"flex flex-wrap gap-1",children:z.allowed_events&&z.allowed_events.length>0?z.allowed_events.map((ue,G)=>m.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-blue-500/20 text-blue-300 border border-blue-500/30",children:ue},G)):m.jsx("span",{className:"text-gray-500 text-xs",children:"all"})})}),m.jsx("td",{className:"px-4 py-3 text-sm text-gray-400 font-mono",children:z.rate_limit??"—"}),m.jsx("td",{className:"px-4 py-3 text-sm text-gray-400",children:z.last_used_at?ur(z.last_used_at):"—"}),m.jsx("td",{className:"px-4 py-3 text-sm text-gray-400",children:ur(z.created_at)}),m.jsx("td",{className:"px-4 py-3",children:m.jsx("button",{onClick:()=>J(z.id),className:"px-3 py-1.5 bg-red-600 hover:bg-red-700 rounded text-sm font-medium transition-colors shadow-lg shadow-red-500/20 hover:shadow-red-500/40",children:"Delete"})})]},z.id))})]}),m.jsx(Vr,{total:f,limit:h,offset:x,onPageChange:E,onLimitChange:v})]})]})}function gb({status:n}){const l={success:"bg-green-500/20 text-green-300 border-green-500/30",failed:"bg-red-500/20 text-red-300 border-red-500/30",skipped:"bg-gray-500/20 text-gray-400 border-gray-500/30"};return m.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium border ${l[n]||l.skipped}`,children:n})}function nu(n,l=60){if(n==null)return"—";const o=typeof n=="string"?n:JSON.stringify(n);return o.length>l?o.slice(0,l)+"...":o}function vb(){const[n,l]=y.useState([]),[o,s]=y.useState(""),[a,c]=y.useState(!0),[f,p]=y.useState(0),[h,v]=y.useState(50),[x,E]=y.useState(0),[w,b]=y.useState(""),[S,C]=y.useState(new Set),j=()=>{c(!0);const L=w.trim()?parseInt(w,10):void 0;H0(h,x,L).then(P=>{l(P.reaction_logs),p(P.total)}).catch(P=>s(P.message)).finally(()=>c(!1))};y.useEffect(()=>{j()},[h,x]);const I=L=>{C(P=>{const M=new Set(P);return M.has(L)?M.delete(L):M.add(L),M})};return a?m.jsx($t,{}):o?m.jsxs("div",{className:"text-red-500 text-center p-8",children:["Error: ",o]}):m.jsxs("div",{className:"max-w-7xl mx-auto",children:[m.jsx("h2",{className:"text-2xl font-bold mb-6",children:"Reaction Logs"}),m.jsx("div",{className:"bg-gray-900/50 backdrop-blur rounded-lg border border-gray-800 p-4 mb-6",children:m.jsxs("div",{className:"flex items-end gap-3",children:[m.jsxs("div",{children:[m.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Filter by Reaction ID"}),m.jsx("input",{type:"number",value:w,onChange:L=>b(L.target.value),placeholder:"Reaction ID",className:"px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 w-40"})]}),m.jsx("button",{onClick:()=>{E(0),j()},className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 rounded-lg text-sm font-medium transition-colors",children:"Filter"}),w&&m.jsx("button",{onClick:()=>{b(""),E(0),setTimeout(j,0)},className:"px-4 py-2 bg-gray-700 hover:bg-gray-600 rounded-lg text-sm font-medium transition-colors",children:"Clear"})]})}),m.jsxs("div",{className:"bg-gray-900/50 backdrop-blur rounded-lg overflow-hidden border border-gray-800",children:[n.length===0?m.jsx(fn,{message:"No reaction logs found"}):m.jsx("div",{className:"overflow-x-auto",children:m.jsxs("table",{className:"w-full",children:[m.jsx("thead",{className:"bg-gray-800/80 border-b border-gray-700",children:m.jsxs("tr",{children:[m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"ID"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Reaction"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Trigger Event"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Projection"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Old Value"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"New Value"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Action"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Status"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Output"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Duration"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Created"})]})}),m.jsx("tbody",{className:"divide-y divide-gray-800",children:n.map((L,P)=>m.jsxs("tr",{className:`transition-colors ${P%2===0?"bg-gray-900/30":"bg-gray-850/30"} hover:bg-gray-800/60`,children:[m.jsx("td",{className:"px-4 py-3 font-mono text-sm text-gray-300",children:L.id}),m.jsx("td",{className:"px-4 py-3 font-mono text-sm text-gray-300",children:L.reaction_id}),m.jsx("td",{className:"px-4 py-3 font-mono text-sm text-gray-300",children:L.trigger_event_id}),m.jsx("td",{className:"px-4 py-3 text-sm text-gray-400 max-w-[120px] truncate",children:nu(L.projection_def,30)}),m.jsx("td",{className:"px-4 py-3 text-sm text-gray-400 font-mono max-w-[120px] truncate",children:nu(L.old_value)}),m.jsx("td",{className:"px-4 py-3 text-sm text-gray-400 font-mono max-w-[120px] truncate",children:nu(L.new_value)}),m.jsx("td",{className:"px-4 py-3",children:m.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-blue-500/20 text-blue-300 border border-blue-500/30",children:L.action})}),m.jsx("td",{className:"px-4 py-3",children:m.jsx(gb,{status:L.status})}),m.jsx("td",{className:"px-4 py-3 text-sm",children:L.handler_output?m.jsxs("div",{children:[m.jsx("button",{onClick:()=>I(L.id),className:"text-blue-400 hover:text-blue-300 text-xs underline",children:S.has(L.id)?"Hide":"Show"}),S.has(L.id)&&m.jsx("pre",{className:"mt-2 p-2 bg-gray-800 rounded text-xs text-gray-300 max-w-xs overflow-auto whitespace-pre-wrap",children:typeof L.handler_output=="string"?L.handler_output:JSON.stringify(L.handler_output,null,2)})]}):m.jsx("span",{className:"text-gray-600",children:"—"})}),m.jsx("td",{className:"px-4 py-3 text-sm text-gray-400 font-mono",children:L.duration_ms!=null?`${L.duration_ms}ms`:"—"}),m.jsx("td",{className:"px-4 py-3 text-sm text-gray-400",children:ur(L.created_at)})]},L.id))})]})}),m.jsx(Vr,{total:f,limit:h,offset:x,onPageChange:E,onLimitChange:v})]})]})}function yb({method:n}){const l={GET:"bg-blue-500/20 text-blue-300 border-blue-500/30",POST:"bg-green-500/20 text-green-300 border-green-500/30",PUT:"bg-yellow-500/20 text-yellow-300 border-yellow-500/30",PATCH:"bg-orange-500/20 text-orange-300 border-orange-500/30",DELETE:"bg-red-500/20 text-red-300 border-red-500/30"};return m.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-bold border ${l[n]||"bg-gray-500/20 text-gray-300 border-gray-500/30"}`,children:n})}function xb({code:n}){let l="bg-gray-500/20 text-gray-300 border-gray-500/30";return n>=200&&n<300?l="bg-green-500/20 text-green-300 border-green-500/30":n>=400&&n<500?l="bg-yellow-500/20 text-yellow-300 border-yellow-500/30":n>=500&&(l="bg-red-500/20 text-red-300 border-red-500/30"),m.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-bold border ${l}`,children:n})}function wb(){const[n,l]=y.useState([]),[o,s]=y.useState(""),[a,c]=y.useState(!0),[f,p]=y.useState(0),[h,v]=y.useState(50),[x,E]=y.useState(0),[w,b]=y.useState(""),S=()=>{c(!0);const C=w.trim()?parseInt(w,10):void 0;V0(h,x,C).then(j=>{l(j.request_logs),p(j.total)}).catch(j=>s(j.message)).finally(()=>c(!1))};return y.useEffect(()=>{S()},[h,x]),a?m.jsx($t,{}):o?m.jsxs("div",{className:"text-red-500 text-center p-8",children:["Error: ",o]}):m.jsxs("div",{className:"max-w-7xl mx-auto",children:[m.jsx("h2",{className:"text-2xl font-bold mb-6",children:"Request Logs"}),m.jsx("div",{className:"bg-gray-900/50 backdrop-blur rounded-lg border border-gray-800 p-4 mb-6",children:m.jsxs("div",{className:"flex items-end gap-3",children:[m.jsxs("div",{children:[m.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Filter by API Key ID"}),m.jsx("input",{type:"number",value:w,onChange:C=>b(C.target.value),placeholder:"API Key ID",className:"px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 w-40"})]}),m.jsx("button",{onClick:()=>{E(0),S()},className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 rounded-lg text-sm font-medium transition-colors",children:"Filter"}),w&&m.jsx("button",{onClick:()=>{b(""),E(0),setTimeout(S,0)},className:"px-4 py-2 bg-gray-700 hover:bg-gray-600 rounded-lg text-sm font-medium transition-colors",children:"Clear"})]})}),m.jsxs("div",{className:"bg-gray-900/50 backdrop-blur rounded-lg overflow-hidden border border-gray-800",children:[n.length===0?m.jsx(fn,{message:"No request logs found"}):m.jsx("div",{className:"overflow-x-auto",children:m.jsxs("table",{className:"w-full",children:[m.jsx("thead",{className:"bg-gray-800/80 border-b border-gray-700",children:m.jsxs("tr",{children:[m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"ID"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Method"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Path"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"API Key"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Status"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Error"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Duration"}),m.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Created"})]})}),m.jsx("tbody",{className:"divide-y divide-gray-800",children:n.map((C,j)=>m.jsxs("tr",{className:`transition-colors ${j%2===0?"bg-gray-900/30":"bg-gray-850/30"} hover:bg-gray-800/60`,children:[m.jsx("td",{className:"px-4 py-3 font-mono text-sm text-gray-300",children:C.id}),m.jsx("td",{className:"px-4 py-3",children:m.jsx(yb,{method:C.method})}),m.jsx("td",{className:"px-4 py-3 text-sm text-gray-300 font-mono",children:C.path}),m.jsx("td",{className:"px-4 py-3 text-sm text-gray-400",children:C.api_key_name||"—"}),m.jsx("td",{className:"px-4 py-3",children:m.jsx(xb,{code:C.status_code})}),m.jsx("td",{className:"px-4 py-3 text-sm text-red-400 max-w-[200px] truncate",children:C.error||"—"}),m.jsx("td",{className:"px-4 py-3 text-sm text-gray-400 font-mono",children:C.duration_ms!=null?`${C.duration_ms}ms`:"—"}),m.jsx("td",{className:"px-4 py-3 text-sm text-gray-400",children:ur(C.created_at)})]},C.id))})]})}),m.jsx(Vr,{total:f,limit:h,offset:x,onPageChange:E,onLimitChange:v})]})]})}const bb=new Set(["health","object-defs","objects","event-defs","events","projection-defs","projections","reactions","api-keys","reaction-logs","request-logs"]);function Ap(){const n=window.location.hash.replace(/^#\/?/,"");return bb.has(n)?n:"health"}function Sb(n){window.history.pushState(null,"",`#/${n}`)}function Eb(){const[n,l]=y.useState(Ap),[o,s]=y.useState(!1),[a,c]=y.useState(""),[f,p]=y.useState(!0);y.useEffect(()=>{const x=()=>l(Ap());return window.addEventListener("hashchange",x),window.addEventListener("popstate",x),()=>{window.removeEventListener("hashchange",x),window.removeEventListener("popstate",x)}},[]);const h=x=>{Sb(x),l(x)};y.useEffect(()=>{setTimeout(()=>{R0()||s(!0),p(!1)},100)},[]);const v=()=>{a.trim()&&(T0(a.trim()),s(!1))};return f?m.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-950",children:m.jsx($t,{})}):o?m.jsx("div",{className:"flex items-center justify-center h-screen bg-gray-950 text-gray-100 px-4",children:m.jsxs("div",{className:"bg-gray-900/80 backdrop-blur border border-gray-800 p-8 rounded-xl shadow-2xl max-w-md w-full animate-fadeIn",children:[m.jsxs("div",{className:"text-center mb-6",children:[m.jsx("h2",{className:"text-3xl font-bold mb-2 bg-gradient-to-r from-blue-400 to-purple-500 bg-clip-text text-transparent",children:"OGraph UI"}),m.jsx("p",{className:"text-gray-400 text-sm",children:"Enter your API token to continue"})]}),m.jsx("input",{type:"text",className:"w-full px-4 py-3 bg-gray-800 border border-gray-700 rounded-lg mb-4 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all",placeholder:"API Token",value:a,onChange:x=>c(x.target.value),onKeyDown:x=>x.key==="Enter"&&v(),autoFocus:!0}),m.jsx("button",{onClick:v,className:"w-full px-4 py-3 bg-blue-600 hover:bg-blue-700 rounded-lg font-semibold shadow-lg shadow-blue-500/30 hover:shadow-blue-500/50 transition-all",children:"Continue"})]})}):m.jsx(O0,{page:n,onPageChange:h,children:m.jsxs("div",{className:"animate-fadeIn",children:[n==="health"&&m.jsx(B0,{}),n==="object-defs"&&m.jsx(U0,{}),n==="objects"&&m.jsx(sb,{}),n==="event-defs"&&m.jsx(ub,{}),n==="events"&&m.jsx(cb,{}),n==="projection-defs"&&m.jsx(db,{}),n==="projections"&&m.jsx(fb,{}),n==="reactions"&&m.jsx(mb,{}),n==="api-keys"&&m.jsx(hb,{}),n==="reaction-logs"&&m.jsx(vb,{}),n==="request-logs"&&m.jsx(wb,{})]})})}N0.createRoot(document.getElementById("root")).render(m.jsx(y.StrictMode,{children:m.jsx(Eb,{})}));
diff --git a/packages/engine/ui/src/App.tsx b/packages/engine/ui/src/App.tsx
index 3f00f79..bcd3d40 100644
--- a/packages/engine/ui/src/App.tsx
+++ b/packages/engine/ui/src/App.tsx
@@ -27,12 +27,44 @@ type Page =
| 'reaction-logs'
| 'request-logs'
+const VALID_PAGES: Set = new Set([
+ 'health', 'object-defs', 'objects', 'event-defs', 'events',
+ 'projection-defs', 'projections', 'reactions', 'api-keys',
+ 'reaction-logs', 'request-logs',
+])
+
+function getPageFromHash(): Page {
+ const hash = window.location.hash.replace(/^#\/?/, '')
+ return VALID_PAGES.has(hash) ? (hash as Page) : 'health'
+}
+
+function setHash(page: Page) {
+ window.history.pushState(null, '', `#/${page}`)
+}
+
function App() {
- const [page, setPage] = useState('health')
+ const [page, setPageState] = useState(getPageFromHash)
const [needsAuth, setNeedsAuth] = useState(false)
const [tokenInput, setTokenInput] = useState('')
const [checking, setChecking] = useState(true)
+ // Sync hash → state on popstate (browser back/forward)
+ useEffect(() => {
+ const onHashChange = () => setPageState(getPageFromHash())
+ window.addEventListener('hashchange', onHashChange)
+ window.addEventListener('popstate', onHashChange)
+ return () => {
+ window.removeEventListener('hashchange', onHashChange)
+ window.removeEventListener('popstate', onHashChange)
+ }
+ }, [])
+
+ // Navigate: update hash + state
+ const setPage = (p: Page) => {
+ setHash(p)
+ setPageState(p)
+ }
+
useEffect(() => {
setTimeout(() => {
if (!getToken()) {