// source --> https://www.hishealinglight.org/wp-content/plugins/give-donation-upsells-woocommerce/assets/dist/js/frontend.js?ver=1.4.2 
(()=>{"use strict";function t(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var o,r,i,a,c=[],u=!0,l=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(o=i.call(n)).done)&&(c.push(o.value),c.length!==e);u=!0);}catch(t){l=!0,r=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw r}}return c}}(t,n)||e(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){if(t){if("string"==typeof t)return n(t,e);var o={}.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?n(t,e):void 0}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=Array(e);n<e;n++)o[n]=t[n];return o}function o(t,e){return(e||document).querySelector(t)}function r(t,e){return(e||document).querySelectorAll(t)}function i(t,e,n,o){!function(t,e,n,o){t.addEventListener(e,n,!!o)}(t,n,function(n){var i=n.target,a=r(e,t);Array.prototype.indexOf.call(a,i)>=0&&o.call(i,n)},"blur"===n||"focus"===n)}function a(t,e){if(t.parentNode)return t.parentNode.tagName.toLowerCase()===e.toLowerCase()?t.parentNode:a(t.parentNode,e)}function c(t,e){var n;return t.childNodes||(n=void 0),Array.from(t.childNodes).forEach(function(t){void 0!==t.classList&&t.classList.contains(e)&&(n=t)}),n}function u(t,e){e=e||"";var n=o("#give-wc-form-"+t);return null!==n&&n.getAttribute("data-"+e)}function l(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),n}function s(n,o){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"POST";if(null!==o){var i,a={},c=function(t,n){var o="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!o){if(Array.isArray(t)||(o=e(t))||n&&t&&"number"==typeof t.length){o&&(t=o);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,u=!1;return{s:function(){o=o.call(t)},n:function(){var t=o.next();return c=t.done,t},e:function(t){u=!0,a=t},f:function(){try{c||null==o.return||o.return()}finally{if(u)throw a}}}}(new FormData(o).entries());try{for(c.s();!(i=c.n()).done;){var u=t(i.value,2),l=u[0],s=u[1];a[l]=s}}catch(t){c.e(t)}finally{c.f()}var d=new URLSearchParams(a);return d.append("action",n),new Promise(function(t,e){fetch(give_wc_vars.admin_ajax,{body:d.toString(),headers:{"Content-Type":"application/x-www-form-urlencoded"},method:r}).then(function(t){if(!t.ok)throw new Error(give_wc_vars.checkout_error);window.location.href=give_wc_vars.checkout_url}).catch(function(t){confirm(t)&&(window.location.href=give_wc_vars.checkout_url)})})}}function d(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"POST",o=new URLSearchParams(e);return o.append("action",t),new Promise(function(t,e){fetch(give_wc_vars.admin_ajax,{body:o.toString(),headers:{"Content-Type":"application/x-www-form-urlencoded"},method:n}).then(function(n){n.ok?t():(console.log(n),e())})})}function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function m(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,f(o.key),o)}}function f(t){var e=function(t,e){if("object"!=v(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!=v(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==v(e)?e:e+""}var w=function(){function t(e,n,o){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.amount=e||0,this.form=o||{},this.args=Object.assign({symbol:"",position:give_wc_vars.currency_settings.currency_position,decimal:give_wc_vars.currency_settings.decimal_sep,thousand:give_wc_vars.currency_settings.thousand_sep,precision:parseInt(give_wc_vars.currency_settings.decimal_numbers),currency:give_wc_vars.currency_settings.currency},n),this.amount=this.unFormatAmount()}return e=t,(n=[{key:"getAmount",value:function(t){return o("#give-wc-form-"+$form_id+" input#give-amount").value.value||!1}},{key:"formatAmount",value:function(){return Give.fn.formatCurrency(this.amount,this.args,this.form)}},{key:"unFormatAmount",value:function(t,e){var n=t||this.args.decimal,o=e||this.amount;return Give.fn.unFormatCurrency(o,n)}},{key:"verifyAmount",value:function(e){var n=this.unFormatAmount(this.args.decimal,this.amount),i=parseFloat(u(e,"minimum")),c=parseFloat(u(e,"maximum")),l=!0,s=o('form.woocommerce-cart-form button[name="update_cart"],form.woocommerce-cart-form *[name="update_cart"] '),d=o("form.woocommerce-checkout button#give_wc_update_donation"),v=o('.give-wc-give-form-row[data-form_id="'+e+'"]'),m=a(o(".give-wc-amount-field",v),"span");if(n<i||n>c){var f=new t(n<i?v.dataset.minimum:v.dataset.maximum,{symbol:give_global_vars.currency_sign}).formatAmount(n),w=n<i?give_global_vars.bad_minimum:give_global_vars.bad_maximum;m.setAttribute("aria-label","".concat(w," ").concat(f)),null!==s&&(s.setAttribute("disabled",""),m.classList.remove("give_wc_hide_tooltip")),null!==d&&(d.setAttribute("disabled",""),m.classList.remove("give_wc_hide_tooltip")),l=!1}return l&&setTimeout(function(){var t=r(".give-wc-invalid-amount"),e=!1;t&&Array.prototype.forEach.call(t,function(t){o('input[type="checkbox"].give-wc-form-selector',a(t,"td")).checked&&(e=!0)}),e||(null!==s&&(s.removeAttribute("disabled"),m.classList.add("give_wc_hide_tooltip")),null!==d&&(d.removeAttribute("disabled"),m.classList.add("give_wc_hide_tooltip")))},100),l}}])&&m(e.prototype,n),i&&m(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,i}();function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function g(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,y(o.key),o)}}function y(t){var e=function(t,e){if("object"!=p(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!=p(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==p(e)?e:e+""}var b=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.$wcPanel=o("body.woocommerce-cart, body.woocommerce-checkout"),this.$donationHead='input[type="checkbox"].give-wc-form-selector, .give-wc-give-form-head,.give-wc-checkbox-row',this.$donationLevel='input[type="radio"].give-wc-donation-level, select.give-wc-select',this.$amount_field="input.give-wc-amount-field",this.$checkoutButton="a.checkout-button",this.$updateButton=o('button[name="update_cart"]'),null!==this.$wcPanel&&this.bindEvents(),this.fixCartWhenHitBack()},e=[{key:"fixCartWhenHitBack",value:function(){window.performance&&window.performance.navigation.type==window.performance.navigation.TYPE_BACK_FORWARD&&r("input.give-wc-form-selector").forEach(function(t){t.checked=!1;var e=a(t,"td"),n=o(".give-wc-donation-inside",e);e.classList.remove("give-wc-active-row"),n.classList.add("give-wc-hidden")})}},{key:"bindEvents",value:function(){var t=this;i(t.$wcPanel,".give-wc-give-form-label input, .give-wc-give-form-label p","click",function(t){t.stopPropagation()}),i(t.$wcPanel,'.woocommerce-checkout button[name="give_wc_update_donation"]',"click",function(t){document.body.dispatchEvent(new l("update_checkout"))}),i(t.$wcPanel,t.$amount_field,"change",function(t){var e=t.target,n=new w(e.value);e.value=n.formatAmount();var i,c=a(e,"td"),u=c.getAttribute("data-form_id"),l=n.unFormatAmount();new w(l).verifyAmount(u)?e.classList.remove("give-wc-invalid-amount"):e.classList.add("give-wc-invalid-amount");var s=r('select.give-wc-select option, input[type="radio"].give-wc-donation-level',c);if(s.length>0)switch(Array.prototype.forEach.call(s,function(t){l!=t.getAttribute("data-amount")||(i=t.value)}),i=void 0===i?"custom":i,give_wc_vars.level_display_style){case"dropdown":o(".give-wc-select",c).value=i;break;case"radio":o(".give_wc_level_"+i,c).checked=!0}}),i(t.$wcPanel,t.$donationHead,"click",function(e){var n=e.target,r=a(n,"td"),i=o(".give-amount-top",r);if(r.classList.toggle("give-wc-active-row"),"INPUT"!==n.nodeName){var u=o('input[type="checkbox"].give-wc-form-selector',r);u.checked=!u.checked}c(r,"give-wc-donation-inside").classList.toggle("give-wc-hidden");var s=r.getAttribute("data-form_id");if(new w(i.value).verifyAmount(s),!t.$updateButton)if(n.checked){var v=o("#give-donation-level-select-"+s+" option:checked").getAttribute("data-price-id");d("give_wc_process_donation",{amount:i.value,priceID:v,formId:s}).then(function(){document.body.dispatchEvent(new l("wc-blocks_added_to_cart"))})}else d("give_wc_remove_donation",{formId:s}).then(function(){document.body.dispatchEvent(new l("wc-blocks_added_to_cart"))})}),i(t.$wcPanel,t.$donationLevel,"change",function(e){e.preventDefault();var n=e.target,r=a(n,"td"),i=c(r,"give-wc-donation-inside"),u=o(".give-amount-top",r),s="SELECT"===n.nodeName?n.options[n.selectedIndex].getAttribute("data-amount"):n.getAttribute("data-amount"),v="SELECT"===n.nodeName?n.options[n.selectedIndex].getAttribute("data-price-id"):n.value,m=r.getAttribute("data-form_id");if(u.value=""!==s?new w(s).formatAmount():0,"custom"===v)return u.setSelectionRange(0,5),void u.focus();o(".give-wc-form-amount",i)&&(o(".give-wc-form-amount",i).innerText=new w(s,{symbol:give_wc_vars.currency_settings.symbol}).formatAmount()),new w(u.value).verifyAmount(m)?u.classList.remove("give-wc-invalid-amount"):u.classList.add("give-wc-invalid-amount"),t.$updateButton||d("give_wc_process_donation",{amount:u.value,priceID:v,formId:m}).then(function(){document.body.dispatchEvent(new l("wc-blocks_added_to_cart"))})}),i(t.$wcPanel,"input.give-wc-amount-field","blur",function(e){if(!t.$updateButton){var n=o(".give-wc-donation-inside").getAttribute("data-form_id");d("give_wc_process_donation",{amount:e.target.value,priceID:"custom",formId:n}).then(function(t){document.body.dispatchEvent(new l("wc-blocks_added_to_cart"))})}}),i(t.$wcPanel,t.$checkoutButton,"click",function(t){t.preventDefault();var e=o(".woocommerce-cart-form");e&&s("give_wc_process_donations",e)})}}],e&&g(t.prototype,e),n&&g(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();document.addEventListener("DOMContentLoaded",function(){"function"!=typeof window.CustomEvent&&(l.prototype=window.Event.prototype,window.CustomEvent=l),new b})})();