@apollosproject/canvas-embeds 2.1.1852 → 2.1.1853

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/widget/index.js CHANGED
@@ -620,7 +620,7 @@ Please change the parent <Route path="${M}"> to <Route path="${M==="/"?"*":`${M}
620
620
  }
621
621
  }
622
622
  }
623
- `);const ya1=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M232,128A104,104,0,1,1,128,24,104.13,104.13,0,0,1,232,128Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Z"}))]]),aw=e.forwardRef((a,t)=>e.createElement(S,{ref:t,...a,weights:ya1}));aw.displayName="CircleIcon";const Av0=aw,Sa1=Object.freeze(Object.defineProperty({__proto__:null,Circle:Av0,CircleIcon:aw},Symbol.toStringTag,{value:"Module"})),ka1=({poll:a,userProfile:t})=>{const n=Bv(),[r,l]=e.useState([]),[i,o]=e.useState(!1),[s,c]=e.useState(void 0),d=!!t?.id,h=a?.totalOptionVotes||0,p=a?.currentUserVotes||[],f=p.length>0,v=e.useMemo(()=>{if(typeof window>"u")return;const[,k]=window.location.pathname.split("/c/");return k||void 0},[]),Z=new Set(p.map(k=>k?.option?.id).filter(Boolean));e.useEffect(()=>{a&&n.track("Poll Viewed",{pollId:a.id,pollTitle:a.title,pollStatus:a.status,optionCount:a.options?.length||0,hasExistingVote:f,contentId:v})},[n,v,f,a]);const E=t?.firstName&&t?.lastName?`${t.firstName.charAt(0)}${t.lastName.charAt(0)}`.toUpperCase():t?.firstName?t.firstName.charAt(0).toUpperCase():"?",M=k=>{if(!a||a.status!=="Active"||i||f)return;const C=a.options?.find(I=>I?.id===k);r.includes(k)?(l([]),n.track("Poll Option Selected",{pollId:a.id,optionId:k,optionValue:C?.value,action:"deselected"})):(l([k]),n.track("Poll Option Selected",{pollId:a.id,optionId:k,optionValue:C?.value,action:"selected"}))},y=async()=>{if(!(r.length===0||!a))if(d)await L();else{const k=window.location.pathname,C=R_(k);if(!C){c("Unable to proceed. Please try again.");return}const I=jg0(C,k,{type:"pollVote",pollId:a.id,optionIds:r});window.location.href=I}},L=async()=>{if(a){o(!0),c(void 0);try{const k=R_(window.location.pathname)||"",C=new FormData;C.append("_action","submitVote"),C.append("pollId",a.id),C.append("optionIds",JSON.stringify(r)),C.append("church",k);const I=await fetch("/api/poll-vote",{method:"POST",body:C});if(!I.ok)throw new Error("Failed to submit vote");const $=await I.json();if($.success){const j=a.options?.filter(O=>O?.id?r.includes(O.id):!1)||[];n.track("Poll Vote Submitted",{pollId:a.id,pollTitle:a.title,optionIds:r,optionValues:j.map(O=>O?.value||""),optionCount:r.length,mode:"SingleChoice",isChangeVote:f,contentId:v}),window.location.reload()}else n.track("Poll Vote Failed",{pollId:a.id,error:$.message||"Failed to submit vote"}),c($.message||"Failed to submit vote")}catch(k){const C=k instanceof Error?k.message:"Failed to submit vote";n.track("Poll Vote Failed",{pollId:a.id,error:C}),c("Failed to submit vote. Please try again."),console.error("PollView: Error in submitVoteDirectly",k)}finally{o(!1)}}},b=a?.status==="Active"&&r.length>0&&!f,w=a?.status!=="Active"||f;return a?T.jsx(T.Fragment,{children:T.jsxs("div",{className:"bg-system-chrome shadow-sm dark:bg-material-regular-dark rounded-xl backdrop-blur-md p-4 my-4 dark:border-white/5 dark:border",children:[T.jsx("div",{className:"mt-0 flex flex-row gap-4 items-center justify-between",children:T.jsx("div",{className:"font-semibold text-2xl flex-1",children:a.title})}),T.jsx("div",{className:"mt-5 flex flex-col gap-3",children:a.options?.map((k,C)=>{const I=r.includes(k?.id||""),$=k?.value||"",j=k?.id||"",O=k?.totalVotes||0,G=h>0?O/h*100:0,t0=Z.has(j),n0=a.status==="Active"&&!i&&!f;return T.jsxs("div",{className:`flex flex-row gap-2 items-center border rounded-3xl transition-colors relative overflow-hidden ${n0?I?"bg-action/10 border-action dark:border-action-dark cursor-pointer":"text-fg-secondary dark:text-fg-primary-dark border-system-thin dark:border-system-regular-dark hover:bg-system-regular dark:hover:bg-system-regular-dark cursor-pointer":"text-fg-secondary dark:text-fg-primary-dark border-system-thin dark:border-system-regular-dark cursor-not-allowed"}`,onClick:()=>M(j),children:[w?T.jsx("div",{className:`absolute left-0 top-0 bottom-0 transition-all duration-300 ${t0?"bg-action/20 dark:bg-action-dark/20":"bg-system-regular/40 dark:bg-system-regular-dark/40"}`,style:{width:`${G}%`}}):null,T.jsxs("div",{className:"relative flex flex-row gap-2 items-center p-2 flex-1",children:[w&&t0&&t?T.jsx(Vu,{src:t.photo?.uri,initials:E,alt:"Your vote",className:"w-8 h-8",noBorder:!0}):I?T.jsx(P_,{weight:"fill",size:24,className:"text-action"}):T.jsx(Av0,{weight:"thin",size:24,className:w?"opacity-0":""}),T.jsx("span",{className:`flex-1 ${t0?"font-semibold":""}`,children:$}),w?T.jsxs("div",{className:"flex flex-row gap-3 items-center",children:[T.jsxs("span",{className:`text-sm ${t0?"font-semibold":"text-fg-secondary dark:text-fg-secondary-dark"}`,children:[G.toFixed(0),"%"]}),T.jsxs("span",{className:"text-xs text-fg-secondary dark:text-fg-secondary-dark min-w-[60px] text-right",children:[O," ",O===1?"vote":"votes"]})]}):null]})]},`option-${j||C}`)})}),b?T.jsx("div",{className:"mt-4",children:T.jsx(dt,{onClick:y,disabled:i,surface:"solid",className:"w-full",children:i?"Submitting...":"Submit Vote"})}):null,s?T.jsx("div",{className:"mt-2 text-red-500 text-sm",children:s}):null,T.jsx("div",{className:"mt-3 flex flex-row gap-4 items-center justify-between px-1",children:T.jsxs("div",{className:"text-fg-secondary dark:text-fg-secondary-dark text-sm text-action",children:[h," ",h===1?"response":"responses"]})})]})}):null},Fa1=({feature:a,church:t,userProfile:n,isInteractionEnabled:r,theme:l})=>a.poll?.status&&a.poll.status!=="Inactive"?T.jsx(ka1,{poll:a.poll,church:t,userProfile:n,isInteractionEnabled:r,theme:l}):null;De(`
623
+ `);const ya1=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M232,128A104,104,0,1,1,128,24,104.13,104.13,0,0,1,232,128Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Z"}))]]),aw=e.forwardRef((a,t)=>e.createElement(S,{ref:t,...a,weights:ya1}));aw.displayName="CircleIcon";const Av0=aw,Sa1=Object.freeze(Object.defineProperty({__proto__:null,Circle:Av0,CircleIcon:aw},Symbol.toStringTag,{value:"Module"})),ka1=({poll:a,userProfile:t})=>{const n=Bv(),[r,l]=e.useState([]),[i,o]=e.useState(!1),[s,c]=e.useState(void 0),d=!!t?.id,h=a?.totalOptionVotes||0,p=a?.currentUserVotes||[],f=p.length>0,v=e.useMemo(()=>{if(typeof window>"u")return;const[,k]=window.location.pathname.split("/c/");return k||void 0},[]),Z=new Set(p.map(k=>k?.option?.id).filter(Boolean));e.useEffect(()=>{a&&n.track("Poll Viewed",{pollId:a.id,pollTitle:a.title,pollStatus:a.status,optionCount:a.options?.length||0,hasExistingVote:f,contentId:v})},[n,v,f,a]);const E=t?.firstName&&t?.lastName?`${t.firstName.charAt(0)}${t.lastName.charAt(0)}`.toUpperCase():t?.firstName?t.firstName.charAt(0).toUpperCase():"?",M=k=>{if(!a||a.status!=="Active"||i||f)return;const C=a.options?.find(I=>I?.id===k);r.includes(k)?(l([]),n.track("Poll Option Selected",{pollId:a.id,optionId:k,optionValue:C?.value,action:"deselected"})):(l([k]),n.track("Poll Option Selected",{pollId:a.id,optionId:k,optionValue:C?.value,action:"selected"}))},y=async()=>{if(!(r.length===0||!a))if(d)await L();else{const k=window.location.pathname,C=R_(k);if(!C){c("Unable to proceed. Please try again.");return}const I=jg0(C,k,{type:"pollVote",pollId:a.id,optionIds:r});window.location.href=I}},L=async()=>{if(a){o(!0),c(void 0);try{const k=R_(window.location.pathname)||"",C=new FormData;C.append("_action","submitVote"),C.append("pollId",a.id),C.append("optionIds",JSON.stringify(r)),C.append("church",k);const I=await fetch("/api/poll-vote",{method:"POST",body:C});if(!I.ok)throw new Error("Failed to save your selection");const $=await I.json();if($.success){const j=a.options?.filter(O=>O?.id?r.includes(O.id):!1)||[];n.track("Poll Vote Submitted",{pollId:a.id,pollTitle:a.title,optionIds:r,optionValues:j.map(O=>O?.value||""),optionCount:r.length,mode:"SingleChoice",isChangeVote:f,contentId:v}),window.location.reload()}else n.track("Poll Vote Failed",{pollId:a.id,error:$.message||"Failed to save your selection"}),c($.message||"Failed to save your selection")}catch(k){const C=k instanceof Error?k.message:"Failed to save your selection";n.track("Poll Vote Failed",{pollId:a.id,error:C}),c("Failed to save your selection. Please try again."),console.error("PollView: Error in submitVoteDirectly",k)}finally{o(!1)}}},b=a?.status==="Active"&&r.length>0&&!f,w=a?.status!=="Active"||f;return a?T.jsx(T.Fragment,{children:T.jsxs("div",{className:"bg-system-chrome shadow-sm dark:bg-material-regular-dark rounded-xl backdrop-blur-md p-4 my-4 dark:border-white/5 dark:border",children:[T.jsx("div",{className:"mt-0 flex flex-row gap-4 items-center justify-between",children:T.jsx("div",{className:"font-semibold text-2xl flex-1",children:a.title})}),T.jsx("div",{className:"mt-5 flex flex-col gap-3",children:a.options?.map((k,C)=>{const I=r.includes(k?.id||""),$=k?.value||"",j=k?.id||"",O=k?.totalVotes||0,G=h>0?O/h*100:0,t0=Z.has(j),n0=a.status==="Active"&&!i&&!f;return T.jsxs("div",{className:`flex flex-row gap-2 items-center border rounded-3xl transition-colors relative overflow-hidden ${n0?I?"bg-action/10 border-action dark:border-action-dark cursor-pointer":"text-fg-secondary dark:text-fg-primary-dark border-system-thin dark:border-system-regular-dark hover:bg-system-regular dark:hover:bg-system-regular-dark cursor-pointer":"text-fg-secondary dark:text-fg-primary-dark border-system-thin dark:border-system-regular-dark cursor-not-allowed"}`,onClick:()=>M(j),children:[w?T.jsx("div",{className:`absolute left-0 top-0 bottom-0 transition-all duration-300 ${t0?"bg-action/20 dark:bg-action-dark/20":"bg-system-regular/40 dark:bg-system-regular-dark/40"}`,style:{width:`${G}%`}}):null,T.jsxs("div",{className:"relative flex flex-row gap-2 items-center p-2 flex-1",children:[w&&t0&&t?T.jsx(Vu,{src:t.photo?.uri,initials:E,alt:"Your selection",className:"w-8 h-8",noBorder:!0}):I?T.jsx(P_,{weight:"fill",size:24,className:"text-action"}):T.jsx(Av0,{weight:"thin",size:24,className:w?"opacity-0":""}),T.jsx("span",{className:`flex-1 ${t0?"font-semibold":""}`,children:$}),w?T.jsxs("div",{className:"flex flex-row gap-3 items-center",children:[T.jsxs("span",{className:`text-sm ${t0?"font-semibold":"text-fg-secondary dark:text-fg-secondary-dark"}`,children:[G.toFixed(0),"%"]}),T.jsx("span",{className:"text-xs text-fg-secondary dark:text-fg-secondary-dark min-w-[24px] text-right",children:O})]}):null]})]},`option-${j||C}`)})}),b?T.jsx("div",{className:"mt-4",children:T.jsx(dt,{onClick:y,disabled:i,surface:"solid",className:"w-full",children:i?"Saving...":"Submit"})}):null,s?T.jsx("div",{className:"mt-2 text-red-500 text-sm",children:s}):null,T.jsx("div",{className:"mt-3 flex flex-row gap-4 items-center justify-between px-1",children:T.jsxs("div",{className:"text-fg-secondary dark:text-fg-secondary-dark text-sm text-action",children:[h," ",h===1?"response":"responses"]})})]})}):null},Fa1=({feature:a,church:t,userProfile:n,isInteractionEnabled:r,theme:l})=>a.poll?.status&&a.poll.status!=="Inactive"?T.jsx(ka1,{poll:a.poll,church:t,userProfile:n,isInteractionEnabled:r,theme:l}):null;De(`
624
624
  fragment PollFeatureFragment on PollFeature {
625
625
  poll {
626
626
  id