!function(r,e){var t,s;e.jsonrpc=(s="/rpc/jsonrpc.tmpl",Drupal?.settings?.is_hub_translated_tdc_enabled&&Drupal?.settings?.pathPrefix&&(s="/"+Drupal.settings.pathPrefix+s.substring(1)),t={id:0,url:s,requestQueue:[],csrfInProgress:!1,csrfRPCMethod:"csrf.getToken",cachedCSRFPromise:null,errorCodes:{101:"The data type of this method is not supported.",102:"The data type of the request parameters is not supported.",103:"Your request did not return any results.",104:"Response is not in the expected format."},fetch:function(r){var e=this,t=this.getCsrfToken(),s=!!r&&r.hasOwnProperty("method")&&r.method===this.csrfRPCMethod,n=this.csrfInProgress;if(e.id++,s){if(n||t)return e.id}else{if(r.id=e.id,t)return this.fetchRPC(r),e.id;this.requestQueue.push(r)}return this.fetchCSRFToken((function(){})).then((function(){for(;e.requestQueue.length>0;)e.fetchRPC(e.requestQueue.shift())}),(function(){console.error("Error retrieving token")})),e.id},fetchCSRFToken:function(e){var t=this;return t.csrfInProgress=!0,this.cachedCSRFPromise||(this.cachedCSRFPromise=r.Deferred((function(r){t.fetchRPC({method:t.csrfRPCMethod,onSuccess:function(e){t.csrfInProgress=!1,r.resolve()},onFailure:function(e){t.csrfInProgress=!1,r.reject()}})})).promise()),this.cachedCSRFPromise.done(e)},fetchRPC:function(t){var s=this,n=t.id;delete t.id;var o=!1;"boolean"==typeof t.bustBrowserCache&&t.bustBrowserCache&&(o=!0);var a={method:"post"};t.sync&&(a.async=!1),t.timeout&&Number.isInteger(t.timeout)&&(a.timeout=t.timeout),t.onBoth?(a.onSuccess=t.onBoth,a.onFailure=t.onBoth):(a.onSuccess=t.onSuccess||function(r){},a.onFailure=t.onFailure||function(r){}),a.onSuccess=a?.onSuccess?.wrap((function(o){if(!o||!o.responseText)return u(s.createErrorResponse(103)),!1;r(document).trigger("RPC:RESULT",[o,t,n]);var a=JSON.parse(o.responseText);if(!Array.isArray(a))return u(s.createErrorResponse(104)),!1;var i=a[0];if(!i)return u(s.createErrorResponse(103)),!1;var c=e.jsonRpcResponse(i);return i.error?(u(c),!1):i.result?c:void 0})),a.onFailure=a.onFailure.wrap((function(r){var t=r;if(void 0!==t.responseText)try{var n=JSON.parse(t.responseText)[0];t=e.jsonRpcResponse(n)}catch(r){t=s.createErrorResponse(t.status,t.responseText)}return t}));var u=a.onFailure,i=t.method||"rpc.form",c=t.params||[];if("string"!=typeof i||i.length<=0)return u(s.createErrorResponse(101)),null;if("string"==typeof c&&(c=JSON.parse(c)),"object"!=typeof c)return u(s.createErrorResponse(102)),null;var f=[{method:t.method||"rpc.form",id:s.id,params:c}];a.data=r.param({JSONRPC:JSON.stringify(f)});var l=t.url||this.url+"?dbgmethod="+i;return o&&(l+="&cachebuster="+Date.parse(new Date)),a.success=function(r,e,t){return a.onSuccess.call(a,t)},a.type="POST",a.error=function(r){return a.onFailure.call(a,r)},t.url&&t.options?(r.ajax(t.url,t.options),this.id):(r.ajax(l,a),this.id)},getCsrfToken:function(){return r.cookie("csrftoken")},createErrorResponse:function(r,t){return t=t||this.errorCodes[r],new e.jsonRpcResponse({error:{code:r,data:{messages:[{text:t,display_locations:[],severity:"MESSAGE",tags:[],key:""}]}},id:this.id})}},t),e.jsonRpcResponse=function(e){var t={},s=e,n=function(r){this.product={sku:{}};var e=/^prod\.(.+)$/,t=/sku\.(.+)$/;for(var s in r){var n=null,o=s.match(e);if(o&&o[1]&&(n=o[1],this.product[n]=r[s]),!n){var a=s.match(t);a&&a[1]&&(n=a[1],this.product.sku[n]=r[s])}n||(this[s]=r[s])}},o=function(e){var t,s=e,o="",a={product:{sku:{}}},u=[];s.ac_results&&Array.isArray(s.ac_results)&&s.ac_results[0]&&(s.ac_results[0].result&&s.ac_results[0].result.CARTITEM&&(a=new n(s.ac_results[0].result.CARTITEM)),s.ac_results[0].action&&(t=s.ac_results[0].action)),s.trans_data&&s.trans_data.order&&Array.isArray(s.trans_data.order.items)&&(o=s.trans_data.items_count,r.each(s.trans_data.order.items,(function(){u.push(this)}))),this.getAllItems=function(){return u},this.getItem=function(){return a},this.getMethod=function(){return t},this.getCount=function(){return o}};return t.getId=function(){return s?s.id:null},t.getError=function(){return s&&s.error?s.error:null},t.getData=function(){return s&&s.result&&s.result.data?s.result.data:null},t.getValue=function(){return s&&s.result&&void 0!==s.result.value?s.result.value:null},t.getMessages=function(){if(s){if(s.result&&s.result.data&&s.result.data.messages)return s.result.data.messages;if(s.error&&s.error.data&&s.error.data.messages)return s.error.data.messages}return null},t.getCartResults=function(){var r=this.getData();return r?new o(r):null},t},r((function(){for(var t=e.onLoadRpcRequests||[],s=[],n=0,o=t.length;n0&&this.params[0].url_params&&("&"===this.params[0].url_params.charAt(0)?c+=this.params[0].url_params:c+="&"+this.params[0].url_params)})),""!==c&&(u+="?"+c.substring(1)),i.data=r.param({JSONRPC:JSON.stringify(s)}),i.type="POST",i.success=function(r){!function(r){for(var e=0,s=t.length;e