window.WPCACONSENTLOG=function(e){"use strict";var t={done:!1},n={unbind:function(){return e(window).off(WPCAFR.getEventName("consent_after"),c),e(window).off(WPCAFR.getEventName("decline_after"),s),e(window).off(WPCAFR.getEventName("init_states_before"),i),e(window).off(WPCAFR.getEventName("reset_after"),g),e("body").off("click",".wpca-btn-delete-consent",r),this},bind:function(t){return t&&this.unbind(),e(window).on(WPCAFR.getEventName("consent_after"),c),e(window).on(WPCAFR.getEventName("decline_after"),s),e(window).on(WPCAFR.getEventName("init_states_before"),i),e(window).on(WPCAFR.getEventName("reset_after"),g),e("body").on("click",".wpca-btn-delete-consent",r),this}};function o(e){try{switch(e.state){case"0":e.errors&&e.errors.length&&WPIE.log(e.errors);break;case"1":WPIE.log("your consent has been logged successfully.")}}catch(e){WPIE.log(e.message,e)}}function a(t,n){try{var a={},c={};c.context=wpcaData.ajaxContextConsentLog,c.type=t,c.consent="consent"===t?"1":"0",c.categories=n.categories||[],a.action="wpie-action",a[wpcaData.ns+"_action"]="wpca-log-consent",a.data=c,a.nonce=wpcaData.nonce,e.post(wpcaData.ajaxurl,a,o,"json")}catch(e){WPIE.log(e.message,e)}}function c(e,t){a("consent",t)}function s(e,t){a("decline",t)}function i(t,n){e(".wpca-btn-delete-consent").length>0?e(".wpca-btn-delete-consent").hideButton(0):e(".wpca-btn-delete-consent").hideButton(1)}function r(t){try{var n={},o={},a=e(this);o.context=wpcaData.ajaxContextConsentLog,n.action="wpie-action",n[wpcaData.ns+"_action"]="wpca-consent-log-delete-by-user",n.data=o,n.nonce=wpcaData.nonce,e.post(wpcaData.ajaxurl,n,(function(e){!function(e,t){try{switch(e.state){case"0":e.errors&&e.errors.length&&WPIE.log(e.errors);break;case"1":e.out.deleted>0?(t.html("Consent log deleted!"),WPIE.log(`your consent log has been deleted successfully. Deleted entries: ${e.out.deleted}`),setTimeout((function(){WPCAFR.triggerResetConsent()}),2e3)):(t.processingBntState("default"),WPIE.log("no consent logs found for your current ip address."))}}catch(e){WPIE.log(e.message,e)}}(e,a)}),"json")}catch(e){WPIE.log(e.message,e)}}function g(e,t){n.bind(!0)}return t.init=function(){try{if(this.done)return;var e=["ajaxContextConsentLog","needLogging"];if(null==wpcaData)throw new Error("Missing global param: wpcaData");for(var t=0;t<e.length;t++)if(null==wpcaData[e[t]])throw new Error("Missing global param: "+e[t]);wpcaData.needLogging&&n.bind(),this.done=!0}catch(e){WPIE.log(e.message,e)}},t}(jQuery||{},window.WPCACONSENTLOG),jQuery((function(e){e(window).on(WPCAFR.getEventName("init_ready"),(function(){WPCACONSENTLOG.init()}))}));