hello-csv
Version:
A modern CSV importer written in Preact
7 lines • 283 kB
JavaScript
"use strict";var Ks=Object.defineProperty;var Ys=(e,t,n)=>t in e?Ks(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var pe=(e,t,n)=>Ys(e,typeof t!="symbol"?t+"":t,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Xs=require("react-dom/client"),d=require("react"),p=require("react/jsx-runtime"),Me=require("react-dom");function Do(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const R=Do(d),ln=Do(Me);function Lo(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Lo(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Zs(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Lo(e))&&(r&&(r+=" "),r+=t);return r}const qr=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Kr=Zs,at=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Kr(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(u=>{const c=n==null?void 0:n[u],m=i==null?void 0:i[u];if(c===null)return null;const h=qr(c)||qr(m);return o[u][h]}),l=n&&Object.entries(n).reduce((u,c)=>{let[m,h]=c;return h===void 0||(u[m]=h),u},{}),a=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,c)=>{let{class:m,className:h,...f}=c;return Object.entries(f).every(g=>{let[v,w]=g;return Array.isArray(w)?w.includes({...i,...l}[v]):{...i,...l}[v]===w})?[...u,m,h]:u},[]);return Kr(e,s,a,n==null?void 0:n.class,n==null?void 0:n.className)},Js=at("text-center inline-block font-semibold px-3 py-2 rounded-md text-sm",{variants:{variant:{primary:"shadow-xs bg-hello-csv-primary text-white",secondary:"bg-white text-hello-csv-primary ring-1 shadow-xs ring-bg-hello-csv-primary ring-inset",tertiary:"bg-white text-gray-900 ring-1 shadow-xs ring-hello-csv-tertiary ring-inset",success:"shadow-xs bg-hello-csv-success text-white",danger:"shadow-xs bg-hello-csv-danger text-white"},withFullWidth:{true:"w-full",false:""},disabled:{true:"opacity-50 cursor-not-allowed pointer-events-none",false:"cursor-pointer"}},compoundVariants:[{variant:"primary",disabled:!1,className:"hover:bg-hello-csv-primary-light focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-hello-csv-primary"},{variant:"secondary",disabled:!1,className:"hover:opacity-80 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-hello-csv-secondary"},{variant:"tertiary",disabled:!1,className:"hover:bg-hello-csv-tertiary-light"},{variant:"success",disabled:!1,className:"hover:opacity-80 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-hello-csv-success"},{variant:"danger",disabled:!1,className:"hover:bg-hello-csv-danger-light focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-hello-csv-danger"}],defaultVariants:{withFullWidth:!1,variant:"primary",disabled:!1}});function $e({children:e,variant:t,disabled:n,onClick:r,withFullWidth:o}){const i=Js({variant:t,disabled:n,withFullWidth:o});return p.jsx("div",{role:"button",tabIndex:0,className:i,onClick:r,"aria-disabled":n,children:e})}const Qs=at("overflow-hidden rounded-md border border-gray-200",{variants:{variant:{default:"bg-white",muted:"bg-hello-csv-muted"},withPadding:{true:"px-4 py-5 sm:p-6",false:""}},defaultVariants:{variant:"default",withPadding:!0}}),Vo=d.forwardRef(({children:e,className:t,variant:n,withPadding:r=!0},o)=>{const i=Qs({variant:n,withPadding:r});return p.jsx("div",{ref:o,className:`${i} ${t}`,children:e})});function Ho({checked:e,setChecked:t,label:n}){const r=d.useId();return p.jsxs("div",{className:"flex gap-3",children:[p.jsx("div",{className:"flex h-6 shrink-0 items-center",children:p.jsxs("div",{className:"group grid size-4 grid-cols-1",children:[p.jsx("input",{checked:e,onChange:o=>t(o.target.checked),id:r,type:"checkbox",className:"checked:border-hello-csv-primary checked:bg-hello-csv-primary indeterminate:border-hello-csv-primary indeterminate:bg-hello-csv-primary focus-visible:outline-hello-csv-hello-csv-primary col-start-1 row-start-1 appearance-none rounded-sm border border-gray-300 bg-white focus-visible:outline-2 focus-visible:outline-offset-2 disabled:border-gray-300 disabled:bg-gray-100 disabled:checked:bg-gray-100 forced-colors:appearance-auto"}),p.jsxs("svg",{fill:"none",viewBox:"0 0 14 14",className:"pointer-events-none col-start-1 row-start-1 size-3.5 self-center justify-self-center stroke-white group-has-disabled:stroke-gray-950/25",children:[p.jsx("path",{d:"M3 8L6 11L11 3.5",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"opacity-0 group-has-checked:opacity-100"}),p.jsx("path",{d:"M3 7H11",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"opacity-0 group-has-indeterminate:opacity-100"})]})]})}),n&&p.jsx("div",{className:"text-sm/6",children:p.jsx("label",{htmlFor:r,className:"font-medium text-gray-900",children:n})})]})}let el=!1;function yr(){return el}const zo=typeof document<"u"?d.useLayoutEffect:()=>{};function tl(e){const t=d.useRef(null);return zo(()=>{t.current=e},[e]),d.useCallback((...n)=>{const r=t.current;return r==null?void 0:r(...n)},[])}const Je=e=>{var t;return(t=e==null?void 0:e.ownerDocument)!==null&&t!==void 0?t:document},nt=e=>e&&"window"in e&&e.window===e?e:Je(e).defaultView||window;function nl(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function rl(e){return nl(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}function Bo(e,t){if(!yr())return t&&e?e.contains(t):!1;if(!e||!t)return!1;let n=t;for(;n!==null;){if(n===e)return!0;n.tagName==="SLOT"&&n.assignedSlot?n=n.assignedSlot.parentNode:rl(n)?n=n.host:n=n.parentNode}return!1}const Yn=(e=document)=>{var t;if(!yr())return e.activeElement;let n=e.activeElement;for(;n&&"shadowRoot"in n&&(!((t=n.shadowRoot)===null||t===void 0)&&t.activeElement);)n=n.shadowRoot.activeElement;return n};function Go(e){return yr()&&e.target.shadowRoot&&e.composedPath?e.composedPath()[0]:e.target}function ol(e){var t;return typeof window>"u"||window.navigator==null?!1:((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.brands.some(n=>e.test(n.brand)))||e.test(window.navigator.userAgent)}function il(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.platform)||window.navigator.platform):!1}function Wo(e){let t=null;return()=>(t==null&&(t=e()),t)}const sl=Wo(function(){return il(/^Mac/i)}),ll=Wo(function(){return ol(/Android/i)});function Uo(){let e=d.useRef(new Map),t=d.useCallback((o,i,s,l)=>{let a=l!=null&&l.once?(...u)=>{e.current.delete(s),s(...u)}:s;e.current.set(s,{type:i,eventTarget:o,fn:a,options:l}),o.addEventListener(i,a,l)},[]),n=d.useCallback((o,i,s,l)=>{var a;let u=((a=e.current.get(s))===null||a===void 0?void 0:a.fn)||s;o.removeEventListener(i,u,l),e.current.delete(s)},[]),r=d.useCallback(()=>{e.current.forEach((o,i)=>{n(o.eventTarget,o.type,i,o.options)})},[n]);return d.useEffect(()=>r,[r]),{addGlobalListener:t,removeGlobalListener:n,removeAllGlobalListeners:r}}function al(e){return e.mozInputSource===0&&e.isTrusted?!0:ll()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function qo(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function ul(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function Ko(e){let t=d.useRef({isFocused:!1,observer:null});zo(()=>{const r=t.current;return()=>{r.observer&&(r.observer.disconnect(),r.observer=null)}},[]);let n=tl(r=>{e==null||e(r)});return d.useCallback(r=>{if(r.target instanceof HTMLButtonElement||r.target instanceof HTMLInputElement||r.target instanceof HTMLTextAreaElement||r.target instanceof HTMLSelectElement){t.current.isFocused=!0;let o=r.target,i=s=>{if(t.current.isFocused=!1,o.disabled){let l=qo(s);n(l)}t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)};o.addEventListener("focusout",i,{once:!0}),t.current.observer=new MutationObserver(()=>{if(t.current.isFocused&&o.disabled){var s;(s=t.current.observer)===null||s===void 0||s.disconnect();let l=o===document.activeElement?null:document.activeElement;o.dispatchEvent(new FocusEvent("blur",{relatedTarget:l})),o.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:l}))}}),t.current.observer.observe(o,{attributes:!0,attributeFilter:["disabled"]})}},[n])}let cl=!1,zt=null,Xn=new Set,Pt=new Map,it=!1,Zn=!1;const dl={Tab:!0,Escape:!0};function Sr(e,t){for(let n of Xn)n(e,t)}function fl(e){return!(e.metaKey||!sl()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function an(e){it=!0,fl(e)&&(zt="keyboard",Sr("keyboard",e))}function ht(e){zt="pointer",(e.type==="mousedown"||e.type==="pointerdown")&&(it=!0,Sr("pointer",e))}function Yo(e){al(e)&&(it=!0,zt="virtual")}function Xo(e){e.target===window||e.target===document||cl||!e.isTrusted||(!it&&!Zn&&(zt="virtual",Sr("virtual",e)),it=!1,Zn=!1)}function Zo(){it=!1,Zn=!0}function Jn(e){if(typeof window>"u"||Pt.get(nt(e)))return;const t=nt(e),n=Je(e);let r=t.HTMLElement.prototype.focus;t.HTMLElement.prototype.focus=function(){it=!0,r.apply(this,arguments)},n.addEventListener("keydown",an,!0),n.addEventListener("keyup",an,!0),n.addEventListener("click",Yo,!0),t.addEventListener("focus",Xo,!0),t.addEventListener("blur",Zo,!1),typeof PointerEvent<"u"&&(n.addEventListener("pointerdown",ht,!0),n.addEventListener("pointermove",ht,!0),n.addEventListener("pointerup",ht,!0)),t.addEventListener("beforeunload",()=>{Jo(e)},{once:!0}),Pt.set(t,{focus:r})}const Jo=(e,t)=>{const n=nt(e),r=Je(e);t&&r.removeEventListener("DOMContentLoaded",t),Pt.has(n)&&(n.HTMLElement.prototype.focus=Pt.get(n).focus,r.removeEventListener("keydown",an,!0),r.removeEventListener("keyup",an,!0),r.removeEventListener("click",Yo,!0),n.removeEventListener("focus",Xo,!0),n.removeEventListener("blur",Zo,!1),typeof PointerEvent<"u"&&(r.removeEventListener("pointerdown",ht,!0),r.removeEventListener("pointermove",ht,!0),r.removeEventListener("pointerup",ht,!0)),Pt.delete(n))};function pl(e){const t=Je(e);let n;return t.readyState!=="loading"?Jn(e):(n=()=>{Jn(e)},t.addEventListener("DOMContentLoaded",n)),()=>Jo(e,n)}typeof document<"u"&&pl();function Qo(){return zt!=="pointer"}const ml=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function gl(e,t,n){let r=Je(n==null?void 0:n.target);const o=typeof window<"u"?nt(n==null?void 0:n.target).HTMLInputElement:HTMLInputElement,i=typeof window<"u"?nt(n==null?void 0:n.target).HTMLTextAreaElement:HTMLTextAreaElement,s=typeof window<"u"?nt(n==null?void 0:n.target).HTMLElement:HTMLElement,l=typeof window<"u"?nt(n==null?void 0:n.target).KeyboardEvent:KeyboardEvent;return e=e||r.activeElement instanceof o&&!ml.has(r.activeElement.type)||r.activeElement instanceof i||r.activeElement instanceof s&&r.activeElement.isContentEditable,!(e&&t==="keyboard"&&n instanceof l&&!dl[n.key])}function hl(e,t,n){Jn(),d.useEffect(()=>{let r=(o,i)=>{gl(!!(n!=null&&n.isTextInput),o,i)&&e(Qo())};return Xn.add(r),()=>{Xn.delete(r)}},t)}function vl(e){let{isDisabled:t,onFocus:n,onBlur:r,onFocusChange:o}=e;const i=d.useCallback(a=>{if(a.target===a.currentTarget)return r&&r(a),o&&o(!1),!0},[r,o]),s=Ko(i),l=d.useCallback(a=>{const u=Je(a.target),c=u?Yn(u):Yn();a.target===a.currentTarget&&c===Go(a.nativeEvent)&&(n&&n(a),o&&o(!0),s(a))},[o,n,s]);return{focusProps:{onFocus:!t&&(n||o||r)?l:void 0,onBlur:!t&&(r||o)?i:void 0}}}function xl(e){let{isDisabled:t,onBlurWithin:n,onFocusWithin:r,onFocusWithinChange:o}=e,i=d.useRef({isFocusWithin:!1}),{addGlobalListener:s,removeAllGlobalListeners:l}=Uo(),a=d.useCallback(m=>{m.currentTarget.contains(m.target)&&i.current.isFocusWithin&&!m.currentTarget.contains(m.relatedTarget)&&(i.current.isFocusWithin=!1,l(),n&&n(m),o&&o(!1))},[n,o,i,l]),u=Ko(a),c=d.useCallback(m=>{if(!m.currentTarget.contains(m.target))return;const h=Je(m.target),f=Yn(h);if(!i.current.isFocusWithin&&f===Go(m.nativeEvent)){r&&r(m),o&&o(!0),i.current.isFocusWithin=!0,u(m);let g=m.currentTarget;s(h,"focus",v=>{if(i.current.isFocusWithin&&!Bo(g,v.target)){let w=new h.defaultView.FocusEvent("blur",{relatedTarget:v.target});ul(w,g);let C=qo(w);a(C)}},{capture:!0})}},[r,o,u,s,a]);return t?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:c,onBlur:a}}}let Qn=!1,On=0;function wl(){Qn=!0,setTimeout(()=>{Qn=!1},50)}function Yr(e){e.pointerType==="touch"&&wl()}function bl(){if(!(typeof document>"u"))return typeof PointerEvent<"u"&&document.addEventListener("pointerup",Yr),On++,()=>{On--,!(On>0)&&typeof PointerEvent<"u"&&document.removeEventListener("pointerup",Yr)}}function ei(e){let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,isDisabled:o}=e,[i,s]=d.useState(!1),l=d.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;d.useEffect(bl,[]);let{addGlobalListener:a,removeAllGlobalListeners:u}=Uo(),{hoverProps:c,triggerHoverEnd:m}=d.useMemo(()=>{let h=(v,w)=>{if(l.pointerType=w,o||w==="touch"||l.isHovered||!v.currentTarget.contains(v.target))return;l.isHovered=!0;let C=v.currentTarget;l.target=C,a(Je(v.target),"pointerover",E=>{l.isHovered&&l.target&&!Bo(l.target,E.target)&&f(E,E.pointerType)},{capture:!0}),t&&t({type:"hoverstart",target:C,pointerType:w}),n&&n(!0),s(!0)},f=(v,w)=>{let C=l.target;l.pointerType="",l.target=null,!(w==="touch"||!l.isHovered||!C)&&(l.isHovered=!1,u(),r&&r({type:"hoverend",target:C,pointerType:w}),n&&n(!1),s(!1))},g={};return typeof PointerEvent<"u"&&(g.onPointerEnter=v=>{Qn&&v.pointerType==="mouse"||h(v,v.pointerType)},g.onPointerLeave=v=>{!o&&v.currentTarget.contains(v.target)&&f(v,v.pointerType)}),{hoverProps:g,triggerHoverEnd:f}},[t,n,r,o,l,a,u]);return d.useEffect(()=>{o&&m({currentTarget:l.target},l.pointerType)},[o]),{hoverProps:c,isHovered:i}}function ti(e={}){let{autoFocus:t=!1,isTextInput:n,within:r}=e,o=d.useRef({isFocused:!1,isFocusVisible:t||Qo()}),[i,s]=d.useState(!1),[l,a]=d.useState(()=>o.current.isFocused&&o.current.isFocusVisible),u=d.useCallback(()=>a(o.current.isFocused&&o.current.isFocusVisible),[]),c=d.useCallback(f=>{o.current.isFocused=f,s(f),u()},[u]);hl(f=>{o.current.isFocusVisible=f,u()},[],{isTextInput:n});let{focusProps:m}=vl({isDisabled:r,onFocusChange:c}),{focusWithinProps:h}=xl({isDisabled:!r,onFocusWithinChange:c});return{isFocused:i,isFocusVisible:l,focusProps:r?h:m}}var yl=Object.defineProperty,Sl=(e,t,n)=>t in e?yl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pn=(e,t,n)=>(Sl(e,typeof t!="symbol"?t+"":t,n),n);let Cl=class{constructor(){Pn(this,"current",this.detect()),Pn(this,"handoffState","pending"),Pn(this,"currentId",0)}set(t){this.current!==t&&(this.handoffState="pending",this.currentId=0,this.current=t)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},ot=new Cl;function St(e){return ot.isServer?null:e instanceof Node?e.ownerDocument:e!=null&&e.hasOwnProperty("current")&&e.current instanceof Node?e.current.ownerDocument:document}function gn(e){typeof queueMicrotask=="function"?queueMicrotask(e):Promise.resolve().then(e).catch(t=>setTimeout(()=>{throw t}))}function ke(){let e=[],t={addEventListener(n,r,o,i){return n.addEventListener(r,o,i),t.add(()=>n.removeEventListener(r,o,i))},requestAnimationFrame(...n){let r=requestAnimationFrame(...n);return t.add(()=>cancelAnimationFrame(r))},nextFrame(...n){return t.requestAnimationFrame(()=>t.requestAnimationFrame(...n))},setTimeout(...n){let r=setTimeout(...n);return t.add(()=>clearTimeout(r))},microTask(...n){let r={current:!0};return gn(()=>{r.current&&n[0]()}),t.add(()=>{r.current=!1})},style(n,r,o){let i=n.style.getPropertyValue(r);return Object.assign(n.style,{[r]:o}),this.add(()=>{Object.assign(n.style,{[r]:i})})},group(n){let r=ke();return n(r),this.add(()=>r.dispose())},add(n){return e.includes(n)||e.push(n),()=>{let r=e.indexOf(n);if(r>=0)for(let o of e.splice(r,1))o()}},dispose(){for(let n of e.splice(0))n()}};return t}function ut(){let[e]=d.useState(ke);return d.useEffect(()=>()=>e.dispose(),[e]),e}let re=(e,t)=>{ot.isServer?d.useEffect(e,t):d.useLayoutEffect(e,t)};function Qe(e){let t=d.useRef(e);return re(()=>{t.current=e},[e]),t}let z=function(e){let t=Qe(e);return d.useCallback((...n)=>t.current(...n),[t])};function El(e){let t=e.width/2,n=e.height/2;return{top:e.clientY-n,right:e.clientX+t,bottom:e.clientY+n,left:e.clientX-t}}function Rl(e,t){return!(!e||!t||e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom)}function $l({disabled:e=!1}={}){let t=d.useRef(null),[n,r]=d.useState(!1),o=ut(),i=z(()=>{t.current=null,r(!1),o.dispose()}),s=z(l=>{if(o.dispose(),t.current===null){t.current=l.currentTarget,r(!0);{let a=St(l.currentTarget);o.addEventListener(a,"pointerup",i,!1),o.addEventListener(a,"pointermove",u=>{if(t.current){let c=El(u);r(Rl(c,t.current.getBoundingClientRect()))}},!1),o.addEventListener(a,"pointercancel",i,!1)}}});return{pressed:n,pressProps:e?{}:{onPointerDown:s,onPointerUp:i,onClick:i}}}let _l=d.createContext(void 0);function Cr(){return d.useContext(_l)}function er(...e){return Array.from(new Set(e.flatMap(t=>typeof t=="string"?t.split(" "):[]))).filter(Boolean).join(" ")}function Ce(e,t,...n){if(e in t){let o=t[e];return typeof o=="function"?o(...n):o}let r=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map(o=>`"${o}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,Ce),r}var wt=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(wt||{}),Ue=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(Ue||{});function fe(){let e=Il();return d.useCallback(t=>Ml({mergeRefs:e,...t}),[e])}function Ml({ourProps:e,theirProps:t,slot:n,defaultTag:r,features:o,visible:i=!0,name:s,mergeRefs:l}){l=l??Tl;let a=ni(t,e);if(i)return Jt(a,n,r,s,l);let u=o??0;if(u&2){let{static:c=!1,...m}=a;if(c)return Jt(m,n,r,s,l)}if(u&1){let{unmount:c=!0,...m}=a;return Ce(c?0:1,{0(){return null},1(){return Jt({...m,hidden:!0,style:{display:"none"}},n,r,s,l)}})}return Jt(a,n,r,s,l)}function Jt(e,t={},n,r,o){let{as:i=n,children:s,refName:l="ref",...a}=An(e,["unmount","static"]),u=e.ref!==void 0?{[l]:e.ref}:{},c=typeof s=="function"?s(t):s;"className"in a&&a.className&&typeof a.className=="function"&&(a.className=a.className(t)),a["aria-labelledby"]&&a["aria-labelledby"]===a.id&&(a["aria-labelledby"]=void 0);let m={};if(t){let h=!1,f=[];for(let[g,v]of Object.entries(t))typeof v=="boolean"&&(h=!0),v===!0&&f.push(g.replace(/([A-Z])/g,w=>`-${w.toLowerCase()}`));if(h){m["data-headlessui-state"]=f.join(" ");for(let g of f)m[`data-${g}`]=""}}if(i===d.Fragment&&(Object.keys(We(a)).length>0||Object.keys(We(m)).length>0))if(!d.isValidElement(c)||Array.isArray(c)&&c.length>1){if(Object.keys(We(a)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${r} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(We(a)).concat(Object.keys(We(m))).map(h=>` - ${h}`).join(`
`),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(h=>` - ${h}`).join(`
`)].join(`
`))}else{let h=c.props,f=h==null?void 0:h.className,g=typeof f=="function"?(...C)=>er(f(...C),a.className):er(f,a.className),v=g?{className:g}:{},w=ni(c.props,We(An(a,["ref"])));for(let C in m)C in w&&delete m[C];return d.cloneElement(c,Object.assign({},w,m,u,{ref:o(Fl(c),u.ref)},v))}return d.createElement(i,Object.assign({},An(a,["ref"]),i!==d.Fragment&&u,i!==d.Fragment&&m),c)}function Il(){let e=d.useRef([]),t=d.useCallback(n=>{for(let r of e.current)r!=null&&(typeof r=="function"?r(n):r.current=n)},[]);return(...n)=>{if(!n.every(r=>r==null))return e.current=n,t}}function Tl(...e){return e.every(t=>t==null)?void 0:t=>{for(let n of e)n!=null&&(typeof n=="function"?n(t):n.current=t)}}function ni(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},n={};for(let r of e)for(let o in r)o.startsWith("on")&&typeof r[o]=="function"?(n[o]!=null||(n[o]=[]),n[o].push(r[o])):t[o]=r[o];if(t.disabled||t["aria-disabled"])for(let r in n)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r)&&(n[r]=[o=>{var i;return(i=o==null?void 0:o.preventDefault)==null?void 0:i.call(o)}]);for(let r in n)Object.assign(t,{[r](o,...i){let s=n[r];for(let l of s){if((o instanceof Event||(o==null?void 0:o.nativeEvent)instanceof Event)&&o.defaultPrevented)return;l(o,...i)}}});return t}function Er(...e){if(e.length===0)return{};if(e.length===1)return e[0];let t={},n={};for(let r of e)for(let o in r)o.startsWith("on")&&typeof r[o]=="function"?(n[o]!=null||(n[o]=[]),n[o].push(r[o])):t[o]=r[o];for(let r in n)Object.assign(t,{[r](...o){let i=n[r];for(let s of i)s==null||s(...o)}});return t}function ce(e){var t;return Object.assign(d.forwardRef(e),{displayName:(t=e.displayName)!=null?t:e.name})}function We(e){let t=Object.assign({},e);for(let n in t)t[n]===void 0&&delete t[n];return t}function An(e,t=[]){let n=Object.assign({},e);for(let r of t)r in n&&delete n[r];return n}function Fl(e){return d.version.split(".")[0]>="19"?e.props.ref:e.ref}function Ol(e,t,n){let[r,o]=d.useState(n),i=e!==void 0,s=d.useRef(i),l=d.useRef(!1),a=d.useRef(!1);return i&&!s.current&&!l.current?(l.current=!0,s.current=i,console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")):!i&&s.current&&!a.current&&(a.current=!0,s.current=i,console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")),[i?e:r,z(u=>(i||o(u),t==null?void 0:t(u)))]}function Pl(e){let[t]=d.useState(e);return t}function ri(e={},t=null,n=[]){for(let[r,o]of Object.entries(e))ii(n,oi(t,r),o);return n}function oi(e,t){return e?e+"["+t+"]":t}function ii(e,t,n){if(Array.isArray(n))for(let[r,o]of n.entries())ii(e,oi(t,r.toString()),o);else n instanceof Date?e.push([t,n.toISOString()]):typeof n=="boolean"?e.push([t,n?"1":"0"]):typeof n=="string"?e.push([t,n]):typeof n=="number"?e.push([t,`${n}`]):n==null?e.push([t,""]):ri(n,t,e)}let Al="span";var bt=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(bt||{});function jl(e,t){var n;let{features:r=1,...o}=e,i={ref:t,"aria-hidden":(r&2)===2?!0:(n=o["aria-hidden"])!=null?n:void 0,hidden:(r&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(r&4)===4&&(r&2)!==2&&{display:"none"}}};return fe()({ourProps:i,theirProps:o,slot:{},defaultTag:Al,name:"Hidden"})}let Nt=ce(jl),kl=d.createContext(null);function Nl({children:e}){let t=d.useContext(kl);if(!t)return d.createElement(d.Fragment,null,e);let{target:n}=t;return n?Me.createPortal(d.createElement(d.Fragment,null,e),n):null}function Dl({data:e,form:t,disabled:n,onReset:r,overrides:o}){let[i,s]=d.useState(null),l=ut();return d.useEffect(()=>{if(r&&i)return l.addEventListener(i,"reset",r)},[i,t,r]),d.createElement(Nl,null,d.createElement(Ll,{setForm:s,formId:t}),ri(e).map(([a,u])=>d.createElement(Nt,{features:bt.Hidden,...We({key:a,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:t,disabled:n,name:a,value:u,...o})})))}function Ll({setForm:e,formId:t}){return d.useEffect(()=>{if(t){let n=document.getElementById(t);n&&e(n)}},[e,t]),t?null:d.createElement(Nt,{features:bt.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:n=>{if(!n)return;let r=n.closest("form");r&&e(r)}})}let Vl=d.createContext(void 0);function si(){return d.useContext(Vl)}function Hl(e){let t=e.parentElement,n=null;for(;t&&!(t instanceof HTMLFieldSetElement);)t instanceof HTMLLegendElement&&(n=t),t=t.parentElement;let r=(t==null?void 0:t.getAttribute("disabled"))==="";return r&&zl(n)?!1:r}function zl(e){if(!e)return!1;let t=e.previousElementSibling;for(;t!==null;){if(t instanceof HTMLLegendElement)return!1;t=t.previousElementSibling}return!0}let li=Symbol();function Bl(e,t=!0){return Object.assign(e,{[li]:t})}function ye(...e){let t=d.useRef(e);d.useEffect(()=>{t.current=e},[e]);let n=z(r=>{for(let o of t.current)o!=null&&(typeof o=="function"?o(r):o.current=r)});return e.every(r=>r==null||(r==null?void 0:r[li]))?void 0:n}let hn=d.createContext(null);hn.displayName="DescriptionContext";function ai(){let e=d.useContext(hn);if(e===null){let t=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,ai),t}return e}function Gl(){var e,t;return(t=(e=d.useContext(hn))==null?void 0:e.value)!=null?t:void 0}function Wl(){let[e,t]=d.useState([]);return[e.length>0?e.join(" "):void 0,d.useMemo(()=>function(n){let r=z(i=>(t(s=>[...s,i]),()=>t(s=>{let l=s.slice(),a=l.indexOf(i);return a!==-1&&l.splice(a,1),l}))),o=d.useMemo(()=>({register:r,slot:n.slot,name:n.name,props:n.props,value:n.value}),[r,n.slot,n.name,n.props,n.value]);return d.createElement(hn.Provider,{value:o},n.children)},[t])]}let Ul="p";function ql(e,t){let n=d.useId(),r=Cr(),{id:o=`headlessui-description-${n}`,...i}=e,s=ai(),l=ye(t);re(()=>s.register(o),[o,s.register]);let a=r||!1,u=d.useMemo(()=>({...s.slot,disabled:a}),[s.slot,a]),c={ref:l,...s.props,id:o};return fe()({ourProps:c,theirProps:i,slot:u,defaultTag:Ul,name:s.name||"Description"})}let Kl=ce(ql),Yl=Object.assign(Kl,{});var ve=(e=>(e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.Delete="Delete",e.ArrowLeft="ArrowLeft",e.ArrowUp="ArrowUp",e.ArrowRight="ArrowRight",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab",e))(ve||{});let vn=d.createContext(null);vn.displayName="LabelContext";function ui(){let e=d.useContext(vn);if(e===null){let t=new Error("You used a <Label /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,ui),t}return e}function xn(e){var t,n,r;let o=(n=(t=d.useContext(vn))==null?void 0:t.value)!=null?n:void 0;return((r=e==null?void 0:e.length)!=null?r:0)>0?[o,...e].filter(Boolean).join(" "):o}function Xl({inherit:e=!1}={}){let t=xn(),[n,r]=d.useState([]),o=e?[t,...n].filter(Boolean):n;return[o.length>0?o.join(" "):void 0,d.useMemo(()=>function(i){let s=z(a=>(r(u=>[...u,a]),()=>r(u=>{let c=u.slice(),m=c.indexOf(a);return m!==-1&&c.splice(m,1),c}))),l=d.useMemo(()=>({register:s,slot:i.slot,name:i.name,props:i.props,value:i.value}),[s,i.slot,i.name,i.props,i.value]);return d.createElement(vn.Provider,{value:l},i.children)},[r])]}let Zl="label";function Jl(e,t){var n;let r=d.useId(),o=ui(),i=si(),s=Cr(),{id:l=`headlessui-label-${r}`,htmlFor:a=i??((n=o.props)==null?void 0:n.htmlFor),passive:u=!1,...c}=e,m=ye(t);re(()=>o.register(l),[l,o.register]);let h=z(w=>{let C=w.currentTarget;if(C instanceof HTMLLabelElement&&w.preventDefault(),o.props&&"onClick"in o.props&&typeof o.props.onClick=="function"&&o.props.onClick(w),C instanceof HTMLLabelElement){let E=document.getElementById(C.htmlFor);if(E){let S=E.getAttribute("disabled");if(S==="true"||S==="")return;let $=E.getAttribute("aria-disabled");if($==="true"||$==="")return;(E instanceof HTMLInputElement&&(E.type==="radio"||E.type==="checkbox")||E.role==="radio"||E.role==="checkbox"||E.role==="switch")&&E.click(),E.focus({preventScroll:!0})}}}),f=s||!1,g=d.useMemo(()=>({...o.slot,disabled:f}),[o.slot,f]),v={ref:m,...o.props,id:l,htmlFor:a,onClick:h};return u&&("onClick"in v&&(delete v.htmlFor,delete v.onClick),"onClick"in c&&delete c.onClick),fe()({ourProps:v,theirProps:c,slot:g,defaultTag:a?Zl:"div",name:o.name||"Label"})}let Ql=ce(Jl),ea=Object.assign(Ql,{}),ta=d.createContext(()=>{});function na({value:e,children:t}){return d.createElement(ta.Provider,{value:e},t)}function mt(e,t,n){let r=n.initialDeps??[],o;function i(){var s,l,a,u;let c;n.key&&((s=n.debug)!=null&&s.call(n))&&(c=Date.now());const m=e();if(!(m.length!==r.length||m.some((g,v)=>r[v]!==g)))return o;r=m;let f;if(n.key&&((l=n.debug)!=null&&l.call(n))&&(f=Date.now()),o=t(...m),n.key&&((a=n.debug)!=null&&a.call(n))){const g=Math.round((Date.now()-c)*100)/100,v=Math.round((Date.now()-f)*100)/100,w=v/16,C=(E,S)=>{for(E=String(E);E.length<S;)E=" "+E;return E};console.info(`%c⏱ ${C(v,5)} /${C(g,5)} ms`,`
font-size: .6rem;
font-weight: bold;
color: hsl(${Math.max(0,Math.min(120-120*w,120))}deg 100% 31%);`,n==null?void 0:n.key)}return(u=n==null?void 0:n.onChange)==null||u.call(n,o),o}return i.updateDeps=s=>{r=s},i}function Xr(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const ra=(e,t)=>Math.abs(e-t)<=1,oa=(e,t,n)=>{let r;return function(...o){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,o),n)}};var It={NODE_ENV:"production"};const Zr=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},ia=e=>e,sa=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let o=t;o<=n;o++)r.push(o);return r},la=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const o=s=>{const{width:l,height:a}=s;t({width:Math.round(l),height:Math.round(a)})};if(o(Zr(n)),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver(s=>{const l=()=>{const a=s[0];if(a!=null&&a.borderBoxSize){const u=a.borderBoxSize[0];if(u){o({width:u.inlineSize,height:u.blockSize});return}}o(Zr(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},Jr={passive:!0},Qr=typeof window>"u"?!0:"onscrollend"in window,aa=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let o=0;const i=e.options.useScrollendEvent&&Qr?()=>{}:oa(r,()=>{t(o,!1)},e.options.isScrollingResetDelay),s=c=>()=>{const{horizontal:m,isRtl:h}=e.options;o=m?n.scrollLeft*(h&&-1||1):n.scrollTop,i(),t(o,c)},l=s(!0),a=s(!1);a(),n.addEventListener("scroll",l,Jr);const u=e.options.useScrollendEvent&&Qr;return u&&n.addEventListener("scrollend",a,Jr),()=>{n.removeEventListener("scroll",l),u&&n.removeEventListener("scrollend",a)}},ua=(e,t,n)=>{if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},ca=(e,{adjustments:t=0,behavior:n},r)=>{var o,i;const s=e+t;(i=(o=r.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[r.options.horizontal?"left":"top"]:s,behavior:n})};class da{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(o=>{o.forEach(i=>{const s=()=>{this._measureElement(i.target,i)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(s):s()})}));return{disconnect:()=>{var o;(o=r())==null||o.disconnect(),n=null},observe:o=>{var i;return(i=r())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=r())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,o])=>{typeof o>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:ia,rangeExtractor:sa,onChange:()=>{},measureElement:ua,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,o;(o=(r=this.options).onChange)==null||o.call(r,this,n)},this.maybeNotify=mt(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:It.NODE_ENV!=="production",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=i,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const o=new Map,i=new Map;for(let s=r-1;s>=0;s--){const l=n[s];if(o.has(l.lane))continue;const a=i.get(l.lane);if(a==null||l.end>a.end?i.set(l.lane,l):l.end<a.end&&o.set(l.lane,!0),o.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((s,l)=>s.end===l.end?s.index-l.index:s.end-l.end)[0]:void 0},this.getMeasurementOptions=mt(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(n,r,o,i,s)=>(this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:o,getItemKey:i,enabled:s}),{key:!1}),this.getMeasurements=mt(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:o,getItemKey:i,enabled:s},l)=>{if(!s)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(c=>{this.itemSizeCache.set(c.key,c.size)}));const a=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const u=this.measurementsCache.slice(0,a);for(let c=a;c<n;c++){const m=i(c),h=this.options.lanes===1?u[c-1]:this.getFurthestMeasurement(u,c),f=h?h.end+this.options.gap:r+o,g=l.get(m),v=typeof g=="number"?g:this.options.estimateSize(c),w=f+v,C=h?h.lane:c%this.options.lanes;u[c]={index:c,start:f,size:v,end:w,key:m,lane:C}}return this.measurementsCache=u,u},{key:It.NODE_ENV!=="production",debug:()=>this.options.debug}),this.calculateRange=mt(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,o,i)=>this.range=n.length>0&&r>0?fa({measurements:n,outerSize:r,scrollOffset:o,lanes:i}):null,{key:It.NODE_ENV!=="production",debug:()=>this.options.debug}),this.getVirtualIndexes=mt(()=>{let n=null,r=null;const o=this.calculateRange();return o&&(n=o.startIndex,r=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,o,i,s)=>i===null||s===null?[]:n({startIndex:i,endIndex:s,overscan:r,count:o}),{key:It.NODE_ENV!=="production",debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,o=n.getAttribute(r);return o?parseInt(o,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(n,r)=>{const o=this.indexFromElement(n),i=this.measurementsCache[o];if(!i)return;const s=i.key,l=this.elementsCache.get(s);l!==n&&(l&&this.observer.unobserve(l),this.observer.observe(n),this.elementsCache.set(s,n)),n.isConnected&&this.resizeItem(o,this.options.measureElement(n,r,this))},this.resizeItem=(n,r)=>{const o=this.measurementsCache[n];if(!o)return;const i=this.itemSizeCache.get(o.key)??o.size,s=r-i;s!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(o,s,this):o.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=s,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(o.index),this.itemSizeCache=new Map(this.itemSizeCache.set(o.key,r)),this.notify(!1))},this.measureElement=n=>{if(!n){this.elementsCache.forEach((r,o)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(o))});return}this._measureElement(n,void 0)},this.getVirtualItems=mt(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const o=[];for(let i=0,s=n.length;i<s;i++){const l=n[i],a=r[l];o.push(a)}return o},{key:It.NODE_ENV!=="production",debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return Xr(r[ci(0,r.length-1,o=>Xr(r[o]).start,n)])},this.getOffsetForAlignment=(n,r,o=0)=>{const i=this.getSize(),s=this.getScrollOffset();r==="auto"&&(r=n>=s+i?"end":"start"),r==="center"?n+=(o-i)/2:r==="end"&&(n-=i);const l=this.getTotalSize()-i;return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const o=this.measurementsCache[n];if(!o)return;const i=this.getSize(),s=this.getScrollOffset();if(r==="auto")if(o.end>=s+i-this.options.scrollPaddingEnd)r="end";else if(o.start<=s+this.options.scrollPaddingStart)r="start";else return[s,r];const l=r==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,r,o.size),r]},this.isDynamicMode=()=>this.elementsCache.size>0,this.cancelScrollToIndex=()=>{this.scrollToIndexTimeoutId!==null&&this.targetWindow&&(this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId),this.scrollToIndexTimeoutId=null)},this.scrollToOffset=(n,{align:r="start",behavior:o}={})=>{this.cancelScrollToIndex(),o==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(n,r),{adjustments:void 0,behavior:o})},this.scrollToIndex=(n,{align:r="auto",behavior:o}={})=>{n=Math.max(0,Math.min(n,this.options.count-1)),this.cancelScrollToIndex(),o==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");const i=this.getOffsetForIndex(n,r);if(!i)return;const[s,l]=i;this._scrollToOffset(s,{adjustments:void 0,behavior:o}),o!=="smooth"&&this.isDynamicMode()&&this.targetWindow&&(this.scrollToIndexTimeoutId=this.targetWindow.setTimeout(()=>{if(this.scrollToIndexTimeoutId=null,this.elementsCache.has(this.options.getItemKey(n))){const u=this.getOffsetForIndex(n,l);if(!u)return;const[c]=u,m=this.getScrollOffset();ra(c,m)||this.scrollToIndex(n,{align:l,behavior:o})}else this.scrollToIndex(n,{align:l,behavior:o})}))},this.scrollBy=(n,{behavior:r}={})=>{this.cancelScrollToIndex(),r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+n,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let o;if(r.length===0)o=this.options.paddingStart;else if(this.options.lanes===1)o=((n=r[r.length-1])==null?void 0:n.end)??0;else{const i=Array(this.options.lanes).fill(null);let s=r.length-1;for(;s>=0&&i.some(l=>l===null);){const l=r[s];i[l.lane]===null&&(i[l.lane]=l.end),s--}o=Math.max(...i.filter(l=>l!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:o})=>{this.options.scrollToFn(n,{behavior:o,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(t)}}const ci=(e,t,n,r)=>{for(;e<=t;){const o=(e+t)/2|0,i=n(o);if(i<r)e=o+1;else if(i>r)t=o-1;else return o}return e>0?e-1:0};function fa({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const o=e.length-1,i=a=>e[a].start;if(e.length<=r)return{startIndex:0,endIndex:o};let s=ci(0,o,i,n),l=s;if(r===1)for(;l<o&&e[l].end<n+t;)l++;else if(r>1){const a=Array(r).fill(0);for(;l<o&&a.some(c=>c<n+t);){const c=e[l];a[c.lane]=c.end,l++}const u=Array(r).fill(n+t);for(;s>=0&&u.some(c=>c>=n);){const c=e[s];u[c.lane]=c.start,s--}s=Math.max(0,s-s%r),l=Math.min(o,l+(r-1-l%r))}return{startIndex:s,endIndex:l}}const eo=typeof document<"u"?R.useLayoutEffect:R.useEffect;function pa(e){const t=R.useReducer(()=>({}),{})[1],n={...e,onChange:(o,i)=>{var s;i?Me.flushSync(t):t(),(s=e.onChange)==null||s.call(e,o,i)}},[r]=R.useState(()=>new da(n));return r.setOptions(n),eo(()=>r._didMount(),[]),eo(()=>r._willUpdate()),r}function di(e){return pa({observeElementRect:la,observeElementOffset:aa,scrollToFn:ca,...e})}function ma(e,t){return e!==null&&t!==null&&typeof e=="object"&&typeof t=="object"&&"id"in e&&"id"in t?e.id===t.id:e===t}function ga(e=ma){return d.useCallback((t,n)=>{if(typeof e=="string"){let r=e;return(t==null?void 0:t[r])===(n==null?void 0:n[r])}return e(t,n)},[e])}function ha(e){if(e===null)return{width:0,height:0};let{width:t,height:n}=e.getBoundingClientRect();return{width:t,height:n}}function to(e,t=!1){let[n,r]=d.useReducer(()=>({}),{}),o=d.useMemo(()=>ha(e),[e,n]);return re(()=>{if(!e)return;let i=new ResizeObserver(r);return i.observe(e),()=>{i.disconnect()}},[e]),t?{width:`${o.width}px`,height:`${o.height}px`}:o}let va=class extends Map{constructor(t){super(),this.factory=t}get(t){let n=super.get(t);return n===void 0&&(n=this.factory(t),this.set(t,n)),n}};function fi(e,t){let n=e(),r=new Set;return{getSnapshot(){return n},subscribe(o){return r.add(o),()=>r.delete(o)},dispatch(o,...i){let s=t[o].call(n,...i);s&&(n=s,r.forEach(l=>l()))}}}function pi(e){return d.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}let xa=new va(()=>fi(()=>[],{ADD(e){return this.includes(e)?this:[...this,e]},REMOVE(e){let t=this.indexOf(e);if(t===-1)return this;let n=this.slice();return n.splice(t,1),n}}));function Ct(e,t){let n=xa.get(t),r=d.useId(),o=pi(n);if(re(()=>{if(e)return n.dispatch("ADD",r),()=>n.dispatch("REMOVE",r)},[n,e]),!e)return!1;let i=o.indexOf(r),s=o.length;return i===-1&&(i=s,s+=1),i===s-1}let tr=new Map,At=new Map;function no(e){var t;let n=(t=At.get(e))!=null?t:0;return At.set(e,n+1),n!==0?()=>ro(e):(tr.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>ro(e))}function ro(e){var t;let n=(t=At.get(e))!=null?t:1;if(n===1?At.delete(e):At.set(e,n-1),n!==1)return;let r=tr.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,tr.delete(e))}function mi(e,{allowed:t,disallowed:n}={}){let r=Ct(e,"inert-others");re(()=>{var o,i;if(!r)return;let s=ke();for(let a of(o=n==null?void 0:n())!=null?o:[])a&&s.add(no(a));let l=(i=t==null?void 0:t())!=null?i:[];for(let a of l){if(!a)continue;let u=St(a);if(!u)continue;let c=a.parentElement;for(;c&&c!==u.body;){for(let m of c.children)l.some(h=>m.contains(h))||s.add(no(m));c=c.parentElement}}return s.dispose},[r,t,n])}function gi(e,t,n){let r=Qe(o=>{let i=o.getBoundingClientRect();i.x===0&&i.y===0&&i.width===0&&i.height===0&&n()});d.useEffect(()=>{if(!e)return;let o=t===null?null:t instanceof HTMLElement?t:t.current;if(!o)return;let i=ke();if(typeof ResizeObserver<"u"){let s=new ResizeObserver(()=>r.current(o));s.observe(o),i.add(()=>s.disconnect())}if(typeof IntersectionObserver<"u"){let s=new IntersectionObserver(()=>r.current(o));s.observe(o),i.add(()=>s.disconnect())}return()=>i.dispose()},[t,r,e])}let un=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(","),wa=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var He=(e=>(e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll",e[e.AutoFocus=64]="AutoFocus",e))(He||{}),nr=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(nr||{}),ba=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(ba||{});function ya(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(un)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}function Sa(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(wa)).sort((t,n)=>Math.sign((t.tabIndex||Number.MAX_SAFE_INTEGER)-(n.tabIndex||Number.MAX_SAFE_INTEGER)))}var hi=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(hi||{});function Ca(e,t=0){var n;return e===((n=St(e))==null?void 0:n.body)?!1:Ce(t,{0(){return e.matches(un)},1(){let r=e;for(;r!==null;){if(r.matches(un))return!0;r=r.parentElement}return!1}})}var Ea=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(Ea||{});typeof window<"u"&&typeof document<"u"&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function Be(e){e==null||e.focus({preventScroll:!0})}let Ra=["textarea","input"].join(",");function $a(e){var t,n;return(n=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,Ra))!=null?n:!1}function vi(e,t=n=>n){return e.slice().sort((n,r)=>{let o=t(n),i=t(r);if(o===null||i===null)return 0;let s=o.compareDocumentPosition(i);return s&Node.DOCUMENT_POSITION_FOLLOWING?-1:s&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function jt(e,t,{sorted:n=!0,relativeTo:r=null,skipElements:o=[]}={}){let i=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,s=Array.isArray(e)?n?vi(e):e:t&64?Sa(e):ya(e);o.length>0&&s.length>1&&(s=s.filter(f=>!o.some(g=>g!=null&&"current"in g?(g==null?void 0:g.current)===f:g===f))),r=r??i.activeElement;let l=(()=>{if(t&5)return 1;if(t&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),a=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,s.indexOf(r))-1;if(t&4)return Math.max(0,s.indexOf(r))+1;if(t&8)return s.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),u=t&32?{preventScroll:!0}:{},c=0,m=s.length,h;do{if(c>=m||c+m<=0)return 0;let f=a+c;if(t&16)f=(f+m)%m;else{if(f<0)return 3;if(f>=m)return 1}h=s[f],h==null||h.focus(u),c+=l}while(h!==i.activeElement);return t&6&&$a(h)&&h.select(),2}function xi(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function _a(){return/Android/gi.test(window.navigator.userAgent)}function wi(){return xi()||_a()}function Tt(e,t,n,r){let o=Qe(n);d.useEffect(()=>{if(!e)return;function i(s){o.current(s)}return document.addEventListener(t,i,r),()=>document.removeEventListener(t,i,r)},[e,t,r])}function bi(e,t,n,r){let o=Qe(n);d.useEffect(()=>{if(!e)return;function i(s){o.current(s)}return window.addEventListener(t,i,r),()=>window.removeEventListener(t,i,r)},[e,t,r])}const oo=30;function yi(e,t,n){let r=Ct(e,"outside-click"),o=Qe(n),i=d.useCallback(function(a,u){if(a.defaultPrevented)return;let c=u(a);if(c===null||!c.getRootNode().contains(c)||!c.isConnected)return;let m=function h(f){return typeof f=="function"?h(f()):Array.isArray(f)||f instanceof Set?f:[f]}(t);for(let h of m)if(h!==null&&(h.contains(c)||a.composed&&a.composedPath().includes(h)))return;return!Ca(c,hi.Loose)&&c.tabIndex!==-1&&a.preventDefault(),o.current(a,c)},[o,t]),s=d.useRef(null);Tt(r,"pointerdown",a=>{var u,c;s.current=((c=(u=a.composedPath)==null?void 0:u.call(a))==null?void 0:c[0])||a.target},!0),Tt(r,"mousedown",a=>{var u,c;s.current=((c=(u=a.composedPath)==null?void 0:u.call(a))==null?void 0:c[0])||a.target},!0),Tt(r,"click",a=>{wi()||s.current&&(i(a,()=>s.current),s.current=null)},!0);let l=d.useRef({x:0,y:0});Tt(r,"touchstart",a=>{l.current.x=a.touches[0].clientX,l.current.y=a.touches[0].clientY},!0),Tt(r,"touchend",a=>{let u={x:a.changedTouches[0].clientX,y:a.changedTouches[0].clientY};if(!(Math.abs(u.x-l.current.x)>=oo||Math.abs(u.y-l.current.y)>=oo))return i(a,()=>a.target