1import{r as b,K as W,j as e,B as C,S as T,T as q,w as L,c as U,v as _,t as Y,h as H,a as J,u as K}from"./index-_aijvlUq.js";import{P as V}from"./PageHeader-DCofr6qo.js";import{m as D}from"./members-I3UAoZ9P.js";import{u as Q}from"./useMemberStore-C9_FW8gS.js";import{a as Z}from"./agreements-BApgy4DC.js";import{r as G}from"./resizeImage-BUqRBCBG.js";import{W as X}from"./WizardShell-BAf42hnX.js";import{I as x}from"./Input-ysTyZFq5.js";import{C as ee}from"./CameraCaptureButton-B4WpiVvJ.js";import{U as se}from"./usStates-B3oQG6kH.js";import{I as te}from"./InstrumentPicker-KS7qdNLg.js";import{e as re}from"./ensembles-WGlB365j.js";import{E as ae}from"./EmptyState-CPGKooqj.js";import{O as ne}from"./orgRoles-D1oGgqrm.js";import{a as ie}from"./loginOutcome-CWrPTVc0.js";import"./downscaleImage-qyGK-a3D.js";import"./ChipToggle-hmCaOMqs.js";const O={required:s=>!s||String(s).trim()===""?"This field is required":null,email:s=>s?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)?null:"Invalid email address":null,maxLength:s=>r=>r&&r.length>s?`Must be ${s} characters or fewer`:null,minLength:s=>r=>r&&r.length<s?`Must be at least ${s} characters`:null,dateFormat:s=>s?/^\d{4}-\d{2}-\d{2}$/.test(s)?null:"Date must be in YYYY-MM-DD format":null};function F(s,r){for(const l of r){const a=l(s);if(a)return a}return null}const le={0:["firstName","lastName","emailAddress"],1:["street","city","state","zip"],2:[],3:[],4:[]};function $(){return{firstName:"",lastName:"",emailAddress:"",birthday:"",profession:"",bio:"",street:"",street2:"",city:"",state:"",zip:"",county:"",memberType:"musician",memberStatus:"active",onboardingDate:W(),instruments:[],ensembleIds:[],orgRoles:["member"],photoResponse:"",photoRespondedBy:"",photoRespondentName:"",createUserAccount:!0,phone:"",communicationProxy:!1,proxyName:"",proxyEmail:"",proxyPhone:"",proxyRelationship:"",proxyMode:"replace",emergencyContactName:"",emergencyContactRelationship:"",emergencyContactEmail:"",emergencyContactPhone:"",linkExistingAccount:!1}}function oe(s){const[r,l]=b.useState(0),[a,o]=b.useState($()),[h,t]=b.useState({}),[n,p]=b.useState(!1),[A,S]=b.useState(null),[y,f]=b.useState(null),i=b.useRef(null),m=5;b.useEffect(()=>(i.current&&clearTimeout(i.current),S(null),a.firstName.trim().length>=2&&a.lastName.trim().length>=2&&(i.current=setTimeout(async()=>{try{const c={firstName:a.firstName.trim(),lastName:a.lastName.trim()};a.emailAddress?.trim()&&(c.emailAddress=a.emailAddress.trim());const g=await D.checkDuplicate(c),d=g.data?.duplicates||g.duplicates||[];d.length>0&&S(d[0])}catch{}},800)),()=>{i.current&&clearTimeout(i.current)}),[a.firstName,a.lastName,a.emailAddress]);const v=b.useCallback(async c=>{const g=(typeof c=="string"?c:a.emailAddress)?.trim();if(!g||!g.includes("@")){f(null);return}try{const d=await D.checkEmail(g);f({...d,checkedEmail:g.toLowerCase()})}catch{f(null)}},[a.emailAddress]);function w(c,g){o(d=>{const u={...d,[c]:g};if(c==="memberType"&&g==="director"){const j=u.orgRoles??[];j.includes("music_director")||(u.orgRoles=[...j,"music_director"])}return u}),h[c]&&t(d=>({...d,[c]:null})),c==="emailAddress"&&f(null)}function N(c){const g=le[c]??[],d={};for(const u of g){let j=null;u==="firstName"||u==="lastName"?j=F(a[u],[O.required,O.maxLength(100)]):u==="emailAddress"&&a[u]?.trim()&&(j=F(a[u],[O.email])),j&&(d[u]=j)}if(c===m-1&&y&&!y.available&&y.inCurrentOrg&&y.checkedEmail===a.emailAddress?.trim().toLowerCase()&&!a.communicationProxy&&(d.reachability="This email is already used by a member in your organization. Use a different email, or set up a communication proxy on the Contact step if this member is reached through someone else."),c===m-1){const u=!!a.emailAddress?.trim(),j=!!a.phone?.trim(),R=a.communicationProxy&&(a.proxyEmail?.trim()||a.proxyPhone?.trim());!u&&!j&&!R&&(d.reachability="This member needs a way to be reached â add an email or phone on the Personal/Contact steps, or a communication proxy."),a.instruments?.length>0&&a.ensembleIds?.length>0&&(a.ensembleIds??[]).filter(B=>!(a.ensembleInstruments||{})[B]).length>0&&(d.ensembleInstruments="Each selected ensemble needs an instrument. Go back to the Ensembles step and pick one for every ensemble you ticked."),a.orgRoles?.length>0||(d.orgRoles='Pick at least one organizational role. "Member" is the default for everyone.'),a.photoResponse&&!a.photoRespondedBy&&(d.photoRespondedBy="Tell us who answered the photo question â the member, their guardian, or their application form.")}return t(d),Object.keys(d).length===0}function E(){N(r)&&l(c=>Math.min(c+1,m-1))}function M(){l(c=>Math.max(c-1,0))}async function P(){if(N(r)){p(!0);try{await s(a)}finally{p(!1)}}}function z(){l(0),o($()),t({}),p(!1),f(null)}return{step:r,data:a,errors:h,isSubmitting:n,duplicateWarning:A,emailCheck:y,checkEmail:v,totalSteps:m,updateField:w,next:E,back:M,submit:P,reset:z}}const me=[{value:"musician",label:"Musician"},{value:"director",label:"Director"},{value:"staff",label:"Staff (non-performing)"},{value:"guest",label:"Guest (occasional)"}],ce=[{value:"active",label:"Active"},{value:"inactive",label:"Inactive"},{value:"retired",label:"Alumni"}];function de({data:s,errors:r,onChange:l,duplicateWarning:a,emailCheck:o,onCheckEmail:h}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Personal Information"}),a?.confidence==="high"&&e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-amber-50 border border-amber-200 rounded-lg",children:[e.jsx("svg",{className:"h-4 w-4 text-amber-500 mt-0.5 shrink-0",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),e.jsx("p",{className:"text-sm text-amber-800",children:a.reason})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(x,{label:"First Name",value:s.firstName,onChange:t=>l("firstName",t.target.value),error:r.firstName,placeholder:"Jane",required:!0}),e.jsx(x,{label:"Last Name",value:s.lastName,onChange:t=>l("lastName",t.target.value),error:r.lastName,placeholder:"Smith",required:!0})]}),e.jsxs("div",{children:[e.jsx(x,{label:"Email Address",type:"email",value:s.emailAddress,onChange:t=>l("emailAddress",t.target.value),onBlur:h,error:r.emailAddress,placeholder:"[email protected]"}),e.jsx("p",{className:"mt-1 text-xs text-band-600",children:"Used for login and notifications. Leave blank if this member will be reached only by phone or through a communication proxy â set one up on the Contact step."}),o&&!o.available&&e.jsx("div",{className:"mt-2 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3",children:o.inCurrentOrg?e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-amber-800",children:"This email is already used by a member in your organization."}),e.jsx("p",{className:"text-xs text-amber-600 mt-1",children:o.existing.filter(t=>t.sameOrg).map(t=>t.name).join(", ")}),e.jsx("p",{className:"text-xs text-amber-600 mt-1",children:"That's fine when this member is reached through the same person (a shared family address or a communication proxy) â otherwise use a different email. You can set up the proxy on the Contact step."})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-amber-800",children:"This email belongs to an existing Backstage Baton member in another organization."}),e.jsx("p",{className:"text-xs text-amber-600",children:o.existing.map(t=>t.name).join(", ")}),e.jsxs("div",{className:"bg-white rounded-lg border border-amber-100 px-3 py-2 mt-2",children:[e.jsx("p",{className:"text-sm text-gray-700 font-medium mb-1",children:"Link this member to your organization?"}),e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"This will connect the existing account to your organization. The member will be able to switch between organizations using the same login."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{type:"button",size:"sm",onClick:()=>l("linkExistingAccount",!0),variant:s.linkExistingAccount?"primary":"secondary",children:"Yes, link existing account"}),e.jsx(C,{type:"button",size:"sm",variant:"ghost",onClick:()=>l("linkExistingAccount",!1),children:"No, use a different email"})]})]})]})}),o&&(o.domainDeliverable===!1||o.suggestion)&&e.jsxs("div",{className:"mt-2 rounded-lg border border-amber-200 bg-amber-50 text-amber-800 text-sm p-3",children:[o.domainDeliverable===!1&&e.jsx("p",{children:"This address's domain doesn't appear to receive mail."}),o.suggestion&&e.jsxs(C,{type:"button",variant:"ghost",size:"sm",className:"!px-0 mt-1 text-amber-900 font-medium underline",onClick:()=>{l("emailAddress",o.suggestion),h?.(o.suggestion)},children:["Did you mean ",o.suggestion,"?"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(T,{label:"Member Type",options:me,value:s.memberType,onCh
1ange:t=>l("memberType",t.target.value)}),e.jsx(T,{label:"Status",options:ce,value:s.memberStatus,onChange:t=>l("memberStatus",t.target.value)})]})]})}function ue({data:s,onChange:r}){const l=b.useRef(null),[a,o]=b.useState(null);async function h(t){const n=t.target.files?.[0];if(!n)return;const p=await G(n);r("photoFile",p),o(URL.createObjectURL(p))}return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Details & Contact"}),e.jsx("h3",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wide",children:"Details"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(x,{label:"Birthday",type:"date",value:s.birthday,onChange:t=>r("birthday",t.target.value)}),e.jsx(x,{label:"Member Since",type:"date",value:s.onboardingDate,onChange:t=>r("onboardingDate",t.target.value)})]}),e.jsx(x,{label:"Profession",value:s.profession,onChange:t=>r("profession",t.target.value),placeholder:"e.g. Teacher, Engineerâ¦"}),e.jsxs("div",{children:[e.jsx(q,{label:"Bio",value:s.bio,onChange:t=>r("bio",t.target.value),maxLength:500,rows:4,placeholder:"A short biography (optional)"}),e.jsxs("p",{className:"mt-1 text-xs text-gray-400 text-right",children:[s.bio?.length??0," / 500"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Photo"}),e.jsxs("div",{className:"flex items-center gap-4",children:[a?e.jsx("img",{src:a,alt:"Preview",className:"h-16 w-16 rounded-full object-cover ring-2 ring-band-200"}):e.jsx("div",{className:"h-16 w-16 rounded-full bg-gray-100 flex items-center justify-center text-gray-400",children:e.jsx("svg",{className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}),e.jsxs("div",{children:[e.jsx(C,{type:"button",variant:"secondary",size:"sm",onClick:()=>l.current?.click(),children:a?"Change photo":"Upload photo"}),e.jsx(ee,{label:"Take a photo",onChange:h,className:"mt-1.5"}),e.jsx("p",{className:"mt-1 text-xs text-gray-400",children:"Optional · JPEG, PNG, or WebP up to 5 MB"}),e.jsx("input",{ref:l,type:"file",accept:"image/jpeg,image/png,image/webp",className:"hidden",onChange:h,"aria-label":"Upload profile photo"})]})]})]}),e.jsx("h3",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wide pt-2",children:"Address & Phone"}),e.jsx(x,{label:"Phone",value:s.phone,onChange:t=>r("phone",L(t.target.value)),placeholder:"(555) 555-5555"}),e.jsx(x,{label:"Street Address",value:s.street,onChange:t=>r("street",t.target.value),placeholder:"123 Main St"}),e.jsx(x,{label:"Street Address Line 2",value:s.street2,onChange:t=>r("street2",t.target.value),placeholder:"Apt, Suite, Unit, etc."}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-6 gap-4",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(x,{label:"City",value:s.city,onChange:t=>r("city",t.target.value),placeholder:"Springfield"})}),e.jsx("div",{className:"col-span-1 sm:col-span-2",children:e.jsx(T,{label:"State",options:se,value:s.state,onChange:t=>r("state",t.target.value)})}),e.jsx("div",{className:"col-span-1 sm:col-span-2",children:e.jsx(x,{label:"Zip Code",value:s.zip,onChange:t=>r("zip",t.target.value),placeholder:"62701"})})]}),e.jsx(x,{label:"County",value:s.county,onChange:t=>r("county",t.target.value),placeholder:"Sangamon"}),e.jsx("h3",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wide pt-2",children:"Emergency Contact"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(x,{label:"Name",value:s.emergencyContactName,onChange:t=>r("emergencyContactName",t.target.value),placeholder:"Jane Doe"}),e.jsx(x,{label:"Relationship",value:s.emergencyContactRelationship,onChange:t=>r("emergencyContactRelationship",t.target.value),placeholder:"Spouse"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(x,{label:"Email Address",type:"email",value:s.emergencyContactEmail,onChange:t=>r("emergencyContactEmail",t.target.value),placeholder:"[email protected]"}),e.jsx(x,{label:"Phone",value:s.emergencyContactPhone,onChange:t=>r("emergencyContactPhone",L(t.target.value)),placeholder:"(555) 555-5555"})]}),e.jsxs("div",{className:"pt-2 border-t border-gray-100",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Communication Proxy"}),e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:"For a member who doesnât use email or SMS â route their notifications to a parent, guardian, or spouse instead."}),e.jsxs("label",{className:"flex items-center gap-2 mb-4 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.communicationProxy||!1,onChange:t=>r("communicationProxy",t.target.checked),className:"rounded border-gray-300 text-band-600 focus:ring-band-500 h-4 w-4"}),e.jsx("span",{className:"text-sm text-gray-700",children:"Route notifications to a proxy contact"})]}),s.communicationProxy&&e.jsxs("div",{className:"space-y-4 pl-6 border-l-2 border-band-200",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 mb-2",children:"Send communications to"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"proxyMode",checked:(s.proxyMode||"replace")==="replace",onChange:()=>r("proxyMode","replace"),className:"mt-0.5 border-gray-300 text-band-600 focus:ring-band-500 h-4 w-4"}),e.jsxs("span",{className:"text-sm text-gray-700",children:["Proxy only ",e.jsx("span",{className:"text-gray-500",children:"â the member won't receive email"})]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"proxyMode",checked:s.proxyMode==="both",onChange:()=>r("proxyMode","both"),className:"mt-0.5 border-gray-300 text-band-600 focus:ring-band-500 h-4 w-4"}),e.jsxs("span",{className:"text-sm text-gray-700",children:["Both member and proxy ",e.jsx("span",{className:"text-gray-500",children:"â each gets a copy (e.g. parent and child)"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(x,{label:"Name",value:s.proxyName,onChange:t=>r("proxyName",t.target.value),placeholder:"Jane Doe"}),e.jsx(x,{label:"Relationship",value:s.proxyRelationship,onChange:t=>r("proxyRelationship",t.target.value),placeholder:"Parent"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(x,{label:"Email Address",type:"email",value:s.proxyEmail,onChange:t=>r("proxyEmail",t.target.value),placeholder:"[email protected]"}),e.jsx(x,{label:"Phone",value:s.proxyPhone,onChange:t=>r("proxyPhone",L(t.target.value)),placeholder:"(555) 555-5555"})]}),!s.proxyEmail&&!s.proxyPhone&&e.jsx("p",{className:"text-xs text-amber-600",children:"Add a proxy email or phone so this member can be reached."})]})]})]})}function he({data:s,onChange:r}){const{showError:l}=U(),[a,o]=b.useState([]),[h,t]=b.useState(!0);return b.useEffect(()=>{_.get("/instruments",{params:{context:"member"}}).then(o).catch(()=>l(Y("instruments"))).finally(()=>t(!1))},[]),h?e.jsx("div",{className:"text-sm text-gray-500",children:"Loading instruments..."}):e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Instruments"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Every instrument this member plays."})]}),e.jsx(te,{instruments:a,selectedIds:(s.instruments||[]).map(n=>n.instrumentId),onChange:n=>r("instruments",n.map(p=>({instrumentId:p}))),onCreated:n=>o(p=>[...p,n])})]})})}function pe({data:s,onChange:r}){const l=H(i=>i.currentOrg),{showError:a}=U(),[o,h]=b.useState([]),[t,n]=b.useState([]),[p,A]=b.useState(!0);b.useEffect(()=>{l?.id&&Promise.all([re.list(l.id),_.get("/instruments",{params:{context:"member"}})]).then(([i,m])=>{h(i),n(m)}).catch(()=>a(Y("ensembles"))).finally(()=>A(!1))},[l?.id]);function S(i){const m=s.ensembleIds??[],v=!m.includes(i),w=v?[...m,i]:m.filter(E=>E!==i);r("ensembleIds",w);const N={...s.ensembleInstruments||{}};v?s.instruments?.length===1&&(N[i]=s.instruments[0].instrumentId):delete N[i],r("ensembleInstruments",N)}function y(i,m){r("ensembleInstruments",{...s.ensembleInstruments||{},[i]:m||null})}if(b.useEffect(()=>{if(s.instruments?.length===1&&(s.ensembleIds?.length??0)>0){const i=s.instruments[0].instrumentId,m=s.ensembleInstruments||{};if(s.ensembleIds.some(w=>m[w]!==i)){const w={...m};for(const N of s.ensembleIds)w[N]=i;r("ensembleInstruments",w)}}},[s.instruments,s.ensembleIds]),p)return e.jsx("div",{className:"text-sm text-gray-500",children:"Loading ensembles..."});if(o.length===0)return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Ensembles"}),e.jsx(ae,{size:"compact",title:"No ensembles have been created yet."})]});const f=(s.instruments??[]).map(i=>{const m=t.find(v=>v.id===i.instrumentId);return m?{value:m.id,label:m.name}:null}
1).filter(Boolean);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Ensembles"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Select the ensembles this member belongs to, and the instrument they play in each."})]}),e.jsx("div",{className:"space-y-2",children:o.map(i=>{const m=(s.ensembleIds??[]).includes(i.id);return e.jsxs("div",{className:`rounded-lg border px-4 py-3 transition-colors ${m?"border-band-300 bg-band-50":"border-gray-200 bg-white"}`,children:[e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:()=>S(i.id),className:"h-4 w-4 rounded border-gray-300 text-band-600 focus:ring-band-500"}),e.jsx("span",{className:`text-sm font-medium flex-1 ${m?"text-gray-900":"text-gray-500"}`,children:i.name}),m&&f.length===1&&e.jsx("span",{className:"text-xs text-gray-500 shrink-0",children:f[0].label})]}),m&&f.length>1&&e.jsxs("div",{className:"mt-2 pl-7",children:[e.jsx(T,{value:s.ensembleInstruments?.[i.id]||"",onChange:v=>y(i.id,v.target.value),options:[{value:"",label:"Select instrumentâ¦"},...f],"aria-label":`Instrument for ${i.name}`,className:`w-full sm:w-56 ${s.ensembleInstruments?.[i.id]?"":"!border-amber-400"}`}),!s.ensembleInstruments?.[i.id]&&e.jsxs("p",{className:"mt-1 text-xs text-amber-700",children:["Pick the instrument they play in ",i.name," â saving without one leaves them on the roster with no instrument tied to this ensemble."]})]}),m&&f.length===0&&e.jsxs("p",{className:"mt-2 pl-7 text-xs text-amber-700",children:["No instruments picked yet â go back to the Instruments step. Saving without one leaves them on the ",i.name," roster with no instrument."]})]},i.id)})})]})}function xe({data:s,errors:r={},onChange:l}){const{canFully:a}=J(),o=a("members:create");function h(n){const p=s.orgRoles??[],A=p.includes(n)?p.filter(S=>S!==n):[...p,n];l("orgRoles",A)}const t=!!s.emailAddress?.trim()&&s.memberType!=="guest";return e.jsxs("div",{className:"space-y-6",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"Roles & Access"}),r.reachability&&e.jsx(k,{message:r.reachability}),r.ensembleInstruments&&e.jsx(k,{message:r.ensembleInstruments}),r.orgRoles&&e.jsx(k,{message:r.orgRoles}),r.photoRespondedBy&&e.jsx(k,{message:r.photoRespondedBy}),o&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 mb-1",children:"Organizational Roles"}),e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"Titles determine what this member can do â access is the combined total of every role checked."}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:ne.map(n=>{const p=(s.orgRoles??[]).includes(n.value);return e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-700 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:p,onChange:()=>h(n.value),className:"h-4 w-4 rounded border-gray-300 text-band-600 focus:ring-band-500"}),n.label]},n.value)})})]}),o&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 mb-1",children:"Can we use their photo?"}),e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"Photos and videos from rehearsals and performances â website, newsletter, social media. Record the answer from their application; you can change it any time."}),e.jsx("div",{className:"flex gap-2 mb-3",children:[{value:"",label:"No answer yet"},{value:"granted",label:"Yes â photos OK"},{value:"declined",label:"No"}].map(n=>e.jsx("button",{type:"button",onClick:()=>l("photoResponse",n.value),className:`px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${(s.photoResponse??"")===n.value?"bg-band-500 border-band-500 text-white":"bg-white border-gray-300 text-gray-700 hover:border-band-400"}`,children:n.label},n.value||"none"))}),s.photoResponse&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-gray-500 mb-1",children:"Who answered?"}),e.jsx("div",{className:"flex gap-2",children:[{value:"member",label:"The member"},{value:"proxy",label:"Parent / guardian"}
1,{value:"admin",label:"From their application form"}].map(n=>e.jsx("button",{type:"button",onClick:()=>{l("photoRespondedBy",n.value),n.value==="proxy"&&!s.photoRespondentName&&s.proxyName&&l("photoRespondentName",s.proxyName)},className:`px-3 py-1 rounded-full text-xs font-medium border transition-colors ${s.photoRespondedBy===n.value?"bg-gray-800 border-gray-800 text-white":"bg-white border-gray-300 text-gray-600 hover:border-gray-400"}`,children:n.label},n.value))})]}),s.photoRespondedBy==="admin"&&e.jsx("p",{className:"text-xs text-gray-400",children:"Use this when copying an answer from a written application."}),s.photoRespondedBy==="proxy"&&e.jsx("input",{type:"text",value:s.photoRespondentName||"",onChange:n=>l("photoRespondentName",n.target.value),placeholder:"Guardian's name",className:"w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:ring-2 focus:ring-band-500 focus:border-band-500"})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 mb-2",children:"Login Account"}),t?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-start gap-3 p-4 rounded-lg border border-gray-200 cursor-pointer hover:bg-gray-50 transition-colors",children:[e.jsx("input",{type:"checkbox",checked:s.createUserAccount,onChange:n=>l("createUserAccount",n.target.checked),className:"mt-0.5 h-4 w-4 rounded border-gray-300 text-band-600 focus:ring-band-500"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:"Create login account"}),e.jsxs("p",{className:"text-sm text-gray-500 mt-0.5",children:["A welcome email will be sent to ",e.jsx("strong",{children:s.emailAddress})," with a link to set their password."]})]})]}),!s.createUserAccount&&e.jsx("p",{className:"mt-2 text-sm text-amber-600 bg-amber-50 rounded-lg p-3",children:"This member wonât be able to log in. You can create their account later from their profile."})]}):e.jsx("p",{className:"text-sm text-gray-500 bg-gray-50 rounded-lg p-3",children:s.memberType==="guest"?"Guests donât get login accounts.":"Add an email on the Personal step to offer this member a login account. Members reached by phone or a communication proxy donât need one."})]})]})}function k({message:s}){return e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-red-50 border border-red-200 rounded-lg",children:[e.jsx("svg",{className:"h-4 w-4 text-red-500 mt-0.5 shrink-0",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),e.jsx("p",{className:"text-sm text-red-700",children:s})]})}const be=["Personal","Contact","Instruments","Ensembles","Admin"];function ge(){const s=K(),{createMember:r}=Q(),{showSuccess:l,showError:a}=U(),{step:o,data:h,errors:t,isSubmitting:n,duplicateWarning:p,emailCheck:A,checkEmail:S,updateField:y,next:f,back:i,submit:m}=oe(async w=>{const{photoFile:N,ensembleIds:E,ensembleInstruments:M,photoResponse:P,photoRespondedBy:z,photoRespondentName:c,...g}=w,d={...g,ensembleAssignments:(E??[]).map(R=>({ensembleId:R,instrumentId:(M??{})[R]||null}))};let u;try{u=await r(d)}catch(R){const I=R.message||"Failed to create member",B=I.includes("UNIQUE")||I.includes("email")?"A member with that email address already exists.":I;a(B);return}if(N&&u?.id)try{const R=await G(N);await D.uploadPhoto(u.id,R)}catch{}if(P&&u?.id)try{await Z.recordMemberResponse(u.id,{response:P,respondedBy:z,respondentName:c||null,sourceNote:"Recorded during member entry (membership application)"})}catch{a("Member added, but the photo-permission answer did not save â record it from their profile.")}const j=u?.login;l(ie(`${d.firstName} ${d.lastName}`,j)),s(`/members/${u.id}`,{state:j?{login:j}:void 0})}),v=[e.jsx(de,{data:h,errors:t,onChange:y,duplicateWarning:p,emailCheck:A,onCheckEmail:S}),e.jsx(ue,{data:h,errors:t,onChange:y}),e.jsx(he,{data:h,onChange:y}),e.jsx(pe,{data:h,onChange:y}),e.jsx(xe,{data:h,errors:t,onChange:y})];return e.jsx(X,{steps:be,currentStep:o,onNext:f,onBack:i,onCancel:()=>s("/members"),onSubmit:m,submitLabel:"Add Member",isSubmitting:n,children:v[o]})}function Be(){return e.jsxs("div",{className:"px-4 md:px-0",children:[e.jsx(V,{title:"Add Member",subtitle:"Enter the new member's details below.",breadcrumbs:[{label:"Home",to:"/"},{label:"Members",to:"/members"},{label:"Add Member"}]}),e.jsx(ge,{})]})}
1export{Be as OnboardingPage};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.