(()=>{"use strict";var e={54610:(e,a,n)=>{n.d(a,{B:()=>l});var t=n(51609),r=n(86087);const o=window.wp.coreData,i=window.wp.i18n;function s(){return window.GiveCampaignOptions}window.wp.apiFetch;const c=(e,a)=>{switch(e){case"amount":case"amountFromSubscriptions":const{currency:e}=s(),n=function(e){return new Intl.NumberFormat(navigator.language,{style:"currency",currency:e})}(e);return n.format(a);default:return a}},m=({showImage:e,showGoal:a,showDescription:n,campaign:r})=>{var o,m;const l=s();return(0,t.createElement)("div",{className:"give-campaigns-component-campaign",style:{"--givewp-primary-color":null!==(o=r.primaryColor)&&void 0!==o?o:"#0b72d9","--givewp-secondary-color":null!==(m=r.secondaryColor)&&void 0!==m?m:"#27ae60",...r.pagePermalink&&!l.isAdmin&&{cursor:"pointer"}},...r.pagePermalink&&!l.isAdmin&&{onClick:()=>window.location=r.pagePermalink}},e&&r.image&&(0,t.createElement)("div",{style:{backgroundImage:`url(${r.image})`},className:"give-campaigns-component-campaign-image"}),(0,t.createElement)("div",{className:"give-campaigns-component-campaign-title"},r.title),n&&(0,t.createElement)("div",{className:"give-campaigns-component-campaign-description"},r.shortDescription),a&&(0,t.createElement)("div",{className:"give-campaigns-component-campaign__goal"},(0,t.createElement)("div",{className:"give-campaigns-component-campaign__goal-progress"},(0,t.createElement)("div",{className:"give-campaigns-component-campaign__goal-progress-container"},(0,t.createElement)("div",{className:"give-campaigns-component-campaign__goal-progress-bar",style:{width:`${r.goalStats.percentage}%`}}))),(0,t.createElement)("div",{className:"give-campaigns-component-campaign__goal-container"},(0,t.createElement)("div",{className:"give-campaigns-component-campaign__goal-container-item"},(0,t.createElement)("span",null,(e=>{switch(e){case"amount":return(0,i.__)("Amount raised","give");case"donations":return(0,i.__)("Number of donations","give");case"donors":return(0,i.__)("Number of donors","give");case"amountFromSubscriptions":return(0,i.__)("Recurring amount raised","give");case"subscriptions":return(0,i.__)("Number of recurring donations","give");case"donorsFromSubscriptions":return(0,i.__)("Number of recurring donors","give")}})(r.goalType)),(0,t.createElement)("strong",null,c(r.goalType,r.goalStats.actual))),(0,t.createElement)("div",{className:"give-campaigns-component-campaign__goal-container-item"},(0,t.createElement)("span",null,(0,i.__)("Our goal","give")),(0,t.createElement)("strong",null,c(r.goalType,r.goal))))))},l=({attributes:e})=>{const{campaign:a,hasResolved:n}=function(e){const a=(0,o.useEntityRecord)("givewp","campaign",e);return{campaign:{...a?.record},hasResolved:a?.hasResolved,isResolving:a?.isResolving}}(e?.campaignId);return n?(0,t.createElement)(m,{campaign:a,showImage:e?.showImage,showDescription:e?.showDescription,showGoal:e?.showGoal}):null},g=document.querySelectorAll("[data-givewp-campaign-block]");g&&Array.from(g).map((e=>{const a=JSON.parse(e.dataset?.attributes);return(0,r.createRoot)(e).render((0,t.createElement)(l,{attributes:a}))}))},51609:e=>{e.exports=window.React},86087:e=>{e.exports=window.wp.element}},a={};function n(t){var r=a[t];if(void 0!==r)return r.exports;var o=a[t]={exports:{}};return e[t](o,o.exports,n),o.exports}n.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return n.d(a,{a}),a},n.d=(e,a)=>{for(var t in a)n.o(a,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:a[t]})},n.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a);var t=n(51609),r=n(86087),o=n(54610);class i extends elementorModules.frontend.handlers.Base{render(){const e=document.querySelectorAll(`[data-id="${this.getID()}"] [data-givewp-campaign-block]`);e?.forEach((e=>{const a=(0,r.createRoot)(e),n=JSON.parse(e.dataset?.attributes);a.render((0,t.createElement)(o.B,{attributes:n}))}))}onInit(){this.render()}}window.addEventListener("elementor/frontend/init",(()=>{elementorFrontend.hooks.addAction("frontend/element_ready/givewp_campaign.default",(e=>{elementorFrontend.elementsHandler.addHandler(i,{$element:e})}))}))})();