PageSourceSearch

https://filofax.com/cdn/shopifycloud/checkout-web/assets/c1/embed-2025-10.CqLrMBTc.js

js filofax.com collected 2026-09-25 20:42:15 UTC 13,506 bytes, 1 lines download raw bytes

1import{j as E}from"./esnext-vendor.B9Da21W6.js";import{dj as v,dk as m}from"./addresses-is-address-empty.Bn2lNY_L.js";import{g as x}from"./proposal-delegated-payment-instrument.Gc2rhfd3.js";import{c as O}from"./graphql-PaymentSessionMutation.CAXCwUvV.js";import{S as D}from"./app.DbSrjjlA.js";import{c as h,i as j,P as R}from"./embed-browser.CEXD5vfZ.js";import{B as z}from"./legacy-client.4Pk7vtv3.js";import{g as G}from"./shared-embed-client-shared.Cdh2Jybq.js";import"./hooks-useShopPayExternalAppContext.DWwMuRnz.js";import"./embed-deferred.B7xD-_a4.js";function q(t){if(!t||typeof t!="object")return!1;const s=t.delivery;if(!s||typeof s!="object")return!1;const r=s.addresses;if(!Array.isArray(r)||r.length===0)return!1;const a=r[0]?.address;return a!==null&&typeof a=="object"}function f(t){if(!t||typeof t!="object")return!1;const e=t,s="cart"in e,r="errors"in e;if(!s&&!r||s&&(e.cart===null||typeof e.cart!="object"))return!1;if(r){if(!Array.isArray(e.errors))return!1;for(const o of e.errors)if(!o||typeof o!="object"||!("code"in o)||!("message"in o)||typeof o.code!="string"||typeof o.message!="string")return!1}return!0}class U extends D{constructor(e,s){super("checkoutSessionIdentifier is required but was not available. This may indicate the GraphQL session field was not queried or the response has not been received.",{metadata:{sourceId:e,sourceType:s}}),this.sourceId=e,this.sourceType=s,this.name="MissingCheckoutSessionIdError",this.unactionable=!0}}function H(t){const{i18n:{locale:e},shop:{merchantPolicies:s=[]}}=t,r=y(t),o=s.find(l=>l.handle==="terms-of-service"),a=s.find(l=>l.handle==="privacy-policy"),d=o?.url||a?.url?{...o?.url&&{termsOfService:o.url},...a?.url&&{privacyPolicy:a.url}}:void 0;return{jsonrpc:"2.0",method:"checkout.start",params:{locale:e,cart:r,...d&&{policies:d}}}}function F(t){const{checkout:e,source:{sourceId:s}}=t,r=e.latestReceipt.value;return{jsonrpc:"2.0",method:"checkout.complete",params:{cart:L(r,s),orderConfirmation:{url:r.confirmationPage.url,order:{id:r.orderIdentity.id},number:r.orderIdentity.buyerIdentifier??void 0,isFirstOrder:r.isFirstOrder??!0}}}}function K(t,e,s=h()){const{addressType:r}=t,o=I(e.checkout.proposal);return{jsonrpc:"2.0",id:s,method:"checkout.addressChangeRequested",params:{addressType:r,selectedAddress:Z(o)}}}function V(t,e,s=h()){const{addressType:r}=t,o=y(e);return{jsonrpc:"2.0",id:s,method:"checkout.addressChangeStart",params:{addressType:r,cart:o}}}function Y(t,e=h()){const s=y(t);return{jsonrpc:"2.0",id:e,method:"checkout.paymentMethodChangeStart",params:{cart:s}}}function B(t,e=h()){const{source:{sourceId:s,checkoutSessionIdentifier:r}}=t,o=y(t);if(!r)throw new U(s,"checkout.submitStart");return{jsonrpc:"2.0",id:e,method:"checkout.submitStart",params:{cart:o,sessionId:r}}}function J(t){return{jsonrpc:"2.0",method:"checkout.error",params:{code:t.code,message:t.message}}}function I(t){const e=t.negotiated.value,s=e.shippingAddress,r=t.proposed.shippingAddress.value,o=e.deliveryNext?.status==="unavailable",a=v(r),d=!s||v(s);if(!(a&&d))return o&&d?r:s}function y(t){const{checkout:e,shop:{domain:s},negotiationContext:r}=t,o=e.proposal.negotiated.value,{merchandiseLines:a,subtotal:d,total:l,discountLines:k,contactInfo:g,buyerIdentity:c,paymentMethods:T}=o,i=I(e.proposal),u=T?.find(b=>b.type==="wallet"&&b.name==="GOOGLE_PAY");return{id:t.source.sourceId,lines:S(a?.lines),cost:{subtotalAmount:n(d),totalAmount:n(l)},buyerIdentity:{email:g?.email,phone:g?.phone,customer:c?.customerProfile?.id?{id:c.customerProfile.id,firstName:c.customerProfile.firstName||void 0,lastName:c.customerProfile.lastName||void 0,email:c.customerProfile.email||void 0,phone:c.customerProfile.phone||void 0}:void 0,countryCode:c?.countryCode||i?.countryCode},deliveryGroups:w(o.deliveryNext,i),delivery:{addresses:i?[{address:{address1:i.address1,address2:i.address2,city:i.city,countryCode:i.countryCode,provinceCode:i.zoneCode,zip:i.postalCode,firstName:i.firstName,lastName:i.lastName,phone:i.phone,company:i.company},oneTimeUse:i.oneTimeUse||!1,selected:!0}]:[]},discountCodes:M(o.discountLines?.lines),appliedGiftCards:_(o.paymentLines?.lines),discountAllocations:P(k?.lines||[]),payment:{methods:r?.delegatedPaymentInstrument?.value?[{type:"creditCard",instruments:[{externalReferenceId:x(r.delegatedPaymentInstrument.value)??""}]}]:[],...u?{handlers:[{id:"gpay",name:"com.google.pay",config:{api_version:2,api_version_minor:0,allowed_payment_methods:[{type:"CARD",parameters:{allowed_auth_methods:u.allowedAuthMethods,allowed_card_networks:u.allowedCardNetworks},tokenization_specification:{type:"PAYMENT_GATEWAY",parameters:{gateway:u.gateway,gateway_merchant_id:u.gatewayMerchantId}}}],merchant_info:{merchant_name:"shopify",merchant_id:u.merchantId,merchant_origin:s,auth_jwt:u.authJwt}}}]}:void 0}}}function L(t,e){const s=t.purchaseOrder,{shippingAddress:r,billingAddress:o}=s,a=o||r;return{id:e,lines:S(s.merchandiseLines?.lines),cost:{subtotalAmount:n(t.subtotal),totalAmount:n(t.checkoutTotal)},buyerIdentity:{email:s.email,phone:s.phone,customer:t.customerId?{id:t.customerId,email:s.email,phone:s.phone,firstName:a?.firstName,lastName:a?.lastName}:void 0,countryCode:a?.countryCode},deliveryGroups:w(s.deliveryNext,r),delivery:r?{addresses:[{address:{address1:r.address1,address2:r.address2,city:r.city,countryCode:r.countryCode,provinceCode:r.zoneCode,zip:r.postalCode,firstName:r.firstName,lastName:r.lastName,phone:r.phone,company:r.company},oneTimeUse:r.oneTimeUse||!1,selected:!0}]}:{addresses:[]},discountCodes:M(t.discountLines?.lines),appliedGiftCards:_(t.purchaseOrder.paymentLines),discountAllocations:P(t.discountLines?.lines),payment:{methods:[],...X(t.purchaseOrder.paymentLines)}}}const W={shopify_installments:"shop_pay",paypal_express:"paypal",amazon_pay_classic:"amazon_pay"};function Q(t){const e=t.toLowerCase();return W[e]??e}function X(t){const e=t?.find(o=>o.method.type==="wallet");if(e)return{expressCheckout:{wallet:Q(e.method.name)}};const s=t?.find(o=>o.method.type==="walletsPlatformPaymentMethod");if(s)return{expressCheckout:{wallet:s.method.name}};if(t?.some(o=>o.method.type==="redeemable"&&o.method.redemptionSource==="SHOP_CASH"))return{expressCheckout:{wallet:"shop_pay"}}}function Z(t){if(t)return{address1:t.address1,address2:t.address2,city:t.city,company:t.company,countryCode:t.countryCode,firstName:t.firstName,lastName:t.lastName,phone:t.phone,provinceCode:t.zoneCode,zip:t.postalCode}}function $(t){return t.status!=="available"||!t.methods?[]:t.methods.map(e=>
1({code:e.code,title:e.title,description:e.description,handle:e.handle,estimatedCost:n(e.cost),deliveryMethodType:A(e.methodType)}))}function ee(t){if(t.status!=="available"||!t.methods||!t.selectedDeliveryMethodHandle)return;const e=t.methods.find(s=>s.handle===t.selectedDeliveryMethodHandle);if(e)return{code:e.code,title:e.title,description:e.description,handle:e.handle,estimatedCost:n(e.cost),deliveryMethodType:A(e.methodType)}}function A(t){switch(t){case"SHIPPING":return"SHIPPING";case"PICK_UP":return"PICKUP";case"PICKUP_POINT":return"PICKUP_POINT";case"LOCAL":return"LOCAL";case"NONE":return"NONE";case"RETAIL":return"PICKUP";default:return"SHIPPING"}}function P(t){return t?t.filter(e=>e.discount&&O(e.discount)&&e.discount.presentationLevel==="CART").map(e=>({discountedAmount:n(e.amount),discountApplication:te(e),targetType:C(e.discount.targetType)})):[]}function te(t){return{allocationMethod:t.discount.targetSelection==="ALL"?"ACROSS":"EACH",targetSelection:t.discount.targetSelection,targetType:C(t.discount.targetType),value:N(t.discount.value)}}function C(t){return t==="DELIVERYLINE"?"SHIPPING_LINE":"LINE_ITEM"}function n(t){return!t||typeof t!="object"?{amount:"0.00",currencyCode:"USD"}:{amount:t.amount.toFixed(2),currencyCode:t.currencyCode}}function S(t){return t?t.flatMap(e=>e.lineAllocations.map(s=>({id:s.stableId,quantity:s.quantity,merchandise:{id:e.id||e.stableId,title:e.title,product:{id:e.productId||"",title:e.title},image:e.image?{url:e.image.url||"",altText:e.image.altText}:void 0,selectedOptions:e.options?e.options.map(({name:r,value:o})=>({name:r,value:o})):[]},cost:{amountPerQuantity:n(e.itemPrice),subtotalAmount:n(s.totalAmountBeforeReductions),totalAmount:n(s.totalAmountAfterLineDiscounts)},discountAllocations:se(s)}))):[]}function se(t){const e=[];return t.allocations.forEach(s=>{const{discountDetails:r,amount:o}=s,a=r.discount;a.type!=="discountCodeTrigger"&&e.push({discountedAmount:n(o),discountApplication:{allocationMethod:a.allocationMethod==="ONE"?"ACROSS":a.allocationMethod,targetSelection:a.targetSelection,targetType:C(a.targetType),value:N(a.value)},targetType:"LINE_ITEM"})}),e}function N(t){return t.typename==="PercentageValue"?{percentage:t.percentage}:n(t.fixedAmount)}function _(t){return t?t.filter(e=>e.method.type==="giftCard"&&e.cost!==void 0&&e.method.balance!==void 0).map(e=>({amountUsed:n(e.cost),balance:n(e.method.balance),lastCharacters:e.method.code.slice(-4),presentmentAmountUsed:n(e.cost)})):[]}function w(t,e){return t?.status!=="filled"||!t.lines?[]:t.lines.map(s=>({deliveryAddress:{address1:e?.address1,address2:e?.address2,city:e?.city,province:e?.zoneCode,country:e?.countryCode,countryCodeV2:e?.countryCode,zip:e?.postalCode,firstName:e?.firstName,lastName:e?.lastName,phone:e?.phone,company:e?.company},deliveryOptions:$(s),selectedDeliveryOption:ee(s),groupType:s.type}))}function M(t){return t?t.map(e=>{if(!("discount"in e))return null;const s=e.discount;if(s.type!=="code"&&s.type!=="discountCodeTrigger")return null;const r=!("message"in e&&e.message);return{code:s.title,applicable:r,...e.message&&{reason:e.message}}}).filter(e=>e!==null):[]}function re(t){if(t.buyerIdentity&&(delete t.buyerIdentity.email,delete t.buyerIdentity.phone,t.buyerIdentity.customer&&delete t.buyerIdentity.customer),t.delivery?.addresses)for(const e of t.delivery.addresses)e.address&&(delete e.address.firstName,delete e.address.lastName,delete e.address.company,delete e.address.address1,delete e.address.address2,delete e.address.city,delete e.address.provinceCode,delete e.address.zip,delete e.address.phone);if(t.deliveryGroups)for(const e of t.deliveryGroups)e.deliveryAddress&&(delete e.deliveryAddress.firstName,delete e.deliveryAddress.lastName,delete e.deliveryAddress.company,delete e.deliveryAddress.address1,delete e.deliveryAddress.address2,delete e.deliveryAddress.city,delete e.deliveryAddress.province,delete e.deliveryAddress.zip,delete e.deliveryAddress.phone)}function oe(t){delete t.url}function ae(t){return!j(t)}function p(t,e){if(ae(e))return t;const s=JSON.parse(JSON.stringify(t));return"cart"in s.params&&s.params.cart&&re(s.params.cart),"orderConfirmation"in s.params&&s.params.orderConfirmation&&oe(s.params.orderConfirmation),s}class fe extends z{constructor(e){super(e),this.version="2025-10",this.#s=!1,this.#t=3e5,this.#e=new R({observability:e.observability}),this.observability.bridgeInitialized()}#e;#s;#r;#t;async ready(){}async start(){const e=H(this.context),s=p(e,this.context);this.#e.notify(s),this.observability.checkoutStarted({embedder:this.context.embed.embedder,buyerEmail:this.context.checkout.proposal.proposed.email.peek(),hasPaymentInstrument:this.hasDelegatedPaymentInstrument()}),this.#o()}async resumeFromReceipt(){this.#o()}async complete(){if(this.#s){this.observability.completedEventSkipped();return}this.#s=!0,this.observability.checkoutCompleted();const e=F(this.context);this.observability.completedEventEmitted(),this.#e.notify(e)}error(e){const s=J({code:e.code,message:e.message});this.#e.notify(s)}async addressChangeRequest(e){const s=K({addressType:e},this.context),r=await this.#e.request(s,{timeoutMs:this.#t});return this.#a(r)}async addressChangeStart(e){const s=V({addressType:e},this.context),r=p(s,this.context),o=await this.#e.request(r,{timeoutMs:this.#t});return this.#n(o)}async paymentMethodChangeStart(){const e=Y(this.context),s=p(e,this.context),r=await this.#e.request(s,{timeoutMs:this.#t});return this.#i(r)}async submitStart(){await this.waitForPendingNegotiations();const e=B(this.context),s=p(e,this.context),r=await this.#e.request(s,{timeoutMs:G(this.context.embed.embedder)});return this.#d(r)}cleanup(){this.#e.cleanup(),this.#r?.()}#o(){this.#r=E(()=>{const e=this.context.checkout.latestReceipt.value;e&&e.status==="processed"&&(this.complete(),this.cleanup())})}
1#a(e){if(!q(e))throw new m("Invalid address change response structure");const s=e.delivery.addresses[0].address;return{firstName:s.firstName,lastName:s.lastName,address1:s.address1,address2:s.address2,city:s.city,company:s.company,countryCode:s.countryCode,phone:s.phone,zoneCode:s.provinceCode,postalCode:s.zip}}#n(e){if(!f(e))throw this.context.observability.log("message_mapper_invalid_response_schema","Invalid response schema for addressChangeStart",{response:e}),new m("Invalid addressChangeStart response structure: must be an object with cart and/or errors fields");return e}#i(e){if(!f(e))throw this.context.observability.log("message_mapper_invalid_response_schema","Invalid response schema for paymentMethodChangeStart",{response:e}),new m("Invalid paymentMethodChangeStart response structure: must be an object with cart and/or errors fields");return e}#d(e){if(!f(e))throw this.context.observability.log("message_mapper_invalid_response_schema","Invalid response schema for submitStart",{response:e}),new m("Invalid submitStart response structure: must be an object with cart and/or errors fields");return e}}export{fe as ShopifyEcp2025_10Client};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.