Package not found. Please check the package name and try again.
@apollosproject/canvas-embeds 2.1.417 → 2.1.419
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
|
@@ -1283,7 +1283,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1283
1283
|
background-color: rgb(var(--color-brand-primary) / 0.3);
|
|
1284
1284
|
color: inherit;
|
|
1285
1285
|
}
|
|
1286
|
-
`,lX=({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:Z,displayLogo:b,title:E,displayHeader:M})=>{const[O,w]=p.useState(()=>(u==null?void 0:u.amount)||a),[F,j]=p.useState(()=>u!=null&&u.selectedFrequency?u.selectedFrequency:e?Tl.find(p0=>p0.id===e)||Tl[2]:null),[k,N]=p.useState(null),[C,I]=p.useState(null),{campuses:z,loading:B}=AJ1(),X=UL(F),W=p.useRef(null),c0=p.useRef(null),a0=p.useRef(null),n0=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)&&w(a)},[a,u==null?void 0:u.amount]),p.useEffect(()=>{if(!(u!=null&&u.selectedFrequency))if(e){const p0=Tl.find(y0=>y0.id===e)||Tl[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 y0=z.find(l0=>l0.id===p0);y0||(y0=z.find(l0=>l0.id===t0)),y0||(y0=z.find(l0=>NL(t0,l0.name))),y0&&N({...y0,donationFunds:y0.donationFunds?y0.donationFunds.map(l0=>({...l0})):[]})}},[r,z,u==null?void 0:u.selectedCampusId]),p.useEffect(()=>{const t0=n||(u==null?void 0:u.selectedFundId);if(t0&&k&&k.donationFunds){let p0=k.donationFunds.find(y0=>y0.id===t0);p0||(p0=k.donationFunds.find(y0=>NL(t0,y0.name)||NL(t0,y0.displayName||""))),p0&&I({...p0})}},[n,k,u==null?void 0:u.selectedFundId]),p.useEffect(()=>{X&&W.current&&a0.current&&setTimeout(()=>{const t0=a0.current,p0=W.current;if(t0&&p0){const y0=t0.getBoundingClientRect();p0.getBoundingClientRect().bottom>y0.bottom&&p0.scrollIntoView({behavior:"smooth",block:"nearest"})}},100)},[X]),p.useEffect(()=>{k&&c0.current&&a0.current&&setTimeout(()=>{const t0=a0.current,p0=c0.current;if(t0&&p0){const y0=t0.getBoundingClientRect();p0.getBoundingClientRect().bottom>y0.bottom&&p0.scrollIntoView({behavior:"smooth",block:"nearest"})}},100)},[k]);const[o0,J]=p.useState(60),U0=p.useRef(null);p.useEffect(()=>{U0.current&&J(Math.max(U0.current.offsetWidth+16,60))},[O]);const w0=t0=>{w(t0)},b0=t0=>{const p0=z.find(y0=>y0.id===t0);N(p0?{...p0,donationFunds:p0.donationFunds?p0.donationFunds.map(y0=>({...y0})):[]}:null),I(null)},L0=t0=>{if(!k)return;const p0=k.donationFunds.find(y0=>y0.id===t0);I(p0?{...p0}:null)},G=t0=>{const p0=Tl.find(y0=>y0.id===t0);j(p0||null)},e0=()=>typeof O=="string"?parseFloat(O):O,s0=()=>{const t0=e0();if(!t0||t0<=0){o({message:"Please enter a valid amount"});return}if(!k){o({message:"Please select a campus"});return}if(!C){o({message:"Please select a fund"});return}m&&m(t0,tX(F),k.id,C.id,{amount:t0.toString(),selectedFrequency:F,selectedCampusId:k.id,selectedFundId:C.id})};return S.jsxs(H1,{display:"flex",flexDirection:"column",className:"h-full",children:[S.jsx("style",{children:Nee}),M!=="false"?S.jsx(rX,{churchName:h,churchLogo:g,message:Z,title:E,displayLogo:b}):null,S.jsx(H1,{flex:1,className:"min-h-0 overflow-y-auto p-6",ref:a0,children:S.jsxs(H1,{className:"space-y-4",children:[S.jsxs(H1,{className:"",children:[S.jsxs(H1,{display:"flex",alignItems:"flex-start",justifyContent:"center",className:"text-[60px] font-bold leading-none min-h-[60px]",children:[S.jsx("span",{className:"text-3xl leading-normal font-bold mt-3 flex-none text-brand",children:"$"}),S.jsx("span",{ref:U0,className:"absolute invisible h-0 overflow-hidden whitespace-pre text-[70px] font-bold font-inherit p-0 m-0",children:O||0}),S.jsx("input",{type:"number",inputMode:"decimal",placeholder:"0",value:O,onChange:t0=>w0(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:`${o0}px`}})]}),n0&&n0.length>0?S.jsx(H1,{display:"flex",flexWrap:"wrap",className:"pt-12",style:{gap:"6px"},children:n0.map(t0=>S.jsxs(b2,{onClick:()=>w0(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]}),S.jsx(H1,{children:S.jsxs(H1,{display:"flex",children:[S.jsxs(b2,{onClick:()=>{j(Tl[2])},disabled:c||B,surface:X?"solid":"material",className:"flex-1 rounded-r-none",style:{...X&&{"--btn-bg":"rgb(var(--color-brand-primary))","--btn-hover-overlay":"rgb(255 255 255 / 15%)"}},children:[S.jsx(aK,{size:24}),"Recurring"]}),S.jsxs(b2,{onClick:()=>j(null),disabled:c||B,surface:X?"material":"solid",className:"flex-1 rounded-l-none",style:{...!X&&{"--btn-bg":"rgb(var(--color-brand-primary))","--btn-hover-overlay":"rgb(255 255 255 / 15%)"}},children:[S.jsx(HK,{size:24}),"One time"]})]})}),X?S.jsxs(H1,{ref:W,children:[S.jsx(sZ,{mb:4,pl:16,color:"text.secondary",children:"Frequency"}),S.jsxs(BV,{value:(F==null?void 0:F.id)||"",onChange:t0=>G(t0.target.value),disabled:c||B,required:!0,surface:"material",children:[S.jsx("option",{value:"",children:"Select a frequency"}),Tl.map(t0=>S.jsx("option",{value:t0.id,children:t0.id},t0.id))]})]}):null,S.jsxs(H1,{children:[S.jsx(sZ,{mb:4,pl:16,color:"text.secondary",children:"Campus"}),S.jsxs(BV,{value:(k==null?void 0:k.id)||"",onChange:t0=>b0(t0.target.value),disabled:c||B,required:!0,surface:"material",children:[S.jsx("option",{value:"",children:B?"Loading...":"Select a campus"}),z.map(t0=>S.jsx("option",{value:t0.id,children:t0.name},t0.id))]})]}),k?S.jsxs(H1,{ref:c0,children:[S.jsx(sZ,{mb:4,pl:16,color:"text.secondary",children:"Fund"}),S.jsxs(BV,{value:(C==null?void 0:C.id)||"",onChange:t0=>L0(t0.target.value),disabled:c,required:!0,surface:"material",children:[S.jsx("option",{value:"",children:"Select a fund"}),k.donationFunds.sort((t0,p0)=>(t0.displayOrder||0)-(p0.displayOrder||0)).map(t0=>S.jsx("option",{value:t0.id,children:t0.displayName||t0.name},t0.id))]})]}):null]})}),S.jsxs(H1,{className:"sticky bottom-0 z-10 px-6 py-4 bg-system-chrome dark:bg-system-chrome-dark",children:[S.jsxs(b2,{type:"button",className:"w-full py-3",onClick:s0,disabled:c||B||!k||!C||e0()<=0,surface:"solid",children:["Give $",e0()," ",X?F.id:""]}),S.jsx(H1,{className:"text-center mt-4 px-6",children:S.jsxs(cZ,{color:"text.secondary",children:["By making this gift, you agree to our",S.jsx("br",{})," ",S.jsx("a",{href:"https://apollos.com/terms",target:"_blank",rel:"noopener noreferrer",className:"text-brand-primary underline",children:"Terms of Use"})," ","and"," ",S.jsx("a",{href:"https://apollos.com/privacy",target:"_blank",rel:"noopener noreferrer",className:"text-brand-primary underline",children:"Privacy Policy"}),"."]})})]})]})};lX.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 oX=({onRetry:a,theme:e})=>{var r,n;return S.jsxs(H1,{className:"text-center p-6 flex flex-col items-center justify-center min-h-full",children:[S.jsx(H1,{className:"mb-6",children:S.jsx(pK,{size:64,color:((n=(r=e==null?void 0:e.colors)==null?void 0:r.base)==null?void 0:n.secondary)||"#17B582",weight:"fill"})}),S.jsx(MJ,{className:"mb-4",children:"Thank You!"}),S.jsx(iZ,{color:"text.secondary",className:"mb-12",children:"Your donation has been processed successfully."}),S.jsx(b2,{surface:"solid",onClick:a,children:"Make Another Donation"})]})};oX.propTypes={onRetry:F0.func.isRequired};const Tee=Te(oX),Iee=kee(void 0),iX=({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:Z=null})=>{const b=G=>{switch(G){case"weekly":return"Weekly";case"every-2-weeks":return"Every 2 Weeks";case"monthly":return"Monthly";case"one-time":return null;default:return"Monthly"}},E=G=>{if(!G)return!1;const e0=G.amount&&typeof G.amount=="string"&&parseFloat(G.amount)>0,s0=G.campusId&&typeof G.campusId=="string",t0=G.fundId===null||G.fundId&&typeof G.fundId=="string",p0=G.selectedFrequency===void 0||G.selectedFrequency===null||G.selectedFrequency&&typeof G.selectedFrequency=="object"&&G.selectedFrequency.id;return e0&&s0&&t0&&p0},[M,O]=p.useState("setup"),[w,F]=p.useState(""),[j,k]=p.useState(null),[N,C]=p.useState(()=>Z&&E(Z)?{amount:Z.amount,selectedFrequency:Z.selectedFrequency??null,selectedCampusId:Z.campusId,selectedFundId:Z.fundId}:{amount:a,selectedFrequency:e!=="one-time"?(()=>{const G=b(e);return Tl.find(e0=>e0.id===G)||Tl[2]})():null,selectedCampusId:null,selectedFundId:null}),[I,z]=p.useState(!1),{currentChurch:B,loading:X}=Ic(),[W,{loading:c0}]=Cee(),a0=p.useCallback(()=>{O("success")},[]),n0=p.useCallback(G=>{F(G.message)},[]),o0=p.useCallback(()=>{O("setup"),F(""),k(null),z(!1)},[]),J=p.useCallback(async(G,e0,s0,t0)=>{var p0;try{const y0={amount:Math.round(G*100),campusId:s0||"",fundId:t0||null};e0==="one-time"?y0.recurring={interval:"off",intervalCount:1}:y0.recurring={interval:e0==="monthly"?"month":"year",intervalCount:1};const{data:l0,errors:D0}=await W({variables:{input:y0}});if(D0)throw new Error(D0[0].message);if((p0=l0==null?void 0:l0.createPaymentIntent)!=null&&p0.clientSecret)k(l0.createPaymentIntent.clientSecret),O("payment");else throw new Error("No client secret received from server")}catch(y0){n0(y0)}},[W,n0]),U0=p.useCallback(()=>{O("setup"),k(null)},[]),w0={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},b0=X||c0;if(p.useEffect(()=>{Z&&E(Z)&&!X&&!c0&&!I&&M==="setup"&&(z(!0),C({amount:Z.amount,selectedFrequency:Z.selectedFrequency??null,selectedCampusId:Z.campusId,selectedFundId:Z.fundId}),J(parseFloat(Z.amount),tX(Z.selectedFrequency),Z.campusId,Z.fundId))},[Z,X,c0,I,M,J]),M==="success")return S.jsx(Vr,{style:w0,children:S.jsx(H1,{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",children:S.jsx(Tee,{onRetry:o0})})});const L0=(B==null?void 0:B.name)||"Your Church";return S.jsxs(Vr,{style:w0,children:[b0?S.jsx("div",{className:"absolute inset-0 bg-material-screen dark:bg-material-screen-dark flex items-center justify-center z-[1000]",children:S.jsx(DL,{size:32,className:"animate-spin mx-auto mb-2"})}):null,S.jsxs(H1,{display:"flex",flexDirection:"column",className:"h-full min-h-[400px]",children:[M==="payment"&&j?S.jsx(GK,{stripe:Iee,options:{clientSecret:j},children:S.jsx(nX,{amount:N!=null&&N.amount?parseFloat(N.amount):parseFloat(a),selectedFrequency:N==null?void 0:N.selectedFrequency,onSuccess:a0,onError:n0,isProcessing:c0,onBack:U0,churchName:L0,churchLogo:B==null?void 0:B.logo,message:r,displayLogo:u,title:h,displayHeader:g})}):S.jsx(S.Fragment,{children:M==="setup"&&!(Z&&E(Z)&&!I)?S.jsx(lX,{initialAmount:a,initialFrequency:b(e),campus:(N==null?void 0:N.selectedCampusId)||N.selectedCampusId||n,fund:(N==null?void 0:N.selectedFundId)||N.selectedFundId||l,predefinedAmounts:o,onError:n0,isProcessing:c0,onShowPayment:(G,e0,s0,t0,p0)=>{C({amount:p0.amount,selectedFrequency:p0.selectedFrequency,selectedCampusId:p0.selectedCampusId,selectedFundId:p0.selectedFundId}),J(G,e0,s0,t0)},persistedFormData:N,churchName:L0,churchLogo:B==null?void 0:B.logo,message:r,displayLogo:u,title:h,displayHeader:g}):M==="setup"&&Z&&E(Z)&&!I?S.jsxs(H1,{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",className:"h-full min-h-[400px]",children:[S.jsx(DL,{size:32,className:"animate-spin mx-auto mb-2"}),S.jsx(iZ,{children:"Preparing your donation..."})]}):null}),w?S.jsxs(H1,{mt:3,p:3,bg:"error.light",borderRadius:"md",children:[S.jsx(iZ,{color:"error.main",children:w}),S.jsx(b2,{variant:"outlined",size:"small",onClick:o0,mt:2,children:"Try Again"})]}):null]})]})};iX.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 Dee=Te(De.div`
|
|
1286
|
+
`,lX=({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:Z,displayLogo:b,title:E,displayHeader:M})=>{const[O,w]=p.useState(()=>(u==null?void 0:u.amount)||a),[F,j]=p.useState(()=>u!=null&&u.selectedFrequency?u.selectedFrequency:e?Tl.find(p0=>p0.id===e)||Tl[2]:null),[k,N]=p.useState(null),[C,I]=p.useState(null),{campuses:z,loading:B}=AJ1(),X=UL(F),W=p.useRef(null),c0=p.useRef(null),a0=p.useRef(null),n0=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)&&w(a)},[a,u==null?void 0:u.amount]),p.useEffect(()=>{if(!(u!=null&&u.selectedFrequency))if(e){const p0=Tl.find(y0=>y0.id===e)||Tl[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 y0=z.find(l0=>l0.id===p0);y0||(y0=z.find(l0=>l0.id===t0)),y0||(y0=z.find(l0=>NL(t0,l0.name))),y0&&N({...y0,donationFunds:y0.donationFunds?y0.donationFunds.map(l0=>({...l0})):[]})}},[r,z,u==null?void 0:u.selectedCampusId]),p.useEffect(()=>{const t0=n||(u==null?void 0:u.selectedFundId);if(t0&&k&&k.donationFunds){let p0=k.donationFunds.find(y0=>y0.id===t0);p0||(p0=k.donationFunds.find(y0=>NL(t0,y0.name)||NL(t0,y0.displayName||""))),p0&&I({...p0})}},[n,k,u==null?void 0:u.selectedFundId]),p.useEffect(()=>{X&&W.current&&a0.current&&setTimeout(()=>{const t0=a0.current,p0=W.current;if(t0&&p0){const y0=t0.getBoundingClientRect();p0.getBoundingClientRect().bottom>y0.bottom&&p0.scrollIntoView({behavior:"smooth",block:"nearest"})}},100)},[X]),p.useEffect(()=>{k&&c0.current&&a0.current&&setTimeout(()=>{const t0=a0.current,p0=c0.current;if(t0&&p0){const y0=t0.getBoundingClientRect();p0.getBoundingClientRect().bottom>y0.bottom&&p0.scrollIntoView({behavior:"smooth",block:"nearest"})}},100)},[k]);const[o0,J]=p.useState(60),U0=p.useRef(null);p.useEffect(()=>{U0.current&&J(Math.max(U0.current.offsetWidth+16,60))},[O]);const w0=t0=>{w(t0)},b0=t0=>{const p0=z.find(y0=>y0.id===t0);N(p0?{...p0,donationFunds:p0.donationFunds?p0.donationFunds.map(y0=>({...y0})):[]}:null),I(null)},L0=t0=>{if(!k)return;const p0=k.donationFunds.find(y0=>y0.id===t0);I(p0?{...p0}:null)},G=t0=>{const p0=Tl.find(y0=>y0.id===t0);j(p0||null)},e0=()=>typeof O=="string"?parseFloat(O):O,s0=()=>{const t0=e0();if(!t0||t0<=0){o({message:"Please enter a valid amount"});return}if(!k){o({message:"Please select a campus"});return}if(!C){o({message:"Please select a fund"});return}m&&m(t0,tX(F),k.id,C.id,{amount:t0.toString(),selectedFrequency:F,selectedCampusId:k.id,selectedFundId:C.id})};return S.jsxs(H1,{display:"flex",flexDirection:"column",className:"h-full",children:[S.jsx("style",{children:Nee}),M!=="false"?S.jsx(rX,{churchName:h,churchLogo:g,message:Z,title:E,displayLogo:b}):null,S.jsx(H1,{flex:1,className:"min-h-0 overflow-y-auto p-6",ref:a0,children:S.jsxs(H1,{className:"space-y-4",children:[S.jsxs(H1,{className:"",children:[S.jsxs(H1,{display:"flex",alignItems:"flex-start",justifyContent:"center",className:"text-[60px] font-bold leading-none min-h-[60px]",children:[S.jsx("span",{className:"text-3xl leading-normal font-bold mt-3 flex-none text-brand",children:"$"}),S.jsx("span",{ref:U0,className:"absolute invisible h-0 overflow-hidden whitespace-pre text-[70px] font-bold font-inherit p-0 m-0",children:O||0}),S.jsx("input",{type:"number",inputMode:"decimal",placeholder:"0",value:O,onChange:t0=>w0(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:`${o0}px`}})]}),n0&&n0.length>0?S.jsx(H1,{display:"flex",flexWrap:"wrap",className:"pt-12",style:{gap:"6px"},children:n0.map(t0=>S.jsxs(b2,{onClick:()=>w0(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]}),S.jsx(H1,{children:S.jsxs(H1,{display:"flex",children:[S.jsxs(b2,{onClick:()=>{j(Tl[2])},disabled:c||B,surface:X?"solid":"material",className:"flex-1 rounded-r-none",style:{...X&&{"--btn-bg":"rgb(var(--color-brand-primary))","--btn-hover-overlay":"rgb(255 255 255 / 15%)"}},children:[S.jsx(aK,{size:24}),"Recurring"]}),S.jsxs(b2,{onClick:()=>j(null),disabled:c||B,surface:X?"material":"solid",className:"flex-1 rounded-l-none",style:{...!X&&{"--btn-bg":"rgb(var(--color-brand-primary))","--btn-hover-overlay":"rgb(255 255 255 / 15%)"}},children:[S.jsx(HK,{size:24}),"One time"]})]})}),X?S.jsxs(H1,{ref:W,children:[S.jsx(sZ,{mb:4,pl:16,color:"text.secondary",children:"Frequency"}),S.jsxs(BV,{value:(F==null?void 0:F.id)||"",onChange:t0=>G(t0.target.value),disabled:c||B,required:!0,surface:"material",children:[S.jsx("option",{value:"",children:"Select a frequency"}),Tl.map(t0=>S.jsx("option",{value:t0.id,children:t0.id},t0.id))]})]}):null,S.jsxs(H1,{children:[S.jsx(sZ,{mb:4,pl:16,color:"text.secondary",children:"Campus"}),S.jsxs(BV,{value:(k==null?void 0:k.id)||"",onChange:t0=>b0(t0.target.value),disabled:c||B,required:!0,surface:"material",children:[S.jsx("option",{value:"",children:B?"Loading...":"Select a campus"}),z.map(t0=>S.jsx("option",{value:t0.id,children:t0.name},t0.id))]})]}),k?S.jsxs(H1,{ref:c0,children:[S.jsx(sZ,{mb:4,pl:16,color:"text.secondary",children:"Fund"}),S.jsxs(BV,{value:(C==null?void 0:C.id)||"",onChange:t0=>L0(t0.target.value),disabled:c,required:!0,surface:"material",children:[S.jsx("option",{value:"",children:"Select a fund"}),k.donationFunds.sort((t0,p0)=>(t0.displayOrder||0)-(p0.displayOrder||0)).map(t0=>S.jsx("option",{value:t0.id,children:t0.displayName||t0.name},t0.id))]})]}):null]})}),S.jsxs(H1,{className:"sticky bottom-0 z-10 px-6 py-4 bg-system-chrome dark:bg-system-chrome-dark",children:[S.jsxs(b2,{type:"button",className:"w-full py-3",onClick:s0,disabled:c||B||!k||!C||e0()<=0,surface:"solid",children:["Give $",e0()," ",X?F.id:""]}),S.jsx(H1,{className:"text-center mt-4 px-6",children:S.jsxs(cZ,{color:"text.secondary",children:["By making this gift, you agree to our",S.jsx("br",{})," ",S.jsx("a",{href:"https://apollos.com/terms",target:"_blank",rel:"noopener noreferrer",className:"text-brand-primary underline",children:"Terms of Use"})," ","and"," ",S.jsx("a",{href:"https://apollos.com/privacy",target:"_blank",rel:"noopener noreferrer",className:"text-brand-primary underline",children:"Privacy Policy"}),"."]})})]})]})};lX.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 oX=({onRetry:a,theme:e})=>{var r,n;return S.jsxs(H1,{className:"text-center p-6 flex flex-col items-center justify-center min-h-full",children:[S.jsx(H1,{className:"mb-6",children:S.jsx(pK,{size:64,color:((n=(r=e==null?void 0:e.colors)==null?void 0:r.base)==null?void 0:n.secondary)||"#17B582",weight:"fill"})}),S.jsx(MJ,{className:"mb-4",children:"Thank You!"}),S.jsx(iZ,{color:"text.secondary",className:"mb-12",children:"Your donation has been processed successfully."}),S.jsx(b2,{surface:"solid",onClick:a,children:"Make Another Donation"})]})};oX.propTypes={onRetry:F0.func.isRequired};const Tee=Te(oX),Iee=kee("pk_live_51P6BtlGSfwVV9QRBvu4fa42325oofBgCIrme6D8IP7zrcxFgO2x7iLMqS76Q3jBsF4H9f5OUDmcPJKNFunNSTShv00rZPxHA6F"),iX=({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:Z=null})=>{const b=G=>{switch(G){case"weekly":return"Weekly";case"every-2-weeks":return"Every 2 Weeks";case"monthly":return"Monthly";case"one-time":return null;default:return"Monthly"}},E=G=>{if(!G)return!1;const e0=G.amount&&typeof G.amount=="string"&&parseFloat(G.amount)>0,s0=G.campusId&&typeof G.campusId=="string",t0=G.fundId===null||G.fundId&&typeof G.fundId=="string",p0=G.selectedFrequency===void 0||G.selectedFrequency===null||G.selectedFrequency&&typeof G.selectedFrequency=="object"&&G.selectedFrequency.id;return e0&&s0&&t0&&p0},[M,O]=p.useState("setup"),[w,F]=p.useState(""),[j,k]=p.useState(null),[N,C]=p.useState(()=>Z&&E(Z)?{amount:Z.amount,selectedFrequency:Z.selectedFrequency??null,selectedCampusId:Z.campusId,selectedFundId:Z.fundId}:{amount:a,selectedFrequency:e!=="one-time"?(()=>{const G=b(e);return Tl.find(e0=>e0.id===G)||Tl[2]})():null,selectedCampusId:null,selectedFundId:null}),[I,z]=p.useState(!1),{currentChurch:B,loading:X}=Ic(),[W,{loading:c0}]=Cee(),a0=p.useCallback(()=>{O("success")},[]),n0=p.useCallback(G=>{F(G.message)},[]),o0=p.useCallback(()=>{O("setup"),F(""),k(null),z(!1)},[]),J=p.useCallback(async(G,e0,s0,t0)=>{var p0;try{const y0={amount:Math.round(G*100),campusId:s0||"",fundId:t0||null};e0==="one-time"?y0.recurring={interval:"off",intervalCount:1}:y0.recurring={interval:e0==="monthly"?"month":"year",intervalCount:1};const{data:l0,errors:D0}=await W({variables:{input:y0}});if(D0)throw new Error(D0[0].message);if((p0=l0==null?void 0:l0.createPaymentIntent)!=null&&p0.clientSecret)k(l0.createPaymentIntent.clientSecret),O("payment");else throw new Error("No client secret received from server")}catch(y0){n0(y0)}},[W,n0]),U0=p.useCallback(()=>{O("setup"),k(null)},[]),w0={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},b0=X||c0;if(p.useEffect(()=>{Z&&E(Z)&&!X&&!c0&&!I&&M==="setup"&&(z(!0),C({amount:Z.amount,selectedFrequency:Z.selectedFrequency??null,selectedCampusId:Z.campusId,selectedFundId:Z.fundId}),J(parseFloat(Z.amount),tX(Z.selectedFrequency),Z.campusId,Z.fundId))},[Z,X,c0,I,M,J]),M==="success")return S.jsx(Vr,{style:w0,children:S.jsx(H1,{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",children:S.jsx(Tee,{onRetry:o0})})});const L0=(B==null?void 0:B.name)||"Your Church";return S.jsxs(Vr,{style:w0,children:[b0?S.jsx("div",{className:"absolute inset-0 bg-material-screen dark:bg-material-screen-dark flex items-center justify-center z-[1000]",children:S.jsx(DL,{size:32,className:"animate-spin mx-auto mb-2"})}):null,S.jsxs(H1,{display:"flex",flexDirection:"column",className:"h-full min-h-[400px]",children:[M==="payment"&&j?S.jsx(GK,{stripe:Iee,options:{clientSecret:j},children:S.jsx(nX,{amount:N!=null&&N.amount?parseFloat(N.amount):parseFloat(a),selectedFrequency:N==null?void 0:N.selectedFrequency,onSuccess:a0,onError:n0,isProcessing:c0,onBack:U0,churchName:L0,churchLogo:B==null?void 0:B.logo,message:r,displayLogo:u,title:h,displayHeader:g})}):S.jsx(S.Fragment,{children:M==="setup"&&!(Z&&E(Z)&&!I)?S.jsx(lX,{initialAmount:a,initialFrequency:b(e),campus:(N==null?void 0:N.selectedCampusId)||N.selectedCampusId||n,fund:(N==null?void 0:N.selectedFundId)||N.selectedFundId||l,predefinedAmounts:o,onError:n0,isProcessing:c0,onShowPayment:(G,e0,s0,t0,p0)=>{C({amount:p0.amount,selectedFrequency:p0.selectedFrequency,selectedCampusId:p0.selectedCampusId,selectedFundId:p0.selectedFundId}),J(G,e0,s0,t0)},persistedFormData:N,churchName:L0,churchLogo:B==null?void 0:B.logo,message:r,displayLogo:u,title:h,displayHeader:g}):M==="setup"&&Z&&E(Z)&&!I?S.jsxs(H1,{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",className:"h-full min-h-[400px]",children:[S.jsx(DL,{size:32,className:"animate-spin mx-auto mb-2"}),S.jsx(iZ,{children:"Preparing your donation..."})]}):null}),w?S.jsxs(H1,{mt:3,p:3,bg:"error.light",borderRadius:"md",children:[S.jsx(iZ,{color:"error.main",children:w}),S.jsx(b2,{variant:"outlined",size:"small",onClick:o0,mt:2,children:"Try Again"})]}):null]})]})};iX.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 Dee=Te(De.div`
|
|
1287
1287
|
display: flex;
|
|
1288
1288
|
padding: ${we("space.xs")};
|
|
1289
1289
|
border-radius: ${we("radii.xl")};
|