@dropins/storefront-checkout 2.1.0-alpha1 → 2.1.0-alpha2
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.
- package/api/getCompanyCredit/getCompanyCredit.d.ts +4 -0
- package/api/getCompanyCredit/graphql/getCompanyCredit.graphql.d.ts +18 -0
- package/api/getCompanyCredit/graphql/index.d.ts +18 -0
- package/api/getCompanyCredit/index.d.ts +18 -0
- package/api/graphql/PaymentMethodFragment.graphql.d.ts +1 -1
- package/api/index.d.ts +1 -0
- package/api/initialize/initialize.d.ts +18 -3
- package/api/initialize/listeners.d.ts +3 -17
- package/api.js +2 -2
- package/api.js.map +1 -1
- package/chunks/PaymentOnAccount2.js +4 -0
- package/chunks/PaymentOnAccount2.js.map +1 -0
- package/chunks/PurchaseOrder.js +4 -0
- package/chunks/PurchaseOrder.js.map +1 -0
- package/chunks/classifiers.js +4 -0
- package/chunks/classifiers.js.map +1 -0
- package/chunks/events.js +1 -1
- package/chunks/events.js.map +1 -1
- package/chunks/events2.js +1 -1
- package/chunks/events2.js.map +1 -1
- package/chunks/fetch-graphql.js +2 -2
- package/chunks/fetch-graphql.js.map +1 -1
- package/chunks/getCompanyCredit.js +15 -0
- package/chunks/getCompanyCredit.js.map +1 -0
- package/chunks/guards.js +1 -1
- package/chunks/render.js +10 -0
- package/chunks/render.js.map +1 -0
- package/chunks/setBillingAddress.js +1 -1
- package/chunks/setGuestEmailOnCart.js +1 -1
- package/chunks/setGuestEmailOnCart.js.map +1 -1
- package/chunks/setShippingAddress.js +10 -10
- package/chunks/setShippingAddress.js.map +1 -1
- package/chunks/setShippingMethods.js +2 -2
- package/chunks/synchronizeCheckout.js +7 -7
- package/chunks/synchronizeCheckout.js.map +1 -1
- package/components/PaymentOnAccount/PaymentOnAccount.d.ts +17 -0
- package/components/PaymentOnAccount/PaymentOnAccountSkeleton.d.ts +4 -0
- package/components/PaymentOnAccount/index.d.ts +20 -0
- package/components/PurchaseOrder/PurchaseOrder.d.ts +10 -0
- package/components/PurchaseOrder/index.d.ts +19 -0
- package/components/index.d.ts +3 -1
- package/containers/AddressValidation.js +1 -1
- package/containers/AddressValidation.js.map +1 -1
- package/containers/BillToShippingAddress.js +1 -1
- package/containers/BillToShippingAddress.js.map +1 -1
- package/containers/EstimateShipping.js +1 -1
- package/containers/EstimateShipping.js.map +1 -1
- package/containers/LoginForm.js +1 -1
- package/containers/LoginForm.js.map +1 -1
- package/containers/MergedCartBanner.js +1 -1
- package/containers/MergedCartBanner.js.map +1 -1
- package/containers/OutOfStock.js +1 -1
- package/containers/OutOfStock.js.map +1 -1
- package/containers/PaymentMethods/PaymentMethods.d.ts +8 -6
- package/containers/PaymentMethods/handlers.d.ts +11 -0
- package/containers/PaymentMethods.js +1 -1
- package/containers/PaymentMethods.js.map +1 -1
- package/containers/PaymentOnAccount/PaymentOnAccount.d.ts +10 -0
- package/containers/PaymentOnAccount/index.d.ts +11 -0
- package/containers/PaymentOnAccount.d.ts +3 -0
- package/containers/PaymentOnAccount.js +4 -0
- package/containers/PaymentOnAccount.js.map +1 -0
- package/containers/PlaceOrder/PlaceOrder.d.ts +2 -1
- package/containers/PlaceOrder.js +1 -1
- package/containers/PlaceOrder.js.map +1 -1
- package/containers/PurchaseOrder/PurchaseOrder.d.ts +10 -0
- package/containers/PurchaseOrder/index.d.ts +19 -0
- package/containers/PurchaseOrder.d.ts +3 -0
- package/containers/PurchaseOrder.js +4 -0
- package/containers/PurchaseOrder.js.map +1 -0
- package/containers/ServerError/ServerError.d.ts +2 -1
- package/containers/ServerError.js +1 -1
- package/containers/ServerError.js.map +1 -1
- package/containers/ShippingMethods/ShippingMethods.d.ts +2 -1
- package/containers/ShippingMethods.js +1 -1
- package/containers/ShippingMethods.js.map +1 -1
- package/containers/TermsAndConditions.js +1 -1
- package/containers/TermsAndConditions.js.map +1 -1
- package/containers/index.d.ts +2 -0
- package/data/models/company-credit.d.ts +7 -0
- package/data/models/index.d.ts +1 -0
- package/data/models/payment-method.d.ts +2 -0
- package/data/transforms/index.d.ts +1 -0
- package/data/transforms/transform-cart-address.d.ts +2 -0
- package/data/transforms/transform-company-credit.d.ts +7 -0
- package/data/transforms/transform-quote-address.d.ts +2 -0
- package/fragments.js +8 -7
- package/fragments.js.map +1 -1
- package/i18n/en_US.json.d.ts +20 -0
- package/lib/errors/classifiers.d.ts +3 -1
- package/lib/utils/api.d.ts +1 -1
- package/lib/utils.js +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +1 -1
- package/render.js +5 -5
- package/render.js.map +1 -1
- package/tests/fixtures/fragments/cart.d.ts +4 -0
- package/tests/fixtures/helpers/session-storage.d.ts +68 -0
- package/tests/fixtures/index.d.ts +1 -0
- package/tests/fixtures/queries/get-company-credit.d.ts +14 -0
- package/tests/fixtures/queries/index.d.ts +1 -0
- package/types/index.d.ts +2 -1
- package/types/storefront.d.ts +1 -1
- package/types/utils.d.ts +19 -0
package/chunks/render.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
(function(n,o){try{if(typeof document<"u"){const t=document.createElement("style"),r=o.styleId;for(const e in o.attributes)t.setAttribute(e,o.attributes[e]);t.setAttribute("data-dropin",r),t.appendChild(document.createTextNode(n));const a=document.querySelector('style[data-dropin="sdk"]');if(a)a.after(t);else{const e=document.querySelector('link[rel="stylesheet"], style');e?e.before(t):document.head.append(t)}}}catch(t){console.error("dropin-styles (injectCodeFunction)",t)}})(`.checkout__banner{margin-bottom:var(--spacing-xbig)}
|
|
4
|
+
.checkout-shipping-methods__title,.checkout-shipping-methods__title h3{color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-shipping-methods__content{position:relative;display:block}.checkout-shipping-methods__method{margin-bottom:var(--spacing-medium);width:fit-content;cursor:pointer;font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.checkout-shipping-methods__method:last-child{margin-bottom:0}.dropin-radio-button__label .dropin-price{color:var(--color-neutral-800);font-weight:400}.checkout-shipping-methods__options--busy{opacity:.4;pointer-events:none}.checkout-shipping-methods__spinner{margin:0 auto;position:absolute;z-index:999;left:0;right:0;top:calc(50% - (var(--size) / 2));bottom:0}.checkout-shipping-methods__options--toggleButton{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-medium)}.checkout-shipping-methods__options--toggleButton .dropin-toggle-button__content{justify-content:start;display:grid;grid-template-columns:1fr min-content}.checkout-shipping-methods__options--toggleButton .checkout-shipping-methods__method{margin-bottom:0;width:auto}.checkout-shipping-methods__error{margin-top:var(--spacing-medium)}
|
|
5
|
+
.checkout-place-order{display:grid;padding-bottom:var(--spacing-big)}.checkout-place-order__button{align-self:flex-end;justify-self:flex-end}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout-place-order{background-color:var(--color-neutral-200);padding:var(--spacing-medium) var(--spacing-medium) var(--spacing-big) var(--spacing-medium)}.checkout-place-order__button{align-self:center;justify-self:stretch}}
|
|
6
|
+
.checkout-payment-on-account{margin-bottom:var(--spacing-medium)}.checkout-payment-on-account__form{width:100%}.checkout-payment-on-account__credit{display:flex;justify-content:space-between;align-items:center;padding:var(--spacing-small);margin-bottom:var(--spacing-medium);background-color:var(--color-neutral-100);border:1px solid var(--color-neutral-300);border-radius:4px;font-size:14px;line-height:1.4}.checkout-payment-on-account__credit-label{font-weight:500;color:var(--color-neutral-700)}.checkout-payment-on-account__credit-amount{font-weight:600;color:var(--color-success-600)}.checkout-payment-on-account__exceed-message{margin-top:var(--spacing-medium);margin-bottom:var(--spacing-medium)}.checkout-payment-on-account .dropin-field{margin-bottom:0}
|
|
7
|
+
.checkout-bill-to-shipping-address label{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);gap:0}.checkout-bill-to-shipping-address__error{margin-top:var(--spacing-medium)}
|
|
8
|
+
.checkout-address-validation{display:grid;gap:var(--spacing-medium)}.checkout-address-validation__options--busy{opacity:.4;pointer-events:none}.checkout-address-validation__title{margin-bottom:var(--spacing-small)}.checkout-address-validation__subtitle{color:var(--color-neutral-700);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.checkout-address-validation__options{display:grid;gap:var(--spacing-xbig);grid-template-columns:1fr 1fr}.checkout-address-validation__option{margin:0}.checkout-address-validation__option-title{margin-bottom:var(--spacing-xsmall)}.checkout-estimate-shipping{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-xxsmall);align-items:center;color:var(--color-neutral-800)}.checkout-estimate-shipping__label,.checkout-estimate-shipping__price{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.checkout-estimate-shipping__label--muted{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);color:var(--color-neutral-700)}.checkout-estimate-shipping__price--muted{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.checkout-estimate-shipping__price{text-align:right}.checkout-estimate-shipping__label--bold,.checkout-estimate-shipping__price--bold{font:var(--type-body-1-emphasized-font);letter-spacing:var(--type-body-1-emphasized-letter-spacing)}.checkout-estimate-shipping__caption{font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing);color:var(--color-neutral-700)}.cart-order-summary__shipping .dropin-skeleton{grid-template-columns:1fr}.checkout-login-form__heading{display:grid;grid-template-columns:1fr max-content;grid-auto-rows:max-content;margin:0 0 var(--spacing-medium) 0;align-items:center}.checkout-login-form__heading:empty{display:none}.checkout-login-form__content{grid-auto-rows:max-content}.checkout-login-form__content .dropin-field__hint a{font-weight:400}.checkout-login-form__customer-details{display:grid;grid-auto-flow:row;gap:var(--spacing-xxsmall)}.checkout-login-form__customer-name{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.checkout-login-form__customer-email{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);color:var(--color-neutral-700)}.checkout-login-form__title,.checkout-login-form__title h2{grid-column-start:1;color:var(--color-neutral-800);font:var(--type-headline-2-default-font);letter-spacing:var(--type-headline-2-default-letter-spacing);margin:0}.checkout-login-form__heading-label,.checkout-login-form__sign-in,.checkout-login-form__sign-out{grid-column-start:2;color:var(--color-neutral-800);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);justify-self:flex-end}.checkout-login-form__heading-label a,a.checkout-login-form__link{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin-left:var(--spacing-xxsmall)}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout-login-form__heading{grid-template-columns:1fr;grid-template-rows:1fr}.checkout-login-form__heading-label{grid-column-start:1;align-self:flex-start;justify-self:flex-start;margin-top:var(--spacing-medium)}}.checkout-out-of-stock.dropin-card{border-color:var(--color-warning-500)}.checkout-out-of-stock .dropin-card__content{gap:var(--spacing-small);padding:var(--spacing-small)}.checkout-out-of-stock__title{color:var(--color-neutral-900);font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin:0;display:flex;gap:var(--spacing-xxsmall);align-items:center;justify-content:left;text-align:center}.checkout-out-of-stock__message{color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);margin:0}.checkout-out-of-stock__items{display:grid;grid-template-columns:repeat(5,100px);grid-gap:var(--spacing-small);list-style:none;padding:0;margin:0}.checkout-out-of-stock__item img{width:100%;height:auto}.checkout-out-of-stock__actions{display:flex;gap:var(--spacing-small);justify-content:flex-end}a.checkout-out-of-stock__action{color:var(--color-brand-500);font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing)}.checkout-out-of-stock__action{color:var(--color-brand-500);font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);background:none;border:none;padding:0;cursor:pointer}.checkout-out-of-stock__action:hover{--textColor: var(--color-brand-700);text-decoration:solid underline var(--textColor);text-underline-offset:6px}@media only screen and (width >= 320px) and (width <= 768px){.checkout-out-of-stock__items{grid-template-columns:repeat(3,100px)}}.checkout-payment-methods__title,.checkout-payment-methods__title h2{color:var(--color-neutral-800);font:var(--type-headline-2-default-font);letter-spacing:var(--type-headline-2-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-payment-methods__wrapper{position:relative;display:grid}.checkout-payment-methods__wrapper--busy{opacity:.4;pointer-events:none}.checkout-payment-methods__methods{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-medium)}.checkout-payment-methods__content{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin-top:var(--spacing-xbig)}.checkout-payment-methods__content>div[data-slot=PaymentMethodSlot]:not(:empty){margin-top:var(--spacing-medium)}.checkout-payment-methods--full-width{grid-template-columns:1fr}.checkout-payment-methods__spinner{margin:0 auto;position:absolute;z-index:999;left:0;right:0;top:calc(50% - (var(--size) / 2));bottom:0}.checkout__content [data-slot=PaymentMethods]:empty{display:none}.checkout-payment-methods__error{margin-top:var(--spacing-medium)}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout-payment-methods__methods{grid-template-columns:1fr}}.checkout-purchase-order{margin-bottom:var(--spacing-medium)}.checkout-purchase-order__form{width:100%}.checkout-purchase-order .dropin-field{margin-bottom:0}.checkout-server-error{position:relative;text-align:center}.checkout-server-error__icon .error-icon{color:var(--color-alert-500)}.checkout-server-error a{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing)}.checkout-terms-and-conditions{display:grid}.checkout-terms-and-conditions__error{font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing);color:var(--color-alert-800);text-align:left;margin-top:var(--spacing-xsmall)}.checkout-terms-and-conditions__error:empty{display:none}`,{styleId:"checkout"});
|
|
9
|
+
import{jsx as d}from"@dropins/tools/preact-jsx-runtime.js";import{Render as f}from"@dropins/tools/lib.js";import"./fetch-graphql.js";import{events as y}from"@dropins/tools/event-bus.js";import{c as g}from"./synchronizeCheckout.js";import{UIProvider as b}from"@dropins/tools/components.js";import{useState as h,useEffect as p}from"@dropins/tools/preact-hooks.js";function w(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var O=function(r){return E(r)&&!S(r)};function E(e){return!!e&&typeof e=="object"}function S(e){var r=Object.prototype.toString.call(e);return r==="[object RegExp]"||r==="[object Date]"||A(e)}var v=typeof Symbol=="function"&&Symbol.for,P=v?Symbol.for("react.element"):60103;function A(e){return e.$$typeof===P}function j(e){return Array.isArray(e)?[]:{}}function o(e,r){return r.clone!==!1&&r.isMergeableObject(e)?i(j(e),e,r):e}function M(e,r,t){return e.concat(r).map(function(a){return o(a,t)})}function x(e,r){if(!r.customMerge)return i;var t=r.customMerge(e);return typeof t=="function"?t:i}function T(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(r){return Object.propertyIsEnumerable.call(e,r)}):[]}function l(e){return Object.keys(e).concat(T(e))}function m(e,r){try{return r in e}catch{return!1}}function I(e,r){return m(e,r)&&!(Object.hasOwnProperty.call(e,r)&&Object.propertyIsEnumerable.call(e,r))}function C(e,r,t){var a={};return t.isMergeableObject(e)&&l(e).forEach(function(n){a[n]=o(e[n],t)}),l(r).forEach(function(n){I(e,n)||(m(e,n)&&t.isMergeableObject(r[n])?a[n]=x(n,t)(e[n],r[n],t):a[n]=o(r[n],t))}),a}function i(e,r,t){t=t||{},t.arrayMerge=t.arrayMerge||M,t.isMergeableObject=t.isMergeableObject||O,t.cloneUnlessOtherwiseSpecified=o;var a=Array.isArray(r),n=Array.isArray(e),s=a===n;return s?a?t.arrayMerge(e,r,t):C(e,r,t):o(r,t)}i.all=function(r,t){if(!Array.isArray(r))throw new Error("first argument should be an array");return r.reduce(function(a,n){return i(a,n,t)},{})};var L=i,N=L;const D=w(N),W={AddressValidation:{title:"Verify your address",subtitle:"To ensure accurate delivery, we suggest the changes highlighted below. Please choose which address you would like to use. If neither option is correct, edit your address.",suggestedAddress:"Suggested Address",originalAddress:"Original Address"},BillToShippingAddress:{cartSyncError:"We were unable to save your changes. Please try again later.",title:"Bill to shipping address"},EmptyCart:{button:"Start shopping",title:"Your cart is empty"},EstimateShipping:{estimated:"Estimated Shipping",freeShipping:"Free",label:"Shipping",taxToBeDetermined:"TBD",withoutTaxes:"Excluding taxes",withTaxes:"Including taxes"},LoginForm:{account:"Already have an account?",ariaLabel:"Email",emailExists:{alreadyHaveAccount:"It looks like you already have an account.",forFasterCheckout:"for a faster checkout.",signInButton:"Sign in"},floatingLabel:"Email *",invalidEmailError:"Please enter a valid email address.",missingEmailError:"Enter an email address.",cartSyncError:"We were unable to save your changes. Please try again later.",placeholder:"Enter your email address",signIn:"Sign In",signOut:"Sign Out",switch:"Do you want to switch account?",title:"Contact details"},MergedCartBanner:{items:{many:"{{count}} items from a previous session were added to your cart. Please review your new subtotal.",one:"1 item from a previous session was added to your cart. Please review your new subtotal."}},OutOfStock:{actions:{removeOutOfStock:"Remove out of stock items",reviewCart:"Review cart"},alert:"Out of stock!",lowInventory:{many:"Only {{count}} left!",one:"Last item!"},message:"The following items are out of stock:",title:"Your cart contains items that are out of stock"},PaymentMethods:{cartSyncError:"We were unable to save your changes. Please try again later.",emptyState:"No payment methods available",title:"Payment"},PaymentOnAccount:{referenceNumberLabel:"Custom Reference Number",referenceNumberPlaceholder:"Enter custom reference number",referenceNumberHint:"",availableCreditLabel:"Available Credit",exceedLimitWarning:"The credit limit is {{creditLimit}}. It will be exceeded by {{exceededAmount}} with this order.",exceedLimitWarningPrefix:"The credit limit is",exceedLimitWarningMiddle:". It will be exceeded by",exceedLimitWarningSuffix:"with this order.",exceedLimitError:"Payment On Account cannot be used for this order because your order amount exceeds your credit amount."},PurchaseOrder:{referenceNumberLabel:"Custom Reference Number",referenceNumberPlaceholder:"Enter custom reference number",referenceNumberHint:""},PlaceOrder:{button:"Place Order"},ServerError:{button:"Try again",contactSupport:"If you continue to have issues, please contact support.",title:"We were unable to process your order",unexpected:"An unexpected error occurred while processing your order. Please try again later."},Quote:{permissionDenied:"You do not have permission to checkout with this quote.",dataError:"We were unable to retrieve the quote data. Please try again later."},ShippingMethods:{cartSyncError:"We were unable to save your changes. Please try again later.",emptyState:"This order can't be shipped to the address provided. Please review the address details you entered and make sure they're correct.",title:"Shipping options"},Summary:{Edit:"Edit"},TermsAndConditions:{error:"Please accept the Terms and Conditions to continue.",label:"I have read, understand, and accept our <a href='https://www.adobe.com/legal/terms.html' target='_blank'>Terms of Use, Terms of Sales, Privacy Policy, and Return Policy</a>."},title:"Checkout"},R={Checkout:W},_={default:R},k=({children:e})=>{var s;const[r,t]=h(),a=(s=g.getConfig())==null?void 0:s.langDefinitions;p(()=>{const c=y.on("locale",u=>{u!==r&&t(u)},{eager:!0});return()=>{c==null||c.off()}},[r]);const n=D(_,a??{});return d(b,{lang:r,langDefinitions:n,children:e})},q=new f(d(k,{}));export{k as P,q as r};
|
|
10
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sources":["../../node_modules/deepmerge/dist/cjs.js","/@dropins/storefront-checkout/src/render/Provider.tsx","/@dropins/storefront-checkout/src/render/render.tsx"],"sourcesContent":["'use strict';\n\nvar isMergeableObject = function isMergeableObject(value) {\n\treturn isNonNullObject(value)\n\t\t&& !isSpecial(value)\n};\n\nfunction isNonNullObject(value) {\n\treturn !!value && typeof value === 'object'\n}\n\nfunction isSpecial(value) {\n\tvar stringValue = Object.prototype.toString.call(value);\n\n\treturn stringValue === '[object RegExp]'\n\t\t|| stringValue === '[object Date]'\n\t\t|| isReactElement(value)\n}\n\n// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25\nvar canUseSymbol = typeof Symbol === 'function' && Symbol.for;\nvar REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;\n\nfunction isReactElement(value) {\n\treturn value.$$typeof === REACT_ELEMENT_TYPE\n}\n\nfunction emptyTarget(val) {\n\treturn Array.isArray(val) ? [] : {}\n}\n\nfunction cloneUnlessOtherwiseSpecified(value, options) {\n\treturn (options.clone !== false && options.isMergeableObject(value))\n\t\t? deepmerge(emptyTarget(value), value, options)\n\t\t: value\n}\n\nfunction defaultArrayMerge(target, source, options) {\n\treturn target.concat(source).map(function(element) {\n\t\treturn cloneUnlessOtherwiseSpecified(element, options)\n\t})\n}\n\nfunction getMergeFunction(key, options) {\n\tif (!options.customMerge) {\n\t\treturn deepmerge\n\t}\n\tvar customMerge = options.customMerge(key);\n\treturn typeof customMerge === 'function' ? customMerge : deepmerge\n}\n\nfunction getEnumerableOwnPropertySymbols(target) {\n\treturn Object.getOwnPropertySymbols\n\t\t? Object.getOwnPropertySymbols(target).filter(function(symbol) {\n\t\t\treturn Object.propertyIsEnumerable.call(target, symbol)\n\t\t})\n\t\t: []\n}\n\nfunction getKeys(target) {\n\treturn Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))\n}\n\nfunction propertyIsOnObject(object, property) {\n\ttry {\n\t\treturn property in object\n\t} catch(_) {\n\t\treturn false\n\t}\n}\n\n// Protects from prototype poisoning and unexpected merging up the prototype chain.\nfunction propertyIsUnsafe(target, key) {\n\treturn propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,\n\t\t&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,\n\t\t\t&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.\n}\n\nfunction mergeObject(target, source, options) {\n\tvar destination = {};\n\tif (options.isMergeableObject(target)) {\n\t\tgetKeys(target).forEach(function(key) {\n\t\t\tdestination[key] = cloneUnlessOtherwiseSpecified(target[key], options);\n\t\t});\n\t}\n\tgetKeys(source).forEach(function(key) {\n\t\tif (propertyIsUnsafe(target, key)) {\n\t\t\treturn\n\t\t}\n\n\t\tif (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {\n\t\t\tdestination[key] = getMergeFunction(key, options)(target[key], source[key], options);\n\t\t} else {\n\t\t\tdestination[key] = cloneUnlessOtherwiseSpecified(source[key], options);\n\t\t}\n\t});\n\treturn destination\n}\n\nfunction deepmerge(target, source, options) {\n\toptions = options || {};\n\toptions.arrayMerge = options.arrayMerge || defaultArrayMerge;\n\toptions.isMergeableObject = options.isMergeableObject || isMergeableObject;\n\t// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()\n\t// implementations can use it. The caller may not replace it.\n\toptions.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;\n\n\tvar sourceIsArray = Array.isArray(source);\n\tvar targetIsArray = Array.isArray(target);\n\tvar sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;\n\n\tif (!sourceAndTargetTypesMatch) {\n\t\treturn cloneUnlessOtherwiseSpecified(source, options)\n\t} else if (sourceIsArray) {\n\t\treturn options.arrayMerge(target, source, options)\n\t} else {\n\t\treturn mergeObject(target, source, options)\n\t}\n}\n\ndeepmerge.all = function deepmergeAll(array, options) {\n\tif (!Array.isArray(array)) {\n\t\tthrow new Error('first argument should be an array')\n\t}\n\n\treturn array.reduce(function(prev, next) {\n\t\treturn deepmerge(prev, next, options)\n\t}, {})\n};\n\nvar deepmerge_1 = deepmerge;\n\nmodule.exports = deepmerge_1;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { config } from '@/checkout/api';\nimport { UIProvider } from '@adobe-commerce/elsie/components';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { deepmerge } from '@adobe-commerce/elsie/lib/deepmerge';\nimport { events } from '@adobe-commerce/event-bus';\nimport { FunctionComponent } from 'preact';\nimport { useEffect, useState } from 'preact/hooks';\n\nimport en_US from '../i18n/en_US.json';\n\n// Langs\nconst langDefinitions = {\n default: en_US,\n};\n\ninterface IntlProviderProps {\n children?: any;\n}\n\nexport const Provider: FunctionComponent<IntlProviderProps> = ({\n children,\n}) => {\n const [locale, setLang] = useState<Lang>();\n\n const userLangDefinitions = config.getConfig()?.langDefinitions;\n\n useEffect(() => {\n const localeEvent = events.on(\n 'locale',\n (payload) => {\n if (payload !== locale) setLang(payload as Lang);\n },\n { eager: true }\n );\n return () => {\n localeEvent?.off();\n };\n }, [locale]);\n\n // Merge language definitions with user language definitions\n const definitions = deepmerge(langDefinitions, userLangDefinitions ?? {});\n\n return (\n <UIProvider lang={locale} langDefinitions={definitions}>\n {children}\n </UIProvider>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Render } from '@adobe-commerce/elsie/lib';\nimport { Provider } from './Provider';\nexport { Provider };\nexport const render = new Render(<Provider />);\n"],"names":["isMergeableObject","value","isNonNullObject","isSpecial","stringValue","isReactElement","canUseSymbol","REACT_ELEMENT_TYPE","emptyTarget","val","cloneUnlessOtherwiseSpecified","options","deepmerge","defaultArrayMerge","target","source","element","getMergeFunction","key","customMerge","getEnumerableOwnPropertySymbols","symbol","getKeys","propertyIsOnObject","object","property","propertyIsUnsafe","mergeObject","destination","sourceIsArray","targetIsArray","sourceAndTargetTypesMatch","array","prev","next","deepmerge_1","cjs","langDefinitions","en_US","Provider","children","locale","setLang","useState","userLangDefinitions","_a","config","useEffect","localeEvent","events","payload","definitions","UIProvider","render","Render","jsx"],"mappings":"8cAEA,IAAIA,EAAoB,SAA2BC,EAAO,CACzD,OAAOC,EAAgBD,CAAK,GACxB,CAACE,EAAUF,CAAK,CACrB,EAEA,SAASC,EAAgBD,EAAO,CAC/B,MAAO,CAAC,CAACA,GAAS,OAAOA,GAAU,QACpC,CAEA,SAASE,EAAUF,EAAO,CACzB,IAAIG,EAAc,OAAO,UAAU,SAAS,KAAKH,CAAK,EAEtD,OAAOG,IAAgB,mBACnBA,IAAgB,iBAChBC,EAAeJ,CAAK,CACzB,CAGA,IAAIK,EAAe,OAAO,QAAW,YAAc,OAAO,IACtDC,EAAqBD,EAAe,OAAO,IAAI,eAAe,EAAI,MAEtE,SAASD,EAAeJ,EAAO,CAC9B,OAAOA,EAAM,WAAaM,CAC3B,CAEA,SAASC,EAAYC,EAAK,CACzB,OAAO,MAAM,QAAQA,CAAG,EAAI,CAAA,EAAK,CAAA,CAClC,CAEA,SAASC,EAA8BT,EAAOU,EAAS,CACtD,OAAQA,EAAQ,QAAU,IAASA,EAAQ,kBAAkBV,CAAK,EAC/DW,EAAUJ,EAAYP,CAAK,EAAGA,EAAOU,CAAO,EAC5CV,CACJ,CAEA,SAASY,EAAkBC,EAAQC,EAAQJ,EAAS,CACnD,OAAOG,EAAO,OAAOC,CAAM,EAAE,IAAI,SAASC,EAAS,CAClD,OAAON,EAA8BM,EAASL,CAAO,CACrD,CAAA,CACF,CAEA,SAASM,EAAiBC,EAAKP,EAAS,CACvC,GAAI,CAACA,EAAQ,YACZ,OAAOC,EAER,IAAIO,EAAcR,EAAQ,YAAYO,CAAG,EACzC,OAAO,OAAOC,GAAgB,WAAaA,EAAcP,CAC1D,CAEA,SAASQ,EAAgCN,EAAQ,CAChD,OAAO,OAAO,sBACX,OAAO,sBAAsBA,CAAM,EAAE,OAAO,SAASO,EAAQ,CAC9D,OAAO,OAAO,qBAAqB,KAAKP,EAA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F,IAAkBC,EAElD,OAAKC,EAEMF,EACHlB,EAAQ,WAAWG,EAAQC,EAAQJ,CAAO,EAE1CgB,EAAYb,EAAQC,EAAQJ,CAAO,EAJnCD,EAA8BK,EAAQJ,CAAO,CAMtD,CAEAC,EAAU,IAAM,SAAsBoB,EAAOrB,EAAS,CACrD,GAAI,CAAC,MAAM,QAAQqB,CAAK,EACvB,MAAM,IAAI,MAAM,mCAAmC,EAGpD,OAAOA,EAAM,OAAO,SAASC,EAAMC,EAAM,CACxC,OAAOtB,EAAUqB,EAAMC,EAAMvB,CAAO,CACtC,EAAI,CAAE,CAAA,CACN,EAEA,IAAIwB,EAAcvB,EAElBwB,EAAiBD,8iHCxGXE,EAAkB,CACtB,QAASC,CACX,EAMaC,EAAiD,CAAC,CAC7D,SAAAC,CACF,IAAM,OACJ,KAAM,CAACC,EAAQC,CAAO,EAAIC,EAAe,EAEnCC,GAAsBC,EAAAC,EAAO,UAAA,IAAP,YAAAD,EAAoB,gBAEhDE,EAAU,IAAM,CACd,MAAMC,EAAcC,EAAO,GACzB,SACCC,GAAY,CACPA,IAAYT,GAAQC,EAAQQ,CAAe,CACjD,EACA,CAAE,MAAO,EAAK,CAChB,EACA,MAAO,IAAM,CACXF,GAAA,MAAAA,EAAa,KACf,CAAA,EACC,CAACP,CAAM,CAAC,EAGX,MAAMU,EAAcvC,EAAUyB,EAAiBO,GAAuB,CAAA,CAAE,EAExE,SACGQ,EAAW,CAAA,KAAMX,EAAQ,gBAAiBU,EACxC,SAAAX,EACH,CAEJ,EC5Caa,EAAS,IAAIC,EAAOC,EAAChB,IAAS,CAAE","x_google_ignoreList":[0]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{CHECKOUT_DATA_FRAGMENT as A,NEGOTIABLE_QUOTE_FRAGMENT as I}from"../fragments.js";import{e as g,
|
|
3
|
+
import{CHECKOUT_DATA_FRAGMENT as A,NEGOTIABLE_QUOTE_FRAGMENT as I}from"../fragments.js";import{e as g,c as p,d as c}from"./guards.js";import{t as B,e as m}from"./synchronizeCheckout.js";import{s as r,d as f,Q as C,I as o,l as a}from"./fetch-graphql.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";const Q=`
|
|
4
4
|
mutation setBillingAddress(
|
|
5
5
|
$cartId: String!
|
|
6
6
|
$billingAddress: BillingAddressInput!
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{CUSTOMER_FRAGMENT as o,CHECKOUT_DATA_FRAGMENT as n}from"../fragments.js";import{s as m,d as r,l,
|
|
3
|
+
import{CUSTOMER_FRAGMENT as o,CHECKOUT_DATA_FRAGMENT as n}from"../fragments.js";import{s as m,d as r,q as l,n as u,Q as c}from"./fetch-graphql.js";import{merge as E}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import{c as f,t as p}from"./synchronizeCheckout.js";const C=t=>{var i,a,s;if(!t)return null;const e={firstName:t.firstname||"",lastName:t.lastname||"",email:t.email||""};return E(e,(s=(a=(i=f.getConfig().models)==null?void 0:i.CustomerModel)==null?void 0:a.transformer)==null?void 0:s.call(a,t))},y=t=>!!(t!=null&&t.is_email_available),A=`
|
|
4
4
|
query getCustomer {
|
|
5
5
|
customer {
|
|
6
6
|
...CUSTOMER_FRAGMENT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setGuestEmailOnCart.js","sources":["/@dropins/storefront-checkout/src/data/transforms/transform-customer.ts","/@dropins/storefront-checkout/src/data/transforms/transform-email-availability.ts","/@dropins/storefront-checkout/src/api/getCustomer/graphql/getCustomer.graphql.ts","/@dropins/storefront-checkout/src/api/getCustomer/getCustomer.ts","/@dropins/storefront-checkout/src/api/isEmailAvailable/graphql/isEmailAvailable.graphql.ts","/@dropins/storefront-checkout/src/api/isEmailAvailable/isEmailAvailable.ts","/@dropins/storefront-checkout/src/api/setGuestEmailOnCart/graphql/setGuestEmailOnCart.graphql.ts","/@dropins/storefront-checkout/src/api/setGuestEmailOnCart/setGuestEmailOnCart.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { config } from '@/checkout/api';\nimport { Customer as CustomerModel } from '@/checkout/data/models';\nimport { GetCustomerQuery } from '@/checkout/__generated__/types';\nimport { merge } from '@adobe-commerce/elsie/lib';\n\ntype Customer = GetCustomerQuery['customer'];\n\nconst transformCustomer = (data: Customer): CustomerModel | null => {\n if (!data) return null;\n\n const model = {\n firstName: data.firstname || '',\n lastName: data.lastname || '',\n email: data.email || '',\n };\n\n // Extend the model merging custom transformer, if provided\n return merge(\n model, // default transformer\n config.getConfig().models?.CustomerModel?.transformer?.(data) // custom transformer\n );\n};\n\nexport { Customer, transformCustomer };\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { IsEmailAvailableQuery } from '@/checkout/__generated__/types';\nimport { EmailAvailability } from '@/checkout/data/models';\n\nconst transformEmailAvailability = (\n data: IsEmailAvailableQuery['isEmailAvailable']\n): EmailAvailability => {\n return Boolean(data?.is_email_available);\n};\n\nexport { transformEmailAvailability };\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CUSTOMER_FRAGMENT } from '@/checkout/api/graphql/CustomerFragment.graphql';\n\nexport const getCustomerQuery = /* GraphQL */ `\n query getCustomer {\n customer {\n ...CUSTOMER_FRAGMENT\n }\n }\n\n ${CUSTOMER_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { getCustomerQuery } from '@/checkout/api/getCustomer/graphql/getCustomer.graphql';\nimport { Customer } from '@/checkout/data/models';\nimport { transformCustomer } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { state } from '@/checkout/lib/state';\n\nexport const getCustomer = async (): Promise<Customer | null> => {\n if (!state.authenticated) return null;\n\n return await dispatchApiCall({\n options: { method: 'GET', cache: 'no-cache' },\n path: 'customer',\n query: getCustomerQuery,\n transformer: transformCustomer,\n type: 'query',\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const isEmailAvailableQuery = /* GraphQL */ `\n query isEmailAvailable($email: String!) {\n isEmailAvailable(email: $email) {\n is_email_available\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { isEmailAvailableQuery } from '@/checkout/api/isEmailAvailable/graphql/isEmailAvailable.graphql';\nimport { EmailAvailability } from '@/checkout/data/models/email-availability';\nimport { transformEmailAvailability } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { MissingEmail } from '@/checkout/lib/errors';\n\nexport const isEmailAvailable = async (\n email: string\n): Promise<EmailAvailability> => {\n if (!email) throw new MissingEmail();\n\n return await dispatchApiCall({\n options: { method: 'GET', cache: 'no-cache', variables: { email } },\n path: 'isEmailAvailable',\n query: isEmailAvailableQuery,\n transformer: transformEmailAvailability,\n type: 'query',\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setGuestEmailMutation = /* GraphQL */ `\n mutation setGuestEmail($cartId: String!, $email: String!) {\n setGuestEmailOnCart(input: { cart_id: $cartId, email: $email }) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { setGuestEmailMutation } from '@/checkout/api/setGuestEmailOnCart/graphql/setGuestEmailOnCart.graphql';\nimport { transformCart } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { QueueName } from '@/checkout/lib/enqueueRequest';\nimport { MissingCart } from '@/checkout/lib/errors';\nimport { state } from '@/checkout/lib/state';\n\nexport const setGuestEmailOnCart = async (email: string) => {\n const cartId = state.cartId;\n\n if (!cartId) throw new MissingCart();\n\n return await dispatchApiCall({\n options: { variables: { cartId, email } },\n path: 'setGuestEmailOnCart.cart',\n query: setGuestEmailMutation,\n queueName: QueueName.Updates,\n transformer: transformCart,\n type: 'mutation',\n });\n};\n"],"names":["transformCustomer","data","model","merge","_c","_b","_a","config","transformEmailAvailability","getCustomerQuery","CUSTOMER_FRAGMENT","getCustomer","state","dispatchApiCall","isEmailAvailableQuery","isEmailAvailable","email","MissingEmail","setGuestEmailMutation","CHECKOUT_DATA_FRAGMENT","setGuestEmailOnCart","cartId","MissingCart","QueueName","transformCart"],"mappings":"oRAwBA,MAAMA,EAAqBC,GAAyC,WAC9D,GAAA,CAACA,EAAa,OAAA,KAElB,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/@dropins/storefront-checkout/src/data/transforms/transform-customer.ts","/@dropins/storefront-checkout/src/data/transforms/transform-email-availability.ts","/@dropins/storefront-checkout/src/api/getCustomer/graphql/getCustomer.graphql.ts","/@dropins/storefront-checkout/src/api/getCustomer/getCustomer.ts","/@dropins/storefront-checkout/src/api/isEmailAvailable/graphql/isEmailAvailable.graphql.ts","/@dropins/storefront-checkout/src/api/isEmailAvailable/isEmailAvailable.ts","/@dropins/storefront-checkout/src/api/setGuestEmailOnCart/graphql/setGuestEmailOnCart.graphql.ts","/@dropins/storefront-checkout/src/api/setGuestEmailOnCart/setGuestEmailOnCart.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { config } from '@/checkout/api';\nimport { Customer as CustomerModel } from '@/checkout/data/models';\nimport { GetCustomerQuery } from '@/checkout/__generated__/types';\nimport { merge } from '@adobe-commerce/elsie/lib';\n\ntype Customer = GetCustomerQuery['customer'];\n\nconst transformCustomer = (data: Customer): CustomerModel | null => {\n if (!data) return null;\n\n const model = {\n firstName: data.firstname || '',\n lastName: data.lastname || '',\n email: data.email || '',\n };\n\n // Extend the model merging custom transformer, if provided\n return merge(\n model, // default transformer\n config.getConfig().models?.CustomerModel?.transformer?.(data) // custom transformer\n );\n};\n\nexport { Customer, transformCustomer };\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { IsEmailAvailableQuery } from '@/checkout/__generated__/types';\nimport { EmailAvailability } from '@/checkout/data/models';\n\nconst transformEmailAvailability = (\n data: IsEmailAvailableQuery['isEmailAvailable']\n): EmailAvailability => {\n return Boolean(data?.is_email_available);\n};\n\nexport { transformEmailAvailability };\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CUSTOMER_FRAGMENT } from '@/checkout/api/graphql/CustomerFragment.graphql';\n\nexport const getCustomerQuery = /* GraphQL */ `\n query getCustomer {\n customer {\n ...CUSTOMER_FRAGMENT\n }\n }\n\n ${CUSTOMER_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { getCustomerQuery } from '@/checkout/api/getCustomer/graphql/getCustomer.graphql';\nimport { Customer } from '@/checkout/data/models';\nimport { transformCustomer } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { state } from '@/checkout/lib/state';\n\nexport const getCustomer = async (): Promise<Customer | null> => {\n if (!state.authenticated) return null;\n\n return await dispatchApiCall({\n options: { method: 'GET', cache: 'no-cache' },\n path: 'customer',\n query: getCustomerQuery,\n transformer: transformCustomer,\n type: 'query',\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const isEmailAvailableQuery = /* GraphQL */ `\n query isEmailAvailable($email: String!) {\n isEmailAvailable(email: $email) {\n is_email_available\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { isEmailAvailableQuery } from '@/checkout/api/isEmailAvailable/graphql/isEmailAvailable.graphql';\nimport { EmailAvailability } from '@/checkout/data/models/email-availability';\nimport { transformEmailAvailability } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { MissingEmail } from '@/checkout/lib/errors';\n\nexport const isEmailAvailable = async (\n email: string\n): Promise<EmailAvailability> => {\n if (!email) throw new MissingEmail();\n\n return await dispatchApiCall({\n options: { method: 'GET', cache: 'no-cache', variables: { email } },\n path: 'isEmailAvailable',\n query: isEmailAvailableQuery,\n transformer: transformEmailAvailability,\n type: 'query',\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setGuestEmailMutation = /* GraphQL */ `\n mutation setGuestEmail($cartId: String!, $email: String!) {\n setGuestEmailOnCart(input: { cart_id: $cartId, email: $email }) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { setGuestEmailMutation } from '@/checkout/api/setGuestEmailOnCart/graphql/setGuestEmailOnCart.graphql';\nimport { transformCart } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { QueueName } from '@/checkout/lib/enqueueRequest';\nimport { MissingCart } from '@/checkout/lib/errors';\nimport { state } from '@/checkout/lib/state';\n\nexport const setGuestEmailOnCart = async (email: string) => {\n const cartId = state.cartId;\n\n if (!cartId) throw new MissingCart();\n\n return await dispatchApiCall({\n options: { variables: { cartId, email } },\n path: 'setGuestEmailOnCart.cart',\n query: setGuestEmailMutation,\n queueName: QueueName.Updates,\n transformer: transformCart,\n type: 'mutation',\n });\n};\n"],"names":["transformCustomer","data","model","merge","_c","_b","_a","config","transformEmailAvailability","getCustomerQuery","CUSTOMER_FRAGMENT","getCustomer","state","dispatchApiCall","isEmailAvailableQuery","isEmailAvailable","email","MissingEmail","setGuestEmailMutation","CHECKOUT_DATA_FRAGMENT","setGuestEmailOnCart","cartId","MissingCart","QueueName","transformCart"],"mappings":"yRAwBA,MAAMA,EAAqBC,GAAyC,WAC9D,GAAA,CAACA,EAAa,OAAA,KAElB,MAAMC,EAAQ,CACZ,UAAWD,EAAK,WAAa,GAC7B,SAAUA,EAAK,UAAY,GAC3B,MAAOA,EAAK,OAAS,EACvB,EAGO,OAAAE,EACLD,GACAE,GAAAC,GAAAC,EAAAC,EAAO,UAAU,EAAE,SAAnB,YAAAD,EAA2B,gBAA3B,YAAAD,EAA0C,cAA1C,YAAAD,EAAA,KAAAC,EAAwDJ,EAC1D,CACF,EClBMO,EACJP,GAEO,GAAQA,GAAA,MAAAA,EAAM,oBCJVQ,EAAiC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAO1CC,CAAiB;AAAA,ECHRC,EAAc,SACpBC,EAAM,cAEJ,MAAMC,EAAgB,CAC3B,QAAS,CAAE,OAAQ,MAAO,MAAO,UAAW,EAC5C,KAAM,WACN,MAAOJ,EACP,YAAaT,EACb,KAAM,OAAA,CACP,EARgC,KCPtBc,EAAsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECMtCC,EAAmB,MAC9BC,GAC+B,CAC/B,GAAI,CAACA,EAAa,MAAA,IAAIC,EAEtB,OAAO,MAAMJ,EAAgB,CAC3B,QAAS,CAAE,OAAQ,MAAO,MAAO,WAAY,UAAW,CAAE,MAAAG,EAAQ,EAClE,KAAM,mBACN,MAAOF,EACP,YAAaN,EACb,KAAM,OAAA,CACP,CACH,EChBaU,EAAsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAS/CC,CAAsB;AAAA,ECJbC,EAAsB,MAAOJ,GAAkB,CAC1D,MAAMK,EAAST,EAAM,OAErB,GAAI,CAACS,EAAc,MAAA,IAAIC,EAEvB,OAAO,MAAMT,EAAgB,CAC3B,QAAS,CAAE,UAAW,CAAE,OAAAQ,EAAQ,MAAAL,EAAQ,EACxC,KAAM,2BACN,MAAOE,EACP,UAAWK,EAAU,QACrB,YAAaC,EACb,KAAM,UAAA,CACP,CACH"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{s as o,
|
|
3
|
+
import{s as o,n as G,o as D,d as q,Q as E,I as l,p as Q}from"./fetch-graphql.js";import"@dropins/tools/lib.js";import{t as F,a as O}from"./transform-shipping-estimate.js";import{a as R}from"./transform-shipping-methods.js";import{events as $}from"@dropins/tools/event-bus.js";import{g as N}from"./values.js";import{c as w,t as x,e as H}from"./synchronizeCheckout.js";import{e as V,f as K,g as L}from"./guards.js";import{CHECKOUT_DATA_FRAGMENT as y,NEGOTIABLE_QUOTE_FRAGMENT as B}from"../fragments.js";const k=`
|
|
4
4
|
mutation estimateShippingMethods(
|
|
5
5
|
$cartId: String!
|
|
6
6
|
$address: EstimateAddressInput!
|
|
@@ -26,7 +26,7 @@ import{s as o,m as B,n as b,d as M,Q as $,I as c,o as O}from"./fetch-graphql.js"
|
|
|
26
26
|
error_message
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
`,
|
|
29
|
+
`,ae=async e=>{var _,m,I,S;const s=o.cartId,t=((_=e==null?void 0:e.criteria)==null?void 0:_.country_code)??((m=o.config)==null?void 0:m.defaultCountry);if(!s)throw new G;if(!t)throw new D;const{region_id:i,region_name:a,zip:p}=(e==null?void 0:e.criteria)??{},n=i||a?{region_id:typeof i=="string"?parseInt(i,10):i,region_code:a}:void 0,h={country_code:t,...p&&{postcode:p},...n&&{region:{...n.region_id&&{region_id:n.region_id},...n.region_code&&{region_code:n.region_code}}}},A={country_id:t,region:(I=h.region)==null?void 0:I.region_code,region_id:(S=h.region)==null?void 0:S.region_id,postcode:p},b=O(A);return q({options:{variables:{cartId:s,address:h}},path:"estimateShippingMethods",query:k,queueName:E.ShippingEstimate,transformer:R,type:"mutation"}).then(r=>{const{defaults:c,shipping:u}=w.getConfig(),f=u!=null&&u.filterOptions?r.filter(u.filterOptions):r,v=f.length>0,U=O(A);let M=null;if(v){const d=N("selectedShippingMethod");let g=r.find(C=>C.code===(d==null?void 0:d.code)&&C.carrier.code===(d==null?void 0:d.carrier.code));!g&&(c!=null&&c.selectedShippingMethod)&&(g=c.selectedShippingMethod(r)??void 0),g||(g=r[0]),M=F(g)}return $.emit("shipping/estimate",{address:U,availableShippingMethods:r,shippingMethod:M,success:!0}),f}).catch(r=>{throw $.emit("shipping/estimate",{address:b,shippingMethod:null,availableShippingMethods:[],success:!1}),r})},z=`
|
|
30
30
|
mutation setShippingAddressOnCartAndUseAsBilling(
|
|
31
31
|
$cartId: String!
|
|
32
32
|
$shippingAddress: ShippingAddressInput!
|
|
@@ -48,8 +48,8 @@ import{s as o,m as B,n as b,d as M,Q as $,I as c,o as O}from"./fetch-graphql.js"
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
${
|
|
52
|
-
`,
|
|
51
|
+
${y}
|
|
52
|
+
`,P=`
|
|
53
53
|
mutation setShippingAddressOnCart(
|
|
54
54
|
$cartId: String!
|
|
55
55
|
$shippingAddress: ShippingAddressInput!
|
|
@@ -63,8 +63,8 @@ import{s as o,m as B,n as b,d as M,Q as $,I as c,o as O}from"./fetch-graphql.js"
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
${
|
|
67
|
-
`,
|
|
66
|
+
${y}
|
|
67
|
+
`,j=`
|
|
68
68
|
mutation setShippingAddressOnQuote(
|
|
69
69
|
$quoteId: ID!
|
|
70
70
|
$shippingAddress: NegotiableQuoteShippingAddressInput!
|
|
@@ -78,8 +78,8 @@ import{s as o,m as B,n as b,d as M,Q as $,I as c,o as O}from"./fetch-graphql.js"
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
${
|
|
82
|
-
`,
|
|
81
|
+
${B}
|
|
82
|
+
`,J=`
|
|
83
83
|
mutation setShippingAddressOnQuoteAndUseAsBilling(
|
|
84
84
|
$quoteId: ID!
|
|
85
85
|
$shippingAddress: NegotiableQuoteShippingAddressInput!
|
|
@@ -104,6 +104,6 @@ import{s as o,m as B,n as b,d as M,Q as $,I as c,o as O}from"./fetch-graphql.js"
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
${
|
|
108
|
-
`,
|
|
107
|
+
${B}
|
|
108
|
+
`,W=({address:e,customerAddressId:s,customerAddressUid:t,pickupLocationCode:i})=>{if(!s&&t)throw new l("customerAddressUid is not supported");if(!s&&!i&&!e)throw new Q},X=({address:e,customerAddressId:s,customerAddressUid:t,pickupLocationCode:i})=>{if(i)throw new l("pickup location is not supported in quotes");if(!t&&s)throw new l("customerAddressId is not supported in quotes");if(!t&&!e)throw new Q},Y=e=>{const s=!!o.cartId,t=!!o.quoteId;s?W(e):t&&X(e)},T=(e,s,t,i,a,p)=>async n=>await q({type:"mutation",query:t,options:{variables:{[s]:e,shippingAddress:a(n)}},path:p,queueName:E.Updates,transformer:i}),pe=async e=>{V(),Y(e);const{defaults:s}=w.getConfig(),t=N("isBillToShipping")??(s==null?void 0:s.isBillToShipping);return await(!!o.cartId?T(o.cartId,"cartId",t?z:P,x,K,t?"setBillingAddressOnCart.cart":"setShippingAddressesOnCart.cart"):T(o.quoteId,"quoteId",t?J:j,H,L,t?"setNegotiableQuoteBillingAddress.quote":"setNegotiableQuoteShippingAddress.quote"))(e)};export{ae as e,pe as s};
|
|
109
109
|
//# sourceMappingURL=setShippingAddress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setShippingAddress.js","sources":["/@dropins/storefront-checkout/src/api/estimateShippingMethods/graphql/estimateShippingMethods.graphql.ts","/@dropins/storefront-checkout/src/api/estimateShippingMethods/estimateShippingMethods.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnCartAndUseAsBillingMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnCartMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnQuote.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnQuoteAndUseAsBillingMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/setShippingAddress.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const estimateShippingMethodsMutation = /* GraphQL */ `\n mutation estimateShippingMethods(\n $cartId: String!\n $address: EstimateAddressInput!\n ) {\n estimateShippingMethods(input: { cart_id: $cartId, address: $address }) {\n carrier_title\n carrier_code\n method_title\n method_code\n available\n amount {\n currency\n value\n }\n price_excl_tax {\n currency\n value\n }\n price_incl_tax {\n currency\n value\n }\n error_message\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { MissingCart, MissingCountry } from '@/checkout/lib/errors';\nimport { estimateShippingMethodsMutation } from '@/checkout/api/estimateShippingMethods/graphql';\nimport { ShippingMethod } from '@/checkout/data/models';\nimport {\n transformShippingEstimatePartialAddress,\n transformShippingEstimateShippingMethod,\n transformShippingMethods,\n} from '@/checkout/data/transforms';\nimport { dispatchApiCall, getValue, QueueName, state } from '@/checkout/lib';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface ShippingEstimationCriteria {\n country_code: string;\n region_name?: string;\n region_id?: string | number;\n zip?: string;\n}\n\nexport type EstimateShippingInput = {\n criteria: ShippingEstimationCriteria;\n};\n\nexport const estimateShippingMethods = async (\n input?: EstimateShippingInput\n): Promise<ShippingMethod[] | undefined> => {\n const cartId = state.cartId;\n const countryCode =\n input?.criteria?.country_code ?? state.config?.defaultCountry;\n\n if (!cartId) throw new MissingCart();\n if (!countryCode) throw new MissingCountry();\n\n const { region_id, region_name, zip } = input?.criteria ?? {};\n\n // Process region information\n const region =\n region_id || region_name\n ? {\n region_id:\n typeof region_id === 'string' ? parseInt(region_id, 10) : region_id,\n region_code: region_name,\n }\n : undefined;\n\n // Build address for API call\n const address = {\n country_code: countryCode,\n ...(zip && { postcode: zip }),\n ...(region && {\n region: {\n ...(region.region_id && { region_id: region.region_id }),\n ...(region.region_code && { region_code: region.region_code }),\n },\n }),\n };\n\n // Create address data for transformation\n const estimateShippingAddressData = {\n country_id: countryCode,\n region: address.region?.region_code,\n region_id: address.region?.region_id,\n postcode: zip,\n };\n\n const partialAddress = transformShippingEstimatePartialAddress(\n estimateShippingAddressData\n );\n\n return dispatchApiCall({\n options: { variables: { cartId, address } },\n path: 'estimateShippingMethods',\n query: estimateShippingMethodsMutation,\n queueName: QueueName.ShippingEstimate,\n transformer: transformShippingMethods,\n type: 'mutation',\n })\n .then((estimation) => {\n const hasAvailableOptions = estimation.length > 0;\n const partialAddress = transformShippingEstimatePartialAddress(\n estimateShippingAddressData\n );\n\n let shippingMethod = null;\n\n if (hasAvailableOptions) {\n const userSelection = getValue('selectedShippingMethod');\n\n const selection = estimation.find(\n (method) =>\n method.code === userSelection?.code &&\n method.carrier.code === userSelection?.carrier.code\n );\n\n shippingMethod = transformShippingEstimateShippingMethod(\n selection ?? estimation[0]\n );\n }\n\n events.emit('shipping/estimate', {\n address: partialAddress,\n availableShippingMethods: estimation,\n shippingMethod,\n success: true,\n });\n\n return estimation;\n })\n .catch((error) => {\n events.emit('shipping/estimate', {\n address: partialAddress,\n shippingMethod: null,\n availableShippingMethods: [],\n success: false,\n });\n\n throw error;\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setShippingAddressOnCartAndUseAsBillingMutation = /* GraphQL */ `\n mutation setShippingAddressOnCartAndUseAsBilling(\n $cartId: String!\n $shippingAddress: ShippingAddressInput!\n ) {\n setShippingAddressesOnCart(\n input: { cart_id: $cartId, shipping_addresses: [$shippingAddress] }\n ) {\n cart {\n id\n }\n }\n\n setBillingAddressOnCart(\n input: { cart_id: $cartId, billing_address: { same_as_shipping: true } }\n ) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setShippingAddressOnCartMutation = /* GraphQL */ `\n mutation setShippingAddressOnCart(\n $cartId: String!\n $shippingAddress: ShippingAddressInput!\n ) {\n setShippingAddressesOnCart(\n input: { cart_id: $cartId, shipping_addresses: [$shippingAddress] }\n ) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const setShippingAddressOnQuoteMutation = /* GraphQL */ `\n mutation setShippingAddressOnQuote(\n $quoteId: ID!\n $shippingAddress: NegotiableQuoteShippingAddressInput!\n ) {\n setNegotiableQuoteShippingAddress(\n input: { quote_uid: $quoteId, shipping_addresses: [$shippingAddress] }\n ) {\n quote {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const setShippingAddressOnQuoteAndUseAsBillingMutation = /* GraphQL */ `\n mutation setShippingAddressOnQuoteAndUseAsBilling(\n $quoteId: ID!\n $shippingAddress: NegotiableQuoteShippingAddressInput!\n ) {\n setNegotiableQuoteShippingAddress(\n input: { quote_uid: $quoteId, shipping_addresses: [$shippingAddress] }\n ) {\n quote {\n uid\n }\n }\n\n setNegotiableQuoteBillingAddress(\n input: {\n quote_uid: $quoteId\n billing_address: { same_as_shipping: true }\n }\n ) {\n quote {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { config } from '@/checkout/api';\nimport {\n setShippingAddressOnCartAndUseAsBillingMutation,\n setShippingAddressOnCartMutation,\n setShippingAddressOnQuoteAndUseAsBillingMutation,\n setShippingAddressOnQuoteMutation,\n} from '@/checkout/api/setShippingAddress/graphql';\nimport { ShippingAddressInput as ShippingAddressInputModel } from '@/checkout/data/models';\nimport {\n transformCart,\n transformNegotiableQuote,\n transformShippingAddressInputModelToCartInput,\n transformShippingAddressInputModelToQuoteInput,\n} from '@/checkout/data/transforms';\nimport { dispatchApiCall, getValue, QueueName } from '@/checkout/lib';\nimport { InvalidInput, MissingShippingAddress } from '@/checkout/lib/errors';\nimport { ensureHasCartOrQuoteId } from '@/checkout/lib/guards';\nimport { state } from '@/checkout/lib/state';\n\nconst ensureIsValidCartInput = ({\n address,\n customerAddressId,\n customerAddressUid,\n pickupLocationCode,\n}: ShippingAddressInputModel) => {\n if (!customerAddressId && customerAddressUid) {\n throw new InvalidInput('customerAddressUid is not supported');\n }\n\n if (!customerAddressId && !pickupLocationCode && !address) {\n throw new MissingShippingAddress();\n }\n};\n\nconst ensureIsValidQuoteInput = ({\n address,\n customerAddressId,\n customerAddressUid,\n pickupLocationCode,\n}: ShippingAddressInputModel) => {\n if (pickupLocationCode) {\n throw new InvalidInput('pickup location is not supported in quotes');\n }\n\n if (!customerAddressUid && customerAddressId) {\n throw new InvalidInput('customerAddressId is not supported in quotes');\n }\n\n if (!customerAddressUid && !address) {\n throw new MissingShippingAddress();\n }\n};\n\nconst ensureIsValidInput = (input: ShippingAddressInputModel) => {\n const isCart = Boolean(state.cartId);\n const isQuote = Boolean(state.quoteId);\n\n if (isCart) {\n ensureIsValidCartInput(input);\n } else if (isQuote) {\n ensureIsValidQuoteInput(input);\n }\n};\n\nconst createShippingAddressSetter = <TTransformedInput, TTransformedOutput>(\n entityId: string,\n entityKey: string,\n mutation: string,\n transformer: (data: any) => TTransformedOutput,\n transformInput: (input: ShippingAddressInputModel) => TTransformedInput,\n path: string\n) => {\n return async (\n input: ShippingAddressInputModel\n ): Promise<TTransformedOutput> => {\n return await dispatchApiCall({\n type: 'mutation',\n query: mutation,\n options: {\n variables: {\n [entityKey]: entityId,\n shippingAddress: transformInput(input),\n },\n },\n path,\n queueName: QueueName.Updates,\n transformer,\n });\n };\n};\n\nexport const setShippingAddress = async (input: ShippingAddressInputModel) => {\n ensureHasCartOrQuoteId();\n ensureIsValidInput(input);\n\n const { defaults } = config.getConfig();\n\n const isBillToShipping =\n getValue('isBillToShipping') ?? defaults?.isBillToShipping;\n\n const isCart = Boolean(state.cartId);\n\n const setter = isCart\n ? createShippingAddressSetter(\n state.cartId!,\n 'cartId',\n isBillToShipping\n ? setShippingAddressOnCartAndUseAsBillingMutation\n : setShippingAddressOnCartMutation,\n transformCart,\n transformShippingAddressInputModelToCartInput,\n isBillToShipping\n ? 'setBillingAddressOnCart.cart'\n : 'setShippingAddressesOnCart.cart'\n )\n : createShippingAddressSetter(\n state.quoteId!,\n 'quoteId',\n isBillToShipping\n ? setShippingAddressOnQuoteAndUseAsBillingMutation\n : setShippingAddressOnQuoteMutation,\n transformNegotiableQuote,\n transformShippingAddressInputModelToQuoteInput,\n isBillToShipping\n ? 'setNegotiableQuoteBillingAddress.quote'\n : 'setNegotiableQuoteShippingAddress.quote'\n );\n\n return await setter(input);\n};\n"],"names":["estimateShippingMethodsMutation","estimateShippingMethods","input","cartId","state","countryCode","_a","_b","MissingCart","MissingCountry","region_id","region_name","zip","region","address","estimateShippingAddressData","_c","_d","partialAddress","transformShippingEstimatePartialAddress","dispatchApiCall","QueueName","transformShippingMethods","estimation","hasAvailableOptions","shippingMethod","userSelection","getValue","selection","method","transformShippingEstimateShippingMethod","events","error","setShippingAddressOnCartAndUseAsBillingMutation","CHECKOUT_DATA_FRAGMENT","setShippingAddressOnCartMutation","setShippingAddressOnQuoteMutation","NEGOTIABLE_QUOTE_FRAGMENT","setShippingAddressOnQuoteAndUseAsBillingMutation","ensureIsValidCartInput","customerAddressId","customerAddressUid","pickupLocationCode","InvalidInput","MissingShippingAddress","ensureIsValidQuoteInput","ensureIsValidInput","isCart","isQuote","createShippingAddressSetter","entityId","entityKey","mutation","transformer","transformInput","path","setShippingAddress","ensureHasCartOrQuoteId","defaults","config","isBillToShipping","transformCart","transformShippingAddressInputModelToCartInput","transformNegotiableQuote","transformShippingAddressInputModelToQuoteInput"],"mappings":"qfAiBa,MAAAA,EAAgD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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EACA,mBAAAC,EACA,mBAAAC,CACF,IAAiC,CAC/B,GAAIA,EACI,MAAA,IAAIC,EAAa,4CAA4C,EAGjE,GAAA,CAACF,GAAsBD,EACnB,MAAA,IAAIG,EAAa,8CAA8C,EAGnE,GAAA,CAACF,GAAsB,CAAC3B,EAC1B,MAAM,IAAI8B,CAEd,EAEME,EAAsB5C,GAAqC,CACzD,MAAA6C,EAAS,EAAQ3C,EAAM,OACvB4C,EAAU,EAAQ5C,EAAM,QAE1B2C,EACFR,EAAuBrC,CAAK,EACnB8C,GACTH,EAAwB3C,CAAK,CAEjC,EAEM+C,EAA8B,CAClCC,EACAC,EACAC,EACAC,EACAC,EACAC,IAEO,MACLrD,GAEO,MAAMkB,EAAgB,CAC3B,KAAM,WACN,MAAOgC,EACP,QAAS,CACP,UAAW,CACT,CAACD,CAAS,EAAGD,EACb,gBAAiBI,EAAepD,CAAK,CAAA,CAEzC,EACA,KAAAqD,EACA,UAAWlC,EAAU,QACrB,YAAAgC,CAAA,CACD,EAIQG,GAAqB,MAAOtD,GAAqC,CACrDuD,EAAA,EACvBX,EAAmB5C,CAAK,EAExB,KAAM,CAAE,SAAAwD,CAAA,EAAaC,EAAO,UAAU,EAEhCC,EACJjC,EAAS,kBAAkB,IAAK+B,GAAA,YAAAA,EAAU,kBA8BrC,OAAA,MA5BQ,EAAQtD,EAAM,OAGzB6C,EACE7C,EAAM,OACN,SACAwD,EACI3B,EACAE,EACJ0B,EACAC,EACAF,EACI,+BACA,iCAAA,EAENX,EACE7C,EAAM,QACN,UACAwD,EACItB,EACAF,EACJ2B,EACAC,EACAJ,EACI,yCACA,yCACN,GAEgB1D,CAAK,CAC3B"}
|
|
1
|
+
{"version":3,"file":"setShippingAddress.js","sources":["/@dropins/storefront-checkout/src/api/estimateShippingMethods/graphql/estimateShippingMethods.graphql.ts","/@dropins/storefront-checkout/src/api/estimateShippingMethods/estimateShippingMethods.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnCartAndUseAsBillingMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnCartMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnQuote.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnQuoteAndUseAsBillingMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/setShippingAddress.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const estimateShippingMethodsMutation = /* GraphQL */ `\n mutation estimateShippingMethods(\n $cartId: String!\n $address: EstimateAddressInput!\n ) {\n estimateShippingMethods(input: { cart_id: $cartId, address: $address }) {\n carrier_title\n carrier_code\n method_title\n method_code\n available\n amount {\n currency\n value\n }\n price_excl_tax {\n currency\n value\n }\n price_incl_tax {\n currency\n value\n }\n error_message\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { config } from '@/checkout/api';\nimport { estimateShippingMethodsMutation } from '@/checkout/api/estimateShippingMethods/graphql';\nimport { ShippingMethod } from '@/checkout/data/models';\nimport {\n transformShippingEstimatePartialAddress,\n transformShippingEstimateShippingMethod,\n transformShippingMethods,\n} from '@/checkout/data/transforms';\nimport { dispatchApiCall, getValue, QueueName, state } from '@/checkout/lib';\nimport { MissingCart, MissingCountry } from '@/checkout/lib/errors';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface ShippingEstimationCriteria {\n country_code: string;\n region_name?: string;\n region_id?: string | number;\n zip?: string;\n}\n\nexport type EstimateShippingInput = {\n criteria: ShippingEstimationCriteria;\n};\n\nexport const estimateShippingMethods = async (\n input?: EstimateShippingInput\n): Promise<ShippingMethod[] | undefined> => {\n const cartId = state.cartId;\n const countryCode =\n input?.criteria?.country_code ?? state.config?.defaultCountry;\n\n if (!cartId) throw new MissingCart();\n if (!countryCode) throw new MissingCountry();\n\n const { region_id, region_name, zip } = input?.criteria ?? {};\n\n // Process region information\n const region =\n region_id || region_name\n ? {\n region_id:\n typeof region_id === 'string' ? parseInt(region_id, 10) : region_id,\n region_code: region_name,\n }\n : undefined;\n\n // Build address for API call\n const address = {\n country_code: countryCode,\n ...(zip && { postcode: zip }),\n ...(region && {\n region: {\n ...(region.region_id && { region_id: region.region_id }),\n ...(region.region_code && { region_code: region.region_code }),\n },\n }),\n };\n\n // Create address data for transformation\n const estimateShippingAddressData = {\n country_id: countryCode,\n region: address.region?.region_code,\n region_id: address.region?.region_id,\n postcode: zip,\n };\n\n const partialAddress = transformShippingEstimatePartialAddress(\n estimateShippingAddressData\n );\n\n return dispatchApiCall({\n options: { variables: { cartId, address } },\n path: 'estimateShippingMethods',\n query: estimateShippingMethodsMutation,\n queueName: QueueName.ShippingEstimate,\n transformer: transformShippingMethods,\n type: 'mutation',\n })\n .then((estimation) => {\n const { defaults, shipping } = config.getConfig();\n\n const filteredOptions = shipping?.filterOptions\n ? estimation.filter(shipping.filterOptions)\n : estimation;\n\n const hasAvailableOptions = filteredOptions.length > 0;\n const partialAddress = transformShippingEstimatePartialAddress(\n estimateShippingAddressData\n );\n\n let shippingMethod = null;\n\n if (hasAvailableOptions) {\n const userSelection = getValue('selectedShippingMethod');\n\n let selection = estimation.find(\n (method) =>\n method.code === userSelection?.code &&\n method.carrier.code === userSelection?.carrier.code\n );\n\n if (!selection && defaults?.selectedShippingMethod) {\n selection = defaults.selectedShippingMethod(estimation) ?? undefined;\n }\n\n if (!selection) {\n selection = estimation[0];\n }\n\n shippingMethod = transformShippingEstimateShippingMethod(selection);\n }\n\n events.emit('shipping/estimate', {\n address: partialAddress,\n availableShippingMethods: estimation,\n shippingMethod,\n success: true,\n });\n\n return filteredOptions;\n })\n .catch((error) => {\n events.emit('shipping/estimate', {\n address: partialAddress,\n shippingMethod: null,\n availableShippingMethods: [],\n success: false,\n });\n\n throw error;\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setShippingAddressOnCartAndUseAsBillingMutation = /* GraphQL */ `\n mutation setShippingAddressOnCartAndUseAsBilling(\n $cartId: String!\n $shippingAddress: ShippingAddressInput!\n ) {\n setShippingAddressesOnCart(\n input: { cart_id: $cartId, shipping_addresses: [$shippingAddress] }\n ) {\n cart {\n id\n }\n }\n\n setBillingAddressOnCart(\n input: { cart_id: $cartId, billing_address: { same_as_shipping: true } }\n ) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setShippingAddressOnCartMutation = /* GraphQL */ `\n mutation setShippingAddressOnCart(\n $cartId: String!\n $shippingAddress: ShippingAddressInput!\n ) {\n setShippingAddressesOnCart(\n input: { cart_id: $cartId, shipping_addresses: [$shippingAddress] }\n ) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const setShippingAddressOnQuoteMutation = /* GraphQL */ `\n mutation setShippingAddressOnQuote(\n $quoteId: ID!\n $shippingAddress: NegotiableQuoteShippingAddressInput!\n ) {\n setNegotiableQuoteShippingAddress(\n input: { quote_uid: $quoteId, shipping_addresses: [$shippingAddress] }\n ) {\n quote {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const setShippingAddressOnQuoteAndUseAsBillingMutation = /* GraphQL */ `\n mutation setShippingAddressOnQuoteAndUseAsBilling(\n $quoteId: ID!\n $shippingAddress: NegotiableQuoteShippingAddressInput!\n ) {\n setNegotiableQuoteShippingAddress(\n input: { quote_uid: $quoteId, shipping_addresses: [$shippingAddress] }\n ) {\n quote {\n uid\n }\n }\n\n setNegotiableQuoteBillingAddress(\n input: {\n quote_uid: $quoteId\n billing_address: { same_as_shipping: true }\n }\n ) {\n quote {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { config } from '@/checkout/api';\nimport {\n setShippingAddressOnCartAndUseAsBillingMutation,\n setShippingAddressOnCartMutation,\n setShippingAddressOnQuoteAndUseAsBillingMutation,\n setShippingAddressOnQuoteMutation,\n} from '@/checkout/api/setShippingAddress/graphql';\nimport { ShippingAddressInput as ShippingAddressInputModel } from '@/checkout/data/models';\nimport {\n transformCart,\n transformNegotiableQuote,\n transformShippingAddressInputModelToCartInput,\n transformShippingAddressInputModelToQuoteInput,\n} from '@/checkout/data/transforms';\nimport { dispatchApiCall, getValue, QueueName } from '@/checkout/lib';\nimport { InvalidInput, MissingShippingAddress } from '@/checkout/lib/errors';\nimport { ensureHasCartOrQuoteId } from '@/checkout/lib/guards';\nimport { state } from '@/checkout/lib/state';\n\nconst ensureIsValidCartInput = ({\n address,\n customerAddressId,\n customerAddressUid,\n pickupLocationCode,\n}: ShippingAddressInputModel) => {\n if (!customerAddressId && customerAddressUid) {\n throw new InvalidInput('customerAddressUid is not supported');\n }\n\n if (!customerAddressId && !pickupLocationCode && !address) {\n throw new MissingShippingAddress();\n }\n};\n\nconst ensureIsValidQuoteInput = ({\n address,\n customerAddressId,\n customerAddressUid,\n pickupLocationCode,\n}: ShippingAddressInputModel) => {\n if (pickupLocationCode) {\n throw new InvalidInput('pickup location is not supported in quotes');\n }\n\n if (!customerAddressUid && customerAddressId) {\n throw new InvalidInput('customerAddressId is not supported in quotes');\n }\n\n if (!customerAddressUid && !address) {\n throw new MissingShippingAddress();\n }\n};\n\nconst ensureIsValidInput = (input: ShippingAddressInputModel) => {\n const isCart = Boolean(state.cartId);\n const isQuote = Boolean(state.quoteId);\n\n if (isCart) {\n ensureIsValidCartInput(input);\n } else if (isQuote) {\n ensureIsValidQuoteInput(input);\n }\n};\n\nconst createShippingAddressSetter = <TTransformedInput, TTransformedOutput>(\n entityId: string,\n entityKey: string,\n mutation: string,\n transformer: (data: any) => TTransformedOutput,\n transformInput: (input: ShippingAddressInputModel) => TTransformedInput,\n path: string\n) => {\n return async (\n input: ShippingAddressInputModel\n ): Promise<TTransformedOutput> => {\n return await dispatchApiCall({\n type: 'mutation',\n query: mutation,\n options: {\n variables: {\n [entityKey]: entityId,\n shippingAddress: transformInput(input),\n },\n },\n path,\n queueName: QueueName.Updates,\n transformer,\n });\n };\n};\n\nexport const setShippingAddress = async (input: ShippingAddressInputModel) => {\n ensureHasCartOrQuoteId();\n ensureIsValidInput(input);\n\n const { defaults } = config.getConfig();\n\n const isBillToShipping =\n getValue('isBillToShipping') ?? defaults?.isBillToShipping;\n\n const isCart = Boolean(state.cartId);\n\n const setter = isCart\n ? createShippingAddressSetter(\n state.cartId!,\n 'cartId',\n isBillToShipping\n ? setShippingAddressOnCartAndUseAsBillingMutation\n : setShippingAddressOnCartMutation,\n transformCart,\n transformShippingAddressInputModelToCartInput,\n isBillToShipping\n ? 'setBillingAddressOnCart.cart'\n : 'setShippingAddressesOnCart.cart'\n )\n : createShippingAddressSetter(\n state.quoteId!,\n 'quoteId',\n isBillToShipping\n ? setShippingAddressOnQuoteAndUseAsBillingMutation\n : setShippingAddressOnQuoteMutation,\n transformNegotiableQuote,\n transformShippingAddressInputModelToQuoteInput,\n isBillToShipping\n ? 'setNegotiableQuoteBillingAddress.quote'\n : 'setNegotiableQuoteShippingAddress.quote'\n );\n\n return await setter(input);\n};\n"],"names":["estimateShippingMethodsMutation","estimateShippingMethods","input","cartId","state","countryCode","_a","_b","MissingCart","MissingCountry","region_id","region_name","zip","region","address","estimateShippingAddressData","_c","_d","partialAddress","transformShippingEstimatePartialAddress","dispatchApiCall","QueueName","transformShippingMethods","estimation","defaults","shipping","config","filteredOptions","hasAvailableOptions","shippingMethod","userSelection","getValue","selection","method","transformShippingEstimateShippingMethod","events","error","setShippingAddressOnCartAndUseAsBillingMutation","CHECKOUT_DATA_FRAGMENT","setShippingAddressOnCartMutation","setShippingAddressOnQuoteMutation","NEGOTIABLE_QUOTE_FRAGMENT","setShippingAddressOnQuoteAndUseAsBillingMutation","ensureIsValidCartInput","customerAddressId","customerAddressUid","pickupLocationCode","InvalidInput","MissingShippingAddress","ensureIsValidQuoteInput","ensureIsValidInput","isCart","isQuote","createShippingAddressSetter","entityId","entityKey","mutation","transformer","transformInput","path","setShippingAddress","ensureHasCartOrQuoteId","isBillToShipping","transformCart","transformShippingAddressInputModelToCartInput","transformNegotiableQuote","transformShippingAddressInputModelToQuoteInput"],"mappings":"qfAiBa,MAAAA,EAAgD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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ACAE,EACJwB,EACAC,EACAF,EACI,+BACA,iCAAA,EAENT,EACEjD,EAAM,QACN,UACA0D,EACIpB,EACAF,EACJyB,EACAC,EACAJ,EACI,yCACA,yCACN,GAEgB5D,CAAK,CAC3B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{CHECKOUT_DATA_FRAGMENT as r,NEGOTIABLE_QUOTE_FRAGMENT as h}from"../fragments.js";import{e as d,t as u}from"./guards.js";import{t as
|
|
3
|
+
import{CHECKOUT_DATA_FRAGMENT as r,NEGOTIABLE_QUOTE_FRAGMENT as h}from"../fragments.js";import{e as d,t as u}from"./guards.js";import{t as g,e as M}from"./synchronizeCheckout.js";import{s as e,j as m,d as c,Q as I}from"./fetch-graphql.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";const S=`
|
|
4
4
|
mutation setShippingMethodsOnCart(
|
|
5
5
|
$cartId: String!
|
|
6
6
|
$shippingMethods: [ShippingMethodInput]!
|
|
@@ -30,5 +30,5 @@ import{CHECKOUT_DATA_FRAGMENT as r,NEGOTIABLE_QUOTE_FRAGMENT as h}from"../fragme
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
${h}
|
|
33
|
-
`,o=(t,s,i,n,p)=>async a=>await c({type:"mutation",query:i,queueName:I.Updates,options:{variables:{[s]:t,shippingMethods:u(a)}},path:p,transformer:n}),C=t=>{if(!Array.isArray(t)||t.length===0)throw new m},Q=async t=>(d(),C(t),await(!!e.cartId?o(e.cartId,"cartId",S,
|
|
33
|
+
`,o=(t,s,i,n,p)=>async a=>await c({type:"mutation",query:i,queueName:I.Updates,options:{variables:{[s]:t,shippingMethods:u(a)}},path:p,transformer:n}),C=t=>{if(!Array.isArray(t)||t.length===0)throw new m},Q=async t=>(d(),C(t),await(!!e.cartId?o(e.cartId,"cartId",S,g,"setShippingMethodsOnCart.cart"):o(e.quoteId,"quoteId",A,M,"setNegotiableQuoteShippingMethods.quote"))(t));export{Q as s};
|
|
34
34
|
//# sourceMappingURL=setShippingMethods.js.map
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{s as
|
|
3
|
+
import{s as r,n as Q,d as y,U as N,t as D,e as S}from"./fetch-graphql.js";import{merge as k,Initializer as z,deepmerge as G}from"@dropins/tools/lib.js";import{events as d}from"@dropins/tools/event-bus.js";import{CHECKOUT_DATA_FRAGMENT as C,NEGOTIABLE_QUOTE_FRAGMENT as O}from"../fragments.js";import{b as R,c as P,d as U,a as L,e as x,f as B,g as $}from"./transform-shipping-methods.js";import{E as g}from"./classifiers.js";const F=async(e=!1)=>{r.authenticated=e},_=e=>{if(!e)return;const{code:t,title:i,...s}=e;return{code:t,title:i,additionalData:s}},b=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:i,title:s,...c}=t;return{code:i,title:s,additionalData:c}})},H=e=>{var i,s,c;if(!e)return;const t={availablePaymentMethods:b(e.available_payment_methods),billingAddress:P(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:_(e.selected_payment_method),shippingAddresses:R(e.shipping_addresses),isGuest:!r.authenticated};return k(t,(c=(s=(i=te.getConfig().models)==null?void 0:i.CartModel)==null?void 0:s.transformer)==null?void 0:c.call(s,e))},q=e=>{const t=e.street.filter(Boolean);return{city:e.city,company:e.company||void 0,country:$(e.country),customAttributes:B(e.custom_attributes),fax:e.fax||void 0,firstName:e.firstname,lastName:e.lastname,middleName:e.middlename||void 0,postCode:e.postcode||void 0,prefix:e.prefix||void 0,region:x(e.region),street:t,suffix:e.suffix||void 0,telephone:e.telephone||void 0,uid:e.uid,vatId:e.vat_id||void 0}},K=e=>{if(e)return q(e)},V=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:i,selected_shipping_method:s,...c}=t;return{...q(c),availableShippingMethods:L(i),selectedShippingMethod:U(s)}}),W=e=>e?{availablePaymentMethods:b(e.available_payment_methods),billingAddress:K(e.billing_address),email:e.email??"",isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,name:e.name,selectedPaymentMethod:_(e.selected_payment_method),shippingAddresses:V(e.shipping_addresses),status:e.status,uid:e.uid}:null,Y=`
|
|
4
4
|
query getCart($cartId: String!) {
|
|
5
5
|
cart(cart_id: $cartId) {
|
|
6
6
|
...CHECKOUT_DATA_FRAGMENT
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
${
|
|
11
|
-
`,
|
|
10
|
+
${C}
|
|
11
|
+
`,j=`
|
|
12
12
|
query getCustomerCart {
|
|
13
13
|
cart: customerCart {
|
|
14
14
|
...CHECKOUT_DATA_FRAGMENT
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
${
|
|
19
|
-
`,
|
|
18
|
+
${C}
|
|
19
|
+
`,I=async()=>{const e=r.cartId,t=r.authenticated===!1,i=t?Y:j,s=t?{cartId:e}:{};if(t&&!e)throw new Q;return await y({type:"query",query:i,options:{method:"POST",cache:"no-cache",variables:s},path:"cart",transformer:H})},J=`
|
|
20
20
|
query getNegotiableQuote($quoteId: ID!) {
|
|
21
21
|
negotiableQuote(uid: $quoteId) {
|
|
22
22
|
...NEGOTIABLE_QUOTE_FRAGMENT
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
${
|
|
27
|
-
`,
|
|
26
|
+
${O}
|
|
27
|
+
`,A=async(e={})=>{const t=e.uid??r.quoteId;if(r.authenticated===!1)throw new N;if(!t)throw new D;return await y({type:"query",query:J,options:{method:"GET",cache:"no-cache",variables:{quoteId:t}},path:"negotiableQuote",transformer:W})},m={eager:!0},X=e=>{var f,p;const t=((p=(f=e==null?void 0:e.features)==null?void 0:f.b2b)==null?void 0:p.quotes)??!1;return[["authenticated",(u=!1)=>{var o,a,l;if(F(u),!t||u)return;const n=(l=(a=(o=e==null?void 0:e.features)==null?void 0:o.b2b)==null?void 0:a.routeLogin)==null?void 0:l.call(a);n&&window.location.assign(n)},m],...t?[["quote-management/quote-data/initialized",u=>{var n,o,a,l;if(!u.quote.canCheckout){const M=((l=(a=(o=(n=e==null?void 0:e.langDefinitions)==null?void 0:n.default)==null?void 0:o.Checkout)==null?void 0:a.Quote)==null?void 0:l.permissionDenied)||"You do not have permission to checkout with this quote.";d.emit("checkout/error",{message:M,code:g.QUOTE_PERMISSION_DENIED});return}h(u.quote)},m],["quote-management/quote-data/error",()=>{var n,o,a,l;const u=((l=(a=(o=(n=e==null?void 0:e.langDefinitions)==null?void 0:n.default)==null?void 0:o.Checkout)==null?void 0:a.Quote)==null?void 0:l.dataError)||"We were unable to retrieve the quote data. Please try again later.";d.emit("checkout/error",{message:u,code:g.QUOTE_DATA_ERROR})}]]:[["cart/initialized",h,m],["cart/reset",w],["cart/updated",T]]].map(([u,n,o])=>d.on(u,n,o))},Z=new URL(window.location.href),ee=Z.searchParams.get("quoteId");r.quoteId=ee;const E=new z({init:async(e={})=>{E.config.setConfig(G({defaults:{isBillToShipping:!0,selectedShippingMethod:t=>t.length>0?t[0]:null},features:{b2b:{quotes:!1}}},e))},listeners:X}),te=E.config,v=e=>"id"in e,re=async e=>{try{return v(e)?(r.cartId=e.id,r.quoteId=null,await I()??null):(r.cartId=null,r.quoteId=e.uid,await A()??null)}catch(t){return console.error("Checkout initialization failed:",t),null}},h=async e=>{if(r.initialized){await T(e);return}r.config||(r.config=await S());const t=e?await re(e):null;r.initialized=!0,d.emit("checkout/initialized",t)},w=()=>{r.initialized&&(r.cartId=null,r.quoteId=null,d.emit("checkout/updated",null))},se=async e=>{try{return v(e)?(r.cartId=e.id,r.quoteId=null,await I()??null):(r.cartId=null,r.quoteId=e.uid,await A()??null)}catch(t){return console.error("Checkout synchronization failed:",t),null}},T=async e=>{if(!r.initialized)return h(e);if(e===null){w();return}const t=await se(e);d.emit("checkout/updated",t)};export{F as a,A as b,te as c,h as d,W as e,I as g,E as i,w as r,T as s,H as t};
|
|
28
28
|
//# sourceMappingURL=synchronizeCheckout.js.map
|