@headlessui/react
Advanced tools
Comparing version 0.2.0-03d412f to 0.2.0-1da8e49
@@ -15,51 +15,3 @@ import React, { ElementType } from 'react'; | ||
export declare namespace Dialog { | ||
var Overlay: <TTag extends React.ElementType<any> = "div">(props: ({ | ||
as?: TTag | undefined; | ||
children?: string | number | boolean | {} | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactNodeArray | React.ReactPortal | ((bag: OverlayRenderPropArg) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>) | null | undefined; | ||
refName?: string | undefined; | ||
} & Pick<import("../../types").PropsOf<TTag>, Exclude<keyof import("../../types").PropsOf<TTag>, "id">> & { | ||
static?: undefined; | ||
} & { | ||
unmount?: boolean | undefined; | ||
}) | ({ | ||
as?: TTag | undefined; | ||
children?: string | number | boolean | {} | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactNodeArray | React.ReactPortal | ((bag: OverlayRenderPropArg) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>) | null | undefined; | ||
refName?: string | undefined; | ||
} & Pick<import("../../types").PropsOf<TTag>, Exclude<keyof import("../../types").PropsOf<TTag>, "id">> & { | ||
unmount?: undefined; | ||
} & { | ||
static?: boolean | undefined; | ||
}) | ({ | ||
as?: TTag | undefined; | ||
children?: string | number | boolean | {} | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactNodeArray | React.ReactPortal | ((bag: OverlayRenderPropArg) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>) | null | undefined; | ||
refName?: string | undefined; | ||
} & Pick<import("../../types").PropsOf<TTag>, Exclude<keyof import("../../types").PropsOf<TTag>, "aria-hidden">> & { | ||
static?: undefined; | ||
} & { | ||
unmount?: boolean | undefined; | ||
}) | ({ | ||
as?: TTag | undefined; | ||
children?: string | number | boolean | {} | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactNodeArray | React.ReactPortal | ((bag: OverlayRenderPropArg) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>) | null | undefined; | ||
refName?: string | undefined; | ||
} & Pick<import("../../types").PropsOf<TTag>, Exclude<keyof import("../../types").PropsOf<TTag>, "aria-hidden">> & { | ||
unmount?: undefined; | ||
} & { | ||
static?: boolean | undefined; | ||
}) | ({ | ||
as?: TTag | undefined; | ||
children?: string | number | boolean | {} | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactNodeArray | React.ReactPortal | ((bag: OverlayRenderPropArg) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>) | null | undefined; | ||
refName?: string | undefined; | ||
} & Pick<import("../../types").PropsOf<TTag>, Exclude<keyof import("../../types").PropsOf<TTag>, "onClick">> & { | ||
static?: undefined; | ||
} & { | ||
unmount?: boolean | undefined; | ||
}) | ({ | ||
as?: TTag | undefined; | ||
children?: string | number | boolean | {} | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactNodeArray | React.ReactPortal | ((bag: OverlayRenderPropArg) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>) | null | undefined; | ||
refName?: string | undefined; | ||
} & Pick<import("../../types").PropsOf<TTag>, Exclude<keyof import("../../types").PropsOf<TTag>, "onClick">> & { | ||
unmount?: undefined; | ||
} & { | ||
static?: boolean | undefined; | ||
}), ref: React.Ref<HTMLDivElement>) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null; | ||
var Overlay: <TTag extends React.ElementType<any> = "div">(props: Props<TTag, OverlayRenderPropArg, OverlayPropsWeControl>, ref: React.Ref<HTMLDivElement>) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null; | ||
var Title: <TTag extends React.ElementType<any> = "h2">(props: Props<TTag, TitleRenderPropArg, TitlePropsWeControl>) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null; | ||
@@ -71,2 +23,3 @@ var Description: <TTag extends React.ElementType<any> = "p">(props: Props<TTag, DescriptionRenderPropArg, TitlePropsWeControl>) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null; | ||
} | ||
declare type OverlayPropsWeControl = 'id' | 'aria-hidden' | 'onClick'; | ||
interface TitleRenderPropArg { | ||
@@ -73,0 +26,0 @@ open: boolean; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n,t,r,o=require("react"),u=(e=o)&&"object"==typeof e&&"default"in e?e.default:e;function i(){return(i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function a(e,n){if(null==e)return{};var t,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n.indexOf(t=u[r])>=0||(o[t]=e[t]);return o}function c(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function l(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return c(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?c(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}function s(e,n){if(e in n){for(var t=n[e],r=arguments.length,o=new Array(r>2?r-2:0),u=2;u<r;u++)o[u-2]=arguments[u];return"function"==typeof t?t.apply(void 0,o):t}var i=new Error('Tried to handle "'+e+'" but there is no handler defined. Only defined handlers are: '+Object.keys(n).map((function(e){return'"'+e+'"'})).join(", ")+".");throw Error.captureStackTrace&&Error.captureStackTrace(i,s),i}function f(e,r,o,u,c){if(void 0===c&&(c=!0),c)return d(e,r,o);var l=null!=u?u:n.None;if(l&n.Static){var f=e.static,p=void 0!==f&&f,v=a(e,["static"]);if(p)return d(v,r,o)}if(l&n.RenderStrategy){var m,b=e.unmount,y=void 0===b||b,h=a(e,["unmount"]);return s(y?t.Unmount:t.Hidden,((m={})[t.Unmount]=function(){return null},m[t.Hidden]=function(){return d(i({},h,{hidden:!0,style:{display:"none"}}),r,o)},m))}return d(e,r,o)}function d(e,n,t){var r,u=v(e,["unmount","static"]),i=u.as,c=void 0===i?t:i,s=u.children,f=u.refName,p=void 0===f?"ref":f,m=a(u,["as","children","refName"]),b=void 0!==e.ref?((r={})[p]=e.ref,r):{},y="function"==typeof s?s(n):s;if(c===o.Fragment&&Object.keys(m).length>0){if(Array.isArray(y)&&y.length>1){var h=new Error("You should only render 1 child");throw Error.captureStackTrace&&Error.captureStackTrace(h,d),h}if(!o.isValidElement(y)){var S=new Error('You should render an element as a child. Did you forget the as="..." prop?');throw Error.captureStackTrace&&Error.captureStackTrace(S,d),S}return o.cloneElement(y,Object.assign({},function(e,n,t){for(var r,o=Object.assign({},e),u=function(){var t,u=r.value;void 0!==e[u]&&void 0!==n[u]&&Object.assign(o,((t={})[u]=function(t){t.defaultPrevented||e[u](t),t.defaultPrevented||n[u](t)},t))},i=l(["onClick"]);!(r=i()).done;)u();return o}(function(e){var n=Object.assign({},e);for(var t in n)void 0===n[t]&&delete n[t];return n}(v(m,["ref"])),y.props),b))}return o.createElement(c,Object.assign({},v(m,["ref"]),c!==o.Fragment&&b),y)}function p(e){return o.forwardRef(e)}function v(e,n){void 0===n&&(n=[]);for(var t,r=Object.assign({},e),o=l(n);!(t=o()).done;){var u=t.value;u in r&&delete r[u]}return r}function m(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return o.useCallback((function(e){n.forEach((function(n){if(null!==n)return"function"==typeof n?n(e):void(n.current=e)}))}),[n])}function b(e){for(var n,t,r=e.parentElement,o=null;r&&!(r instanceof HTMLFieldSetElement);)r instanceof HTMLLegendElement&&(o=r),r=r.parentElement;var u=null!=(n=""===(null==(t=r)?void 0:t.getAttribute("disabled")))&&n;return(!u||!function(e){if(!e)return!1;for(var n=e.previousElementSibling;null!==n;){if(n instanceof HTMLLegendElement)return!1;n=n.previousElementSibling}return!0}(o))&&u}!function(e){e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static"}(n||(n={})),function(e){e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden"}(t||(t={})),function(e){e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.ArrowUp="ArrowUp",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab"}(r||(r={}));var y="undefined"!=typeof window?o.useLayoutEffect:o.useEffect,h={serverHandoffComplete:!1},S=0;function g(){return++S}function x(){var e=o.useState(h.serverHandoffComplete?g:null),n=e[0],t=e[1];return y((function(){null===n&&t(g())}),[n]),o.useEffect((function(){!1===h.serverHandoffComplete&&(h.serverHandoffComplete=!0)}),[]),null!=n?""+n:void 0}var E,C,w,I=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map((function(e){return e+":not([tabindex='-1'])"})).join(",");function O(e){e&&e.focus({preventScroll:!0})}function k(e,n){void 0===n&&(n=!0);var t=o.useRef(null),u=o.useRef(null),i=o.useRef(!1),a=o.useCallback((function(){return e.current?Array.from(e.current.querySelectorAll(I)):[]}),[e]);y((function(){if(n){i.current=!0,t.current=document.activeElement;var e=a();if(e.length<=0)throw new Error("There are no focusable elements inside the <FocusTrap />");return function n(t){void 0!==t&&(O(t),document.activeElement!==t?n(e[e.indexOf(t)+1]):u.current=t)}(e[0]),function(){i.current=!1,O(t.current),t.current=null,u.current=null}}}),[n,i]),y((function(){if(n)return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)};function e(e){if(e.key===r.Tab&&document.activeElement){e.preventDefault();var n=e.shiftKey?-1:1,t=a(),o=t.length;!function e(r){void 0===r&&(r=0);var i=t.indexOf(document.activeElement),a=t[(i+o+n+r)%o];O(a),a!==document.activeElement?e(r+n):u.current=a}()}}}),[n,a]),y((function(){if(n&&e.current){var t=e.current;return window.addEventListener("focus",r,!0),function(){return window.removeEventListener("focus",r,!0)}}function r(e){var n=u.current;if(n&&i.current){var r=e.target;r&&r instanceof HTMLElement?t.contains(r)?(u.current=r,O(r)):(e.preventDefault(),e.stopPropagation(),O(n)):O(u.current)}}}),[n,i,e])}!function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(C||(C={})),function(e){e[e.SetTitleElement=0]="SetTitleElement",e[e.SetDescriptionElement=1]="SetDescriptionElement"}(w||(w={}));var R=((E={})[w.SetTitleElement]=function(e,n){return e.titleElement===n.element?e:i({},e,{titleElement:n.element})},E[w.SetDescriptionElement]=function(e,n){return e.descriptionElement===n.element?e:i({},e,{descriptionElement:n.element})},E),T=o.createContext(null);function D(e){var n=o.useContext(T);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+P.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,D),t}return n}function L(e,n){return s(n.type,R,e,n)}T.displayName="DialogContext";var F=n.RenderStrategy|n.Static;function P(e){var n,t,c=e.open,l=e.onClose,s=a(e,["open","onClose"]),d=o.useRef(null),p=e.hasOwnProperty("open"),v=e.hasOwnProperty("onClose");if(!p)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!v)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if("boolean"!=typeof c)throw new Error("You provided an `open` prop to the `Dialog`, but the value is not a boolean. Received: "+c);if("function"!=typeof l)throw new Error("You provided an `onClose` prop to the `Dialog`, but the value is not a function. Received: "+l);var m=c?C.Open:C.Closed,b=o.useReducer(L,{titleElement:null,descriptionElement:null}),y=b[0],h=b[1],S=o.useCallback((function(){return l(!1)}),[l]),g=o.useCallback((function(e){return h({type:w.SetTitleElement,element:e})}),[h]),E=o.useCallback((function(e){return h({type:w.SetDescriptionElement,element:e})}),[h]);o.useEffect((function(){function e(e){e.key===r.Escape&&m===C.Open&&S()}return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}}),[S,m]),k(d,!!e.static||m===C.Open);var I="headlessui-dialog-"+x(),O=o.useMemo((function(){return[{dialogState:m,close:S,setTitle:g,setDescription:E},y]}),[m,y,S,g,E]),R=o.useMemo((function(){return{open:m===C.Open,close:S}}),[m,S]),D={ref:d,id:I,role:"dialog","aria-modal":!0,"aria-labelledby":null==(n=y.titleElement)?void 0:n.id,"aria-describedby":null==(t=y.descriptionElement)?void 0:t.id};return u.createElement(T.Provider,{value:O},f(i({},s,D),R,"div",F,m===C.Open))}var M,A,j,N=n.RenderStrategy|n.Static,U=p((function e(n,t){var r=D([P.name,e.name].join("."))[0],u=r.dialogState,a=r.close,c=m(t),l="headlessui-dialog-overlay-"+x(),s=o.useCallback((function(e){if(b(e.currentTarget))return e.preventDefault();a()}),[a]),d=o.useMemo((function(){return{open:u===C.Open}}),[u]);return f(i({},n,{ref:c,id:l,"aria-hidden":!0,onClick:s}),d,"div",N,u===C.Open)}));P.Overlay=U,P.Title=function e(n){var t=D([P.name,e.name].join("."))[0],r=t.dialogState,u=t.setTitle,a="headlessui-dialog-title-"+x(),c=o.useMemo((function(){return{open:r===C.Open}}),[r]);return f(i({},n,{ref:u,id:a}),c,"h2")},P.Description=function e(n){var t=D([P.name,e.name].join("."))[0],r=t.dialogState,u=t.setDescription,a="headlessui-dialog-description-"+x(),c=o.useMemo((function(){return{open:r===C.Open}}),[r]);return f(i({},n,{ref:u,id:a}),c,"p")},function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(A||(A={})),function(e){e[e.ToggleDisclosure=0]="ToggleDisclosure",e[e.SetButtonId=1]="SetButtonId",e[e.SetPanelId=2]="SetPanelId",e[e.LinkPanel=3]="LinkPanel",e[e.UnlinkPanel=4]="UnlinkPanel"}(j||(j={}));var G=((M={})[j.ToggleDisclosure]=function(e){var n;return i({},e,{disclosureState:s(e.disclosureState,(n={},n[A.Open]=A.Closed,n[A.Closed]=A.Open,n))})},M[j.LinkPanel]=function(e){return i({},e,{linkedPanel:!0})},M[j.UnlinkPanel]=function(e){return i({},e,{linkedPanel:!1})},M[j.SetButtonId]=function(e,n){return i({},e,{buttonId:n.buttonId})},M[j.SetPanelId]=function(e,n){return i({},e,{panelId:n.panelId})},M),H=o.createContext(null);function V(e){var n=o.useContext(H);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+K.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,V),t}return n}function Q(e,n){return s(n.type,G,e,n)}H.displayName="DisclosureContext";var B=o.Fragment;function K(e){var n="headlessui-disclosure-button-"+x(),t="headlessui-disclosure-panel-"+x(),r=o.useReducer(Q,{disclosureState:A.Closed,linkedPanel:!1,buttonId:n,panelId:t}),i=r[0].disclosureState,a=r[1];o.useEffect((function(){return a({type:j.SetButtonId,buttonId:n})}),[n,a]),o.useEffect((function(){return a({type:j.SetPanelId,panelId:t})}),[t,a]);var c=o.useMemo((function(){return{open:i===A.Open}}),[i]);return u.createElement(H.Provider,{value:r},f(e,c,B))}var q,Y,W,_,$=p((function e(n,t){var u=V([K.name,e.name].join(".")),a=u[0],c=u[1],l=m(t),s=o.useCallback((function(e){switch(e.key){case r.Space:case r.Enter:e.preventDefault(),c({type:j.ToggleDisclosure})}}),[c]),d=o.useCallback((function(e){b(e.currentTarget)||n.disabled||c({type:j.ToggleDisclosure})}),[c,n.disabled]),p=o.useMemo((function(){return{open:a.disclosureState===A.Open}}),[a]);return f(i({},n,{ref:l,id:a.buttonId,type:"button","aria-expanded":a.disclosureState===A.Open||void 0,"aria-controls":a.linkedPanel?a.panelId:void 0,onKeyDown:s,onClick:d}),p,"button")})),z=n.RenderStrategy|n.Static,J=p((function e(n,t){var r=V([K.name,e.name].join(".")),a=r[0],c=r[1],l=m(t,(function(){a.linkedPanel||c({type:j.LinkPanel})}));o.useEffect((function(){return function(){return c({type:j.UnlinkPanel})}}),[c]),u.useEffect((function(){var e;a.disclosureState!==A.Closed||null!=(e=n.unmount)&&!e||c({type:j.UnlinkPanel})}),[a.disclosureState,n.unmount,c]);var s=u.useMemo((function(){return{open:a.disclosureState===A.Open}}),[a]);return f(i({},n,{ref:l,id:a.panelId}),s,"div",z,a.disclosureState===A.Open)}));function X(){var e=[],n={requestAnimationFrame:function(e){function n(){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(){var e=requestAnimationFrame.apply(void 0,arguments);n.add((function(){return cancelAnimationFrame(e)}))})),nextFrame:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.requestAnimationFrame((function(){n.requestAnimationFrame.apply(n,t)}))},setTimeout:function(e){function n(){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(){var e=setTimeout.apply(void 0,arguments);n.add((function(){return clearTimeout(e)}))})),add:function(n){e.push(n)},dispose:function(){for(var n,t=l(e.splice(0));!(n=t()).done;)(0,n.value)()}};return n}function Z(){var e=o.useState(X)[0];return o.useEffect((function(){return function(){return e.dispose()}}),[e]),e}function ee(e,n){var t=o.useState(e),r=t[0],u=t[1],i=o.useRef(e);return y((function(){i.current=e}),[e]),y((function(){return u(i.current)}),[i,u].concat(n)),r}function ne(e,n){var t=n.resolveItems();if(t.length<=0)return null;var r=n.resolveActiveIndex(),o=null!=r?r:-1,u=function(){switch(e.focus){case q.First:return t.findIndex((function(e){return!n.resolveDisabled(e)}));case q.Previous:var r=t.slice().reverse().findIndex((function(e,t,r){return!(-1!==o&&r.length-t-1>=o||n.resolveDisabled(e))}));return-1===r?r:t.length-1-r;case q.Next:return t.findIndex((function(e,t){return!(t<=o||n.resolveDisabled(e))}));case q.Last:var u=t.slice().reverse().findIndex((function(e){return!n.resolveDisabled(e)}));return-1===u?u:t.length-1-u;case q.Specific:return t.findIndex((function(t){return n.resolveId(t)===e.id}));case q.Nothing:return null;default:!function(e){throw new Error("Unexpected object: "+e)}(e)}}();return-1===u?r:u}function te(e,n){if(void 0!==e)return"function"==typeof e?e(n):e}K.Button=$,K.Panel=J,function(e){e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing"}(q||(q={})),function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(W||(W={})),function(e){e[e.OpenListbox=0]="OpenListbox",e[e.CloseListbox=1]="CloseListbox",e[e.GoToOption=2]="GoToOption",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.RegisterOption=5]="RegisterOption",e[e.UnregisterOption=6]="UnregisterOption"}(_||(_={}));var re=((Y={})[_.CloseListbox]=function(e){return i({},e,{activeOptionIndex:null,listboxState:W.Closed})},Y[_.OpenListbox]=function(e){return i({},e,{listboxState:W.Open})},Y[_.GoToOption]=function(e,n){var t=ne(n,{resolveItems:function(){return e.options},resolveActiveIndex:function(){return e.activeOptionIndex},resolveId:function(e){return e.id},resolveDisabled:function(e){return e.dataRef.current.disabled}});return""===e.searchQuery&&e.activeOptionIndex===t?e:i({},e,{searchQuery:"",activeOptionIndex:t})},Y[_.Search]=function(e,n){var t=e.searchQuery+n.value,r=e.options.findIndex((function(e){var n;return!e.dataRef.current.disabled&&(null==(n=e.dataRef.current.textValue)?void 0:n.startsWith(t))}));return i({},e,-1===r||r===e.activeOptionIndex?{searchQuery:t}:{searchQuery:t,activeOptionIndex:r})},Y[_.ClearSearch]=function(e){return i({},e,{searchQuery:""})},Y[_.RegisterOption]=function(e,n){return i({},e,{options:[].concat(e.options,[{id:n.id,dataRef:n.dataRef}])})},Y[_.UnregisterOption]=function(e,n){var t=e.options.slice(),r=null!==e.activeOptionIndex?t[e.activeOptionIndex]:null,o=t.findIndex((function(e){return e.id===n.id}));return-1!==o&&t.splice(o,1),i({},e,{options:t,activeOptionIndex:o===e.activeOptionIndex||null===r?null:t.indexOf(r)})},Y),oe=o.createContext(null);function ue(e){var n=o.useContext(oe);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+ce.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,ue),t}return n}function ie(e,n){return s(n.type,re,e,n)}oe.displayName="ListboxContext";var ae=o.Fragment;function ce(e){var n=e.value,t=e.onChange,r=a(e,["value","onChange"]),i=Z(),c=o.useReducer(ie,{listboxState:W.Closed,propsRef:{current:{value:n,onChange:t}},labelRef:o.createRef(),buttonRef:o.createRef(),optionsRef:o.createRef(),options:[],searchQuery:"",activeOptionIndex:null}),l=c[0],s=l.listboxState,d=l.propsRef,p=l.optionsRef,v=l.buttonRef,m=c[1];y((function(){d.current.value=n}),[n,d]),y((function(){d.current.onChange=t}),[t,d]),o.useEffect((function(){function e(e){var n,t,r,o=e.target,u=document.activeElement;s===W.Open&&((null==(n=v.current)?void 0:n.contains(o))||((null==(t=p.current)?void 0:t.contains(o))||m({type:_.CloseListbox}),u!==document.body&&(null==u?void 0:u.contains(o))||e.defaultPrevented||null==(r=v.current)||r.focus({preventScroll:!0})))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[s,p,v,i,m]);var b=o.useMemo((function(){return{open:s===W.Open}}),[s]);return u.createElement(oe.Provider,{value:c},f(r,b,ae))}var le,se,fe,de=p((function e(n,t){var u,a=ue([ce.name,e.name].join(".")),c=a[0],l=a[1],s=m(c.buttonRef,t),d="headlessui-listbox-button-"+x(),p=Z(),v=o.useCallback((function(e){switch(e.key){case r.Space:case r.Enter:case r.ArrowDown:e.preventDefault(),l({type:_.OpenListbox}),p.nextFrame((function(){var e;null==(e=c.optionsRef.current)||e.focus({preventScroll:!0}),c.propsRef.current.value||l({type:_.GoToOption,focus:q.First})}));break;case r.ArrowUp:e.preventDefault(),l({type:_.OpenListbox}),p.nextFrame((function(){var e;null==(e=c.optionsRef.current)||e.focus({preventScroll:!0}),c.propsRef.current.value||l({type:_.GoToOption,focus:q.Last})}))}}),[l,c,p]),y=o.useCallback((function(e){if(b(e.currentTarget))return e.preventDefault();n.disabled||(c.listboxState===W.Open?(l({type:_.CloseListbox}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),l({type:_.OpenListbox}),p.nextFrame((function(){var e;return null==(e=c.optionsRef.current)?void 0:e.focus({preventScroll:!0})}))))}),[l,p,c,n.disabled]),h=ee((function(){if(c.labelRef.current)return[c.labelRef.current.id,d].join(" ")}),[c.labelRef.current,d]),S=o.useMemo((function(){return{open:c.listboxState===W.Open}}),[c]);return f(i({},n,{ref:s,id:d,type:"button","aria-haspopup":!0,"aria-controls":null==(u=c.optionsRef.current)?void 0:u.id,"aria-expanded":c.listboxState===W.Open||void 0,"aria-labelledby":h,onKeyDown:v,onClick:y}),S,"button")})),pe=n.RenderStrategy|n.Static,ve=p((function e(n,t){var u,a=ue([ce.name,e.name].join(".")),c=a[0],l=a[1],s=m(c.optionsRef,t),d="headlessui-listbox-options-"+x(),p=Z(),v=Z(),b=o.useCallback((function(e){switch(v.dispose(),e.key){case r.Space:if(""!==c.searchQuery)return e.preventDefault(),l({type:_.Search,value:e.key});case r.Enter:e.preventDefault(),l({type:_.CloseListbox}),null!==c.activeOptionIndex&&c.propsRef.current.onChange(c.options[c.activeOptionIndex].dataRef.current.value),X().nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case r.ArrowDown:return e.preventDefault(),l({type:_.GoToOption,focus:q.Next});case r.ArrowUp:return e.preventDefault(),l({type:_.GoToOption,focus:q.Previous});case r.Home:case r.PageUp:return e.preventDefault(),l({type:_.GoToOption,focus:q.First});case r.End:case r.PageDown:return e.preventDefault(),l({type:_.GoToOption,focus:q.Last});case r.Escape:return e.preventDefault(),l({type:_.CloseListbox}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));case r.Tab:return e.preventDefault();default:1===e.key.length&&(l({type:_.Search,value:e.key}),v.setTimeout((function(){return l({type:_.ClearSearch})}),350))}}),[p,l,v,c]),y=ee((function(){var e,n,t;return null!=(e=null==(n=c.labelRef.current)?void 0:n.id)?e:null==(t=c.buttonRef.current)?void 0:t.id}),[c.labelRef.current,c.buttonRef.current]),h=o.useMemo((function(){return{open:c.listboxState===W.Open}}),[c]);return f(i({},n,{"aria-activedescendant":null===c.activeOptionIndex||null==(u=c.options[c.activeOptionIndex])?void 0:u.id,"aria-labelledby":y,id:d,onKeyDown:b,role:"listbox",tabIndex:0,ref:s}),h,"ul",pe,c.listboxState===W.Open)}));ce.Button=de,ce.Label=function e(n){var t=ue([ce.name,e.name].join("."))[0],r="headlessui-listbox-label-"+x(),u=o.useCallback((function(){var e;return null==(e=t.buttonRef.current)?void 0:e.focus({preventScroll:!0})}),[t.buttonRef]),a=o.useMemo((function(){return{open:t.listboxState===W.Open}}),[t]);return f(i({},n,{ref:t.labelRef,id:r,onClick:u}),a,"label")},ce.Options=ve,ce.Option=function e(n){var t=n.disabled,r=void 0!==t&&t,u=n.value,c=n.className,l=a(n,["disabled","value","className"]),s=ue([ce.name,e.name].join(".")),d=s[0],p=s[1],v="headlessui-listbox-option-"+x(),m=null!==d.activeOptionIndex&&d.options[d.activeOptionIndex].id===v,b=d.propsRef.current.value===u,h=o.useRef({disabled:r,value:u});y((function(){h.current.disabled=r}),[h,r]),y((function(){h.current.value=u}),[h,u]),y((function(){var e,n;h.current.textValue=null==(e=document.getElementById(v))||null==(n=e.textContent)?void 0:n.toLowerCase()}),[h,v]);var S=o.useCallback((function(){return d.propsRef.current.onChange(u)}),[d.propsRef,u]);y((function(){return p({type:_.RegisterOption,id:v,dataRef:h}),function(){return p({type:_.UnregisterOption,id:v})}}),[h,v]),y((function(){var e;d.listboxState===W.Open&&b&&(p({type:_.GoToOption,focus:q.Specific,id:v}),null==(e=document.getElementById(v))||null==e.focus||e.focus())}),[d.listboxState]),y((function(){if(d.listboxState===W.Open&&m){var e=X();return e.nextFrame((function(){var e;return null==(e=document.getElementById(v))||null==e.scrollIntoView?void 0:e.scrollIntoView({block:"nearest"})})),e.dispose}}),[m,d.listboxState]);var g=o.useCallback((function(e){if(r)return e.preventDefault();S(),p({type:_.CloseListbox}),X().nextFrame((function(){var e;return null==(e=d.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))}),[p,d.buttonRef,r,S]),E=o.useCallback((function(){if(r)return p({type:_.GoToOption,focus:q.Nothing});p({type:_.GoToOption,focus:q.Specific,id:v})}),[r,v,p]),C=o.useCallback((function(){r||m||p({type:_.GoToOption,focus:q.Specific,id:v})}),[r,m,v,p]),w=o.useCallback((function(){r||m&&p({type:_.GoToOption,focus:q.Nothing})}),[r,m,p]),I=o.useMemo((function(){return{active:m,selected:b,disabled:r}}),[m,b,r]);return f(i({},l,{id:v,role:"option",tabIndex:-1,className:te(c,I),"aria-disabled":!0===r||void 0,"aria-selected":!0===b||void 0,onClick:g,onFocus:E,onPointerMove:C,onMouseMove:C,onPointerLeave:w,onMouseLeave:w}),I,"li")},function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(se||(se={})),function(e){e[e.OpenMenu=0]="OpenMenu",e[e.CloseMenu=1]="CloseMenu",e[e.GoToItem=2]="GoToItem",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.RegisterItem=5]="RegisterItem",e[e.UnregisterItem=6]="UnregisterItem"}(fe||(fe={}));var me=((le={})[fe.CloseMenu]=function(e){return i({},e,{activeItemIndex:null,menuState:se.Closed})},le[fe.OpenMenu]=function(e){return i({},e,{menuState:se.Open})},le[fe.GoToItem]=function(e,n){var t=ne(n,{resolveItems:function(){return e.items},resolveActiveIndex:function(){return e.activeItemIndex},resolveId:function(e){return e.id},resolveDisabled:function(e){return e.dataRef.current.disabled}});return""===e.searchQuery&&e.activeItemIndex===t?e:i({},e,{searchQuery:"",activeItemIndex:t})},le[fe.Search]=function(e,n){var t=e.searchQuery+n.value,r=e.items.findIndex((function(e){var n;return(null==(n=e.dataRef.current.textValue)?void 0:n.startsWith(t))&&!e.dataRef.current.disabled}));return i({},e,-1===r||r===e.activeItemIndex?{searchQuery:t}:{searchQuery:t,activeItemIndex:r})},le[fe.ClearSearch]=function(e){return i({},e,{searchQuery:""})},le[fe.RegisterItem]=function(e,n){return i({},e,{items:[].concat(e.items,[{id:n.id,dataRef:n.dataRef}])})},le[fe.UnregisterItem]=function(e,n){var t=e.items.slice(),r=null!==e.activeItemIndex?t[e.activeItemIndex]:null,o=t.findIndex((function(e){return e.id===n.id}));return-1!==o&&t.splice(o,1),i({},e,{items:t,activeItemIndex:o===e.activeItemIndex||null===r?null:t.indexOf(r)})},le),be=o.createContext(null);function ye(e){var n=o.useContext(be);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+ge.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,ye),t}return n}function he(e,n){return s(n.type,me,e,n)}be.displayName="MenuContext";var Se=o.Fragment;function ge(e){var n=o.useReducer(he,{menuState:se.Closed,buttonRef:o.createRef(),itemsRef:o.createRef(),items:[],searchQuery:"",activeItemIndex:null}),t=n[0],r=t.menuState,i=t.itemsRef,a=t.buttonRef,c=n[1];o.useEffect((function(){function e(e){var n,t,o,u=e.target,l=document.activeElement;r===se.Open&&((null==(n=a.current)?void 0:n.contains(u))||((null==(t=i.current)?void 0:t.contains(u))||c({type:fe.CloseMenu}),l!==document.body&&(null==l?void 0:l.contains(u))||e.defaultPrevented||null==(o=a.current)||o.focus({preventScroll:!0})))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[r,i,a,c]);var l=o.useMemo((function(){return{open:r===se.Open}}),[r]);return u.createElement(be.Provider,{value:n},f(e,l,Se))}var xe=p((function e(n,t){var u,a=ye([ge.name,e.name].join(".")),c=a[0],l=a[1],s=m(c.buttonRef,t),d="headlessui-menu-button-"+x(),p=Z(),v=o.useCallback((function(e){switch(e.key){case r.Space:case r.Enter:case r.ArrowDown:e.preventDefault(),l({type:fe.OpenMenu}),p.nextFrame((function(){var e;null==(e=c.itemsRef.current)||e.focus({preventScroll:!0}),l({type:fe.GoToItem,focus:q.First})}));break;case r.ArrowUp:e.preventDefault(),l({type:fe.OpenMenu}),p.nextFrame((function(){var e;null==(e=c.itemsRef.current)||e.focus({preventScroll:!0}),l({type:fe.GoToItem,focus:q.Last})}))}}),[l,c,p]),y=o.useCallback((function(e){if(b(e.currentTarget))return e.preventDefault();n.disabled||(c.menuState===se.Open?(l({type:fe.CloseMenu}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),l({type:fe.OpenMenu}),p.nextFrame((function(){var e;return null==(e=c.itemsRef.current)?void 0:e.focus({preventScroll:!0})}))))}),[l,p,c,n.disabled]),h=o.useMemo((function(){return{open:c.menuState===se.Open}}),[c]);return f(i({},n,{ref:s,id:d,type:"button","aria-haspopup":!0,"aria-controls":null==(u=c.itemsRef.current)?void 0:u.id,"aria-expanded":c.menuState===se.Open||void 0,onKeyDown:v,onClick:y}),h,"button")})),Ee=n.RenderStrategy|n.Static,Ce=p((function e(n,t){var u,a,c=ye([ge.name,e.name].join(".")),l=c[0],s=c[1],d=m(l.itemsRef,t),p="headlessui-menu-items-"+x(),v=Z(),b=o.useCallback((function(e){switch(v.dispose(),e.key){case r.Space:if(""!==l.searchQuery)return e.preventDefault(),s({type:fe.Search,value:e.key});case r.Enter:var n;e.preventDefault(),s({type:fe.CloseMenu}),null!==l.activeItemIndex&&(null==(n=document.getElementById(l.items[l.activeItemIndex].id))||n.click()),X().nextFrame((function(){var e;return null==(e=l.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case r.ArrowDown:return e.preventDefault(),s({type:fe.GoToItem,focus:q.Next});case r.ArrowUp:return e.preventDefault(),s({type:fe.GoToItem,focus:q.Previous});case r.Home:case r.PageUp:return e.preventDefault(),s({type:fe.GoToItem,focus:q.First});case r.End:case r.PageDown:return e.preventDefault(),s({type:fe.GoToItem,focus:q.Last});case r.Escape:e.preventDefault(),s({type:fe.CloseMenu}),X().nextFrame((function(){var e;return null==(e=l.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case r.Tab:return e.preventDefault();default:1===e.key.length&&(s({type:fe.Search,value:e.key}),v.setTimeout((function(){return s({type:fe.ClearSearch})}),350))}}),[s,v,l]),y=o.useMemo((function(){return{open:l.menuState===se.Open}}),[l]);return f(i({},n,{"aria-activedescendant":null===l.activeItemIndex||null==(u=l.items[l.activeItemIndex])?void 0:u.id,"aria-labelledby":null==(a=l.buttonRef.current)?void 0:a.id,id:p,onKeyDown:b,role:"menu",tabIndex:0,ref:d}),y,"div",Ee,l.menuState===se.Open)})),we=o.Fragment;ge.Button=xe,ge.Items=Ce,ge.Item=function e(n){var t=n.disabled,r=void 0!==t&&t,u=n.className,c=n.onClick,l=a(n,["disabled","className","onClick"]),s=ye([ge.name,e.name].join(".")),d=s[0],p=s[1],v="headlessui-menu-item-"+x(),m=null!==d.activeItemIndex&&d.items[d.activeItemIndex].id===v,b=o.useRef({disabled:r});y((function(){b.current.disabled=r}),[b,r]),y((function(){var e,n;b.current.textValue=null==(e=document.getElementById(v))||null==(n=e.textContent)?void 0:n.toLowerCase()}),[b,v]),y((function(){return p({type:fe.RegisterItem,id:v,dataRef:b}),function(){return p({type:fe.UnregisterItem,id:v})}}),[b,v]);var h=o.useCallback((function(e){return r?e.preventDefault():(p({type:fe.CloseMenu}),X().nextFrame((function(){var e;return null==(e=d.buttonRef.current)?void 0:e.focus({preventScroll:!0})})),c?c(e):void 0)}),[p,d.buttonRef,r,c]),S=o.useCallback((function(){if(r)return p({type:fe.GoToItem,focus:q.Nothing});p({type:fe.GoToItem,focus:q.Specific,id:v})}),[r,v,p]),g=o.useCallback((function(){r||m||p({type:fe.GoToItem,focus:q.Specific,id:v})}),[r,m,v,p]),E=o.useCallback((function(){r||m&&p({type:fe.GoToItem,focus:q.Nothing})}),[r,m,p]),C=o.useMemo((function(){return{active:m,disabled:r}}),[m,r]);return f(i({},l,{id:v,role:"menuitem",tabIndex:-1,className:te(u,C),"aria-disabled":!0===r||void 0,onClick:h,onFocus:S,onPointerMove:g,onMouseMove:g,onPointerLeave:E,onMouseLeave:E}),C,we)};var Ie=o.createContext(null);function Oe(e){var n=o.useContext(Ie);if(null===n){var t=new Error("<"+e+" /> is missing a parent <Switch.Group /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,Oe),t}return n}Ie.displayName="GroupContext";var ke,Re=o.Fragment;function Te(e){var n,t,u=e.checked,c=e.onChange,l=e.className,s=a(e,["checked","onChange","className"]),d="headlessui-switch-"+x(),p=o.useContext(Ie),v=o.useCallback((function(){return c(!u)}),[c,u]),m=o.useCallback((function(e){if(b(e.currentTarget))return e.preventDefault();e.preventDefault(),v()}),[v]),y=o.useCallback((function(e){e.key!==r.Tab&&e.preventDefault(),e.key===r.Space&&v()}),[v]),h=o.useCallback((function(e){return e.preventDefault()}),[]),S=o.useMemo((function(){return{checked:u}}),[u]),g={id:d,ref:null===p?void 0:p.setSwitch,role:"switch",tabIndex:0,className:te(l,S),"aria-checked":u,"aria-labelledby":null==p||null==(n=p.label)?void 0:n.id,"aria-describedby":null==p||null==(t=p.description)?void 0:t.id,onClick:m,onKeyUp:y,onKeyPress:h};return"button"===s.as&&Object.assign(g,{type:"button"}),f(i({},s,g),S,"button")}function De(){var e=o.useRef(!0);return o.useEffect((function(){e.current=!1}),[]),e.current}function Le(e){for(var n,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e&&r.length>0&&(n=e.classList).add.apply(n,r)}function Fe(e){for(var n,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e&&r.length>0&&(n=e.classList).remove.apply(n,r)}function Pe(e,n,t,r,o){var u=X(),i=void 0!==o?function(e){var n={called:!1};return function(){if(!n.called)return n.called=!0,e.apply(void 0,arguments)}}(o):function(){};return Le.apply(void 0,[e].concat(n,t)),u.nextFrame((function(){Fe.apply(void 0,[e].concat(t)),Le.apply(void 0,[e].concat(r)),u.add(function(e,n){var t=X();if(!e)return t.dispose;var r=getComputedStyle(e),o=[r.transitionDuration,r.transitionDelay].map((function(e){var n=e.split(",").filter(Boolean).map((function(e){return e.includes("ms")?parseFloat(e):1e3*parseFloat(e)})).sort((function(e,n){return n-e}))[0];return void 0===n?0:n})),u=o[0];return 0!==u?t.setTimeout((function(){n(ke.Finished)}),u+o[1]):n(ke.Finished),t.add((function(){return n(ke.Cancelled)})),t.dispose}(e,(function(t){return Fe.apply(void 0,[e].concat(r,n)),i(t)})))})),u.add((function(){return Fe.apply(void 0,[e].concat(n,t,r))})),u.add((function(){return i(ke.Cancelled)})),u.dispose}function Me(e){return void 0===e&&(e=""),o.useMemo((function(){return e.split(" ").filter((function(e){return e.trim().length>1}))}),[e])}Te.Group=function(e){var n=o.useState(null),t=n[0],r=n[1],i=o.useState(null),a=i[0],c=i[1],l=o.useState(null),s=l[0],d=l[1],p=o.useMemo((function(){return{switch:t,setSwitch:r,label:a,setLabel:c,description:s,setDescription:d}}),[t,r,a,c,s,d]);return u.createElement(Ie.Provider,{value:p},f(e,{},Re))},Te.Label=function e(n){var t=Oe([Te.name,e.name].join(".")),r="headlessui-switch-label-"+x(),u=o.useCallback((function(){t.switch&&(t.switch.click(),t.switch.focus({preventScroll:!0}))}),[t.switch]);return f(i({},n,{ref:t.setLabel,id:r,onClick:u}),{},"label")},Te.Description=function e(n){var t=Oe([Te.name,e.name].join(".")),r="headlessui-switch-description-"+x();return f(i({},n,{ref:t.setDescription,id:r}),{},"p")},function(e){e.Finished="finished",e.Cancelled="cancelled"}(ke||(ke={}));var Ae,je=o.createContext(null);je.displayName="TransitionContext",function(e){e.Visible="visible",e.Hidden="hidden"}(Ae||(Ae={}));var Ne=o.createContext(null);function Ue(e){return"children"in e?Ue(e.children):e.current.filter((function(e){return e.state===Ae.Visible})).length>0}function Ge(e){var n=o.useRef(e),r=o.useRef([]),u=function(){var e=o.useRef(!0);return o.useEffect((function(){return function(){e.current=!1}}),[]),e}();o.useEffect((function(){n.current=e}),[e]);var i=o.useCallback((function(e,o){var i;void 0===o&&(o=t.Hidden);var a=r.current.findIndex((function(n){return n.id===e}));-1!==a&&(s(o,((i={})[t.Unmount]=function(){r.current.splice(a,1)},i[t.Hidden]=function(){r.current[a].state=Ae.Hidden},i)),!Ue(r)&&u.current&&(null==n.current||n.current()))}),[n,u,r]),a=o.useCallback((function(e){var n=r.current.find((function(n){return n.id===e}));return n?n.state!==Ae.Visible&&(n.state=Ae.Visible):r.current.push({id:e,state:Ae.Visible}),function(){return i(e,t.Unmount)}}),[r,i]);return o.useMemo((function(){return{children:r,register:a,unregister:i}}),[a,i,r])}function He(){}Ne.displayName="NestingContext";var Ve=["beforeEnter","afterEnter","beforeLeave","afterLeave"];function Qe(e){for(var n,t={},r=l(Ve);!(n=r()).done;){var o,u=n.value;t[u]=null!=(o=e[u])?o:He}return t}var Be=n.RenderStrategy;function Ke(e){var n=e.beforeEnter,r=e.afterEnter,c=e.beforeLeave,l=e.afterLeave,d=e.enter,p=e.enterFrom,v=e.enterTo,m=e.leave,b=e.leaveFrom,h=e.leaveTo,S=a(e,["beforeEnter","afterEnter","beforeLeave","afterLeave","enter","enterFrom","enterTo","leave","leaveFrom","leaveTo"]),g=o.useRef(null),E=o.useState(Ae.Visible),C=E[0],w=E[1],I=S.unmount?t.Unmount:t.Hidden,O=function(){var e=o.useContext(je);if(null===e)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition />.");return e}(),k=O.show,R=O.appear,T=function(){var e=o.useContext(Ne);if(null===e)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition />.");return e}(),D=T.register,L=T.unregister,F=De(),P=x(),M=o.useRef(!1),A=Ge((function(){M.current||(w(Ae.Hidden),L(P),Q.current.afterLeave())}));y((function(){if(P)return D(P)}),[D,P]),y((function(){var e;I===t.Hidden&&P&&(k&&C!==Ae.Visible?w(Ae.Visible):s(C,((e={})[Ae.Hidden]=function(){return L(P)},e[Ae.Visible]=function(){return D(P)},e)))}),[C,P,D,L,k,I]);var j=Me(d),N=Me(p),U=Me(v),G=Me(m),H=Me(b),V=Me(h),Q=function(e){var n=o.useRef(Qe(e));return o.useEffect((function(){n.current=Qe(e)}),[e]),n}({beforeEnter:n,afterEnter:r,beforeLeave:c,afterLeave:l});o.useEffect((function(){if(C===Ae.Visible&&null===g.current)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")}),[g,C]);var B=F&&!R;return y((function(){var e=g.current;if(e&&!B)return M.current=!0,k&&Q.current.beforeEnter(),k||Q.current.beforeLeave(),k?Pe(e,j,N,U,(function(e){M.current=!1,e===ke.Finished&&Q.current.afterEnter()})):Pe(e,G,H,V,(function(e){M.current=!1,e===ke.Finished&&(Ue(A)||(w(Ae.Hidden),L(P),Q.current.afterLeave()))}))}),[Q,P,M,L,A,g,B,k,j,N,U,G,H,V]),u.createElement(Ne.Provider,{value:A},f(i({},S,{ref:g}),{},"div",Be,C===Ae.Visible))}function qe(e){var n=e.show,t=e.appear,r=void 0!==t&&t,c=e.unmount,l=a(e,["show","appear","unmount"]);if(![!0,!1].includes(n))throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");var s=o.useState(n?Ae.Visible:Ae.Hidden),d=s[0],p=s[1],v=Ge((function(){p(Ae.Hidden)})),m=De(),b=o.useMemo((function(){return{show:n,appear:r||!m}}),[n,r,m]);o.useEffect((function(){n?p(Ae.Visible):Ue(v)||p(Ae.Hidden)}),[n,v]);var y={unmount:c};return u.createElement(Ne.Provider,{value:v},u.createElement(je.Provider,{value:b},f(i({},y,{as:o.Fragment,children:u.createElement(Ke,Object.assign({},y,l))}),{},o.Fragment,Be,d===Ae.Visible)))}qe.Child=Ke,exports.Dialog=P,exports.Disclosure=K,exports.FocusTrap=function(e){var n=o.useRef(null);return k(n),f(i({},e,{ref:n}),{},"div")},exports.Listbox=ce,exports.Menu=ge,exports.Switch=Te,exports.Transition=qe; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n,t,r,o=require("react"),u=(e=o)&&"object"==typeof e&&"default"in e?e.default:e;function i(){return(i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function a(e,n){if(null==e)return{};var t,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n.indexOf(t=u[r])>=0||(o[t]=e[t]);return o}function c(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function l(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return c(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?c(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}function s(e,n){if(e in n){for(var t=n[e],r=arguments.length,o=new Array(r>2?r-2:0),u=2;u<r;u++)o[u-2]=arguments[u];return"function"==typeof t?t.apply(void 0,o):t}var i=new Error('Tried to handle "'+e+'" but there is no handler defined. Only defined handlers are: '+Object.keys(n).map((function(e){return'"'+e+'"'})).join(", ")+".");throw Error.captureStackTrace&&Error.captureStackTrace(i,s),i}function f(e,r,o,u,c){if(void 0===c&&(c=!0),c)return d(e,r,o);var l=null!=u?u:n.None;if(l&n.Static){var f=e.static,p=void 0!==f&&f,v=a(e,["static"]);if(p)return d(v,r,o)}if(l&n.RenderStrategy){var m,b=e.unmount,y=void 0===b||b,h=a(e,["unmount"]);return s(y?t.Unmount:t.Hidden,((m={})[t.Unmount]=function(){return null},m[t.Hidden]=function(){return d(i({},h,{hidden:!0,style:{display:"none"}}),r,o)},m))}return d(e,r,o)}function d(e,n,t){var r,u=v(e,["unmount","static"]),i=u.as,c=void 0===i?t:i,s=u.children,f=u.refName,p=void 0===f?"ref":f,m=a(u,["as","children","refName"]),b=void 0!==e.ref?((r={})[p]=e.ref,r):{},y="function"==typeof s?s(n):s;if(c===o.Fragment&&Object.keys(m).length>0){if(Array.isArray(y)&&y.length>1){var h=new Error("You should only render 1 child");throw Error.captureStackTrace&&Error.captureStackTrace(h,d),h}if(!o.isValidElement(y)){var S=new Error('You should render an element as a child. Did you forget the as="..." prop?');throw Error.captureStackTrace&&Error.captureStackTrace(S,d),S}return o.cloneElement(y,Object.assign({},function(e,n,t){for(var r,o=Object.assign({},e),u=function(){var t,u=r.value;void 0!==e[u]&&void 0!==n[u]&&Object.assign(o,((t={})[u]=function(t){t.defaultPrevented||e[u](t),t.defaultPrevented||n[u](t)},t))},i=l(["onClick"]);!(r=i()).done;)u();return o}(function(e){var n=Object.assign({},e);for(var t in n)void 0===n[t]&&delete n[t];return n}(v(m,["ref"])),y.props),b))}return o.createElement(c,Object.assign({},v(m,["ref"]),c!==o.Fragment&&b),y)}function p(e){return o.forwardRef(e)}function v(e,n){void 0===n&&(n=[]);for(var t,r=Object.assign({},e),o=l(n);!(t=o()).done;){var u=t.value;u in r&&delete r[u]}return r}function m(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return o.useCallback((function(e){n.forEach((function(n){if(null!==n)return"function"==typeof n?n(e):void(n.current=e)}))}),[n])}function b(e){for(var n,t,r=e.parentElement,o=null;r&&!(r instanceof HTMLFieldSetElement);)r instanceof HTMLLegendElement&&(o=r),r=r.parentElement;var u=null!=(n=""===(null==(t=r)?void 0:t.getAttribute("disabled")))&&n;return(!u||!function(e){if(!e)return!1;for(var n=e.previousElementSibling;null!==n;){if(n instanceof HTMLLegendElement)return!1;n=n.previousElementSibling}return!0}(o))&&u}!function(e){e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static"}(n||(n={})),function(e){e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden"}(t||(t={})),function(e){e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.ArrowUp="ArrowUp",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab"}(r||(r={}));var y="undefined"!=typeof window?o.useLayoutEffect:o.useEffect,h={serverHandoffComplete:!1},S=0;function g(){return++S}function x(){var e=o.useState(h.serverHandoffComplete?g:null),n=e[0],t=e[1];return y((function(){null===n&&t(g())}),[n]),o.useEffect((function(){!1===h.serverHandoffComplete&&(h.serverHandoffComplete=!0)}),[]),null!=n?""+n:void 0}var E,C,w,I=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map((function(e){return e+":not([tabindex='-1'])"})).join(",");function O(e){e&&e.focus({preventScroll:!0})}function k(e,n){void 0===n&&(n=!0);var t=o.useRef(null),u=o.useRef(null),i=o.useRef(!1),a=o.useCallback((function(){return e.current?Array.from(e.current.querySelectorAll(I)):[]}),[e]);y((function(){if(n){i.current=!0,t.current=document.activeElement;var e=a();if(e.length<=0)throw new Error("There are no focusable elements inside the <FocusTrap />");return function n(t){void 0!==t&&(O(t),document.activeElement!==t?n(e[e.indexOf(t)+1]):u.current=t)}(e[0]),function(){i.current=!1,O(t.current),t.current=null,u.current=null}}}),[n,i]),y((function(){if(n)return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)};function e(e){if(e.key===r.Tab&&document.activeElement){e.preventDefault();var n=e.shiftKey?-1:1,t=a(),o=t.length;!function e(r){void 0===r&&(r=0);var i=t.indexOf(document.activeElement),a=t[(i+o+n+r)%o];O(a),a!==document.activeElement?e(r+n):u.current=a}()}}}),[n,a]),y((function(){if(n&&e.current){var t=e.current;return window.addEventListener("focus",r,!0),function(){return window.removeEventListener("focus",r,!0)}}function r(e){var n=u.current;if(n&&i.current){var r=e.target;r&&r instanceof HTMLElement?t.contains(r)?(u.current=r,O(r)):(e.preventDefault(),e.stopPropagation(),O(n)):O(u.current)}}}),[n,i,e])}!function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(C||(C={})),function(e){e[e.SetTitleElement=0]="SetTitleElement",e[e.SetDescriptionElement=1]="SetDescriptionElement"}(w||(w={}));var R=((E={})[w.SetTitleElement]=function(e,n){return e.titleElement===n.element?e:i({},e,{titleElement:n.element})},E[w.SetDescriptionElement]=function(e,n){return e.descriptionElement===n.element?e:i({},e,{descriptionElement:n.element})},E),T=o.createContext(null);function D(e){var n=o.useContext(T);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+P.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,D),t}return n}function L(e,n){return s(n.type,R,e,n)}T.displayName="DialogContext";var F=n.RenderStrategy|n.Static;function P(e){var n,t,c=e.open,l=e.onClose,s=a(e,["open","onClose"]),d=o.useRef(null),p=e.hasOwnProperty("open"),v=e.hasOwnProperty("onClose");if(!p)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!v)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if("boolean"!=typeof c)throw new Error("You provided an `open` prop to the `Dialog`, but the value is not a boolean. Received: "+c);if("function"!=typeof l)throw new Error("You provided an `onClose` prop to the `Dialog`, but the value is not a function. Received: "+l);var m=c?C.Open:C.Closed,b=o.useReducer(L,{titleElement:null,descriptionElement:null}),y=b[0],h=b[1],S=o.useCallback((function(){return l(!1)}),[l]),g=o.useCallback((function(e){return h({type:w.SetTitleElement,element:e})}),[h]),E=o.useCallback((function(e){return h({type:w.SetDescriptionElement,element:e})}),[h]);o.useEffect((function(){function e(e){e.key===r.Escape&&m===C.Open&&S()}return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}}),[S,m]),k(d,!!e.static||m===C.Open);var I="headlessui-dialog-"+x(),O=o.useMemo((function(){return[{dialogState:m,close:S,setTitle:g,setDescription:E},y]}),[m,y,S,g,E]),R=o.useMemo((function(){return{open:m===C.Open,close:S}}),[m,S]),D={ref:d,id:I,role:"dialog","aria-modal":!0,"aria-labelledby":null==(n=y.titleElement)?void 0:n.id,"aria-describedby":null==(t=y.descriptionElement)?void 0:t.id};return u.createElement(T.Provider,{value:O},f(i({},s,D),R,"div",F,m===C.Open))}var M,A,j,N=p((function e(n,t){var r=D([P.name,e.name].join("."))[0],u=r.dialogState,a=r.close,c=m(t),l="headlessui-dialog-overlay-"+x(),s=o.useCallback((function(e){if(b(e.currentTarget))return e.preventDefault();a()}),[a]),d=o.useMemo((function(){return{open:u===C.Open}}),[u]);return f(i({},n,{ref:c,id:l,"aria-hidden":!0,onClick:s}),d,"div")}));P.Overlay=N,P.Title=function e(n){var t=D([P.name,e.name].join("."))[0],r=t.dialogState,u=t.setTitle,a="headlessui-dialog-title-"+x(),c=o.useMemo((function(){return{open:r===C.Open}}),[r]);return f(i({},n,{ref:u,id:a}),c,"h2")},P.Description=function e(n){var t=D([P.name,e.name].join("."))[0],r=t.dialogState,u=t.setDescription,a="headlessui-dialog-description-"+x(),c=o.useMemo((function(){return{open:r===C.Open}}),[r]);return f(i({},n,{ref:u,id:a}),c,"p")},function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(A||(A={})),function(e){e[e.ToggleDisclosure=0]="ToggleDisclosure",e[e.SetButtonId=1]="SetButtonId",e[e.SetPanelId=2]="SetPanelId",e[e.LinkPanel=3]="LinkPanel",e[e.UnlinkPanel=4]="UnlinkPanel"}(j||(j={}));var U=((M={})[j.ToggleDisclosure]=function(e){var n;return i({},e,{disclosureState:s(e.disclosureState,(n={},n[A.Open]=A.Closed,n[A.Closed]=A.Open,n))})},M[j.LinkPanel]=function(e){return i({},e,{linkedPanel:!0})},M[j.UnlinkPanel]=function(e){return i({},e,{linkedPanel:!1})},M[j.SetButtonId]=function(e,n){return i({},e,{buttonId:n.buttonId})},M[j.SetPanelId]=function(e,n){return i({},e,{panelId:n.panelId})},M),G=o.createContext(null);function H(e){var n=o.useContext(G);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+B.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,H),t}return n}function V(e,n){return s(n.type,U,e,n)}G.displayName="DisclosureContext";var Q=o.Fragment;function B(e){var n="headlessui-disclosure-button-"+x(),t="headlessui-disclosure-panel-"+x(),r=o.useReducer(V,{disclosureState:A.Closed,linkedPanel:!1,buttonId:n,panelId:t}),i=r[0].disclosureState,a=r[1];o.useEffect((function(){return a({type:j.SetButtonId,buttonId:n})}),[n,a]),o.useEffect((function(){return a({type:j.SetPanelId,panelId:t})}),[t,a]);var c=o.useMemo((function(){return{open:i===A.Open}}),[i]);return u.createElement(G.Provider,{value:r},f(e,c,Q))}var K,q,Y,W,_=p((function e(n,t){var u=H([B.name,e.name].join(".")),a=u[0],c=u[1],l=m(t),s=o.useCallback((function(e){switch(e.key){case r.Space:case r.Enter:e.preventDefault(),c({type:j.ToggleDisclosure})}}),[c]),d=o.useCallback((function(e){b(e.currentTarget)||n.disabled||c({type:j.ToggleDisclosure})}),[c,n.disabled]),p=o.useMemo((function(){return{open:a.disclosureState===A.Open}}),[a]);return f(i({},n,{ref:l,id:a.buttonId,type:"button","aria-expanded":a.disclosureState===A.Open||void 0,"aria-controls":a.linkedPanel?a.panelId:void 0,onKeyDown:s,onClick:d}),p,"button")})),$=n.RenderStrategy|n.Static,z=p((function e(n,t){var r=H([B.name,e.name].join(".")),a=r[0],c=r[1],l=m(t,(function(){a.linkedPanel||c({type:j.LinkPanel})}));o.useEffect((function(){return function(){return c({type:j.UnlinkPanel})}}),[c]),u.useEffect((function(){var e;a.disclosureState!==A.Closed||null!=(e=n.unmount)&&!e||c({type:j.UnlinkPanel})}),[a.disclosureState,n.unmount,c]);var s=u.useMemo((function(){return{open:a.disclosureState===A.Open}}),[a]);return f(i({},n,{ref:l,id:a.panelId}),s,"div",$,a.disclosureState===A.Open)}));function J(){var e=[],n={requestAnimationFrame:function(e){function n(){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(){var e=requestAnimationFrame.apply(void 0,arguments);n.add((function(){return cancelAnimationFrame(e)}))})),nextFrame:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.requestAnimationFrame((function(){n.requestAnimationFrame.apply(n,t)}))},setTimeout:function(e){function n(){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(){var e=setTimeout.apply(void 0,arguments);n.add((function(){return clearTimeout(e)}))})),add:function(n){e.push(n)},dispose:function(){for(var n,t=l(e.splice(0));!(n=t()).done;)(0,n.value)()}};return n}function X(){var e=o.useState(J)[0];return o.useEffect((function(){return function(){return e.dispose()}}),[e]),e}function Z(e,n){var t=o.useState(e),r=t[0],u=t[1],i=o.useRef(e);return y((function(){i.current=e}),[e]),y((function(){return u(i.current)}),[i,u].concat(n)),r}function ee(e,n){var t=n.resolveItems();if(t.length<=0)return null;var r=n.resolveActiveIndex(),o=null!=r?r:-1,u=function(){switch(e.focus){case K.First:return t.findIndex((function(e){return!n.resolveDisabled(e)}));case K.Previous:var r=t.slice().reverse().findIndex((function(e,t,r){return!(-1!==o&&r.length-t-1>=o||n.resolveDisabled(e))}));return-1===r?r:t.length-1-r;case K.Next:return t.findIndex((function(e,t){return!(t<=o||n.resolveDisabled(e))}));case K.Last:var u=t.slice().reverse().findIndex((function(e){return!n.resolveDisabled(e)}));return-1===u?u:t.length-1-u;case K.Specific:return t.findIndex((function(t){return n.resolveId(t)===e.id}));case K.Nothing:return null;default:!function(e){throw new Error("Unexpected object: "+e)}(e)}}();return-1===u?r:u}function ne(e,n){if(void 0!==e)return"function"==typeof e?e(n):e}B.Button=_,B.Panel=z,function(e){e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing"}(K||(K={})),function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(Y||(Y={})),function(e){e[e.OpenListbox=0]="OpenListbox",e[e.CloseListbox=1]="CloseListbox",e[e.GoToOption=2]="GoToOption",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.RegisterOption=5]="RegisterOption",e[e.UnregisterOption=6]="UnregisterOption"}(W||(W={}));var te=((q={})[W.CloseListbox]=function(e){return i({},e,{activeOptionIndex:null,listboxState:Y.Closed})},q[W.OpenListbox]=function(e){return i({},e,{listboxState:Y.Open})},q[W.GoToOption]=function(e,n){var t=ee(n,{resolveItems:function(){return e.options},resolveActiveIndex:function(){return e.activeOptionIndex},resolveId:function(e){return e.id},resolveDisabled:function(e){return e.dataRef.current.disabled}});return""===e.searchQuery&&e.activeOptionIndex===t?e:i({},e,{searchQuery:"",activeOptionIndex:t})},q[W.Search]=function(e,n){var t=e.searchQuery+n.value,r=e.options.findIndex((function(e){var n;return!e.dataRef.current.disabled&&(null==(n=e.dataRef.current.textValue)?void 0:n.startsWith(t))}));return i({},e,-1===r||r===e.activeOptionIndex?{searchQuery:t}:{searchQuery:t,activeOptionIndex:r})},q[W.ClearSearch]=function(e){return i({},e,{searchQuery:""})},q[W.RegisterOption]=function(e,n){return i({},e,{options:[].concat(e.options,[{id:n.id,dataRef:n.dataRef}])})},q[W.UnregisterOption]=function(e,n){var t=e.options.slice(),r=null!==e.activeOptionIndex?t[e.activeOptionIndex]:null,o=t.findIndex((function(e){return e.id===n.id}));return-1!==o&&t.splice(o,1),i({},e,{options:t,activeOptionIndex:o===e.activeOptionIndex||null===r?null:t.indexOf(r)})},q),re=o.createContext(null);function oe(e){var n=o.useContext(re);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+ae.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,oe),t}return n}function ue(e,n){return s(n.type,te,e,n)}re.displayName="ListboxContext";var ie=o.Fragment;function ae(e){var n=e.value,t=e.onChange,r=a(e,["value","onChange"]),i=X(),c=o.useReducer(ue,{listboxState:Y.Closed,propsRef:{current:{value:n,onChange:t}},labelRef:o.createRef(),buttonRef:o.createRef(),optionsRef:o.createRef(),options:[],searchQuery:"",activeOptionIndex:null}),l=c[0],s=l.listboxState,d=l.propsRef,p=l.optionsRef,v=l.buttonRef,m=c[1];y((function(){d.current.value=n}),[n,d]),y((function(){d.current.onChange=t}),[t,d]),o.useEffect((function(){function e(e){var n,t,r,o=e.target,u=document.activeElement;s===Y.Open&&((null==(n=v.current)?void 0:n.contains(o))||((null==(t=p.current)?void 0:t.contains(o))||m({type:W.CloseListbox}),u!==document.body&&(null==u?void 0:u.contains(o))||e.defaultPrevented||null==(r=v.current)||r.focus({preventScroll:!0})))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[s,p,v,i,m]);var b=o.useMemo((function(){return{open:s===Y.Open}}),[s]);return u.createElement(re.Provider,{value:c},f(r,b,ie))}var ce,le,se,fe=p((function e(n,t){var u,a=oe([ae.name,e.name].join(".")),c=a[0],l=a[1],s=m(c.buttonRef,t),d="headlessui-listbox-button-"+x(),p=X(),v=o.useCallback((function(e){switch(e.key){case r.Space:case r.Enter:case r.ArrowDown:e.preventDefault(),l({type:W.OpenListbox}),p.nextFrame((function(){var e;null==(e=c.optionsRef.current)||e.focus({preventScroll:!0}),c.propsRef.current.value||l({type:W.GoToOption,focus:K.First})}));break;case r.ArrowUp:e.preventDefault(),l({type:W.OpenListbox}),p.nextFrame((function(){var e;null==(e=c.optionsRef.current)||e.focus({preventScroll:!0}),c.propsRef.current.value||l({type:W.GoToOption,focus:K.Last})}))}}),[l,c,p]),y=o.useCallback((function(e){if(b(e.currentTarget))return e.preventDefault();n.disabled||(c.listboxState===Y.Open?(l({type:W.CloseListbox}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),l({type:W.OpenListbox}),p.nextFrame((function(){var e;return null==(e=c.optionsRef.current)?void 0:e.focus({preventScroll:!0})}))))}),[l,p,c,n.disabled]),h=Z((function(){if(c.labelRef.current)return[c.labelRef.current.id,d].join(" ")}),[c.labelRef.current,d]),S=o.useMemo((function(){return{open:c.listboxState===Y.Open}}),[c]);return f(i({},n,{ref:s,id:d,type:"button","aria-haspopup":!0,"aria-controls":null==(u=c.optionsRef.current)?void 0:u.id,"aria-expanded":c.listboxState===Y.Open||void 0,"aria-labelledby":h,onKeyDown:v,onClick:y}),S,"button")})),de=n.RenderStrategy|n.Static,pe=p((function e(n,t){var u,a=oe([ae.name,e.name].join(".")),c=a[0],l=a[1],s=m(c.optionsRef,t),d="headlessui-listbox-options-"+x(),p=X(),v=X(),b=o.useCallback((function(e){switch(v.dispose(),e.key){case r.Space:if(""!==c.searchQuery)return e.preventDefault(),l({type:W.Search,value:e.key});case r.Enter:e.preventDefault(),l({type:W.CloseListbox}),null!==c.activeOptionIndex&&c.propsRef.current.onChange(c.options[c.activeOptionIndex].dataRef.current.value),J().nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case r.ArrowDown:return e.preventDefault(),l({type:W.GoToOption,focus:K.Next});case r.ArrowUp:return e.preventDefault(),l({type:W.GoToOption,focus:K.Previous});case r.Home:case r.PageUp:return e.preventDefault(),l({type:W.GoToOption,focus:K.First});case r.End:case r.PageDown:return e.preventDefault(),l({type:W.GoToOption,focus:K.Last});case r.Escape:return e.preventDefault(),l({type:W.CloseListbox}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));case r.Tab:return e.preventDefault();default:1===e.key.length&&(l({type:W.Search,value:e.key}),v.setTimeout((function(){return l({type:W.ClearSearch})}),350))}}),[p,l,v,c]),y=Z((function(){var e,n,t;return null!=(e=null==(n=c.labelRef.current)?void 0:n.id)?e:null==(t=c.buttonRef.current)?void 0:t.id}),[c.labelRef.current,c.buttonRef.current]),h=o.useMemo((function(){return{open:c.listboxState===Y.Open}}),[c]);return f(i({},n,{"aria-activedescendant":null===c.activeOptionIndex||null==(u=c.options[c.activeOptionIndex])?void 0:u.id,"aria-labelledby":y,id:d,onKeyDown:b,role:"listbox",tabIndex:0,ref:s}),h,"ul",de,c.listboxState===Y.Open)}));ae.Button=fe,ae.Label=function e(n){var t=oe([ae.name,e.name].join("."))[0],r="headlessui-listbox-label-"+x(),u=o.useCallback((function(){var e;return null==(e=t.buttonRef.current)?void 0:e.focus({preventScroll:!0})}),[t.buttonRef]),a=o.useMemo((function(){return{open:t.listboxState===Y.Open}}),[t]);return f(i({},n,{ref:t.labelRef,id:r,onClick:u}),a,"label")},ae.Options=pe,ae.Option=function e(n){var t=n.disabled,r=void 0!==t&&t,u=n.value,c=n.className,l=a(n,["disabled","value","className"]),s=oe([ae.name,e.name].join(".")),d=s[0],p=s[1],v="headlessui-listbox-option-"+x(),m=null!==d.activeOptionIndex&&d.options[d.activeOptionIndex].id===v,b=d.propsRef.current.value===u,h=o.useRef({disabled:r,value:u});y((function(){h.current.disabled=r}),[h,r]),y((function(){h.current.value=u}),[h,u]),y((function(){var e,n;h.current.textValue=null==(e=document.getElementById(v))||null==(n=e.textContent)?void 0:n.toLowerCase()}),[h,v]);var S=o.useCallback((function(){return d.propsRef.current.onChange(u)}),[d.propsRef,u]);y((function(){return p({type:W.RegisterOption,id:v,dataRef:h}),function(){return p({type:W.UnregisterOption,id:v})}}),[h,v]),y((function(){var e;d.listboxState===Y.Open&&b&&(p({type:W.GoToOption,focus:K.Specific,id:v}),null==(e=document.getElementById(v))||null==e.focus||e.focus())}),[d.listboxState]),y((function(){if(d.listboxState===Y.Open&&m){var e=J();return e.nextFrame((function(){var e;return null==(e=document.getElementById(v))||null==e.scrollIntoView?void 0:e.scrollIntoView({block:"nearest"})})),e.dispose}}),[m,d.listboxState]);var g=o.useCallback((function(e){if(r)return e.preventDefault();S(),p({type:W.CloseListbox}),J().nextFrame((function(){var e;return null==(e=d.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))}),[p,d.buttonRef,r,S]),E=o.useCallback((function(){if(r)return p({type:W.GoToOption,focus:K.Nothing});p({type:W.GoToOption,focus:K.Specific,id:v})}),[r,v,p]),C=o.useCallback((function(){r||m||p({type:W.GoToOption,focus:K.Specific,id:v})}),[r,m,v,p]),w=o.useCallback((function(){r||m&&p({type:W.GoToOption,focus:K.Nothing})}),[r,m,p]),I=o.useMemo((function(){return{active:m,selected:b,disabled:r}}),[m,b,r]);return f(i({},l,{id:v,role:"option",tabIndex:-1,className:ne(c,I),"aria-disabled":!0===r||void 0,"aria-selected":!0===b||void 0,onClick:g,onFocus:E,onPointerMove:C,onMouseMove:C,onPointerLeave:w,onMouseLeave:w}),I,"li")},function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(le||(le={})),function(e){e[e.OpenMenu=0]="OpenMenu",e[e.CloseMenu=1]="CloseMenu",e[e.GoToItem=2]="GoToItem",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.RegisterItem=5]="RegisterItem",e[e.UnregisterItem=6]="UnregisterItem"}(se||(se={}));var ve=((ce={})[se.CloseMenu]=function(e){return i({},e,{activeItemIndex:null,menuState:le.Closed})},ce[se.OpenMenu]=function(e){return i({},e,{menuState:le.Open})},ce[se.GoToItem]=function(e,n){var t=ee(n,{resolveItems:function(){return e.items},resolveActiveIndex:function(){return e.activeItemIndex},resolveId:function(e){return e.id},resolveDisabled:function(e){return e.dataRef.current.disabled}});return""===e.searchQuery&&e.activeItemIndex===t?e:i({},e,{searchQuery:"",activeItemIndex:t})},ce[se.Search]=function(e,n){var t=e.searchQuery+n.value,r=e.items.findIndex((function(e){var n;return(null==(n=e.dataRef.current.textValue)?void 0:n.startsWith(t))&&!e.dataRef.current.disabled}));return i({},e,-1===r||r===e.activeItemIndex?{searchQuery:t}:{searchQuery:t,activeItemIndex:r})},ce[se.ClearSearch]=function(e){return i({},e,{searchQuery:""})},ce[se.RegisterItem]=function(e,n){return i({},e,{items:[].concat(e.items,[{id:n.id,dataRef:n.dataRef}])})},ce[se.UnregisterItem]=function(e,n){var t=e.items.slice(),r=null!==e.activeItemIndex?t[e.activeItemIndex]:null,o=t.findIndex((function(e){return e.id===n.id}));return-1!==o&&t.splice(o,1),i({},e,{items:t,activeItemIndex:o===e.activeItemIndex||null===r?null:t.indexOf(r)})},ce),me=o.createContext(null);function be(e){var n=o.useContext(me);if(null===n){var t=new Error("<"+e+" /> is missing a parent <"+Se.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,be),t}return n}function ye(e,n){return s(n.type,ve,e,n)}me.displayName="MenuContext";var he=o.Fragment;function Se(e){var n=o.useReducer(ye,{menuState:le.Closed,buttonRef:o.createRef(),itemsRef:o.createRef(),items:[],searchQuery:"",activeItemIndex:null}),t=n[0],r=t.menuState,i=t.itemsRef,a=t.buttonRef,c=n[1];o.useEffect((function(){function e(e){var n,t,o,u=e.target,l=document.activeElement;r===le.Open&&((null==(n=a.current)?void 0:n.contains(u))||((null==(t=i.current)?void 0:t.contains(u))||c({type:se.CloseMenu}),l!==document.body&&(null==l?void 0:l.contains(u))||e.defaultPrevented||null==(o=a.current)||o.focus({preventScroll:!0})))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[r,i,a,c]);var l=o.useMemo((function(){return{open:r===le.Open}}),[r]);return u.createElement(me.Provider,{value:n},f(e,l,he))}var ge=p((function e(n,t){var u,a=be([Se.name,e.name].join(".")),c=a[0],l=a[1],s=m(c.buttonRef,t),d="headlessui-menu-button-"+x(),p=X(),v=o.useCallback((function(e){switch(e.key){case r.Space:case r.Enter:case r.ArrowDown:e.preventDefault(),l({type:se.OpenMenu}),p.nextFrame((function(){var e;null==(e=c.itemsRef.current)||e.focus({preventScroll:!0}),l({type:se.GoToItem,focus:K.First})}));break;case r.ArrowUp:e.preventDefault(),l({type:se.OpenMenu}),p.nextFrame((function(){var e;null==(e=c.itemsRef.current)||e.focus({preventScroll:!0}),l({type:se.GoToItem,focus:K.Last})}))}}),[l,c,p]),y=o.useCallback((function(e){if(b(e.currentTarget))return e.preventDefault();n.disabled||(c.menuState===le.Open?(l({type:se.CloseMenu}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),l({type:se.OpenMenu}),p.nextFrame((function(){var e;return null==(e=c.itemsRef.current)?void 0:e.focus({preventScroll:!0})}))))}),[l,p,c,n.disabled]),h=o.useMemo((function(){return{open:c.menuState===le.Open}}),[c]);return f(i({},n,{ref:s,id:d,type:"button","aria-haspopup":!0,"aria-controls":null==(u=c.itemsRef.current)?void 0:u.id,"aria-expanded":c.menuState===le.Open||void 0,onKeyDown:v,onClick:y}),h,"button")})),xe=n.RenderStrategy|n.Static,Ee=p((function e(n,t){var u,a,c=be([Se.name,e.name].join(".")),l=c[0],s=c[1],d=m(l.itemsRef,t),p="headlessui-menu-items-"+x(),v=X(),b=o.useCallback((function(e){switch(v.dispose(),e.key){case r.Space:if(""!==l.searchQuery)return e.preventDefault(),s({type:se.Search,value:e.key});case r.Enter:var n;e.preventDefault(),s({type:se.CloseMenu}),null!==l.activeItemIndex&&(null==(n=document.getElementById(l.items[l.activeItemIndex].id))||n.click()),J().nextFrame((function(){var e;return null==(e=l.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case r.ArrowDown:return e.preventDefault(),s({type:se.GoToItem,focus:K.Next});case r.ArrowUp:return e.preventDefault(),s({type:se.GoToItem,focus:K.Previous});case r.Home:case r.PageUp:return e.preventDefault(),s({type:se.GoToItem,focus:K.First});case r.End:case r.PageDown:return e.preventDefault(),s({type:se.GoToItem,focus:K.Last});case r.Escape:e.preventDefault(),s({type:se.CloseMenu}),J().nextFrame((function(){var e;return null==(e=l.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case r.Tab:return e.preventDefault();default:1===e.key.length&&(s({type:se.Search,value:e.key}),v.setTimeout((function(){return s({type:se.ClearSearch})}),350))}}),[s,v,l]),y=o.useMemo((function(){return{open:l.menuState===le.Open}}),[l]);return f(i({},n,{"aria-activedescendant":null===l.activeItemIndex||null==(u=l.items[l.activeItemIndex])?void 0:u.id,"aria-labelledby":null==(a=l.buttonRef.current)?void 0:a.id,id:p,onKeyDown:b,role:"menu",tabIndex:0,ref:d}),y,"div",xe,l.menuState===le.Open)})),Ce=o.Fragment;Se.Button=ge,Se.Items=Ee,Se.Item=function e(n){var t=n.disabled,r=void 0!==t&&t,u=n.className,c=n.onClick,l=a(n,["disabled","className","onClick"]),s=be([Se.name,e.name].join(".")),d=s[0],p=s[1],v="headlessui-menu-item-"+x(),m=null!==d.activeItemIndex&&d.items[d.activeItemIndex].id===v,b=o.useRef({disabled:r});y((function(){b.current.disabled=r}),[b,r]),y((function(){var e,n;b.current.textValue=null==(e=document.getElementById(v))||null==(n=e.textContent)?void 0:n.toLowerCase()}),[b,v]),y((function(){return p({type:se.RegisterItem,id:v,dataRef:b}),function(){return p({type:se.UnregisterItem,id:v})}}),[b,v]);var h=o.useCallback((function(e){return r?e.preventDefault():(p({type:se.CloseMenu}),J().nextFrame((function(){var e;return null==(e=d.buttonRef.current)?void 0:e.focus({preventScroll:!0})})),c?c(e):void 0)}),[p,d.buttonRef,r,c]),S=o.useCallback((function(){if(r)return p({type:se.GoToItem,focus:K.Nothing});p({type:se.GoToItem,focus:K.Specific,id:v})}),[r,v,p]),g=o.useCallback((function(){r||m||p({type:se.GoToItem,focus:K.Specific,id:v})}),[r,m,v,p]),E=o.useCallback((function(){r||m&&p({type:se.GoToItem,focus:K.Nothing})}),[r,m,p]),C=o.useMemo((function(){return{active:m,disabled:r}}),[m,r]);return f(i({},l,{id:v,role:"menuitem",tabIndex:-1,className:ne(u,C),"aria-disabled":!0===r||void 0,onClick:h,onFocus:S,onPointerMove:g,onMouseMove:g,onPointerLeave:E,onMouseLeave:E}),C,Ce)};var we=o.createContext(null);function Ie(e){var n=o.useContext(we);if(null===n){var t=new Error("<"+e+" /> is missing a parent <Switch.Group /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(t,Ie),t}return n}we.displayName="GroupContext";var Oe,ke=o.Fragment;function Re(e){var n,t,u=e.checked,c=e.onChange,l=e.className,s=a(e,["checked","onChange","className"]),d="headlessui-switch-"+x(),p=o.useContext(we),v=o.useCallback((function(){return c(!u)}),[c,u]),m=o.useCallback((function(e){if(b(e.currentTarget))return e.preventDefault();e.preventDefault(),v()}),[v]),y=o.useCallback((function(e){e.key!==r.Tab&&e.preventDefault(),e.key===r.Space&&v()}),[v]),h=o.useCallback((function(e){return e.preventDefault()}),[]),S=o.useMemo((function(){return{checked:u}}),[u]),g={id:d,ref:null===p?void 0:p.setSwitch,role:"switch",tabIndex:0,className:ne(l,S),"aria-checked":u,"aria-labelledby":null==p||null==(n=p.label)?void 0:n.id,"aria-describedby":null==p||null==(t=p.description)?void 0:t.id,onClick:m,onKeyUp:y,onKeyPress:h};return"button"===s.as&&Object.assign(g,{type:"button"}),f(i({},s,g),S,"button")}function Te(){var e=o.useRef(!0);return o.useEffect((function(){e.current=!1}),[]),e.current}function De(e){for(var n,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e&&r.length>0&&(n=e.classList).add.apply(n,r)}function Le(e){for(var n,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e&&r.length>0&&(n=e.classList).remove.apply(n,r)}function Fe(e,n,t,r,o){var u=J(),i=void 0!==o?function(e){var n={called:!1};return function(){if(!n.called)return n.called=!0,e.apply(void 0,arguments)}}(o):function(){};return De.apply(void 0,[e].concat(n,t)),u.nextFrame((function(){Le.apply(void 0,[e].concat(t)),De.apply(void 0,[e].concat(r)),u.add(function(e,n){var t=J();if(!e)return t.dispose;var r=getComputedStyle(e),o=[r.transitionDuration,r.transitionDelay].map((function(e){var n=e.split(",").filter(Boolean).map((function(e){return e.includes("ms")?parseFloat(e):1e3*parseFloat(e)})).sort((function(e,n){return n-e}))[0];return void 0===n?0:n})),u=o[0];return 0!==u?t.setTimeout((function(){n(Oe.Finished)}),u+o[1]):n(Oe.Finished),t.add((function(){return n(Oe.Cancelled)})),t.dispose}(e,(function(t){return Le.apply(void 0,[e].concat(r,n)),i(t)})))})),u.add((function(){return Le.apply(void 0,[e].concat(n,t,r))})),u.add((function(){return i(Oe.Cancelled)})),u.dispose}function Pe(e){return void 0===e&&(e=""),o.useMemo((function(){return e.split(" ").filter((function(e){return e.trim().length>1}))}),[e])}Re.Group=function(e){var n=o.useState(null),t=n[0],r=n[1],i=o.useState(null),a=i[0],c=i[1],l=o.useState(null),s=l[0],d=l[1],p=o.useMemo((function(){return{switch:t,setSwitch:r,label:a,setLabel:c,description:s,setDescription:d}}),[t,r,a,c,s,d]);return u.createElement(we.Provider,{value:p},f(e,{},ke))},Re.Label=function e(n){var t=Ie([Re.name,e.name].join(".")),r="headlessui-switch-label-"+x(),u=o.useCallback((function(){t.switch&&(t.switch.click(),t.switch.focus({preventScroll:!0}))}),[t.switch]);return f(i({},n,{ref:t.setLabel,id:r,onClick:u}),{},"label")},Re.Description=function e(n){var t=Ie([Re.name,e.name].join(".")),r="headlessui-switch-description-"+x();return f(i({},n,{ref:t.setDescription,id:r}),{},"p")},function(e){e.Finished="finished",e.Cancelled="cancelled"}(Oe||(Oe={}));var Me,Ae=o.createContext(null);Ae.displayName="TransitionContext",function(e){e.Visible="visible",e.Hidden="hidden"}(Me||(Me={}));var je=o.createContext(null);function Ne(e){return"children"in e?Ne(e.children):e.current.filter((function(e){return e.state===Me.Visible})).length>0}function Ue(e){var n=o.useRef(e),r=o.useRef([]),u=function(){var e=o.useRef(!0);return o.useEffect((function(){return function(){e.current=!1}}),[]),e}();o.useEffect((function(){n.current=e}),[e]);var i=o.useCallback((function(e,o){var i;void 0===o&&(o=t.Hidden);var a=r.current.findIndex((function(n){return n.id===e}));-1!==a&&(s(o,((i={})[t.Unmount]=function(){r.current.splice(a,1)},i[t.Hidden]=function(){r.current[a].state=Me.Hidden},i)),!Ne(r)&&u.current&&(null==n.current||n.current()))}),[n,u,r]),a=o.useCallback((function(e){var n=r.current.find((function(n){return n.id===e}));return n?n.state!==Me.Visible&&(n.state=Me.Visible):r.current.push({id:e,state:Me.Visible}),function(){return i(e,t.Unmount)}}),[r,i]);return o.useMemo((function(){return{children:r,register:a,unregister:i}}),[a,i,r])}function Ge(){}je.displayName="NestingContext";var He=["beforeEnter","afterEnter","beforeLeave","afterLeave"];function Ve(e){for(var n,t={},r=l(He);!(n=r()).done;){var o,u=n.value;t[u]=null!=(o=e[u])?o:Ge}return t}var Qe=n.RenderStrategy;function Be(e){var n=e.beforeEnter,r=e.afterEnter,c=e.beforeLeave,l=e.afterLeave,d=e.enter,p=e.enterFrom,v=e.enterTo,m=e.leave,b=e.leaveFrom,h=e.leaveTo,S=a(e,["beforeEnter","afterEnter","beforeLeave","afterLeave","enter","enterFrom","enterTo","leave","leaveFrom","leaveTo"]),g=o.useRef(null),E=o.useState(Me.Visible),C=E[0],w=E[1],I=S.unmount?t.Unmount:t.Hidden,O=function(){var e=o.useContext(Ae);if(null===e)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition />.");return e}(),k=O.show,R=O.appear,T=function(){var e=o.useContext(je);if(null===e)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition />.");return e}(),D=T.register,L=T.unregister,F=Te(),P=x(),M=o.useRef(!1),A=Ue((function(){M.current||(w(Me.Hidden),L(P),Q.current.afterLeave())}));y((function(){if(P)return D(P)}),[D,P]),y((function(){var e;I===t.Hidden&&P&&(k&&C!==Me.Visible?w(Me.Visible):s(C,((e={})[Me.Hidden]=function(){return L(P)},e[Me.Visible]=function(){return D(P)},e)))}),[C,P,D,L,k,I]);var j=Pe(d),N=Pe(p),U=Pe(v),G=Pe(m),H=Pe(b),V=Pe(h),Q=function(e){var n=o.useRef(Ve(e));return o.useEffect((function(){n.current=Ve(e)}),[e]),n}({beforeEnter:n,afterEnter:r,beforeLeave:c,afterLeave:l});o.useEffect((function(){if(C===Me.Visible&&null===g.current)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")}),[g,C]);var B=F&&!R;return y((function(){var e=g.current;if(e&&!B)return M.current=!0,k&&Q.current.beforeEnter(),k||Q.current.beforeLeave(),k?Fe(e,j,N,U,(function(e){M.current=!1,e===Oe.Finished&&Q.current.afterEnter()})):Fe(e,G,H,V,(function(e){M.current=!1,e===Oe.Finished&&(Ne(A)||(w(Me.Hidden),L(P),Q.current.afterLeave()))}))}),[Q,P,M,L,A,g,B,k,j,N,U,G,H,V]),u.createElement(je.Provider,{value:A},f(i({},S,{ref:g}),{},"div",Qe,C===Me.Visible))}function Ke(e){var n=e.show,t=e.appear,r=void 0!==t&&t,c=e.unmount,l=a(e,["show","appear","unmount"]);if(![!0,!1].includes(n))throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");var s=o.useState(n?Me.Visible:Me.Hidden),d=s[0],p=s[1],v=Ue((function(){p(Me.Hidden)})),m=Te(),b=o.useMemo((function(){return{show:n,appear:r||!m}}),[n,r,m]);o.useEffect((function(){n?p(Me.Visible):Ne(v)||p(Me.Hidden)}),[n,v]);var y={unmount:c};return u.createElement(je.Provider,{value:v},u.createElement(Ae.Provider,{value:b},f(i({},y,{as:o.Fragment,children:u.createElement(Be,Object.assign({},y,l))}),{},o.Fragment,Qe,d===Me.Visible)))}Ke.Child=Be,exports.Dialog=P,exports.Disclosure=B,exports.FocusTrap=function(e){var n=o.useRef(null);return k(n),f(i({},e,{ref:n}),{},"div")},exports.Listbox=ae,exports.Menu=Se,exports.Switch=Re,exports.Transition=Ke; | ||
//# sourceMappingURL=headlessui.cjs.production.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e=e||self).headlessui={},e.React)}(this,(function(e,n){"use strict";var t,r,o,u="default"in n?n.default:n;function i(){return(i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function a(e,n){if(null==e)return{};var t,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n.indexOf(t=u[r])>=0||(o[t]=e[t]);return o}function c(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function l(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return c(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?c(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}function s(e,n){if(e in n){for(var t=n[e],r=arguments.length,o=new Array(r>2?r-2:0),u=2;u<r;u++)o[u-2]=arguments[u];return"function"==typeof t?t.apply(void 0,o):t}var i=new Error('Tried to handle "'+e+'" but there is no handler defined. Only defined handlers are: '+Object.keys(n).map((function(e){return'"'+e+'"'})).join(", ")+".");throw Error.captureStackTrace&&Error.captureStackTrace(i,s),i}function f(e,n,o,u,c){if(void 0===c&&(c=!0),c)return d(e,n,o);var l=null!=u?u:t.None;if(l&t.Static){var f=e.static,p=void 0!==f&&f,v=a(e,["static"]);if(p)return d(v,n,o)}if(l&t.RenderStrategy){var m,b=e.unmount,y=void 0===b||b,h=a(e,["unmount"]);return s(y?r.Unmount:r.Hidden,((m={})[r.Unmount]=function(){return null},m[r.Hidden]=function(){return d(i({},h,{hidden:!0,style:{display:"none"}}),n,o)},m))}return d(e,n,o)}function d(e,t,r){var o,u=v(e,["unmount","static"]),i=u.as,c=void 0===i?r:i,s=u.children,f=u.refName,p=void 0===f?"ref":f,m=a(u,["as","children","refName"]),b=void 0!==e.ref?((o={})[p]=e.ref,o):{},y="function"==typeof s?s(t):s;if(c===n.Fragment&&Object.keys(m).length>0){if(Array.isArray(y)&&y.length>1){var h=new Error("You should only render 1 child");throw Error.captureStackTrace&&Error.captureStackTrace(h,d),h}if(!n.isValidElement(y)){var S=new Error('You should render an element as a child. Did you forget the as="..." prop?');throw Error.captureStackTrace&&Error.captureStackTrace(S,d),S}return n.cloneElement(y,Object.assign({},function(e,n,t){for(var r,o=Object.assign({},e),u=function(){var t,u=r.value;void 0!==e[u]&&void 0!==n[u]&&Object.assign(o,((t={})[u]=function(t){t.defaultPrevented||e[u](t),t.defaultPrevented||n[u](t)},t))},i=l(["onClick"]);!(r=i()).done;)u();return o}(function(e){var n=Object.assign({},e);for(var t in n)void 0===n[t]&&delete n[t];return n}(v(m,["ref"])),y.props),b))}return n.createElement(c,Object.assign({},v(m,["ref"]),c!==n.Fragment&&b),y)}function p(e){return n.forwardRef(e)}function v(e,n){void 0===n&&(n=[]);for(var t,r=Object.assign({},e),o=l(n);!(t=o()).done;){var u=t.value;u in r&&delete r[u]}return r}function m(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.useCallback((function(e){t.forEach((function(n){if(null!==n)return"function"==typeof n?n(e):void(n.current=e)}))}),[t])}function b(e){for(var n,t,r=e.parentElement,o=null;r&&!(r instanceof HTMLFieldSetElement);)r instanceof HTMLLegendElement&&(o=r),r=r.parentElement;var u=null!=(n=""===(null==(t=r)?void 0:t.getAttribute("disabled")))&&n;return(!u||!function(e){if(!e)return!1;for(var n=e.previousElementSibling;null!==n;){if(n instanceof HTMLLegendElement)return!1;n=n.previousElementSibling}return!0}(o))&&u}!function(e){e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static"}(t||(t={})),function(e){e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden"}(r||(r={})),function(e){e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.ArrowUp="ArrowUp",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab"}(o||(o={}));var y="undefined"!=typeof window?n.useLayoutEffect:n.useEffect,h={serverHandoffComplete:!1},S=0;function g(){return++S}function x(){var e=n.useState(h.serverHandoffComplete?g:null),t=e[0],r=e[1];return y((function(){null===t&&r(g())}),[t]),n.useEffect((function(){!1===h.serverHandoffComplete&&(h.serverHandoffComplete=!0)}),[]),null!=t?""+t:void 0}var E,C,w,I=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map((function(e){return e+":not([tabindex='-1'])"})).join(",");function O(e){e&&e.focus({preventScroll:!0})}function k(e,t){void 0===t&&(t=!0);var r=n.useRef(null),u=n.useRef(null),i=n.useRef(!1),a=n.useCallback((function(){return e.current?Array.from(e.current.querySelectorAll(I)):[]}),[e]);y((function(){if(t){i.current=!0,r.current=document.activeElement;var e=a();if(e.length<=0)throw new Error("There are no focusable elements inside the <FocusTrap />");return function n(t){void 0!==t&&(O(t),document.activeElement!==t?n(e[e.indexOf(t)+1]):u.current=t)}(e[0]),function(){i.current=!1,O(r.current),r.current=null,u.current=null}}}),[t,i]),y((function(){if(t)return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)};function e(e){if(e.key===o.Tab&&document.activeElement){e.preventDefault();var n=e.shiftKey?-1:1,t=a(),r=t.length;!function e(o){void 0===o&&(o=0);var i=t.indexOf(document.activeElement),a=t[(i+r+n+o)%r];O(a),a!==document.activeElement?e(o+n):u.current=a}()}}}),[t,a]),y((function(){if(t&&e.current){var n=e.current;return window.addEventListener("focus",r,!0),function(){return window.removeEventListener("focus",r,!0)}}function r(e){var t=u.current;if(t&&i.current){var r=e.target;r&&r instanceof HTMLElement?n.contains(r)?(u.current=r,O(r)):(e.preventDefault(),e.stopPropagation(),O(t)):O(u.current)}}}),[t,i,e])}!function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(C||(C={})),function(e){e[e.SetTitleElement=0]="SetTitleElement",e[e.SetDescriptionElement=1]="SetDescriptionElement"}(w||(w={}));var R=((E={})[w.SetTitleElement]=function(e,n){return e.titleElement===n.element?e:i({},e,{titleElement:n.element})},E[w.SetDescriptionElement]=function(e,n){return e.descriptionElement===n.element?e:i({},e,{descriptionElement:n.element})},E),T=n.createContext(null);function D(e){var t=n.useContext(T);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+P.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,D),r}return t}function L(e,n){return s(n.type,R,e,n)}T.displayName="DialogContext";var F=t.RenderStrategy|t.Static;function P(e){var t,r,c=e.open,l=e.onClose,s=a(e,["open","onClose"]),d=n.useRef(null),p=e.hasOwnProperty("open"),v=e.hasOwnProperty("onClose");if(!p)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!v)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if("boolean"!=typeof c)throw new Error("You provided an `open` prop to the `Dialog`, but the value is not a boolean. Received: "+c);if("function"!=typeof l)throw new Error("You provided an `onClose` prop to the `Dialog`, but the value is not a function. Received: "+l);var m=c?C.Open:C.Closed,b=n.useReducer(L,{titleElement:null,descriptionElement:null}),y=b[0],h=b[1],S=n.useCallback((function(){return l(!1)}),[l]),g=n.useCallback((function(e){return h({type:w.SetTitleElement,element:e})}),[h]),E=n.useCallback((function(e){return h({type:w.SetDescriptionElement,element:e})}),[h]);n.useEffect((function(){function e(e){e.key===o.Escape&&m===C.Open&&S()}return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}}),[S,m]),k(d,!!e.static||m===C.Open);var I="headlessui-dialog-"+x(),O=n.useMemo((function(){return[{dialogState:m,close:S,setTitle:g,setDescription:E},y]}),[m,y,S,g,E]),R=n.useMemo((function(){return{open:m===C.Open,close:S}}),[m,S]),D={ref:d,id:I,role:"dialog","aria-modal":!0,"aria-labelledby":null==(t=y.titleElement)?void 0:t.id,"aria-describedby":null==(r=y.descriptionElement)?void 0:r.id};return u.createElement(T.Provider,{value:O},f(i({},s,D),R,"div",F,m===C.Open))}var M,A,j,N=t.RenderStrategy|t.Static,U=p((function e(t,r){var o=D([P.name,e.name].join("."))[0],u=o.dialogState,a=o.close,c=m(r),l="headlessui-dialog-overlay-"+x(),s=n.useCallback((function(e){if(b(e.currentTarget))return e.preventDefault();a()}),[a]),d=n.useMemo((function(){return{open:u===C.Open}}),[u]);return f(i({},t,{ref:c,id:l,"aria-hidden":!0,onClick:s}),d,"div",N,u===C.Open)}));P.Overlay=U,P.Title=function e(t){var r=D([P.name,e.name].join("."))[0],o=r.dialogState,u=r.setTitle,a="headlessui-dialog-title-"+x(),c=n.useMemo((function(){return{open:o===C.Open}}),[o]);return f(i({},t,{ref:u,id:a}),c,"h2")},P.Description=function e(t){var r=D([P.name,e.name].join("."))[0],o=r.dialogState,u=r.setDescription,a="headlessui-dialog-description-"+x(),c=n.useMemo((function(){return{open:o===C.Open}}),[o]);return f(i({},t,{ref:u,id:a}),c,"p")},function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(A||(A={})),function(e){e[e.ToggleDisclosure=0]="ToggleDisclosure",e[e.SetButtonId=1]="SetButtonId",e[e.SetPanelId=2]="SetPanelId",e[e.LinkPanel=3]="LinkPanel",e[e.UnlinkPanel=4]="UnlinkPanel"}(j||(j={}));var G=((M={})[j.ToggleDisclosure]=function(e){var n;return i({},e,{disclosureState:s(e.disclosureState,(n={},n[A.Open]=A.Closed,n[A.Closed]=A.Open,n))})},M[j.LinkPanel]=function(e){return i({},e,{linkedPanel:!0})},M[j.UnlinkPanel]=function(e){return i({},e,{linkedPanel:!1})},M[j.SetButtonId]=function(e,n){return i({},e,{buttonId:n.buttonId})},M[j.SetPanelId]=function(e,n){return i({},e,{panelId:n.panelId})},M),H=n.createContext(null);function V(e){var t=n.useContext(H);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+K.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,V),r}return t}function Q(e,n){return s(n.type,G,e,n)}H.displayName="DisclosureContext";var B=n.Fragment;function K(e){var t="headlessui-disclosure-button-"+x(),r="headlessui-disclosure-panel-"+x(),o=n.useReducer(Q,{disclosureState:A.Closed,linkedPanel:!1,buttonId:t,panelId:r}),i=o[0].disclosureState,a=o[1];n.useEffect((function(){return a({type:j.SetButtonId,buttonId:t})}),[t,a]),n.useEffect((function(){return a({type:j.SetPanelId,panelId:r})}),[r,a]);var c=n.useMemo((function(){return{open:i===A.Open}}),[i]);return u.createElement(H.Provider,{value:o},f(e,c,B))}var q,Y,W,_,$=p((function e(t,r){var u=V([K.name,e.name].join(".")),a=u[0],c=u[1],l=m(r),s=n.useCallback((function(e){switch(e.key){case o.Space:case o.Enter:e.preventDefault(),c({type:j.ToggleDisclosure})}}),[c]),d=n.useCallback((function(e){b(e.currentTarget)||t.disabled||c({type:j.ToggleDisclosure})}),[c,t.disabled]),p=n.useMemo((function(){return{open:a.disclosureState===A.Open}}),[a]);return f(i({},t,{ref:l,id:a.buttonId,type:"button","aria-expanded":a.disclosureState===A.Open||void 0,"aria-controls":a.linkedPanel?a.panelId:void 0,onKeyDown:s,onClick:d}),p,"button")})),z=t.RenderStrategy|t.Static,J=p((function e(t,r){var o=V([K.name,e.name].join(".")),a=o[0],c=o[1],l=m(r,(function(){a.linkedPanel||c({type:j.LinkPanel})}));n.useEffect((function(){return function(){return c({type:j.UnlinkPanel})}}),[c]),u.useEffect((function(){var e;a.disclosureState!==A.Closed||null!=(e=t.unmount)&&!e||c({type:j.UnlinkPanel})}),[a.disclosureState,t.unmount,c]);var s=u.useMemo((function(){return{open:a.disclosureState===A.Open}}),[a]);return f(i({},t,{ref:l,id:a.panelId}),s,"div",z,a.disclosureState===A.Open)}));function X(){var e=[],n={requestAnimationFrame:function(e){function n(){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(){var e=requestAnimationFrame.apply(void 0,arguments);n.add((function(){return cancelAnimationFrame(e)}))})),nextFrame:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.requestAnimationFrame((function(){n.requestAnimationFrame.apply(n,t)}))},setTimeout:function(e){function n(){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(){var e=setTimeout.apply(void 0,arguments);n.add((function(){return clearTimeout(e)}))})),add:function(n){e.push(n)},dispose:function(){for(var n,t=l(e.splice(0));!(n=t()).done;)(0,n.value)()}};return n}function Z(){var e=n.useState(X)[0];return n.useEffect((function(){return function(){return e.dispose()}}),[e]),e}function ee(e,t){var r=n.useState(e),o=r[0],u=r[1],i=n.useRef(e);return y((function(){i.current=e}),[e]),y((function(){return u(i.current)}),[i,u].concat(t)),o}function ne(e,n){var t=n.resolveItems();if(t.length<=0)return null;var r=n.resolveActiveIndex(),o=null!=r?r:-1,u=function(){switch(e.focus){case q.First:return t.findIndex((function(e){return!n.resolveDisabled(e)}));case q.Previous:var r=t.slice().reverse().findIndex((function(e,t,r){return!(-1!==o&&r.length-t-1>=o||n.resolveDisabled(e))}));return-1===r?r:t.length-1-r;case q.Next:return t.findIndex((function(e,t){return!(t<=o||n.resolveDisabled(e))}));case q.Last:var u=t.slice().reverse().findIndex((function(e){return!n.resolveDisabled(e)}));return-1===u?u:t.length-1-u;case q.Specific:return t.findIndex((function(t){return n.resolveId(t)===e.id}));case q.Nothing:return null;default:!function(e){throw new Error("Unexpected object: "+e)}(e)}}();return-1===u?r:u}function te(e,n){if(void 0!==e)return"function"==typeof e?e(n):e}K.Button=$,K.Panel=J,function(e){e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing"}(q||(q={})),function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(W||(W={})),function(e){e[e.OpenListbox=0]="OpenListbox",e[e.CloseListbox=1]="CloseListbox",e[e.GoToOption=2]="GoToOption",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.RegisterOption=5]="RegisterOption",e[e.UnregisterOption=6]="UnregisterOption"}(_||(_={}));var re=((Y={})[_.CloseListbox]=function(e){return i({},e,{activeOptionIndex:null,listboxState:W.Closed})},Y[_.OpenListbox]=function(e){return i({},e,{listboxState:W.Open})},Y[_.GoToOption]=function(e,n){var t=ne(n,{resolveItems:function(){return e.options},resolveActiveIndex:function(){return e.activeOptionIndex},resolveId:function(e){return e.id},resolveDisabled:function(e){return e.dataRef.current.disabled}});return""===e.searchQuery&&e.activeOptionIndex===t?e:i({},e,{searchQuery:"",activeOptionIndex:t})},Y[_.Search]=function(e,n){var t=e.searchQuery+n.value,r=e.options.findIndex((function(e){var n;return!e.dataRef.current.disabled&&(null==(n=e.dataRef.current.textValue)?void 0:n.startsWith(t))}));return i({},e,-1===r||r===e.activeOptionIndex?{searchQuery:t}:{searchQuery:t,activeOptionIndex:r})},Y[_.ClearSearch]=function(e){return i({},e,{searchQuery:""})},Y[_.RegisterOption]=function(e,n){return i({},e,{options:[].concat(e.options,[{id:n.id,dataRef:n.dataRef}])})},Y[_.UnregisterOption]=function(e,n){var t=e.options.slice(),r=null!==e.activeOptionIndex?t[e.activeOptionIndex]:null,o=t.findIndex((function(e){return e.id===n.id}));return-1!==o&&t.splice(o,1),i({},e,{options:t,activeOptionIndex:o===e.activeOptionIndex||null===r?null:t.indexOf(r)})},Y),oe=n.createContext(null);function ue(e){var t=n.useContext(oe);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+ce.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,ue),r}return t}function ie(e,n){return s(n.type,re,e,n)}oe.displayName="ListboxContext";var ae=n.Fragment;function ce(e){var t=e.value,r=e.onChange,o=a(e,["value","onChange"]),i=Z(),c=n.useReducer(ie,{listboxState:W.Closed,propsRef:{current:{value:t,onChange:r}},labelRef:n.createRef(),buttonRef:n.createRef(),optionsRef:n.createRef(),options:[],searchQuery:"",activeOptionIndex:null}),l=c[0],s=l.listboxState,d=l.propsRef,p=l.optionsRef,v=l.buttonRef,m=c[1];y((function(){d.current.value=t}),[t,d]),y((function(){d.current.onChange=r}),[r,d]),n.useEffect((function(){function e(e){var n,t,r,o=e.target,u=document.activeElement;s===W.Open&&((null==(n=v.current)?void 0:n.contains(o))||((null==(t=p.current)?void 0:t.contains(o))||m({type:_.CloseListbox}),u!==document.body&&(null==u?void 0:u.contains(o))||e.defaultPrevented||null==(r=v.current)||r.focus({preventScroll:!0})))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[s,p,v,i,m]);var b=n.useMemo((function(){return{open:s===W.Open}}),[s]);return u.createElement(oe.Provider,{value:c},f(o,b,ae))}var le,se,fe,de=p((function e(t,r){var u,a=ue([ce.name,e.name].join(".")),c=a[0],l=a[1],s=m(c.buttonRef,r),d="headlessui-listbox-button-"+x(),p=Z(),v=n.useCallback((function(e){switch(e.key){case o.Space:case o.Enter:case o.ArrowDown:e.preventDefault(),l({type:_.OpenListbox}),p.nextFrame((function(){var e;null==(e=c.optionsRef.current)||e.focus({preventScroll:!0}),c.propsRef.current.value||l({type:_.GoToOption,focus:q.First})}));break;case o.ArrowUp:e.preventDefault(),l({type:_.OpenListbox}),p.nextFrame((function(){var e;null==(e=c.optionsRef.current)||e.focus({preventScroll:!0}),c.propsRef.current.value||l({type:_.GoToOption,focus:q.Last})}))}}),[l,c,p]),y=n.useCallback((function(e){if(b(e.currentTarget))return e.preventDefault();t.disabled||(c.listboxState===W.Open?(l({type:_.CloseListbox}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),l({type:_.OpenListbox}),p.nextFrame((function(){var e;return null==(e=c.optionsRef.current)?void 0:e.focus({preventScroll:!0})}))))}),[l,p,c,t.disabled]),h=ee((function(){if(c.labelRef.current)return[c.labelRef.current.id,d].join(" ")}),[c.labelRef.current,d]),S=n.useMemo((function(){return{open:c.listboxState===W.Open}}),[c]);return f(i({},t,{ref:s,id:d,type:"button","aria-haspopup":!0,"aria-controls":null==(u=c.optionsRef.current)?void 0:u.id,"aria-expanded":c.listboxState===W.Open||void 0,"aria-labelledby":h,onKeyDown:v,onClick:y}),S,"button")})),pe=t.RenderStrategy|t.Static,ve=p((function e(t,r){var u,a=ue([ce.name,e.name].join(".")),c=a[0],l=a[1],s=m(c.optionsRef,r),d="headlessui-listbox-options-"+x(),p=Z(),v=Z(),b=n.useCallback((function(e){switch(v.dispose(),e.key){case o.Space:if(""!==c.searchQuery)return e.preventDefault(),l({type:_.Search,value:e.key});case o.Enter:e.preventDefault(),l({type:_.CloseListbox}),null!==c.activeOptionIndex&&c.propsRef.current.onChange(c.options[c.activeOptionIndex].dataRef.current.value),X().nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case o.ArrowDown:return e.preventDefault(),l({type:_.GoToOption,focus:q.Next});case o.ArrowUp:return e.preventDefault(),l({type:_.GoToOption,focus:q.Previous});case o.Home:case o.PageUp:return e.preventDefault(),l({type:_.GoToOption,focus:q.First});case o.End:case o.PageDown:return e.preventDefault(),l({type:_.GoToOption,focus:q.Last});case o.Escape:return e.preventDefault(),l({type:_.CloseListbox}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));case o.Tab:return e.preventDefault();default:1===e.key.length&&(l({type:_.Search,value:e.key}),v.setTimeout((function(){return l({type:_.ClearSearch})}),350))}}),[p,l,v,c]),y=ee((function(){var e,n,t;return null!=(e=null==(n=c.labelRef.current)?void 0:n.id)?e:null==(t=c.buttonRef.current)?void 0:t.id}),[c.labelRef.current,c.buttonRef.current]),h=n.useMemo((function(){return{open:c.listboxState===W.Open}}),[c]);return f(i({},t,{"aria-activedescendant":null===c.activeOptionIndex||null==(u=c.options[c.activeOptionIndex])?void 0:u.id,"aria-labelledby":y,id:d,onKeyDown:b,role:"listbox",tabIndex:0,ref:s}),h,"ul",pe,c.listboxState===W.Open)}));ce.Button=de,ce.Label=function e(t){var r=ue([ce.name,e.name].join("."))[0],o="headlessui-listbox-label-"+x(),u=n.useCallback((function(){var e;return null==(e=r.buttonRef.current)?void 0:e.focus({preventScroll:!0})}),[r.buttonRef]),a=n.useMemo((function(){return{open:r.listboxState===W.Open}}),[r]);return f(i({},t,{ref:r.labelRef,id:o,onClick:u}),a,"label")},ce.Options=ve,ce.Option=function e(t){var r=t.disabled,o=void 0!==r&&r,u=t.value,c=t.className,l=a(t,["disabled","value","className"]),s=ue([ce.name,e.name].join(".")),d=s[0],p=s[1],v="headlessui-listbox-option-"+x(),m=null!==d.activeOptionIndex&&d.options[d.activeOptionIndex].id===v,b=d.propsRef.current.value===u,h=n.useRef({disabled:o,value:u});y((function(){h.current.disabled=o}),[h,o]),y((function(){h.current.value=u}),[h,u]),y((function(){var e,n;h.current.textValue=null==(e=document.getElementById(v))||null==(n=e.textContent)?void 0:n.toLowerCase()}),[h,v]);var S=n.useCallback((function(){return d.propsRef.current.onChange(u)}),[d.propsRef,u]);y((function(){return p({type:_.RegisterOption,id:v,dataRef:h}),function(){return p({type:_.UnregisterOption,id:v})}}),[h,v]),y((function(){var e;d.listboxState===W.Open&&b&&(p({type:_.GoToOption,focus:q.Specific,id:v}),null==(e=document.getElementById(v))||null==e.focus||e.focus())}),[d.listboxState]),y((function(){if(d.listboxState===W.Open&&m){var e=X();return e.nextFrame((function(){var e;return null==(e=document.getElementById(v))||null==e.scrollIntoView?void 0:e.scrollIntoView({block:"nearest"})})),e.dispose}}),[m,d.listboxState]);var g=n.useCallback((function(e){if(o)return e.preventDefault();S(),p({type:_.CloseListbox}),X().nextFrame((function(){var e;return null==(e=d.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))}),[p,d.buttonRef,o,S]),E=n.useCallback((function(){if(o)return p({type:_.GoToOption,focus:q.Nothing});p({type:_.GoToOption,focus:q.Specific,id:v})}),[o,v,p]),C=n.useCallback((function(){o||m||p({type:_.GoToOption,focus:q.Specific,id:v})}),[o,m,v,p]),w=n.useCallback((function(){o||m&&p({type:_.GoToOption,focus:q.Nothing})}),[o,m,p]),I=n.useMemo((function(){return{active:m,selected:b,disabled:o}}),[m,b,o]);return f(i({},l,{id:v,role:"option",tabIndex:-1,className:te(c,I),"aria-disabled":!0===o||void 0,"aria-selected":!0===b||void 0,onClick:g,onFocus:E,onPointerMove:C,onMouseMove:C,onPointerLeave:w,onMouseLeave:w}),I,"li")},function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(se||(se={})),function(e){e[e.OpenMenu=0]="OpenMenu",e[e.CloseMenu=1]="CloseMenu",e[e.GoToItem=2]="GoToItem",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.RegisterItem=5]="RegisterItem",e[e.UnregisterItem=6]="UnregisterItem"}(fe||(fe={}));var me=((le={})[fe.CloseMenu]=function(e){return i({},e,{activeItemIndex:null,menuState:se.Closed})},le[fe.OpenMenu]=function(e){return i({},e,{menuState:se.Open})},le[fe.GoToItem]=function(e,n){var t=ne(n,{resolveItems:function(){return e.items},resolveActiveIndex:function(){return e.activeItemIndex},resolveId:function(e){return e.id},resolveDisabled:function(e){return e.dataRef.current.disabled}});return""===e.searchQuery&&e.activeItemIndex===t?e:i({},e,{searchQuery:"",activeItemIndex:t})},le[fe.Search]=function(e,n){var t=e.searchQuery+n.value,r=e.items.findIndex((function(e){var n;return(null==(n=e.dataRef.current.textValue)?void 0:n.startsWith(t))&&!e.dataRef.current.disabled}));return i({},e,-1===r||r===e.activeItemIndex?{searchQuery:t}:{searchQuery:t,activeItemIndex:r})},le[fe.ClearSearch]=function(e){return i({},e,{searchQuery:""})},le[fe.RegisterItem]=function(e,n){return i({},e,{items:[].concat(e.items,[{id:n.id,dataRef:n.dataRef}])})},le[fe.UnregisterItem]=function(e,n){var t=e.items.slice(),r=null!==e.activeItemIndex?t[e.activeItemIndex]:null,o=t.findIndex((function(e){return e.id===n.id}));return-1!==o&&t.splice(o,1),i({},e,{items:t,activeItemIndex:o===e.activeItemIndex||null===r?null:t.indexOf(r)})},le),be=n.createContext(null);function ye(e){var t=n.useContext(be);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+ge.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,ye),r}return t}function he(e,n){return s(n.type,me,e,n)}be.displayName="MenuContext";var Se=n.Fragment;function ge(e){var t=n.useReducer(he,{menuState:se.Closed,buttonRef:n.createRef(),itemsRef:n.createRef(),items:[],searchQuery:"",activeItemIndex:null}),r=t[0],o=r.menuState,i=r.itemsRef,a=r.buttonRef,c=t[1];n.useEffect((function(){function e(e){var n,t,r,u=e.target,l=document.activeElement;o===se.Open&&((null==(n=a.current)?void 0:n.contains(u))||((null==(t=i.current)?void 0:t.contains(u))||c({type:fe.CloseMenu}),l!==document.body&&(null==l?void 0:l.contains(u))||e.defaultPrevented||null==(r=a.current)||r.focus({preventScroll:!0})))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[o,i,a,c]);var l=n.useMemo((function(){return{open:o===se.Open}}),[o]);return u.createElement(be.Provider,{value:t},f(e,l,Se))}var xe=p((function e(t,r){var u,a=ye([ge.name,e.name].join(".")),c=a[0],l=a[1],s=m(c.buttonRef,r),d="headlessui-menu-button-"+x(),p=Z(),v=n.useCallback((function(e){switch(e.key){case o.Space:case o.Enter:case o.ArrowDown:e.preventDefault(),l({type:fe.OpenMenu}),p.nextFrame((function(){var e;null==(e=c.itemsRef.current)||e.focus({preventScroll:!0}),l({type:fe.GoToItem,focus:q.First})}));break;case o.ArrowUp:e.preventDefault(),l({type:fe.OpenMenu}),p.nextFrame((function(){var e;null==(e=c.itemsRef.current)||e.focus({preventScroll:!0}),l({type:fe.GoToItem,focus:q.Last})}))}}),[l,c,p]),y=n.useCallback((function(e){if(b(e.currentTarget))return e.preventDefault();t.disabled||(c.menuState===se.Open?(l({type:fe.CloseMenu}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),l({type:fe.OpenMenu}),p.nextFrame((function(){var e;return null==(e=c.itemsRef.current)?void 0:e.focus({preventScroll:!0})}))))}),[l,p,c,t.disabled]),h=n.useMemo((function(){return{open:c.menuState===se.Open}}),[c]);return f(i({},t,{ref:s,id:d,type:"button","aria-haspopup":!0,"aria-controls":null==(u=c.itemsRef.current)?void 0:u.id,"aria-expanded":c.menuState===se.Open||void 0,onKeyDown:v,onClick:y}),h,"button")})),Ee=t.RenderStrategy|t.Static,Ce=p((function e(t,r){var u,a,c=ye([ge.name,e.name].join(".")),l=c[0],s=c[1],d=m(l.itemsRef,r),p="headlessui-menu-items-"+x(),v=Z(),b=n.useCallback((function(e){switch(v.dispose(),e.key){case o.Space:if(""!==l.searchQuery)return e.preventDefault(),s({type:fe.Search,value:e.key});case o.Enter:var n;e.preventDefault(),s({type:fe.CloseMenu}),null!==l.activeItemIndex&&(null==(n=document.getElementById(l.items[l.activeItemIndex].id))||n.click()),X().nextFrame((function(){var e;return null==(e=l.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case o.ArrowDown:return e.preventDefault(),s({type:fe.GoToItem,focus:q.Next});case o.ArrowUp:return e.preventDefault(),s({type:fe.GoToItem,focus:q.Previous});case o.Home:case o.PageUp:return e.preventDefault(),s({type:fe.GoToItem,focus:q.First});case o.End:case o.PageDown:return e.preventDefault(),s({type:fe.GoToItem,focus:q.Last});case o.Escape:e.preventDefault(),s({type:fe.CloseMenu}),X().nextFrame((function(){var e;return null==(e=l.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case o.Tab:return e.preventDefault();default:1===e.key.length&&(s({type:fe.Search,value:e.key}),v.setTimeout((function(){return s({type:fe.ClearSearch})}),350))}}),[s,v,l]),y=n.useMemo((function(){return{open:l.menuState===se.Open}}),[l]);return f(i({},t,{"aria-activedescendant":null===l.activeItemIndex||null==(u=l.items[l.activeItemIndex])?void 0:u.id,"aria-labelledby":null==(a=l.buttonRef.current)?void 0:a.id,id:p,onKeyDown:b,role:"menu",tabIndex:0,ref:d}),y,"div",Ee,l.menuState===se.Open)})),we=n.Fragment;ge.Button=xe,ge.Items=Ce,ge.Item=function e(t){var r=t.disabled,o=void 0!==r&&r,u=t.className,c=t.onClick,l=a(t,["disabled","className","onClick"]),s=ye([ge.name,e.name].join(".")),d=s[0],p=s[1],v="headlessui-menu-item-"+x(),m=null!==d.activeItemIndex&&d.items[d.activeItemIndex].id===v,b=n.useRef({disabled:o});y((function(){b.current.disabled=o}),[b,o]),y((function(){var e,n;b.current.textValue=null==(e=document.getElementById(v))||null==(n=e.textContent)?void 0:n.toLowerCase()}),[b,v]),y((function(){return p({type:fe.RegisterItem,id:v,dataRef:b}),function(){return p({type:fe.UnregisterItem,id:v})}}),[b,v]);var h=n.useCallback((function(e){return o?e.preventDefault():(p({type:fe.CloseMenu}),X().nextFrame((function(){var e;return null==(e=d.buttonRef.current)?void 0:e.focus({preventScroll:!0})})),c?c(e):void 0)}),[p,d.buttonRef,o,c]),S=n.useCallback((function(){if(o)return p({type:fe.GoToItem,focus:q.Nothing});p({type:fe.GoToItem,focus:q.Specific,id:v})}),[o,v,p]),g=n.useCallback((function(){o||m||p({type:fe.GoToItem,focus:q.Specific,id:v})}),[o,m,v,p]),E=n.useCallback((function(){o||m&&p({type:fe.GoToItem,focus:q.Nothing})}),[o,m,p]),C=n.useMemo((function(){return{active:m,disabled:o}}),[m,o]);return f(i({},l,{id:v,role:"menuitem",tabIndex:-1,className:te(u,C),"aria-disabled":!0===o||void 0,onClick:h,onFocus:S,onPointerMove:g,onMouseMove:g,onPointerLeave:E,onMouseLeave:E}),C,we)};var Ie=n.createContext(null);function Oe(e){var t=n.useContext(Ie);if(null===t){var r=new Error("<"+e+" /> is missing a parent <Switch.Group /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,Oe),r}return t}Ie.displayName="GroupContext";var ke,Re=n.Fragment;function Te(e){var t,r,u=e.checked,c=e.onChange,l=e.className,s=a(e,["checked","onChange","className"]),d="headlessui-switch-"+x(),p=n.useContext(Ie),v=n.useCallback((function(){return c(!u)}),[c,u]),m=n.useCallback((function(e){if(b(e.currentTarget))return e.preventDefault();e.preventDefault(),v()}),[v]),y=n.useCallback((function(e){e.key!==o.Tab&&e.preventDefault(),e.key===o.Space&&v()}),[v]),h=n.useCallback((function(e){return e.preventDefault()}),[]),S=n.useMemo((function(){return{checked:u}}),[u]),g={id:d,ref:null===p?void 0:p.setSwitch,role:"switch",tabIndex:0,className:te(l,S),"aria-checked":u,"aria-labelledby":null==p||null==(t=p.label)?void 0:t.id,"aria-describedby":null==p||null==(r=p.description)?void 0:r.id,onClick:m,onKeyUp:y,onKeyPress:h};return"button"===s.as&&Object.assign(g,{type:"button"}),f(i({},s,g),S,"button")}function De(){var e=n.useRef(!0);return n.useEffect((function(){e.current=!1}),[]),e.current}function Le(e){for(var n,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e&&r.length>0&&(n=e.classList).add.apply(n,r)}function Fe(e){for(var n,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e&&r.length>0&&(n=e.classList).remove.apply(n,r)}function Pe(e,n,t,r,o){var u=X(),i=void 0!==o?function(e){var n={called:!1};return function(){if(!n.called)return n.called=!0,e.apply(void 0,arguments)}}(o):function(){};return Le.apply(void 0,[e].concat(n,t)),u.nextFrame((function(){Fe.apply(void 0,[e].concat(t)),Le.apply(void 0,[e].concat(r)),u.add(function(e,n){var t=X();if(!e)return t.dispose;var r=getComputedStyle(e),o=[r.transitionDuration,r.transitionDelay].map((function(e){var n=e.split(",").filter(Boolean).map((function(e){return e.includes("ms")?parseFloat(e):1e3*parseFloat(e)})).sort((function(e,n){return n-e}))[0];return void 0===n?0:n})),u=o[0];return 0!==u?t.setTimeout((function(){n(ke.Finished)}),u+o[1]):n(ke.Finished),t.add((function(){return n(ke.Cancelled)})),t.dispose}(e,(function(t){return Fe.apply(void 0,[e].concat(r,n)),i(t)})))})),u.add((function(){return Fe.apply(void 0,[e].concat(n,t,r))})),u.add((function(){return i(ke.Cancelled)})),u.dispose}function Me(e){return void 0===e&&(e=""),n.useMemo((function(){return e.split(" ").filter((function(e){return e.trim().length>1}))}),[e])}Te.Group=function(e){var t=n.useState(null),r=t[0],o=t[1],i=n.useState(null),a=i[0],c=i[1],l=n.useState(null),s=l[0],d=l[1],p=n.useMemo((function(){return{switch:r,setSwitch:o,label:a,setLabel:c,description:s,setDescription:d}}),[r,o,a,c,s,d]);return u.createElement(Ie.Provider,{value:p},f(e,{},Re))},Te.Label=function e(t){var r=Oe([Te.name,e.name].join(".")),o="headlessui-switch-label-"+x(),u=n.useCallback((function(){r.switch&&(r.switch.click(),r.switch.focus({preventScroll:!0}))}),[r.switch]);return f(i({},t,{ref:r.setLabel,id:o,onClick:u}),{},"label")},Te.Description=function e(n){var t=Oe([Te.name,e.name].join(".")),r="headlessui-switch-description-"+x();return f(i({},n,{ref:t.setDescription,id:r}),{},"p")},function(e){e.Finished="finished",e.Cancelled="cancelled"}(ke||(ke={}));var Ae,je=n.createContext(null);je.displayName="TransitionContext",function(e){e.Visible="visible",e.Hidden="hidden"}(Ae||(Ae={}));var Ne=n.createContext(null);function Ue(e){return"children"in e?Ue(e.children):e.current.filter((function(e){return e.state===Ae.Visible})).length>0}function Ge(e){var t=n.useRef(e),o=n.useRef([]),u=function(){var e=n.useRef(!0);return n.useEffect((function(){return function(){e.current=!1}}),[]),e}();n.useEffect((function(){t.current=e}),[e]);var i=n.useCallback((function(e,n){var i;void 0===n&&(n=r.Hidden);var a=o.current.findIndex((function(n){return n.id===e}));-1!==a&&(s(n,((i={})[r.Unmount]=function(){o.current.splice(a,1)},i[r.Hidden]=function(){o.current[a].state=Ae.Hidden},i)),!Ue(o)&&u.current&&(null==t.current||t.current()))}),[t,u,o]),a=n.useCallback((function(e){var n=o.current.find((function(n){return n.id===e}));return n?n.state!==Ae.Visible&&(n.state=Ae.Visible):o.current.push({id:e,state:Ae.Visible}),function(){return i(e,r.Unmount)}}),[o,i]);return n.useMemo((function(){return{children:o,register:a,unregister:i}}),[a,i,o])}function He(){}Ne.displayName="NestingContext";var Ve=["beforeEnter","afterEnter","beforeLeave","afterLeave"];function Qe(e){for(var n,t={},r=l(Ve);!(n=r()).done;){var o,u=n.value;t[u]=null!=(o=e[u])?o:He}return t}var Be=t.RenderStrategy;function Ke(e){var t=e.beforeEnter,o=e.afterEnter,c=e.beforeLeave,l=e.afterLeave,d=e.enter,p=e.enterFrom,v=e.enterTo,m=e.leave,b=e.leaveFrom,h=e.leaveTo,S=a(e,["beforeEnter","afterEnter","beforeLeave","afterLeave","enter","enterFrom","enterTo","leave","leaveFrom","leaveTo"]),g=n.useRef(null),E=n.useState(Ae.Visible),C=E[0],w=E[1],I=S.unmount?r.Unmount:r.Hidden,O=function(){var e=n.useContext(je);if(null===e)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition />.");return e}(),k=O.show,R=O.appear,T=function(){var e=n.useContext(Ne);if(null===e)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition />.");return e}(),D=T.register,L=T.unregister,F=De(),P=x(),M=n.useRef(!1),A=Ge((function(){M.current||(w(Ae.Hidden),L(P),Q.current.afterLeave())}));y((function(){if(P)return D(P)}),[D,P]),y((function(){var e;I===r.Hidden&&P&&(k&&C!==Ae.Visible?w(Ae.Visible):s(C,((e={})[Ae.Hidden]=function(){return L(P)},e[Ae.Visible]=function(){return D(P)},e)))}),[C,P,D,L,k,I]);var j=Me(d),N=Me(p),U=Me(v),G=Me(m),H=Me(b),V=Me(h),Q=function(e){var t=n.useRef(Qe(e));return n.useEffect((function(){t.current=Qe(e)}),[e]),t}({beforeEnter:t,afterEnter:o,beforeLeave:c,afterLeave:l});n.useEffect((function(){if(C===Ae.Visible&&null===g.current)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")}),[g,C]);var B=F&&!R;return y((function(){var e=g.current;if(e&&!B)return M.current=!0,k&&Q.current.beforeEnter(),k||Q.current.beforeLeave(),k?Pe(e,j,N,U,(function(e){M.current=!1,e===ke.Finished&&Q.current.afterEnter()})):Pe(e,G,H,V,(function(e){M.current=!1,e===ke.Finished&&(Ue(A)||(w(Ae.Hidden),L(P),Q.current.afterLeave()))}))}),[Q,P,M,L,A,g,B,k,j,N,U,G,H,V]),u.createElement(Ne.Provider,{value:A},f(i({},S,{ref:g}),{},"div",Be,C===Ae.Visible))}function qe(e){var t=e.show,r=e.appear,o=void 0!==r&&r,c=e.unmount,l=a(e,["show","appear","unmount"]);if(![!0,!1].includes(t))throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");var s=n.useState(t?Ae.Visible:Ae.Hidden),d=s[0],p=s[1],v=Ge((function(){p(Ae.Hidden)})),m=De(),b=n.useMemo((function(){return{show:t,appear:o||!m}}),[t,o,m]);n.useEffect((function(){t?p(Ae.Visible):Ue(v)||p(Ae.Hidden)}),[t,v]);var y={unmount:c};return u.createElement(Ne.Provider,{value:v},u.createElement(je.Provider,{value:b},f(i({},y,{as:n.Fragment,children:u.createElement(Ke,Object.assign({},y,l))}),{},n.Fragment,Be,d===Ae.Visible)))}qe.Child=Ke,e.Dialog=P,e.Disclosure=K,e.FocusTrap=function(e){var t=n.useRef(null);return k(t),f(i({},e,{ref:t}),{},"div")},e.Listbox=ce,e.Menu=ge,e.Switch=Te,e.Transition=qe,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e=e||self).headlessui={},e.React)}(this,(function(e,n){"use strict";var t,r,o,u="default"in n?n.default:n;function i(){return(i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function a(e,n){if(null==e)return{};var t,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n.indexOf(t=u[r])>=0||(o[t]=e[t]);return o}function c(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function l(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return c(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?c(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}function s(e,n){if(e in n){for(var t=n[e],r=arguments.length,o=new Array(r>2?r-2:0),u=2;u<r;u++)o[u-2]=arguments[u];return"function"==typeof t?t.apply(void 0,o):t}var i=new Error('Tried to handle "'+e+'" but there is no handler defined. Only defined handlers are: '+Object.keys(n).map((function(e){return'"'+e+'"'})).join(", ")+".");throw Error.captureStackTrace&&Error.captureStackTrace(i,s),i}function f(e,n,o,u,c){if(void 0===c&&(c=!0),c)return d(e,n,o);var l=null!=u?u:t.None;if(l&t.Static){var f=e.static,p=void 0!==f&&f,v=a(e,["static"]);if(p)return d(v,n,o)}if(l&t.RenderStrategy){var m,b=e.unmount,y=void 0===b||b,h=a(e,["unmount"]);return s(y?r.Unmount:r.Hidden,((m={})[r.Unmount]=function(){return null},m[r.Hidden]=function(){return d(i({},h,{hidden:!0,style:{display:"none"}}),n,o)},m))}return d(e,n,o)}function d(e,t,r){var o,u=v(e,["unmount","static"]),i=u.as,c=void 0===i?r:i,s=u.children,f=u.refName,p=void 0===f?"ref":f,m=a(u,["as","children","refName"]),b=void 0!==e.ref?((o={})[p]=e.ref,o):{},y="function"==typeof s?s(t):s;if(c===n.Fragment&&Object.keys(m).length>0){if(Array.isArray(y)&&y.length>1){var h=new Error("You should only render 1 child");throw Error.captureStackTrace&&Error.captureStackTrace(h,d),h}if(!n.isValidElement(y)){var S=new Error('You should render an element as a child. Did you forget the as="..." prop?');throw Error.captureStackTrace&&Error.captureStackTrace(S,d),S}return n.cloneElement(y,Object.assign({},function(e,n,t){for(var r,o=Object.assign({},e),u=function(){var t,u=r.value;void 0!==e[u]&&void 0!==n[u]&&Object.assign(o,((t={})[u]=function(t){t.defaultPrevented||e[u](t),t.defaultPrevented||n[u](t)},t))},i=l(["onClick"]);!(r=i()).done;)u();return o}(function(e){var n=Object.assign({},e);for(var t in n)void 0===n[t]&&delete n[t];return n}(v(m,["ref"])),y.props),b))}return n.createElement(c,Object.assign({},v(m,["ref"]),c!==n.Fragment&&b),y)}function p(e){return n.forwardRef(e)}function v(e,n){void 0===n&&(n=[]);for(var t,r=Object.assign({},e),o=l(n);!(t=o()).done;){var u=t.value;u in r&&delete r[u]}return r}function m(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.useCallback((function(e){t.forEach((function(n){if(null!==n)return"function"==typeof n?n(e):void(n.current=e)}))}),[t])}function b(e){for(var n,t,r=e.parentElement,o=null;r&&!(r instanceof HTMLFieldSetElement);)r instanceof HTMLLegendElement&&(o=r),r=r.parentElement;var u=null!=(n=""===(null==(t=r)?void 0:t.getAttribute("disabled")))&&n;return(!u||!function(e){if(!e)return!1;for(var n=e.previousElementSibling;null!==n;){if(n instanceof HTMLLegendElement)return!1;n=n.previousElementSibling}return!0}(o))&&u}!function(e){e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static"}(t||(t={})),function(e){e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden"}(r||(r={})),function(e){e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.ArrowUp="ArrowUp",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab"}(o||(o={}));var y="undefined"!=typeof window?n.useLayoutEffect:n.useEffect,h={serverHandoffComplete:!1},S=0;function g(){return++S}function x(){var e=n.useState(h.serverHandoffComplete?g:null),t=e[0],r=e[1];return y((function(){null===t&&r(g())}),[t]),n.useEffect((function(){!1===h.serverHandoffComplete&&(h.serverHandoffComplete=!0)}),[]),null!=t?""+t:void 0}var E,C,w,I=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map((function(e){return e+":not([tabindex='-1'])"})).join(",");function O(e){e&&e.focus({preventScroll:!0})}function k(e,t){void 0===t&&(t=!0);var r=n.useRef(null),u=n.useRef(null),i=n.useRef(!1),a=n.useCallback((function(){return e.current?Array.from(e.current.querySelectorAll(I)):[]}),[e]);y((function(){if(t){i.current=!0,r.current=document.activeElement;var e=a();if(e.length<=0)throw new Error("There are no focusable elements inside the <FocusTrap />");return function n(t){void 0!==t&&(O(t),document.activeElement!==t?n(e[e.indexOf(t)+1]):u.current=t)}(e[0]),function(){i.current=!1,O(r.current),r.current=null,u.current=null}}}),[t,i]),y((function(){if(t)return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)};function e(e){if(e.key===o.Tab&&document.activeElement){e.preventDefault();var n=e.shiftKey?-1:1,t=a(),r=t.length;!function e(o){void 0===o&&(o=0);var i=t.indexOf(document.activeElement),a=t[(i+r+n+o)%r];O(a),a!==document.activeElement?e(o+n):u.current=a}()}}}),[t,a]),y((function(){if(t&&e.current){var n=e.current;return window.addEventListener("focus",r,!0),function(){return window.removeEventListener("focus",r,!0)}}function r(e){var t=u.current;if(t&&i.current){var r=e.target;r&&r instanceof HTMLElement?n.contains(r)?(u.current=r,O(r)):(e.preventDefault(),e.stopPropagation(),O(t)):O(u.current)}}}),[t,i,e])}!function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(C||(C={})),function(e){e[e.SetTitleElement=0]="SetTitleElement",e[e.SetDescriptionElement=1]="SetDescriptionElement"}(w||(w={}));var R=((E={})[w.SetTitleElement]=function(e,n){return e.titleElement===n.element?e:i({},e,{titleElement:n.element})},E[w.SetDescriptionElement]=function(e,n){return e.descriptionElement===n.element?e:i({},e,{descriptionElement:n.element})},E),T=n.createContext(null);function D(e){var t=n.useContext(T);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+P.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,D),r}return t}function L(e,n){return s(n.type,R,e,n)}T.displayName="DialogContext";var F=t.RenderStrategy|t.Static;function P(e){var t,r,c=e.open,l=e.onClose,s=a(e,["open","onClose"]),d=n.useRef(null),p=e.hasOwnProperty("open"),v=e.hasOwnProperty("onClose");if(!p)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!v)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if("boolean"!=typeof c)throw new Error("You provided an `open` prop to the `Dialog`, but the value is not a boolean. Received: "+c);if("function"!=typeof l)throw new Error("You provided an `onClose` prop to the `Dialog`, but the value is not a function. Received: "+l);var m=c?C.Open:C.Closed,b=n.useReducer(L,{titleElement:null,descriptionElement:null}),y=b[0],h=b[1],S=n.useCallback((function(){return l(!1)}),[l]),g=n.useCallback((function(e){return h({type:w.SetTitleElement,element:e})}),[h]),E=n.useCallback((function(e){return h({type:w.SetDescriptionElement,element:e})}),[h]);n.useEffect((function(){function e(e){e.key===o.Escape&&m===C.Open&&S()}return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}}),[S,m]),k(d,!!e.static||m===C.Open);var I="headlessui-dialog-"+x(),O=n.useMemo((function(){return[{dialogState:m,close:S,setTitle:g,setDescription:E},y]}),[m,y,S,g,E]),R=n.useMemo((function(){return{open:m===C.Open,close:S}}),[m,S]),D={ref:d,id:I,role:"dialog","aria-modal":!0,"aria-labelledby":null==(t=y.titleElement)?void 0:t.id,"aria-describedby":null==(r=y.descriptionElement)?void 0:r.id};return u.createElement(T.Provider,{value:O},f(i({},s,D),R,"div",F,m===C.Open))}var M,A,j,N=p((function e(t,r){var o=D([P.name,e.name].join("."))[0],u=o.dialogState,a=o.close,c=m(r),l="headlessui-dialog-overlay-"+x(),s=n.useCallback((function(e){if(b(e.currentTarget))return e.preventDefault();a()}),[a]),d=n.useMemo((function(){return{open:u===C.Open}}),[u]);return f(i({},t,{ref:c,id:l,"aria-hidden":!0,onClick:s}),d,"div")}));P.Overlay=N,P.Title=function e(t){var r=D([P.name,e.name].join("."))[0],o=r.dialogState,u=r.setTitle,a="headlessui-dialog-title-"+x(),c=n.useMemo((function(){return{open:o===C.Open}}),[o]);return f(i({},t,{ref:u,id:a}),c,"h2")},P.Description=function e(t){var r=D([P.name,e.name].join("."))[0],o=r.dialogState,u=r.setDescription,a="headlessui-dialog-description-"+x(),c=n.useMemo((function(){return{open:o===C.Open}}),[o]);return f(i({},t,{ref:u,id:a}),c,"p")},function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(A||(A={})),function(e){e[e.ToggleDisclosure=0]="ToggleDisclosure",e[e.SetButtonId=1]="SetButtonId",e[e.SetPanelId=2]="SetPanelId",e[e.LinkPanel=3]="LinkPanel",e[e.UnlinkPanel=4]="UnlinkPanel"}(j||(j={}));var U=((M={})[j.ToggleDisclosure]=function(e){var n;return i({},e,{disclosureState:s(e.disclosureState,(n={},n[A.Open]=A.Closed,n[A.Closed]=A.Open,n))})},M[j.LinkPanel]=function(e){return i({},e,{linkedPanel:!0})},M[j.UnlinkPanel]=function(e){return i({},e,{linkedPanel:!1})},M[j.SetButtonId]=function(e,n){return i({},e,{buttonId:n.buttonId})},M[j.SetPanelId]=function(e,n){return i({},e,{panelId:n.panelId})},M),G=n.createContext(null);function H(e){var t=n.useContext(G);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+B.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,H),r}return t}function V(e,n){return s(n.type,U,e,n)}G.displayName="DisclosureContext";var Q=n.Fragment;function B(e){var t="headlessui-disclosure-button-"+x(),r="headlessui-disclosure-panel-"+x(),o=n.useReducer(V,{disclosureState:A.Closed,linkedPanel:!1,buttonId:t,panelId:r}),i=o[0].disclosureState,a=o[1];n.useEffect((function(){return a({type:j.SetButtonId,buttonId:t})}),[t,a]),n.useEffect((function(){return a({type:j.SetPanelId,panelId:r})}),[r,a]);var c=n.useMemo((function(){return{open:i===A.Open}}),[i]);return u.createElement(G.Provider,{value:o},f(e,c,Q))}var K,q,Y,W,_=p((function e(t,r){var u=H([B.name,e.name].join(".")),a=u[0],c=u[1],l=m(r),s=n.useCallback((function(e){switch(e.key){case o.Space:case o.Enter:e.preventDefault(),c({type:j.ToggleDisclosure})}}),[c]),d=n.useCallback((function(e){b(e.currentTarget)||t.disabled||c({type:j.ToggleDisclosure})}),[c,t.disabled]),p=n.useMemo((function(){return{open:a.disclosureState===A.Open}}),[a]);return f(i({},t,{ref:l,id:a.buttonId,type:"button","aria-expanded":a.disclosureState===A.Open||void 0,"aria-controls":a.linkedPanel?a.panelId:void 0,onKeyDown:s,onClick:d}),p,"button")})),$=t.RenderStrategy|t.Static,z=p((function e(t,r){var o=H([B.name,e.name].join(".")),a=o[0],c=o[1],l=m(r,(function(){a.linkedPanel||c({type:j.LinkPanel})}));n.useEffect((function(){return function(){return c({type:j.UnlinkPanel})}}),[c]),u.useEffect((function(){var e;a.disclosureState!==A.Closed||null!=(e=t.unmount)&&!e||c({type:j.UnlinkPanel})}),[a.disclosureState,t.unmount,c]);var s=u.useMemo((function(){return{open:a.disclosureState===A.Open}}),[a]);return f(i({},t,{ref:l,id:a.panelId}),s,"div",$,a.disclosureState===A.Open)}));function J(){var e=[],n={requestAnimationFrame:function(e){function n(){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(){var e=requestAnimationFrame.apply(void 0,arguments);n.add((function(){return cancelAnimationFrame(e)}))})),nextFrame:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.requestAnimationFrame((function(){n.requestAnimationFrame.apply(n,t)}))},setTimeout:function(e){function n(){return e.apply(this,arguments)}return n.toString=function(){return e.toString()},n}((function(){var e=setTimeout.apply(void 0,arguments);n.add((function(){return clearTimeout(e)}))})),add:function(n){e.push(n)},dispose:function(){for(var n,t=l(e.splice(0));!(n=t()).done;)(0,n.value)()}};return n}function X(){var e=n.useState(J)[0];return n.useEffect((function(){return function(){return e.dispose()}}),[e]),e}function Z(e,t){var r=n.useState(e),o=r[0],u=r[1],i=n.useRef(e);return y((function(){i.current=e}),[e]),y((function(){return u(i.current)}),[i,u].concat(t)),o}function ee(e,n){var t=n.resolveItems();if(t.length<=0)return null;var r=n.resolveActiveIndex(),o=null!=r?r:-1,u=function(){switch(e.focus){case K.First:return t.findIndex((function(e){return!n.resolveDisabled(e)}));case K.Previous:var r=t.slice().reverse().findIndex((function(e,t,r){return!(-1!==o&&r.length-t-1>=o||n.resolveDisabled(e))}));return-1===r?r:t.length-1-r;case K.Next:return t.findIndex((function(e,t){return!(t<=o||n.resolveDisabled(e))}));case K.Last:var u=t.slice().reverse().findIndex((function(e){return!n.resolveDisabled(e)}));return-1===u?u:t.length-1-u;case K.Specific:return t.findIndex((function(t){return n.resolveId(t)===e.id}));case K.Nothing:return null;default:!function(e){throw new Error("Unexpected object: "+e)}(e)}}();return-1===u?r:u}function ne(e,n){if(void 0!==e)return"function"==typeof e?e(n):e}B.Button=_,B.Panel=z,function(e){e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing"}(K||(K={})),function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(Y||(Y={})),function(e){e[e.OpenListbox=0]="OpenListbox",e[e.CloseListbox=1]="CloseListbox",e[e.GoToOption=2]="GoToOption",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.RegisterOption=5]="RegisterOption",e[e.UnregisterOption=6]="UnregisterOption"}(W||(W={}));var te=((q={})[W.CloseListbox]=function(e){return i({},e,{activeOptionIndex:null,listboxState:Y.Closed})},q[W.OpenListbox]=function(e){return i({},e,{listboxState:Y.Open})},q[W.GoToOption]=function(e,n){var t=ee(n,{resolveItems:function(){return e.options},resolveActiveIndex:function(){return e.activeOptionIndex},resolveId:function(e){return e.id},resolveDisabled:function(e){return e.dataRef.current.disabled}});return""===e.searchQuery&&e.activeOptionIndex===t?e:i({},e,{searchQuery:"",activeOptionIndex:t})},q[W.Search]=function(e,n){var t=e.searchQuery+n.value,r=e.options.findIndex((function(e){var n;return!e.dataRef.current.disabled&&(null==(n=e.dataRef.current.textValue)?void 0:n.startsWith(t))}));return i({},e,-1===r||r===e.activeOptionIndex?{searchQuery:t}:{searchQuery:t,activeOptionIndex:r})},q[W.ClearSearch]=function(e){return i({},e,{searchQuery:""})},q[W.RegisterOption]=function(e,n){return i({},e,{options:[].concat(e.options,[{id:n.id,dataRef:n.dataRef}])})},q[W.UnregisterOption]=function(e,n){var t=e.options.slice(),r=null!==e.activeOptionIndex?t[e.activeOptionIndex]:null,o=t.findIndex((function(e){return e.id===n.id}));return-1!==o&&t.splice(o,1),i({},e,{options:t,activeOptionIndex:o===e.activeOptionIndex||null===r?null:t.indexOf(r)})},q),re=n.createContext(null);function oe(e){var t=n.useContext(re);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+ae.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,oe),r}return t}function ue(e,n){return s(n.type,te,e,n)}re.displayName="ListboxContext";var ie=n.Fragment;function ae(e){var t=e.value,r=e.onChange,o=a(e,["value","onChange"]),i=X(),c=n.useReducer(ue,{listboxState:Y.Closed,propsRef:{current:{value:t,onChange:r}},labelRef:n.createRef(),buttonRef:n.createRef(),optionsRef:n.createRef(),options:[],searchQuery:"",activeOptionIndex:null}),l=c[0],s=l.listboxState,d=l.propsRef,p=l.optionsRef,v=l.buttonRef,m=c[1];y((function(){d.current.value=t}),[t,d]),y((function(){d.current.onChange=r}),[r,d]),n.useEffect((function(){function e(e){var n,t,r,o=e.target,u=document.activeElement;s===Y.Open&&((null==(n=v.current)?void 0:n.contains(o))||((null==(t=p.current)?void 0:t.contains(o))||m({type:W.CloseListbox}),u!==document.body&&(null==u?void 0:u.contains(o))||e.defaultPrevented||null==(r=v.current)||r.focus({preventScroll:!0})))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[s,p,v,i,m]);var b=n.useMemo((function(){return{open:s===Y.Open}}),[s]);return u.createElement(re.Provider,{value:c},f(o,b,ie))}var ce,le,se,fe=p((function e(t,r){var u,a=oe([ae.name,e.name].join(".")),c=a[0],l=a[1],s=m(c.buttonRef,r),d="headlessui-listbox-button-"+x(),p=X(),v=n.useCallback((function(e){switch(e.key){case o.Space:case o.Enter:case o.ArrowDown:e.preventDefault(),l({type:W.OpenListbox}),p.nextFrame((function(){var e;null==(e=c.optionsRef.current)||e.focus({preventScroll:!0}),c.propsRef.current.value||l({type:W.GoToOption,focus:K.First})}));break;case o.ArrowUp:e.preventDefault(),l({type:W.OpenListbox}),p.nextFrame((function(){var e;null==(e=c.optionsRef.current)||e.focus({preventScroll:!0}),c.propsRef.current.value||l({type:W.GoToOption,focus:K.Last})}))}}),[l,c,p]),y=n.useCallback((function(e){if(b(e.currentTarget))return e.preventDefault();t.disabled||(c.listboxState===Y.Open?(l({type:W.CloseListbox}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),l({type:W.OpenListbox}),p.nextFrame((function(){var e;return null==(e=c.optionsRef.current)?void 0:e.focus({preventScroll:!0})}))))}),[l,p,c,t.disabled]),h=Z((function(){if(c.labelRef.current)return[c.labelRef.current.id,d].join(" ")}),[c.labelRef.current,d]),S=n.useMemo((function(){return{open:c.listboxState===Y.Open}}),[c]);return f(i({},t,{ref:s,id:d,type:"button","aria-haspopup":!0,"aria-controls":null==(u=c.optionsRef.current)?void 0:u.id,"aria-expanded":c.listboxState===Y.Open||void 0,"aria-labelledby":h,onKeyDown:v,onClick:y}),S,"button")})),de=t.RenderStrategy|t.Static,pe=p((function e(t,r){var u,a=oe([ae.name,e.name].join(".")),c=a[0],l=a[1],s=m(c.optionsRef,r),d="headlessui-listbox-options-"+x(),p=X(),v=X(),b=n.useCallback((function(e){switch(v.dispose(),e.key){case o.Space:if(""!==c.searchQuery)return e.preventDefault(),l({type:W.Search,value:e.key});case o.Enter:e.preventDefault(),l({type:W.CloseListbox}),null!==c.activeOptionIndex&&c.propsRef.current.onChange(c.options[c.activeOptionIndex].dataRef.current.value),J().nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case o.ArrowDown:return e.preventDefault(),l({type:W.GoToOption,focus:K.Next});case o.ArrowUp:return e.preventDefault(),l({type:W.GoToOption,focus:K.Previous});case o.Home:case o.PageUp:return e.preventDefault(),l({type:W.GoToOption,focus:K.First});case o.End:case o.PageDown:return e.preventDefault(),l({type:W.GoToOption,focus:K.Last});case o.Escape:return e.preventDefault(),l({type:W.CloseListbox}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));case o.Tab:return e.preventDefault();default:1===e.key.length&&(l({type:W.Search,value:e.key}),v.setTimeout((function(){return l({type:W.ClearSearch})}),350))}}),[p,l,v,c]),y=Z((function(){var e,n,t;return null!=(e=null==(n=c.labelRef.current)?void 0:n.id)?e:null==(t=c.buttonRef.current)?void 0:t.id}),[c.labelRef.current,c.buttonRef.current]),h=n.useMemo((function(){return{open:c.listboxState===Y.Open}}),[c]);return f(i({},t,{"aria-activedescendant":null===c.activeOptionIndex||null==(u=c.options[c.activeOptionIndex])?void 0:u.id,"aria-labelledby":y,id:d,onKeyDown:b,role:"listbox",tabIndex:0,ref:s}),h,"ul",de,c.listboxState===Y.Open)}));ae.Button=fe,ae.Label=function e(t){var r=oe([ae.name,e.name].join("."))[0],o="headlessui-listbox-label-"+x(),u=n.useCallback((function(){var e;return null==(e=r.buttonRef.current)?void 0:e.focus({preventScroll:!0})}),[r.buttonRef]),a=n.useMemo((function(){return{open:r.listboxState===Y.Open}}),[r]);return f(i({},t,{ref:r.labelRef,id:o,onClick:u}),a,"label")},ae.Options=pe,ae.Option=function e(t){var r=t.disabled,o=void 0!==r&&r,u=t.value,c=t.className,l=a(t,["disabled","value","className"]),s=oe([ae.name,e.name].join(".")),d=s[0],p=s[1],v="headlessui-listbox-option-"+x(),m=null!==d.activeOptionIndex&&d.options[d.activeOptionIndex].id===v,b=d.propsRef.current.value===u,h=n.useRef({disabled:o,value:u});y((function(){h.current.disabled=o}),[h,o]),y((function(){h.current.value=u}),[h,u]),y((function(){var e,n;h.current.textValue=null==(e=document.getElementById(v))||null==(n=e.textContent)?void 0:n.toLowerCase()}),[h,v]);var S=n.useCallback((function(){return d.propsRef.current.onChange(u)}),[d.propsRef,u]);y((function(){return p({type:W.RegisterOption,id:v,dataRef:h}),function(){return p({type:W.UnregisterOption,id:v})}}),[h,v]),y((function(){var e;d.listboxState===Y.Open&&b&&(p({type:W.GoToOption,focus:K.Specific,id:v}),null==(e=document.getElementById(v))||null==e.focus||e.focus())}),[d.listboxState]),y((function(){if(d.listboxState===Y.Open&&m){var e=J();return e.nextFrame((function(){var e;return null==(e=document.getElementById(v))||null==e.scrollIntoView?void 0:e.scrollIntoView({block:"nearest"})})),e.dispose}}),[m,d.listboxState]);var g=n.useCallback((function(e){if(o)return e.preventDefault();S(),p({type:W.CloseListbox}),J().nextFrame((function(){var e;return null==(e=d.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))}),[p,d.buttonRef,o,S]),E=n.useCallback((function(){if(o)return p({type:W.GoToOption,focus:K.Nothing});p({type:W.GoToOption,focus:K.Specific,id:v})}),[o,v,p]),C=n.useCallback((function(){o||m||p({type:W.GoToOption,focus:K.Specific,id:v})}),[o,m,v,p]),w=n.useCallback((function(){o||m&&p({type:W.GoToOption,focus:K.Nothing})}),[o,m,p]),I=n.useMemo((function(){return{active:m,selected:b,disabled:o}}),[m,b,o]);return f(i({},l,{id:v,role:"option",tabIndex:-1,className:ne(c,I),"aria-disabled":!0===o||void 0,"aria-selected":!0===b||void 0,onClick:g,onFocus:E,onPointerMove:C,onMouseMove:C,onPointerLeave:w,onMouseLeave:w}),I,"li")},function(e){e[e.Open=0]="Open",e[e.Closed=1]="Closed"}(le||(le={})),function(e){e[e.OpenMenu=0]="OpenMenu",e[e.CloseMenu=1]="CloseMenu",e[e.GoToItem=2]="GoToItem",e[e.Search=3]="Search",e[e.ClearSearch=4]="ClearSearch",e[e.RegisterItem=5]="RegisterItem",e[e.UnregisterItem=6]="UnregisterItem"}(se||(se={}));var ve=((ce={})[se.CloseMenu]=function(e){return i({},e,{activeItemIndex:null,menuState:le.Closed})},ce[se.OpenMenu]=function(e){return i({},e,{menuState:le.Open})},ce[se.GoToItem]=function(e,n){var t=ee(n,{resolveItems:function(){return e.items},resolveActiveIndex:function(){return e.activeItemIndex},resolveId:function(e){return e.id},resolveDisabled:function(e){return e.dataRef.current.disabled}});return""===e.searchQuery&&e.activeItemIndex===t?e:i({},e,{searchQuery:"",activeItemIndex:t})},ce[se.Search]=function(e,n){var t=e.searchQuery+n.value,r=e.items.findIndex((function(e){var n;return(null==(n=e.dataRef.current.textValue)?void 0:n.startsWith(t))&&!e.dataRef.current.disabled}));return i({},e,-1===r||r===e.activeItemIndex?{searchQuery:t}:{searchQuery:t,activeItemIndex:r})},ce[se.ClearSearch]=function(e){return i({},e,{searchQuery:""})},ce[se.RegisterItem]=function(e,n){return i({},e,{items:[].concat(e.items,[{id:n.id,dataRef:n.dataRef}])})},ce[se.UnregisterItem]=function(e,n){var t=e.items.slice(),r=null!==e.activeItemIndex?t[e.activeItemIndex]:null,o=t.findIndex((function(e){return e.id===n.id}));return-1!==o&&t.splice(o,1),i({},e,{items:t,activeItemIndex:o===e.activeItemIndex||null===r?null:t.indexOf(r)})},ce),me=n.createContext(null);function be(e){var t=n.useContext(me);if(null===t){var r=new Error("<"+e+" /> is missing a parent <"+Se.name+" /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,be),r}return t}function ye(e,n){return s(n.type,ve,e,n)}me.displayName="MenuContext";var he=n.Fragment;function Se(e){var t=n.useReducer(ye,{menuState:le.Closed,buttonRef:n.createRef(),itemsRef:n.createRef(),items:[],searchQuery:"",activeItemIndex:null}),r=t[0],o=r.menuState,i=r.itemsRef,a=r.buttonRef,c=t[1];n.useEffect((function(){function e(e){var n,t,r,u=e.target,l=document.activeElement;o===le.Open&&((null==(n=a.current)?void 0:n.contains(u))||((null==(t=i.current)?void 0:t.contains(u))||c({type:se.CloseMenu}),l!==document.body&&(null==l?void 0:l.contains(u))||e.defaultPrevented||null==(r=a.current)||r.focus({preventScroll:!0})))}return window.addEventListener("mousedown",e),function(){return window.removeEventListener("mousedown",e)}}),[o,i,a,c]);var l=n.useMemo((function(){return{open:o===le.Open}}),[o]);return u.createElement(me.Provider,{value:t},f(e,l,he))}var ge=p((function e(t,r){var u,a=be([Se.name,e.name].join(".")),c=a[0],l=a[1],s=m(c.buttonRef,r),d="headlessui-menu-button-"+x(),p=X(),v=n.useCallback((function(e){switch(e.key){case o.Space:case o.Enter:case o.ArrowDown:e.preventDefault(),l({type:se.OpenMenu}),p.nextFrame((function(){var e;null==(e=c.itemsRef.current)||e.focus({preventScroll:!0}),l({type:se.GoToItem,focus:K.First})}));break;case o.ArrowUp:e.preventDefault(),l({type:se.OpenMenu}),p.nextFrame((function(){var e;null==(e=c.itemsRef.current)||e.focus({preventScroll:!0}),l({type:se.GoToItem,focus:K.Last})}))}}),[l,c,p]),y=n.useCallback((function(e){if(b(e.currentTarget))return e.preventDefault();t.disabled||(c.menuState===le.Open?(l({type:se.CloseMenu}),p.nextFrame((function(){var e;return null==(e=c.buttonRef.current)?void 0:e.focus({preventScroll:!0})}))):(e.preventDefault(),l({type:se.OpenMenu}),p.nextFrame((function(){var e;return null==(e=c.itemsRef.current)?void 0:e.focus({preventScroll:!0})}))))}),[l,p,c,t.disabled]),h=n.useMemo((function(){return{open:c.menuState===le.Open}}),[c]);return f(i({},t,{ref:s,id:d,type:"button","aria-haspopup":!0,"aria-controls":null==(u=c.itemsRef.current)?void 0:u.id,"aria-expanded":c.menuState===le.Open||void 0,onKeyDown:v,onClick:y}),h,"button")})),xe=t.RenderStrategy|t.Static,Ee=p((function e(t,r){var u,a,c=be([Se.name,e.name].join(".")),l=c[0],s=c[1],d=m(l.itemsRef,r),p="headlessui-menu-items-"+x(),v=X(),b=n.useCallback((function(e){switch(v.dispose(),e.key){case o.Space:if(""!==l.searchQuery)return e.preventDefault(),s({type:se.Search,value:e.key});case o.Enter:var n;e.preventDefault(),s({type:se.CloseMenu}),null!==l.activeItemIndex&&(null==(n=document.getElementById(l.items[l.activeItemIndex].id))||n.click()),J().nextFrame((function(){var e;return null==(e=l.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case o.ArrowDown:return e.preventDefault(),s({type:se.GoToItem,focus:K.Next});case o.ArrowUp:return e.preventDefault(),s({type:se.GoToItem,focus:K.Previous});case o.Home:case o.PageUp:return e.preventDefault(),s({type:se.GoToItem,focus:K.First});case o.End:case o.PageDown:return e.preventDefault(),s({type:se.GoToItem,focus:K.Last});case o.Escape:e.preventDefault(),s({type:se.CloseMenu}),J().nextFrame((function(){var e;return null==(e=l.buttonRef.current)?void 0:e.focus({preventScroll:!0})}));break;case o.Tab:return e.preventDefault();default:1===e.key.length&&(s({type:se.Search,value:e.key}),v.setTimeout((function(){return s({type:se.ClearSearch})}),350))}}),[s,v,l]),y=n.useMemo((function(){return{open:l.menuState===le.Open}}),[l]);return f(i({},t,{"aria-activedescendant":null===l.activeItemIndex||null==(u=l.items[l.activeItemIndex])?void 0:u.id,"aria-labelledby":null==(a=l.buttonRef.current)?void 0:a.id,id:p,onKeyDown:b,role:"menu",tabIndex:0,ref:d}),y,"div",xe,l.menuState===le.Open)})),Ce=n.Fragment;Se.Button=ge,Se.Items=Ee,Se.Item=function e(t){var r=t.disabled,o=void 0!==r&&r,u=t.className,c=t.onClick,l=a(t,["disabled","className","onClick"]),s=be([Se.name,e.name].join(".")),d=s[0],p=s[1],v="headlessui-menu-item-"+x(),m=null!==d.activeItemIndex&&d.items[d.activeItemIndex].id===v,b=n.useRef({disabled:o});y((function(){b.current.disabled=o}),[b,o]),y((function(){var e,n;b.current.textValue=null==(e=document.getElementById(v))||null==(n=e.textContent)?void 0:n.toLowerCase()}),[b,v]),y((function(){return p({type:se.RegisterItem,id:v,dataRef:b}),function(){return p({type:se.UnregisterItem,id:v})}}),[b,v]);var h=n.useCallback((function(e){return o?e.preventDefault():(p({type:se.CloseMenu}),J().nextFrame((function(){var e;return null==(e=d.buttonRef.current)?void 0:e.focus({preventScroll:!0})})),c?c(e):void 0)}),[p,d.buttonRef,o,c]),S=n.useCallback((function(){if(o)return p({type:se.GoToItem,focus:K.Nothing});p({type:se.GoToItem,focus:K.Specific,id:v})}),[o,v,p]),g=n.useCallback((function(){o||m||p({type:se.GoToItem,focus:K.Specific,id:v})}),[o,m,v,p]),E=n.useCallback((function(){o||m&&p({type:se.GoToItem,focus:K.Nothing})}),[o,m,p]),C=n.useMemo((function(){return{active:m,disabled:o}}),[m,o]);return f(i({},l,{id:v,role:"menuitem",tabIndex:-1,className:ne(u,C),"aria-disabled":!0===o||void 0,onClick:h,onFocus:S,onPointerMove:g,onMouseMove:g,onPointerLeave:E,onMouseLeave:E}),C,Ce)};var we=n.createContext(null);function Ie(e){var t=n.useContext(we);if(null===t){var r=new Error("<"+e+" /> is missing a parent <Switch.Group /> component.");throw Error.captureStackTrace&&Error.captureStackTrace(r,Ie),r}return t}we.displayName="GroupContext";var Oe,ke=n.Fragment;function Re(e){var t,r,u=e.checked,c=e.onChange,l=e.className,s=a(e,["checked","onChange","className"]),d="headlessui-switch-"+x(),p=n.useContext(we),v=n.useCallback((function(){return c(!u)}),[c,u]),m=n.useCallback((function(e){if(b(e.currentTarget))return e.preventDefault();e.preventDefault(),v()}),[v]),y=n.useCallback((function(e){e.key!==o.Tab&&e.preventDefault(),e.key===o.Space&&v()}),[v]),h=n.useCallback((function(e){return e.preventDefault()}),[]),S=n.useMemo((function(){return{checked:u}}),[u]),g={id:d,ref:null===p?void 0:p.setSwitch,role:"switch",tabIndex:0,className:ne(l,S),"aria-checked":u,"aria-labelledby":null==p||null==(t=p.label)?void 0:t.id,"aria-describedby":null==p||null==(r=p.description)?void 0:r.id,onClick:m,onKeyUp:y,onKeyPress:h};return"button"===s.as&&Object.assign(g,{type:"button"}),f(i({},s,g),S,"button")}function Te(){var e=n.useRef(!0);return n.useEffect((function(){e.current=!1}),[]),e.current}function De(e){for(var n,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e&&r.length>0&&(n=e.classList).add.apply(n,r)}function Le(e){for(var n,t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];e&&r.length>0&&(n=e.classList).remove.apply(n,r)}function Fe(e,n,t,r,o){var u=J(),i=void 0!==o?function(e){var n={called:!1};return function(){if(!n.called)return n.called=!0,e.apply(void 0,arguments)}}(o):function(){};return De.apply(void 0,[e].concat(n,t)),u.nextFrame((function(){Le.apply(void 0,[e].concat(t)),De.apply(void 0,[e].concat(r)),u.add(function(e,n){var t=J();if(!e)return t.dispose;var r=getComputedStyle(e),o=[r.transitionDuration,r.transitionDelay].map((function(e){var n=e.split(",").filter(Boolean).map((function(e){return e.includes("ms")?parseFloat(e):1e3*parseFloat(e)})).sort((function(e,n){return n-e}))[0];return void 0===n?0:n})),u=o[0];return 0!==u?t.setTimeout((function(){n(Oe.Finished)}),u+o[1]):n(Oe.Finished),t.add((function(){return n(Oe.Cancelled)})),t.dispose}(e,(function(t){return Le.apply(void 0,[e].concat(r,n)),i(t)})))})),u.add((function(){return Le.apply(void 0,[e].concat(n,t,r))})),u.add((function(){return i(Oe.Cancelled)})),u.dispose}function Pe(e){return void 0===e&&(e=""),n.useMemo((function(){return e.split(" ").filter((function(e){return e.trim().length>1}))}),[e])}Re.Group=function(e){var t=n.useState(null),r=t[0],o=t[1],i=n.useState(null),a=i[0],c=i[1],l=n.useState(null),s=l[0],d=l[1],p=n.useMemo((function(){return{switch:r,setSwitch:o,label:a,setLabel:c,description:s,setDescription:d}}),[r,o,a,c,s,d]);return u.createElement(we.Provider,{value:p},f(e,{},ke))},Re.Label=function e(t){var r=Ie([Re.name,e.name].join(".")),o="headlessui-switch-label-"+x(),u=n.useCallback((function(){r.switch&&(r.switch.click(),r.switch.focus({preventScroll:!0}))}),[r.switch]);return f(i({},t,{ref:r.setLabel,id:o,onClick:u}),{},"label")},Re.Description=function e(n){var t=Ie([Re.name,e.name].join(".")),r="headlessui-switch-description-"+x();return f(i({},n,{ref:t.setDescription,id:r}),{},"p")},function(e){e.Finished="finished",e.Cancelled="cancelled"}(Oe||(Oe={}));var Me,Ae=n.createContext(null);Ae.displayName="TransitionContext",function(e){e.Visible="visible",e.Hidden="hidden"}(Me||(Me={}));var je=n.createContext(null);function Ne(e){return"children"in e?Ne(e.children):e.current.filter((function(e){return e.state===Me.Visible})).length>0}function Ue(e){var t=n.useRef(e),o=n.useRef([]),u=function(){var e=n.useRef(!0);return n.useEffect((function(){return function(){e.current=!1}}),[]),e}();n.useEffect((function(){t.current=e}),[e]);var i=n.useCallback((function(e,n){var i;void 0===n&&(n=r.Hidden);var a=o.current.findIndex((function(n){return n.id===e}));-1!==a&&(s(n,((i={})[r.Unmount]=function(){o.current.splice(a,1)},i[r.Hidden]=function(){o.current[a].state=Me.Hidden},i)),!Ne(o)&&u.current&&(null==t.current||t.current()))}),[t,u,o]),a=n.useCallback((function(e){var n=o.current.find((function(n){return n.id===e}));return n?n.state!==Me.Visible&&(n.state=Me.Visible):o.current.push({id:e,state:Me.Visible}),function(){return i(e,r.Unmount)}}),[o,i]);return n.useMemo((function(){return{children:o,register:a,unregister:i}}),[a,i,o])}function Ge(){}je.displayName="NestingContext";var He=["beforeEnter","afterEnter","beforeLeave","afterLeave"];function Ve(e){for(var n,t={},r=l(He);!(n=r()).done;){var o,u=n.value;t[u]=null!=(o=e[u])?o:Ge}return t}var Qe=t.RenderStrategy;function Be(e){var t=e.beforeEnter,o=e.afterEnter,c=e.beforeLeave,l=e.afterLeave,d=e.enter,p=e.enterFrom,v=e.enterTo,m=e.leave,b=e.leaveFrom,h=e.leaveTo,S=a(e,["beforeEnter","afterEnter","beforeLeave","afterLeave","enter","enterFrom","enterTo","leave","leaveFrom","leaveTo"]),g=n.useRef(null),E=n.useState(Me.Visible),C=E[0],w=E[1],I=S.unmount?r.Unmount:r.Hidden,O=function(){var e=n.useContext(Ae);if(null===e)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition />.");return e}(),k=O.show,R=O.appear,T=function(){var e=n.useContext(je);if(null===e)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition />.");return e}(),D=T.register,L=T.unregister,F=Te(),P=x(),M=n.useRef(!1),A=Ue((function(){M.current||(w(Me.Hidden),L(P),Q.current.afterLeave())}));y((function(){if(P)return D(P)}),[D,P]),y((function(){var e;I===r.Hidden&&P&&(k&&C!==Me.Visible?w(Me.Visible):s(C,((e={})[Me.Hidden]=function(){return L(P)},e[Me.Visible]=function(){return D(P)},e)))}),[C,P,D,L,k,I]);var j=Pe(d),N=Pe(p),U=Pe(v),G=Pe(m),H=Pe(b),V=Pe(h),Q=function(e){var t=n.useRef(Ve(e));return n.useEffect((function(){t.current=Ve(e)}),[e]),t}({beforeEnter:t,afterEnter:o,beforeLeave:c,afterLeave:l});n.useEffect((function(){if(C===Me.Visible&&null===g.current)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")}),[g,C]);var B=F&&!R;return y((function(){var e=g.current;if(e&&!B)return M.current=!0,k&&Q.current.beforeEnter(),k||Q.current.beforeLeave(),k?Fe(e,j,N,U,(function(e){M.current=!1,e===Oe.Finished&&Q.current.afterEnter()})):Fe(e,G,H,V,(function(e){M.current=!1,e===Oe.Finished&&(Ne(A)||(w(Me.Hidden),L(P),Q.current.afterLeave()))}))}),[Q,P,M,L,A,g,B,k,j,N,U,G,H,V]),u.createElement(je.Provider,{value:A},f(i({},S,{ref:g}),{},"div",Qe,C===Me.Visible))}function Ke(e){var t=e.show,r=e.appear,o=void 0!==r&&r,c=e.unmount,l=a(e,["show","appear","unmount"]);if(![!0,!1].includes(t))throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");var s=n.useState(t?Me.Visible:Me.Hidden),d=s[0],p=s[1],v=Ue((function(){p(Me.Hidden)})),m=Te(),b=n.useMemo((function(){return{show:t,appear:o||!m}}),[t,o,m]);n.useEffect((function(){t?p(Me.Visible):Ne(v)||p(Me.Hidden)}),[t,v]);var y={unmount:c};return u.createElement(je.Provider,{value:v},u.createElement(Ae.Provider,{value:b},f(i({},y,{as:n.Fragment,children:u.createElement(Be,Object.assign({},y,l))}),{},n.Fragment,Qe,d===Me.Visible)))}Ke.Child=Be,e.Dialog=P,e.Disclosure=B,e.FocusTrap=function(e){var t=n.useRef(null);return k(t),f(i({},e,{ref:t}),{},"div")},e.Listbox=ae,e.Menu=Se,e.Switch=Re,e.Transition=Ke,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=headlessui.umd.production.min.js.map |
{ | ||
"name": "@headlessui/react", | ||
"version": "0.2.0-03d412f", | ||
"version": "0.2.0-1da8e49", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "typings": "dist/index.d.ts", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1242023
8376