import{r as p,j as e,c1 as h,b8 as x,v as j}from"./vendor-BKmmeuxg.js";import{B as a}from"./button-BpNwv2aE.js";import N from"./resource-form-BCcyGRWo.js";import"./index-WW_1X1qx.js";import"./utils-DxSsnXxD.js";import"./chunked-uploader-input-D0XPVOTS.js";import"./input-DM0goJrn.js";import"./index-D9-QKOod.js";import"./input-error-LaPr_4wd.js";import"./loading-button-BnTVAMJ7.js";import"./label-HmIcv5Yx.js";import"./select-CD9o3HN1.js";import"./file-metadata-CAFSN-Sn.js";import"./inertia-SZXqLvQm.js";const R=({lesson:i,isSubmit:c,setIsSubmit:d,setOpen:o})=>{const[m,l]=p.useState(""),n=async(s,t)=>{t.preventDefault();try{const r=route("resources.download",s.id);window.open(r,"_blank")}catch{window.open(s.resource,"_blank")}};return e.jsx("div",{className:"space-y-4 py-3",children:i.resources.length>0?i.resources.map(s=>e.jsx("div",{className:"bg-muted rounded-md p-1.5",children:s.id===m?e.jsxs("div",{className:"relative",children:[e.jsx(N,{lesson:i,resource:s,isSubmit:c,setIsSubmit:d,setIsOpen:o}),e.jsx(a,{variant:"secondary",className:"absolute right-0 bottom-0",onClick:()=>l(""),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"w-full px-1",children:s.type==="link"?e.jsx("a",{target:"_blank",href:s.resource,className:"cursor-pointer text-sm hover:underline",children:s.title.slice(0,50)+(s.title.length>50?"...":"")}):e.jsx("span",{className:"cursor-pointer text-sm hover:underline",onClick:t=>n(s,t),children:s.title.slice(0,50)+(s.title.length>50?"...":"")})}),e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(a,{size:"icon",variant:"secondary",className:"h-7 w-7",onClick:()=>l(s.id),children:e.jsx(h,{className:"h-3 w-3"})}),s.type!=="link"?e.jsx(a,{asChild:!0,size:"icon",variant:"secondary",className:"h-7 w-7",children:e.jsx("a",{target:"_blank",href:s.resource,children:e.jsx(x,{className:"h-3 w-3"})})}):e.jsx(a,{size:"icon",variant:"secondary",className:"h-7 w-7",onClick:t=>n(s,t),children:e.jsx(j,{className:"h-3 w-3"})})]})]},s.id)})):e.jsx("div",{className:"bg-muted rounded-md p-1.5",children:e.jsx("div",{className:"w-full px-1 py-6 text-center",children:e.jsx("p",{className:"text-sm",children:"No resources available"})})})})};export{R as default};