index of
/
home
/
thefkyzp
/
hulmvisaadvisor.com
/
wp-content
/
plugins
/
surecart
/
dist
/
File: /home/thefkyzp/hulmvisaadvisor.com/wp-content/plugins/surecart/dist/1012.js
"use strict";(self.webpackChunk_surecart_surecart=self.webpackChunk_surecart_surecart||[]).push([[1012],{4805:function(e,n,r){r.d(n,{a:function(){return p},b:function(){return s},g:function(){return d}});var t=r(4467),i=r(296);function o(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),r.push.apply(r,t)}return r}function u(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?o(Object(r),!0).forEach((function(n){(0,t.A)(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}function c(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return a(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var _n=0,t=function(){};return{s:t,n:function(){return _n>=e.length?{done:!0}:{done:!1,value:e[_n++]}},e:function(e){throw e},f:t}}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 i,o=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){u=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(u)throw i}}}}function a(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=Array(n);r<n;r++)t[r]=e[r];return t}function s(e){for(var n,r="",t=Object.entries(e);n=t.shift();){var o=n,u=(0,i.A)(o,2),a=u[0],s=u[1];if(Array.isArray(s)||s&&s.constructor===Object){var l,d=c(Object.entries(s).reverse());try{for(d.s();!(l=d.n()).done;){var p=(0,i.A)(l.value,2),f=p[0],h=p[1];t.unshift(["".concat(a,"[").concat(f,"]"),h])}}catch(e){d.e(e)}finally{d.f()}}else void 0!==s&&(null===s&&(s=""),r+="&"+[a,s].map(encodeURIComponent).join("="))}return r.substr(1)}function l(e){try{return decodeURIComponent(e)}catch(n){return e}}function d(e){return(function(e){var n;try{n=new URL(e,"http://example.com").search.substring(1)}catch(e){}if(n)return n}(e)||"").replace(/\+/g,"%20").split("&").reduce((function(e,n){var r=n.split("=").filter(Boolean).map(l),t=(0,i.A)(r,2),o=t[0],c=t[1],a=void 0===c?"":c;return o&&function(e,n,r){for(var t=n.length,i=t-1,o=0;o<t;o++){var c=n[o];!c&&Array.isArray(e)&&(c=e.length.toString()),c=["__proto__","constructor","prototype"].includes(c)?c.toUpperCase():c;var a=!isNaN(Number(n[o+1]));e[c]=o===i?r:e[c]||(a?[]:{}),Array.isArray(e[c])&&!a&&(e[c]=u({},e[c])),e=e[c]}}(e,o.replace(/\]/g,"").split("["),a),e}),Object.create(null))}function p(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1?arguments[1]:void 0;if(!n||!Object.keys(n).length)return e;var r=e,t=e.indexOf("?");return-1!==t&&(n=Object.assign(d(e),n),r=r.substr(0,t)),r+"?"+s(n)}},488:function(e,n,r){r.d(n,{i:function(){return o},m:function(){return i},z:function(){return t}});var t=["bif","byr","clp","djf","gnf","isk","jpy","kmf","krw","pyg","rwf","ugx","vnd","vuv","xaf","xag","xau","xba","xbb","xbc","xbd","xdr","xof","xpd","xpf","xpt","xts"],i=function(e,n){return o(n)?e:e/100},o=function(e){var n;return t.includes(null===(n=null==e?void 0:e.toLowerCase)||void 0===n?void 0:n.call(e))}},3:function(e,n,r){r.d(n,{a:function(){return z},h:function(){return G}});var t=r(467),i=r(45),o=r(296),u=r(4467),c=r(9280),a=r.n(c),s=r(4805),l=r(3506),d=["rest_route"],p=["path","url"],f=["url","path","data","parse"];function h(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),r.push.apply(r,t)}return r}function v(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?h(Object(r),!0).forEach((function(n){(0,u.A)(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}function w(e,n){return void 0!==(0,l.g)(e,n)}function _(e){var n=e.split("?"),r=n[1],t=n[0];return r?t+"?"+r.split("&").map((function(e){return e.split("=")})).map((function(e){return e.map(decodeURIComponent)})).sort((function(e,n){return e[0].localeCompare(n[0])})).map((function(e){return e.map(encodeURIComponent)})).map((function(e){return e.join("=")})).join("&"):t}var m=function(e,n){var r,t,i=e.path;return"string"==typeof e.namespace&&"string"==typeof e.endpoint&&(r=e.namespace.replace(/^\/|\/$/g,""),i=(t=e.endpoint.replace(/^\//,""))?r+"/"+t:r),delete e.namespace,delete e.endpoint,n(v(v({},e),{},{path:i}))};function b(e,n){return Promise.resolve(n?e.body:new window.Response(JSON.stringify(e.body),{status:200,statusText:"OK",headers:e.headers}))}var y=function(e){return e.json?e.json():Promise.reject(e)},g=function(e){return function(e){if(!e)return{};var n=e.match(/<([^>]+)>; rel="next"/);return n?{next:n[1]}:{}}(e.headers.get("link")).next},O=function(e){var n=!!e.path&&-1!==e.path.indexOf("per_page=-1"),r=!!e.url&&-1!==e.url.indexOf("per_page=-1");return n||r},x=function(){var e=(0,t.A)(a().mark((function e(n,r){var t,o,u,c,l,d;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!1!==n.parse){e.next=2;break}return e.abrupt("return",r(n));case 2:if(O(n)){e.next=4;break}return e.abrupt("return",r(n));case 4:return e.next=6,z(v(v({},(f={per_page:100},void 0,void 0,h=(a=n).path,w=a.url,v(v({},(0,i.A)(a,p)),{},{url:w&&(0,s.a)(w,f),path:h&&(0,s.a)(h,f)}))),{},{parse:!1}));case 6:return t=e.sent,e.next=9,y(t);case 9:if(o=e.sent,Array.isArray(o)){e.next=12;break}return e.abrupt("return",o);case 12:if(u=g(t)){e.next=15;break}return e.abrupt("return",o);case 15:c=[].concat(o);case 16:if(!u){e.next=27;break}return e.next=19,z(v(v({},n),{},{path:void 0,url:u,parse:!1}));case 19:return l=e.sent,e.next=22,y(l);case 22:d=e.sent,c=c.concat(d),u=g(l),e.next=16;break;case 27:return e.abrupt("return",c);case 28:case"end":return e.stop()}var a,f,h,w}),e)})));return function(_x,n){return e.apply(this,arguments)}}(),k=new Set(["PATCH","PUT","DELETE"]),j=function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Promise.resolve(function(e){return arguments.length>1&&void 0!==arguments[1]&&!arguments[1]?e:204===e.status?null:e.json?e.json():Promise.reject(e)}(e,n)).catch((function(e){return P(e,n)}))};function P(e){if(arguments.length>1&&void 0!==arguments[1]&&!arguments[1])throw e;return function(e){var n={code:"invalid_json",message:wp.i18n.__("The response is not a valid JSON response.")};if(!e||!e.json)throw n;return e.json().catch((function(){throw n}))}(e).then((function(e){var n={code:"unknown_error",message:wp.i18n.__("An unknown error occurred.")};throw e||n}))}var A,S,C,F,T,E,D,I={Accept:"application/json, */*;q=0.1"},M={credentials:"include"},N=[function(e,n){return"string"!=typeof e.url||w(e.url,"_locale")||(e.url=(0,s.a)(e.url,{_locale:"user"})),"string"!=typeof e.path||w(e.path,"_locale")||(e.path=(0,s.a)(e.path,{_locale:"user"})),n(e)},m,function(e,n){var r=e.method,t=void 0===r?"GET":r;return k.has(t.toUpperCase())&&(e=v(v({},e),{},{headers:v(v({},e.headers),{},{"X-HTTP-Method-Override":t,"Content-Type":"application/json"}),method:"POST"})),n(e)},x],U=function(e){if(e.status>=200&&e.status<300)return e;throw e},R=function(e){var n=e.url,r=e.path,t=e.data,o=e.parse,u=void 0===o||o,c=(0,i.A)(e,f),a=e.body,s=e.headers;return s=v(v({},I),s),t&&(a=JSON.stringify(t),s["Content-Type"]="application/json"),window.fetch(n||r||window.location.href,v(v(v({},M),c),{},{body:a,headers:s})).then((function(e){return Promise.resolve(e).then(U).catch((function(e){return P(e,u)})).then((function(e){return j(e,u)}))}),(function(e){if(e&&"AbortError"===e.name)throw e;throw{code:"fetch_error",message:wp.i18n.__("You are probably offline.")}}))};function z(e){return N.reduceRight((function(e,n){return function(r){return n(r,e)}}),R)(e).catch((function(n){return"rest_cookie_invalid_nonce"!==n.code?Promise.reject(n):window.fetch(z.nonceEndpoint).then(U).then((function(e){return e.text()})).then((function(n){return z.nonceMiddleware.nonce=n,z(e)}))}))}z.use=function(e){N.unshift(e)},z.setFetchHandler=function(e){R=e},z.createNonceMiddleware=function(e){var n=function e(n,r){var t=n.headers,i=void 0===t?{}:t;for(var o in i)if("x-wp-nonce"===o.toLowerCase()&&i[o]===e.nonce)return r(n);return r(v(v({},n),{},{headers:v(v({},i),{},{"X-WP-Nonce":e.nonce})}))};return n.nonce=e,n},z.createPreloadingMiddleware=function(e){var n=Object.fromEntries(Object.entries(e).map((function(e){var n=(0,o.A)(e,2),r=n[0],t=n[1];return[_(r),t]})));return function(e,r){var t=e.parse,o=void 0===t||t,u=e.path;if(!u&&e.url){var c=(0,s.g)(e.url),a=c.rest_route,l=(0,i.A)(c,d);"string"==typeof a&&(u=(0,s.a)(a,l))}if("string"!=typeof u)return r(e);var p=e.method||"GET",f=_(u);if("GET"===p&&n[f]){var h=n[f];return delete n[f],b(h,!!o)}if("OPTIONS"===p&&n[p]&&n[p][f]){var v=n[p][f];return delete n[p][f],b(v,!!o)}return r(e)}},z.createRootURLMiddleware=function(e){return function(n,r){return m(n,(function(n){var t,i=n.url,o=n.path;return"string"==typeof o&&(t=e,-1!==e.indexOf("?")&&(o=o.replace("?","&")),o=o.replace(/^\//,""),"string"==typeof t&&-1!==t.indexOf("?")&&(o=o.replace("?","&")),i=t+o),r(v(v({},n),{},{url:i}))}))}},z.fetchAllMiddleware=x,z.mediaUploadMiddleware=function(e,n){if(!function(e){var n=!!e.method&&"POST"===e.method;return(!!e.path&&-1!==e.path.indexOf("/wp/v2/media")||!!e.url&&-1!==e.url.indexOf("/wp/v2/media"))&&n}(e))return n(e);var r=0,t=function e(t){return r++,n({path:"/wp/v2/media/".concat(t,"/post-process"),method:"POST",data:{action:"create-image-subsizes"},parse:!1}).catch((function(){return r<5?e(t):(n({path:"/wp/v2/media/".concat(t,"?force=true"),method:"DELETE"}),Promise.reject())}))};return n(v(v({},e),{},{parse:!1})).catch((function(n){var r=n.headers.get("x-wp-upload-attachment-id");return n.status>=500&&n.status<600&&r?t(r).catch((function(){return!1!==e.parse?Promise.reject({code:"post_process",message:wp.i18n.__("Media upload failed. If this is a photo or a large image, please scale it down and try again.")}):Promise.reject(n)})):P(n,e.parse)})).then((function(n){return j(n,e.parse)}))},z.createThemePreviewMiddleware=function(e){return function(n,r){if("string"==typeof n.url){var t=(0,l.g)(n.url,"wp_theme_preview");void 0===t?n.url=(0,s.a)(n.url,{wp_theme_preview:e}):""===t&&(n.url=(0,l.r)(n.url,"wp_theme_preview"))}if("string"==typeof n.path){var i=(0,l.g)(n.path,"wp_theme_preview");void 0===i?n.path=(0,s.a)(n.path,{wp_theme_preview:e}):""===i&&(n.path=(0,l.r)(n.path,"wp_theme_preview"))}return r(n)}},z.fetchAllMiddleware=null,z.use(z.createRootURLMiddleware((null===(S=null===(A=null===window||void 0===window?void 0:window.parent)||void 0===A?void 0:A.scData)||void 0===S?void 0:S.root_url)||(null===(C=null===window||void 0===window?void 0:window.scData)||void 0===C?void 0:C.root_url))),(null===(F=null===window||void 0===window?void 0:window.scData)||void 0===F?void 0:F.nonce)&&(z.nonceMiddleware=z.createNonceMiddleware(null===(T=null===window||void 0===window?void 0:window.scData)||void 0===T?void 0:T.nonce),z.use(z.nonceMiddleware)),(null===(E=null===window||void 0===window?void 0:window.scData)||void 0===E?void 0:E.nonce_endpoint)&&(z.nonceEndpoint=null===(D=null===window||void 0===window?void 0:window.scData)||void 0===D?void 0:D.nonce_endpoint),z.use((function(e,n){return e.path=(0,s.a)(e.path,{t:Date.now()}),n(e)})),z.use((function(e,n){var r=n(e);return r.catch((function(e){return"invalid_json"===e.code&&(e.message=wp.i18n.__("The response is not a valid JSON response.","surecart"),e.additional_errors=[{code:"invalid_json",message:wp.i18n.sprintf(/* translators: %s: URL to debug settings page */ wp.i18n.__("Please ensure that your site is not in debug mode as this may interfere with API responses. %s","surecart"),'<a href="'.concat("https://surecart.com/docs/is-not-a-valid-json-response/",'" target="_blank" rel="noopener noreferrer">').concat(wp.i18n.__("More Information","surecart"),"</a>"))}]),"checkout.finalize_error"===e.code&&(e.additional_errors=[{code:"checkout.finalize_error",message:e.message}],e.message=wp.i18n.__("We were not able to process this order","surecart")),Promise.reject(e)})),r}));var L=function(e){var n={code:"invalid_json",message:wp.i18n.__("The response is not a valid JSON response.","surecart")};if((null==e?void 0:e.code)&&(null==e?void 0:e.message))throw e;if(!e||!e.json)throw n;return e.json().catch((function(){throw n}))},G=function(){var e=(0,t.A)(a().mark((function e(n){var r;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,L(n);case 2:if("rest_cookie_invalid_nonce"===(r=e.sent).code){e.next=5;break}throw r;case 5:return e.abrupt("return",window.fetch(z.nonceEndpoint).then((function(e){if(e.status>=200&&e.status<300)return e;throw e})).then((function(e){return e.text()})).then((function(e){z.nonceMiddleware.nonce=e})));case 6:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}()},2942:function(e,n,r){r.d(n,{o:function(){return t}});var t=function(e,n){new window.IntersectionObserver((function(e,r){e[0].intersectionRatio>0&&(n(),r.unobserve(e[0].target))})).observe(e)}},1517:function(e,n,r){r.d(n,{a:function(){return i},b:function(){return d},c:function(){return f},d:function(){return u},g:function(){return o},i:function(){return a},p:function(){return p},t:function(){return c}});var t=r(488),i=function(e){return(null==e?void 0:e.amount_off)&&(null==e?void 0:e.currency)?o({amount:e.amount_off,currency:e.currency}):(null==e?void 0:e.percent_off)?wp.i18n.sprintf(wp.i18n.__("%1d%% off","surecart"),0|e.percent_off):""},o=function(e){var n=e.amount,r=e.currency,i=function(e,n){return t.z.includes(n)?e:e/100}(n,r);return"".concat(new Intl.NumberFormat(void 0,{style:"currency",currency:r}).format(parseFloat(i.toFixed(2))))},u=function(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"usd";return null===(e=new Intl.NumberFormat(void 0,{style:"currency",currency:n}).formatToParts().find((function(e){return"currency"===e.type})))||void 0===e?void 0:e.value},c=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:wp.i18n.__("every","surecart"),t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:wp.i18n.__("once","surecart"),i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];switch(n){case"day":return"".concat(r," ").concat(wp.i18n.sprintf(i?wp.i18n._n("%d day","%d days",e,"surecart"):wp.i18n._n("day","%d days",e,"surecart"),e));case"week":return"".concat(r," ").concat(wp.i18n.sprintf(i?wp.i18n._n("%d week","%d weeks",e,"surecart"):wp.i18n._n("week","%d weeks",e,"surecart"),e));case"month":return"".concat(r," ").concat(wp.i18n.sprintf(i?wp.i18n._n("%d month","%d months",e,"surecart"):wp.i18n._n("month","%d months",e,"surecart"),e));case"year":return"".concat(r," ").concat(wp.i18n.sprintf(i?wp.i18n._n("%d year","%d years",e,"surecart"):wp.i18n._n("year","%d years",e,"surecart"),e));default:return t}},a=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return"";var r=n.showOnce,t=n.labels,i=n.abbreviate,o=(t||{}).interval,u=void 0===o?wp.i18n.__("every","surecart"):o;return"".concat(s(e,u,r?wp.i18n.__("once","surecart"):"",i)," ").concat(l(e,i))},s=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:wp.i18n.__("once","surecart"),t=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return e.recurring_interval_count&&e.recurring_interval&&1!==(null==e?void 0:e.recurring_period_count)?t?function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:wp.i18n.__("once","surecart"),t=arguments.length>3&&void 0!==arguments[3]&&arguments[3];switch(n){case"day":return" / ".concat(wp.i18n.sprintf(t?wp.i18n._n("%d day","%d days",e,"surecart"):wp.i18n._n("day","%d days",e,"surecart"),e));case"week":return" / ".concat(wp.i18n.sprintf(t?wp.i18n._n("%d wk","%d wks",e,"surecart"):wp.i18n._n("wk","%d wks",e,"surecart"),e));case"month":return" / ".concat(wp.i18n.sprintf(t?wp.i18n._n("%d mo","%d months",e,"surecart"):wp.i18n._n("mo","%d mos",e,"surecart"),e));case"year":return" / ".concat(wp.i18n.sprintf(t?wp.i18n._n("%d yr","%d yrs",e,"surecart"):wp.i18n._n("yr","%d yrs",e,"surecart"),e));default:return r}}(e.recurring_interval_count,e.recurring_interval,r):c(e.recurring_interval_count,e.recurring_interval," ".concat(n),r):""},l=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(null==e?void 0:e.recurring_period_count)&&1!==(null==e?void 0:e.recurring_period_count)?n?"x ".concat(e.recurring_period_count):" (".concat(wp.i18n.sprintf(wp.i18n._n("%d payment","%d payments",e.recurring_period_count,"surecart"),e.recurring_period_count),")"):""},d=function(e){return wp.i18n.sprintf(wp.i18n._n("%d payment remaining","%d payments remaining",e,"surecart"),e)},p=function(e){var n;return e?"".concat(null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.name," ").concat((null==e?void 0:e.name)?"— ".concat(e.name):""):""},f=function(e){switch(e){case"invalid":return wp.i18n.__("Not valid","surecart");case"expired":return wp.i18n.__("Expired","surecart");case"gone":return wp.i18n.__("Not available","surecart");case"less_than_min_subtotal_amount":return wp.i18n.__("Minimum not met","surecart");case"greater_than_max_subtotal_amount":return wp.i18n.__("Order too large","surecart");case"not_applicable":return wp.i18n.__("Product(s) not eligible","surecart");case"not_applicable_to_customer":return wp.i18n.__("Not eligible","surecart");case"":return"";default:return wp.i18n.__("Not redeemable","surecart")}}},3506:function(e,n,r){r.d(n,{g:function(){return i},r:function(){return o}});var t=r(4805);function i(e,n){return(0,t.g)(e)[n]}function o(e){var n=e.indexOf("?");if(-1===n)return e;for(var r=(0,t.g)(e),i=e.substr(0,n),o=arguments.length,u=new Array(o>1?o-1:0),c=1;c<o;c++)u[c-1]=arguments[c];u.forEach((function(e){return delete r[e]}));var a=(0,t.b)(r);return a?i+"?"+a:i}},1012:function(e,n,r){r.r(n),r.d(n,{sc_subscription_switch:function(){return _}});var t=r(9394),i=r(4467),o=r(467),u=r(3029),c=r(2901),a=r(9280),s=r.n(a),l=r(1346),d=r(3),p=r(2942),f=r(1517),h=r(4805);function v(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),r.push.apply(r,t)}return r}function w(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?v(Object(r),!0).forEach((function(n){(0,i.A)(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}var _=function(){return(0,c.A)((function e(n){(0,u.A)(this,e),(0,l.r)(this,n),this.query=void 0,this.heading=void 0,this.productGroupId=void 0,this.productId=void 0,this.subscription=void 0,this.filterAbove=4,this.successUrl=window.location.href,this.selectedPrice=void 0,this.products=[],this.prices=void 0,this.filter="month",this.hasFilters=void 0,this.showFilters=void 0,this.loading=void 0,this.busy=void 0,this.error=void 0}),[{key:"componentWillLoad",value:function(){var e=this;(0,p.o)(this.el,(0,o.A)(s().mark((function n(){return s().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,e.loading=!0,n.next=4,Promise.all([e.getGroup(),e.getProductPrices()]);case 4:n.next=10;break;case 6:n.prev=6,n.t0=n.catch(0),console.error(n.t0),(null===n.t0||void 0===n.t0?void 0:n.t0.message)?e.error=n.t0.message:e.error=wp.i18n.__("Something went wrong","surecart");case 10:return n.prev=10,e.loading=!1,n.finish(10);case 13:case"end":return n.stop()}}),n,null,[[0,6,10,13]])})))),this.handleSubscriptionChange()}},{key:"handleProductsChange",value:function(){var e;this.prices=this.products.map((function(e){var n;return null===(n=null==e?void 0:e.prices)||void 0===n?void 0:n.data})).flat().filter((function(e,n,r){return r.findIndex((function(n){return n.id===e.id}))===n})).filter((function(e){return!(null==e?void 0:e.archived)})).filter((function(e){return e.portal_subscription_update_enabled})),this.showFilters=(null===(e=this.prices)||void 0===e?void 0:e.length)>this.filterAbove}},{key:"handlePricesChange",value:function(e,n){var r=this;!(null==n?void 0:n.length)&&(null==e?void 0:e.length)&&(this.selectedPrice=e.find((function(e){var n,t;return e.id===(null===(t=null===(n=r.subscription)||void 0===n?void 0:n.price)||void 0===t?void 0:t.id)}))),this.hasFilters=w(w({},this.hasFilters),{},{split:this.prices.some((function(e){return!!(null==e?void 0:e.recurring_period_count)&&!(null==e?void 0:e.archived)})),month:this.prices.some((function(e){return"month"===e.recurring_interval&&!(null==e?void 0:e.recurring_period_count)&&!(null==e?void 0:e.archived)})),year:this.prices.some((function(e){return"year"===e.recurring_interval&&!(null==e?void 0:e.recurring_period_count)&&!(null==e?void 0:e.archived)})),never:this.prices.some((function(e){return!("never"!==e.recurring_interval&&e.recurring_interval||(null==e?void 0:e.archived))}))})}},{key:"handleSubscriptionChange",value:function(){var e,n;this.filter=(null===(n=null===(e=this.subscription)||void 0===e?void 0:e.price)||void 0===n?void 0:n.recurring_interval)||"month"}},{key:"hasMultipleFilters",value:function(){return Object.values(this.hasFilters||{}).filter((function(e){return!!e})).length>1}},{key:"getGroup",value:(r=(0,o.A)(s().mark((function e(){var n;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.productGroupId){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,(0,d.a)({path:(0,h.a)("surecart/v1/products/",w({product_group_ids:[this.productGroupId],expand:["prices"]},this.query))});case 4:return e.next=6,e.sent;case 6:n=e.sent,this.products=[].concat((0,t.A)(this.products),(0,t.A)(n));case 8:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getProductPrices",value:(n=(0,o.A)(s().mark((function e(){var n;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.productId){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,(0,d.a)({path:(0,h.a)("surecart/v1/products/".concat(this.productId),{expand:["prices"]})});case 4:return e.next=6,e.sent;case 6:n=e.sent,this.products=[].concat((0,t.A)(this.products),[n]);case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"handleSubmit",value:(e=(0,o.A)(s().mark((function e(n){var r,t,i,o,u,c,a,l,d,p,f,v;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.target.getFormJson();case 2:if(d=e.sent,p=d.plan,f=this.prices.find((function(e){return e.id===p})),v=null===(r=this.subscription)||void 0===r?void 0:r.price,(null==f?void 0:f.id)!==v.id||(null==f?void 0:f.ad_hoc)||(null===(i=null===(t=this.subscription)||void 0===t?void 0:t.variant_options)||void 0===i?void 0:i.length)){e.next=8;break}return e.abrupt("return");case 8:if(!(null===(u=null===(o=this.subscription)||void 0===o?void 0:o.variant_options)||void 0===u?void 0:u.length)){e.next=11;break}return this.busy=!0,e.abrupt("return",window.location.assign((0,h.a)(this.successUrl,w({action:"confirm_variation",price_id:p},!1===(null===(c=this.subscription)||void 0===c?void 0:c.live_mode)?{live_mode:!1}:{}))));case 11:if(!(null==f?void 0:f.ad_hoc)){e.next=14;break}return this.busy=!0,e.abrupt("return",window.location.assign((0,h.a)(this.successUrl,w({action:"confirm_amount",price_id:p},!1===(null===(a=this.subscription)||void 0===a?void 0:a.live_mode)?{live_mode:!1}:{}))));case 14:this.busy=!0,window.location.assign((0,h.a)(this.successUrl,w({action:"confirm",price_id:p},!1===(null===(l=this.subscription)||void 0===l?void 0:l.live_mode)?{live_mode:!1}:{})));case 16:case"end":return e.stop()}}),e,this)}))),function(_x){return e.apply(this,arguments)})},{key:"renderSwitcher",value:function(){var e=this;if(this.hasMultipleFilters()&&this.showFilters)return(0,l.h)("sc-flex",{slot:"end",class:"subscriptions-switch__switcher"},this.hasFilters.month&&(0,l.h)("sc-button",{onClick:function(){return e.filter="month"},size:"small",type:"month"===this.filter?"default":"text"},wp.i18n.__("Monthly","surecart")),this.hasFilters.week&&(0,l.h)("sc-button",{onClick:function(){return e.filter="week"},size:"small",type:"week"===this.filter?"default":"text"},wp.i18n.__("Weekly","surecart")),this.hasFilters.year&&(0,l.h)("sc-button",{onClick:function(){return e.filter="year"},size:"small",type:"year"===this.filter?"default":"text"},wp.i18n.__("Yearly","surecart")),this.hasFilters.never&&(0,l.h)("sc-button",{onClick:function(){return e.filter="never"},size:"small",type:"never"===this.filter?"default":"text"},wp.i18n.__("Lifetime","surecart")),this.hasFilters.split&&(0,l.h)("sc-button",{onClick:function(){return e.filter="split"},size:"small",type:"split"===this.filter?"default":"text"},wp.i18n.__("Payment Plan","surecart")))}},{key:"renderLoading",value:function(){return(0,l.h)("sc-choice",{name:"loading",disabled:!0},(0,l.h)("sc-skeleton",{style:{width:"60px",display:"inline-block"}}),(0,l.h)("sc-skeleton",{style:{width:"80px",display:"inline-block"},slot:"price"}),(0,l.h)("sc-skeleton",{style:{width:"120px",display:"inline-block"},slot:"description"}))}},{key:"isHidden",value:function(e){if(!this.showFilters||!this.hasMultipleFilters())return!1;var n=this.filter!==e.recurring_interval;return"never"!==this.filter||(null==e?void 0:e.recurring_interval)||(n=!1),"split"===this.filter&&(null==e?void 0:e.recurring_period_count)&&(n=!1),n}},{key:"renderContent",value:function(){var e=this;return this.loading?this.renderLoading():(0,l.h)("sc-choices",{required:!0},(0,l.h)("div",null,(this.prices||[]).filter((function(e){return!e.archived})).filter((function(n){var r;return(null==n?void 0:n.currency)===(null===(r=e.subscription)||void 0===r?void 0:r.currency)})).sort((function(e,n){return e.amount-n.amount})).map((function(n){var r,t,i=(null===(t=null===(r=e.subscription)||void 0===r?void 0:r.price)||void 0===t?void 0:t.id)===(null==n?void 0:n.id),o=e.products.find((function(e){return e.id===(null==n?void 0:n.product)}));return(0,l.h)("sc-choice",{key:null==n?void 0:n.id,checked:i,name:"plan",value:null==n?void 0:n.id,hidden:e.isHidden(n),onScChange:function(r){r.detail&&(e.selectedPrice=e.prices.find((function(e){return e.id===(null==n?void 0:n.id)})))}},(0,l.h)("div",null,(0,l.h)("strong",null,null==o?void 0:o.name," ",(null==n?void 0:n.name)&&(0,l.h)(l.F,null," — ",null==n?void 0:n.name))),(0,l.h)("div",{slot:"description"},(null==n?void 0:n.ad_hoc)?"".concat(wp.i18n.__("Custom amount","surecart")," ").concat((0,f.i)(n)):(0,l.h)(l.F,null,(0,l.h)("sc-format-number",{type:"currency",currency:(null==n?void 0:n.currency)||"usd",value:null==n?void 0:n.amount})," ",(0,f.i)(n,{showOnce:!0}))),i&&(0,l.h)("sc-tag",{type:"warning",slot:"price"},wp.i18n.__("Current Plan","surecart")))}))))}},{key:"buttonText",value:function(){var e,n,r,t,i,o,u,c,a;return(null===(n=null===(e=this.subscription)||void 0===e?void 0:e.variant_options)||void 0===n?void 0:n.length)?(null===(r=this.selectedPrice)||void 0===r?void 0:r.id)===(null===(i=null===(t=this.subscription)||void 0===t?void 0:t.price)||void 0===i?void 0:i.id)?wp.i18n.__("Update Options","surecart"):wp.i18n.__("Choose Options","surecart"):(null===(o=this.selectedPrice)||void 0===o?void 0:o.ad_hoc)?(null===(u=this.selectedPrice)||void 0===u?void 0:u.id)===(null===(a=null===(c=this.subscription)||void 0===c?void 0:c.price)||void 0===a?void 0:a.id)?wp.i18n.__("Update Amount","surecart"):wp.i18n.__("Choose Amount","surecart"):wp.i18n.__("Next","surecart")}},{key:"buttonDisabled",value:function(){var e,n,r,t,i;return!(null===(e=this.subscription)||void 0===e?void 0:e.variant_options)&&(null===(r=null===(n=this.subscription)||void 0===n?void 0:n.price)||void 0===r?void 0:r.id)===(null===(t=this.selectedPrice)||void 0===t?void 0:t.id)&&!(null===(i=this.selectedPrice)||void 0===i?void 0:i.ad_hoc)}},{key:"render",value:function(){var e,n,r,t,i,o,u=this;return!this.loading&&(null===(e=this.prices)||void 0===e?void 0:e.length)<2&&!(null===(r=null===(n=this.prices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.ad_hoc)&&!(null===(i=null===(t=this.subscription)||void 0===t?void 0:t.variant_options)||void 0===i?void 0:i.length)?null:(null===(o=this.subscription)||void 0===o?void 0:o.finite)?(0,l.h)("sc-alert",{type:"info",open:!0},wp.i18n.__("To make changes to your payment plan, please contact us.","surecart")):(0,l.h)("sc-dashboard-module",{heading:this.heading||wp.i18n.__("Update Plan","surecart"),class:"subscription-switch",error:this.error},(0,l.h)("span",{slot:"end"},this.renderSwitcher()),(0,l.h)("sc-form",{class:"subscriptions-switch",onScFormSubmit:function(e){return u.handleSubmit(e)}},this.renderContent(),(0,l.h)("sc-button",{type:"primary",full:!0,submit:!0,loading:this.loading||this.busy,disabled:this.buttonDisabled()},this.buttonText()," ",(0,l.h)("sc-icon",{name:"arrow-right",slot:"suffix"})),this.busy&&(0,l.h)("sc-block-ui",{style:{zIndex:"9"}})))}},{key:"el",get:function(){return(0,l.a)(this)}}],[{key:"watchers",get:function(){return{products:["handleProductsChange"],prices:["handlePricesChange"],subscription:["handleSubscriptionChange"]}}}]);var e,n,r}();_.style=":host{display:block;position:relative}[hidden]{display:none !important}.subscriptions-switch{display:grid;gap:0.5em}.subscriptions-switch__switcher{background:rgba(0, 0, 0, 0.035);padding:2px;line-height:1;border-radius:var(--sc-border-radius-small)}"},45:function(e,n,r){r.d(n,{A:function(){return i}});var t=r(8587);function i(e,n){if(null==e)return{};var r,i,o=(0,t.A)(e,n);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(i=0;i<u.length;i++)r=u[i],n.indexOf(r)>=0||{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}},8587:function(e,n,r){function t(e,n){if(null==e)return{};var r={};for(var t in e)if({}.hasOwnProperty.call(e,t)){if(n.indexOf(t)>=0)continue;r[t]=e[t]}return r}r.d(n,{A:function(){return t}})}}]);