import{jsxs as c,jsx as e}from"react/jsx-runtime";import{I as s}from"./input-qMvM9qch.js";import{L as a}from"./label-DMnntKPk.js";import{S as g,a as N,b as y,c as S,f as r}from"./select-DfhewM4T.js";import{C as _}from"./checkbox-DXBO59MA.js";import{Loader2 as b}from"lucide-react";import{MaskSelect as k}from"./MaskSelect-db8-mWU9.js";import{TemplateSelect as C}from"./TemplateSelect-DfGd1_U3.js";import"./utils-CMbmcP35.js";import"clsx";import"tailwind-merge";import"@radix-ui/react-label";import"@radix-ui/react-select";import"@radix-ui/react-checkbox";import"react";function q({formData:i,setFormData:d,errors:l,masks:n,itemName:m,isLoadingItemName:p,onItemIdBlur:o,showUsageLimit:h=!1,showDuration:u=!1,showIpRestricted:x=!1,showExpireDate:v=!1}){return c("div",{className:"space-y-4",children:[e("div",{className:"p-3 bg-muted/50 rounded-lg border border-dashed",children:e(C,{onSelect:t=>{t&&d({...i,item_id:String(t.item_id),count:String(t.count),proctype:String(t.proctype),octet:t.octet||"0",mask:String(t.mask)})}})}),c("div",{className:"space-y-2",children:[e(a,{htmlFor:"item-id",children:"Item ID *"}),c("div",{className:"grid grid-cols-2 gap-2",children:[c("div",{className:"relative",children:[e(s,{id:"item-id",type:"number",placeholder:"Enter item ID",value:i.item_id,onChange:t=>d({...i,item_id:t.target.value}),onBlur:o}),p&&e("div",{className:"absolute right-2 top-2.5",children:e(b,{className:"h-4 w-4 animate-spin"})})]}),e(s,{placeholder:"Item name will appear here",value:m,disabled:!0,className:"bg-muted"})]}),l.item_id&&e("p",{className:"text-sm text-destructive",children:l.item_id})]}),c("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[c("div",{className:"space-y-2",children:[e(a,{htmlFor:"count",children:"Count *"}),e(s,{id:"count",type:"number",min:"1",value:i.count,onChange:t=>d({...i,count:t.target.value})}),l.count&&e("p",{className:"text-sm text-destructive",children:l.count})]}),h&&c("div",{className:"space-y-2",children:[e(a,{htmlFor:"usage-limit",children:"Usage Limit *"}),e(s,{id:"usage-limit",type:"number",min:"1",max:"1000",value:i.usage_limit,onChange:t=>d({...i,usage_limit:t.target.value})}),e("p",{className:"text-xs text-muted-foreground",children:"Maximum times this voucher can be claimed"}),l.usage_limit&&e("p",{className:"text-sm text-destructive",children:l.usage_limit})]})]}),c("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[c("div",{className:"space-y-2",children:[e(a,{htmlFor:"proctype",children:"Proctype *"}),e(s,{id:"proctype",type:"number",value:i.proctype,onChange:t=>d({...i,proctype:t.target.value})}),l.proctype&&e("p",{className:"text-sm text-destructive",children:l.proctype})]}),c("div",{className:"space-y-2",children:[e(a,{htmlFor:"octet",children:"Octet *"}),e(s,{id:"octet",type:"text",value:i.octet,onChange:t=>d({...i,octet:t.target.value}),placeholder:"Hex octet data",className:"font-mono text-xs"}),l.octet&&e("p",{className:"text-sm text-destructive",children:l.octet})]})]}),c("div",{className:"space-y-2",children:[e(a,{htmlFor:"mask",children:"Mask *"}),e(k,{id:"mask",value:i.mask,onValueChange:t=>d({...i,mask:t}),masks:n}),l.mask&&e("p",{className:"text-sm text-destructive",children:l.mask})]}),u&&c("div",{className:"space-y-2",children:[e(a,{htmlFor:"duration",children:"Expiry Duration"}),c(g,{value:i.duration,onValueChange:t=>d({...i,duration:t}),children:[e(N,{id:"duration",children:e(y,{placeholder:"Select expiry duration"})}),c(S,{children:[e(r,{value:"none",children:"No Expiry (Never expires)"}),e(r,{value:"86400",children:"1 day (24 hours)"}),e(r,{value:"604800",children:"7 days (1 week)"}),e(r,{value:"2592000",children:"30 days (1 month)"})]})]}),e("p",{className:"text-xs text-muted-foreground",children:'Leave empty or select "No Expiry" if the voucher should never expire.'})]}),v&&c("div",{className:"space-y-2",children:[e(a,{htmlFor:"expire-date",children:"Expire Date (Optional)"}),e("div",{className:"flex gap-2",children:e(s,{id:"expire-date",type:"date",value:i.expire_date,onChange:t=>d({...i,expire_date:t.target.value}),className:"flex-1"})}),e("p",{className:"text-xs text-muted-foreground",children:"Leave empty for no expiration"}),l.expire_date&&e("p",{className:"text-sm text-destructive",children:l.expire_date})]}),x&&c("div",{className:"space-y-2",children:[c("div",{className:"flex items-center space-x-2",children:[e(_,{id:"ip-restricted",checked:i.ip_restricted,onCheckedChange:t=>d({...i,ip_restricted:t})}),e(a,{htmlFor:"ip-restricted",className:"cursor-pointer",children:"IP Restricted"})]}),e("p",{className:"text-xs text-muted-foreground",children:"Only allow one voucher claim per IP address."})]})]})}export{q as VoucherFormFields};
