react-flexible-datepicker
Version:
Custom React Datepicker component
2 lines (1 loc) • 39.7 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react"),wt=require("react-dom");function rt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const E=rt(v),vt=rt(wt);const Pe=e=>v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",fill:"none",...e,className:e.className},v.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8",d:"M3.5 6l4.193 3.887a.414.414 0 00.138.083.488.488 0 00.337 0c.053-.02.1-.048.138-.083L12.5 6"})),xt=e=>v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 20 20",...e,className:e.className},v.createElement("path",{fillRule:"evenodd",d:"M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z",clipRule:"evenodd"})),K=(...e)=>e.filter(Boolean).join(" "),me=v.forwardRef(({children:e,className:t,withHoverEffect:n=!0,...r},o)=>v.createElement("button",{...r,ref:o,className:K("border border-secondary-200 p-2.5 text-sm text-gray-700 rounded-md disabled:text-gray-400 focus:ring-1 flex items-center justify-center",n?"hover:enabled:bg-blue-50":"",t)},e));me.displayName="Button";function re(e){return ot(e)?(e.nodeName||"").toLowerCase():"#document"}function U(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Q(e){var t;return(t=(ot(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ot(e){return e instanceof Node||e instanceof U(e).Node}function V(e){return e instanceof Element||e instanceof U(e).Element}function z(e){return e instanceof HTMLElement||e instanceof U(e).HTMLElement}function Te(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof U(e).ShadowRoot}function ye(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=X(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function bt(e){return["table","td","th"].includes(re(e))}function Le(e){const t=We(),n=X(e);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function Et(e){let t=se(e);for(;z(t)&&!le(t);){if(Le(t))return t;t=se(t)}return null}function We(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function le(e){return["html","body","#document"].includes(re(e))}function X(e){return U(e).getComputedStyle(e)}function De(e){return V(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function se(e){if(re(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Te(e)&&e.host||Q(e);return Te(t)?t.host:t}function it(e){const t=se(e);return le(t)?e.ownerDocument?e.ownerDocument.body:e.body:z(t)&&ye(t)?t:it(t)}function ne(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=it(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=U(o);return i?t.concat(s,s.visualViewport||[],ye(o)?o:[],s.frameElement&&n?ne(s.frameElement):[]):t.concat(o,ne(o,[],n))}function Ve(e,t){if(!e||!t)return!1;const n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&Te(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function je(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function Rt(e){return"nativeEvent"in e}function Dt(e){return e.matches("html,body")}function Ye(e){return(e==null?void 0:e.ownerDocument)||document}function Oe(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function he(e){return"composedPath"in e?e.composedPath()[0]:e.target}const $t="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function Ct(e){return z(e)&&e.matches($t)}const ge=Math.min,Z=Math.max,be=Math.round,ve=Math.floor,oe=e=>({x:e,y:e});function Ae(e,t){return typeof e=="function"?e(t):e}function $e(e){return e.split("-")[0]}function Ie(e){return e.split("-")[1]}function kt(e){return e==="x"?"y":"x"}function Ot(e){return e==="y"?"height":"width"}function Ce(e){return["top","bottom"].includes($e(e))?"y":"x"}function St(e){return kt(Ce(e))}function Mt(e){return{top:0,right:0,bottom:0,left:0,...e}}function _t(e){return typeof e!="number"?Mt(e):{top:e,right:e,bottom:e,left:e}}function Ee(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}function Ke(e,t,n){let{reference:r,floating:o}=e;const i=Ce(t),s=St(t),c=Ot(s),a=$e(t),l=i==="y",p=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,y=r[c]/2-o[c]/2;let m;switch(a){case"top":m={x:p,y:r.y-o.height};break;case"bottom":m={x:p,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:h};break;case"left":m={x:r.x-o.width,y:h};break;default:m={x:r.x,y:r.y}}switch(Ie(t)){case"start":m[s]-=y*(n&&l?-1:1);break;case"end":m[s]+=y*(n&&l?-1:1);break}return m}const Pt=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,c=i.filter(Boolean),a=await(s.isRTL==null?void 0:s.isRTL(t));let l=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:p,y:h}=Ke(l,r,a),y=r,m={},x=0;for(let R=0;R<c.length;R++){const{name:N,fn:k}=c[R],{x:_,y:W,data:M,reset:$}=await k({x:p,y:h,initialPlacement:r,placement:y,strategy:o,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});if(p=_??p,h=W??h,m={...m,[N]:{...m[N],...M}},$&&x<=50){x++,typeof $=="object"&&($.placement&&(y=$.placement),$.rects&&(l=$.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):$.rects),{x:p,y:h}=Ke(l,y,a)),R=-1;continue}}return{x:p,y:h,placement:y,strategy:o,middlewareData:m}};async function Tt(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:c,strategy:a}=e,{boundary:l="clippingAncestors",rootBoundary:p="viewport",elementContext:h="floating",altBoundary:y=!1,padding:m=0}=Ae(t,e),x=_t(m),N=c[y?h==="floating"?"reference":"floating":h],k=Ee(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(N)))==null||n?N:N.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:l,rootBoundary:p,strategy:a})),_=h==="floating"?{...s.floating,x:r,y:o}:s.reference,W=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),M=await(i.isElement==null?void 0:i.isElement(W))?await(i.getScale==null?void 0:i.getScale(W))||{x:1,y:1}:{x:1,y:1},$=Ee(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({rect:_,offsetParent:W,strategy:a}):_);return{top:(k.top-$.top+x.top)/M.y,bottom:($.bottom-k.bottom+x.bottom)/M.y,left:(k.left-$.left+x.left)/M.x,right:($.right-k.right+x.right)/M.x}}async function Nt(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=$e(n),c=Ie(n),a=Ce(n)==="y",l=["left","top"].includes(s)?-1:1,p=i&&a?-1:1,h=Ae(t,e);let{mainAxis:y,crossAxis:m,alignmentAxis:x}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...h};return c&&typeof x=="number"&&(m=c==="end"?x*-1:x),a?{x:m*p,y:y*l}:{x:y*l,y:m*p}}const Lt=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:c}=t,a=await Nt(t,e);return s===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:o+a.x,y:i+a.y,data:{...a,placement:s}}}}},Wt=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:o,elements:i}=t,{apply:s=()=>{},...c}=Ae(e,t),a=await Tt(t,c),l=$e(n),p=Ie(n),h=Ce(n)==="y",{width:y,height:m}=r.floating;let x,R;l==="top"||l==="bottom"?(x=l,R=p===(await(o.isRTL==null?void 0:o.isRTL(i.floating))?"start":"end")?"left":"right"):(R=l,x=p==="end"?"top":"bottom");const N=m-a[x],k=y-a[R],_=!t.middlewareData.shift;let W=N,M=k;if(h){const S=y-a.left-a.right;M=p||_?ge(k,S):S}else{const S=m-a.top-a.bottom;W=p||_?ge(N,S):S}if(_&&!p){const S=Z(a.left,0),B=Z(a.right,0),O=Z(a.top,0),A=Z(a.bottom,0);h?M=y-2*(S!==0||B!==0?S+B:Z(a.left,a.right)):W=m-2*(O!==0||A!==0?O+A:Z(a.top,a.bottom))}await s({...t,availableWidth:M,availableHeight:W});const $=await o.getDimensions(i.floating);return y!==$.width||m!==$.height?{reset:{rects:!0}}:{}}}};function st(e){const t=X(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=z(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,c=be(n)!==i||be(r)!==s;return c&&(n=i,r=s),{width:n,height:r,$:c}}function Fe(e){return V(e)?e:e.contextElement}function ae(e){const t=Fe(e);if(!z(t))return oe(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=st(t);let s=(i?be(n.width):n.width)/r,c=(i?be(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!c||!Number.isFinite(c))&&(c=1),{x:s,y:c}}const At=oe(0);function ct(e){const t=U(e);return!We()||!t.visualViewport?At:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function It(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==U(e)?!1:t}function ce(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=Fe(e);let s=oe(1);t&&(r?V(r)&&(s=ae(r)):s=ae(e));const c=It(i,n,r)?ct(i):oe(0);let a=(o.left+c.x)/s.x,l=(o.top+c.y)/s.y,p=o.width/s.x,h=o.height/s.y;if(i){const y=U(i),m=r&&V(r)?U(r):r;let x=y.frameElement;for(;x&&r&&m!==y;){const R=ae(x),N=x.getBoundingClientRect(),k=X(x),_=N.left+(x.clientLeft+parseFloat(k.paddingLeft))*R.x,W=N.top+(x.clientTop+parseFloat(k.paddingTop))*R.y;a*=R.x,l*=R.y,p*=R.x,h*=R.y,a+=_,l+=W,x=U(x).frameElement}}return Ee({width:p,height:h,x:a,y:l})}function Ft(e){let{rect:t,offsetParent:n,strategy:r}=e;const o=z(n),i=Q(n);if(n===i)return t;let s={scrollLeft:0,scrollTop:0},c=oe(1);const a=oe(0);if((o||!o&&r!=="fixed")&&((re(n)!=="body"||ye(i))&&(s=De(n)),z(n))){const l=ce(n);c=ae(n),a.x=l.x+n.clientLeft,a.y=l.y+n.clientTop}return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-s.scrollLeft*c.x+a.x,y:t.y*c.y-s.scrollTop*c.y+a.y}}function Ht(e){return Array.from(e.getClientRects())}function ut(e){return ce(Q(e)).left+De(e).scrollLeft}function Bt(e){const t=Q(e),n=De(e),r=e.ownerDocument.body,o=Z(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Z(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+ut(e);const c=-n.scrollTop;return X(r).direction==="rtl"&&(s+=Z(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:c}}function Vt(e,t){const n=U(e),r=Q(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,c=0,a=0;if(o){i=o.width,s=o.height;const l=We();(!l||l&&t==="fixed")&&(c=o.offsetLeft,a=o.offsetTop)}return{width:i,height:s,x:c,y:a}}function jt(e,t){const n=ce(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=z(e)?ae(e):oe(1),s=e.clientWidth*i.x,c=e.clientHeight*i.y,a=o*i.x,l=r*i.y;return{width:s,height:c,x:a,y:l}}function Ue(e,t,n){let r;if(t==="viewport")r=Vt(e,n);else if(t==="document")r=Bt(Q(e));else if(V(t))r=jt(t,n);else{const o=ct(e);r={...t,x:t.x-o.x,y:t.y-o.y}}return Ee(r)}function at(e,t){const n=se(e);return n===t||!V(n)||le(n)?!1:X(n).position==="fixed"||at(n,t)}function Yt(e,t){const n=t.get(e);if(n)return n;let r=ne(e,[],!1).filter(c=>V(c)&&re(c)!=="body"),o=null;const i=X(e).position==="fixed";let s=i?se(e):e;for(;V(s)&&!le(s);){const c=X(s),a=Le(s);!a&&c.position==="fixed"&&(o=null),(i?!a&&!o:!a&&c.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||ye(s)&&!a&&at(e,s))?r=r.filter(p=>p!==s):o=c,s=se(s)}return t.set(e,r),r}function Kt(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?Yt(t,this._c):[].concat(n),r],c=s[0],a=s.reduce((l,p)=>{const h=Ue(t,p,o);return l.top=Z(h.top,l.top),l.right=ge(h.right,l.right),l.bottom=ge(h.bottom,l.bottom),l.left=Z(h.left,l.left),l},Ue(t,c,o));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Ut(e){return st(e)}function zt(e,t,n){const r=z(t),o=Q(t),i=n==="fixed",s=ce(e,!0,i,t);let c={scrollLeft:0,scrollTop:0};const a=oe(0);if(r||!r&&!i)if((re(t)!=="body"||ye(o))&&(c=De(t)),r){const l=ce(t,!0,i,t);a.x=l.x+t.clientLeft,a.y=l.y+t.clientTop}else o&&(a.x=ut(o));return{x:s.left+c.scrollLeft-a.x,y:s.top+c.scrollTop-a.y,width:s.width,height:s.height}}function ze(e,t){return!z(e)||X(e).position==="fixed"?null:t?t(e):e.offsetParent}function lt(e,t){const n=U(e);if(!z(e))return n;let r=ze(e,t);for(;r&&bt(r)&&X(r).position==="static";)r=ze(r,t);return r&&(re(r)==="html"||re(r)==="body"&&X(r).position==="static"&&!Le(r))?n:r||Et(e)||n}const Xt=async function(e){let{reference:t,floating:n,strategy:r}=e;const o=this.getOffsetParent||lt,i=this.getDimensions;return{reference:zt(t,await o(n),r),floating:{x:0,y:0,...await i(n)}}};function qt(e){return X(e).direction==="rtl"}const Jt={convertOffsetParentRelativeRectToViewportRelativeRect:Ft,getDocumentElement:Q,getClippingRect:Kt,getOffsetParent:lt,getElementRects:Xt,getClientRects:Ht,getDimensions:Ut,getScale:ae,isElement:V,isRTL:qt};function Zt(e,t){let n=null,r;const o=Q(e);function i(){clearTimeout(r),n&&n.disconnect(),n=null}function s(c,a){c===void 0&&(c=!1),a===void 0&&(a=1),i();const{left:l,top:p,width:h,height:y}=e.getBoundingClientRect();if(c||t(),!h||!y)return;const m=ve(p),x=ve(o.clientWidth-(l+h)),R=ve(o.clientHeight-(p+y)),N=ve(l),_={rootMargin:-m+"px "+-x+"px "+-R+"px "+-N+"px",threshold:Z(0,ge(1,a))||1};let W=!0;function M($){const S=$[0].intersectionRatio;if(S!==a){if(!W)return s();S?s(!1,S):r=setTimeout(()=>{s(!1,1e-7)},100)}W=!1}try{n=new IntersectionObserver(M,{..._,root:o.ownerDocument})}catch{n=new IntersectionObserver(M,_)}n.observe(e)}return s(!0),i}function Gt(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,l=Fe(e),p=o||i?[...l?ne(l):[],...ne(t)]:[];p.forEach(k=>{o&&k.addEventListener("scroll",n,{passive:!0}),i&&k.addEventListener("resize",n)});const h=l&&c?Zt(l,n):null;let y=-1,m=null;s&&(m=new ResizeObserver(k=>{let[_]=k;_&&_.target===l&&m&&(m.unobserve(t),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{m&&m.observe(t)})),n()}),l&&!a&&m.observe(l),m.observe(t));let x,R=a?ce(e):null;a&&N();function N(){const k=ce(e);R&&(k.x!==R.x||k.y!==R.y||k.width!==R.width||k.height!==R.height)&&n(),R=k,x=requestAnimationFrame(N)}return n(),()=>{p.forEach(k=>{o&&k.removeEventListener("scroll",n),i&&k.removeEventListener("resize",n)}),h&&h(),m&&m.disconnect(),m=null,a&&cancelAnimationFrame(x)}}const Qt=(e,t,n)=>{const r=new Map,o={platform:Jt,...n},i={...o.platform,_c:r};return Pt(e,t,{...o,platform:i})};var xe=typeof document<"u"?v.useLayoutEffect:v.useEffect;function Re(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!Re(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!Re(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function ft(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Xe(e,t){const n=ft(e);return Math.round(t*n)/n}function qe(e){const t=E.useRef(e);return xe(()=>{t.current=e}),t}function en(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:c=!0,whileElementsMounted:a,open:l}=e,[p,h]=E.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[y,m]=E.useState(r);Re(y,r)||m(r);const[x,R]=E.useState(null),[N,k]=E.useState(null),_=E.useCallback(f=>{f!=S.current&&(S.current=f,R(f))},[R]),W=E.useCallback(f=>{f!==B.current&&(B.current=f,k(f))},[k]),M=i||x,$=s||N,S=E.useRef(null),B=E.useRef(null),O=E.useRef(p),A=qe(a),T=qe(o),C=E.useCallback(()=>{if(!S.current||!B.current)return;const f={placement:t,strategy:n,middleware:y};T.current&&(f.platform=T.current),Qt(S.current,B.current,f).then(g=>{const u={...g,isPositioned:!0};q.current&&!Re(O.current,u)&&(O.current=u,vt.flushSync(()=>{h(u)}))})},[y,t,n,T]);xe(()=>{l===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,h(f=>({...f,isPositioned:!1})))},[l]);const q=E.useRef(!1);xe(()=>(q.current=!0,()=>{q.current=!1}),[]),xe(()=>{if(M&&(S.current=M),$&&(B.current=$),M&&$){if(A.current)return A.current(M,$,C);C()}},[M,$,C,A]);const G=E.useMemo(()=>({reference:S,floating:B,setReference:_,setFloating:W}),[_,W]),w=E.useMemo(()=>({reference:M,floating:$}),[M,$]),d=E.useMemo(()=>{const f={position:n,left:0,top:0};if(!w.floating)return f;const g=Xe(w.floating,p.x),u=Xe(w.floating,p.y);return c?{...f,transform:"translate("+g+"px, "+u+"px)",...ft(w.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:g,top:u}},[n,c,w.floating,p.x,p.y]);return E.useMemo(()=>({...p,update:C,refs:G,elements:w,floatingStyles:d}),[p,C,G,w,d])}const tn=E["useInsertionEffect".toString()],nn=tn||(e=>e());function ue(e){const t=E.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return nn(()=>{t.current=e}),E.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}var dt=typeof document<"u"?v.useLayoutEffect:v.useEffect;let Se=!1,rn=0;const Je=()=>"floating-ui-"+rn++;function on(){const[e,t]=E.useState(()=>Se?Je():void 0);return dt(()=>{e==null&&t(Je())},[]),E.useEffect(()=>{Se||(Se=!0)},[]),e}const sn=E["useId".toString()],cn=sn||on;function un(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(o=>o(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,((r=e.get(t))==null?void 0:r.filter(o=>o!==n))||[])}}}const an=E.createContext(null),ln=E.createContext(null),fn=()=>{var e;return((e=E.useContext(an))==null?void 0:e.id)||null},ht=()=>E.useContext(ln);function dn(e){return"data-floating-ui-"+e}function Me(e,t){let n=e.filter(o=>{var i;return o.parentId===t&&((i=o.context)==null?void 0:i.open)}),r=n;for(;r.length;)r=e.filter(o=>{var i;return(i=r)==null?void 0:i.some(s=>{var c;return o.parentId===s.id&&((c=o.context)==null?void 0:c.open)})}),n=n.concat(r);return n}function Ze(e){return z(e.target)&&e.target.tagName==="BUTTON"}function Ge(e){return Ct(e)}function hn(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,dataRef:o,elements:{domReference:i}}=e,{enabled:s=!0,event:c="click",toggle:a=!0,ignoreMouse:l=!1,keyboardHandlers:p=!0}=t,h=E.useRef(),y=E.useRef(!1);return E.useMemo(()=>s?{reference:{onPointerDown(m){h.current=m.pointerType},onMouseDown(m){m.button===0&&(je(h.current,!0)&&l||c!=="click"&&(n&&a&&(!o.current.openEvent||o.current.openEvent.type==="mousedown")?r(!1,m.nativeEvent,"click"):(m.preventDefault(),r(!0,m.nativeEvent,"click"))))},onClick(m){if(c==="mousedown"&&h.current){h.current=void 0;return}je(h.current,!0)&&l||(n&&a&&(!o.current.openEvent||o.current.openEvent.type==="click")?r(!1,m.nativeEvent,"click"):r(!0,m.nativeEvent,"click"))},onKeyDown(m){h.current=void 0,!(m.defaultPrevented||!p||Ze(m))&&(m.key===" "&&!Ge(i)&&(m.preventDefault(),y.current=!0),m.key==="Enter"&&r(!(n&&a),m.nativeEvent,"click"))},onKeyUp(m){m.defaultPrevented||!p||Ze(m)||Ge(i)||m.key===" "&&y.current&&(y.current=!1,r(!(n&&a),m.nativeEvent,"click"))}}}:{},[s,o,c,l,p,i,a,n,r])}const mn={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},gn={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Qe=e=>{var t,n;return{escapeKey:typeof e=="boolean"?e:(t=e==null?void 0:e.escapeKey)!=null?t:!1,outsidePress:typeof e=="boolean"?e:(n=e==null?void 0:e.outsidePress)!=null?n:!0}};function pn(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,nodeId:o,elements:{reference:i,domReference:s,floating:c},dataRef:a}=e,{enabled:l=!0,escapeKey:p=!0,outsidePress:h=!0,outsidePressEvent:y="pointerdown",referencePress:m=!1,referencePressEvent:x="pointerdown",ancestorScroll:R=!1,bubbles:N,capture:k}=t,_=ht(),W=ue(typeof h=="function"?h:()=>!1),M=typeof h=="function"?W:h,$=E.useRef(!1),S=E.useRef(!1),{escapeKey:B,outsidePress:O}=Qe(N),{escapeKey:A,outsidePress:T}=Qe(k),C=ue(d=>{if(!n||!l||!p||d.key!=="Escape")return;const f=_?Me(_.nodesRef.current,o):[];if(!B&&(d.stopPropagation(),f.length>0)){let g=!0;if(f.forEach(u=>{var b;if((b=u.context)!=null&&b.open&&!u.context.dataRef.current.__escapeKeyBubbles){g=!1;return}}),!g)return}r(!1,Rt(d)?d.nativeEvent:d,"escape-key")}),q=ue(d=>{var f;const g=()=>{var u;C(d),(u=he(d))==null||u.removeEventListener("keydown",g)};(f=he(d))==null||f.addEventListener("keydown",g)}),G=ue(d=>{const f=$.current;$.current=!1;const g=S.current;if(S.current=!1,y==="click"&&g||f||typeof M=="function"&&!M(d))return;const u=he(d),b="["+dn("inert")+"]",D=Ye(c).querySelectorAll(b);let P=V(u)?u:null;for(;P&&!le(P);){const L=se(P);if(le(L)||!V(L))break;P=L}if(D.length&&V(u)&&!Dt(u)&&!Ve(u,c)&&Array.from(D).every(L=>!Ve(P,L)))return;if(z(u)&&c){const L=u.clientWidth>0&&u.scrollWidth>u.clientWidth,H=u.clientHeight>0&&u.scrollHeight>u.clientHeight;let J=H&&d.offsetX>u.clientWidth;if(H&&X(u).direction==="rtl"&&(J=d.offsetX<=u.offsetWidth-u.clientWidth),J||L&&d.offsetY>u.clientHeight)return}const I=_&&Me(_.nodesRef.current,o).some(L=>{var H;return Oe(d,(H=L.context)==null?void 0:H.elements.floating)});if(Oe(d,c)||Oe(d,s)||I)return;const F=_?Me(_.nodesRef.current,o):[];if(F.length>0){let L=!0;if(F.forEach(H=>{var J;if((J=H.context)!=null&&J.open&&!H.context.dataRef.current.__outsidePressBubbles){L=!1;return}}),!L)return}r(!1,d,"outside-press")}),w=ue(d=>{var f;const g=()=>{var u;G(d),(u=he(d))==null||u.removeEventListener(y,g)};(f=he(d))==null||f.addEventListener(y,g)});return E.useEffect(()=>{if(!n||!l)return;a.current.__escapeKeyBubbles=B,a.current.__outsidePressBubbles=O;function d(u){r(!1,u,"ancestor-scroll")}const f=Ye(c);p&&f.addEventListener("keydown",A?q:C,A),M&&f.addEventListener(y,T?w:G,T);let g=[];return R&&(V(s)&&(g=ne(s)),V(c)&&(g=g.concat(ne(c))),!V(i)&&i&&i.contextElement&&(g=g.concat(ne(i.contextElement)))),g=g.filter(u=>{var b;return u!==((b=f.defaultView)==null?void 0:b.visualViewport)}),g.forEach(u=>{u.addEventListener("scroll",d,{passive:!0})}),()=>{p&&f.removeEventListener("keydown",A?q:C,A),M&&f.removeEventListener(y,T?w:G,T),g.forEach(u=>{u.removeEventListener("scroll",d)})}},[a,c,s,i,p,M,y,n,r,R,l,B,O,C,A,q,G,T,w]),E.useEffect(()=>{$.current=!1},[M,y]),E.useMemo(()=>l?{reference:{onKeyDown:C,[mn[x]]:d=>{m&&r(!1,d.nativeEvent,"reference-press")}},floating:{onKeyDown:C,onMouseDown(){S.current=!0},onMouseUp(){S.current=!0},[gn[y]]:()=>{$.current=!0}}}:{},[l,m,y,x,r,C])}let Ne;process.env.NODE_ENV!=="production"&&(Ne=new Set);function yn(e){var t;e===void 0&&(e={});const{open:n=!1,onOpenChange:r,nodeId:o}=e;if(process.env.NODE_ENV!=="production"){var i;const O="Floating UI: Cannot pass a virtual element to the `elements.reference` option, as it must be a real DOM element. Use `refs.setPositionReference` instead.";if((i=e.elements)!=null&&i.reference&&!V(e.elements.reference)){var s;if(!((s=Ne)!=null&&s.has(O))){var c;(c=Ne)==null||c.add(O),console.error(O)}}}const[a,l]=E.useState(null),p=((t=e.elements)==null?void 0:t.reference)||a,h=en(e),y=ht(),m=fn()!=null,x=ue((O,A,T)=>{O&&(N.current.openEvent=A),k.emit("openchange",{open:O,event:A,reason:T,nested:m}),r==null||r(O,A,T)}),R=E.useRef(null),N=E.useRef({}),k=E.useState(()=>un())[0],_=cn(),W=E.useCallback(O=>{const A=V(O)?{getBoundingClientRect:()=>O.getBoundingClientRect(),contextElement:O}:O;h.refs.setReference(A)},[h.refs]),M=E.useCallback(O=>{(V(O)||O===null)&&(R.current=O,l(O)),(V(h.refs.reference.current)||h.refs.reference.current===null||O!==null&&!V(O))&&h.refs.setReference(O)},[h.refs]),$=E.useMemo(()=>({...h.refs,setReference:M,setPositionReference:W,domReference:R}),[h.refs,M,W]),S=E.useMemo(()=>({...h.elements,domReference:p}),[h.elements,p]),B=E.useMemo(()=>({...h,refs:$,elements:S,dataRef:N,nodeId:o,floatingId:_,events:k,open:n,onOpenChange:x}),[h,o,_,k,n,x,$,S]);return dt(()=>{const O=y==null?void 0:y.nodesRef.current.find(A=>A.id===o);O&&(O.context=B)}),E.useMemo(()=>({...h,context:B,refs:$,elements:S}),[h,$,S,B])}const et="active",tt="selected";function _e(e,t,n){const r=new Map,o=n==="item";let i=e;if(o&&e){const{[et]:s,[tt]:c,...a}=e;i=a}return{...n==="floating"&&{tabIndex:-1},...i,...t.map(s=>{const c=s?s[n]:null;return typeof c=="function"?e?c(e):null:c}).concat(e).reduce((s,c)=>(c&&Object.entries(c).forEach(a=>{let[l,p]=a;if(!(o&&[et,tt].includes(l)))if(l.indexOf("on")===0){if(r.has(l)||r.set(l,[]),typeof p=="function"){var h;(h=r.get(l))==null||h.push(p),s[l]=function(){for(var y,m=arguments.length,x=new Array(m),R=0;R<m;R++)x[R]=arguments[R];return(y=r.get(l))==null?void 0:y.map(N=>N(...x)).find(N=>N!==void 0)}}}else s[l]=p}),s),{})}}function wn(e){e===void 0&&(e=[]);const t=e,n=E.useCallback(i=>_e(i,e,"reference"),t),r=E.useCallback(i=>_e(i,e,"floating"),t),o=E.useCallback(i=>_e(i,e,"item"),e.map(i=>i==null?void 0:i.item));return E.useMemo(()=>({getReferenceProps:n,getFloatingProps:r,getItemProps:o}),[n,r,o])}const ke=v.createContext(null),vn=({children:e})=>{const[t,n]=v.useState(!1),{refs:r,floatingStyles:o,context:i}=yn({open:t,onOpenChange:n,whileElementsMounted:Gt,middleware:[Lt(8),Wt({apply({rects:y,elements:m}){Object.assign(m.floating.style,{minWidth:`${y.reference.width}px`})}})]}),s=hn(i),c=pn(i),{getReferenceProps:a,getFloatingProps:l}=wn([s,c]),h={isPanelOpen:t,refs:r,floatingStyles:o,getReferenceProps:a,getFloatingProps:l,close:()=>{n(!1)}};return v.createElement(ke.Provider,{value:h},e)},xn=({children:e,disabled:t,className:n})=>{const r=v.useContext(ke);return v.createElement(me,{ref:r==null?void 0:r.refs.setReference,className:K(`w-72 border border-secondary-700 rounded-md shadow-xs flex items-center gap-x-2 px-4 py-2 ${t?"bg-secondary-600 text-neutral-800":"text-gray-700 hover:bg-info-50"}`,n),...r==null?void 0:r.getReferenceProps()},e,v.createElement(Pe,{className:"w-4 h-4 ml-auto"}))},bn=({classes:e,children:t})=>v.createElement("div",{className:K("shadow-sm border bg-white border-neutral-200 flex flex-col p-6 rounded-lg",e==null?void 0:e.root)},t),En=({children:e,classes:t})=>{const n=v.useContext(ke);return(!n||(n==null?void 0:n.isPanelOpen))&&v.createElement("div",{ref:n==null?void 0:n.refs.setFloating,style:n==null?void 0:n.floatingStyles,...n==null?void 0:n.getFloatingProps()},v.createElement(bn,{classes:t},e))},pe=({children:e})=>v.createElement(vn,null,e);pe.Button=xn;pe.Panel=En;const Rn=({children:e,className:t})=>v.createElement("div",{className:K("grid grid-cols-[36px_36px_36px_36px_36px_36px_36px] grid-rows-[36px_36px_36px_36px_36px_36px_36px] gap-1",t)},e);var He=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Be(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var mt={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(He,function(){var n=1e3,r=6e4,o=36e5,i="millisecond",s="second",c="minute",a="hour",l="day",p="week",h="month",y="quarter",m="year",x="date",R="Invalid Date",N=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,k=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,_={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(w){var d=["th","st","nd","rd"],f=w%100;return"["+w+(d[(f-20)%10]||d[f]||d[0])+"]"}},W=function(w,d,f){var g=String(w);return!g||g.length>=d?w:""+Array(d+1-g.length).join(f)+w},M={s:W,z:function(w){var d=-w.utcOffset(),f=Math.abs(d),g=Math.floor(f/60),u=f%60;return(d<=0?"+":"-")+W(g,2,"0")+":"+W(u,2,"0")},m:function w(d,f){if(d.date()<f.date())return-w(f,d);var g=12*(f.year()-d.year())+(f.month()-d.month()),u=d.clone().add(g,h),b=f-u<0,D=d.clone().add(g+(b?-1:1),h);return+(-(g+(f-u)/(b?u-D:D-u))||0)},a:function(w){return w<0?Math.ceil(w)||0:Math.floor(w)},p:function(w){return{M:h,y:m,w:p,d:l,D:x,h:a,m:c,s,ms:i,Q:y}[w]||String(w||"").toLowerCase().replace(/s$/,"")},u:function(w){return w===void 0}},$="en",S={};S[$]=_;var B="$isDayjsObject",O=function(w){return w instanceof q||!(!w||!w[B])},A=function w(d,f,g){var u;if(!d)return $;if(typeof d=="string"){var b=d.toLowerCase();S[b]&&(u=b),f&&(S[b]=f,u=b);var D=d.split("-");if(!u&&D.length>1)return w(D[0])}else{var P=d.name;S[P]=d,u=P}return!g&&u&&($=u),u||!g&&$},T=function(w,d){if(O(w))return w.clone();var f=typeof d=="object"?d:{};return f.date=w,f.args=arguments,new q(f)},C=M;C.l=A,C.i=O,C.w=function(w,d){return T(w,{locale:d.$L,utc:d.$u,x:d.$x,$offset:d.$offset})};var q=function(){function w(f){this.$L=A(f.locale,null,!0),this.parse(f),this.$x=this.$x||f.x||{},this[B]=!0}var d=w.prototype;return d.parse=function(f){this.$d=function(g){var u=g.date,b=g.utc;if(u===null)return new Date(NaN);if(C.u(u))return new Date;if(u instanceof Date)return new Date(u);if(typeof u=="string"&&!/Z$/i.test(u)){var D=u.match(N);if(D){var P=D[2]-1||0,I=(D[7]||"0").substring(0,3);return b?new Date(Date.UTC(D[1],P,D[3]||1,D[4]||0,D[5]||0,D[6]||0,I)):new Date(D[1],P,D[3]||1,D[4]||0,D[5]||0,D[6]||0,I)}}return new Date(u)}(f),this.init()},d.init=function(){var f=this.$d;this.$y=f.getFullYear(),this.$M=f.getMonth(),this.$D=f.getDate(),this.$W=f.getDay(),this.$H=f.getHours(),this.$m=f.getMinutes(),this.$s=f.getSeconds(),this.$ms=f.getMilliseconds()},d.$utils=function(){return C},d.isValid=function(){return this.$d.toString()!==R},d.isSame=function(f,g){var u=T(f);return this.startOf(g)<=u&&u<=this.endOf(g)},d.isAfter=function(f,g){return T(f)<this.startOf(g)},d.isBefore=function(f,g){return this.endOf(g)<T(f)},d.$g=function(f,g,u){return C.u(f)?this[g]:this.set(u,f)},d.unix=function(){return Math.floor(this.valueOf()/1e3)},d.valueOf=function(){return this.$d.getTime()},d.startOf=function(f,g){var u=this,b=!!C.u(g)||g,D=C.p(f),P=function(ie,Y){var te=C.w(u.$u?Date.UTC(u.$y,Y,ie):new Date(u.$y,Y,ie),u);return b?te:te.endOf(l)},I=function(ie,Y){return C.w(u.toDate()[ie].apply(u.toDate("s"),(b?[0,0,0,0]:[23,59,59,999]).slice(Y)),u)},F=this.$W,L=this.$M,H=this.$D,J="set"+(this.$u?"UTC":"");switch(D){case m:return b?P(1,0):P(31,11);case h:return b?P(1,L):P(0,L+1);case p:var ee=this.$locale().weekStart||0,fe=(F<ee?F+7:F)-ee;return P(b?H-fe:H+(6-fe),L);case l:case x:return I(J+"Hours",0);case a:return I(J+"Minutes",1);case c:return I(J+"Seconds",2);case s:return I(J+"Milliseconds",3);default:return this.clone()}},d.endOf=function(f){return this.startOf(f,!1)},d.$set=function(f,g){var u,b=C.p(f),D="set"+(this.$u?"UTC":""),P=(u={},u[l]=D+"Date",u[x]=D+"Date",u[h]=D+"Month",u[m]=D+"FullYear",u[a]=D+"Hours",u[c]=D+"Minutes",u[s]=D+"Seconds",u[i]=D+"Milliseconds",u)[b],I=b===l?this.$D+(g-this.$W):g;if(b===h||b===m){var F=this.clone().set(x,1);F.$d[P](I),F.init(),this.$d=F.set(x,Math.min(this.$D,F.daysInMonth())).$d}else P&&this.$d[P](I);return this.init(),this},d.set=function(f,g){return this.clone().$set(f,g)},d.get=function(f){return this[C.p(f)]()},d.add=function(f,g){var u,b=this;f=Number(f);var D=C.p(g),P=function(L){var H=T(b);return C.w(H.date(H.date()+Math.round(L*f)),b)};if(D===h)return this.set(h,this.$M+f);if(D===m)return this.set(m,this.$y+f);if(D===l)return P(1);if(D===p)return P(7);var I=(u={},u[c]=r,u[a]=o,u[s]=n,u)[D]||1,F=this.$d.getTime()+f*I;return C.w(F,this)},d.subtract=function(f,g){return this.add(-1*f,g)},d.format=function(f){var g=this,u=this.$locale();if(!this.isValid())return u.invalidDate||R;var b=f||"YYYY-MM-DDTHH:mm:ssZ",D=C.z(this),P=this.$H,I=this.$m,F=this.$M,L=u.weekdays,H=u.months,J=u.meridiem,ee=function(Y,te,de,we){return Y&&(Y[te]||Y(g,b))||de[te].slice(0,we)},fe=function(Y){return C.s(P%12||12,Y,"0")},ie=J||function(Y,te,de){var we=Y<12?"AM":"PM";return de?we.toLowerCase():we};return b.replace(k,function(Y,te){return te||function(de){switch(de){case"YY":return String(g.$y).slice(-2);case"YYYY":return C.s(g.$y,4,"0");case"M":return F+1;case"MM":return C.s(F+1,2,"0");case"MMM":return ee(u.monthsShort,F,H,3);case"MMMM":return ee(H,F);case"D":return g.$D;case"DD":return C.s(g.$D,2,"0");case"d":return String(g.$W);case"dd":return ee(u.weekdaysMin,g.$W,L,2);case"ddd":return ee(u.weekdaysShort,g.$W,L,3);case"dddd":return L[g.$W];case"H":return String(P);case"HH":return C.s(P,2,"0");case"h":return fe(1);case"hh":return fe(2);case"a":return ie(P,I,!0);case"A":return ie(P,I,!1);case"m":return String(I);case"mm":return C.s(I,2,"0");case"s":return String(g.$s);case"ss":return C.s(g.$s,2,"0");case"SSS":return C.s(g.$ms,3,"0");case"Z":return D}return null}(Y)||D.replace(":","")})},d.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},d.diff=function(f,g,u){var b,D=this,P=C.p(g),I=T(f),F=(I.utcOffset()-this.utcOffset())*r,L=this-I,H=function(){return C.m(D,I)};switch(P){case m:b=H()/12;break;case h:b=H();break;case y:b=H()/3;break;case p:b=(L-F)/6048e5;break;case l:b=(L-F)/864e5;break;case a:b=L/o;break;case c:b=L/r;break;case s:b=L/n;break;default:b=L}return u?b:C.a(b)},d.daysInMonth=function(){return this.endOf(h).$D},d.$locale=function(){return S[this.$L]},d.locale=function(f,g){if(!f)return this.$L;var u=this.clone(),b=A(f,g,!0);return b&&(u.$L=b),u},d.clone=function(){return C.w(this.$d,this)},d.toDate=function(){return new Date(this.valueOf())},d.toJSON=function(){return this.isValid()?this.toISOString():null},d.toISOString=function(){return this.$d.toISOString()},d.toString=function(){return this.$d.toUTCString()},w}(),G=q.prototype;return T.prototype=G,[["$ms",i],["$s",s],["$m",c],["$H",a],["$W",l],["$M",h],["$y",m],["$D",x]].forEach(function(w){G[w[1]]=function(d){return this.$g(d,w[0],w[1])}}),T.extend=function(w,d){return w.$i||(w(d,q,T),w.$i=!0),T},T.locale=A,T.isDayjs=O,T.unix=function(w){return T(1e3*w)},T.en=S[$],T.Ls=S,T.p={},T})})(mt);var Dn=mt.exports;const j=Be(Dn);var gt={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(He,function(){var n="day";return function(r,o,i){var s=function(l){return l.add(4-l.isoWeekday(),n)},c=o.prototype;c.isoWeekYear=function(){return s(this).year()},c.isoWeek=function(l){if(!this.$utils().u(l))return this.add(7*(l-this.isoWeek()),n);var p,h,y,m,x=s(this),R=(p=this.isoWeekYear(),h=this.$u,y=(h?i.utc:i)().year(p).startOf("year"),m=4-y.isoWeekday(),y.isoWeekday()>4&&(m+=7),y.add(m,n));return x.diff(R,"week")+1},c.isoWeekday=function(l){return this.$utils().u(l)?this.day()||7:this.day(this.day()%7?l:l-7)};var a=c.startOf;c.startOf=function(l,p){var h=this.$utils(),y=!!h.u(p)||p;return h.p(l)==="isoweek"?y?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):a.bind(this)(l,p)}}})})(gt);var $n=gt.exports;const Cn=Be($n);var pt={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(He,function(){return function(n,r){r.prototype.weekday=function(o){var i=this.$locale().weekStart||0,s=this.$W,c=(s<i?s+7:s)-i;return this.$utils().u(o)?c:this.subtract(c,"day").add(o,"day")}}})})(pt);var kn=pt.exports;const On=Be(kn);j.extend(Cn);j.extend(On);const Sn=({day:e,isoWeek:t})=>t?j().isoWeekday(e+1):j().weekday(e),Mn=({weekDaysMap:e,isoWeek:t})=>Array.from(Array(7).keys()).map(n=>{const r=Sn({day:n,isoWeek:t});return(e==null?void 0:e[r.format("dddd")])||r.format("ddd")}),_n=({month:e,monthsMap:t})=>{const n=j().month(e).format("MMMM");return(t==null?void 0:t[n])||n},Pn=(e=j(),t=!1)=>{const n=[],r=e.clone().set("date",1),o=r.clone().startOf(t?"isoWeek":"week"),i=r.clone().endOf("month"),s=o.clone();let c=0;for(;s.add(c,"day").clone().isBefore(i,"day")||n.length<6*7;)n.push(s.add(c,"day").clone()),c++;return n},Tn=e=>j(e).subtract(1,"month"),Nn=e=>j(e).add(1,"month"),nt=(e,t=j())=>j(t).isSame(e,"month"),Ln=(e,t=j())=>j(t).isSame(e,"day"),yt=({children:e,classes:t,isActive:n,isToday:r,isInRange:o,disabled:i,onClick:s})=>{var c,a,l,p,h;return v.createElement(me,{type:"button",disabled:i,className:K("w-9 h-9 border-none p-0",t==null?void 0:t.root,n?K("bg-blue-600 text-white disabled:bg-neutral-200 disabled:text-gray-400",(c=t==null?void 0:t.active)==null?void 0:c.root):"hover:text-blue-600",r?K("relative",(a=t==null?void 0:t.active)==null?void 0:a.root):null,o?K("bg-blue-100",(l=t==null?void 0:t.inRange)==null?void 0:l.root):null),withHoverEffect:!n,onClick:s},e,v.createElement("div",{className:K("absolute bottom-1 left-1/2 -translate-x-1/2 w-1/2 h-0.5 rounded bg-blue-600",t==null?void 0:t.underline,n?K("bg-white",(p=t==null?void 0:t.active)==null?void 0:p.underline):"bg-blue-600",r?null:K("hidden",(h=t==null?void 0:t.today)==null?void 0:h.underline))}))},Wn=({customNames:e,isoWeek:t,classes:n})=>Mn({weekDaysMap:e,isoWeek:t}).map(o=>v.createElement(yt,{key:o,disabled:!0,classes:n},o)),An=({day:e,selectedDate:t,calendarMonth:n,onClick:r,classes:o})=>{const i=nt(e,t),s=Ln(e,t),c=nt(e,n),a=()=>{r(e)};return v.createElement(yt,{disabled:!c,isActive:i&&s,onClick:a,classes:o},e.format("D"))},In=({month:e,year:t,customNames:n,classes:r})=>{const o=_n({month:e,monthsMap:n});return v.createElement("div",{className:K("bg-neutral-200 rounded-lg py-2.5 px-2.5 flex-grow text-center text-sm font-semibold flex items-center justify-center",r==null?void 0:r.root)},o," ",t)},Fn=({month:e,setMonth:t,classes:n})=>{const r=()=>{t(i=>Tn(i))},o=()=>{t(i=>Nn(i))};return v.createElement(v.Fragment,null,v.createElement(me,{className:"my-1",onClick:r},v.createElement(Pe,{className:"w-4 h-4 rotate-90"})),v.createElement(In,{month:e.month(),year:e.year(),classes:n==null?void 0:n.month}),v.createElement(me,{className:"my-1",onClick:o},v.createElement(Pe,{className:"w-4 h-4 -rotate-90"})))},Hn=({date:e=j(),onSelectDate:t,classes:n,isoWeek:r})=>{const[o,i]=v.useState(e),s=Pn(o,r);return v.createElement("div",{className:K("grid grid-cols-[auto_1fr_auto] gap-x-3",n==null?void 0:n.root)},v.createElement(Fn,{month:o,setMonth:i,classes:n}),v.createElement(Rn,{className:"col-start-2 mt-4"},v.createElement(Wn,{isoWeek:r,classes:n==null?void 0:n.weekDay}),s.map(c=>v.createElement(An,{key:c.toISOString(),day:c,selectedDate:e,calendarMonth:o,onClick:t,classes:n==null?void 0:n.day}))))},Bn=({value:e,onChange:t,defaultValue:n,classes:r,isoWeek:o})=>{var m;const i=v.useContext(ke),s=typeof e<"u",c=typeof n<"u",[a,l]=v.useState(c?n:""),p=s?e:a,h=j(p).isValid(),y=x=>{const R=x.toISOString();t&&t(R),s||l(R),i==null||i.close()};return v.createElement(v.Fragment,null,v.createElement(pe.Button,{className:(m=r==null?void 0:r.input)==null?void 0:m.root},v.createElement(xt,{className:"w-5 h-5"}),v.createElement("span",null,h?j(p).format("D MMM YYYY"):"No date selected")),v.createElement(pe.Panel,null,v.createElement(Hn,{date:h?j(p):void 0,onSelectDate:y,classes:r==null?void 0:r.calendar,isoWeek:o})))},Vn=e=>v.createElement(pe,null,v.createElement(Bn,{...e}));exports.DatePicker=Vn;