@dropins/storefront-checkout 3.3.0-beta.0 → 3.3.0-beta.2
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/CHANGELOG.md +12 -0
- package/api.js +266 -0
- package/api.js.map +1 -0
- package/chunks/PaymentOnAccount.js +1 -1
- package/chunks/PaymentOnAccount.js.map +1 -1
- package/chunks/PurchaseOrder.js +1 -1
- package/chunks/PurchaseOrder.js.map +1 -1
- package/chunks/components.js +2 -2
- package/chunks/components.js.map +1 -1
- package/chunks/events.js +4 -0
- package/chunks/events.js.map +1 -0
- package/chunks/render.js +1 -1
- package/chunks/render.js.map +1 -1
- package/chunks/ui.js +4 -0
- package/chunks/ui.js.map +1 -0
- 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.js +1 -1
- package/containers/PaymentMethods.js.map +1 -1
- package/containers/PaymentOnAccount.js +1 -1
- package/containers/PlaceOrder.js +1 -1
- package/containers/PlaceOrder.js.map +1 -1
- package/containers/PurchaseOrder.js +1 -1
- package/containers/ServerError.js +1 -1
- package/containers/ServerError.js.map +1 -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/fragments.js +275 -1
- package/fragments.js.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils.js +1 -537
- package/lib/utils.js.map +1 -1
- package/package.json +1 -1
- package/render.js +1 -1
package/lib/utils.js
CHANGED
|
@@ -1,540 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2026 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{
|
|
4
|
-
fragment ESTIMATE_SHIPPING_METHOD_FRAGMENT on AvailableShippingMethod {
|
|
5
|
-
amount {
|
|
6
|
-
currency
|
|
7
|
-
value
|
|
8
|
-
}
|
|
9
|
-
available
|
|
10
|
-
carrier_code
|
|
11
|
-
carrier_title
|
|
12
|
-
error_message
|
|
13
|
-
method_code
|
|
14
|
-
method_title
|
|
15
|
-
price_excl_tax {
|
|
16
|
-
value
|
|
17
|
-
currency
|
|
18
|
-
}
|
|
19
|
-
price_incl_tax {
|
|
20
|
-
value
|
|
21
|
-
currency
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
`,ce=`
|
|
25
|
-
fragment AVAILABLE_SHIPPING_METHOD_FRAGMENT on AvailableShippingMethod {
|
|
26
|
-
amount {
|
|
27
|
-
currency
|
|
28
|
-
value
|
|
29
|
-
}
|
|
30
|
-
carrier_code
|
|
31
|
-
carrier_title
|
|
32
|
-
error_message
|
|
33
|
-
method_code
|
|
34
|
-
method_title
|
|
35
|
-
price_excl_tax {
|
|
36
|
-
value
|
|
37
|
-
currency
|
|
38
|
-
}
|
|
39
|
-
price_incl_tax {
|
|
40
|
-
value
|
|
41
|
-
currency
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
`,ae=`
|
|
45
|
-
fragment SELECTED_SHIPPING_METHOD_FRAGMENT on SelectedShippingMethod {
|
|
46
|
-
amount {
|
|
47
|
-
currency
|
|
48
|
-
value
|
|
49
|
-
}
|
|
50
|
-
carrier_code
|
|
51
|
-
carrier_title
|
|
52
|
-
method_code
|
|
53
|
-
method_title
|
|
54
|
-
price_excl_tax {
|
|
55
|
-
value
|
|
56
|
-
currency
|
|
57
|
-
}
|
|
58
|
-
price_incl_tax {
|
|
59
|
-
value
|
|
60
|
-
currency
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
`,Ve=`
|
|
64
|
-
mutation estimateShippingMethods(
|
|
65
|
-
$cartId: String!
|
|
66
|
-
$address: EstimateAddressInput!
|
|
67
|
-
) {
|
|
68
|
-
estimateShippingMethods(input: { cart_id: $cartId, address: $address }) {
|
|
69
|
-
...ESTIMATE_SHIPPING_METHOD_FRAGMENT
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
${He}
|
|
74
|
-
`;function ke({code:e,...t}){return{code:e,...t}}function je({code:e,...t}){return{code:e,...t}}const ze=e=>{if("carrier_code"in e&&"method_code"in e)return e;const t=e,{carrierCode:n,methodCode:r,...i}=t;return{carrier_code:n,method_code:r,...i}};function Xe(e){return e.map(ze)}function U(e){var t;return{fax:e.fax,middlename:e.middleName,prefix:e.prefix,suffix:e.suffix,vat_id:e.vatId,city:e.city,custom_attributes:((t=e.customAttributes)==null?void 0:t.map(n=>({attribute_code:n.code,value:n.value})))||[],company:e.company,country_code:e.countryCode,firstname:e.firstName,lastname:e.lastName,postcode:e.postcode,region:e.region,region_id:e.regionId,save_in_address_book:e.saveInAddressBook,street:e.street,telephone:e.telephone}}function Ke(e){const{customerAddressId:t,pickupLocationCode:n,address:r}=e,i={};return t?{customer_address_id:t}:(n&&(i.pickup_location_code=n),!n&&r&&(i.address=U(r)),i)}function Ye(e){const{customerAddressUid:t,address:n}=e,r={};return t?{customer_address_uid:t}:(n&&(r.address=U(n)),r)}function We(e){const{customerAddressId:t,sameAsShipping:n=!1,useForShipping:r=!1,address:i}=e;let o={use_for_shipping:r,same_as_shipping:n};return!n&&t?(o.customer_address_id=t,o):(!n&&i&&(o.address=U(i)),o)}function Je(e){const{customerAddressUid:t,sameAsShipping:n=!1,useForShipping:r=!1,address:i}=e;let o={use_for_shipping:r,same_as_shipping:n};return!n&&t?(o.customer_address_uid=t,o):(!n&&i&&(o.address=U(i)),o)}const Ze=e=>e?"code"in e&&"value"in e:!1,le=e=>e?e.filter(Ze).map(t=>{const{code:n,value:r}=t;return{code:n,value:r}}):[],de=e=>{if(!e)return;const{code:t,title:n,...r}=e;return{code:t,title:n,additionalData:r}},pe=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:n,title:r,...i}=t;return{code:n,title:r,additionalData:i}})},me=e=>{const t=e.street.filter(Boolean);return{city:e.city,company:e.company||void 0,country:_e(e.country),customAttributes:le(e.custom_attributes),fax:e.fax||void 0,firstName:e.firstname,id:(e==null?void 0:e.id)||void 0,lastName:e.lastname,middleName:e.middlename||void 0,postCode:e.postcode||void 0,prefix:e.prefix||void 0,region:fe(e.region),street:t,suffix:e.suffix||void 0,telephone:e.telephone||void 0,uid:e.uid,vatId:e.vat_id||void 0}},et=e=>{if(e)return me(e)},tt=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:n,selected_shipping_method:r,same_as_billing:i,...o}=t;return{...me(o),availableShippingMethods:V(n),selectedShippingMethod:Te(r),sameAsBilling:i}}),Xn=e=>{var t,n;if(e)return{city:e.city,company:e.company,countryCode:e.country.code,customAttributes:e.customAttributes||[],firstName:e.firstName,lastName:e.lastName,postcode:e.postCode,region:(t=e.region)==null?void 0:t.code,regionId:(n=e.region)==null?void 0:n.id,street:e.street,telephone:e.telephone,vatId:e.vatId,prefix:e.prefix,suffix:e.suffix,middleName:e.middleName,fax:e.fax}},b=e=>{var n,r,i;if(!e)return;const t={type:"cart",availablePaymentMethods:pe(e.available_payment_methods),billingAddress:et(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:de(e.selected_payment_method),shippingAddresses:tt(e.shipping_addresses),isGuest:!s.authenticated};return se(t,(i=(r=(n=q.getConfig().models)==null?void 0:n.CartModel)==null?void 0:r.transformer)==null?void 0:i.call(r,e))},nt=e=>!e||!(e!=null&&e.available_credit)||e.available_credit.value==null||!e.available_credit.currency?null:{availableCredit:{value:e.available_credit.value,currency:e.available_credit.currency},exceedLimit:(e==null?void 0:e.exceed_limit)||!1},he=e=>{const t=e.street.filter(Boolean);return{city:e.city,company:e.company||void 0,country:_e(e.country),customAttributes:le(e.custom_attributes),customerAddressUid:e.customer_address_uid||void 0,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:fe(e.region),street:t,suffix:e.suffix||void 0,telephone:e.telephone||void 0,uid:e.uid,vatId:e.vat_id||void 0}},rt=e=>{if(e)return he(e)},it=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:n,selected_shipping_method:r,...i}=t;return{...he(i),availableShippingMethods:V(n),selectedShippingMethod:Te(r)}});var ge=(e=>(e.MANUAL="manual",e.AUTO="auto",e))(ge||{}),N=(e=>(e.EXCLUDING_TAX="EXCLUDING_TAX",e.INCLUDING_EXCLUDING_TAX="INCLUDING_AND_EXCLUDING_TAX",e.INCLUDING_TAX="INCLUDING_TAX",e))(N||{});const ot=e=>e?e.filter(t=>!!t).map(t=>({id:t.agreement_id,name:t.name,mode:ge[t.mode],text:t.checkbox_text,content:{value:t.content,html:t.is_html,height:t.content_height??null}})):[],_e=e=>({code:(e==null?void 0:e.code)??"",label:(e==null?void 0:e.label)??""}),st=e=>{var n,r,i;if(!e)return null;const t={firstName:e.firstname||"",lastName:e.lastname||"",email:e.email||""};return se(t,(i=(r=(n=q.getConfig().models)==null?void 0:n.CustomerModel)==null?void 0:r.transformer)==null?void 0:i.call(r,e))},ut=e=>!!(e!=null&&e.is_email_available),G=e=>e?{type:"quote",availablePaymentMethods:pe(e.available_payment_methods),billingAddress:rt(e.billing_address),email:e.email??"",isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,name:e.name,selectedPaymentMethod:de(e.selected_payment_method),shippingAddresses:it(e.shipping_addresses),status:e.status,uid:e.uid}:null,fe=e=>{if(!(!(e!=null&&e.code)||!(e!=null&&e.label)))return{code:e.code,name:e.label,id:e.region_id??void 0}};function ct(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var at=function(t){return lt(t)&&!dt(t)};function lt(e){return!!e&&typeof e=="object"}function dt(e){var t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||ht(e)}var pt=typeof Symbol=="function"&&Symbol.for,mt=pt?Symbol.for("react.element"):60103;function ht(e){return e.$$typeof===mt}function gt(e){return Array.isArray(e)?[]:{}}function D(e,t){return t.clone!==!1&&t.isMergeableObject(e)?C(gt(e),e,t):e}function _t(e,t,n){return e.concat(t).map(function(r){return D(r,n)})}function ft(e,t){if(!t.customMerge)return C;var n=t.customMerge(e);return typeof n=="function"?n:C}function At(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function W(e){return Object.keys(e).concat(At(e))}function Ae(e,t){try{return t in e}catch{return!1}}function Et(e,t){return Ae(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function It(e,t,n){var r={};return n.isMergeableObject(e)&&W(e).forEach(function(i){r[i]=D(e[i],n)}),W(t).forEach(function(i){Et(e,i)||(Ae(e,i)&&n.isMergeableObject(t[i])?r[i]=ft(i,n)(e[i],t[i],n):r[i]=D(t[i],n))}),r}function C(e,t,n){n=n||{},n.arrayMerge=n.arrayMerge||_t,n.isMergeableObject=n.isMergeableObject||at,n.cloneUnlessOtherwiseSpecified=D;var r=Array.isArray(t),i=Array.isArray(e),o=r===i;return o?r?n.arrayMerge(e,t,n):It(e,t,n):D(t,n)}C.all=function(t,n){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(r,i){return C(r,i,n)},{})};var yt=C,Tt=yt;const Ee=ct(Tt),Mt={arrayMerge:(e,t,n)=>{const r=e.slice();return t.forEach((i,o)=>{typeof r[o]>"u"?r[o]=n.cloneUnlessOtherwiseSpecified(i,n):n.isMergeableObject(i)?r[o]=Ee(e[o],i,n):e.indexOf(i)===-1&&r.push(i)}),r}};function Nt(e,t){return t?Ee(e,t,Mt):e}const J=e=>({countryCode:e.country_id,postCode:e.postcode||"",...e.region_id?{regionId:Number(e.region_id)}:{...e.region?{region:e.region}:{}}}),Ct=e=>({carrierCode:e.carrier.code||"",methodCode:e.code||"",amount:e.amount,amountExclTax:e.amountExclTax,amountInclTax:e.amountInclTax}),St=e=>{var n,r,i;const t=V(e);return Nt(t,(i=(r=(n=q.getConfig().models)==null?void 0:n.EstimateShippingModel)==null?void 0:r.transformer)==null?void 0:i.call(r,e))},bt=(e,t)=>e.amount.value-t.amount.value,vt=e=>e==null,Ie=e=>!(!e||!e.method_code||!e.method_title||vt(e.amount.value)||!e.amount.currency),ye=e=>({amount:{value:e.amount.value,currency:e.amount.currency},title:e.method_title,code:e.method_code,carrier:{code:e.carrier_code,title:e.carrier_title},value:`${e.carrier_code} - ${e.method_code}`,...e.price_excl_tax&&{amountExclTax:{value:e.price_excl_tax.value,currency:e.price_excl_tax.currency}},...e.price_incl_tax&&{amountInclTax:{value:e.price_incl_tax.value,currency:e.price_incl_tax.currency}},...e.original_amount&&{originalAmount:{value:e.original_amount.value,currency:e.original_amount.currency}}}),Te=e=>{if(Ie(e))return ye(e)},V=e=>e?e.filter(Ie).map(t=>ye(t)).sort(bt):[],Z=ie(!1);let Q=0;function Kn({type:e="shipping",debounceMs:t=0}){const n=e==="shipping"?Un:Sn,r=ue(i=>{Q+=1,n(i).catch(console.error).finally(()=>{Q-=1,Q===0&&(Z.value=!1)})},t);return({data:i,isDataValid:o})=>{if(!o)return;Z.value=!0;const u=Gt(i);r(u)}}function Yn({debounceMs:e=0}){let t={},n=!1;const r=ue(i=>{var u,d,c,a;if(n)return;const o={country_code:i.countryCode,region_name:String(((u=i.region)==null?void 0:u.regionCode)||""),region_id:String(((d=i.region)==null?void 0:d.regionId)||""),zip:i.postcode};nn({criteria:o}),t={countryCode:i.countryCode,regionCode:((c=i.region)==null?void 0:c.regionCode)||"",regionId:((a=i.region)==null?void 0:a.regionId)||"",postcode:i.postcode}},e);return({data:i,isDataValid:o})=>{var u,d;if(o){n=!0;return}t.countryCode===i.countryCode&&t.regionCode===(((u=i.region)==null?void 0:u.regionCode)||"")&&t.regionId===(((d=i.region)==null?void 0:d.regionId)||"")&&t.postcode===i.postcode||r(i)}}function Ot(){return h.lastPayload("checkout/initialized")??null}function Rt(){return h.lastPayload("checkout/updated")??null}function k(){return Rt()??Ot()}function Wn(){var t;const e=k();return!!((t=e==null?void 0:e.shippingAddresses)!=null&&t.length)}function Jn(){const e=k();return(e==null?void 0:e.email)??null}function Zn(e){if(e===void 0){const t=k();return!!(t!=null&&t.isVirtual)}return!!(e!=null&&e.isVirtual)}function er(e){return!e||e.isEmpty}function tr(e){var n;if(!e)return null;const t=e.shippingAddresses||[];return t.length===0?null:(n=t[0])==null?void 0:n.selectedShippingMethod}function nr(e,t="shipping"){var r;return e?(t==="shipping"?(r=e.shippingAddresses)==null?void 0:r[0]:e.billingAddress)??null:null}function rr(e){if(!e)return null;const{selectedPaymentMethod:t}=e;return!t||!(t!=null&&t.code)?null:e.selectedPaymentMethod}function Dt(e,t=!1){var u;const{name:n,ref:r}=e,i=document.forms.namedItem(n);if(!i||i.offsetParent===null)return!0;i.setAttribute("novalidate","");const o=((u=r==null?void 0:r.current)==null?void 0:u.handleValidationSubmit(!1))??i.checkValidity();return!o&&t&&wt(i),o}function ir(e){for(const t of e)if(!Dt(t,!0))return!1;return!0}function or(e){return document.createRange().createContextualFragment(e)}function sr(e){return function(t){return e.querySelector(t)}}function M(e,t,n){if(!e||!n)return;const r=document.head.querySelector(`meta[${n}="${e}"]`);if(!t){r==null||r.remove();return}if(r)r.setAttribute("content",t);else{const i=document.createElement("meta");i.setAttribute(n,e),i.setAttribute("content",t),document.head.appendChild(i)}}function ur(e){M("title",e,"name"),M("description",e,"name"),M("keywords",e,"name"),M("og:description",e,"property"),M("og:title",e,"property"),M("og:url",window.location.href,"property")}const Gt=e=>{var r,i,o;if(!(!(e!=null&&e.id)&&!(e!=null&&e.uid)))return{customerAddressId:e.id,customerAddressUid:e.uid};const n=(r=e.customAttributes)==null?void 0:r.map(({code:u,value:d})=>({code:u,value:String(d)}));return{address:{city:e.city,company:e==null?void 0:e.company,countryCode:e.countryCode,customAttributes:n,fax:e.fax,firstName:e.firstName,lastName:e.lastName,middleName:e.middleName,postcode:e.postcode,prefix:e.prefix,region:(i=e==null?void 0:e.region)==null?void 0:i.regionCode,regionId:(o=e==null?void 0:e.region)==null?void 0:o.regionId,street:e.street,suffix:e.suffix,telephone:e.telephone,vatId:e.vatId,saveInAddressBook:e.saveAddressBook}}},cr=e=>{var t,n,r;return{city:e.city,company:e==null?void 0:e.company,countryCode:(t=e.country)==null?void 0:t.code,customAttributes:e.customAttributes,fax:e.fax,firstName:e.firstName,lastName:e.lastName,middleName:e.middleName,postcode:e.postCode,prefix:e.prefix,region:{regionCode:(n=e.region)==null?void 0:n.code,regionId:(r=e.region)==null?void 0:r.id},street:e.street,suffix:e.suffix,telephone:e.telephone,vatId:e.vatId}};function qt(e){return e.closest("[data-dropin-container]")}function Pt(e){e.focus(),document.activeElement!==e&&e.scrollIntoView({behavior:"smooth"})}function wt(e){const t=qt(e);t&&Pt(t)}var y=(e=>(e.Updates="updates",e.Default="default",e.ShippingEstimate="shippingEstimate",e))(y||{});const x=new Map,B=new Map,S=ie(new Set),Me=new Map;Me.set("updates",e=>{h.emit("checkout/updated",e)});async function $t(e){B.set(e,!0);const t=x.get(e);let n;for(;t.length>0;){const o=t.shift();try{const u=await o.requestFn();o.resolve(u),n=u}catch(u){o.reject(u)}}B.set(e,!1);const r=new Set(S.value);r.delete(e),S.value=r;const i=Me.get(e);i&&n&&i(n)}function xt(e,t="default"){x.has(t)||x.set(t,[]);const n=x.get(t),r=new Promise((o,u)=>{n.push({requestFn:e,resolve:o,reject:u})}),i=new Set(S.value);return i.add(t),S.value=i,B.get(t)||$t(t),r}const ar=oe(()=>S.value.has("updates")),lr=oe(()=>S.value.has("shippingEstimate")),Ut=["sender_email","recipient_email"];function Lt(e){return e.filter(t=>!t.path||!Ut.some(n=>{var r;return((r=t.path)==null?void 0:r.at(-1))===n}))}class Qt extends Error{constructor(t){super(t.map(n=>n.message).join(" ")),this.name="FetchError"}}class A extends Error{constructor(t){super(t),this.name="InvalidInput"}}class E extends A{constructor(t){super(`${t} is required.`)}}class j extends E{constructor(){super("Cart ID")}}class Bt extends A{constructor(){super("Either Cart ID or Quote ID is required.")}}class Ne extends Error{constructor(){super("User is not authenticated")}}class Ft extends E{constructor(){super("Negotiable Quote ID")}}class Ht extends E{constructor(){super("Email")}}class Vt extends E{constructor(){super("Payment method code")}}class Ce extends E{constructor(){super("Shipping address")}}class kt extends E{constructor(){super("Shipping method")}}class Se extends E{constructor(){super("Billing address")}}class jt extends E{constructor(){super("Country Code")}}var R=(e=>(e.INVALID_INPUT="INVALID_INPUT",e.SERVER_ERROR="SERVER_ERROR",e.UNAUTHENTICATED="UNAUTHENTICATED",e.UNKNOWN_ERROR="UNKNOWN_ERROR",e.QUOTE_DATA_ERROR="QUOTE_DATA_ERROR",e.QUOTE_PERMISSION_DENIED="QUOTE_PERMISSION_DENIED",e.PERMISSION_DENIED="PERMISSION_DENIED",e))(R||{});const zt=["PlaceOrderError"],Xt=[{code:"INVALID_INPUT",matches:e=>e instanceof A},{code:"UNAUTHENTICATED",matches:e=>e instanceof Ne},{code:"SERVER_ERROR",matches:e=>!e||typeof e!="object"||!("name"in e)?!1:zt.includes(e.name)}];function dr(e){const t=Xt.find(n=>n.matches(e));return t?t.code:R.UNKNOWN_ERROR}function Kt(e,t){return t.split(".").reduce((n,r)=>n&&n[r]!==void 0?n[r]:void 0,e)}async function g(e){const{defaultValueOnFail:t,options:n,path:r,query:i,queueName:o,transformer:u,type:d}=e;try{const c=async()=>{const{data:p,errors:l}=await rn(i,{method:d==="query"?"GET":"POST",cache:d==="query"?"no-cache":void 0,...n});if(l){const _=Lt(l);if(_.length>0)throw new Qt(_)}let m=Kt(p,r);if(m===void 0)throw new Error(`No data found at path: ${r}`);return u?u(m):m};return d==="mutation"?await xt(c,o):await c()}catch(c){if(t!==void 0)return t;throw c}}const z={EMAIL:/^[a-z0-9,!#$%&'*+/=?^_`{|}~-]+(\.[a-z0-9,!#$%&'*+/=?^_`{|}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i,NOT_EMPTY:/^(?!\s*$).+/},pr=e=>z.EMAIL.test(e),mr=e=>z.NOT_EMPTY.test(e),hr={NOT_EMPTY:z.NOT_EMPTY.source},Yt={email:"",isBillToShipping:void 0,selectedPaymentMethod:null,selectedShippingMethod:null};function gr(e){const n={...h.lastPayload("checkout/values")??Yt,...e};h.emit("checkout/values",n)}function be(e){const t=h.lastPayload("checkout/values");return t&&e in t?t[e]:null}const Wt=`
|
|
75
|
-
query getStoreConfig {
|
|
76
|
-
storeConfig {
|
|
77
|
-
default_country
|
|
78
|
-
is_checkout_agreements_enabled
|
|
79
|
-
is_guest_checkout_enabled
|
|
80
|
-
is_one_page_checkout_enabled
|
|
81
|
-
shopping_cart_display_shipping
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
`,Jt="US",F={defaultCountry:Jt,agreementsEnabled:!0,shoppingCartDisplaySetting:{shipping:N.EXCLUDING_TAX}},Zt=async()=>await g({defaultValueOnFail:F,options:{method:"GET",cache:"no-cache"},path:"storeConfig",query:Wt,transformer:tn,type:"query"}),_r=()=>s.config;function en(e){switch(e){case 1:return N.EXCLUDING_TAX;case 2:return N.INCLUDING_TAX;case 3:return N.INCLUDING_EXCLUDING_TAX;default:return N.EXCLUDING_TAX}}function tn(e){if(!e)return F;const{default_country:t,is_checkout_agreements_enabled:n,shopping_cart_display_shipping:r}=e;return{defaultCountry:t||F.defaultCountry,agreementsEnabled:n,shoppingCartDisplaySetting:{shipping:en(r)}}}const nn=async e=>{var p,l,m,_;const t=s.cartId,n=((p=e==null?void 0:e.criteria)==null?void 0:p.country_code)??((l=s.config)==null?void 0:l.defaultCountry);if(!t)throw new j;if(!n)throw new jt;const{region_id:r,region_name:i,zip:o}=(e==null?void 0:e.criteria)??{},u=r||i?{region_id:typeof r=="string"?parseInt(r,10):r,region_code:i}:void 0,d={country_code:n,...o&&{postcode:o},...u&&{region:{...u.region_id&&{region_id:u.region_id},...u.region_code&&{region_code:u.region_code}}}},c={country_id:n,region:(m=d.region)==null?void 0:m.region_code,region_id:(_=d.region)==null?void 0:_.region_id,postcode:o},a=J(c);return g({options:{variables:{cartId:t,address:d}},path:"estimateShippingMethods",query:Ve,queueName:y.ShippingEstimate,transformer:St,type:"mutation"}).then(f=>{const{defaults:P,shipping:w}=q.getConfig(),X=w!=null&&w.filterOptions?f.filter(w.filterOptions):f,$e=X.length>0,xe=J(c);let K=null;if($e){const T=be("selectedShippingMethod");let O=f.find(Y=>Y.code===(T==null?void 0:T.code)&&Y.carrier.code===(T==null?void 0:T.carrier.code));!O&&(P!=null&&P.selectedShippingMethod)&&(O=P.selectedShippingMethod(f)??void 0),O||(O=f[0]),K=Ct(O)}return h.emit("shipping/estimate",{address:xe,availableShippingMethods:f,shippingMethod:K,success:!0}),X}).catch(f=>{throw h.emit("shipping/estimate",{address:a,shippingMethod:null,availableShippingMethods:[],success:!1}),f})},{setEndpoint:fr,setFetchGraphQlHeader:Ar,removeFetchGraphQlHeader:Er,setFetchGraphQlHeaders:Ir,fetchGraphQl:rn,getConfig:yr}=new Qe().getMethods(),on=`
|
|
85
|
-
fragment BILLING_CART_ADDRESS_FRAGMENT on BillingCartAddress {
|
|
86
|
-
city
|
|
87
|
-
company
|
|
88
|
-
country {
|
|
89
|
-
code
|
|
90
|
-
label
|
|
91
|
-
}
|
|
92
|
-
custom_attributes {
|
|
93
|
-
... on AttributeValue {
|
|
94
|
-
code
|
|
95
|
-
value
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
fax
|
|
99
|
-
firstname
|
|
100
|
-
id
|
|
101
|
-
lastname
|
|
102
|
-
middlename
|
|
103
|
-
postcode
|
|
104
|
-
prefix
|
|
105
|
-
region {
|
|
106
|
-
region_id
|
|
107
|
-
code
|
|
108
|
-
label
|
|
109
|
-
}
|
|
110
|
-
street
|
|
111
|
-
suffix
|
|
112
|
-
telephone
|
|
113
|
-
uid
|
|
114
|
-
vat_id
|
|
115
|
-
}
|
|
116
|
-
`,sn=`
|
|
117
|
-
fragment SHIPPING_CART_ADDRESS_FRAGMENT on ShippingCartAddress {
|
|
118
|
-
available_shipping_methods {
|
|
119
|
-
...AVAILABLE_SHIPPING_METHOD_FRAGMENT
|
|
120
|
-
}
|
|
121
|
-
city
|
|
122
|
-
company
|
|
123
|
-
country {
|
|
124
|
-
code
|
|
125
|
-
label
|
|
126
|
-
}
|
|
127
|
-
custom_attributes {
|
|
128
|
-
... on AttributeValue {
|
|
129
|
-
code
|
|
130
|
-
value
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
fax
|
|
134
|
-
firstname
|
|
135
|
-
id
|
|
136
|
-
lastname
|
|
137
|
-
middlename
|
|
138
|
-
postcode
|
|
139
|
-
prefix
|
|
140
|
-
region {
|
|
141
|
-
region_id
|
|
142
|
-
code
|
|
143
|
-
label
|
|
144
|
-
}
|
|
145
|
-
same_as_billing
|
|
146
|
-
selected_shipping_method {
|
|
147
|
-
...SELECTED_SHIPPING_METHOD_FRAGMENT
|
|
148
|
-
}
|
|
149
|
-
street
|
|
150
|
-
suffix
|
|
151
|
-
telephone
|
|
152
|
-
uid
|
|
153
|
-
vat_id
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
${ce}
|
|
157
|
-
${ae}
|
|
158
|
-
`,ve=`
|
|
159
|
-
fragment AVAILABLE_PAYMENT_METHOD_FRAGMENT on AvailablePaymentMethod {
|
|
160
|
-
code
|
|
161
|
-
title
|
|
162
|
-
}
|
|
163
|
-
`,Oe=`
|
|
164
|
-
fragment SELECTED_PAYMENT_METHOD_FRAGMENT on SelectedPaymentMethod {
|
|
165
|
-
code
|
|
166
|
-
title
|
|
167
|
-
purchase_order_number
|
|
168
|
-
}
|
|
169
|
-
`,I=`
|
|
170
|
-
fragment CHECKOUT_DATA_FRAGMENT on Cart {
|
|
171
|
-
id
|
|
172
|
-
is_virtual
|
|
173
|
-
email
|
|
174
|
-
total_quantity
|
|
175
|
-
billing_address {
|
|
176
|
-
...BILLING_CART_ADDRESS_FRAGMENT
|
|
177
|
-
}
|
|
178
|
-
shipping_addresses {
|
|
179
|
-
...SHIPPING_CART_ADDRESS_FRAGMENT
|
|
180
|
-
}
|
|
181
|
-
available_payment_methods {
|
|
182
|
-
...AVAILABLE_PAYMENT_METHOD_FRAGMENT
|
|
183
|
-
}
|
|
184
|
-
selected_payment_method {
|
|
185
|
-
...SELECTED_PAYMENT_METHOD_FRAGMENT
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
${on}
|
|
190
|
-
${sn}
|
|
191
|
-
${ve}
|
|
192
|
-
${Oe}
|
|
193
|
-
`,un=`
|
|
194
|
-
query getCart($cartId: String!) {
|
|
195
|
-
cart(cart_id: $cartId) {
|
|
196
|
-
...CHECKOUT_DATA_FRAGMENT
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
${I}
|
|
201
|
-
`,cn=`
|
|
202
|
-
query getCustomerCart {
|
|
203
|
-
cart: customerCart {
|
|
204
|
-
...CHECKOUT_DATA_FRAGMENT
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
${I}
|
|
209
|
-
`,Re=async()=>{const e=s.cartId,t=s.authenticated===!1,n=t?un:cn,r=t?{cartId:e}:{};if(t&&!e)throw new j;return await g({type:"query",query:n,options:{method:"POST",cache:"no-cache",variables:r},path:"cart",transformer:b})},an=`
|
|
210
|
-
query GET_CHECKOUT_AGREEMENTS {
|
|
211
|
-
checkoutAgreements {
|
|
212
|
-
agreement_id
|
|
213
|
-
checkbox_text
|
|
214
|
-
content
|
|
215
|
-
content_height
|
|
216
|
-
is_html
|
|
217
|
-
mode
|
|
218
|
-
name
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
`,Tr=async()=>await g({defaultValueOnFail:[],options:{method:"GET",cache:"no-cache"},path:"checkoutAgreements",query:an,transformer:ot,type:"query"}),ln=`
|
|
222
|
-
query getCompanyCredit {
|
|
223
|
-
company {
|
|
224
|
-
credit {
|
|
225
|
-
exceed_limit
|
|
226
|
-
available_credit {
|
|
227
|
-
value
|
|
228
|
-
currency
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
`,Mr=async()=>await g({type:"query",query:ln,options:{method:"GET",cache:"no-cache"},path:"company.credit",transformer:nt,defaultValueOnFail:null}),dn=`
|
|
234
|
-
fragment CUSTOMER_FRAGMENT on Customer {
|
|
235
|
-
firstname
|
|
236
|
-
lastname
|
|
237
|
-
email
|
|
238
|
-
}
|
|
239
|
-
`,pn=`
|
|
240
|
-
query getCustomer {
|
|
241
|
-
customer {
|
|
242
|
-
...CUSTOMER_FRAGMENT
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
${dn}
|
|
247
|
-
`,Nr=async()=>s.authenticated?await g({options:{method:"GET",cache:"no-cache"},path:"customer",query:pn,transformer:st,type:"query"}):null,mn=`
|
|
248
|
-
fragment NEGOTIABLE_QUOTE_BILLING_ADDRESS_FRAGMENT on NegotiableQuoteBillingAddress {
|
|
249
|
-
city
|
|
250
|
-
company
|
|
251
|
-
country {
|
|
252
|
-
code
|
|
253
|
-
label
|
|
254
|
-
}
|
|
255
|
-
custom_attributes {
|
|
256
|
-
... on AttributeValue {
|
|
257
|
-
code
|
|
258
|
-
value
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
customer_address_uid
|
|
262
|
-
fax
|
|
263
|
-
firstname
|
|
264
|
-
lastname
|
|
265
|
-
middlename
|
|
266
|
-
postcode
|
|
267
|
-
prefix
|
|
268
|
-
region {
|
|
269
|
-
region_id
|
|
270
|
-
code
|
|
271
|
-
label
|
|
272
|
-
}
|
|
273
|
-
street
|
|
274
|
-
suffix
|
|
275
|
-
telephone
|
|
276
|
-
uid
|
|
277
|
-
vat_id
|
|
278
|
-
}
|
|
279
|
-
`,hn=`
|
|
280
|
-
fragment NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_FRAGMENT on NegotiableQuoteShippingAddress {
|
|
281
|
-
available_shipping_methods {
|
|
282
|
-
...AVAILABLE_SHIPPING_METHOD_FRAGMENT
|
|
283
|
-
}
|
|
284
|
-
city
|
|
285
|
-
company
|
|
286
|
-
country {
|
|
287
|
-
code
|
|
288
|
-
label
|
|
289
|
-
}
|
|
290
|
-
custom_attributes {
|
|
291
|
-
... on AttributeValue {
|
|
292
|
-
code
|
|
293
|
-
value
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
customer_address_uid
|
|
297
|
-
fax
|
|
298
|
-
firstname
|
|
299
|
-
lastname
|
|
300
|
-
middlename
|
|
301
|
-
postcode
|
|
302
|
-
prefix
|
|
303
|
-
region {
|
|
304
|
-
region_id
|
|
305
|
-
code
|
|
306
|
-
label
|
|
307
|
-
}
|
|
308
|
-
selected_shipping_method {
|
|
309
|
-
...SELECTED_SHIPPING_METHOD_FRAGMENT
|
|
310
|
-
}
|
|
311
|
-
street
|
|
312
|
-
suffix
|
|
313
|
-
telephone
|
|
314
|
-
uid
|
|
315
|
-
vat_id
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
${ce}
|
|
319
|
-
${ae}
|
|
320
|
-
`,v=`
|
|
321
|
-
fragment NEGOTIABLE_QUOTE_FRAGMENT on NegotiableQuote {
|
|
322
|
-
available_payment_methods {
|
|
323
|
-
...AVAILABLE_PAYMENT_METHOD_FRAGMENT
|
|
324
|
-
}
|
|
325
|
-
billing_address {
|
|
326
|
-
...NEGOTIABLE_QUOTE_BILLING_ADDRESS_FRAGMENT
|
|
327
|
-
}
|
|
328
|
-
email
|
|
329
|
-
is_virtual
|
|
330
|
-
name
|
|
331
|
-
selected_payment_method {
|
|
332
|
-
...SELECTED_PAYMENT_METHOD_FRAGMENT
|
|
333
|
-
}
|
|
334
|
-
shipping_addresses {
|
|
335
|
-
...NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_FRAGMENT
|
|
336
|
-
}
|
|
337
|
-
status
|
|
338
|
-
total_quantity
|
|
339
|
-
uid
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
${mn}
|
|
343
|
-
${hn}
|
|
344
|
-
${ve}
|
|
345
|
-
${Oe}
|
|
346
|
-
`,gn=`
|
|
347
|
-
query getNegotiableQuote($quoteId: ID!) {
|
|
348
|
-
negotiableQuote(uid: $quoteId) {
|
|
349
|
-
...NEGOTIABLE_QUOTE_FRAGMENT
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
${v}
|
|
354
|
-
`,De=async(e={})=>{const t=e.uid??s.quoteId;if(s.authenticated===!1)throw new Ne;if(!t)throw new Ft;return await g({type:"query",query:gn,options:{method:"GET",cache:"no-cache",variables:{quoteId:t}},path:"negotiableQuote",transformer:G})},$={eager:!0},_n=e=>{var u,d;const t=((d=(u=e==null?void 0:e.features)==null?void 0:u.b2b)==null?void 0:d.quotes)??!1;return[["authenticated",(c=!1)=>{var p,l,m;if(Fe(c),!t||c)return;const a=(m=(l=(p=e==null?void 0:e.features)==null?void 0:p.b2b)==null?void 0:l.routeLogin)==null?void 0:m.call(l);a&&window.location.assign(a)},$],...t?[["quote-management/quote-data/initialized",c=>{var a,p,l,m;if(!c.quote.canCheckout){const _=((m=(l=(p=(a=e==null?void 0:e.langDefinitions)==null?void 0:a.default)==null?void 0:p.Checkout)==null?void 0:l.Quote)==null?void 0:m.permissionDenied)||"You do not have permission to checkout with this quote.";h.emit("checkout/error",{message:_,code:R.QUOTE_PERMISSION_DENIED});return}H(c.quote)},$],["quote-management/quote-data/error",()=>{var a,p,l,m;const c=((m=(l=(p=(a=e==null?void 0:e.langDefinitions)==null?void 0:a.default)==null?void 0:p.Checkout)==null?void 0:l.Quote)==null?void 0:m.dataError)||"We were unable to retrieve the quote data. Please try again later.";h.emit("checkout/error",{message:c,code:R.QUOTE_DATA_ERROR})}]]:[["cart/initialized",H,$],["cart/reset",Pe],["cart/updated",we],["auth/permissions",c=>{var a,p,l,m;if(c.admin!==!0&&!c["Magento_Sales::place_order"]){const _=((m=(l=(p=(a=e==null?void 0:e.langDefinitions)==null?void 0:a.default)==null?void 0:p.Checkout)==null?void 0:l.ServerError)==null?void 0:m.permissionDenied)||"You do not have permission to complete checkout. Please contact your administrator for assistance.";h.emit("checkout/error",{message:_,code:R.PERMISSION_DENIED})}},$]]].map(([c,a,p])=>h.on(c,a,p))},fn=new URL(window.location.href),An=fn.searchParams.get("quoteId");s.quoteId=An;const Ge=new Ue({init:async(e={})=>{Ge.config.setConfig(Le({defaults:{isBillToShipping:!0,selectedShippingMethod:t=>t.length>0?t[0]:null},features:{b2b:{quotes:!1}}},e))},listeners:_n}),q=Ge.config,qe=e=>"id"in e,En=async e=>{try{return qe(e)?(s.cartId=e.id,s.quoteId=null,await Re()??null):(s.cartId=null,s.quoteId=e.uid,await De()??null)}catch(t){return console.error("Checkout initialization failed:",t),null}},H=async e=>{if(s.initialized){await we(e);return}s.config||(s.config=await Zt());const t=e?await En(e):null;s.initialized=!0,h.emit("checkout/initialized",t)},In=`
|
|
355
|
-
query isEmailAvailable($email: String!) {
|
|
356
|
-
isEmailAvailable(email: $email) {
|
|
357
|
-
is_email_available
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
`,Cr=async e=>{if(!e)throw new Ht;return await g({options:{method:"GET",cache:"no-cache",variables:{email:e}},path:"isEmailAvailable",query:In,transformer:ut,type:"query"})},Pe=()=>{s.initialized&&(s.cartId=null,s.quoteId=null,h.emit("checkout/updated",null))},yn=`
|
|
361
|
-
mutation setBillingAddress(
|
|
362
|
-
$cartId: String!
|
|
363
|
-
$billingAddress: BillingAddressInput!
|
|
364
|
-
) {
|
|
365
|
-
setBillingAddressOnCart(
|
|
366
|
-
input: { cart_id: $cartId, billing_address: $billingAddress }
|
|
367
|
-
) {
|
|
368
|
-
cart {
|
|
369
|
-
...CHECKOUT_DATA_FRAGMENT
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
${I}
|
|
375
|
-
`,Tn=`
|
|
376
|
-
mutation setBillingAddressOnQuote(
|
|
377
|
-
$quoteId: ID!
|
|
378
|
-
$billingAddress: NegotiableQuoteBillingAddressInput!
|
|
379
|
-
) {
|
|
380
|
-
setNegotiableQuoteBillingAddress(
|
|
381
|
-
input: { quote_uid: $quoteId, billing_address: $billingAddress }
|
|
382
|
-
) {
|
|
383
|
-
quote {
|
|
384
|
-
...NEGOTIABLE_QUOTE_FRAGMENT
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
${v}
|
|
390
|
-
`,L=()=>{const{cartId:e,quoteId:t}=s;if(!e&&!t)throw new Bt},ee=(e,t,n,r,i,o)=>async u=>await g({type:"mutation",query:n,options:{variables:{[t]:e,billingAddress:i(u)}},path:o,queueName:y.Updates,transformer:r}),Mn=({address:e,customerAddressId:t,customerAddressUid:n,sameAsShipping:r=!1})=>{if(!t&&n)throw new A("customerAddressUid is not supported");if(!r&&!t&&!e)throw new Se},Nn=({address:e,customerAddressId:t,customerAddressUid:n,sameAsShipping:r=!1})=>{if(!n&&t)throw new A("customerAddressId is not supported");if(!r&&!n&&!e)throw new Se},Cn=e=>{const t=!!s.cartId,n=!!s.quoteId;t?Mn(e):n&&Nn(e)},Sn=async e=>(L(),Cn(e),await(!!s.cartId?ee(s.cartId,"cartId",yn,b,We,"setBillingAddressOnCart.cart"):ee(s.quoteId,"quoteId",Tn,G,Je,"setNegotiableQuoteBillingAddress.quote"))(e)),bn=`
|
|
391
|
-
mutation setGuestEmail($cartId: String!, $email: String!) {
|
|
392
|
-
setGuestEmailOnCart(input: { cart_id: $cartId, email: $email }) {
|
|
393
|
-
cart {
|
|
394
|
-
...CHECKOUT_DATA_FRAGMENT
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
${I}
|
|
400
|
-
`,Sr=async e=>{const t=s.cartId;if(!t)throw new j;return await g({options:{variables:{cartId:t,email:e}},path:"setGuestEmailOnCart.cart",query:bn,queueName:y.Updates,transformer:b,type:"mutation"})},vn=`
|
|
401
|
-
mutation setPaymentMethodOnCart(
|
|
402
|
-
$cartId: String!
|
|
403
|
-
$input: PaymentMethodInput!
|
|
404
|
-
) {
|
|
405
|
-
setPaymentMethodOnCart(
|
|
406
|
-
input: { cart_id: $cartId, payment_method: $input }
|
|
407
|
-
) {
|
|
408
|
-
cart {
|
|
409
|
-
...CHECKOUT_DATA_FRAGMENT
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
${I}
|
|
415
|
-
`,On=`
|
|
416
|
-
mutation setPaymentMethodOnQuote(
|
|
417
|
-
$quoteId: ID!
|
|
418
|
-
$input: NegotiableQuotePaymentMethodInput!
|
|
419
|
-
) {
|
|
420
|
-
setNegotiableQuotePaymentMethod(
|
|
421
|
-
input: { quote_uid: $quoteId, payment_method: $input }
|
|
422
|
-
) {
|
|
423
|
-
quote {
|
|
424
|
-
...NEGOTIABLE_QUOTE_FRAGMENT
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
${v}
|
|
430
|
-
`,te=(e,t,n,r,i,o)=>async u=>await g({type:"mutation",query:n,options:{variables:{[t]:e,input:i(u)}},path:o,queueName:y.Updates,transformer:r}),Rn=e=>{if(!e.code)throw new Vt},br=async e=>(L(),Rn(e),await(!!s.cartId?te(s.cartId,"cartId",vn,b,ke,"setPaymentMethodOnCart.cart"):te(s.quoteId,"quoteId",On,G,je,"setNegotiableQuotePaymentMethod.quote"))(e)),Dn=`
|
|
431
|
-
mutation setShippingAddressOnCartAndUseAsBilling(
|
|
432
|
-
$cartId: String!
|
|
433
|
-
$shippingAddress: ShippingAddressInput!
|
|
434
|
-
) {
|
|
435
|
-
setShippingAddressesOnCart(
|
|
436
|
-
input: { cart_id: $cartId, shipping_addresses: [$shippingAddress] }
|
|
437
|
-
) {
|
|
438
|
-
cart {
|
|
439
|
-
id
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
setBillingAddressOnCart(
|
|
444
|
-
input: { cart_id: $cartId, billing_address: { same_as_shipping: true } }
|
|
445
|
-
) {
|
|
446
|
-
cart {
|
|
447
|
-
...CHECKOUT_DATA_FRAGMENT
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
${I}
|
|
453
|
-
`,Gn=`
|
|
454
|
-
mutation setShippingAddressOnCart(
|
|
455
|
-
$cartId: String!
|
|
456
|
-
$shippingAddress: ShippingAddressInput!
|
|
457
|
-
) {
|
|
458
|
-
setShippingAddressesOnCart(
|
|
459
|
-
input: { cart_id: $cartId, shipping_addresses: [$shippingAddress] }
|
|
460
|
-
) {
|
|
461
|
-
cart {
|
|
462
|
-
...CHECKOUT_DATA_FRAGMENT
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
${I}
|
|
468
|
-
`,qn=`
|
|
469
|
-
mutation setShippingAddressOnQuote(
|
|
470
|
-
$quoteId: ID!
|
|
471
|
-
$shippingAddress: NegotiableQuoteShippingAddressInput!
|
|
472
|
-
) {
|
|
473
|
-
setNegotiableQuoteShippingAddress(
|
|
474
|
-
input: { quote_uid: $quoteId, shipping_addresses: [$shippingAddress] }
|
|
475
|
-
) {
|
|
476
|
-
quote {
|
|
477
|
-
...NEGOTIABLE_QUOTE_FRAGMENT
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
${v}
|
|
483
|
-
`,Pn=`
|
|
484
|
-
mutation setShippingAddressOnQuoteAndUseAsBilling(
|
|
485
|
-
$quoteId: ID!
|
|
486
|
-
$shippingAddress: NegotiableQuoteShippingAddressInput!
|
|
487
|
-
) {
|
|
488
|
-
setNegotiableQuoteShippingAddress(
|
|
489
|
-
input: { quote_uid: $quoteId, shipping_addresses: [$shippingAddress] }
|
|
490
|
-
) {
|
|
491
|
-
quote {
|
|
492
|
-
uid
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
setNegotiableQuoteBillingAddress(
|
|
497
|
-
input: {
|
|
498
|
-
quote_uid: $quoteId
|
|
499
|
-
billing_address: { same_as_shipping: true }
|
|
500
|
-
}
|
|
501
|
-
) {
|
|
502
|
-
quote {
|
|
503
|
-
...NEGOTIABLE_QUOTE_FRAGMENT
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
${v}
|
|
509
|
-
`,wn=({address:e,customerAddressId:t,customerAddressUid:n,pickupLocationCode:r})=>{if(!t&&n)throw new A("customerAddressUid is not supported");if(!t&&!r&&!e)throw new Ce},$n=({address:e,customerAddressId:t,customerAddressUid:n,pickupLocationCode:r})=>{if(r)throw new A("pickup location is not supported in quotes");if(!n&&t)throw new A("customerAddressId is not supported in quotes");if(!n&&!e)throw new Ce},xn=e=>{const t=!!s.cartId,n=!!s.quoteId;t?wn(e):n&&$n(e)},ne=(e,t,n,r,i,o)=>async u=>await g({type:"mutation",query:n,options:{variables:{[t]:e,shippingAddress:i(u)}},path:o,queueName:y.Updates,transformer:r}),Un=async e=>{L(),xn(e);const{defaults:t}=q.getConfig(),n=be("isBillToShipping")??(t==null?void 0:t.isBillToShipping);return await(!!s.cartId?ne(s.cartId,"cartId",n?Dn:Gn,b,Ke,n?"setBillingAddressOnCart.cart":"setShippingAddressesOnCart.cart"):ne(s.quoteId,"quoteId",n?Pn:qn,G,Ye,n?"setNegotiableQuoteBillingAddress.quote":"setNegotiableQuoteShippingAddress.quote"))(e)},Ln=`
|
|
510
|
-
mutation setShippingMethodsOnCart(
|
|
511
|
-
$cartId: String!
|
|
512
|
-
$shippingMethods: [ShippingMethodInput]!
|
|
513
|
-
) {
|
|
514
|
-
setShippingMethodsOnCart(
|
|
515
|
-
input: { cart_id: $cartId, shipping_methods: $shippingMethods }
|
|
516
|
-
) {
|
|
517
|
-
cart {
|
|
518
|
-
...CHECKOUT_DATA_FRAGMENT
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
${I}
|
|
524
|
-
`,Qn=`
|
|
525
|
-
mutation setShippingMethodsOnQuote(
|
|
526
|
-
$quoteId: ID!
|
|
527
|
-
$shippingMethods: [ShippingMethodInput]!
|
|
528
|
-
) {
|
|
529
|
-
setNegotiableQuoteShippingMethods(
|
|
530
|
-
input: { quote_uid: $quoteId, shipping_methods: $shippingMethods }
|
|
531
|
-
) {
|
|
532
|
-
quote {
|
|
533
|
-
...NEGOTIABLE_QUOTE_FRAGMENT
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
${v}
|
|
539
|
-
`,re=(e,t,n,r,i)=>async o=>await g({type:"mutation",query:n,queueName:y.Updates,options:{variables:{[t]:e,shippingMethods:Xe(o)}},path:i,transformer:r}),Bn=e=>{if(!Array.isArray(e)||e.length===0)throw new kt},vr=async e=>(L(),Bn(e),await(!!s.cartId?re(s.cartId,"cartId",Ln,b,"setShippingMethodsOnCart.cart"):re(s.quoteId,"quoteId",Qn,G,"setNegotiableQuoteShippingMethods.quote"))(e)),Fn=async e=>{try{return qe(e)?(s.cartId=e.id,s.quoteId=null,await Re()??null):(s.cartId=null,s.quoteId=e.uid,await De()??null)}catch(t){return console.error("Checkout synchronization failed:",t),null}},we=async e=>{if(!s.initialized)return H(e);if(e===null){Pe();return}const t=await Fn(e);h.emit("checkout/updated",t)};export{ve as A,on as B,I as C,Jt as DEFAULT_COUNTRY,He as E,mn as N,sn as S,F as STORE_CONFIG_DEFAULTS,N as T,dn as a,Fe as authenticateCustomer,hn as b,v as c,q as config,or as createFragment,M as createMetaTag,sr as createScopedSelector,Oe as d,ce as e,Yn as estimateShippingCost,nn as estimateShippingMethods,ae as f,rn as fetchGraphQl,Rt as g,Re as getCart,nr as getCartAddress,rr as getCartPaymentMethod,tr as getCartShippingMethod,Tr as getCheckoutAgreements,Mr as getCompanyCredit,yr as getConfig,Nr as getCustomer,De as getNegotiableQuote,qt as getParentContainer,Zt as getStoreConfig,_r as getStoreConfigCache,hr as h,ge as i,Ge as initialize,H as initializeCheckout,Cr as isEmailAvailable,er as isEmptyCart,Zn as isVirtualCart,ar as j,lr as k,Wn as l,be as m,gr as n,zn as o,dr as p,R as q,Z as r,Er as removeFetchGraphQlHeader,Pe as resetCheckout,s,Pt as scrollToElement,wt as scrollToParentContainer,Kn as setAddressOnCart,Sn as setBillingAddress,fr as setEndpoint,Ar as setFetchGraphQlHeader,Ir as setFetchGraphQlHeaders,Sr as setGuestEmailOnCart,ur as setMetaTags,br as setPaymentMethod,Un as setShippingAddress,vr as setShippingMethods,vr as setShippingMethodsOnCart,we as synchronizeCheckout,Ct as t,Gt as transformAddressFormValuesToAddressInput,cr as transformCartAddressToFormValues,pr as u,mr as v,Dt as validateForm,ir as validateForms,Jn as w,Xn as x,Ee as y};
|
|
3
|
+
import{setShippingAddress as C,setBillingAddress as d,estimateShippingMethods as A}from"../api.js";import{debounce as g}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import{i as l}from"../chunks/ui.js";import{i as y}from"../chunks/components.js";import{j as U,s as G}from"../chunks/components.js";import{b as J,c as K,g as L,a as Q,i as W}from"../chunks/events.js";import"@dropins/tools/signals.js";import"../fragments.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/preact-hooks.js";const h=e=>{var r,o,s;if(!(!(e!=null&&e.id)&&!(e!=null&&e.uid)))return{customerAddressId:e.id,customerAddressUid:e.uid};const n=(r=e.customAttributes)==null?void 0:r.map(({code:i,value:c})=>({code:i,value:String(c)}));return{address:{city:e.city,company:e==null?void 0:e.company,countryCode:e.countryCode,customAttributes:n,fax:e.fax,firstName:e.firstName,lastName:e.lastName,middleName:e.middleName,postcode:e.postcode,prefix:e.prefix,region:(o=e==null?void 0:e.region)==null?void 0:o.regionCode,regionId:(s=e==null?void 0:e.region)==null?void 0:s.regionId,street:e.street,suffix:e.suffix,telephone:e.telephone,vatId:e.vatId,saveInAddressBook:e.saveAddressBook}}},q=e=>{var t,n,r;return{city:e.city,company:e==null?void 0:e.company,countryCode:(t=e.country)==null?void 0:t.code,customAttributes:e.customAttributes,fax:e.fax,firstName:e.firstName,lastName:e.lastName,middleName:e.middleName,postcode:e.postCode,prefix:e.prefix,region:{regionCode:(n=e.region)==null?void 0:n.code,regionId:(r=e.region)==null?void 0:r.id},street:e.street,suffix:e.suffix,telephone:e.telephone,vatId:e.vatId}};let m=0;function B({type:e="shipping",debounceMs:t=0}){const n=e==="shipping"?C:d,r=g(o=>{m+=1,n(o).catch(console.error).finally(()=>{m-=1,m===0&&(l.value=!1)})},t);return({data:o,isDataValid:s})=>{if(!s)return;l.value=!0;const i=h(o);r(i)}}function R({debounceMs:e=0}){let t={},n=!1;const r=g(o=>{var i,c,p,f;if(n)return;const s={country_code:o.countryCode,region_name:String(((i=o.region)==null?void 0:i.regionCode)||""),region_id:String(((c=o.region)==null?void 0:c.regionId)||""),zip:o.postcode};A({criteria:s}),t={countryCode:o.countryCode,regionCode:((p=o.region)==null?void 0:p.regionCode)||"",regionId:((f=o.region)==null?void 0:f.regionId)||"",postcode:o.postcode}},e);return({data:o,isDataValid:s})=>{var i,c;if(s){n=!0;return}t.countryCode===o.countryCode&&t.regionCode===(((i=o.region)==null?void 0:i.regionCode)||"")&&t.regionId===(((c=o.region)==null?void 0:c.regionId)||"")&&t.postcode===o.postcode||r(o)}}function I(e,t=!1){var i;const{name:n,ref:r}=e,o=document.forms.namedItem(n);if(!o||o.offsetParent===null)return!0;o.setAttribute("novalidate","");const s=((i=r==null?void 0:r.current)==null?void 0:i.handleValidationSubmit(!1))??o.checkValidity();return!s&&t&&y(o),s}function _(e){for(const t of e)if(!I(t,!0))return!1;return!0}function D(e){return document.createRange().createContextualFragment(e)}function $(e){return function(t){return e.querySelector(t)}}function u(e,t,n){if(!e||!n)return;const r=document.head.querySelector(`meta[${n}="${e}"]`);if(!t){r==null||r.remove();return}if(r)r.setAttribute("content",t);else{const o=document.createElement("meta");o.setAttribute(n,e),o.setAttribute("content",t),document.head.appendChild(o)}}function j(e){u("title",e,"name"),u("description",e,"name"),u("keywords",e,"name"),u("og:description",e,"property"),u("og:title",e,"property"),u("og:url",window.location.href,"property")}export{D as createFragment,u as createMetaTag,$ as createScopedSelector,R as estimateShippingCost,J as getCartAddress,K as getCartPaymentMethod,L as getCartShippingMethod,U as getParentContainer,Q as isEmptyCart,W as isVirtualCart,G as scrollToElement,y as scrollToParentContainer,B as setAddressOnCart,j as setMetaTags,h as transformAddressFormValuesToAddressInput,q as transformCartAddressToFormValues,I as validateForm,_ as validateForms};
|
|
540
4
|
//# sourceMappingURL=utils.js.map
|