import{q as s,b7 as l,W as p,c as d,a as m}from"./shop-pay-FullScreenBackground.wUQlmEwa.js";import{q as g,n as f,y as h,u as y,R as _}from"./dist-vendor.a3kfnPsb.js";import{u as b}from"./graphql-useReplaceShopPayInHistory.DHx79QHD.js";function C(t){return!t||t.__typename!=="TipWrapper"?[]:t.tipSuggestions.map(e=>({percentage:e.percentage,amount:s(e.amount)}))}function G(t){return!t||t.__typename!=="TipWrapper"||!t.terms||t.terms.__typename!=="FilledTipTerms"?[]:t.terms.tipLines.map(v).filter(e=>!!e)}function v(t){if(t.__typename==="TipLine")return{amount:s(t.amount)}}function T(t){return t?.map(({amount:e})=>({amount:{value:{amount:e.amount.toString(),currencyCode:e.currencyCode}}}))??[]}function U(t,e,o){return t?.length&&t.every(({amount:{currencyCode:r}})=>r===o?.presentmentCurrency)?t:e??[]}function A(t,e,o){return{message:e??t.note??null,customAttributes:o?.map(({...r})=>r)??t.customAttributes?.map(r=>({key:r.key,value:r.value}))??[]}}function E(t){if(!(!t.message||t.__typename!=="Note"))return t.message}function N(t){return t.__typename!=="Note"?[]:t.customAttributes?.map(({__typename:e,...o})=>o)}function R(t){return{signature:t.signature??void 0,contents:t.contents.map(e=>({signature:e.signature,targetTerms:e.targetTerms,targetLine:e.targetLine===void 0?void 0:{allLines:e.targetLine?.allLines??!1,index:e.targetLine?.index},attributes:e.attributes}))}}function x(t){return{signature:t.signature,contents:t.contents.map(e=>({signature:e.signature,targetTerms:e.targetTerms,targetLine:e.targetLine===void 0||e.targetLine===null?void 0:{allLines:e.targetLine.allLines,index:e.targetLine.index},attributes:e.attributes}))}}function P(t,e){if(!t||t.__typename!=="AllocatedAlternativePaymentCurrencyTotal"||!e?.lines)return;const o=e.lines.flatMap(n=>n.method.type==="giftCard"?[n.stableId]:[]),r=t.paymentLineAllocations.reduce((n,a)=>o.includes(a.stableId)?n:n+parseFloat(a.amount.amount),0);return{total:s(t.total),totalWithoutGiftCards:s({amount:r.toString(),currencyCode:t.total.currencyCode,__typename:"Money"})}}function k(t){if(t)return{total:{amount:t.total.amount.toString(),currencyCode:t.total.currencyCode}}}function w(t){return e=>e?t[e]:void 0}function W({name:t,base:e,bold:o}){const{weight:r,sources:n}=e||{},{weight:a,sources:u}=o||{};return{fonts:t??void 0,weightBase:r??void 0,sourceBase:n??void 0,weightBold:a??void 0,sourceBold:u??void 0}}function B(){const t=l(),{editorSetShopPaySignal:e}=p(),o=g(r=>e.value?.setShopPay(r),[e]);return{setEditorShopPay:t&&e.value?o:void 0}}function F(){const{currentPage:t}=d().value,{currentUrl:{search:e,pathname:o}}=f(),{observability:r,shopPay:n}=m(),a=o.includes("/shoppay"),{replaceShopPayInHistory:u}=b(),c=t&&!a;return h(()=>{a&&(r.error(new i('Attempted to render "/shoppay" route in 3 page layout, which is not supported')),r.counter({name:"shop_pay_route_not_found",value:1}),u(n.config.checkoutAsGuestUrl))},[a,e,r,u,n.config.checkoutAsGuestUrl]),c?y(_,{to:{pathname:t.route,search:e}}):null}class i extends Error{constructor(e){super(e),this.name="RouteNotFoundError"}}const M=Object.freeze(Object.defineProperty({__proto__:null,RouteNotFoundError:i,default:F},Symbol.toStringTag,{value:"Module"}));export{M as N,k as a,A as b,C as c,G as d,P as e,W as f,x as g,N as h,E as i,U as j,w as m,R as n,T as t,B as u};
