import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{a as t,f as n,i as r,n as i,r as a,u as o}from"./createLucideIcon-XxmMb-o2.js";import{i as s}from"./donations-BReZ0sJ2.js";import{t as c}from"./utils-CCDJ05Ll.js";import{t as l}from"./donor-page-header-Wb83AVtI.js";import{s as u}from"./app-BvqieymH.js";import{t as d}from"./input-error-oHEIsY1C.js";import{a as f,i as p,n as m,r as h,t as g}from"./form-styles-CSOZH2T9.js";import{n as _,r as v,t as y}from"./location-selects-Dg_1h6RC.js";var b=a(),x=e(n(),1),S=i();function C(e){let n=(0,b.c)(22),{user:i,upazilas:a,unions:C,villages:w}=e,T=o().props.errors,[E,D]=(0,x.useState)(i.blood_group),[O,k]=(0,x.useState)(i.available),[A,j]=(0,x.useState)(i.union_id?String(i.union_id):``),[M,N]=(0,x.useState)(i.village_id?String(i.village_id):``),[P,F]=(0,x.useState)(w),I,L;n[0]===T?(I=n[1],L=n[2]):(I=()=>{Object.keys(T??{}).length>0&&s.error(`Please fix the highlighted fields.`)},L=[T],n[0]=T,n[1]=I,n[2]=L),(0,x.useEffect)(I,L);let R;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,S.jsx)(t,{title:`Edit Profile`}),n[3]=R):R=n[3];let z;n[4]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,S.jsx)(l,{title:`Edit Profile`,backHref:`/profile`}),n[4]=z):z=n[4];let B;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(B=u.form(),n[5]=B):B=n[5];let V;return n[6]!==O||n[7]!==E||n[8]!==T?.blood_group||n[9]!==T?.name||n[10]!==T?.phone||n[11]!==T?.username||n[12]!==T?.village_id||n[13]!==P||n[14]!==A||n[15]!==C||n[16]!==a||n[17]!==i.name||n[18]!==i.phone||n[19]!==i.username||n[20]!==M?(V=(0,S.jsxs)(S.Fragment,{children:[R,(0,S.jsxs)(`div`,{className:`min-h-screen bg-page`,children:[z,(0,S.jsx)(r,{...B,className:`px-4 py-4`,children:e=>{let{processing:t}=e;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`input`,{type:`hidden`,name:`blood_group`,value:E}),(0,S.jsx)(`input`,{type:`hidden`,name:`is_available`,value:O?`1`:`0`}),(0,S.jsx)(`div`,{className:f,children:`Personal Information`}),(0,S.jsxs)(`div`,{className:c(p,`mb-4`),children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{htmlFor:`name`,className:m,children:`Full Name`}),(0,S.jsx)(`input`,{id:`name`,type:`text`,name:`name`,required:!0,defaultValue:i.name,className:g}),(0,S.jsx)(d,{message:T?.name})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{htmlFor:`phone`,className:m,children:`Phone Number`}),(0,S.jsx)(`input`,{id:`phone`,type:`tel`,name:`phone`,required:!0,defaultValue:i.phone,className:`${g} font-mono`}),(0,S.jsx)(d,{message:T?.phone})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{htmlFor:`username`,className:m,children:`Username`}),(0,S.jsx)(`input`,{id:`username`,type:`text`,name:`username`,required:!0,defaultValue:i.username,className:`${g} font-mono`}),(0,S.jsx)(d,{message:T?.username})]})]}),(0,S.jsx)(`div`,{className:f,children:`Blood Information`}),(0,S.jsxs)(`div`,{className:`mb-4 rounded-lg border border-line bg-white p-3.5`,children:[(0,S.jsx)(`label`,{className:c(m,`mb-2`),children:`Blood Group`}),(0,S.jsx)(_,{value:E,onChange:D}),(0,S.jsx)(d,{message:T?.blood_group})]}),(0,S.jsx)(`div`,{className:f,children:`Location`}),(0,S.jsxs)(`div`,{className:c(p,`mb-4`),children:[(0,S.jsx)(y,{upazilas:a,unions:C,villages:P,unionId:A,villageId:M,onUnionChange:j,onVillageChange:N,onVillageCreated:e=>F(t=>[...t,e])}),(0,S.jsx)(d,{message:T?.village_id})]}),(0,S.jsx)(`div`,{className:f,children:`Donor Status`}),(0,S.jsx)(`div`,{className:`mb-4 rounded-lg border border-line bg-white p-3.5`,children:(0,S.jsx)(v,{value:O,onChange:k})}),(0,S.jsx)(`button`,{type:`submit`,disabled:t,className:h,children:`Save Changes`})]})}})]})]}),n[6]=O,n[7]=E,n[8]=T?.blood_group,n[9]=T?.name,n[10]=T?.phone,n[11]=T?.username,n[12]=T?.village_id,n[13]=P,n[14]=A,n[15]=C,n[16]=a,n[17]=i.name,n[18]=i.phone,n[19]=i.username,n[20]=M,n[21]=V):V=n[21],V}export{C as default};