import{r as j,j as s,bm as f,cs as g,T as v}from"./vendor-BKmmeuxg.js";import{I as w}from"./input-error-LaPr_4wd.js";import{B as a}from"./button-BpNwv2aE.js";import{I}from"./input-DM0goJrn.js";import{L as c}from"./label-HmIcv5Yx.js";import"./utils-DxSsnXxD.js";import"./index-WW_1X1qx.js";const L=({data:h,setData:n,errors:p})=>{var l;const o=((l=h.options)==null?void 0:l.items)||[];j.useEffect(()=>{o.length===0&&n("options",{items:["","",""]})},[]);const d=()=>{const t=[...o,""];n("options",{items:t})},u=t=>{const e=o.filter((r,m)=>m!==t);n("options",{items:e})},x=(t,e)=>{const r=[...o];r[t]=e,n("options",{items:r})},i=(t,e)=>{if(e==="up"&&t===0||e==="down"&&t===o.length-1)return;const r=[...o],m=e==="up"?t-1:t+1;[r[t],r[m]]=[r[m],r[t]],n("options",{items:r})};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(c,{children:"Instructions"}),s.jsxs("div",{className:"p-3 bg-blue-50 rounded-md text-sm text-blue-900",children:[s.jsx("p",{className:"font-medium mb-1",children:"How ordering questions work:"}),s.jsx("p",{children:"1. List the items in the correct order below"}),s.jsx("p",{children:"2. The system will shuffle them for students"}),s.jsx("p",{children:"3. Students must arrange them in the correct order"})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(c,{children:"Items (in correct order) *"}),s.jsxs(a,{type:"button",variant:"outline",size:"sm",onClick:d,children:[s.jsx(f,{className:"h-4 w-4"}),"Add Item"]})]}),o.map((t,e)=>s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(a,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(e,"up"),disabled:e===0,className:"h-5 w-8 p-0 text-gray-400 hover:text-gray-600",children:"▲"}),s.jsx(a,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(e,"down"),disabled:e===o.length-1,className:"h-5 w-8 p-0 text-gray-400 hover:text-gray-600",children:"▼"})]}),s.jsx(g,{className:"h-5 w-5 text-gray-400"}),s.jsxs("span",{className:"text-sm font-medium text-gray-500 w-8",children:[e+1,"."]}),s.jsx("div",{className:"flex-1",children:s.jsx(I,{placeholder:`Item ${e+1}`,value:t,onChange:r=>x(e,r.target.value)})}),o.length>2&&s.jsx(a,{type:"button",variant:"ghost",size:"sm",onClick:()=>u(e),className:"text-red-600",children:s.jsx(v,{className:"h-4 w-4"})})]},e))]}),s.jsx(w,{message:p.options})]})};export{L as default};