File: /var/www/html/bwcdev/wp-content/plugins/woocommerce-payments-old/dist/tokenized-payment-request.js
(()=>{var t={4676:()=>{jQuery((t=>{t("input[name=wc_deposit_option],input[name=wc_deposit_payment_plan]").on("change",(()=>{t("form").has("input[name=wc_deposit_option],input[name=wc_deposit_payment_plan]").trigger("woocommerce_variation_has_changed")}))}))}},e={};function a(r){var n=e[r];if(void 0!==n)return n.exports;var o=e[r]={exports:{}};return t[r](o,o.exports,a),o.exports}a.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return a.d(e,{a:e}),e},a.d=(t,e)=>{for(var r in e)a.o(e,r)&&!a.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t;a.g.importScripts&&(t=a.g.location+"");var e=a.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!t||!/^http(s?):/.test(t));)t=r[n--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=t})(),a.p=window.wcpayAssets.url,(()=>{"use strict";const t=window.wp.hooks,e=t=>"undefined"!=typeof wcpayConfig?wcpayConfig[t]:r(t),r=t=>{let e=null;if("undefined"!=typeof wcpay_upe_config)e=wcpay_upe_config;else{if("object"!=typeof wc||void 0===wc.wcSettings)return null;e=wc.wcSettings.getSetting("woocommerce_payments_data")||{}}return e[t]||null},n=t=>"object"==typeof wcpayExpressCheckoutParams&&wcpayExpressCheckoutParams.hasOwnProperty(t)?wcpayExpressCheckoutParams[t]:"object"==typeof wcpayPaymentRequestParams&&wcpayPaymentRequestParams.hasOwnProperty(t)?wcpayPaymentRequestParams[t]:null,o=t=>n("wc_ajax_url").toString().replace("%%endpoint%%","wcpay_"+t),i=t=>n(t),s=t=>o(t),c=(t,e,a="wcpay_")=>t.toString().replace("%%endpoint%%",a+e),l=["color","padding","paddingTop","paddingRight","paddingBottom","paddingLeft"],u=["fontFamily","fontSize","lineHeight","letterSpacing","fontWeight","fontVariation","textDecoration","textShadow","textTransform","-webkit-font-smoothing","-moz-osx-font-smoothing","transition"],d=["backgroundColor","border","borderTop","borderRight","borderBottom","borderLeft","borderRadius","borderWidth","borderColor","borderStyle","borderTopWidth","borderTopColor","borderTopStyle","borderRightWidth","borderRightColor","borderRightStyle","borderBottomWidth","borderBottomColor","borderBottomStyle","borderLeftWidth","borderLeftColor","borderLeftStyle","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","outline","outlineOffset","boxShadow"],p={".Label":[...l,...u],".Input":[...l,...u,...d],".Error":[...l,...u,...d],".Tab":[...l,...u,...d],".TabIcon":[...l],".TabLabel":[...l,...u],".Block":[...l.slice(1),...d.slice(1)]},h={".Label":p[".Label"],".Input":[...p[".Input"],"outlineColor","outlineWidth","outlineStyle"],".Error":p[".Error"],".Tab":["backgroundColor","color","fontFamily"],".Tab--selected":["outlineColor","outlineWidth","outlineStyle","backgroundColor","color",d],".TabIcon":p[".TabIcon"],".TabIcon--selected":["color"],".TabLabel":p[".TabLabel"],".Block":p[".Block"]};function m(t){return m="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},m(t)}var y=/^\s+/,f=/\s+$/;function b(t,e){if(e=e||{},(t=t||"")instanceof b)return t;if(!(this instanceof b))return new b(t,e);var a=function(t){var e,a,r,n={r:0,g:0,b:0},o=1,i=null,s=null,c=null,l=!1,u=!1;return"string"==typeof t&&(t=function(t){t=t.replace(y,"").replace(f,"").toLowerCase();var e,a=!1;if(j[t])t=j[t],a=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};return(e=G.rgb.exec(t))?{r:e[1],g:e[2],b:e[3]}:(e=G.rgba.exec(t))?{r:e[1],g:e[2],b:e[3],a:e[4]}:(e=G.hsl.exec(t))?{h:e[1],s:e[2],l:e[3]}:(e=G.hsla.exec(t))?{h:e[1],s:e[2],l:e[3],a:e[4]}:(e=G.hsv.exec(t))?{h:e[1],s:e[2],v:e[3]}:(e=G.hsva.exec(t))?{h:e[1],s:e[2],v:e[3],a:e[4]}:(e=G.hex8.exec(t))?{r:B(e[1]),g:B(e[2]),b:B(e[3]),a:Q(e[4]),format:a?"name":"hex8"}:(e=G.hex6.exec(t))?{r:B(e[1]),g:B(e[2]),b:B(e[3]),format:a?"name":"hex"}:(e=G.hex4.exec(t))?{r:B(e[1]+""+e[1]),g:B(e[2]+""+e[2]),b:B(e[3]+""+e[3]),a:Q(e[4]+""+e[4]),format:a?"name":"hex8"}:!!(e=G.hex3.exec(t))&&{r:B(e[1]+""+e[1]),g:B(e[2]+""+e[2]),b:B(e[3]+""+e[3]),format:a?"name":"hex"}}(t)),"object"==m(t)&&(X(t.r)&&X(t.g)&&X(t.b)?(e=t.r,a=t.g,r=t.b,n={r:255*D(e,255),g:255*D(a,255),b:255*D(r,255)},l=!0,u="%"===String(t.r).substr(-1)?"prgb":"rgb"):X(t.h)&&X(t.s)&&X(t.v)?(i=O(t.s),s=O(t.v),n=function(t,e,a){t=6*D(t,360),e=D(e,100),a=D(a,100);var r=Math.floor(t),n=t-r,o=a*(1-e),i=a*(1-n*e),s=a*(1-(1-n)*e),c=r%6;return{r:255*[a,i,o,o,s,a][c],g:255*[s,a,a,i,o,o][c],b:255*[o,o,s,a,a,i][c]}}(t.h,i,s),l=!0,u="hsv"):X(t.h)&&X(t.s)&&X(t.l)&&(i=O(t.s),c=O(t.l),n=function(t,e,a){var r,n,o;function i(t,e,a){return a<0&&(a+=1),a>1&&(a-=1),a<1/6?t+6*(e-t)*a:a<.5?e:a<2/3?t+(e-t)*(2/3-a)*6:t}if(t=D(t,360),e=D(e,100),a=D(a,100),0===e)r=n=o=a;else{var s=a<.5?a*(1+e):a+e-a*e,c=2*a-s;r=i(c,s,t+1/3),n=i(c,s,t),o=i(c,s,t-1/3)}return{r:255*r,g:255*n,b:255*o}}(t.h,i,c),l=!0,u="hsl"),t.hasOwnProperty("a")&&(o=t.a)),o=L(o),{ok:l,format:t.format||u,r:Math.min(255,Math.max(n.r,0)),g:Math.min(255,Math.max(n.g,0)),b:Math.min(255,Math.max(n.b,0)),a:o}}(t);this._originalInput=t,this._r=a.r,this._g=a.g,this._b=a.b,this._a=a.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||a.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=a.ok}function g(t,e,a){t=D(t,255),e=D(e,255),a=D(a,255);var r,n,o=Math.max(t,e,a),i=Math.min(t,e,a),s=(o+i)/2;if(o==i)r=n=0;else{var c=o-i;switch(n=s>.5?c/(2-o-i):c/(o+i),o){case t:r=(e-a)/c+(e<a?6:0);break;case e:r=(a-t)/c+2;break;case a:r=(t-e)/c+4}r/=6}return{h:r,s:n,l:s}}function _(t,e,a){t=D(t,255),e=D(e,255),a=D(a,255);var r,n,o=Math.max(t,e,a),i=Math.min(t,e,a),s=o,c=o-i;if(n=0===o?0:c/o,o==i)r=0;else{switch(o){case t:r=(e-a)/c+(e<a?6:0);break;case e:r=(a-t)/c+2;break;case a:r=(t-e)/c+4}r/=6}return{h:r,s:n,v:s}}function w(t,e,a,r){var n=[H(Math.round(t).toString(16)),H(Math.round(e).toString(16)),H(Math.round(a).toString(16))];return r&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0):n.join("")}function v(t,e,a,r){return[H(W(r)),H(Math.round(t).toString(16)),H(Math.round(e).toString(16)),H(Math.round(a).toString(16))].join("")}function k(t,e){e=0===e?0:e||10;var a=b(t).toHsl();return a.s-=e/100,a.s=N(a.s),b(a)}function S(t,e){e=0===e?0:e||10;var a=b(t).toHsl();return a.s+=e/100,a.s=N(a.s),b(a)}function C(t){return b(t).desaturate(100)}function q(t,e){e=0===e?0:e||10;var a=b(t).toHsl();return a.l+=e/100,a.l=N(a.l),b(a)}function x(t,e){e=0===e?0:e||10;var a=b(t).toRgb();return a.r=Math.max(0,Math.min(255,a.r-Math.round(-e/100*255))),a.g=Math.max(0,Math.min(255,a.g-Math.round(-e/100*255))),a.b=Math.max(0,Math.min(255,a.b-Math.round(-e/100*255))),b(a)}function A(t,e){e=0===e?0:e||10;var a=b(t).toHsl();return a.l-=e/100,a.l=N(a.l),b(a)}function P(t,e){var a=b(t).toHsl(),r=(a.h+e)%360;return a.h=r<0?360+r:r,b(a)}function R(t){var e=b(t).toHsl();return e.h=(e.h+180)%360,b(e)}function T(t,e){if(isNaN(e)||e<=0)throw new Error("Argument to polyad must be a positive number");for(var a=b(t).toHsl(),r=[b(t)],n=360/e,o=1;o<e;o++)r.push(b({h:(a.h+o*n)%360,s:a.s,l:a.l}));return r}function I(t){var e=b(t).toHsl(),a=e.h;return[b(t),b({h:(a+72)%360,s:e.s,l:e.l}),b({h:(a+216)%360,s:e.s,l:e.l})]}function M(t,e,a){e=e||6,a=a||30;var r=b(t).toHsl(),n=360/a,o=[b(t)];for(r.h=(r.h-(n*e>>1)+720)%360;--e;)r.h=(r.h+n)%360,o.push(b(r));return o}function E(t,e){e=e||6;for(var a=b(t).toHsv(),r=a.h,n=a.s,o=a.v,i=[],s=1/e;e--;)i.push(b({h:r,s:n,v:o})),o=(o+s)%1;return i}b.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,a,r=this.toRgb();return t=r.r/255,e=r.g/255,a=r.b/255,.2126*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.7152*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.0722*(a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4))},setAlpha:function(t){return this._a=L(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=_(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=_(this._r,this._g,this._b),e=Math.round(360*t.h),a=Math.round(100*t.s),r=Math.round(100*t.v);return 1==this._a?"hsv("+e+", "+a+"%, "+r+"%)":"hsva("+e+", "+a+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=g(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=g(this._r,this._g,this._b),e=Math.round(360*t.h),a=Math.round(100*t.s),r=Math.round(100*t.l);return 1==this._a?"hsl("+e+", "+a+"%, "+r+"%)":"hsla("+e+", "+a+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return w(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,a,r,n){var o=[H(Math.round(t).toString(16)),H(Math.round(e).toString(16)),H(Math.round(a).toString(16)),H(W(r))];return n&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1)?o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0):o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*D(this._r,255))+"%",g:Math.round(100*D(this._g,255))+"%",b:Math.round(100*D(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*D(this._r,255))+"%, "+Math.round(100*D(this._g,255))+"%, "+Math.round(100*D(this._b,255))+"%)":"rgba("+Math.round(100*D(this._r,255))+"%, "+Math.round(100*D(this._g,255))+"%, "+Math.round(100*D(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(F[w(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+v(this._r,this._g,this._b,this._a),a=e,r=this._gradientType?"GradientType = 1, ":"";if(t){var n=b(t);a="#"+v(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+e+",endColorstr="+a+")"},toString:function(t){var e=!!t;t=t||this._format;var a=!1,r=this._a<1&&this._a>=0;return e||!r||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(a=this.toRgbString()),"prgb"===t&&(a=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(a=this.toHexString()),"hex3"===t&&(a=this.toHexString(!0)),"hex4"===t&&(a=this.toHex8String(!0)),"hex8"===t&&(a=this.toHex8String()),"name"===t&&(a=this.toName()),"hsl"===t&&(a=this.toHslString()),"hsv"===t&&(a=this.toHsvString()),a||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return b(this.toString())},_applyModification:function(t,e){var a=t.apply(null,[this].concat([].slice.call(e)));return this._r=a._r,this._g=a._g,this._b=a._b,this.setAlpha(a._a),this},lighten:function(){return this._applyModification(q,arguments)},brighten:function(){return this._applyModification(x,arguments)},darken:function(){return this._applyModification(A,arguments)},desaturate:function(){return this._applyModification(k,arguments)},saturate:function(){return this._applyModification(S,arguments)},greyscale:function(){return this._applyModification(C,arguments)},spin:function(){return this._applyModification(P,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(M,arguments)},complement:function(){return this._applyCombination(R,arguments)},monochromatic:function(){return this._applyCombination(E,arguments)},splitcomplement:function(){return this._applyCombination(I,arguments)},triad:function(){return this._applyCombination(T,[3])},tetrad:function(){return this._applyCombination(T,[4])}},b.fromRatio=function(t,e){if("object"==m(t)){var a={};for(var r in t)t.hasOwnProperty(r)&&(a[r]="a"===r?t[r]:O(t[r]));t=a}return b(t,e)},b.equals=function(t,e){return!(!t||!e)&&b(t).toRgbString()==b(e).toRgbString()},b.random=function(){return b.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},b.mix=function(t,e,a){a=0===a?0:a||50;var r=b(t).toRgb(),n=b(e).toRgb(),o=a/100;return b({r:(n.r-r.r)*o+r.r,g:(n.g-r.g)*o+r.g,b:(n.b-r.b)*o+r.b,a:(n.a-r.a)*o+r.a})},b.readability=function(t,e){var a=b(t),r=b(e);return(Math.max(a.getLuminance(),r.getLuminance())+.05)/(Math.min(a.getLuminance(),r.getLuminance())+.05)},b.isReadable=function(t,e,a){var r,n,o,i,s,c=b.readability(t,e);switch(n=!1,(o=a,"AA"!==(i=((o=o||{level:"AA",size:"small"}).level||"AA").toUpperCase())&&"AAA"!==i&&(i="AA"),"small"!==(s=(o.size||"small").toLowerCase())&&"large"!==s&&(s="small"),r={level:i,size:s}).level+r.size){case"AAsmall":case"AAAlarge":n=c>=4.5;break;case"AAlarge":n=c>=3;break;case"AAAsmall":n=c>=7}return n},b.mostReadable=function(t,e,a){var r,n,o,i,s=null,c=0;n=(a=a||{}).includeFallbackColors,o=a.level,i=a.size;for(var l=0;l<e.length;l++)(r=b.readability(t,e[l]))>c&&(c=r,s=b(e[l]));return b.isReadable(t,s,{level:o,size:i})||!n?s:(a.includeFallbackColors=!1,b.mostReadable(t,["#fff","#000"],a))};var j=b.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},F=b.hexNames=function(t){var e={};for(var a in t)t.hasOwnProperty(a)&&(e[t[a]]=a);return e}(j);function L(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function D(t,e){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var a=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(t);return t=Math.min(e,Math.max(0,parseFloat(t))),a&&(t=parseInt(t*e,10)/100),Math.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function N(t){return Math.min(1,Math.max(0,t))}function B(t){return parseInt(t,16)}function H(t){return 1==t.length?"0"+t:""+t}function O(t){return t<=1&&(t=100*t+"%"),t}function W(t){return Math.round(255*parseFloat(t)).toString(16)}function Q(t){return B(t)/255}var z,$,U,G=($="[\\s|\\(]+("+(z="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+z+")[,|\\s]+("+z+")\\s*\\)?",U="[\\s|\\(]+("+z+")[,|\\s]+("+z+")[,|\\s]+("+z+")[,|\\s]+("+z+")\\s*\\)?",{CSS_UNIT:new RegExp(z),rgb:new RegExp("rgb"+$),rgba:new RegExp("rgba"+U),hsl:new RegExp("hsl"+$),hsla:new RegExp("hsla"+U),hsv:new RegExp("hsv"+$),hsva:new RegExp("hsva"+U),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function X(t){return!!G.CSS_UNIT.exec(t)}const V=t=>{const e=t.match(/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0?(\.\d+)?|1?(\.0+)?)\s*\)$/);if(e){const a=e[4]||1;t=`rgb(${e.slice(1,4).map((t=>Math.round(t*a+255*(1-a)))).join(", ")})`}return t},K={default:{hiddenContainer:"#wcpay-hidden-div",hiddenInput:"#wcpay-hidden-input",hiddenInvalidInput:"#wcpay-hidden-invalid-input"},classicCheckout:{appendTarget:".woocommerce-billing-fields__field-wrapper",upeThemeInputSelector:"#billing_first_name",upeThemeLabelSelector:".woocommerce-checkout .form-row label",rowElement:"p",validClasses:["form-row"],invalidClasses:["form-row","woocommerce-invalid","woocommerce-invalid-required-field"],backgroundSelectors:["li.wc_payment_method .wc-payment-form","li.wc_payment_method .payment_box","#payment","#order_review","form.checkout","body"]},blocksCheckout:{appendTarget:"#billing.wc-block-components-address-form",upeThemeInputSelector:"#billing-first_name",upeThemeLabelSelector:".wc-block-components-checkout-step__description",rowElement:"div",validClasses:["wc-block-components-text-input"],invalidClasses:["wc-block-components-text-input","has-error"],alternateSelectors:{appendTarget:"#shipping.wc-block-components-address-form",upeThemeInputSelector:"#shipping-first_name",upeThemeLabelSelector:".wc-block-components-checkout-step__description"},backgroundSelectors:["#payment-method .wc-block-components-radio-control-accordion-option","#payment-method","form.wc-block-checkout__form",".wc-block-checkout","body"]},bnplProductPage:{appendTarget:".product .cart .quantity",upeThemeInputSelector:".product .cart .quantity .qty",upeThemeLabelSelector:".product .cart .quantity label",rowElement:"div",validClasses:["input-text"],invalidClasses:["input-text","has-error"],backgroundSelectors:["#payment-method-message","#main > .product > div.summary.entry-summary","#main > .product","#main","body"]},bnplClassicCart:{appendTarget:".cart .quantity",upeThemeInputSelector:".cart .quantity .qty",upeThemeLabelSelector:".cart .quantity label",rowElement:"div",validClasses:["input-text"],invalidClasses:["input-text","has-error"],backgroundSelectors:["#payment-method-message","#main .entry-content .cart_totals","#main .entry-content","#main","body"]},bnplCartBlock:{appendTarget:".wc-block-cart .wc-block-components-quantity-selector",upeThemeInputSelector:".wc-block-cart .wc-block-components-quantity-selector .wc-block-components-quantity-selector__input",upeThemeLabelSelector:".wc-block-components-text-input",rowElement:"div",validClasses:["wc-block-components-text-input"],invalidClasses:["wc-block-components-text-input","has-error"],backgroundSelectors:[".wc-block-components-bnpl-wrapper",".wc-block-components-order-meta",".wc-block-components-totals-wrapper",".wp-block-woocommerce-cart-order-summary-block",".wp-block-woocommerce-cart-totals-block",".wp-block-woocommerce-cart .wc-block-cart",".wp-block-woocommerce-cart","body"]},updateSelectors:function(t){return t.hasOwnProperty("alternateSelectors")&&(Object.entries(t.alternateSelectors).forEach((e=>{const[a,r]=e;document.querySelector(t[a])||(t[a]=r)})),delete t.alternateSelectors),t},getSelectors:function(t){let e=this.blocksCheckout;switch(t){case"blocks_checkout":e=this.blocksCheckout;break;case"shortcode_checkout":e=this.classicCheckout;break;case"bnpl_product_page":e=this.bnplProductPage;break;case"bnpl_classic_cart":e=this.bnplClassicCart;break;case"bnpl_cart_block":e=this.bnplCartBlock}return{...this.default,...this.updateSelectors(e)}}},J={getHiddenContainer:function(t){const e=document.createElement("div");return e.setAttribute("id",this.getIDFromSelector(t)),e.style.border=0,e.style.clip="rect(0 0 0 0)",e.style.height="1px",e.style.margin="-1px",e.style.overflow="hidden",e.style.padding="0",e.style.position="absolute",e.style.width="1px",e},createRow:function(t,e=[]){const a=document.createElement(t);return e.length&&a.classList.add(...e),a},appendClone:function(t,e,a){const r=document.querySelector(e);if(r){const e=r.cloneNode(!0);e.id=this.getIDFromSelector(a),e.value="",t.appendChild(e)}},getIDFromSelector:function(t){return t.startsWith("#")||t.startsWith(".")?t.slice(1):t},init:function(t){const e=K.getSelectors(t),a=document.querySelector(e.appendTarget),r=document.querySelector(e.upeThemeInputSelector);if(!a||!r)return;document.querySelector(e.hiddenContainer)&&this.cleanup();const n=this.getHiddenContainer(e.hiddenContainer);a.appendChild(n);const o=this.createRow(e.rowElement,e.validClasses);n.appendChild(o);const i=this.createRow(e.rowElement,e.invalidClasses);n.appendChild(i),this.appendClone(o,e.upeThemeInputSelector,e.hiddenInput),this.appendClone(i,e.upeThemeInputSelector,e.hiddenInvalidInput),this.appendClone(i,e.upeThemeLabelSelector,e.hiddenInvalidInput),document.querySelector(e.hiddenInput).style.transition="none"},cleanup:function(){const t=document.querySelector(K.default.hiddenContainer);t&&t.remove()}},Y=(t,e,a=null)=>{if(!document.querySelector(t))return{};const r=h[e],n=document.querySelector(t),o=window.getComputedStyle(n),i={};for(let t=0;t<o.length;t++){const e=o[t].replace(/-([a-z])/g,(function(t){return t[1].toUpperCase()}));r.includes(e)&&(i[e]=V(o.getPropertyValue(o[t])))}if(".Input"===e||".Tab--selected"===e){const t=((t,e="solid",a)=>t&&a?[t,e,a].join(" "):"")(i.outlineWidth,i.outlineStyle,i.outlineColor);""!==t&&(i.outline=t),delete i.outlineWidth,delete i.outlineColor,delete i.outlineStyle}const s=o.getPropertyValue("text-indent");return"0px"!==s&&"0px"===i.paddingLeft&&"0px"===i.paddingRight&&(i.paddingLeft=s,i.paddingRight=s),".Block"===e&&(i.backgroundColor=a),i},Z=t=>{const e=K.getSelectors(t);J.init(t);const a=Y(e.hiddenInput,".Input"),r=Y(e.hiddenInvalidInput,".Input"),n=Y(e.upeThemeLabelSelector,".Label"),o=Y(e.upeThemeInputSelector,".Tab"),i=Y(e.hiddenInput,".Tab--selected"),s=(t=>{const e=Object.assign({},t);if(!t.backgroundColor||!t.color)return t;const a=((t,e)=>{const a={backgroundColor:t,color:e},r=b(t),n=b(e);if(!r.isValid()||!n.isValid())return{backgroundColor:"",color:""};const o=r.getBrightness()>50?b(r).darken(7):b(r).lighten(7),i=b.mostReadable(o,[n],{includeFallbackColors:!0});return a.backgroundColor=o.toRgbString(),a.color=i.toRgbString(),a})(t.backgroundColor,t.color);return e.backgroundColor=a.backgroundColor,e.color=a.color,e})(o),c={color:s.color},l={color:i.color},u=(t=>{let e=null,a=0;for(;!e&&a<t.length;){const r=document.querySelector(t[a]);if(!r){a++;continue}const n=window.getComputedStyle(r).backgroundColor;n&&b(n).getAlpha()>0&&(e=n),a++}return e||"#ffffff"})(e.backgroundSelectors),d=Y(e.upeThemeLabelSelector,".Block",u),p={variables:{colorBackground:u,colorText:n.color,fontFamily:n.fontFamily,fontSizeBase:n.fontSize},theme:(h=u,b(h).getBrightness()>125?"stripe":"night"),rules:{".Input":a,".Input--invalid":r,".Label":n,".Block":d,".Tab":o,".Tab:hover":s,".Tab--selected":i,".TabIcon:hover":c,".TabIcon--selected":l,".Text":n,".Text--redirect":n}};var h;return J.cleanup(),p};class tt{constructor(t,e){this.options=t,this.stripe=null,this.stripePlatform=null,this.request=e,this.isWooPayRequesting=!1}createStripe(t,e,a="",r=[]){const n={locale:e};return a&&(n.stripeAccount=a),r&&(n.betas=r),new Stripe(t,n)}getStripeForUPE(t){return this.options.forceNetworkSavedCards=r("paymentMethodsConfig")[t].forceNetworkSavedCards,this.getStripe()}getStripe(t=!1){const{publishableKey:e,accountId:a,forceNetworkSavedCards:r,locale:n,isStripeLinkEnabled:o}=this.options;if(r&&!t)return this.stripePlatform||(this.stripePlatform=this.createStripe(e,n)),this.stripePlatform;if(!this.stripe){let t=["card_country_event_beta_1"];o&&(t=t.concat(["link_autofill_modal_beta_1"])),this.stripe=this.createStripe(e,n,a,t)}return this.stripe}loadStripe(t=!1){return new Promise((e=>{try{e(this.getStripe(t))}catch(t){e({error:t})}}))}confirmIntent(t,a){const r=t.match(/#wcpay-confirm-(pi|si):(.+):(.+):(.+)$/);if(!r)return!0;const n="si"===r[1];let o=r[2];const s=r[3],c=r[4],l=t.indexOf("order-pay"),u=l>-1&&t.substring(l).match(/\d+/);return u&&(o=u[0]),(()=>{const{locale:t,publishableKey:a}=this.options,r=e("accountIdForIntentConfirmation");return n?this.getStripe().handleNextAction({clientSecret:s}):r?this.createStripe(a,t,r).confirmCardPayment(s):this.getStripe(!0).handleNextAction({clientSecret:s})})().then((t=>{var r;const n=t.paymentIntent&&t.paymentIntent.id||t.setupIntent&&t.setupIntent.id||t.error&&t.error.payment_intent&&t.error.payment_intent.id||t.error.setup_intent&&t.error.setup_intent.id,s=null!==(r=i("ajax_url"))&&void 0!==r?r:e("ajaxUrl");return[this.request(s,{action:"update_order_status",order_id:o,_ajax_nonce:c,intent_id:n,payment_method_id:a||null}),t.error]})).then((([t,e])=>{if(e)throw e;return t.then((t=>{const e="string"==typeof t?JSON.parse(t):t;if(e.error)throw e.error;return e.return_url}))}))}setupIntent(t){return this.request(e("ajaxUrl"),{action:"create_setup_intent","wcpay-payment-method":t,_ajax_nonce:e("createSetupIntentNonce")}).then((t=>{if(!t.success)throw t.data.error;return"succeeded"===t.data.status?t.data:this.getStripe().confirmCardSetup(t.data.client_secret).then((t=>{const{setupIntent:e,error:a}=t;if(a)throw a;return e}))}))}saveUPEAppearance(t,a){return this.request(e("ajaxUrl"),{elements_location:a,appearance:JSON.stringify(t),action:"save_upe_appearance",_ajax_nonce:e("saveUPEAppearanceNonce")}).then((t=>t.data)).catch((t=>{throw t.message?t:new Error(t.statusText)}))}paymentRequestCalculateShippingOptions(t){return this.request(s("get_shipping_options"),{security:i("nonce")?.shipping,is_product_page:i("is_product_page"),...t})}paymentRequestUpdateShippingDetails(t){return this.request(s("update_shipping_method"),{security:i("nonce")?.update_shipping,shipping_method:[t.id],is_product_page:i("is_product_page")})}paymentRequestGetCartDetails(){return this.request(s("get_cart_details"),{security:i("nonce")?.get_cart_details})}paymentRequestAddToCart(t){return this.request(s("add_to_cart"),{security:i("nonce")?.add_to_cart,...t})}paymentRequestEmptyCart(t){return this.request(s("empty_cart"),{security:i("nonce")?.empty_cart,booking_id:t})}paymentRequestGetSelectedProductData(t){return this.request(s("get_selected_product_data"),{security:i("nonce")?.get_selected_product_data,...t})}paymentRequestCreateOrder(t){return this.request(s("create_order"),{_wpnonce:i("nonce")?.checkout,...t})}expressCheckoutECECalculateShippingOptions(t){return this.request(o("get_shipping_options"),{security:n("nonce")?.shipping,is_product_page:n("is_product_page"),...t})}expressCheckoutECECreateOrder(t){return this.request(o("create_order"),{_wpnonce:n("nonce")?.checkout,...t})}expressCheckoutECEPayForOrder(t,e){return this.request(o("pay_for_order"),{_wpnonce:n("nonce")?.pay_for_order,order:t,...e})}initWooPay(t,a){if(!this.isWooPayRequesting){this.isWooPayRequesting=!0;const r=e("wcAjaxUrl"),n=e("initWooPayNonce"),o=document.querySelector(".wp-block-woocommerce-checkout")?"blocks_checkout":document.querySelector(".woocommerce-billing-fields")?"shortcode_checkout":document.querySelector(".wp-block-woocommerce-cart")?"bnpl_cart_block":document.querySelector(".woocommerce-cart-form")?"bnpl_classic_cart":document.querySelector(".wp-block-woocommerce-product-details")?"bnpl_product_page":void 0;return this.request(c(r,"init_woopay"),{_wpnonce:n,appearance:Z(o),email:t,user_session:a,order_id:e("order_id"),key:e("key"),billing_email:e("billing_email")}).finally((()=>{this.isWooPayRequesting=!1}))}}expressCheckoutAddToCart(t){const a=e("wcAjaxUrl"),r=e("addToCartNonce");return this.request(c(a,"add_to_cart"),{security:r,...t})}paymentRequestPayForOrder(t,e){return this.request(s("pay_for_order"),{_wpnonce:i("nonce")?.pay_for_order,order:t,...e})}pmmeGetCartData(){return fetch(`${r("storeApiURL")}/cart`,{method:"GET",credentials:"same-origin",headers:{"Content-Type":"application/json"}}).then((t=>{if(!t.ok)throw new Error(t.statusText);return t.json()}))}}const et=window.wp.apiFetch;var at=a.n(et);const rt=window.wp.url,nt=window.wp.i18n,ot=window.wp.htmlEntities,it=(t,e)=>{var a;return t*10**((null!==(a=ct("checkout")?.currency_decimals)&&void 0!==a?a:2)-e.currency_minor_unit)},st=t=>{const e=t.items.map((t=>({amount:it(parseInt(t.prices.price,10),t.prices),label:[t.name,t.quantity>1&&`(x${t.quantity})`,t.variation&&t.variation.map((t=>`${t.attribute}: ${t.value}`)).join(", ")].filter(Boolean).join(" ")}))),a=parseInt(t.totals.total_tax||"0",10);a&&e.push({amount:it(a,t.totals),label:(0,nt.__)("Tax","woocommerce-payments")});const r=parseInt(t.totals.total_shipping||"0",10);r&&e.push({amount:it(r,t.totals),label:(0,nt.__)("Shipping","woocommerce-payments")});const n=parseInt(t.totals.total_refund||"0",10);return n&&e.push({amount:-it(n,t.totals),label:(0,nt.__)("Refund","woocommerce-payments")}),e},ct=t=>"object"==typeof wcpayPaymentRequestParams&&wcpayPaymentRequestParams.hasOwnProperty(t)?wcpayPaymentRequestParams[t]:null;class lt{cartRequestHeaders={};async _request(t){return await at()({...t,path:(0,rt.addQueryArgs)(t.path,{currency:ct("checkout").currency_code.toUpperCase()}),headers:{...this.cartRequestHeaders,...t.headers}})}async placeOrder(t){return await this._request({method:"POST",path:"/wc/store/v1/checkout",credentials:"product"===ct("button_context")?"omit":void 0,headers:{"X-WooPayments-Express-Payment-Request":!0,"X-WooPayments-Express-Payment-Request-Nonce":ct("nonce").tokenized_cart_nonce||void 0,...this.cartRequestHeaders},data:t})}async getCart(){const t=await this._request({method:"GET",path:"/wc/store/v1/cart",parse:!1});return this.cartRequestHeaders={Nonce:t.headers.get("Nonce")},t.json()}async createAnonymousCart(){const t=await this._request({method:"GET",path:"/wc/store/v1/cart",credentials:"omit",parse:!1});this.cartRequestHeaders={Nonce:t.headers.get("Nonce"),"X-WooPayments-Store-Api-Nonce":t.headers.get("Nonce"),"Cart-Token":t.headers.get("Cart-Token"),"X-WooPayments-Express-Payment-Request-Nonce":t.headers.get("X-WooPayments-Express-Payment-Request-Nonce")}}async updateCustomer(t){return await this._request({method:"POST",path:"/wc/store/v1/cart/update-customer",credentials:"product"===ct("button_context")?"omit":void 0,headers:{"X-WooPayments-Express-Payment-Request":!0,"X-WooPayments-Express-Payment-Request-Nonce":ct("nonce").tokenized_cart_nonce||void 0,...this.cartRequestHeaders},data:t})}async selectShippingRate(t){return await this._request({method:"POST",path:"/wc/store/v1/cart/select-shipping-rate",credentials:"product"===ct("button_context")?"omit":void 0,data:t})}async addProductToCart(){const e={id:jQuery(".single_add_to_cart_button").val(),quantity:parseInt(jQuery(".quantity .qty").val(),10)||1,variation:[]};return await this._request({method:"POST",path:"/wc/store/v1/cart/add-item",credentials:"omit",data:(0,t.applyFilters)("wcpay.payment-request.cart-add-item",e)})}async emptyCart(){try{const t=(await this._request({method:"GET",path:"/wc/store/v1/cart",credentials:"omit"})).items.map((t=>this._request({method:"POST",path:"/wc/store/v1/cart/remove-item",credentials:"omit",data:{key:t.key}})));await Promise.all(t)}catch(t){}}}class ut{orderId;key;billingEmail="";cachedCartData={};constructor({orderId:t,key:e,billingEmail:a=""}){this.orderId=t,this.key=e,this.billingEmail=a}async placeOrder(t){return await at()({method:"POST",path:`/wc/store/v1/checkout/${this.orderId}`,headers:{Nonce:ct("nonce").tokenized_order_nonce},data:{...t,key:this.key,billing_email:this.billingEmail,billing_address:this.cachedCartData.billing_address,shipping_address:this.cachedCartData.shipping_address}})}async getCart(){return this.cachedCartData=await at()({method:"GET",path:(0,rt.addQueryArgs)(`/wc/store/v1/order/${this.orderId}`,{key:this.key,billing_email:this.billingEmail})})}}const dt=window.lodash;window.wp.domReady;const pt=(t,a={})=>{var r,n,o;const s=null!==(r=e("platformTrackerNonce"))&&void 0!==r?r:null===(n=i("nonce"))||void 0===n?void 0:n.platform_tracker,c=null!==(o=e("ajaxUrl"))&&void 0!==o?o:i("ajax_url"),l=new FormData;l.append("tracksNonce",s),l.append("action","platform_tracks"),l.append("tracksEventName",t),l.append("tracksEventProp",JSON.stringify(a)),fetch(c,{method:"post",body:l})};let ht;const mt=t=>{const e={google_pay:"gpay_button_click",apple_pay:"applepay_button_click"}[ht];e&&pt(e,{source:t})},yt=(0,dt.debounce)((t=>{const e={google_pay:"gpay_button_load",apple_pay:"applepay_button_load"}[ht];e&&pt(e,{source:t})}),1e3),ft=t=>{var e,a,r,n,o,i,s,c,l;return{shipping_address:{first_name:null!==(e=t.recipient?.split(" ")?.slice(0,1)?.join(" "))&&void 0!==e?e:"",last_name:null!==(a=t.recipient?.split(" ")?.slice(1)?.join(" "))&&void 0!==a?a:"",company:null!==(r=t.organization)&&void 0!==r?r:"",address_1:null!==(n=t.addressLine?.[0])&&void 0!==n?n:"",address_2:null!==(o=t.addressLine?.[1])&&void 0!==o?o:"",city:null!==(i=t.city)&&void 0!==i?i:"",state:null!==(s=t.region)&&void 0!==s?s:"",country:null!==(c=t.country)&&void 0!==c?c:"",postcode:null!==(l=t.postalCode?.replace(" ",""))&&void 0!==l?l:""}}},bt=t=>{var e,a,r,n,o,i,s,c,l,u,d,p,h,m,y,f;const b=(null!==(e=t.paymentMethod?.billing_details?.name)&&void 0!==e?e:t.payerName)||"",g=null!==(a=t.paymentMethod?.billing_details?.address)&&void 0!==a?a:{},_=null!==(r=t.shippingAddress)&&void 0!==r?r:{},w="applePay"===t.walletName?"apple_pay":"google_pay",v=null!==(n=null!==(o=t.paymentMethod?.billing_details?.phone)&&void 0!==o?o:t.payerPhone?.replace("/[() -]/g",""))&&void 0!==n?n:"";return{customer_note:t.order_comments,billing_address:{first_name:null!==(i=b.split(" ")?.slice(0,1)?.join(" "))&&void 0!==i?i:"",last_name:b.split(" ")?.slice(1)?.join(" ")||"-",company:null!==(s=g.organization)&&void 0!==s?s:"",address_1:null!==(c=g.line1)&&void 0!==c?c:"",address_2:null!==(l=g.line2)&&void 0!==l?l:"",city:null!==(u=g.city)&&void 0!==u?u:"",state:null!==(d=g.state)&&void 0!==d?d:"",postcode:null!==(p=g.postal_code)&&void 0!==p?p:"",country:null!==(h=g.country)&&void 0!==h?h:"",email:null!==(m=null!==(y=t.paymentMethod?.billing_details?.email)&&void 0!==y?y:t.payerEmail)&&void 0!==m?m:"",phone:v},shipping_address:{...ft(_).shipping_address,phone:v},payment_method:"woocommerce_payments",payment_data:[{key:"payment_method",value:"card"},{key:"payment_request_type",value:w},{key:"wcpay-fraud-prevention-token",value:null!==(f=window.wcpayFraudPreventionToken)&&void 0!==f?f:""},{key:"wcpay-payment-method",value:t.paymentMethod?.id}]}};let gt=null;const _t={init:({$container:t})=>{gt=t},getElements:()=>jQuery(".wcpay-payment-request-wrapper,#wcpay-payment-request-button-separator"),blockButton:()=>{gt.data("blockUI.isBlocked")||gt.block({message:null})},unblockButton:()=>{_t.show(),gt.unblock()},showButton:t=>{gt.length&&(_t.show(),t.mount("#wcpay-payment-request-button"))},hide:()=>{_t.getElements().hide()},show:()=>{_t.getElements().show()}},wt=_t,vt=(t,e,a=!1)=>{let r;return function(){const n=this,o=arguments,i=a&&!r;clearTimeout(r),r=setTimeout((()=>{r=null,a||e.apply(n,o)}),t),i&&e.apply(n,o)}},kt=()=>null;class St{isPaymentAborted=!1;areListenersInitialized=!1;cachedCartData=void 0;paymentRequestCartApi=void 0;wcpayApi=void 0;initialProductData=void 0;constructor({wcpayApi:t,paymentRequestCartApi:e,productData:a}){this.wcpayApi=t,this.paymentRequestCartApi=e,this.initialProductData=a}async startPaymentRequest(){const e=this,a=(({stripe:t,cartData:e,productData:a})=>{let r=ct("checkout")?.country_code;return"PR"===r&&(r="US"),t.paymentRequest({country:r,requestPayerName:!0,requestPayerEmail:!0,requestPayerPhone:ct("checkout")?.needs_payer_phone,...a?{currency:a.currency,total:a.total,displayItems:a.displayItems,requestShipping:a.needs_shipping}:{currency:e.totals.currency_code.toLowerCase(),total:{label:ct("total_label"),amount:it(parseInt(e.totals.total_price,10)-parseInt(e.totals.total_refund||0,10),e.totals)},requestShipping:"pay_for_order"!==ct("button_context")&&e.needs_shipping,displayItems:st(e)}})})({stripe:this.wcpayApi.getStripe(),cartData:this.cachedCartData,productData:this.initialProductData}),r=await a.canMakePayment();if(!r)return void(0,t.doAction)("wcpay.payment-request.availability",{paymentRequestType:null});const n=r.applePay?"apple_pay":"google_pay";(0,t.doAction)("wcpay.payment-request.availability",{paymentRequestType:n}),ht=n,yt(ct("button_context")),"product"===ct("button_context")&&await this.paymentRequestCartApi.createAnonymousCart();const o=this.wcpayApi.getStripe().elements().create("paymentRequestButton",{paymentRequest:a,style:{paymentRequestButton:{type:ct("button").type,theme:ct("button").theme,height:ct("button").height+"px"}}});if(wt.showButton(o),"pay_for_order"===ct("button_context")&&o.on("click",(()=>{mt("pay_for_order")})),"product"===ct("button_context")&&this.attachPaymentRequestButtonEventListeners(),(0,t.removeFilter)("wcpay.payment-request.update-button-data","automattic/wcpay/payment-request"),(0,t.addFilter)("wcpay.payment-request.update-button-data","automattic/wcpay/payment-request",(async t=>{await t;const r=await e.getCartData(),n=e.initialProductData?.needs_shipping||e.cachedCartData?.needs_shipping;e.cachedCartData=r,e.isPaymentAborted||n!==r.needs_shipping?await e.init():a.update({total:{label:ct("total_label"),amount:it(parseInt(r.totals.total_price,10)-parseInt(r.totals.total_refund||0,10),r.totals)},displayItems:st(r)})})),"product"===ct("button_context")){const t=jQuery(".single_add_to_cart_button");o.on("click",(a=>(mt("product"),ct("login_confirmation")?(a.preventDefault(),void(t=>{if(!ct("login_confirmation"))return;let e=ct("login_confirmation")?.message;e=e.replace(/\*\*.*?\*\*/,"apple_pay"===t?"Apple Pay":"Google Pay"),e=e.replace(/\*\*/g,""),confirm(e)&&(window.location.href=ct("login_confirmation")?.redirect_url)})(n)):t.is(".disabled")?(a.preventDefault(),void(t.is(".wc-variation-is-unavailable")?window.alert(window.wc_add_to_cart_variation_params?.i18n_unavailable_text||(0,nt.__)("Sorry, this product is unavailable. Please choose a different combination.","woocommerce-payments")):window.alert(window?.wc_add_to_cart_variation_params?.i18n_make_a_selection_text||(0,nt.__)("Please select some product options before adding this product to your cart.","woocommerce-payments")))):void e.paymentRequestCartApi.addProductToCart())))}a.on("cancel",(()=>{e.isPaymentAborted=!0,"product"===ct("button_context")&&e.paymentRequestCartApi.emptyCart()})),a.on("shippingaddresschange",(async t=>{try{const a=await e.paymentRequestCartApi.updateCustomer(ft(t.shippingAddress)),r=(t=>t.shipping_rates[0].shipping_rates.map((t=>({id:t.rate_id,label:(0,ot.decodeEntities)(t.name),amount:it(parseInt(t.price,10),t),detail:[t.meta_data.find((t=>"pickup_address"===t.key))?.value,t.meta_data.find((t=>"pickup_details"===t.key))?.value].filter(Boolean).map(ot.decodeEntities).join(" - ")}))))(a);if(0===r.length)return t.updateWith({status:"invalid_shipping_address"}),void(e.cachedCartData=a);t.updateWith({status:"success",shippingOptions:r,total:{label:ct("total_label"),amount:it(parseInt(a.totals.total_price,10)-parseInt(a.totals.total_refund||0,10),a.totals)},displayItems:st(a)}),e.cachedCartData=a}catch(e){t.updateWith({status:"fail"})}})),a.on("shippingoptionchange",(async t=>{try{const a=await e.paymentRequestCartApi.selectShippingRate({package_id:0,rate_id:t.shippingOption.id});t.updateWith({status:"success",total:{label:ct("total_label"),amount:it(parseInt(a.totals.total_price,10)-parseInt(a.totals.total_refund||0,10),a.totals)},displayItems:st(a)}),e.cachedCartData=a}catch(e){t.updateWith({status:"fail"})}})),a.on("paymentmethod",(async a=>{try{const r=await e.paymentRequestCartApi.placeOrder({...bt(a),extensions:(0,t.applyFilters)("wcpay.payment-request.cart-place-order-extension-data",{})}),n=e.wcpayApi.confirmIntent(r.payment_result.redirect_url);a.complete("success");let o="";o=!0===n?r.payment_result.redirect_url:await n,jQuery.blockUI({message:null,overlayCSS:{background:"#fff",opacity:.6}}),window.location=o}catch(t){a.complete("fail"),jQuery(".woocommerce-error").remove();const e=jQuery(".woocommerce-notices-wrapper").first();e.length&&(e.append(jQuery('<div class="woocommerce-error" />').text(t.message)),jQuery("html, body").animate({scrollTop:e.find(".woocommerce-error").offset().top},600))}}))}attachPaymentRequestButtonEventListeners(){if(this.areListenersInitialized)return;this.areListenersInitialized=!0;const e=jQuery(".quantity");e.on("input",".qty",(()=>{wt.blockButton()})),e.on("input",".qty",vt(250,(async()=>{await(0,t.applyFilters)("wcpay.payment-request.update-button-data",Promise.resolve()),wt.unblockButton()})))}async getCartData(){if("product"!==ct("button_context"))return await this.paymentRequestCartApi.getCart();const t=new lt;await t.createAnonymousCart();const e=await t.addProductToCart();return t.emptyCart().finally(kt),e}async init(){if(!this.cachedCartData)try{this.cachedCartData=await this.getCartData()}catch(t){}this.cachedCartData&&(this.initialProductData=void 0),await this.startPaymentRequest(),this.isPaymentAborted=!1}}a(4676),(0,t.addFilter)("wcpay.payment-request.cart-place-order-extension-data","automattic/wcpay/payment-request",(t=>{const e=jQuery("#wcpay-express-checkout__order-attribution-inputs input");if(!e.length)return t;const a={};return e.each((function(){const t=jQuery(this).attr("name").replace("wc_order_attribution_",""),e=jQuery(this).val();t&&e&&(a[t]=e)})),{...t,"woocommerce/order-attribution":a}})),jQuery((e=>{e(document.body).on("woocommerce_variation_has_changed",(async()=>{try{wt.blockButton(),await(0,t.applyFilters)("wcpay.payment-request.update-button-data",Promise.resolve()),wt.unblockButton()}catch(t){wt.hide()}}))})),(0,t.addFilter)("wcpay.payment-request.cart-add-item","automattic/wcpay/payment-request",(t=>{const e=jQuery(".single_variation_wrap");if(!e.length)return t;const a=e.find('input[name="product_id"]').val();return{...t,id:parseInt(a,10)}})),(0,t.addFilter)("wcpay.payment-request.cart-add-item","automattic/wcpay/payment-request",(t=>{const e=jQuery(".variations_form");if(!e.length)return t;const a=[];return e.find(".variations select").each((function(){const t=jQuery(this),e=t.data("attribute_name")||t.attr("name");a.push({attribute:document.querySelector(`label[for="${e.replace("attribute_","")}"]`).innerHTML,value:t.val()||""})})),{...t,variation:[...t.variation,...a]}})),jQuery((e=>{if(ct("has_block")&&"pay_for_order"!==ct("button_context"))return;const a=ct("stripe").publishableKey;if(!a)return;wt.init({$container:e("#wcpay-payment-request-button")});const n=new tt({publishableKey:a,accountId:ct("stripe").accountId,locale:ct("stripe").locale},((t,a)=>new Promise(((r,n)=>{e.post(t,a).then(r).fail(n)}))));let o=new lt;"pay_for_order"===ct("button_context")&&(o=new ut({orderId:r("order_id"),key:r("key"),billingEmail:r("billing_email")}));const i=new St({wcpayApi:n,paymentRequestCartApi:o,productData:ct("product")||void 0});i.init(),e(document.body).on("updated_cart_totals",(async()=>{await(0,t.applyFilters)("wcpay.payment-request.update-button-data",Promise.resolve()),i.init()})),e(document.body).on("updated_checkout",(async()=>{await(0,t.applyFilters)("wcpay.payment-request.update-button-data",Promise.resolve())}))}))})()})();