1 2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="fe67382c-edf1-5ed5-82b3-258569cad778")}catch(e){}}(); 3import{j as e,bO as l,E as se,H as x,a2 as F,J as ne,a5 as c,T as u,c4 as K,c5 as G,c6 as J,a8 as Z,cL as Re,au as Ye,ao as Ue,B as re,K as ae,a4 as ge,C as $,p as Me,bh as ye,bF as be,bV as ke,am as _e,cK as $e,d5 as Le,bJ as qe,aT as Ee,bW as Ve}from"./mui-D8xxi4z_.js";import{r as j}from"./react-vendor-Cvo_QYmw.js";import{ap as ve,aq as Se,ar as He}from"./uploadLink-CPQgh7z0.js";import{E as ee,S as Xe,d as Qe}from"./table-BF6VCtTh.js";import{P as je}from"./PhoneFormatter-DPfeiHi9.js";import{R as Ke}from"./RelationshipDropdown-INP0EjTW.js";import{C as Ge}from"./CountryDropdown-DovJWzoS.js";import{S as Je}from"./StateDropdown-DvV4rzkN.js";import{u as oe,I as q,H as M,l as L,C as Ae}from"./index-BKDUXvj_.js";import{E as Ze}from"./EmailValidator-C8rB4-yD.js";import{P as et}from"./PreventCharInput-CTOVPJ4g.js";import{u as le}from"./useAlert-q8x5clgZ.js";import{j as E}from"./apollo-WEBFLdxc.js";import tt from"./DonorFooter-DY1mdeaL.js";import{C as it}from"./ConfirmDestructivePopover-Dnw96tWe.js";import"./mui-x-B6XbM1b3.js";function Ce({values:r,updateInfo:h,styles:n={}}){const A=n.textfield||{display:"flex"};return e.jsxs(e.Fragment,{children:[e.jsx(l,{size:{xs:6,sm:4},children:e.jsx(se,{fullWidth:!0,sx:{...A},children:e.jsxs(x,{select:!0,"data-cy":"successor-tier-select",value:r.tier,label:"Tier",onChange:d=>h("tier",d.target.value),children:[e.jsx(F,{value:"primary",children:"Primary"}),e.jsx(F,{value:"contingent",children:"Contingent"}),e.jsx(F,{value:"tertiary",children:"Tertiary"})]})})}),e.jsx(l,{size:{xs:6,sm:4},children:e.jsx(se,{fullWidth:!0,sx:{...A},children:e.jsxs(x,{select:!0,"data-cy":"successor-allocation-type",value:r.allocationType,label:"Allocation Type",onChange:d=>h("allocationType",d.target.value),children:[e.jsx(F,{value:"percentage",children:"Percentage"}),e.jsx(F,{value:"fixedAmount",children:"Fixed Amount"})]})})}),e.jsx(l,{size:{xs:6,sm:4},children:r.allocationType==="fixedAmount"?e.jsx(x,{"data-cy":"successor-fixed-amount",value:r.fixedAmount??"",onChange:d=>h("fixedAmount",d.target.value),label:"Amount",type:"number",sx:{...A},slotProps:{input:{startAdornment:e.jsx(ne,{position:"start",children:"$"})},htmlInput:{min:0}}}):e.jsx(x,{"data-cy":"successor-percentage",value:r.percentOfDaf??"",onChange:d=>{const o=d.target.value;(o===""||parseFloat(o)>=0&&parseFloat(o)<=100)&&h("percentOfDaf",o)},label:"Percentage",type:"number",sx:{...A},helperText:"% of remaining balance after fixed amounts",slotProps:{input:{endAdornment:e.jsx(ne,{position:"end",children:"%"})},htmlInput:{min:0,max:100}}})})]})}function Te({values:r,updateInfo:h}){return e.jsxs(e.Fragment,{children:[e.jsx(l,{size:{xs:6,sm:4},children:e.jsx(se,{fullWidth:!0,children:e.jsxs(x,{select:!0,"data-cy":"successor-distribution-timing",value:r.distributionTiming,label:"Distribution Timing",onChange:n=>h("distributionTiming",n.target.value),children:[e.jsx(F,{value:"immediate",children:"Immediate"}),e.jsx(F,{value:"overTime",children:"Over Time"})]})})}),r.distributionTiming==="overTime"&&e.jsx(l,{size:{xs:6,sm:4},children:e.jsx(x,{"data-cy":"successor-distribution-years",value:r.distributionYears,onChange:n=>h("distributionYears",n.target.value),label:"Distribution Years",type:"number",fullWidth:!0,required:!0,helperText:"Number of years to distribute",slotProps:{htmlInput:{min:1}}})})]})}function X({loggedInUser:r,onNewIndividual:h,successorToEdit:n,successorToEditIndex:A,onEditIndividual:d,defaultTier:o="primary"}){const{showAlert:g}=le(),{contextUserData:C,contextProduct:y,updateContextUser:v}=oe(),[U]=E(ve,{refetchQueries:[{query:q}]}),[D]=E(Se,{refetchQueries:[{query:q}]}),[W,T]=j.useState(!1),[t,w]=j.useState(n?{type:n.type,relationship:n.relationship,firstName:n.firstName,lastName:n.lastName,address1:n.address1,address2:n.address2,city:n.city,state:n.state,zip:n.zip,country:n.country,email:n.email,phone:n.phone,tier:n.tier||"primary",allocationType:n.allocationType||"percentage",percentOfDaf:n.percentOfDaf,fixedAmount:n.fixedAmount,dateOfBirth:n.dateOfBirth?new Date(n.dateOfBirth).toISOString().split("T")[0]:"",minimumAge:n.minimumAge??18,perStirpes:n.perStirpes||!1,trustee:n.trustee||{name:"",relationship:"",email:"",ph
3one:""},distributionTiming:n.distributionTiming||"immediate",distributionYears:n.distributionYears??"",specialInstructions:n.specialInstructions||""}:{type:"individual",relationship:"",firstName:"",lastName:"",address1:"",address2:"",city:"",state:"",zip:"",country:"",email:"",phone:"",tier:o,allocationType:"percentage",percentOfDaf:0,fixedAmount:void 0,dateOfBirth:"",minimumAge:18,perStirpes:!1,trustee:{name:"",relationship:"",email:"",phone:""},distributionTiming:"immediate",distributionYears:"",specialInstructions:""});function b(i,z){let f={...t};f[i]=z,i==="distributionTiming"&&z==="immediate"&&(f.distributionYears=""),w(f)}function O(i,z){w(f=>({...f,trustee:{...f.trustee,[i]:z}}))}const R=()=>{if(!(!t.trustee?.name&&!t.trustee?.email))return{name:t.trustee.name||void 0,relationship:t.trustee.relationship||void 0,email:t.trustee.email||void 0,phone:t.trustee.phone||void 0}},B=()=>({tier:t.tier,allocationType:t.allocationType,percentOfDaf:t.allocationType!=="fixedAmount"?parseFloat(t.percentOfDaf)||0:void 0,fixedAmount:t.allocationType==="fixedAmount"?parseFloat(t.fixedAmount)||0:void 0}),N=()=>({dateOfBirth:t.dateOfBirth?new Date(t.dateOfBirth).getTime():void 0,minimumAge:t.minimumAge?parseInt(t.minimumAge):18,perStirpes:t.perStirpes,trustee:R(),distributionTiming:t.distributionTiming,distributionYears:t.distributionTiming==="overTime"&&t.distributionYears?parseInt(t.distributionYears):void 0,specialInstructions:t.specialInstructions||void 0});console.log(M(window.location.hostname));const I=()=>({firstName:t.firstName,lastName:t.lastName,address1:t.address1,address2:t.address2,city:t.city,state:t.state,zip:t.zip,country:t.country,type:"individual",email:t.email,relationship:t.relationship}),k=async()=>{if(T(!0),t.firstName?.trim()&&t.lastName?.trim()&&t.relationship?.trim()&&t.address1?.trim()&&t.city?.trim()&&t.country?.trim()&&(t.country?.trim()!=="United States of America (USA)"||t.state?.trim()&&t.zip?.trim()))if(!t.email||t.email&&Ze(t.email))if(!t.phone||t.phone&&t.phone.replace(/[^\d]/g,"").length>=10){if(t.minimumAge&&parseInt(t.minimumAge)<18){g("Minimum age must be at least 18"),T(!1);return}if(t.distributionTiming==="overTime"&&!t.distributionYears){g("Distribution Years is required when timing is set to Over Time"),T(!1);return}try{if(n){const i=await D({variables:{productId:r?.products?.[y]?.product?._id,successorIndex:A,branding:M(window.location.hostname),args:{...I(),phone:t.phone,...B(),...N()}}});d(i?.data?.updateSuccessor?.product,A),C&&v(r._id)}else{const z=(r?.products?.[y]?.product?.successors||[]).filter(P=>(P.tier||"primary")===t.tier).length,f=await U({variables:{productId:r.products[y]?.product._id,branding:M(window.location.hostname),successor:{...I(),phone:je(t.phone),priority:z,...B(),...N()}}});h(),C&&v(r._id),g("Successfully added successor!",{variant:"success"}),w({type:"individual",relationship:"",firstName:"",lastName:"",address1:"",address2:"",city:"",state:"",zip:"",country:"",email:"",phone:"",tier:o,allocationType:"percentage",percentOfDaf:0,fixedAmount:void 0,dateOfBirth:"",minimumAge:18,perStirpes:!1,trustee:{name:"",relationship:"",email:"",phone:""},distributionTiming:"immediate",distributionYears:"",specialInstructions:""})}}catch(i){throw console.log(i),g("Error submitting. Please contact support."),T(!1),new Error("SuccessorIndividual submithandler error:",i)}}else g("Please provide a valid phone number");else g("Please provide a valid email");else g("Please fill out all required fields");T(!1)},p={textfield:{display:"flex"}};return e.jsxs(c,{sx:{display:"flex",flexDirection:"column",maxWidth:L.content},children:[e.jsx(u,{variant:"h6",sx:{mb:1},children:"Individual Successor"}),e.jsxs(l,{container:!0,spacing:{xs:1,sm:2},sx:{width:"100%"},children:[e.jsx(l,{container:!0,spacing:{xs:1,sm:2},sx:{width:"100%"},children:e.jsx(Ce,{values:t,updateInfo:b,styles:p})}),e.jsx(l,{container:!0,spacing:{xs:1,sm:2},sx:{width:"100%"},children:e.jsx(l,{size:{xs:12,sm:4},children:e.jsx(Ke,{userKey:"relationship",value:t.relationship,onChange:i=>b("relationship",i.target.value),sx:{...p.textfield}})})}),e.jsxs(l,{container:!0,spacing:{xs:1,sm:2},sx:{width:"100%"},children:[e.jsx(l,{size:{xs:6,sm:4},children:e.jsx(x,{"data-cy":"successor-first-name",value:t.firstName,onChange:i=>b("firstName",i.target.value),label:"First Name",required:!0,sx:{...p.textfield}})}),e.jsx(l,{size:{xs:6,sm:4},children:e.jsx(x,{"data-cy":"successor-last-name",value:t.lastName,onChange:i=>b("lastName",i.target.value),label:"Last Name",required:!0,sx:{...p.textfield}})})]}),e.jsx(l,{size:{xs:6,sm:4},children:e.jsx(x,{required:!0,value:t.address1,label:"Address 1",sx:{...p.textfield},onChange:i=>b("address1",i.target.value)})}),e.jsx(l,{size:{xs:6,sm:4},children:e.jsx(x,{value:t.address2,label:"Address 2",sx:{...p.textfield},onChange:i=>b("address2",i.target.value)})}),e.jsx(l,{size:{xs:6,sm:4},children:e.jsx(x,{required:!0,value:t.city,label:"City",sx:{...p.textfield},onChange:i=>b("city",i.target.value)})}),e.jsx(l,{size:{xs:6,sm:4},children:e.jsx(Je,{label:"State",value:t.state,sxToPass:{...p.textfield},onValueChange:b,userKey:"state",required:t.country==="United States of America (USA)"})}),e.jsx(l,{size:{xs:6,sm:4},children:e.jsx(x,{required:t.country==="United States of America (USA)",label:"Zip",type:"number",value:t.zip,sx:{...p.textfield},onChange:i=>b("zip",i.target.value)})}),e.jsx(l,{size:{xs:6,sm:4},children:e.jsx(Ge,{value:t.country,sxToPass:{...p.textfield}
3,onValueChange:b,userKey:"country",required:!0})}),e.jsx(l,{size:{xs:6,sm:4},children:e.jsx(x,{value:t.email,onChange:i=>b("email",i.target.value),label:"Email",sx:{...p.textfield}})}),e.jsx(l,{size:{xs:6,sm:4},children:e.jsx(x,{value:je(t.phone),onChange:i=>b("phone",i.target.value),label:"Phone",onKeyDown:et,sx:{...p.textfield},slotProps:{htmlInput:{maxLength:18}}})})]}),e.jsxs(K,{"data-cy":"estate-planning-accordion",sx:{mt:2},children:[e.jsx(G,{expandIcon:e.jsx(ee,{}),children:e.jsx(u,{variant:"subtitle2",children:"Estate Planning Options"})}),e.jsx(J,{children:e.jsxs(l,{container:!0,spacing:2,children:[e.jsx(l,{size:{xs:6,sm:4},children:e.jsx(x,{"data-cy":"successor-dob",value:t.dateOfBirth,onChange:i=>b("dateOfBirth",i.target.value),label:"Date of Birth",type:"date",fullWidth:!0,helperText:"For age-restricted distributions",slotProps:{inputLabel:{shrink:!0}}})}),e.jsx(l,{size:{xs:6,sm:4},children:e.jsx(x,{"data-cy":"successor-minimum-age",value:t.minimumAge,onChange:i=>b("minimumAge",i.target.value),label:"Age Restriction",type:"number",fullWidth:!0,helperText:"Minimum age to re
3ceive control of funds",slotProps:{input:{endAdornment:e.jsx(ne,{position:"end",children:e.jsx(Z,{title:"Minors cannot control funds. The beneficiary receives control when they reach this age. For example: set to 18 for standard adult control, or 25 to delay until that age.",arrow:!0,placement:"top",children:e.jsx(Re,{fontSize:"small",sx:{color:"text.secondary",cursor:"help"}})})})},htmlInput:{min:18,max:100}}})}),e.jsxs(l,{size:{xs:12,sm:4},children:[e.jsx(Ye,{"data-cy":"successor-per-stirpes",control:e.jsx(Ue,{checked:t.perStirpes,onChange:i=>b("perStirpes",i.target.checked)}),label:"Per Stirpes"}),e.jsx(u,{variant:"caption",color:"text.secondary",display:"block",children:"Share passes to beneficiary's descendants if predeceased"})]}),e.jsx(Te,{values:t,updateInfo:b}),e.jsx(l,{size:12,children:e.jsx(u,{variant:"subtitle2",sx:{mt:1,mb:1},children:"Trustee/Guardian (for minors or restricted beneficiaries)"})}),e.jsx(l,{size:{xs:6,sm:3},children:e.jsx(x,{"data-cy":"successor-trustee-name",value:t.trustee?.name||"",onChange:i=>O("name",i.target.value),label:"Trustee Name",fullWidth:!0})}),e.jsx(l,{size:{xs:6,sm:3},children:e.jsx(x,{"data-cy":"successor-trustee-relationship",value:t.trustee?.relationship||"",onChange:i=>O("relationship",i.target.value),label:"Trustee Relationship",fullWidth:!0})}),e.jsx(l,{size:{xs:6,sm:3},children:e.jsx(x,{"data-cy":"successor-trustee-email",value:t.trustee?.email||"",onChange:i=>O("email",i.target.value),label:"Trustee Email",fullWidth:!0})}),e.jsx(l,{size:{xs:6,sm:3},children:e.jsx(x,{"data-cy":"successor-trustee-phone",value:t.trustee?.phone||"",onChange:i=>O("phone",i.target.value),label:"Trustee Phone",fullWidth:!0})}),e.jsx(l,{size:12,children:e.jsx(x,{"data-cy":"successor-special-instructions",value:t.specialInstructions,onChange:i=>b("specialInstructions",i.target.value),label:"Special Instructions",multiline:!0,rows:3,fullWidth:!0,helperText:"Any additional instructions or conditions",slotProps:{htmlInput:{maxLength:2e3}}})})]})})]}),e.jsx(c,{sx:{display:"flex"},children:e.jsxs(re,{id:"submitIndividualSuccessor","data-cy":"successor-submit",variant:"filledPrimary",sx:{display:"flex",...p.textfield,my:{xs:1,sm:2}},onClick:k,disabled:W,children:["Submit",W&&e.jsx(Ae,{centeredButton:!0,size:24})]})})]})}function Q({loggedInUser:r,onNewOrg:h,successorToEdit:n,successorToEditIndex:A,onEditOrg:d,defaultTier:o="primary"}){const{contextUserData:g,contextProduct:C,updateContextUser:y}=oe(),{showAlert:v}=le(),[U]=E(ve,{refetchQueries:[{query:q}]}),[D]=E(Se,{refetchQueries:[{query:q}]}),[W,T]=j.useState(!1),[t,w]=j.useState(n?{type:n.type,organizationName:n.organizationName,ein:n.ein?n.ein?.slice(0,2)+"-"+n.ein?.slice(2):"",organizationNotes:n.organizationNotes,tier:n.tier||"primary",allocationType:n.allocationType||"percentage",percentOfDaf:n.percentOfDaf,fixedAmount:n.fixedAmount,distributionTiming:n.distributionTiming||"immediate",distributionYears:n.distributionYears??"",specialInstructions:n.specialInstructions||""}:{type:"entity",organizationName:"",ein:"",organizationNotes:"",tier:o,allocationType:"percentage",percentOfDaf:0,fixedAmount:void 0,distributionTiming:"immediate",distributionYears:"",specialInstructions:""}),b=i=>{const f=i?.replace(/[^0-9]/g,"").slice(0,9);if(f?.length>=3){const P=`${f.slice(0,2)}-${f?.slice(2)}`;I("ein",P)}else I("ein",f)},O=()=>({tier:t.tier,allocationType:t.allocationType,percentOfDaf:t.allocationType!=="fixedAmount"?parseFloat(t.percentOfDaf)||0:void 0,fixedAmount:t.allocationType==="fixedAmount"?parseFloat(t.fixedAmount)||0:void 0}),R=()=>({distributionTiming:t.distributionTiming,distributionYears:t.distributionTiming==="overTime"&&t.distributionYears?parseInt(t.distributionYears):void 0,specialInstructions:t.specialInstructions||void 0}),B=()=>({organizationName:t.organizationName,ein:t.ein.replace(/-/g,""),organizationNotes:t.organizationNotes,type:"entity"}),N=async()=>{if(T(!0),t.organizationName?.trim()&&t.ein?.trim())if(t.ein?.replace(/[^\d]/g,"").length===9){if(t.distributionTiming==="overTime"&&!t.distributionYears){v("Distribution Years is required when timing is set to Over Time"),T(!1);return}try{if(n){const i=await D({variables:{productId:r?.products?.[C]?.product?._id,successorIndex:A,branding:M(window.location.hostname),args:{successorId:n._id,...B(),...O(),...R()}}});d(i?.data?.updateSuccessor?.product,A),g&&y(r._id),v("Successfully updated successor!",{variant:"success"})}else{const z=(r?.products?.[C]?.product?.successors||[]).filter(P=>(P.tier||"primary")===t.tier).length,f=await U({variables:{productId:r.products[C]?.product._id,branding:M(window.location.hostname),successor:{...B(),priority:z,...O(),...R()}}});h(),console.log("responseReturn",f.data.addSuccessorToProduct),g&&y(r._id),v("Successfully added successor!",{variant:"success"}),w({type:"entity",organizationName:"",ein:"",organizationNotes:"",tier:o,allocationType:"percentage",percentOfDaf:0,fixedAmount:void 0,distributionTiming:"immediate",distributionYears:"",specialInstructions:""})}}catch(i){throw console.log(i),v("Error submitting. Please contact support."),T(!1),new Error("SuccessOrgs submithandler error:",i)}}else v("A valid EIN must contain 9 digits. Ex: XX-XXXXXXX");else v("Please fill out all required fields");T(!1)};function I(i,z){let f={...t};f[i]=z,i==="distributionTiming"&&z==="immediate"&&(f.distributionYears=""),w(f)}const k=()=>{window.open("https://apps.irs.gov/app/eos/","_blank")},p={textfield:{display:"flex"}};return e.jsxs(c,{sx:{display:"flex",flexDirection:"column",flexWrap:"wrap",maxWidth:L.content},children:[e.jsx(u,{variant:"h6",sx:{mb:1},children:"Successor Organization"}),e.jsxs(l,{container:!0,spacing:{xs:1,sm:2},sx:{width:"100%"},children:[e.jsx(Ce,{values:t,updateInfo:I,styles:p}),e.jsx(l,{size:6,children:e.jsx(x,{required:!0,"data-cy":"successor-org-name",value:t.organizationName,label:"Organization Name",sx:{...p.textfield},onChange:i=>I("organizationName",i.target.value)})}),e.jsx(l,{size:6,children:e.jsxs(c,{sx:{...p.textfield},children:[e.jsx(x,{required:!0,"data-cy":"successor-ein",value:t.ein,label:"EIN",sx:{flex:1},onChange:i=>b(i.target.value)}),e.jsx(c,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Z,{title:"Search EIN here",placement:"right",children:e.jsx(ae,{onClick:k,children:e.jsx(Xe,{sx:{color:"primary.main"}})})})})]})}),e.jsx(l,{container:!0,spacing:{xs:1,sm:2},sx:{width:"100%"},children:e.jsx(l,{size:12,children:e.jsx(x,{label:"Notes for Organization (Optional)",value:t.organizationNotes,sx:{...p.textfield},multiline:!0,rows:3,onChange:i=>I("organizationNotes",i.target.value)})})})]}),e.jsxs(K,{"data-cy":"distribution-options-accordion",sx:{mt:2},children:[e.jsx(G,{expandIcon:e.jsx(ee,{}),children:e.jsx(u,{variant:"subtitle2",children:"Distribution Options"})}),e.jsx(J,{children:e.jsxs(l,{container:!0,spacing:2,children:[e.jsx(Te,{values:t,updateInfo:I}),e.jsx(l,{size:12,children:e.jsx(x,{"data-cy":"successor-special-instructions",value:t.specialInstructions,onChange:i=>I("specialInstructions",i.target.value),label:"Special Instructions",multiline:!0,rows:3,fullWidth:!0,helperText:"Any additional instructions or conditions for this organization",slotProps:{htmlInput:{maxLength:2e3}}})})]})})]}),e.jsx(c,{sx:{display:"flex"},children:e.jsxs(re,{id:"submitOrganizationSuccessor","data-cy":"successor-submit",variant:"filledPrimary",sx:{...p.textfield,my:{xs:1,sm:2}},onClick:N,disabled:W,children:["Submit",W&&e.jsx(Ae,{centeredButton:!0,size:24})]})})]})}const st={primary:"Primary",contingent:"Contingent",tertiary:"Tertiary"};function nt({successors:r=[]}){const h=j.useMemo(()=>{const d={byTier:{primary:[],contingent:[],tertiary:[]},totalFixed:0,percentageByTier:{primary:0,contingent:0,tertiary:0}};return r.forEach(o=>{const g=o.tier||"primary",C=o.allocationType||"percentage",v={name:o.type==="individual"?`${o.firstName} ${o.lastName}`:o.organizationName,type:C,value:C==="fixedAmount"?o.fixedAmount||0:o.percentOfDaf||0};d.byTier[g].push(v),C==="fixedAmount"?d.totalFixed+=o.fixedAmount||0:d.percentageByTier[g]+=o.percentOfDaf||0}),d},[r]),n=d=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(d),A=d=>{const o=h.byTier[d];if(o.length===0)return null;const g=o.filter(y=>y.type==="fixedAmount"),C=o.filter(y=>y.type==="percentage");return e.jsxs(c,{"data-cy":`tier-summary-${d}`,sx:{mb:2},children:[e.jsxs(u,{variant:"subtitle2",sx:{fontWeight:"bold",mb:1},children:[st[d]," Tier"]}),g.length>0&&e.jsxs(c,{sx:{ml:2,mb:1},children:[e.jsx(u,{variant:"body2",color:"text.secondary",children:"Fixed Amounts:"}),g.map((y,v)=>e.jsxs(c,{sx:{display:"flex",justifyContent:"space-between",ml:2},children:[e.jsx(u,{variant:"body2",children:y.name}),e.jsx(u,{variant:"body2",children:n(y.value)})]},v))]}),C.length>0&&e.jsxs(c,{sx:{ml:2,mb:1},children:[e.jsx(u,{variant:"body2",color:"text.secondary",children:"Percentage Allocations:"}),C.map((y,v)=>e.jsxs(c,{sx:{display:"flex",justifyContent:"space-between",ml:2},children:[e.jsx(u,{variant:"body2",children:y.name}),e.jsxs(u,{variant:"body2",children:[y.value,"%"]})]},v)),e.jsxs(c,{sx:{display:"flex",justifyContent:"space-between",ml:2,mt:.5},children:[e.jsx(u,{variant:"body2",sx:{fontWeight:"bold"},children:"Total"}),e.jsx($,{size:"small",label:`${h.percentageByTier[d]}%`,color:h.percentageByTier[d]===100?"success":h.percentageByTier[d]>100?"error":"warning"})]})]})]},d)};return r.length===0?null:e.jsxs(c,{"data-cy":"allocation-summary",sx:{p:2},children:[h.totalFixed>0&&e.jsxs(c,{"data-cy":"total-fixed-amount",sx:{mb:2},children:[e.jsxs(c,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(u,{variant:"body1",children:"Total Fixed Amounts:"}),e.jsx(u,{variant:"body1",sx:{fontWeight:"bold"},children:n(h.totalFixed)})]}),e.jsx(ge,{sx:{my:1}})]}),A("primary"),A("contingent"),A("tertiary"),e.jsx(ge,{sx:{my:2}}),e.jsxs(c,{sx:{bgcolor:"grey.50",p:1.5,borderRadius:1},children:[e.jsx(u,{variant:"subtitle2",sx:{fontWeight:"bold",mb:1},children:"How Allocations Work:"}),e.jsxs(u,{variant:"body2",color:"text.secondary",sx:{mb:1},children:[e.jsx("strong",{children:"1. Fixed Amounts"})," are distributed first as specific dollar amounts."]}),e.jsxs(u,{variant:"body2",color:"text.secondary",sx:{mb:1},children:[e.jsx("strong",{children:"2. Percentages"})," split the remaining balance after fixed amounts. They should total 100%."]}),e.jsxs(u,{variant:"body2",color:"text.secondary",sx:{mb:1},children:[e.jsx("strong",{children:"3. Tiers (Waterfall)"}),": Primary successors receive allocations first. If a primary successor is unavailable (deceased, declined, etc.), their share flows to contingent successors, and then to tert
3iary if needed."]})]})]})}const at={primary:{label:"Primary Successors",description:"First to receive allocations"},contingent:{label:"Contingent Successors",description:"Receive if primary unavailable"},tertiary:{label:"Tertiary Successors",description:"Receive if both above unavailable"}};function St({user:r}){const h=Me("(max-width:600px)"),{contextProduct:n,contextUserData:A,updateContextUser:d}=oe(),[o,g]=j.useState(r?.products?.[n]?.product?.successors||[]),[C,y]=j.useState(!1),[v,U]=j.useState(),[D,W]=j.useState(),[T,t]=j.useState(),[w,b]=j.useState("primary"),{showAlert:O}=le(),[R,B]=j.useState(null),[N,I]=j.useState(null),[k]=E(He,{refetchQueries:[{query:q}]}),p=j.useMemo(()=>{const s={primary:[],contingent:[],tertiary:[]};return o?.forEach((a,m)=>{const S=a.tier||"primary";s[S].push({...a,originalIndex:m})}),Object.keys(s).forEach(a=>{s[a].sort((m,S)=>(m.priority||0)-(S.priority||0))}),s},[o]),i=j.useMemo(()=>{const s={primary:0,contingent:0,tertiary:0};return o?.forEach(a=>{const m=a.tier||"primary";(a.allocationType||"percentage")==="percentage"&&(s[m]+=a.percentOfDaf||0)}),s},[o]),z=j.useMemo(()=>{const s={primary:!1,contingent:!1,tertiary:!1};return o?.forEach(a=>{const m=a.tier||"primary";(a.allocationType||"percentage")==="percentage"&&(s[m]=!0)}),s},[o]);j.useEffect(()=>{g(r?.products?.[n]?.product?.successors||[])},[r,n]);const[f,P]=j.useState(!1),ce=(s,a)=>{W(s),t(a),P(!0)},de=()=>P(!1),[ue,me]=j.useState(null),Ie=!!ue,ze=(s,a)=>{s.stopPropagation(),U(a),me(s.currentTarget)},xe=()=>{me(null),U(null)};j.useEffect(()=>{window.scrollTo(0,0)},[]);const V=()=>{I(null)},H=(s,a)=>{P(!1);const m=[...o];m[a]=s.successors[a],g(m)},we=async()=>{y(!0);try{await k({variables:{productId:r.products?.[n]?.product?._id,successorIndex:v,branding:M(window.location.hostname)}});const s=o.filter((a,m)=>m!==v);g(s),A&&d(r._id),O("Successfully removed successor!",{variant:"success"})}catch(s){console.log(s),O("Failed to remove successor.")}finally{y(!1),xe()}},De=s=>{B(s.currentTarget)},te=()=>{B(null)},Oe=()=>{te(),I("individual")},Ne=()=>{te(),I("organization")},pe=()=>{I(null)},Pe=s=>(s.allocationType||"percentage")==="fixedAmount"?`$${(s.fixedAmount||0).toLocaleString()}`:`${s.percentOfDaf||0}%`,he={modal:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:862,maxWidth:"95vw",maxHeight:"90vh",overflow:"auto",bgcolor:"background.paper",boxShadow:24,p:4}},Fe=s=>{if(!s)return null;const a=new Date,m=new Date(s);let S=a.getFullYear()-m.getFullYear();const Y=a.getMonth()-m.getMonth();return(Y<0||Y===0&&a.getDate()<m.getDate())&&S--,S},Be=s=>{const a=[];if(s.dateOfBirth){const m=Fe(s.dateOfBirth);m!==null&&m<18&&a.push(`Age ${m}`)}return s.minimumAge>18&&s.type==="individual"&&a.push(`Control at ${s.minimumAge}`),s.trustee?.name&&a.push(`Trustee: ${s.trustee.name}`),s.perStirpes&&a.push("Per Stirpes"),s.distributionTiming==="overTime"&&s.distributionYears&&a.push(`Over ${s.distributionYears}yr`),a},We=(s,a)=>{const m=s.tier||"primary",S=Be(s);return e.jsxs(Ee,{"data-cy":"successor-row",divider:!0,sx:{display:"flex",justifyContent:"space-between",alignItems:"center",py:1.5,gap:2},onClick:()=>ce(s,a),children:[e.jsxs(c,{sx:{display:"flex",flexDirection:"column",flex:1,minWidth:0},children:[e.jsxs(c,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[e.jsx(u,{"data-cy":"successor-name",variant:"body1",sx:{fontWeight:500},noWrap:!0,children:s.type==="individual"?`${s.firstName} ${s.lastName}`:s.organizationName}),m!=="primary"&&e.jsx($,{"data-cy":"successor-tier",label:m,size:"small",variant:"outlined",sx:{textTransform:"capitalize"}})]}),S.length>0&&e.jsx(u,{"data-cy":"successor-estate-details",variant:"caption",color:"text.secondary",sx:{mt:.25},children:S.join(" ⢠")})]}),e.jsxs(c,{sx:{display:"flex",alignItems:"center",gap:1,flexShrink:0},children:[e.jsx($,{"data-cy":"successor-allocation",label:Pe(s),size:"small",color:"primary",variant:"outlined"}),e.jsx(Z,{title:"Edit",children:e.jsx(ae,{"data-cy":"successor-edit",size:"small",onClick:Y=>{Y.stopPropagation(),ce(s,a)},children:e.jsx(Qe,{fontSize:"small"})})}),e.jsx(Z,{title:"Remove",children:e.jsx(ae,{"data-cy":"successor-delete",size:"small",onClick:Y=>ze(Y,a),children:e.jsx(Ve,{fontSize:"small",color:"error"})})})]})]},`successor-${a}`)},ie=s=>{const a=p[s],m=at[s];if(s!=="primary"&&a.length===0)return null;const S=i[s],_=z[s]?S===100?"complete":S>100?"over":"incomplete":null;return e.jsxs(K,{"data-cy":`tier-accordion-${s}`,defaultExpanded:s==="primary",sx:{mb:1},children:[e.jsx(G,{expandIcon:e.jsx(ee,{}),children:e.jsxs(c,{sx:{display:"flex",alignItems:"center",gap:2,flexGrow:1},children:[e.jsx(u,{variant:"subtitle1",sx:{fontWeight:600},children:m.label}),a.length>0&&e.jsx($,{label:a.length,size:"small",color:s==="primary"?"primary":"default"}),_&&e.jsx($,{"data-cy":`tier-allocation-status-${s}`,label:_==="complete"?`${S}%`:_==="over"?`${S}% (over)`:`${S}% of 100%`,size:"small",color:_==="complete"?"success":_==="over"?"error":"warning",variant:"outlined",sx:{ml:"auto",mr:1}})]})}),e.jsx(J,{sx:{p:0},children:a.length>0?e.jsx(qe,{variant:"outlined",children:a.map(fe=>We(fe,fe.originalIndex))}):e.jsx(u,{variant:"body2",sx:{p:2,color:"text.secondary"},children:"No successors in this tier yet."})})]},s)};return e.jsxs(e.Fragment,{children:[e.jsxs(c,{sx:{mx:{xs:2.5,sm:4},minHeight:"100vh",display:"flex",flexDirection:"column"},children:[e.jsxs(c,{sx:{mb:2},children:[e.jsx(u,{variant:"h4",sx:{color:"primary.main",mb:1},children:"Succession Plan"}),e.jsx(u,{variant:"body2",sx:{maxWidth:"700px",color:"text.secondary"},children:"Designate successors to continue your charitable legacy. Allocate fixed dollar amounts or percentages of the remaining balance. Use tiers to specify backup successorsâif a primary is unavailable, their share flows to contingent, then tertiary."})]}),h?e.jsx(ye,{anchor:"bottom",open:f,onClose:de,children:e.jsx(c,{sx:{height:"85vh",p:2,overflow:"auto"},children:D?.type==="individual"?e.jsx(X,{loggedInUser:r,successorToEdit:D,successorToEditIndex:T,onEditIndividual:H}):e.jsx(Q,{loggedInUser:r,successorToEdit:D,successorToEditIndex:T,onEditOrg:H})})}):e.jsx(be,{open:f,onClose:de,children:e.jsx(c,{sx:he.modal,children:D?.type==="individual"?e.jsx(X,{loggedInUser:r,successorToEdit:D,successorToEditIndex:T,onEditIndividual:H}):e.jsx(Q,{loggedInUser:r,successorToEdit:D,successorToEditIndex:T,onEditOrg:H})})}),e.jsxs(c,{sx:{maxWidth:L.content,my:2},children:[ie("primary"),ie("contingent"),ie("tertiary"),p.contingent.length===0&&p.tertiary.length===0&&o?.length>0&&e.jsx(u,{variant:"body2",sx:{mt:2,color:"text.secondary"},children:"Need backup successors? Add contingent or tertiary successors using the form below."})]}),o?.length>0&&e.jsx(c,{sx:{maxWidth:L.content,mb:3},children:e.jsxs(K,{"data-cy":"allocation-summary-accordion",children:[e.jsx(G,{expandIcon:e.jsx(ee,{}),children:e.jsx(u,{variant:"body2",sx:{fontWeight:500},children:"View Allocation Breakdown"})}),e.jsx(J,{sx:{p:0},children:e.jsx(nt,{successors:o})})]})}),e.jsx(it,{open:Ie,anchorEl:ue,onClose:xe,onConfirm:we,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"right"},title:"Remove this successor?",confirmLabel:"Remove",confirmColor:"error",confirmLoading:C,confirmDataCy:"confirm-remove-button"}),e.jsxs(c,{sx:{maxWidth:L.content,mb:5},children:[e.jsx(re,{"data-cy":"add-successor-button",variant:"filledPrimary",startIcon:e.jsx(ke,{}),onClick:De,children:"Add Successor"}),e.jsxs(_e,{anchorEl:R,open:!!R,onClose:te,children:[e.jsxs(F,{"data-cy":"add-indiv
3idual-option",onClick:Oe,children:[e.jsx($e,{sx:{mr:1}})," Individual"]}),e.jsxs(F,{"data-cy":"add-organization-option",onClick:Ne,children:[e.jsx(Le,{sx:{mr:1}})," Organization"]})]})]}),h?e.jsx(ye,{anchor:"bottom",open:!!N,onClose:pe,children:e.jsx(c,{sx:{height:"85vh",p:2,overflow:"auto"},children:N==="individual"?e.jsx(X,{onNewIndividual:V,loggedInUser:r,defaultTier:w}):e.jsx(Q,{loggedInUser:r,onNewOrg:V,defaultTier:w})})}):e.jsx(be,{open:!!N,onClose:pe,children:e.jsx(c,{sx:he.modal,children:N==="individual"?e.jsx(X,{onNewIndividual:V,loggedInUser:r,defaultTier:w}):e.jsx(Q,{loggedInUser:r,onNewOrg:V,defaultTier:w})})})]}),e.jsx(tt,{})]})}export{St as default}; 4//# sourceMappingURL=Successors-CQEGSvhP.js.map 5 6//# debugId=fe67382c-edf1-5ed5-82b3-258569cad778
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.