import{r as x,j as e}from"./vendor-BKmmeuxg.js";import{I as l}from"./input-error-LaPr_4wd.js";import{I as t}from"./input-DM0goJrn.js";import{L as r}from"./label-HmIcv5Yx.js";import{R as p,a as o}from"./radio-group-C0C2vfl-.js";import{o as m}from"./inertia-SZXqLvQm.js";import"./utils-DxSsnXxD.js";import"./index-WW_1X1qx.js";const N=({data:i,setData:c,errors:n})=>(x.useEffect(()=>{if(i.price&&i.discount){const s=i.price*i.discount/100,d=i.price-s;c("discount_price",d.toFixed(2))}else c("discount_price",i.price||0)},[i.price,i.discount]),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Pricing Type *"}),e.jsxs(p,{value:i.pricing_type,onValueChange:s=>c("pricing_type",s),className:"flex items-center space-x-4 pt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(o,{value:"free",id:"free"}),e.jsx(r,{htmlFor:"free",className:"cursor-pointer font-normal",children:"Free"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(o,{value:"paid",id:"paid"}),e.jsx(r,{htmlFor:"paid",className:"cursor-pointer font-normal",children:"Paid"})]})]}),e.jsx(l,{message:n.pricing_type})]}),i.pricing_type==="paid"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(r,{htmlFor:"price",children:"Price (USD) *"}),e.jsx(t,{id:"price",name:"price",type:"number",value:i.price,onChange:s=>m(s,c),placeholder:"0.00",step:"0.01",min:"0",required:!0}),e.jsx(l,{message:n.price})]}),e.jsxs("div",{children:[e.jsx(r,{htmlFor:"discount",children:"Discount (%)"}),e.jsx(t,{id:"discount",name:"discount",type:"number",value:i.discount,onChange:s=>m(s,c),placeholder:"0",min:"0",max:"100"}),e.jsx(l,{message:n.discount})]}),i.discount>0&&e.jsx("div",{className:"rounded-lg bg-green-50 p-4",children:e.jsxs("p",{className:"text-sm text-green-800",children:[e.jsx("span",{className:"font-semibold",children:"Final Price:"})," $",i.discount_price," (",i.discount,"% off from $",i.price,")"]})})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx(r,{children:"Access Duration *"}),e.jsxs(p,{value:i.expiry_type||"lifetime",onValueChange:s=>c("expiry_type",s),className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(o,{value:"lifetime",id:"lifetime"}),e.jsx(r,{htmlFor:"lifetime",className:"cursor-pointer font-normal",children:"Lifetime Access"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(o,{value:"limited",id:"limited"}),e.jsx(r,{htmlFor:"limited",className:"cursor-pointer font-normal",children:"Limited Access"})]})]}),e.jsx(l,{message:n.expiry_type})]}),i.expiry_type==="limited"&&e.jsxs("div",{children:[e.jsx(r,{htmlFor:"expiry_duration",children:"Access Duration (Days) *"}),e.jsx(t,{id:"expiry_duration",name:"expiry_duration",type:"number",value:i.expiry_duration,onChange:s=>m(s,c),placeholder:"30",min:"1",required:!0}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Students will have access for this many days after enrollment"}),e.jsx(l,{message:n.expiry_duration})]})]}));export{N as default};