@givefreely/adunit 1.4.2 → 1.5.0-dev.0
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=w;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[A.bind(r),e=>("function"==typeof e&&(e=e(r.value)),b(r,e))]}function d(e,t,r){x(v(e,t,!1,n))}function p(e,r,o){t=k;const i=v(e,r,!1,n);i.user=!0,c?c.push(i):x(i)}function m(t,n,r){r=r?Object.assign({},e,r):e;const o=v(t,n,!0,0);return o.observers=null,o.observerSlots=null,o.comparator=r.equals||void 0,x(o),A.bind(o)}function h(e){if(null===a)return e();const t=a;a=null;try{return e()}finally{a=t}}function f(e){p((()=>h(e)))}function A(){if(this.sources&&this.state)if(this.state===n)x(this);else{const e=l;l=null,C((()=>P(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&&C((()=>{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&&S(r)),o||(r.state=n)}if(l.length>1e6)throw l=[],new Error}),!1)),t}function x(e){if(!e.fn)return;E(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(E),e.owned=null),e.updatedAt=r+1,T(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 v(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 y(e){if(0===e.state)return;if(e.state===r)return P(e);if(e.suspense&&h(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)x(e);else if(e.state===r){const n=l;l=null,C((()=>P(e,t[0])),!1),l=n}}function C(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&&(w(l),l=null),e)return;const n=c;c=null,n.length&&C((()=>t(n)),!1)}(r),n}catch(e){r||(c=null),l=null,T(e)}}function w(e){for(let t=0;t<e.length;t++)y(e[t])}function k(e){let t,n=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[n++]=r:y(r)}for(t=0;t<n;t++)y(e[t])}function P(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)&&y(i):e===r&&P(i,t)}}}function S(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&&S(n))}}function E(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--)E(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)E(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 T(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 O(e,t){return h((()=>e(t||{})))}function D(e){const t=e.keyed,n=m((()=>e.when),void 0,{equals:(e,n)=>t?e===n:!e==!n});return m((()=>{const r=n();if(r){const o=e.children;return"function"==typeof o&&o.length>0?h((()=>o(t?r:()=>{if(!h(n))throw"Stale read from <Show>.";return e.when}))):o}return e.fallback}),void 0,void 0)}const I="_$DX_DELEGATE";function R(e,t,n){let r;const o=()=>{const t=document.createElement("template");return t.innerHTML=e,t.content.firstChild},i=t?()=>h((()=>document.importNode(r||(r=o()),!0))):()=>(r||(r=o())).cloneNode(!0);return i.cloneNode=i,i}function _(e,t=window.document){const n=t[I]||(t[I]=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,$))}}function N(e,t,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}function L(e,t,n){if(!t)return n?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 F(e,t,n,r){if(void 0===n||r||(r=[]),"function"!=typeof t)return M(e,t,r,n);d((r=>M(e,t(),r,n)),r)}function $(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 M(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=H(e,n,r,o)}else n=""!==n&&"string"==typeof n?e.firstChild.data=t:e.textContent=t}else if(null==t||"boolean"===i)n=H(e,n,r);else{if("function"===i)return d((()=>{let o=t();for(;"function"==typeof o;)o=o();n=M(e,o,n,r)})),()=>n;if(Array.isArray(t)){const i=[],a=n&&Array.isArray(n);if(U(i,t,n,o))return d((()=>n=M(e,i,n,r,!0))),()=>n;if(0===i.length){if(n=H(e,n,r),s)return n}else a?0===n.length?G(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&&H(e),G(e,i));n=i}else if(t.nodeType){if(Array.isArray(n)){if(s)return n=H(e,n,r,t);H(e,n,null,t)}else null!=n&&""!==n&&e.firstChild?e.replaceChild(t,e.firstChild):e.appendChild(t);n=t}}return n}function U(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=U(e,a,l)||o;else if("function"===s)if(r){for(;"function"==typeof a;)a=a();o=U(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 G(e,t,n=null){for(let r=0,o=t.length;r<o;r++)e.insertBefore(t[r],n)}function H(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 B{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}] - ${B.LOGGER_PREFIX} ${s} ${t}`,r):console[i](`[${n}] - ${B.LOGGER_PREFIX} ${s} ${t}`)}}var j,K;B.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"}(j||(j={})),function(e){e.adUnitLog="ADUNIT-LOG"}(K||(K={}));const W=["debug","info","warn","error"];class V{constructor(e){this.config={minLevel:e?.minLevel??"debug",enabled:e?.enabled??!1,transports:e?.transports??[new B],title:e?.title??""}}static getInstance(e){return V.instance||(V.instance=new V(e)),V.instance}configure(e){this.config={...this.config,...e}}shouldLog(e){return!!this.config.enabled&&W.indexOf(e)>=W.indexOf(this.config.minLevel)}createLogMessage(e,t,n){return{level:e,version:"1.4.2",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 Y=3,z=e=>1e3*e;async function q(e,t={}){const{maxAttempts:n=Y,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 X=chrome;async function Z(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||X.runtime.sendMessage(e,o)}catch(e){r(e)}}))}async function J(e,t,n){return q((()=>Z(e,t)),{maxAttempts:Y,delayFn:z})}const Q={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"}},ee={height:"100%","overflow-x":"hidden","overlfow-y":"auto",position:"relative",padding:"0px 15px"},te={},ne={display:"flex","align-items":"center","margin-bottom":"10px"},re={flex:"1","font-size":"24px","font-weight":"700","margin-top":"20px","margin-bottom":"0px"},oe={background:"none",border:"none",padding:"4px 8px",color:"#666464","font-size":"38px",cursor:"pointer","line-height":"1"},ie={color:"black","margin-top":"20px","max-width":"40%"},se={"font-size":"18px","font-weight":"400","margin-top":"20px","margin-bottom":"0px"},ae={display:"flex",gap:"10px",width:"100%","margin-top":"20px","margin-bottom":"20px","flex-wrap":"wrap","justify-content":"space-between"},le={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"},ce={"max-width":"120px","max-height":"70px","margin-bottom":"5px","object-fit":"contain"},ge={"background-color":"#FFD812",cursor:"pointer","border-radius":"8px",padding:"8px",color:"white","min-width":"100px",border:"0","font-weight":"600",width:"100%"},ue={display:"flex","flex-direction":"column",gap:"10px",width:"100%","color-scheme":"light"},de={display:"flex","align-items":"center",gap:"5px",border:"1px solid #ddd",padding:"15px","border-radius":"5px","font-weight":"600",cursor:"pointer","margin-bottom":"8px"},pe={"text-align":"right"},me={background:"none",border:"none",color:"blue","text-decoration":"underline",padding:"0",cursor:"pointer","margin-bottom":"15px"},he={display:"flex","justify-content":"space-between",margin:"20px 0px 10px 0px","font-size":"14px"},fe={margin:"5px 0px 5px 0px","font-size":"14px","text-align":"center"},Ae={color:"#666464","text-decoration":"underline"},be={color:"rgb(102, 100, 100)","text-decoration":"underline",margin:"0",cursor:"pointer"},xe={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"},ve={padding:"0 5px 0 10px",width:"100%","font-size":"12px","box-sizing":"border-box"},ye={display:"grid","grid-template-columns":"4fr 1fr","padding-right":"15px","padding-bottom":"5px"},Ce={color:"#000","margin-bottom":"4px"},we={"font-size":"14px",color:"#555","text-align":"right"},ke=(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 Pe=R("<span>");function Se(e){return t=Pe(),d((()=>{return t.innerHTML=(n=e.title,r=e.activeDomain,n.replace("{0}",ke(r.Merchant.MaxRate?.Kind,r.Merchant.MaxRate?.Amount??"0")));var n,r})),t;var t}var Ee=R("<div>"),Te=R("<div><div class=gf-offer-details><p>Select a charity to activate a donation during your online shopping session.</p><p> <b>Eligible Transaction:</b> A purchase made immediately after selecting a charity.</p><p><b>Donation rates:</b> <!> for each eligible transaction. The following donation rates and exclusions apply:</p><p><b>Donation amounts:</b> Donation amount is calculated based upon the applicable rates and exclusions, which may change from time to time. Amounts may be adjusted or canceled due to returned items, suspected fraud, or other factors described within the terms and conditions.</p><p><b>Donation timing:</b> On average, donation payouts occur 60-120 days after your completed transaction, but some donations may take 180 days or longer. We provide a donation to the charity you had selected at the time of purchase, in monthly batches, after any holdback periods due to applicable return or cancellation policies have passed.</p><p>See a summary of <a target=_blank rel=noreferrer>terms and conditions</a>."),Oe=R("<div class=gf-offer-details-rate-item><div></div><div>");const De=e=>{return t=Te(),o=(r=(n=t.firstChild).firstChild.nextSibling.nextSibling).firstChild.nextSibling.nextSibling,i=r.nextSibling,s=i.nextSibling.nextSibling.firstChild.nextSibling,F(r,(()=>e.parsedMaxRate?`Up to ${e.parsedMaxRate}`:"Earn"),o),F(n,O(D,{get when(){return!!e.merchantRateDetail?.length},get children(){var t=Ee();return F(t,(()=>e.merchantRateDetail?.map((e=>{return t=Oe(),n=t.firstChild,r=n.nextSibling,F(n,(()=>e.Name||"")),F(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=ye,i=Ce,s=we;return e.e=L(t,o,e.e),e.t=L(n,i,e.t),e.a=L(r,s,e.a),e}),{e:void 0,t:void 0,a:void 0}),t;var t,n,r})))),t}}),i),d((r=>{var o=xe,i=ve,a=Ae,l=e.termsUrl;return r.e=L(t,o,r.e),r.t=L(n,i,r.t),r.a=L(s,a,r.a),l!==r.o&&N(s,"href",r.o=l),r}),{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t,n,r,o,i,s};function Ie(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 Re={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)}))},m={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})}},h={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return n.privacy={network:{"*":h},services:{"*":h},websites:{"*":h}},l(e,m,n)};e.exports=n(chrome)}}(Re);var _e=Ie(Re.exports);const Ne="GIVE_FREELY_",Le={async get(e){const t=`${Ne}${e}`;return(await _e.storage.local.get(t))[t]||null},async set(e,t){const n=`${Ne}${e}`;await _e.storage.local.set({[n]:t})},async remove(e){const t=Array.isArray(e)?e.map((e=>`${Ne}${e}`)):`${Ne}${e}`;await _e.storage.local.remove(t)}};class Fe{constructor(e){this.partnerApiKey=e,this.partnerConfig=null,this.globalConfig=null,this.lastConfigRefresh=0,this.CONFIG_REFRESH_INTERVAL=3e5,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(`https://cdn.givefreely.com/adunit/config/${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 Le.set(this.PARTNER_CONFIG_STORAGE_KEY,t),e}async fetchAndUpdateGlobalConfig(){const e=await q((async()=>{const e=await fetch("https://cdn.givefreely.com/adunit/config/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 Le.set(this.GLOBAL_CONFIG_STORAGE_KEY,t),e}async getConfig(){const e=Date.now(),t=await Le.get(this.PARTNER_CONFIG_STORAGE_KEY),n=await Le.get(this.GLOBAL_CONFIG_STORAGE_KEY);if(this.partnerConfig=t?.config||null,this.globalConfig=n?.config||null,this.lastConfigRefresh=Math.max(t?.lastRefresh||0,n?.lastRefresh||0),!this.partnerConfig||!this.globalConfig||e-this.lastConfigRefresh>this.CONFIG_REFRESH_INTERVAL)try{const[t,n]=await Promise.all([this.fetchAndUpdatePartnerConfig(),this.fetchAndUpdateGlobalConfig()]);this.partnerConfig=t,this.globalConfig=n,this.lastConfigRefresh=e}catch(e){if(!this.partnerConfig||!this.globalConfig)throw e}const r=this.mergeConfigs(this.globalConfig,this.partnerConfig);return((e,t,n)=>{const r=[...t.merchantExclusions??[],...n.merchantExclusions??[]];e.merchantExclusions=r})(r,this.globalConfig,this.partnerConfig),r}async clearCache(){await Promise.all([Le.remove(this.PARTNER_CONFIG_STORAGE_KEY),Le.remove(this.GLOBAL_CONFIG_STORAGE_KEY)]),this.partnerConfig=null,this.globalConfig=null,this.lastConfigRefresh=0}mergeConfigs(e,t){if(!t)return e;const n={...e};return Object.keys(t).forEach((r=>{if(!Object.prototype.hasOwnProperty.call(t,r))return;const o=e[r],i=t[r];Array.isArray(i)&&Array.isArray(o)?n[r]=i:n[r]=null===i||"object"!=typeof i||"object"!=typeof o?void 0!==i?i:o:this.mergeConfigs(o,i)})),n}getStoredState(e){return e?{config:e.config,lastRefresh:e.lastRefresh}:{config:null,lastRefresh:0}}}const $e="TRACK_EVENT",Me="GF_HIDE_POPUP",Ue="GF_GET_POPUP_CONFIG",Ge="GF_IS_ACTIVE_DOMAIN",He="GF_SHOULD_STAND_DOWN",Be="GF_ACTIVATE_OFFER",je="GF_STORE_SHOPIFY_SHOP_ID",Ke="GF_GET_DOMAIN_BY_SHOP_ID",We={ein:"0",tpi:"0",logo:"",title:"Unknown Charity"},Ve=()=>String("1.4.2");class Ye{constructor(e,t,n=60){this._config=null,this.track=async(e,t,n)=>{null===this._config&&(this._config=await new Fe(this._partnerApiKey).getConfig());const r={partner:`adUnit_${this._partnerApiKey}`,eventType:e,eventData:{userId:this._userService?.user?.id,libVersion:Ve(),wfDeviceId:t,...n}};try{const e=JSON.stringify(r);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",r),!1)}catch(e){return this._logger.info("Something unexpected happened when dispatching a gf event",{error:e,event:r}),!1}},this.getEventsHistory=async()=>{const{GF_AD_EVENT_HISTORY:e}=await X.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 X.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 X.storage.local.set({GF_AD_EVENT_HISTORY:t})},this._partnerApiKey=e,this._userService=t,this._debounceWindowInMinutes=n,this._logger=V.getInstance({title:"Analytics"})}}Ye.trackEvent=async(e,t)=>{await Z({type:$e,payload:{eventType:e,eventData:t}})};var ze=R("<a href=#!>"),qe=R("<button class=give-freely-close-button aria-label=Close>×"),Xe=R('<div><div><div><span></span></div></div><hr><div></div><div><div><div><br><span></span></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">'),Ze=R("<div><div><img><span></span></div><button>"),Je=R("<div>");function Qe(e){const[t,n]=u(!1);p((()=>{t()&&e.mainContainerRef&&e.mainContainerRef.scroll({top:e.mainContainerRef.scrollHeight,behavior:"smooth"})}));const r=()=>e.onCharitySelect(We,e.checkoutPopupConf.checkoutPopupActivateAndCloseSkipSuccess);return[(i=Xe(),s=i.firstChild,a=s.firstChild,l=a.firstChild,c=s.nextSibling.nextSibling,g=c.nextSibling,h=g.firstChild,f=h.firstChild,A=f.firstChild.nextSibling,b=f.nextSibling,x=g.nextSibling,v=x.firstChild,y=v.nextSibling,F(s,O(D,{get when(){return e.checkoutPopupConf.checkoutPopupActivateAndClose},get children(){var t=ze();return t.$$click=r,d((n=>{var r=ie,o=e.checkoutPopupConf.checkoutPopupActivateAndClose;return n.e=L(t,r,n.e),o!==n.t&&(t.innerHTML=n.t=o),n}),{e:void 0,t:void 0}),t}}),null),F(s,O(D,{get when(){return e.checkoutPopupConf.checkoutPopupMainCloseButtonVisible&&!e.checkoutPopupConf.checkoutPopupActivateAndClose},get children(){var t=qe();return t.$$click=()=>e.onClose(),d((e=>L(t,oe,e))),t}}),null),F(c,O(Se,{get title(){return e.subtitle},get activeDomain(){return e.activeDomain}})),F(g,(()=>e.checkoutPopupConf.checkoutPopupCharities.map((t=>{return o=(r=Ze()).firstChild,s=(i=o.firstChild).nextSibling,a=o.nextSibling,r.$$click=()=>e.onCharitySelect(t),F(r,(n=m((()=>!!(t.decorator&&t.decoratorLeftStyle&&t.decoratorRightStyle))),()=>{return n()&&[(r=Je(),d((e=>{var n=t.decoratorLeftStyle,o=t.decorator;return e.e=L(r,n,e.e),o!==e.t&&(r.innerHTML=e.t=o),e}),{e:void 0,t:void 0}),r),(e=Je(),d((n=>{var r=t.decoratorRightStyle,o=t.decorator;return n.e=L(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"),F(s,(()=>t.title)),F(a,(()=>e.checkoutPopupConf.checkoutPopupCharitySelectString||"Select")),d((n=>{var o=le,s=t.logo,l=ce,c=t.title,g={...ge,"background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812"},u=`Select charity: ${t.title}`;return n.e=L(r,o,n.e),s!==n.t&&N(i,"src",n.t=s),n.a=L(i,l,n.a),c!==n.o&&N(i,"alt",n.o=c),n.i=L(a,g,n.i),u!==n.n&&N(a,"aria-label",n.n=u),n}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),r;var n,r,o,i,s,a}))),h),h.$$click=()=>e.onSuppress(),f.style.setProperty("height","100px"),f.style.setProperty("text-align","center"),F(b,(()=>e.checkoutPopupConf.checkoupPopupDontShowAgainButtonText||"Settings...")),v.$$click=()=>{e.onOfferDetailsClick(!t()),n(!t())},F(v,(()=>e.checkoutPopupConf.checkoutPopupOfferDetailsLabelString||"Offer Details")),y.$$click=()=>{Ye.trackEvent(j.checkoutPopupWhyAmISeeingThisClicked,{domain:globalThis.window.location.hostname})},F(y,(()=>e.checkoutPopupConf.checkoutPopupWhyAmISeeingThisLabelString||"Why am I seeing this?")),F(i,(o=m((()=>!!e.checkoutPopupConf.checkoutPopupDisplayNameInFooter)),()=>{return o()&&(t=Je(),d((n=>{var r=fe,o=e.checkoutPopupConf.checkoutPopupDisplayNameInFooter;return n.e=L(t,r,n.e),o!==n.t&&(t.innerHTML=n.t=o),n}),{e:void 0,t:void 0}),t);var t}),null),d((t=>{var n=te,r=ne,o=re,u=e.checkoutPopupConf.checkoutPopupMainTitle,d=se,p=ae,m=le,f=e.checkoutPopupConf.checkoutPopupSixthBoxWording,C={...ge,"background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812"},w=he,k=be,P=Ae,S=e.checkoutPopupConf.externalUrls.giveFreelyWhyAmISeeingThis;return t.e=L(i,n,t.e),t.t=L(s,r,t.t),t.a=L(a,o,t.a),u!==t.o&&(l.innerHTML=t.o=u),t.i=L(c,d,t.i),t.n=L(g,p,t.n),t.s=L(h,m,t.s),f!==t.h&&(A.innerHTML=t.h=f),t.r=L(b,C,t.r),t.d=L(x,w,t.d),t.l=L(v,k,t.l),t.u=L(y,P,t.u),S!==t.c&&N(y,"href",t.c=S),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}),i),O(D,{get when(){return t()},get children(){return O(De,{get merchantName(){return e.activeDomain.Merchant.Name},get extensionName(){return e.checkoutPopupConf.displayName},get termsUrl(){return e.checkoutPopupConf.externalUrls.giveFreelyTermsAndConditions},get parsedMaxRate(){return m((()=>!!e.activeDomain.Merchant.MaxRate))()?ke(e.activeDomain.Merchant.MaxRate.Kind,e.activeDomain.Merchant.MaxRate?.Amount):null},get merchantRateDetail(){return e.merchantRates},onClose:()=>n(!1)})}})];var o,i,s,a,l,c,g,h,f,A,b,x,v,y}_(["click"]);var et=R("<button class=give-freely-close-button aria-label=Close>×"),tt=R("<label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=18250><span>Don't ask me again... ever"),nt=R("<div><div><div></div></div><button class=give-freely-back-button aria-label=\"Back to charity selection\">I changed my mind! I'd like to select a charity.</button><hr><div id=give-freely-goodbye-screen-options><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=1><span>Don't ask me again for 1 day</span></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=7><span>Don't ask me again for 7 days</span></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=30><span>Don't ask me again for 30 days</span></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=90><span>Don't ask me again for 90 days</span></label></div><button class=give-freely-submit-button>Submit");function rt(e){const[t,n]=u(0);return r=nt(),o=r.firstChild,i=o.firstChild,s=o.nextSibling,a=s.nextSibling.nextSibling,c=(l=a.firstChild).firstChild,p=(g=l.nextSibling).firstChild,h=(m=g.nextSibling).firstChild,A=(f=m.nextSibling).firstChild,b=a.nextSibling,r.style.setProperty("font-size","14px"),F(i,(()=>e.checkoutPopupConf.checkoutPopupSupressTitle)),F(o,O(D,{get when(){return e.checkoutPopupConf.checkoutPopupSupressCloseButtonVisible},get children(){var t=et();return t.$$click=()=>e.onGoodbye(0),d((e=>L(t,oe,e))),t}}),null),s.$$click=()=>e.onBack(),c.addEventListener("change",(()=>n(1))),p.addEventListener("change",(()=>n(7))),h.addEventListener("change",(()=>n(30))),A.addEventListener("change",(()=>n(90))),F(a,O(D,{get when(){return e.checkoutPopupConf.checkoutPopupNeverSuppressionAllowed},get children(){var e=tt();return e.firstChild.addEventListener("change",(()=>n(18250))),d((t=>L(e,de,t))),e}}),null),b.$$click=()=>{const n=t();n&&(e.onGoodbye(n),e.setScreen("main"))},d((t=>{var n=ne,r=re,c=me,u=ue,d=de,p=de,h=de,A=de,x={...ge,"font-weight":"700","margin-top":"10px","margin-bottom":"0px","background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812",width:"100px"};return t.e=L(o,n,t.e),t.t=L(i,r,t.t),t.a=L(s,c,t.a),t.o=L(a,u,t.o),t.i=L(l,d,t.i),t.n=L(g,p,t.n),t.s=L(m,h,t.s),t.h=L(f,A,t.h),t.r=L(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}),r;var r,o,i,s,a,l,c,g,p,m,h,f,A,b}_(["click"]);class ot{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 it=R("<div><p>"),st=R("<div><div><div></div><button class=give-freely-close-button aria-label=Close>×</button></div><hr><div><span>");function at(e){const[t,n]=u(null);let r;var o,s,a,l,c,g,p;return o=()=>clearInterval(r),null===i||(null===i.cleanups?i.cleanups=[o]:i.cleanups.push(o)),f((()=>{e.failedDonation||(()=>{const t=e.checkoutPopupConf.checkoutPopupDonationSuccessAutoCloseInSeconds??3;n(t),r=setInterval((()=>{n((t=>null===t||t<=1?(clearInterval(r),e.onClose(),0):t-1))}),1e3)})()})),s=st(),a=s.firstChild,l=a.firstChild,c=l.nextSibling,g=a.nextSibling.nextSibling,p=g.firstChild,s.style.setProperty("font-size","14px"),F(l,(()=>e.failedDonation?"Oops! Something went wrong":e.checkoutPopupConf.checkoutPopupDonationTitle)),c.$$click=()=>e.onClose(),g.style.setProperty("padding","30px"),g.style.setProperty("height","150px"),g.style.setProperty("font-size","14px"),F(s,O(D,{get when(){return!e.failedDonation},get children(){var n=it(),r=n.firstChild;return F(r,(()=>ot.formatMessage(e.checkoutPopupConf.checkoutPopupDonationSuccessAutoCloseLabelStringMask||"Closing in {0}",t()??0))),d((e=>L(r,pe,e))),n}}),null),d((t=>{var n=ne,r=re,o=oe,i=e.failedDonation?"Please try again later.":e.checkoutPopupConf.checkoutPopupDonationWording;return t.e=L(a,n,t.e),t.t=L(l,r,t.t),t.a=L(c,o,t.a),i!==t.o&&(p.innerHTML=t.o=i),t}),{e:void 0,t:void 0,a:void 0,o:void 0}),s}_(["click"]);var lt=R("<div><div>");const ct=(e,t,n)=>"donate"===e?"340px":t.checkoutPopupDisplayNameInFooter?"520px":n;function gt(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)=>{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 m;return b=lt(),x=b.firstChild,"function"==typeof m?(f=m,A=x,h((()=>f(A,undefined)))):m=x,F(x,O(D,{get when(){return"main"===t()},get children(){return O(Qe,{mainContainerRef:m,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},get subtitle(){return e.checkoutPopupConf.checkoutPopupSubTitle}})}}),null),F(x,O(D,{get when(){return"goodbye"===t()},get children(){return O(rt,{get checkoutPopupConf(){return e.checkoutPopupConf},onClose:()=>e.onClose(),onBack:g,onGoodbye:p,setScreen:n})}}),null),F(x,O(D,{get when(){return"donate"===t()},get children(){return O(at,{get checkoutPopupConf(){return e.checkoutPopupConf},get selectedCharity(){return r()},onClose:()=>e.onClose(),get failedDonation(){return i()},setScreen:n})}}),null),d((n=>{var r={...Q,height:ct(t(),e.checkoutPopupConf,Q.height)},o=e.elementId,i=ee;return n.e=L(b,r,n.e),o!==n.t&&N(b,"id",n.t=o),n.a=L(x,i,n.a),n}),{e:void 0,t:void 0,a:void 0}),b;var f,A,b,x}function ut(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 dt(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 pt(e){try{const t=await Z({type:Ke,payload:{shopId:e}});return t.payload.found&&t.payload.domain?t.payload.domain:null}catch{return null}}function mt(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 ht(){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 ft=V.getInstance();function At(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 ft.error("Error extracting domain",e),""}}(n);ft.debug("Checking merchant regex rules",{currentDomain:r,currentUrl:t});const o=e.merchantPopupRules.filter((e=>r.includes(e.domain)));if(0===o.length)return ft.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 ft.debug("Merchant regex rule matched",{merchant:e.name,rule:n.rule,currentUrl:t}),!0}catch(t){ft.error("Invalid regex in merchant rule",{merchant:e.name,rule:n.rule,error:t})}return ft.debug("No matching regex rules found",{currentUrl:t}),!1}catch(e){return ft.error("Error in merchantRegexRule",e),!1}}function bt(){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 xt(e){return!0!==e.checkoutPopupOnlyShowLanguageMatch||"en"===bt()}const vt=(e,t=!1)=>e.length<2&&t?null:Array.from(e).filter((e=>!t||e.dataset.extensionId!==X.runtime.id)).map((e=>e.dataset.extensionName)).join(",");var yt=R("<div class=gf-app>");function Ct(){const e=V.getInstance(),[t,n]=u(null),[r,o]=u(void 0),[i,s]=u(!1),[a,l]=u([]);f((async()=>{e.info("Mounting GfApp component");try{const i=await(async()=>{const e=await Z({type:Ue,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"});const a=Ve();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})(a,i.minVersion))return void e.debug(`Current version: ${a}. Minimum version ${i.minVersion} not met`);if(!1===i.checkoutPopupMasterSwitch)return void e.debug("Checkout popup master switch is disabled");const c=document.getElementsByClassName("give-freely-root");let g=!1;c.length>1&&(e.debug("There is more than one gf extension installed"),c.item(0).dataset.extensionId!==X.runtime.id&&(e.debug("Giving preference to the first gf extension injected in the DOM"),g=!0),e.debug("Providing this extension preference over the other installed extensions"));const{domain:u,rates:d}=await(async e=>{const{hostname:t}=window.location;e.debug("Checking if domain is active",{hostname:t});const n=await Z({type:Ge,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(d),o(u),u)await function(e,t){const n=mt(t)||ht();return n>0&&function(e,t,n){if(e&&!(e<=0))try{Z({type:je,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}(u,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 pt(parseInt(t));if(!n)return e.error("Shop domain not found"),void s(!1);e.debug("Shop domain found",{shopDomain:n}),o(n)}const p=await(async e=>{const t=await Le.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(p)return;if(!r())return void s(!1);const m=await(async(e,t)=>{const{Domain:n}=t,r=window.location.href,{payload:o}=await Z({type:He,payload:{activeDomain:n,url:r}});return!!o.result&&(e.info("Stand Down detected"),!0)})(e,r());if(m)return void s(!1);const h=t()?.anonymousActiveDomainLogging??!1,f=r()??void 0;f&&h&&!function(e){const t=`gfhv-${e}`;return!!sessionStorage.getItem(t)||(sessionStorage.setItem(t,"true"),!1)}(f.Domain)&&Ye.trackEvent(j.checkoutPopupActiveDomain,{url:f.Domain});const A=setInterval((async()=>{e.debug("Checking checkout rules");const t=await(async e=>{const t=V.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=mt(e)||ht();return!("shop.app"!==window.location.hostname&&!window.location.hostname.endsWith(".shop.app")||!(t>0)||!await pt(t))}(t),s=xt(e)&&(ut(n.pathname.toLowerCase())||dt(r,document)||At(e,r,o)||i);return t.debug("Popup show decision based on rules",{shouldShow:s,matchesCartRule:ut(n.pathname.toLowerCase()),matchesBookingRule:dt(r,document),matchesShopPayRule:i,matchesMerchantRegexRule:At(e,r,o),matchesLanguageRule:xt(e)}),s})(i);if(t&&g)return Ye.trackEvent(j.checkoutPopupLooserExtension,{url:globalThis.window.location.href,winner:c.item(0).dataset.extensionName}),e.debug("Standing down because, another ad-unit extension will pop"),void clearInterval(A);if(s(t),t){e.debug("Should show popup based on checkout rules",{shouldShowResult:t});const n=bt();Ye.trackEvent(j.checkoutPopupShown,{url:globalThis.window.location.href,pageLanguage:n,looserCompetingExtensions:vt(c,!0)}),clearInterval(A)}}),2e3)}catch(t){s(!1),e.error("An error occurred in GfApp",{error:t})}}));const c=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 J({type:Be,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}),Ye.trackEvent(r.payload.response?j.checkoutPopupDonation:j.checkoutPopupFailedActivation,{activeDomain:n.Domain,url:globalThis.window.location.href,charity:{ein:t.ein,tpi:t.tpi},rate:n.Merchant.MaxRate}),r.payload.response},g=async t=>{s(await(async(e,t)=>{try{e.info("Hiding ad",{days:t});const n=await J({type:Me,payload:{days:t??0}});return void 0!==t&&Ye.trackEvent(j.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))},d=async e=>{Ye.trackEvent(j.checkoutPopupOfferDetailsClicked,{action:e?"opened":"closed"})};return F(h=yt(),(p=m((()=>!(!r()||!i()))),()=>p()&&O(gt,{get checkoutPopupConf(){return t()},elementId:"give-freely-checkout-popup",get activeDomain(){return r()},get merchantRates(){return a()},onClose:g,onDonate:c,onOfferDetailsClick:d,logger:e}))),h;var p,h}exports.browser=X,exports.initializeAdUnit=async function(){const e=document.createElement("div");e.id=`give-freely-root-${X.runtime.id}`,e.className="give-freely-root",e.style.display="block",e.dataset.extensionId=X.runtime.id,e.dataset.extensionName=X.runtime.getManifest().name||X.runtime.id,document.body.appendChild(e);const t=e.attachShadow({mode:"open"}),n=document.createElement("div"),r=document.createElement("style");r.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',t.appendChild(r),t.appendChild(n),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((()=>h((()=>E(c)))));i=c,a=null;try{return C(g,!0)}finally{a=n,i=r}})((r=>{s=r,t===document?e():F(t,e(),t.firstChild?null:void 0,n)}),r.owner)}((()=>O(Ct,{})),n)};
|
|
1
|
+
"use strict";const e={equals:(e,t)=>e===t};let t=C;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[A.bind(r),e=>("function"==typeof e&&(e=e(r.value)),b(r,e))]}function d(e,t,r){x(v(e,t,!1,n))}function p(e,r,o){t=k;const i=v(e,r,!1,n);i.user=!0,c?c.push(i):x(i)}function m(t,n,r){r=r?Object.assign({},e,r):e;const o=v(t,n,!0,0);return o.observers=null,o.observerSlots=null,o.comparator=r.equals||void 0,x(o),A.bind(o)}function h(e){if(null===a)return e();const t=a;a=null;try{return e()}finally{a=t}}function f(e){p((()=>h(e)))}function A(){if(this.sources&&this.state)if(this.state===n)x(this);else{const e=l;l=null,w((()=>P(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&&w((()=>{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&&S(r)),o||(r.state=n)}if(l.length>1e6)throw l=[],new Error}),!1)),t}function x(e){if(!e.fn)return;E(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(E),e.owned=null),e.updatedAt=r+1,T(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 v(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 y(e){if(0===e.state)return;if(e.state===r)return P(e);if(e.suspense&&h(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)x(e);else if(e.state===r){const n=l;l=null,w((()=>P(e,t[0])),!1),l=n}}function w(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&&(C(l),l=null),e)return;const n=c;c=null,n.length&&w((()=>t(n)),!1)}(r),n}catch(e){r||(c=null),l=null,T(e)}}function C(e){for(let t=0;t<e.length;t++)y(e[t])}function k(e){let t,n=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[n++]=r:y(r)}for(t=0;t<n;t++)y(e[t])}function P(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)&&y(i):e===r&&P(i,t)}}}function S(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&&S(n))}}function E(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--)E(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)E(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 T(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 O(e,t){return h((()=>e(t||{})))}function D(e){const t=e.keyed,n=m((()=>e.when),void 0,{equals:(e,n)=>t?e===n:!e==!n});return m((()=>{const r=n();if(r){const o=e.children;return"function"==typeof o&&o.length>0?h((()=>o(t?r:()=>{if(!h(n))throw"Stale read from <Show>.";return e.when}))):o}return e.fallback}),void 0,void 0)}const I="_$DX_DELEGATE";function R(e,t,n){let r;const o=()=>{const t=document.createElement("template");return t.innerHTML=e,t.content.firstChild},i=t?()=>h((()=>document.importNode(r||(r=o()),!0))):()=>(r||(r=o())).cloneNode(!0);return i.cloneNode=i,i}function _(e,t=window.document){const n=t[I]||(t[I]=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,$))}}function N(e,t,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}function L(e,t,n){if(!t)return n?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 F(e,t,n,r){if(void 0===n||r||(r=[]),"function"!=typeof t)return M(e,t,r,n);d((r=>M(e,t(),r,n)),r)}function $(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 M(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=H(e,n,r,o)}else n=""!==n&&"string"==typeof n?e.firstChild.data=t:e.textContent=t}else if(null==t||"boolean"===i)n=H(e,n,r);else{if("function"===i)return d((()=>{let o=t();for(;"function"==typeof o;)o=o();n=M(e,o,n,r)})),()=>n;if(Array.isArray(t)){const i=[],a=n&&Array.isArray(n);if(U(i,t,n,o))return d((()=>n=M(e,i,n,r,!0))),()=>n;if(0===i.length){if(n=H(e,n,r),s)return n}else a?0===n.length?G(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&&H(e),G(e,i));n=i}else if(t.nodeType){if(Array.isArray(n)){if(s)return n=H(e,n,r,t);H(e,n,null,t)}else null!=n&&""!==n&&e.firstChild?e.replaceChild(t,e.firstChild):e.appendChild(t);n=t}}return n}function U(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=U(e,a,l)||o;else if("function"===s)if(r){for(;"function"==typeof a;)a=a();o=U(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 G(e,t,n=null){for(let r=0,o=t.length;r<o;r++)e.insertBefore(t[r],n)}function H(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 B{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}] - ${B.LOGGER_PREFIX} ${s} ${t}`,r):console[i](`[${n}] - ${B.LOGGER_PREFIX} ${s} ${t}`)}}var j,K;B.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"}(j||(j={})),function(e){e.adUnitLog="ADUNIT-LOG"}(K||(K={}));const W=["debug","info","warn","error"];class V{constructor(e){this.config={minLevel:e?.minLevel??"debug",enabled:e?.enabled??!1,transports:e?.transports??[new B],title:e?.title??""}}static getInstance(e){return V.instance||(V.instance=new V(e)),V.instance}configure(e){this.config={...this.config,...e}}shouldLog(e){return!!this.config.enabled&&W.indexOf(e)>=W.indexOf(this.config.minLevel)}createLogMessage(e,t,n){return{level:e,version:"1.4.2",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 Y=3,z=e=>1e3*e;async function q(e,t={}){const{maxAttempts:n=Y,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 X=chrome;async function Z(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||X.runtime.sendMessage(e,o)}catch(e){r(e)}}))}async function J(e,t,n){return q((()=>Z(e,t)),{maxAttempts:Y,delayFn:z})}const Q={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"}},ee={height:"100%","overflow-x":"hidden","overlfow-y":"auto",position:"relative",padding:"0px 15px"},te={},ne={display:"flex","align-items":"center","margin-bottom":"10px"},re={flex:"1","font-size":"24px","font-weight":"700","margin-top":"20px","margin-bottom":"0px"},oe={background:"none",border:"none",padding:"4px 8px",color:"#666464","font-size":"38px",cursor:"pointer","line-height":"1"},ie={color:"black","margin-top":"20px","max-width":"40%"},se={color:"gray",cursor:"default","pointer-events":"none","text-decoration":"none"},ae={"font-size":"18px","font-weight":"400","margin-top":"20px","margin-bottom":"0px"},le={display:"flex",gap:"10px",width:"100%","margin-top":"20px","margin-bottom":"20px","flex-wrap":"wrap","justify-content":"space-between"},ce={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"},ge={color:"white","background-color":"lightgray",cursor:"default","pointer-events":"none"},ue={"max-width":"120px","max-height":"70px","margin-bottom":"5px","object-fit":"contain"},de={"background-color":"#FFD812",cursor:"pointer","border-radius":"8px",padding:"8px",color:"white","min-width":"100px",border:"0","font-weight":"600",width:"100%"},pe={display:"flex","flex-direction":"column",gap:"10px",width:"100%","color-scheme":"light"},me={display:"flex","align-items":"center",gap:"5px",border:"1px solid #ddd",padding:"15px","border-radius":"5px","font-weight":"600",cursor:"pointer","margin-bottom":"8px"},he={"text-align":"right"},fe={background:"none",border:"none",color:"blue","text-decoration":"underline",padding:"0",cursor:"pointer","margin-bottom":"15px"},Ae={display:"flex","justify-content":"space-between",margin:"20px 0px 10px 0px","font-size":"14px"},be={margin:"5px 0px 5px 0px","font-size":"14px","text-align":"center"},xe={color:"#666464","text-decoration":"underline"},ve={color:"rgb(102, 100, 100)","text-decoration":"underline",margin:"0",cursor:"pointer"},ye={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"},we={padding:"0 5px 0 10px",width:"100%","font-size":"12px","box-sizing":"border-box"},Ce={display:"grid","grid-template-columns":"4fr 1fr","padding-right":"15px","padding-bottom":"5px"},ke={color:"#000","margin-bottom":"4px"},Pe={"font-size":"14px",color:"#555","text-align":"right"},Se=(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 Ee=R("<span>");function Te(e){return t=Ee(),d((()=>{return t.innerHTML=(n=e.title,r=e.activeDomain,n.replace("{0}",Se(r.Merchant.MaxRate?.Kind,r.Merchant.MaxRate?.Amount??"0")));var n,r})),t;var t}var Oe=R("<div>"),De=R("<div><div class=gf-offer-details><p>Select a charity to activate a donation during your online shopping session.</p><p> <b>Eligible Transaction:</b> A purchase made immediately after selecting a charity.</p><p><b>Donation rates:</b> <!> for each eligible transaction. The following donation rates and exclusions apply:</p><p><b>Donation amounts:</b> Donation amount is calculated based upon the applicable rates and exclusions, which may change from time to time. Amounts may be adjusted or canceled due to returned items, suspected fraud, or other factors described within the terms and conditions.</p><p><b>Donation timing:</b> On average, donation payouts occur 60-120 days after your completed transaction, but some donations may take 180 days or longer. We provide a donation to the charity you had selected at the time of purchase, in monthly batches, after any holdback periods due to applicable return or cancellation policies have passed.</p><p>See a summary of <a target=_blank rel=noreferrer>terms and conditions</a>."),Ie=R("<div class=gf-offer-details-rate-item><div></div><div>");const Re=e=>{return t=De(),o=(r=(n=t.firstChild).firstChild.nextSibling.nextSibling).firstChild.nextSibling.nextSibling,i=r.nextSibling,s=i.nextSibling.nextSibling.firstChild.nextSibling,F(r,(()=>e.parsedMaxRate?`Up to ${e.parsedMaxRate}`:"Earn"),o),F(n,O(D,{get when(){return!!e.merchantRateDetail?.length},get children(){var t=Oe();return F(t,(()=>e.merchantRateDetail?.map((e=>{return t=Ie(),n=t.firstChild,r=n.nextSibling,F(n,(()=>e.Name||"")),F(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=Ce,i=ke,s=Pe;return e.e=L(t,o,e.e),e.t=L(n,i,e.t),e.a=L(r,s,e.a),e}),{e:void 0,t:void 0,a:void 0}),t;var t,n,r})))),t}}),i),d((r=>{var o=ye,i=we,a=xe,l=e.termsUrl;return r.e=L(t,o,r.e),r.t=L(n,i,r.t),r.a=L(s,a,r.a),l!==r.o&&N(s,"href",r.o=l),r}),{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t,n,r,o,i,s};function _e(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 Ne={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)}))},m={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})}},h={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return n.privacy={network:{"*":h},services:{"*":h},websites:{"*":h}},l(e,m,n)};e.exports=n(chrome)}}(Ne);var Le=_e(Ne.exports);const Fe="GIVE_FREELY_",$e={async get(e){const t=`${Fe}${e}`;return(await Le.storage.local.get(t))[t]||null},async set(e,t){const n=`${Fe}${e}`;await Le.storage.local.set({[n]:t})},async remove(e){const t=Array.isArray(e)?e.map((e=>`${Fe}${e}`)):`${Fe}${e}`;await Le.storage.local.remove(t)}};class Me{constructor(e){this.partnerApiKey=e,this.partnerConfig=null,this.globalConfig=null,this.lastConfigRefresh=0,this.CONFIG_REFRESH_INTERVAL=3e5,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(`https://cdn.givefreely.com/adunit/config/${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 $e.set(this.PARTNER_CONFIG_STORAGE_KEY,t),e}async fetchAndUpdateGlobalConfig(){const e=await q((async()=>{const e=await fetch("https://cdn.givefreely.com/adunit/config/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 $e.set(this.GLOBAL_CONFIG_STORAGE_KEY,t),e}async getConfig(){const e=Date.now(),t=await $e.get(this.PARTNER_CONFIG_STORAGE_KEY),n=await $e.get(this.GLOBAL_CONFIG_STORAGE_KEY);if(this.partnerConfig=t?.config||null,this.globalConfig=n?.config||null,this.lastConfigRefresh=Math.max(t?.lastRefresh||0,n?.lastRefresh||0),!this.partnerConfig||!this.globalConfig||e-this.lastConfigRefresh>this.CONFIG_REFRESH_INTERVAL)try{const[t,n]=await Promise.all([this.fetchAndUpdatePartnerConfig(),this.fetchAndUpdateGlobalConfig()]);this.partnerConfig=t,this.globalConfig=n,this.lastConfigRefresh=e}catch(e){if(!this.partnerConfig||!this.globalConfig)throw e}const r=this.mergeConfigs(this.globalConfig,this.partnerConfig);return((e,t,n)=>{const r=[...t.merchantExclusions??[],...n.merchantExclusions??[]];e.merchantExclusions=r})(r,this.globalConfig,this.partnerConfig),r}async clearCache(){await Promise.all([$e.remove(this.PARTNER_CONFIG_STORAGE_KEY),$e.remove(this.GLOBAL_CONFIG_STORAGE_KEY)]),this.partnerConfig=null,this.globalConfig=null,this.lastConfigRefresh=0}mergeConfigs(e,t){if(!t)return e;const n={...e};return Object.keys(t).forEach((r=>{if(!Object.prototype.hasOwnProperty.call(t,r))return;const o=e[r],i=t[r];Array.isArray(i)&&Array.isArray(o)?n[r]=i:n[r]=null===i||"object"!=typeof i||"object"!=typeof o?void 0!==i?i:o:this.mergeConfigs(o,i)})),n}getStoredState(e){return e?{config:e.config,lastRefresh:e.lastRefresh}:{config:null,lastRefresh:0}}}const Ue="TRACK_EVENT",Ge="GF_HIDE_POPUP",He="GF_GET_POPUP_CONFIG",Be="GF_IS_ACTIVE_DOMAIN",je="GF_SHOULD_STAND_DOWN",Ke="GF_ACTIVATE_OFFER",We="GF_STORE_SHOPIFY_SHOP_ID",Ve="GF_GET_DOMAIN_BY_SHOP_ID",Ye={ein:"0",tpi:"0",logo:"",title:"Unknown Charity"},ze=()=>String("1.4.2");class qe{constructor(e,t,n=60){this._config=null,this.track=async(e,t,n)=>{null===this._config&&(this._config=await new Me(this._partnerApiKey).getConfig());const r={partner:`adUnit_${this._partnerApiKey}`,eventType:e,eventData:{userId:this._userService?.user?.id,libVersion:ze(),wfDeviceId:t,...n}};try{const e=JSON.stringify(r);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",r),!1)}catch(e){return this._logger.info("Something unexpected happened when dispatching a gf event",{error:e,event:r}),!1}},this.getEventsHistory=async()=>{const{GF_AD_EVENT_HISTORY:e}=await X.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 X.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 X.storage.local.set({GF_AD_EVENT_HISTORY:t})},this._partnerApiKey=e,this._userService=t,this._debounceWindowInMinutes=n,this._logger=V.getInstance({title:"Analytics"})}}function Xe(e,t,n){return e?{...t,...n}:t}qe.trackEvent=async(e,t)=>{await Z({type:Ue,payload:{eventType:e,eventData:t}})};var Ze=R("<a href=#!>"),Je=R("<button class=give-freely-close-button aria-label=Close>×"),Qe=R('<div><div><div><span></span></div></div><hr><div></div><div><div><div><br><span></span></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">'),et=R("<div><div><img><span></span></div><button>"),tt=R("<div>");function nt(e){const[t,n]=u(!1),[r,o]=u(null);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 i=(e,t)=>o({charity:e,closeOnDonation:t}),s=()=>!!r()?.charity;return[(l=Qe(),c=l.firstChild,g=c.firstChild,h=g.firstChild,f=c.nextSibling.nextSibling,A=f.nextSibling,b=A.firstChild,x=b.firstChild,v=x.firstChild.nextSibling,y=x.nextSibling,w=A.nextSibling,C=w.firstChild,k=C.nextSibling,F(c,O(D,{get when(){return e.checkoutPopupConf.checkoutPopupActivateAndClose},get children(){var t=Ze();return t.$$click=()=>i(Ye,!0),d((n=>{var r=Xe(s(),ie,se),o=e.checkoutPopupConf.checkoutPopupActivateAndClose;return n.e=L(t,r,n.e),o!==n.t&&(t.innerHTML=n.t=o),n}),{e:void 0,t:void 0}),t}}),null),F(c,O(D,{get when(){return e.checkoutPopupConf.checkoutPopupMainCloseButtonVisible&&!e.checkoutPopupConf.checkoutPopupActivateAndClose},get children(){var t=Je();return t.$$click=()=>e.onClose(),d((e=>L(t,oe,e))),t}}),null),F(f,O(Te,{get title(){return e.subtitle},get activeDomain(){return e.activeDomain}})),F(A,(()=>e.checkoutPopupConf.checkoutPopupCharities.map((t=>{return o=(r=et()).firstChild,l=(a=o.firstChild).nextSibling,c=o.nextSibling,r.$$click=()=>!s()&&i(t),F(r,(n=m((()=>!!(t.decorator&&t.decoratorLeftStyle&&t.decoratorRightStyle))),()=>{return n()&&[(r=tt(),d((e=>{var n=t.decoratorLeftStyle,o=t.decorator;return e.e=L(r,n,e.e),o!==e.t&&(r.innerHTML=e.t=o),e}),{e:void 0,t:void 0}),r),(e=tt(),d((n=>{var r=t.decoratorRightStyle,o=t.decorator;return n.e=L(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"),F(l,(()=>t.title)),F(c,(()=>e.checkoutPopupConf.checkoutPopupCharitySelectString||"Select")),d((n=>{var o=Xe(s(),ce,{cursor:"default"}),i=t.logo,l=ue,g=t.title,u=Xe(s(),{...de,"background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812"},ge),d=s(),p=`Select charity: ${t.title}`;return n.e=L(r,o,n.e),i!==n.t&&N(a,"src",n.t=i),n.a=L(a,l,n.a),g!==n.o&&N(a,"alt",n.o=g),n.i=L(c,u,n.i),d!==n.n&&(c.disabled=n.n=d),p!==n.s&&N(c,"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,a,l,c}))),b),b.$$click=()=>!s()&&e.onSuppress(),x.style.setProperty("height","100px"),x.style.setProperty("text-align","center"),F(y,(()=>e.checkoutPopupConf.checkoupPopupDontShowAgainButtonText||"Settings...")),C.$$click=()=>{e.onOfferDetailsClick(!t()),n(!t())},F(C,(()=>e.checkoutPopupConf.checkoutPopupOfferDetailsLabelString||"Offer Details")),k.$$click=()=>{qe.trackEvent(j.checkoutPopupWhyAmISeeingThisClicked,{domain:globalThis.window.location.hostname})},F(k,(()=>e.checkoutPopupConf.checkoutPopupWhyAmISeeingThisLabelString||"Why am I seeing this?")),F(l,(a=m((()=>!!e.checkoutPopupConf.checkoutPopupDisplayNameInFooter)),()=>{return a()&&(t=tt(),d((n=>{var r=be,o=e.checkoutPopupConf.checkoutPopupDisplayNameInFooter;return n.e=L(t,r,n.e),o!==n.t&&(t.innerHTML=n.t=o),n}),{e:void 0,t:void 0}),t);var t}),null),d((t=>{var n=te,r=ne,o=re,i=e.checkoutPopupConf.checkoutPopupMainTitle,a=ae,u=le,d=Xe(s(),ce,{cursor:"default"}),p=e.checkoutPopupConf.checkoutPopupSixthBoxWording,m=Xe(s(),{...de,"background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812"},ge),x=s(),P=Ae,S=ve,E=xe,T=e.checkoutPopupConf.externalUrls.giveFreelyWhyAmISeeingThis;return t.e=L(l,n,t.e),t.t=L(c,r,t.t),t.a=L(g,o,t.a),i!==t.o&&(h.innerHTML=t.o=i),t.i=L(f,a,t.i),t.n=L(A,u,t.n),t.s=L(b,d,t.s),p!==t.h&&(v.innerHTML=t.h=p),t.r=L(y,m,t.r),x!==t.d&&(y.disabled=t.d=x),t.l=L(w,P,t.l),t.u=L(C,S,t.u),t.c=L(k,E,t.c),T!==t.w&&N(k,"href",t.w=T),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,w:void 0}),l),O(D,{get when(){return t()},get children(){return O(Re,{get merchantName(){return e.activeDomain.Merchant.Name},get extensionName(){return e.checkoutPopupConf.displayName},get termsUrl(){return e.checkoutPopupConf.externalUrls.giveFreelyTermsAndConditions},get parsedMaxRate(){return m((()=>!!e.activeDomain.Merchant.MaxRate))()?Se(e.activeDomain.Merchant.MaxRate.Kind,e.activeDomain.Merchant.MaxRate?.Amount):null},get merchantRateDetail(){return e.merchantRates},onClose:()=>n(!1)})}})];var a,l,c,g,h,f,A,b,x,v,y,w,C,k}_(["click"]);var rt=R("<button class=give-freely-close-button aria-label=Close>×"),ot=R("<label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=18250><span>Don't ask me again... ever"),it=R("<div><div><div></div></div><button class=give-freely-back-button aria-label=\"Back to charity selection\">I changed my mind! I'd like to select a charity.</button><hr><div id=give-freely-goodbye-screen-options><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=1><span>Don't ask me again for 1 day</span></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=7><span>Don't ask me again for 7 days</span></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=30><span>Don't ask me again for 30 days</span></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=90><span>Don't ask me again for 90 days</span></label></div><button class=give-freely-submit-button>Submit");function st(e){const[t,n]=u(0);return r=it(),o=r.firstChild,i=o.firstChild,s=o.nextSibling,a=s.nextSibling.nextSibling,c=(l=a.firstChild).firstChild,p=(g=l.nextSibling).firstChild,h=(m=g.nextSibling).firstChild,A=(f=m.nextSibling).firstChild,b=a.nextSibling,r.style.setProperty("font-size","14px"),F(i,(()=>e.checkoutPopupConf.checkoutPopupSupressTitle)),F(o,O(D,{get when(){return e.checkoutPopupConf.checkoutPopupSupressCloseButtonVisible},get children(){var t=rt();return t.$$click=()=>e.onGoodbye(0),d((e=>L(t,oe,e))),t}}),null),s.$$click=()=>e.onBack(),c.addEventListener("change",(()=>n(1))),p.addEventListener("change",(()=>n(7))),h.addEventListener("change",(()=>n(30))),A.addEventListener("change",(()=>n(90))),F(a,O(D,{get when(){return e.checkoutPopupConf.checkoutPopupNeverSuppressionAllowed},get children(){var e=ot();return e.firstChild.addEventListener("change",(()=>n(18250))),d((t=>L(e,me,t))),e}}),null),b.$$click=()=>{const n=t();n&&(e.onGoodbye(n),e.setScreen("main"))},d((t=>{var n=ne,r=re,c=fe,u=pe,d=me,p=me,h=me,A=me,x={...de,"font-weight":"700","margin-top":"10px","margin-bottom":"0px","background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812",width:"100px"};return t.e=L(o,n,t.e),t.t=L(i,r,t.t),t.a=L(s,c,t.a),t.o=L(a,u,t.o),t.i=L(l,d,t.i),t.n=L(g,p,t.n),t.s=L(m,h,t.s),t.h=L(f,A,t.h),t.r=L(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}),r;var r,o,i,s,a,l,c,g,p,m,h,f,A,b}_(["click"]);class at{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 lt=R("<div><p>"),ct=R("<div><div><div></div><button class=give-freely-close-button aria-label=Close>×</button></div><hr><div><span>");function gt(e){const[t,n]=u(null);let r;var o,s,a,l,c,g,p;return o=()=>clearInterval(r),null===i||(null===i.cleanups?i.cleanups=[o]:i.cleanups.push(o)),f((()=>{e.failedDonation||(()=>{const t=e.checkoutPopupConf.checkoutPopupDonationSuccessAutoCloseInSeconds??3;n(t),r=setInterval((()=>{n((t=>null===t||t<=1?(clearInterval(r),e.onClose(),0):t-1))}),1e3)})()})),s=ct(),a=s.firstChild,l=a.firstChild,c=l.nextSibling,g=a.nextSibling.nextSibling,p=g.firstChild,s.style.setProperty("font-size","14px"),F(l,(()=>e.failedDonation?"Oops! Something went wrong":e.checkoutPopupConf.checkoutPopupDonationTitle)),c.$$click=()=>e.onClose(),g.style.setProperty("padding","30px"),g.style.setProperty("height","150px"),g.style.setProperty("font-size","14px"),F(s,O(D,{get when(){return!e.failedDonation},get children(){var n=lt(),r=n.firstChild;return F(r,(()=>at.formatMessage(e.checkoutPopupConf.checkoutPopupDonationSuccessAutoCloseLabelStringMask||"Closing in {0}",t()??0))),d((e=>L(r,he,e))),n}}),null),d((t=>{var n=ne,r=re,o=oe,i=e.failedDonation?"Please try again later.":e.checkoutPopupConf.checkoutPopupDonationWording;return t.e=L(a,n,t.e),t.t=L(l,r,t.t),t.a=L(c,o,t.a),i!==t.o&&(p.innerHTML=t.o=i),t}),{e:void 0,t:void 0,a:void 0,o:void 0}),s}_(["click"]);var ut=R("<div><div>");const dt=(e,t,n)=>"donate"===e?"340px":t.checkoutPopupDisplayNameInFooter?"520px":n;function pt(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 m;return b=ut(),x=b.firstChild,"function"==typeof m?(f=m,A=x,h((()=>f(A,undefined)))):m=x,F(x,O(D,{get when(){return"main"===t()},get children(){return O(nt,{mainContainerRef:m,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},get subtitle(){return e.checkoutPopupConf.checkoutPopupSubTitle}})}}),null),F(x,O(D,{get when(){return"goodbye"===t()},get children(){return O(st,{get checkoutPopupConf(){return e.checkoutPopupConf},onClose:()=>e.onClose(),onBack:g,onGoodbye:p,setScreen:n})}}),null),F(x,O(D,{get when(){return"donate"===t()},get children(){return O(gt,{get checkoutPopupConf(){return e.checkoutPopupConf},get selectedCharity(){return r()},onClose:()=>e.onClose(),get failedDonation(){return i()},setScreen:n})}}),null),d((n=>{var r={...Q,height:dt(t(),e.checkoutPopupConf,Q.height)},o=e.elementId,i=ee;return n.e=L(b,r,n.e),o!==n.t&&N(b,"id",n.t=o),n.a=L(x,i,n.a),n}),{e:void 0,t:void 0,a:void 0}),b;var f,A,b,x}function mt(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 ht(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 ft(e){try{const t=await Z({type:Ve,payload:{shopId:e}});return t.payload.found&&t.payload.domain?t.payload.domain:null}catch{return null}}function At(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 bt(){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 xt=V.getInstance();function vt(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 xt.error("Error extracting domain",e),""}}(n);xt.debug("Checking merchant regex rules",{currentDomain:r,currentUrl:t});const o=e.merchantPopupRules.filter((e=>r.includes(e.domain)));if(0===o.length)return xt.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 xt.debug("Merchant regex rule matched",{merchant:e.name,rule:n.rule,currentUrl:t}),!0}catch(t){xt.error("Invalid regex in merchant rule",{merchant:e.name,rule:n.rule,error:t})}return xt.debug("No matching regex rules found",{currentUrl:t}),!1}catch(e){return xt.error("Error in merchantRegexRule",e),!1}}function yt(){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 wt(e){return!0!==e.checkoutPopupOnlyShowLanguageMatch||"en"===yt()}const Ct=(e,t=!1)=>e.length<2&&t?null:Array.from(e).filter((e=>!t||e.dataset.extensionId!==X.runtime.id)).map((e=>e.dataset.extensionName)).join(",");var kt=R("<div class=gf-app>");function Pt(){const e=V.getInstance(),[t,n]=u(null),[r,o]=u(void 0),[i,s]=u(!1),[a,l]=u([]);f((async()=>{e.info("Mounting GfApp component");try{const i=await(async()=>{const e=await Z({type:He,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"});const a=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})(a,i.minVersion))return void e.debug(`Current version: ${a}. Minimum version ${i.minVersion} not met`);if(!1===i.checkoutPopupMasterSwitch)return void e.debug("Checkout popup master switch is disabled");const c=document.getElementsByClassName("give-freely-root");let g=!1;c.length>1&&(e.debug("There is more than one gf extension installed"),c.item(0).dataset.extensionId!==X.runtime.id&&(e.debug("Giving preference to the first gf extension injected in the DOM"),g=!0),e.debug("Providing this extension preference over the other installed extensions"));const{domain:u,rates:d}=await(async e=>{const{hostname:t}=window.location;e.debug("Checking if domain is active",{hostname:t});const n=await Z({type:Be,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(d),o(u),u)await function(e,t){const n=At(t)||bt();return n>0&&function(e,t,n){if(e&&!(e<=0))try{Z({type:We,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}(u,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 ft(parseInt(t));if(!n)return e.error("Shop domain not found"),void s(!1);e.debug("Shop domain found",{shopDomain:n}),o(n)}const p=await(async e=>{const t=await $e.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(p)return;if(!r())return void s(!1);const m=await(async(e,t)=>{const{Domain:n}=t,r=window.location.href,{payload:o}=await Z({type:je,payload:{activeDomain:n,url:r}});return!!o.result&&(e.info("Stand Down detected"),!0)})(e,r());if(m)return void s(!1);const h=t()?.anonymousActiveDomainLogging??!1,f=r()??void 0;f&&h&&!function(e){const t=`gfhv-${e}`;return!!sessionStorage.getItem(t)||(sessionStorage.setItem(t,"true"),!1)}(f.Domain)&&qe.trackEvent(j.checkoutPopupActiveDomain,{url:f.Domain});const A=setInterval((async()=>{e.debug("Checking checkout rules");const t=await(async e=>{const t=V.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=At(e)||bt();return!("shop.app"!==window.location.hostname&&!window.location.hostname.endsWith(".shop.app")||!(t>0)||!await ft(t))}(t),s=wt(e)&&(mt(n.pathname.toLowerCase())||ht(r,document)||vt(e,r,o)||i);return t.debug("Popup show decision based on rules",{shouldShow:s,matchesCartRule:mt(n.pathname.toLowerCase()),matchesBookingRule:ht(r,document),matchesShopPayRule:i,matchesMerchantRegexRule:vt(e,r,o),matchesLanguageRule:wt(e)}),s})(i);if(t&&g)return qe.trackEvent(j.checkoutPopupLooserExtension,{url:globalThis.window.location.href,winner:c.item(0).dataset.extensionName}),e.debug("Standing down because, another ad-unit extension will pop"),void clearInterval(A);if(s(t),t){e.debug("Should show popup based on checkout rules",{shouldShowResult:t});const n=yt();qe.trackEvent(j.checkoutPopupShown,{url:globalThis.window.location.href,pageLanguage:n,looserCompetingExtensions:Ct(c,!0)}),clearInterval(A)}}),2e3)}catch(t){s(!1),e.error("An error occurred in GfApp",{error:t})}}));const c=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 J({type:Ke,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}),qe.trackEvent(r.payload.response?j.checkoutPopupDonation:j.checkoutPopupFailedActivation,{activeDomain:n.Domain,url:globalThis.window.location.href,charity:{ein:t.ein,tpi:t.tpi},rate:n.Merchant.MaxRate}),r.payload.response},g=async t=>{s(await(async(e,t)=>{try{e.info("Hiding ad",{days:t});const n=await J({type:Ge,payload:{days:t??0}});return void 0!==t&&qe.trackEvent(j.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))},d=async e=>{qe.trackEvent(j.checkoutPopupOfferDetailsClicked,{action:e?"opened":"closed"})};return F(h=kt(),(p=m((()=>!(!r()||!i()))),()=>p()&&O(pt,{get checkoutPopupConf(){return t()},elementId:"give-freely-checkout-popup",get activeDomain(){return r()},get merchantRates(){return a()},onClose:g,onDonate:c,onOfferDetailsClick:d,logger:e}))),h;var p,h}exports.browser=X,exports.initializeAdUnit=async function(){const e=`give-freely-root-${X.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=X.runtime.id,t.dataset.extensionName=X.runtime.getManifest().name||X.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((()=>h((()=>E(c)))));i=c,a=null;try{return w(g,!0)}finally{a=n,i=r}})((r=>{s=r,t===document?e():F(t,e(),t.firstChild?null:void 0,n)}),r.owner)}((()=>O(Pt,{})),r)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={equals:(e,t)=>e===t};let t=w;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[A.bind(r),e=>("function"==typeof e&&(e=e(r.value)),b(r,e))]}function d(e,t,r){x(v(e,t,!1,n))}function p(e,r,o){t=k;const i=v(e,r,!1,n);i.user=!0,c?c.push(i):x(i)}function m(t,n,r){r=r?Object.assign({},e,r):e;const o=v(t,n,!0,0);return o.observers=null,o.observerSlots=null,o.comparator=r.equals||void 0,x(o),A.bind(o)}function h(e){if(null===a)return e();const t=a;a=null;try{return e()}finally{a=t}}function f(e){p((()=>h(e)))}function A(){if(this.sources&&this.state)if(this.state===n)x(this);else{const e=l;l=null,C((()=>P(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&&C((()=>{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&&S(r)),o||(r.state=n)}if(l.length>1e6)throw l=[],new Error}),!1)),t}function x(e){if(!e.fn)return;E(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(E),e.owned=null),e.updatedAt=r+1,T(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 v(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 y(e){if(0===e.state)return;if(e.state===r)return P(e);if(e.suspense&&h(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)x(e);else if(e.state===r){const n=l;l=null,C((()=>P(e,t[0])),!1),l=n}}function C(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&&(w(l),l=null),e)return;const n=c;c=null,n.length&&C((()=>t(n)),!1)}(r),n}catch(e){r||(c=null),l=null,T(e)}}function w(e){for(let t=0;t<e.length;t++)y(e[t])}function k(e){let t,n=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[n++]=r:y(r)}for(t=0;t<n;t++)y(e[t])}function P(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)&&y(i):e===r&&P(i,t)}}}function S(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&&S(n))}}function E(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--)E(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)E(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 T(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 O(e,t){return h((()=>e(t||{})))}function D(e){const t=e.keyed,n=m((()=>e.when),void 0,{equals:(e,n)=>t?e===n:!e==!n});return m((()=>{const r=n();if(r){const o=e.children;return"function"==typeof o&&o.length>0?h((()=>o(t?r:()=>{if(!h(n))throw"Stale read from <Show>.";return e.when}))):o}return e.fallback}),void 0,void 0)}const I="_$DX_DELEGATE";function R(e,t,n){let r;const o=()=>{const t=document.createElement("template");return t.innerHTML=e,t.content.firstChild},i=t?()=>h((()=>document.importNode(r||(r=o()),!0))):()=>(r||(r=o())).cloneNode(!0);return i.cloneNode=i,i}function _(e,t=window.document){const n=t[I]||(t[I]=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,$))}}function N(e,t,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}function L(e,t,n){if(!t)return n?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 F(e,t,n,r){if(void 0===n||r||(r=[]),"function"!=typeof t)return M(e,t,r,n);d((r=>M(e,t(),r,n)),r)}function $(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 M(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=H(e,n,r,o)}else n=""!==n&&"string"==typeof n?e.firstChild.data=t:e.textContent=t}else if(null==t||"boolean"===i)n=H(e,n,r);else{if("function"===i)return d((()=>{let o=t();for(;"function"==typeof o;)o=o();n=M(e,o,n,r)})),()=>n;if(Array.isArray(t)){const i=[],a=n&&Array.isArray(n);if(U(i,t,n,o))return d((()=>n=M(e,i,n,r,!0))),()=>n;if(0===i.length){if(n=H(e,n,r),s)return n}else a?0===n.length?G(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&&H(e),G(e,i));n=i}else if(t.nodeType){if(Array.isArray(n)){if(s)return n=H(e,n,r,t);H(e,n,null,t)}else null!=n&&""!==n&&e.firstChild?e.replaceChild(t,e.firstChild):e.appendChild(t);n=t}}return n}function U(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=U(e,a,l)||o;else if("function"===s)if(r){for(;"function"==typeof a;)a=a();o=U(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 G(e,t,n=null){for(let r=0,o=t.length;r<o;r++)e.insertBefore(t[r],n)}function H(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 B{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}] - ${B.LOGGER_PREFIX} ${s} ${t}`,r):console[i](`[${n}] - ${B.LOGGER_PREFIX} ${s} ${t}`)}}var j,K;B.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"}(j||(j={})),function(e){e.adUnitLog="ADUNIT-LOG"}(K||(K={}));const W=["debug","info","warn","error"];class V{constructor(e){this.config={minLevel:e?.minLevel??"debug",enabled:e?.enabled??!1,transports:e?.transports??[new B],title:e?.title??""}}static getInstance(e){return V.instance||(V.instance=new V(e)),V.instance}configure(e){this.config={...this.config,...e}}shouldLog(e){return!!this.config.enabled&&W.indexOf(e)>=W.indexOf(this.config.minLevel)}createLogMessage(e,t,n){return{level:e,version:"1.4.2",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 Y=3,z=e=>1e3*e;async function q(e,t={}){const{maxAttempts:n=Y,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 X=chrome;async function Z(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||X.runtime.sendMessage(e,o)}catch(e){r(e)}}))}async function J(e,t,n){return q((()=>Z(e,t)),{maxAttempts:Y,delayFn:z})}const Q={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"}},ee={height:"100%","overflow-x":"hidden","overlfow-y":"auto",position:"relative",padding:"0px 15px"},te={},ne={display:"flex","align-items":"center","margin-bottom":"10px"},re={flex:"1","font-size":"24px","font-weight":"700","margin-top":"20px","margin-bottom":"0px"},oe={background:"none",border:"none",padding:"4px 8px",color:"#666464","font-size":"38px",cursor:"pointer","line-height":"1"},ie={color:"black","margin-top":"20px","max-width":"40%"},se={"font-size":"18px","font-weight":"400","margin-top":"20px","margin-bottom":"0px"},ae={display:"flex",gap:"10px",width:"100%","margin-top":"20px","margin-bottom":"20px","flex-wrap":"wrap","justify-content":"space-between"},le={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"},ce={"max-width":"120px","max-height":"70px","margin-bottom":"5px","object-fit":"contain"},ge={"background-color":"#FFD812",cursor:"pointer","border-radius":"8px",padding:"8px",color:"white","min-width":"100px",border:"0","font-weight":"600",width:"100%"},ue={display:"flex","flex-direction":"column",gap:"10px",width:"100%","color-scheme":"light"},de={display:"flex","align-items":"center",gap:"5px",border:"1px solid #ddd",padding:"15px","border-radius":"5px","font-weight":"600",cursor:"pointer","margin-bottom":"8px"},pe={"text-align":"right"},me={background:"none",border:"none",color:"blue","text-decoration":"underline",padding:"0",cursor:"pointer","margin-bottom":"15px"},he={display:"flex","justify-content":"space-between",margin:"20px 0px 10px 0px","font-size":"14px"},fe={margin:"5px 0px 5px 0px","font-size":"14px","text-align":"center"},Ae={color:"#666464","text-decoration":"underline"},be={color:"rgb(102, 100, 100)","text-decoration":"underline",margin:"0",cursor:"pointer"},xe={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"},ve={padding:"0 5px 0 10px",width:"100%","font-size":"12px","box-sizing":"border-box"},ye={display:"grid","grid-template-columns":"4fr 1fr","padding-right":"15px","padding-bottom":"5px"},Ce={color:"#000","margin-bottom":"4px"},we={"font-size":"14px",color:"#555","text-align":"right"},ke=(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 Pe=R("<span>");function Se(e){return t=Pe(),d((()=>{return t.innerHTML=(n=e.title,r=e.activeDomain,n.replace("{0}",ke(r.Merchant.MaxRate?.Kind,r.Merchant.MaxRate?.Amount??"0")));var n,r})),t;var t}var Ee=R("<div>"),Te=R("<div><div class=gf-offer-details><p>Select a charity to activate a donation during your online shopping session.</p><p> <b>Eligible Transaction:</b> A purchase made immediately after selecting a charity.</p><p><b>Donation rates:</b> <!> for each eligible transaction. The following donation rates and exclusions apply:</p><p><b>Donation amounts:</b> Donation amount is calculated based upon the applicable rates and exclusions, which may change from time to time. Amounts may be adjusted or canceled due to returned items, suspected fraud, or other factors described within the terms and conditions.</p><p><b>Donation timing:</b> On average, donation payouts occur 60-120 days after your completed transaction, but some donations may take 180 days or longer. We provide a donation to the charity you had selected at the time of purchase, in monthly batches, after any holdback periods due to applicable return or cancellation policies have passed.</p><p>See a summary of <a target=_blank rel=noreferrer>terms and conditions</a>."),Oe=R("<div class=gf-offer-details-rate-item><div></div><div>");const De=e=>{return t=Te(),o=(r=(n=t.firstChild).firstChild.nextSibling.nextSibling).firstChild.nextSibling.nextSibling,i=r.nextSibling,s=i.nextSibling.nextSibling.firstChild.nextSibling,F(r,(()=>e.parsedMaxRate?`Up to ${e.parsedMaxRate}`:"Earn"),o),F(n,O(D,{get when(){return!!e.merchantRateDetail?.length},get children(){var t=Ee();return F(t,(()=>e.merchantRateDetail?.map((e=>{return t=Oe(),n=t.firstChild,r=n.nextSibling,F(n,(()=>e.Name||"")),F(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=ye,i=Ce,s=we;return e.e=L(t,o,e.e),e.t=L(n,i,e.t),e.a=L(r,s,e.a),e}),{e:void 0,t:void 0,a:void 0}),t;var t,n,r})))),t}}),i),d((r=>{var o=xe,i=ve,a=Ae,l=e.termsUrl;return r.e=L(t,o,r.e),r.t=L(n,i,r.t),r.a=L(s,a,r.a),l!==r.o&&N(s,"href",r.o=l),r}),{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t,n,r,o,i,s};function Ie(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 Re={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)}))},m={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})}},h={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return n.privacy={network:{"*":h},services:{"*":h},websites:{"*":h}},l(e,m,n)};e.exports=n(chrome)}}(Re);var _e=Ie(Re.exports);const Ne="GIVE_FREELY_",Le={async get(e){const t=`${Ne}${e}`;return(await _e.storage.local.get(t))[t]||null},async set(e,t){const n=`${Ne}${e}`;await _e.storage.local.set({[n]:t})},async remove(e){const t=Array.isArray(e)?e.map((e=>`${Ne}${e}`)):`${Ne}${e}`;await _e.storage.local.remove(t)}};class Fe{constructor(e){this.partnerApiKey=e,this.partnerConfig=null,this.globalConfig=null,this.lastConfigRefresh=0,this.CONFIG_REFRESH_INTERVAL=3e5,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(`https://cdn.givefreely.com/adunit/config/${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 Le.set(this.PARTNER_CONFIG_STORAGE_KEY,t),e}async fetchAndUpdateGlobalConfig(){const e=await q((async()=>{const e=await fetch("https://cdn.givefreely.com/adunit/config/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 Le.set(this.GLOBAL_CONFIG_STORAGE_KEY,t),e}async getConfig(){const e=Date.now(),t=await Le.get(this.PARTNER_CONFIG_STORAGE_KEY),n=await Le.get(this.GLOBAL_CONFIG_STORAGE_KEY);if(this.partnerConfig=t?.config||null,this.globalConfig=n?.config||null,this.lastConfigRefresh=Math.max(t?.lastRefresh||0,n?.lastRefresh||0),!this.partnerConfig||!this.globalConfig||e-this.lastConfigRefresh>this.CONFIG_REFRESH_INTERVAL)try{const[t,n]=await Promise.all([this.fetchAndUpdatePartnerConfig(),this.fetchAndUpdateGlobalConfig()]);this.partnerConfig=t,this.globalConfig=n,this.lastConfigRefresh=e}catch(e){if(!this.partnerConfig||!this.globalConfig)throw e}const r=this.mergeConfigs(this.globalConfig,this.partnerConfig);return((e,t,n)=>{const r=[...t.merchantExclusions??[],...n.merchantExclusions??[]];e.merchantExclusions=r})(r,this.globalConfig,this.partnerConfig),r}async clearCache(){await Promise.all([Le.remove(this.PARTNER_CONFIG_STORAGE_KEY),Le.remove(this.GLOBAL_CONFIG_STORAGE_KEY)]),this.partnerConfig=null,this.globalConfig=null,this.lastConfigRefresh=0}mergeConfigs(e,t){if(!t)return e;const n={...e};return Object.keys(t).forEach((r=>{if(!Object.prototype.hasOwnProperty.call(t,r))return;const o=e[r],i=t[r];Array.isArray(i)&&Array.isArray(o)?n[r]=i:n[r]=null===i||"object"!=typeof i||"object"!=typeof o?void 0!==i?i:o:this.mergeConfigs(o,i)})),n}getStoredState(e){return e?{config:e.config,lastRefresh:e.lastRefresh}:{config:null,lastRefresh:0}}}const $e="TRACK_EVENT",Me="GF_HIDE_POPUP",Ue="GF_GET_POPUP_CONFIG",Ge="GF_IS_ACTIVE_DOMAIN",He="GF_SHOULD_STAND_DOWN",Be="GF_ACTIVATE_OFFER",je="GF_STORE_SHOPIFY_SHOP_ID",Ke="GF_GET_DOMAIN_BY_SHOP_ID",We={ein:"0",tpi:"0",logo:"",title:"Unknown Charity"},Ve=()=>String("1.4.2");class Ye{constructor(e,t,n=60){this._config=null,this.track=async(e,t,n)=>{null===this._config&&(this._config=await new Fe(this._partnerApiKey).getConfig());const r={partner:`adUnit_${this._partnerApiKey}`,eventType:e,eventData:{userId:this._userService?.user?.id,libVersion:Ve(),wfDeviceId:t,...n}};try{const e=JSON.stringify(r);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",r),!1)}catch(e){return this._logger.info("Something unexpected happened when dispatching a gf event",{error:e,event:r}),!1}},this.getEventsHistory=async()=>{const{GF_AD_EVENT_HISTORY:e}=await X.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 X.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 X.storage.local.set({GF_AD_EVENT_HISTORY:t})},this._partnerApiKey=e,this._userService=t,this._debounceWindowInMinutes=n,this._logger=V.getInstance({title:"Analytics"})}}Ye.trackEvent=async(e,t)=>{await Z({type:$e,payload:{eventType:e,eventData:t}})};var ze=R("<a href=#!>"),qe=R("<button class=give-freely-close-button aria-label=Close>×"),Xe=R('<div><div><div><span></span></div></div><hr><div></div><div><div><div><br><span></span></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">'),Ze=R("<div><div><img><span></span></div><button>"),Je=R("<div>");function Qe(e){const[t,n]=u(!1);p((()=>{t()&&e.mainContainerRef&&e.mainContainerRef.scroll({top:e.mainContainerRef.scrollHeight,behavior:"smooth"})}));const r=()=>e.onCharitySelect(We,e.checkoutPopupConf.checkoutPopupActivateAndCloseSkipSuccess);return[(i=Xe(),s=i.firstChild,a=s.firstChild,l=a.firstChild,c=s.nextSibling.nextSibling,g=c.nextSibling,h=g.firstChild,f=h.firstChild,A=f.firstChild.nextSibling,b=f.nextSibling,x=g.nextSibling,v=x.firstChild,y=v.nextSibling,F(s,O(D,{get when(){return e.checkoutPopupConf.checkoutPopupActivateAndClose},get children(){var t=ze();return t.$$click=r,d((n=>{var r=ie,o=e.checkoutPopupConf.checkoutPopupActivateAndClose;return n.e=L(t,r,n.e),o!==n.t&&(t.innerHTML=n.t=o),n}),{e:void 0,t:void 0}),t}}),null),F(s,O(D,{get when(){return e.checkoutPopupConf.checkoutPopupMainCloseButtonVisible&&!e.checkoutPopupConf.checkoutPopupActivateAndClose},get children(){var t=qe();return t.$$click=()=>e.onClose(),d((e=>L(t,oe,e))),t}}),null),F(c,O(Se,{get title(){return e.subtitle},get activeDomain(){return e.activeDomain}})),F(g,(()=>e.checkoutPopupConf.checkoutPopupCharities.map((t=>{return o=(r=Ze()).firstChild,s=(i=o.firstChild).nextSibling,a=o.nextSibling,r.$$click=()=>e.onCharitySelect(t),F(r,(n=m((()=>!!(t.decorator&&t.decoratorLeftStyle&&t.decoratorRightStyle))),()=>{return n()&&[(r=Je(),d((e=>{var n=t.decoratorLeftStyle,o=t.decorator;return e.e=L(r,n,e.e),o!==e.t&&(r.innerHTML=e.t=o),e}),{e:void 0,t:void 0}),r),(e=Je(),d((n=>{var r=t.decoratorRightStyle,o=t.decorator;return n.e=L(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"),F(s,(()=>t.title)),F(a,(()=>e.checkoutPopupConf.checkoutPopupCharitySelectString||"Select")),d((n=>{var o=le,s=t.logo,l=ce,c=t.title,g={...ge,"background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812"},u=`Select charity: ${t.title}`;return n.e=L(r,o,n.e),s!==n.t&&N(i,"src",n.t=s),n.a=L(i,l,n.a),c!==n.o&&N(i,"alt",n.o=c),n.i=L(a,g,n.i),u!==n.n&&N(a,"aria-label",n.n=u),n}),{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),r;var n,r,o,i,s,a}))),h),h.$$click=()=>e.onSuppress(),f.style.setProperty("height","100px"),f.style.setProperty("text-align","center"),F(b,(()=>e.checkoutPopupConf.checkoupPopupDontShowAgainButtonText||"Settings...")),v.$$click=()=>{e.onOfferDetailsClick(!t()),n(!t())},F(v,(()=>e.checkoutPopupConf.checkoutPopupOfferDetailsLabelString||"Offer Details")),y.$$click=()=>{Ye.trackEvent(j.checkoutPopupWhyAmISeeingThisClicked,{domain:globalThis.window.location.hostname})},F(y,(()=>e.checkoutPopupConf.checkoutPopupWhyAmISeeingThisLabelString||"Why am I seeing this?")),F(i,(o=m((()=>!!e.checkoutPopupConf.checkoutPopupDisplayNameInFooter)),()=>{return o()&&(t=Je(),d((n=>{var r=fe,o=e.checkoutPopupConf.checkoutPopupDisplayNameInFooter;return n.e=L(t,r,n.e),o!==n.t&&(t.innerHTML=n.t=o),n}),{e:void 0,t:void 0}),t);var t}),null),d((t=>{var n=te,r=ne,o=re,u=e.checkoutPopupConf.checkoutPopupMainTitle,d=se,p=ae,m=le,f=e.checkoutPopupConf.checkoutPopupSixthBoxWording,C={...ge,"background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812"},w=he,k=be,P=Ae,S=e.checkoutPopupConf.externalUrls.giveFreelyWhyAmISeeingThis;return t.e=L(i,n,t.e),t.t=L(s,r,t.t),t.a=L(a,o,t.a),u!==t.o&&(l.innerHTML=t.o=u),t.i=L(c,d,t.i),t.n=L(g,p,t.n),t.s=L(h,m,t.s),f!==t.h&&(A.innerHTML=t.h=f),t.r=L(b,C,t.r),t.d=L(x,w,t.d),t.l=L(v,k,t.l),t.u=L(y,P,t.u),S!==t.c&&N(y,"href",t.c=S),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}),i),O(D,{get when(){return t()},get children(){return O(De,{get merchantName(){return e.activeDomain.Merchant.Name},get extensionName(){return e.checkoutPopupConf.displayName},get termsUrl(){return e.checkoutPopupConf.externalUrls.giveFreelyTermsAndConditions},get parsedMaxRate(){return m((()=>!!e.activeDomain.Merchant.MaxRate))()?ke(e.activeDomain.Merchant.MaxRate.Kind,e.activeDomain.Merchant.MaxRate?.Amount):null},get merchantRateDetail(){return e.merchantRates},onClose:()=>n(!1)})}})];var o,i,s,a,l,c,g,h,f,A,b,x,v,y}_(["click"]);var et=R("<button class=give-freely-close-button aria-label=Close>×"),tt=R("<label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=18250><span>Don't ask me again... ever"),nt=R("<div><div><div></div></div><button class=give-freely-back-button aria-label=\"Back to charity selection\">I changed my mind! I'd like to select a charity.</button><hr><div id=give-freely-goodbye-screen-options><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=1><span>Don't ask me again for 1 day</span></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=7><span>Don't ask me again for 7 days</span></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=30><span>Don't ask me again for 30 days</span></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=90><span>Don't ask me again for 90 days</span></label></div><button class=give-freely-submit-button>Submit");function rt(e){const[t,n]=u(0);return r=nt(),o=r.firstChild,i=o.firstChild,s=o.nextSibling,a=s.nextSibling.nextSibling,c=(l=a.firstChild).firstChild,p=(g=l.nextSibling).firstChild,h=(m=g.nextSibling).firstChild,A=(f=m.nextSibling).firstChild,b=a.nextSibling,r.style.setProperty("font-size","14px"),F(i,(()=>e.checkoutPopupConf.checkoutPopupSupressTitle)),F(o,O(D,{get when(){return e.checkoutPopupConf.checkoutPopupSupressCloseButtonVisible},get children(){var t=et();return t.$$click=()=>e.onGoodbye(0),d((e=>L(t,oe,e))),t}}),null),s.$$click=()=>e.onBack(),c.addEventListener("change",(()=>n(1))),p.addEventListener("change",(()=>n(7))),h.addEventListener("change",(()=>n(30))),A.addEventListener("change",(()=>n(90))),F(a,O(D,{get when(){return e.checkoutPopupConf.checkoutPopupNeverSuppressionAllowed},get children(){var e=tt();return e.firstChild.addEventListener("change",(()=>n(18250))),d((t=>L(e,de,t))),e}}),null),b.$$click=()=>{const n=t();n&&(e.onGoodbye(n),e.setScreen("main"))},d((t=>{var n=ne,r=re,c=me,u=ue,d=de,p=de,h=de,A=de,x={...ge,"font-weight":"700","margin-top":"10px","margin-bottom":"0px","background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812",width:"100px"};return t.e=L(o,n,t.e),t.t=L(i,r,t.t),t.a=L(s,c,t.a),t.o=L(a,u,t.o),t.i=L(l,d,t.i),t.n=L(g,p,t.n),t.s=L(m,h,t.s),t.h=L(f,A,t.h),t.r=L(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}),r;var r,o,i,s,a,l,c,g,p,m,h,f,A,b}_(["click"]);class ot{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 it=R("<div><p>"),st=R("<div><div><div></div><button class=give-freely-close-button aria-label=Close>×</button></div><hr><div><span>");function at(e){const[t,n]=u(null);let r;var o,s,a,l,c,g,p;return o=()=>clearInterval(r),null===i||(null===i.cleanups?i.cleanups=[o]:i.cleanups.push(o)),f((()=>{e.failedDonation||(()=>{const t=e.checkoutPopupConf.checkoutPopupDonationSuccessAutoCloseInSeconds??3;n(t),r=setInterval((()=>{n((t=>null===t||t<=1?(clearInterval(r),e.onClose(),0):t-1))}),1e3)})()})),s=st(),a=s.firstChild,l=a.firstChild,c=l.nextSibling,g=a.nextSibling.nextSibling,p=g.firstChild,s.style.setProperty("font-size","14px"),F(l,(()=>e.failedDonation?"Oops! Something went wrong":e.checkoutPopupConf.checkoutPopupDonationTitle)),c.$$click=()=>e.onClose(),g.style.setProperty("padding","30px"),g.style.setProperty("height","150px"),g.style.setProperty("font-size","14px"),F(s,O(D,{get when(){return!e.failedDonation},get children(){var n=it(),r=n.firstChild;return F(r,(()=>ot.formatMessage(e.checkoutPopupConf.checkoutPopupDonationSuccessAutoCloseLabelStringMask||"Closing in {0}",t()??0))),d((e=>L(r,pe,e))),n}}),null),d((t=>{var n=ne,r=re,o=oe,i=e.failedDonation?"Please try again later.":e.checkoutPopupConf.checkoutPopupDonationWording;return t.e=L(a,n,t.e),t.t=L(l,r,t.t),t.a=L(c,o,t.a),i!==t.o&&(p.innerHTML=t.o=i),t}),{e:void 0,t:void 0,a:void 0,o:void 0}),s}_(["click"]);var lt=R("<div><div>");const ct=(e,t,n)=>"donate"===e?"340px":t.checkoutPopupDisplayNameInFooter?"520px":n;function gt(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)=>{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 m;return b=lt(),x=b.firstChild,"function"==typeof m?(f=m,A=x,h((()=>f(A,undefined)))):m=x,F(x,O(D,{get when(){return"main"===t()},get children(){return O(Qe,{mainContainerRef:m,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},get subtitle(){return e.checkoutPopupConf.checkoutPopupSubTitle}})}}),null),F(x,O(D,{get when(){return"goodbye"===t()},get children(){return O(rt,{get checkoutPopupConf(){return e.checkoutPopupConf},onClose:()=>e.onClose(),onBack:g,onGoodbye:p,setScreen:n})}}),null),F(x,O(D,{get when(){return"donate"===t()},get children(){return O(at,{get checkoutPopupConf(){return e.checkoutPopupConf},get selectedCharity(){return r()},onClose:()=>e.onClose(),get failedDonation(){return i()},setScreen:n})}}),null),d((n=>{var r={...Q,height:ct(t(),e.checkoutPopupConf,Q.height)},o=e.elementId,i=ee;return n.e=L(b,r,n.e),o!==n.t&&N(b,"id",n.t=o),n.a=L(x,i,n.a),n}),{e:void 0,t:void 0,a:void 0}),b;var f,A,b,x}function ut(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 dt(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 pt(e){try{const t=await Z({type:Ke,payload:{shopId:e}});return t.payload.found&&t.payload.domain?t.payload.domain:null}catch{return null}}function mt(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 ht(){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 ft=V.getInstance();function At(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 ft.error("Error extracting domain",e),""}}(n);ft.debug("Checking merchant regex rules",{currentDomain:r,currentUrl:t});const o=e.merchantPopupRules.filter((e=>r.includes(e.domain)));if(0===o.length)return ft.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 ft.debug("Merchant regex rule matched",{merchant:e.name,rule:n.rule,currentUrl:t}),!0}catch(t){ft.error("Invalid regex in merchant rule",{merchant:e.name,rule:n.rule,error:t})}return ft.debug("No matching regex rules found",{currentUrl:t}),!1}catch(e){return ft.error("Error in merchantRegexRule",e),!1}}function bt(){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 xt(e){return!0!==e.checkoutPopupOnlyShowLanguageMatch||"en"===bt()}const vt=(e,t=!1)=>e.length<2&&t?null:Array.from(e).filter((e=>!t||e.dataset.extensionId!==X.runtime.id)).map((e=>e.dataset.extensionName)).join(",");var yt=R("<div class=gf-app>");function Ct(){const e=V.getInstance(),[t,n]=u(null),[r,o]=u(void 0),[i,s]=u(!1),[a,l]=u([]);f((async()=>{e.info("Mounting GfApp component");try{const i=await(async()=>{const e=await Z({type:Ue,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"});const a=Ve();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})(a,i.minVersion))return void e.debug(`Current version: ${a}. Minimum version ${i.minVersion} not met`);if(!1===i.checkoutPopupMasterSwitch)return void e.debug("Checkout popup master switch is disabled");const c=document.getElementsByClassName("give-freely-root");let g=!1;c.length>1&&(e.debug("There is more than one gf extension installed"),c.item(0).dataset.extensionId!==X.runtime.id&&(e.debug("Giving preference to the first gf extension injected in the DOM"),g=!0),e.debug("Providing this extension preference over the other installed extensions"));const{domain:u,rates:d}=await(async e=>{const{hostname:t}=window.location;e.debug("Checking if domain is active",{hostname:t});const n=await Z({type:Ge,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(d),o(u),u)await function(e,t){const n=mt(t)||ht();return n>0&&function(e,t,n){if(e&&!(e<=0))try{Z({type:je,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}(u,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 pt(parseInt(t));if(!n)return e.error("Shop domain not found"),void s(!1);e.debug("Shop domain found",{shopDomain:n}),o(n)}const p=await(async e=>{const t=await Le.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(p)return;if(!r())return void s(!1);const m=await(async(e,t)=>{const{Domain:n}=t,r=window.location.href,{payload:o}=await Z({type:He,payload:{activeDomain:n,url:r}});return!!o.result&&(e.info("Stand Down detected"),!0)})(e,r());if(m)return void s(!1);const h=t()?.anonymousActiveDomainLogging??!1,f=r()??void 0;f&&h&&!function(e){const t=`gfhv-${e}`;return!!sessionStorage.getItem(t)||(sessionStorage.setItem(t,"true"),!1)}(f.Domain)&&Ye.trackEvent(j.checkoutPopupActiveDomain,{url:f.Domain});const A=setInterval((async()=>{e.debug("Checking checkout rules");const t=await(async e=>{const t=V.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=mt(e)||ht();return!("shop.app"!==window.location.hostname&&!window.location.hostname.endsWith(".shop.app")||!(t>0)||!await pt(t))}(t),s=xt(e)&&(ut(n.pathname.toLowerCase())||dt(r,document)||At(e,r,o)||i);return t.debug("Popup show decision based on rules",{shouldShow:s,matchesCartRule:ut(n.pathname.toLowerCase()),matchesBookingRule:dt(r,document),matchesShopPayRule:i,matchesMerchantRegexRule:At(e,r,o),matchesLanguageRule:xt(e)}),s})(i);if(t&&g)return Ye.trackEvent(j.checkoutPopupLooserExtension,{url:globalThis.window.location.href,winner:c.item(0).dataset.extensionName}),e.debug("Standing down because, another ad-unit extension will pop"),void clearInterval(A);if(s(t),t){e.debug("Should show popup based on checkout rules",{shouldShowResult:t});const n=bt();Ye.trackEvent(j.checkoutPopupShown,{url:globalThis.window.location.href,pageLanguage:n,looserCompetingExtensions:vt(c,!0)}),clearInterval(A)}}),2e3)}catch(t){s(!1),e.error("An error occurred in GfApp",{error:t})}}));const c=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 J({type:Be,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}),Ye.trackEvent(r.payload.response?j.checkoutPopupDonation:j.checkoutPopupFailedActivation,{activeDomain:n.Domain,url:globalThis.window.location.href,charity:{ein:t.ein,tpi:t.tpi},rate:n.Merchant.MaxRate}),r.payload.response},g=async t=>{s(await(async(e,t)=>{try{e.info("Hiding ad",{days:t});const n=await J({type:Me,payload:{days:t??0}});return void 0!==t&&Ye.trackEvent(j.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))},d=async e=>{Ye.trackEvent(j.checkoutPopupOfferDetailsClicked,{action:e?"opened":"closed"})};return F(h=yt(),(p=m((()=>!(!r()||!i()))),()=>p()&&O(gt,{get checkoutPopupConf(){return t()},elementId:"give-freely-checkout-popup",get activeDomain(){return r()},get merchantRates(){return a()},onClose:g,onDonate:c,onOfferDetailsClick:d,logger:e}))),h;var p,h}async function wt(){const e=document.createElement("div");e.id=`give-freely-root-${X.runtime.id}`,e.className="give-freely-root",e.style.display="block",e.dataset.extensionId=X.runtime.id,e.dataset.extensionName=X.runtime.getManifest().name||X.runtime.id,document.body.appendChild(e);const t=e.attachShadow({mode:"open"}),n=document.createElement("div"),r=document.createElement("style");r.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',t.appendChild(r),t.appendChild(n),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((()=>h((()=>E(c)))));i=c,a=null;try{return C(g,!0)}finally{a=n,i=r}})((r=>{s=r,t===document?e():F(t,e(),t.firstChild?null:void 0,n)}),r.owner)}((()=>O(Ct,{})),n)}export{X as browser,wt as initializeAdUnit};
|
|
1
|
+
const e={equals:(e,t)=>e===t};let t=C;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[A.bind(r),e=>("function"==typeof e&&(e=e(r.value)),b(r,e))]}function d(e,t,r){x(v(e,t,!1,n))}function p(e,r,o){t=k;const i=v(e,r,!1,n);i.user=!0,c?c.push(i):x(i)}function m(t,n,r){r=r?Object.assign({},e,r):e;const o=v(t,n,!0,0);return o.observers=null,o.observerSlots=null,o.comparator=r.equals||void 0,x(o),A.bind(o)}function h(e){if(null===a)return e();const t=a;a=null;try{return e()}finally{a=t}}function f(e){p((()=>h(e)))}function A(){if(this.sources&&this.state)if(this.state===n)x(this);else{const e=l;l=null,w((()=>P(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&&w((()=>{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&&S(r)),o||(r.state=n)}if(l.length>1e6)throw l=[],new Error}),!1)),t}function x(e){if(!e.fn)return;E(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(E),e.owned=null),e.updatedAt=r+1,T(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 v(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 y(e){if(0===e.state)return;if(e.state===r)return P(e);if(e.suspense&&h(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)x(e);else if(e.state===r){const n=l;l=null,w((()=>P(e,t[0])),!1),l=n}}function w(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&&(C(l),l=null),e)return;const n=c;c=null,n.length&&w((()=>t(n)),!1)}(r),n}catch(e){r||(c=null),l=null,T(e)}}function C(e){for(let t=0;t<e.length;t++)y(e[t])}function k(e){let t,n=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[n++]=r:y(r)}for(t=0;t<n;t++)y(e[t])}function P(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)&&y(i):e===r&&P(i,t)}}}function S(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&&S(n))}}function E(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--)E(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)E(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 T(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 O(e,t){return h((()=>e(t||{})))}function D(e){const t=e.keyed,n=m((()=>e.when),void 0,{equals:(e,n)=>t?e===n:!e==!n});return m((()=>{const r=n();if(r){const o=e.children;return"function"==typeof o&&o.length>0?h((()=>o(t?r:()=>{if(!h(n))throw"Stale read from <Show>.";return e.when}))):o}return e.fallback}),void 0,void 0)}const I="_$DX_DELEGATE";function R(e,t,n){let r;const o=()=>{const t=document.createElement("template");return t.innerHTML=e,t.content.firstChild},i=t?()=>h((()=>document.importNode(r||(r=o()),!0))):()=>(r||(r=o())).cloneNode(!0);return i.cloneNode=i,i}function _(e,t=window.document){const n=t[I]||(t[I]=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,$))}}function N(e,t,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}function L(e,t,n){if(!t)return n?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 F(e,t,n,r){if(void 0===n||r||(r=[]),"function"!=typeof t)return M(e,t,r,n);d((r=>M(e,t(),r,n)),r)}function $(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 M(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=H(e,n,r,o)}else n=""!==n&&"string"==typeof n?e.firstChild.data=t:e.textContent=t}else if(null==t||"boolean"===i)n=H(e,n,r);else{if("function"===i)return d((()=>{let o=t();for(;"function"==typeof o;)o=o();n=M(e,o,n,r)})),()=>n;if(Array.isArray(t)){const i=[],a=n&&Array.isArray(n);if(U(i,t,n,o))return d((()=>n=M(e,i,n,r,!0))),()=>n;if(0===i.length){if(n=H(e,n,r),s)return n}else a?0===n.length?G(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&&H(e),G(e,i));n=i}else if(t.nodeType){if(Array.isArray(n)){if(s)return n=H(e,n,r,t);H(e,n,null,t)}else null!=n&&""!==n&&e.firstChild?e.replaceChild(t,e.firstChild):e.appendChild(t);n=t}}return n}function U(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=U(e,a,l)||o;else if("function"===s)if(r){for(;"function"==typeof a;)a=a();o=U(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 G(e,t,n=null){for(let r=0,o=t.length;r<o;r++)e.insertBefore(t[r],n)}function H(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 B{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}] - ${B.LOGGER_PREFIX} ${s} ${t}`,r):console[i](`[${n}] - ${B.LOGGER_PREFIX} ${s} ${t}`)}}var j,K;B.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"}(j||(j={})),function(e){e.adUnitLog="ADUNIT-LOG"}(K||(K={}));const W=["debug","info","warn","error"];class V{constructor(e){this.config={minLevel:e?.minLevel??"debug",enabled:e?.enabled??!1,transports:e?.transports??[new B],title:e?.title??""}}static getInstance(e){return V.instance||(V.instance=new V(e)),V.instance}configure(e){this.config={...this.config,...e}}shouldLog(e){return!!this.config.enabled&&W.indexOf(e)>=W.indexOf(this.config.minLevel)}createLogMessage(e,t,n){return{level:e,version:"1.4.2",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 Y=3,z=e=>1e3*e;async function q(e,t={}){const{maxAttempts:n=Y,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 X=chrome;async function Z(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||X.runtime.sendMessage(e,o)}catch(e){r(e)}}))}async function J(e,t,n){return q((()=>Z(e,t)),{maxAttempts:Y,delayFn:z})}const Q={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"}},ee={height:"100%","overflow-x":"hidden","overlfow-y":"auto",position:"relative",padding:"0px 15px"},te={},ne={display:"flex","align-items":"center","margin-bottom":"10px"},re={flex:"1","font-size":"24px","font-weight":"700","margin-top":"20px","margin-bottom":"0px"},oe={background:"none",border:"none",padding:"4px 8px",color:"#666464","font-size":"38px",cursor:"pointer","line-height":"1"},ie={color:"black","margin-top":"20px","max-width":"40%"},se={color:"gray",cursor:"default","pointer-events":"none","text-decoration":"none"},ae={"font-size":"18px","font-weight":"400","margin-top":"20px","margin-bottom":"0px"},le={display:"flex",gap:"10px",width:"100%","margin-top":"20px","margin-bottom":"20px","flex-wrap":"wrap","justify-content":"space-between"},ce={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"},ge={color:"white","background-color":"lightgray",cursor:"default","pointer-events":"none"},ue={"max-width":"120px","max-height":"70px","margin-bottom":"5px","object-fit":"contain"},de={"background-color":"#FFD812",cursor:"pointer","border-radius":"8px",padding:"8px",color:"white","min-width":"100px",border:"0","font-weight":"600",width:"100%"},pe={display:"flex","flex-direction":"column",gap:"10px",width:"100%","color-scheme":"light"},me={display:"flex","align-items":"center",gap:"5px",border:"1px solid #ddd",padding:"15px","border-radius":"5px","font-weight":"600",cursor:"pointer","margin-bottom":"8px"},he={"text-align":"right"},fe={background:"none",border:"none",color:"blue","text-decoration":"underline",padding:"0",cursor:"pointer","margin-bottom":"15px"},Ae={display:"flex","justify-content":"space-between",margin:"20px 0px 10px 0px","font-size":"14px"},be={margin:"5px 0px 5px 0px","font-size":"14px","text-align":"center"},xe={color:"#666464","text-decoration":"underline"},ve={color:"rgb(102, 100, 100)","text-decoration":"underline",margin:"0",cursor:"pointer"},ye={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"},we={padding:"0 5px 0 10px",width:"100%","font-size":"12px","box-sizing":"border-box"},Ce={display:"grid","grid-template-columns":"4fr 1fr","padding-right":"15px","padding-bottom":"5px"},ke={color:"#000","margin-bottom":"4px"},Pe={"font-size":"14px",color:"#555","text-align":"right"},Se=(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 Ee=R("<span>");function Te(e){return t=Ee(),d((()=>{return t.innerHTML=(n=e.title,r=e.activeDomain,n.replace("{0}",Se(r.Merchant.MaxRate?.Kind,r.Merchant.MaxRate?.Amount??"0")));var n,r})),t;var t}var Oe=R("<div>"),De=R("<div><div class=gf-offer-details><p>Select a charity to activate a donation during your online shopping session.</p><p> <b>Eligible Transaction:</b> A purchase made immediately after selecting a charity.</p><p><b>Donation rates:</b> <!> for each eligible transaction. The following donation rates and exclusions apply:</p><p><b>Donation amounts:</b> Donation amount is calculated based upon the applicable rates and exclusions, which may change from time to time. Amounts may be adjusted or canceled due to returned items, suspected fraud, or other factors described within the terms and conditions.</p><p><b>Donation timing:</b> On average, donation payouts occur 60-120 days after your completed transaction, but some donations may take 180 days or longer. We provide a donation to the charity you had selected at the time of purchase, in monthly batches, after any holdback periods due to applicable return or cancellation policies have passed.</p><p>See a summary of <a target=_blank rel=noreferrer>terms and conditions</a>."),Ie=R("<div class=gf-offer-details-rate-item><div></div><div>");const Re=e=>{return t=De(),o=(r=(n=t.firstChild).firstChild.nextSibling.nextSibling).firstChild.nextSibling.nextSibling,i=r.nextSibling,s=i.nextSibling.nextSibling.firstChild.nextSibling,F(r,(()=>e.parsedMaxRate?`Up to ${e.parsedMaxRate}`:"Earn"),o),F(n,O(D,{get when(){return!!e.merchantRateDetail?.length},get children(){var t=Oe();return F(t,(()=>e.merchantRateDetail?.map((e=>{return t=Ie(),n=t.firstChild,r=n.nextSibling,F(n,(()=>e.Name||"")),F(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=Ce,i=ke,s=Pe;return e.e=L(t,o,e.e),e.t=L(n,i,e.t),e.a=L(r,s,e.a),e}),{e:void 0,t:void 0,a:void 0}),t;var t,n,r})))),t}}),i),d((r=>{var o=ye,i=we,a=xe,l=e.termsUrl;return r.e=L(t,o,r.e),r.t=L(n,i,r.t),r.a=L(s,a,r.a),l!==r.o&&N(s,"href",r.o=l),r}),{e:void 0,t:void 0,a:void 0,o:void 0}),t;var t,n,r,o,i,s};function _e(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 Ne={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)}))},m={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})}},h={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return n.privacy={network:{"*":h},services:{"*":h},websites:{"*":h}},l(e,m,n)};e.exports=n(chrome)}}(Ne);var Le=_e(Ne.exports);const Fe="GIVE_FREELY_",$e={async get(e){const t=`${Fe}${e}`;return(await Le.storage.local.get(t))[t]||null},async set(e,t){const n=`${Fe}${e}`;await Le.storage.local.set({[n]:t})},async remove(e){const t=Array.isArray(e)?e.map((e=>`${Fe}${e}`)):`${Fe}${e}`;await Le.storage.local.remove(t)}};class Me{constructor(e){this.partnerApiKey=e,this.partnerConfig=null,this.globalConfig=null,this.lastConfigRefresh=0,this.CONFIG_REFRESH_INTERVAL=3e5,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(`https://cdn.givefreely.com/adunit/config/${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 $e.set(this.PARTNER_CONFIG_STORAGE_KEY,t),e}async fetchAndUpdateGlobalConfig(){const e=await q((async()=>{const e=await fetch("https://cdn.givefreely.com/adunit/config/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 $e.set(this.GLOBAL_CONFIG_STORAGE_KEY,t),e}async getConfig(){const e=Date.now(),t=await $e.get(this.PARTNER_CONFIG_STORAGE_KEY),n=await $e.get(this.GLOBAL_CONFIG_STORAGE_KEY);if(this.partnerConfig=t?.config||null,this.globalConfig=n?.config||null,this.lastConfigRefresh=Math.max(t?.lastRefresh||0,n?.lastRefresh||0),!this.partnerConfig||!this.globalConfig||e-this.lastConfigRefresh>this.CONFIG_REFRESH_INTERVAL)try{const[t,n]=await Promise.all([this.fetchAndUpdatePartnerConfig(),this.fetchAndUpdateGlobalConfig()]);this.partnerConfig=t,this.globalConfig=n,this.lastConfigRefresh=e}catch(e){if(!this.partnerConfig||!this.globalConfig)throw e}const r=this.mergeConfigs(this.globalConfig,this.partnerConfig);return((e,t,n)=>{const r=[...t.merchantExclusions??[],...n.merchantExclusions??[]];e.merchantExclusions=r})(r,this.globalConfig,this.partnerConfig),r}async clearCache(){await Promise.all([$e.remove(this.PARTNER_CONFIG_STORAGE_KEY),$e.remove(this.GLOBAL_CONFIG_STORAGE_KEY)]),this.partnerConfig=null,this.globalConfig=null,this.lastConfigRefresh=0}mergeConfigs(e,t){if(!t)return e;const n={...e};return Object.keys(t).forEach((r=>{if(!Object.prototype.hasOwnProperty.call(t,r))return;const o=e[r],i=t[r];Array.isArray(i)&&Array.isArray(o)?n[r]=i:n[r]=null===i||"object"!=typeof i||"object"!=typeof o?void 0!==i?i:o:this.mergeConfigs(o,i)})),n}getStoredState(e){return e?{config:e.config,lastRefresh:e.lastRefresh}:{config:null,lastRefresh:0}}}const Ue="TRACK_EVENT",Ge="GF_HIDE_POPUP",He="GF_GET_POPUP_CONFIG",Be="GF_IS_ACTIVE_DOMAIN",je="GF_SHOULD_STAND_DOWN",Ke="GF_ACTIVATE_OFFER",We="GF_STORE_SHOPIFY_SHOP_ID",Ve="GF_GET_DOMAIN_BY_SHOP_ID",Ye={ein:"0",tpi:"0",logo:"",title:"Unknown Charity"},ze=()=>String("1.4.2");class qe{constructor(e,t,n=60){this._config=null,this.track=async(e,t,n)=>{null===this._config&&(this._config=await new Me(this._partnerApiKey).getConfig());const r={partner:`adUnit_${this._partnerApiKey}`,eventType:e,eventData:{userId:this._userService?.user?.id,libVersion:ze(),wfDeviceId:t,...n}};try{const e=JSON.stringify(r);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",r),!1)}catch(e){return this._logger.info("Something unexpected happened when dispatching a gf event",{error:e,event:r}),!1}},this.getEventsHistory=async()=>{const{GF_AD_EVENT_HISTORY:e}=await X.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 X.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 X.storage.local.set({GF_AD_EVENT_HISTORY:t})},this._partnerApiKey=e,this._userService=t,this._debounceWindowInMinutes=n,this._logger=V.getInstance({title:"Analytics"})}}function Xe(e,t,n){return e?{...t,...n}:t}qe.trackEvent=async(e,t)=>{await Z({type:Ue,payload:{eventType:e,eventData:t}})};var Ze=R("<a href=#!>"),Je=R("<button class=give-freely-close-button aria-label=Close>×"),Qe=R('<div><div><div><span></span></div></div><hr><div></div><div><div><div><br><span></span></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">'),et=R("<div><div><img><span></span></div><button>"),tt=R("<div>");function nt(e){const[t,n]=u(!1),[r,o]=u(null);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 i=(e,t)=>o({charity:e,closeOnDonation:t}),s=()=>!!r()?.charity;return[(l=Qe(),c=l.firstChild,g=c.firstChild,h=g.firstChild,f=c.nextSibling.nextSibling,A=f.nextSibling,b=A.firstChild,x=b.firstChild,v=x.firstChild.nextSibling,y=x.nextSibling,w=A.nextSibling,C=w.firstChild,k=C.nextSibling,F(c,O(D,{get when(){return e.checkoutPopupConf.checkoutPopupActivateAndClose},get children(){var t=Ze();return t.$$click=()=>i(Ye,!0),d((n=>{var r=Xe(s(),ie,se),o=e.checkoutPopupConf.checkoutPopupActivateAndClose;return n.e=L(t,r,n.e),o!==n.t&&(t.innerHTML=n.t=o),n}),{e:void 0,t:void 0}),t}}),null),F(c,O(D,{get when(){return e.checkoutPopupConf.checkoutPopupMainCloseButtonVisible&&!e.checkoutPopupConf.checkoutPopupActivateAndClose},get children(){var t=Je();return t.$$click=()=>e.onClose(),d((e=>L(t,oe,e))),t}}),null),F(f,O(Te,{get title(){return e.subtitle},get activeDomain(){return e.activeDomain}})),F(A,(()=>e.checkoutPopupConf.checkoutPopupCharities.map((t=>{return o=(r=et()).firstChild,l=(a=o.firstChild).nextSibling,c=o.nextSibling,r.$$click=()=>!s()&&i(t),F(r,(n=m((()=>!!(t.decorator&&t.decoratorLeftStyle&&t.decoratorRightStyle))),()=>{return n()&&[(r=tt(),d((e=>{var n=t.decoratorLeftStyle,o=t.decorator;return e.e=L(r,n,e.e),o!==e.t&&(r.innerHTML=e.t=o),e}),{e:void 0,t:void 0}),r),(e=tt(),d((n=>{var r=t.decoratorRightStyle,o=t.decorator;return n.e=L(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"),F(l,(()=>t.title)),F(c,(()=>e.checkoutPopupConf.checkoutPopupCharitySelectString||"Select")),d((n=>{var o=Xe(s(),ce,{cursor:"default"}),i=t.logo,l=ue,g=t.title,u=Xe(s(),{...de,"background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812"},ge),d=s(),p=`Select charity: ${t.title}`;return n.e=L(r,o,n.e),i!==n.t&&N(a,"src",n.t=i),n.a=L(a,l,n.a),g!==n.o&&N(a,"alt",n.o=g),n.i=L(c,u,n.i),d!==n.n&&(c.disabled=n.n=d),p!==n.s&&N(c,"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,a,l,c}))),b),b.$$click=()=>!s()&&e.onSuppress(),x.style.setProperty("height","100px"),x.style.setProperty("text-align","center"),F(y,(()=>e.checkoutPopupConf.checkoupPopupDontShowAgainButtonText||"Settings...")),C.$$click=()=>{e.onOfferDetailsClick(!t()),n(!t())},F(C,(()=>e.checkoutPopupConf.checkoutPopupOfferDetailsLabelString||"Offer Details")),k.$$click=()=>{qe.trackEvent(j.checkoutPopupWhyAmISeeingThisClicked,{domain:globalThis.window.location.hostname})},F(k,(()=>e.checkoutPopupConf.checkoutPopupWhyAmISeeingThisLabelString||"Why am I seeing this?")),F(l,(a=m((()=>!!e.checkoutPopupConf.checkoutPopupDisplayNameInFooter)),()=>{return a()&&(t=tt(),d((n=>{var r=be,o=e.checkoutPopupConf.checkoutPopupDisplayNameInFooter;return n.e=L(t,r,n.e),o!==n.t&&(t.innerHTML=n.t=o),n}),{e:void 0,t:void 0}),t);var t}),null),d((t=>{var n=te,r=ne,o=re,i=e.checkoutPopupConf.checkoutPopupMainTitle,a=ae,u=le,d=Xe(s(),ce,{cursor:"default"}),p=e.checkoutPopupConf.checkoutPopupSixthBoxWording,m=Xe(s(),{...de,"background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812"},ge),x=s(),P=Ae,S=ve,E=xe,T=e.checkoutPopupConf.externalUrls.giveFreelyWhyAmISeeingThis;return t.e=L(l,n,t.e),t.t=L(c,r,t.t),t.a=L(g,o,t.a),i!==t.o&&(h.innerHTML=t.o=i),t.i=L(f,a,t.i),t.n=L(A,u,t.n),t.s=L(b,d,t.s),p!==t.h&&(v.innerHTML=t.h=p),t.r=L(y,m,t.r),x!==t.d&&(y.disabled=t.d=x),t.l=L(w,P,t.l),t.u=L(C,S,t.u),t.c=L(k,E,t.c),T!==t.w&&N(k,"href",t.w=T),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,w:void 0}),l),O(D,{get when(){return t()},get children(){return O(Re,{get merchantName(){return e.activeDomain.Merchant.Name},get extensionName(){return e.checkoutPopupConf.displayName},get termsUrl(){return e.checkoutPopupConf.externalUrls.giveFreelyTermsAndConditions},get parsedMaxRate(){return m((()=>!!e.activeDomain.Merchant.MaxRate))()?Se(e.activeDomain.Merchant.MaxRate.Kind,e.activeDomain.Merchant.MaxRate?.Amount):null},get merchantRateDetail(){return e.merchantRates},onClose:()=>n(!1)})}})];var a,l,c,g,h,f,A,b,x,v,y,w,C,k}_(["click"]);var rt=R("<button class=give-freely-close-button aria-label=Close>×"),ot=R("<label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=18250><span>Don't ask me again... ever"),it=R("<div><div><div></div></div><button class=give-freely-back-button aria-label=\"Back to charity selection\">I changed my mind! I'd like to select a charity.</button><hr><div id=give-freely-goodbye-screen-options><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=1><span>Don't ask me again for 1 day</span></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=7><span>Don't ask me again for 7 days</span></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=30><span>Don't ask me again for 30 days</span></label><label class=give-freely-radio-option><input type=radio name=gf-rad-goodbye value=90><span>Don't ask me again for 90 days</span></label></div><button class=give-freely-submit-button>Submit");function st(e){const[t,n]=u(0);return r=it(),o=r.firstChild,i=o.firstChild,s=o.nextSibling,a=s.nextSibling.nextSibling,c=(l=a.firstChild).firstChild,p=(g=l.nextSibling).firstChild,h=(m=g.nextSibling).firstChild,A=(f=m.nextSibling).firstChild,b=a.nextSibling,r.style.setProperty("font-size","14px"),F(i,(()=>e.checkoutPopupConf.checkoutPopupSupressTitle)),F(o,O(D,{get when(){return e.checkoutPopupConf.checkoutPopupSupressCloseButtonVisible},get children(){var t=rt();return t.$$click=()=>e.onGoodbye(0),d((e=>L(t,oe,e))),t}}),null),s.$$click=()=>e.onBack(),c.addEventListener("change",(()=>n(1))),p.addEventListener("change",(()=>n(7))),h.addEventListener("change",(()=>n(30))),A.addEventListener("change",(()=>n(90))),F(a,O(D,{get when(){return e.checkoutPopupConf.checkoutPopupNeverSuppressionAllowed},get children(){var e=ot();return e.firstChild.addEventListener("change",(()=>n(18250))),d((t=>L(e,me,t))),e}}),null),b.$$click=()=>{const n=t();n&&(e.onGoodbye(n),e.setScreen("main"))},d((t=>{var n=ne,r=re,c=fe,u=pe,d=me,p=me,h=me,A=me,x={...de,"font-weight":"700","margin-top":"10px","margin-bottom":"0px","background-color":e.checkoutPopupConf.checkoutPopupSelectCharityButtonBgColor||"#FFD812",width:"100px"};return t.e=L(o,n,t.e),t.t=L(i,r,t.t),t.a=L(s,c,t.a),t.o=L(a,u,t.o),t.i=L(l,d,t.i),t.n=L(g,p,t.n),t.s=L(m,h,t.s),t.h=L(f,A,t.h),t.r=L(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}),r;var r,o,i,s,a,l,c,g,p,m,h,f,A,b}_(["click"]);class at{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 lt=R("<div><p>"),ct=R("<div><div><div></div><button class=give-freely-close-button aria-label=Close>×</button></div><hr><div><span>");function gt(e){const[t,n]=u(null);let r;var o,s,a,l,c,g,p;return o=()=>clearInterval(r),null===i||(null===i.cleanups?i.cleanups=[o]:i.cleanups.push(o)),f((()=>{e.failedDonation||(()=>{const t=e.checkoutPopupConf.checkoutPopupDonationSuccessAutoCloseInSeconds??3;n(t),r=setInterval((()=>{n((t=>null===t||t<=1?(clearInterval(r),e.onClose(),0):t-1))}),1e3)})()})),s=ct(),a=s.firstChild,l=a.firstChild,c=l.nextSibling,g=a.nextSibling.nextSibling,p=g.firstChild,s.style.setProperty("font-size","14px"),F(l,(()=>e.failedDonation?"Oops! Something went wrong":e.checkoutPopupConf.checkoutPopupDonationTitle)),c.$$click=()=>e.onClose(),g.style.setProperty("padding","30px"),g.style.setProperty("height","150px"),g.style.setProperty("font-size","14px"),F(s,O(D,{get when(){return!e.failedDonation},get children(){var n=lt(),r=n.firstChild;return F(r,(()=>at.formatMessage(e.checkoutPopupConf.checkoutPopupDonationSuccessAutoCloseLabelStringMask||"Closing in {0}",t()??0))),d((e=>L(r,he,e))),n}}),null),d((t=>{var n=ne,r=re,o=oe,i=e.failedDonation?"Please try again later.":e.checkoutPopupConf.checkoutPopupDonationWording;return t.e=L(a,n,t.e),t.t=L(l,r,t.t),t.a=L(c,o,t.a),i!==t.o&&(p.innerHTML=t.o=i),t}),{e:void 0,t:void 0,a:void 0,o:void 0}),s}_(["click"]);var ut=R("<div><div>");const dt=(e,t,n)=>"donate"===e?"340px":t.checkoutPopupDisplayNameInFooter?"520px":n;function pt(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 m;return b=ut(),x=b.firstChild,"function"==typeof m?(f=m,A=x,h((()=>f(A,undefined)))):m=x,F(x,O(D,{get when(){return"main"===t()},get children(){return O(nt,{mainContainerRef:m,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},get subtitle(){return e.checkoutPopupConf.checkoutPopupSubTitle}})}}),null),F(x,O(D,{get when(){return"goodbye"===t()},get children(){return O(st,{get checkoutPopupConf(){return e.checkoutPopupConf},onClose:()=>e.onClose(),onBack:g,onGoodbye:p,setScreen:n})}}),null),F(x,O(D,{get when(){return"donate"===t()},get children(){return O(gt,{get checkoutPopupConf(){return e.checkoutPopupConf},get selectedCharity(){return r()},onClose:()=>e.onClose(),get failedDonation(){return i()},setScreen:n})}}),null),d((n=>{var r={...Q,height:dt(t(),e.checkoutPopupConf,Q.height)},o=e.elementId,i=ee;return n.e=L(b,r,n.e),o!==n.t&&N(b,"id",n.t=o),n.a=L(x,i,n.a),n}),{e:void 0,t:void 0,a:void 0}),b;var f,A,b,x}function mt(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 ht(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 ft(e){try{const t=await Z({type:Ve,payload:{shopId:e}});return t.payload.found&&t.payload.domain?t.payload.domain:null}catch{return null}}function At(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 bt(){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 xt=V.getInstance();function vt(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 xt.error("Error extracting domain",e),""}}(n);xt.debug("Checking merchant regex rules",{currentDomain:r,currentUrl:t});const o=e.merchantPopupRules.filter((e=>r.includes(e.domain)));if(0===o.length)return xt.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 xt.debug("Merchant regex rule matched",{merchant:e.name,rule:n.rule,currentUrl:t}),!0}catch(t){xt.error("Invalid regex in merchant rule",{merchant:e.name,rule:n.rule,error:t})}return xt.debug("No matching regex rules found",{currentUrl:t}),!1}catch(e){return xt.error("Error in merchantRegexRule",e),!1}}function yt(){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 wt(e){return!0!==e.checkoutPopupOnlyShowLanguageMatch||"en"===yt()}const Ct=(e,t=!1)=>e.length<2&&t?null:Array.from(e).filter((e=>!t||e.dataset.extensionId!==X.runtime.id)).map((e=>e.dataset.extensionName)).join(",");var kt=R("<div class=gf-app>");function Pt(){const e=V.getInstance(),[t,n]=u(null),[r,o]=u(void 0),[i,s]=u(!1),[a,l]=u([]);f((async()=>{e.info("Mounting GfApp component");try{const i=await(async()=>{const e=await Z({type:He,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"});const a=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})(a,i.minVersion))return void e.debug(`Current version: ${a}. Minimum version ${i.minVersion} not met`);if(!1===i.checkoutPopupMasterSwitch)return void e.debug("Checkout popup master switch is disabled");const c=document.getElementsByClassName("give-freely-root");let g=!1;c.length>1&&(e.debug("There is more than one gf extension installed"),c.item(0).dataset.extensionId!==X.runtime.id&&(e.debug("Giving preference to the first gf extension injected in the DOM"),g=!0),e.debug("Providing this extension preference over the other installed extensions"));const{domain:u,rates:d}=await(async e=>{const{hostname:t}=window.location;e.debug("Checking if domain is active",{hostname:t});const n=await Z({type:Be,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(d),o(u),u)await function(e,t){const n=At(t)||bt();return n>0&&function(e,t,n){if(e&&!(e<=0))try{Z({type:We,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}(u,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 ft(parseInt(t));if(!n)return e.error("Shop domain not found"),void s(!1);e.debug("Shop domain found",{shopDomain:n}),o(n)}const p=await(async e=>{const t=await $e.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(p)return;if(!r())return void s(!1);const m=await(async(e,t)=>{const{Domain:n}=t,r=window.location.href,{payload:o}=await Z({type:je,payload:{activeDomain:n,url:r}});return!!o.result&&(e.info("Stand Down detected"),!0)})(e,r());if(m)return void s(!1);const h=t()?.anonymousActiveDomainLogging??!1,f=r()??void 0;f&&h&&!function(e){const t=`gfhv-${e}`;return!!sessionStorage.getItem(t)||(sessionStorage.setItem(t,"true"),!1)}(f.Domain)&&qe.trackEvent(j.checkoutPopupActiveDomain,{url:f.Domain});const A=setInterval((async()=>{e.debug("Checking checkout rules");const t=await(async e=>{const t=V.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=At(e)||bt();return!("shop.app"!==window.location.hostname&&!window.location.hostname.endsWith(".shop.app")||!(t>0)||!await ft(t))}(t),s=wt(e)&&(mt(n.pathname.toLowerCase())||ht(r,document)||vt(e,r,o)||i);return t.debug("Popup show decision based on rules",{shouldShow:s,matchesCartRule:mt(n.pathname.toLowerCase()),matchesBookingRule:ht(r,document),matchesShopPayRule:i,matchesMerchantRegexRule:vt(e,r,o),matchesLanguageRule:wt(e)}),s})(i);if(t&&g)return qe.trackEvent(j.checkoutPopupLooserExtension,{url:globalThis.window.location.href,winner:c.item(0).dataset.extensionName}),e.debug("Standing down because, another ad-unit extension will pop"),void clearInterval(A);if(s(t),t){e.debug("Should show popup based on checkout rules",{shouldShowResult:t});const n=yt();qe.trackEvent(j.checkoutPopupShown,{url:globalThis.window.location.href,pageLanguage:n,looserCompetingExtensions:Ct(c,!0)}),clearInterval(A)}}),2e3)}catch(t){s(!1),e.error("An error occurred in GfApp",{error:t})}}));const c=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 J({type:Ke,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}),qe.trackEvent(r.payload.response?j.checkoutPopupDonation:j.checkoutPopupFailedActivation,{activeDomain:n.Domain,url:globalThis.window.location.href,charity:{ein:t.ein,tpi:t.tpi},rate:n.Merchant.MaxRate}),r.payload.response},g=async t=>{s(await(async(e,t)=>{try{e.info("Hiding ad",{days:t});const n=await J({type:Ge,payload:{days:t??0}});return void 0!==t&&qe.trackEvent(j.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))},d=async e=>{qe.trackEvent(j.checkoutPopupOfferDetailsClicked,{action:e?"opened":"closed"})};return F(h=kt(),(p=m((()=>!(!r()||!i()))),()=>p()&&O(pt,{get checkoutPopupConf(){return t()},elementId:"give-freely-checkout-popup",get activeDomain(){return r()},get merchantRates(){return a()},onClose:g,onDonate:c,onOfferDetailsClick:d,logger:e}))),h;var p,h}async function St(){const e=`give-freely-root-${X.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=X.runtime.id,t.dataset.extensionName=X.runtime.getManifest().name||X.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((()=>h((()=>E(c)))));i=c,a=null;try{return w(g,!0)}finally{a=n,i=r}})((r=>{s=r,t===document?e():F(t,e(),t.firstChild?null:void 0,n)}),r.owner)}((()=>O(Pt,{})),r)}export{X as browser,St as initializeAdUnit};
|