@apollosproject/canvas-embeds 2.1.464 → 2.1.465
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/widget/index.js +1 -1
package/package.json
CHANGED
package/widget/index.js
CHANGED
|
@@ -1296,7 +1296,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1296
1296
|
background-color: rgb(var(--color-brand-primary) / 0.3);
|
|
1297
1297
|
color: inherit;
|
|
1298
1298
|
}
|
|
1299
|
-
`,bX=({initialAmount:a="0",initialFrequency:e="Monthly",campus:r="",fund:n="",predefinedAmounts:l="",onError:o,isProcessing:c=!1,onShowPayment:m,persistedFormData:u,churchName:h,churchLogo:g,message:A,displayLogo:y,title:E,displayHeader:M})=>{const[O,S]=p.useState(()=>(u==null?void 0:u.amount)||a),[F,j]=p.useState(()=>u!=null&&u.selectedFrequency?u.selectedFrequency:e?Il.find(p0=>p0.id===e)||Il[2]:null),[P,N]=p.useState(null),[C,I]=p.useState(null),{campuses:z,loading:B}=WQ(),J=KS(F),W=p.useRef(null),c0=p.useRef(null),r0=p.useRef(null),a0=l?l.split(",").map(t0=>t0.trim()).filter(t0=>t0):[];p.useEffect(()=>{((u==null?void 0:u.amount)===void 0||(u==null?void 0:u.amount)===null)&&S(a)},[a,u==null?void 0:u.amount]),p.useEffect(()=>{if(!(u!=null&&u.selectedFrequency))if(e){const p0=Il.find(b0=>b0.id===e)||Il[2];j(p0)}else j(null)},[e,u==null?void 0:u.selectedFrequency]),p.useEffect(()=>{const t0=r||(u==null?void 0:u.selectedCampusId);if(t0&&z.length>0){const p0=t0.startsWith("Campus:")?t0.substring(7):t0;let b0=z.find(o0=>o0.id===p0);b0||(b0=z.find(o0=>o0.id===t0)),b0||(b0=z.find(o0=>US(t0,o0.name))),b0&&N({...b0,donationFunds:b0.donationFunds?b0.donationFunds.map(o0=>({...o0})):[]})}},[r,z,u==null?void 0:u.selectedCampusId]),p.useEffect(()=>{const t0=n||(u==null?void 0:u.selectedFundId);if(t0&&P&&P.donationFunds){let p0=P.donationFunds.find(b0=>b0.id===t0);p0||(p0=P.donationFunds.find(b0=>US(t0,b0.name)||US(t0,b0.displayName||""))),p0&&I({...p0})}},[n,P,u==null?void 0:u.selectedFundId]),p.useEffect(()=>{J&&W.current&&r0.current&&setTimeout(()=>{const t0=r0.current,p0=W.current;if(t0&&p0){const b0=t0.getBoundingClientRect();p0.getBoundingClientRect().bottom>b0.bottom&&p0.scrollIntoView({behavior:"smooth",block:"nearest"})}},100)},[J]),p.useEffect(()=>{P&&c0.current&&r0.current&&setTimeout(()=>{const t0=r0.current,p0=c0.current;if(t0&&p0){const b0=t0.getBoundingClientRect();p0.getBoundingClientRect().bottom>b0.bottom&&p0.scrollIntoView({behavior:"smooth",block:"nearest"})}},100)},[P]);const[l0,e0]=p.useState(60),q0=p.useRef(null);p.useEffect(()=>{q0.current&&e0(Math.max(q0.current.offsetWidth+16,60))},[O]);const $0=t0=>{S(t0)},A0=t0=>{const p0=z.find(b0=>b0.id===t0);N(p0?{...p0,donationFunds:p0.donationFunds?p0.donationFunds.map(b0=>({...b0})):[]}:null),I(null)},L0=t0=>{if(!P)return;const p0=P.donationFunds.find(b0=>b0.id===t0);I(p0?{...p0}:null)},Y=t0=>{const p0=Il.find(b0=>b0.id===t0);j(p0||null)},X=()=>typeof O=="string"?parseFloat(O):O,s0=()=>{const t0=X();if(!t0||t0<=0){o({message:"Please enter a valid amount"});return}if(!P){o({message:"Please select a campus"});return}if(!C){o({message:"Please select a fund"});return}m&&m(t0,gX(F),P.id,C.id,{amount:t0.toString(),selectedFrequency:F,selectedCampusId:P.id,selectedFundId:C.id})};return w.jsxs(u1,{display:"flex",flexDirection:"column",className:"h-full",children:[w.jsx("style",{children:v2e}),M!=="false"?w.jsx(ZX,{churchName:h,churchLogo:g,message:A,title:E,displayLogo:y}):null,w.jsx(u1,{flex:1,className:"min-h-0 overflow-y-auto p-6",ref:r0,children:w.jsxs(u1,{className:"space-y-4",children:[w.jsxs(u1,{className:"",children:[w.jsxs(u1,{display:"flex",alignItems:"flex-start",justifyContent:"center",className:"text-[60px] font-bold leading-none min-h-[60px]",children:[w.jsx("span",{className:"text-3xl leading-normal font-bold mt-3 flex-none text-brand",children:"$"}),w.jsx("span",{ref:q0,className:"absolute invisible h-0 overflow-hidden whitespace-pre text-[70px] font-bold font-inherit p-0 m-0",children:O||0}),w.jsx("input",{type:"number",inputMode:"decimal",placeholder:"0",value:O,onChange:t0=>$0(t0.target.value),onFocus:t0=>{setTimeout(()=>{t0.target.select()},0)},onClick:t0=>{t0.target.select()},disabled:c||B,min:"1",step:"1",className:"text-[80px] font-bold border-none outline-none bg-transparent flex-none p-0 m-0 text-brand caret-current text-center appearance-none transition-[width] duration-100 ease-in-out",style:{width:`${l0}px`}})]}),a0&&a0.length>0?w.jsx(u1,{display:"flex",flexWrap:"wrap",className:"pt-12",style:{gap:"6px"},children:a0.map(t0=>w.jsxs(Xe,{onClick:()=>$0(t0),disabled:c||B,surface:O===t0?"solid":"material",className:"min-w-0 flex-1",style:{flexBasis:"calc(25% - 4.5px)",minWidth:"0",...O===t0&&{"--btn-bg":"rgb(var(--color-brand-primary))","--btn-hover-overlay":"rgb(255 255 255 / 15%)"}},children:["$",t0]},t0))}):null]}),w.jsx(u1,{children:w.jsxs(u1,{display:"flex",children:[w.jsxs(Xe,{onClick:()=>{j(Il[2])},disabled:c||B,surface:J?"solid":"material",className:"flex-1 rounded-r-none",style:{...J&&{"--btn-bg":"rgb(var(--color-brand-primary))","--btn-hover-overlay":"rgb(255 255 255 / 15%)"}},children:[w.jsx(fK,{size:24}),"Recurring"]}),w.jsxs(Xe,{onClick:()=>j(null),disabled:c||B,surface:J?"material":"solid",className:"flex-1 rounded-l-none",style:{...!J&&{"--btn-bg":"rgb(var(--color-brand-primary))","--btn-hover-overlay":"rgb(255 255 255 / 15%)"}},children:[w.jsx(_K,{size:24}),"One time"]})]})}),J?w.jsxs(u1,{ref:W,children:[w.jsx(dZ,{mb:4,pl:16,color:"text.secondary",children:"Frequency"}),w.jsxs(JV,{value:(F==null?void 0:F.id)||"",onChange:t0=>Y(t0.target.value),disabled:c||B,required:!0,surface:"material",children:[w.jsx("option",{value:"",children:"Select a frequency"}),Il.map(t0=>w.jsx("option",{value:t0.id,children:t0.id},t0.id))]})]}):null,w.jsxs(u1,{children:[w.jsx(dZ,{mb:4,pl:16,color:"text.secondary",children:"Campus"}),w.jsxs(JV,{value:(P==null?void 0:P.id)||"",onChange:t0=>A0(t0.target.value),disabled:c||B,required:!0,surface:"material",children:[w.jsx("option",{value:"",children:B?"Loading...":"Select a campus"}),z.map(t0=>w.jsx("option",{value:t0.id,children:t0.name},t0.id))]})]}),P?w.jsxs(u1,{ref:c0,children:[w.jsx(dZ,{mb:4,pl:16,color:"text.secondary",children:"Fund"}),w.jsxs(JV,{value:(C==null?void 0:C.id)||"",onChange:t0=>L0(t0.target.value),disabled:c,required:!0,surface:"material",children:[w.jsx("option",{value:"",children:"Select a fund"}),P.donationFunds.sort((t0,p0)=>(t0.displayOrder||0)-(p0.displayOrder||0)).map(t0=>w.jsx("option",{value:t0.id,children:t0.displayName||t0.name},t0.id))]})]}):null]})}),w.jsxs(u1,{className:"sticky bottom-0 z-10 px-6 py-4 bg-system-chrome dark:bg-system-chrome-dark",children:[w.jsxs(Xe,{type:"button",className:"w-full py-3",onClick:s0,disabled:c||B||!P||!C||X()<=0,surface:"solid",children:["Give $",X()," ",J?F.id:""]}),w.jsx(u1,{className:"text-center mt-4 px-6",children:w.jsxs(xl,{color:"text.secondary",children:["By making this gift, you agree to our",w.jsx("br",{})," ",w.jsx("a",{href:"https://apollos.com/terms",target:"_blank",rel:"noopener noreferrer",className:"text-brand-primary underline",children:"Terms of Use"})," ","and"," ",w.jsx("a",{href:"https://apollos.com/privacy",target:"_blank",rel:"noopener noreferrer",className:"text-brand-primary underline",children:"Privacy Policy"}),"."]})})]})]})};bX.propTypes={initialAmount:F0.string,initialFrequency:F0.string,campus:F0.string,fund:F0.string,predefinedAmounts:F0.string,onError:F0.func.isRequired,isProcessing:F0.bool,onShowPayment:F0.func,persistedFormData:F0.shape({amount:F0.string,selectedFrequency:F0.object,selectedCampusId:F0.string,selectedFundId:F0.string}),churchName:F0.string.isRequired,churchLogo:F0.string,message:F0.string,displayLogo:F0.string,title:F0.string,displayHeader:F0.string};const HX=({onRetry:a,theme:e})=>{var r,n;return w.jsxs(u1,{className:"text-center p-6 flex flex-col items-center justify-center min-h-full",children:[w.jsx(u1,{className:"mb-6",children:w.jsx(OK,{size:64,color:((n=(r=e==null?void 0:e.colors)==null?void 0:r.base)==null?void 0:n.secondary)||"#17B582",weight:"fill"})}),w.jsx(DJ,{className:"mb-4",children:"Thank You!"}),w.jsx(Z9,{color:"text.secondary",className:"mb-12",children:"Your donation has been processed successfully."}),w.jsx(Xe,{surface:"solid",onClick:a,children:"Make Another Donation"})]})};HX.propTypes={onRetry:F0.func.isRequired};const g2e=Te(HX),EX=({amount:a="0",frequency:e="one-time",message:r="",campus:n="",fund:l="",predefinedAmounts:o="",width:c="",height:m="",displayLogo:u="",title:h="",displayHeader:g="",prefilledPayment:A=null,userFirstName:y=null,userLastName:E=null,userEmail:M=null,userPhone:O=null})=>{var j0;const S=w0=>{switch(w0){case"weekly":return"Weekly";case"every-2-weeks":return"Every 2 Weeks";case"monthly":return"Monthly";case"one-time":return null;default:return"Monthly"}},F=w0=>{if(w0==="one-time")return null;const Y0=S(w0);return Il.find(d1=>d1.id===Y0)||Il[2]},j=w0=>{if(!w0)return!1;const Y0=w0.amount&&typeof w0.amount=="string"&&parseFloat(w0.amount)>0,d1=w0.campusId&&typeof w0.campusId=="string",j1=w0.fundId===null||w0.fundId&&typeof w0.fundId=="string",f1=w0.selectedFrequency===void 0||w0.selectedFrequency===null||w0.selectedFrequency&&typeof w0.selectedFrequency=="object"&&w0.selectedFrequency.id;return Y0&&d1&&j1&&f1},[P,N]=p.useState("setup"),[C,I]=p.useState(""),[z,B]=p.useState(null),[J,W]=p.useState(!1),[c0,r0]=p.useState(null),[a0,l0]=p.useState(()=>A&&j(A)?{amount:A.amount,selectedFrequency:A.selectedFrequency??null,selectedCampusId:A.campusId,selectedFundId:A.fundId}:{amount:a,selectedFrequency:F(e),selectedCampusId:null,selectedFundId:null}),[e0,q0]=p.useState(!1),{currentChurch:$0,loading:A0,error:L0}=xc(),Y=PQ(),X=yJ1(),s0=p.useMemo(()=>{const w0={light:{primary:X.colors.base.primary,background:Ge.colors.light.fill.screen,componentBackground:Ge.colors.light.fill.paper,componentBorder:Ge.colors.light.neutral.gray5,componentDivider:Ge.colors.light.neutral.gray4,primaryText:Ge.colors.light.text.primary,secondaryText:Ge.colors.light.text.secondary,componentText:Ge.colors.light.text.primary,icon:Ge.colors.light.neutral.gray},dark:{primary:X.colors.base.secondary,background:Ge.colors.dark.fill.screen,componentBackground:Ge.colors.dark.fill.paper,componentBorder:Ge.colors.dark.neutral.gray5,componentDivider:Ge.colors.dark.neutral.gray4,primaryText:Ge.colors.dark.text.primary,secondaryText:Ge.colors.dark.text.secondary,componentText:Ge.colors.dark.text.primary,icon:Ge.colors.dark.neutral.gray}};return{theme:Y==="dark"?"night":"stripe",variables:{colorPrimary:X.colors.base.primary,colorBackground:Y==="dark"?w0.dark.componentBackground:w0.light.componentBackground,colorText:Y==="dark"?w0.dark.primaryText:w0.light.primaryText,colorTextSecondary:Y==="dark"?w0.dark.secondaryText:w0.light.secondaryText,colorTextPlaceholder:Y==="dark"?w0.dark.placeholderText:w0.light.placeholderText,colorDanger:X.colors.base.alert,colorSuccess:X.colors.base.success,colorWarning:X.colors.base.warning,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",fontSizeBase:"16px",spacingUnit:X.space.xxxs,borderRadius:X.radii.base,iconColor:Y==="dark"?w0.dark.icon:w0.light.icon}}},[X,Y]);p.useEffect(()=>{var w0;if((w0=$0==null?void 0:$0.stripeConnectAccount)!=null&&w0.publishableKey){const Y0=p2e($0.stripeConnectAccount.publishableKey);r0(Y0)}},[(j0=$0==null?void 0:$0.stripeConnectAccount)==null?void 0:j0.publishableKey]);const[t0,{loading:p0}]=f2e(),b0=p.useCallback(()=>{N("success")},[]),o0=p.useCallback(w0=>{I(w0.message)},[]),z0=p.useCallback(()=>{I("")},[]),Q=p.useCallback(()=>{N("setup"),I(""),B(null),q0(!1),l0({amount:a,selectedFrequency:F(e),selectedCampusId:null,selectedFundId:null}),W(!1)},[a,e]),h0=p.useCallback(async(w0,Y0,d1,j1)=>{var f1;try{const c1={amount:Math.round(w0*100),campusId:d1||"",fundId:j1||null};Y0==="one-time"?c1.recurring={interval:"off",intervalCount:1}:c1.recurring={interval:Y0==="monthly"?"month":"year",intervalCount:1};const{data:e1,errors:W0}=await t0({variables:{input:c1}});if(W0)throw new Error(W0[0].message);if((f1=e1==null?void 0:e1.createPaymentIntent)!=null&&f1.clientSecret)B(e1.createPaymentIntent.clientSecret),N("payment");else throw new Error("No client secret received from server")}catch(c1){o0(c1)}},[t0,o0]),v0=p.useCallback(()=>{N("setup"),B(null)},[]),Z0={width:c?isNaN(c)?c:`${c}px`:"100%",height:m?isNaN(m)?m:`${m}px`:"500px",maxWidth:c?void 0:"400px",margin:c?"0":"0 auto",border:"none",position:"relative",overflow:"hidden",padding:0},g0=A0||!c0||p0||J;if(p.useEffect(()=>{A&&j(A)&&!A0&&!p0&&!e0&&P==="setup"&&(q0(!0),l0({amount:A.amount,selectedFrequency:A.selectedFrequency??null,selectedCampusId:A.campusId,selectedFundId:A.fundId}),h0(parseFloat(A.amount),gX(A.selectedFrequency),A.campusId,A.fundId))},[A,A0,p0,e0,P,h0]),L0)return w.jsx(f4,{style:Z0,children:w.jsxs(u1,{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",p:3,children:[w.jsx(Z9,{color:"error.main",children:"Unable to load church information. Please try again later."}),w.jsx(Xe,{variant:"outlined",size:"small",onClick:Q,mt:2,children:"Try Again"})]})});if(!A0&&!c0)return w.jsx(f4,{style:Z0,children:w.jsx(u1,{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",p:3,children:w.jsx(Z9,{color:"error.main",children:"Online giving is not currently available. Please contact your church for assistance."})})});if(P==="success")return w.jsx(f4,{style:Z0,children:w.jsx(u1,{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",children:w.jsx(g2e,{onRetry:Q})})});const y0=y||E?`${y} ${E}`.trim():"",x0=($0==null?void 0:$0.name)||"Your Church";return w.jsxs(f4,{style:Z0,children:[g0?w.jsx("div",{className:"absolute inset-0 bg-material-screen dark:bg-material-screen-dark flex items-center justify-center z-[1000]",children:w.jsx(WS,{size:32,className:"animate-spin mx-auto mb-2"})}):null,C?w.jsxs(u1,{className:"absolute top-0 left-0 right-0 z-50 p-3 flex items-center gap-2 bg-red-50 dark:bg-red-900/20 rounded-xl",style:{borderColor:X.colors.base.alert},children:[w.jsx(WK,{size:20,color:X.colors.base.alert,weight:"fill"}),w.jsx(u1,{className:"flex-1",children:w.jsx(Z9,{className:"text-red-700 dark:text-red-300 font-medium text-sm",children:C})}),w.jsx(Xe,{variant:"ghost",size:"small",onClick:z0,className:"p-1 min-w-0 text-red-700 dark:text-red-300 hover:bg-red-100 dark:hover:bg-red-800/30",children:w.jsx(c9,{size:16})})]}):null,w.jsx(u1,{display:"flex",flexDirection:"column",className:"h-full min-h-[400px]",children:P==="payment"&&z&&c0?w.jsx(mX,{stripe:c0,options:{clientSecret:z,appearance:s0},children:w.jsx(yX,{amount:a0!=null&&a0.amount?parseFloat(a0.amount):parseFloat(a),selectedFrequency:a0==null?void 0:a0.selectedFrequency,selectedCampusId:a0==null?void 0:a0.selectedCampusId,selectedFundId:a0==null?void 0:a0.selectedFundId,onSuccess:b0,onError:o0,isProcessing:J,onProcessingChange:W,onBack:v0,userFullName:y0,userEmail:M,userPhone:O,churchName:x0,churchLogo:$0==null?void 0:$0.logo,message:r,displayLogo:u,title:h,displayHeader:g})}):w.jsx(w.Fragment,{children:P==="setup"&&!(A&&j(A)&&!e0)?w.jsx(bX,{initialAmount:a,initialFrequency:S(e),campus:(a0==null?void 0:a0.selectedCampusId)||a0.selectedCampusId||n,fund:(a0==null?void 0:a0.selectedFundId)||a0.selectedFundId||l,predefinedAmounts:o,onError:o0,isProcessing:p0,onShowPayment:(w0,Y0,d1,j1,f1)=>{l0({amount:f1.amount,selectedFrequency:f1.selectedFrequency,selectedCampusId:f1.selectedCampusId,selectedFundId:f1.selectedFundId}),h0(w0,Y0,d1,j1)},persistedFormData:a0,churchName:x0,churchLogo:$0==null?void 0:$0.logo,message:r,displayLogo:u,title:h,displayHeader:g}):P==="setup"&&A&&j(A)&&!e0?w.jsxs(u1,{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",className:"h-full min-h-[400px]",children:[w.jsx(WS,{size:32,className:"animate-spin mx-auto mb-2"}),w.jsx(Z9,{children:"Preparing your donation..."})]}):null})})]})};EX.propTypes={amount:F0.string,frequency:F0.oneOf(["one-time","weekly","every-2-weeks","monthly"]),message:F0.string,campus:F0.string,fund:F0.string,predefinedAmounts:F0.string,width:F0.string,height:F0.string,displayLogo:F0.string,title:F0.string,displayHeader:F0.string,prefilledPayment:F0.shape({amount:F0.string.isRequired,campusId:F0.string.isRequired,fundId:F0.string,selectedFrequency:F0.shape({id:F0.string.isRequired,intervalUnit:F0.string.isRequired,intervalCount:F0.number.isRequired})})};const A2e=Te(De.div`
|
|
1299
|
+
`,bX=({initialAmount:a="0",initialFrequency:e="Monthly",campus:r="",fund:n="",predefinedAmounts:l="",onError:o,isProcessing:c=!1,onShowPayment:m,persistedFormData:u,churchName:h,churchLogo:g,message:A,displayLogo:y,title:E,displayHeader:M})=>{const[O,S]=p.useState(()=>(u==null?void 0:u.amount)||a),[F,j]=p.useState(()=>u!=null&&u.selectedFrequency?u.selectedFrequency:e?Il.find(p0=>p0.id===e)||Il[2]:null),[P,N]=p.useState(null),[C,I]=p.useState(null),{campuses:z,loading:B}=WQ(),J=KS(F),W=p.useRef(null),c0=p.useRef(null),r0=p.useRef(null),a0=l?l.split(",").map(t0=>t0.trim()).filter(t0=>t0):[];p.useEffect(()=>{((u==null?void 0:u.amount)===void 0||(u==null?void 0:u.amount)===null)&&S(a)},[a,u==null?void 0:u.amount]),p.useEffect(()=>{if(!(u!=null&&u.selectedFrequency))if(e){const p0=Il.find(b0=>b0.id===e)||Il[2];j(p0)}else j(null)},[e,u==null?void 0:u.selectedFrequency]),p.useEffect(()=>{const t0=r||(u==null?void 0:u.selectedCampusId);if(t0&&z.length>0){const p0=t0.startsWith("Campus:")?t0.substring(7):t0;let b0=z.find(o0=>o0.id===p0);b0||(b0=z.find(o0=>o0.id===t0)),b0||(b0=z.find(o0=>US(t0,o0.name))),b0&&N({...b0,donationFunds:b0.donationFunds?b0.donationFunds.map(o0=>({...o0})):[]})}},[r,z,u==null?void 0:u.selectedCampusId]),p.useEffect(()=>{const t0=n||(u==null?void 0:u.selectedFundId);if(t0&&P&&P.donationFunds){let p0=P.donationFunds.find(b0=>b0.id===t0);p0||(p0=P.donationFunds.find(b0=>US(t0,b0.name)||US(t0,b0.displayName||""))),p0&&I({...p0})}},[n,P,u==null?void 0:u.selectedFundId]),p.useEffect(()=>{J&&W.current&&r0.current&&setTimeout(()=>{const t0=r0.current,p0=W.current;if(t0&&p0){const b0=t0.getBoundingClientRect();p0.getBoundingClientRect().bottom>b0.bottom&&p0.scrollIntoView({behavior:"smooth",block:"nearest"})}},100)},[J]),p.useEffect(()=>{P&&c0.current&&r0.current&&setTimeout(()=>{const t0=r0.current,p0=c0.current;if(t0&&p0){const b0=t0.getBoundingClientRect();p0.getBoundingClientRect().bottom>b0.bottom&&p0.scrollIntoView({behavior:"smooth",block:"nearest"})}},100)},[P]);const[l0,e0]=p.useState(60),q0=p.useRef(null);p.useEffect(()=>{q0.current&&e0(Math.max(q0.current.offsetWidth+16,60))},[O]);const $0=t0=>{S(t0)},A0=t0=>{const p0=z.find(b0=>b0.id===t0);N(p0?{...p0,donationFunds:p0.donationFunds?p0.donationFunds.map(b0=>({...b0})):[]}:null),I(null)},L0=t0=>{if(!P)return;const p0=P.donationFunds.find(b0=>b0.id===t0);I(p0?{...p0}:null)},Y=t0=>{const p0=Il.find(b0=>b0.id===t0);j(p0||null)},X=()=>typeof O=="string"?parseFloat(O):O,s0=()=>{const t0=X();if(!t0||t0<=0){o({message:"Please enter a valid amount"});return}if(!P){o({message:"Please select a campus"});return}if(!C){o({message:"Please select a fund"});return}m&&m(t0,gX(F),P.id,C.id,{amount:t0.toString(),selectedFrequency:F,selectedCampusId:P.id,selectedFundId:C.id})};return w.jsxs(u1,{display:"flex",flexDirection:"column",className:"h-full",children:[w.jsx("style",{children:v2e}),M!=="false"?w.jsx(ZX,{churchName:h,churchLogo:g,message:A,title:E,displayLogo:y}):null,w.jsx(u1,{flex:1,className:"min-h-0 overflow-y-auto p-6",ref:r0,children:w.jsxs(u1,{className:"space-y-4",children:[w.jsxs(u1,{className:"",children:[w.jsxs(u1,{display:"flex",alignItems:"flex-start",justifyContent:"center",className:"text-[60px] font-bold leading-none min-h-[60px]",children:[w.jsx("span",{className:"text-3xl leading-normal font-bold mt-3 flex-none text-brand dark:text-white",children:"$"}),w.jsx("span",{ref:q0,className:"absolute invisible h-0 overflow-hidden whitespace-pre text-[70px] font-bold font-inherit p-0 m-0",children:O||0}),w.jsx("input",{type:"number",inputMode:"decimal",placeholder:"0",value:O,onChange:t0=>$0(t0.target.value),onFocus:t0=>{setTimeout(()=>{t0.target.select()},0)},onClick:t0=>{t0.target.select()},disabled:c||B,min:"1",step:"1",className:"text-[80px] font-bold border-none outline-none bg-transparent flex-none p-0 m-0 text-brand dark:text-white caret-current text-center appearance-none transition-[width] duration-100 ease-in-out",style:{width:`${l0}px`}})]}),a0&&a0.length>0?w.jsx(u1,{display:"flex",flexWrap:"wrap",className:"pt-12",style:{gap:"6px"},children:a0.map(t0=>w.jsxs(Xe,{onClick:()=>$0(t0),disabled:c||B,surface:O===t0?"solid":"material",className:"min-w-0 flex-1",style:{flexBasis:"calc(25% - 4.5px)",minWidth:"0",...O===t0&&{"--btn-bg":"rgb(var(--color-brand-primary))","--btn-hover-overlay":"rgb(255 255 255 / 15%)"}},children:["$",t0]},t0))}):null]}),w.jsx(u1,{children:w.jsxs(u1,{display:"flex",children:[w.jsxs(Xe,{onClick:()=>{j(Il[2])},disabled:c||B,surface:J?"solid":"material",className:"flex-1 rounded-r-none",style:{...J&&{"--btn-bg":"rgb(var(--color-brand-primary))","--btn-hover-overlay":"rgb(255 255 255 / 15%)"}},children:[w.jsx(fK,{size:24}),"Recurring"]}),w.jsxs(Xe,{onClick:()=>j(null),disabled:c||B,surface:J?"material":"solid",className:"flex-1 rounded-l-none",style:{...!J&&{"--btn-bg":"rgb(var(--color-brand-primary))","--btn-hover-overlay":"rgb(255 255 255 / 15%)"}},children:[w.jsx(_K,{size:24}),"One time"]})]})}),J?w.jsxs(u1,{ref:W,children:[w.jsx(dZ,{mb:4,pl:16,color:"text.secondary",children:"Frequency"}),w.jsxs(JV,{value:(F==null?void 0:F.id)||"",onChange:t0=>Y(t0.target.value),disabled:c||B,required:!0,surface:"material",children:[w.jsx("option",{value:"",children:"Select a frequency"}),Il.map(t0=>w.jsx("option",{value:t0.id,children:t0.id},t0.id))]})]}):null,w.jsxs(u1,{children:[w.jsx(dZ,{mb:4,pl:16,color:"text.secondary",children:"Campus"}),w.jsxs(JV,{value:(P==null?void 0:P.id)||"",onChange:t0=>A0(t0.target.value),disabled:c||B,required:!0,surface:"material",children:[w.jsx("option",{value:"",children:B?"Loading...":"Select a campus"}),z.map(t0=>w.jsx("option",{value:t0.id,children:t0.name},t0.id))]})]}),P?w.jsxs(u1,{ref:c0,children:[w.jsx(dZ,{mb:4,pl:16,color:"text.secondary",children:"Fund"}),w.jsxs(JV,{value:(C==null?void 0:C.id)||"",onChange:t0=>L0(t0.target.value),disabled:c,required:!0,surface:"material",children:[w.jsx("option",{value:"",children:"Select a fund"}),P.donationFunds.sort((t0,p0)=>(t0.displayOrder||0)-(p0.displayOrder||0)).map(t0=>w.jsx("option",{value:t0.id,children:t0.displayName||t0.name},t0.id))]})]}):null]})}),w.jsxs(u1,{className:"sticky bottom-0 z-10 px-6 py-4 bg-system-chrome dark:bg-system-chrome-dark",children:[w.jsxs(Xe,{type:"button",className:"w-full py-3",onClick:s0,disabled:c||B||!P||!C||X()<=0,surface:"solid",children:["Give $",X()," ",J?F.id:""]}),w.jsx(u1,{className:"text-center mt-4 px-6",children:w.jsxs(xl,{color:"text.secondary",children:["By making this gift, you agree to our",w.jsx("br",{})," ",w.jsx("a",{href:"https://apollos.com/terms",target:"_blank",rel:"noopener noreferrer",className:"text-brand-primary underline",children:"Terms of Use"})," ","and"," ",w.jsx("a",{href:"https://apollos.com/privacy",target:"_blank",rel:"noopener noreferrer",className:"text-brand-primary underline",children:"Privacy Policy"}),"."]})})]})]})};bX.propTypes={initialAmount:F0.string,initialFrequency:F0.string,campus:F0.string,fund:F0.string,predefinedAmounts:F0.string,onError:F0.func.isRequired,isProcessing:F0.bool,onShowPayment:F0.func,persistedFormData:F0.shape({amount:F0.string,selectedFrequency:F0.object,selectedCampusId:F0.string,selectedFundId:F0.string}),churchName:F0.string.isRequired,churchLogo:F0.string,message:F0.string,displayLogo:F0.string,title:F0.string,displayHeader:F0.string};const HX=({onRetry:a,theme:e})=>{var r,n;return w.jsxs(u1,{className:"text-center p-6 flex flex-col items-center justify-center min-h-full",children:[w.jsx(u1,{className:"mb-6",children:w.jsx(OK,{size:64,color:((n=(r=e==null?void 0:e.colors)==null?void 0:r.base)==null?void 0:n.secondary)||"#17B582",weight:"fill"})}),w.jsx(DJ,{className:"mb-4",children:"Thank You!"}),w.jsx(Z9,{color:"text.secondary",className:"mb-12",children:"Your donation has been processed successfully."}),w.jsx(Xe,{surface:"solid",onClick:a,children:"Make Another Donation"})]})};HX.propTypes={onRetry:F0.func.isRequired};const g2e=Te(HX),EX=({amount:a="0",frequency:e="one-time",message:r="",campus:n="",fund:l="",predefinedAmounts:o="",width:c="",height:m="",displayLogo:u="",title:h="",displayHeader:g="",prefilledPayment:A=null,userFirstName:y=null,userLastName:E=null,userEmail:M=null,userPhone:O=null})=>{var j0;const S=w0=>{switch(w0){case"weekly":return"Weekly";case"every-2-weeks":return"Every 2 Weeks";case"monthly":return"Monthly";case"one-time":return null;default:return"Monthly"}},F=w0=>{if(w0==="one-time")return null;const Y0=S(w0);return Il.find(d1=>d1.id===Y0)||Il[2]},j=w0=>{if(!w0)return!1;const Y0=w0.amount&&typeof w0.amount=="string"&&parseFloat(w0.amount)>0,d1=w0.campusId&&typeof w0.campusId=="string",j1=w0.fundId===null||w0.fundId&&typeof w0.fundId=="string",f1=w0.selectedFrequency===void 0||w0.selectedFrequency===null||w0.selectedFrequency&&typeof w0.selectedFrequency=="object"&&w0.selectedFrequency.id;return Y0&&d1&&j1&&f1},[P,N]=p.useState("setup"),[C,I]=p.useState(""),[z,B]=p.useState(null),[J,W]=p.useState(!1),[c0,r0]=p.useState(null),[a0,l0]=p.useState(()=>A&&j(A)?{amount:A.amount,selectedFrequency:A.selectedFrequency??null,selectedCampusId:A.campusId,selectedFundId:A.fundId}:{amount:a,selectedFrequency:F(e),selectedCampusId:null,selectedFundId:null}),[e0,q0]=p.useState(!1),{currentChurch:$0,loading:A0,error:L0}=xc(),Y=PQ(),X=yJ1(),s0=p.useMemo(()=>{const w0={light:{primary:X.colors.base.primary,background:Ge.colors.light.fill.screen,componentBackground:Ge.colors.light.fill.paper,componentBorder:Ge.colors.light.neutral.gray5,componentDivider:Ge.colors.light.neutral.gray4,primaryText:Ge.colors.light.text.primary,secondaryText:Ge.colors.light.text.secondary,componentText:Ge.colors.light.text.primary,icon:Ge.colors.light.neutral.gray},dark:{primary:X.colors.base.secondary,background:Ge.colors.dark.fill.screen,componentBackground:Ge.colors.dark.fill.paper,componentBorder:Ge.colors.dark.neutral.gray5,componentDivider:Ge.colors.dark.neutral.gray4,primaryText:Ge.colors.dark.text.primary,secondaryText:Ge.colors.dark.text.secondary,componentText:Ge.colors.dark.text.primary,icon:Ge.colors.dark.neutral.gray}};return{theme:Y==="dark"?"night":"stripe",variables:{colorPrimary:X.colors.base.primary,colorBackground:Y==="dark"?w0.dark.componentBackground:w0.light.componentBackground,colorText:Y==="dark"?w0.dark.primaryText:w0.light.primaryText,colorTextSecondary:Y==="dark"?w0.dark.secondaryText:w0.light.secondaryText,colorTextPlaceholder:Y==="dark"?w0.dark.placeholderText:w0.light.placeholderText,colorDanger:X.colors.base.alert,colorSuccess:X.colors.base.success,colorWarning:X.colors.base.warning,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",fontSizeBase:"16px",spacingUnit:X.space.xxxs,borderRadius:X.radii.base,iconColor:Y==="dark"?w0.dark.icon:w0.light.icon}}},[X,Y]);p.useEffect(()=>{var w0;if((w0=$0==null?void 0:$0.stripeConnectAccount)!=null&&w0.publishableKey){const Y0=p2e($0.stripeConnectAccount.publishableKey);r0(Y0)}},[(j0=$0==null?void 0:$0.stripeConnectAccount)==null?void 0:j0.publishableKey]);const[t0,{loading:p0}]=f2e(),b0=p.useCallback(()=>{N("success")},[]),o0=p.useCallback(w0=>{I(w0.message)},[]),z0=p.useCallback(()=>{I("")},[]),Q=p.useCallback(()=>{N("setup"),I(""),B(null),q0(!1),l0({amount:a,selectedFrequency:F(e),selectedCampusId:null,selectedFundId:null}),W(!1)},[a,e]),h0=p.useCallback(async(w0,Y0,d1,j1)=>{var f1;try{const c1={amount:Math.round(w0*100),campusId:d1||"",fundId:j1||null};Y0==="one-time"?c1.recurring={interval:"off",intervalCount:1}:c1.recurring={interval:Y0==="monthly"?"month":"year",intervalCount:1};const{data:e1,errors:W0}=await t0({variables:{input:c1}});if(W0)throw new Error(W0[0].message);if((f1=e1==null?void 0:e1.createPaymentIntent)!=null&&f1.clientSecret)B(e1.createPaymentIntent.clientSecret),N("payment");else throw new Error("No client secret received from server")}catch(c1){o0(c1)}},[t0,o0]),v0=p.useCallback(()=>{N("setup"),B(null)},[]),Z0={width:c?isNaN(c)?c:`${c}px`:"100%",height:m?isNaN(m)?m:`${m}px`:"500px",maxWidth:c?void 0:"400px",margin:c?"0":"0 auto",border:"none",position:"relative",overflow:"hidden",padding:0},g0=A0||!c0||p0||J;if(p.useEffect(()=>{A&&j(A)&&!A0&&!p0&&!e0&&P==="setup"&&(q0(!0),l0({amount:A.amount,selectedFrequency:A.selectedFrequency??null,selectedCampusId:A.campusId,selectedFundId:A.fundId}),h0(parseFloat(A.amount),gX(A.selectedFrequency),A.campusId,A.fundId))},[A,A0,p0,e0,P,h0]),L0)return w.jsx(f4,{style:Z0,children:w.jsxs(u1,{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",p:3,children:[w.jsx(Z9,{color:"error.main",children:"Unable to load church information. Please try again later."}),w.jsx(Xe,{variant:"outlined",size:"small",onClick:Q,mt:2,children:"Try Again"})]})});if(!A0&&!c0)return w.jsx(f4,{style:Z0,children:w.jsx(u1,{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",p:3,children:w.jsx(Z9,{color:"error.main",children:"Online giving is not currently available. Please contact your church for assistance."})})});if(P==="success")return w.jsx(f4,{style:Z0,children:w.jsx(u1,{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",children:w.jsx(g2e,{onRetry:Q})})});const y0=y||E?`${y} ${E}`.trim():"",x0=($0==null?void 0:$0.name)||"Your Church";return w.jsxs(f4,{style:Z0,children:[g0?w.jsx("div",{className:"absolute inset-0 bg-material-screen dark:bg-material-screen-dark flex items-center justify-center z-[1000]",children:w.jsx(WS,{size:32,className:"animate-spin mx-auto mb-2"})}):null,C?w.jsxs(u1,{className:"absolute top-0 left-0 right-0 z-50 p-3 flex items-center gap-2 bg-red-50 dark:bg-red-900/20 rounded-xl",style:{borderColor:X.colors.base.alert},children:[w.jsx(WK,{size:20,color:X.colors.base.alert,weight:"fill"}),w.jsx(u1,{className:"flex-1",children:w.jsx(Z9,{className:"text-red-700 dark:text-red-300 font-medium text-sm",children:C})}),w.jsx(Xe,{variant:"ghost",size:"small",onClick:z0,className:"p-1 min-w-0 text-red-700 dark:text-red-300 hover:bg-red-100 dark:hover:bg-red-800/30",children:w.jsx(c9,{size:16})})]}):null,w.jsx(u1,{display:"flex",flexDirection:"column",className:"h-full min-h-[400px]",children:P==="payment"&&z&&c0?w.jsx(mX,{stripe:c0,options:{clientSecret:z,appearance:s0},children:w.jsx(yX,{amount:a0!=null&&a0.amount?parseFloat(a0.amount):parseFloat(a),selectedFrequency:a0==null?void 0:a0.selectedFrequency,selectedCampusId:a0==null?void 0:a0.selectedCampusId,selectedFundId:a0==null?void 0:a0.selectedFundId,onSuccess:b0,onError:o0,isProcessing:J,onProcessingChange:W,onBack:v0,userFullName:y0,userEmail:M,userPhone:O,churchName:x0,churchLogo:$0==null?void 0:$0.logo,message:r,displayLogo:u,title:h,displayHeader:g})}):w.jsx(w.Fragment,{children:P==="setup"&&!(A&&j(A)&&!e0)?w.jsx(bX,{initialAmount:a,initialFrequency:S(e),campus:(a0==null?void 0:a0.selectedCampusId)||a0.selectedCampusId||n,fund:(a0==null?void 0:a0.selectedFundId)||a0.selectedFundId||l,predefinedAmounts:o,onError:o0,isProcessing:p0,onShowPayment:(w0,Y0,d1,j1,f1)=>{l0({amount:f1.amount,selectedFrequency:f1.selectedFrequency,selectedCampusId:f1.selectedCampusId,selectedFundId:f1.selectedFundId}),h0(w0,Y0,d1,j1)},persistedFormData:a0,churchName:x0,churchLogo:$0==null?void 0:$0.logo,message:r,displayLogo:u,title:h,displayHeader:g}):P==="setup"&&A&&j(A)&&!e0?w.jsxs(u1,{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",className:"h-full min-h-[400px]",children:[w.jsx(WS,{size:32,className:"animate-spin mx-auto mb-2"}),w.jsx(Z9,{children:"Preparing your donation..."})]}):null})})]})};EX.propTypes={amount:F0.string,frequency:F0.oneOf(["one-time","weekly","every-2-weeks","monthly"]),message:F0.string,campus:F0.string,fund:F0.string,predefinedAmounts:F0.string,width:F0.string,height:F0.string,displayLogo:F0.string,title:F0.string,displayHeader:F0.string,prefilledPayment:F0.shape({amount:F0.string.isRequired,campusId:F0.string.isRequired,fundId:F0.string,selectedFrequency:F0.shape({id:F0.string.isRequired,intervalUnit:F0.string.isRequired,intervalCount:F0.number.isRequired})})};const A2e=Te(De.div`
|
|
1300
1300
|
display: flex;
|
|
1301
1301
|
padding: ${we("space.xs")};
|
|
1302
1302
|
border-radius: ${we("radii.xl")};
|