UNPKG

react-appointment-scheduler

Version:

A production-ready React scheduler component for appointment management with day/week views, drag-and-drop, and TypeScript support

5 lines 103 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),a=require("react"),Ke=require("react-dom"),pt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function He(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Vt(t){return"nodeType"in t}function ie(t){var e,s;return t?He(t)?t:Vt(t)&&(e=(s=t.ownerDocument)==null?void 0:s.defaultView)!=null?e:window:window}function Jt(t){const{Document:e}=ie(t);return t instanceof e}function st(t){return He(t)?!1:t instanceof ie(t).HTMLElement}function bn(t){return t instanceof ie(t).SVGElement}function Pe(t){return t?He(t)?t.document:Vt(t)?Jt(t)?t:st(t)||bn(t)?t.ownerDocument:document:document:document}const ke=pt?a.useLayoutEffect:a.useEffect;function bt(t){const e=a.useRef(t);return ke(()=>{e.current=t}),a.useCallback(function(){for(var s=arguments.length,r=new Array(s),i=0;i<s;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function ls(){const t=a.useRef(null),e=a.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),s=a.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,s]}function Ze(t,e){e===void 0&&(e=[t]);const s=a.useRef(t);return ke(()=>{s.current!==t&&(s.current=t)},e),s}function rt(t,e){const s=a.useRef();return a.useMemo(()=>{const r=t(s.current);return s.current=r,r},[...e])}function ut(t){const e=bt(t),s=a.useRef(null),r=a.useCallback(i=>{i!==s.current&&e?.(i,s.current),s.current=i},[]);return[s,r]}function ht(t){const e=a.useRef();return a.useEffect(()=>{e.current=t},[t]),e.current}let Lt={};function xt(t,e){return a.useMemo(()=>{if(e)return e;const s=Lt[t]==null?0:Lt[t]+1;return Lt[t]=s,t+"-"+s},[t,e])}function xn(t){return function(e){for(var s=arguments.length,r=new Array(s>1?s-1:0),i=1;i<s;i++)r[i-1]=arguments[i];return r.reduce((o,l)=>{const c=Object.entries(l);for(const[d,u]of c){const h=o[d];h!=null&&(o[d]=h+t*u)}return o},{...e})}}const Fe=xn(1),ft=xn(-1);function cs(t){return"clientX"in t&&"clientY"in t}function Yt(t){if(!t)return!1;const{KeyboardEvent:e}=ie(t.target);return e&&t instanceof e}function ds(t){if(!t)return!1;const{TouchEvent:e}=ie(t.target);return e&&t instanceof e}function mt(t){if(ds(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:s}=t.touches[0];return{x:e,y:s}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:s}=t.changedTouches[0];return{x:e,y:s}}}return cs(t)?{x:t.clientX,y:t.clientY}:null}const et=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:s}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:s}=t;return"scaleX("+e+") scaleY("+s+")"}},Transform:{toString(t){if(t)return[et.Translate.toString(t),et.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:s,easing:r}=t;return e+" "+s+"ms "+r}}}),an="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function us(t){return t.matches(an)?t:t.querySelector(an)}const hs={display:"none"};function fs(t){let{id:e,value:s}=t;return a.createElement("div",{id:e,style:hs},s)}function ms(t){let{id:e,announcement:s,ariaLiveType:r="assertive"}=t;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return a.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},s)}function gs(){const[t,e]=a.useState("");return{announce:a.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const yn=a.createContext(null);function vs(t){const e=a.useContext(yn);a.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function ps(){const[t]=a.useState(()=>new Set),e=a.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[a.useCallback(r=>{let{type:i,event:o}=r;t.forEach(l=>{var c;return(c=l[i])==null?void 0:c.call(l,o)})},[t]),e]}const bs={draggable:` To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel. `},xs={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:s}=t;return s?"Draggable item "+e.id+" was moved over droppable area "+s.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:s}=t;return s?"Draggable item "+e.id+" was dropped over droppable area "+s.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function ys(t){let{announcements:e=xs,container:s,hiddenTextDescribedById:r,screenReaderInstructions:i=bs}=t;const{announce:o,announcement:l}=gs(),c=xt("DndLiveRegion"),[d,u]=a.useState(!1);if(a.useEffect(()=>{u(!0)},[]),vs(a.useMemo(()=>({onDragStart(f){let{active:m}=f;o(e.onDragStart({active:m}))},onDragMove(f){let{active:m,over:x}=f;e.onDragMove&&o(e.onDragMove({active:m,over:x}))},onDragOver(f){let{active:m,over:x}=f;o(e.onDragOver({active:m,over:x}))},onDragEnd(f){let{active:m,over:x}=f;o(e.onDragEnd({active:m,over:x}))},onDragCancel(f){let{active:m,over:x}=f;o(e.onDragCancel({active:m,over:x}))}}),[o,e])),!d)return null;const h=a.createElement(a.Fragment,null,a.createElement(fs,{id:r,value:i.draggable}),a.createElement(ms,{id:c,announcement:l}));return s?Ke.createPortal(h,s):h}var Q;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Q||(Q={}));function gt(){}function It(t,e){return a.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function js(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return a.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const ge=Object.freeze({x:0,y:0});function Ns(t,e){const s=mt(t);if(!s)return"0 0";const r={x:(s.x-e.left)/e.width*100,y:(s.y-e.top)/e.height*100};return r.x+"% "+r.y+"%"}function ws(t,e){let{data:{value:s}}=t,{data:{value:r}}=e;return r-s}function Cs(t,e){if(!t||t.length===0)return null;const[s]=t;return s[e]}function Ds(t,e){const s=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),o=Math.min(e.top+e.height,t.top+t.height),l=i-r,c=o-s;if(r<i&&s<o){const d=e.width*e.height,u=t.width*t.height,h=l*c,f=h/(d+u-h);return Number(f.toFixed(4))}return 0}const ks=t=>{let{collisionRect:e,droppableRects:s,droppableContainers:r}=t;const i=[];for(const o of r){const{id:l}=o,c=s.get(l);if(c){const d=Ds(c,e);d>0&&i.push({id:l,data:{droppableContainer:o,value:d}})}}return i.sort(ws)};function Ss(t,e,s){return{...t,scaleX:e&&s?e.width/s.width:1,scaleY:e&&s?e.height/s.height:1}}function jn(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:ge}function Ts(t){return function(s){for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];return i.reduce((l,c)=>({...l,top:l.top+t*c.y,bottom:l.bottom+t*c.y,left:l.left+t*c.x,right:l.right+t*c.x}),{...s})}}const Ms=Ts(1);function Nn(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function Es(t,e,s){const r=Nn(e);if(!r)return t;const{scaleX:i,scaleY:o,x:l,y:c}=r,d=t.left-l-(1-i)*parseFloat(s),u=t.top-c-(1-o)*parseFloat(s.slice(s.indexOf(" ")+1)),h=i?t.width/i:t.width,f=o?t.height/o:t.height;return{width:h,height:f,top:u,right:d+h,bottom:u+f,left:d}}const Rs={ignoreTransform:!1};function at(t,e){e===void 0&&(e=Rs);let s=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:h}=ie(t).getComputedStyle(t);u&&(s=Es(s,u,h))}const{top:r,left:i,width:o,height:l,bottom:c,right:d}=s;return{top:r,left:i,width:o,height:l,bottom:c,right:d}}function on(t){return at(t,{ignoreTransform:!0})}function As(t){const e=t.innerWidth,s=t.innerHeight;return{top:0,left:0,right:e,bottom:s,width:e,height:s}}function Ls(t,e){return e===void 0&&(e=ie(t).getComputedStyle(t)),e.position==="fixed"}function Is(t,e){e===void 0&&(e=ie(t).getComputedStyle(t));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const o=e[i];return typeof o=="string"?s.test(o):!1})}function qt(t,e){const s=[];function r(i){if(e!=null&&s.length>=e||!i)return s;if(Jt(i)&&i.scrollingElement!=null&&!s.includes(i.scrollingElement))return s.push(i.scrollingElement),s;if(!st(i)||bn(i)||s.includes(i))return s;const o=ie(t).getComputedStyle(i);return i!==t&&Is(i,o)&&s.push(i),Ls(i,o)?s:r(i.parentNode)}return t?r(t):s}function wn(t){const[e]=qt(t,1);return e??null}function $t(t){return!pt||!t?null:He(t)?t:Vt(t)?Jt(t)||t===Pe(t).scrollingElement?window:st(t)?t:null:null}function Cn(t){return He(t)?t.scrollX:t.scrollLeft}function Dn(t){return He(t)?t.scrollY:t.scrollTop}function Ft(t){return{x:Cn(t),y:Dn(t)}}var ee;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(ee||(ee={}));function kn(t){return!pt||!t?!1:t===document.scrollingElement}function Sn(t){const e={x:0,y:0},s=kn(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-s.width,y:t.scrollHeight-s.height},i=t.scrollTop<=e.y,o=t.scrollLeft<=e.x,l=t.scrollTop>=r.y,c=t.scrollLeft>=r.x;return{isTop:i,isLeft:o,isBottom:l,isRight:c,maxScroll:r,minScroll:e}}const $s={x:.2,y:.2};function Os(t,e,s,r,i){let{top:o,left:l,right:c,bottom:d}=s;r===void 0&&(r=10),i===void 0&&(i=$s);const{isTop:u,isBottom:h,isLeft:f,isRight:m}=Sn(t),x={x:0,y:0},v={x:0,y:0},b={height:e.height*i.y,width:e.width*i.x};return!u&&o<=e.top+b.height?(x.y=ee.Backward,v.y=r*Math.abs((e.top+b.height-o)/b.height)):!h&&d>=e.bottom-b.height&&(x.y=ee.Forward,v.y=r*Math.abs((e.bottom-b.height-d)/b.height)),!m&&c>=e.right-b.width?(x.x=ee.Forward,v.x=r*Math.abs((e.right-b.width-c)/b.width)):!f&&l<=e.left+b.width&&(x.x=ee.Backward,v.x=r*Math.abs((e.left+b.width-l)/b.width)),{direction:x,speed:v}}function Bs(t){if(t===document.scrollingElement){const{innerWidth:o,innerHeight:l}=window;return{top:0,left:0,right:o,bottom:l,width:o,height:l}}const{top:e,left:s,right:r,bottom:i}=t.getBoundingClientRect();return{top:e,left:s,right:r,bottom:i,width:t.clientWidth,height:t.clientHeight}}function Tn(t){return t.reduce((e,s)=>Fe(e,Ft(s)),ge)}function Fs(t){return t.reduce((e,s)=>e+Cn(s),0)}function zs(t){return t.reduce((e,s)=>e+Dn(s),0)}function Mn(t,e){if(e===void 0&&(e=at),!t)return;const{top:s,left:r,bottom:i,right:o}=e(t);wn(t)&&(i<=0||o<=0||s>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const Hs=[["x",["left","right"],Fs],["y",["top","bottom"],zs]];class Ut{constructor(e,s){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=qt(s),i=Tn(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[o,l,c]of Hs)for(const d of l)Object.defineProperty(this,d,{get:()=>{const u=c(r),h=i[o]-u;return this.rect[d]+h},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Xe{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(s=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...s)})},this.target=e}add(e,s,r){var i;(i=this.target)==null||i.addEventListener(e,s,r),this.listeners.push([e,s,r])}}function Ps(t){const{EventTarget:e}=ie(t);return t instanceof e?t:Pe(t)}function Ot(t,e){const s=Math.abs(t.x),r=Math.abs(t.y);return typeof e=="number"?Math.sqrt(s**2+r**2)>e:"x"in e&&"y"in e?s>e.x&&r>e.y:"x"in e?s>e.x:"y"in e?r>e.y:!1}var fe;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(fe||(fe={}));function ln(t){t.preventDefault()}function Ws(t){t.stopPropagation()}var U;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(U||(U={}));const En={start:[U.Space,U.Enter],cancel:[U.Esc],end:[U.Space,U.Enter,U.Tab]},Vs=(t,e)=>{let{currentCoordinates:s}=e;switch(t.code){case U.Right:return{...s,x:s.x+25};case U.Left:return{...s,x:s.x-25};case U.Down:return{...s,y:s.y+25};case U.Up:return{...s,y:s.y-25}}};class Kt{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:s}}=e;this.props=e,this.listeners=new Xe(Pe(s)),this.windowListeners=new Xe(ie(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(fe.Resize,this.handleCancel),this.windowListeners.add(fe.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(fe.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:s}=this.props,r=e.node.current;r&&Mn(r),s(ge)}handleKeyDown(e){if(Yt(e)){const{active:s,context:r,options:i}=this.props,{keyboardCodes:o=En,coordinateGetter:l=Vs,scrollBehavior:c="smooth"}=i,{code:d}=e;if(o.end.includes(d)){this.handleEnd(e);return}if(o.cancel.includes(d)){this.handleCancel(e);return}const{collisionRect:u}=r.current,h=u?{x:u.left,y:u.top}:ge;this.referenceCoordinates||(this.referenceCoordinates=h);const f=l(e,{active:s,context:r.current,currentCoordinates:h});if(f){const m=ft(f,h),x={x:0,y:0},{scrollableAncestors:v}=r.current;for(const b of v){const y=e.code,{isTop:D,isRight:k,isLeft:N,isBottom:I,maxScroll:R,minScroll:L}=Sn(b),j=Bs(b),E={x:Math.min(y===U.Right?j.right-j.width/2:j.right,Math.max(y===U.Right?j.left:j.left+j.width/2,f.x)),y:Math.min(y===U.Down?j.bottom-j.height/2:j.bottom,Math.max(y===U.Down?j.top:j.top+j.height/2,f.y))},$=y===U.Right&&!k||y===U.Left&&!N,O=y===U.Down&&!I||y===U.Up&&!D;if($&&E.x!==f.x){const H=b.scrollLeft+m.x,P=y===U.Right&&H<=R.x||y===U.Left&&H>=L.x;if(P&&!m.y){b.scrollTo({left:H,behavior:c});return}P?x.x=b.scrollLeft-H:x.x=y===U.Right?b.scrollLeft-R.x:b.scrollLeft-L.x,x.x&&b.scrollBy({left:-x.x,behavior:c});break}else if(O&&E.y!==f.y){const H=b.scrollTop+m.y,P=y===U.Down&&H<=R.y||y===U.Up&&H>=L.y;if(P&&!m.x){b.scrollTo({top:H,behavior:c});return}P?x.y=b.scrollTop-H:x.y=y===U.Down?b.scrollTop-R.y:b.scrollTop-L.y,x.y&&b.scrollBy({top:-x.y,behavior:c});break}}this.handleMove(e,Fe(ft(f,this.referenceCoordinates),x))}}}handleMove(e,s){const{onMove:r}=this.props;e.preventDefault(),r(s)}handleEnd(e){const{onEnd:s}=this.props;e.preventDefault(),this.detach(),s()}handleCancel(e){const{onCancel:s}=this.props;e.preventDefault(),this.detach(),s()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Kt.activators=[{eventName:"onKeyDown",handler:(t,e,s)=>{let{keyboardCodes:r=En,onActivation:i}=e,{active:o}=s;const{code:l}=t.nativeEvent;if(r.start.includes(l)){const c=o.activatorNode.current;return c&&t.target!==c?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function cn(t){return!!(t&&"distance"in t)}function dn(t){return!!(t&&"delay"in t)}class Xt{constructor(e,s,r){var i;r===void 0&&(r=Ps(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=s;const{event:o}=e,{target:l}=o;this.props=e,this.events=s,this.document=Pe(l),this.documentListeners=new Xe(this.document),this.listeners=new Xe(r),this.windowListeners=new Xe(ie(l)),this.initialCoordinates=(i=mt(o))!=null?i:ge,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:s,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(fe.Resize,this.handleCancel),this.windowListeners.add(fe.DragStart,ln),this.windowListeners.add(fe.VisibilityChange,this.handleCancel),this.windowListeners.add(fe.ContextMenu,ln),this.documentListeners.add(fe.Keydown,this.handleKeydown),s){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(dn(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(cn(s)){this.handlePending(s);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,s){const{active:r,onPending:i}=this.props;i(r,e,this.initialCoordinates,s)}handleStart(){const{initialCoordinates:e}=this,{onStart:s}=this.props;e&&(this.activated=!0,this.documentListeners.add(fe.Click,Ws,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(fe.SelectionChange,this.removeTextSelection),s(e))}handleMove(e){var s;const{activated:r,initialCoordinates:i,props:o}=this,{onMove:l,options:{activationConstraint:c}}=o;if(!i)return;const d=(s=mt(e))!=null?s:ge,u=ft(i,d);if(!r&&c){if(cn(c)){if(c.tolerance!=null&&Ot(u,c.tolerance))return this.handleCancel();if(Ot(u,c.distance))return this.handleStart()}if(dn(c)&&Ot(u,c.tolerance))return this.handleCancel();this.handlePending(c,u);return}e.cancelable&&e.preventDefault(),l(d)}handleEnd(){const{onAbort:e,onEnd:s}=this.props;this.detach(),this.activated||e(this.props.active),s()}handleCancel(){const{onAbort:e,onCancel:s}=this.props;this.detach(),this.activated||e(this.props.active),s()}handleKeydown(e){e.code===U.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const Js={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class _t extends Xt{constructor(e){const{event:s}=e,r=Pe(s.target);super(e,Js,r)}}_t.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:r}=e;return!s.isPrimary||s.button!==0?!1:(r?.({event:s}),!0)}}];const Ys={move:{name:"mousemove"},end:{name:"mouseup"}};var zt;(function(t){t[t.RightClick=2]="RightClick"})(zt||(zt={}));class qs extends Xt{constructor(e){super(e,Ys,Pe(e.event.target))}}qs.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:r}=e;return s.button===zt.RightClick?!1:(r?.({event:s}),!0)}}];const Bt={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Rn extends Xt{constructor(e){super(e,Bt)}static setup(){return window.addEventListener(Bt.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Bt.move.name,e)};function e(){}}}Rn.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:s}=t,{onActivation:r}=e;const{touches:i}=s;return i.length>1?!1:(r?.({event:s}),!0)}}];var _e;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(_e||(_e={}));var vt;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(vt||(vt={}));function Us(t){let{acceleration:e,activator:s=_e.Pointer,canScroll:r,draggingRect:i,enabled:o,interval:l=5,order:c=vt.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:h,delta:f,threshold:m}=t;const x=Xs({delta:f,disabled:!o}),[v,b]=ls(),y=a.useRef({x:0,y:0}),D=a.useRef({x:0,y:0}),k=a.useMemo(()=>{switch(s){case _e.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case _e.DraggableRect:return i}},[s,i,d]),N=a.useRef(null),I=a.useCallback(()=>{const L=N.current;if(!L)return;const j=y.current.x*D.current.x,E=y.current.y*D.current.y;L.scrollBy(j,E)},[]),R=a.useMemo(()=>c===vt.TreeOrder?[...u].reverse():u,[c,u]);a.useEffect(()=>{if(!o||!u.length||!k){b();return}for(const L of R){if(r?.(L)===!1)continue;const j=u.indexOf(L),E=h[j];if(!E)continue;const{direction:$,speed:O}=Os(L,E,k,e,m);for(const H of["x","y"])x[H][$[H]]||(O[H]=0,$[H]=0);if(O.x>0||O.y>0){b(),N.current=L,v(I,l),y.current=O,D.current=$;return}}y.current={x:0,y:0},D.current={x:0,y:0},b()},[e,I,r,b,o,l,JSON.stringify(k),JSON.stringify(x),v,u,R,h,JSON.stringify(m)])}const Ks={x:{[ee.Backward]:!1,[ee.Forward]:!1},y:{[ee.Backward]:!1,[ee.Forward]:!1}};function Xs(t){let{delta:e,disabled:s}=t;const r=ht(e);return rt(i=>{if(s||!r||!i)return Ks;const o={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[ee.Backward]:i.x[ee.Backward]||o.x===-1,[ee.Forward]:i.x[ee.Forward]||o.x===1},y:{[ee.Backward]:i.y[ee.Backward]||o.y===-1,[ee.Forward]:i.y[ee.Forward]||o.y===1}}},[s,e,r])}function _s(t,e){const s=e!=null?t.get(e):void 0,r=s?s.node.current:null;return rt(i=>{var o;return e==null?null:(o=r??i)!=null?o:null},[r,e])}function Gs(t,e){return a.useMemo(()=>t.reduce((s,r)=>{const{sensor:i}=r,o=i.activators.map(l=>({eventName:l.eventName,handler:e(l.handler,r)}));return[...s,...o]},[]),[t,e])}var tt;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(tt||(tt={}));var Ht;(function(t){t.Optimized="optimized"})(Ht||(Ht={}));const un=new Map;function Qs(t,e){let{dragging:s,dependencies:r,config:i}=e;const[o,l]=a.useState(null),{frequency:c,measure:d,strategy:u}=i,h=a.useRef(t),f=y(),m=Ze(f),x=a.useCallback(function(D){D===void 0&&(D=[]),!m.current&&l(k=>k===null?D:k.concat(D.filter(N=>!k.includes(N))))},[m]),v=a.useRef(null),b=rt(D=>{if(f&&!s)return un;if(!D||D===un||h.current!==t||o!=null){const k=new Map;for(let N of t){if(!N)continue;if(o&&o.length>0&&!o.includes(N.id)&&N.rect.current){k.set(N.id,N.rect.current);continue}const I=N.node.current,R=I?new Ut(d(I),I):null;N.rect.current=R,R&&k.set(N.id,R)}return k}return D},[t,o,s,f,d]);return a.useEffect(()=>{h.current=t},[t]),a.useEffect(()=>{f||x()},[s,f]),a.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),a.useEffect(()=>{f||typeof c!="number"||v.current!==null||(v.current=setTimeout(()=>{x(),v.current=null},c))},[c,f,x,...r]),{droppableRects:b,measureDroppableContainers:x,measuringScheduled:o!=null};function y(){switch(u){case tt.Always:return!1;case tt.BeforeDragging:return s;default:return!s}}}function Gt(t,e){return rt(s=>t?s||(typeof e=="function"?e(t):t):null,[e,t])}function Zs(t,e){return Gt(t,e)}function er(t){let{callback:e,disabled:s}=t;const r=bt(e),i=a.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(r)},[r,s]);return a.useEffect(()=>()=>i?.disconnect(),[i]),i}function yt(t){let{callback:e,disabled:s}=t;const r=bt(e),i=a.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(r)},[s]);return a.useEffect(()=>()=>i?.disconnect(),[i]),i}function tr(t){return new Ut(at(t),t)}function hn(t,e,s){e===void 0&&(e=tr);const[r,i]=a.useState(null);function o(){i(d=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=d??s)!=null?u:null}const h=e(t);return JSON.stringify(d)===JSON.stringify(h)?d:h})}const l=er({callback(d){if(t)for(const u of d){const{type:h,target:f}=u;if(h==="childList"&&f instanceof HTMLElement&&f.contains(t)){o();break}}}}),c=yt({callback:o});return ke(()=>{o(),t?(c?.observe(t),l?.observe(document.body,{childList:!0,subtree:!0})):(c?.disconnect(),l?.disconnect())},[t]),r}function nr(t){const e=Gt(t);return jn(t,e)}const fn=[];function sr(t){const e=a.useRef(t),s=rt(r=>t?r&&r!==fn&&t&&e.current&&t.parentNode===e.current.parentNode?r:qt(t):fn,[t]);return a.useEffect(()=>{e.current=t},[t]),s}function rr(t){const[e,s]=a.useState(null),r=a.useRef(t),i=a.useCallback(o=>{const l=$t(o.target);l&&s(c=>c?(c.set(l,Ft(l)),new Map(c)):null)},[]);return a.useEffect(()=>{const o=r.current;if(t!==o){l(o);const c=t.map(d=>{const u=$t(d);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,Ft(u)]):null}).filter(d=>d!=null);s(c.length?new Map(c):null),r.current=t}return()=>{l(t),l(o)};function l(c){c.forEach(d=>{const u=$t(d);u?.removeEventListener("scroll",i)})}},[i,t]),a.useMemo(()=>t.length?e?Array.from(e.values()).reduce((o,l)=>Fe(o,l),ge):Tn(t):ge,[t,e])}function mn(t,e){e===void 0&&(e=[]);const s=a.useRef(null);return a.useEffect(()=>{s.current=null},e),a.useEffect(()=>{const r=t!==ge;r&&!s.current&&(s.current=t),!r&&s.current&&(s.current=null)},[t]),s.current?ft(t,s.current):ge}function ar(t){a.useEffect(()=>{if(!pt)return;const e=t.map(s=>{let{sensor:r}=s;return r.setup==null?void 0:r.setup()});return()=>{for(const s of e)s?.()}},t.map(e=>{let{sensor:s}=e;return s}))}function ir(t,e){return a.useMemo(()=>t.reduce((s,r)=>{let{eventName:i,handler:o}=r;return s[i]=l=>{o(l,e)},s},{}),[t,e])}function An(t){return a.useMemo(()=>t?As(t):null,[t])}const gn=[];function or(t,e){e===void 0&&(e=at);const[s]=t,r=An(s?ie(s):null),[i,o]=a.useState(gn);function l(){o(()=>t.length?t.map(d=>kn(d)?r:new Ut(e(d),d)):gn)}const c=yt({callback:l});return ke(()=>{c?.disconnect(),l(),t.forEach(d=>c?.observe(d))},[t]),i}function Ln(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return st(e)?e:t}function lr(t){let{measure:e}=t;const[s,r]=a.useState(null),i=a.useCallback(u=>{for(const{target:h}of u)if(st(h)){r(f=>{const m=e(h);return f?{...f,width:m.width,height:m.height}:m});break}},[e]),o=yt({callback:i}),l=a.useCallback(u=>{const h=Ln(u);o?.disconnect(),h&&o?.observe(h),r(h?e(h):null)},[e,o]),[c,d]=ut(l);return a.useMemo(()=>({nodeRef:c,rect:s,setRef:d}),[s,c,d])}const cr=[{sensor:_t,options:{}},{sensor:Kt,options:{}}],dr={current:{}},dt={draggable:{measure:on},droppable:{measure:on,strategy:tt.WhileDragging,frequency:Ht.Optimized},dragOverlay:{measure:at}};class Ge extends Map{get(e){var s;return e!=null&&(s=super.get(e))!=null?s:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:s}=e;return!s})}getNodeFor(e){var s,r;return(s=(r=this.get(e))==null?void 0:r.node.current)!=null?s:void 0}}const ur={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Ge,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:gt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:dt,measureDroppableContainers:gt,windowRect:null,measuringScheduled:!1},In={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:gt,draggableNodes:new Map,over:null,measureDroppableContainers:gt},it=a.createContext(In),$n=a.createContext(ur);function hr(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Ge}}}function fr(t,e){switch(e.type){case Q.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Q.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case Q.DragEnd:case Q.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Q.RegisterDroppable:{const{element:s}=e,{id:r}=s,i=new Ge(t.droppable.containers);return i.set(r,s),{...t,droppable:{...t.droppable,containers:i}}}case Q.SetDroppableDisabled:{const{id:s,key:r,disabled:i}=e,o=t.droppable.containers.get(s);if(!o||r!==o.key)return t;const l=new Ge(t.droppable.containers);return l.set(s,{...o,disabled:i}),{...t,droppable:{...t.droppable,containers:l}}}case Q.UnregisterDroppable:{const{id:s,key:r}=e,i=t.droppable.containers.get(s);if(!i||r!==i.key)return t;const o=new Ge(t.droppable.containers);return o.delete(s),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function mr(t){let{disabled:e}=t;const{active:s,activatorEvent:r,draggableNodes:i}=a.useContext(it),o=ht(r),l=ht(s?.id);return a.useEffect(()=>{if(!e&&!r&&o&&l!=null){if(!Yt(o)||document.activeElement===o.target)return;const c=i.get(l);if(!c)return;const{activatorNode:d,node:u}=c;if(!d.current&&!u.current)return;requestAnimationFrame(()=>{for(const h of[d.current,u.current]){if(!h)continue;const f=us(h);if(f){f.focus();break}}})}},[r,e,i,l,o]),null}function On(t,e){let{transform:s,...r}=e;return t!=null&&t.length?t.reduce((i,o)=>o({transform:i,...r}),s):s}function gr(t){return a.useMemo(()=>({draggable:{...dt.draggable,...t?.draggable},droppable:{...dt.droppable,...t?.droppable},dragOverlay:{...dt.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function vr(t){let{activeNode:e,measure:s,initialRect:r,config:i=!0}=t;const o=a.useRef(!1),{x:l,y:c}=typeof i=="boolean"?{x:i,y:i}:i;ke(()=>{if(!l&&!c||!e){o.current=!1;return}if(o.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const h=s(u),f=jn(h,r);if(l||(f.x=0),c||(f.y=0),o.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const m=wn(u);m&&m.scrollBy({top:f.y,left:f.x})}},[e,l,c,r,s])}const jt=a.createContext({...ge,scaleX:1,scaleY:1});var Re;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Re||(Re={}));const pr=a.memo(function(e){var s,r,i,o;let{id:l,accessibility:c,autoScroll:d=!0,children:u,sensors:h=cr,collisionDetection:f=ks,measuring:m,modifiers:x,...v}=e;const b=a.useReducer(fr,void 0,hr),[y,D]=b,[k,N]=ps(),[I,R]=a.useState(Re.Uninitialized),L=I===Re.Initialized,{draggable:{active:j,nodes:E,translate:$},droppable:{containers:O}}=y,H=j!=null?E.get(j):null,P=a.useRef({initial:null,translated:null}),J=a.useMemo(()=>{var re;return j!=null?{id:j,data:(re=H?.data)!=null?re:dr,rect:P}:null},[j,H]),q=a.useRef(null),[ne,C]=a.useState(null),[F,Z]=a.useState(null),K=Ze(v,Object.values(v)),se=xt("DndDescribedBy",l),_=a.useMemo(()=>O.getEnabled(),[O]),w=gr(m),{droppableRects:B,measureDroppableContainers:g,measuringScheduled:S}=Qs(_,{dragging:L,dependencies:[$.x,$.y],config:w.droppable}),A=_s(E,j),W=a.useMemo(()=>F?mt(F):null,[F]),p=os(),M=Zs(A,w.draggable.measure);vr({activeNode:j!=null?E.get(j):null,config:p.layoutShiftCompensation,initialRect:M,measure:w.draggable.measure});const V=hn(A,w.draggable.measure,M),X=hn(A?A.parentElement:null),G=a.useRef({activatorEvent:null,active:null,activeNode:A,collisionRect:null,collisions:null,droppableRects:B,draggableNodes:E,draggingNode:null,draggingNodeRect:null,droppableContainers:O,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ue=O.getNodeFor((s=G.current.over)==null?void 0:s.id),me=lr({measure:w.dragOverlay.measure}),ve=(r=me.nodeRef.current)!=null?r:A,pe=L?(i=me.rect)!=null?i:V:null,Ne=!!(me.nodeRef.current&&me.rect),Ve=nr(Ne?null:V),Je=An(ve?ie(ve):null),be=sr(L?ue??A:null),Le=or(be),Ie=On(x,{transform:{x:$.x-Ve.x,y:$.y-Ve.y,scaleX:1,scaleY:1},activatorEvent:F,active:J,activeNodeRect:V,containerNodeRect:X,draggingNodeRect:pe,over:G.current.over,overlayNodeRect:me.rect,scrollableAncestors:be,scrollableAncestorRects:Le,windowRect:Je}),lt=W?Fe(W,$):null,ct=rr(be),Mt=mn(ct),$e=mn(ct,[V]),we=Fe(Ie,Mt),Se=pe?Ms(pe,Ie):null,T=J&&Se?f({active:J,collisionRect:Se,droppableRects:B,droppableContainers:_,pointerCoordinates:lt}):null,z=Cs(T,"id"),[Y,Ce]=a.useState(null),Oe=Ne?Ie:Fe(Ie,$e),Et=Ss(Oe,(o=Y?.rect)!=null?o:null,V),Rt=a.useRef(null),sn=a.useCallback((re,oe)=>{let{sensor:le,options:Te}=oe;if(q.current==null)return;const he=E.get(q.current);if(!he)return;const ce=re.nativeEvent,xe=new le({active:q.current,activeNode:he,event:ce,options:Te,context:G,onAbort(te){if(!E.get(te))return;const{onDragAbort:ye}=K.current,De={id:te};ye?.(De),k({type:"onDragAbort",event:De})},onPending(te,Me,ye,De){if(!E.get(te))return;const{onDragPending:qe}=K.current,Ee={id:te,constraint:Me,initialCoordinates:ye,offset:De};qe?.(Ee),k({type:"onDragPending",event:Ee})},onStart(te){const Me=q.current;if(Me==null)return;const ye=E.get(Me);if(!ye)return;const{onDragStart:De}=K.current,Ye={activatorEvent:ce,active:{id:Me,data:ye.data,rect:P}};Ke.unstable_batchedUpdates(()=>{De?.(Ye),R(Re.Initializing),D({type:Q.DragStart,initialCoordinates:te,active:Me}),k({type:"onDragStart",event:Ye}),C(Rt.current),Z(ce)})},onMove(te){D({type:Q.DragMove,coordinates:te})},onEnd:Be(Q.DragEnd),onCancel:Be(Q.DragCancel)});Rt.current=xe;function Be(te){return async function(){const{active:ye,collisions:De,over:Ye,scrollAdjustedTranslate:qe}=G.current;let Ee=null;if(ye&&qe){const{cancelDrop:Ue}=K.current;Ee={activatorEvent:ce,active:ye,collisions:De,delta:qe,over:Ye},te===Q.DragEnd&&typeof Ue=="function"&&await Promise.resolve(Ue(Ee))&&(te=Q.DragCancel)}q.current=null,Ke.unstable_batchedUpdates(()=>{D({type:te}),R(Re.Uninitialized),Ce(null),C(null),Z(null),Rt.current=null;const Ue=te===Q.DragEnd?"onDragEnd":"onDragCancel";if(Ee){const At=K.current[Ue];At?.(Ee),k({type:Ue,event:Ee})}})}}},[E]),rs=a.useCallback((re,oe)=>(le,Te)=>{const he=le.nativeEvent,ce=E.get(Te);if(q.current!==null||!ce||he.dndKit||he.defaultPrevented)return;const xe={active:ce};re(le,oe.options,xe)===!0&&(he.dndKit={capturedBy:oe.sensor},q.current=Te,sn(le,oe))},[E,sn]),rn=Gs(h,rs);ar(h),ke(()=>{V&&I===Re.Initializing&&R(Re.Initialized)},[V,I]),a.useEffect(()=>{const{onDragMove:re}=K.current,{active:oe,activatorEvent:le,collisions:Te,over:he}=G.current;if(!oe||!le)return;const ce={active:oe,activatorEvent:le,collisions:Te,delta:{x:we.x,y:we.y},over:he};Ke.unstable_batchedUpdates(()=>{re?.(ce),k({type:"onDragMove",event:ce})})},[we.x,we.y]),a.useEffect(()=>{const{active:re,activatorEvent:oe,collisions:le,droppableContainers:Te,scrollAdjustedTranslate:he}=G.current;if(!re||q.current==null||!oe||!he)return;const{onDragOver:ce}=K.current,xe=Te.get(z),Be=xe&&xe.rect.current?{id:xe.id,rect:xe.rect.current,data:xe.data,disabled:xe.disabled}:null,te={active:re,activatorEvent:oe,collisions:le,delta:{x:he.x,y:he.y},over:Be};Ke.unstable_batchedUpdates(()=>{Ce(Be),ce?.(te),k({type:"onDragOver",event:te})})},[z]),ke(()=>{G.current={activatorEvent:F,active:J,activeNode:A,collisionRect:Se,collisions:T,droppableRects:B,draggableNodes:E,draggingNode:ve,draggingNodeRect:pe,droppableContainers:O,over:Y,scrollableAncestors:be,scrollAdjustedTranslate:we},P.current={initial:pe,translated:Se}},[J,A,T,Se,E,ve,pe,B,O,Y,be,we]),Us({...p,delta:$,draggingRect:Se,pointerCoordinates:lt,scrollableAncestors:be,scrollableAncestorRects:Le});const as=a.useMemo(()=>({active:J,activeNode:A,activeNodeRect:V,activatorEvent:F,collisions:T,containerNodeRect:X,dragOverlay:me,draggableNodes:E,droppableContainers:O,droppableRects:B,over:Y,measureDroppableContainers:g,scrollableAncestors:be,scrollableAncestorRects:Le,measuringConfiguration:w,measuringScheduled:S,windowRect:Je}),[J,A,V,F,T,X,me,E,O,B,Y,g,be,Le,w,S,Je]),is=a.useMemo(()=>({activatorEvent:F,activators:rn,active:J,activeNodeRect:V,ariaDescribedById:{draggable:se},dispatch:D,draggableNodes:E,over:Y,measureDroppableContainers:g}),[F,rn,J,V,D,se,E,Y,g]);return a.createElement(yn.Provider,{value:N},a.createElement(it.Provider,{value:is},a.createElement($n.Provider,{value:as},a.createElement(jt.Provider,{value:Et},u)),a.createElement(mr,{disabled:c?.restoreFocus===!1})),a.createElement(ys,{...c,hiddenTextDescribedById:se}));function os(){const re=ne?.autoScrollEnabled===!1,oe=typeof d=="object"?d.enabled===!1:d===!1,le=L&&!re&&!oe;return typeof d=="object"?{...d,enabled:le}:{enabled:le}}}),br=a.createContext(null),vn="button",xr="Draggable";function yr(t){let{id:e,data:s,disabled:r=!1,attributes:i}=t;const o=xt(xr),{activators:l,activatorEvent:c,active:d,activeNodeRect:u,ariaDescribedById:h,draggableNodes:f,over:m}=a.useContext(it),{role:x=vn,roleDescription:v="draggable",tabIndex:b=0}=i??{},y=d?.id===e,D=a.useContext(y?jt:br),[k,N]=ut(),[I,R]=ut(),L=ir(l,e),j=Ze(s);ke(()=>(f.set(e,{id:e,key:o,node:k,activatorNode:I,data:j}),()=>{const $=f.get(e);$&&$.key===o&&f.delete(e)}),[f,e]);const E=a.useMemo(()=>({role:x,tabIndex:b,"aria-disabled":r,"aria-pressed":y&&x===vn?!0:void 0,"aria-roledescription":v,"aria-describedby":h.draggable}),[r,x,b,y,v,h.draggable]);return{active:d,activatorEvent:c,activeNodeRect:u,attributes:E,isDragging:y,listeners:r?void 0:L,node:k,over:m,setNodeRef:N,setActivatorNodeRef:R,transform:D}}function jr(){return a.useContext($n)}const Nr="Droppable",wr={timeout:25};function Bn(t){let{data:e,disabled:s=!1,id:r,resizeObserverConfig:i}=t;const o=xt(Nr),{active:l,dispatch:c,over:d,measureDroppableContainers:u}=a.useContext(it),h=a.useRef({disabled:s}),f=a.useRef(!1),m=a.useRef(null),x=a.useRef(null),{disabled:v,updateMeasurementsFor:b,timeout:y}={...wr,...i},D=Ze(b??r),k=a.useCallback(()=>{if(!f.current){f.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{u(Array.isArray(D.current)?D.current:[D.current]),x.current=null},y)},[y]),N=yt({callback:k,disabled:v||!l}),I=a.useCallback((E,$)=>{N&&($&&(N.unobserve($),f.current=!1),E&&N.observe(E))},[N]),[R,L]=ut(I),j=Ze(e);return a.useEffect(()=>{!N||!R.current||(N.disconnect(),f.current=!1,N.observe(R.current))},[R,N]),a.useEffect(()=>(c({type:Q.RegisterDroppable,element:{id:r,key:o,disabled:s,node:R,rect:m,data:j}}),()=>c({type:Q.UnregisterDroppable,key:o,id:r})),[r]),a.useEffect(()=>{s!==h.current.disabled&&(c({type:Q.SetDroppableDisabled,id:r,key:o,disabled:s}),h.current.disabled=s)},[r,o,s,c]),{active:l,rect:m,isOver:d?.id===r,node:R,over:d,setNodeRef:L}}function Cr(t){let{animation:e,children:s}=t;const[r,i]=a.useState(null),[o,l]=a.useState(null),c=ht(s);return!s&&!r&&c&&i(c),ke(()=>{if(!o)return;const d=r?.key,u=r?.props.id;if(d==null||u==null){i(null);return}Promise.resolve(e(u,o)).then(()=>{i(null)})},[e,r,o]),a.createElement(a.Fragment,null,s,r?a.cloneElement(r,{ref:l}):null)}const Dr={x:0,y:0,scaleX:1,scaleY:1};function kr(t){let{children:e}=t;return a.createElement(it.Provider,{value:In},a.createElement(jt.Provider,{value:Dr},e))}const Sr={position:"fixed",touchAction:"none"},Tr=t=>Yt(t)?"transform 250ms ease":void 0,Mr=a.forwardRef((t,e)=>{let{as:s,activatorEvent:r,adjustScale:i,children:o,className:l,rect:c,style:d,transform:u,transition:h=Tr}=t;if(!c)return null;const f=i?u:{...u,scaleX:1,scaleY:1},m={...Sr,width:c.width,height:c.height,top:c.top,left:c.left,transform:et.Transform.toString(f),transformOrigin:i&&r?Ns(r,c):void 0,transition:typeof h=="function"?h(r):h,...d};return a.createElement(s,{className:l,style:m,ref:e},o)}),Er=t=>e=>{let{active:s,dragOverlay:r}=e;const i={},{styles:o,className:l}=t;if(o!=null&&o.active)for(const[c,d]of Object.entries(o.active))d!==void 0&&(i[c]=s.node.style.getPropertyValue(c),s.node.style.setProperty(c,d));if(o!=null&&o.dragOverlay)for(const[c,d]of Object.entries(o.dragOverlay))d!==void 0&&r.node.style.setProperty(c,d);return l!=null&&l.active&&s.node.classList.add(l.active),l!=null&&l.dragOverlay&&r.node.classList.add(l.dragOverlay),function(){for(const[d,u]of Object.entries(i))s.node.style.setProperty(d,u);l!=null&&l.active&&s.node.classList.remove(l.active)}},Rr=t=>{let{transform:{initial:e,final:s}}=t;return[{transform:et.Transform.toString(e)},{transform:et.Transform.toString(s)}]},Ar={duration:250,easing:"ease",keyframes:Rr,sideEffects:Er({styles:{active:{opacity:"0"}}})};function Lr(t){let{config:e,draggableNodes:s,droppableContainers:r,measuringConfiguration:i}=t;return bt((o,l)=>{if(e===null)return;const c=s.get(o);if(!c)return;const d=c.node.current;if(!d)return;const u=Ln(l);if(!u)return;const{transform:h}=ie(l).getComputedStyle(l),f=Nn(h);if(!f)return;const m=typeof e=="function"?e:Ir(e);return Mn(d,i.draggable.measure),m({active:{id:o,data:c.data,node:d,rect:i.draggable.measure(d)},draggableNodes:s,dragOverlay:{node:l,rect:i.dragOverlay.measure(u)},droppableContainers:r,measuringConfiguration:i,transform:f})})}function Ir(t){const{duration:e,easing:s,sideEffects:r,keyframes:i}={...Ar,...t};return o=>{let{active:l,dragOverlay:c,transform:d,...u}=o;if(!e)return;const h={x:c.rect.left-l.rect.left,y:c.rect.top-l.rect.top},f={scaleX:d.scaleX!==1?l.rect.width*d.scaleX/c.rect.width:1,scaleY:d.scaleY!==1?l.rect.height*d.scaleY/c.rect.height:1},m={x:d.x-h.x,y:d.y-h.y,...f},x=i({...u,active:l,dragOverlay:c,transform:{initial:d,final:m}}),[v]=x,b=x[x.length-1];if(JSON.stringify(v)===JSON.stringify(b))return;const y=r?.({active:l,dragOverlay:c,...u}),D=c.node.animate(x,{duration:e,easing:s,fill:"forwards"});return new Promise(k=>{D.onfinish=()=>{y?.(),k()}})}}let pn=0;function $r(t){return a.useMemo(()=>{if(t!=null)return pn++,pn},[t])}const Or=a.memo(t=>{let{adjustScale:e=!1,children:s,dropAnimation:r,style:i,transition:o,modifiers:l,wrapperElement:c="div",className:d,zIndex:u=999}=t;const{activatorEvent:h,active:f,activeNodeRect:m,containerNodeRect:x,draggableNodes:v,droppableContainers:b,dragOverlay:y,over:D,measuringConfiguration:k,scrollableAncestors:N,scrollableAncestorRects:I,windowRect:R}=jr(),L=a.useContext(jt),j=$r(f?.id),E=On(l,{activatorEvent:h,active:f,activeNodeRect:m,containerNodeRect:x,draggingNodeRect:y.rect,over:D,overlayNodeRect:y.rect,scrollableAncestors:N,scrollableAncestorRects:I,transform:L,windowRect:R}),$=Gt(m),O=Lr({config:r,draggableNodes:v,droppableContainers:b,measuringConfiguration:k}),H=$?y.setRef:void 0;return a.createElement(kr,null,a.createElement(Cr,{animation:O},f&&j?a.createElement(Mr,{key:j,id:f.id,ref:H,as:c,activatorEvent:h,adjustScale:e,className:d,transition:o,rect:$,style:{zIndex:u,...i},transform:E},s):null))}),ae=60,je=30;function Ae(t){return t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}function ze(t){return t.toLocaleDateString("en-US",{weekday:"short",day:"numeric"})}function Nt(t){return t.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}function wt(t,e,s){const r=[];for(let i=e;i<s;i++)for(let o=0;o<60;o+=je){const l=new Date(t);l.setHours(i,o,0,0),r.push({time:l,hour:i,minute:o,label:Ae(l),isHourStart:o===0})}return r}function Fn(t,e){const s=t.getHours(),r=t.getMinutes();return((s-e)*60+r)/je*ae}function zn(t){return t/je*ae}function Hn(t){const e=new Date(t);return e.setHours(0,0,0,0),e}function Br(t){const e=new Date(t);return e.setHours(23,59,59,999),e}function Qt(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function Zt(t){const e=new Date(t),s=e.getDay();e.setDate(e.getDate()-s),e.setHours(0,0,0,0);const r=[];for(let i=0;i<7;i++){const o=new Date(e);o.setDate(e.getDate()+i),r.push(o)}return r}function We(t,e){return new Date(t.getTime()+e*60*1e3)}function Pn(t){const e=new Date(t),s=e.getMinutes(),r=Math.round(s/je)*je;return e.setMinutes(r,0,0),e}function Fr(t,e,s){const r=t.getHours(),i=t.getMinutes();return!(r<e||r>=s||r===s&&i===0)}function zr(t,e,s){const r=new Date(t);return r.setHours(e,s,0,0),r}function Pt(){return Hn(new Date)}function en(t){return Qt(t,new Date)}function de(t){if(t!=null)return typeof t=="string"?t:t.id}function Wn(t,e){return t==null?"":typeof t=="object"?t.name??t.id??"":e?.length?e.find(r=>r.id===t)?.name??t:t}function Vn({initialView:t="week",initialDate:e,detailDisplay:s="modal"}={}){const[r,i]=a.useState(t),[o,l]=a.useState(e??Pt()),[c,d]=a.useState(null),u=a.useCallback(()=>{l(b=>{const y=new Date(b);return r==="day"?y.setDate(y.getDate()-1):y.setDate(y.getDate()-7),y})},[r]),h=a.useCallback(()=>{l(b=>{const y=new Date(b);return r==="day"?y.setDate(y.getDate()+1):y.setDate(y.getDate()+7),y})},[r]),f=a.useCallback(()=>{l(Pt())},[]),m=a.useCallback(b=>{d(b)},[]),x=a.useCallback(()=>{d(null)},[]),v=a.useMemo(()=>c!==null,[c]);return{view:r,setView:i,selectedDate:o,setSelectedDate:l,goToPrevious:u,goToNext:h,goToToday:f,selectedAppointment:c,selectAppointment:m,isDetailOpen:v,closeDetail:x,detailDisplay:s}}function Jn({startHour:t,endHour:e,getHoursForDate:s,onReschedule:r}){const[i,o]=a.useState(null),l=a.useCallback(u=>{const{active:h}=u;o(h.id)},[]),c=a.useCallback(u=>{const{active:h,delta:f,over:m}=u;if(o(null),!r)return;const x=h.data.current;if(!x?.appointment)return;const v=x.appointment,y=Math.round(f.y/ae)*je;let D=null;if(m?.data?.current){const O=m.data.current;O.date&&(D=O.date)}if(y===0&&!D)return;let k;if(D){k=new Date(D);const O=v.startTime.getHours(),H=v.startTime.getMinutes();k.setHours(O,H,0,0),k=new Date(k.getTime()+y*60*1e3)}else k=new Date(v.startTime.getTime()+y*60*1e3);const N=Pn(k),I=D??v.startTime,{startHour:R,endHour:L}=s?s(I):{startHour:t,endHour:e},j=N.getHours(),E=N.getMinutes(),$=j+Math.floor((E+v.duration)/60);j<R||$>L||N.getTime()!==v.startTime.getTime()&&r(v.id,N)},[r,t,e,s]),d=a.useMemo(()=>({transform:u})=>({...u,y:Math.round(u.y/ae)*ae,x:u.x}),[]);return{draggingId:i,handleDragStart:l,handleDragEnd:c,snapModifier:d}}const nt="#64748b";function Yn(t,e){if(!t||!e?.length)return nt;const s=e.find(r=>r.id===t);return s?.color?s.color:nt}function ot(t,e){const s=de(t.artist);return Yn(s??void 0,e)}const Wt={Classic:{className:"service-classic",badgeColor:"var(--color-rose-400)"},Hybrid:{className:"service-hybrid",badgeColor:"var(--color-violet-400)"},Volume:{className:"service-volume",badgeColor:"var(--color-amber-400)"},Refill:{className:"service-refill",badgeColor:"var(--color-emerald-400)"}};function qn(t){return Wt[t]||Wt.Classic}function Hr(t,e=!1){const r=["appointment-block",qn(t).className];return e&&r.push("dragging"),r.join(" ")}function Un(t){return t||"Unknown Service"}function Pr(t){return{Classic:90,Hybrid:120,Volume:150,Refill:60}[t]||60}function Qe(t){return new Date(t.startTime.getTime()+t.duration*60*1e3)}function Wr(t){if(t.length===0)return[];const e=[...t].sort((o,l)=>o.startTime.getTime()-l.startTime.getTime()),s=[];let r=[e[0]],i=Qe(e[0]).getTime();for(let o=1;o<e.length;o++){const l=e[o];l.startTime.getTime()<i?(r.push(l),i=Math.max(i,Qe(l).getTime())):(s.push(r),r=[l],i=Qe(l).getTime())}return s.push(r),s}function Vr(t){const e=[...t].sort((i,o)=>{const l=i.startTime.getTime()-o.startTime.getTime();return l!==0?l:o.duration-i.duration}),s=new Map,r=[];for(const i of e){const o=i.startTime.getTime();let l=-1;for(let c=0;c<r.length;c++)if(r[c]<=o){l=c;break}l===-1&&(l=r.length,r.push(0)),s.set(i.id,l),r[l]=Qe(i).getTime()}return s}function Ct(t,e){if(t.length===0)return[];const s=Wr(t),r=[];for(const i of s){const o=Vr(i),l=new Set(o.values()).size;for(const c of i)r.push({appointment:c,lane:o.get(c.id)??0,totalLanes:l,top:Fn(c.startTime,e),height:zn(c.duration)})}return r}function Dt(t,e){return t.filter(s=>Qt(s.startTime,e))}function kt(t,e,s){return t.filter(r=>{const i=r.startTime.getHours(),o=Qe(r),l=o.getHours(),c=o.getMinutes(),d=i<s,u=l>e||l===e&&c>0;return d&&u&&i>=e})}function Kn(t,e){return(e-t)*2}function Jr(t,e,s){return Kn(t,e)*s}const St=a.memo(function({slots:e,slotHeight:s}){return n.jsx("div",{className:"time-column",style:{width:"80px"},children:e.map((r,i)=>n.jsxs("div",{className:"time-slot-label",style:{height:`${s}px`},children:[r.isHourStart&&n.jsx("span",{children:r.label}),r.isHourStart&&i>0&&n.jsx("div",{className:"time-slot-divider"})]},`${r.hour}-${r.minute}`))})}),Tt=a.memo(function({layout:e,onClick:s,isSelected:r=!1,isDragging:i=!1}){const{appointment:o,lane:l,totalLanes:c,top:d,height:u}=e,h=e.color??nt,{attributes:f,listeners:m,setNodeRef:x,transform:v,isDragging:b}=yr({id:o.id,data:{appointment:o}}),y=x||(()=>{}),D=We(o.startTime,o.duration),k=2,I=(100-(c-1)*.5)/c,R=l*(I+.5),L=i||b,j=o.status??"pending",E=`appointment-status-${j}`,$=j.charAt(0).toUpperCase()+j.slice(1),O={position:"absolute",top:`${d}px`,left:`${R}%`,width:`${I}%`,height:`${Math.max(u-k,30)}px`,zIndex:L?100:r?50:10,transform:v?`translate(${v.x}px, ${v.y}px)`:void 0,pointerEvents:"auto",touchAction:"none","--block-color":h},H=J=>{J.stopPropagation(),s&&!L&&s(o)},P=["appointment-block","technician-color",L?"dragging":"",r?"selected":""].filter(Boolean).join(" ");return n.jsx("div",{ref:y,style:O,className:P,onClick:H,...f,...m,role:"button","aria-label":`${o.client.name}, ${Un(o.serviceType)} at ${Ae(o.startTime)}`,children:n.jsxs("div",{className:"appointment-content",children:[n.jsxs("div",{className:"appointment-badge",children:[n.jsx("span",{className:"appointment-badge-dot","aria-hidden":"true"}),n.jsx("span",{className:"appointment-badge-text",children:o.serviceType})]}),n.jsx("p",{className:"appointment-client",children:o.client.name}),n.jsxs("div",{className:"appointment-details",children:[n.jsxs("p",{className:"appointment-time",children:[Ae(o.startTime)," – ",Ae(D)]}),n.jsx("p",{className:`appointment-status ${E}`,children:$})]})]})})}),Yr=a.memo(function({date:e,technician:s,appointments:r,slots:i,startHour:o,endHour:l,onAppointmentClick:c,onSlotClick:d,selectedAppointmentId:u,draggingAppointmentId:h}){const{setNodeRef:f,isOver:m}=Bn({id:`tech-${s.id}-${e.toISOString()}`,data:{date:e,technicianId:s.id}}),x=f||(()=>{}),v=a.useMemo(()=>r.filter(N=>de(N.artist)===s.id),[r,s.id]),b=s.color??nt,y=a.useMemo(()=>{const N=Dt(v,e),I=kt(N,o,l);return Ct(I,o).map(L=>({...L,color:b}))},[v,e,o,l,b]),D=a.useCallback(N=>{if(d){const I=new Date(e);I.setHours(N.hour,N.minute,0,0);const R=We(I,je);d(I,R,s.id)}},[e,d,s.id]),k=i.length*ae;return n.jsxs("div",{ref:x,className:`tech-column ${m?"drag-over":""}`,children:[n.jsx("div",{className:`column-header ${m?