import{c as ze,r as i,R as xe,t as et,j as r,d as q,f as Hn,l as ve,P as ee,i as J,k as en,D as Sr,v as Ds,h as Wt,w as Nr,x as jr,X as Rs,n as Is,y as Dr,A as Es,m as We,C as Ts,z as Ms,V as ks,B as As,E as Ps,F as Os,p as _s}from"./index-7mCYgmGq.js";import{R as Rr,h as Ir,c as Er,F as Tr,d as Mr,C as kr,u as ar,a as oe}from"./api-DTr_VGP6.js";import{F as Ar,C as Pr,a as Ls,B as Et,u as me}from"./badge-Jk5N1SqW.js";import{M as Fs}from"./MainLayout-DBQR6vfb.js";import{B as X}from"./button-BfkoTqK7.js";import{I as Ze}from"./input-DKWBtE-I.js";import{L as we}from"./label-yOd4dcRB.js";import{c as dt,d as zs,m as Nt,B as Or}from"./index-C5l5cIjg.js";import{T as Bs,a as $s,b as wn,c as Cn}from"./tabs-CdAiC77o.js";import{S as tn,L as Wn}from"./square-pen-DBORN0jx.js";/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Us=ze("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Vs=ze("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Qn=ze("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ir=ze("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const gt=ze("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ut=ze("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Hs=ze("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ws=ze("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const lr=ze("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);function Qs(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return i.useMemo(()=>o=>{t.forEach(s=>s(o))},t)}const nn=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function mt(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Kn(e){return"nodeType"in e}function Ce(e){var t,n;return e?mt(e)?e:Kn(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Gn(e){const{Document:t}=Ce(e);return e instanceof t}function Pt(e){return mt(e)?!1:e instanceof Ce(e).HTMLElement}function _r(e){return e instanceof Ce(e).SVGElement}function xt(e){return e?mt(e)?e.document:Kn(e)?Gn(e)?e:Pt(e)||_r(e)?e.ownerDocument:document:document:document}const Pe=nn?i.useLayoutEffect:i.useEffect;function Xn(e){const t=i.useRef(e);return Pe(()=>{t.current=e}),i.useCallback(function(){for(var n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];return t.current==null?void 0:t.current(...o)},[])}function Ks(){const e=i.useRef(null),t=i.useCallback((o,s)=>{e.current=setInterval(o,s)},[]),n=i.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Tt(e,t){t===void 0&&(t=[e]);const n=i.useRef(e);return Pe(()=>{n.current!==e&&(n.current=e)},t),n}function Ot(e,t){const n=i.useRef();return i.useMemo(()=>{const o=e(n.current);return n.current=o,o},[...t])}function Qt(e){const t=Xn(e),n=i.useRef(null),o=i.useCallback(s=>{s!==n.current&&(t==null||t(s,n.current)),n.current=s},[]);return[n,o]}function In(e){const t=i.useRef();return i.useEffect(()=>{t.current=e},[e]),t.current}let Sn={};function _t(e,t){return i.useMemo(()=>{if(t)return t;const n=Sn[e]==null?0:Sn[e]+1;return Sn[e]=n,e+"-"+n},[e,t])}function Lr(e){return function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];return o.reduce((a,c)=>{const l=Object.entries(c);for(const[d,u]of l){const p=a[d];p!=null&&(a[d]=p+e*u)}return a},{...t})}}const ft=Lr(1),Mt=Lr(-1);function Gs(e){return"clientX"in e&&"clientY"in e}function qn(e){if(!e)return!1;const{KeyboardEvent:t}=Ce(e.target);return t&&e instanceof t}function Xs(e){if(!e)return!1;const{TouchEvent:t}=Ce(e.target);return t&&e instanceof t}function En(e){if(Xs(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Gs(e)?{x:e.clientX,y:e.clientY}:null}const ot=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[ot.Translate.toString(e),ot.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:o}=e;return t+" "+n+"ms "+o}}}),cr="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function qs(e){return e.matches(cr)?e:e.querySelector(cr)}const Ys={display:"none"};function Js(e){let{id:t,value:n}=e;return xe.createElement("div",{id:t,style:Ys},n)}function Zs(e){let{id:t,announcement:n,ariaLiveType:o="assertive"}=e;const s={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 xe.createElement("div",{id:t,style:s,role:"status","aria-live":o,"aria-atomic":!0},n)}function ea(){const[e,t]=i.useState("");return{announce:i.useCallback(o=>{o!=null&&t(o)},[]),announcement:e}}const Fr=i.createContext(null);function ta(e){const t=i.useContext(Fr);i.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function na(){const[e]=i.useState(()=>new Set),t=i.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[i.useCallback(o=>{let{type:s,event:a}=o;e.forEach(c=>{var l;return(l=c[s])==null?void 0:l.call(c,a)})},[e]),t]}const ra={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.
  `},oa={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function sa(e){let{announcements:t=oa,container:n,hiddenTextDescribedById:o,screenReaderInstructions:s=ra}=e;const{announce:a,announcement:c}=ea(),l=_t("DndLiveRegion"),[d,u]=i.useState(!1);if(i.useEffect(()=>{u(!0)},[]),ta(i.useMemo(()=>({onDragStart(f){let{active:m}=f;a(t.onDragStart({active:m}))},onDragMove(f){let{active:m,over:x}=f;t.onDragMove&&a(t.onDragMove({active:m,over:x}))},onDragOver(f){let{active:m,over:x}=f;a(t.onDragOver({active:m,over:x}))},onDragEnd(f){let{active:m,over:x}=f;a(t.onDragEnd({active:m,over:x}))},onDragCancel(f){let{active:m,over:x}=f;a(t.onDragCancel({active:m,over:x}))}}),[a,t])),!d)return null;const p=xe.createElement(xe.Fragment,null,xe.createElement(Js,{id:o,value:s.draggable}),xe.createElement(Zs,{id:l,announcement:c}));return n?et.createPortal(p,n):p}var se;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(se||(se={}));function Kt(){}function Gt(e,t){return i.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function zr(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return i.useMemo(()=>[...t].filter(o=>o!=null),[...t])}const Te=Object.freeze({x:0,y:0});function Br(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function $r(e,t){let{data:{value:n}}=e,{data:{value:o}}=t;return n-o}function aa(e,t){let{data:{value:n}}=e,{data:{value:o}}=t;return o-n}function dr(e){let{left:t,top:n,height:o,width:s}=e;return[{x:t,y:n},{x:t+s,y:n},{x:t,y:n+o},{x:t+s,y:n+o}]}function Ur(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function ur(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const Tn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const s=ur(t,t.left,t.top),a=[];for(const c of o){const{id:l}=c,d=n.get(l);if(d){const u=Br(ur(d),s);a.push({id:l,data:{droppableContainer:c,value:u}})}}return a.sort($r)},ia=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const s=dr(t),a=[];for(const c of o){const{id:l}=c,d=n.get(l);if(d){const u=dr(d),p=s.reduce((m,x,N)=>m+Br(u[N],x),0),f=Number((p/4).toFixed(4));a.push({id:l,data:{droppableContainer:c,value:f}})}}return a.sort($r)};function la(e,t){const n=Math.max(t.top,e.top),o=Math.max(t.left,e.left),s=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),c=s-o,l=a-n;if(o<s&&n<a){const d=t.width*t.height,u=e.width*e.height,p=c*l,f=p/(d+u-p);return Number(f.toFixed(4))}return 0}const ca=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const s=[];for(const a of o){const{id:c}=a,l=n.get(c);if(l){const d=la(l,t);d>0&&s.push({id:c,data:{droppableContainer:a,value:d}})}}return s.sort(aa)};function da(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Vr(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Te}function ua(e){return function(n){for(var o=arguments.length,s=new Array(o>1?o-1:0),a=1;a<o;a++)s[a-1]=arguments[a];return s.reduce((c,l)=>({...c,top:c.top+e*l.y,bottom:c.bottom+e*l.y,left:c.left+e*l.x,right:c.right+e*l.x}),{...n})}}const fa=ua(1);function pa(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function ha(e,t,n){const o=pa(t);if(!o)return e;const{scaleX:s,scaleY:a,x:c,y:l}=o,d=e.left-c-(1-s)*parseFloat(n),u=e.top-l-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),p=s?e.width/s:e.width,f=a?e.height/a:e.height;return{width:p,height:f,top:u,right:d+p,bottom:u+f,left:d}}const ga={ignoreTransform:!1};function vt(e,t){t===void 0&&(t=ga);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:p}=Ce(e).getComputedStyle(e);u&&(n=ha(n,u,p))}const{top:o,left:s,width:a,height:c,bottom:l,right:d}=n;return{top:o,left:s,width:a,height:c,bottom:l,right:d}}function fr(e){return vt(e,{ignoreTransform:!0})}function ma(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function xa(e,t){return t===void 0&&(t=Ce(e).getComputedStyle(e)),t.position==="fixed"}function va(e,t){t===void 0&&(t=Ce(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const a=t[s];return typeof a=="string"?n.test(a):!1})}function rn(e,t){const n=[];function o(s){if(t!=null&&n.length>=t||!s)return n;if(Gn(s)&&s.scrollingElement!=null&&!n.includes(s.scrollingElement))return n.push(s.scrollingElement),n;if(!Pt(s)||_r(s)||n.includes(s))return n;const a=Ce(e).getComputedStyle(s);return s!==e&&va(s,a)&&n.push(s),xa(s,a)?n:o(s.parentNode)}return e?o(e):n}function Hr(e){const[t]=rn(e,1);return t??null}function Nn(e){return!nn||!e?null:mt(e)?e:Kn(e)?Gn(e)||e===xt(e).scrollingElement?window:Pt(e)?e:null:null}function Wr(e){return mt(e)?e.scrollX:e.scrollLeft}function Qr(e){return mt(e)?e.scrollY:e.scrollTop}function Mn(e){return{x:Wr(e),y:Qr(e)}}var ce;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ce||(ce={}));function Kr(e){return!nn||!e?!1:e===document.scrollingElement}function Gr(e){const t={x:0,y:0},n=Kr(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},s=e.scrollTop<=t.y,a=e.scrollLeft<=t.x,c=e.scrollTop>=o.y,l=e.scrollLeft>=o.x;return{isTop:s,isLeft:a,isBottom:c,isRight:l,maxScroll:o,minScroll:t}}const ba={x:.2,y:.2};function ya(e,t,n,o,s){let{top:a,left:c,right:l,bottom:d}=n;o===void 0&&(o=10),s===void 0&&(s=ba);const{isTop:u,isBottom:p,isLeft:f,isRight:m}=Gr(e),x={x:0,y:0},N={x:0,y:0},h={height:t.height*s.y,width:t.width*s.x};return!u&&a<=t.top+h.height?(x.y=ce.Backward,N.y=o*Math.abs((t.top+h.height-a)/h.height)):!p&&d>=t.bottom-h.height&&(x.y=ce.Forward,N.y=o*Math.abs((t.bottom-h.height-d)/h.height)),!m&&l>=t.right-h.width?(x.x=ce.Forward,N.x=o*Math.abs((t.right-h.width-l)/h.width)):!f&&c<=t.left+h.width&&(x.x=ce.Backward,N.x=o*Math.abs((t.left+h.width-c)/h.width)),{direction:x,speed:N}}function wa(e){if(e===document.scrollingElement){const{innerWidth:a,innerHeight:c}=window;return{top:0,left:0,right:a,bottom:c,width:a,height:c}}const{top:t,left:n,right:o,bottom:s}=e.getBoundingClientRect();return{top:t,left:n,right:o,bottom:s,width:e.clientWidth,height:e.clientHeight}}function Xr(e){return e.reduce((t,n)=>ft(t,Mn(n)),Te)}function Ca(e){return e.reduce((t,n)=>t+Wr(n),0)}function Sa(e){return e.reduce((t,n)=>t+Qr(n),0)}function Na(e,t){if(t===void 0&&(t=vt),!e)return;const{top:n,left:o,bottom:s,right:a}=t(e);Hr(e)&&(s<=0||a<=0||n>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const ja=[["x",["left","right"],Ca],["y",["top","bottom"],Sa]];class Yn{constructor(t,n){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 o=rn(n),s=Xr(o);this.rect={...t},this.width=t.width,this.height=t.height;for(const[a,c,l]of ja)for(const d of c)Object.defineProperty(this,d,{get:()=>{const u=l(o),p=s[a]-u;return this.rect[d]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Dt{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...n)})},this.target=t}add(t,n,o){var s;(s=this.target)==null||s.addEventListener(t,n,o),this.listeners.push([t,n,o])}}function Da(e){const{EventTarget:t}=Ce(e);return e instanceof t?e:xt(e)}function jn(e,t){const n=Math.abs(e.x),o=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+o**2)>t:"x"in t&&"y"in t?n>t.x&&o>t.y:"x"in t?n>t.x:"y"in t?o>t.y:!1}var je;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(je||(je={}));function pr(e){e.preventDefault()}function Ra(e){e.stopPropagation()}var B;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(B||(B={}));const qr={start:[B.Space,B.Enter],cancel:[B.Esc],end:[B.Space,B.Enter,B.Tab]},Ia=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case B.Right:return{...n,x:n.x+25};case B.Left:return{...n,x:n.x-25};case B.Down:return{...n,y:n.y+25};case B.Up:return{...n,y:n.y-25}}};class on{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Dt(xt(n)),this.windowListeners=new Dt(Ce(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(je.Resize,this.handleCancel),this.windowListeners.add(je.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(je.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,o=t.node.current;o&&Na(o),n(Te)}handleKeyDown(t){if(qn(t)){const{active:n,context:o,options:s}=this.props,{keyboardCodes:a=qr,coordinateGetter:c=Ia,scrollBehavior:l="smooth"}=s,{code:d}=t;if(a.end.includes(d)){this.handleEnd(t);return}if(a.cancel.includes(d)){this.handleCancel(t);return}const{collisionRect:u}=o.current,p=u?{x:u.left,y:u.top}:Te;this.referenceCoordinates||(this.referenceCoordinates=p);const f=c(t,{active:n,context:o.current,currentCoordinates:p});if(f){const m=Mt(f,p),x={x:0,y:0},{scrollableAncestors:N}=o.current;for(const h of N){const b=t.code,{isTop:C,isRight:v,isLeft:y,isBottom:I,maxScroll:T,minScroll:k}=Gr(h),D=wa(h),M={x:Math.min(b===B.Right?D.right-D.width/2:D.right,Math.max(b===B.Right?D.left:D.left+D.width/2,f.x)),y:Math.min(b===B.Down?D.bottom-D.height/2:D.bottom,Math.max(b===B.Down?D.top:D.top+D.height/2,f.y))},_=b===B.Right&&!v||b===B.Left&&!y,L=b===B.Down&&!I||b===B.Up&&!C;if(_&&M.x!==f.x){const P=h.scrollLeft+m.x,U=b===B.Right&&P<=T.x||b===B.Left&&P>=k.x;if(U&&!m.y){h.scrollTo({left:P,behavior:l});return}U?x.x=h.scrollLeft-P:x.x=b===B.Right?h.scrollLeft-T.x:h.scrollLeft-k.x,x.x&&h.scrollBy({left:-x.x,behavior:l});break}else if(L&&M.y!==f.y){const P=h.scrollTop+m.y,U=b===B.Down&&P<=T.y||b===B.Up&&P>=k.y;if(U&&!m.x){h.scrollTo({top:P,behavior:l});return}U?x.y=h.scrollTop-P:x.y=b===B.Down?h.scrollTop-T.y:h.scrollTop-k.y,x.y&&h.scrollBy({top:-x.y,behavior:l});break}}this.handleMove(t,ft(Mt(f,this.referenceCoordinates),x))}}}handleMove(t,n){const{onMove:o}=this.props;t.preventDefault(),o(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}on.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:o=qr,onActivation:s}=t,{active:a}=n;const{code:c}=e.nativeEvent;if(o.start.includes(c)){const l=a.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),s==null||s({event:e.nativeEvent}),!0)}return!1}}];function hr(e){return!!(e&&"distance"in e)}function gr(e){return!!(e&&"delay"in e)}class Jn{constructor(t,n,o){var s;o===void 0&&(o=Da(t.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=t,this.events=n;const{event:a}=t,{target:c}=a;this.props=t,this.events=n,this.document=xt(c),this.documentListeners=new Dt(this.document),this.listeners=new Dt(o),this.windowListeners=new Dt(Ce(c)),this.initialCoordinates=(s=En(a))!=null?s:Te,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:t,props:{options:{activationConstraint:n,bypassActivationConstraint:o}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(je.Resize,this.handleCancel),this.windowListeners.add(je.DragStart,pr),this.windowListeners.add(je.VisibilityChange,this.handleCancel),this.windowListeners.add(je.ContextMenu,pr),this.documentListeners.add(je.Keydown,this.handleKeydown),n){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(gr(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(hr(n)){this.handlePending(n);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(t,n){const{active:o,onPending:s}=this.props;s(o,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(je.Click,Ra,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(je.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:o,initialCoordinates:s,props:a}=this,{onMove:c,options:{activationConstraint:l}}=a;if(!s)return;const d=(n=En(t))!=null?n:Te,u=Mt(s,d);if(!o&&l){if(hr(l)){if(l.tolerance!=null&&jn(u,l.tolerance))return this.handleCancel();if(jn(u,l.distance))return this.handleStart()}if(gr(l)&&jn(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}t.cancelable&&t.preventDefault(),c(d)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===B.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Ea={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class sn extends Jn{constructor(t){const{event:n}=t,o=xt(n.target);super(t,Ea,o)}}sn.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;return!n.isPrimary||n.button!==0?!1:(o==null||o({event:n}),!0)}}];const Ta={move:{name:"mousemove"},end:{name:"mouseup"}};var kn;(function(e){e[e.RightClick=2]="RightClick"})(kn||(kn={}));class Ma extends Jn{constructor(t){super(t,Ta,xt(t.event.target))}}Ma.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;return n.button===kn.RightClick?!1:(o==null||o({event:n}),!0)}}];const Dn={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ka extends Jn{constructor(t){super(t,Dn)}static setup(){return window.addEventListener(Dn.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Dn.move.name,t)};function t(){}}}ka.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;const{touches:s}=n;return s.length>1?!1:(o==null||o({event:n}),!0)}}];var Rt;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Rt||(Rt={}));var Xt;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Xt||(Xt={}));function Aa(e){let{acceleration:t,activator:n=Rt.Pointer,canScroll:o,draggingRect:s,enabled:a,interval:c=5,order:l=Xt.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:p,delta:f,threshold:m}=e;const x=Oa({delta:f,disabled:!a}),[N,h]=Ks(),b=i.useRef({x:0,y:0}),C=i.useRef({x:0,y:0}),v=i.useMemo(()=>{switch(n){case Rt.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case Rt.DraggableRect:return s}},[n,s,d]),y=i.useRef(null),I=i.useCallback(()=>{const k=y.current;if(!k)return;const D=b.current.x*C.current.x,M=b.current.y*C.current.y;k.scrollBy(D,M)},[]),T=i.useMemo(()=>l===Xt.TreeOrder?[...u].reverse():u,[l,u]);i.useEffect(()=>{if(!a||!u.length||!v){h();return}for(const k of T){if((o==null?void 0:o(k))===!1)continue;const D=u.indexOf(k),M=p[D];if(!M)continue;const{direction:_,speed:L}=ya(k,M,v,t,m);for(const P of["x","y"])x[P][_[P]]||(L[P]=0,_[P]=0);if(L.x>0||L.y>0){h(),y.current=k,N(I,c),b.current=L,C.current=_;return}}b.current={x:0,y:0},C.current={x:0,y:0},h()},[t,I,o,h,a,c,JSON.stringify(v),JSON.stringify(x),N,u,T,p,JSON.stringify(m)])}const Pa={x:{[ce.Backward]:!1,[ce.Forward]:!1},y:{[ce.Backward]:!1,[ce.Forward]:!1}};function Oa(e){let{delta:t,disabled:n}=e;const o=In(t);return Ot(s=>{if(n||!o||!s)return Pa;const a={x:Math.sign(t.x-o.x),y:Math.sign(t.y-o.y)};return{x:{[ce.Backward]:s.x[ce.Backward]||a.x===-1,[ce.Forward]:s.x[ce.Forward]||a.x===1},y:{[ce.Backward]:s.y[ce.Backward]||a.y===-1,[ce.Forward]:s.y[ce.Forward]||a.y===1}}},[n,t,o])}function _a(e,t){const n=t!=null?e.get(t):void 0,o=n?n.node.current:null;return Ot(s=>{var a;return t==null?null:(a=o??s)!=null?a:null},[o,t])}function La(e,t){return i.useMemo(()=>e.reduce((n,o)=>{const{sensor:s}=o,a=s.activators.map(c=>({eventName:c.eventName,handler:t(c.handler,o)}));return[...n,...a]},[]),[e,t])}var kt;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(kt||(kt={}));var An;(function(e){e.Optimized="optimized"})(An||(An={}));const mr=new Map;function Fa(e,t){let{dragging:n,dependencies:o,config:s}=t;const[a,c]=i.useState(null),{frequency:l,measure:d,strategy:u}=s,p=i.useRef(e),f=b(),m=Tt(f),x=i.useCallback(function(C){C===void 0&&(C=[]),!m.current&&c(v=>v===null?C:v.concat(C.filter(y=>!v.includes(y))))},[m]),N=i.useRef(null),h=Ot(C=>{if(f&&!n)return mr;if(!C||C===mr||p.current!==e||a!=null){const v=new Map;for(let y of e){if(!y)continue;if(a&&a.length>0&&!a.includes(y.id)&&y.rect.current){v.set(y.id,y.rect.current);continue}const I=y.node.current,T=I?new Yn(d(I),I):null;y.rect.current=T,T&&v.set(y.id,T)}return v}return C},[e,a,n,f,d]);return i.useEffect(()=>{p.current=e},[e]),i.useEffect(()=>{f||x()},[n,f]),i.useEffect(()=>{a&&a.length>0&&c(null)},[JSON.stringify(a)]),i.useEffect(()=>{f||typeof l!="number"||N.current!==null||(N.current=setTimeout(()=>{x(),N.current=null},l))},[l,f,x,...o]),{droppableRects:h,measureDroppableContainers:x,measuringScheduled:a!=null};function b(){switch(u){case kt.Always:return!1;case kt.BeforeDragging:return n;default:return!n}}}function Yr(e,t){return Ot(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function za(e,t){return Yr(e,t)}function Ba(e){let{callback:t,disabled:n}=e;const o=Xn(t),s=i.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(o)},[o,n]);return i.useEffect(()=>()=>s==null?void 0:s.disconnect(),[s]),s}function an(e){let{callback:t,disabled:n}=e;const o=Xn(t),s=i.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(o)},[n]);return i.useEffect(()=>()=>s==null?void 0:s.disconnect(),[s]),s}function $a(e){return new Yn(vt(e),e)}function xr(e,t,n){t===void 0&&(t=$a);const[o,s]=i.useState(null);function a(){s(d=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=d??n)!=null?u:null}const p=t(e);return JSON.stringify(d)===JSON.stringify(p)?d:p})}const c=Ba({callback(d){if(e)for(const u of d){const{type:p,target:f}=u;if(p==="childList"&&f instanceof HTMLElement&&f.contains(e)){a();break}}}}),l=an({callback:a});return Pe(()=>{a(),e?(l==null||l.observe(e),c==null||c.observe(document.body,{childList:!0,subtree:!0})):(l==null||l.disconnect(),c==null||c.disconnect())},[e]),o}function Ua(e){const t=Yr(e);return Vr(e,t)}const vr=[];function Va(e){const t=i.useRef(e),n=Ot(o=>e?o&&o!==vr&&e&&t.current&&e.parentNode===t.current.parentNode?o:rn(e):vr,[e]);return i.useEffect(()=>{t.current=e},[e]),n}function Ha(e){const[t,n]=i.useState(null),o=i.useRef(e),s=i.useCallback(a=>{const c=Nn(a.target);c&&n(l=>l?(l.set(c,Mn(c)),new Map(l)):null)},[]);return i.useEffect(()=>{const a=o.current;if(e!==a){c(a);const l=e.map(d=>{const u=Nn(d);return u?(u.addEventListener("scroll",s,{passive:!0}),[u,Mn(u)]):null}).filter(d=>d!=null);n(l.length?new Map(l):null),o.current=e}return()=>{c(e),c(a)};function c(l){l.forEach(d=>{const u=Nn(d);u==null||u.removeEventListener("scroll",s)})}},[s,e]),i.useMemo(()=>e.length?t?Array.from(t.values()).reduce((a,c)=>ft(a,c),Te):Xr(e):Te,[e,t])}function br(e,t){t===void 0&&(t=[]);const n=i.useRef(null);return i.useEffect(()=>{n.current=null},t),i.useEffect(()=>{const o=e!==Te;o&&!n.current&&(n.current=e),!o&&n.current&&(n.current=null)},[e]),n.current?Mt(e,n.current):Te}function Wa(e){i.useEffect(()=>{if(!nn)return;const t=e.map(n=>{let{sensor:o}=n;return o.setup==null?void 0:o.setup()});return()=>{for(const n of t)n==null||n()}},e.map(t=>{let{sensor:n}=t;return n}))}function Qa(e,t){return i.useMemo(()=>e.reduce((n,o)=>{let{eventName:s,handler:a}=o;return n[s]=c=>{a(c,t)},n},{}),[e,t])}function Jr(e){return i.useMemo(()=>e?ma(e):null,[e])}const yr=[];function Ka(e,t){t===void 0&&(t=vt);const[n]=e,o=Jr(n?Ce(n):null),[s,a]=i.useState(yr);function c(){a(()=>e.length?e.map(d=>Kr(d)?o:new Yn(t(d),d)):yr)}const l=an({callback:c});return Pe(()=>{l==null||l.disconnect(),c(),e.forEach(d=>l==null?void 0:l.observe(d))},[e]),s}function Ga(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Pt(t)?t:e}function Xa(e){let{measure:t}=e;const[n,o]=i.useState(null),s=i.useCallback(u=>{for(const{target:p}of u)if(Pt(p)){o(f=>{const m=t(p);return f?{...f,width:m.width,height:m.height}:m});break}},[t]),a=an({callback:s}),c=i.useCallback(u=>{const p=Ga(u);a==null||a.disconnect(),p&&(a==null||a.observe(p)),o(p?t(p):null)},[t,a]),[l,d]=Qt(c);return i.useMemo(()=>({nodeRef:l,rect:n,setRef:d}),[n,l,d])}const qa=[{sensor:sn,options:{}},{sensor:on,options:{}}],Ya={current:{}},Vt={draggable:{measure:fr},droppable:{measure:fr,strategy:kt.WhileDragging,frequency:An.Optimized},dragOverlay:{measure:vt}};class It extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,o;return(n=(o=this.get(t))==null?void 0:o.node.current)!=null?n:void 0}}const Ja={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new It,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Kt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Vt,measureDroppableContainers:Kt,windowRect:null,measuringScheduled:!1},Za={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Kt,draggableNodes:new Map,over:null,measureDroppableContainers:Kt},ln=i.createContext(Za),Zr=i.createContext(Ja);function ei(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new It}}}function ti(e,t){switch(t.type){case se.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case se.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case se.DragEnd:case se.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case se.RegisterDroppable:{const{element:n}=t,{id:o}=n,s=new It(e.droppable.containers);return s.set(o,n),{...e,droppable:{...e.droppable,containers:s}}}case se.SetDroppableDisabled:{const{id:n,key:o,disabled:s}=t,a=e.droppable.containers.get(n);if(!a||o!==a.key)return e;const c=new It(e.droppable.containers);return c.set(n,{...a,disabled:s}),{...e,droppable:{...e.droppable,containers:c}}}case se.UnregisterDroppable:{const{id:n,key:o}=t,s=e.droppable.containers.get(n);if(!s||o!==s.key)return e;const a=new It(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function ni(e){let{disabled:t}=e;const{active:n,activatorEvent:o,draggableNodes:s}=i.useContext(ln),a=In(o),c=In(n==null?void 0:n.id);return i.useEffect(()=>{if(!t&&!o&&a&&c!=null){if(!qn(a)||document.activeElement===a.target)return;const l=s.get(c);if(!l)return;const{activatorNode:d,node:u}=l;if(!d.current&&!u.current)return;requestAnimationFrame(()=>{for(const p of[d.current,u.current]){if(!p)continue;const f=qs(p);if(f){f.focus();break}}})}},[o,t,s,c,a]),null}function ri(e,t){let{transform:n,...o}=t;return e!=null&&e.length?e.reduce((s,a)=>a({transform:s,...o}),n):n}function oi(e){return i.useMemo(()=>({draggable:{...Vt.draggable,...e==null?void 0:e.draggable},droppable:{...Vt.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Vt.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function si(e){let{activeNode:t,measure:n,initialRect:o,config:s=!0}=e;const a=i.useRef(!1),{x:c,y:l}=typeof s=="boolean"?{x:s,y:s}:s;Pe(()=>{if(!c&&!l||!t){a.current=!1;return}if(a.current||!o)return;const u=t==null?void 0:t.node.current;if(!u||u.isConnected===!1)return;const p=n(u),f=Vr(p,o);if(c||(f.x=0),l||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const m=Hr(u);m&&m.scrollBy({top:f.y,left:f.x})}},[t,c,l,o,n])}const eo=i.createContext({...Te,scaleX:1,scaleY:1});var Ve;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ve||(Ve={}));const Pn=i.memo(function(t){var n,o,s,a;let{id:c,accessibility:l,autoScroll:d=!0,children:u,sensors:p=qa,collisionDetection:f=ca,measuring:m,modifiers:x,...N}=t;const h=i.useReducer(ti,void 0,ei),[b,C]=h,[v,y]=na(),[I,T]=i.useState(Ve.Uninitialized),k=I===Ve.Initialized,{draggable:{active:D,nodes:M,translate:_},droppable:{containers:L}}=b,P=D!=null?M.get(D):null,U=i.useRef({initial:null,translated:null}),V=i.useMemo(()=>{var le;return D!=null?{id:D,data:(le=P==null?void 0:P.data)!=null?le:Ya,rect:U}:null},[D,P]),$=i.useRef(null),[W,H]=i.useState(null),[F,te]=i.useState(null),K=Tt(N,Object.values(N)),fe=_t("DndDescribedBy",c),de=i.useMemo(()=>L.getEnabled(),[L]),Y=oi(m),{droppableRects:ne,measureDroppableContainers:re,measuringScheduled:ae}=Fa(de,{dragging:k,dependencies:[_.x,_.y],config:Y.droppable}),G=_a(M,D),E=i.useMemo(()=>F?En(F):null,[F]),z=yn(),w=za(G,Y.draggable.measure);si({activeNode:D!=null?M.get(D):null,config:z.layoutShiftCompensation,initialRect:w,measure:Y.draggable.measure});const S=xr(G,Y.draggable.measure,w),A=xr(G?G.parentElement:null),O=i.useRef({activatorEvent:null,active:null,activeNode:G,collisionRect:null,collisions:null,droppableRects:ne,draggableNodes:M,draggingNode:null,draggingNodeRect:null,droppableContainers:L,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ie=L.getNodeFor((n=O.current.over)==null?void 0:n.id),Z=Xa({measure:Y.dragOverlay.measure}),be=(o=Z.nodeRef.current)!=null?o:G,Se=k?(s=Z.rect)!=null?s:S:null,ke=!!(Z.nodeRef.current&&Z.rect),lt=Ua(ke?null:S),Be=Jr(be?Ce(be):null),De=Va(k?ie??G:null),Ge=Ka(De),Xe=ri(x,{transform:{x:_.x-lt.x,y:_.y-lt.y,scaleX:1,scaleY:1},activatorEvent:F,active:V,activeNodeRect:S,containerNodeRect:A,draggingNodeRect:Se,over:O.current.over,overlayNodeRect:Z.rect,scrollableAncestors:De,scrollableAncestorRects:Ge,windowRect:Be}),Lt=E?ft(E,_):null,yt=Ha(De),Ft=br(yt),hn=br(yt,[S]),Oe=ft(Xe,Ft),_e=Se?fa(Se,Xe):null,qe=V&&_e?f({active:V,collisionRect:_e,droppableRects:ne,droppableContainers:de,pointerCoordinates:Lt}):null,wt=Ur(qe,"id"),[Re,Ct]=i.useState(null),gn=ke?Xe:ft(Xe,hn),mn=da(gn,(a=Re==null?void 0:Re.rect)!=null?a:null,S),St=i.useRef(null),zt=i.useCallback((le,pe)=>{let{sensor:he,options:Ae}=pe;if($.current==null)return;const ye=M.get($.current);if(!ye)return;const ge=le.nativeEvent,Ne=new he({active:$.current,activeNode:ye,event:ge,options:Ae,context:O,onAbort(g){if(!M.get(g))return;const{onDragAbort:j}=K.current,Q={id:g};j==null||j(Q),v({type:"onDragAbort",event:Q})},onPending(g,R,j,Q){if(!M.get(g))return;const{onDragPending:Le}=K.current,ue={id:g,constraint:R,initialCoordinates:j,offset:Q};Le==null||Le(ue),v({type:"onDragPending",event:ue})},onStart(g){const R=$.current;if(R==null)return;const j=M.get(R);if(!j)return;const{onDragStart:Q}=K.current,Ie={activatorEvent:ge,active:{id:R,data:j.data,rect:U}};et.unstable_batchedUpdates(()=>{Q==null||Q(Ie),T(Ve.Initializing),C({type:se.DragStart,initialCoordinates:g,active:R}),v({type:"onDragStart",event:Ie}),H(St.current),te(ge)})},onMove(g){C({type:se.DragMove,coordinates:g})},onEnd:$e(se.DragEnd),onCancel:$e(se.DragCancel)});St.current=Ne;function $e(g){return async function(){const{active:j,collisions:Q,over:Ie,scrollAdjustedTranslate:Le}=O.current;let ue=null;if(j&&Le){const{cancelDrop:Ye}=K.current;ue={activatorEvent:ge,active:j,collisions:Q,delta:Le,over:Ie},g===se.DragEnd&&typeof Ye=="function"&&await Promise.resolve(Ye(ue))&&(g=se.DragCancel)}$.current=null,et.unstable_batchedUpdates(()=>{C({type:g}),T(Ve.Uninitialized),Ct(null),H(null),te(null),St.current=null;const Ye=g===se.DragEnd?"onDragEnd":"onDragCancel";if(ue){const Fe=K.current[Ye];Fe==null||Fe(ue),v({type:Ye,event:ue})}})}}},[M]),xn=i.useCallback((le,pe)=>(he,Ae)=>{const ye=he.nativeEvent,ge=M.get(Ae);if($.current!==null||!ge||ye.dndKit||ye.defaultPrevented)return;const Ne={active:ge};le(he,pe.options,Ne)===!0&&(ye.dndKit={capturedBy:pe.sensor},$.current=Ae,zt(he,pe))},[M,zt]),Bt=La(p,xn);Wa(p),Pe(()=>{S&&I===Ve.Initializing&&T(Ve.Initialized)},[S,I]),i.useEffect(()=>{const{onDragMove:le}=K.current,{active:pe,activatorEvent:he,collisions:Ae,over:ye}=O.current;if(!pe||!he)return;const ge={active:pe,activatorEvent:he,collisions:Ae,delta:{x:Oe.x,y:Oe.y},over:ye};et.unstable_batchedUpdates(()=>{le==null||le(ge),v({type:"onDragMove",event:ge})})},[Oe.x,Oe.y]),i.useEffect(()=>{const{active:le,activatorEvent:pe,collisions:he,droppableContainers:Ae,scrollAdjustedTranslate:ye}=O.current;if(!le||$.current==null||!pe||!ye)return;const{onDragOver:ge}=K.current,Ne=Ae.get(wt),$e=Ne&&Ne.rect.current?{id:Ne.id,rect:Ne.rect.current,data:Ne.data,disabled:Ne.disabled}:null,g={active:le,activatorEvent:pe,collisions:he,delta:{x:ye.x,y:ye.y},over:$e};et.unstable_batchedUpdates(()=>{Ct($e),ge==null||ge(g),v({type:"onDragOver",event:g})})},[wt]),Pe(()=>{O.current={activatorEvent:F,active:V,activeNode:G,collisionRect:_e,collisions:qe,droppableRects:ne,draggableNodes:M,draggingNode:be,draggingNodeRect:Se,droppableContainers:L,over:Re,scrollableAncestors:De,scrollAdjustedTranslate:Oe},U.current={initial:Se,translated:_e}},[V,G,qe,_e,M,be,Se,ne,L,Re,De,Oe]),Aa({...z,delta:_,draggingRect:_e,pointerCoordinates:Lt,scrollableAncestors:De,scrollableAncestorRects:Ge});const vn=i.useMemo(()=>({active:V,activeNode:G,activeNodeRect:S,activatorEvent:F,collisions:qe,containerNodeRect:A,dragOverlay:Z,draggableNodes:M,droppableContainers:L,droppableRects:ne,over:Re,measureDroppableContainers:re,scrollableAncestors:De,scrollableAncestorRects:Ge,measuringConfiguration:Y,measuringScheduled:ae,windowRect:Be}),[V,G,S,F,qe,A,Z,M,L,ne,Re,re,De,Ge,Y,ae,Be]),bn=i.useMemo(()=>({activatorEvent:F,activators:Bt,active:V,activeNodeRect:S,ariaDescribedById:{draggable:fe},dispatch:C,draggableNodes:M,over:Re,measureDroppableContainers:re}),[F,Bt,V,S,C,fe,M,Re,re]);return xe.createElement(Fr.Provider,{value:y},xe.createElement(ln.Provider,{value:bn},xe.createElement(Zr.Provider,{value:vn},xe.createElement(eo.Provider,{value:mn},u)),xe.createElement(ni,{disabled:(l==null?void 0:l.restoreFocus)===!1})),xe.createElement(sa,{...l,hiddenTextDescribedById:fe}));function yn(){const le=(W==null?void 0:W.autoScrollEnabled)===!1,pe=typeof d=="object"?d.enabled===!1:d===!1,he=k&&!le&&!pe;return typeof d=="object"?{...d,enabled:he}:{enabled:he}}}),ai=i.createContext(null),wr="button",ii="Draggable";function li(e){let{id:t,data:n,disabled:o=!1,attributes:s}=e;const a=_t(ii),{activators:c,activatorEvent:l,active:d,activeNodeRect:u,ariaDescribedById:p,draggableNodes:f,over:m}=i.useContext(ln),{role:x=wr,roleDescription:N="draggable",tabIndex:h=0}=s??{},b=(d==null?void 0:d.id)===t,C=i.useContext(b?eo:ai),[v,y]=Qt(),[I,T]=Qt(),k=Qa(c,t),D=Tt(n);Pe(()=>(f.set(t,{id:t,key:a,node:v,activatorNode:I,data:D}),()=>{const _=f.get(t);_&&_.key===a&&f.delete(t)}),[f,t]);const M=i.useMemo(()=>({role:x,tabIndex:h,"aria-disabled":o,"aria-pressed":b&&x===wr?!0:void 0,"aria-roledescription":N,"aria-describedby":p.draggable}),[o,x,h,b,N,p.draggable]);return{active:d,activatorEvent:l,activeNodeRect:u,attributes:M,isDragging:b,listeners:o?void 0:k,node:v,over:m,setNodeRef:y,setActivatorNodeRef:T,transform:C}}function ci(){return i.useContext(Zr)}const di="Droppable",ui={timeout:25};function fi(e){let{data:t,disabled:n=!1,id:o,resizeObserverConfig:s}=e;const a=_t(di),{active:c,dispatch:l,over:d,measureDroppableContainers:u}=i.useContext(ln),p=i.useRef({disabled:n}),f=i.useRef(!1),m=i.useRef(null),x=i.useRef(null),{disabled:N,updateMeasurementsFor:h,timeout:b}={...ui,...s},C=Tt(h??o),v=i.useCallback(()=>{if(!f.current){f.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{u(Array.isArray(C.current)?C.current:[C.current]),x.current=null},b)},[b]),y=an({callback:v,disabled:N||!c}),I=i.useCallback((M,_)=>{y&&(_&&(y.unobserve(_),f.current=!1),M&&y.observe(M))},[y]),[T,k]=Qt(I),D=Tt(t);return i.useEffect(()=>{!y||!T.current||(y.disconnect(),f.current=!1,y.observe(T.current))},[T,y]),i.useEffect(()=>(l({type:se.RegisterDroppable,element:{id:o,key:a,disabled:n,node:T,rect:m,data:D}}),()=>l({type:se.UnregisterDroppable,key:a,id:o})),[o]),i.useEffect(()=>{n!==p.current.disabled&&(l({type:se.SetDroppableDisabled,id:o,key:a,disabled:n}),p.current.disabled=n)},[o,a,n,l]),{active:c,rect:m,isOver:(d==null?void 0:d.id)===o,node:T,over:d,setNodeRef:k}}function At(e,t,n){const o=e.slice();return o.splice(n<0?o.length+n:n,0,o.splice(t,1)[0]),o}function pi(e,t){return e.reduce((n,o,s)=>{const a=t.get(o);return a&&(n[s]=a),n},Array(e.length))}function $t(e){return e!==null&&e>=0}function hi(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function gi(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const to=e=>{let{rects:t,activeIndex:n,overIndex:o,index:s}=e;const a=At(t,o,n),c=t[s],l=a[s];return!l||!c?null:{x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height}},Ut={scaleX:1,scaleY:1},On=e=>{var t;let{activeIndex:n,activeNodeRect:o,index:s,rects:a,overIndex:c}=e;const l=(t=a[n])!=null?t:o;if(!l)return null;if(s===n){const u=a[c];return u?{x:0,y:n<c?u.top+u.height-(l.top+l.height):u.top-l.top,...Ut}:null}const d=mi(a,s,n);return s>n&&s<=c?{x:0,y:-l.height-d,...Ut}:s<n&&s>=c?{x:0,y:l.height+d,...Ut}:{x:0,y:0,...Ut}};function mi(e,t,n){const o=e[t],s=e[t-1],a=e[t+1];return o?n<t?s?o.top-(s.top+s.height):a?a.top-(o.top+o.height):0:a?a.top-(o.top+o.height):s?o.top-(s.top+s.height):0:0}const no="Sortable",ro=xe.createContext({activeIndex:-1,containerId:no,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:to,disabled:{draggable:!1,droppable:!1}});function _n(e){let{children:t,id:n,items:o,strategy:s=to,disabled:a=!1}=e;const{active:c,dragOverlay:l,droppableRects:d,over:u,measureDroppableContainers:p}=ci(),f=_t(no,n),m=l.rect!==null,x=i.useMemo(()=>o.map(k=>typeof k=="object"&&"id"in k?k.id:k),[o]),N=c!=null,h=c?x.indexOf(c.id):-1,b=u?x.indexOf(u.id):-1,C=i.useRef(x),v=!hi(x,C.current),y=b!==-1&&h===-1||v,I=gi(a);Pe(()=>{v&&N&&p(x)},[v,x,N,p]),i.useEffect(()=>{C.current=x},[x]);const T=i.useMemo(()=>({activeIndex:h,containerId:f,disabled:I,disableTransforms:y,items:x,overIndex:b,useDragOverlay:m,sortedRects:pi(x,d),strategy:s}),[h,f,I.draggable,I.droppable,y,x,b,d,m,s]);return xe.createElement(ro.Provider,{value:T},t)}const xi=e=>{let{id:t,items:n,activeIndex:o,overIndex:s}=e;return At(n,o,s).indexOf(t)},vi=e=>{let{containerId:t,isSorting:n,wasDragging:o,index:s,items:a,newIndex:c,previousItems:l,previousContainerId:d,transition:u}=e;return!u||!o||l!==a&&s===c?!1:n?!0:c!==s&&t===d},bi={duration:200,easing:"ease"},oo="transform",yi=ot.Transition.toString({property:oo,duration:0,easing:"linear"}),wi={roleDescription:"sortable"};function Ci(e){let{disabled:t,index:n,node:o,rect:s}=e;const[a,c]=i.useState(null),l=i.useRef(n);return Pe(()=>{if(!t&&n!==l.current&&o.current){const d=s.current;if(d){const u=vt(o.current,{ignoreTransform:!0}),p={x:d.left-u.left,y:d.top-u.top,scaleX:d.width/u.width,scaleY:d.height/u.height};(p.x||p.y)&&c(p)}}n!==l.current&&(l.current=n)},[t,n,o,s]),i.useEffect(()=>{a&&c(null)},[a]),a}function Zn(e){let{animateLayoutChanges:t=vi,attributes:n,disabled:o,data:s,getNewIndex:a=xi,id:c,strategy:l,resizeObserverConfig:d,transition:u=bi}=e;const{items:p,containerId:f,activeIndex:m,disabled:x,disableTransforms:N,sortedRects:h,overIndex:b,useDragOverlay:C,strategy:v}=i.useContext(ro),y=Si(o,x),I=p.indexOf(c),T=i.useMemo(()=>({sortable:{containerId:f,index:I,items:p},...s}),[f,s,I,p]),k=i.useMemo(()=>p.slice(p.indexOf(c)),[p,c]),{rect:D,node:M,isOver:_,setNodeRef:L}=fi({id:c,data:T,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...d}}),{active:P,activatorEvent:U,activeNodeRect:V,attributes:$,setNodeRef:W,listeners:H,isDragging:F,over:te,setActivatorNodeRef:K,transform:fe}=li({id:c,data:T,attributes:{...wi,...n},disabled:y.draggable}),de=Qs(L,W),Y=!!P,ne=Y&&!N&&$t(m)&&$t(b),re=!C&&F,ae=re&&ne?fe:null,E=ne?ae??(l??v)({rects:h,activeNodeRect:V,activeIndex:m,overIndex:b,index:I}):null,z=$t(m)&&$t(b)?a({id:c,items:p,activeIndex:m,overIndex:b}):I,w=P==null?void 0:P.id,S=i.useRef({activeId:w,items:p,newIndex:z,containerId:f}),A=p!==S.current.items,O=t({active:P,containerId:f,isDragging:F,isSorting:Y,id:c,index:I,items:p,newIndex:S.current.newIndex,previousItems:S.current.items,previousContainerId:S.current.containerId,transition:u,wasDragging:S.current.activeId!=null}),ie=Ci({disabled:!O,index:I,node:M,rect:D});return i.useEffect(()=>{Y&&S.current.newIndex!==z&&(S.current.newIndex=z),f!==S.current.containerId&&(S.current.containerId=f),p!==S.current.items&&(S.current.items=p)},[Y,z,f,p]),i.useEffect(()=>{if(w===S.current.activeId)return;if(w!=null&&S.current.activeId==null){S.current.activeId=w;return}const be=setTimeout(()=>{S.current.activeId=w},50);return()=>clearTimeout(be)},[w]),{active:P,activeIndex:m,attributes:$,data:T,rect:D,index:I,newIndex:z,items:p,isOver:_,isSorting:Y,isDragging:F,listeners:H,node:M,overIndex:b,over:te,setNodeRef:de,setActivatorNodeRef:K,setDroppableNodeRef:L,setDraggableNodeRef:W,transform:ie??E,transition:Z()};function Z(){if(ie||A&&S.current.newIndex===I)return yi;if(!(re&&!qn(U)||!u)&&(Y||O))return ot.Transition.toString({...u,property:oo})}}function Si(e,t){var n,o;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e==null?void 0:e.draggable)!=null?n:t.draggable,droppable:(o=e==null?void 0:e.droppable)!=null?o:t.droppable}}function qt(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const Ni=[B.Down,B.Right,B.Up,B.Left],so=(e,t)=>{let{context:{active:n,collisionRect:o,droppableRects:s,droppableContainers:a,over:c,scrollableAncestors:l}}=t;if(Ni.includes(e.code)){if(e.preventDefault(),!n||!o)return;const d=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const m=s.get(f.id);if(m)switch(e.code){case B.Down:o.top<m.top&&d.push(f);break;case B.Up:o.top>m.top&&d.push(f);break;case B.Left:o.left>m.left&&d.push(f);break;case B.Right:o.left<m.left&&d.push(f);break}});const u=ia({active:n,collisionRect:o,droppableRects:s,droppableContainers:d,pointerCoordinates:null});let p=Ur(u,"id");if(p===(c==null?void 0:c.id)&&u.length>1&&(p=u[1].id),p!=null){const f=a.get(n.id),m=a.get(p),x=m?s.get(m.id):null,N=m==null?void 0:m.node.current;if(N&&x&&f&&m){const b=rn(N).some((k,D)=>l[D]!==k),C=ao(f,m),v=ji(f,m),y=b||!C?{x:0,y:0}:{x:v?o.width-x.width:0,y:v?o.height-x.height:0},I={x:x.left,y:x.top};return y.x&&y.y?I:Mt(I,y)}}}};function ao(e,t){return!qt(e)||!qt(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function ji(e,t){return!qt(e)||!qt(t)||!ao(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function Di(e,t,n){const o={...e};return t.top+e.y<=n.top?o.y=n.top-t.top:t.bottom+e.y>=n.top+n.height&&(o.y=n.top+n.height-t.bottom),t.left+e.x<=n.left?o.x=n.left-t.left:t.right+e.x>=n.left+n.width&&(o.x=n.left+n.width-t.right),o}const Ln=e=>{let{containerNodeRect:t,draggingNodeRect:n,transform:o}=e;return!n||!t?o:Di(o,n,t)},Fn=e=>{let{transform:t}=e;return{...t,x:0}},pt=i.forwardRef(({className:e,...t},n)=>r.jsx("textarea",{className:q("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));pt.displayName="Textarea";var cn="Dialog",[io,$l]=Hn(cn),[Ri,Me]=io(cn),lo=e=>{const{__scopeDialog:t,children:n,open:o,defaultOpen:s,onOpenChange:a,modal:c=!0}=e,l=i.useRef(null),d=i.useRef(null),[u,p]=Wt({prop:o,defaultProp:s??!1,onChange:a,caller:cn});return r.jsx(Ri,{scope:t,triggerRef:l,contentRef:d,contentId:dt(),titleId:dt(),descriptionId:dt(),open:u,onOpenChange:p,onOpenToggle:i.useCallback(()=>p(f=>!f),[p]),modal:c,children:n})};lo.displayName=cn;var co="DialogTrigger",Ii=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,s=Me(co,n),a=ve(t,s.triggerRef);return r.jsx(ee.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":nr(s.open),...o,ref:a,onClick:J(e.onClick,s.onOpenToggle)})});Ii.displayName=co;var er="DialogPortal",[Ei,uo]=io(er,{forceMount:void 0}),fo=e=>{const{__scopeDialog:t,forceMount:n,children:o,container:s}=e,a=Me(er,t);return r.jsx(Ei,{scope:t,forceMount:n,children:i.Children.map(o,c=>r.jsx(en,{present:n||a.open,children:r.jsx(Nr,{asChild:!0,container:s,children:c})}))})};fo.displayName=er;var Yt="DialogOverlay",po=i.forwardRef((e,t)=>{const n=uo(Yt,e.__scopeDialog),{forceMount:o=n.forceMount,...s}=e,a=Me(Yt,e.__scopeDialog);return a.modal?r.jsx(en,{present:o||a.open,children:r.jsx(Mi,{...s,ref:t})}):null});po.displayName=Yt;var Ti=jr("DialogOverlay.RemoveScroll"),Mi=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,s=Me(Yt,n);return r.jsx(Rr,{as:Ti,allowPinchZoom:!0,shards:[s.contentRef],children:r.jsx(ee.div,{"data-state":nr(s.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),st="DialogContent",ho=i.forwardRef((e,t)=>{const n=uo(st,e.__scopeDialog),{forceMount:o=n.forceMount,...s}=e,a=Me(st,e.__scopeDialog);return r.jsx(en,{present:o||a.open,children:a.modal?r.jsx(ki,{...s,ref:t}):r.jsx(Ai,{...s,ref:t})})});ho.displayName=st;var ki=i.forwardRef((e,t)=>{const n=Me(st,e.__scopeDialog),o=i.useRef(null),s=ve(t,n.contentRef,o);return i.useEffect(()=>{const a=o.current;if(a)return Ir(a)},[]),r.jsx(go,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:J(e.onCloseAutoFocus,a=>{var c;a.preventDefault(),(c=n.triggerRef.current)==null||c.focus()}),onPointerDownOutside:J(e.onPointerDownOutside,a=>{const c=a.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0;(c.button===2||l)&&a.preventDefault()}),onFocusOutside:J(e.onFocusOutside,a=>a.preventDefault())})}),Ai=i.forwardRef((e,t)=>{const n=Me(st,e.__scopeDialog),o=i.useRef(!1),s=i.useRef(!1);return r.jsx(go,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var c,l;(c=e.onCloseAutoFocus)==null||c.call(e,a),a.defaultPrevented||(o.current||(l=n.triggerRef.current)==null||l.focus(),a.preventDefault()),o.current=!1,s.current=!1},onInteractOutside:a=>{var d,u;(d=e.onInteractOutside)==null||d.call(e,a),a.defaultPrevented||(o.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const c=a.target;((u=n.triggerRef.current)==null?void 0:u.contains(c))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})}),go=i.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,...c}=e,l=Me(st,n),d=i.useRef(null),u=ve(t,d);return Er(),r.jsxs(r.Fragment,{children:[r.jsx(Tr,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:s,onUnmountAutoFocus:a,children:r.jsx(Sr,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":nr(l.open),...c,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(Pi,{titleId:l.titleId}),r.jsx(_i,{contentRef:d,descriptionId:l.descriptionId})]})]})}),tr="DialogTitle",mo=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,s=Me(tr,n);return r.jsx(ee.h2,{id:s.titleId,...o,ref:t})});mo.displayName=tr;var xo="DialogDescription",vo=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,s=Me(xo,n);return r.jsx(ee.p,{id:s.descriptionId,...o,ref:t})});vo.displayName=xo;var bo="DialogClose",yo=i.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,s=Me(bo,n);return r.jsx(ee.button,{type:"button",...o,ref:t,onClick:J(e.onClick,()=>s.onOpenChange(!1))})});yo.displayName=bo;function nr(e){return e?"open":"closed"}var wo="DialogTitleWarning",[Ul,Co]=Ds(wo,{contentName:st,titleName:tr,docsSlug:"dialog"}),Pi=({titleId:e})=>{const t=Co(wo),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.

If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.

For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return i.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Oi="DialogDescriptionWarning",_i=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Co(Oi).contentName}}.`;return i.useEffect(()=>{var a;const s=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(o))},[o,e,t]),null},Li=lo,Fi=fo,So=po,No=ho,jo=mo,Do=vo,zi=yo;const ht=Li,Bi=Fi,Ro=i.forwardRef(({className:e,...t},n)=>r.jsx(So,{ref:n,className:q("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Ro.displayName=So.displayName;const tt=i.forwardRef(({className:e,children:t,...n},o)=>r.jsxs(Bi,{children:[r.jsx(Ro,{}),r.jsxs(No,{ref:o,className:q("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,r.jsxs(zi,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[r.jsx(Rs,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));tt.displayName=No.displayName;const nt=({className:e,...t})=>r.jsx("div",{className:q("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});nt.displayName="DialogHeader";const rt=i.forwardRef(({className:e,...t},n)=>r.jsx(jo,{ref:n,className:q("text-lg font-semibold leading-none tracking-tight",e),...t}));rt.displayName=jo.displayName;const $i=i.forwardRef(({className:e,...t},n)=>r.jsx(Do,{ref:n,className:q("text-sm text-muted-foreground",e),...t}));$i.displayName=Do.displayName;const Io=i.forwardRef(({className:e,...t},n)=>r.jsx("div",{className:"relative w-full overflow-auto",children:r.jsx("table",{ref:n,className:q("w-full caption-bottom text-sm",e),...t})}));Io.displayName="Table";const Eo=i.forwardRef(({className:e,...t},n)=>r.jsx("thead",{ref:n,className:q("[&_tr]:border-b",e),...t}));Eo.displayName="TableHeader";const To=i.forwardRef(({className:e,...t},n)=>r.jsx("tbody",{ref:n,className:q("[&_tr:last-child]:border-0",e),...t}));To.displayName="TableBody";const Ui=i.forwardRef(({className:e,...t},n)=>r.jsx("tfoot",{ref:n,className:q("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));Ui.displayName="TableFooter";const Jt=i.forwardRef(({className:e,...t},n)=>r.jsx("tr",{ref:n,className:q("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",e),...t}));Jt.displayName="TableRow";const ct=i.forwardRef(({className:e,...t},n)=>r.jsx("th",{ref:n,className:q("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));ct.displayName="TableHead";const Je=i.forwardRef(({className:e,...t},n)=>r.jsx("td",{ref:n,className:q("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));Je.displayName="TableCell";const Vi=i.forwardRef(({className:e,...t},n)=>r.jsx("caption",{ref:n,className:q("mt-4 text-sm text-muted-foreground",e),...t}));Vi.displayName="TableCaption";function Mo({section:e,onEdit:t,onDelete:n,onAddSubTopic:o,isSubTopic:s}){const{attributes:a,listeners:c,setNodeRef:l,transform:d,transition:u,isDragging:p}=Zn({id:e.id,disabled:!!s}),f={transform:ot.Transform.toString(d),transition:u,opacity:p?.5:1};return r.jsxs("div",{ref:l,style:f,className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50 transition-colors bg-background/50 border border-transparent hover:border-border",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[s?r.jsx("div",{className:"w-4 mr-0.5"}):r.jsx("button",{className:"cursor-grab active:cursor-grabbing p-0.5 rounded hover:bg-muted/80 text-muted-foreground",...a,...c,children:r.jsx(Qn,{className:"w-3 h-3"})}),r.jsx(Ar,{className:"w-3 h-3 text-muted-foreground"}),r.jsx("span",{className:"text-sm font-medium",children:e.title}),e.videoUrl&&r.jsx(Ws,{className:"w-3 h-3 text-primary"}),e.notesUrl&&r.jsx(Vs,{className:"w-3 h-3 text-accent"})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[o&&r.jsx(X,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-md",onClick:()=>o(e.id),title:"Add Sub Topic",children:r.jsx(gt,{className:"w-3 h-3"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-md",onClick:()=>t(e),children:r.jsx(tn,{className:"w-3 h-3"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-md text-destructive",onClick:()=>n(e.id),children:r.jsx(ut,{className:"w-3 h-3"})})]})]}),e.subsections&&e.subsections.length>0&&r.jsx("div",{className:"ml-6 pl-2 border-l border-muted-foreground/20 space-y-1",children:e.subsections.map(m=>r.jsx(Mo,{section:m,onEdit:t,onDelete:n,onAddSubTopic:o,isSubTopic:!0},m.id))})]})}function Hi({sections:e,onReorder:t,onEdit:n,onDelete:o,onAddSubTopic:s}){const a=zr(Gt(sn,{activationConstraint:{distance:5}}),Gt(on,{coordinateGetter:so})),c=l=>{const{active:d,over:u}=l;if(u&&d.id!==u.id){const p=e.findIndex(x=>x.id===d.id),f=e.findIndex(x=>x.id===u.id),m=At(e,p,f);t(m.map(x=>x.id))}};return r.jsx("div",{className:"flex flex-col gap-1 w-full",children:r.jsx(Pn,{sensors:a,collisionDetection:Tn,onDragEnd:c,modifiers:[Fn,Ln],children:r.jsx(_n,{items:e.map(l=>l.id),strategy:On,children:e.map(l=>r.jsx(Mo,{section:l,onEdit:n,onDelete:o,onAddSubTopic:s},l.id))})})})}function Cr(e,[t,n]){return Math.min(n,Math.max(t,e))}function ko(e){const t=i.useRef({value:e,previous:e});return i.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Wi=[" ","Enter","ArrowUp","ArrowDown"],Qi=[" ","Enter"],at="Select",[dn,un,Ki]=Is(at),[bt,Vl]=Hn(at,[Ki,Dr]),fn=Dr(),[Gi,Qe]=bt(at),[Xi,qi]=bt(at),Ao=e=>{const{__scopeSelect:t,children:n,open:o,defaultOpen:s,onOpenChange:a,value:c,defaultValue:l,onValueChange:d,dir:u,name:p,autoComplete:f,disabled:m,required:x,form:N}=e,h=fn(t),[b,C]=i.useState(null),[v,y]=i.useState(null),[I,T]=i.useState(!1),k=zs(u),[D,M]=Wt({prop:o,defaultProp:s??!1,onChange:a,caller:at}),[_,L]=Wt({prop:c,defaultProp:l,onChange:d,caller:at}),P=i.useRef(null),U=b?N||!!b.closest("form"):!0,[V,$]=i.useState(new Set),W=Array.from(V).map(H=>H.props.value).join(";");return r.jsx(Ps,{...h,children:r.jsxs(Gi,{required:x,scope:t,trigger:b,onTriggerChange:C,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:I,onValueNodeHasChildrenChange:T,contentId:dt(),value:_,onValueChange:L,open:D,onOpenChange:M,dir:k,triggerPointerDownPosRef:P,disabled:m,children:[r.jsx(dn.Provider,{scope:t,children:r.jsx(Xi,{scope:e.__scopeSelect,onNativeOptionAdd:i.useCallback(H=>{$(F=>new Set(F).add(H))},[]),onNativeOptionRemove:i.useCallback(H=>{$(F=>{const te=new Set(F);return te.delete(H),te})},[]),children:n})}),U?r.jsxs(rs,{"aria-hidden":!0,required:x,tabIndex:-1,name:p,autoComplete:f,value:_,onChange:H=>L(H.target.value),disabled:m,form:N,children:[_===void 0?r.jsx("option",{value:""}):null,Array.from(V)]},W):null]})})};Ao.displayName=at;var Po="SelectTrigger",Oo=i.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:o=!1,...s}=e,a=fn(n),c=Qe(Po,n),l=c.disabled||o,d=ve(t,c.onTriggerChange),u=un(n),p=i.useRef("touch"),[f,m,x]=ss(h=>{const b=u().filter(y=>!y.disabled),C=b.find(y=>y.value===c.value),v=as(b,h,C);v!==void 0&&c.onValueChange(v.value)}),N=h=>{l||(c.onOpenChange(!0),x()),h&&(c.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return r.jsx(Es,{asChild:!0,...a,children:r.jsx(ee.button,{type:"button",role:"combobox","aria-controls":c.contentId,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":"none",dir:c.dir,"data-state":c.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":os(c.value)?"":void 0,...s,ref:d,onClick:J(s.onClick,h=>{h.currentTarget.focus(),p.current!=="mouse"&&N(h)}),onPointerDown:J(s.onPointerDown,h=>{p.current=h.pointerType;const b=h.target;b.hasPointerCapture(h.pointerId)&&b.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(N(h),h.preventDefault())}),onKeyDown:J(s.onKeyDown,h=>{const b=f.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&m(h.key),!(b&&h.key===" ")&&Wi.includes(h.key)&&(N(),h.preventDefault())})})})});Oo.displayName=Po;var _o="SelectValue",Lo=i.forwardRef((e,t)=>{const{__scopeSelect:n,className:o,style:s,children:a,placeholder:c="",...l}=e,d=Qe(_o,n),{onValueNodeHasChildrenChange:u}=d,p=a!==void 0,f=ve(t,d.onValueNodeChange);return We(()=>{u(p)},[u,p]),r.jsx(ee.span,{...l,ref:f,style:{pointerEvents:"none"},children:os(d.value)?r.jsx(r.Fragment,{children:c}):a})});Lo.displayName=_o;var Yi="SelectIcon",Fo=i.forwardRef((e,t)=>{const{__scopeSelect:n,children:o,...s}=e;return r.jsx(ee.span,{"aria-hidden":!0,...s,ref:t,children:o||"▼"})});Fo.displayName=Yi;var Ji="SelectPortal",zo=e=>r.jsx(Nr,{asChild:!0,...e});zo.displayName=Ji;var it="SelectContent",Bo=i.forwardRef((e,t)=>{const n=Qe(it,e.__scopeSelect),[o,s]=i.useState();if(We(()=>{s(new DocumentFragment)},[]),!n.open){const a=o;return a?et.createPortal(r.jsx($o,{scope:e.__scopeSelect,children:r.jsx(dn.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),a):null}return r.jsx(Uo,{...e,ref:t})});Bo.displayName=it;var Ee=10,[$o,Ke]=bt(it),Zi="SelectContentImpl",el=jr("SelectContent.RemoveScroll"),Uo=i.forwardRef((e,t)=>{const{__scopeSelect:n,position:o="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:a,onPointerDownOutside:c,side:l,sideOffset:d,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:m,collisionPadding:x,sticky:N,hideWhenDetached:h,avoidCollisions:b,...C}=e,v=Qe(it,n),[y,I]=i.useState(null),[T,k]=i.useState(null),D=ve(t,E=>I(E)),[M,_]=i.useState(null),[L,P]=i.useState(null),U=un(n),[V,$]=i.useState(!1),W=i.useRef(!1);i.useEffect(()=>{if(y)return Ir(y)},[y]),Er();const H=i.useCallback(E=>{const[z,...w]=U().map(O=>O.ref.current),[S]=w.slice(-1),A=document.activeElement;for(const O of E)if(O===A||(O==null||O.scrollIntoView({block:"nearest"}),O===z&&T&&(T.scrollTop=0),O===S&&T&&(T.scrollTop=T.scrollHeight),O==null||O.focus(),document.activeElement!==A))return},[U,T]),F=i.useCallback(()=>H([M,y]),[H,M,y]);i.useEffect(()=>{V&&F()},[V,F]);const{onOpenChange:te,triggerPointerDownPosRef:K}=v;i.useEffect(()=>{if(y){let E={x:0,y:0};const z=S=>{var A,O;E={x:Math.abs(Math.round(S.pageX)-(((A=K.current)==null?void 0:A.x)??0)),y:Math.abs(Math.round(S.pageY)-(((O=K.current)==null?void 0:O.y)??0))}},w=S=>{E.x<=10&&E.y<=10?S.preventDefault():y.contains(S.target)||te(!1),document.removeEventListener("pointermove",z),K.current=null};return K.current!==null&&(document.addEventListener("pointermove",z),document.addEventListener("pointerup",w,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",z),document.removeEventListener("pointerup",w,{capture:!0})}}},[y,te,K]),i.useEffect(()=>{const E=()=>te(!1);return window.addEventListener("blur",E),window.addEventListener("resize",E),()=>{window.removeEventListener("blur",E),window.removeEventListener("resize",E)}},[te]);const[fe,de]=ss(E=>{const z=U().filter(A=>!A.disabled),w=z.find(A=>A.ref.current===document.activeElement),S=as(z,E,w);S&&setTimeout(()=>S.ref.current.focus())}),Y=i.useCallback((E,z,w)=>{const S=!W.current&&!w;(v.value!==void 0&&v.value===z||S)&&(_(E),S&&(W.current=!0))},[v.value]),ne=i.useCallback(()=>y==null?void 0:y.focus(),[y]),re=i.useCallback((E,z,w)=>{const S=!W.current&&!w;(v.value!==void 0&&v.value===z||S)&&P(E)},[v.value]),ae=o==="popper"?zn:Vo,G=ae===zn?{side:l,sideOffset:d,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:m,collisionPadding:x,sticky:N,hideWhenDetached:h,avoidCollisions:b}:{};return r.jsx($o,{scope:n,content:y,viewport:T,onViewportChange:k,itemRefCallback:Y,selectedItem:M,onItemLeave:ne,itemTextRefCallback:re,focusSelectedItem:F,selectedItemText:L,position:o,isPositioned:V,searchRef:fe,children:r.jsx(Rr,{as:el,allowPinchZoom:!0,children:r.jsx(Tr,{asChild:!0,trapped:v.open,onMountAutoFocus:E=>{E.preventDefault()},onUnmountAutoFocus:J(s,E=>{var z;(z=v.trigger)==null||z.focus({preventScroll:!0}),E.preventDefault()}),children:r.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:E=>E.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:r.jsx(ae,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:E=>E.preventDefault(),...C,...G,onPlaced:()=>$(!0),ref:D,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:J(C.onKeyDown,E=>{const z=E.ctrlKey||E.altKey||E.metaKey;if(E.key==="Tab"&&E.preventDefault(),!z&&E.key.length===1&&de(E.key),["ArrowUp","ArrowDown","Home","End"].includes(E.key)){let S=U().filter(A=>!A.disabled).map(A=>A.ref.current);if(["ArrowUp","End"].includes(E.key)&&(S=S.slice().reverse()),["ArrowUp","ArrowDown"].includes(E.key)){const A=E.target,O=S.indexOf(A);S=S.slice(O+1)}setTimeout(()=>H(S)),E.preventDefault()}})})})})})})});Uo.displayName=Zi;var tl="SelectItemAlignedPosition",Vo=i.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:o,...s}=e,a=Qe(it,n),c=Ke(it,n),[l,d]=i.useState(null),[u,p]=i.useState(null),f=ve(t,D=>p(D)),m=un(n),x=i.useRef(!1),N=i.useRef(!0),{viewport:h,selectedItem:b,selectedItemText:C,focusSelectedItem:v}=c,y=i.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&u&&h&&b&&C){const D=a.trigger.getBoundingClientRect(),M=u.getBoundingClientRect(),_=a.valueNode.getBoundingClientRect(),L=C.getBoundingClientRect();if(a.dir!=="rtl"){const A=L.left-M.left,O=_.left-A,ie=D.left-O,Z=D.width+ie,be=Math.max(Z,M.width),Se=window.innerWidth-Ee,ke=Cr(O,[Ee,Math.max(Ee,Se-be)]);l.style.minWidth=Z+"px",l.style.left=ke+"px"}else{const A=M.right-L.right,O=window.innerWidth-_.right-A,ie=window.innerWidth-D.right-O,Z=D.width+ie,be=Math.max(Z,M.width),Se=window.innerWidth-Ee,ke=Cr(O,[Ee,Math.max(Ee,Se-be)]);l.style.minWidth=Z+"px",l.style.right=ke+"px"}const P=m(),U=window.innerHeight-Ee*2,V=h.scrollHeight,$=window.getComputedStyle(u),W=parseInt($.borderTopWidth,10),H=parseInt($.paddingTop,10),F=parseInt($.borderBottomWidth,10),te=parseInt($.paddingBottom,10),K=W+H+V+te+F,fe=Math.min(b.offsetHeight*5,K),de=window.getComputedStyle(h),Y=parseInt(de.paddingTop,10),ne=parseInt(de.paddingBottom,10),re=D.top+D.height/2-Ee,ae=U-re,G=b.offsetHeight/2,E=b.offsetTop+G,z=W+H+E,w=K-z;if(z<=re){const A=P.length>0&&b===P[P.length-1].ref.current;l.style.bottom="0px";const O=u.clientHeight-h.offsetTop-h.offsetHeight,ie=Math.max(ae,G+(A?ne:0)+O+F),Z=z+ie;l.style.height=Z+"px"}else{const A=P.length>0&&b===P[0].ref.current;l.style.top="0px";const ie=Math.max(re,W+h.offsetTop+(A?Y:0)+G)+w;l.style.height=ie+"px",h.scrollTop=z-re+h.offsetTop}l.style.margin=`${Ee}px 0`,l.style.minHeight=fe+"px",l.style.maxHeight=U+"px",o==null||o(),requestAnimationFrame(()=>x.current=!0)}},[m,a.trigger,a.valueNode,l,u,h,b,C,a.dir,o]);We(()=>y(),[y]);const[I,T]=i.useState();We(()=>{u&&T(window.getComputedStyle(u).zIndex)},[u]);const k=i.useCallback(D=>{D&&N.current===!0&&(y(),v==null||v(),N.current=!1)},[y,v]);return r.jsx(rl,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:x,onScrollButtonChange:k,children:r.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:I},children:r.jsx(ee.div,{...s,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});Vo.displayName=tl;var nl="SelectPopperPosition",zn=i.forwardRef((e,t)=>{const{__scopeSelect:n,align:o="start",collisionPadding:s=Ee,...a}=e,c=fn(n);return r.jsx(Ts,{...c,...a,ref:t,align:o,collisionPadding:s,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});zn.displayName=nl;var[rl,rr]=bt(it,{}),Bn="SelectViewport",Ho=i.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:o,...s}=e,a=Ke(Bn,n),c=rr(Bn,n),l=ve(t,a.onViewportChange),d=i.useRef(0);return r.jsxs(r.Fragment,{children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),r.jsx(dn.Slot,{scope:n,children:r.jsx(ee.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:J(s.onScroll,u=>{const p=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:m}=c;if(m!=null&&m.current&&f){const x=Math.abs(d.current-p.scrollTop);if(x>0){const N=window.innerHeight-Ee*2,h=parseFloat(f.style.minHeight),b=parseFloat(f.style.height),C=Math.max(h,b);if(C<N){const v=C+x,y=Math.min(N,v),I=v-y;f.style.height=y+"px",f.style.bottom==="0px"&&(p.scrollTop=I>0?I:0,f.style.justifyContent="flex-end")}}}d.current=p.scrollTop})})})]})});Ho.displayName=Bn;var Wo="SelectGroup",[ol,sl]=bt(Wo),al=i.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,s=dt();return r.jsx(ol,{scope:n,id:s,children:r.jsx(ee.div,{role:"group","aria-labelledby":s,...o,ref:t})})});al.displayName=Wo;var Qo="SelectLabel",Ko=i.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,s=sl(Qo,n);return r.jsx(ee.div,{id:s.id,...o,ref:t})});Ko.displayName=Qo;var Zt="SelectItem",[il,Go]=bt(Zt),Xo=i.forwardRef((e,t)=>{const{__scopeSelect:n,value:o,disabled:s=!1,textValue:a,...c}=e,l=Qe(Zt,n),d=Ke(Zt,n),u=l.value===o,[p,f]=i.useState(a??""),[m,x]=i.useState(!1),N=ve(t,v=>{var y;return(y=d.itemRefCallback)==null?void 0:y.call(d,v,o,s)}),h=dt(),b=i.useRef("touch"),C=()=>{s||(l.onValueChange(o),l.onOpenChange(!1))};if(o==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return r.jsx(il,{scope:n,value:o,disabled:s,textId:h,isSelected:u,onItemTextChange:i.useCallback(v=>{f(y=>y||((v==null?void 0:v.textContent)??"").trim())},[]),children:r.jsx(dn.ItemSlot,{scope:n,value:o,disabled:s,textValue:p,children:r.jsx(ee.div,{role:"option","aria-labelledby":h,"data-highlighted":m?"":void 0,"aria-selected":u&&m,"data-state":u?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...c,ref:N,onFocus:J(c.onFocus,()=>x(!0)),onBlur:J(c.onBlur,()=>x(!1)),onClick:J(c.onClick,()=>{b.current!=="mouse"&&C()}),onPointerUp:J(c.onPointerUp,()=>{b.current==="mouse"&&C()}),onPointerDown:J(c.onPointerDown,v=>{b.current=v.pointerType}),onPointerMove:J(c.onPointerMove,v=>{var y;b.current=v.pointerType,s?(y=d.onItemLeave)==null||y.call(d):b.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:J(c.onPointerLeave,v=>{var y;v.currentTarget===document.activeElement&&((y=d.onItemLeave)==null||y.call(d))}),onKeyDown:J(c.onKeyDown,v=>{var I;((I=d.searchRef)==null?void 0:I.current)!==""&&v.key===" "||(Qi.includes(v.key)&&C(),v.key===" "&&v.preventDefault())})})})})});Xo.displayName=Zt;var jt="SelectItemText",qo=i.forwardRef((e,t)=>{const{__scopeSelect:n,className:o,style:s,...a}=e,c=Qe(jt,n),l=Ke(jt,n),d=Go(jt,n),u=qi(jt,n),[p,f]=i.useState(null),m=ve(t,C=>f(C),d.onItemTextChange,C=>{var v;return(v=l.itemTextRefCallback)==null?void 0:v.call(l,C,d.value,d.disabled)}),x=p==null?void 0:p.textContent,N=i.useMemo(()=>r.jsx("option",{value:d.value,disabled:d.disabled,children:x},d.value),[d.disabled,d.value,x]),{onNativeOptionAdd:h,onNativeOptionRemove:b}=u;return We(()=>(h(N),()=>b(N)),[h,b,N]),r.jsxs(r.Fragment,{children:[r.jsx(ee.span,{id:d.textId,...a,ref:m}),d.isSelected&&c.valueNode&&!c.valueNodeHasChildren?et.createPortal(a.children,c.valueNode):null]})});qo.displayName=jt;var Yo="SelectItemIndicator",Jo=i.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e;return Go(Yo,n).isSelected?r.jsx(ee.span,{"aria-hidden":!0,...o,ref:t}):null});Jo.displayName=Yo;var $n="SelectScrollUpButton",Zo=i.forwardRef((e,t)=>{const n=Ke($n,e.__scopeSelect),o=rr($n,e.__scopeSelect),[s,a]=i.useState(!1),c=ve(t,o.onScrollButtonChange);return We(()=>{if(n.viewport&&n.isPositioned){let l=function(){const u=d.scrollTop>0;a(u)};const d=n.viewport;return l(),d.addEventListener("scroll",l),()=>d.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?r.jsx(ts,{...e,ref:c,onAutoScroll:()=>{const{viewport:l,selectedItem:d}=n;l&&d&&(l.scrollTop=l.scrollTop-d.offsetHeight)}}):null});Zo.displayName=$n;var Un="SelectScrollDownButton",es=i.forwardRef((e,t)=>{const n=Ke(Un,e.__scopeSelect),o=rr(Un,e.__scopeSelect),[s,a]=i.useState(!1),c=ve(t,o.onScrollButtonChange);return We(()=>{if(n.viewport&&n.isPositioned){let l=function(){const u=d.scrollHeight-d.clientHeight,p=Math.ceil(d.scrollTop)<u;a(p)};const d=n.viewport;return l(),d.addEventListener("scroll",l),()=>d.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?r.jsx(ts,{...e,ref:c,onAutoScroll:()=>{const{viewport:l,selectedItem:d}=n;l&&d&&(l.scrollTop=l.scrollTop+d.offsetHeight)}}):null});es.displayName=Un;var ts=i.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:o,...s}=e,a=Ke("SelectScrollButton",n),c=i.useRef(null),l=un(n),d=i.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return i.useEffect(()=>()=>d(),[d]),We(()=>{var p;const u=l().find(f=>f.ref.current===document.activeElement);(p=u==null?void 0:u.ref.current)==null||p.scrollIntoView({block:"nearest"})},[l]),r.jsx(ee.div,{"aria-hidden":!0,...s,ref:t,style:{flexShrink:0,...s.style},onPointerDown:J(s.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(o,50))}),onPointerMove:J(s.onPointerMove,()=>{var u;(u=a.onItemLeave)==null||u.call(a),c.current===null&&(c.current=window.setInterval(o,50))}),onPointerLeave:J(s.onPointerLeave,()=>{d()})})}),ll="SelectSeparator",ns=i.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e;return r.jsx(ee.div,{"aria-hidden":!0,...o,ref:t})});ns.displayName=ll;var Vn="SelectArrow",cl=i.forwardRef((e,t)=>{const{__scopeSelect:n,...o}=e,s=fn(n),a=Qe(Vn,n),c=Ke(Vn,n);return a.open&&c.position==="popper"?r.jsx(Ms,{...s,...o,ref:t}):null});cl.displayName=Vn;var dl="SelectBubbleInput",rs=i.forwardRef(({__scopeSelect:e,value:t,...n},o)=>{const s=i.useRef(null),a=ve(o,s),c=ko(t);return i.useEffect(()=>{const l=s.current;if(!l)return;const d=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(c!==t&&p){const f=new Event("change",{bubbles:!0});p.call(l,t),l.dispatchEvent(f)}},[c,t]),r.jsx(ee.select,{...n,style:{...ks,...n.style},ref:a,defaultValue:t})});rs.displayName=dl;function os(e){return e===""||e===void 0}function ss(e){const t=As(e),n=i.useRef(""),o=i.useRef(0),s=i.useCallback(c=>{const l=n.current+c;t(l),function d(u){n.current=u,window.clearTimeout(o.current),u!==""&&(o.current=window.setTimeout(()=>d(""),1e3))}(l)},[t]),a=i.useCallback(()=>{n.current="",window.clearTimeout(o.current)},[]);return i.useEffect(()=>()=>window.clearTimeout(o.current),[]),[n,s,a]}function as(e,t,n){const s=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let c=ul(e,Math.max(a,0));s.length===1&&(c=c.filter(u=>u!==n));const d=c.find(u=>u.textValue.toLowerCase().startsWith(s.toLowerCase()));return d!==n?d:void 0}function ul(e,t){return e.map((n,o)=>e[(t+o)%e.length])}var fl=Ao,is=Oo,pl=Lo,hl=Fo,gl=zo,ls=Bo,ml=Ho,cs=Ko,ds=Xo,xl=qo,vl=Jo,us=Zo,fs=es,ps=ns;const bl=fl,yl=pl,hs=i.forwardRef(({className:e,children:t,...n},o)=>r.jsxs(is,{ref:o,className:q("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,r.jsx(hl,{asChild:!0,children:r.jsx(Pr,{className:"h-4 w-4 opacity-50"})})]}));hs.displayName=is.displayName;const gs=i.forwardRef(({className:e,...t},n)=>r.jsx(us,{ref:n,className:q("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Us,{className:"h-4 w-4"})}));gs.displayName=us.displayName;const ms=i.forwardRef(({className:e,...t},n)=>r.jsx(fs,{ref:n,className:q("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Pr,{className:"h-4 w-4"})}));ms.displayName=fs.displayName;const xs=i.forwardRef(({className:e,children:t,position:n="popper",...o},s)=>r.jsx(gl,{children:r.jsxs(ls,{ref:s,className:q("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...o,children:[r.jsx(gs,{}),r.jsx(ml,{className:q("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),r.jsx(ms,{})]})}));xs.displayName=ls.displayName;const wl=i.forwardRef(({className:e,...t},n)=>r.jsx(cs,{ref:n,className:q("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));wl.displayName=cs.displayName;const Ht=i.forwardRef(({className:e,children:t,...n},o)=>r.jsxs(ds,{ref:o,className:q("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...n,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(vl,{children:r.jsx(Mr,{className:"h-4 w-4"})})}),r.jsx(xl,{children:t})]}));Ht.displayName=ds.displayName;const Cl=i.forwardRef(({className:e,...t},n)=>r.jsx(ps,{ref:n,className:q("-mx-1 my-1 h-px bg-muted",e),...t}));Cl.displayName=ps.displayName;var pn="Checkbox",[Sl,Hl]=Hn(pn),[Nl,or]=Sl(pn);function jl(e){const{__scopeCheckbox:t,checked:n,children:o,defaultChecked:s,disabled:a,form:c,name:l,onCheckedChange:d,required:u,value:p="on",internal_do_not_use_render:f}=e,[m,x]=Wt({prop:n,defaultProp:s??!1,onChange:d,caller:pn}),[N,h]=i.useState(null),[b,C]=i.useState(null),v=i.useRef(!1),y=N?!!c||!!N.closest("form"):!0,I={checked:m,disabled:a,setChecked:x,control:N,setControl:h,name:l,form:c,value:p,hasConsumerStoppedPropagationRef:v,required:u,defaultChecked:He(s)?!1:s,isFormControl:y,bubbleInput:b,setBubbleInput:C};return r.jsx(Nl,{scope:t,...I,children:Dl(f)?f(I):o})}var vs="CheckboxTrigger",bs=i.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...o},s)=>{const{control:a,value:c,disabled:l,checked:d,required:u,setControl:p,setChecked:f,hasConsumerStoppedPropagationRef:m,isFormControl:x,bubbleInput:N}=or(vs,e),h=ve(s,p),b=i.useRef(d);return i.useEffect(()=>{const C=a==null?void 0:a.form;if(C){const v=()=>f(b.current);return C.addEventListener("reset",v),()=>C.removeEventListener("reset",v)}},[a,f]),r.jsx(ee.button,{type:"button",role:"checkbox","aria-checked":He(d)?"mixed":d,"aria-required":u,"data-state":Ns(d),"data-disabled":l?"":void 0,disabled:l,value:c,...o,ref:h,onKeyDown:J(t,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:J(n,C=>{f(v=>He(v)?!0:!v),N&&x&&(m.current=C.isPropagationStopped(),m.current||C.stopPropagation())})})});bs.displayName=vs;var sr=i.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:o,checked:s,defaultChecked:a,required:c,disabled:l,value:d,onCheckedChange:u,form:p,...f}=e;return r.jsx(jl,{__scopeCheckbox:n,checked:s,defaultChecked:a,disabled:l,required:c,onCheckedChange:u,name:o,form:p,value:d,internal_do_not_use_render:({isFormControl:m})=>r.jsxs(r.Fragment,{children:[r.jsx(bs,{...f,ref:t,__scopeCheckbox:n}),m&&r.jsx(Ss,{__scopeCheckbox:n})]})})});sr.displayName=pn;var ys="CheckboxIndicator",ws=i.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:o,...s}=e,a=or(ys,n);return r.jsx(en,{present:o||He(a.checked)||a.checked===!0,children:r.jsx(ee.span,{"data-state":Ns(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:t,style:{pointerEvents:"none",...e.style}})})});ws.displayName=ys;var Cs="CheckboxBubbleInput",Ss=i.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:o,hasConsumerStoppedPropagationRef:s,checked:a,defaultChecked:c,required:l,disabled:d,name:u,value:p,form:f,bubbleInput:m,setBubbleInput:x}=or(Cs,e),N=ve(n,x),h=ko(a),b=Os(o);i.useEffect(()=>{const v=m;if(!v)return;const y=window.HTMLInputElement.prototype,T=Object.getOwnPropertyDescriptor(y,"checked").set,k=!s.current;if(h!==a&&T){const D=new Event("click",{bubbles:k});v.indeterminate=He(a),T.call(v,He(a)?!1:a),v.dispatchEvent(D)}},[m,h,a,s]);const C=i.useRef(He(a)?!1:a);return r.jsx(ee.input,{type:"checkbox","aria-hidden":!0,defaultChecked:c??C.current,required:l,disabled:d,name:u,value:p,form:f,...t,tabIndex:-1,ref:N,style:{...t.style,...b,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Ss.displayName=Cs;function Dl(e){return typeof e=="function"}function He(e){return e==="indeterminate"}function Ns(e){return He(e)?"indeterminate":e?"checked":"unchecked"}const js=i.forwardRef(({className:e,...t},n)=>r.jsx(sr,{ref:n,className:q("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:r.jsx(ws,{className:q("flex items-center justify-center text-current"),children:r.jsx(Mr,{className:"h-4 w-4"})})}));js.displayName=sr.displayName;function Ue(){return`q-${Date.now()}-${Math.random().toString(36).slice(2,7)}`}function Rl({quiz:e,courseId:t,chapter:n,onSave:o,onGenerateAI:s,onDelete:a}){const[c,l]=i.useState(!1),[d,u]=i.useState((e==null?void 0:e.questions)||[]),[p,f]=i.useState((e==null?void 0:e.title)||`${n.title} Quiz`),[m,x]=i.useState(null),[N,h]=i.useState(!1),[b,C]=i.useState(!1),[v,y]=i.useState(!1),[I,T]=i.useState(!1),[k,D]=i.useState(5),[M,_]=i.useState("");i.useEffect(()=>{e?(u(e.questions||[]),f(e.title||`${n.title} Quiz`)):(u([]),f(`${n.title} Quiz`))},[e,n.title]);const[L,P]=i.useState("multiple_choice"),[U,V]=i.useState(""),[$,W]=i.useState([{id:Ue(),text:""},{id:Ue(),text:""}]),[H,F]=i.useState([]),te=()=>{x(null),P("multiple_choice"),V(""),W([{id:Ue(),text:""},{id:Ue(),text:""}]),F([]),h(!0)},K=w=>{x(w),P(w.type),V(w.question),W([...w.options]),F([...w.correctOptionIds||[]]),h(!0)},fe=w=>{P(w),F([]),w==="true_false"&&W([{id:Ue(),text:"True"},{id:Ue(),text:"False"}])},de=()=>{$.length<6&&W(w=>[...w,{id:Ue(),text:""}])},Y=w=>{W(S=>S.filter(A=>A.id!==w)),F(S=>S.filter(A=>A!==w))},ne=w=>{F(L==="multiple_select"?S=>S.includes(w)?S.filter(A=>A!==w):[...S,w]:[w])},re=()=>{const w={id:(m==null?void 0:m.id)||Ue(),type:L,question:U,options:$,correctOptionIds:H};u(m?S=>S.map(A=>A.id===w.id?w:A):S=>[...S,w]),h(!1)},ae=w=>{u(S=>S.filter(A=>A.id!==w))},G=async()=>{y(!0);const w={...e?{id:e.id}:{},chapterId:n.id,courseId:t,title:p,questions:d.map(S=>({...S,correctOptionIds:S.correctOptionIds||[]}))};try{await o(w),e||l(!1)}finally{y(!1)}},E=async()=>{C(!0),T(!1);try{const w=await s(n.id,{count:k,instructions:M});w&&w.questions&&(u(w.questions),w.title&&f(w.title))}catch(w){console.error(w)}finally{C(!1)}},z=w=>w==="multiple_choice"?"MC":w==="true_false"?"T/F":"Multi";return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs(X,{variant:"outline",size:"sm",className:"rounded-lg gap-1.5",onClick:()=>l(!0),children:[r.jsx(Ls,{className:"w-3.5 h-3.5"}),e?`Quiz (${e.questions.length}q)`:"Add Quiz"]})}),r.jsx(ht,{open:c,onOpenChange:l,children:r.jsxs(tt,{className:"glass-card sm:max-w-2xl w-[95vw] max-h-[90vh] flex flex-col p-0 overflow-hidden border-primary/20",children:[r.jsx(nt,{className:"p-6 pb-0",children:r.jsxs(rt,{className:"font-heading text-2xl",children:[e?"Edit":"Create"," Quiz — ",n.title]})}),r.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-6 custom-scrollbar",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(we,{children:"Quiz Title"}),r.jsx(Ze,{value:p,onChange:w=>f(w.target.value),placeholder:"Chapter quiz title"})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("h4",{className:"font-heading font-semibold text-sm",children:["Questions (",d.length,")"]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(X,{variant:"outline",size:"sm",className:"rounded-lg gap-1.5",onClick:()=>T(!0),disabled:b,children:[r.jsx(lr,{className:q("w-3.5 h-3.5",b&&"animate-spin")}),b?"Generating...":"AI Generate"]}),r.jsxs(X,{variant:"outline",size:"sm",className:"rounded-lg gap-1.5",onClick:te,children:[r.jsx(gt,{className:"w-3.5 h-3.5"})," Add Manually"]})]})]}),d.length===0&&r.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No questions yet. Add manually or generate with AI."}),r.jsx("div",{className:"space-y-2",children:d.map((w,S)=>r.jsxs(Nt.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},className:"flex items-center gap-3 p-3 rounded-xl bg-muted/50 group",children:[r.jsxs("span",{className:"text-xs text-muted-foreground font-mono w-6",children:[S+1,"."]}),r.jsx(Et,{variant:"secondary",className:"rounded-md text-[10px]",children:z(w.type)}),r.jsx("span",{className:"text-sm truncate flex-1",children:w.question}),r.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[r.jsx(X,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-md",onClick:()=>K(w),children:r.jsx(tn,{className:"w-3 h-3"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-md text-destructive",onClick:()=>ae(w.id),children:r.jsx(ut,{className:"w-3 h-3"})})]})]},w.id))})]})}),r.jsx("div",{className:"p-6 pt-0 mt-auto",children:r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{onClick:G,disabled:d.length===0||!p||v,className:"flex-1 h-12 rounded-xl gradient-primary text-primary-foreground border-0 shadow-glow font-semibold text-base transition-all hover:scale-[1.02] active:scale-[0.98]",children:v?"Saving...":e?"Update Quiz":"Create Quiz"}),e&&r.jsx(X,{variant:"outline",className:"h-12 rounded-xl text-destructive px-4 border-destructive/20 hover:bg-destructive/5",onClick:()=>{a(),l(!1)},children:r.jsx(ut,{className:"w-5 h-5"})})]})}),b&&r.jsxs("div",{className:"absolute inset-0 z-50 flex flex-col items-center justify-center bg-background/60 backdrop-blur-sm rounded-lg",children:[r.jsx(lr,{className:"w-12 h-12 text-primary animate-pulse mb-4"}),r.jsx("p",{className:"font-heading text-lg font-semibold animate-pulse",children:"AI is crafting your quiz..."}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"This may take a moment"})]})]})}),r.jsx(ht,{open:N,onOpenChange:h,children:r.jsxs(tt,{className:"glass-card sm:max-w-lg w-[95vw] max-h-[85vh] flex flex-col p-0 overflow-hidden border-primary/20",children:[r.jsx(nt,{className:"p-6 pb-0",children:r.jsxs(rt,{className:"font-heading text-xl",children:[m?"Edit":"Add"," Question"]})}),r.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-6 custom-scrollbar",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(we,{children:"Question Type"}),r.jsxs(bl,{value:L,onValueChange:w=>fe(w),children:[r.jsx(hs,{className:"rounded-lg",children:r.jsx(yl,{})}),r.jsxs(xs,{children:[r.jsx(Ht,{value:"multiple_choice",children:"Multiple Choice"}),r.jsx(Ht,{value:"true_false",children:"True / False"}),r.jsx(Ht,{value:"multiple_select",children:"Multiple Select"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(we,{children:"Question Text"}),r.jsx(pt,{value:U,onChange:w=>V(w.target.value),placeholder:"Enter your question...",rows:3})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(we,{children:["Options (check correct answer",L==="multiple_select"?"s":"",")"]}),L!=="true_false"&&$.length<6&&r.jsxs(X,{variant:"ghost",size:"sm",className:"rounded-lg gap-1 text-xs",onClick:de,children:[r.jsx(gt,{className:"w-3 h-3"})," Add Option"]})]}),r.jsx("div",{className:"space-y-2",children:$.map((w,S)=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(js,{checked:H.includes(w.id),onCheckedChange:()=>ne(w.id),className:"rounded"}),r.jsx(Ze,{value:w.text,onChange:A=>{const O=A.target.value;W(ie=>ie.map(Z=>Z.id===w.id?{...Z,text:O}:Z))},placeholder:`Option ${S+1}`,disabled:L==="true_false",className:"flex-1"}),L!=="true_false"&&$.length>2&&r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-md text-destructive",onClick:()=>Y(w.id),children:r.jsx(ut,{className:"w-3 h-3"})})]},w.id))})]})]})}),r.jsx("div",{className:"p-6 pt-0 mt-auto",children:r.jsx(X,{onClick:re,disabled:!U||$.some(w=>!w.text)||H.length===0,className:"w-full h-12 rounded-xl gradient-primary text-primary-foreground border-0 shadow-glow font-semibold transition-all hover:scale-[1.02] active:scale-[0.98]",children:m?"Update Question":"Add Question"})})]})}),r.jsx(ht,{open:I,onOpenChange:T,children:r.jsxs(tt,{className:"glass-card sm:max-w-md w-[95vw] border-primary/20 p-6",children:[r.jsx(nt,{children:r.jsx(rt,{className:"font-heading text-xl",children:"AI Quiz Settings"})}),r.jsxs("div",{className:"space-y-6 pt-4",children:[r.jsxs("div",{className:"space-y-3",children:[r.jsxs(we,{className:"flex justify-between",children:[r.jsx("span",{children:"Number of Questions"}),r.jsx("span",{className:"text-primary font-bold",children:k})]}),r.jsx("input",{type:"range",min:"3",max:"15",step:"1",value:k,onChange:w=>D(parseInt(w.target.value)),className:"w-full h-2 bg-muted rounded-lg appearance-none cursor-pointer accent-primary"}),r.jsxs("div",{className:"flex justify-between text-[10px] text-muted-foreground px-1",children:[r.jsx("span",{children:"3"}),r.jsx("span",{children:"5"}),r.jsx("span",{children:"10"}),r.jsx("span",{children:"15"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(we,{children:"Custom Instructions (Optional)"}),r.jsx(pt,{value:M,onChange:w=>_(w.target.value),placeholder:"e.g. Focus on word problems, make it difficult, use humor...",rows:4,className:"resize-none"})]}),r.jsx(X,{onClick:E,className:"w-full h-12 rounded-xl gradient-primary text-primary-foreground border-0 shadow-glow font-semibold transition-all hover:scale-[1.02] active:scale-[0.98]",children:"Generate Quiz"})]})]})})]})}function Il({chapter:e,courseId:t,isExpanded:n,onToggle:o,onEdit:s,onDelete:a,onAddSection:c,onAddSubTopic:l,onEditSection:d,onDeleteSection:u,onReorderSections:p,quiz:f,onSaveQuiz:m,onDeleteQuiz:x,onGenerateAIQuiz:N}){const{attributes:h,listeners:b,setNodeRef:C,transform:v,transition:y,isDragging:I}=Zn({id:e.id}),T={transform:ot.Transform.toString(v),transition:y,opacity:I?.5:1,zIndex:I?10:void 0};return r.jsxs("div",{ref:C,style:T,className:"glass-card rounded-xl overflow-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-1",onClick:o,children:[r.jsx("button",{className:"cursor-grab active:cursor-grabbing p-0.5 rounded hover:bg-muted/80 text-muted-foreground",...h,...b,onClick:k=>k.stopPropagation(),children:r.jsx(Qn,{className:"w-3.5 h-3.5"})}),r.jsx(kr,{className:`w-3 h-3 transition-transform ${n?"rotate-90":""}`}),r.jsx(Wn,{className:"w-4 h-4 text-accent"}),r.jsx("span",{className:"font-medium text-sm",children:e.title}),r.jsxs(Et,{variant:"secondary",className:"rounded-md text-xs",children:[e.sections.length," sections"]}),f&&r.jsxs(Et,{variant:"secondary",className:"rounded-md text-xs bg-primary/10 text-primary",children:[f.questions.length,"q quiz"]})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(X,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-md",onClick:s,children:r.jsx(tn,{className:"w-3 h-3"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-md text-destructive",onClick:a,children:r.jsx(ut,{className:"w-3 h-3"})})]})]}),n&&r.jsxs("div",{className:"border-t p-3 space-y-3 bg-background/50",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Sections"}),r.jsxs(X,{size:"sm",variant:"outline",className:"rounded-lg gap-1 h-7 text-xs",onClick:c,children:[r.jsx(gt,{className:"w-3 h-3"})," Add Section"]})]}),e.sections.length===0&&r.jsx("p",{className:"text-xs text-muted-foreground",children:"No sections yet."}),e.sections.length>0&&r.jsx(Hi,{sections:e.sections,onReorder:p,onEdit:d,onDelete:u,onAddSubTopic:l}),r.jsx("div",{className:"pt-2 border-t",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Chapter Quiz"}),r.jsx(Rl,{quiz:f,courseId:t,chapter:e,onSave:m,onGenerateAI:N,onDelete:x})]})})]})]})}function El({course:e,isExpanded:t,onToggle:n,onEdit:o,onDelete:s,expandedContent:a}){const{attributes:c,listeners:l,setNodeRef:d,transform:u,transition:p,isDragging:f}=Zn({id:e.id}),m={transform:ot.Transform.toString(u),transition:p,opacity:f?.5:1,zIndex:f?20:void 0},x=e.chapters.reduce((N,h)=>N+h.sections.length,0);return r.jsxs(xe.Fragment,{children:[r.jsxs(Jt,{ref:d,style:m,className:`group cursor-pointer ${f?"bg-muted":""}`,onClick:n,children:[r.jsx(Je,{children:r.jsx("button",{className:"cursor-grab active:cursor-grabbing p-1 rounded hover:bg-muted/80 text-muted-foreground",...c,...l,onClick:N=>N.stopPropagation(),children:r.jsx(Qn,{className:"w-4 h-4"})})}),r.jsx(Je,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(kr,{className:`w-4 h-4 transition-transform ${t?"rotate-90":""}`}),r.jsx("div",{className:"w-9 h-9 rounded-lg gradient-primary flex items-center justify-center shadow-glow",children:r.jsx(Or,{className:"w-4 h-4 text-primary-foreground"})}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:e.title}),r.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:e.description})]})]})}),r.jsx(Je,{children:r.jsxs(Et,{variant:"secondary",className:"rounded-lg",children:[r.jsx(Wn,{className:"w-3 h-3 mr-1"})," ",e.chapters.length]})}),r.jsx(Je,{children:r.jsx(Et,{variant:"secondary",className:"rounded-lg",children:x})}),r.jsx(Je,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:N=>N.stopPropagation(),children:[r.jsx(X,{variant:"ghost",size:"icon",className:"rounded-lg",onClick:o,children:r.jsx(tn,{className:"w-4 h-4"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"rounded-lg text-destructive",onClick:s,children:r.jsx(ut,{className:"w-4 h-4"})})]})})]}),t&&r.jsx(Jt,{children:r.jsx(Je,{colSpan:5,className:"p-0 border-b-0",children:a})})]})}const Tl={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.08}}},Rn={hidden:{opacity:0,y:20},show:{opacity:1,y:0,transition:{duration:.5}}};function Wl(){const e=_s(),t=()=>e.invalidateQueries({queryKey:["courses"]}),{data:n,isLoading:o}=ar({queryKey:["courses"],queryFn:oe.getCourses}),{data:s,isLoading:a}=ar({queryKey:["quizzes"],queryFn:async()=>{const g=n||[];return(await Promise.all(g.map(j=>oe.getQuizzesByCourse(j.id)))).flat()},enabled:!!n}),[c,l]=i.useState(!1),[d,u]=i.useState("create"),[p,f]=i.useState(null),[m,x]=i.useState(""),[N,h]=i.useState(""),[b,C]=i.useState(!1),[v,y]=i.useState("create"),[I,T]=i.useState(null),[k,D]=i.useState(""),[M,_]=i.useState(""),[L,P]=i.useState(!1),[U,V]=i.useState("create"),[$,W]=i.useState(null),[H,F]=i.useState(""),[te,K]=i.useState(""),[fe,de]=i.useState(""),[Y,ne]=i.useState(""),[re,ae]=i.useState(""),[G,E]=i.useState(null),[z,w]=i.useState(""),[S,A]=i.useState(null),[O,ie]=i.useState(null),[Z,be]=i.useState(null),[Se,ke]=i.useState(null),[lt,Be]=i.useState(!1),De=zr(Gt(sn,{activationConstraint:{distance:5}}),Gt(on,{coordinateGetter:so})),Ge=me({mutationFn:()=>oe.createCourse({title:m,description:N}),onSuccess:()=>{t(),l(!1)}}),Xe=me({mutationFn:()=>oe.updateCourse(p.id,{title:m,description:N}),onSuccess:()=>{t(),l(!1)}}),Lt=me({mutationFn:oe.deleteCourse,onSuccess:t}),yt=me({mutationFn:()=>{var g;return oe.addChapter(M,{title:k,orderIndex:(((g=n==null?void 0:n.find(R=>R.id===M))==null?void 0:g.chapters.length)||0)+1,isPublished:!0})},onSuccess:()=>{t(),C(!1)}}),Ft=me({mutationFn:()=>oe.updateChapter(I.id,{title:k}),onSuccess:()=>{t(),C(!1)}}),hn=me({mutationFn:g=>oe.deleteChapter(g.chapterId),onSuccess:t}),Oe=me({mutationFn:async()=>{const g=Se||Math.random().toString(36).substring(2,14);let R=re;if(G){Be(!0);try{const j=new FormData;j.append("files",G);const Q=await oe.uploadSectionFiles(g,j);Q&&Q.files&&Q.files.length>0&&(R=Q.files[0].filePath)}finally{Be(!1)}}return oe.addSection(z,{id:g,title:H,type:"text",content:fe,description:te,videoUrl:Y,notesUrl:R,orderIndex:0,isPublished:!0},Z||void 0)},onSuccess:()=>{t(),P(!1),be(null),ke(null),E(null)}}),_e=me({mutationFn:async()=>{let g=re;if(G){Be(!0);try{const R=new FormData;R.append("files",G);const j=await oe.uploadSectionFiles($.id,R);j&&j.files&&j.files.length>0&&(g=j.files[0].filePath)}finally{Be(!1)}}return oe.updateSection($.id,{title:H,content:fe,description:te,videoUrl:Y,notesUrl:g})},onSuccess:()=>{t(),P(!1),E(null)}}),qe=me({mutationFn:g=>oe.deleteSection(g.sectionId),onSuccess:t}),wt=me({mutationFn:g=>oe.reorderCourses(g),onSuccess:t}),Re=me({mutationFn:g=>oe.reorderChapters(g.chapterIds),onSuccess:t}),Ct=me({mutationFn:g=>oe.reorderSections(g.sectionIds),onSuccess:t}),gn=me({mutationFn:g=>oe.saveQuiz(g),onSuccess:()=>{t(),e.invalidateQueries({queryKey:["quizzes"]})}}),mn=me({mutationFn:g=>oe.generateAiQuiz(g.chapterId,g.count,g.instructions),onSuccess:()=>{t(),e.invalidateQueries({queryKey:["quizzes"]})}}),St=me({mutationFn:g=>oe.deleteQuiz(g),onSuccess:()=>{t(),e.invalidateQueries({queryKey:["quizzes"]})}}),zt=()=>{u("create"),x(""),h(""),f(null),l(!0)},xn=g=>{u("edit"),x(g.title),h(g.description),f(g),l(!0)},Bt=g=>{y("create"),D(""),T(null),_(g),C(!0)},vn=(g,R)=>{y("edit"),D(R.title),T(R),_(g),C(!0)},bn=(g,R)=>{V("create"),F(""),K(""),de(""),ne(""),ae(""),W(null),E(null),_(g),w(R),be(null),ke(Math.random().toString(36).substring(2,14)),P(!0)},yn=(g,R,j)=>{V("create"),F(""),K(""),de(""),ne(""),ae(""),W(null),E(null),_(g),w(R),be(j),ke(Math.random().toString(36).substring(2,14)),P(!0)},le=(g,R,j)=>{V("edit"),F(j.title),K(j.description||""),de(j.content||""),ne(j.videoUrl||""),ae(j.notesUrl||""),W(j),E(null),_(g),w(R),P(!0)},pe=g=>{var j;const R=(j=g.target.files)==null?void 0:j[0];R&&(E(R),ae(R.name))},he=g=>{const{active:R,over:j}=g;if(j&&R.id!==j.id&&n){const Q=n.findIndex(ue=>ue.id===R.id),Ie=n.findIndex(ue=>ue.id===j.id),Le=At(n,Q,Ie);wt.mutate(Le.map(ue=>ue.id))}},Ae=(g,R)=>j=>{const{active:Q,over:Ie}=j;if(Ie&&Q.id!==Ie.id){const Le=R.findIndex(Fe=>Fe.id===Q.id),ue=R.findIndex(Fe=>Fe.id===Ie.id),Ye=At(R,Le,ue);Re.mutate({chapterIds:Ye.map(Fe=>Fe.id)})}},ye=(n==null?void 0:n.reduce((g,R)=>g+R.chapters.length,0))??0,ge=(n==null?void 0:n.reduce((g,R)=>g+R.chapters.reduce((j,Q)=>j+Q.sections.length,0),0))??0,Ne=wt.isPending||Re.isPending||Ct.isPending,$e=o||a||Ne;return r.jsxs(Fs,{children:[$e&&r.jsx("div",{className:"fixed inset-0 z-[100] bg-background/50 backdrop-blur-sm flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-4 glass-card p-6 rounded-2xl shadow-glow",children:[r.jsx(ir,{className:"w-10 h-10 animate-spin text-primary"}),r.jsx("p",{className:"text-foreground font-medium",children:Ne?"Saving order...":"Loading data..."})]})}),r.jsx("div",{className:"container max-w-6xl mx-auto px-4 relative",children:r.jsxs(Nt.div,{variants:Tl,initial:"hidden",animate:"show",children:[r.jsxs(Nt.div,{variants:Rn,className:"flex items-center justify-between mb-8",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"font-heading text-4xl font-bold mb-2",children:"Admin Dashboard"}),r.jsx("p",{className:"text-muted-foreground",children:"Manage courses, chapters, and sections"})]}),r.jsxs(X,{onClick:zt,className:"rounded-xl gradient-primary text-primary-foreground border-0 shadow-glow",children:[r.jsx(gt,{className:"w-4 h-4 mr-2"})," New Course"]})]}),r.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 mb-8",children:[{icon:Or,label:"Courses",value:(n==null?void 0:n.length)??0,color:"text-primary"},{icon:Wn,label:"Chapters",value:ye,color:"text-accent"},{icon:Ar,label:"Sections",value:ge,color:"text-success"}].map(g=>r.jsxs(Nt.div,{variants:Rn,whileHover:{y:-4},className:"glass-card-interactive rounded-2xl p-6",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(g.icon,{className:`w-5 h-5 ${g.color}`}),r.jsx("span",{className:"text-sm text-muted-foreground",children:g.label})]}),r.jsx("p",{className:"font-heading text-3xl font-bold",children:g.value})]},g.label))}),r.jsx(Nt.div,{variants:Rn,className:"glass-card rounded-2xl overflow-hidden",children:r.jsx(Pn,{sensors:De,collisionDetection:Tn,onDragEnd:he,modifiers:[Fn,Ln],children:r.jsxs(Io,{children:[r.jsx(Eo,{children:r.jsxs(Jt,{children:[r.jsx(ct,{className:"w-10"}),r.jsx(ct,{children:"Course"}),r.jsx(ct,{children:"Chapters"}),r.jsx(ct,{children:"Sections"}),r.jsx(ct,{className:"text-right",children:"Actions"})]})}),r.jsx(_n,{items:(n==null?void 0:n.map(g=>g.id))||[],strategy:On,children:r.jsx(To,{children:n==null?void 0:n.map(g=>r.jsx(El,{course:g,isExpanded:S===g.id,onToggle:()=>A(S===g.id?null:g.id),onEdit:()=>xn(g),onDelete:()=>Lt.mutate(g.id),expandedContent:r.jsxs("div",{className:"bg-muted/30 p-4 space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("h3",{className:"font-heading font-semibold text-sm",children:["Chapters",r.jsx("span",{className:"text-xs font-normal text-muted-foreground ml-2",children:"Drag to reorder"})]}),r.jsxs(X,{size:"sm",variant:"outline",className:"rounded-lg gap-1",onClick:()=>Bt(g.id),children:[r.jsx(gt,{className:"w-3 h-3"})," Add Chapter"]})]}),g.chapters.length===0&&r.jsx("p",{className:"text-sm text-muted-foreground",children:"No chapters yet."}),g.chapters.length>0&&r.jsx(Pn,{sensors:De,collisionDetection:Tn,onDragEnd:Ae(g.id,g.chapters),modifiers:[Fn,Ln],children:r.jsx(_n,{items:g.chapters.map(R=>R.id),strategy:On,children:g.chapters.map(R=>r.jsx(Il,{chapter:R,courseId:g.id,isExpanded:O===R.id,onToggle:()=>ie(O===R.id?null:R.id),onEdit:()=>vn(g.id,R),onDelete:()=>hn.mutate({chapterId:R.id}),onAddSection:()=>bn(g.id,R.id),onAddSubTopic:j=>yn(g.id,R.id,j),onEditSection:j=>le(g.id,R.id,j),onDeleteSection:j=>qe.mutate({sectionId:j}),onReorderSections:j=>Ct.mutate({sectionIds:j}),quiz:s==null?void 0:s.find(j=>j.chapterId===R.id&&j.courseId===g.id),onSaveQuiz:j=>gn.mutate(j),onGenerateAIQuiz:(j,Q)=>mn.mutateAsync({chapterId:j,...Q}),onDeleteQuiz:()=>{const j=s==null?void 0:s.find(Q=>Q.chapterId===R.id&&Q.courseId===g.id);j&&St.mutate(j.id)}},R.id))})})]})},g.id))})})]})})})]})}),r.jsx(ht,{open:c,onOpenChange:l,children:r.jsxs(tt,{className:"glass-card",children:[r.jsx(nt,{children:r.jsx(rt,{className:"font-heading",children:d==="create"?"Create New Course":"Edit Course"})}),r.jsxs("div",{className:"space-y-4 pt-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(we,{children:"Title"}),r.jsx(Ze,{value:m,onChange:g=>x(g.target.value),placeholder:"Course title"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(we,{children:"Description"}),r.jsx(pt,{value:N,onChange:g=>h(g.target.value),placeholder:"Course description"})]}),r.jsx(X,{onClick:()=>d==="create"?Ge.mutate():Xe.mutate(),disabled:!m||Ge.isPending||Xe.isPending,className:"w-full rounded-xl gradient-primary text-primary-foreground border-0 shadow-glow",children:d==="create"?"Create Course":"Save Changes"})]})]})}),r.jsx(ht,{open:b,onOpenChange:C,children:r.jsxs(tt,{className:"glass-card",children:[r.jsx(nt,{children:r.jsx(rt,{className:"font-heading",children:v==="create"?"Add Chapter":"Edit Chapter"})}),r.jsxs("div",{className:"space-y-4 pt-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(we,{children:"Title"}),r.jsx(Ze,{value:k,onChange:g=>D(g.target.value),placeholder:"Chapter title"})]}),r.jsx(X,{onClick:()=>v==="create"?yt.mutate():Ft.mutate(),disabled:!k||yt.isPending||Ft.isPending,className:"w-full rounded-xl gradient-primary text-primary-foreground border-0 shadow-glow",children:v==="create"?"Add Chapter":"Save Changes"})]})]})}),r.jsx(ht,{open:L,onOpenChange:P,children:r.jsxs(tt,{className:"glass-card sm:max-w-2xl max-h-[85vh] overflow-y-auto",children:[r.jsx(nt,{children:r.jsx(rt,{className:"font-heading",children:U==="create"?"Add Section":"Edit Section"})}),r.jsxs(Bs,{defaultValue:"general",className:"pt-2",children:[r.jsxs($s,{className:"w-full rounded-lg mb-4",children:[r.jsx(wn,{value:"general",className:"rounded-md flex-1",children:"General"}),r.jsx(wn,{value:"content",className:"rounded-md flex-1",children:"Content"}),r.jsx(wn,{value:"media",className:"rounded-md flex-1",children:"Media"})]}),r.jsxs(Cn,{value:"general",className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(we,{children:"Title"}),r.jsx(Ze,{value:H,onChange:g=>F(g.target.value),placeholder:"Section title"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(we,{children:"Description"}),r.jsx(pt,{value:te,onChange:g=>K(g.target.value),placeholder:"Brief description",rows:3})]})]}),r.jsx(Cn,{value:"content",className:"space-y-4",children:r.jsxs("div",{className:"space-y-2",children:[r.jsx(we,{children:"Content (supports LaTeX with $$ delimiters)"}),r.jsx(pt,{value:fe,onChange:g=>de(g.target.value),placeholder:`Write content here...

Use $$ for block math:
$$x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}$$

Use $ for inline math: $x^2$`,rows:12,className:"font-mono text-sm"})]})}),r.jsxs(Cn,{value:"media",className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(we,{children:"Video URL"}),r.jsx(Ze,{value:Y,onChange:g=>ne(g.target.value),placeholder:"https://www.youtube.com/embed/..."}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Use YouTube embed URLs"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(we,{children:"Notes PDF"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ze,{value:re,onChange:g=>ae(g.target.value),placeholder:"https://example.com/notes.pdf",className:"flex-1"}),($||Se)&&r.jsxs("div",{className:"relative",children:[r.jsx("input",{type:"file",accept:".pdf",onChange:pe,className:"absolute inset-0 opacity-0 cursor-pointer w-full",disabled:lt}),r.jsx(X,{variant:"outline",size:"icon",className:"h-10 w-10 shrink-0",disabled:lt,children:lt?r.jsx(ir,{className:"w-4 h-4 animate-spin"}):r.jsx(Hs,{className:"w-4 h-4"})})]})]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Direct link to a PDF file or upload from your device (available after creating section)"})]})]})]}),r.jsx(X,{onClick:()=>U==="create"?Oe.mutate():_e.mutate(),disabled:!H||Oe.isPending||_e.isPending,className:"w-full rounded-xl gradient-primary text-primary-foreground border-0 shadow-glow mt-4",children:U==="create"?"Add Section":"Save Changes"})]})})]})}export{Wl as default};
