(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,61794,e=>{"use strict";var t=e.i(843476),s=e.i(522016),r=e.i(271645),a=e.i(618566),c=e.i(970065),n=e.i(167881),l=e.i(23750),o=e.i(62870),d=e.i(270598),i=e.i(272944),u=e.i(551956);e.s(["default",0,function(){let e=(0,a.useRouter)(),m=(0,r.useMemo)(()=>(0,i.getApiService)(),[]),{success:x,error:f}=(0,d.useToast)(),[h,j]=(0,r.useState)([]),[g,v]=(0,r.useState)(!1),[b,p]=(0,r.useState)({fromAccountId:"",toAccountId:"",transferDate:new Date().toISOString().split("T")[0],amount:0,referenceNumber:"",notes:""});(0,r.useEffect)(()=>{(async()=>{let e=await m.listAccounts({pageSize:200});e.success&&e.data?j(e.data.results||[]):f("Failed to load accounts",e.error)})()},[m,f]);let N=async t=>{if(t.preventDefault(),!b.fromAccountId||!b.toAccountId)return void f("Please select both accounts");if(b.fromAccountId===b.toAccountId)return void f("From and To accounts must be different");if(!b.amount||b.amount<=0)return void f("Amount must be greater than 0");v(!0);let s={fromAccountId:b.fromAccountId,toAccountId:b.toAccountId,transferDate:b.transferDate,amount:Number(b.amount),referenceNumber:b.referenceNumber.trim()||void 0,notes:b.notes.trim()||void 0},r=await m.createAccountTransfer(s);r.success?(x("Transfer created"),e.push("/accounts/transfers")):f("Failed to create transfer",r.error),v(!1)};return(0,t.jsxs)("div",{className:"flex-1 space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-3xl font-bold text-foreground",children:"New Account Transfer"}),(0,t.jsx)("p",{className:"text-muted-foreground mt-2",children:"Move funds between cash, bank, or MFS accounts"})]}),(0,t.jsx)(s.default,{href:"/accounts/transfers",children:(0,t.jsx)(n.Button,{variant:"outline",children:"Back"})})]}),(0,t.jsxs)(c.Card,{className:"bg-card border-border",children:[(0,t.jsx)(c.CardHeader,{children:(0,t.jsx)(c.CardTitle,{children:"Transfer Details"})}),(0,t.jsx)(c.CardContent,{children:(0,t.jsxs)("form",{onSubmit:N,className:"space-y-4",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:"From Account"}),(0,t.jsxs)(o.Select,{value:b.fromAccountId,onValueChange:e=>p(t=>({...t,fromAccountId:e})),children:[(0,t.jsx)(o.SelectTrigger,{className:"mt-2",children:(0,t.jsx)(o.SelectValue,{placeholder:"Select account"})}),(0,t.jsx)(o.SelectContent,{children:h.map(e=>(0,t.jsxs)(o.SelectItem,{value:e.id,children:[e.name," (",e.type,")"]},e.id))})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:"To Account"}),(0,t.jsxs)(o.Select,{value:b.toAccountId,onValueChange:e=>p(t=>({...t,toAccountId:e})),children:[(0,t.jsx)(o.SelectTrigger,{className:"mt-2",children:(0,t.jsx)(o.SelectValue,{placeholder:"Select account"})}),(0,t.jsx)(o.SelectContent,{children:h.map(e=>(0,t.jsxs)(o.SelectItem,{value:e.id,children:[e.name," (",e.type,")"]},e.id))})]})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:"Transfer Date"}),(0,t.jsx)(l.Input,{type:"date",value:b.transferDate,onChange:e=>p(t=>({...t,transferDate:e.target.value})),className:"mt-2"})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"text-sm text-muted-foreground",children:["Amount (",u.config.locale.currencySymbol,")"]}),(0,t.jsx)(l.Input,{type:"number",value:b.amount,onChange:e=>p(t=>({...t,amount:Number(e.target.value)})),className:"mt-2"})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:"Reference"}),(0,t.jsx)(l.Input,{value:b.referenceNumber,onChange:e=>p(t=>({...t,referenceNumber:e.target.value})),placeholder:"Optional",className:"mt-2"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm text-muted-foreground",children:"Notes"}),(0,t.jsx)(l.Input,{value:b.notes,onChange:e=>p(t=>({...t,notes:e.target.value})),placeholder:"Optional",className:"mt-2"})]})]}),(0,t.jsxs)("div",{className:"flex gap-3 justify-end",children:[(0,t.jsx)(n.Button,{type:"button",variant:"outline",onClick:()=>e.back(),children:"Cancel"}),(0,t.jsx)(n.Button,{type:"submit",disabled:g,children:g?"Saving...":"Create Transfer"})]})]})})]})]})}])}]);