var _____WB$wombat$assign$function_____=function(name){return (globalThis._wb_wombat && globalThis._wb_wombat.local_init && globalThis._wb_wombat.local_init(name))||globalThis[name];};if(!globalThis.__WB_pmw){globalThis.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}var window = _____WB$wombat$assign$function_____("window");
var self = _____WB$wombat$assign$function_____("self");
var document = _____WB$wombat$assign$function_____("document");
var location = _____WB$wombat$assign$function_____("location");
var top = _____WB$wombat$assign$function_____("top");
var parent = _____WB$wombat$assign$function_____("parent");
var frames = _____WB$wombat$assign$function_____("frames");
var opener = _____WB$wombat$assign$function_____("opener");
import{a7 as E,c4 as k,c5 as R,bH as M,c6 as A,c7 as T}from"./app.ZXowmuNl.js";let y=class extends Error{name="EditorBridgeError"};const O="editor_domain";function U(){if(window.Shopify==null)throw new y("Shopify object is missing");const{shop:t,editorDomain:o}=window.Shopify;if(o==null&&t==null){const c=new URLSearchParams(window.location.search).get(O);if(c==null)throw new y("Could not find Editor Domain on URL");return c}return o||t}function L(){return`https://${U()}`}const P={error:!1},x={error:!0};function D(t,o){E(()=>{const c=F(t,o);return()=>c()},[o,t])}function F(t,o){const c=async i=>{if(i.origin===L()&&i.data.type===t){const u=i.data.payload;let n;try{const s=await o(u);n=s?{...s,error:!1}:P}catch(s){const d=s instanceof Error?s.message:"";n={...x,errorMessage:d}}window.parent.postMessage({id:i.data.id,type:i.data.type,payload:n},i.origin)}};return window.addEventListener("message",c),()=>window.removeEventListener("message",c)}const H={id:"1ddc80dd1747cfb53029784271e481f3361746816882735d1284cb4b37994106",type:"query",name:"Fonts",source:"query Fonts($onlineStoreEditorSessionId:String){shop{id designSystem(onlineStoreEditorSessionId:$onlineStoreEditorSessionId){typography{...GlobalTypographyFragment __typename}__typename}__typename}}fragment GlobalTypographyFragment on Typography{size{base ratio __typename}primary{name loadingStrategy base{weight sources preloadUrl style __typename}bold{weight sources preloadUrl style __typename}__typename}secondary{name loadingStrategy base{weight sources preloadUrl style __typename}bold{weight sources preloadUrl style __typename}__typename}__typename}"},I="rgba(0,0,0,0)",m={small:40,medium:60,large:80},B={transparent:"transparent",white:void 0};class p extends Error{name="EditorBridgeError"}function q(){const t=k(),o=R(),c=M(),i=r=>{t.preview(r)},u=(r,e)=>{t.set(r,{...t.configuration[r],...e})},n=(r,e)=>{o.set(r,{...o.configuration[r],...e})},s=async r=>{const{data:e,error:a}=await c.query(H,{cache:!1});if(a)throw a;if(!e?.shop)throw new p("Fonts query failed");u(r==="primary"?"typographyPrimary":"typographySecondary",A(e.shop.designSystem?.typography?.[r]??{}))},d=r=>r?.image.originalSrc,S=r=>{const e=new Image,a=new Promise(h=>{e.onload=()=>{h({width:e.width,height:e.height})}});return e.src=r,a},g=r=>r&&r!==I?T(r):void 0;function _(r){n("header",{position:G(o)[r],alignment:C(o)[r]}),n("buyerJourney",{alignment:N(o)[r]})}return D("StorefrontMessage::BroadcastSettingUpdate",({settingId:r,settingValue:e})=>{if(r.startsWith("checkout_"))switch(r){case"checkout_header_image":{const a=o.configuration.header.alignment==="center"&&o.configuration.header.position!=="inlineSecondary",h=o.configuration.header.alignment==="start",l=a?"center":h?"left":"right";return n("header",{banner:{...o.configuration.header.banner,image:d(e)}}),_(l)}case"checkout_logo_image":{const{logo:a}=o.configuration.header,h=a?.maxWidth&&a?.aspectRatio?Math.round(a.maxWidth/a.aspectRatio/10)*10:m.medium;if(!e){n("header",{logo:{...o.configuration.header.logo,image:void 0,maxWidth:h,aspectRatio:1}});return}S(d(e)).then(({width:l,height:b})=>{const f=l/b,w=h*f;n("header",{logo:{...a,image:d(e),maxWidth:w,aspectRatio:f}})}).catch(()=>{throw new p(`${r} is not handled!`)});return}case"checkout_logo_position":return n("header",{colorScheme:e==="start"?"scheme1":"inherit"}),_(e);case"checkout_logo_size":if(o.configuration.header.logo?.aspectRatio){const a=m[e]*o.configuration.header.logo.aspectRatio;n("header",{logo:{...o.configuration.header.logo,maxWidth:a}})}else n("header",{logo:{...o.configuration.header.logo,maxWidth:m[e],aspectRatio:1}});return;case"checkout_body_background_color":return i({schemes:{scheme1:{base:{background:g(e)}}}});case"checkout_body_background_image":return n("shell",{backgroundImage:d(e)});case"checkout_input_background_color_mode":return u("control",{background:B[e]});case"checkout_sidebar_background_image":return n("orderSummary",{backgroundImage:d(e)});case"checkout_sidebar_background_color":return i({schemes:{scheme2:{base:{background:g(e)}}}});case"checkout_heading_font":return s("secondary");case"checkout_body_font":return s("primary");case"checkout_accent_color":return i({global:{accent:g(e)}});case"checkout_button_color":return i({global:{brand:g(e)}});case"checkout_error_color":return i({global:{critical:g(e)}});default:throw new p(`${r} is not handled!`)}}),null}function C(t){return t.configuration.header?.banner?.image?{left:"start",center:"center",right:"end"}:{left:"start",center:"center",right:"center"}}function G(t){return t.configuration.header?.banner?.image?{left:"start",center:"start",right:"start"}:{left:"inline",center:"inline",right:"inlineSecondary"}}function N(t){return t.configuration.header?.banner?.image?{left:"start",center:"start",right:"start"}:{left:"start",center:"center",right:"start"}}export{q as default};