brainerce 1.53.1 → 1.55.0

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.
@@ -1,5 +1,5 @@
1
- "use strict";(()=>{var z="https://api.brainerce.com",j=new Set(["he","ar"]),F=/^#[0-9A-Fa-f]{6}$/,$="#6366F1",N={en:{online:"Online",placeholder:"Ask anything\u2026",error:"Something went wrong \u2014 please try again.",leaveMessage:"Leave a message for the team",yourEmail:"Your email",yourMessage:"Your message",send:"Send",sent:"Thanks! The team will get back to you by email.",close:"Close",expand:"Expand",collapse:"Collapse",searching:"Searching the store\u2026",addToCart:"Add to cart",added:"Added",view:"View",chooseOptions:"View product",results:"From the store",poweredBy:"Powered by Brainerce",addFailed:"I couldn\u2019t add that to the cart \u2014 try the button on the product card."},he:{online:"\u05DE\u05D7\u05D5\u05D1\u05E8",placeholder:"\u05E9\u05D0\u05DC\u05D5 \u05D0\u05D5\u05EA\u05D9 \u05D4\u05DB\u05DC\u2026",error:"\u05DE\u05E9\u05D4\u05D5 \u05D4\u05E9\u05EA\u05D1\u05E9 \u2014 \u05E0\u05E1\u05D5 \u05E9\u05D5\u05D1.",leaveMessage:"\u05D4\u05E9\u05D0\u05D9\u05E8\u05D5 \u05D4\u05D5\u05D3\u05E2\u05D4 \u05DC\u05E6\u05D5\u05D5\u05EA",yourEmail:"\u05D4\u05D0\u05D9\u05DE\u05D9\u05D9\u05DC \u05E9\u05DC\u05DB\u05DD",yourMessage:"\u05D4\u05D4\u05D5\u05D3\u05E2\u05D4 \u05E9\u05DC\u05DB\u05DD",send:"\u05E9\u05DC\u05D9\u05D7\u05D4",sent:"\u05EA\u05D5\u05D3\u05D4! \u05D4\u05E6\u05D5\u05D5\u05EA \u05D9\u05D7\u05D6\u05D5\u05E8 \u05D0\u05DC\u05D9\u05DB\u05DD \u05D1\u05DE\u05D9\u05D9\u05DC.",close:"\u05E1\u05D2\u05D9\u05E8\u05D4",expand:"\u05D4\u05E8\u05D7\u05D1\u05D4",collapse:"\u05DB\u05D9\u05D5\u05D5\u05E5",searching:"\u05DE\u05D7\u05E4\u05E9 \u05D1\u05D7\u05E0\u05D5\u05EA\u2026",addToCart:"\u05D4\u05D5\u05E1\u05E4\u05D4 \u05DC\u05E1\u05DC",added:"\u05E0\u05D5\u05E1\u05E3",view:"\u05E6\u05E4\u05D9\u05D9\u05D4",chooseOptions:"\u05DC\u05E6\u05E4\u05D5\u05EA \u05D1\u05DE\u05D5\u05E6\u05E8",results:"\u05DE\u05EA\u05D5\u05DA \u05D4\u05D7\u05E0\u05D5\u05EA",poweredBy:"\u05DE\u05D5\u05E4\u05E2\u05DC \u05E2\u05DC \u05D9\u05D3\u05D9 Brainerce",addFailed:"\u05DC\u05D0 \u05D4\u05E6\u05DC\u05D7\u05EA\u05D9 \u05DC\u05D4\u05D5\u05E1\u05D9\u05E3 \u05DC\u05E1\u05DC \u2014 \u05E0\u05E1\u05D5 \u05D3\u05E8\u05DA \u05D4\u05DB\u05E4\u05EA\u05D5\u05E8 \u05D1\u05DB\u05E8\u05D8\u05D9\u05E1 \u05D4\u05DE\u05D5\u05E6\u05E8."}},U={chat:'<svg viewBox="0 0 24 24" fill="none"><path d="M12 3C7.03 3 3 6.58 3 11c0 2.04.86 3.9 2.28 5.32-.15 1.23-.62 2.39-1.1 3.21-.13.23.05.52.31.47 1.56-.27 3.07-.93 4.13-1.62A10.6 10.6 0 0 0 12 19c4.97 0 9-3.58 9-8s-4.03-8-9-8Z" fill="currentColor"/></svg>',close:'<svg viewBox="0 0 24 24" fill="none"><path d="M6 6l12 12M18 6L6 18" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',expand:'<svg viewBox="0 0 24 24" fill="none"><path d="M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>',collapse:'<svg viewBox="0 0 24 24" fill="none"><path d="M20 10h-6V4M4 14h6v6M20 4l-6 6M4 20l6-6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>',mail:'<svg viewBox="0 0 24 24" fill="none"><rect x="3.5" y="5.5" width="17" height="13" rx="2.5" stroke="currentColor" stroke-width="1.7"/><path d="m4.5 7.5 7.5 5.5 7.5-5.5" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>',send:'<svg viewBox="0 0 24 24" fill="none"><path d="M4.4 11.2 19 4.6c.7-.3 1.4.4 1.1 1.1l-6.6 14.6c-.3.7-1.3.6-1.5-.1l-1.7-5.4a1 1 0 0 0-.6-.6l-5.4-1.7c-.7-.2-.8-1.2-.1-1.5Z" fill="currentColor"/></svg>',cart:'<svg viewBox="0 0 24 24" fill="none"><path d="M3 4h2l2.4 11.2A2 2 0 0 0 9.36 17H17.5a2 2 0 0 0 1.95-1.55L21 8H6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="10" cy="20.5" r="1.4" fill="currentColor"/><circle cx="17" cy="20.5" r="1.4" fill="currentColor"/></svg>',check:'<svg viewBox="0 0 24 24" fill="none"><path d="m5 12.5 4.5 4.5L19 7.5" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg>',arrow:'<svg viewBox="0 0 24 24" fill="none"><path d="M7 17 17 7M9 7h8v8" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>',sparkle:'<svg viewBox="0 0 24 24" fill="none"><path d="M12 3v2M12 19v2M3 12h2M19 12h2M6.34 6.34l1.42 1.42M16.24 16.24l1.42 1.42M6.34 17.66l1.42-1.42M16.24 7.76l1.42-1.42" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><circle cx="12" cy="12" r="3.5" fill="currentColor"/></svg>'},D="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAADsOAAA7DgHMtqGDAAAJ8klEQVR4nK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5BYYQmiGnQr83oTnS5WO4PAsX2gYsGY7lRW72dbWcuCeQ5GJphKXKuLaVRvpW6peEAvbuo/BAqvT5SoxhaUNMxv+IwSOKAhwGs0Q6hhU6K0onqqRDKwo2J9B/Z/Z137VmhbzzcAAAAASUVORK5CYII=",K=typeof DOMParser<"u"?new DOMParser:null;function f(c){let e=(U[c]??U.chat).replace("<svg ",'<svg xmlns="http://www.w3.org/2000/svg" '),t=K?.parseFromString(e,"image/svg+xml")?.documentElement;return!t||t.nodeName==="parsererror"?document.createTextNode(""):(t.setAttribute("aria-hidden","true"),t.setAttribute("class","bb-ic"),t)}function q(c){let e=new Uint8Array(16);crypto.getRandomValues(e);let n=btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`${c}${n}`}function T(c){return/^\/(?!\/)/.test(c)||/^https?:\/\//i.test(c)}var R=/\*\*([^*\n]+)\*\*|\[([^\]\n]+)\]\(([^)\s]+)\)/g;function H(c,e){let n=0;R.lastIndex=0;for(let t=R.exec(e);t;t=R.exec(e)){if(t.index>n&&c.appendChild(document.createTextNode(e.slice(n,t.index))),t[1]!==void 0){let s=document.createElement("strong");s.textContent=t[1],c.appendChild(s)}else if(T(t[3])){let s=document.createElement("a");s.href=t[3],s.target="_blank",s.rel="noopener noreferrer",s.textContent=t[2],c.appendChild(s)}else c.appendChild(document.createTextNode(t[2]));n=t.index+t[0].length}n<e.length&&c.appendChild(document.createTextNode(e.slice(n)))}function P(c,e){c.replaceChildren();let n=e.split(`
2
- `),t=null,s=null;for(let o of n){let d=/^\s*[-•*]\s+(.*)$/.exec(o);if(d){s=null,t||(t=document.createElement("ul"),c.appendChild(t));let l=document.createElement("li");H(l,d[1]),t.appendChild(l);continue}if(t=null,!o.trim()){s=null;continue}s?s.appendChild(document.createElement("br")):(s=document.createElement("p"),c.appendChild(s)),H(s,o)}}var B=class c{constructor(e){this.botSessionToken=null;this.botSessionFetchedAt=0;this.settings={enabled:!1};this.locale="en";this.sessionId=null;this.conversationId=null;this.busy=!1;this.opened=!1;this.expanded=!1;this.destroyed=!1;this.pendingText="";this.cardsRow=null;this.cardIds=new Set;this.prevBodyOverflow=null;this.connectionId=e.connectionId,this.baseUrl=(e.baseUrl||z).replace(/\/$/,""),this.storageKey=`brainerce-bot:${this.connectionId}`,this.onAddToCart=e.onAddToCart,this.customerSessionProxyPath=e.customerSessionProxyPath?.replace(/\/$/,"")}static async mount(e){if(!e?.connectionId)return console.warn("[BrainerceBot] connectionId is required"),null;let n=new c(e);return await n.boot(e.target??document.body)?n:null}destroy(){this.destroyed=!0,this.prevBodyOverflow!==null&&(document.body.style.overflow=this.prevBodyOverflow,this.prevBodyOverflow=null),this.host?.remove()}async boot(e){try{let n=await fetch(`${this.baseUrl}/api/storefront-bot/${encodeURIComponent(this.connectionId)}/settings`);if(!n.ok)return!1;this.settings=await n.json()}catch{return!1}return this.settings.enabled?(this.locale=this.settings.languages?.[0]??"en",this.restoreIds(),this.render(e),this.settings.displayMode==="auto_open"&&setTimeout(()=>!this.destroyed&&this.open(),3e3),!0):!1}t(e){return(N[this.locale]??N.en)[e]??N.en[e]??e}restoreIds(){try{let e=localStorage.getItem(this.storageKey);if(e){let n=JSON.parse(e);this.sessionId=n.sessionId??null,this.conversationId=n.conversationId??null}}catch{}}persistIds(){try{localStorage.setItem(this.storageKey,JSON.stringify({sessionId:this.sessionId,conversationId:this.conversationId}))}catch{}}css(e,n,t){let s=this.settings.bubbleShape==="square",o=s?"14px":"22px",d=s?"8px":"15px",l="5px",a=this.settings.displayMode??"floating",r=a==="side_rail",i=a==="full_screen";return`
1
+ "use strict";(()=>{var z="https://api.brainerce.com",j=new Set(["he","ar"]),F=/^#[0-9A-Fa-f]{6}$/,$="#6366F1",B={en:{online:"Online",placeholder:"Ask anything\u2026",error:"Something went wrong \u2014 please try again.",leaveMessage:"Leave a message for the team",yourEmail:"Your email",yourMessage:"Your message",send:"Send",sent:"Thanks! The team will get back to you by email.",close:"Close",expand:"Expand",collapse:"Collapse",searching:"Searching the store\u2026",addToCart:"Add to cart",added:"Added",view:"View",chooseOptions:"View product",results:"From the store",poweredBy:"Powered by Brainerce",addFailed:"I couldn\u2019t add that to the cart \u2014 try the button on the product card."},he:{online:"\u05DE\u05D7\u05D5\u05D1\u05E8",placeholder:"\u05E9\u05D0\u05DC\u05D5 \u05D0\u05D5\u05EA\u05D9 \u05D4\u05DB\u05DC\u2026",error:"\u05DE\u05E9\u05D4\u05D5 \u05D4\u05E9\u05EA\u05D1\u05E9 \u2014 \u05E0\u05E1\u05D5 \u05E9\u05D5\u05D1.",leaveMessage:"\u05D4\u05E9\u05D0\u05D9\u05E8\u05D5 \u05D4\u05D5\u05D3\u05E2\u05D4 \u05DC\u05E6\u05D5\u05D5\u05EA",yourEmail:"\u05D4\u05D0\u05D9\u05DE\u05D9\u05D9\u05DC \u05E9\u05DC\u05DB\u05DD",yourMessage:"\u05D4\u05D4\u05D5\u05D3\u05E2\u05D4 \u05E9\u05DC\u05DB\u05DD",send:"\u05E9\u05DC\u05D9\u05D7\u05D4",sent:"\u05EA\u05D5\u05D3\u05D4! \u05D4\u05E6\u05D5\u05D5\u05EA \u05D9\u05D7\u05D6\u05D5\u05E8 \u05D0\u05DC\u05D9\u05DB\u05DD \u05D1\u05DE\u05D9\u05D9\u05DC.",close:"\u05E1\u05D2\u05D9\u05E8\u05D4",expand:"\u05D4\u05E8\u05D7\u05D1\u05D4",collapse:"\u05DB\u05D9\u05D5\u05D5\u05E5",searching:"\u05DE\u05D7\u05E4\u05E9 \u05D1\u05D7\u05E0\u05D5\u05EA\u2026",addToCart:"\u05D4\u05D5\u05E1\u05E4\u05D4 \u05DC\u05E1\u05DC",added:"\u05E0\u05D5\u05E1\u05E3",view:"\u05E6\u05E4\u05D9\u05D9\u05D4",chooseOptions:"\u05DC\u05E6\u05E4\u05D5\u05EA \u05D1\u05DE\u05D5\u05E6\u05E8",results:"\u05DE\u05EA\u05D5\u05DA \u05D4\u05D7\u05E0\u05D5\u05EA",poweredBy:"\u05DE\u05D5\u05E4\u05E2\u05DC \u05E2\u05DC \u05D9\u05D3\u05D9 Brainerce",addFailed:"\u05DC\u05D0 \u05D4\u05E6\u05DC\u05D7\u05EA\u05D9 \u05DC\u05D4\u05D5\u05E1\u05D9\u05E3 \u05DC\u05E1\u05DC \u2014 \u05E0\u05E1\u05D5 \u05D3\u05E8\u05DA \u05D4\u05DB\u05E4\u05EA\u05D5\u05E8 \u05D1\u05DB\u05E8\u05D8\u05D9\u05E1 \u05D4\u05DE\u05D5\u05E6\u05E8."}},U={chat:'<svg viewBox="0 0 24 24" fill="none"><path d="M12 3C7.03 3 3 6.58 3 11c0 2.04.86 3.9 2.28 5.32-.15 1.23-.62 2.39-1.1 3.21-.13.23.05.52.31.47 1.56-.27 3.07-.93 4.13-1.62A10.6 10.6 0 0 0 12 19c4.97 0 9-3.58 9-8s-4.03-8-9-8Z" fill="currentColor"/></svg>',close:'<svg viewBox="0 0 24 24" fill="none"><path d="M6 6l12 12M18 6L6 18" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',expand:'<svg viewBox="0 0 24 24" fill="none"><path d="M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>',collapse:'<svg viewBox="0 0 24 24" fill="none"><path d="M20 10h-6V4M4 14h6v6M20 4l-6 6M4 20l6-6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>',mail:'<svg viewBox="0 0 24 24" fill="none"><rect x="3.5" y="5.5" width="17" height="13" rx="2.5" stroke="currentColor" stroke-width="1.7"/><path d="m4.5 7.5 7.5 5.5 7.5-5.5" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>',send:'<svg viewBox="0 0 24 24" fill="none"><path d="M4.4 11.2 19 4.6c.7-.3 1.4.4 1.1 1.1l-6.6 14.6c-.3.7-1.3.6-1.5-.1l-1.7-5.4a1 1 0 0 0-.6-.6l-5.4-1.7c-.7-.2-.8-1.2-.1-1.5Z" fill="currentColor"/></svg>',cart:'<svg viewBox="0 0 24 24" fill="none"><path d="M3 4h2l2.4 11.2A2 2 0 0 0 9.36 17H17.5a2 2 0 0 0 1.95-1.55L21 8H6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="10" cy="20.5" r="1.4" fill="currentColor"/><circle cx="17" cy="20.5" r="1.4" fill="currentColor"/></svg>',check:'<svg viewBox="0 0 24 24" fill="none"><path d="m5 12.5 4.5 4.5L19 7.5" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg>',arrow:'<svg viewBox="0 0 24 24" fill="none"><path d="M7 17 17 7M9 7h8v8" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>',sparkle:'<svg viewBox="0 0 24 24" fill="none"><path d="M12 3v2M12 19v2M3 12h2M19 12h2M6.34 6.34l1.42 1.42M16.24 16.24l1.42 1.42M6.34 17.66l1.42-1.42M16.24 7.76l1.42-1.42" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><circle cx="12" cy="12" r="3.5" fill="currentColor"/></svg>'},D="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAADsOAAA7DgHMtqGDAAAJ8klEQVR4nK1YeVDT1xa+ogLDH1UcOmMJWh8aSMQFXLE+N/QhSpQ1ZAGaKryouFDqhqCN2lpRUdAuiiCIS1XqCgoqaFArIiQgayCtRpGgRB4JS0Tc7pvzY4i5kASwnpnzT86dc7+c+7vfOd9FqI+GEe6HEe4vEeKB8tVyi3Sh0ipb2Dgoj42HiFnNNuBpbDwkYV7joAQhtspcjS0ShHhgGsL9EcL9+rpfn4CJER4gFigsxQL14Bx2A+02p9Yhm6tyyea8mH2V38i67K9hX2Q3+5/nv2Id92qbncJvd07mvaIfZGtpcQI8WCzAliKEB3xioB0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llJTLiWRh63YR8RcNavzl+MXdPotOgy6zJjLWaOWoy3Eg4RqzqtgbKatskFjcObB2DK3wHLE9+BVzq+BltOuMdQrgOn0LW7+LSAaA9W33gWPU72Omc6npOvlkOnWU8QdPUd8bVNwUOLtFIU+YMmk0veweEykUlgh3EU7wVhLJ11iD4v/h29rj9apGXRngKPU38A4iibmtrZ36JEwBMOnOXlrHG1lJ42XFc1DpHWuEu4imzirCW0nUMi0NFP/W7yW5ncNBV8bPyskjAJ5Iy/pocLZjPd84JCZnOFQVcFyr82iovNwcJLAx6U4ddWSIZtRKoTp0V6z0vqpB/R7mPFPEPNNT+FHghrt4vXFJOnrVoSo/xKlMMhIpxN2P1gBIM3iGWL68yREU/7LvpJcdpvJajRHzjVvkTNhb/9KV3Tox9WQmgGNU3naguoao1y9d2EwowlYhEfWjgtZquIEbZKkT3TcooJJdiTlgyaY+g5sYFKGccCsnmV5dwHWSS0YiSXpfwH0ACU9j7CgtjStSu4GoDv5RfLtC/kT3VFVZraCIubfA7ObwVRMSUnOcZNLNcCGobw6Ote/gOk0Ex23Oj9RYL4xrYIKonp/csm3jccn9K3dKmsI3x7/uEZiLtxbaF3QIIGFGpcSHohK4reVp5v8AnK6S/eCtBJ4jQPGDqJ52Sj138nnNCtdrjTEOh/LP2otO5MKYTlsTK6WF75HardtbOCzuRI59Ru5pell1jH1FxQpoXw6lEgZFwh0811/XKT6NgcrHA5BYYQmiGnQr83oTnS5WO4PAsX2gYsGY7lRW72dbWcuCeQ5GJphKXKuLaVRvpW6peEAvbuo/BAqvT5SoxhaUNMxv+IwSOKAhwGs0Q6hhU6K0onqqRDKwo2J9B/Z/Z137VmhbzzcAAAAASUVORK5CYII=",K=typeof DOMParser<"u"?new DOMParser:null;function f(a){let e=(U[a]??U.chat).replace("<svg ",'<svg xmlns="http://www.w3.org/2000/svg" '),t=K?.parseFromString(e,"image/svg+xml")?.documentElement;return!t||t.nodeName==="parsererror"?document.createTextNode(""):(t.setAttribute("aria-hidden","true"),t.setAttribute("class","bb-ic"),t)}function J(a){let e=new Uint8Array(16);crypto.getRandomValues(e);let n=btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`${a}${n}`}function S(a){return/^\/(?!\/)/.test(a)||/^https?:\/\//i.test(a)}var R=/\*\*([^*\n]+)\*\*|\[([^\]\n]+)\]\(([^)\s]+)\)/g;function H(a,e){let n=0;R.lastIndex=0;for(let t=R.exec(e);t;t=R.exec(e)){if(t.index>n&&a.appendChild(document.createTextNode(e.slice(n,t.index))),t[1]!==void 0){let i=document.createElement("strong");i.textContent=t[1],a.appendChild(i)}else if(S(t[3])){let i=document.createElement("a");i.href=t[3],i.target="_blank",i.rel="noopener noreferrer",i.textContent=t[2],a.appendChild(i)}else a.appendChild(document.createTextNode(t[2]));n=t.index+t[0].length}n<e.length&&a.appendChild(document.createTextNode(e.slice(n)))}function P(a,e){a.replaceChildren();let n=e.split(`
2
+ `),t=null,i=null;for(let o of n){let l=/^\s*[-•*]\s+(.*)$/.exec(o);if(l){i=null,t||(t=document.createElement("ul"),a.appendChild(t));let c=document.createElement("li");H(c,l[1]),t.appendChild(c);continue}if(t=null,!o.trim()){i=null;continue}i?i.appendChild(document.createElement("br")):(i=document.createElement("p"),a.appendChild(i)),H(i,o)}}var q=/^vc_[A-Za-z0-9_-]{6,}$/;function V(a){return typeof a=="string"&&q.test(a)}var L=class a{constructor(e){this.botSessionToken=null;this.botSessionFetchedAt=0;this.settings={enabled:!1};this.locale="en";this.sessionId=null;this.conversationId=null;this.busy=!1;this.opened=!1;this.expanded=!1;this.destroyed=!1;this.pendingText="";this.cardsRow=null;this.cardIds=new Set;this.prevBodyOverflow=null;this.connectionId=e.connectionId,this.baseUrl=(e.baseUrl||z).replace(/\/$/,""),this.storageKey=`brainerce-bot:${this.connectionId}`,this.onAddToCart=e.onAddToCart,this.customerSessionProxyPath=e.customerSessionProxyPath?.replace(/\/$/,"")}static async mount(e){if(!V(e?.connectionId))return console.warn(`[BrainerceBot] not mounting: connectionId must look like "vc_\u2026", received ${JSON.stringify(e?.connectionId)}. Check the data-connection-id attribute (or the build-time variable behind it).`),null;let n=new a(e);return await n.boot(e.target??document.body)?n:null}destroy(){this.destroyed=!0,this.prevBodyOverflow!==null&&(document.body.style.overflow=this.prevBodyOverflow,this.prevBodyOverflow=null),this.host?.remove()}async boot(e){try{let n=await fetch(`${this.baseUrl}/api/storefront-bot/${encodeURIComponent(this.connectionId)}/settings`);if(!n.ok)return!1;this.settings=await n.json()}catch{return!1}return this.settings.enabled?(this.locale=this.settings.languages?.[0]??"en",this.restoreIds(),this.render(e),this.settings.displayMode==="auto_open"&&setTimeout(()=>!this.destroyed&&this.open(),3e3),!0):!1}t(e){return(B[this.locale]??B.en)[e]??B.en[e]??e}restoreIds(){try{let e=localStorage.getItem(this.storageKey);if(e){let n=JSON.parse(e);this.sessionId=n.sessionId??null,this.conversationId=n.conversationId??null}}catch{}}persistIds(){try{localStorage.setItem(this.storageKey,JSON.stringify({sessionId:this.sessionId,conversationId:this.conversationId}))}catch{}}css(e,n,t){let i=this.settings.bubbleShape==="square",o=i?"14px":"22px",l=i?"8px":"15px",c="5px",r=this.settings.displayMode??"floating",d=r==="side_rail",s=r==="full_screen";return`
3
3
  :host { all: initial; }
4
4
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0;
5
5
  font-family: -apple-system, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, "Helvetica Neue", sans-serif;
@@ -33,7 +33,7 @@
33
33
  .bb-launcher {
34
34
  width: 58px; height: 58px; position: relative; display: flex; align-items: center;
35
35
  justify-content: center; color: #fff; background: ${e};
36
- border-radius: ${s?"16px":"999px"}; overflow: hidden;
36
+ border-radius: ${i?"16px":"999px"}; overflow: hidden;
37
37
  box-shadow: 0 6px 16px -4px color-mix(in srgb, ${e} 55%, rgba(10,12,30,.4)), 0 2px 6px rgba(10,12,30,.18);
38
38
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .22s ease;
39
39
  }
@@ -66,9 +66,9 @@
66
66
  .bb.expanded .bb-window { position: fixed;
67
67
  inset: min(6vh, 60px) max(24px, calc((100vw - 1680px) / 2));
68
68
  width: auto; max-width: none; height: auto; }
69
- ${r?`.bb-window { bottom: 0; top: auto; ${t}: 0; height: calc(100vh - 98px); border-end-start-radius: ${o}; }
69
+ ${d?`.bb-window { bottom: 0; top: auto; ${t}: 0; height: calc(100vh - 98px); border-end-start-radius: ${o}; }
70
70
  .bb.expanded .bb-window { width: min(560px, calc(100vw - 40px)); }`:""}
71
- ${i?`.bb.open .bb-window { position: fixed;
71
+ ${s?`.bb.open .bb-window { position: fixed;
72
72
  inset: min(6vh, 60px) max(24px, calc((100vw - 1680px) / 2));
73
73
  width: auto; max-width: none; height: auto; }
74
74
  .bb.open .bb-launcher { opacity: 0; pointer-events: none; }`:""}
@@ -113,19 +113,19 @@
113
113
  .bb-msg li { margin: 2px 0; }
114
114
  .bb-msg a { color: ${e}; font-weight: 550; text-decoration: underline; text-underline-offset: 2px; }
115
115
  .bb-msg.bot { align-self: flex-start; background: #fff; color: #232633;
116
- border: 1px solid #eceef3; border-radius: ${d}; border-end-start-radius: ${l};
116
+ border: 1px solid #eceef3; border-radius: ${l}; border-end-start-radius: ${c};
117
117
  box-shadow: 0 1px 2px rgba(15,18,34,.04); }
118
118
  .bb-msg.user { align-self: flex-end; background: ${e}; color: #fff;
119
- border-radius: ${d}; border-end-end-radius: ${l};
119
+ border-radius: ${l}; border-end-end-radius: ${c};
120
120
  box-shadow: 0 2px 6px -2px color-mix(in srgb, ${e} 50%, rgba(10,12,30,.3)); }
121
121
  .bb-msg.err { align-self: flex-start; background: #fef2f2; color: #b91c1c;
122
- border: 1px solid #fecaca; border-radius: ${d}; }
122
+ border: 1px solid #fecaca; border-radius: ${l}; }
123
123
  @keyframes bb-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
124
124
 
125
125
  /* typing / tool status */
126
126
  .bb-typing { align-self: flex-start; display: flex; align-items: center; gap: 8px;
127
- background: #fff; border: 1px solid #eceef3; border-radius: ${d};
128
- border-end-start-radius: ${l}; padding: 10px 13px; animation: bb-in .2s ease both; }
127
+ background: #fff; border: 1px solid #eceef3; border-radius: ${l};
128
+ border-end-start-radius: ${c}; padding: 10px 13px; animation: bb-in .2s ease both; }
129
129
  .bb-typing .bb-dots { display: flex; gap: 4px; }
130
130
  .bb-typing .bb-dots i { width: 6px; height: 6px; border-radius: 99px;
131
131
  background: color-mix(in srgb, ${e} 65%, #aab); animation: bb-bounce 1.2s ease-in-out infinite; }
@@ -245,6 +245,6 @@
245
245
  transition: color .12s ease; }
246
246
  .bb-foot a:hover { color: #6b7280; }
247
247
  .bb-foot-mark { width: 14px; height: 14px; border-radius: 3px; display: block; }
248
- `}render(e){let n=this.settings.accentColor,t=n&&F.test(n)?n:$,s=j.has(this.locale)?"rtl":"ltr",o=this.settings.position==="start"?"left":"right",d=s==="rtl"?o==="left"?"right":"left":o,l=this.settings.displayName||"Assistant";this.host=document.createElement("div"),this.host.setAttribute("data-brainerce-bot",this.connectionId),this.root=this.host.attachShadow({mode:"open"});let a=document.createElement("style");a.textContent=this.css(t,s,d),this.root.appendChild(a);let r=document.createElement("div");r.className="bb",this.root.appendChild(r);let i=document.createElement("div");i.className="bb-scrim",i.addEventListener("click",()=>{this.expanded?this.toggleExpand():this.close()}),r.appendChild(i),this.windowEl=document.createElement("div"),this.windowEl.className="bb-window",r.appendChild(this.windowEl);let p=document.createElement("div");p.className="bb-header";let h=document.createElement("span");if(h.className="bb-avatar",this.settings.avatarUrl&&T(this.settings.avatarUrl)){let u=document.createElement("img");u.src=this.settings.avatarUrl,u.alt="",h.appendChild(u)}else h.appendChild(f("sparkle"));let b=document.createElement("span");b.className="bb-head-main";let E=document.createElement("span");E.className="bb-name",E.textContent=l;let k=document.createElement("span");k.className="bb-status",k.textContent=this.t("online"),b.appendChild(E),b.appendChild(k);let x=document.createElement("span");x.className="bb-actions",(this.settings.displayMode??"floating")!=="full_screen"&&this.settings.allowExpand!==!1&&(this.expandBtn=this.iconButton("expand",this.t("expand"),()=>this.toggleExpand()),x.appendChild(this.expandBtn)),x.appendChild(this.iconButton("mail",this.t("leaveMessage"),()=>this.toggleEscalation())),x.appendChild(this.iconButton("close",this.t("close"),()=>this.close())),p.appendChild(h),p.appendChild(b),p.appendChild(x),this.windowEl.appendChild(p),this.messagesEl=document.createElement("div"),this.messagesEl.className="bb-msgs",this.windowEl.appendChild(this.messagesEl),this.chipsEl=document.createElement("div"),this.chipsEl.className="bb-chips";for(let u of this.settings.starterQuestions??[]){let L=document.createElement("button");L.className="bb-chip",L.textContent=u,L.addEventListener("click",()=>this.send(u)),this.chipsEl.appendChild(L)}this.windowEl.appendChild(this.chipsEl);let v=document.createElement("div");v.className="bb-esc";let I=document.createElement("span");I.className="bb-esc-title",I.textContent=this.t("leaveMessage");let S=document.createElement("input");S.type="email",S.name="email",S.placeholder=this.t("yourEmail");let A=document.createElement("textarea");A.name="message",A.rows=2,A.placeholder=this.t("yourMessage");let m=document.createElement("button");m.type="button",m.className="bb-esc-send",m.textContent=this.t("send"),m.addEventListener("click",()=>this.submitEscalation(v)),v.appendChild(I),v.appendChild(S),v.appendChild(A),v.appendChild(m),this.windowEl.appendChild(v);let M=document.createElement("div");M.className="bb-composer",this.inputEl=document.createElement("textarea"),this.inputEl.className="bb-input",this.inputEl.rows=1,this.inputEl.maxLength=4e3,this.inputEl.placeholder=this.t("placeholder"),this.inputEl.addEventListener("keydown",u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),this.send(this.inputEl?.value??""))}),this.inputEl.addEventListener("input",()=>this.syncSendState()),this.sendBtn=document.createElement("button"),this.sendBtn.className="bb-send",this.sendBtn.disabled=!0,this.sendBtn.setAttribute("aria-label",this.t("send")),this.sendBtn.appendChild(f("send")),this.sendBtn.addEventListener("click",()=>this.send(this.inputEl?.value??"")),M.appendChild(this.inputEl),M.appendChild(this.sendBtn),this.windowEl.appendChild(M);let C=document.createElement("div");C.className="bb-foot";let w=document.createElement("a");w.href="https://brainerce.com",w.target="_blank",w.rel="noopener noreferrer";let y=document.createElement("img");if(y.src=D,y.alt="",y.className="bb-foot-mark",w.appendChild(y),w.appendChild(document.createTextNode(this.t("poweredBy"))),C.appendChild(w),this.windowEl.appendChild(C),this.launcherEl=document.createElement("button"),this.launcherEl.className="bb-launcher",this.launcherEl.setAttribute("aria-label",l),this.settings.avatarUrl&&T(this.settings.avatarUrl)){let u=document.createElement("img");u.src=this.settings.avatarUrl,u.alt="",this.launcherEl.appendChild(u)}else{let u=f("chat");u.classList.add("bb-l-chat"),this.launcherEl.appendChild(u)}let O=f("close");O.classList.add("bb-l-close"),this.launcherEl.appendChild(O),this.launcherEl.addEventListener("click",()=>this.opened?this.close():this.open()),r.appendChild(this.launcherEl),e.appendChild(this.host)}iconButton(e,n,t){let s=document.createElement("button");return s.className="bb-iconbtn",s.title=n,s.setAttribute("aria-label",n),s.appendChild(f(e)),s.addEventListener("click",t),s}syncSendState(){this.sendBtn&&(this.sendBtn.disabled=!(this.inputEl?.value??"").trim()||this.busy)}open(){if(!this.windowEl||this.opened)return;this.opened=!0;let e=this.root?.querySelector(".bb");e?.classList.add("open");let n=(this.settings.displayMode??"floating")==="full_screen"||window.innerWidth<=520;e?.classList.toggle("big",n||this.expanded),this.syncBodyScroll(),this.messagesEl&&this.messagesEl.childElementCount===0&&this.primeThread(),this.inputEl?.focus()}close(){this.opened=!1;let e=this.root?.querySelector(".bb");e?.classList.remove("open"),this.expanded||e?.classList.remove("big"),this.syncBodyScroll()}syncBodyScroll(){let e=this.opened&&!!this.root?.querySelector(".bb")?.classList.contains("big");e&&this.prevBodyOverflow===null?(this.prevBodyOverflow=document.body.style.overflow||"",document.body.style.overflow="hidden"):!e&&this.prevBodyOverflow!==null&&(document.body.style.overflow=this.prevBodyOverflow,this.prevBodyOverflow=null)}toggleExpand(){if(this.expanded=!this.expanded,this.root?.querySelector(".bb")?.classList.toggle("expanded",this.expanded),this.root?.querySelector(".bb")?.classList.toggle("big",this.expanded),this.syncBodyScroll(),this.expandBtn){this.expandBtn.replaceChildren(f(this.expanded?"collapse":"expand"));let e=this.t(this.expanded?"collapse":"expand");this.expandBtn.title=e,this.expandBtn.setAttribute("aria-label",e)}}async primeThread(){if(this.conversationId&&this.sessionId)try{let e=await fetch(`${this.baseUrl}/api/storefront-bot/${encodeURIComponent(this.connectionId)}/conversations/${encodeURIComponent(this.conversationId)}?limit=50`,{headers:{"X-Bot-Session":this.sessionId}});if(e.ok){let n=await e.json();for(let t of n.data){let s=this.appendMessage(t.role==="assistant"?"bot":"user","");P(s,t.content)}if(n.data.length>0){this.chipsEl?.remove();return}}else this.conversationId=null,this.sessionId=null,this.persistIds()}catch{}if(this.settings.greeting){let e=this.appendMessage("bot","");P(e,this.settings.greeting)}}async refreshCustomerSession(){if(!this.customerSessionProxyPath)return;let e=240*1e3;if(!(this.botSessionToken&&Date.now()-this.botSessionFetchedAt<e))try{let n=await fetch(`${this.customerSessionProxyPath}/api/storefront-bot/${encodeURIComponent(this.connectionId)}/customer-session`,{credentials:"include"});if(!n.ok)return;let t=await n.json();this.botSessionToken=t.loggedIn&&t.botSessionToken?t.botSessionToken:null,this.botSessionFetchedAt=Date.now()}catch{}}async send(e){let n=e.trim();if(!n||this.busy)return;this.busy=!0,this.inputEl&&(this.inputEl.value=""),this.syncSendState(),this.chipsEl?.remove(),this.appendMessage("user",n);let t=this.appendTyping();this.pendingText="",this.cardsRow=null,this.cardIds=new Set;let s=null;try{await this.refreshCustomerSession();let o=await fetch(`${this.baseUrl}/api/storefront-bot/${encodeURIComponent(this.connectionId)}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:n,turnId:q("trn_"),...this.conversationId?{conversationId:this.conversationId}:{},...this.sessionId?{anonymousSessionId:this.sessionId}:{},locale:this.locale,...this.botSessionToken?{botSessionToken:this.botSessionToken}:{}})});if(!o.ok||!o.body)throw new Error(`chat failed (${o.status})`);let d=o.body.getReader(),l=new TextDecoder,a="";for(;;){let{value:r,done:i}=await d.read();if(i)break;a+=l.decode(r,{stream:!0});let p;for(;(p=a.indexOf(`
248
+ `}render(e){let n=this.settings.accentColor,t=n&&F.test(n)?n:$,i=j.has(this.locale)?"rtl":"ltr",o=this.settings.position==="start"?"left":"right",l=i==="rtl"?o==="left"?"right":"left":o,c=this.settings.displayName||"Assistant";this.host=document.createElement("div"),this.host.setAttribute("data-brainerce-bot",this.connectionId),this.root=this.host.attachShadow({mode:"open"});let r=document.createElement("style");r.textContent=this.css(t,i,l),this.root.appendChild(r);let d=document.createElement("div");d.className="bb",this.root.appendChild(d);let s=document.createElement("div");s.className="bb-scrim",s.addEventListener("click",()=>{this.expanded?this.toggleExpand():this.close()}),d.appendChild(s),this.windowEl=document.createElement("div"),this.windowEl.className="bb-window",d.appendChild(this.windowEl);let p=document.createElement("div");p.className="bb-header";let h=document.createElement("span");if(h.className="bb-avatar",this.settings.avatarUrl&&S(this.settings.avatarUrl)){let u=document.createElement("img");u.src=this.settings.avatarUrl,u.alt="",h.appendChild(u)}else h.appendChild(f("sparkle"));let b=document.createElement("span");b.className="bb-head-main";let E=document.createElement("span");E.className="bb-name",E.textContent=c;let k=document.createElement("span");k.className="bb-status",k.textContent=this.t("online"),b.appendChild(E),b.appendChild(k);let x=document.createElement("span");x.className="bb-actions",(this.settings.displayMode??"floating")!=="full_screen"&&this.settings.allowExpand!==!1&&(this.expandBtn=this.iconButton("expand",this.t("expand"),()=>this.toggleExpand()),x.appendChild(this.expandBtn)),x.appendChild(this.iconButton("mail",this.t("leaveMessage"),()=>this.toggleEscalation())),x.appendChild(this.iconButton("close",this.t("close"),()=>this.close())),p.appendChild(h),p.appendChild(b),p.appendChild(x),this.windowEl.appendChild(p),this.messagesEl=document.createElement("div"),this.messagesEl.className="bb-msgs",this.windowEl.appendChild(this.messagesEl),this.chipsEl=document.createElement("div"),this.chipsEl.className="bb-chips";for(let u of this.settings.starterQuestions??[]){let N=document.createElement("button");N.className="bb-chip",N.textContent=u,N.addEventListener("click",()=>this.send(u)),this.chipsEl.appendChild(N)}this.windowEl.appendChild(this.chipsEl);let v=document.createElement("div");v.className="bb-esc";let I=document.createElement("span");I.className="bb-esc-title",I.textContent=this.t("leaveMessage");let T=document.createElement("input");T.type="email",T.name="email",T.placeholder=this.t("yourEmail");let A=document.createElement("textarea");A.name="message",A.rows=2,A.placeholder=this.t("yourMessage");let m=document.createElement("button");m.type="button",m.className="bb-esc-send",m.textContent=this.t("send"),m.addEventListener("click",()=>this.submitEscalation(v)),v.appendChild(I),v.appendChild(T),v.appendChild(A),v.appendChild(m),this.windowEl.appendChild(v);let M=document.createElement("div");M.className="bb-composer",this.inputEl=document.createElement("textarea"),this.inputEl.className="bb-input",this.inputEl.rows=1,this.inputEl.maxLength=4e3,this.inputEl.placeholder=this.t("placeholder"),this.inputEl.addEventListener("keydown",u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),this.send(this.inputEl?.value??""))}),this.inputEl.addEventListener("input",()=>this.syncSendState()),this.sendBtn=document.createElement("button"),this.sendBtn.className="bb-send",this.sendBtn.disabled=!0,this.sendBtn.setAttribute("aria-label",this.t("send")),this.sendBtn.appendChild(f("send")),this.sendBtn.addEventListener("click",()=>this.send(this.inputEl?.value??"")),M.appendChild(this.inputEl),M.appendChild(this.sendBtn),this.windowEl.appendChild(M);let C=document.createElement("div");C.className="bb-foot";let w=document.createElement("a");w.href="https://brainerce.com",w.target="_blank",w.rel="noopener noreferrer";let y=document.createElement("img");if(y.src=D,y.alt="",y.className="bb-foot-mark",w.appendChild(y),w.appendChild(document.createTextNode(this.t("poweredBy"))),C.appendChild(w),this.windowEl.appendChild(C),this.launcherEl=document.createElement("button"),this.launcherEl.className="bb-launcher",this.launcherEl.setAttribute("aria-label",c),this.settings.avatarUrl&&S(this.settings.avatarUrl)){let u=document.createElement("img");u.src=this.settings.avatarUrl,u.alt="",this.launcherEl.appendChild(u)}else{let u=f("chat");u.classList.add("bb-l-chat"),this.launcherEl.appendChild(u)}let O=f("close");O.classList.add("bb-l-close"),this.launcherEl.appendChild(O),this.launcherEl.addEventListener("click",()=>this.opened?this.close():this.open()),d.appendChild(this.launcherEl),e.appendChild(this.host)}iconButton(e,n,t){let i=document.createElement("button");return i.className="bb-iconbtn",i.title=n,i.setAttribute("aria-label",n),i.appendChild(f(e)),i.addEventListener("click",t),i}syncSendState(){this.sendBtn&&(this.sendBtn.disabled=!(this.inputEl?.value??"").trim()||this.busy)}open(){if(!this.windowEl||this.opened)return;this.opened=!0;let e=this.root?.querySelector(".bb");e?.classList.add("open");let n=(this.settings.displayMode??"floating")==="full_screen"||window.innerWidth<=520;e?.classList.toggle("big",n||this.expanded),this.syncBodyScroll(),this.messagesEl&&this.messagesEl.childElementCount===0&&this.primeThread(),this.inputEl?.focus()}close(){this.opened=!1;let e=this.root?.querySelector(".bb");e?.classList.remove("open"),this.expanded||e?.classList.remove("big"),this.syncBodyScroll()}syncBodyScroll(){let e=this.opened&&!!this.root?.querySelector(".bb")?.classList.contains("big");e&&this.prevBodyOverflow===null?(this.prevBodyOverflow=document.body.style.overflow||"",document.body.style.overflow="hidden"):!e&&this.prevBodyOverflow!==null&&(document.body.style.overflow=this.prevBodyOverflow,this.prevBodyOverflow=null)}toggleExpand(){if(this.expanded=!this.expanded,this.root?.querySelector(".bb")?.classList.toggle("expanded",this.expanded),this.root?.querySelector(".bb")?.classList.toggle("big",this.expanded),this.syncBodyScroll(),this.expandBtn){this.expandBtn.replaceChildren(f(this.expanded?"collapse":"expand"));let e=this.t(this.expanded?"collapse":"expand");this.expandBtn.title=e,this.expandBtn.setAttribute("aria-label",e)}}async primeThread(){if(this.conversationId&&this.sessionId)try{let e=await fetch(`${this.baseUrl}/api/storefront-bot/${encodeURIComponent(this.connectionId)}/conversations/${encodeURIComponent(this.conversationId)}?limit=50`,{headers:{"X-Bot-Session":this.sessionId}});if(e.ok){let n=await e.json();for(let t of n.data){let i=this.appendMessage(t.role==="assistant"?"bot":"user","");P(i,t.content)}if(n.data.length>0){this.chipsEl?.remove();return}}else this.conversationId=null,this.sessionId=null,this.persistIds()}catch{}if(this.settings.greeting){let e=this.appendMessage("bot","");P(e,this.settings.greeting)}}async refreshCustomerSession(){if(!this.customerSessionProxyPath)return;let e=240*1e3;if(!(this.botSessionToken&&Date.now()-this.botSessionFetchedAt<e))try{let n=await fetch(`${this.customerSessionProxyPath}/api/storefront-bot/${encodeURIComponent(this.connectionId)}/customer-session`,{credentials:"include"});if(!n.ok)return;let t=await n.json();this.botSessionToken=t.loggedIn&&t.botSessionToken?t.botSessionToken:null,this.botSessionFetchedAt=Date.now()}catch{}}async send(e){let n=e.trim();if(!n||this.busy)return;this.busy=!0,this.inputEl&&(this.inputEl.value=""),this.syncSendState(),this.chipsEl?.remove(),this.appendMessage("user",n);let t=this.appendTyping();this.pendingText="",this.cardsRow=null,this.cardIds=new Set;let i=null;try{await this.refreshCustomerSession();let o=await fetch(`${this.baseUrl}/api/storefront-bot/${encodeURIComponent(this.connectionId)}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:n,turnId:J("trn_"),...this.conversationId?{conversationId:this.conversationId}:{},...this.sessionId?{anonymousSessionId:this.sessionId}:{},locale:this.locale,...this.botSessionToken?{botSessionToken:this.botSessionToken}:{}})});if(!o.ok||!o.body)throw new Error(`chat failed (${o.status})`);let l=o.body.getReader(),c=new TextDecoder,r="";for(;;){let{value:d,done:s}=await l.read();if(s)break;r+=c.decode(d,{stream:!0});let p;for(;(p=r.indexOf(`
249
249
 
250
- `))>=0;){let h=a.slice(0,p);if(a=a.slice(p+2),!h.startsWith("data: "))continue;let b;try{b=JSON.parse(h.slice(6))}catch{continue}s=this.handleFrame(b,t,s)}}s&&this.pendingText&&P(s,this.pendingText)}catch{this.appendMessage("err",this.t("error"))}finally{t.remove(),this.busy=!1,this.syncSendState()}}handleFrame(e,n,t){switch(e.type){case"connected":return this.conversationId=e.conversationId||this.conversationId,this.sessionId=e.anonymousSessionId||this.sessionId,this.persistIds(),t;case"token":return t||(n.remove(),t=this.appendMessage("bot","")),this.pendingText+=e.text,t.textContent=this.pendingText,this.scrollDown(),t;case"tool":return n.classList.toggle("searching",e.status==="running"),t;case"card":return this.appendCard(e.card),t;case"action":return this.handleAction(e),t;case"error":return this.appendMessage("err",e.message||this.t("error")),t;case"escalate_offer":return this.openEscalation(),t;case"done":default:return t}}appendCard(e){if(!this.messagesEl||this.cardIds.has(e.productId))return;if(this.cardIds.add(e.productId),!this.cardsRow){let i=document.createElement("div");i.className="bb-shelf";let p=document.createElement("div");p.className="bb-shelf-cap",p.textContent=this.t("results"),this.cardsRow=document.createElement("div"),this.cardsRow.className="bb-cards",i.appendChild(p),i.appendChild(this.cardsRow),this.messagesEl.appendChild(i)}let n=T(e.url)?e.url:null,t=document.createElement("div");t.className="bb-card";let s=()=>{this.beacon(e.botRef),n&&(window.location.href=n)},o=document.createElement("span");if(o.className="bb-card-img",e.imageUrl&&T(e.imageUrl)){let i=document.createElement("img");i.src=e.imageUrl,i.alt="",i.loading="lazy",o.appendChild(i)}else o.appendChild(f("cart"));o.addEventListener("click",s),t.appendChild(o);let d=document.createElement("span");d.className="bb-card-body";let l=document.createElement("span");l.className="bb-card-title",l.textContent=e.title,l.addEventListener("click",s);let a=document.createElement("span");a.className="bb-card-price",a.textContent=e.price.formatted,d.appendChild(l),d.appendChild(a);let r=document.createElement("span");if(r.className="bb-card-cta",e.requiresOptions){let i=document.createElement("button");i.className="bb-btn bb-btn-add",i.setAttribute("aria-label",this.t("addToCart")),i.appendChild(f("cart")),e.variants?.length?i.addEventListener("click",()=>this.togglePicker(d,e,o)):i.addEventListener("click",s),r.appendChild(i)}else{let i=document.createElement("button");i.className="bb-btn bb-btn-add bb-sq",i.setAttribute("aria-label",this.t("addToCart")),i.appendChild(f("cart")),i.addEventListener("click",()=>void this.addToCart(e,i));let p=document.createElement("button");p.className="bb-btn bb-btn-ghost bb-wide",p.appendChild(document.createTextNode(this.t("view"))),p.addEventListener("click",s),r.appendChild(p),r.appendChild(i)}d.appendChild(r),t.appendChild(d),this.cardsRow.appendChild(t),this.scrollDown()}togglePicker(e,n,t){let s=e.parentElement,o=e.querySelector(".bb-pick");if(o){o.remove(),s?.classList.remove("picking");return}s?.classList.add("picking");let d=n.variants??[],l=[];for(let h of d)for(let b of Object.keys(h.attributes))l.includes(b)||l.push(b);let a={},r=document.createElement("span");r.className="bb-pick";let i=()=>d.find(h=>l.every(b=>a[b]&&h.attributes[b]===a[b]))??null,p=()=>{r.replaceChildren();for(let g of l){let v=document.createElement("span");v.className="bb-pick-key",v.textContent=g;let I=document.createElement("span");I.className="bb-pick-vals";let S=new Set;for(let A of d){let m=A.attributes[g];if(!m||S.has(m))continue;S.add(m);let M=d.some(w=>w.attributes[g]===m&&l.every(y=>y===g||!a[y]||w.attributes[y]===a[y])),C=document.createElement("button");C.className=`bb-chipv${a[g]===m?" sel":""}${M?"":" off"}`,C.textContent=m,C.addEventListener("click",()=>{a[g]===m?delete a[g]:a[g]=m,p()}),I.appendChild(C)}r.appendChild(v),r.appendChild(I)}let h=document.createElement("button");h.className="bb-pick-close",h.setAttribute("aria-label",this.t("close")),h.appendChild(f("close")),h.addEventListener("click",()=>{r.remove(),s?.classList.remove("picking")}),r.appendChild(h);let b=i(),E=document.createElement("span");E.className="bb-pick-foot";let k=document.createElement("span");k.className="bb-pick-price",k.textContent=b?b.price.formatted:"";let x=document.createElement("button");if(x.className="bb-btn bb-btn-add bb-sq",x.setAttribute("aria-label",this.t("addToCart")),x.appendChild(f("cart")),b||(x.disabled=!0),x.addEventListener("click",()=>{let g=i();g&&this.addToCart(n,x,g.id)}),E.appendChild(k),E.appendChild(x),r.appendChild(E),b?.imageUrl&&T(b.imageUrl)){let g=t.querySelector("img");g&&(g.src=b.imageUrl)}this.scrollDown()};p(),e.appendChild(r),this.scrollDown()}async addToCart(e,n,t){this.beacon(e.botRef),n.dataset.state="busy",await this.dispatchAdd(e.productId,t??null)?(n.dataset.state="done",n.replaceChildren(f("check"),document.createTextNode(this.t("added"))),setTimeout(()=>{!this.destroyed&&n.isConnected&&(delete n.dataset.state,n.replaceChildren(f("cart"),document.createTextNode(this.t("addToCart"))))},2200)):(delete n.dataset.state,T(e.url)&&(window.location.href=e.url))}async dispatchAdd(e,n){try{if(this.onAddToCart)return await this.onAddToCart({productId:e,variantId:n,quantity:1})!==!1;let t=new CustomEvent("brainerce:bot:add-to-cart",{detail:{productId:e,variantId:n,quantity:1,connectionId:this.connectionId},cancelable:!0,bubbles:!0,composed:!0});return!window.dispatchEvent(t)}catch{return!1}}async handleAction(e){if(e.action!=="add_to_cart")return;e.botRef&&this.beacon(e.botRef),await this.dispatchAdd(e.productId,e.variantId)||this.appendMessage("err",this.t("addFailed"))}beacon(e){try{navigator.sendBeacon?.(`${this.baseUrl}/api/storefront-bot/attribution/click`,new Blob([JSON.stringify({botRef:e})],{type:"application/json"}))}catch{}}toggleEscalation(){this.root?.querySelector(".bb-esc")?.classList.toggle("open")}openEscalation(){this.root?.querySelector(".bb-esc")?.classList.add("open")}async submitEscalation(e){let n=e.querySelector('input[name="email"]')?.value.trim(),t=e.querySelector('textarea[name="message"]')?.value.trim();if(!(!n||!t||!this.conversationId||!this.sessionId))try{if((await fetch(`${this.baseUrl}/api/storefront-bot/${encodeURIComponent(this.connectionId)}/escalate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:n,message:t,conversationId:this.conversationId,anonymousSessionId:this.sessionId,locale:this.locale})})).ok){let o=document.createElement("span");o.className="bb-esc-note",o.appendChild(f("check")),o.appendChild(document.createTextNode(this.t("sent"))),e.replaceChildren(o)}}catch{}}appendMessage(e,n){let t=document.createElement("div");return t.className=`bb-msg ${e}`,t.setAttribute("dir","auto"),t.textContent=n,this.messagesEl?.appendChild(t),this.scrollDown(),t}appendTyping(){let e=document.createElement("div");e.className="bb-typing";let n=document.createElement("span");n.className="bb-dots";for(let s=0;s<3;s++)n.appendChild(document.createElement("i"));let t=document.createElement("span");return t.className="bb-tool",t.textContent=this.t("searching"),e.appendChild(n),e.appendChild(t),this.messagesEl?.appendChild(e),this.scrollDown(),e}scrollDown(){this.messagesEl&&(this.messagesEl.scrollTop=this.messagesEl.scrollHeight)}};(()=>{let c=document.currentScript,e=c?.dataset.connectionId;if(!e){console.warn("[BrainerceBot] missing data-connection-id on the bot.js script tag");return}let n=c?.dataset.apiBase||void 0,t=()=>void B.mount({connectionId:e,baseUrl:n});document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()})();})();
250
+ `))>=0;){let h=r.slice(0,p);if(r=r.slice(p+2),!h.startsWith("data: "))continue;let b;try{b=JSON.parse(h.slice(6))}catch{continue}i=this.handleFrame(b,t,i)}}i&&this.pendingText&&P(i,this.pendingText)}catch{this.appendMessage("err",this.t("error"))}finally{t.remove(),this.busy=!1,this.syncSendState()}}handleFrame(e,n,t){switch(e.type){case"connected":return this.conversationId=e.conversationId||this.conversationId,this.sessionId=e.anonymousSessionId||this.sessionId,this.persistIds(),t;case"token":return t||(n.remove(),t=this.appendMessage("bot","")),this.pendingText+=e.text,t.textContent=this.pendingText,this.scrollDown(),t;case"tool":return n.classList.toggle("searching",e.status==="running"),t;case"card":return this.appendCard(e.card),t;case"action":return this.handleAction(e),t;case"error":return this.appendMessage("err",e.message||this.t("error")),t;case"escalate_offer":return this.openEscalation(),t;case"done":default:return t}}appendCard(e){if(!this.messagesEl||this.cardIds.has(e.productId))return;if(this.cardIds.add(e.productId),!this.cardsRow){let s=document.createElement("div");s.className="bb-shelf";let p=document.createElement("div");p.className="bb-shelf-cap",p.textContent=this.t("results"),this.cardsRow=document.createElement("div"),this.cardsRow.className="bb-cards",s.appendChild(p),s.appendChild(this.cardsRow),this.messagesEl.appendChild(s)}let n=S(e.url)?e.url:null,t=document.createElement("div");t.className="bb-card";let i=()=>{this.beacon(e.botRef),n&&(window.location.href=n)},o=document.createElement("span");if(o.className="bb-card-img",e.imageUrl&&S(e.imageUrl)){let s=document.createElement("img");s.src=e.imageUrl,s.alt="",s.loading="lazy",o.appendChild(s)}else o.appendChild(f("cart"));o.addEventListener("click",i),t.appendChild(o);let l=document.createElement("span");l.className="bb-card-body";let c=document.createElement("span");c.className="bb-card-title",c.textContent=e.title,c.addEventListener("click",i);let r=document.createElement("span");r.className="bb-card-price",r.textContent=e.price.formatted,l.appendChild(c),l.appendChild(r);let d=document.createElement("span");if(d.className="bb-card-cta",e.requiresOptions){let s=document.createElement("button");s.className="bb-btn bb-btn-add",s.setAttribute("aria-label",this.t("addToCart")),s.appendChild(f("cart")),e.variants?.length?s.addEventListener("click",()=>this.togglePicker(l,e,o)):s.addEventListener("click",i),d.appendChild(s)}else{let s=document.createElement("button");s.className="bb-btn bb-btn-add bb-sq",s.setAttribute("aria-label",this.t("addToCart")),s.appendChild(f("cart")),s.addEventListener("click",()=>void this.addToCart(e,s));let p=document.createElement("button");p.className="bb-btn bb-btn-ghost bb-wide",p.appendChild(document.createTextNode(this.t("view"))),p.addEventListener("click",i),d.appendChild(p),d.appendChild(s)}l.appendChild(d),t.appendChild(l),this.cardsRow.appendChild(t),this.scrollDown()}togglePicker(e,n,t){let i=e.parentElement,o=e.querySelector(".bb-pick");if(o){o.remove(),i?.classList.remove("picking");return}i?.classList.add("picking");let l=n.variants??[],c=[];for(let h of l)for(let b of Object.keys(h.attributes))c.includes(b)||c.push(b);let r={},d=document.createElement("span");d.className="bb-pick";let s=()=>l.find(h=>c.every(b=>r[b]&&h.attributes[b]===r[b]))??null,p=()=>{d.replaceChildren();for(let g of c){let v=document.createElement("span");v.className="bb-pick-key",v.textContent=g;let I=document.createElement("span");I.className="bb-pick-vals";let T=new Set;for(let A of l){let m=A.attributes[g];if(!m||T.has(m))continue;T.add(m);let M=l.some(w=>w.attributes[g]===m&&c.every(y=>y===g||!r[y]||w.attributes[y]===r[y])),C=document.createElement("button");C.className=`bb-chipv${r[g]===m?" sel":""}${M?"":" off"}`,C.textContent=m,C.addEventListener("click",()=>{r[g]===m?delete r[g]:r[g]=m,p()}),I.appendChild(C)}d.appendChild(v),d.appendChild(I)}let h=document.createElement("button");h.className="bb-pick-close",h.setAttribute("aria-label",this.t("close")),h.appendChild(f("close")),h.addEventListener("click",()=>{d.remove(),i?.classList.remove("picking")}),d.appendChild(h);let b=s(),E=document.createElement("span");E.className="bb-pick-foot";let k=document.createElement("span");k.className="bb-pick-price",k.textContent=b?b.price.formatted:"";let x=document.createElement("button");if(x.className="bb-btn bb-btn-add bb-sq",x.setAttribute("aria-label",this.t("addToCart")),x.appendChild(f("cart")),b||(x.disabled=!0),x.addEventListener("click",()=>{let g=s();g&&this.addToCart(n,x,g.id)}),E.appendChild(k),E.appendChild(x),d.appendChild(E),b?.imageUrl&&S(b.imageUrl)){let g=t.querySelector("img");g&&(g.src=b.imageUrl)}this.scrollDown()};p(),e.appendChild(d),this.scrollDown()}async addToCart(e,n,t){this.beacon(e.botRef),n.dataset.state="busy",await this.dispatchAdd(e.productId,t??null)?(n.dataset.state="done",n.replaceChildren(f("check"),document.createTextNode(this.t("added"))),setTimeout(()=>{!this.destroyed&&n.isConnected&&(delete n.dataset.state,n.replaceChildren(f("cart"),document.createTextNode(this.t("addToCart"))))},2200)):(delete n.dataset.state,S(e.url)&&(window.location.href=e.url))}async dispatchAdd(e,n){try{if(this.onAddToCart)return await this.onAddToCart({productId:e,variantId:n,quantity:1})!==!1;let t=new CustomEvent("brainerce:bot:add-to-cart",{detail:{productId:e,variantId:n,quantity:1,connectionId:this.connectionId},cancelable:!0,bubbles:!0,composed:!0});return!window.dispatchEvent(t)}catch{return!1}}async handleAction(e){if(e.action!=="add_to_cart")return;e.botRef&&this.beacon(e.botRef),await this.dispatchAdd(e.productId,e.variantId)||this.appendMessage("err",this.t("addFailed"))}beacon(e){try{navigator.sendBeacon?.(`${this.baseUrl}/api/storefront-bot/attribution/click`,new Blob([JSON.stringify({botRef:e})],{type:"application/json"}))}catch{}}toggleEscalation(){this.root?.querySelector(".bb-esc")?.classList.toggle("open")}openEscalation(){this.root?.querySelector(".bb-esc")?.classList.add("open")}async submitEscalation(e){let n=e.querySelector('input[name="email"]')?.value.trim(),t=e.querySelector('textarea[name="message"]')?.value.trim();if(!(!n||!t||!this.conversationId||!this.sessionId))try{if((await fetch(`${this.baseUrl}/api/storefront-bot/${encodeURIComponent(this.connectionId)}/escalate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:n,message:t,conversationId:this.conversationId,anonymousSessionId:this.sessionId,locale:this.locale})})).ok){let o=document.createElement("span");o.className="bb-esc-note",o.appendChild(f("check")),o.appendChild(document.createTextNode(this.t("sent"))),e.replaceChildren(o)}}catch{}}appendMessage(e,n){let t=document.createElement("div");return t.className=`bb-msg ${e}`,t.setAttribute("dir","auto"),t.textContent=n,this.messagesEl?.appendChild(t),this.scrollDown(),t}appendTyping(){let e=document.createElement("div");e.className="bb-typing";let n=document.createElement("span");n.className="bb-dots";for(let i=0;i<3;i++)n.appendChild(document.createElement("i"));let t=document.createElement("span");return t.className="bb-tool",t.textContent=this.t("searching"),e.appendChild(n),e.appendChild(t),this.messagesEl?.appendChild(e),this.scrollDown(),e}scrollDown(){this.messagesEl&&(this.messagesEl.scrollTop=this.messagesEl.scrollHeight)}};(()=>{let a=document.currentScript,e=a?.dataset.connectionId;if(!e){console.warn("[BrainerceBot] missing data-connection-id on the bot.js script tag");return}let n=a?.dataset.apiBase||void 0,t=()=>void L.mount({connectionId:e,baseUrl:n});document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()})();})();
package/dist/bot/index.js CHANGED
@@ -164,6 +164,10 @@ function renderRich(el, text) {
164
164
  appendInline(para, line);
165
165
  }
166
166
  }
167
+ var CONNECTION_ID_PATTERN = /^vc_[A-Za-z0-9_-]{6,}$/;
168
+ function isValidConnectionId(value) {
169
+ return typeof value === "string" && CONNECTION_ID_PATTERN.test(value);
170
+ }
167
171
  var BrainerceBot = class _BrainerceBot {
168
172
  constructor(options) {
169
173
  /** Part 2 (order-lookup login gating) — short-lived, in-memory only (never
@@ -195,8 +199,12 @@ var BrainerceBot = class _BrainerceBot {
195
199
  }
196
200
  /** Boot the widget. Resolves to null when the bot is disabled server-side. */
197
201
  static async mount(options) {
198
- if (!options?.connectionId) {
199
- console.warn("[BrainerceBot] connectionId is required");
202
+ if (!isValidConnectionId(options?.connectionId)) {
203
+ console.warn(
204
+ `[BrainerceBot] not mounting: connectionId must look like "vc_\u2026", received ${JSON.stringify(
205
+ options?.connectionId
206
+ )}. Check the data-connection-id attribute (or the build-time variable behind it).`
207
+ );
200
208
  return null;
201
209
  }
202
210
  const bot = new _BrainerceBot(options);
@@ -138,6 +138,10 @@ function renderRich(el, text) {
138
138
  appendInline(para, line);
139
139
  }
140
140
  }
141
+ var CONNECTION_ID_PATTERN = /^vc_[A-Za-z0-9_-]{6,}$/;
142
+ function isValidConnectionId(value) {
143
+ return typeof value === "string" && CONNECTION_ID_PATTERN.test(value);
144
+ }
141
145
  var BrainerceBot = class _BrainerceBot {
142
146
  constructor(options) {
143
147
  /** Part 2 (order-lookup login gating) — short-lived, in-memory only (never
@@ -169,8 +173,12 @@ var BrainerceBot = class _BrainerceBot {
169
173
  }
170
174
  /** Boot the widget. Resolves to null when the bot is disabled server-side. */
171
175
  static async mount(options) {
172
- if (!options?.connectionId) {
173
- console.warn("[BrainerceBot] connectionId is required");
176
+ if (!isValidConnectionId(options?.connectionId)) {
177
+ console.warn(
178
+ `[BrainerceBot] not mounting: connectionId must look like "vc_\u2026", received ${JSON.stringify(
179
+ options?.connectionId
180
+ )}. Check the data-connection-id attribute (or the build-time variable behind it).`
181
+ );
174
182
  return null;
175
183
  }
176
184
  const bot = new _BrainerceBot(options);
package/dist/index.d.mts CHANGED
@@ -246,7 +246,91 @@ interface StoreInfo {
246
246
  * Feeds Product JSON-LD `shippingDetails` — pass as `buildProductJsonLd(product, { ..., shipping: storeInfo.shipping })`.
247
247
  */
248
248
  shipping?: ShippingSummaryEntry[];
249
+ /**
250
+ * Marketing tag ids for this sales channel (sales-channel mode only).
251
+ *
252
+ * Resolved server-side from the marketplace apps the merchant already
253
+ * connected — connecting the Google & YouTube app runs GA4 discovery and the
254
+ * measurement id lands here on its own; same for the Meta and TikTok pixels.
255
+ * The merchant types nothing, and the storefront needs no redeploy: a newly
256
+ * connected app shows up here within 5 minutes.
257
+ *
258
+ * Pass the whole object to {@link BrainerceClient.initTracking} — it boots
259
+ * every tag that is present and skips the rest. Absent fields are the normal
260
+ * state (that app simply isn't connected), never an error.
261
+ */
262
+ tracking?: StoreTracking;
263
+ }
264
+ /**
265
+ * Marketing tag ids served by `GET /api/vc/:connectionId/info`.
266
+ *
267
+ * Every id here is public by nature — it renders into the page source of the
268
+ * storefront — and is format-validated by the backend before being served, so
269
+ * it is safe to interpolate into a tag bootstrap.
270
+ */
271
+ interface StoreTracking {
272
+ /** GA4 measurement id, `G-XXXXXXX`. Auto-discovered by the Google & YouTube app. */
273
+ ga4MeasurementId?: string;
274
+ /**
275
+ * Google Tag Manager container id, `GTM-XXXXXX`. The one tag that cannot be
276
+ * auto-discovered — no OAuth surface exposes a container id — so it appears
277
+ * only when a merchant sets it on the sales channel.
278
+ */
279
+ gtmContainerId?: string;
280
+ /** Meta (Facebook) pixel id. Auto-discovered by the Meta Commerce app. */
281
+ metaPixelId?: string;
282
+ /** TikTok pixel id. Auto-discovered by the TikTok Shop app. */
283
+ tiktokPixelId?: string;
284
+ }
285
+ /**
286
+ * A normalized e-commerce event, fanned out by
287
+ * {@link BrainerceClient.trackMarketingEvent} to every tag that is loaded.
288
+ *
289
+ * Field names follow the GA4 e-commerce spec; the SDK translates them to each
290
+ * vendor's own vocabulary (`fbq` Meta standard events, `ttq` TikTok events) so
291
+ * you describe what happened once instead of three times.
292
+ */
293
+ interface TrackingEventPayload {
294
+ /** ISO 4217, e.g. `ILS`. Required for `purchase` / `begin_checkout` to be usable in ad optimization. */
295
+ currency?: string;
296
+ /** Monetary value of the event. */
297
+ value?: number;
298
+ /**
299
+ * Order id, for `purchase` only. Used as GA4's `transaction_id`, Meta's
300
+ * `eventID` and TikTok's `event_id`, which makes a duplicate send (page
301
+ * refresh, back-button) de-duplicate on the vendor's side rather than
302
+ * double-counting revenue.
303
+ */
304
+ transactionId?: string;
305
+ /** Shipping charged on the order (`purchase`). */
306
+ shipping?: number;
307
+ /** Tax charged on the order (`purchase`). */
308
+ tax?: number;
309
+ /** Coupon code applied. */
310
+ coupon?: string;
311
+ /** Line items. `itemId` must match the id you sync to the ad platform's catalog. */
312
+ items?: TrackingEventItem[];
313
+ }
314
+ /** One line item inside a {@link TrackingEventPayload}. */
315
+ interface TrackingEventItem {
316
+ /**
317
+ * The item id as the ad platform's catalog knows it.
318
+ *
319
+ * Use the product's SKU: that is what the Meta and Google catalog feeds
320
+ * publish as the item id, so anything else silently breaks attribution and
321
+ * dynamic remarketing — the pixel reports an id the catalog has never heard
322
+ * of, and the audience never builds.
323
+ */
324
+ itemId: string;
325
+ itemName?: string;
326
+ /** Unit price (GA4 multiplies by `quantity` itself — do not pre-multiply). */
327
+ price?: number;
328
+ quantity?: number;
329
+ itemVariant?: string;
330
+ itemCategory?: string;
249
331
  }
332
+ /** E-commerce event names understood by {@link BrainerceClient.trackMarketingEvent}. */
333
+ type TrackingEventName = 'view_item' | 'view_item_list' | 'add_to_cart' | 'remove_from_cart' | 'view_cart' | 'begin_checkout' | 'add_payment_info' | 'purchase' | 'search' | 'sign_up';
250
334
  /** One flat-rate/free shipping zone, as exposed by `StoreInfo.shipping`. */
251
335
  interface ShippingSummaryEntry {
252
336
  /** ISO 3166-1 alpha-2 country codes this rate applies to. */
@@ -1131,8 +1215,14 @@ declare function getCartTotals(cart: Pick<Cart, 'subtotal' | 'discountAmount'> |
1131
1215
  };
1132
1216
  /**
1133
1217
  * Get the display name for a cart item.
1134
- * Handles the nested product/variant structure - uses variant name if available,
1135
- * otherwise falls back to product name.
1218
+ * Handles the nested product/variant structure - the product name identifies the
1219
+ * line, with the variant name appended as a qualifier: `"Blue T-Shirt - Large"`.
1220
+ *
1221
+ * The suffix is omitted for products with no variant, and for variants whose name
1222
+ * was copied from the product (so the name never renders twice).
1223
+ *
1224
+ * Need the two parts separately — e.g. to render the variant on its own line —
1225
+ * read `item.product.name` and `item.variant?.name` directly.
1136
1226
  *
1137
1227
  * @param item - The cart item
1138
1228
  * @returns The display name for the item
@@ -1140,7 +1230,7 @@ declare function getCartTotals(cart: Pick<Cart, 'subtotal' | 'discountAmount'> |
1140
1230
  * @example
1141
1231
  * ```typescript
1142
1232
  * cart.items.forEach(item => {
1143
- * const name = getCartItemName(item);
1233
+ * const name = getCartItemName(item); // "Blue T-Shirt - Large"
1144
1234
  * console.log(`${name} x ${item.quantity}`);
1145
1235
  * });
1146
1236
  * ```
@@ -4630,6 +4720,37 @@ interface AutoRegionResponse {
4630
4720
  * still runs at checkout against the full shipping address (state / postal /
4631
4721
  * per-class). Render with an "Estimate" affordance.
4632
4722
  */
4723
+ /**
4724
+ * Manual per-region price override (regional pricing) — the merchant's
4725
+ * hand-set price pair for one product or variant in one region, denominated
4726
+ * in the REGION's currency. Replaces the automatic FX conversion for regions
4727
+ * that actually charge their currency (presentment). Admin (api-key) surface.
4728
+ */
4729
+ interface RegionPrice {
4730
+ id: string;
4731
+ productId: string;
4732
+ /** null = the product-level price (covers every variant without its own row). */
4733
+ variantId: string | null;
4734
+ /** Regular price in the region currency (Decimal string). */
4735
+ price: string;
4736
+ /** Sale price in the region currency — always lower than price; null = no regional sale. */
4737
+ salePrice: string | null;
4738
+ updatedAt: string;
4739
+ }
4740
+ /** One bulk entry for `upsertRegionPrices`. `remove: true` deletes the row. */
4741
+ interface RegionPriceEntry {
4742
+ productId: string;
4743
+ variantId?: string;
4744
+ /** Required unless `remove` — regular price in the region currency. */
4745
+ price?: number;
4746
+ /** Optional sale price — must be lower than `price`. */
4747
+ salePrice?: number;
4748
+ remove?: boolean;
4749
+ }
4750
+ interface UpsertRegionPricesResult {
4751
+ upserted: number;
4752
+ removed: number;
4753
+ }
4633
4754
  interface TaxEstimateResponse {
4634
4755
  appliesTax: boolean;
4635
4756
  /** Percent — e.g. 18 for 18%. `null` when no matching rule. */
@@ -6278,6 +6399,17 @@ declare global {
6278
6399
  interface Window {
6279
6400
  dataLayer?: unknown[];
6280
6401
  gtag?: (...args: unknown[]) => void;
6402
+ /** Meta pixel queue, installed by `initTracking()` when a pixel id is configured. */
6403
+ fbq?: ((...args: unknown[]) => void) & {
6404
+ queue?: unknown[];
6405
+ loaded?: boolean;
6406
+ version?: string;
6407
+ };
6408
+ _fbq?: unknown;
6409
+ /** TikTok pixel queue, installed by `initTracking()` when a pixel id is configured. */
6410
+ ttq?: Record<string, unknown> & {
6411
+ track?: (...args: unknown[]) => void;
6412
+ };
6281
6413
  }
6282
6414
  }
6283
6415
  /**
@@ -6340,6 +6472,9 @@ declare class BrainerceClient {
6340
6472
  private _pendingRecoverCartId;
6341
6473
  private _ga4MeasurementId;
6342
6474
  private _ga4StitchPromise;
6475
+ private _gtmContainerId;
6476
+ private _metaPixelId;
6477
+ private _tiktokPixelId;
6343
6478
  /**
6344
6479
  * Fields present on `getAddressDetails().address` that the address endpoints
6345
6480
  * do NOT accept — stripped by `stripResolvedOnlyAddressFields()` so a
@@ -6572,6 +6707,71 @@ declare class BrainerceClient {
6572
6707
  * consent.
6573
6708
  */
6574
6709
  private resolveGa4StitchIds;
6710
+ /**
6711
+ * Boot every marketing tag the merchant has configured — GA4, Google Tag
6712
+ * Manager, the Meta pixel, the TikTok pixel — in one call.
6713
+ *
6714
+ * Pass `storeInfo.tracking` straight through. The ids in it are resolved
6715
+ * server-side from the marketplace apps the merchant already connected, so
6716
+ * for the common case nobody types an id anywhere and nobody redeploys the
6717
+ * storefront: connect the Google app in the dashboard and this call starts
6718
+ * loading GA4 on the next page render.
6719
+ *
6720
+ * Call it once, as early as possible (root layout / app entry). It is
6721
+ * idempotent, a no-op during SSR, and never throws — a blocked or missing
6722
+ * tag must never take a storefront down with it.
6723
+ *
6724
+ * GA4 goes through {@link loadGoogleAnalytics}, so the `client_id` /
6725
+ * `session_id` stitch ids keep flowing onto cart and checkout calls and the
6726
+ * server-side purchase conversion still lands in the right session.
6727
+ *
6728
+ * @example
6729
+ * ```typescript
6730
+ * const storeInfo = await client.getStoreInfo();
6731
+ * client.initTracking(storeInfo.tracking);
6732
+ * // …later, on the order confirmation page:
6733
+ * client.trackMarketingEvent('purchase', {
6734
+ * transactionId: order.id,
6735
+ * currency: order.currency,
6736
+ * value: order.totalAmount,
6737
+ * items: order.items.map((i) => ({ itemId: i.sku, itemName: i.name, price: i.price, quantity: i.quantity })),
6738
+ * });
6739
+ * ```
6740
+ */
6741
+ initTracking(tracking?: StoreTracking | null): void;
6742
+ /**
6743
+ * Report one e-commerce event to every marketing tag that
6744
+ * {@link initTracking} loaded (GA4/GTM, Meta, TikTok).
6745
+ *
6746
+ * Distinct from {@link trackEvent}, which posts a cookieless pageview/beacon
6747
+ * to Brainerce's own storefront analytics. This one is about ad platforms —
6748
+ * call both; they answer different questions.
6749
+ *
6750
+ * You describe what happened once, in GA4's vocabulary, and the SDK
6751
+ * translates: a `dataLayer` push for GA4/GTM, the matching Meta standard
6752
+ * event via `fbq`, and the matching TikTok event via `ttq`. Tags that aren't
6753
+ * loaded are skipped silently, so the same call is correct whether the
6754
+ * merchant has connected none, one, or all of them.
6755
+ *
6756
+ * Why this matters for ad spend: a GTM container with no `dataLayer` events
6757
+ * is an empty container, and Meta cannot optimize a campaign it never sees a
6758
+ * `Purchase` for. The value/currency/item-id triple in {@link TrackingEventPayload}
6759
+ * is the whole input to that optimization.
6760
+ *
6761
+ * `purchase` is de-duplicated by the vendors on `transactionId` (GA4
6762
+ * `transaction_id`, Meta `eventID`, TikTok `event_id`), so a shopper
6763
+ * refreshing the confirmation page cannot double-count the order — pass the
6764
+ * order id and the safety is automatic.
6765
+ *
6766
+ * SSR-safe and never throws.
6767
+ */
6768
+ trackMarketingEvent(name: TrackingEventName, payload?: TrackingEventPayload): void;
6769
+ /** Install the GTM container loader. Idempotent; no-op if already present. */
6770
+ private loadGtm;
6771
+ /** Install the Meta pixel and fire its initial PageView. Idempotent. */
6772
+ private loadMetaPixel;
6773
+ /** Install the TikTok pixel and fire its initial page view. Idempotent. */
6774
+ private loadTikTokPixel;
6575
6775
  /**
6576
6776
  * Merge the resolved GA4 stitch ids onto a request body — only for fields
6577
6777
  * the caller didn't already set explicitly (explicit values always win).
@@ -10474,6 +10674,24 @@ declare class BrainerceClient {
10474
10674
  appId: string;
10475
10675
  name?: string | null;
10476
10676
  }>>;
10677
+ /**
10678
+ * List a region's manual price overrides (regional pricing, admin). Prices
10679
+ * are in the region's currency; `variantId: null` rows are product-level.
10680
+ */
10681
+ getRegionPrices(regionId: string, params?: {
10682
+ productId?: string;
10683
+ page?: number;
10684
+ limit?: number;
10685
+ }): Promise<PaginatedResponse<RegionPrice>>;
10686
+ /**
10687
+ * Bulk upsert/remove manual price overrides for a region (admin). Each
10688
+ * entry: `price` = regular, `salePrice` = sale (must be lower), in the
10689
+ * REGION's currency; `remove: true` deletes. A product/variant with no
10690
+ * entry keeps automatic FX conversion.
10691
+ */
10692
+ upsertRegionPrices(regionId: string, entries: RegionPriceEntry[]): Promise<UpsertRegionPricesResult>;
10693
+ /** Delete one manual price override by id (admin). */
10694
+ deleteRegionPrice(regionId: string, priceId: string): Promise<void>;
10477
10695
  /**
10478
10696
  * List the store's ACTIVE regions (public, no apiKey). Works in storeId and
10479
10697
  * vibe-coded modes. Returns only storefront-safe fields (no internal flags).
@@ -11126,7 +11344,7 @@ declare class BrainerceError extends Error {
11126
11344
  constructor(message: string, statusCode: number, details?: unknown);
11127
11345
  }
11128
11346
 
11129
- declare const SDK_VERSION = "1.53.1";
11347
+ declare const SDK_VERSION = "1.54.0";
11130
11348
 
11131
11349
  /**
11132
11350
  * Verify a webhook signature from Brainerce
@@ -11524,4 +11742,4 @@ interface CategorySitemapOptions {
11524
11742
  */
11525
11743
  declare function getCategorySitemapEntries(client: BrainerceClient, opts: CategorySitemapOptions): Promise<SitemapEntry[]>;
11526
11744
 
11527
- export { type AddToCartDto, type AddressDetailsResult, type AddressSuggestion, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, type Attribute, type AttributeOption, type AttributeSource, type BlogSitemapOptions, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type BusinessHoursWindow, type Cart, type CartAppliedDiscount, type CartBundleOffer, type CartBundlesResponse, type CartIncludeOption, type CartIncludeOptions, type CartItem, type CartItemModifierLine, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type CartWithIncludes, type Category, type CategoryDetail, type CategoryNode, type CategorySitemapOptions, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutBumpsResponse, type CheckoutCustomFieldDefinition, type CheckoutFieldPricing, type CheckoutFieldVisibility, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type ContactFormFieldType, type ContactFormFieldValidation, type ContactFormPublic, type ContactFormPublicField, type ContactFormSummary, type Content, type ContentDataMap, type ContentStatus, type ContentSummary, type ContentType, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateContentInput, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateModifierGroupInput, type CreateModifierInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateTagDto as CreateTagInput, type CreateTaxRateDto as CreateTaxRateInput, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DateAvailabilityConstraints, type DateFieldParseResult, type DeleteProductResponse, type DiscountBanner, type DiscountRuleType, type DownloadFile, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailTemplatesResponse, type EmailVerificationResponse, type ExtendReservationResponse, type FaqContent, type FaqItem, type FooterColumn, type FooterContent, type FooterLink, type FooterSocialLink, type FormatPriceOptions, type FormatProductPriceOptions, type FreeAllocationPolicy, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type HeaderContent, type HeaderCta, type HeaderLogo, type HeaderNavItem, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type JsonLdOptions, type ListModifierGroupsParams, type LocalCart, type LocalCartItem, type LockedVariant, type LoyaltyNextTierSummary, type LoyaltyReward, type LoyaltyStatus, type LoyaltyTierSummary, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldFilter, type MetafieldFilterValue, type MetafieldFiltersResponse, type MetafieldType, type Modifier, type ModifierGroup, type ModifierSelection, type ModifierSelectionType, type ModifierValidationCode, type ModifierValidationError, type MyProductReview, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type Order, type OrderAddress, type OrderBump, type OrderCustomer, type OrderDownloadLink, type OrderItem, type OrderQueryParams, type OrderStatus, type OrderStatusChange, type PageContent, type PageSeo, type PaginatedResponse, type ParsedDateFieldValue, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PaymentUrlOptions, type PickupLocation, type PlatformCouponCapabilities, type PlatformMetafieldMetadata, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductModifierGroupAttachment, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductReview, type ProductReviewAdmin, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, RTL_LOCALES, type RecommendationVariant, type ReconcileInventoryResponse, type RedeemRewardResult, type ReferralInfo, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type RichTextContent, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, type SetMetafieldPlatformsDto as SetMetafieldPlatformsInput, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingDestinations, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingSummaryEntry, type ShippingZone, type ShippingZoneQueryParams, type SitemapEntry, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type SubmitProductReviewInput, type SupportedLocaleObject, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type UpdateAddressDto, type UpdateAttachmentInput, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateContentInput, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateModifierGroupInput, type UpdateModifierInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateStoreMemberDto as UpdateStoreMemberInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type UserStore, type UserStorePermissions, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, type WriteProductReviewInput, buildArticleJsonLd, buildBreadcrumbJsonLd, buildCollectionPageJsonLd, buildOrganizationJsonLd, buildProductJsonLd, buildWebsiteJsonLd, computeAvailableSlots, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getBlogSitemapEntries, getBusinessHoursForDate, getCartItemImage, getCartItemName, getCartTotals, getCategorySitemapEntries, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCalendarDateAllowed, isCouponApplicableToProduct, isDateValueAllowed, isHtmlDescription, isWebhookEventType, jsonLdScriptProps, parseDateFieldValue, parseWebhookEvent, resolveStoreLocalParts, safePaymentRedirect, stripHtml, validateDateAvailabilityConfig, verifyWebhook };
11745
+ export { type AddToCartDto, type AddressDetailsResult, type AddressSuggestion, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, type Attribute, type AttributeOption, type AttributeSource, type BlogPost, type BlogPostListParams, type BlogPostListResponse, type BlogSitemapOptions, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type BusinessHoursWindow, type Cart, type CartAppliedDiscount, type CartBundleOffer, type CartBundlesResponse, type CartIncludeOption, type CartIncludeOptions, type CartItem, type CartItemModifierLine, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type CartWithIncludes, type Category, type CategoryDetail, type CategoryNode, type CategorySitemapOptions, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutBumpsResponse, type CheckoutCustomFieldDefinition, type CheckoutFieldPricing, type CheckoutFieldVisibility, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type ContactFormFieldType, type ContactFormFieldValidation, type ContactFormPublic, type ContactFormPublicField, type ContactFormSummary, type Content, type ContentDataMap, type ContentStatus, type ContentSummary, type ContentType, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateContentInput, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateModifierGroupInput, type CreateModifierInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateTagDto as CreateTagInput, type CreateTaxRateDto as CreateTaxRateInput, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DateAvailabilityConstraints, type DateFieldParseResult, type DeleteProductResponse, type DiscountBanner, type DiscountRuleType, type DownloadFile, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailTemplatesResponse, type EmailVerificationResponse, type ExtendReservationResponse, type FaqContent, type FaqItem, type FooterColumn, type FooterContent, type FooterLink, type FooterSocialLink, type FormatPriceOptions, type FormatProductPriceOptions, type FreeAllocationPolicy, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type HeaderContent, type HeaderCta, type HeaderLogo, type HeaderNavItem, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type JsonLdOptions, type ListModifierGroupsParams, type LocalCart, type LocalCartItem, type LockedVariant, type LoyaltyNextTierSummary, type LoyaltyReward, type LoyaltyStatus, type LoyaltyTierSummary, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldFilter, type MetafieldFilterValue, type MetafieldFiltersResponse, type MetafieldType, type Modifier, type ModifierGroup, type ModifierSelection, type ModifierSelectionType, type ModifierValidationCode, type ModifierValidationError, type MyProductReview, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type Order, type OrderAddress, type OrderBump, type OrderCustomer, type OrderDownloadLink, type OrderItem, type OrderQueryParams, type OrderStatus, type OrderStatusChange, type PageContent, type PageSeo, type PaginatedResponse, type ParsedDateFieldValue, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PaymentUrlOptions, type PickupLocation, type PlatformCouponCapabilities, type PlatformMetafieldMetadata, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductModifierGroupAttachment, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductReview, type ProductReviewAdmin, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, RTL_LOCALES, type RecommendationVariant, type ReconcileInventoryResponse, type RedeemRewardResult, type ReferralInfo, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type RichTextContent, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, type SetMetafieldPlatformsDto as SetMetafieldPlatformsInput, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingDestinations, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingSummaryEntry, type ShippingZone, type ShippingZoneQueryParams, type SitemapEntry, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type StoreTracking, type SubmitProductReviewInput, type SupportedLocaleObject, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type TrackingEventItem, type TrackingEventName, type TrackingEventPayload, type UpdateAddressDto, type UpdateAttachmentInput, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateContentInput, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateModifierGroupInput, type UpdateModifierInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateStoreMemberDto as UpdateStoreMemberInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type UserStore, type UserStorePermissions, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, type WriteProductReviewInput, buildArticleJsonLd, buildBreadcrumbJsonLd, buildCollectionPageJsonLd, buildOrganizationJsonLd, buildProductJsonLd, buildWebsiteJsonLd, computeAvailableSlots, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getBlogSitemapEntries, getBusinessHoursForDate, getCartItemImage, getCartItemName, getCartTotals, getCategorySitemapEntries, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCalendarDateAllowed, isCouponApplicableToProduct, isDateValueAllowed, isHtmlDescription, isWebhookEventType, jsonLdScriptProps, parseDateFieldValue, parseWebhookEvent, resolveStoreLocalParts, safePaymentRedirect, stripHtml, validateDateAvailabilityConfig, verifyWebhook };