@zonos/elements 1.3.107 → 1.3.109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/cjs/{cart-9f3864db.js → cart-d25b699a.js} +4 -2
  2. package/dist/cjs/{createCustomEvent-7a156d77.js → createCustomEvent-4ea7b6dc.js} +1 -1
  3. package/dist/cjs/index.cjs.js +7 -7
  4. package/dist/cjs/{paypal-610cccad.js → paypal-fd423375.js} +7 -1
  5. package/dist/cjs/zonos-address_7.cjs.entry.js +1 -1
  6. package/dist/cjs/zonos-cart-items_13.cjs.entry.js +3 -3
  7. package/dist/cjs/zonos-checkout.cjs.entry.js +4 -3
  8. package/dist/cjs/zonos-controller.cjs.entry.js +1 -1
  9. package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
  10. package/dist/cjs/zonos-country-select_4.cjs.entry.js +1 -1
  11. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +1 -1
  12. package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
  13. package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
  14. package/dist/cjs/zonos-notification_3.cjs.entry.js +2 -2
  15. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +2 -1
  16. package/dist/collection/components/store/checkout/paypal.js +3 -1
  17. package/dist/collection/components/store/checkout/stripe.js +4 -2
  18. package/dist/collection/utils/generateCloudflareDeployUrl.js +2 -1
  19. package/dist/esm/{cart-4ba1878f.js → cart-911ba5dd.js} +4 -2
  20. package/dist/esm/{createCustomEvent-5fdd75bf.js → createCustomEvent-6ba5bcde.js} +1 -1
  21. package/dist/esm/index.js +7 -7
  22. package/dist/esm/{paypal-3d7d0148.js → paypal-04a10fc2.js} +7 -2
  23. package/dist/esm/zonos-address_7.entry.js +1 -1
  24. package/dist/esm/zonos-cart-items_13.entry.js +3 -3
  25. package/dist/esm/zonos-checkout.entry.js +4 -3
  26. package/dist/esm/zonos-controller.entry.js +1 -1
  27. package/dist/esm/zonos-country-flag.entry.js +1 -1
  28. package/dist/esm/zonos-country-select_4.entry.js +1 -1
  29. package/dist/esm/zonos-hello-dialog.entry.js +1 -1
  30. package/dist/esm/zonos-hello.entry.js +1 -1
  31. package/dist/esm/zonos-language-select_2.entry.js +1 -1
  32. package/dist/esm/zonos-notification_3.entry.js +2 -2
  33. package/dist/esm-es5/cart-911ba5dd.js +1 -0
  34. package/dist/esm-es5/{createCustomEvent-5fdd75bf.js → createCustomEvent-6ba5bcde.js} +1 -1
  35. package/dist/esm-es5/index.js +1 -1
  36. package/dist/esm-es5/{paypal-3d7d0148.js → paypal-04a10fc2.js} +2 -2
  37. package/dist/esm-es5/zonos-address_7.entry.js +1 -1
  38. package/dist/esm-es5/zonos-cart-items_13.entry.js +1 -1
  39. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  40. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  41. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  42. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  43. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  44. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  45. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  46. package/dist/esm-es5/zonos-notification_3.entry.js +1 -1
  47. package/dist/scripts/index.js +1 -1
  48. package/dist/scripts/loadZonos.js +1 -1
  49. package/dist/scripts/zonos.js +1 -1
  50. package/dist/types/components/store/checkout/stripe.d.ts +1 -0
  51. package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
  52. package/dist/zonos-elements/index.esm.js +1 -1
  53. package/dist/zonos-elements/p-018a4b36.js +1 -0
  54. package/dist/zonos-elements/{p-b0e0271d.system.entry.js → p-123cabaa.system.entry.js} +1 -1
  55. package/dist/zonos-elements/{p-db824268.entry.js → p-1e1397fe.entry.js} +1 -1
  56. package/dist/zonos-elements/{p-43df09ad.system.entry.js → p-24813754.system.entry.js} +1 -1
  57. package/dist/zonos-elements/{p-fce4ea2c.system.entry.js → p-27188a22.system.entry.js} +1 -1
  58. package/dist/zonos-elements/p-39c09f18.system.entry.js +1 -0
  59. package/dist/zonos-elements/{p-62d88537.system.entry.js → p-45323a2f.system.entry.js} +1 -1
  60. package/dist/zonos-elements/{p-99d3ecd4.js → p-60303c84.js} +1 -1
  61. package/dist/zonos-elements/{p-c3167f3c.system.js → p-631570f0.system.js} +1 -1
  62. package/dist/zonos-elements/{p-bac9279b.system.entry.js → p-6927d227.system.entry.js} +1 -1
  63. package/dist/zonos-elements/{p-2a522e2f.system.entry.js → p-76a4a647.system.entry.js} +1 -1
  64. package/dist/zonos-elements/{p-db0c6041.entry.js → p-8632c8f1.entry.js} +1 -1
  65. package/dist/zonos-elements/{p-b2a3e0f0.entry.js → p-8b0feb0e.entry.js} +1 -1
  66. package/dist/zonos-elements/{p-250f5e67.entry.js → p-8d98fed0.entry.js} +1 -1
  67. package/dist/zonos-elements/{p-7ef9b1e9.system.js → p-9d678aea.system.js} +1 -1
  68. package/dist/zonos-elements/{p-a84da418.entry.js → p-a0af6dc1.entry.js} +1 -1
  69. package/dist/zonos-elements/{p-b9f595e2.entry.js → p-adbcf21c.entry.js} +1 -1
  70. package/dist/zonos-elements/{p-d65d7206.entry.js → p-ba3d2965.entry.js} +1 -1
  71. package/dist/zonos-elements/p-c78dd680.system.js +1 -1
  72. package/dist/zonos-elements/{p-6b58734c.system.entry.js → p-c9e8f159.system.entry.js} +1 -1
  73. package/dist/zonos-elements/{p-bfab2cf6.entry.js → p-d6de8661.entry.js} +1 -1
  74. package/dist/zonos-elements/p-e2fa7600.entry.js +1 -0
  75. package/dist/zonos-elements/{p-7f543fa7.system.entry.js → p-e5d1d031.system.entry.js} +1 -1
  76. package/dist/zonos-elements/{p-09faf6e8.system.js → p-e880ab28.system.js} +2 -2
  77. package/dist/zonos-elements/p-e9771827.system.js +1 -0
  78. package/dist/zonos-elements/{p-5d7606f0.entry.js → p-eaf09ccb.entry.js} +1 -1
  79. package/dist/zonos-elements/{p-6fb1434f.system.entry.js → p-ee14ba06.system.entry.js} +1 -1
  80. package/dist/zonos-elements/p-ef9d6106.js +17 -0
  81. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  82. package/package.json +1 -1
  83. package/dist/esm-es5/cart-4ba1878f.js +0 -1
  84. package/dist/zonos-elements/p-61489a67.js +0 -17
  85. package/dist/zonos-elements/p-9c89dadf.system.js +0 -1
  86. package/dist/zonos-elements/p-9d7eb65e.system.entry.js +0 -1
  87. package/dist/zonos-elements/p-d9752dd6.js +0 -1
  88. package/dist/zonos-elements/p-ec46325e.entry.js +0 -1
@@ -1,17 +0,0 @@
1
- import{z as o,c as e}from"./p-a24da794.js";import{d as r,u as n,t,r as a,h as i}from"./p-99d3ecd4.js";import{h as s,l as c,a as l,j as u}from"./p-970fa103.js";import{t as d}from"./p-032159ed.js";
2
- /*!
3
- * paypal-js v8.1.0 (2024-06-07T16:55:00.122Z)
4
- * Copyright 2020-present, PayPal, Inc. All rights reserved.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */function p(o,e){void 0===e&&(e={});var r=document.createElement("script");return r.src=o,Object.keys(e).forEach((function(o){r.setAttribute(o,e[o]),"data-csp-nonce"===o&&r.setAttribute("nonce",e["data-csp-nonce"])})),r}function y(o){return window[o]}function v(o,e){if("object"!=typeof o||null===o)throw new Error("Expected an options object.");var r=o.environment;if(r&&"production"!==r&&"sandbox"!==r)throw new Error('The `environment` option must be either "production" or "sandbox".');if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}const f=({backgroundColor1:o,backgroundColor2:e})=>d.readability(o,e)>2.5,w=e=>{const r=o.checkoutSettings.analyticsProviders.find((o=>"GOOGLE_ANALYTICS"===o.type));r&&"DISABLED"!==(null==r?void 0:r.status)&&"function"==typeof window.gtag&&(c("Zonos submits gtag event","log",e),window.gtag("event",e,{}))},{reset:b,state:h}=e((()=>({orderIdCreated:null,paypalButtons:[],paypalClientId:"",paypalErrorMessage:null}))),m=({checkoutSessionId:e,onPaypalFail:c,onPaypalSessionDone:d,overrideBorderRaidus:p,overridePrimaryColor:y})=>({createOrder:async()=>{try{h.paypalErrorMessage=null,r.inventoryCheckErrorMessage=null;try{r.inventoryCheckErrorMessage=await n()}catch(o){r.inventoryCheckErrorMessage=t("Unable to check inventory. Please try again.")}return r.inventoryCheckErrorMessage?"":await(async({checkoutSessionId:o})=>{var e,r;const{errors:n,json:t}=await(async({checkoutSessionId:o})=>{const{errors:e,json:r}=await s("/api/zonos-elements/create-paypal-order",{body:{checkoutSessionId:o},method:"POST"});return{errors:e,json:r}})({checkoutSessionId:o}),a=null===(e=null==t?void 0:t.paypalOrderCreate)||void 0===e?void 0:e.paypalOrderId;if(n.length||!a)throw new Error((null===(r=n.find(Boolean))||void 0===r?void 0:r.message)||"An unexpected error occurred when creating paypal order.");return a})({checkoutSessionId:e})}catch(o){return l("Failed to create paypal order",o),h.paypalErrorMessage=t("Failed to create PayPal order. Please try again, or consider using an alternative method."),null==c||c(),""}},onApprove:async()=>{try{h.paypalErrorMessage=null,w("zonos-checkout-payment-info");const o=await(async({checkoutSessionId:o,paypalMockResponse:e})=>{var r,n;new URL(window.location.href);const{errors:a,json:i}=await(async({checkoutSessionId:o,paypalMockResponse:e})=>{const{errors:r,json:n}=await s("/api/zonos-elements/capture-paypal-order",{body:{checkoutSessionId:o,paypalMockResponse:e},method:"POST"});return{errors:r,json:n}})({checkoutSessionId:o,paypalMockResponse:e}),c=null===(r=null==i?void 0:i.paypalOrderCapture.order)||void 0===r?void 0:r.id;if(a.length||!c)throw new Error((null===(n=a.find(Boolean))||void 0===n?void 0:n.message)||t("An unexpected error occurred when processing PayPal order."));return c})({checkoutSessionId:e,paypalMockResponse:window.Zonos._paypalMockResponse});h.orderIdCreated=o,null==d||d({orderId:o}),a(),i()}catch(o){if(l("==== Failed to capture paypal order",o),o instanceof Error)return(({error:o})=>{var e;const r=u(o.message),n=null===(e=null==r?void 0:r.errors.find(Boolean))||void 0===e?void 0:e.message,a=(null==n?void 0:n.match(/\[(.*?)\] (.*)/i))||[];a||(h.paypalErrorMessage=t("An unexpected error occurred when processing PayPal order."));const i=a[2]||t("An unexpected error occurred when processing PayPal order.");h.paypalErrorMessage=i})({error:o});null==c||c()}},style:{borderRadius:"SHARP"===p?0:10,color:f({backgroundColor1:"#ffc33a",backgroundColor2:y||o.appearance.colorPrimary||""})?"gold":"blue",shape:"rect"}}),P=async({currency:e})=>{var r;if(!(null===(r=o.checkoutSettings.externalPaymentMethods)||void 0===r?void 0:r.find((o=>"PAYPAL"===o.type&&"ENABLED"===o.status))))return void c("=== Paypal is disabled for this store","warn");const n=o.checkoutSettings.externalServiceTokens.find((o=>"PAYPAL_CLIENT_ID"===o.type));if(!n)return void c("Failed to load paypal -- missing paypal publishable key","warn");const t="production"===o.zonosMode&&"LIVE"===o.checkoutSettings.mode?"production":"sandbox";window.Zonos.paypal=await function(o,e){if(void 0===e&&(e=Promise),v(o,e),"undefined"==typeof document)return e.resolve(null);var r=function(o){var e="sandbox"===o.environment?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js";delete o.environment,o.sdkBaseUrl&&(e=o.sdkBaseUrl,delete o.sdkBaseUrl);var r,n,t=o,a=Object.keys(t).filter((function(o){return null!=t[o]&&""!==t[o]})).reduce((function(o,e){var r=t[e].toString();return"data"===(e=e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(function(o,e){return(e?"-":"")+o.toLowerCase()}))).substring(0,4)||"crossorigin"===e?o.attributes[e]=r:o.queryParams[e]=r,o}),{queryParams:{},attributes:{}}),i=a.queryParams,s=a.attributes;return i["merchant-id"]&&-1!==i["merchant-id"].indexOf(",")&&(s["data-merchant-id"]=i["merchant-id"],i["merchant-id"]="*"),{url:"".concat(e,"?").concat((r=i,n="",Object.keys(r).forEach((function(o){0!==n.length&&(n+="&"),n+=o+"="+r[o]})),n)),attributes:s}}(o),n=r.url,t=r.attributes,a=t["data-namespace"]||"paypal",i=y(a);return t["data-js-sdk-library"]||(t["data-js-sdk-library"]="paypal-js"),function(o,e){var r=document.querySelector('script[src="'.concat(o,'"]'));if(null===r)return null;var n=p(o,e),t=r.cloneNode();if(delete t.dataset.uidAuto,Object.keys(t.dataset).length!==Object.keys(n.dataset).length)return null;var a=!0;return Object.keys(t.dataset).forEach((function(o){t.dataset[o]!==n.dataset[o]&&(a=!1)})),a?r:null}(n,t)&&i?e.resolve(i):function(o,e){void 0===e&&(e=Promise),v(o,e);var r=o.url,n=o.attributes;if("string"!=typeof r||0===r.length)throw new Error("Invalid url.");if(void 0!==n&&"object"!=typeof n)throw new Error("Expected attributes to be an object.");return new e((function(o,e){if("undefined"==typeof document)return o();!function(o){var e=o.onSuccess,r=o.onError,n=p(o.url,o.attributes);n.onerror=r,n.onload=e,document.head.insertBefore(n,document.head.firstElementChild)}({url:r,attributes:n,onSuccess:function(){return o()},onError:function(){var o=new Error('The script "'.concat(r,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return e(o)}})}))}({url:n,attributes:t},e).then((function(){var o=y(a);if(o)return o;throw new Error("The window.".concat(a," global variable is not available."))}))}({clientId:n.token,currency:e,environment:t}),c("==== Paypal script loaded")},k=o=>{var e;const n=window.Zonos.paypal;if(!n)return c("Paypal is not available"),null;const t=r.checkoutSessionId;if(!t)return c("Paypal is not available due to checkoutSessionId is not available"),null;c("==== Loading Paypal buttons"),h.paypalButtons.length&&(h.paypalButtons.forEach((async o=>{await o.close()})),h.paypalButtons=[]);const a=[null===(e=n.FUNDING)||void 0===e?void 0:e.PAYPAL].filter(Boolean);return h.paypalButtons=a.map((e=>{var r;let a=null;try{a=(null===(r=n.Buttons)||void 0===r?void 0:r.call(n,Object.assign(Object.assign({},m(Object.assign({checkoutSessionId:t,fundingSource:e},o))),{fundingSource:e})))||null}catch(o){c(`===== Failed to load paypal's "${e}" button`,"warn",o)}return(null==a?void 0:a.isEligible())?(c(`==== Paypal button ${e} loaded`),a):null})).filter(Boolean),h.paypalButtons};export{h as a,b,k as c,f as i,P as p,w as s}