// source --> https://theoutdoorchef.com.au/wp-content/plugins/contact-form-7-paypal-add-on/assets/js/redirect_method.js?ver=2.4.6 
jQuery(document).ready(function($) {

	var cf7pp_formid;
	var cf7pp_id_long;
	var cf7pp_amount_total;
	var cf7pp_email;
	var cf7pp_stripe_return;
	var cf7pp_payment_id;

	// for redirect method 1
	document.addEventListener('wpcf7mailsent', function( event ) {
		
		if (ajax_object_cf7pp.method == 1) {
			
			var cf7pp_id_long =			event.detail.contactFormId;
			var cf7pp_id = 				event.detail.contactFormId;
			
			var cf7pp_formid = cf7pp_id_long;
			var cf7pp_formid = cf7pp_id;

			cf7pp_redirect(cf7pp_formid, cf7pp_id_long);
		}
		
	}, false );
	
	
	
	
	// for redirect method 2
    if (ajax_object_cf7pp.method == 2) {
        var cf7pp_form_counter = 0;
        jQuery('.wpcf7-form').bind('DOMSubtreeModified', function(e) {
            if (cf7pp_form_counter == 0) {
                cf7pp_form_counter = 1; // Set counter immediately to prevent multiple intervals
                var $form = jQuery(this);
                var interval = setInterval(function(){
                    if ($form.hasClass('sent')) {
                        clearInterval(interval);

                        // get form id
                        var cf7pp_id = $form.parent().attr('id').substring(7);

                        cf7pp_id = cf7pp_id.split('-')[0];

                        var cf7pp_id_long = $form.parent().attr('id');

                        cf7pp_redirect(cf7pp_id, cf7pp_id_long);
                    }
                }, 500);
            }
        });
    }
	
	
	// used for redirect method 1 and 2
	function cf7pp_redirect(cf7pp_id, cf7pp_id_long) {
		
		var cf7pp_forms = ajax_object_cf7pp.forms;
		
		var cf7pp_result_paypal = cf7pp_forms.indexOf(cf7pp_id+'|paypal'); // check to see if form is enabled for redriect
		var cf7pp_result_stripe = cf7pp_forms.indexOf(cf7pp_id+'|stripe');
		
		
		var cf7pp_gateway;
		
		var cf7pp_data = {
			'action':	'cf7pp_get_form_post',
		};
		
		// Use REST API if request_method is 2, otherwise use AJAX
		var requestUrl = (ajax_object_cf7pp.request_method == '2') 
			? ajax_object_cf7pp.rest_url + 'cf7pp_get_form_post'
			: ajax_object_cf7pp.ajax_url;
		
		jQuery.ajax({
			type: "GET",
			data: cf7pp_data,
			dataType: "json",
			async: false,
			url: requestUrl,
			xhrFields: {
				withCredentials: true
			},
			success: function (response) {
				cf7pp_gateway = 			response.gateway;
				cf7pp_amount_total = 		response.amount_total;
				cf7pp_email = 				response.email;
				cf7pp_stripe_return = 		response.stripe_return;
				cf7pp_payment_id = 			response.payment_id;
			}
		});
		
		var cf7pp_path_paypal = ajax_object_cf7pp.path_paypal+cf7pp_id+'&cf7pp_p='+cf7pp_payment_id;
		var cf7pp_path_stripe = ajax_object_cf7pp.path_stripe+cf7pp_id+'&cf7pp_fid='+cf7pp_id_long+'&cf7pp_p='+cf7pp_payment_id+'&cf7pp_return='+window.location.href;
		
		
		// gateway chooser
		if (cf7pp_gateway != null) {
			// paypal
			if (cf7pp_result_paypal > -1 && cf7pp_gateway == 'paypal') {
				window.location.href = cf7pp_path_paypal;
			}
			
			// stripe
			if (cf7pp_result_stripe > -1 && cf7pp_gateway == 'stripe') {
				window.location.href = cf7pp_path_stripe;
			}
		} else {
			// no gateway chooser
			if (cf7pp_result_paypal > -1) {
				window.location.href = cf7pp_path_paypal;
			}
			
			// stripe
			if (cf7pp_result_stripe > -1) {
				window.location.href = cf7pp_path_stripe;
			}
		}
	}


	// show stripe success message
	let searchParams = new URLSearchParams(window.location.search)
	
	if (searchParams.has('cf7pp_stripe_success')) {
		
		let fid = searchParams.get('cf7pp_fid');
		
		var cf7pp_data = {
			'action':	'cf7pp_get_form_stripe_success',
		};
		
		// Use REST API if request_method is 2, otherwise use AJAX
		var requestUrl = (ajax_object_cf7pp.request_method == '2') 
			? ajax_object_cf7pp.rest_url + 'cf7pp_get_form_stripe_success'
			: ajax_object_cf7pp.ajax_url;
		
		jQuery.ajax({
			type: (ajax_object_cf7pp.request_method == '2') ? "GET" : "POST",
			data: cf7pp_data,
			dataType: "json",
			async: false,
			url: requestUrl,
			xhrFields: {
				withCredentials: true
			},
			success: function (response) {
				var html_response = response.html;
				
				jQuery('[id^="wpcf7-f' + fid + '-"]').html(html_response);
			}
		});
		
	}



});
// source --> https://theoutdoorchef.com.au/wp-content/plugins/eventprime-event-calendar-management/public/js/eventprime-event-calendar-management-public.js?ver=4.3.2.0 
(function( $ ) {
	'use strict';

	/**
	 * All of the code for your public-facing JavaScript source
	 * should reside in this file.
	 *
	 * Note: It has been assumed you will write jQuery code here, so the
	 * $ function reference has been prepared for usage within the scope
	 * of this function.
	 *
	 * This enables you to define handlers, for when the DOM is ready:
	 *
	 * $(function() {
	 *
	 * });
	 *
	 * When the window is loaded:
	 *
	 * $( window ).load(function() {
	 *
	 * });
	 *
	 * ...and/or other possibilities.
	 *
	 * Ideally, it is not considered best practise to attach more than a
	 * single DOM-ready or window-load handler for a particular page.
	 * Although scripts in the WordPress core, Plugins and Themes may be
	 * practising this, we should strive to set a better example in our own work.
	 */

})( jQuery );
// source --> https://theoutdoorchef.com.au/wp-content/plugins/eventprime-event-calendar-management/public/js/jquery.toast.min.js?ver=4.3.2.0 
"function"!=typeof Object.create&&(Object.create=function(t){function o(){}return o.prototype=t,new o}),function(t,o,i,s){"use strict";var n={_positionClasses:["bottom-left","bottom-right","top-right","top-left","bottom-center","top-center","mid-center"],_defaultIcons:["success","error","info","warning"],init:function(o,i){this.prepareOptions(o,t.toast.options),this.process()},prepareOptions:function(o,i){var s={};"string"==typeof o||o instanceof Array?s.text=o:s=o,this.options=t.extend({},i,s)},process:function(){this.setup(),this.addToDom(),this.position(),this.bindToast(),this.animate()},setup:function(){var o="";if(this._toastEl=this._toastEl||t("<div></div>",{class:"jq-toast-single"}),o+='<span class="jq-toast-loader"></span>',this.options.allowToastClose&&(o+='<span class="close-jq-toast-single">&times;</span>'),this.options.text instanceof Array){this.options.heading&&(o+='<h2 class="jq-toast-heading">'+this.options.heading+"</h2>"),o+='<ul class="jq-toast-ul">';for(var i=0;i<this.options.text.length;i++)o+='<li class="jq-toast-li" id="jq-toast-item-'+i+'">'+this.options.text[i]+"</li>";o+="</ul>"}else this.options.heading&&(o+='<h2 class="jq-toast-heading">'+this.options.heading+"</h2>"),o+=this.options.text;this._toastEl.html(o),!1!==this.options.bgColor&&this._toastEl.css("background-color",this.options.bgColor),!1!==this.options.textColor&&this._toastEl.css("color",this.options.textColor),this.options.textAlign&&this._toastEl.css("text-align",this.options.textAlign),!1!==this.options.icon&&(this._toastEl.addClass("jq-has-icon"),-1!==t.inArray(this.options.icon,this._defaultIcons)&&this._toastEl.addClass("jq-icon-"+this.options.icon)),!1!==this.options.class&&this._toastEl.addClass(this.options.class)},position:function(){"string"==typeof this.options.position&&-1!==t.inArray(this.options.position,this._positionClasses)?"bottom-center"===this.options.position?this._container.css({left:t(o).outerWidth()/2-this._container.outerWidth()/2,bottom:20}):"top-center"===this.options.position?this._container.css({left:t(o).outerWidth()/2-this._container.outerWidth()/2,top:20}):"mid-center"===this.options.position?this._container.css({left:t(o).outerWidth()/2-this._container.outerWidth()/2,top:t(o).outerHeight()/2-this._container.outerHeight()/2}):this._container.addClass(this.options.position):"object"==typeof this.options.position?this._container.css({top:this.options.position.top?this.options.position.top:"auto",bottom:this.options.position.bottom?this.options.position.bottom:"auto",left:this.options.position.left?this.options.position.left:"auto",right:this.options.position.right?this.options.position.right:"auto"}):this._container.addClass("bottom-left")},bindToast:function(){var t=this;this._toastEl.on("afterShown",function(){t.processLoader()}),this._toastEl.find(".close-jq-toast-single").on("click",function(o){o.preventDefault(),"fade"===t.options.showHideTransition?(t._toastEl.trigger("beforeHide"),t._toastEl.fadeOut(function(){t._toastEl.trigger("afterHidden")})):"slide"===t.options.showHideTransition?(t._toastEl.trigger("beforeHide"),t._toastEl.slideUp(function(){t._toastEl.trigger("afterHidden")})):(t._toastEl.trigger("beforeHide"),t._toastEl.hide(function(){t._toastEl.trigger("afterHidden")}))}),"function"==typeof this.options.beforeShow&&this._toastEl.on("beforeShow",function(){t.options.beforeShow(t._toastEl)}),"function"==typeof this.options.afterShown&&this._toastEl.on("afterShown",function(){t.options.afterShown(t._toastEl)}),"function"==typeof this.options.beforeHide&&this._toastEl.on("beforeHide",function(){t.options.beforeHide(t._toastEl)}),"function"==typeof this.options.afterHidden&&this._toastEl.on("afterHidden",function(){t.options.afterHidden(t._toastEl)}),"function"==typeof this.options.onClick&&this._toastEl.on("click",function(){t.options.onClick(t._toastEl)})},addToDom:function(){var o=t(".jq-toast-wrap");if(0===o.length?(o=t("<div></div>",{class:"jq-toast-wrap",role:"alert","aria-live":"polite"}),t("body").append(o)):this.options.stack&&!isNaN(parseInt(this.options.stack,10))||o.empty(),o.find(".jq-toast-single:hidden").remove(),o.append(this._toastEl),this.options.stack&&!isNaN(parseInt(this.options.stack),10)){var i=o.find(".jq-toast-single").length-this.options.stack;i>0&&t(".jq-toast-wrap").find(".jq-toast-single").slice(0,i).remove()}this._container=o},canAutoHide:function(){return!1!==this.options.hideAfter&&!isNaN(parseInt(this.options.hideAfter,10))},processLoader:function(){if(!this.canAutoHide()||!1===this.options.loader)return!1;var t=this._toastEl.find(".jq-toast-loader"),o=(this.options.hideAfter-400)/1e3+"s",i=this.options.loaderBg,s=t.attr("style")||"";s=s.substring(0,s.indexOf("-webkit-transition")),s+="-webkit-transition: width "+o+" ease-in;                       -o-transition: width "+o+" ease-in;                       transition: width "+o+" ease-in;                       background-color: "+i+";",t.attr("style",s).addClass("jq-toast-loaded")},animate:function(){t=this;if(this._toastEl.hide(),this._toastEl.trigger("beforeShow"),"fade"===this.options.showHideTransition.toLowerCase()?this._toastEl.fadeIn(function(){t._toastEl.trigger("afterShown")}):"slide"===this.options.showHideTransition.toLowerCase()?this._toastEl.slideDown(function(){t._toastEl.trigger("afterShown")}):this._toastEl.show(function(){t._toastEl.trigger("afterShown")}),this.canAutoHide()){var t=this;o.setTimeout(function(){"fade"===t.options.showHideTransition.toLowerCase()?(t._toastEl.trigger("beforeHide"),t._toastEl.fadeOut(function(){t._toastEl.trigger("afterHidden")})):"slide"===t.options.showHideTransition.toLowerCase()?(t._toastEl.trigger("beforeHide"),t._toastEl.slideUp(function(){t._toastEl.trigger("afterHidden")})):(t._toastEl.trigger("beforeHide"),t._toastEl.hide(function(){t._toastEl.trigger("afterHidden")}))},this.options.hideAfter)}},reset:function(o){"all"===o?t(".jq-toast-wrap").remove():this._toastEl.remove()},update:function(t){this.prepareOptions(t,this.options),this.setup(),this.bindToast()},close:function(){this._toastEl.find(".close-jq-toast-single").click()}};t.toast=function(t){var o=Object.create(n);return o.init(t,this),{reset:function(t){o.reset(t)},update:function(t){o.update(t)},close:function(){o.close()}}},t.toast.options={text:"",heading:"",showHideTransition:"fade",allowToastClose:!0,hideAfter:3e3,loader:!0,loaderBg:"#9EC600",stack:5,position:"bottom-left",bgColor:!1,textColor:!1,textAlign:"left",icon:!1,beforeShow:function(){},afterShown:function(){},beforeHide:function(){},afterHidden:function(){},onClick:function(){}}}(jQuery,window,document);