@givefreely/adunit 1.6.3-dev.2 → 1.6.3-dev.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e={equals:(e,t)=>e===t};let t=P;const n=1,r=2,o={owned:null,cleanups:null,context:null,owner:null};var i=null;let s=null,a=null,l=null,c=null,g=0;function u(t,n){const r={value:t,observers:null,observerSlots:null,comparator:(n=n?Object.assign({},e,n):e).equals||void 0};return[v.bind(r),e=>("function"==typeof e&&(e=e(r.value)),b(r,e))]}function d(e,t,r){y(w(e,t,!1,n))}function p(e,r,o){t=E;const i=w(e,r,!1,n);i.user=!0,c?c.push(i):y(i)}function h(t,n,r){r=r?Object.assign({},e,r):e;const o=w(t,n,!0,0);return o.observers=null,o.observerSlots=null,o.comparator=r.equals||void 0,y(o),v.bind(o)}function m(e){if(null===a)return e();const t=a;a=null;try{return e()}finally{a=t}}function f(e){p((()=>m(e)))}function A(e){let t;return i&&i.context&&void 0!==(t=i.context[e.id])?t:e.defaultValue}function x(e){const t=h(e),n=h((()=>D(t())));return n.toArray=()=>{const e=n();return Array.isArray(e)?e:null!=e?[e]:[]},n}function v(){if(this.sources&&this.state)if(this.state===n)y(this);else{const e=l;l=null,k((()=>S(this)),!1),l=e}if(a){const e=this.observers?this.observers.length:0;a.sources?(a.sources.push(this),a.sourceSlots.push(e)):(a.sources=[this],a.sourceSlots=[e]),this.observers?(this.observers.push(a),this.observerSlots.push(a.sources.length-1)):(this.observers=[a],this.observerSlots=[a.sources.length-1])}return this.value}function b(e,t,r){let o=e.value;return e.comparator&&e.comparator(o,t)||(e.value=t,e.observers&&e.observers.length&&k((()=>{for(let t=0;t<e.observers.length;t+=1){const r=e.observers[t],o=s&&s.running;o&&s.disposed.has(r),(o?r.tState:r.state)||(r.pure?l.push(r):c.push(r),r.observers&&T(r)),o||(r.state=n)}if(l.length>1e6)throw l=[],new Error}),!1)),t}function y(e){if(!e.fn)return;O(e);const t=g;!function(e,t,r){let o;const s=i,l=a;a=i=e;try{o=e.fn(t)}catch(t){return e.pure&&(e.state=n,e.owned&&e.owned.forEach(O),e.owned=null),e.updatedAt=r+1,R(t)}finally{a=l,i=s}(!e.updatedAt||e.updatedAt<=r)&&(null!=e.updatedAt&&"observers"in e?b(e,o):e.value=o,e.updatedAt=r)}(e,e.value,t)}function w(e,t,r,s=n,a){const l={fn:e,state:s,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:i,context:i?i.context:null,pure:r};return null===i||i!==o&&(i.owned?i.owned.push(l):i.owned=[l]),l}function C(e){if(0===e.state)return;if(e.state===r)return S(e);if(e.suspense&&m(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<g);)e.state&&t.push(e);for(let o=t.length-1;o>=0;o--)if((e=t[o]).state===n)y(e);else if(e.state===r){const n=l;l=null,k((()=>S(e,t[0])),!1),l=n}}function k(e,n){if(l)return e();let r=!1;n||(l=[]),c?r=!0:c=[],g++;try{const n=e();return function(e){if(l&&(P(l),l=null),e)return;const n=c;c=null,n.length&&k((()=>t(n)),!1)}(r),n}catch(e){r||(c=null),l=null,R(e)}}function P(e){for(let t=0;t<e.length;t++)C(e[t])}function E(e){let t,n=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[n++]=r:C(r)}for(t=0;t<n;t++)C(e[t])}function S(e,t){e.state=0;for(let o=0;o<e.sources.length;o+=1){const i=e.sources[o];if(i.sources){const e=i.state;e===n?i!==t&&(!i.updatedAt||i.updatedAt<g)&&C(i):e===r&&S(i,t)}}}function T(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=r,n.pure?l.push(n):c.push(n),n.observers&&T(n))}}function O(e){let t;if(e.sources)for(;e.sources.length;){const t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){const e=r.pop(),o=t.observerSlots.pop();n<r.length&&(e.sourceSlots[o]=n,r[n]=e,t.observerSlots[n]=o)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)O(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)O(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function R(e,t=i){const n=function(e){return e instanceof Error?e:new Error("string"==typeof e?e:"Unknown error",{cause:e})}(e);throw n}function D(e){if("function"==typeof e&&!e.length)return D(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const r=D(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function I(e,t){return function(t){let n;return d((()=>n=m((()=>(i.context={...i.context,[e]:t.value},x((()=>t.children)))))),void 0),n}}function N(e,t){return m((()=>e(t||{})))}function _(e){const t=e.keyed,n=h((()=>e.when),void 0,{equals:(e,n)=>t?e===n:!e==!n});return h((()=>{const r=n();if(r){const o=e.children;return"function"==typeof o&&o.length>0?m((()=>o(t?r:()=>{if(!m(n))throw"Stale read from <Show>.";return e.when}))):o}return e.fallback}),void 0,void 0)}const L="_$DX_DELEGATE";function F(e,t,n){let r;const o=()=>(r||(r=(()=>{const t=document.createElement("template");return t.innerHTML=e,t.content.firstChild})())).cloneNode(!0);return o.cloneNode=o,o}function M(e,t=window.document){const n=t[L]||(t[L]=new Set);for(let r=0,o=e.length;r<o;r++){const o=e[r];n.has(o)||(n.add(o),t.addEventListener(o,H))}}function $(e,t,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}function G(e,t,n){if(!t)return n?$(e,"style"):t;const r=e.style;if("string"==typeof t)return r.cssText=t;let o,i;for(i in"string"==typeof n&&(r.cssText=n=void 0),n||(n={}),t||(t={}),n)null==t[i]&&r.removeProperty(i),delete n[i];for(i in t)o=t[i],o!==n[i]&&(r.setProperty(i,o),n[i]=o);return n}function U(e,t,n,r){if(void 0===n||r||(r=[]),"function"!=typeof t)return B(e,t,r,n);d((r=>B(e,t(),r,n)),r)}function H(e){let t=e.target;const n=`$$${e.type}`,r=e.target,o=e.currentTarget,i=t=>Object.defineProperty(e,"target",{configurable:!0,value:t}),s=()=>{const r=t[n];if(r&&!t.disabled){const o=t[`${n}Data`];if(void 0!==o?r.call(t,o,e):r.call(t,e),e.cancelBubble)return}return t.host&&"string"!=typeof t.host&&!t.host._$host&&t.contains(e.target)&&i(t.host),!0},a=()=>{for(;s()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get:()=>t||document}),e.composedPath){const n=e.composedPath();i(n[0]);for(let e=0;e<n.length-2&&(t=n[e],s());e++){if(t._$host){t=t._$host,a();break}if(t.parentNode===o)break}}else a();i(r)}function B(e,t,n,r,o){for(;"function"==typeof n;)n=n();if(t===n)return n;const i=typeof t,s=void 0!==r;if(e=s&&n[0]&&n[0].parentNode||e,"string"===i||"number"===i){if("number"===i&&(t=t.toString())===n)return n;if(s){let o=n[0];o&&3===o.nodeType?o.data!==t&&(o.data=t):o=document.createTextNode(t),n=W(e,n,r,o)}else n=""!==n&&"string"==typeof n?e.firstChild.data=t:e.textContent=t}else if(null==t||"boolean"===i)n=W(e,n,r);else{if("function"===i)return d((()=>{let o=t();for(;"function"==typeof o;)o=o();n=B(e,o,n,r)})),()=>n;if(Array.isArray(t)){const i=[],a=n&&Array.isArray(n);if(j(i,t,n,o))return d((()=>n=B(e,i,n,r,!0))),()=>n;if(0===i.length){if(n=W(e,n,r),s)return n}else a?0===n.length?K(e,i,r):function(e,t,n){let r=n.length,o=t.length,i=r,s=0,a=0,l=t[o-1].nextSibling,c=null;for(;s<o||a<i;)if(t[s]!==n[a]){for(;t[o-1]===n[i-1];)o--,i--;if(o===s){const t=i<r?a?n[a-1].nextSibling:n[i-a]:l;for(;a<i;)e.insertBefore(n[a++],t)}else if(i===a)for(;s<o;)c&&c.has(t[s])||t[s].remove(),s++;else if(t[s]===n[i-1]&&n[a]===t[o-1]){const r=t[--o].nextSibling;e.insertBefore(n[a++],t[s++].nextSibling),e.insertBefore(n[--i],r),t[o]=n[i]}else{if(!c){c=new Map;let e=a;for(;e<i;)c.set(n[e],e++)}const r=c.get(t[s]);if(null!=r)if(a<r&&r<i){let l,g=s,u=1;for(;++g<o&&g<i&&null!=(l=c.get(t[g]))&&l===r+u;)u++;if(u>r-a){const o=t[s];for(;a<r;)e.insertBefore(n[a++],o)}else e.replaceChild(n[a++],t[s++])}else s++;else t[s++].remove()}}else s++,a++}(e,n,i):(n&&W(e),K(e,i));n=i}else if(t.nodeType){if(Array.isArray(n)){if(s)return n=W(e,n,r,t);W(e,n,null,t)}else null!=n&&""!==n&&e.firstChild?e.replaceChild(t,e.firstChild):e.appendChild(t);n=t}}return n}function j(e,t,n,r){let o=!1;for(let i=0,s=t.length;i<s;i++){let s,a=t[i],l=n&&n[e.length];if(null==a||!0===a||!1===a);else if("object"==(s=typeof a)&&a.nodeType)e.push(a);else if(Array.isArray(a))o=j(e,a,l)||o;else if("function"===s)if(r){for(;"function"==typeof a;)a=a();o=j(e,Array.isArray(a)?a:[a],Array.isArray(l)?l:[l])||o}else e.push(a),o=!0;else{const t=String(a);l&&3===l.nodeType&&l.data===t?e.push(l):e.push(document.createTextNode(t))}}return o}function K(e,t,n=null){for(let r=0,o=t.length;r<o;r++)e.insertBefore(t[r],n)}function W(e,t,n,r){if(void 0===n)return e.textContent="";const o=r||document.createTextNode("");if(t.length){let r=!1;for(let i=t.length-1;i>=0;i--){const s=t[i];if(o!==s){const t=s.parentNode===e;r||i?t&&s.remove():t?e.replaceChild(o,s):e.insertBefore(o,n)}else r=!0}}else e.insertBefore(o,n);return[o]}class V{log({level:e,message:t,timestamp:n,data:r,title:o}){const i="debug"===e?"log":e,s=o?`[${o}]`:"";void 0!==r?console[i](`[${n}] - ${V.LOGGER_PREFIX} ${s} ${t}`,r):console[i](`[${n}] - ${V.LOGGER_PREFIX} ${s} ${t}`)}}var z,Y;V.LOGGER_PREFIX="[GFAdUnit] -",function(e){e.checkoutPopupShown="CHECKOUT-POPUP-SHOWN",e.checkoutPopupNotShown="CHECKOUT-POPUP-NOT-SHOWN",e.checkoutPopupSupressed="CHECKOUT-POPUP-SUPRESSED",e.checkoutPopupDonation="CHECKOUT-POPUP-DONATION",e.checkoutPopupFailedActivation="CHECKOUT-POPUP-FAILED-ACTIVATION",e.checkoutPopupPurchaseConfirmed="CHECKOUT-POPUP-PURCHASE-CONFIRMED",e.checkoutPopupHealthCheck="CHECKOUT-POPUP-HEALTH-CHECK",e.checkouPopupActivationFailed="CHECKOUT-POPUP-ACTIVATION-FAILED",e.checkoutPopupOfferDetailsClicked="CHECKOUT-POPUP-OFFER-DETAILS-CLICKED",e.checkoutPopupWhyAmISeeingThisClicked="CHECKOUT-POPUP-WHY-AM-I-SEEING-THIS-CLICKED",e.checkoutPopupLooserExtension="CHECKOUT-POPUP-LOOSER-EXTENSION",e.checkoutPopupActiveDomain="CHECKOUT-POPUP-ACTIVE-DOMAIN",e.checkoutPopupSiteMatches="CHECKOUT-POPUP-SITE-MATCHES"}(z||(z={})),function(e){e.adUnitLog="ADUNIT-LOG"}(Y||(Y={}));const q=["debug","info","warn","error"];class J{constructor(e){this.config={minLevel:e?.minLevel??"debug",enabled:e?.enabled??!1,transports:e?.transports??[new V],title:e?.title??""}}static getInstance(e){return J.instance||(J.instance=new J(e)),J.instance}configure(e){this.config={...this.config,...e}}shouldLog(e){return!!this.config.enabled&&q.indexOf(e)>=q.indexOf(this.config.minLevel)}createLogMessage(e,t,n){return{level:e,version:"1.6.3",message:t,timestamp:(new Date).toISOString(),data:n,title:this.config.title}}log(e,t,n){if(!this.shouldLog(e))return;const r=this.createLogMessage(e,t,n);this.config.transports.forEach((e=>e.log(r)))}debug(e,t){this.log("debug",e,t)}info(e,t){this.log("info",e,t)}warn(e,t){this.log("warn",e,t)}error(e,t){this.log("error",e,t)}addTransport(e){this.config.transports.push(e)}clearTransports(){this.config.transports=[]}disable(){this.config.enabled=!1}enable(){this.config.enabled=!0}}const X=3,Z=e=>1e3*e;async function Q(e,t={}){const{maxAttempts:n=X,delayFn:r=Z}=t;let o=null;for(let t=1;t<=n;t+=1)try{return await e()}catch(e){o=e,t<n&&await new Promise((e=>{setTimeout(e,r(t))}))}throw o||new Error("Operation failed after multiple attempts")}const ee=chrome;async function te(e,t){return new Promise(((n,r)=>{try{const o=t=>chrome.runtime.lastError?r({error:chrome.runtime.lastError,message:e}):n(t);t?.tabId||ee.runtime.sendMessage(e,o)}catch(e){r(e)}}))}async function ne(e,t,n){return Q((()=>te(e,t)),{maxAttempts:X,delayFn:Z})}const re={display:"block",position:"fixed",top:"0%",left:"100%",width:"500px",height:"520px","margin-left":"-560px","margin-top":"50px",padding:"2px 5px","background-color":"white",border:"1px solid black","border-radius":"10px","box-shadow":"0 2px 10px rgba(0, 0, 0, 0.1)","z-index":"2147483647","font-family":"Arial","line-height":"1","vertical-align":"baseline","box-sizing":"border-box",color:"rgb(34, 34, 34)","@media (max-width: 600px), (max-height: 480px)":{display:"none !important"}},oe={height:"100%","overflow-x":"hidden","overlfow-y":"auto",position:"relative",padding:"0px 15px"},ie={},se={display:"flex","align-items":"center","margin-bottom":"10px"},ae={flex:"1","font-size":"24px","font-weight":"700","margin-top":"20px","margin-bottom":"0px"},le={background:"none",border:"none",padding:"4px 8px",color:"#666464","font-size":"38px",cursor:"pointer","line-height":"1"},ce={color:"black","margin-top":"20px","max-width":"40%"},ge={color:"gray",cursor:"default","pointer-events":"none","text-decoration":"none"},ue={"font-size":"18px","font-weight":"400","margin-top":"20px","margin-bottom":"0px"},de={display:"flex",gap:"10px",width:"100%","margin-top":"20px","margin-bottom":"20px","flex-wrap":"wrap","justify-content":"space-between"},pe={width:"28%",position:"relative",display:"flex","flex-direction":"column","align-items":"center",background:"none",border:"1px solid #ccc","border-radius":"5px",padding:"5px",gap:"5px","text-align":"center","font-size":"14px",cursor:"pointer",transition:"background-color 0.2s ease"},he={color:"white","background-color":"lightgray",cursor:"default","pointer-events":"none"},me={"max-width":"120px","max-height":"70px","margin-bottom":"5px","object-fit":"contain"},fe={"background-color":"#FFD812",cursor:"pointer","border-radius":"8px",padding:"8px",color:"white","min-width":"100px",border:"0","font-weight":"600",width:"100%"},Ae={display:"flex","flex-direction":"column",gap:"10px",width:"100%","color-scheme":"light"},xe={display:"flex","align-items":"center",gap:"5px",border:"1px solid #ddd",padding:"15px","border-radius":"5px","font-weight":"600",cursor:"pointer","margin-bottom":"8px"},ve={"text-align":"right"},be={background:"none",border:"none",color:"blue","text-decoration":"underline",padding:"0",cursor:"pointer","margin-bottom":"15px"},ye={display:"flex","justify-content":"space-between",margin:"20px 0px 10px 0px","font-size":"14px"},we={margin:"5px 0px 5px 0px","font-size":"14px","text-align":"center"},Ce={color:"#666464","text-decoration":"underline"},ke={color:"rgb(102, 100, 100)","text-decoration":"underline",margin:"0",cursor:"pointer"},Pe={width:"100%","background-color":"#f2f2f2",border:"1px solid black","border-radius":"10px","border-top":"1px solid #bbb7b7","margin-top":"10px","margin-bottom":"20px","box-sizing":"border-box"},Ee={padding:"0 5px 0 10px",width:"100%","font-size":"12px","box-sizing":"border-box"},Se={display:"grid","grid-template-columns":"4fr 1fr","padding-right":"15px","padding-bottom":"5px"},Te={color:"#000","margin-bottom":"4px"},Oe={"font-size":"14px",color:"#555","text-align":"right"},Re=(e,t)=>{let n=parseFloat(t);return"FLAT"===e&&(n*=.75),((e,t)=>{let n=parseFloat(t);return n<1&&(n=1),n=Math.floor(n),"PERCENTAGE"===e?`${n}%`:`$${n}`})(e,n.toString())};var De=F("<span>");function Ie(e){return t=De(),d((()=>{return t.innerHTML=(n=e.title,r=e.activeDomain,n.replace("{0}",Re(r.Merchant.MaxRate?.Kind,r.Merchant.MaxRate?.Amount??"0")));var n,r})),t;var t}const Ne=function(){const e=Symbol("context");return{id:e,Provider:I(e),defaultValue:()=>({translate:e=>"",getAllCharities:()=>[]})}}(),_e=Ne,Le=()=>{const e=A(_e)();if(!e)throw new Error("Content provider context is undefined");return t=>e.translate(t)};class Fe{static formatMessage(e,...t){return e.replace(/{(\d+)}/g,((e,n)=>{const r=Number(n);return void 0!==t[r]?String(t[r]):`{${r}}`}))}}var Me=F("<div>"),$e=F("<div><div class=gf-offer-details><p><span></span></p><p><span></span></p><p><span></span></p><p><span></span></p><p><span></span></p><p><a target=_blank rel=noreferrer>"),Ge=F("<div class=gf-offer-details-rate-item><div></div><div>");const Ue=e=>{const t=Le();return n=$e(),o=(r=n.firstChild).firstChild,i=o.firstChild,s=o.nextSibling,a=s.firstChild,l=s.nextSibling,c=l.firstChild,g=l.nextSibling,u=g.firstChild,p=g.nextSibling,h=p.firstChild,m=p.nextSibling.firstChild,U(r,N(_,{get when(){return!!e.merchantRateDetail?.length},get children(){var t=Me();return U(t,(()=>e.merchantRateDetail?.map((e=>{return t=Ge(),n=t.firstChild,r=n.nextSibling,U(n,(()=>e.Name||"")),U(r,(()=>((e,t=1,n=1)=>{const r=e.BoostedOffer??null;let o=parseFloat(e?.Amount??"");if(r?.EndDate&&new Date(r.EndDate)<new Date&&(o=parseFloat(r.OriginalMaxRate)),Number.isNaN(o))return"";const i=o*t;return"PERCENTAGE"===e?.Kind?`${i.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:n})}%`:"FLAT"===e?.Kind?i.toLocaleString("en-US",{style:"currency",currency:e.Currency}):""})(e))),d((e=>{var o=Se,i=Te,s=Oe;return e.e=G(t,o,e.e),e.t=G(n,i,e.t),e.a=G(r,s,e.a),e}),{e:void 0,t:void 0,a:void 0}),t;var t,n,r})))),t}}),g),U(m,(()=>t("offerDetails.termsAndConditions"))),d((o=>{var s=Pe,l=Ee,g=t("offerDetails.intro"),d=t("offerDetails.eligible"),p=e.parsedMaxRate?Fe.formatMessage(t("offerDetails.donationRatesWithValue"),e.parsedMaxRate):Fe.formatMessage(t("offerDetails.donationRates")),f=t("offerDetails.donationAmounts"),A=t("offerDetails.donationTiming"),x=Ce,v=e.termsUrl;return o.e=G(n,s,o.e),o.t=G(r,l,o.t),g!==o.a&&(i.innerHTML=o.a=g),d!==o.o&&(a.innerHTML=o.o=d),p!==o.i&&(c.innerHTML=o.i=p),f!==o.n&&(u.innerHTML=o.n=f),A!==o.s&&(h.innerHTML=o.s=A),o.h=G(m,x,o.h),v!==o.r&&$(m,"href",o.r=v),o}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),n;var n,r,o,i,s,a,l,c,g,u,p,h,m};function He(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var Be={exports:{}};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self&&self,function(e){if(!(globalThis.chrome&&globalThis.chrome.runtime&&globalThis.chrome.runtime.id))throw new Error("This script should only be loaded in a browser extension.");if(globalThis.browser&&globalThis.browser.runtime&&globalThis.browser.runtime.id)e.exports=globalThis.browser;else{const t="The message port closed before a response was received.",n=e=>{const n={alarms:{clear:{minArgs:0,maxArgs:1},clearAll:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getAll:{minArgs:0,maxArgs:0}},bookmarks:{create:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},getChildren:{minArgs:1,maxArgs:1},getRecent:{minArgs:1,maxArgs:1},getSubTree:{minArgs:1,maxArgs:1},getTree:{minArgs:0,maxArgs:0},move:{minArgs:2,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeTree:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}},browserAction:{disable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},enable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},getBadgeBackgroundColor:{minArgs:1,maxArgs:1},getBadgeText:{minArgs:1,maxArgs:1},getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},openPopup:{minArgs:0,maxArgs:0},setBadgeBackgroundColor:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setBadgeText:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},browsingData:{remove:{minArgs:2,maxArgs:2},removeCache:{minArgs:1,maxArgs:1},removeCookies:{minArgs:1,maxArgs:1},removeDownloads:{minArgs:1,maxArgs:1},removeFormData:{minArgs:1,maxArgs:1},removeHistory:{minArgs:1,maxArgs:1},removeLocalStorage:{minArgs:1,maxArgs:1},removePasswords:{minArgs:1,maxArgs:1},removePluginData:{minArgs:1,maxArgs:1},settings:{minArgs:0,maxArgs:0}},commands:{getAll:{minArgs:0,maxArgs:0}},contextMenus:{remove:{minArgs:1,maxArgs:1},removeAll:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},cookies:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:1,maxArgs:1},getAllCookieStores:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},devtools:{inspectedWindow:{eval:{minArgs:1,maxArgs:2,singleCallbackArg:!1}},panels:{create:{minArgs:3,maxArgs:3,singleCallbackArg:!0},elements:{createSidebarPane:{minArgs:1,maxArgs:1}}}},downloads:{cancel:{minArgs:1,maxArgs:1},download:{minArgs:1,maxArgs:1},erase:{minArgs:1,maxArgs:1},getFileIcon:{minArgs:1,maxArgs:2},open:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},pause:{minArgs:1,maxArgs:1},removeFile:{minArgs:1,maxArgs:1},resume:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},extension:{isAllowedFileSchemeAccess:{minArgs:0,maxArgs:0},isAllowedIncognitoAccess:{minArgs:0,maxArgs:0}},history:{addUrl:{minArgs:1,maxArgs:1},deleteAll:{minArgs:0,maxArgs:0},deleteRange:{minArgs:1,maxArgs:1},deleteUrl:{minArgs:1,maxArgs:1},getVisits:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1}},i18n:{detectLanguage:{minArgs:1,maxArgs:1},getAcceptLanguages:{minArgs:0,maxArgs:0}},identity:{launchWebAuthFlow:{minArgs:1,maxArgs:1}},idle:{queryState:{minArgs:1,maxArgs:1}},management:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},getSelf:{minArgs:0,maxArgs:0},setEnabled:{minArgs:2,maxArgs:2},uninstallSelf:{minArgs:0,maxArgs:1}},notifications:{clear:{minArgs:1,maxArgs:1},create:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:0},getPermissionLevel:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},pageAction:{getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},hide:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},permissions:{contains:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},request:{minArgs:1,maxArgs:1}},runtime:{getBackgroundPage:{minArgs:0,maxArgs:0},getPlatformInfo:{minArgs:0,maxArgs:0},openOptionsPage:{minArgs:0,maxArgs:0},requestUpdateCheck:{minArgs:0,maxArgs:0},sendMessage:{minArgs:1,maxArgs:3},sendNativeMessage:{minArgs:2,maxArgs:2},setUninstallURL:{minArgs:1,maxArgs:1}},sessions:{getDevices:{minArgs:0,maxArgs:1},getRecentlyClosed:{minArgs:0,maxArgs:1},restore:{minArgs:0,maxArgs:1}},storage:{local:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},managed:{get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1}},sync:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}}},tabs:{captureVisibleTab:{minArgs:0,maxArgs:2},create:{minArgs:1,maxArgs:1},detectLanguage:{minArgs:0,maxArgs:1},discard:{minArgs:0,maxArgs:1},duplicate:{minArgs:1,maxArgs:1},executeScript:{minArgs:1,maxArgs:2},get:{minArgs:1,maxArgs:1},getCurrent:{minArgs:0,maxArgs:0},getZoom:{minArgs:0,maxArgs:1},getZoomSettings:{minArgs:0,maxArgs:1},goBack:{minArgs:0,maxArgs:1},goForward:{minArgs:0,maxArgs:1},highlight:{minArgs:1,maxArgs:1},insertCSS:{minArgs:1,maxArgs:2},move:{minArgs:2,maxArgs:2},query:{minArgs:1,maxArgs:1},reload:{minArgs:0,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeCSS:{minArgs:1,maxArgs:2},sendMessage:{minArgs:2,maxArgs:3},setZoom:{minArgs:1,maxArgs:2},setZoomSettings:{minArgs:1,maxArgs:2},update:{minArgs:1,maxArgs:2}},topSites:{get:{minArgs:0,maxArgs:0}},webNavigation:{getAllFrames:{minArgs:1,maxArgs:1},getFrame:{minArgs:1,maxArgs:1}},webRequest:{handlerBehaviorChanged:{minArgs:0,maxArgs:0}},windows:{create:{minArgs:0,maxArgs:1},get:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:1},getCurrent:{minArgs:0,maxArgs:1},getLastFocused:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}}};if(0===Object.keys(n).length)throw new Error("api-metadata.json has not been included in browser-polyfill");class r extends WeakMap{constructor(e,t=void 0){super(t),this.createItem=e}get(e){return this.has(e)||this.set(e,this.createItem(e)),super.get(e)}}const o=(t,n)=>(...r)=>{e.runtime.lastError?t.reject(new Error(e.runtime.lastError.message)):n.singleCallbackArg||r.length<=1&&!1!==n.singleCallbackArg?t.resolve(r[0]):t.resolve(r)},i=e=>1==e?"argument":"arguments",s=(e,t,n)=>new Proxy(t,{apply:(t,r,o)=>n.call(r,e,...o)});let a=Function.call.bind(Object.prototype.hasOwnProperty);const l=(e,t={},n={})=>{let r=Object.create(null),c={has:(t,n)=>n in e||n in r,get(c,g,u){if(g in r)return r[g];if(!(g in e))return;let d=e[g];if("function"==typeof d)if("function"==typeof t[g])d=s(e,e[g],t[g]);else if(a(n,g)){let t=((e,t)=>function(n,...r){if(r.length<t.minArgs)throw new Error(`Expected at least ${t.minArgs} ${i(t.minArgs)} for ${e}(), got ${r.length}`);if(r.length>t.maxArgs)throw new Error(`Expected at most ${t.maxArgs} ${i(t.maxArgs)} for ${e}(), got ${r.length}`);return new Promise(((i,s)=>{if(t.fallbackToNoCallback)try{n[e](...r,o({resolve:i,reject:s},t))}catch(o){console.warn(`${e} API method doesn't seem to support the callback parameter, falling back to call it without a callback: `,o),n[e](...r),t.fallbackToNoCallback=!1,t.noCallback=!0,i()}else t.noCallback?(n[e](...r),i()):n[e](...r,o({resolve:i,reject:s},t))}))})(g,n[g]);d=s(e,e[g],t)}else d=d.bind(e);else if("object"==typeof d&&null!==d&&(a(t,g)||a(n,g)))d=l(d,t[g],n[g]);else{if(!a(n,"*"))return Object.defineProperty(r,g,{configurable:!0,enumerable:!0,get:()=>e[g],set(t){e[g]=t}}),d;d=l(d,t[g],n["*"])}return r[g]=d,d},set:(t,n,o,i)=>(n in r?r[n]=o:e[n]=o,!0),defineProperty:(e,t,n)=>Reflect.defineProperty(r,t,n),deleteProperty:(e,t)=>Reflect.deleteProperty(r,t)},g=Object.create(e);return new Proxy(g,c)},c=e=>({addListener(t,n,...r){t.addListener(e.get(n),...r)},hasListener:(t,n)=>t.hasListener(e.get(n)),removeListener(t,n){t.removeListener(e.get(n))}}),g=new r((e=>"function"!=typeof e?e:function(t){const n=l(t,{},{getContent:{minArgs:0,maxArgs:0}});e(n)})),u=new r((e=>"function"!=typeof e?e:function(t,n,r){let o,i,s=!1,a=new Promise((e=>{o=function(t){s=!0,e(t)}}));try{i=e(t,n,o)}catch(e){i=Promise.reject(e)}const l=!0!==i&&((c=i)&&"object"==typeof c&&"function"==typeof c.then);var c;if(!0!==i&&!l&&!s)return!1;return(l?i:a).then((e=>{r(e)}),(e=>{let t;t=e&&(e instanceof Error||"string"==typeof e.message)?e.message:"An unexpected error occurred",r({__mozWebExtensionPolyfillReject__:!0,message:t})})).catch((e=>{console.error("Failed to send onMessage rejected reply",e)})),!0})),d=({reject:n,resolve:r},o)=>{e.runtime.lastError?e.runtime.lastError.message===t?r():n(new Error(e.runtime.lastError.message)):o&&o.__mozWebExtensionPolyfillReject__?n(new Error(o.message)):r(o)},p=(e,t,n,...r)=>{if(r.length<t.minArgs)throw new Error(`Expected at least ${t.minArgs} ${i(t.minArgs)} for ${e}(), got ${r.length}`);if(r.length>t.maxArgs)throw new Error(`Expected at most ${t.maxArgs} ${i(t.maxArgs)} for ${e}(), got ${r.length}`);return new Promise(((e,t)=>{const o=d.bind(null,{resolve:e,reject:t});r.push(o),n.sendMessage(...r)}))},h={devtools:{network:{onRequestFinished:c(g)}},runtime:{onMessage:c(u),onMessageExternal:c(u),sendMessage:p.bind(null,"sendMessage",{minArgs:1,maxArgs:3})},tabs:{sendMessage:p.bind(null,"sendMessage",{minArgs:2,maxArgs:3})}},m={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return n.privacy={network:{"*":m},services:{"*":m},websites:{"*":m}},l(e,h,n)};e.exports=n(chrome)}}(Be);var je=He(Be.exports);const Ke="GIVE_FREELY_",We={async get(e){const t=`${Ke}${e}`;return(await je.storage.local.get(t))[t]||null},async set(e,t){const n=`${Ke}${e}`;await je.storage.local.set({[n]:t})},async remove(e){const t=Array.isArray(e)?e.map((e=>`${Ke}${e}`)):`${Ke}${e}`;await je.storage.local.remove(t)}},Ve="version",ze=()=>String("1.6.3"),Ye="https://cdn.givefreely.com/adunit/behavioral/";class qe{constructor(e){this.partnerApiKey=e,this.partnerConfig=null,this.globalConfig=null,this.lastConfigRefresh=0,this.CONFIG_REFRESH_INTERVAL=300,this.PARTNER_CONFIG_STORAGE_KEY="gf_partner_config",this.GLOBAL_CONFIG_STORAGE_KEY="gf_global_config"}getRetryOptions(){return{delayFn:e=>1e3*e,maxAttempts:3}}async fetchAndUpdatePartnerConfig(){const e=await Q((async()=>{const e=await fetch(`${Ye}${this.partnerApiKey}.json`,{cache:"no-store"});if(!e.ok)throw new Error(`Failed to fetch partner config: ${e.statusText}`);return e.json()}),this.getRetryOptions()),t={config:e,lastRefresh:Date.now()};return await We.set(this.PARTNER_CONFIG_STORAGE_KEY,t),e}async fetchAndUpdateGlobalConfig(){const e=await Q((async()=>{const e=await fetch(`${Ye}global.json`,{cache:"no-store"});if(!e.ok)throw new Error(`Failed to fetch global config: ${e.statusText}`);return e.json()}),this.getRetryOptions()),t={config:e,lastRefresh:Date.now()};return await We.set(this.GLOBAL_CONFIG_STORAGE_KEY,t),e}async getConfig(e=!1){const t=Date.now(),n=await We.get(this.PARTNER_CONFIG_STORAGE_KEY),r=await We.get(this.GLOBAL_CONFIG_STORAGE_KEY);this.partnerConfig=n?.config||null,this.globalConfig=r?.config||null,this.lastConfigRefresh=Math.max(n?.lastRefresh||0,r?.lastRefresh||0);let o=!1;e&&(o=await(async(e=!0)=>{const t=await We.get(Ve),n=await ze(),r=t!==n;var o;return e&&r&&await(o=n,We.set(Ve,o)),r})());const i=this.partnerConfig?.configRefreshInterval||this.globalConfig?.configRefreshInterval||this.CONFIG_REFRESH_INTERVAL;if(o||!this.partnerConfig||!this.globalConfig||t-this.lastConfigRefresh>1e3*i)try{const[e,n]=await Promise.all([this.fetchAndUpdatePartnerConfig(),this.fetchAndUpdateGlobalConfig()]);this.partnerConfig=e,this.globalConfig=n,this.lastConfigRefresh=t}catch(e){if(!this.partnerConfig||!this.globalConfig)throw e}const s=this.mergeConfigs(JSON.parse(JSON.stringify(this.globalConfig)),JSON.parse(JSON.stringify(this.partnerConfig)));return s&&((e,t,n)=>{const r=[...t.merchantExclusions??[],...n.merchantExclusions??[]];e.merchantExclusions=r})(s,this.globalConfig,this.partnerConfig),s}async clearCache(){await Promise.all([We.remove(this.PARTNER_CONFIG_STORAGE_KEY),We.remove(this.GLOBAL_CONFIG_STORAGE_KEY)]),this.partnerConfig=null,this.globalConfig=null,this.lastConfigRefresh=0}mergeConfigs(e,t){if(!t)return e;if(!e)return t;const n={...e};return Object.keys(t).forEach((r=>{if(!Object.prototype.hasOwnProperty.call(t,r))return;const o=e[r],i=t[r];void 0!==i&&(Array.isArray(i)?n[r]=[...i]:n[r]=null===i||"object"!=typeof i||null===o||"object"!=typeof o?i:this.mergeConfigs(o,i))})),n}getStoredState(e){return e?{config:e.config,lastRefresh:e.lastRefresh}:{config:null,lastRefresh:0}}}const Je="TRACK_EVENT",Xe="GF_HIDE_POPUP",Ze="GF_GET_POPUP_CONFIG",Qe="GF_IS_ACTIVE_DOMAIN",et="GF_SHOULD_STAND_DOWN",tt="GF_ACTIVATE_OFFER",nt="GF_STORE_SHOPIFY_SHOP_ID",rt="GF_GET_DOMAIN_BY_SHOP_ID",ot="GF_GET_LANGUAGE_CONTENT",it={ein:"0",tpi:"0"};class st{constructor(e,t,n=60){this._config=null,this.track=async(e,t,n,r=!1)=>{null===this._config&&(this._config=await new qe(this._partnerApiKey).getConfig());const o={partner:`adUnit_${this._partnerApiKey}`,eventType:e,eventData:{userId:r?void 0:this._userService?.user?.id,libVersion:ze(),wfDeviceId:t,...n}};try{const e=JSON.stringify(o);return await this.shouldBroadcastEvent(e)?(await fetch(this._config.eventsUrl,{headers:{"Content-Type":"application/json"},method:"POST",body:e,cache:"no-store"}),await this.pushEventToHistory(e),!0):(this._logger.info("This event has already been broadcasted during the past hour",o),!1)}catch(e){return this._logger.info("Something unexpected happened when dispatching a gf event",{error:e,event:o}),!1}},this.getEventsHistory=async()=>{const{GF_AD_EVENT_HISTORY:e}=await ee.storage.local.get({GF_AD_EVENT_HISTORY:""}),t=(e=>{const t=new Date;return t.setTime(t.getTime()+60*e*1e3),t.getTime()})(-this._debounceWindowInMinutes),n=(e||[]).filter((e=>e.createdAt>t));return await ee.storage.local.set({GF_AD_EVENT_HISTORY:n}),n},this.shouldBroadcastEvent=async e=>!(await this.getEventsHistory()).some((t=>t.payload===e)),this.pushEventToHistory=async e=>{const t=await this.getEventsHistory();t.push({createdAt:Date.now(),payload:e}),await ee.storage.local.set({GF_AD_EVENT_HISTORY:t})},this._partnerApiKey=e,this._userService=t,this._debounceWindowInMinutes=n,this._logger=J.getInstance({title:"Analytics"})}}function at(e,t,n){return e?{...t,...n}:t}st.trackEvent=async(e,t,n=!1)=>{await te({type:Je,payload:{eventType:e,eventData:t,anonymous:n}})};var lt=F("<a href=#!>"),ct=F("<button class=give-freely-close-button aria-label=Close>×"),gt=F('<div><div><div></div></div><hr><div></div><div><div><div><br></div><button aria-label="Don\'t show again"></button></div></div><div><p></p><a class=give-freely-footer-link target=_blank rel="noopener noreferrer">'),ut=F("<div><div><img><span></span></div><button>"),dt=F("<div>");function pt(e){const[t,n]=u(!1),[r,o]=u(null),i=Le(),s=(()=>{const e=A(Ne)();if(!e)throw new Error("Content provider context is undefined");return()=>e.getAllCharities()})();p((()=>{t()&&e.mainContainerRef&&e.mainContainerRef.scroll({top:e.mainContainerRef.scrollHeight,behavior:"smooth"})})),p((()=>{const t=r();t&&e.onCharitySelect(t.charity,t.closeOnDonation?e.checkoutPopupConf.checkoutPopupActivateAndCloseSkipSuccess:void 0)}));const a=(e,t)=>o({charity:e,closeOnDonation:t}),l=()=>!!r()?.charity;return[(g=gt(),m=g.firstChild,f=m.firstChild,x=m.nextSibling.nextSibling,v=x.nextSibling,b=v.firstChild,y=b.firstChild,w=y.nextSibling,C=v.nextSibling,k=C.firstChild,P=k.nextSibling,U(f,(()=>i("main.title"))),U(m,N(_,{get when(){return e.checkoutPopupConf.checkoutPopupActivateAndClose},get children(){var e=lt();return e.$$click=()=>a(it,!0),d((t=>{var n=at(l(),ce,ge),r=i("main.activateAndClose");return t.e=G(e,n,t.e),r!==t.t&&(e.innerHTML=t.t=r),t}),{e:void 0,t:void 0}),e}}),null),U(m,N(_,{get when(){return e.checkoutPopupConf.checkoutPopupMainCloseButtonVisible&&!e.checkoutPopupConf.checkoutPopupActivateAndClose},get children(){var t=ct();return t.$$click=()=>e.onClose(),d((e=>G(t,le,e))),t}}),null),U(x,N(Ie,{get title(){return i("main.subTitle")},get activeDomain(){return e.activeDomain}})),U(v,(()=>s().map((t=>{return o=(r=ut()).firstChild,c=(s=o.firstChild).nextSibling,g=o.nextSibling,r.$$click=()=>!l()&&a(t),U(r,(n=h((()=>!!(t.decorator&&t.decoratorLeftStyle&&t.decoratorRightStyle))),()=>{return n()&&[(r=dt(),d((e=>{var n=t.decoratorLeftStyle,o=t.decorator;return e.e=G(r,n,e.e),o!==e.t&&(r.innerHTML=e.t=o),e}),{e:void 0,t:void 0}),r),(e=dt(),d((n=>{var r=t.decoratorRightStyle,o=t.decorator;return n.e=G(e,r,n.e),o!==n.t&&(e.innerHTML=n.t=o),n}),{e:void 0,t:void 0}),e)];var e,r}),o),o.style.setProperty("height","100px"),o.style.setProperty("text-align","center"),U(c,(()=>t.title)),U(g,(()=>i("main.charitySelect"))),d((n=>{var o=at(l(),pe,{cursor:"default"}),i=t.logo,a=me,c=t.title,u=at(l(),{...fe,"background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812"},he),d=l(),p=`Select charity: ${t.title}`;return n.e=G(r,o,n.e),i!==n.t&&$(s,"src",n.t=i),n.a=G(s,a,n.a),c!==n.o&&$(s,"alt",n.o=c),n.i=G(g,u,n.i),d!==n.n&&(g.disabled=n.n=d),p!==n.s&&$(g,"aria-label",n.s=p),n}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),r;var n,r,o,s,c,g}))),b),b.$$click=()=>!l()&&e.onSuppress(),y.style.setProperty("height","100px"),y.style.setProperty("text-align","center"),U(y,(()=>i("main.sixthBox")),null),U(w,(()=>i("main.settings"))),k.$$click=()=>{e.onOfferDetailsClick(!t()),n(!t())},U(k,(()=>i("main.offerDetails"))),P.$$click=()=>{st.trackEvent(z.checkoutPopupWhyAmISeeingThisClicked,{domain:globalThis.window.location.hostname})},U(P,(()=>i("main.whyAmISeeingThis"))),U(g,(c=h((()=>!!e.checkoutPopupConf.checkoutPopupDisplayNameInFooter)),()=>{return c()&&(U(e=dt(),(()=>i("main.footer"))),d((t=>G(e,we,t))),e);var e}),null),d((t=>{var n=ie,r=se,o=ae,i=ue,s=de,a=at(l(),pe,{cursor:"default"}),c=at(l(),{...fe,"background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812"},he),u=l(),d=ye,p=ke,h=Ce,A=e.checkoutPopupConf.externalUrls.giveFreelyWhyAmISeeingThis;return t.e=G(g,n,t.e),t.t=G(m,r,t.t),t.a=G(f,o,t.a),t.o=G(x,i,t.o),t.i=G(v,s,t.i),t.n=G(b,a,t.n),t.s=G(w,c,t.s),u!==t.h&&(w.disabled=t.h=u),t.r=G(C,d,t.r),t.d=G(k,p,t.d),t.l=G(P,h,t.l),A!==t.u&&$(P,"href",t.u=A),t}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0}),g),N(_,{get when(){return t()},get children(){return N(Ue,{get merchantName(){return e.activeDomain.Merchant.Name},get extensionName(){return e.checkoutPopupConf.displayName},get termsUrl(){return e.checkoutPopupConf.externalUrls.giveFreelyTermsAndConditions},get parsedMaxRate(){return h((()=>!!e.activeDomain.Merchant.MaxRate))()?Re(e.activeDomain.Merchant.MaxRate.Kind,e.activeDomain.Merchant.MaxRate?.Amount):null},get merchantRateDetail(){return e.merchantRates},onClose:()=>n(!1)})}})];var c,g,m,f,x,v,b,y,w,C,k,P}M(["click"]);var ht=F("<button class=give-freely-close-button aria-label=Close>×"),mt=F("<label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=18250><span>"),ft=F('<div><div><div></div></div><button class=give-freely-back-button aria-label="Back to charity selection"></button><hr><div id=give-freely-goodbye-screen-options><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=1></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=7></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=30></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=90><span></span></label></div><button class=give-freely-submit-button>');function At(e){const[t,n]=u(0),r=Le();return o=ft(),i=o.firstChild,s=i.firstChild,a=i.nextSibling,l=a.nextSibling.nextSibling,g=(c=l.firstChild).firstChild,h=(p=c.nextSibling).firstChild,f=(m=p.nextSibling).firstChild,v=(x=(A=m.nextSibling).firstChild).nextSibling,b=l.nextSibling,o.style.setProperty("font-size","14px"),U(s,(()=>r("suppress.title"))),U(i,N(_,{get when(){return e.checkoutPopupConf.checkoutPopupSupressCloseButtonVisible},get children(){var t=ht();return t.$$click=()=>e.onGoodbye(0),d((e=>G(t,le,e))),t}}),null),a.$$click=()=>e.onBack(),U(a,(()=>r("suppress.backButton"))),g.addEventListener("change",(()=>n(1))),U(c,(()=>r("suppress.suppressionPeriod").replace("{0}","1")),null),h.addEventListener("change",(()=>n(7))),U(p,(()=>r("suppress.suppressionPeriodPlural").replace("{0}","7")),null),f.addEventListener("change",(()=>n(30))),U(m,(()=>r("suppress.suppressionPeriodPlural").replace("{0}","30")),null),x.addEventListener("change",(()=>n(90))),U(v,(()=>r("suppress.suppressionPeriodPlural").replace("{0}","90"))),U(l,N(_,{get when(){return e.checkoutPopupConf.checkoutPopupNeverSuppressionAllowed},get children(){var e=mt(),t=e.firstChild,o=t.nextSibling;return t.addEventListener("change",(()=>n(18250))),U(o,(()=>r("suppress.suppressionPeriodNever"))),d((t=>G(e,xe,t))),e}}),null),b.$$click=()=>{const n=t();n&&(e.onGoodbye(n),e.setScreen("main"))},U(b,(()=>r("suppress.submitButton"))),d((t=>{var n=se,r=ae,o=be,g=Ae,u=xe,d=xe,h=xe,f=xe,x={...fe,"font-weight":"700","margin-top":"10px","margin-bottom":"0px","background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812",width:"100px"};return t.e=G(i,n,t.e),t.t=G(s,r,t.t),t.a=G(a,o,t.a),t.o=G(l,g,t.o),t.i=G(c,u,t.i),t.n=G(p,d,t.n),t.s=G(m,h,t.s),t.h=G(A,f,t.h),t.r=G(b,x,t.r),t}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),o;var o,i,s,a,l,c,g,p,h,m,f,A,x,v,b}M(["click"]);var xt=F("<div><p>"),vt=F("<div><div><div></div><button class=give-freely-close-button aria-label=Close>×</button></div><hr><div><span>");function bt(e){const[t,n]=u(null),r=Le();let o;var s,a,l,c,g,p,m,A;return s=()=>clearInterval(o),null===i||(null===i.cleanups?i.cleanups=[s]:i.cleanups.push(s)),f((()=>{e.failedDonation||(()=>{const t=e.checkoutPopupConf.checkoutPopupDonationSuccessAutoCloseInSeconds??3;n(t),o=setInterval((()=>{n((t=>null===t||t<=1?(clearInterval(o),e.onClose(),0):t-1))}),1e3)})()})),l=vt(),c=l.firstChild,g=c.firstChild,p=g.nextSibling,m=c.nextSibling.nextSibling,A=m.firstChild,l.style.setProperty("font-size","14px"),U(g,(a=h((()=>!!e.failedDonation)),()=>a()?r("donate.failTitle"):r("donate.title"))),p.$$click=()=>e.onClose(),m.style.setProperty("padding","30px"),m.style.setProperty("height","150px"),m.style.setProperty("font-size","14px"),U(l,N(_,{get when(){return!e.failedDonation},get children(){var e=xt(),n=e.firstChild;return U(n,(()=>Fe.formatMessage(r("donate.autoClosing"),t()??0))),d((e=>G(n,ve,e))),e}}),null),d((t=>{var n=se,o=ae,i=le,s=e.failedDonation?r("donate.failContent"):r("donate.content");return t.e=G(c,n,t.e),t.t=G(g,o,t.t),t.a=G(p,i,t.a),s!==t.o&&(A.innerHTML=t.o=s),t}),{e:void 0,t:void 0,a:void 0,o:void 0}),l}M(["click"]);var yt=F("<div><div>");const wt=(e,t,n)=>"donate"===e?"340px":t.checkoutPopupDisplayNameInFooter?"520px":n;function Ct(e){const[t,n]=u("main"),[r,o]=u(),[i,s]=u(!1),a=()=>{e.logger.debug("Close button clicked"),e.onClose()},l=async(t,r=!1)=>{r&&e.onClose(),e.logger.info("Charity selected",{charity:t,domain:e.activeDomain.Domain}),o(t);const i=await e.onDonate(t,e.activeDomain);r?e.onClose():(s(!i),n("donate"))},c=()=>{e.logger.debug("Suppress button clicked"),n("goodbye")},g=()=>{e.logger.debug("Navigating back to main screen"),n("main")},p=t=>{e.logger.info("User chose to hide popup",{days:t}),e.onClose(t)};let h;return x=yt(),v=x.firstChild,"function"==typeof h?(f=h,A=v,m((()=>f(A,undefined)))):h=v,U(v,N(_,{get when(){return"main"===t()},get children(){return N(pt,{mainContainerRef:h,get checkoutPopupConf(){return e.checkoutPopupConf},get activeDomain(){return e.activeDomain},get merchantRates(){return e.merchantRates},onClose:a,onCharitySelect:l,onSuppress:c,get onOfferDetailsClick(){return e.onOfferDetailsClick}})}}),null),U(v,N(_,{get when(){return"goodbye"===t()},get children(){return N(At,{get checkoutPopupConf(){return e.checkoutPopupConf},onClose:()=>e.onClose(),onBack:g,onGoodbye:p,setScreen:n})}}),null),U(v,N(_,{get when(){return"donate"===t()},get children(){return N(bt,{get checkoutPopupConf(){return e.checkoutPopupConf},get selectedCharity(){return r()},onClose:()=>e.onClose(),get failedDonation(){return i()},setScreen:n})}}),null),d((n=>{var r={...re,height:wt(t(),e.checkoutPopupConf,re.height)},o=e.elementId,i=oe;return n.e=G(x,r,n.e),o!==n.t&&$(x,"id",n.t=o),n.a=G(v,i,n.a),n}),{e:void 0,t:void 0,a:void 0}),x;var f,A,x,v}function kt(e){const t=["",".asp",".aspx",".php",".js",".htm",".html"],n=["cart","checkout","shopping-bag","shopping-basket","shopping-cart","basket"].flatMap((e=>t.map((t=>e+t)))).filter((e=>"basket"!==e)),r=["tote-cart","tote.cart"],o=e,i=n.filter((e=>o.includes(e))),s=o.split("/");return!s.some((e=>r.some((t=>e.includes(t)))))&&(s.some((e=>n.some((t=>e.startsWith(t)||e.endsWith(t)))))||"basket"===s[s.length-1].toLowerCase()||i.length>1||1===i.length&&o.includes("shopping"))}function Pt(e,t){const n=["book"];return e.split("/").some((e=>n.some((t=>e.startsWith(t)||e.endsWith(t)))))&&null!=t.evaluate("//*[self::h1 or self::h2 or self::h3 or self::h4 or self::h5 or self::h6][contains(., 'Your Reservation') or contains(., 'Your reservation')]",t,null,XPathResult.ANY_TYPE,null)?.iterateNext()}async function Et(e){try{const t=await te({type:rt,payload:{shopId:e}});return t.payload.found&&t.payload.domain?t.payload.domain:null}catch{return null}}function St(e){try{const e=Array.from(document.querySelectorAll("script"));for(const t of e){if(t.dataset?.shopId&&(t.dataset?.shopId?.startsWith("gid")||t.src.includes("shopify"))){const e=parseInt(t.dataset.shopId.replace("gid://shopify/Shop/",""));if(!Number.isNaN(e)&&e>0)return e}const e=t.textContent||"";if(e.includes("ShopifyAnalytics")&&e.includes("shopId")){const t=e.match(/shopId['"]*:\s*['"]*(\d+)['"]*[,}]/);if(t&&t[1]){const e=parseInt(t[1]);if(!Number.isNaN(e)&&e>0)return e}}}const t=document.querySelector("[data-shop-id]");if(t instanceof HTMLElement){const{shopId:e}=t.dataset;if(e){const t=parseInt(e);if(!Number.isNaN(t)&&t>0)return t}}const n=window?.ShopifyAnalytics?.lib?.trekkie?.defaultAttributes?.shopId;return n&&parseInt(n)||0}catch(t){return e.error("Error accessing ShopifyAnalytics:",t),0}}function Tt(){try{if(!window.location.href.startsWith("https://shop.app"))return 0;const e=document?.head?.querySelector('meta[name="store"][content]');if(!e)return 0;try{const t=JSON.parse(e.content);return t?.id||0}catch{return 0}}catch{return 0}}const Ot=J.getInstance();function Rt(e,t,n){try{const r=function(e){try{const t=e.split(".");return t.length>=2?t.slice(-2).join("."):e}catch(e){return Ot.error("Error extracting domain",e),""}}(n);Ot.debug("Checking merchant regex rules",{currentDomain:r,currentUrl:t});const o=e.merchantPopupRules.filter((e=>r.includes(e.domain)));if(0===o.length)return Ot.debug("No matching merchant rules found for domain",{currentDomain:r}),!1;for(const e of o)for(const n of e.rules)try{if(new RegExp(n.rule).test(t))return Ot.debug("Merchant regex rule matched",{merchant:e.name,rule:n.rule,currentUrl:t}),!0}catch(t){Ot.error("Invalid regex in merchant rule",{merchant:e.name,rule:n.rule,error:t})}return Ot.debug("No matching regex rules found",{currentUrl:t}),!1}catch(e){return Ot.error("Error in merchantRegexRule",e),!1}}function Dt(){const e=document.documentElement.lang,t=document.querySelector('meta[http-equiv="Content-Language"]')?.content,n=document.querySelector('link[rel="alternate"][hreflang]')?.getAttribute("hreflang"),r=navigator.language,o=e||t||n||r||"en";return"string"==typeof o?o.split("-")[0]:"en"}function It(e){return!0!==e.checkoutPopupOnlyShowLanguageMatch||"en"===Dt()}const Nt=(e,t=!1)=>e.length<2&&t?null:Array.from(e).filter((e=>!t||e.dataset.extensionId!==ee.runtime.id)).map((e=>e.dataset.extensionName)).join(",");const _t=e=>{const t=h((()=>({translate:e.translate()||(e=>""),getAllCharities:e.charities()||(()=>[])})));return N(Ne.Provider,{value:t,get children(){return e.children}})},Lt=J.getInstance(),Ft="countryCode",Mt=async()=>await We.get(Ft)||(async()=>{Lt.debug("detecting country");const e={method:"GET",headers:{"Content-Type":"application/json",Authorization:"Basic OTEzOTkxOnFlYmpaWF9DOGNRY0lxSHA4WTVjNGxzU1pRSlM2VW9MMExzTF9tbWs="}};try{const t=await fetch("https://geoip.maxmind.com/geoip/v2.1/country/me",e);if(Lt.debug("Received geolocation response",{status:t.status}),!t.ok)return void Lt.warn("Failed to get geolocation data",{status:t.status});const n=await t.json();if(!n)throw new Error("There was an error fetching geoip look up");return await We.set(Ft,n.country.iso_code),n.country.iso_code}catch(e){return void Lt.error("Failed to get geolocation data",{error:e})}})();var $t=F("<div class=gf-app>");function Gt(){const e=J.getInstance(),[t,n]=u(null),[r,o]=u(void 0),[i,s]=u(!1),[a,l]=u([]),[c,g]=u(),[d,p]=u({});f((async()=>{e.info("Mounting GfApp component");try{const i=await(async()=>{const e=await te({type:Ze,payload:{}});if(!e.payload.config)throw new Error("No checkout popup config found");return e.payload.config})();if(!i)return void e.error("No checkout popup config found");n(i),e.configure({enabled:!0,title:"Content - GfAdUnit",minLevel:i.checkoutPopupMinLogLevel??"error"}),function(e){if(!e?.shouldCheckSiteMatches)return;let t;(e?.siteMatchesRegex??[]).some((e=>{var n;return n=window.location.href,!(!new RegExp(e).test(n)||(t=e,0))}))&&t&&st.trackEvent(z.checkoutPopupSiteMatches,{url:window.location.href,matchedRule:t,uts:Date.now()},!0)}(i);const a=Dt();v(a);const c=ze();if(i.minVersion&&((e,t)=>{if(e===t)return!1;const n=e.split(".").map((e=>parseInt(e,10))),r=t.split(".").map((e=>parseInt(e,10)));for(let e=0;e<n.length;e++){if(n[e]<r[e])return!0;if(n[e]>r[e])return!1}return!1})(c,i.minVersion))return void e.debug(`Current version: ${c}. Minimum version ${i.minVersion} not met`);const g=await Mt()??"us",u=i.charities[g.toLowerCase()]??i.charities.us;if(p(u||{}),e.debug("Charities for current country",{currentCountry:g,charities:u}),!1===i.checkoutPopupMasterSwitch)return void e.debug("Checkout popup master switch is disabled");const d=document.getElementsByClassName("give-freely-root");let h=!1;d.length>1&&(e.debug("There is more than one gf extension installed"),d.item(0).dataset.extensionId!==ee.runtime.id&&(e.debug("Giving preference to the first gf extension injected in the DOM"),h=!0),e.debug("Providing this extension preference over the other installed extensions"));const{domain:m,rates:f}=await(async e=>{const{hostname:t}=window.location;e.debug("Checking if domain is active",{hostname:t});const n=await te({type:Qe,payload:{hostname:t}});return n.payload.isActive?(e.debug("Active domain",{domain:n.payload.domain}),e.debug("Merchant rates",{rates:n.payload.rates}),e.info("Domain and rates ({})ed successfully."),{isActive:!0,domain:n.payload.domain,rates:n.payload.rates}):{isActive:!1,domain:void 0,rates:[]}})(e);if(l(f),o(m),m)await function(e,t){const n=St(t)||Tt();return n>0&&function(e,t,n){if(e&&!(e<=0))try{te({type:nt,payload:{shopId:e,domain:t}}).catch((e=>{n.error("Error sending shop ID to background:",e)}))}catch(e){n.error("Error sending Shopify shop ID:",e)}}(n,e,t),n}(m,e);else{if("shop.app"!==window.location.hostname&&!window.location.hostname.endsWith(".shop.app"))return void s(!1);const t=window.location.pathname.split("/")[2];if(!t)return e.error("Shop ID not found"),void s(!1);const n=await Et(parseInt(t));if(!n)return e.error("Shop domain not found"),void s(!1);e.debug("Shop domain found",{shopDomain:n}),o(n)}const A=await(async e=>{const t=await We.get("popup_hide");if(!t)return e.debug("No expiry found in storage"),!1;const{popupHide:n}=t,r=!!n&&Date.now()<n;return e.debug("Is AdUnit Muted?",{isMuted:r,expiry:n}),r})(e);if(A)return;if(!r())return void s(!1);const x=await(async(e,t)=>{const{Domain:n}=t,r=window.location.href,{payload:o}=await te({type:et,payload:{activeDomain:n,url:r}});return!!o.result&&(e.info("Stand Down detected"),!0)})(e,r());if(x)return void s(!1);const b=t()?.anonymousActiveDomainLogging??!1,y=r()??void 0;y&&b&&!function(e){const t=`gfhv-${e}`;return!!sessionStorage.getItem(t)||(sessionStorage.setItem(t,"true"),!1)}(y.Domain)&&st.trackEvent(z.checkoutPopupActiveDomain,{url:y.Domain});const w=setInterval((async()=>{e.debug("Checking checkout rules");const t=await(async e=>{const t=J.getInstance();t.configure({enabled:!0,title:"Content - checkoutRulesTest"});const n=new URL(globalThis.location.href),r=n.href,{hostname:o}=n;t.debug("Checking if popup should be shown",{currentUrl:r});const i=await async function(e){const t=St(e)||Tt();return!("shop.app"!==window.location.hostname&&!window.location.hostname.endsWith(".shop.app")||!(t>0)||!await Et(t))}(t),s=It(e)&&(kt(n.pathname.toLowerCase())||Pt(r,document)||Rt(e,r,o)||i);return t.debug("Popup show decision based on rules",{shouldShow:s,matchesCartRule:kt(n.pathname.toLowerCase()),matchesBookingRule:Pt(r,document),matchesShopPayRule:i,matchesMerchantRegexRule:Rt(e,r,o),matchesLanguageRule:It(e)}),s})(i);if(t&&h)return st.trackEvent(z.checkoutPopupLooserExtension,{url:globalThis.window.location.href,winner:d.item(0).dataset.extensionName}),e.debug("Standing down because, another ad-unit extension will pop"),void clearInterval(w);s(t),t&&(e.debug("Should show popup based on checkout rules",{shouldShowResult:t}),st.trackEvent(z.checkoutPopupShown,{url:globalThis.window.location.href,pageLanguage:a,looserCompetingExtensions:Nt(d,!0)}),clearInterval(w))}),2e3)}catch(t){s(!1),e.error("An error occurred in GfApp",{error:t})}}));const m=async(t,n)=>{e.info("Processing donation",{charity:t,domain:n.Domain});const r=await(async(e,t,n,r)=>{e.debug("Activating offer",{activeDomain:t,selectedCharity:r});const o=await ne({type:tt,payload:{activeDomain:t,originalUrl:n,selectedCharity:r}});return e.debug("Activate offer response",{response:o}),o})(e,n,window.location.href,{ein:t.ein,thirdPartyId:t.tpi});return e.debug("Activate offer response",{activationResponse:r}),st.trackEvent(r.payload.response?z.checkoutPopupDonation:z.checkoutPopupFailedActivation,{activeDomain:n.Domain,url:globalThis.window.location.href,charity:{ein:t.ein,tpi:t.tpi},rate:n.Merchant.MaxRate}),r.payload.response},A=async t=>{s(await(async(e,t)=>{try{e.info("Hiding ad",{days:t});const n=await ne({type:Xe,payload:{days:t??0}});return void 0!==t&&st.trackEvent(z.checkoutPopupSupressed,{url:globalThis.window.location.href,days:t}),e.info("Hiding ad response",{hideResponse:n}),n.payload.ack?(e.debug("Ad hidden successfully"),!1):(e.warn("Failed to hide ad"),!0)}catch{return!1}})(e,t))},x=async e=>{st.trackEvent(z.checkoutPopupOfferDetailsClicked,{action:e?"opened":"closed"})},v=async t=>{e.debug("Getting translation provider",{currentLanguage:t});const{translations:n,charities:r}=await async function(e,t){try{t&&t.debug("Getting language content",{languageCode:e});const n=await te({type:ot,payload:{lang:e}});return{translations:n.payload.translations,charities:n.payload.charities}}catch(n){return t&&t.error("Error getting language content",{error:n,languageCode:e}),{translations:null,charities:null}}}(t,e),o={translate:e=>n&&n[e]?n[e]:"",getAllCharities:()=>{const e=d();return Object.entries(e).map((([e,t])=>{const{ein:n}=t,o=r?.[n];if(!o)throw new Error(`Failed to find charity metadata for ein ${n}`);return{ein:n,tpi:o.tpi,title:o.title,order:parseInt(e,10),logo:o.logo,decorator:t.decorator,decoratorLeftStyle:t.decoratorLeftStyle,decoratorRightStyle:t.decoratorRightStyle}}))}};e.debug("Setting content provider with translations and charity functions"),g((()=>o))};return N(_t,{translate:()=>c()?.translate,charities:()=>c()?.getAllCharities,get children(){var n,o=$t();return U(o,(n=h((()=>!(!r()||!i()))),()=>n()&&N(Ct,{get checkoutPopupConf(){return t()},elementId:"give-freely-checkout-popup",get activeDomain(){return r()},get merchantRates(){return a()},onClose:A,onDonate:m,onOfferDetailsClick:x,logger:e}))),o}})}exports.browser=ee,exports.initializeAdUnit=async function(){const e=`give-freely-root-${ee.runtime.id}`;if(document.getElementById(e))return;const t=document.createElement("div");t.id=e,t.className="give-freely-root",t.style.display="block",t.dataset.extensionId=ee.runtime.id,t.dataset.extensionName=ee.runtime.getManifest().name||ee.runtime.id,document.body.appendChild(t);const n=t.attachShadow({mode:"open"}),r=document.createElement("div"),s=document.createElement("style");s.textContent='\n :host {\n all: initial;\n }\n\n .gf-scroll-remove::-webkit-scrollbar {\n border-radius-bottom-right: 15px;\n }\n\n button {\n cursor: pointer;\n transition: transform 0.1s ease;\n }\n\n button:active {\n transform: scale(0.98);\n }\n\n .give-freely-close-button:hover {\n opacity: 0.7;\n }\n\n input[type="radio"] {\n margin-right: 8px;\n }\n\n hr {\n border: none;\n border-top: 1px solid #e5e5e5;\n margin: 1em 0;\n }\n\n @media (max-width: 600px), (max-height: 480px) {\n #give-freely-checkout-popup {\n display: none !important;\n }\n }\n',n.appendChild(s),n.appendChild(r),function(e,t,n,r={}){let s;(function(e,t){const n=a,r=i,s=0===e.length,l=void 0===t?r:t,c=s?o:{owned:null,cleanups:null,context:l?l.context:null,owner:l},g=s?e:()=>e((()=>m((()=>O(c)))));i=c,a=null;try{return k(g,!0)}finally{a=n,i=r}})((r=>{s=r,t===document?e():U(t,e(),t.firstChild?null:void 0,n)}),r.owner)}((()=>N(Gt,{})),r)};
|
|
1
|
+
"use strict";const e={equals:(e,t)=>e===t};let t=P;const n=1,r=2,o={owned:null,cleanups:null,context:null,owner:null};var i=null;let s=null,a=null,l=null,c=null,g=0;function u(t,n){const r={value:t,observers:null,observerSlots:null,comparator:(n=n?Object.assign({},e,n):e).equals||void 0};return[v.bind(r),e=>("function"==typeof e&&(e=e(r.value)),b(r,e))]}function d(e,t,r){y(w(e,t,!1,n))}function p(e,r,o){t=E;const i=w(e,r,!1,n);i.user=!0,c?c.push(i):y(i)}function h(t,n,r){r=r?Object.assign({},e,r):e;const o=w(t,n,!0,0);return o.observers=null,o.observerSlots=null,o.comparator=r.equals||void 0,y(o),v.bind(o)}function m(e){if(null===a)return e();const t=a;a=null;try{return e()}finally{a=t}}function f(e){p((()=>m(e)))}function A(e){let t;return i&&i.context&&void 0!==(t=i.context[e.id])?t:e.defaultValue}function x(e){const t=h(e),n=h((()=>D(t())));return n.toArray=()=>{const e=n();return Array.isArray(e)?e:null!=e?[e]:[]},n}function v(){if(this.sources&&this.state)if(this.state===n)y(this);else{const e=l;l=null,k((()=>S(this)),!1),l=e}if(a){const e=this.observers?this.observers.length:0;a.sources?(a.sources.push(this),a.sourceSlots.push(e)):(a.sources=[this],a.sourceSlots=[e]),this.observers?(this.observers.push(a),this.observerSlots.push(a.sources.length-1)):(this.observers=[a],this.observerSlots=[a.sources.length-1])}return this.value}function b(e,t,r){let o=e.value;return e.comparator&&e.comparator(o,t)||(e.value=t,e.observers&&e.observers.length&&k((()=>{for(let t=0;t<e.observers.length;t+=1){const r=e.observers[t],o=s&&s.running;o&&s.disposed.has(r),(o?r.tState:r.state)||(r.pure?l.push(r):c.push(r),r.observers&&T(r)),o||(r.state=n)}if(l.length>1e6)throw l=[],new Error}),!1)),t}function y(e){if(!e.fn)return;O(e);const t=g;!function(e,t,r){let o;const s=i,l=a;a=i=e;try{o=e.fn(t)}catch(t){return e.pure&&(e.state=n,e.owned&&e.owned.forEach(O),e.owned=null),e.updatedAt=r+1,R(t)}finally{a=l,i=s}(!e.updatedAt||e.updatedAt<=r)&&(null!=e.updatedAt&&"observers"in e?b(e,o):e.value=o,e.updatedAt=r)}(e,e.value,t)}function w(e,t,r,s=n,a){const l={fn:e,state:s,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:i,context:i?i.context:null,pure:r};return null===i||i!==o&&(i.owned?i.owned.push(l):i.owned=[l]),l}function C(e){if(0===e.state)return;if(e.state===r)return S(e);if(e.suspense&&m(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<g);)e.state&&t.push(e);for(let o=t.length-1;o>=0;o--)if((e=t[o]).state===n)y(e);else if(e.state===r){const n=l;l=null,k((()=>S(e,t[0])),!1),l=n}}function k(e,n){if(l)return e();let r=!1;n||(l=[]),c?r=!0:c=[],g++;try{const n=e();return function(e){if(l&&(P(l),l=null),e)return;const n=c;c=null,n.length&&k((()=>t(n)),!1)}(r),n}catch(e){r||(c=null),l=null,R(e)}}function P(e){for(let t=0;t<e.length;t++)C(e[t])}function E(e){let t,n=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[n++]=r:C(r)}for(t=0;t<n;t++)C(e[t])}function S(e,t){e.state=0;for(let o=0;o<e.sources.length;o+=1){const i=e.sources[o];if(i.sources){const e=i.state;e===n?i!==t&&(!i.updatedAt||i.updatedAt<g)&&C(i):e===r&&S(i,t)}}}function T(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=r,n.pure?l.push(n):c.push(n),n.observers&&T(n))}}function O(e){let t;if(e.sources)for(;e.sources.length;){const t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){const e=r.pop(),o=t.observerSlots.pop();n<r.length&&(e.sourceSlots[o]=n,r[n]=e,t.observerSlots[n]=o)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)O(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)O(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function R(e,t=i){const n=function(e){return e instanceof Error?e:new Error("string"==typeof e?e:"Unknown error",{cause:e})}(e);throw n}function D(e){if("function"==typeof e&&!e.length)return D(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const r=D(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function I(e,t){return function(t){let n;return d((()=>n=m((()=>(i.context={...i.context,[e]:t.value},x((()=>t.children)))))),void 0),n}}function N(e,t){return m((()=>e(t||{})))}function _(e){const t=e.keyed,n=h((()=>e.when),void 0,{equals:(e,n)=>t?e===n:!e==!n});return h((()=>{const r=n();if(r){const o=e.children;return"function"==typeof o&&o.length>0?m((()=>o(t?r:()=>{if(!m(n))throw"Stale read from <Show>.";return e.when}))):o}return e.fallback}),void 0,void 0)}const L="_$DX_DELEGATE";function F(e,t,n){let r;const o=()=>(r||(r=(()=>{const t=document.createElement("template");return t.innerHTML=e,t.content.firstChild})())).cloneNode(!0);return o.cloneNode=o,o}function M(e,t=window.document){const n=t[L]||(t[L]=new Set);for(let r=0,o=e.length;r<o;r++){const o=e[r];n.has(o)||(n.add(o),t.addEventListener(o,H))}}function $(e,t,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}function G(e,t,n){if(!t)return n?$(e,"style"):t;const r=e.style;if("string"==typeof t)return r.cssText=t;let o,i;for(i in"string"==typeof n&&(r.cssText=n=void 0),n||(n={}),t||(t={}),n)null==t[i]&&r.removeProperty(i),delete n[i];for(i in t)o=t[i],o!==n[i]&&(r.setProperty(i,o),n[i]=o);return n}function U(e,t,n,r){if(void 0===n||r||(r=[]),"function"!=typeof t)return B(e,t,r,n);d((r=>B(e,t(),r,n)),r)}function H(e){let t=e.target;const n=`$$${e.type}`,r=e.target,o=e.currentTarget,i=t=>Object.defineProperty(e,"target",{configurable:!0,value:t}),s=()=>{const r=t[n];if(r&&!t.disabled){const o=t[`${n}Data`];if(void 0!==o?r.call(t,o,e):r.call(t,e),e.cancelBubble)return}return t.host&&"string"!=typeof t.host&&!t.host._$host&&t.contains(e.target)&&i(t.host),!0},a=()=>{for(;s()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get:()=>t||document}),e.composedPath){const n=e.composedPath();i(n[0]);for(let e=0;e<n.length-2&&(t=n[e],s());e++){if(t._$host){t=t._$host,a();break}if(t.parentNode===o)break}}else a();i(r)}function B(e,t,n,r,o){for(;"function"==typeof n;)n=n();if(t===n)return n;const i=typeof t,s=void 0!==r;if(e=s&&n[0]&&n[0].parentNode||e,"string"===i||"number"===i){if("number"===i&&(t=t.toString())===n)return n;if(s){let o=n[0];o&&3===o.nodeType?o.data!==t&&(o.data=t):o=document.createTextNode(t),n=W(e,n,r,o)}else n=""!==n&&"string"==typeof n?e.firstChild.data=t:e.textContent=t}else if(null==t||"boolean"===i)n=W(e,n,r);else{if("function"===i)return d((()=>{let o=t();for(;"function"==typeof o;)o=o();n=B(e,o,n,r)})),()=>n;if(Array.isArray(t)){const i=[],a=n&&Array.isArray(n);if(j(i,t,n,o))return d((()=>n=B(e,i,n,r,!0))),()=>n;if(0===i.length){if(n=W(e,n,r),s)return n}else a?0===n.length?K(e,i,r):function(e,t,n){let r=n.length,o=t.length,i=r,s=0,a=0,l=t[o-1].nextSibling,c=null;for(;s<o||a<i;)if(t[s]!==n[a]){for(;t[o-1]===n[i-1];)o--,i--;if(o===s){const t=i<r?a?n[a-1].nextSibling:n[i-a]:l;for(;a<i;)e.insertBefore(n[a++],t)}else if(i===a)for(;s<o;)c&&c.has(t[s])||t[s].remove(),s++;else if(t[s]===n[i-1]&&n[a]===t[o-1]){const r=t[--o].nextSibling;e.insertBefore(n[a++],t[s++].nextSibling),e.insertBefore(n[--i],r),t[o]=n[i]}else{if(!c){c=new Map;let e=a;for(;e<i;)c.set(n[e],e++)}const r=c.get(t[s]);if(null!=r)if(a<r&&r<i){let l,g=s,u=1;for(;++g<o&&g<i&&null!=(l=c.get(t[g]))&&l===r+u;)u++;if(u>r-a){const o=t[s];for(;a<r;)e.insertBefore(n[a++],o)}else e.replaceChild(n[a++],t[s++])}else s++;else t[s++].remove()}}else s++,a++}(e,n,i):(n&&W(e),K(e,i));n=i}else if(t.nodeType){if(Array.isArray(n)){if(s)return n=W(e,n,r,t);W(e,n,null,t)}else null!=n&&""!==n&&e.firstChild?e.replaceChild(t,e.firstChild):e.appendChild(t);n=t}}return n}function j(e,t,n,r){let o=!1;for(let i=0,s=t.length;i<s;i++){let s,a=t[i],l=n&&n[e.length];if(null==a||!0===a||!1===a);else if("object"==(s=typeof a)&&a.nodeType)e.push(a);else if(Array.isArray(a))o=j(e,a,l)||o;else if("function"===s)if(r){for(;"function"==typeof a;)a=a();o=j(e,Array.isArray(a)?a:[a],Array.isArray(l)?l:[l])||o}else e.push(a),o=!0;else{const t=String(a);l&&3===l.nodeType&&l.data===t?e.push(l):e.push(document.createTextNode(t))}}return o}function K(e,t,n=null){for(let r=0,o=t.length;r<o;r++)e.insertBefore(t[r],n)}function W(e,t,n,r){if(void 0===n)return e.textContent="";const o=r||document.createTextNode("");if(t.length){let r=!1;for(let i=t.length-1;i>=0;i--){const s=t[i];if(o!==s){const t=s.parentNode===e;r||i?t&&s.remove():t?e.replaceChild(o,s):e.insertBefore(o,n)}else r=!0}}else e.insertBefore(o,n);return[o]}class V{log({level:e,message:t,timestamp:n,data:r,title:o}){const i="debug"===e?"log":e,s=o?`[${o}]`:"";void 0!==r?console[i](`[${n}] - ${V.LOGGER_PREFIX} ${s} ${t}`,r):console[i](`[${n}] - ${V.LOGGER_PREFIX} ${s} ${t}`)}}var z,Y;V.LOGGER_PREFIX="[GFAdUnit] -",function(e){e.checkoutPopupShown="CHECKOUT-POPUP-SHOWN",e.checkoutPopupNotShown="CHECKOUT-POPUP-NOT-SHOWN",e.checkoutPopupSupressed="CHECKOUT-POPUP-SUPRESSED",e.checkoutPopupDonation="CHECKOUT-POPUP-DONATION",e.checkoutPopupFailedActivation="CHECKOUT-POPUP-FAILED-ACTIVATION",e.checkoutPopupPurchaseConfirmed="CHECKOUT-POPUP-PURCHASE-CONFIRMED",e.checkoutPopupHealthCheck="CHECKOUT-POPUP-HEALTH-CHECK",e.checkouPopupActivationFailed="CHECKOUT-POPUP-ACTIVATION-FAILED",e.checkoutPopupOfferDetailsClicked="CHECKOUT-POPUP-OFFER-DETAILS-CLICKED",e.checkoutPopupWhyAmISeeingThisClicked="CHECKOUT-POPUP-WHY-AM-I-SEEING-THIS-CLICKED",e.checkoutPopupLooserExtension="CHECKOUT-POPUP-LOOSER-EXTENSION",e.checkoutPopupActiveDomain="CHECKOUT-POPUP-ACTIVE-DOMAIN",e.checkoutPopupSiteMatches="CHECKOUT-POPUP-SITE-MATCHES"}(z||(z={})),function(e){e.adUnitLog="ADUNIT-LOG"}(Y||(Y={}));const q=["debug","info","warn","error"];class J{constructor(e){this.config={minLevel:e?.minLevel??"debug",enabled:e?.enabled??!1,transports:e?.transports??[new V],title:e?.title??""}}static getInstance(e){return J.instance||(J.instance=new J(e)),J.instance}configure(e){this.config={...this.config,...e}}shouldLog(e){return!!this.config.enabled&&q.indexOf(e)>=q.indexOf(this.config.minLevel)}createLogMessage(e,t,n){return{level:e,version:"1.6.3",message:t,timestamp:(new Date).toISOString(),data:n,title:this.config.title}}log(e,t,n){if(!this.shouldLog(e))return;const r=this.createLogMessage(e,t,n);this.config.transports.forEach((e=>e.log(r)))}debug(e,t){this.log("debug",e,t)}info(e,t){this.log("info",e,t)}warn(e,t){this.log("warn",e,t)}error(e,t){this.log("error",e,t)}addTransport(e){this.config.transports.push(e)}clearTransports(){this.config.transports=[]}disable(){this.config.enabled=!1}enable(){this.config.enabled=!0}}const X=3,Z=e=>1e3*e;async function Q(e,t={}){const{maxAttempts:n=X,delayFn:r=Z}=t;let o=null;for(let t=1;t<=n;t+=1)try{return await e()}catch(e){o=e,t<n&&await new Promise((e=>{setTimeout(e,r(t))}))}throw o||new Error("Operation failed after multiple attempts")}const ee=chrome;async function te(e,t){return new Promise(((n,r)=>{try{const o=t=>chrome.runtime.lastError?r({error:chrome.runtime.lastError,message:e}):n(t);t?.tabId||ee.runtime.sendMessage(e,o)}catch(e){r(e)}}))}async function ne(e,t,n){return Q((()=>te(e,t)),{maxAttempts:X,delayFn:Z})}const re={display:"block",position:"fixed",top:"0%",left:"100%",width:"500px",height:"520px","margin-left":"-560px","margin-top":"50px",padding:"2px 5px","background-color":"white",border:"1px solid black","border-radius":"10px","box-shadow":"0 2px 10px rgba(0, 0, 0, 0.1)","z-index":"2147483647","font-family":"Arial","line-height":"1","vertical-align":"baseline","box-sizing":"border-box",color:"rgb(34, 34, 34)","@media (max-width: 600px), (max-height: 480px)":{display:"none !important"}},oe={height:"100%","overflow-x":"hidden","overlfow-y":"auto",position:"relative",padding:"0px 15px"},ie={},se={display:"flex","align-items":"center","margin-bottom":"10px"},ae={flex:"1","font-size":"24px","font-weight":"700","margin-top":"20px","margin-bottom":"0px"},le={background:"none",border:"none",padding:"4px 8px",color:"#666464","font-size":"38px",cursor:"pointer","line-height":"1"},ce={color:"black","margin-top":"20px","max-width":"40%"},ge={color:"gray",cursor:"default","pointer-events":"none","text-decoration":"none"},ue={"font-size":"18px","font-weight":"400","margin-top":"20px","margin-bottom":"0px"},de={display:"flex",gap:"10px",width:"100%","margin-top":"20px","margin-bottom":"20px","flex-wrap":"wrap","justify-content":"space-between"},pe={width:"28%",position:"relative",display:"flex","flex-direction":"column","align-items":"center",background:"none",border:"1px solid #ccc","border-radius":"5px",padding:"5px",gap:"5px","text-align":"center","font-size":"14px",cursor:"pointer",transition:"background-color 0.2s ease"},he={color:"white","background-color":"lightgray",cursor:"default","pointer-events":"none"},me={"max-width":"120px","max-height":"70px","margin-bottom":"5px","object-fit":"contain"},fe={"background-color":"#FFD812",cursor:"pointer","border-radius":"8px",padding:"8px",color:"white","min-width":"100px",border:"0","font-weight":"600",width:"100%"},Ae={display:"flex","flex-direction":"column",gap:"10px",width:"100%","color-scheme":"light"},xe={display:"flex","align-items":"center",gap:"5px",border:"1px solid #ddd",padding:"15px","border-radius":"5px","font-weight":"600",cursor:"pointer","margin-bottom":"8px"},ve={"text-align":"right"},be={background:"none",border:"none",color:"blue","text-decoration":"underline",padding:"0",cursor:"pointer","margin-bottom":"15px"},ye={display:"flex","justify-content":"space-between",margin:"20px 0px 10px 0px","font-size":"14px"},we={margin:"5px 0px 5px 0px","font-size":"14px","text-align":"center"},Ce={color:"#666464","text-decoration":"underline"},ke={color:"rgb(102, 100, 100)","text-decoration":"underline",margin:"0",cursor:"pointer"},Pe={width:"100%","background-color":"#f2f2f2",border:"1px solid black","border-radius":"10px","border-top":"1px solid #bbb7b7","margin-top":"10px","margin-bottom":"20px","box-sizing":"border-box"},Ee={padding:"0 5px 0 10px",width:"100%","font-size":"12px","box-sizing":"border-box"},Se={display:"grid","grid-template-columns":"4fr 1fr","padding-right":"15px","padding-bottom":"5px"},Te={color:"#000","margin-bottom":"4px"},Oe={"font-size":"14px",color:"#555","text-align":"right"},Re=(e,t)=>{let n=parseFloat(t);return"FLAT"===e&&(n*=.75),((e,t)=>{let n=parseFloat(t);return n<1&&(n=1),n=Math.floor(n),"PERCENTAGE"===e?`${n}%`:`$${n}`})(e,n.toString())};var De=F("<span>");function Ie(e){return t=De(),d((()=>{return t.innerHTML=(n=e.title,r=e.activeDomain,n.replace("{0}",Re(r.Merchant.MaxRate?.Kind,r.Merchant.MaxRate?.Amount??"0")));var n,r})),t;var t}const Ne=function(){const e=Symbol("context");return{id:e,Provider:I(e),defaultValue:()=>({translate:e=>"",getAllCharities:()=>[]})}}(),_e=Ne,Le=()=>{const e=A(_e)();if(!e)throw new Error("Content provider context is undefined");return t=>e.translate(t)};class Fe{static formatMessage(e,...t){return e.replace(/{(\d+)}/g,((e,n)=>{const r=Number(n);return void 0!==t[r]?String(t[r]):`{${r}}`}))}}var Me=F("<div>"),$e=F("<div><div class=gf-offer-details><p><span></span></p><p><span></span></p><p><span></span></p><p><span></span></p><p><span></span></p><p><a target=_blank rel=noreferrer>"),Ge=F("<div class=gf-offer-details-rate-item><div></div><div>");const Ue=e=>{const t=Le();return n=$e(),o=(r=n.firstChild).firstChild,i=o.firstChild,s=o.nextSibling,a=s.firstChild,l=s.nextSibling,c=l.firstChild,g=l.nextSibling,u=g.firstChild,p=g.nextSibling,h=p.firstChild,m=p.nextSibling.firstChild,U(r,N(_,{get when(){return!!e.merchantRateDetail?.length},get children(){var t=Me();return U(t,(()=>e.merchantRateDetail?.map((e=>{return t=Ge(),n=t.firstChild,r=n.nextSibling,U(n,(()=>e.Name||"")),U(r,(()=>((e,t=1,n=1)=>{const r=e.BoostedOffer??null;let o=parseFloat(e?.Amount??"");if(r?.EndDate&&new Date(r.EndDate)<new Date&&(o=parseFloat(r.OriginalMaxRate)),Number.isNaN(o))return"";const i=o*t;return"PERCENTAGE"===e?.Kind?`${i.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:n})}%`:"FLAT"===e?.Kind?i.toLocaleString("en-US",{style:"currency",currency:e.Currency}):""})(e))),d((e=>{var o=Se,i=Te,s=Oe;return e.e=G(t,o,e.e),e.t=G(n,i,e.t),e.a=G(r,s,e.a),e}),{e:void 0,t:void 0,a:void 0}),t;var t,n,r})))),t}}),g),U(m,(()=>t("offerDetails.termsAndConditions"))),d((o=>{var s=Pe,l=Ee,g=t("offerDetails.intro"),d=t("offerDetails.eligible"),p=e.parsedMaxRate?Fe.formatMessage(t("offerDetails.donationRatesWithValue"),e.parsedMaxRate):Fe.formatMessage(t("offerDetails.donationRates")),f=t("offerDetails.donationAmounts"),A=t("offerDetails.donationTiming"),x=Ce,v=e.termsUrl;return o.e=G(n,s,o.e),o.t=G(r,l,o.t),g!==o.a&&(i.innerHTML=o.a=g),d!==o.o&&(a.innerHTML=o.o=d),p!==o.i&&(c.innerHTML=o.i=p),f!==o.n&&(u.innerHTML=o.n=f),A!==o.s&&(h.innerHTML=o.s=A),o.h=G(m,x,o.h),v!==o.r&&$(m,"href",o.r=v),o}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),n;var n,r,o,i,s,a,l,c,g,u,p,h,m};function He(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var Be={exports:{}};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self&&self,function(e){if(!(globalThis.chrome&&globalThis.chrome.runtime&&globalThis.chrome.runtime.id))throw new Error("This script should only be loaded in a browser extension.");if(globalThis.browser&&globalThis.browser.runtime&&globalThis.browser.runtime.id)e.exports=globalThis.browser;else{const t="The message port closed before a response was received.",n=e=>{const n={alarms:{clear:{minArgs:0,maxArgs:1},clearAll:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getAll:{minArgs:0,maxArgs:0}},bookmarks:{create:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},getChildren:{minArgs:1,maxArgs:1},getRecent:{minArgs:1,maxArgs:1},getSubTree:{minArgs:1,maxArgs:1},getTree:{minArgs:0,maxArgs:0},move:{minArgs:2,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeTree:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}},browserAction:{disable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},enable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},getBadgeBackgroundColor:{minArgs:1,maxArgs:1},getBadgeText:{minArgs:1,maxArgs:1},getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},openPopup:{minArgs:0,maxArgs:0},setBadgeBackgroundColor:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setBadgeText:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},browsingData:{remove:{minArgs:2,maxArgs:2},removeCache:{minArgs:1,maxArgs:1},removeCookies:{minArgs:1,maxArgs:1},removeDownloads:{minArgs:1,maxArgs:1},removeFormData:{minArgs:1,maxArgs:1},removeHistory:{minArgs:1,maxArgs:1},removeLocalStorage:{minArgs:1,maxArgs:1},removePasswords:{minArgs:1,maxArgs:1},removePluginData:{minArgs:1,maxArgs:1},settings:{minArgs:0,maxArgs:0}},commands:{getAll:{minArgs:0,maxArgs:0}},contextMenus:{remove:{minArgs:1,maxArgs:1},removeAll:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},cookies:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:1,maxArgs:1},getAllCookieStores:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},devtools:{inspectedWindow:{eval:{minArgs:1,maxArgs:2,singleCallbackArg:!1}},panels:{create:{minArgs:3,maxArgs:3,singleCallbackArg:!0},elements:{createSidebarPane:{minArgs:1,maxArgs:1}}}},downloads:{cancel:{minArgs:1,maxArgs:1},download:{minArgs:1,maxArgs:1},erase:{minArgs:1,maxArgs:1},getFileIcon:{minArgs:1,maxArgs:2},open:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},pause:{minArgs:1,maxArgs:1},removeFile:{minArgs:1,maxArgs:1},resume:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},extension:{isAllowedFileSchemeAccess:{minArgs:0,maxArgs:0},isAllowedIncognitoAccess:{minArgs:0,maxArgs:0}},history:{addUrl:{minArgs:1,maxArgs:1},deleteAll:{minArgs:0,maxArgs:0},deleteRange:{minArgs:1,maxArgs:1},deleteUrl:{minArgs:1,maxArgs:1},getVisits:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1}},i18n:{detectLanguage:{minArgs:1,maxArgs:1},getAcceptLanguages:{minArgs:0,maxArgs:0}},identity:{launchWebAuthFlow:{minArgs:1,maxArgs:1}},idle:{queryState:{minArgs:1,maxArgs:1}},management:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},getSelf:{minArgs:0,maxArgs:0},setEnabled:{minArgs:2,maxArgs:2},uninstallSelf:{minArgs:0,maxArgs:1}},notifications:{clear:{minArgs:1,maxArgs:1},create:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:0},getPermissionLevel:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},pageAction:{getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},hide:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},permissions:{contains:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},request:{minArgs:1,maxArgs:1}},runtime:{getBackgroundPage:{minArgs:0,maxArgs:0},getPlatformInfo:{minArgs:0,maxArgs:0},openOptionsPage:{minArgs:0,maxArgs:0},requestUpdateCheck:{minArgs:0,maxArgs:0},sendMessage:{minArgs:1,maxArgs:3},sendNativeMessage:{minArgs:2,maxArgs:2},setUninstallURL:{minArgs:1,maxArgs:1}},sessions:{getDevices:{minArgs:0,maxArgs:1},getRecentlyClosed:{minArgs:0,maxArgs:1},restore:{minArgs:0,maxArgs:1}},storage:{local:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},managed:{get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1}},sync:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}}},tabs:{captureVisibleTab:{minArgs:0,maxArgs:2},create:{minArgs:1,maxArgs:1},detectLanguage:{minArgs:0,maxArgs:1},discard:{minArgs:0,maxArgs:1},duplicate:{minArgs:1,maxArgs:1},executeScript:{minArgs:1,maxArgs:2},get:{minArgs:1,maxArgs:1},getCurrent:{minArgs:0,maxArgs:0},getZoom:{minArgs:0,maxArgs:1},getZoomSettings:{minArgs:0,maxArgs:1},goBack:{minArgs:0,maxArgs:1},goForward:{minArgs:0,maxArgs:1},highlight:{minArgs:1,maxArgs:1},insertCSS:{minArgs:1,maxArgs:2},move:{minArgs:2,maxArgs:2},query:{minArgs:1,maxArgs:1},reload:{minArgs:0,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeCSS:{minArgs:1,maxArgs:2},sendMessage:{minArgs:2,maxArgs:3},setZoom:{minArgs:1,maxArgs:2},setZoomSettings:{minArgs:1,maxArgs:2},update:{minArgs:1,maxArgs:2}},topSites:{get:{minArgs:0,maxArgs:0}},webNavigation:{getAllFrames:{minArgs:1,maxArgs:1},getFrame:{minArgs:1,maxArgs:1}},webRequest:{handlerBehaviorChanged:{minArgs:0,maxArgs:0}},windows:{create:{minArgs:0,maxArgs:1},get:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:1},getCurrent:{minArgs:0,maxArgs:1},getLastFocused:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}}};if(0===Object.keys(n).length)throw new Error("api-metadata.json has not been included in browser-polyfill");class r extends WeakMap{constructor(e,t=void 0){super(t),this.createItem=e}get(e){return this.has(e)||this.set(e,this.createItem(e)),super.get(e)}}const o=(t,n)=>(...r)=>{e.runtime.lastError?t.reject(new Error(e.runtime.lastError.message)):n.singleCallbackArg||r.length<=1&&!1!==n.singleCallbackArg?t.resolve(r[0]):t.resolve(r)},i=e=>1==e?"argument":"arguments",s=(e,t,n)=>new Proxy(t,{apply:(t,r,o)=>n.call(r,e,...o)});let a=Function.call.bind(Object.prototype.hasOwnProperty);const l=(e,t={},n={})=>{let r=Object.create(null),c={has:(t,n)=>n in e||n in r,get(c,g,u){if(g in r)return r[g];if(!(g in e))return;let d=e[g];if("function"==typeof d)if("function"==typeof t[g])d=s(e,e[g],t[g]);else if(a(n,g)){let t=((e,t)=>function(n,...r){if(r.length<t.minArgs)throw new Error(`Expected at least ${t.minArgs} ${i(t.minArgs)} for ${e}(), got ${r.length}`);if(r.length>t.maxArgs)throw new Error(`Expected at most ${t.maxArgs} ${i(t.maxArgs)} for ${e}(), got ${r.length}`);return new Promise(((i,s)=>{if(t.fallbackToNoCallback)try{n[e](...r,o({resolve:i,reject:s},t))}catch(o){console.warn(`${e} API method doesn't seem to support the callback parameter, falling back to call it without a callback: `,o),n[e](...r),t.fallbackToNoCallback=!1,t.noCallback=!0,i()}else t.noCallback?(n[e](...r),i()):n[e](...r,o({resolve:i,reject:s},t))}))})(g,n[g]);d=s(e,e[g],t)}else d=d.bind(e);else if("object"==typeof d&&null!==d&&(a(t,g)||a(n,g)))d=l(d,t[g],n[g]);else{if(!a(n,"*"))return Object.defineProperty(r,g,{configurable:!0,enumerable:!0,get:()=>e[g],set(t){e[g]=t}}),d;d=l(d,t[g],n["*"])}return r[g]=d,d},set:(t,n,o,i)=>(n in r?r[n]=o:e[n]=o,!0),defineProperty:(e,t,n)=>Reflect.defineProperty(r,t,n),deleteProperty:(e,t)=>Reflect.deleteProperty(r,t)},g=Object.create(e);return new Proxy(g,c)},c=e=>({addListener(t,n,...r){t.addListener(e.get(n),...r)},hasListener:(t,n)=>t.hasListener(e.get(n)),removeListener(t,n){t.removeListener(e.get(n))}}),g=new r((e=>"function"!=typeof e?e:function(t){const n=l(t,{},{getContent:{minArgs:0,maxArgs:0}});e(n)})),u=new r((e=>"function"!=typeof e?e:function(t,n,r){let o,i,s=!1,a=new Promise((e=>{o=function(t){s=!0,e(t)}}));try{i=e(t,n,o)}catch(e){i=Promise.reject(e)}const l=!0!==i&&((c=i)&&"object"==typeof c&&"function"==typeof c.then);var c;if(!0!==i&&!l&&!s)return!1;return(l?i:a).then((e=>{r(e)}),(e=>{let t;t=e&&(e instanceof Error||"string"==typeof e.message)?e.message:"An unexpected error occurred",r({__mozWebExtensionPolyfillReject__:!0,message:t})})).catch((e=>{console.error("Failed to send onMessage rejected reply",e)})),!0})),d=({reject:n,resolve:r},o)=>{e.runtime.lastError?e.runtime.lastError.message===t?r():n(new Error(e.runtime.lastError.message)):o&&o.__mozWebExtensionPolyfillReject__?n(new Error(o.message)):r(o)},p=(e,t,n,...r)=>{if(r.length<t.minArgs)throw new Error(`Expected at least ${t.minArgs} ${i(t.minArgs)} for ${e}(), got ${r.length}`);if(r.length>t.maxArgs)throw new Error(`Expected at most ${t.maxArgs} ${i(t.maxArgs)} for ${e}(), got ${r.length}`);return new Promise(((e,t)=>{const o=d.bind(null,{resolve:e,reject:t});r.push(o),n.sendMessage(...r)}))},h={devtools:{network:{onRequestFinished:c(g)}},runtime:{onMessage:c(u),onMessageExternal:c(u),sendMessage:p.bind(null,"sendMessage",{minArgs:1,maxArgs:3})},tabs:{sendMessage:p.bind(null,"sendMessage",{minArgs:2,maxArgs:3})}},m={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return n.privacy={network:{"*":m},services:{"*":m},websites:{"*":m}},l(e,h,n)};e.exports=n(chrome)}}(Be);var je=He(Be.exports);const Ke="GIVE_FREELY_",We={async get(e){const t=`${Ke}${e}`;return(await je.storage.local.get(t))[t]||null},async set(e,t){const n=`${Ke}${e}`;await je.storage.local.set({[n]:t})},async remove(e){const t=Array.isArray(e)?e.map((e=>`${Ke}${e}`)):`${Ke}${e}`;await je.storage.local.remove(t)}},Ve="version",ze=()=>String("1.6.3"),Ye="https://cdn.givefreely.com/adunit/behavioral/";class qe{constructor(e){this.partnerApiKey=e,this.partnerConfig=null,this.globalConfig=null,this.lastConfigRefresh=0,this.CONFIG_REFRESH_INTERVAL=300,this.PARTNER_CONFIG_STORAGE_KEY="gf_partner_config",this.GLOBAL_CONFIG_STORAGE_KEY="gf_global_config"}getRetryOptions(){return{delayFn:e=>1e3*e,maxAttempts:3}}async fetchAndUpdatePartnerConfig(){const e=await Q((async()=>{const e=await fetch(`${Ye}${this.partnerApiKey}.json`,{cache:"no-store"});if(!e.ok)throw new Error(`Failed to fetch partner config: ${e.statusText}`);return e.json()}),this.getRetryOptions()),t={config:e,lastRefresh:Date.now()};return await We.set(this.PARTNER_CONFIG_STORAGE_KEY,t),e}async fetchAndUpdateGlobalConfig(){const e=await Q((async()=>{const e=await fetch(`${Ye}global.json`,{cache:"no-store"});if(!e.ok)throw new Error(`Failed to fetch global config: ${e.statusText}`);return e.json()}),this.getRetryOptions()),t={config:e,lastRefresh:Date.now()};return await We.set(this.GLOBAL_CONFIG_STORAGE_KEY,t),e}async getConfig(e=!1){const t=Date.now(),n=await We.get(this.PARTNER_CONFIG_STORAGE_KEY),r=await We.get(this.GLOBAL_CONFIG_STORAGE_KEY);this.partnerConfig=n?.config||null,this.globalConfig=r?.config||null,this.lastConfigRefresh=Math.max(n?.lastRefresh||0,r?.lastRefresh||0);let o=!1;e&&(o=await(async(e=!0)=>{const t=await We.get(Ve),n=await ze(),r=t!==n;var o;return e&&r&&await(o=n,We.set(Ve,o)),r})());const i=this.partnerConfig?.configRefreshInterval||this.globalConfig?.configRefreshInterval||this.CONFIG_REFRESH_INTERVAL;if(o||!this.partnerConfig||!this.globalConfig||t-this.lastConfigRefresh>1e3*i)try{const[e,n]=await Promise.all([this.fetchAndUpdatePartnerConfig(),this.fetchAndUpdateGlobalConfig()]);this.partnerConfig=e,this.globalConfig=n,this.lastConfigRefresh=t}catch(e){if(!this.partnerConfig||!this.globalConfig)throw e}const s=this.mergeConfigs(JSON.parse(JSON.stringify(this.globalConfig)),JSON.parse(JSON.stringify(this.partnerConfig)));return s&&((e,t,n)=>{const r=[...t.merchantExclusions??[],...n.merchantExclusions??[]];e.merchantExclusions=r})(s,this.globalConfig,this.partnerConfig),s}async clearCache(){await Promise.all([We.remove(this.PARTNER_CONFIG_STORAGE_KEY),We.remove(this.GLOBAL_CONFIG_STORAGE_KEY)]),this.partnerConfig=null,this.globalConfig=null,this.lastConfigRefresh=0}mergeConfigs(e,t){if(!t)return e;if(!e)return t;const n={...e};return Object.keys(t).forEach((r=>{if(!Object.prototype.hasOwnProperty.call(t,r))return;const o=e[r],i=t[r];void 0!==i&&(Array.isArray(i)?n[r]=[...i]:n[r]=null===i||"object"!=typeof i||null===o||"object"!=typeof o?i:this.mergeConfigs(o,i))})),n}getStoredState(e){return e?{config:e.config,lastRefresh:e.lastRefresh}:{config:null,lastRefresh:0}}}const Je="TRACK_EVENT",Xe="GF_HIDE_POPUP",Ze="GF_GET_POPUP_CONFIG",Qe="GF_IS_ACTIVE_DOMAIN",et="GF_SHOULD_STAND_DOWN",tt="GF_ACTIVATE_OFFER",nt="GF_STORE_SHOPIFY_SHOP_ID",rt="GF_GET_DOMAIN_BY_SHOP_ID",ot="GF_GET_LANGUAGE_CONTENT",it={ein:"0",tpi:"0"};class st{constructor(e,t,n=60){this._config=null,this.track=async(e,t,n,r=!1)=>{null===this._config&&(this._config=await new qe(this._partnerApiKey).getConfig());const o={partner:`adUnit_${this._partnerApiKey}`,eventType:e,eventData:{userId:r?void 0:this._userService?.user?.id,libVersion:ze(),wfDeviceId:t,...n}};try{const e=JSON.stringify(o);return await this.shouldBroadcastEvent(e)?(await fetch(this._config.eventsUrl,{headers:{"Content-Type":"application/json"},method:"POST",body:e,cache:"no-store"}),await this.pushEventToHistory(e),!0):(this._logger.info("This event has already been broadcasted during the past hour",o),!1)}catch(e){return this._logger.info("Something unexpected happened when dispatching a gf event",{error:e,event:o}),!1}},this.getEventsHistory=async()=>{const{GF_AD_EVENT_HISTORY:e}=await ee.storage.local.get({GF_AD_EVENT_HISTORY:""}),t=(e=>{const t=new Date;return t.setTime(t.getTime()+60*e*1e3),t.getTime()})(-this._debounceWindowInMinutes),n=(e||[]).filter((e=>e.createdAt>t));return await ee.storage.local.set({GF_AD_EVENT_HISTORY:n}),n},this.shouldBroadcastEvent=async e=>!(await this.getEventsHistory()).some((t=>t.payload===e)),this.pushEventToHistory=async e=>{const t=await this.getEventsHistory();t.push({createdAt:Date.now(),payload:e}),await ee.storage.local.set({GF_AD_EVENT_HISTORY:t})},this._partnerApiKey=e,this._userService=t,this._debounceWindowInMinutes=n,this._logger=J.getInstance({title:"Analytics"})}}function at(e,t,n){return e?{...t,...n}:t}st.trackEvent=async(e,t,n=!1)=>{await te({type:Je,payload:{eventType:e,eventData:t,anonymous:n}})};var lt=F("<a href=#!>"),ct=F("<button class=give-freely-close-button aria-label=Close>×"),gt=F('<div><div><div></div></div><hr><div></div><div><div><div><br></div><button aria-label="Don\'t show again"></button></div></div><div><p></p><a class=give-freely-footer-link target=_blank rel="noopener noreferrer">'),ut=F("<div><div><img><span></span></div><button>"),dt=F("<div>");function pt(e){const[t,n]=u(!1),[r,o]=u(null),i=Le(),s=(()=>{const e=A(Ne)();if(!e)throw new Error("Content provider context is undefined");return()=>e.getAllCharities()})();p((()=>{t()&&e.mainContainerRef&&e.mainContainerRef.scroll({top:e.mainContainerRef.scrollHeight,behavior:"smooth"})})),p((()=>{const t=r();t&&e.onCharitySelect(t.charity,t.closeOnDonation?e.checkoutPopupConf.checkoutPopupActivateAndCloseSkipSuccess:void 0)}));const a=(e,t)=>o({charity:e,closeOnDonation:t}),l=()=>!!r()?.charity;return[(g=gt(),m=g.firstChild,f=m.firstChild,x=m.nextSibling.nextSibling,v=x.nextSibling,b=v.firstChild,y=b.firstChild,w=y.nextSibling,C=v.nextSibling,k=C.firstChild,P=k.nextSibling,U(m,N(_,{get when(){return e.checkoutPopupConf.checkoutPopupActivateAndClose},get children(){var e=lt();return e.$$click=()=>a(it,!0),d((t=>{var n=at(l(),ce,ge),r=i("main.activateAndClose");return t.e=G(e,n,t.e),r!==t.t&&(e.innerHTML=t.t=r),t}),{e:void 0,t:void 0}),e}}),null),U(m,N(_,{get when(){return e.checkoutPopupConf.checkoutPopupMainCloseButtonVisible&&!e.checkoutPopupConf.checkoutPopupActivateAndClose},get children(){var t=ct();return t.$$click=()=>e.onClose(),d((e=>G(t,le,e))),t}}),null),U(x,N(Ie,{get title(){return i("main.subTitle")},get activeDomain(){return e.activeDomain}})),U(v,(()=>s().map((t=>{return o=(r=ut()).firstChild,c=(s=o.firstChild).nextSibling,g=o.nextSibling,r.$$click=()=>!l()&&a(t),U(r,(n=h((()=>!!(t.decorator&&t.decoratorLeftStyle&&t.decoratorRightStyle))),()=>{return n()&&[(r=dt(),d((e=>{var n=t.decoratorLeftStyle,o=t.decorator;return e.e=G(r,n,e.e),o!==e.t&&(r.innerHTML=e.t=o),e}),{e:void 0,t:void 0}),r),(e=dt(),d((n=>{var r=t.decoratorRightStyle,o=t.decorator;return n.e=G(e,r,n.e),o!==n.t&&(e.innerHTML=n.t=o),n}),{e:void 0,t:void 0}),e)];var e,r}),o),o.style.setProperty("height","100px"),o.style.setProperty("text-align","center"),U(c,(()=>t.title)),U(g,(()=>i("main.charitySelect"))),d((n=>{var o=at(l(),pe,{cursor:"default"}),i=t.logo,a=me,c=t.title,u=at(l(),{...fe,"background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812"},he),d=l(),p=`Select charity: ${t.title}`;return n.e=G(r,o,n.e),i!==n.t&&$(s,"src",n.t=i),n.a=G(s,a,n.a),c!==n.o&&$(s,"alt",n.o=c),n.i=G(g,u,n.i),d!==n.n&&(g.disabled=n.n=d),p!==n.s&&$(g,"aria-label",n.s=p),n}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),r;var n,r,o,s,c,g}))),b),b.$$click=()=>!l()&&e.onSuppress(),y.style.setProperty("height","100px"),y.style.setProperty("text-align","center"),U(y,(()=>i("main.sixthBox")),null),U(w,(()=>i("main.settings"))),k.$$click=()=>{e.onOfferDetailsClick(!t()),n(!t())},U(k,(()=>i("main.offerDetails"))),P.$$click=()=>{st.trackEvent(z.checkoutPopupWhyAmISeeingThisClicked,{domain:globalThis.window.location.hostname})},U(P,(()=>i("main.whyAmISeeingThis"))),U(g,(c=h((()=>!!e.checkoutPopupConf.checkoutPopupDisplayNameInFooter)),()=>{return c()&&(U(e=dt(),(()=>i("main.footer"))),d((t=>G(e,we,t))),e);var e}),null),d((t=>{var n=ie,r=se,o=ae,s=i("main.title"),a=ue,c=de,u=at(l(),pe,{cursor:"default"}),d=at(l(),{...fe,"background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812"},he),p=l(),h=ye,A=ke,y=Ce,E=e.checkoutPopupConf.externalUrls.giveFreelyWhyAmISeeingThis;return t.e=G(g,n,t.e),t.t=G(m,r,t.t),t.a=G(f,o,t.a),s!==t.o&&(f.innerHTML=t.o=s),t.i=G(x,a,t.i),t.n=G(v,c,t.n),t.s=G(b,u,t.s),t.h=G(w,d,t.h),p!==t.r&&(w.disabled=t.r=p),t.d=G(C,h,t.d),t.l=G(k,A,t.l),t.u=G(P,y,t.u),E!==t.c&&$(P,"href",t.c=E),t}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0}),g),N(_,{get when(){return t()},get children(){return N(Ue,{get merchantName(){return e.activeDomain.Merchant.Name},get extensionName(){return e.checkoutPopupConf.displayName},get termsUrl(){return e.checkoutPopupConf.externalUrls.giveFreelyTermsAndConditions},get parsedMaxRate(){return h((()=>!!e.activeDomain.Merchant.MaxRate))()?Re(e.activeDomain.Merchant.MaxRate.Kind,e.activeDomain.Merchant.MaxRate?.Amount):null},get merchantRateDetail(){return e.merchantRates},onClose:()=>n(!1)})}})];var c,g,m,f,x,v,b,y,w,C,k,P}M(["click"]);var ht=F("<button class=give-freely-close-button aria-label=Close>×"),mt=F("<label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=18250><span>"),ft=F('<div><div><div></div></div><button class=give-freely-back-button aria-label="Back to charity selection"></button><hr><div id=give-freely-goodbye-screen-options><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=1></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=7></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=30></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=90><span></span></label></div><button class=give-freely-submit-button>');function At(e){const[t,n]=u(0),r=Le();return o=ft(),i=o.firstChild,s=i.firstChild,a=i.nextSibling,l=a.nextSibling.nextSibling,g=(c=l.firstChild).firstChild,h=(p=c.nextSibling).firstChild,f=(m=p.nextSibling).firstChild,v=(x=(A=m.nextSibling).firstChild).nextSibling,b=l.nextSibling,o.style.setProperty("font-size","14px"),U(s,(()=>r("suppress.title"))),U(i,N(_,{get when(){return e.checkoutPopupConf.checkoutPopupSupressCloseButtonVisible},get children(){var t=ht();return t.$$click=()=>e.onGoodbye(0),d((e=>G(t,le,e))),t}}),null),a.$$click=()=>e.onBack(),U(a,(()=>r("suppress.backButton"))),g.addEventListener("change",(()=>n(1))),U(c,(()=>r("suppress.suppressionPeriod").replace("{0}","1")),null),h.addEventListener("change",(()=>n(7))),U(p,(()=>r("suppress.suppressionPeriodPlural").replace("{0}","7")),null),f.addEventListener("change",(()=>n(30))),U(m,(()=>r("suppress.suppressionPeriodPlural").replace("{0}","30")),null),x.addEventListener("change",(()=>n(90))),U(v,(()=>r("suppress.suppressionPeriodPlural").replace("{0}","90"))),U(l,N(_,{get when(){return e.checkoutPopupConf.checkoutPopupNeverSuppressionAllowed},get children(){var e=mt(),t=e.firstChild,o=t.nextSibling;return t.addEventListener("change",(()=>n(18250))),U(o,(()=>r("suppress.suppressionPeriodNever"))),d((t=>G(e,xe,t))),e}}),null),b.$$click=()=>{const n=t();n&&(e.onGoodbye(n),e.setScreen("main"))},U(b,(()=>r("suppress.submitButton"))),d((t=>{var n=se,r=ae,o=be,g=Ae,u=xe,d=xe,h=xe,f=xe,x={...fe,"font-weight":"700","margin-top":"10px","margin-bottom":"0px","background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812",width:"100px"};return t.e=G(i,n,t.e),t.t=G(s,r,t.t),t.a=G(a,o,t.a),t.o=G(l,g,t.o),t.i=G(c,u,t.i),t.n=G(p,d,t.n),t.s=G(m,h,t.s),t.h=G(A,f,t.h),t.r=G(b,x,t.r),t}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),o;var o,i,s,a,l,c,g,p,h,m,f,A,x,v,b}M(["click"]);var xt=F("<div><p>"),vt=F("<div><div><div></div><button class=give-freely-close-button aria-label=Close>×</button></div><hr><div><span>");function bt(e){const[t,n]=u(null),r=Le();let o;var s,a,l,c,g,p,m,A;return s=()=>clearInterval(o),null===i||(null===i.cleanups?i.cleanups=[s]:i.cleanups.push(s)),f((()=>{e.failedDonation||(()=>{const t=e.checkoutPopupConf.checkoutPopupDonationSuccessAutoCloseInSeconds??3;n(t),o=setInterval((()=>{n((t=>null===t||t<=1?(clearInterval(o),e.onClose(),0):t-1))}),1e3)})()})),l=vt(),c=l.firstChild,g=c.firstChild,p=g.nextSibling,m=c.nextSibling.nextSibling,A=m.firstChild,l.style.setProperty("font-size","14px"),U(g,(a=h((()=>!!e.failedDonation)),()=>a()?r("donate.failTitle"):r("donate.title"))),p.$$click=()=>e.onClose(),m.style.setProperty("padding","30px"),m.style.setProperty("height","150px"),m.style.setProperty("font-size","14px"),U(l,N(_,{get when(){return!e.failedDonation},get children(){var e=xt(),n=e.firstChild;return U(n,(()=>Fe.formatMessage(r("donate.autoClosing"),t()??0))),d((e=>G(n,ve,e))),e}}),null),d((t=>{var n=se,o=ae,i=le,s=e.failedDonation?r("donate.failContent"):r("donate.content");return t.e=G(c,n,t.e),t.t=G(g,o,t.t),t.a=G(p,i,t.a),s!==t.o&&(A.innerHTML=t.o=s),t}),{e:void 0,t:void 0,a:void 0,o:void 0}),l}M(["click"]);var yt=F("<div><div>");const wt=(e,t,n)=>"donate"===e?"340px":t.checkoutPopupDisplayNameInFooter?"520px":n;function Ct(e){const[t,n]=u("main"),[r,o]=u(),[i,s]=u(!1),a=()=>{e.logger.debug("Close button clicked"),e.onClose()},l=async(t,r=!1)=>{r&&e.onClose(),e.logger.info("Charity selected",{charity:t,domain:e.activeDomain.Domain}),o(t);const i=await e.onDonate(t,e.activeDomain);r?e.onClose():(s(!i),n("donate"))},c=()=>{e.logger.debug("Suppress button clicked"),n("goodbye")},g=()=>{e.logger.debug("Navigating back to main screen"),n("main")},p=t=>{e.logger.info("User chose to hide popup",{days:t}),e.onClose(t)};let h;return x=yt(),v=x.firstChild,"function"==typeof h?(f=h,A=v,m((()=>f(A,undefined)))):h=v,U(v,N(_,{get when(){return"main"===t()},get children(){return N(pt,{mainContainerRef:h,get checkoutPopupConf(){return e.checkoutPopupConf},get activeDomain(){return e.activeDomain},get merchantRates(){return e.merchantRates},onClose:a,onCharitySelect:l,onSuppress:c,get onOfferDetailsClick(){return e.onOfferDetailsClick}})}}),null),U(v,N(_,{get when(){return"goodbye"===t()},get children(){return N(At,{get checkoutPopupConf(){return e.checkoutPopupConf},onClose:()=>e.onClose(),onBack:g,onGoodbye:p,setScreen:n})}}),null),U(v,N(_,{get when(){return"donate"===t()},get children(){return N(bt,{get checkoutPopupConf(){return e.checkoutPopupConf},get selectedCharity(){return r()},onClose:()=>e.onClose(),get failedDonation(){return i()},setScreen:n})}}),null),d((n=>{var r={...re,height:wt(t(),e.checkoutPopupConf,re.height)},o=e.elementId,i=oe;return n.e=G(x,r,n.e),o!==n.t&&$(x,"id",n.t=o),n.a=G(v,i,n.a),n}),{e:void 0,t:void 0,a:void 0}),x;var f,A,x,v}function kt(e){const t=["",".asp",".aspx",".php",".js",".htm",".html"],n=["cart","checkout","shopping-bag","shopping-basket","shopping-cart","basket"].flatMap((e=>t.map((t=>e+t)))).filter((e=>"basket"!==e)),r=["tote-cart","tote.cart"],o=e,i=n.filter((e=>o.includes(e))),s=o.split("/");return!s.some((e=>r.some((t=>e.includes(t)))))&&(s.some((e=>n.some((t=>e.startsWith(t)||e.endsWith(t)))))||"basket"===s[s.length-1].toLowerCase()||i.length>1||1===i.length&&o.includes("shopping"))}function Pt(e,t){const n=["book"];return e.split("/").some((e=>n.some((t=>e.startsWith(t)||e.endsWith(t)))))&&null!=t.evaluate("//*[self::h1 or self::h2 or self::h3 or self::h4 or self::h5 or self::h6][contains(., 'Your Reservation') or contains(., 'Your reservation')]",t,null,XPathResult.ANY_TYPE,null)?.iterateNext()}async function Et(e){try{const t=await te({type:rt,payload:{shopId:e}});return t.payload.found&&t.payload.domain?t.payload.domain:null}catch{return null}}function St(e){try{const e=Array.from(document.querySelectorAll("script"));for(const t of e){if(t.dataset?.shopId&&(t.dataset?.shopId?.startsWith("gid")||t.src.includes("shopify"))){const e=parseInt(t.dataset.shopId.replace("gid://shopify/Shop/",""));if(!Number.isNaN(e)&&e>0)return e}const e=t.textContent||"";if(e.includes("ShopifyAnalytics")&&e.includes("shopId")){const t=e.match(/shopId['"]*:\s*['"]*(\d+)['"]*[,}]/);if(t&&t[1]){const e=parseInt(t[1]);if(!Number.isNaN(e)&&e>0)return e}}}const t=document.querySelector("[data-shop-id]");if(t instanceof HTMLElement){const{shopId:e}=t.dataset;if(e){const t=parseInt(e);if(!Number.isNaN(t)&&t>0)return t}}const n=window?.ShopifyAnalytics?.lib?.trekkie?.defaultAttributes?.shopId;return n&&parseInt(n)||0}catch(t){return e.error("Error accessing ShopifyAnalytics:",t),0}}function Tt(){try{if(!window.location.href.startsWith("https://shop.app"))return 0;const e=document?.head?.querySelector('meta[name="store"][content]');if(!e)return 0;try{const t=JSON.parse(e.content);return t?.id||0}catch{return 0}}catch{return 0}}const Ot=J.getInstance();function Rt(e,t,n){try{const r=function(e){try{const t=e.split(".");return t.length>=2?t.slice(-2).join("."):e}catch(e){return Ot.error("Error extracting domain",e),""}}(n);Ot.debug("Checking merchant regex rules",{currentDomain:r,currentUrl:t});const o=e.merchantPopupRules.filter((e=>r.includes(e.domain)));if(0===o.length)return Ot.debug("No matching merchant rules found for domain",{currentDomain:r}),!1;for(const e of o)for(const n of e.rules)try{if(new RegExp(n.rule).test(t))return Ot.debug("Merchant regex rule matched",{merchant:e.name,rule:n.rule,currentUrl:t}),!0}catch(t){Ot.error("Invalid regex in merchant rule",{merchant:e.name,rule:n.rule,error:t})}return Ot.debug("No matching regex rules found",{currentUrl:t}),!1}catch(e){return Ot.error("Error in merchantRegexRule",e),!1}}function Dt(){const e=document.documentElement.lang,t=document.querySelector('meta[http-equiv="Content-Language"]')?.content,n=document.querySelector('link[rel="alternate"][hreflang]')?.getAttribute("hreflang"),r=navigator.language,o=e||t||n||r||"en";return"string"==typeof o?o.split("-")[0]:"en"}function It(e){return!0!==e.checkoutPopupOnlyShowLanguageMatch||"en"===Dt()}const Nt=(e,t=!1)=>e.length<2&&t?null:Array.from(e).filter((e=>!t||e.dataset.extensionId!==ee.runtime.id)).map((e=>e.dataset.extensionName)).join(",");const _t=e=>{const t=h((()=>({translate:e.translate()||(e=>""),getAllCharities:e.charities()||(()=>[])})));return N(Ne.Provider,{value:t,get children(){return e.children}})},Lt=J.getInstance(),Ft="countryCode",Mt=async()=>await We.get(Ft)||(async()=>{Lt.debug("detecting country");const e={method:"GET",headers:{"Content-Type":"application/json",Authorization:"Basic OTEzOTkxOnFlYmpaWF9DOGNRY0lxSHA4WTVjNGxzU1pRSlM2VW9MMExzTF9tbWs="}};try{const t=await fetch("https://geoip.maxmind.com/geoip/v2.1/country/me",e);if(Lt.debug("Received geolocation response",{status:t.status}),!t.ok)return void Lt.warn("Failed to get geolocation data",{status:t.status});const n=await t.json();if(!n)throw new Error("There was an error fetching geoip look up");return await We.set(Ft,n.country.iso_code),n.country.iso_code}catch(e){return void Lt.error("Failed to get geolocation data",{error:e})}})();var $t=F("<div class=gf-app>");function Gt(){const e=J.getInstance(),[t,n]=u(null),[r,o]=u(void 0),[i,s]=u(!1),[a,l]=u([]),[c,g]=u(),[d,p]=u({});f((async()=>{e.info("Mounting GfApp component");try{const i=await(async()=>{const e=await te({type:Ze,payload:{}});if(!e.payload.config)throw new Error("No checkout popup config found");return e.payload.config})();if(!i)return void e.error("No checkout popup config found");n(i),e.configure({enabled:!0,title:"Content - GfAdUnit",minLevel:i.checkoutPopupMinLogLevel??"error"}),function(e){if(!e?.shouldCheckSiteMatches)return;let t;(e?.siteMatchesRegex??[]).some((e=>{var n;return n=window.location.href,!(!new RegExp(e).test(n)||(t=e,0))}))&&t&&st.trackEvent(z.checkoutPopupSiteMatches,{url:window.location.href,matchedRule:t,uts:Date.now()},!0)}(i);const a=Dt();v(a);const c=ze();if(i.minVersion&&((e,t)=>{if(e===t)return!1;const n=e.split(".").map((e=>parseInt(e,10))),r=t.split(".").map((e=>parseInt(e,10)));for(let e=0;e<n.length;e++){if(n[e]<r[e])return!0;if(n[e]>r[e])return!1}return!1})(c,i.minVersion))return void e.debug(`Current version: ${c}. Minimum version ${i.minVersion} not met`);const g=await Mt()??"us",u=i.charities[g.toLowerCase()]??i.charities.us;if(p(u||{}),e.debug("Charities for current country",{currentCountry:g,charities:u}),!1===i.checkoutPopupMasterSwitch)return void e.debug("Checkout popup master switch is disabled");const d=document.getElementsByClassName("give-freely-root");let h=!1;d.length>1&&(e.debug("There is more than one gf extension installed"),d.item(0).dataset.extensionId!==ee.runtime.id&&(e.debug("Giving preference to the first gf extension injected in the DOM"),h=!0),e.debug("Providing this extension preference over the other installed extensions"));const{domain:m,rates:f}=await(async e=>{const{hostname:t}=window.location;e.debug("Checking if domain is active",{hostname:t});const n=await te({type:Qe,payload:{hostname:t}});return n.payload.isActive?(e.debug("Active domain",{domain:n.payload.domain}),e.debug("Merchant rates",{rates:n.payload.rates}),e.info("Domain and rates ({})ed successfully."),{isActive:!0,domain:n.payload.domain,rates:n.payload.rates}):{isActive:!1,domain:void 0,rates:[]}})(e);if(l(f),o(m),m)await function(e,t){const n=St(t)||Tt();return n>0&&function(e,t,n){if(e&&!(e<=0))try{te({type:nt,payload:{shopId:e,domain:t}}).catch((e=>{n.error("Error sending shop ID to background:",e)}))}catch(e){n.error("Error sending Shopify shop ID:",e)}}(n,e,t),n}(m,e);else{if("shop.app"!==window.location.hostname&&!window.location.hostname.endsWith(".shop.app"))return void s(!1);const t=window.location.pathname.split("/")[2];if(!t)return e.error("Shop ID not found"),void s(!1);const n=await Et(parseInt(t));if(!n)return e.error("Shop domain not found"),void s(!1);e.debug("Shop domain found",{shopDomain:n}),o(n)}const A=await(async e=>{const t=await We.get("popup_hide");if(!t)return e.debug("No expiry found in storage"),!1;const{popupHide:n}=t,r=!!n&&Date.now()<n;return e.debug("Is AdUnit Muted?",{isMuted:r,expiry:n}),r})(e);if(A)return;if(!r())return void s(!1);const x=await(async(e,t)=>{const{Domain:n}=t,r=window.location.href,{payload:o}=await te({type:et,payload:{activeDomain:n,url:r}});return!!o.result&&(e.info("Stand Down detected"),!0)})(e,r());if(x)return void s(!1);const b=t()?.anonymousActiveDomainLogging??!1,y=r()??void 0;y&&b&&!function(e){const t=`gfhv-${e}`;return!!sessionStorage.getItem(t)||(sessionStorage.setItem(t,"true"),!1)}(y.Domain)&&st.trackEvent(z.checkoutPopupActiveDomain,{url:y.Domain});const w=setInterval((async()=>{e.debug("Checking checkout rules");const t=await(async e=>{const t=J.getInstance();t.configure({enabled:!0,title:"Content - checkoutRulesTest"});const n=new URL(globalThis.location.href),r=n.href,{hostname:o}=n;t.debug("Checking if popup should be shown",{currentUrl:r});const i=await async function(e){const t=St(e)||Tt();return!("shop.app"!==window.location.hostname&&!window.location.hostname.endsWith(".shop.app")||!(t>0)||!await Et(t))}(t),s=It(e)&&(kt(n.pathname.toLowerCase())||Pt(r,document)||Rt(e,r,o)||i);return t.debug("Popup show decision based on rules",{shouldShow:s,matchesCartRule:kt(n.pathname.toLowerCase()),matchesBookingRule:Pt(r,document),matchesShopPayRule:i,matchesMerchantRegexRule:Rt(e,r,o),matchesLanguageRule:It(e)}),s})(i);if(t&&h)return st.trackEvent(z.checkoutPopupLooserExtension,{url:globalThis.window.location.href,winner:d.item(0).dataset.extensionName}),e.debug("Standing down because, another ad-unit extension will pop"),void clearInterval(w);s(t),t&&(e.debug("Should show popup based on checkout rules",{shouldShowResult:t}),st.trackEvent(z.checkoutPopupShown,{url:globalThis.window.location.href,pageLanguage:a,looserCompetingExtensions:Nt(d,!0)}),clearInterval(w))}),2e3)}catch(t){s(!1),e.error("An error occurred in GfApp",{error:t})}}));const m=async(t,n)=>{e.info("Processing donation",{charity:t,domain:n.Domain});const r=await(async(e,t,n,r)=>{e.debug("Activating offer",{activeDomain:t,selectedCharity:r});const o=await ne({type:tt,payload:{activeDomain:t,originalUrl:n,selectedCharity:r}});return e.debug("Activate offer response",{response:o}),o})(e,n,window.location.href,{ein:t.ein,thirdPartyId:t.tpi});return e.debug("Activate offer response",{activationResponse:r}),st.trackEvent(r.payload.response?z.checkoutPopupDonation:z.checkoutPopupFailedActivation,{activeDomain:n.Domain,url:globalThis.window.location.href,charity:{ein:t.ein,tpi:t.tpi},rate:n.Merchant.MaxRate}),r.payload.response},A=async t=>{s(await(async(e,t)=>{try{e.info("Hiding ad",{days:t});const n=await ne({type:Xe,payload:{days:t??0}});return void 0!==t&&st.trackEvent(z.checkoutPopupSupressed,{url:globalThis.window.location.href,days:t}),e.info("Hiding ad response",{hideResponse:n}),n.payload.ack?(e.debug("Ad hidden successfully"),!1):(e.warn("Failed to hide ad"),!0)}catch{return!1}})(e,t))},x=async e=>{st.trackEvent(z.checkoutPopupOfferDetailsClicked,{action:e?"opened":"closed"})},v=async t=>{e.debug("Getting translation provider",{currentLanguage:t});const{translations:n,charities:r}=await async function(e,t){try{t&&t.debug("Getting language content",{languageCode:e});const n=await te({type:ot,payload:{lang:e}});return{translations:n.payload.translations,charities:n.payload.charities}}catch(n){return t&&t.error("Error getting language content",{error:n,languageCode:e}),{translations:null,charities:null}}}(t,e),o={translate:e=>n&&n[e]?n[e]:"",getAllCharities:()=>{const e=d();return Object.entries(e).map((([e,t])=>{const{ein:n}=t,o=r?.[n];if(!o)throw new Error(`Failed to find charity metadata for ein ${n}`);return{ein:n,tpi:o.tpi,title:o.title,order:parseInt(e,10),logo:o.logo,decorator:t.decorator,decoratorLeftStyle:t.decoratorLeftStyle,decoratorRightStyle:t.decoratorRightStyle}}))}};e.debug("Setting content provider with translations and charity functions"),g((()=>o))};return N(_t,{translate:()=>c()?.translate,charities:()=>c()?.getAllCharities,get children(){var n,o=$t();return U(o,(n=h((()=>!(!r()||!i()))),()=>n()&&N(Ct,{get checkoutPopupConf(){return t()},elementId:"give-freely-checkout-popup",get activeDomain(){return r()},get merchantRates(){return a()},onClose:A,onDonate:m,onOfferDetailsClick:x,logger:e}))),o}})}exports.browser=ee,exports.initializeAdUnit=async function(){const e=`give-freely-root-${ee.runtime.id}`;if(document.getElementById(e))return;const t=document.createElement("div");t.id=e,t.className="give-freely-root",t.style.display="block",t.dataset.extensionId=ee.runtime.id,t.dataset.extensionName=ee.runtime.getManifest().name||ee.runtime.id,document.body.appendChild(t);const n=t.attachShadow({mode:"open"}),r=document.createElement("div"),s=document.createElement("style");s.textContent='\n :host {\n all: initial;\n }\n\n .gf-scroll-remove::-webkit-scrollbar {\n border-radius-bottom-right: 15px;\n }\n\n button {\n cursor: pointer;\n transition: transform 0.1s ease;\n }\n\n button:active {\n transform: scale(0.98);\n }\n\n .give-freely-close-button:hover {\n opacity: 0.7;\n }\n\n input[type="radio"] {\n margin-right: 8px;\n }\n\n hr {\n border: none;\n border-top: 1px solid #e5e5e5;\n margin: 1em 0;\n }\n\n @media (max-width: 600px), (max-height: 480px) {\n #give-freely-checkout-popup {\n display: none !important;\n }\n }\n',n.appendChild(s),n.appendChild(r),function(e,t,n,r={}){let s;(function(e,t){const n=a,r=i,s=0===e.length,l=void 0===t?r:t,c=s?o:{owned:null,cleanups:null,context:l?l.context:null,owner:l},g=s?e:()=>e((()=>m((()=>O(c)))));i=c,a=null;try{return k(g,!0)}finally{a=n,i=r}})((r=>{s=r,t===document?e():U(t,e(),t.firstChild?null:void 0,n)}),r.owner)}((()=>N(Gt,{})),r)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={equals:(e,t)=>e===t};let t=P;const n=1,r=2,o={owned:null,cleanups:null,context:null,owner:null};var i=null;let s=null,a=null,l=null,c=null,g=0;function u(t,n){const r={value:t,observers:null,observerSlots:null,comparator:(n=n?Object.assign({},e,n):e).equals||void 0};return[v.bind(r),e=>("function"==typeof e&&(e=e(r.value)),b(r,e))]}function d(e,t,r){y(w(e,t,!1,n))}function p(e,r,o){t=E;const i=w(e,r,!1,n);i.user=!0,c?c.push(i):y(i)}function h(t,n,r){r=r?Object.assign({},e,r):e;const o=w(t,n,!0,0);return o.observers=null,o.observerSlots=null,o.comparator=r.equals||void 0,y(o),v.bind(o)}function m(e){if(null===a)return e();const t=a;a=null;try{return e()}finally{a=t}}function f(e){p((()=>m(e)))}function A(e){let t;return i&&i.context&&void 0!==(t=i.context[e.id])?t:e.defaultValue}function x(e){const t=h(e),n=h((()=>D(t())));return n.toArray=()=>{const e=n();return Array.isArray(e)?e:null!=e?[e]:[]},n}function v(){if(this.sources&&this.state)if(this.state===n)y(this);else{const e=l;l=null,k((()=>S(this)),!1),l=e}if(a){const e=this.observers?this.observers.length:0;a.sources?(a.sources.push(this),a.sourceSlots.push(e)):(a.sources=[this],a.sourceSlots=[e]),this.observers?(this.observers.push(a),this.observerSlots.push(a.sources.length-1)):(this.observers=[a],this.observerSlots=[a.sources.length-1])}return this.value}function b(e,t,r){let o=e.value;return e.comparator&&e.comparator(o,t)||(e.value=t,e.observers&&e.observers.length&&k((()=>{for(let t=0;t<e.observers.length;t+=1){const r=e.observers[t],o=s&&s.running;o&&s.disposed.has(r),(o?r.tState:r.state)||(r.pure?l.push(r):c.push(r),r.observers&&T(r)),o||(r.state=n)}if(l.length>1e6)throw l=[],new Error}),!1)),t}function y(e){if(!e.fn)return;O(e);const t=g;!function(e,t,r){let o;const s=i,l=a;a=i=e;try{o=e.fn(t)}catch(t){return e.pure&&(e.state=n,e.owned&&e.owned.forEach(O),e.owned=null),e.updatedAt=r+1,R(t)}finally{a=l,i=s}(!e.updatedAt||e.updatedAt<=r)&&(null!=e.updatedAt&&"observers"in e?b(e,o):e.value=o,e.updatedAt=r)}(e,e.value,t)}function w(e,t,r,s=n,a){const l={fn:e,state:s,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:i,context:i?i.context:null,pure:r};return null===i||i!==o&&(i.owned?i.owned.push(l):i.owned=[l]),l}function C(e){if(0===e.state)return;if(e.state===r)return S(e);if(e.suspense&&m(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<g);)e.state&&t.push(e);for(let o=t.length-1;o>=0;o--)if((e=t[o]).state===n)y(e);else if(e.state===r){const n=l;l=null,k((()=>S(e,t[0])),!1),l=n}}function k(e,n){if(l)return e();let r=!1;n||(l=[]),c?r=!0:c=[],g++;try{const n=e();return function(e){if(l&&(P(l),l=null),e)return;const n=c;c=null,n.length&&k((()=>t(n)),!1)}(r),n}catch(e){r||(c=null),l=null,R(e)}}function P(e){for(let t=0;t<e.length;t++)C(e[t])}function E(e){let t,n=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[n++]=r:C(r)}for(t=0;t<n;t++)C(e[t])}function S(e,t){e.state=0;for(let o=0;o<e.sources.length;o+=1){const i=e.sources[o];if(i.sources){const e=i.state;e===n?i!==t&&(!i.updatedAt||i.updatedAt<g)&&C(i):e===r&&S(i,t)}}}function T(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=r,n.pure?l.push(n):c.push(n),n.observers&&T(n))}}function O(e){let t;if(e.sources)for(;e.sources.length;){const t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){const e=r.pop(),o=t.observerSlots.pop();n<r.length&&(e.sourceSlots[o]=n,r[n]=e,t.observerSlots[n]=o)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)O(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)O(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function R(e,t=i){const n=function(e){return e instanceof Error?e:new Error("string"==typeof e?e:"Unknown error",{cause:e})}(e);throw n}function D(e){if("function"==typeof e&&!e.length)return D(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const r=D(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function I(e,t){return function(t){let n;return d((()=>n=m((()=>(i.context={...i.context,[e]:t.value},x((()=>t.children)))))),void 0),n}}function N(e,t){return m((()=>e(t||{})))}function _(e){const t=e.keyed,n=h((()=>e.when),void 0,{equals:(e,n)=>t?e===n:!e==!n});return h((()=>{const r=n();if(r){const o=e.children;return"function"==typeof o&&o.length>0?m((()=>o(t?r:()=>{if(!m(n))throw"Stale read from <Show>.";return e.when}))):o}return e.fallback}),void 0,void 0)}const L="_$DX_DELEGATE";function F(e,t,n){let r;const o=()=>(r||(r=(()=>{const t=document.createElement("template");return t.innerHTML=e,t.content.firstChild})())).cloneNode(!0);return o.cloneNode=o,o}function M(e,t=window.document){const n=t[L]||(t[L]=new Set);for(let r=0,o=e.length;r<o;r++){const o=e[r];n.has(o)||(n.add(o),t.addEventListener(o,H))}}function $(e,t,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}function G(e,t,n){if(!t)return n?$(e,"style"):t;const r=e.style;if("string"==typeof t)return r.cssText=t;let o,i;for(i in"string"==typeof n&&(r.cssText=n=void 0),n||(n={}),t||(t={}),n)null==t[i]&&r.removeProperty(i),delete n[i];for(i in t)o=t[i],o!==n[i]&&(r.setProperty(i,o),n[i]=o);return n}function U(e,t,n,r){if(void 0===n||r||(r=[]),"function"!=typeof t)return B(e,t,r,n);d((r=>B(e,t(),r,n)),r)}function H(e){let t=e.target;const n=`$$${e.type}`,r=e.target,o=e.currentTarget,i=t=>Object.defineProperty(e,"target",{configurable:!0,value:t}),s=()=>{const r=t[n];if(r&&!t.disabled){const o=t[`${n}Data`];if(void 0!==o?r.call(t,o,e):r.call(t,e),e.cancelBubble)return}return t.host&&"string"!=typeof t.host&&!t.host._$host&&t.contains(e.target)&&i(t.host),!0},a=()=>{for(;s()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get:()=>t||document}),e.composedPath){const n=e.composedPath();i(n[0]);for(let e=0;e<n.length-2&&(t=n[e],s());e++){if(t._$host){t=t._$host,a();break}if(t.parentNode===o)break}}else a();i(r)}function B(e,t,n,r,o){for(;"function"==typeof n;)n=n();if(t===n)return n;const i=typeof t,s=void 0!==r;if(e=s&&n[0]&&n[0].parentNode||e,"string"===i||"number"===i){if("number"===i&&(t=t.toString())===n)return n;if(s){let o=n[0];o&&3===o.nodeType?o.data!==t&&(o.data=t):o=document.createTextNode(t),n=W(e,n,r,o)}else n=""!==n&&"string"==typeof n?e.firstChild.data=t:e.textContent=t}else if(null==t||"boolean"===i)n=W(e,n,r);else{if("function"===i)return d((()=>{let o=t();for(;"function"==typeof o;)o=o();n=B(e,o,n,r)})),()=>n;if(Array.isArray(t)){const i=[],a=n&&Array.isArray(n);if(j(i,t,n,o))return d((()=>n=B(e,i,n,r,!0))),()=>n;if(0===i.length){if(n=W(e,n,r),s)return n}else a?0===n.length?K(e,i,r):function(e,t,n){let r=n.length,o=t.length,i=r,s=0,a=0,l=t[o-1].nextSibling,c=null;for(;s<o||a<i;)if(t[s]!==n[a]){for(;t[o-1]===n[i-1];)o--,i--;if(o===s){const t=i<r?a?n[a-1].nextSibling:n[i-a]:l;for(;a<i;)e.insertBefore(n[a++],t)}else if(i===a)for(;s<o;)c&&c.has(t[s])||t[s].remove(),s++;else if(t[s]===n[i-1]&&n[a]===t[o-1]){const r=t[--o].nextSibling;e.insertBefore(n[a++],t[s++].nextSibling),e.insertBefore(n[--i],r),t[o]=n[i]}else{if(!c){c=new Map;let e=a;for(;e<i;)c.set(n[e],e++)}const r=c.get(t[s]);if(null!=r)if(a<r&&r<i){let l,g=s,u=1;for(;++g<o&&g<i&&null!=(l=c.get(t[g]))&&l===r+u;)u++;if(u>r-a){const o=t[s];for(;a<r;)e.insertBefore(n[a++],o)}else e.replaceChild(n[a++],t[s++])}else s++;else t[s++].remove()}}else s++,a++}(e,n,i):(n&&W(e),K(e,i));n=i}else if(t.nodeType){if(Array.isArray(n)){if(s)return n=W(e,n,r,t);W(e,n,null,t)}else null!=n&&""!==n&&e.firstChild?e.replaceChild(t,e.firstChild):e.appendChild(t);n=t}}return n}function j(e,t,n,r){let o=!1;for(let i=0,s=t.length;i<s;i++){let s,a=t[i],l=n&&n[e.length];if(null==a||!0===a||!1===a);else if("object"==(s=typeof a)&&a.nodeType)e.push(a);else if(Array.isArray(a))o=j(e,a,l)||o;else if("function"===s)if(r){for(;"function"==typeof a;)a=a();o=j(e,Array.isArray(a)?a:[a],Array.isArray(l)?l:[l])||o}else e.push(a),o=!0;else{const t=String(a);l&&3===l.nodeType&&l.data===t?e.push(l):e.push(document.createTextNode(t))}}return o}function K(e,t,n=null){for(let r=0,o=t.length;r<o;r++)e.insertBefore(t[r],n)}function W(e,t,n,r){if(void 0===n)return e.textContent="";const o=r||document.createTextNode("");if(t.length){let r=!1;for(let i=t.length-1;i>=0;i--){const s=t[i];if(o!==s){const t=s.parentNode===e;r||i?t&&s.remove():t?e.replaceChild(o,s):e.insertBefore(o,n)}else r=!0}}else e.insertBefore(o,n);return[o]}class V{log({level:e,message:t,timestamp:n,data:r,title:o}){const i="debug"===e?"log":e,s=o?`[${o}]`:"";void 0!==r?console[i](`[${n}] - ${V.LOGGER_PREFIX} ${s} ${t}`,r):console[i](`[${n}] - ${V.LOGGER_PREFIX} ${s} ${t}`)}}var Y,z;V.LOGGER_PREFIX="[GFAdUnit] -",function(e){e.checkoutPopupShown="CHECKOUT-POPUP-SHOWN",e.checkoutPopupNotShown="CHECKOUT-POPUP-NOT-SHOWN",e.checkoutPopupSupressed="CHECKOUT-POPUP-SUPRESSED",e.checkoutPopupDonation="CHECKOUT-POPUP-DONATION",e.checkoutPopupFailedActivation="CHECKOUT-POPUP-FAILED-ACTIVATION",e.checkoutPopupPurchaseConfirmed="CHECKOUT-POPUP-PURCHASE-CONFIRMED",e.checkoutPopupHealthCheck="CHECKOUT-POPUP-HEALTH-CHECK",e.checkouPopupActivationFailed="CHECKOUT-POPUP-ACTIVATION-FAILED",e.checkoutPopupOfferDetailsClicked="CHECKOUT-POPUP-OFFER-DETAILS-CLICKED",e.checkoutPopupWhyAmISeeingThisClicked="CHECKOUT-POPUP-WHY-AM-I-SEEING-THIS-CLICKED",e.checkoutPopupLooserExtension="CHECKOUT-POPUP-LOOSER-EXTENSION",e.checkoutPopupActiveDomain="CHECKOUT-POPUP-ACTIVE-DOMAIN",e.checkoutPopupSiteMatches="CHECKOUT-POPUP-SITE-MATCHES"}(Y||(Y={})),function(e){e.adUnitLog="ADUNIT-LOG"}(z||(z={}));const q=["debug","info","warn","error"];class J{constructor(e){this.config={minLevel:e?.minLevel??"debug",enabled:e?.enabled??!1,transports:e?.transports??[new V],title:e?.title??""}}static getInstance(e){return J.instance||(J.instance=new J(e)),J.instance}configure(e){this.config={...this.config,...e}}shouldLog(e){return!!this.config.enabled&&q.indexOf(e)>=q.indexOf(this.config.minLevel)}createLogMessage(e,t,n){return{level:e,version:"1.6.3",message:t,timestamp:(new Date).toISOString(),data:n,title:this.config.title}}log(e,t,n){if(!this.shouldLog(e))return;const r=this.createLogMessage(e,t,n);this.config.transports.forEach((e=>e.log(r)))}debug(e,t){this.log("debug",e,t)}info(e,t){this.log("info",e,t)}warn(e,t){this.log("warn",e,t)}error(e,t){this.log("error",e,t)}addTransport(e){this.config.transports.push(e)}clearTransports(){this.config.transports=[]}disable(){this.config.enabled=!1}enable(){this.config.enabled=!0}}const X=3,Z=e=>1e3*e;async function Q(e,t={}){const{maxAttempts:n=X,delayFn:r=Z}=t;let o=null;for(let t=1;t<=n;t+=1)try{return await e()}catch(e){o=e,t<n&&await new Promise((e=>{setTimeout(e,r(t))}))}throw o||new Error("Operation failed after multiple attempts")}const ee=chrome;async function te(e,t){return new Promise(((n,r)=>{try{const o=t=>chrome.runtime.lastError?r({error:chrome.runtime.lastError,message:e}):n(t);t?.tabId||ee.runtime.sendMessage(e,o)}catch(e){r(e)}}))}async function ne(e,t,n){return Q((()=>te(e,t)),{maxAttempts:X,delayFn:Z})}const re={display:"block",position:"fixed",top:"0%",left:"100%",width:"500px",height:"520px","margin-left":"-560px","margin-top":"50px",padding:"2px 5px","background-color":"white",border:"1px solid black","border-radius":"10px","box-shadow":"0 2px 10px rgba(0, 0, 0, 0.1)","z-index":"2147483647","font-family":"Arial","line-height":"1","vertical-align":"baseline","box-sizing":"border-box",color:"rgb(34, 34, 34)","@media (max-width: 600px), (max-height: 480px)":{display:"none !important"}},oe={height:"100%","overflow-x":"hidden","overlfow-y":"auto",position:"relative",padding:"0px 15px"},ie={},se={display:"flex","align-items":"center","margin-bottom":"10px"},ae={flex:"1","font-size":"24px","font-weight":"700","margin-top":"20px","margin-bottom":"0px"},le={background:"none",border:"none",padding:"4px 8px",color:"#666464","font-size":"38px",cursor:"pointer","line-height":"1"},ce={color:"black","margin-top":"20px","max-width":"40%"},ge={color:"gray",cursor:"default","pointer-events":"none","text-decoration":"none"},ue={"font-size":"18px","font-weight":"400","margin-top":"20px","margin-bottom":"0px"},de={display:"flex",gap:"10px",width:"100%","margin-top":"20px","margin-bottom":"20px","flex-wrap":"wrap","justify-content":"space-between"},pe={width:"28%",position:"relative",display:"flex","flex-direction":"column","align-items":"center",background:"none",border:"1px solid #ccc","border-radius":"5px",padding:"5px",gap:"5px","text-align":"center","font-size":"14px",cursor:"pointer",transition:"background-color 0.2s ease"},he={color:"white","background-color":"lightgray",cursor:"default","pointer-events":"none"},me={"max-width":"120px","max-height":"70px","margin-bottom":"5px","object-fit":"contain"},fe={"background-color":"#FFD812",cursor:"pointer","border-radius":"8px",padding:"8px",color:"white","min-width":"100px",border:"0","font-weight":"600",width:"100%"},Ae={display:"flex","flex-direction":"column",gap:"10px",width:"100%","color-scheme":"light"},xe={display:"flex","align-items":"center",gap:"5px",border:"1px solid #ddd",padding:"15px","border-radius":"5px","font-weight":"600",cursor:"pointer","margin-bottom":"8px"},ve={"text-align":"right"},be={background:"none",border:"none",color:"blue","text-decoration":"underline",padding:"0",cursor:"pointer","margin-bottom":"15px"},ye={display:"flex","justify-content":"space-between",margin:"20px 0px 10px 0px","font-size":"14px"},we={margin:"5px 0px 5px 0px","font-size":"14px","text-align":"center"},Ce={color:"#666464","text-decoration":"underline"},ke={color:"rgb(102, 100, 100)","text-decoration":"underline",margin:"0",cursor:"pointer"},Pe={width:"100%","background-color":"#f2f2f2",border:"1px solid black","border-radius":"10px","border-top":"1px solid #bbb7b7","margin-top":"10px","margin-bottom":"20px","box-sizing":"border-box"},Ee={padding:"0 5px 0 10px",width:"100%","font-size":"12px","box-sizing":"border-box"},Se={display:"grid","grid-template-columns":"4fr 1fr","padding-right":"15px","padding-bottom":"5px"},Te={color:"#000","margin-bottom":"4px"},Oe={"font-size":"14px",color:"#555","text-align":"right"},Re=(e,t)=>{let n=parseFloat(t);return"FLAT"===e&&(n*=.75),((e,t)=>{let n=parseFloat(t);return n<1&&(n=1),n=Math.floor(n),"PERCENTAGE"===e?`${n}%`:`$${n}`})(e,n.toString())};var De=F("<span>");function Ie(e){return t=De(),d((()=>{return t.innerHTML=(n=e.title,r=e.activeDomain,n.replace("{0}",Re(r.Merchant.MaxRate?.Kind,r.Merchant.MaxRate?.Amount??"0")));var n,r})),t;var t}const Ne=function(){const e=Symbol("context");return{id:e,Provider:I(e),defaultValue:()=>({translate:e=>"",getAllCharities:()=>[]})}}(),_e=Ne,Le=()=>{const e=A(_e)();if(!e)throw new Error("Content provider context is undefined");return t=>e.translate(t)};class Fe{static formatMessage(e,...t){return e.replace(/{(\d+)}/g,((e,n)=>{const r=Number(n);return void 0!==t[r]?String(t[r]):`{${r}}`}))}}var Me=F("<div>"),$e=F("<div><div class=gf-offer-details><p><span></span></p><p><span></span></p><p><span></span></p><p><span></span></p><p><span></span></p><p><a target=_blank rel=noreferrer>"),Ge=F("<div class=gf-offer-details-rate-item><div></div><div>");const Ue=e=>{const t=Le();return n=$e(),o=(r=n.firstChild).firstChild,i=o.firstChild,s=o.nextSibling,a=s.firstChild,l=s.nextSibling,c=l.firstChild,g=l.nextSibling,u=g.firstChild,p=g.nextSibling,h=p.firstChild,m=p.nextSibling.firstChild,U(r,N(_,{get when(){return!!e.merchantRateDetail?.length},get children(){var t=Me();return U(t,(()=>e.merchantRateDetail?.map((e=>{return t=Ge(),n=t.firstChild,r=n.nextSibling,U(n,(()=>e.Name||"")),U(r,(()=>((e,t=1,n=1)=>{const r=e.BoostedOffer??null;let o=parseFloat(e?.Amount??"");if(r?.EndDate&&new Date(r.EndDate)<new Date&&(o=parseFloat(r.OriginalMaxRate)),Number.isNaN(o))return"";const i=o*t;return"PERCENTAGE"===e?.Kind?`${i.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:n})}%`:"FLAT"===e?.Kind?i.toLocaleString("en-US",{style:"currency",currency:e.Currency}):""})(e))),d((e=>{var o=Se,i=Te,s=Oe;return e.e=G(t,o,e.e),e.t=G(n,i,e.t),e.a=G(r,s,e.a),e}),{e:void 0,t:void 0,a:void 0}),t;var t,n,r})))),t}}),g),U(m,(()=>t("offerDetails.termsAndConditions"))),d((o=>{var s=Pe,l=Ee,g=t("offerDetails.intro"),d=t("offerDetails.eligible"),p=e.parsedMaxRate?Fe.formatMessage(t("offerDetails.donationRatesWithValue"),e.parsedMaxRate):Fe.formatMessage(t("offerDetails.donationRates")),f=t("offerDetails.donationAmounts"),A=t("offerDetails.donationTiming"),x=Ce,v=e.termsUrl;return o.e=G(n,s,o.e),o.t=G(r,l,o.t),g!==o.a&&(i.innerHTML=o.a=g),d!==o.o&&(a.innerHTML=o.o=d),p!==o.i&&(c.innerHTML=o.i=p),f!==o.n&&(u.innerHTML=o.n=f),A!==o.s&&(h.innerHTML=o.s=A),o.h=G(m,x,o.h),v!==o.r&&$(m,"href",o.r=v),o}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),n;var n,r,o,i,s,a,l,c,g,u,p,h,m};function He(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var Be={exports:{}};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self&&self,function(e){if(!(globalThis.chrome&&globalThis.chrome.runtime&&globalThis.chrome.runtime.id))throw new Error("This script should only be loaded in a browser extension.");if(globalThis.browser&&globalThis.browser.runtime&&globalThis.browser.runtime.id)e.exports=globalThis.browser;else{const t="The message port closed before a response was received.",n=e=>{const n={alarms:{clear:{minArgs:0,maxArgs:1},clearAll:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getAll:{minArgs:0,maxArgs:0}},bookmarks:{create:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},getChildren:{minArgs:1,maxArgs:1},getRecent:{minArgs:1,maxArgs:1},getSubTree:{minArgs:1,maxArgs:1},getTree:{minArgs:0,maxArgs:0},move:{minArgs:2,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeTree:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}},browserAction:{disable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},enable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},getBadgeBackgroundColor:{minArgs:1,maxArgs:1},getBadgeText:{minArgs:1,maxArgs:1},getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},openPopup:{minArgs:0,maxArgs:0},setBadgeBackgroundColor:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setBadgeText:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},browsingData:{remove:{minArgs:2,maxArgs:2},removeCache:{minArgs:1,maxArgs:1},removeCookies:{minArgs:1,maxArgs:1},removeDownloads:{minArgs:1,maxArgs:1},removeFormData:{minArgs:1,maxArgs:1},removeHistory:{minArgs:1,maxArgs:1},removeLocalStorage:{minArgs:1,maxArgs:1},removePasswords:{minArgs:1,maxArgs:1},removePluginData:{minArgs:1,maxArgs:1},settings:{minArgs:0,maxArgs:0}},commands:{getAll:{minArgs:0,maxArgs:0}},contextMenus:{remove:{minArgs:1,maxArgs:1},removeAll:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},cookies:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:1,maxArgs:1},getAllCookieStores:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},devtools:{inspectedWindow:{eval:{minArgs:1,maxArgs:2,singleCallbackArg:!1}},panels:{create:{minArgs:3,maxArgs:3,singleCallbackArg:!0},elements:{createSidebarPane:{minArgs:1,maxArgs:1}}}},downloads:{cancel:{minArgs:1,maxArgs:1},download:{minArgs:1,maxArgs:1},erase:{minArgs:1,maxArgs:1},getFileIcon:{minArgs:1,maxArgs:2},open:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},pause:{minArgs:1,maxArgs:1},removeFile:{minArgs:1,maxArgs:1},resume:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},extension:{isAllowedFileSchemeAccess:{minArgs:0,maxArgs:0},isAllowedIncognitoAccess:{minArgs:0,maxArgs:0}},history:{addUrl:{minArgs:1,maxArgs:1},deleteAll:{minArgs:0,maxArgs:0},deleteRange:{minArgs:1,maxArgs:1},deleteUrl:{minArgs:1,maxArgs:1},getVisits:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1}},i18n:{detectLanguage:{minArgs:1,maxArgs:1},getAcceptLanguages:{minArgs:0,maxArgs:0}},identity:{launchWebAuthFlow:{minArgs:1,maxArgs:1}},idle:{queryState:{minArgs:1,maxArgs:1}},management:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},getSelf:{minArgs:0,maxArgs:0},setEnabled:{minArgs:2,maxArgs:2},uninstallSelf:{minArgs:0,maxArgs:1}},notifications:{clear:{minArgs:1,maxArgs:1},create:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:0},getPermissionLevel:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},pageAction:{getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},hide:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},permissions:{contains:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},request:{minArgs:1,maxArgs:1}},runtime:{getBackgroundPage:{minArgs:0,maxArgs:0},getPlatformInfo:{minArgs:0,maxArgs:0},openOptionsPage:{minArgs:0,maxArgs:0},requestUpdateCheck:{minArgs:0,maxArgs:0},sendMessage:{minArgs:1,maxArgs:3},sendNativeMessage:{minArgs:2,maxArgs:2},setUninstallURL:{minArgs:1,maxArgs:1}},sessions:{getDevices:{minArgs:0,maxArgs:1},getRecentlyClosed:{minArgs:0,maxArgs:1},restore:{minArgs:0,maxArgs:1}},storage:{local:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},managed:{get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1}},sync:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}}},tabs:{captureVisibleTab:{minArgs:0,maxArgs:2},create:{minArgs:1,maxArgs:1},detectLanguage:{minArgs:0,maxArgs:1},discard:{minArgs:0,maxArgs:1},duplicate:{minArgs:1,maxArgs:1},executeScript:{minArgs:1,maxArgs:2},get:{minArgs:1,maxArgs:1},getCurrent:{minArgs:0,maxArgs:0},getZoom:{minArgs:0,maxArgs:1},getZoomSettings:{minArgs:0,maxArgs:1},goBack:{minArgs:0,maxArgs:1},goForward:{minArgs:0,maxArgs:1},highlight:{minArgs:1,maxArgs:1},insertCSS:{minArgs:1,maxArgs:2},move:{minArgs:2,maxArgs:2},query:{minArgs:1,maxArgs:1},reload:{minArgs:0,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeCSS:{minArgs:1,maxArgs:2},sendMessage:{minArgs:2,maxArgs:3},setZoom:{minArgs:1,maxArgs:2},setZoomSettings:{minArgs:1,maxArgs:2},update:{minArgs:1,maxArgs:2}},topSites:{get:{minArgs:0,maxArgs:0}},webNavigation:{getAllFrames:{minArgs:1,maxArgs:1},getFrame:{minArgs:1,maxArgs:1}},webRequest:{handlerBehaviorChanged:{minArgs:0,maxArgs:0}},windows:{create:{minArgs:0,maxArgs:1},get:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:1},getCurrent:{minArgs:0,maxArgs:1},getLastFocused:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}}};if(0===Object.keys(n).length)throw new Error("api-metadata.json has not been included in browser-polyfill");class r extends WeakMap{constructor(e,t=void 0){super(t),this.createItem=e}get(e){return this.has(e)||this.set(e,this.createItem(e)),super.get(e)}}const o=(t,n)=>(...r)=>{e.runtime.lastError?t.reject(new Error(e.runtime.lastError.message)):n.singleCallbackArg||r.length<=1&&!1!==n.singleCallbackArg?t.resolve(r[0]):t.resolve(r)},i=e=>1==e?"argument":"arguments",s=(e,t,n)=>new Proxy(t,{apply:(t,r,o)=>n.call(r,e,...o)});let a=Function.call.bind(Object.prototype.hasOwnProperty);const l=(e,t={},n={})=>{let r=Object.create(null),c={has:(t,n)=>n in e||n in r,get(c,g,u){if(g in r)return r[g];if(!(g in e))return;let d=e[g];if("function"==typeof d)if("function"==typeof t[g])d=s(e,e[g],t[g]);else if(a(n,g)){let t=((e,t)=>function(n,...r){if(r.length<t.minArgs)throw new Error(`Expected at least ${t.minArgs} ${i(t.minArgs)} for ${e}(), got ${r.length}`);if(r.length>t.maxArgs)throw new Error(`Expected at most ${t.maxArgs} ${i(t.maxArgs)} for ${e}(), got ${r.length}`);return new Promise(((i,s)=>{if(t.fallbackToNoCallback)try{n[e](...r,o({resolve:i,reject:s},t))}catch(o){console.warn(`${e} API method doesn't seem to support the callback parameter, falling back to call it without a callback: `,o),n[e](...r),t.fallbackToNoCallback=!1,t.noCallback=!0,i()}else t.noCallback?(n[e](...r),i()):n[e](...r,o({resolve:i,reject:s},t))}))})(g,n[g]);d=s(e,e[g],t)}else d=d.bind(e);else if("object"==typeof d&&null!==d&&(a(t,g)||a(n,g)))d=l(d,t[g],n[g]);else{if(!a(n,"*"))return Object.defineProperty(r,g,{configurable:!0,enumerable:!0,get:()=>e[g],set(t){e[g]=t}}),d;d=l(d,t[g],n["*"])}return r[g]=d,d},set:(t,n,o,i)=>(n in r?r[n]=o:e[n]=o,!0),defineProperty:(e,t,n)=>Reflect.defineProperty(r,t,n),deleteProperty:(e,t)=>Reflect.deleteProperty(r,t)},g=Object.create(e);return new Proxy(g,c)},c=e=>({addListener(t,n,...r){t.addListener(e.get(n),...r)},hasListener:(t,n)=>t.hasListener(e.get(n)),removeListener(t,n){t.removeListener(e.get(n))}}),g=new r((e=>"function"!=typeof e?e:function(t){const n=l(t,{},{getContent:{minArgs:0,maxArgs:0}});e(n)})),u=new r((e=>"function"!=typeof e?e:function(t,n,r){let o,i,s=!1,a=new Promise((e=>{o=function(t){s=!0,e(t)}}));try{i=e(t,n,o)}catch(e){i=Promise.reject(e)}const l=!0!==i&&((c=i)&&"object"==typeof c&&"function"==typeof c.then);var c;if(!0!==i&&!l&&!s)return!1;return(l?i:a).then((e=>{r(e)}),(e=>{let t;t=e&&(e instanceof Error||"string"==typeof e.message)?e.message:"An unexpected error occurred",r({__mozWebExtensionPolyfillReject__:!0,message:t})})).catch((e=>{console.error("Failed to send onMessage rejected reply",e)})),!0})),d=({reject:n,resolve:r},o)=>{e.runtime.lastError?e.runtime.lastError.message===t?r():n(new Error(e.runtime.lastError.message)):o&&o.__mozWebExtensionPolyfillReject__?n(new Error(o.message)):r(o)},p=(e,t,n,...r)=>{if(r.length<t.minArgs)throw new Error(`Expected at least ${t.minArgs} ${i(t.minArgs)} for ${e}(), got ${r.length}`);if(r.length>t.maxArgs)throw new Error(`Expected at most ${t.maxArgs} ${i(t.maxArgs)} for ${e}(), got ${r.length}`);return new Promise(((e,t)=>{const o=d.bind(null,{resolve:e,reject:t});r.push(o),n.sendMessage(...r)}))},h={devtools:{network:{onRequestFinished:c(g)}},runtime:{onMessage:c(u),onMessageExternal:c(u),sendMessage:p.bind(null,"sendMessage",{minArgs:1,maxArgs:3})},tabs:{sendMessage:p.bind(null,"sendMessage",{minArgs:2,maxArgs:3})}},m={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return n.privacy={network:{"*":m},services:{"*":m},websites:{"*":m}},l(e,h,n)};e.exports=n(chrome)}}(Be);var je=He(Be.exports);const Ke="GIVE_FREELY_",We={async get(e){const t=`${Ke}${e}`;return(await je.storage.local.get(t))[t]||null},async set(e,t){const n=`${Ke}${e}`;await je.storage.local.set({[n]:t})},async remove(e){const t=Array.isArray(e)?e.map((e=>`${Ke}${e}`)):`${Ke}${e}`;await je.storage.local.remove(t)}},Ve="version",Ye=()=>String("1.6.3"),ze="https://cdn.givefreely.com/adunit/behavioral/";class qe{constructor(e){this.partnerApiKey=e,this.partnerConfig=null,this.globalConfig=null,this.lastConfigRefresh=0,this.CONFIG_REFRESH_INTERVAL=300,this.PARTNER_CONFIG_STORAGE_KEY="gf_partner_config",this.GLOBAL_CONFIG_STORAGE_KEY="gf_global_config"}getRetryOptions(){return{delayFn:e=>1e3*e,maxAttempts:3}}async fetchAndUpdatePartnerConfig(){const e=await Q((async()=>{const e=await fetch(`${ze}${this.partnerApiKey}.json`,{cache:"no-store"});if(!e.ok)throw new Error(`Failed to fetch partner config: ${e.statusText}`);return e.json()}),this.getRetryOptions()),t={config:e,lastRefresh:Date.now()};return await We.set(this.PARTNER_CONFIG_STORAGE_KEY,t),e}async fetchAndUpdateGlobalConfig(){const e=await Q((async()=>{const e=await fetch(`${ze}global.json`,{cache:"no-store"});if(!e.ok)throw new Error(`Failed to fetch global config: ${e.statusText}`);return e.json()}),this.getRetryOptions()),t={config:e,lastRefresh:Date.now()};return await We.set(this.GLOBAL_CONFIG_STORAGE_KEY,t),e}async getConfig(e=!1){const t=Date.now(),n=await We.get(this.PARTNER_CONFIG_STORAGE_KEY),r=await We.get(this.GLOBAL_CONFIG_STORAGE_KEY);this.partnerConfig=n?.config||null,this.globalConfig=r?.config||null,this.lastConfigRefresh=Math.max(n?.lastRefresh||0,r?.lastRefresh||0);let o=!1;e&&(o=await(async(e=!0)=>{const t=await We.get(Ve),n=await Ye(),r=t!==n;var o;return e&&r&&await(o=n,We.set(Ve,o)),r})());const i=this.partnerConfig?.configRefreshInterval||this.globalConfig?.configRefreshInterval||this.CONFIG_REFRESH_INTERVAL;if(o||!this.partnerConfig||!this.globalConfig||t-this.lastConfigRefresh>1e3*i)try{const[e,n]=await Promise.all([this.fetchAndUpdatePartnerConfig(),this.fetchAndUpdateGlobalConfig()]);this.partnerConfig=e,this.globalConfig=n,this.lastConfigRefresh=t}catch(e){if(!this.partnerConfig||!this.globalConfig)throw e}const s=this.mergeConfigs(JSON.parse(JSON.stringify(this.globalConfig)),JSON.parse(JSON.stringify(this.partnerConfig)));return s&&((e,t,n)=>{const r=[...t.merchantExclusions??[],...n.merchantExclusions??[]];e.merchantExclusions=r})(s,this.globalConfig,this.partnerConfig),s}async clearCache(){await Promise.all([We.remove(this.PARTNER_CONFIG_STORAGE_KEY),We.remove(this.GLOBAL_CONFIG_STORAGE_KEY)]),this.partnerConfig=null,this.globalConfig=null,this.lastConfigRefresh=0}mergeConfigs(e,t){if(!t)return e;if(!e)return t;const n={...e};return Object.keys(t).forEach((r=>{if(!Object.prototype.hasOwnProperty.call(t,r))return;const o=e[r],i=t[r];void 0!==i&&(Array.isArray(i)?n[r]=[...i]:n[r]=null===i||"object"!=typeof i||null===o||"object"!=typeof o?i:this.mergeConfigs(o,i))})),n}getStoredState(e){return e?{config:e.config,lastRefresh:e.lastRefresh}:{config:null,lastRefresh:0}}}const Je="TRACK_EVENT",Xe="GF_HIDE_POPUP",Ze="GF_GET_POPUP_CONFIG",Qe="GF_IS_ACTIVE_DOMAIN",et="GF_SHOULD_STAND_DOWN",tt="GF_ACTIVATE_OFFER",nt="GF_STORE_SHOPIFY_SHOP_ID",rt="GF_GET_DOMAIN_BY_SHOP_ID",ot="GF_GET_LANGUAGE_CONTENT",it={ein:"0",tpi:"0"};class st{constructor(e,t,n=60){this._config=null,this.track=async(e,t,n,r=!1)=>{null===this._config&&(this._config=await new qe(this._partnerApiKey).getConfig());const o={partner:`adUnit_${this._partnerApiKey}`,eventType:e,eventData:{userId:r?void 0:this._userService?.user?.id,libVersion:Ye(),wfDeviceId:t,...n}};try{const e=JSON.stringify(o);return await this.shouldBroadcastEvent(e)?(await fetch(this._config.eventsUrl,{headers:{"Content-Type":"application/json"},method:"POST",body:e,cache:"no-store"}),await this.pushEventToHistory(e),!0):(this._logger.info("This event has already been broadcasted during the past hour",o),!1)}catch(e){return this._logger.info("Something unexpected happened when dispatching a gf event",{error:e,event:o}),!1}},this.getEventsHistory=async()=>{const{GF_AD_EVENT_HISTORY:e}=await ee.storage.local.get({GF_AD_EVENT_HISTORY:""}),t=(e=>{const t=new Date;return t.setTime(t.getTime()+60*e*1e3),t.getTime()})(-this._debounceWindowInMinutes),n=(e||[]).filter((e=>e.createdAt>t));return await ee.storage.local.set({GF_AD_EVENT_HISTORY:n}),n},this.shouldBroadcastEvent=async e=>!(await this.getEventsHistory()).some((t=>t.payload===e)),this.pushEventToHistory=async e=>{const t=await this.getEventsHistory();t.push({createdAt:Date.now(),payload:e}),await ee.storage.local.set({GF_AD_EVENT_HISTORY:t})},this._partnerApiKey=e,this._userService=t,this._debounceWindowInMinutes=n,this._logger=J.getInstance({title:"Analytics"})}}function at(e,t,n){return e?{...t,...n}:t}st.trackEvent=async(e,t,n=!1)=>{await te({type:Je,payload:{eventType:e,eventData:t,anonymous:n}})};var lt=F("<a href=#!>"),ct=F("<button class=give-freely-close-button aria-label=Close>×"),gt=F('<div><div><div></div></div><hr><div></div><div><div><div><br></div><button aria-label="Don\'t show again"></button></div></div><div><p></p><a class=give-freely-footer-link target=_blank rel="noopener noreferrer">'),ut=F("<div><div><img><span></span></div><button>"),dt=F("<div>");function pt(e){const[t,n]=u(!1),[r,o]=u(null),i=Le(),s=(()=>{const e=A(Ne)();if(!e)throw new Error("Content provider context is undefined");return()=>e.getAllCharities()})();p((()=>{t()&&e.mainContainerRef&&e.mainContainerRef.scroll({top:e.mainContainerRef.scrollHeight,behavior:"smooth"})})),p((()=>{const t=r();t&&e.onCharitySelect(t.charity,t.closeOnDonation?e.checkoutPopupConf.checkoutPopupActivateAndCloseSkipSuccess:void 0)}));const a=(e,t)=>o({charity:e,closeOnDonation:t}),l=()=>!!r()?.charity;return[(g=gt(),m=g.firstChild,f=m.firstChild,x=m.nextSibling.nextSibling,v=x.nextSibling,b=v.firstChild,y=b.firstChild,w=y.nextSibling,C=v.nextSibling,k=C.firstChild,P=k.nextSibling,U(f,(()=>i("main.title"))),U(m,N(_,{get when(){return e.checkoutPopupConf.checkoutPopupActivateAndClose},get children(){var e=lt();return e.$$click=()=>a(it,!0),d((t=>{var n=at(l(),ce,ge),r=i("main.activateAndClose");return t.e=G(e,n,t.e),r!==t.t&&(e.innerHTML=t.t=r),t}),{e:void 0,t:void 0}),e}}),null),U(m,N(_,{get when(){return e.checkoutPopupConf.checkoutPopupMainCloseButtonVisible&&!e.checkoutPopupConf.checkoutPopupActivateAndClose},get children(){var t=ct();return t.$$click=()=>e.onClose(),d((e=>G(t,le,e))),t}}),null),U(x,N(Ie,{get title(){return i("main.subTitle")},get activeDomain(){return e.activeDomain}})),U(v,(()=>s().map((t=>{return o=(r=ut()).firstChild,c=(s=o.firstChild).nextSibling,g=o.nextSibling,r.$$click=()=>!l()&&a(t),U(r,(n=h((()=>!!(t.decorator&&t.decoratorLeftStyle&&t.decoratorRightStyle))),()=>{return n()&&[(r=dt(),d((e=>{var n=t.decoratorLeftStyle,o=t.decorator;return e.e=G(r,n,e.e),o!==e.t&&(r.innerHTML=e.t=o),e}),{e:void 0,t:void 0}),r),(e=dt(),d((n=>{var r=t.decoratorRightStyle,o=t.decorator;return n.e=G(e,r,n.e),o!==n.t&&(e.innerHTML=n.t=o),n}),{e:void 0,t:void 0}),e)];var e,r}),o),o.style.setProperty("height","100px"),o.style.setProperty("text-align","center"),U(c,(()=>t.title)),U(g,(()=>i("main.charitySelect"))),d((n=>{var o=at(l(),pe,{cursor:"default"}),i=t.logo,a=me,c=t.title,u=at(l(),{...fe,"background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812"},he),d=l(),p=`Select charity: ${t.title}`;return n.e=G(r,o,n.e),i!==n.t&&$(s,"src",n.t=i),n.a=G(s,a,n.a),c!==n.o&&$(s,"alt",n.o=c),n.i=G(g,u,n.i),d!==n.n&&(g.disabled=n.n=d),p!==n.s&&$(g,"aria-label",n.s=p),n}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),r;var n,r,o,s,c,g}))),b),b.$$click=()=>!l()&&e.onSuppress(),y.style.setProperty("height","100px"),y.style.setProperty("text-align","center"),U(y,(()=>i("main.sixthBox")),null),U(w,(()=>i("main.settings"))),k.$$click=()=>{e.onOfferDetailsClick(!t()),n(!t())},U(k,(()=>i("main.offerDetails"))),P.$$click=()=>{st.trackEvent(Y.checkoutPopupWhyAmISeeingThisClicked,{domain:globalThis.window.location.hostname})},U(P,(()=>i("main.whyAmISeeingThis"))),U(g,(c=h((()=>!!e.checkoutPopupConf.checkoutPopupDisplayNameInFooter)),()=>{return c()&&(U(e=dt(),(()=>i("main.footer"))),d((t=>G(e,we,t))),e);var e}),null),d((t=>{var n=ie,r=se,o=ae,i=ue,s=de,a=at(l(),pe,{cursor:"default"}),c=at(l(),{...fe,"background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812"},he),u=l(),d=ye,p=ke,h=Ce,A=e.checkoutPopupConf.externalUrls.giveFreelyWhyAmISeeingThis;return t.e=G(g,n,t.e),t.t=G(m,r,t.t),t.a=G(f,o,t.a),t.o=G(x,i,t.o),t.i=G(v,s,t.i),t.n=G(b,a,t.n),t.s=G(w,c,t.s),u!==t.h&&(w.disabled=t.h=u),t.r=G(C,d,t.r),t.d=G(k,p,t.d),t.l=G(P,h,t.l),A!==t.u&&$(P,"href",t.u=A),t}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0}),g),N(_,{get when(){return t()},get children(){return N(Ue,{get merchantName(){return e.activeDomain.Merchant.Name},get extensionName(){return e.checkoutPopupConf.displayName},get termsUrl(){return e.checkoutPopupConf.externalUrls.giveFreelyTermsAndConditions},get parsedMaxRate(){return h((()=>!!e.activeDomain.Merchant.MaxRate))()?Re(e.activeDomain.Merchant.MaxRate.Kind,e.activeDomain.Merchant.MaxRate?.Amount):null},get merchantRateDetail(){return e.merchantRates},onClose:()=>n(!1)})}})];var c,g,m,f,x,v,b,y,w,C,k,P}M(["click"]);var ht=F("<button class=give-freely-close-button aria-label=Close>×"),mt=F("<label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=18250><span>"),ft=F('<div><div><div></div></div><button class=give-freely-back-button aria-label="Back to charity selection"></button><hr><div id=give-freely-goodbye-screen-options><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=1></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=7></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=30></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=90><span></span></label></div><button class=give-freely-submit-button>');function At(e){const[t,n]=u(0),r=Le();return o=ft(),i=o.firstChild,s=i.firstChild,a=i.nextSibling,l=a.nextSibling.nextSibling,g=(c=l.firstChild).firstChild,h=(p=c.nextSibling).firstChild,f=(m=p.nextSibling).firstChild,v=(x=(A=m.nextSibling).firstChild).nextSibling,b=l.nextSibling,o.style.setProperty("font-size","14px"),U(s,(()=>r("suppress.title"))),U(i,N(_,{get when(){return e.checkoutPopupConf.checkoutPopupSupressCloseButtonVisible},get children(){var t=ht();return t.$$click=()=>e.onGoodbye(0),d((e=>G(t,le,e))),t}}),null),a.$$click=()=>e.onBack(),U(a,(()=>r("suppress.backButton"))),g.addEventListener("change",(()=>n(1))),U(c,(()=>r("suppress.suppressionPeriod").replace("{0}","1")),null),h.addEventListener("change",(()=>n(7))),U(p,(()=>r("suppress.suppressionPeriodPlural").replace("{0}","7")),null),f.addEventListener("change",(()=>n(30))),U(m,(()=>r("suppress.suppressionPeriodPlural").replace("{0}","30")),null),x.addEventListener("change",(()=>n(90))),U(v,(()=>r("suppress.suppressionPeriodPlural").replace("{0}","90"))),U(l,N(_,{get when(){return e.checkoutPopupConf.checkoutPopupNeverSuppressionAllowed},get children(){var e=mt(),t=e.firstChild,o=t.nextSibling;return t.addEventListener("change",(()=>n(18250))),U(o,(()=>r("suppress.suppressionPeriodNever"))),d((t=>G(e,xe,t))),e}}),null),b.$$click=()=>{const n=t();n&&(e.onGoodbye(n),e.setScreen("main"))},U(b,(()=>r("suppress.submitButton"))),d((t=>{var n=se,r=ae,o=be,g=Ae,u=xe,d=xe,h=xe,f=xe,x={...fe,"font-weight":"700","margin-top":"10px","margin-bottom":"0px","background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812",width:"100px"};return t.e=G(i,n,t.e),t.t=G(s,r,t.t),t.a=G(a,o,t.a),t.o=G(l,g,t.o),t.i=G(c,u,t.i),t.n=G(p,d,t.n),t.s=G(m,h,t.s),t.h=G(A,f,t.h),t.r=G(b,x,t.r),t}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),o;var o,i,s,a,l,c,g,p,h,m,f,A,x,v,b}M(["click"]);var xt=F("<div><p>"),vt=F("<div><div><div></div><button class=give-freely-close-button aria-label=Close>×</button></div><hr><div><span>");function bt(e){const[t,n]=u(null),r=Le();let o;var s,a,l,c,g,p,m,A;return s=()=>clearInterval(o),null===i||(null===i.cleanups?i.cleanups=[s]:i.cleanups.push(s)),f((()=>{e.failedDonation||(()=>{const t=e.checkoutPopupConf.checkoutPopupDonationSuccessAutoCloseInSeconds??3;n(t),o=setInterval((()=>{n((t=>null===t||t<=1?(clearInterval(o),e.onClose(),0):t-1))}),1e3)})()})),l=vt(),c=l.firstChild,g=c.firstChild,p=g.nextSibling,m=c.nextSibling.nextSibling,A=m.firstChild,l.style.setProperty("font-size","14px"),U(g,(a=h((()=>!!e.failedDonation)),()=>a()?r("donate.failTitle"):r("donate.title"))),p.$$click=()=>e.onClose(),m.style.setProperty("padding","30px"),m.style.setProperty("height","150px"),m.style.setProperty("font-size","14px"),U(l,N(_,{get when(){return!e.failedDonation},get children(){var e=xt(),n=e.firstChild;return U(n,(()=>Fe.formatMessage(r("donate.autoClosing"),t()??0))),d((e=>G(n,ve,e))),e}}),null),d((t=>{var n=se,o=ae,i=le,s=e.failedDonation?r("donate.failContent"):r("donate.content");return t.e=G(c,n,t.e),t.t=G(g,o,t.t),t.a=G(p,i,t.a),s!==t.o&&(A.innerHTML=t.o=s),t}),{e:void 0,t:void 0,a:void 0,o:void 0}),l}M(["click"]);var yt=F("<div><div>");const wt=(e,t,n)=>"donate"===e?"340px":t.checkoutPopupDisplayNameInFooter?"520px":n;function Ct(e){const[t,n]=u("main"),[r,o]=u(),[i,s]=u(!1),a=()=>{e.logger.debug("Close button clicked"),e.onClose()},l=async(t,r=!1)=>{r&&e.onClose(),e.logger.info("Charity selected",{charity:t,domain:e.activeDomain.Domain}),o(t);const i=await e.onDonate(t,e.activeDomain);r?e.onClose():(s(!i),n("donate"))},c=()=>{e.logger.debug("Suppress button clicked"),n("goodbye")},g=()=>{e.logger.debug("Navigating back to main screen"),n("main")},p=t=>{e.logger.info("User chose to hide popup",{days:t}),e.onClose(t)};let h;return x=yt(),v=x.firstChild,"function"==typeof h?(f=h,A=v,m((()=>f(A,undefined)))):h=v,U(v,N(_,{get when(){return"main"===t()},get children(){return N(pt,{mainContainerRef:h,get checkoutPopupConf(){return e.checkoutPopupConf},get activeDomain(){return e.activeDomain},get merchantRates(){return e.merchantRates},onClose:a,onCharitySelect:l,onSuppress:c,get onOfferDetailsClick(){return e.onOfferDetailsClick}})}}),null),U(v,N(_,{get when(){return"goodbye"===t()},get children(){return N(At,{get checkoutPopupConf(){return e.checkoutPopupConf},onClose:()=>e.onClose(),onBack:g,onGoodbye:p,setScreen:n})}}),null),U(v,N(_,{get when(){return"donate"===t()},get children(){return N(bt,{get checkoutPopupConf(){return e.checkoutPopupConf},get selectedCharity(){return r()},onClose:()=>e.onClose(),get failedDonation(){return i()},setScreen:n})}}),null),d((n=>{var r={...re,height:wt(t(),e.checkoutPopupConf,re.height)},o=e.elementId,i=oe;return n.e=G(x,r,n.e),o!==n.t&&$(x,"id",n.t=o),n.a=G(v,i,n.a),n}),{e:void 0,t:void 0,a:void 0}),x;var f,A,x,v}function kt(e){const t=["",".asp",".aspx",".php",".js",".htm",".html"],n=["cart","checkout","shopping-bag","shopping-basket","shopping-cart","basket"].flatMap((e=>t.map((t=>e+t)))).filter((e=>"basket"!==e)),r=["tote-cart","tote.cart"],o=e,i=n.filter((e=>o.includes(e))),s=o.split("/");return!s.some((e=>r.some((t=>e.includes(t)))))&&(s.some((e=>n.some((t=>e.startsWith(t)||e.endsWith(t)))))||"basket"===s[s.length-1].toLowerCase()||i.length>1||1===i.length&&o.includes("shopping"))}function Pt(e,t){const n=["book"];return e.split("/").some((e=>n.some((t=>e.startsWith(t)||e.endsWith(t)))))&&null!=t.evaluate("//*[self::h1 or self::h2 or self::h3 or self::h4 or self::h5 or self::h6][contains(., 'Your Reservation') or contains(., 'Your reservation')]",t,null,XPathResult.ANY_TYPE,null)?.iterateNext()}async function Et(e){try{const t=await te({type:rt,payload:{shopId:e}});return t.payload.found&&t.payload.domain?t.payload.domain:null}catch{return null}}function St(e){try{const e=Array.from(document.querySelectorAll("script"));for(const t of e){if(t.dataset?.shopId&&(t.dataset?.shopId?.startsWith("gid")||t.src.includes("shopify"))){const e=parseInt(t.dataset.shopId.replace("gid://shopify/Shop/",""));if(!Number.isNaN(e)&&e>0)return e}const e=t.textContent||"";if(e.includes("ShopifyAnalytics")&&e.includes("shopId")){const t=e.match(/shopId['"]*:\s*['"]*(\d+)['"]*[,}]/);if(t&&t[1]){const e=parseInt(t[1]);if(!Number.isNaN(e)&&e>0)return e}}}const t=document.querySelector("[data-shop-id]");if(t instanceof HTMLElement){const{shopId:e}=t.dataset;if(e){const t=parseInt(e);if(!Number.isNaN(t)&&t>0)return t}}const n=window?.ShopifyAnalytics?.lib?.trekkie?.defaultAttributes?.shopId;return n&&parseInt(n)||0}catch(t){return e.error("Error accessing ShopifyAnalytics:",t),0}}function Tt(){try{if(!window.location.href.startsWith("https://shop.app"))return 0;const e=document?.head?.querySelector('meta[name="store"][content]');if(!e)return 0;try{const t=JSON.parse(e.content);return t?.id||0}catch{return 0}}catch{return 0}}const Ot=J.getInstance();function Rt(e,t,n){try{const r=function(e){try{const t=e.split(".");return t.length>=2?t.slice(-2).join("."):e}catch(e){return Ot.error("Error extracting domain",e),""}}(n);Ot.debug("Checking merchant regex rules",{currentDomain:r,currentUrl:t});const o=e.merchantPopupRules.filter((e=>r.includes(e.domain)));if(0===o.length)return Ot.debug("No matching merchant rules found for domain",{currentDomain:r}),!1;for(const e of o)for(const n of e.rules)try{if(new RegExp(n.rule).test(t))return Ot.debug("Merchant regex rule matched",{merchant:e.name,rule:n.rule,currentUrl:t}),!0}catch(t){Ot.error("Invalid regex in merchant rule",{merchant:e.name,rule:n.rule,error:t})}return Ot.debug("No matching regex rules found",{currentUrl:t}),!1}catch(e){return Ot.error("Error in merchantRegexRule",e),!1}}function Dt(){const e=document.documentElement.lang,t=document.querySelector('meta[http-equiv="Content-Language"]')?.content,n=document.querySelector('link[rel="alternate"][hreflang]')?.getAttribute("hreflang"),r=navigator.language,o=e||t||n||r||"en";return"string"==typeof o?o.split("-")[0]:"en"}function It(e){return!0!==e.checkoutPopupOnlyShowLanguageMatch||"en"===Dt()}const Nt=(e,t=!1)=>e.length<2&&t?null:Array.from(e).filter((e=>!t||e.dataset.extensionId!==ee.runtime.id)).map((e=>e.dataset.extensionName)).join(",");const _t=e=>{const t=h((()=>({translate:e.translate()||(e=>""),getAllCharities:e.charities()||(()=>[])})));return N(Ne.Provider,{value:t,get children(){return e.children}})},Lt=J.getInstance(),Ft="countryCode",Mt=async()=>await We.get(Ft)||(async()=>{Lt.debug("detecting country");const e={method:"GET",headers:{"Content-Type":"application/json",Authorization:"Basic OTEzOTkxOnFlYmpaWF9DOGNRY0lxSHA4WTVjNGxzU1pRSlM2VW9MMExzTF9tbWs="}};try{const t=await fetch("https://geoip.maxmind.com/geoip/v2.1/country/me",e);if(Lt.debug("Received geolocation response",{status:t.status}),!t.ok)return void Lt.warn("Failed to get geolocation data",{status:t.status});const n=await t.json();if(!n)throw new Error("There was an error fetching geoip look up");return await We.set(Ft,n.country.iso_code),n.country.iso_code}catch(e){return void Lt.error("Failed to get geolocation data",{error:e})}})();var $t=F("<div class=gf-app>");function Gt(){const e=J.getInstance(),[t,n]=u(null),[r,o]=u(void 0),[i,s]=u(!1),[a,l]=u([]),[c,g]=u(),[d,p]=u({});f((async()=>{e.info("Mounting GfApp component");try{const i=await(async()=>{const e=await te({type:Ze,payload:{}});if(!e.payload.config)throw new Error("No checkout popup config found");return e.payload.config})();if(!i)return void e.error("No checkout popup config found");n(i),e.configure({enabled:!0,title:"Content - GfAdUnit",minLevel:i.checkoutPopupMinLogLevel??"error"}),function(e){if(!e?.shouldCheckSiteMatches)return;let t;(e?.siteMatchesRegex??[]).some((e=>{var n;return n=window.location.href,!(!new RegExp(e).test(n)||(t=e,0))}))&&t&&st.trackEvent(Y.checkoutPopupSiteMatches,{url:window.location.href,matchedRule:t,uts:Date.now()},!0)}(i);const a=Dt();v(a);const c=Ye();if(i.minVersion&&((e,t)=>{if(e===t)return!1;const n=e.split(".").map((e=>parseInt(e,10))),r=t.split(".").map((e=>parseInt(e,10)));for(let e=0;e<n.length;e++){if(n[e]<r[e])return!0;if(n[e]>r[e])return!1}return!1})(c,i.minVersion))return void e.debug(`Current version: ${c}. Minimum version ${i.minVersion} not met`);const g=await Mt()??"us",u=i.charities[g.toLowerCase()]??i.charities.us;if(p(u||{}),e.debug("Charities for current country",{currentCountry:g,charities:u}),!1===i.checkoutPopupMasterSwitch)return void e.debug("Checkout popup master switch is disabled");const d=document.getElementsByClassName("give-freely-root");let h=!1;d.length>1&&(e.debug("There is more than one gf extension installed"),d.item(0).dataset.extensionId!==ee.runtime.id&&(e.debug("Giving preference to the first gf extension injected in the DOM"),h=!0),e.debug("Providing this extension preference over the other installed extensions"));const{domain:m,rates:f}=await(async e=>{const{hostname:t}=window.location;e.debug("Checking if domain is active",{hostname:t});const n=await te({type:Qe,payload:{hostname:t}});return n.payload.isActive?(e.debug("Active domain",{domain:n.payload.domain}),e.debug("Merchant rates",{rates:n.payload.rates}),e.info("Domain and rates ({})ed successfully."),{isActive:!0,domain:n.payload.domain,rates:n.payload.rates}):{isActive:!1,domain:void 0,rates:[]}})(e);if(l(f),o(m),m)await function(e,t){const n=St(t)||Tt();return n>0&&function(e,t,n){if(e&&!(e<=0))try{te({type:nt,payload:{shopId:e,domain:t}}).catch((e=>{n.error("Error sending shop ID to background:",e)}))}catch(e){n.error("Error sending Shopify shop ID:",e)}}(n,e,t),n}(m,e);else{if("shop.app"!==window.location.hostname&&!window.location.hostname.endsWith(".shop.app"))return void s(!1);const t=window.location.pathname.split("/")[2];if(!t)return e.error("Shop ID not found"),void s(!1);const n=await Et(parseInt(t));if(!n)return e.error("Shop domain not found"),void s(!1);e.debug("Shop domain found",{shopDomain:n}),o(n)}const A=await(async e=>{const t=await We.get("popup_hide");if(!t)return e.debug("No expiry found in storage"),!1;const{popupHide:n}=t,r=!!n&&Date.now()<n;return e.debug("Is AdUnit Muted?",{isMuted:r,expiry:n}),r})(e);if(A)return;if(!r())return void s(!1);const x=await(async(e,t)=>{const{Domain:n}=t,r=window.location.href,{payload:o}=await te({type:et,payload:{activeDomain:n,url:r}});return!!o.result&&(e.info("Stand Down detected"),!0)})(e,r());if(x)return void s(!1);const b=t()?.anonymousActiveDomainLogging??!1,y=r()??void 0;y&&b&&!function(e){const t=`gfhv-${e}`;return!!sessionStorage.getItem(t)||(sessionStorage.setItem(t,"true"),!1)}(y.Domain)&&st.trackEvent(Y.checkoutPopupActiveDomain,{url:y.Domain});const w=setInterval((async()=>{e.debug("Checking checkout rules");const t=await(async e=>{const t=J.getInstance();t.configure({enabled:!0,title:"Content - checkoutRulesTest"});const n=new URL(globalThis.location.href),r=n.href,{hostname:o}=n;t.debug("Checking if popup should be shown",{currentUrl:r});const i=await async function(e){const t=St(e)||Tt();return!("shop.app"!==window.location.hostname&&!window.location.hostname.endsWith(".shop.app")||!(t>0)||!await Et(t))}(t),s=It(e)&&(kt(n.pathname.toLowerCase())||Pt(r,document)||Rt(e,r,o)||i);return t.debug("Popup show decision based on rules",{shouldShow:s,matchesCartRule:kt(n.pathname.toLowerCase()),matchesBookingRule:Pt(r,document),matchesShopPayRule:i,matchesMerchantRegexRule:Rt(e,r,o),matchesLanguageRule:It(e)}),s})(i);if(t&&h)return st.trackEvent(Y.checkoutPopupLooserExtension,{url:globalThis.window.location.href,winner:d.item(0).dataset.extensionName}),e.debug("Standing down because, another ad-unit extension will pop"),void clearInterval(w);s(t),t&&(e.debug("Should show popup based on checkout rules",{shouldShowResult:t}),st.trackEvent(Y.checkoutPopupShown,{url:globalThis.window.location.href,pageLanguage:a,looserCompetingExtensions:Nt(d,!0)}),clearInterval(w))}),2e3)}catch(t){s(!1),e.error("An error occurred in GfApp",{error:t})}}));const m=async(t,n)=>{e.info("Processing donation",{charity:t,domain:n.Domain});const r=await(async(e,t,n,r)=>{e.debug("Activating offer",{activeDomain:t,selectedCharity:r});const o=await ne({type:tt,payload:{activeDomain:t,originalUrl:n,selectedCharity:r}});return e.debug("Activate offer response",{response:o}),o})(e,n,window.location.href,{ein:t.ein,thirdPartyId:t.tpi});return e.debug("Activate offer response",{activationResponse:r}),st.trackEvent(r.payload.response?Y.checkoutPopupDonation:Y.checkoutPopupFailedActivation,{activeDomain:n.Domain,url:globalThis.window.location.href,charity:{ein:t.ein,tpi:t.tpi},rate:n.Merchant.MaxRate}),r.payload.response},A=async t=>{s(await(async(e,t)=>{try{e.info("Hiding ad",{days:t});const n=await ne({type:Xe,payload:{days:t??0}});return void 0!==t&&st.trackEvent(Y.checkoutPopupSupressed,{url:globalThis.window.location.href,days:t}),e.info("Hiding ad response",{hideResponse:n}),n.payload.ack?(e.debug("Ad hidden successfully"),!1):(e.warn("Failed to hide ad"),!0)}catch{return!1}})(e,t))},x=async e=>{st.trackEvent(Y.checkoutPopupOfferDetailsClicked,{action:e?"opened":"closed"})},v=async t=>{e.debug("Getting translation provider",{currentLanguage:t});const{translations:n,charities:r}=await async function(e,t){try{t&&t.debug("Getting language content",{languageCode:e});const n=await te({type:ot,payload:{lang:e}});return{translations:n.payload.translations,charities:n.payload.charities}}catch(n){return t&&t.error("Error getting language content",{error:n,languageCode:e}),{translations:null,charities:null}}}(t,e),o={translate:e=>n&&n[e]?n[e]:"",getAllCharities:()=>{const e=d();return Object.entries(e).map((([e,t])=>{const{ein:n}=t,o=r?.[n];if(!o)throw new Error(`Failed to find charity metadata for ein ${n}`);return{ein:n,tpi:o.tpi,title:o.title,order:parseInt(e,10),logo:o.logo,decorator:t.decorator,decoratorLeftStyle:t.decoratorLeftStyle,decoratorRightStyle:t.decoratorRightStyle}}))}};e.debug("Setting content provider with translations and charity functions"),g((()=>o))};return N(_t,{translate:()=>c()?.translate,charities:()=>c()?.getAllCharities,get children(){var n,o=$t();return U(o,(n=h((()=>!(!r()||!i()))),()=>n()&&N(Ct,{get checkoutPopupConf(){return t()},elementId:"give-freely-checkout-popup",get activeDomain(){return r()},get merchantRates(){return a()},onClose:A,onDonate:m,onOfferDetailsClick:x,logger:e}))),o}})}async function Ut(){const e=`give-freely-root-${ee.runtime.id}`;if(document.getElementById(e))return;const t=document.createElement("div");t.id=e,t.className="give-freely-root",t.style.display="block",t.dataset.extensionId=ee.runtime.id,t.dataset.extensionName=ee.runtime.getManifest().name||ee.runtime.id,document.body.appendChild(t);const n=t.attachShadow({mode:"open"}),r=document.createElement("div"),s=document.createElement("style");s.textContent='\n :host {\n all: initial;\n }\n\n .gf-scroll-remove::-webkit-scrollbar {\n border-radius-bottom-right: 15px;\n }\n\n button {\n cursor: pointer;\n transition: transform 0.1s ease;\n }\n\n button:active {\n transform: scale(0.98);\n }\n\n .give-freely-close-button:hover {\n opacity: 0.7;\n }\n\n input[type="radio"] {\n margin-right: 8px;\n }\n\n hr {\n border: none;\n border-top: 1px solid #e5e5e5;\n margin: 1em 0;\n }\n\n @media (max-width: 600px), (max-height: 480px) {\n #give-freely-checkout-popup {\n display: none !important;\n }\n }\n',n.appendChild(s),n.appendChild(r),function(e,t,n,r={}){let s;(function(e,t){const n=a,r=i,s=0===e.length,l=void 0===t?r:t,c=s?o:{owned:null,cleanups:null,context:l?l.context:null,owner:l},g=s?e:()=>e((()=>m((()=>O(c)))));i=c,a=null;try{return k(g,!0)}finally{a=n,i=r}})((r=>{s=r,t===document?e():U(t,e(),t.firstChild?null:void 0,n)}),r.owner)}((()=>N(Gt,{})),r)}export{ee as browser,Ut as initializeAdUnit};
|
|
1
|
+
const e={equals:(e,t)=>e===t};let t=P;const n=1,r=2,o={owned:null,cleanups:null,context:null,owner:null};var i=null;let s=null,a=null,l=null,c=null,g=0;function u(t,n){const r={value:t,observers:null,observerSlots:null,comparator:(n=n?Object.assign({},e,n):e).equals||void 0};return[v.bind(r),e=>("function"==typeof e&&(e=e(r.value)),b(r,e))]}function d(e,t,r){y(w(e,t,!1,n))}function p(e,r,o){t=E;const i=w(e,r,!1,n);i.user=!0,c?c.push(i):y(i)}function h(t,n,r){r=r?Object.assign({},e,r):e;const o=w(t,n,!0,0);return o.observers=null,o.observerSlots=null,o.comparator=r.equals||void 0,y(o),v.bind(o)}function m(e){if(null===a)return e();const t=a;a=null;try{return e()}finally{a=t}}function f(e){p((()=>m(e)))}function A(e){let t;return i&&i.context&&void 0!==(t=i.context[e.id])?t:e.defaultValue}function x(e){const t=h(e),n=h((()=>D(t())));return n.toArray=()=>{const e=n();return Array.isArray(e)?e:null!=e?[e]:[]},n}function v(){if(this.sources&&this.state)if(this.state===n)y(this);else{const e=l;l=null,k((()=>S(this)),!1),l=e}if(a){const e=this.observers?this.observers.length:0;a.sources?(a.sources.push(this),a.sourceSlots.push(e)):(a.sources=[this],a.sourceSlots=[e]),this.observers?(this.observers.push(a),this.observerSlots.push(a.sources.length-1)):(this.observers=[a],this.observerSlots=[a.sources.length-1])}return this.value}function b(e,t,r){let o=e.value;return e.comparator&&e.comparator(o,t)||(e.value=t,e.observers&&e.observers.length&&k((()=>{for(let t=0;t<e.observers.length;t+=1){const r=e.observers[t],o=s&&s.running;o&&s.disposed.has(r),(o?r.tState:r.state)||(r.pure?l.push(r):c.push(r),r.observers&&T(r)),o||(r.state=n)}if(l.length>1e6)throw l=[],new Error}),!1)),t}function y(e){if(!e.fn)return;O(e);const t=g;!function(e,t,r){let o;const s=i,l=a;a=i=e;try{o=e.fn(t)}catch(t){return e.pure&&(e.state=n,e.owned&&e.owned.forEach(O),e.owned=null),e.updatedAt=r+1,R(t)}finally{a=l,i=s}(!e.updatedAt||e.updatedAt<=r)&&(null!=e.updatedAt&&"observers"in e?b(e,o):e.value=o,e.updatedAt=r)}(e,e.value,t)}function w(e,t,r,s=n,a){const l={fn:e,state:s,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:i,context:i?i.context:null,pure:r};return null===i||i!==o&&(i.owned?i.owned.push(l):i.owned=[l]),l}function C(e){if(0===e.state)return;if(e.state===r)return S(e);if(e.suspense&&m(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<g);)e.state&&t.push(e);for(let o=t.length-1;o>=0;o--)if((e=t[o]).state===n)y(e);else if(e.state===r){const n=l;l=null,k((()=>S(e,t[0])),!1),l=n}}function k(e,n){if(l)return e();let r=!1;n||(l=[]),c?r=!0:c=[],g++;try{const n=e();return function(e){if(l&&(P(l),l=null),e)return;const n=c;c=null,n.length&&k((()=>t(n)),!1)}(r),n}catch(e){r||(c=null),l=null,R(e)}}function P(e){for(let t=0;t<e.length;t++)C(e[t])}function E(e){let t,n=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[n++]=r:C(r)}for(t=0;t<n;t++)C(e[t])}function S(e,t){e.state=0;for(let o=0;o<e.sources.length;o+=1){const i=e.sources[o];if(i.sources){const e=i.state;e===n?i!==t&&(!i.updatedAt||i.updatedAt<g)&&C(i):e===r&&S(i,t)}}}function T(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=r,n.pure?l.push(n):c.push(n),n.observers&&T(n))}}function O(e){let t;if(e.sources)for(;e.sources.length;){const t=e.sources.pop(),n=e.sourceSlots.pop(),r=t.observers;if(r&&r.length){const e=r.pop(),o=t.observerSlots.pop();n<r.length&&(e.sourceSlots[o]=n,r[n]=e,t.observerSlots[n]=o)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)O(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)O(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function R(e,t=i){const n=function(e){return e instanceof Error?e:new Error("string"==typeof e?e:"Unknown error",{cause:e})}(e);throw n}function D(e){if("function"==typeof e&&!e.length)return D(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const r=D(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function I(e,t){return function(t){let n;return d((()=>n=m((()=>(i.context={...i.context,[e]:t.value},x((()=>t.children)))))),void 0),n}}function N(e,t){return m((()=>e(t||{})))}function _(e){const t=e.keyed,n=h((()=>e.when),void 0,{equals:(e,n)=>t?e===n:!e==!n});return h((()=>{const r=n();if(r){const o=e.children;return"function"==typeof o&&o.length>0?m((()=>o(t?r:()=>{if(!m(n))throw"Stale read from <Show>.";return e.when}))):o}return e.fallback}),void 0,void 0)}const L="_$DX_DELEGATE";function F(e,t,n){let r;const o=()=>(r||(r=(()=>{const t=document.createElement("template");return t.innerHTML=e,t.content.firstChild})())).cloneNode(!0);return o.cloneNode=o,o}function M(e,t=window.document){const n=t[L]||(t[L]=new Set);for(let r=0,o=e.length;r<o;r++){const o=e[r];n.has(o)||(n.add(o),t.addEventListener(o,H))}}function $(e,t,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}function G(e,t,n){if(!t)return n?$(e,"style"):t;const r=e.style;if("string"==typeof t)return r.cssText=t;let o,i;for(i in"string"==typeof n&&(r.cssText=n=void 0),n||(n={}),t||(t={}),n)null==t[i]&&r.removeProperty(i),delete n[i];for(i in t)o=t[i],o!==n[i]&&(r.setProperty(i,o),n[i]=o);return n}function U(e,t,n,r){if(void 0===n||r||(r=[]),"function"!=typeof t)return B(e,t,r,n);d((r=>B(e,t(),r,n)),r)}function H(e){let t=e.target;const n=`$$${e.type}`,r=e.target,o=e.currentTarget,i=t=>Object.defineProperty(e,"target",{configurable:!0,value:t}),s=()=>{const r=t[n];if(r&&!t.disabled){const o=t[`${n}Data`];if(void 0!==o?r.call(t,o,e):r.call(t,e),e.cancelBubble)return}return t.host&&"string"!=typeof t.host&&!t.host._$host&&t.contains(e.target)&&i(t.host),!0},a=()=>{for(;s()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get:()=>t||document}),e.composedPath){const n=e.composedPath();i(n[0]);for(let e=0;e<n.length-2&&(t=n[e],s());e++){if(t._$host){t=t._$host,a();break}if(t.parentNode===o)break}}else a();i(r)}function B(e,t,n,r,o){for(;"function"==typeof n;)n=n();if(t===n)return n;const i=typeof t,s=void 0!==r;if(e=s&&n[0]&&n[0].parentNode||e,"string"===i||"number"===i){if("number"===i&&(t=t.toString())===n)return n;if(s){let o=n[0];o&&3===o.nodeType?o.data!==t&&(o.data=t):o=document.createTextNode(t),n=W(e,n,r,o)}else n=""!==n&&"string"==typeof n?e.firstChild.data=t:e.textContent=t}else if(null==t||"boolean"===i)n=W(e,n,r);else{if("function"===i)return d((()=>{let o=t();for(;"function"==typeof o;)o=o();n=B(e,o,n,r)})),()=>n;if(Array.isArray(t)){const i=[],a=n&&Array.isArray(n);if(j(i,t,n,o))return d((()=>n=B(e,i,n,r,!0))),()=>n;if(0===i.length){if(n=W(e,n,r),s)return n}else a?0===n.length?K(e,i,r):function(e,t,n){let r=n.length,o=t.length,i=r,s=0,a=0,l=t[o-1].nextSibling,c=null;for(;s<o||a<i;)if(t[s]!==n[a]){for(;t[o-1]===n[i-1];)o--,i--;if(o===s){const t=i<r?a?n[a-1].nextSibling:n[i-a]:l;for(;a<i;)e.insertBefore(n[a++],t)}else if(i===a)for(;s<o;)c&&c.has(t[s])||t[s].remove(),s++;else if(t[s]===n[i-1]&&n[a]===t[o-1]){const r=t[--o].nextSibling;e.insertBefore(n[a++],t[s++].nextSibling),e.insertBefore(n[--i],r),t[o]=n[i]}else{if(!c){c=new Map;let e=a;for(;e<i;)c.set(n[e],e++)}const r=c.get(t[s]);if(null!=r)if(a<r&&r<i){let l,g=s,u=1;for(;++g<o&&g<i&&null!=(l=c.get(t[g]))&&l===r+u;)u++;if(u>r-a){const o=t[s];for(;a<r;)e.insertBefore(n[a++],o)}else e.replaceChild(n[a++],t[s++])}else s++;else t[s++].remove()}}else s++,a++}(e,n,i):(n&&W(e),K(e,i));n=i}else if(t.nodeType){if(Array.isArray(n)){if(s)return n=W(e,n,r,t);W(e,n,null,t)}else null!=n&&""!==n&&e.firstChild?e.replaceChild(t,e.firstChild):e.appendChild(t);n=t}}return n}function j(e,t,n,r){let o=!1;for(let i=0,s=t.length;i<s;i++){let s,a=t[i],l=n&&n[e.length];if(null==a||!0===a||!1===a);else if("object"==(s=typeof a)&&a.nodeType)e.push(a);else if(Array.isArray(a))o=j(e,a,l)||o;else if("function"===s)if(r){for(;"function"==typeof a;)a=a();o=j(e,Array.isArray(a)?a:[a],Array.isArray(l)?l:[l])||o}else e.push(a),o=!0;else{const t=String(a);l&&3===l.nodeType&&l.data===t?e.push(l):e.push(document.createTextNode(t))}}return o}function K(e,t,n=null){for(let r=0,o=t.length;r<o;r++)e.insertBefore(t[r],n)}function W(e,t,n,r){if(void 0===n)return e.textContent="";const o=r||document.createTextNode("");if(t.length){let r=!1;for(let i=t.length-1;i>=0;i--){const s=t[i];if(o!==s){const t=s.parentNode===e;r||i?t&&s.remove():t?e.replaceChild(o,s):e.insertBefore(o,n)}else r=!0}}else e.insertBefore(o,n);return[o]}class V{log({level:e,message:t,timestamp:n,data:r,title:o}){const i="debug"===e?"log":e,s=o?`[${o}]`:"";void 0!==r?console[i](`[${n}] - ${V.LOGGER_PREFIX} ${s} ${t}`,r):console[i](`[${n}] - ${V.LOGGER_PREFIX} ${s} ${t}`)}}var Y,z;V.LOGGER_PREFIX="[GFAdUnit] -",function(e){e.checkoutPopupShown="CHECKOUT-POPUP-SHOWN",e.checkoutPopupNotShown="CHECKOUT-POPUP-NOT-SHOWN",e.checkoutPopupSupressed="CHECKOUT-POPUP-SUPRESSED",e.checkoutPopupDonation="CHECKOUT-POPUP-DONATION",e.checkoutPopupFailedActivation="CHECKOUT-POPUP-FAILED-ACTIVATION",e.checkoutPopupPurchaseConfirmed="CHECKOUT-POPUP-PURCHASE-CONFIRMED",e.checkoutPopupHealthCheck="CHECKOUT-POPUP-HEALTH-CHECK",e.checkouPopupActivationFailed="CHECKOUT-POPUP-ACTIVATION-FAILED",e.checkoutPopupOfferDetailsClicked="CHECKOUT-POPUP-OFFER-DETAILS-CLICKED",e.checkoutPopupWhyAmISeeingThisClicked="CHECKOUT-POPUP-WHY-AM-I-SEEING-THIS-CLICKED",e.checkoutPopupLooserExtension="CHECKOUT-POPUP-LOOSER-EXTENSION",e.checkoutPopupActiveDomain="CHECKOUT-POPUP-ACTIVE-DOMAIN",e.checkoutPopupSiteMatches="CHECKOUT-POPUP-SITE-MATCHES"}(Y||(Y={})),function(e){e.adUnitLog="ADUNIT-LOG"}(z||(z={}));const q=["debug","info","warn","error"];class J{constructor(e){this.config={minLevel:e?.minLevel??"debug",enabled:e?.enabled??!1,transports:e?.transports??[new V],title:e?.title??""}}static getInstance(e){return J.instance||(J.instance=new J(e)),J.instance}configure(e){this.config={...this.config,...e}}shouldLog(e){return!!this.config.enabled&&q.indexOf(e)>=q.indexOf(this.config.minLevel)}createLogMessage(e,t,n){return{level:e,version:"1.6.3",message:t,timestamp:(new Date).toISOString(),data:n,title:this.config.title}}log(e,t,n){if(!this.shouldLog(e))return;const r=this.createLogMessage(e,t,n);this.config.transports.forEach((e=>e.log(r)))}debug(e,t){this.log("debug",e,t)}info(e,t){this.log("info",e,t)}warn(e,t){this.log("warn",e,t)}error(e,t){this.log("error",e,t)}addTransport(e){this.config.transports.push(e)}clearTransports(){this.config.transports=[]}disable(){this.config.enabled=!1}enable(){this.config.enabled=!0}}const X=3,Z=e=>1e3*e;async function Q(e,t={}){const{maxAttempts:n=X,delayFn:r=Z}=t;let o=null;for(let t=1;t<=n;t+=1)try{return await e()}catch(e){o=e,t<n&&await new Promise((e=>{setTimeout(e,r(t))}))}throw o||new Error("Operation failed after multiple attempts")}const ee=chrome;async function te(e,t){return new Promise(((n,r)=>{try{const o=t=>chrome.runtime.lastError?r({error:chrome.runtime.lastError,message:e}):n(t);t?.tabId||ee.runtime.sendMessage(e,o)}catch(e){r(e)}}))}async function ne(e,t,n){return Q((()=>te(e,t)),{maxAttempts:X,delayFn:Z})}const re={display:"block",position:"fixed",top:"0%",left:"100%",width:"500px",height:"520px","margin-left":"-560px","margin-top":"50px",padding:"2px 5px","background-color":"white",border:"1px solid black","border-radius":"10px","box-shadow":"0 2px 10px rgba(0, 0, 0, 0.1)","z-index":"2147483647","font-family":"Arial","line-height":"1","vertical-align":"baseline","box-sizing":"border-box",color:"rgb(34, 34, 34)","@media (max-width: 600px), (max-height: 480px)":{display:"none !important"}},oe={height:"100%","overflow-x":"hidden","overlfow-y":"auto",position:"relative",padding:"0px 15px"},ie={},se={display:"flex","align-items":"center","margin-bottom":"10px"},ae={flex:"1","font-size":"24px","font-weight":"700","margin-top":"20px","margin-bottom":"0px"},le={background:"none",border:"none",padding:"4px 8px",color:"#666464","font-size":"38px",cursor:"pointer","line-height":"1"},ce={color:"black","margin-top":"20px","max-width":"40%"},ge={color:"gray",cursor:"default","pointer-events":"none","text-decoration":"none"},ue={"font-size":"18px","font-weight":"400","margin-top":"20px","margin-bottom":"0px"},de={display:"flex",gap:"10px",width:"100%","margin-top":"20px","margin-bottom":"20px","flex-wrap":"wrap","justify-content":"space-between"},pe={width:"28%",position:"relative",display:"flex","flex-direction":"column","align-items":"center",background:"none",border:"1px solid #ccc","border-radius":"5px",padding:"5px",gap:"5px","text-align":"center","font-size":"14px",cursor:"pointer",transition:"background-color 0.2s ease"},he={color:"white","background-color":"lightgray",cursor:"default","pointer-events":"none"},me={"max-width":"120px","max-height":"70px","margin-bottom":"5px","object-fit":"contain"},fe={"background-color":"#FFD812",cursor:"pointer","border-radius":"8px",padding:"8px",color:"white","min-width":"100px",border:"0","font-weight":"600",width:"100%"},Ae={display:"flex","flex-direction":"column",gap:"10px",width:"100%","color-scheme":"light"},xe={display:"flex","align-items":"center",gap:"5px",border:"1px solid #ddd",padding:"15px","border-radius":"5px","font-weight":"600",cursor:"pointer","margin-bottom":"8px"},ve={"text-align":"right"},be={background:"none",border:"none",color:"blue","text-decoration":"underline",padding:"0",cursor:"pointer","margin-bottom":"15px"},ye={display:"flex","justify-content":"space-between",margin:"20px 0px 10px 0px","font-size":"14px"},we={margin:"5px 0px 5px 0px","font-size":"14px","text-align":"center"},Ce={color:"#666464","text-decoration":"underline"},ke={color:"rgb(102, 100, 100)","text-decoration":"underline",margin:"0",cursor:"pointer"},Pe={width:"100%","background-color":"#f2f2f2",border:"1px solid black","border-radius":"10px","border-top":"1px solid #bbb7b7","margin-top":"10px","margin-bottom":"20px","box-sizing":"border-box"},Ee={padding:"0 5px 0 10px",width:"100%","font-size":"12px","box-sizing":"border-box"},Se={display:"grid","grid-template-columns":"4fr 1fr","padding-right":"15px","padding-bottom":"5px"},Te={color:"#000","margin-bottom":"4px"},Oe={"font-size":"14px",color:"#555","text-align":"right"},Re=(e,t)=>{let n=parseFloat(t);return"FLAT"===e&&(n*=.75),((e,t)=>{let n=parseFloat(t);return n<1&&(n=1),n=Math.floor(n),"PERCENTAGE"===e?`${n}%`:`$${n}`})(e,n.toString())};var De=F("<span>");function Ie(e){return t=De(),d((()=>{return t.innerHTML=(n=e.title,r=e.activeDomain,n.replace("{0}",Re(r.Merchant.MaxRate?.Kind,r.Merchant.MaxRate?.Amount??"0")));var n,r})),t;var t}const Ne=function(){const e=Symbol("context");return{id:e,Provider:I(e),defaultValue:()=>({translate:e=>"",getAllCharities:()=>[]})}}(),_e=Ne,Le=()=>{const e=A(_e)();if(!e)throw new Error("Content provider context is undefined");return t=>e.translate(t)};class Fe{static formatMessage(e,...t){return e.replace(/{(\d+)}/g,((e,n)=>{const r=Number(n);return void 0!==t[r]?String(t[r]):`{${r}}`}))}}var Me=F("<div>"),$e=F("<div><div class=gf-offer-details><p><span></span></p><p><span></span></p><p><span></span></p><p><span></span></p><p><span></span></p><p><a target=_blank rel=noreferrer>"),Ge=F("<div class=gf-offer-details-rate-item><div></div><div>");const Ue=e=>{const t=Le();return n=$e(),o=(r=n.firstChild).firstChild,i=o.firstChild,s=o.nextSibling,a=s.firstChild,l=s.nextSibling,c=l.firstChild,g=l.nextSibling,u=g.firstChild,p=g.nextSibling,h=p.firstChild,m=p.nextSibling.firstChild,U(r,N(_,{get when(){return!!e.merchantRateDetail?.length},get children(){var t=Me();return U(t,(()=>e.merchantRateDetail?.map((e=>{return t=Ge(),n=t.firstChild,r=n.nextSibling,U(n,(()=>e.Name||"")),U(r,(()=>((e,t=1,n=1)=>{const r=e.BoostedOffer??null;let o=parseFloat(e?.Amount??"");if(r?.EndDate&&new Date(r.EndDate)<new Date&&(o=parseFloat(r.OriginalMaxRate)),Number.isNaN(o))return"";const i=o*t;return"PERCENTAGE"===e?.Kind?`${i.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:n})}%`:"FLAT"===e?.Kind?i.toLocaleString("en-US",{style:"currency",currency:e.Currency}):""})(e))),d((e=>{var o=Se,i=Te,s=Oe;return e.e=G(t,o,e.e),e.t=G(n,i,e.t),e.a=G(r,s,e.a),e}),{e:void 0,t:void 0,a:void 0}),t;var t,n,r})))),t}}),g),U(m,(()=>t("offerDetails.termsAndConditions"))),d((o=>{var s=Pe,l=Ee,g=t("offerDetails.intro"),d=t("offerDetails.eligible"),p=e.parsedMaxRate?Fe.formatMessage(t("offerDetails.donationRatesWithValue"),e.parsedMaxRate):Fe.formatMessage(t("offerDetails.donationRates")),f=t("offerDetails.donationAmounts"),A=t("offerDetails.donationTiming"),x=Ce,v=e.termsUrl;return o.e=G(n,s,o.e),o.t=G(r,l,o.t),g!==o.a&&(i.innerHTML=o.a=g),d!==o.o&&(a.innerHTML=o.o=d),p!==o.i&&(c.innerHTML=o.i=p),f!==o.n&&(u.innerHTML=o.n=f),A!==o.s&&(h.innerHTML=o.s=A),o.h=G(m,x,o.h),v!==o.r&&$(m,"href",o.r=v),o}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),n;var n,r,o,i,s,a,l,c,g,u,p,h,m};function He(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var Be={exports:{}};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self&&self,function(e){if(!(globalThis.chrome&&globalThis.chrome.runtime&&globalThis.chrome.runtime.id))throw new Error("This script should only be loaded in a browser extension.");if(globalThis.browser&&globalThis.browser.runtime&&globalThis.browser.runtime.id)e.exports=globalThis.browser;else{const t="The message port closed before a response was received.",n=e=>{const n={alarms:{clear:{minArgs:0,maxArgs:1},clearAll:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getAll:{minArgs:0,maxArgs:0}},bookmarks:{create:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},getChildren:{minArgs:1,maxArgs:1},getRecent:{minArgs:1,maxArgs:1},getSubTree:{minArgs:1,maxArgs:1},getTree:{minArgs:0,maxArgs:0},move:{minArgs:2,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeTree:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}},browserAction:{disable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},enable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},getBadgeBackgroundColor:{minArgs:1,maxArgs:1},getBadgeText:{minArgs:1,maxArgs:1},getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},openPopup:{minArgs:0,maxArgs:0},setBadgeBackgroundColor:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setBadgeText:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},browsingData:{remove:{minArgs:2,maxArgs:2},removeCache:{minArgs:1,maxArgs:1},removeCookies:{minArgs:1,maxArgs:1},removeDownloads:{minArgs:1,maxArgs:1},removeFormData:{minArgs:1,maxArgs:1},removeHistory:{minArgs:1,maxArgs:1},removeLocalStorage:{minArgs:1,maxArgs:1},removePasswords:{minArgs:1,maxArgs:1},removePluginData:{minArgs:1,maxArgs:1},settings:{minArgs:0,maxArgs:0}},commands:{getAll:{minArgs:0,maxArgs:0}},contextMenus:{remove:{minArgs:1,maxArgs:1},removeAll:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},cookies:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:1,maxArgs:1},getAllCookieStores:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},devtools:{inspectedWindow:{eval:{minArgs:1,maxArgs:2,singleCallbackArg:!1}},panels:{create:{minArgs:3,maxArgs:3,singleCallbackArg:!0},elements:{createSidebarPane:{minArgs:1,maxArgs:1}}}},downloads:{cancel:{minArgs:1,maxArgs:1},download:{minArgs:1,maxArgs:1},erase:{minArgs:1,maxArgs:1},getFileIcon:{minArgs:1,maxArgs:2},open:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},pause:{minArgs:1,maxArgs:1},removeFile:{minArgs:1,maxArgs:1},resume:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},extension:{isAllowedFileSchemeAccess:{minArgs:0,maxArgs:0},isAllowedIncognitoAccess:{minArgs:0,maxArgs:0}},history:{addUrl:{minArgs:1,maxArgs:1},deleteAll:{minArgs:0,maxArgs:0},deleteRange:{minArgs:1,maxArgs:1},deleteUrl:{minArgs:1,maxArgs:1},getVisits:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1}},i18n:{detectLanguage:{minArgs:1,maxArgs:1},getAcceptLanguages:{minArgs:0,maxArgs:0}},identity:{launchWebAuthFlow:{minArgs:1,maxArgs:1}},idle:{queryState:{minArgs:1,maxArgs:1}},management:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},getSelf:{minArgs:0,maxArgs:0},setEnabled:{minArgs:2,maxArgs:2},uninstallSelf:{minArgs:0,maxArgs:1}},notifications:{clear:{minArgs:1,maxArgs:1},create:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:0},getPermissionLevel:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},pageAction:{getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},hide:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},permissions:{contains:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},request:{minArgs:1,maxArgs:1}},runtime:{getBackgroundPage:{minArgs:0,maxArgs:0},getPlatformInfo:{minArgs:0,maxArgs:0},openOptionsPage:{minArgs:0,maxArgs:0},requestUpdateCheck:{minArgs:0,maxArgs:0},sendMessage:{minArgs:1,maxArgs:3},sendNativeMessage:{minArgs:2,maxArgs:2},setUninstallURL:{minArgs:1,maxArgs:1}},sessions:{getDevices:{minArgs:0,maxArgs:1},getRecentlyClosed:{minArgs:0,maxArgs:1},restore:{minArgs:0,maxArgs:1}},storage:{local:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},managed:{get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1}},sync:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}}},tabs:{captureVisibleTab:{minArgs:0,maxArgs:2},create:{minArgs:1,maxArgs:1},detectLanguage:{minArgs:0,maxArgs:1},discard:{minArgs:0,maxArgs:1},duplicate:{minArgs:1,maxArgs:1},executeScript:{minArgs:1,maxArgs:2},get:{minArgs:1,maxArgs:1},getCurrent:{minArgs:0,maxArgs:0},getZoom:{minArgs:0,maxArgs:1},getZoomSettings:{minArgs:0,maxArgs:1},goBack:{minArgs:0,maxArgs:1},goForward:{minArgs:0,maxArgs:1},highlight:{minArgs:1,maxArgs:1},insertCSS:{minArgs:1,maxArgs:2},move:{minArgs:2,maxArgs:2},query:{minArgs:1,maxArgs:1},reload:{minArgs:0,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeCSS:{minArgs:1,maxArgs:2},sendMessage:{minArgs:2,maxArgs:3},setZoom:{minArgs:1,maxArgs:2},setZoomSettings:{minArgs:1,maxArgs:2},update:{minArgs:1,maxArgs:2}},topSites:{get:{minArgs:0,maxArgs:0}},webNavigation:{getAllFrames:{minArgs:1,maxArgs:1},getFrame:{minArgs:1,maxArgs:1}},webRequest:{handlerBehaviorChanged:{minArgs:0,maxArgs:0}},windows:{create:{minArgs:0,maxArgs:1},get:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:1},getCurrent:{minArgs:0,maxArgs:1},getLastFocused:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}}};if(0===Object.keys(n).length)throw new Error("api-metadata.json has not been included in browser-polyfill");class r extends WeakMap{constructor(e,t=void 0){super(t),this.createItem=e}get(e){return this.has(e)||this.set(e,this.createItem(e)),super.get(e)}}const o=(t,n)=>(...r)=>{e.runtime.lastError?t.reject(new Error(e.runtime.lastError.message)):n.singleCallbackArg||r.length<=1&&!1!==n.singleCallbackArg?t.resolve(r[0]):t.resolve(r)},i=e=>1==e?"argument":"arguments",s=(e,t,n)=>new Proxy(t,{apply:(t,r,o)=>n.call(r,e,...o)});let a=Function.call.bind(Object.prototype.hasOwnProperty);const l=(e,t={},n={})=>{let r=Object.create(null),c={has:(t,n)=>n in e||n in r,get(c,g,u){if(g in r)return r[g];if(!(g in e))return;let d=e[g];if("function"==typeof d)if("function"==typeof t[g])d=s(e,e[g],t[g]);else if(a(n,g)){let t=((e,t)=>function(n,...r){if(r.length<t.minArgs)throw new Error(`Expected at least ${t.minArgs} ${i(t.minArgs)} for ${e}(), got ${r.length}`);if(r.length>t.maxArgs)throw new Error(`Expected at most ${t.maxArgs} ${i(t.maxArgs)} for ${e}(), got ${r.length}`);return new Promise(((i,s)=>{if(t.fallbackToNoCallback)try{n[e](...r,o({resolve:i,reject:s},t))}catch(o){console.warn(`${e} API method doesn't seem to support the callback parameter, falling back to call it without a callback: `,o),n[e](...r),t.fallbackToNoCallback=!1,t.noCallback=!0,i()}else t.noCallback?(n[e](...r),i()):n[e](...r,o({resolve:i,reject:s},t))}))})(g,n[g]);d=s(e,e[g],t)}else d=d.bind(e);else if("object"==typeof d&&null!==d&&(a(t,g)||a(n,g)))d=l(d,t[g],n[g]);else{if(!a(n,"*"))return Object.defineProperty(r,g,{configurable:!0,enumerable:!0,get:()=>e[g],set(t){e[g]=t}}),d;d=l(d,t[g],n["*"])}return r[g]=d,d},set:(t,n,o,i)=>(n in r?r[n]=o:e[n]=o,!0),defineProperty:(e,t,n)=>Reflect.defineProperty(r,t,n),deleteProperty:(e,t)=>Reflect.deleteProperty(r,t)},g=Object.create(e);return new Proxy(g,c)},c=e=>({addListener(t,n,...r){t.addListener(e.get(n),...r)},hasListener:(t,n)=>t.hasListener(e.get(n)),removeListener(t,n){t.removeListener(e.get(n))}}),g=new r((e=>"function"!=typeof e?e:function(t){const n=l(t,{},{getContent:{minArgs:0,maxArgs:0}});e(n)})),u=new r((e=>"function"!=typeof e?e:function(t,n,r){let o,i,s=!1,a=new Promise((e=>{o=function(t){s=!0,e(t)}}));try{i=e(t,n,o)}catch(e){i=Promise.reject(e)}const l=!0!==i&&((c=i)&&"object"==typeof c&&"function"==typeof c.then);var c;if(!0!==i&&!l&&!s)return!1;return(l?i:a).then((e=>{r(e)}),(e=>{let t;t=e&&(e instanceof Error||"string"==typeof e.message)?e.message:"An unexpected error occurred",r({__mozWebExtensionPolyfillReject__:!0,message:t})})).catch((e=>{console.error("Failed to send onMessage rejected reply",e)})),!0})),d=({reject:n,resolve:r},o)=>{e.runtime.lastError?e.runtime.lastError.message===t?r():n(new Error(e.runtime.lastError.message)):o&&o.__mozWebExtensionPolyfillReject__?n(new Error(o.message)):r(o)},p=(e,t,n,...r)=>{if(r.length<t.minArgs)throw new Error(`Expected at least ${t.minArgs} ${i(t.minArgs)} for ${e}(), got ${r.length}`);if(r.length>t.maxArgs)throw new Error(`Expected at most ${t.maxArgs} ${i(t.maxArgs)} for ${e}(), got ${r.length}`);return new Promise(((e,t)=>{const o=d.bind(null,{resolve:e,reject:t});r.push(o),n.sendMessage(...r)}))},h={devtools:{network:{onRequestFinished:c(g)}},runtime:{onMessage:c(u),onMessageExternal:c(u),sendMessage:p.bind(null,"sendMessage",{minArgs:1,maxArgs:3})},tabs:{sendMessage:p.bind(null,"sendMessage",{minArgs:2,maxArgs:3})}},m={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return n.privacy={network:{"*":m},services:{"*":m},websites:{"*":m}},l(e,h,n)};e.exports=n(chrome)}}(Be);var je=He(Be.exports);const Ke="GIVE_FREELY_",We={async get(e){const t=`${Ke}${e}`;return(await je.storage.local.get(t))[t]||null},async set(e,t){const n=`${Ke}${e}`;await je.storage.local.set({[n]:t})},async remove(e){const t=Array.isArray(e)?e.map((e=>`${Ke}${e}`)):`${Ke}${e}`;await je.storage.local.remove(t)}},Ve="version",Ye=()=>String("1.6.3"),ze="https://cdn.givefreely.com/adunit/behavioral/";class qe{constructor(e){this.partnerApiKey=e,this.partnerConfig=null,this.globalConfig=null,this.lastConfigRefresh=0,this.CONFIG_REFRESH_INTERVAL=300,this.PARTNER_CONFIG_STORAGE_KEY="gf_partner_config",this.GLOBAL_CONFIG_STORAGE_KEY="gf_global_config"}getRetryOptions(){return{delayFn:e=>1e3*e,maxAttempts:3}}async fetchAndUpdatePartnerConfig(){const e=await Q((async()=>{const e=await fetch(`${ze}${this.partnerApiKey}.json`,{cache:"no-store"});if(!e.ok)throw new Error(`Failed to fetch partner config: ${e.statusText}`);return e.json()}),this.getRetryOptions()),t={config:e,lastRefresh:Date.now()};return await We.set(this.PARTNER_CONFIG_STORAGE_KEY,t),e}async fetchAndUpdateGlobalConfig(){const e=await Q((async()=>{const e=await fetch(`${ze}global.json`,{cache:"no-store"});if(!e.ok)throw new Error(`Failed to fetch global config: ${e.statusText}`);return e.json()}),this.getRetryOptions()),t={config:e,lastRefresh:Date.now()};return await We.set(this.GLOBAL_CONFIG_STORAGE_KEY,t),e}async getConfig(e=!1){const t=Date.now(),n=await We.get(this.PARTNER_CONFIG_STORAGE_KEY),r=await We.get(this.GLOBAL_CONFIG_STORAGE_KEY);this.partnerConfig=n?.config||null,this.globalConfig=r?.config||null,this.lastConfigRefresh=Math.max(n?.lastRefresh||0,r?.lastRefresh||0);let o=!1;e&&(o=await(async(e=!0)=>{const t=await We.get(Ve),n=await Ye(),r=t!==n;var o;return e&&r&&await(o=n,We.set(Ve,o)),r})());const i=this.partnerConfig?.configRefreshInterval||this.globalConfig?.configRefreshInterval||this.CONFIG_REFRESH_INTERVAL;if(o||!this.partnerConfig||!this.globalConfig||t-this.lastConfigRefresh>1e3*i)try{const[e,n]=await Promise.all([this.fetchAndUpdatePartnerConfig(),this.fetchAndUpdateGlobalConfig()]);this.partnerConfig=e,this.globalConfig=n,this.lastConfigRefresh=t}catch(e){if(!this.partnerConfig||!this.globalConfig)throw e}const s=this.mergeConfigs(JSON.parse(JSON.stringify(this.globalConfig)),JSON.parse(JSON.stringify(this.partnerConfig)));return s&&((e,t,n)=>{const r=[...t.merchantExclusions??[],...n.merchantExclusions??[]];e.merchantExclusions=r})(s,this.globalConfig,this.partnerConfig),s}async clearCache(){await Promise.all([We.remove(this.PARTNER_CONFIG_STORAGE_KEY),We.remove(this.GLOBAL_CONFIG_STORAGE_KEY)]),this.partnerConfig=null,this.globalConfig=null,this.lastConfigRefresh=0}mergeConfigs(e,t){if(!t)return e;if(!e)return t;const n={...e};return Object.keys(t).forEach((r=>{if(!Object.prototype.hasOwnProperty.call(t,r))return;const o=e[r],i=t[r];void 0!==i&&(Array.isArray(i)?n[r]=[...i]:n[r]=null===i||"object"!=typeof i||null===o||"object"!=typeof o?i:this.mergeConfigs(o,i))})),n}getStoredState(e){return e?{config:e.config,lastRefresh:e.lastRefresh}:{config:null,lastRefresh:0}}}const Je="TRACK_EVENT",Xe="GF_HIDE_POPUP",Ze="GF_GET_POPUP_CONFIG",Qe="GF_IS_ACTIVE_DOMAIN",et="GF_SHOULD_STAND_DOWN",tt="GF_ACTIVATE_OFFER",nt="GF_STORE_SHOPIFY_SHOP_ID",rt="GF_GET_DOMAIN_BY_SHOP_ID",ot="GF_GET_LANGUAGE_CONTENT",it={ein:"0",tpi:"0"};class st{constructor(e,t,n=60){this._config=null,this.track=async(e,t,n,r=!1)=>{null===this._config&&(this._config=await new qe(this._partnerApiKey).getConfig());const o={partner:`adUnit_${this._partnerApiKey}`,eventType:e,eventData:{userId:r?void 0:this._userService?.user?.id,libVersion:Ye(),wfDeviceId:t,...n}};try{const e=JSON.stringify(o);return await this.shouldBroadcastEvent(e)?(await fetch(this._config.eventsUrl,{headers:{"Content-Type":"application/json"},method:"POST",body:e,cache:"no-store"}),await this.pushEventToHistory(e),!0):(this._logger.info("This event has already been broadcasted during the past hour",o),!1)}catch(e){return this._logger.info("Something unexpected happened when dispatching a gf event",{error:e,event:o}),!1}},this.getEventsHistory=async()=>{const{GF_AD_EVENT_HISTORY:e}=await ee.storage.local.get({GF_AD_EVENT_HISTORY:""}),t=(e=>{const t=new Date;return t.setTime(t.getTime()+60*e*1e3),t.getTime()})(-this._debounceWindowInMinutes),n=(e||[]).filter((e=>e.createdAt>t));return await ee.storage.local.set({GF_AD_EVENT_HISTORY:n}),n},this.shouldBroadcastEvent=async e=>!(await this.getEventsHistory()).some((t=>t.payload===e)),this.pushEventToHistory=async e=>{const t=await this.getEventsHistory();t.push({createdAt:Date.now(),payload:e}),await ee.storage.local.set({GF_AD_EVENT_HISTORY:t})},this._partnerApiKey=e,this._userService=t,this._debounceWindowInMinutes=n,this._logger=J.getInstance({title:"Analytics"})}}function at(e,t,n){return e?{...t,...n}:t}st.trackEvent=async(e,t,n=!1)=>{await te({type:Je,payload:{eventType:e,eventData:t,anonymous:n}})};var lt=F("<a href=#!>"),ct=F("<button class=give-freely-close-button aria-label=Close>×"),gt=F('<div><div><div></div></div><hr><div></div><div><div><div><br></div><button aria-label="Don\'t show again"></button></div></div><div><p></p><a class=give-freely-footer-link target=_blank rel="noopener noreferrer">'),ut=F("<div><div><img><span></span></div><button>"),dt=F("<div>");function pt(e){const[t,n]=u(!1),[r,o]=u(null),i=Le(),s=(()=>{const e=A(Ne)();if(!e)throw new Error("Content provider context is undefined");return()=>e.getAllCharities()})();p((()=>{t()&&e.mainContainerRef&&e.mainContainerRef.scroll({top:e.mainContainerRef.scrollHeight,behavior:"smooth"})})),p((()=>{const t=r();t&&e.onCharitySelect(t.charity,t.closeOnDonation?e.checkoutPopupConf.checkoutPopupActivateAndCloseSkipSuccess:void 0)}));const a=(e,t)=>o({charity:e,closeOnDonation:t}),l=()=>!!r()?.charity;return[(g=gt(),m=g.firstChild,f=m.firstChild,x=m.nextSibling.nextSibling,v=x.nextSibling,b=v.firstChild,y=b.firstChild,w=y.nextSibling,C=v.nextSibling,k=C.firstChild,P=k.nextSibling,U(m,N(_,{get when(){return e.checkoutPopupConf.checkoutPopupActivateAndClose},get children(){var e=lt();return e.$$click=()=>a(it,!0),d((t=>{var n=at(l(),ce,ge),r=i("main.activateAndClose");return t.e=G(e,n,t.e),r!==t.t&&(e.innerHTML=t.t=r),t}),{e:void 0,t:void 0}),e}}),null),U(m,N(_,{get when(){return e.checkoutPopupConf.checkoutPopupMainCloseButtonVisible&&!e.checkoutPopupConf.checkoutPopupActivateAndClose},get children(){var t=ct();return t.$$click=()=>e.onClose(),d((e=>G(t,le,e))),t}}),null),U(x,N(Ie,{get title(){return i("main.subTitle")},get activeDomain(){return e.activeDomain}})),U(v,(()=>s().map((t=>{return o=(r=ut()).firstChild,c=(s=o.firstChild).nextSibling,g=o.nextSibling,r.$$click=()=>!l()&&a(t),U(r,(n=h((()=>!!(t.decorator&&t.decoratorLeftStyle&&t.decoratorRightStyle))),()=>{return n()&&[(r=dt(),d((e=>{var n=t.decoratorLeftStyle,o=t.decorator;return e.e=G(r,n,e.e),o!==e.t&&(r.innerHTML=e.t=o),e}),{e:void 0,t:void 0}),r),(e=dt(),d((n=>{var r=t.decoratorRightStyle,o=t.decorator;return n.e=G(e,r,n.e),o!==n.t&&(e.innerHTML=n.t=o),n}),{e:void 0,t:void 0}),e)];var e,r}),o),o.style.setProperty("height","100px"),o.style.setProperty("text-align","center"),U(c,(()=>t.title)),U(g,(()=>i("main.charitySelect"))),d((n=>{var o=at(l(),pe,{cursor:"default"}),i=t.logo,a=me,c=t.title,u=at(l(),{...fe,"background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812"},he),d=l(),p=`Select charity: ${t.title}`;return n.e=G(r,o,n.e),i!==n.t&&$(s,"src",n.t=i),n.a=G(s,a,n.a),c!==n.o&&$(s,"alt",n.o=c),n.i=G(g,u,n.i),d!==n.n&&(g.disabled=n.n=d),p!==n.s&&$(g,"aria-label",n.s=p),n}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),r;var n,r,o,s,c,g}))),b),b.$$click=()=>!l()&&e.onSuppress(),y.style.setProperty("height","100px"),y.style.setProperty("text-align","center"),U(y,(()=>i("main.sixthBox")),null),U(w,(()=>i("main.settings"))),k.$$click=()=>{e.onOfferDetailsClick(!t()),n(!t())},U(k,(()=>i("main.offerDetails"))),P.$$click=()=>{st.trackEvent(Y.checkoutPopupWhyAmISeeingThisClicked,{domain:globalThis.window.location.hostname})},U(P,(()=>i("main.whyAmISeeingThis"))),U(g,(c=h((()=>!!e.checkoutPopupConf.checkoutPopupDisplayNameInFooter)),()=>{return c()&&(U(e=dt(),(()=>i("main.footer"))),d((t=>G(e,we,t))),e);var e}),null),d((t=>{var n=ie,r=se,o=ae,s=i("main.title"),a=ue,c=de,u=at(l(),pe,{cursor:"default"}),d=at(l(),{...fe,"background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812"},he),p=l(),h=ye,A=ke,y=Ce,E=e.checkoutPopupConf.externalUrls.giveFreelyWhyAmISeeingThis;return t.e=G(g,n,t.e),t.t=G(m,r,t.t),t.a=G(f,o,t.a),s!==t.o&&(f.innerHTML=t.o=s),t.i=G(x,a,t.i),t.n=G(v,c,t.n),t.s=G(b,u,t.s),t.h=G(w,d,t.h),p!==t.r&&(w.disabled=t.r=p),t.d=G(C,h,t.d),t.l=G(k,A,t.l),t.u=G(P,y,t.u),E!==t.c&&$(P,"href",t.c=E),t}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0}),g),N(_,{get when(){return t()},get children(){return N(Ue,{get merchantName(){return e.activeDomain.Merchant.Name},get extensionName(){return e.checkoutPopupConf.displayName},get termsUrl(){return e.checkoutPopupConf.externalUrls.giveFreelyTermsAndConditions},get parsedMaxRate(){return h((()=>!!e.activeDomain.Merchant.MaxRate))()?Re(e.activeDomain.Merchant.MaxRate.Kind,e.activeDomain.Merchant.MaxRate?.Amount):null},get merchantRateDetail(){return e.merchantRates},onClose:()=>n(!1)})}})];var c,g,m,f,x,v,b,y,w,C,k,P}M(["click"]);var ht=F("<button class=give-freely-close-button aria-label=Close>×"),mt=F("<label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=18250><span>"),ft=F('<div><div><div></div></div><button class=give-freely-back-button aria-label="Back to charity selection"></button><hr><div id=give-freely-goodbye-screen-options><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=1></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=7></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=30></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=90><span></span></label></div><button class=give-freely-submit-button>');function At(e){const[t,n]=u(0),r=Le();return o=ft(),i=o.firstChild,s=i.firstChild,a=i.nextSibling,l=a.nextSibling.nextSibling,g=(c=l.firstChild).firstChild,h=(p=c.nextSibling).firstChild,f=(m=p.nextSibling).firstChild,v=(x=(A=m.nextSibling).firstChild).nextSibling,b=l.nextSibling,o.style.setProperty("font-size","14px"),U(s,(()=>r("suppress.title"))),U(i,N(_,{get when(){return e.checkoutPopupConf.checkoutPopupSupressCloseButtonVisible},get children(){var t=ht();return t.$$click=()=>e.onGoodbye(0),d((e=>G(t,le,e))),t}}),null),a.$$click=()=>e.onBack(),U(a,(()=>r("suppress.backButton"))),g.addEventListener("change",(()=>n(1))),U(c,(()=>r("suppress.suppressionPeriod").replace("{0}","1")),null),h.addEventListener("change",(()=>n(7))),U(p,(()=>r("suppress.suppressionPeriodPlural").replace("{0}","7")),null),f.addEventListener("change",(()=>n(30))),U(m,(()=>r("suppress.suppressionPeriodPlural").replace("{0}","30")),null),x.addEventListener("change",(()=>n(90))),U(v,(()=>r("suppress.suppressionPeriodPlural").replace("{0}","90"))),U(l,N(_,{get when(){return e.checkoutPopupConf.checkoutPopupNeverSuppressionAllowed},get children(){var e=mt(),t=e.firstChild,o=t.nextSibling;return t.addEventListener("change",(()=>n(18250))),U(o,(()=>r("suppress.suppressionPeriodNever"))),d((t=>G(e,xe,t))),e}}),null),b.$$click=()=>{const n=t();n&&(e.onGoodbye(n),e.setScreen("main"))},U(b,(()=>r("suppress.submitButton"))),d((t=>{var n=se,r=ae,o=be,g=Ae,u=xe,d=xe,h=xe,f=xe,x={...fe,"font-weight":"700","margin-top":"10px","margin-bottom":"0px","background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812",width:"100px"};return t.e=G(i,n,t.e),t.t=G(s,r,t.t),t.a=G(a,o,t.a),t.o=G(l,g,t.o),t.i=G(c,u,t.i),t.n=G(p,d,t.n),t.s=G(m,h,t.s),t.h=G(A,f,t.h),t.r=G(b,x,t.r),t}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),o;var o,i,s,a,l,c,g,p,h,m,f,A,x,v,b}M(["click"]);var xt=F("<div><p>"),vt=F("<div><div><div></div><button class=give-freely-close-button aria-label=Close>×</button></div><hr><div><span>");function bt(e){const[t,n]=u(null),r=Le();let o;var s,a,l,c,g,p,m,A;return s=()=>clearInterval(o),null===i||(null===i.cleanups?i.cleanups=[s]:i.cleanups.push(s)),f((()=>{e.failedDonation||(()=>{const t=e.checkoutPopupConf.checkoutPopupDonationSuccessAutoCloseInSeconds??3;n(t),o=setInterval((()=>{n((t=>null===t||t<=1?(clearInterval(o),e.onClose(),0):t-1))}),1e3)})()})),l=vt(),c=l.firstChild,g=c.firstChild,p=g.nextSibling,m=c.nextSibling.nextSibling,A=m.firstChild,l.style.setProperty("font-size","14px"),U(g,(a=h((()=>!!e.failedDonation)),()=>a()?r("donate.failTitle"):r("donate.title"))),p.$$click=()=>e.onClose(),m.style.setProperty("padding","30px"),m.style.setProperty("height","150px"),m.style.setProperty("font-size","14px"),U(l,N(_,{get when(){return!e.failedDonation},get children(){var e=xt(),n=e.firstChild;return U(n,(()=>Fe.formatMessage(r("donate.autoClosing"),t()??0))),d((e=>G(n,ve,e))),e}}),null),d((t=>{var n=se,o=ae,i=le,s=e.failedDonation?r("donate.failContent"):r("donate.content");return t.e=G(c,n,t.e),t.t=G(g,o,t.t),t.a=G(p,i,t.a),s!==t.o&&(A.innerHTML=t.o=s),t}),{e:void 0,t:void 0,a:void 0,o:void 0}),l}M(["click"]);var yt=F("<div><div>");const wt=(e,t,n)=>"donate"===e?"340px":t.checkoutPopupDisplayNameInFooter?"520px":n;function Ct(e){const[t,n]=u("main"),[r,o]=u(),[i,s]=u(!1),a=()=>{e.logger.debug("Close button clicked"),e.onClose()},l=async(t,r=!1)=>{r&&e.onClose(),e.logger.info("Charity selected",{charity:t,domain:e.activeDomain.Domain}),o(t);const i=await e.onDonate(t,e.activeDomain);r?e.onClose():(s(!i),n("donate"))},c=()=>{e.logger.debug("Suppress button clicked"),n("goodbye")},g=()=>{e.logger.debug("Navigating back to main screen"),n("main")},p=t=>{e.logger.info("User chose to hide popup",{days:t}),e.onClose(t)};let h;return x=yt(),v=x.firstChild,"function"==typeof h?(f=h,A=v,m((()=>f(A,undefined)))):h=v,U(v,N(_,{get when(){return"main"===t()},get children(){return N(pt,{mainContainerRef:h,get checkoutPopupConf(){return e.checkoutPopupConf},get activeDomain(){return e.activeDomain},get merchantRates(){return e.merchantRates},onClose:a,onCharitySelect:l,onSuppress:c,get onOfferDetailsClick(){return e.onOfferDetailsClick}})}}),null),U(v,N(_,{get when(){return"goodbye"===t()},get children(){return N(At,{get checkoutPopupConf(){return e.checkoutPopupConf},onClose:()=>e.onClose(),onBack:g,onGoodbye:p,setScreen:n})}}),null),U(v,N(_,{get when(){return"donate"===t()},get children(){return N(bt,{get checkoutPopupConf(){return e.checkoutPopupConf},get selectedCharity(){return r()},onClose:()=>e.onClose(),get failedDonation(){return i()},setScreen:n})}}),null),d((n=>{var r={...re,height:wt(t(),e.checkoutPopupConf,re.height)},o=e.elementId,i=oe;return n.e=G(x,r,n.e),o!==n.t&&$(x,"id",n.t=o),n.a=G(v,i,n.a),n}),{e:void 0,t:void 0,a:void 0}),x;var f,A,x,v}function kt(e){const t=["",".asp",".aspx",".php",".js",".htm",".html"],n=["cart","checkout","shopping-bag","shopping-basket","shopping-cart","basket"].flatMap((e=>t.map((t=>e+t)))).filter((e=>"basket"!==e)),r=["tote-cart","tote.cart"],o=e,i=n.filter((e=>o.includes(e))),s=o.split("/");return!s.some((e=>r.some((t=>e.includes(t)))))&&(s.some((e=>n.some((t=>e.startsWith(t)||e.endsWith(t)))))||"basket"===s[s.length-1].toLowerCase()||i.length>1||1===i.length&&o.includes("shopping"))}function Pt(e,t){const n=["book"];return e.split("/").some((e=>n.some((t=>e.startsWith(t)||e.endsWith(t)))))&&null!=t.evaluate("//*[self::h1 or self::h2 or self::h3 or self::h4 or self::h5 or self::h6][contains(., 'Your Reservation') or contains(., 'Your reservation')]",t,null,XPathResult.ANY_TYPE,null)?.iterateNext()}async function Et(e){try{const t=await te({type:rt,payload:{shopId:e}});return t.payload.found&&t.payload.domain?t.payload.domain:null}catch{return null}}function St(e){try{const e=Array.from(document.querySelectorAll("script"));for(const t of e){if(t.dataset?.shopId&&(t.dataset?.shopId?.startsWith("gid")||t.src.includes("shopify"))){const e=parseInt(t.dataset.shopId.replace("gid://shopify/Shop/",""));if(!Number.isNaN(e)&&e>0)return e}const e=t.textContent||"";if(e.includes("ShopifyAnalytics")&&e.includes("shopId")){const t=e.match(/shopId['"]*:\s*['"]*(\d+)['"]*[,}]/);if(t&&t[1]){const e=parseInt(t[1]);if(!Number.isNaN(e)&&e>0)return e}}}const t=document.querySelector("[data-shop-id]");if(t instanceof HTMLElement){const{shopId:e}=t.dataset;if(e){const t=parseInt(e);if(!Number.isNaN(t)&&t>0)return t}}const n=window?.ShopifyAnalytics?.lib?.trekkie?.defaultAttributes?.shopId;return n&&parseInt(n)||0}catch(t){return e.error("Error accessing ShopifyAnalytics:",t),0}}function Tt(){try{if(!window.location.href.startsWith("https://shop.app"))return 0;const e=document?.head?.querySelector('meta[name="store"][content]');if(!e)return 0;try{const t=JSON.parse(e.content);return t?.id||0}catch{return 0}}catch{return 0}}const Ot=J.getInstance();function Rt(e,t,n){try{const r=function(e){try{const t=e.split(".");return t.length>=2?t.slice(-2).join("."):e}catch(e){return Ot.error("Error extracting domain",e),""}}(n);Ot.debug("Checking merchant regex rules",{currentDomain:r,currentUrl:t});const o=e.merchantPopupRules.filter((e=>r.includes(e.domain)));if(0===o.length)return Ot.debug("No matching merchant rules found for domain",{currentDomain:r}),!1;for(const e of o)for(const n of e.rules)try{if(new RegExp(n.rule).test(t))return Ot.debug("Merchant regex rule matched",{merchant:e.name,rule:n.rule,currentUrl:t}),!0}catch(t){Ot.error("Invalid regex in merchant rule",{merchant:e.name,rule:n.rule,error:t})}return Ot.debug("No matching regex rules found",{currentUrl:t}),!1}catch(e){return Ot.error("Error in merchantRegexRule",e),!1}}function Dt(){const e=document.documentElement.lang,t=document.querySelector('meta[http-equiv="Content-Language"]')?.content,n=document.querySelector('link[rel="alternate"][hreflang]')?.getAttribute("hreflang"),r=navigator.language,o=e||t||n||r||"en";return"string"==typeof o?o.split("-")[0]:"en"}function It(e){return!0!==e.checkoutPopupOnlyShowLanguageMatch||"en"===Dt()}const Nt=(e,t=!1)=>e.length<2&&t?null:Array.from(e).filter((e=>!t||e.dataset.extensionId!==ee.runtime.id)).map((e=>e.dataset.extensionName)).join(",");const _t=e=>{const t=h((()=>({translate:e.translate()||(e=>""),getAllCharities:e.charities()||(()=>[])})));return N(Ne.Provider,{value:t,get children(){return e.children}})},Lt=J.getInstance(),Ft="countryCode",Mt=async()=>await We.get(Ft)||(async()=>{Lt.debug("detecting country");const e={method:"GET",headers:{"Content-Type":"application/json",Authorization:"Basic OTEzOTkxOnFlYmpaWF9DOGNRY0lxSHA4WTVjNGxzU1pRSlM2VW9MMExzTF9tbWs="}};try{const t=await fetch("https://geoip.maxmind.com/geoip/v2.1/country/me",e);if(Lt.debug("Received geolocation response",{status:t.status}),!t.ok)return void Lt.warn("Failed to get geolocation data",{status:t.status});const n=await t.json();if(!n)throw new Error("There was an error fetching geoip look up");return await We.set(Ft,n.country.iso_code),n.country.iso_code}catch(e){return void Lt.error("Failed to get geolocation data",{error:e})}})();var $t=F("<div class=gf-app>");function Gt(){const e=J.getInstance(),[t,n]=u(null),[r,o]=u(void 0),[i,s]=u(!1),[a,l]=u([]),[c,g]=u(),[d,p]=u({});f((async()=>{e.info("Mounting GfApp component");try{const i=await(async()=>{const e=await te({type:Ze,payload:{}});if(!e.payload.config)throw new Error("No checkout popup config found");return e.payload.config})();if(!i)return void e.error("No checkout popup config found");n(i),e.configure({enabled:!0,title:"Content - GfAdUnit",minLevel:i.checkoutPopupMinLogLevel??"error"}),function(e){if(!e?.shouldCheckSiteMatches)return;let t;(e?.siteMatchesRegex??[]).some((e=>{var n;return n=window.location.href,!(!new RegExp(e).test(n)||(t=e,0))}))&&t&&st.trackEvent(Y.checkoutPopupSiteMatches,{url:window.location.href,matchedRule:t,uts:Date.now()},!0)}(i);const a=Dt();v(a);const c=Ye();if(i.minVersion&&((e,t)=>{if(e===t)return!1;const n=e.split(".").map((e=>parseInt(e,10))),r=t.split(".").map((e=>parseInt(e,10)));for(let e=0;e<n.length;e++){if(n[e]<r[e])return!0;if(n[e]>r[e])return!1}return!1})(c,i.minVersion))return void e.debug(`Current version: ${c}. Minimum version ${i.minVersion} not met`);const g=await Mt()??"us",u=i.charities[g.toLowerCase()]??i.charities.us;if(p(u||{}),e.debug("Charities for current country",{currentCountry:g,charities:u}),!1===i.checkoutPopupMasterSwitch)return void e.debug("Checkout popup master switch is disabled");const d=document.getElementsByClassName("give-freely-root");let h=!1;d.length>1&&(e.debug("There is more than one gf extension installed"),d.item(0).dataset.extensionId!==ee.runtime.id&&(e.debug("Giving preference to the first gf extension injected in the DOM"),h=!0),e.debug("Providing this extension preference over the other installed extensions"));const{domain:m,rates:f}=await(async e=>{const{hostname:t}=window.location;e.debug("Checking if domain is active",{hostname:t});const n=await te({type:Qe,payload:{hostname:t}});return n.payload.isActive?(e.debug("Active domain",{domain:n.payload.domain}),e.debug("Merchant rates",{rates:n.payload.rates}),e.info("Domain and rates ({})ed successfully."),{isActive:!0,domain:n.payload.domain,rates:n.payload.rates}):{isActive:!1,domain:void 0,rates:[]}})(e);if(l(f),o(m),m)await function(e,t){const n=St(t)||Tt();return n>0&&function(e,t,n){if(e&&!(e<=0))try{te({type:nt,payload:{shopId:e,domain:t}}).catch((e=>{n.error("Error sending shop ID to background:",e)}))}catch(e){n.error("Error sending Shopify shop ID:",e)}}(n,e,t),n}(m,e);else{if("shop.app"!==window.location.hostname&&!window.location.hostname.endsWith(".shop.app"))return void s(!1);const t=window.location.pathname.split("/")[2];if(!t)return e.error("Shop ID not found"),void s(!1);const n=await Et(parseInt(t));if(!n)return e.error("Shop domain not found"),void s(!1);e.debug("Shop domain found",{shopDomain:n}),o(n)}const A=await(async e=>{const t=await We.get("popup_hide");if(!t)return e.debug("No expiry found in storage"),!1;const{popupHide:n}=t,r=!!n&&Date.now()<n;return e.debug("Is AdUnit Muted?",{isMuted:r,expiry:n}),r})(e);if(A)return;if(!r())return void s(!1);const x=await(async(e,t)=>{const{Domain:n}=t,r=window.location.href,{payload:o}=await te({type:et,payload:{activeDomain:n,url:r}});return!!o.result&&(e.info("Stand Down detected"),!0)})(e,r());if(x)return void s(!1);const b=t()?.anonymousActiveDomainLogging??!1,y=r()??void 0;y&&b&&!function(e){const t=`gfhv-${e}`;return!!sessionStorage.getItem(t)||(sessionStorage.setItem(t,"true"),!1)}(y.Domain)&&st.trackEvent(Y.checkoutPopupActiveDomain,{url:y.Domain});const w=setInterval((async()=>{e.debug("Checking checkout rules");const t=await(async e=>{const t=J.getInstance();t.configure({enabled:!0,title:"Content - checkoutRulesTest"});const n=new URL(globalThis.location.href),r=n.href,{hostname:o}=n;t.debug("Checking if popup should be shown",{currentUrl:r});const i=await async function(e){const t=St(e)||Tt();return!("shop.app"!==window.location.hostname&&!window.location.hostname.endsWith(".shop.app")||!(t>0)||!await Et(t))}(t),s=It(e)&&(kt(n.pathname.toLowerCase())||Pt(r,document)||Rt(e,r,o)||i);return t.debug("Popup show decision based on rules",{shouldShow:s,matchesCartRule:kt(n.pathname.toLowerCase()),matchesBookingRule:Pt(r,document),matchesShopPayRule:i,matchesMerchantRegexRule:Rt(e,r,o),matchesLanguageRule:It(e)}),s})(i);if(t&&h)return st.trackEvent(Y.checkoutPopupLooserExtension,{url:globalThis.window.location.href,winner:d.item(0).dataset.extensionName}),e.debug("Standing down because, another ad-unit extension will pop"),void clearInterval(w);s(t),t&&(e.debug("Should show popup based on checkout rules",{shouldShowResult:t}),st.trackEvent(Y.checkoutPopupShown,{url:globalThis.window.location.href,pageLanguage:a,looserCompetingExtensions:Nt(d,!0)}),clearInterval(w))}),2e3)}catch(t){s(!1),e.error("An error occurred in GfApp",{error:t})}}));const m=async(t,n)=>{e.info("Processing donation",{charity:t,domain:n.Domain});const r=await(async(e,t,n,r)=>{e.debug("Activating offer",{activeDomain:t,selectedCharity:r});const o=await ne({type:tt,payload:{activeDomain:t,originalUrl:n,selectedCharity:r}});return e.debug("Activate offer response",{response:o}),o})(e,n,window.location.href,{ein:t.ein,thirdPartyId:t.tpi});return e.debug("Activate offer response",{activationResponse:r}),st.trackEvent(r.payload.response?Y.checkoutPopupDonation:Y.checkoutPopupFailedActivation,{activeDomain:n.Domain,url:globalThis.window.location.href,charity:{ein:t.ein,tpi:t.tpi},rate:n.Merchant.MaxRate}),r.payload.response},A=async t=>{s(await(async(e,t)=>{try{e.info("Hiding ad",{days:t});const n=await ne({type:Xe,payload:{days:t??0}});return void 0!==t&&st.trackEvent(Y.checkoutPopupSupressed,{url:globalThis.window.location.href,days:t}),e.info("Hiding ad response",{hideResponse:n}),n.payload.ack?(e.debug("Ad hidden successfully"),!1):(e.warn("Failed to hide ad"),!0)}catch{return!1}})(e,t))},x=async e=>{st.trackEvent(Y.checkoutPopupOfferDetailsClicked,{action:e?"opened":"closed"})},v=async t=>{e.debug("Getting translation provider",{currentLanguage:t});const{translations:n,charities:r}=await async function(e,t){try{t&&t.debug("Getting language content",{languageCode:e});const n=await te({type:ot,payload:{lang:e}});return{translations:n.payload.translations,charities:n.payload.charities}}catch(n){return t&&t.error("Error getting language content",{error:n,languageCode:e}),{translations:null,charities:null}}}(t,e),o={translate:e=>n&&n[e]?n[e]:"",getAllCharities:()=>{const e=d();return Object.entries(e).map((([e,t])=>{const{ein:n}=t,o=r?.[n];if(!o)throw new Error(`Failed to find charity metadata for ein ${n}`);return{ein:n,tpi:o.tpi,title:o.title,order:parseInt(e,10),logo:o.logo,decorator:t.decorator,decoratorLeftStyle:t.decoratorLeftStyle,decoratorRightStyle:t.decoratorRightStyle}}))}};e.debug("Setting content provider with translations and charity functions"),g((()=>o))};return N(_t,{translate:()=>c()?.translate,charities:()=>c()?.getAllCharities,get children(){var n,o=$t();return U(o,(n=h((()=>!(!r()||!i()))),()=>n()&&N(Ct,{get checkoutPopupConf(){return t()},elementId:"give-freely-checkout-popup",get activeDomain(){return r()},get merchantRates(){return a()},onClose:A,onDonate:m,onOfferDetailsClick:x,logger:e}))),o}})}async function Ut(){const e=`give-freely-root-${ee.runtime.id}`;if(document.getElementById(e))return;const t=document.createElement("div");t.id=e,t.className="give-freely-root",t.style.display="block",t.dataset.extensionId=ee.runtime.id,t.dataset.extensionName=ee.runtime.getManifest().name||ee.runtime.id,document.body.appendChild(t);const n=t.attachShadow({mode:"open"}),r=document.createElement("div"),s=document.createElement("style");s.textContent='\n :host {\n all: initial;\n }\n\n .gf-scroll-remove::-webkit-scrollbar {\n border-radius-bottom-right: 15px;\n }\n\n button {\n cursor: pointer;\n transition: transform 0.1s ease;\n }\n\n button:active {\n transform: scale(0.98);\n }\n\n .give-freely-close-button:hover {\n opacity: 0.7;\n }\n\n input[type="radio"] {\n margin-right: 8px;\n }\n\n hr {\n border: none;\n border-top: 1px solid #e5e5e5;\n margin: 1em 0;\n }\n\n @media (max-width: 600px), (max-height: 480px) {\n #give-freely-checkout-popup {\n display: none !important;\n }\n }\n',n.appendChild(s),n.appendChild(r),function(e,t,n,r={}){let s;(function(e,t){const n=a,r=i,s=0===e.length,l=void 0===t?r:t,c=s?o:{owned:null,cleanups:null,context:l?l.context:null,owner:l},g=s?e:()=>e((()=>m((()=>O(c)))));i=c,a=null;try{return k(g,!0)}finally{a=n,i=r}})((r=>{s=r,t===document?e():U(t,e(),t.firstChild?null:void 0,n)}),r.owner)}((()=>N(Gt,{})),r)}export{ee as browser,Ut as initializeAdUnit};
|