@faststore/api 4.9.3-dev.0 → 4.9.3-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1,12 +1,12 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ln=require("@graphql-tools/merge"),dn=require("@graphql-tools/schema"),j=require("@graphql-tools/utils"),ce=require("graphql"),$=require("@faststore/diagnostics"),nt=require("isomorphic-unfetch"),te=require("cookie"),Pe=require("p-limit"),ge=require("dataloader"),tt=require("sanitize-html"),Ee=require("fast-deep-equal"),rt=require("node:crypto");var un=(e=>(e.Personal="personal",e.Shared="shared",e))(un||{}),pn=(e=>(e.Accepted="accepted",e.Denied="denied",e.Pending="pending",e))(pn||{}),gn=(e=>(e.Brand="Brand",e.Category="Category",e.Cluster="Cluster",e.Collection="Collection",e.Department="Department",e.SubCategory="SubCategory",e))(gn||{}),mn=(e=>(e.Boolean="BOOLEAN",e.Range="RANGE",e))(mn||{}),hn=(e=>(e.DiscountDesc="discount_desc",e.NameAsc="name_asc",e.NameDesc="name_desc",e.OrdersDesc="orders_desc",e.PriceAsc="price_asc",e.PriceDesc="price_desc",e.ReleaseDesc="release_desc",e.ScoreDesc="score_desc",e))(hn||{}),fn=(e=>(e.Error="ERROR",e.Info="INFO",e.Warning="WARNING",e))(fn||{}),Sn=(e=>(e.Input="Input",e.Output="Output",e))(Sn||{});const it=()=>function(n={}){const t=process.env.FS_DISCOVERY_APP_KEY??"",r=process.env.FS_DISCOVERY_APP_TOKEN??"";if(!t||!r)throw new H("No authentication AppKey and AppToken passed.");return{...n,"X-VTEX-API-AppKey":t,"X-VTEX-API-AppToken":r}},yn=async e=>{const{clients:{commerce:n}}=e;try{if((await n.vtexid.validate())?.authStatus?.toLowerCase()!=="success")throw new ee("Authentication required")}catch(t){const r=t.extensions?.status??t.status;throw r===401?new ee("Authentication required"):r===403?new H("You are not allowed to access this resource"):new ee("Authentication required")}},at="auth",In={typeDefs:"directive @auth on FIELD_DEFINITION",transformer:e=>j.mapSchema(e,{[j.MapperKind.OBJECT_FIELD]:n=>{if(j.getDirective(e,n,at)?.[0]){const r=n.resolve;n.resolve=async(i,a,o,s)=>(await yn(o),r?.(i,a,o,s))}return n}})},ot="cacheControl",st=(e,n)=>{const{scope:t="private",sMaxAge:r=0,staleWhileRevalidate:i=0}=e;return`${n?"private":t}, s-maxage=${r}, stale-while-revalidate=${i}`},Re=(e,n)=>typeof e=="number"&&typeof n=="number"?e>n?n:e:typeof e=="number"?e:n,ct=(e,n)=>typeof e=="string"&&typeof n=="string"?e==="public"&&n==="public"?"public":"private":e||n,vn={typeDefs:"directive @cacheControl(sMaxAge: Int, staleWhileRevalidate: Int, scope: String) on FIELD_DEFINITION",transformer:e=>j.mapSchema(e,{[j.MapperKind.OBJECT_FIELD]:n=>{const t=j.getDirective(e,n,ot)?.[0];if(t){const{sMaxAge:r,staleWhileRevalidate:i,scope:a}=t,o=n.resolve;n.resolve=(s,c,u,d)=>(u.cacheControl={sMaxAge:Re(u.cacheControl?.sMaxAge,r),staleWhileRevalidate:Re(u.cacheControl?.staleWhileRevalidate,i),scope:ct(u.cacheControl?.scope,a)},o?.(s,c,u,d))}return n}})},On=e=>(n,t)=>{const r=ln.mergeTypeDefs([...(e??[]).map(({typeDefs:i})=>i),t]);return(e??[]).reduce((i,{transformer:a})=>a?.(i)??i,dn.makeExecutableSchema({typeDefs:r,resolvers:n}))},bn="@faststore/api",Cn="4.9.2",Fe={name:bn,version:Cn},lt=$.logger("@faststore/api"),dt=(e,n="Unknown Graphql Resolver")=>(t,r,i,a)=>{if(!i?.OTEL_ENABLED)return e(t,r,i,a);const o=$.OTELAPI.trace.getTracer("Graphql").startSpan(n,{kind:$.OTELAPI.SpanKind.INTERNAL,attributes:{timestamp:Date.now(),"@faststore_version":Cn,"@faststore_package_name":bn,"@faststore_account_name":i.account,"@faststore_environment":process.env.NODE_ENV,"@faststore_resolver_parent_type":a?.parentType?.name,"@faststore_resolver_field_name":a?.fieldName}}),s=$.OTELAPI.trace.setSpan($.OTELAPI.context.active(),o);try{const c=$.OTELAPI.context.with(s,()=>e(t,r,i,a));return c instanceof Promise?c.then(u=>(o.end(),u),u=>Ne(u,o,n)):(o.end(),c)}catch(c){return Ne(c,o,n)}};function Ne(e,n,t){throw n.setStatus({code:$.OTELAPI.SpanStatusCode.ERROR}),n.recordException(e),n.end(),console.error(`Error at resolver: ${t}:
2
- %o`,e),lt("error",`Error at resolver: %s
3
- %o`,t,e),e}class Y extends Error{constructor(n,t){super(t),this.extensions=n,this.name="FastStoreError"}}class E extends Y{constructor(n){super({status:400,type:"BadRequestError"},n)}}class ee extends Y{constructor(n){super({status:401,type:"UnauthorizedError"},n)}}class H extends Y{constructor(n){super({status:403,type:"ForbiddenError"},n)}}class L extends Y{constructor(n){super({status:404,type:"NotFoundError"},n)}}const ut=e=>e?.name==="FastStoreError",pt=e=>e?.extensions?.type==="BadRequestError",gt=e=>e?.extensions?.type==="UnauthorizedError",wn=e=>e?.extensions?.type==="ForbiddenError",W=e=>e?.extensions?.type==="NotFoundError",mt=`${Fe.name}@${Fe.version}`,y=async(e,n,t)=>{const r=await nt(e,{...n,headers:{...n?.headers??{},"User-Agent":mt}});if(r.ok)return t?.storeCookies&&t.storeCookies(r.headers),r.status!==204?r.json():void 0;console.error(e,n,r);const i=await r.text();if(typeof r?.status=="number")switch(r.status){case 400:throw new E(i);case 401:throw new ee(i);case 403:throw new H(i);case 404:throw new L(i);default:throw new Y({status:r.status,type:"UnknownError"},i)}throw new Error(i)},ht=({account:e,environment:n})=>{const t=`https://${e}.${n}.com.br`;return{getLocalizedProduct:(r,i)=>y(`${t}/api/catalog-dataplane/product/${r}`,{method:"GET",headers:{"Accept-Language":i,"Content-Type":"application/json"}})}},An=e=>{if(!e)return e;const n=new Map,t=e.split(";"),r=[];return t.forEach(i=>{const a=i.trim();if(a){const o=a.indexOf("=");if(o>0){const s=a.substring(0,o),c=a.substring(o+1);n.has(s)||r.push(s),n.set(s,c)}}}),r.map(i=>`${i}=${n.get(i)}`).join("; ")},ft=/^([^=]+)=([^;]*)/,St=(e,n)=>{const t=n.match(ft);if(t){const r=t[1],i=t[2];e.storage.cookies.set(r,{value:i,setCookie:n})}},yt=(e,n)=>{n.getSetCookie().forEach(t=>St(e,t))},It=e=>n=>yt(e,n),fe=e=>{if(!e.headers?.cookie)return null;const n=An(e.headers.cookie),t=Array.from(e.storage.cookies.entries());return t.length===0?n:t.reduce((r,[i,{value:a}])=>vt(r,i,a),n)},Dn=e=>function(t){const r=fe(e);return r?{...t,cookie:r}:t},N=(e,n)=>{const t=An(e);return te.parse(t)[`VtexIdclientAutCookie_${n}`]||""},vt=(e,n,t)=>{const r=new RegExp(`(${n})=([^;]*)`),i=e.match(r);return i?e.replace(i[0],`${i[1]}=${t}`):`${e};${n}=${t}`};function q(e){if(!e)return null;try{return JSON.parse(Buffer.from(e.split(".")[1],"base64").toString())}catch{return null}}const Ot="storefront/faststore.recommendation-shelf@v4",K={method:"POST",headers:{"content-type":"application/json"}},bt=e=>e.split("/").map(encodeURIComponent).join("/"),me=e=>e?{headers:{"Accept-Language":e}}:void 0,Ct=/^\d{4}-\d{2}-\d{2}$/,wt=new Set(["Draft","Requested","InReview","Reviewed","Approved","Declined","Expired","ConvertedToCart","ConvertedToOrder"]);function At({page:e,perPage:n,status:t,createdAtFrom:r,createdAtTo:i,expiresAtFrom:a,expiresAtTo:o}){if(e!==void 0&&(!Number.isInteger(e)||e<1))throw new Error(`listUserQuotes: invalid page "${e}" — must be a positive integer`);if(n!==void 0&&(!Number.isInteger(n)||n<1))throw new Error(`listUserQuotes: invalid perPage "${n}" — must be a positive integer`);for(const[s,c]of[["createdAtFrom",r],["createdAtTo",i],["expiresAtFrom",a],["expiresAtTo",o]])if(c&&!Ct.test(c))throw new Error(`listUserQuotes: invalid ${s} "${c}" — must be YYYY-MM-DD`);if(t&&t.length>0){const s=t.filter(c=>!wt.has(c));if(s.length>0)throw new Error(`listUserQuotes: invalid status values: ${s.join(", ")}`)}}function Dt({page:e,perPage:n,status:t,createdAtFrom:r,createdAtTo:i,expiresAtFrom:a,expiresAtTo:o,label:s}){const c=new URLSearchParams;return e&&c.append("pageNumber",e.toString()),n&&c.append("pageSize",n.toString()),t?.forEach(u=>c.append("status",u)),r&&c.append("createdAtFrom",r),i&&c.append("createdAtTo",i),a&&c.append("expiresAtFrom",a),o&&c.append("expiresAtTo",o),s?.trim()&&c.append("label",s.trim()),c}const Pt=({account:e,environment:n,incrementAddress:t,subDomainPrefix:r},i)=>{const a=`https://${e}.${n}.com.br`,o=It(i),s=Dn(i),c=it(),u=new Headers(i.headers).get("x-forwarded-host")??i.headers?.host??"",d=r&&r.map(l=>l+".").find(l=>u.includes(l))||"",g=u.replace(d,""),f=`${a}/api/recommend-bff/v2`,h=s({accept:"application/json","content-type":"application/json","x-vtex-rec-origin":`${e}/${Ot}`}),v=(l={})=>{const p=N(fe(i)??"",e);return s({...l,"X-FORWARDED-HOST":g,...p?{[`VtexIdclientAutCookie_${e}`]:p}:{}})};return{catalog:{salesChannel:l=>y(`${a}/api/catalog_system/pub/saleschannel/${l}`,void 0,{storeCookies:o}),brand:{list:()=>y(`${a}/api/catalog_system/pub/brand/list`,void 0,{storeCookies:o})},category:{tree:(l=3)=>y(`${a}/api/catalog_system/pub/category/tree/${l}`,void 0,{storeCookies:o})},portal:{pagetype:l=>y(`${a}/api/catalog_system/pub/portal/pagetype/${l}`,void 0,{storeCookies:o})},byLinkId:{category:async(l,p)=>{try{return await y(`${a}/api/catalog_system/pub/category/by-linkid/${bt(l)}`,me(p))}catch(m){if(W(m))return null;throw m}},brand:async(l,p)=>{try{return await y(`${a}/api/catalog_system/pub/brand/by-linkid/${encodeURIComponent(l)}`,me(p))}catch(m){if(W(m))return null;throw m}},collection:async(l,p)=>{try{return await y(`${a}/api/catalog_system/pub/collection/by-linkid/${encodeURIComponent(l)}`,me(p))}catch(m){if(W(m))return null;throw m}}},products:{crossselling:({type:l,productId:p,groupByProduct:m=!0})=>{const S=new URLSearchParams({sc:i.storage.channel.salesChannel,groupByProduct:m.toString()});return y(`${a}/api/catalog_system/pub/products/crossselling/${l}/${p}?${S}`,void 0,{storeCookies:o})}}},checkout:{simulation:(l,{salesChannel:p}=i.storage.channel)=>{const m=new URLSearchParams({sc:p}),S=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/checkout/pub/orderForms/simulation?${m.toString()}`,{...K,headers:S,body:JSON.stringify(l)},{storeCookies:o})},shippingData:({id:l,index:p,deliveryMode:m,selectedAddresses:S},O)=>{const w=O?{startDateUtc:m?.deliveryWindow?.startDate,endDateUtc:m?.deliveryWindow?.endDate}:null,C={logisticsInfo:Array.from({length:p},(I,A)=>({itemIndex:A,selectedDeliveryChannel:m?.deliveryChannel||null,selectedSla:m?.deliveryMethod||null,deliveryWindow:w})),selectedAddresses:S,clearAddressIfPostalCodeNotFound:t},T=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/checkout/pub/orderForm/${l}/attachments/shippingData`,{...K,headers:T,body:JSON.stringify(C)},{storeCookies:o})},marketingData:({id:l,marketingData:p})=>{const m=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/checkout/pub/orderForm/${l}/attachments/marketingData`,{headers:m,body:JSON.stringify(p),method:"POST"},{storeCookies:o})},clientPreferencesData:({id:l,clientPreferencesData:p})=>{const m=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/checkout/pub/orderForm/${l}/attachments/clientPreferencesData`,{headers:m,body:JSON.stringify(p),method:"POST"},{storeCookies:o})},orderForm:({id:l,refreshOutdatedData:p=!0,channel:m=i.storage.channel,preserveSalesChannel:S=!1})=>{const{salesChannel:O}=m,w=s({"content-type":"application/json","X-FORWARDED-HOST":g}),C=new URLSearchParams;(!S||!l)&&C.set("sc",O),l&&C.set("refreshOutdatedData",p.toString());const T=l?`/${l}`:"",I=`${a}/api/checkout/pub/orderForm${T}?${C}`;return y(I,{...K,headers:w,...l?{}:{body:"{}"}},{storeCookies:o})},clearOrderFormMessages:({id:l})=>{const p=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/checkout/pub/orderForm/${l}/messages/clear`,{...K,headers:p,body:"{}"})},updateOrderFormItems:({id:l,orderItems:p,allowOutdatedData:m="paymentData",salesChannel:S=i.storage.channel.salesChannel,shouldSplitItem:O=!0})=>{const w=new URLSearchParams({allowOutdatedData:m,sc:S}),C=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/checkout/pub/orderForm/${l}/items?${w}`,{headers:C,body:JSON.stringify({orderItems:p,noSplitItem:!O}),method:"PATCH"},{storeCookies:o})},setCustomData:({id:l,appId:p,key:m,value:S})=>{const O=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/checkout/pub/orderForm/${l}/customData/${p}/${m}`,{headers:O,body:JSON.stringify({value:S}),method:"PUT"})},region:async({postalCode:l,geoCoordinates:p,country:m,salesChannel:S})=>{const O=new URLSearchParams({country:m,sc:S??""});l?O.append("postalCode",l):O.append("geoCoordinates",`${p?.longitude};${p?.latitude}`);const w=`${a}/api/checkout/pub/regions/?${O.toString()}`,C=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(w,{headers:C},{storeCookies:o})},address:async({postalCode:l,country:p})=>{const m=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/checkout/pub/postal-code/${p}/${l}`,{headers:m},{storeCookies:o})},cancelOrder:({orderId:l,customerEmail:p,reason:m})=>{const S=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/checkout/pub/orders/${l}/user-cancel-request`,{method:"POST",headers:S,body:JSON.stringify({customerEmail:p,reason:m})},{})},pickupPoints:({geoCoordinates:l})=>{if(!l)throw new Error("Missing required parameter for listing pickup points.");const p=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/logistics-shipping/pickuppoints/_search`,{method:"POST",headers:p,body:JSON.stringify({coordinate:l})},{storeCookies:o})}},session:l=>{const p=new URLSearchParams(l);p.set("items","profile.id,profile.email,profile.firstName,profile.lastName,profile.phone,shopper.firstName,shopper.lastName,shopper.organizationManager,shopper.availableContracts,shopper.activeContractId,store.channel,store.countryCode,store.cultureInfo,store.currencyCode,store.currencySymbol,authentication.customerId,authentication.storeUserId,authentication.storeUserEmail,authentication.unitId,authentication.unitName,checkout.regionId,public.postalCode");const m=s({"content-type":"application/json"}),S=te.parse(i?.headers?.cookie??"")?.vtex_session;return y(`${a}/api/sessions?${p.toString()}`,{method:S?"PATCH":"POST",headers:m,body:"{}"},{storeCookies:o})},storeFront:{attachedContracts:l=>{const p=s({"content-type":"application/json"});return y(`https://${e}.myvtex.com/_v/store-front/units/${encodeURIComponent(l)}/contracts/attached?details=true`,{headers:p},{storeCookies:o})}},subscribeToNewsletter:l=>y(`${a}/api/dataentities/NL/documents/`,{...K,body:JSON.stringify({...l,isNewsletterOptIn:!0}),method:"PATCH"},{storeCookies:o}),profile:{addresses:async l=>{const p=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/profile-system/pvt/profiles/${l}/addresses`,{headers:p},{storeCookies:o})}},oms:{userOrder:({orderId:l})=>{const p=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/oms/user/orders/${l}`,{method:"GET",headers:p},{storeCookies:o})},listUserOrders:({page:l,status:p,dateInitial:m,dateFinal:S,text:O,clientEmail:w,perPage:C,pendingMyApproval:T})=>{const I=new URLSearchParams;if(m){const D=new Date(m).setHours(0,0,0,0);m=new Date(D).toISOString()}if(S){const D=new Date(S).setHours(23,59,59,999);S=new Date(D).toISOString()}O&&I.append("text",O),p&&p.length>0&&I.append("status",p.filter(Boolean).join(",")),m&&S?I.append("creation_date",`creationDate:[${m} TO ${S}]`):m?I.append("creation_date",`creationDate:[${m} TO *]`):S&&I.append("creation_date",`creationDate:[* TO ${S}]`),w&&I.append("clientEmail",w),l&&I.append("page",l.toString()),C&&I.append("per_page",C.toString()),T&&I.append("my_pending_approvals",String(!0));const A=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/oms/user/orders?${I.toString()}`,{method:"GET",headers:A},{storeCookies:o})},getCommercialAuthorizationsByOrderId:({orderId:l})=>{const p=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/${e}/commercial-authorizations/order/${l}`,{method:"GET",headers:p},{storeCookies:o})},processOrderAuthorization:async({orderAuthorizationId:l,dimensionId:p,ruleId:m,approved:S})=>{const O=s({"content-type":"application/json","X-FORWARDED-HOST":g}),T={params:{ruleId:m,dimensionId:p,score:S?100:0}};return y(`${a}/${e}/commercial-authorizations/${l}/callback`,{method:"POST",headers:O,body:JSON.stringify(T)},{storeCookies:o})}},savedCards:{listCreditCards:()=>{const l=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/saved-cards/credit-card?an=${e}`,{method:"GET",headers:l},{storeCookies:o})}},units:{getUnitByUserId:({userId:l})=>{const p=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/units/v1/${l}/unit`,{method:"GET",headers:p},{})},getOrgUnitById:({orgUnitId:l})=>{const p=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/units/v1/${l}`,{method:"GET",headers:p},{})},getScopesByOrgUnit:({orgUnitId:l})=>{const p=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/units/v1/${l}/scopes`,{method:"GET",headers:p},{})}},licenseManager:{getUserById:({userId:l})=>{const p=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/license-manager/users/${l}`,{method:"GET",headers:p},{})},getUserByEmail:({email:l})=>{const p=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/license-manager/pvt/users/${l}`,{method:"GET",headers:p},{})},getUserRoles:({userId:l})=>{const p=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/license-manager/storefront/users/${l}/roles`,{method:"GET",headers:p},{})},isResourceGranted:({userId:l,resourceKey:p})=>{const m=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/license-manager/storefront/bff/users/${l}/resources/${p}/granted?an=${e}`,{method:"GET",headers:m},{})}},masterData:{getContractById:({contractId:l})=>{if(!l)throw new E("Missing contractId to fetch CL fields.");const p=v({Accept:"application/json","content-type":"application/json"});return y(`${a}/api/dataentities/CL/documents/${l}?_fields=_all`,{method:"GET",headers:p},{})},getShopperById:({userId:l})=>{if(!l)throw new E("Missing userId to fetch shopper name.");const p=c({Accept:"application/json","content-type":"application/json","X-FORWARDED-HOST":g}),m=l.replace(/-/g,"");return y(`${a}/api/dataentities/shopper/search?_where=(userId=${m} OR userId=${l})&_fields=_all&_schema=v1`,{method:"GET",headers:p},{})}},quotes:{listUserQuotes:l=>{At(l);const p=Dt(l),m=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/quoting/quotes?${p.toString()}`,{method:"GET",headers:m},{storeCookies:o})}},vtexid:{validate:()=>{const l=s({"content-type":"application/json","X-FORWARDED-HOST":g}),p=N(fe(i)??"",e);return y(`${a}/api/vtexid/credential/validate`,{headers:l,body:JSON.stringify({token:p}),method:"POST"},{storeCookies:o})}},orderEntry:{uploadFile:({fileBuffer:l,fileName:p,mimeType:m})=>{const S=s({"content-type":"application/json","X-FORWARDED-HOST":g}),O=`----FastStoreUploadBoundary${Date.now()}`,w=`\r
4
- `,T=/^[a-zA-Z0-9][a-zA-Z0-9!#$&\-.^_]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&\-.^_+]*$/.test(m)?m:"application/octet-stream",I=p.replaceAll(/[\r\n"]/g,"_"),A=[`--${O}`,`Content-Disposition: form-data; name="file"; filename="${I}"`,`Content-Type: ${T}`,"",""].join(w),D=`${w}--${O}--${w}`,k=Buffer.from(A),P=Buffer.from(D),R=new Uint8Array(k.byteLength+l.byteLength+P.byteLength);let b=0;return R.set(k,b),b+=k.byteLength,R.set(l,b),b+=l.byteLength,R.set(P,b),y(`${a}/api/order-entry/upload?an=${e}`,{method:"POST",headers:{...S,"content-type":`multipart/form-data; boundary=${O}`},body:R.buffer},{})},startOperation:({objectKey:l,orderFormId:p,sessionToken:m})=>{const S=s({"content-type":"application/json","X-FORWARDED-HOST":g}),O=JSON.stringify({objectKey:l,orderFormId:p,operation:"CreateCart",...m?{sessionToken:m}:{}});return y(`${a}/api/order-entry/operation?an=${e}`,{method:"POST",headers:S,body:O},{})},getOperation:({operationId:l})=>{const p=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/order-entry/operation/${l}?an=${e}`,{method:"GET",headers:p},{})},createOrderForm:()=>{const l=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/checkout/pub/orderForm?sc=${i.storage.channel.salesChannel}`,{method:"POST",headers:l,body:"{}"},{})},getOrderFormItems:({orderFormId:l})=>{const p=s({"content-type":"application/json","X-FORWARDED-HOST":g});return y(`${a}/api/checkout/pub/orderForm/${l}`,{method:"GET",headers:p},{})}},recommendation:{recommendations:({campaignVrn:l,userId:p,products:m=[],salesChannel:S,locale:O})=>{const w=new URLSearchParams({an:e,campaignVrn:l});return p&&w.append("userId",p),m.length>0&&w.append("products",m.join(",")),S&&w.append("salesChannel",S),O&&w.append("locale",O),y(`${f}/recommendations?${w.toString()}`,{headers:h},{storeCookies:o})},startRecommendationSession:()=>{const l=new URLSearchParams({an:e});return y(`${f}/users/start-session?${l.toString()}`,{method:"POST",headers:h},{storeCookies:o})}}}},ne=e=>e.discoveryConfig?.localization??{},G=e=>ne(e).enabled===!0,Et=e=>Object.keys(ne(e).locales??{}),kt=e=>ne(e).defaultLocale,Pn=e=>G(e)&&e.storage.locale||void 0,Se="fuzzy",ye="operator",Ie="pickupPoint",Le="shipping",Be="delivery-options",Tt="in-stock",Ut="trade-policy",_t="region-id",Rt=new Set([Ut,_t,Se,ye,Ie]),Ft=new Set(["zip-code","pickupPoint","country","coordinates","deliveryZonesHash","pickupPointsHash"]),$e=e=>encodeURI(decodeURI(e)),Nt=e=>encodeURIComponent(decodeURIComponent(e).normalize("NFD").replaceAll(/[\u0300-\u036f]/g,"")),Lt=/^pickup-in-point-(.+)$/;function En(e){if(!e)return{};try{const t=te.parse(e).vtex_segment;if(!t)return{};const r=Buffer.from(t,"base64").toString("utf-8");return JSON.parse(r)}catch{return{}}}function Bt(e){const n={},t=[];for(const r of e.split(";")){const i=r.indexOf("=");if(i<0)continue;const a=r.slice(0,i),o=r.slice(i+1);!a||!o||(Ft.has(a)?n[a]=o:t.push({key:a,value:o}))}return{shipping:n,extraFacets:t}}function $t(e){const n=typeof e.facets=="string"?e.facets:"",{shipping:t,extraFacets:r}=Bt(n);return{segmentParams:{sc:e.channel,regionId:e.regionId,country:e.countryCode??t.country,locale:e.cultureInfo,"zip-code":t["zip-code"],coordinates:t.coordinates,pickupPoint:t.pickupPoint,deliveryZonesHash:t.deliveryZonesHash,pickupPointHash:t.pickupPointsHash,utmSource:e.utm_source??void 0,utmCampaign:e.utm_campaign??void 0,utmiCampaign:e.utmi_campaign??void 0,campaigns:typeof e.campaigns=="string"?e.campaigns:void 0,priceTables:e.priceTables??void 0},extraFacets:r}}function kn(e,n){const t=[["sc",n.sc],["regionId",n.regionId],["country",n.country],["locale",n.locale],["zip-code",n["zip-code"]],["coordinates",n.coordinates],["pickupPoint",n.pickupPoint],["deliveryZonesHash",n.deliveryZonesHash],["pickupPointHash",n.pickupPointHash],["utmSource",n.utmSource],["utmCampaign",n.utmCampaign],["utmiCampaign",n.utmiCampaign],["campaigns",n.campaigns],["priceTables",n.priceTables]];for(const[r,i]of t)i!=null&&i!==""&&e.append(r,String(i))}function Tn(e){return Lt.exec(e)?.[1]}function Mt(e){const n=e.find(r=>r.key==="shipping"),t=n?Tn(n.value):void 0;if(t!==void 0)try{return decodeURIComponent(t)}catch{return t}}function zt(e,n){const t=Mt(n);return t===void 0?e:{...e,pickupPoint:t}}function Vt(e){return e.map(n=>n.key!=="shipping"||Tn(n.value)===void 0?n:{...n,value:"pickup-in-point"})}function qt(e,n){let t=[...e];const r=t.some(i=>i.key==="shipping");for(const i of n)(!r||i.key!=="shipping")&&t.push(i);return t.some(i=>i.key==="shipping"&&i.value==="ignore")&&(t=t.filter(i=>i.key!=="shipping")),Vt(t)}function xt(e){return e.reduce((n,t)=>{let{key:r,value:i}=t;return r==="priceRange"&&(r="price",i=i.replace(" TO ",":")),r==="ft"?n:`${n}${$e(r)}/${Nt($e(i)).replaceAll(/ |%20/g,"-")}/`},"")}const jt=e=>e.key==="fuzzy"&&(e.value==="0"||e.value==="1"||e.value==="auto"),Wt=e=>e.key==="operator"&&(e.value==="and"||e.value==="or");function Gt(e,n){const{segmentParams:t,extraFacets:r}=$t(e??{}),i=n?.salesChannel??t.sc,a=n?.regionId??t.regionId,o=n?.locale??t.locale??"";return{segmentParams:{...t,...i?{sc:i}:{},...a?{regionId:a}:{},locale:o},extraFacets:r}}function Ht(e,n){const t=e.filter(({key:c})=>!Rt.has(c)),r=e.find(({key:c,value:u})=>c===Le&&u!=="all-delivery-methods")??null,i=e.find(({key:c,value:u})=>c===Be&&u!=="all-delivery-options")??null,a=[...t],o=a.some(({key:c})=>c===Le),s=a.some(({key:c})=>c===Be);return r!==null&&!o&&a.push(r),i!==null&&!s&&a.push(i),qt(a,n)}function Xt(e,n){const t=e.find(({key:a})=>a===Se)??null,r=e.find(({key:a})=>a===ye)??null,i=e.find(({key:a})=>a===Ie)??null;t&&jt(t)&&n.append(Se,t.value),r&&Wt(r)&&n.append(ye,r.value),i&&n.append(Ie,i.value)}function Me(e,n,t,r){const{query:i="",page:a,count:o,sort:s,selectedFacets:c=[],showInvisibleItems:u,sponsoredCount:d,hideUnavailableItems:g,allowRedirect:f=!1}=e,h=new URLSearchParams;if(r.includePagination&&a!==void 0&&o!==void 0){const p=a*o,m=o===0?p:p+o-1;h.append("from",p.toString()),h.append("to",m.toString())}i&&h.append("query",i),r.includeSort&&s&&h.append("sort",s);const v=zt(t.segmentParams,c);if(kn(h,v??t.segmentParams),Xt(c,h),u&&h.append("show-invisible-items","true"),n?.hideUnavailableItems!==void 0){const p=c.find(({key:S})=>S===Tt),m=p?p.value:g?.toString()??n.hideUnavailableItems.toString();h.append("hideUnavailableItems",m)}n?.simulationBehavior!==void 0&&h.append("simulationBehavior",n.simulationBehavior.toString()),n?.showSponsored!==void 0&&h.append("showSponsored",n.showSponsored.toString()),d!==void 0&&h.append("sponsoredCount",d.toString()),f!==void 0&&h.append("allowRedirect",f.toString());const l=xt(Ht(c,t.extraFacets));return{params:h,path:l}}function Yt(e,n){const{field:t,value:r,hideUnavailableItems:i,showInvisibleItems:a}=e,o=new URLSearchParams({field:t??"",value:r??""});return kn(o,n),i&&o.append("hideUnavailableItems","true"),a&&o.append("show-invisible-items","true"),o}function Q(e,n){return{path:e,params:n,toString(){const t=n.toString();return e?t?`${e}?${t}`:e:t?`?${t}`:""}}}function Z(e){const{endpoint:n,segment:t,defaults:r,args:i={}}=e,a=Gt(t,r);switch(n){case"product-search":case"facets":{const{params:o,path:s}=Me(i,r,a,{includePagination:!0,includeSort:!0});return Q(s,o)}case"catalog-count":{const{params:o,path:s}=Me(i,r,a,{includePagination:!1,includeSort:!1});return Q(s,o)}case"products":{const o=Yt(i,a.segmentParams);return Q("",o)}case"search-suggestions":{const o=new URLSearchParams({query:i.query?.toString()??"",locale:r?.locale??a.segmentParams.locale??""});return Q("",o)}case"top-searches":{const o=new URLSearchParams({locale:r?.locale??a.segmentParams.locale??""});return Q("",o)}default:{const o=n;throw new Error(`Unknown intelligent-search endpoint: ${o}`)}}}const Jt=10;function Kt(e){const{regionId:n,seller:t}=e.storage.channel;return(t?Buffer.from(`SW#${t}`).toString("base64"):void 0)??(n||void 0)}function Qt(e){const t=En(e.headers?.cookie).cultureInfo||"";return G(e)?e.storage.locale||t:t||e.storage.locale||""}const Zt=({account:e,environment:n,hideUnavailableItems:t,simulationBehavior:r,showSponsored:i,subDomainPrefix:a},o)=>{const s=`https://${e}.${n}.com.br`,c=Dn(o),u=En(o.headers?.cookie),d=()=>({salesChannel:o.storage.channel.salesChannel,regionId:Kt(o),locale:Qt(o),hideUnavailableItems:t,simulationBehavior:r,showSponsored:i}),g=new Headers(o.headers).get("x-forwarded-host")??o.headers?.host??"",f=a&&a.map(I=>I+".").find(I=>g.includes(I))||"",h=g.replace(f,""),v=c({"content-type":"application/json","X-FORWARDED-HOST":h}),l=({type:I,...A})=>{const D=I==="facets"?"facets":"product-search",k=Z({endpoint:D,segment:u,defaults:d(),args:A});return y(`${s}/api/intelligent-search/v1/${D}/${k.path}?${k.params.toString()}`,{headers:v})},p=I=>l({...I,type:"product_search"}),m=({field:I,value:A,hideUnavailableItems:D,showInvisibleItems:k})=>{const P=Z({endpoint:"products",segment:u,defaults:d(),args:{field:I,value:A,hideUnavailableItems:D,showInvisibleItems:k}});return y(`${s}/api/intelligent-search/v1/products?${P.params.toString()}`,{headers:v})};return{facets:I=>l({...I,type:"facets"}),products:p,fetchProduct:m,productsByIdentifier:async({field:I,values:A,showInvisibleItems:D,hideUnavailableItems:k})=>{const P=Pe(Jt);return(await Promise.all(A.map(b=>P(async()=>{try{return await m({field:I,value:b,hideUnavailableItems:k,showInvisibleItems:D})}catch{return null}})))).filter(b=>b!==null)},suggestedTerms:I=>{const A=Z({endpoint:"search-suggestions",segment:u,defaults:d(),args:{query:I.query}});return y(`${s}/api/intelligent-search/v1/search-suggestions?${A.params.toString()}`,{headers:v})},topSearches:()=>{const I=Z({endpoint:"top-searches",segment:u,defaults:d()});return y(`${s}/api/intelligent-search/v1/top-searches?${I.params.toString()}`,{headers:v})},productCount:I=>{const A=Z({endpoint:"catalog-count",segment:u,defaults:d(),args:I});return y(`${s}/api/intelligent-search/v1/catalog-count/${A.path}?${A.params.toString()}`,{headers:v})}}},er=(e,n)=>{const t=Zt(e,n),r=Pt(e,n),i=ht(e);return{search:t,commerce:r,catalog:i}},nr=20,tr=e=>e.entityType==="category",ve=e=>e.entityType==="brand",ze=e=>e.entityType==="collection",rr=(e,n)=>{const t=Pe(nr),r=async i=>Promise.all(i.map(a=>t(async()=>{const o=a.slug.toLowerCase(),s=a.locale,c=await n.commerce.catalog.byLinkId.category(o,s);if(c)return{...c,entityType:"category",slug:o};const u=await n.commerce.catalog.byLinkId.brand(o,s);if(u)return{...u,entityType:"brand"};const d=await n.commerce.catalog.byLinkId.collection(o,s);if(d)return{...d,entityType:"collection"};throw new L(`No catalog entity found for slug: ${a.slug}. Cascade exhausted (category → brand → collection).`)})));return new ge(r,{batch:!1,cacheKeyFn:({slug:i,locale:a})=>`${i.toLowerCase()}::${a??""}`})},ir=(e,n)=>{const t=async r=>Promise.all(r.map(i=>n.commerce.catalog.salesChannel(i)));return new ge(t)},ar=1,or=(e,n)=>{const t=Pe(ar),r=async a=>{const o=a.reduce((g,{items:f})=>[...g,f],[]),s=[...o.flat()],c=await n.commerce.checkout.simulation({country:a[0].country,postalCode:a[0].postalCode,items:s}),u=c.items.reduce((g,f)=>{const h=f.requestIndex;return typeof h=="number"&&h<g.length&&(g[h]=f),g},Array(s.length).fill(null)),d=o.reduce((g,f)=>[...g,f.length+g[g.length-1]],[0]);return o.map((g,f)=>({...c,items:u.slice(d[f],d[f+1]).filter(h=>!!h)}))},i=async a=>t(r,a);return new ge(i,{maxBatchSize:50})},sr=(e,n)=>tt(e,n);function cr(e){return{...e,description:e.description?sr(e.description):e.description}}const F=(e,n)=>({...e,isVariantOf:cr(n)}),lr=({flags:e},n)=>{const t=async r=>{const i=r.map(d=>d.split("-")[0]),a=r.some(d=>d.split("-")[1]==="invisibleItems"),s=(await n.search.productsByIdentifier({field:"sku",values:i,showInvisibleItems:a,...e?.enableUnavailableItemsOnCart&&{hideUnavailableItems:!1}})).reduce((d,g)=>{for(const f of g.items)d[f.itemId]=F(f,g);return d},{}),c=i.map(d=>s[d]),u=i.filter(d=>!s[d]);if(u.length>0)throw new L(`Search API did not found the following skus: ${u.join(",")}`);return c};return new ge(t,{maxBatchSize:99})},dr=(e,n)=>{const{clients:t}=n,r=lr(e,t),i=or(e,t),a=rr(e,t),o=ir(e,t);return{skuLoader:r,simulationLoader:i,collectionLoader:a,salesChannelLoader:o}},M=e=>e.AvailableQuantity>0,X=e=>e.spotPrice??0,ur=e=>e.Price??0,Ve=e=>e?"https://schema.org/InStock":"https://schema.org/OutOfStock",Un=(e,n)=>M(e)&&!M(n)?-1:!M(e)&&M(n)?1:X(e)-X(n),pr=e=>e==="available",x=(e,n=0,t=1)=>{const r=n/t;return Math.round((e+r)*100)/100},gr=(e,n={includeTaxes:!1})=>{const t=e.filter(M),r=t[t.length-1],i=r?X(r):0;return n.includeTaxes?x(i,r?.Tax,r?.product?.unitMultiplier):i},qe=(e,n={includeTaxes:!1})=>{const[t]=e.filter(M),r=t?X(t):0;return n.includeTaxes?x(r,t?.Tax,t?.product?.unitMultiplier):r},mr={highPrice:e=>gr(e),lowPrice:e=>qe(e),lowPriceWithTaxes:e=>qe(e,{includeTaxes:!0}),offerCount:e=>e.length,priceCurrency:async(e,n,t)=>{const{loaders:{salesChannelLoader:r},storage:{channel:i}}=t;return(await r.load(i.salesChannel)).CurrencyCode??""},offers:e=>e},hr={ratingValue:()=>5,reviewCount:()=>0},xe="ÁÄÂÀÃÅČÇĆĎÉĚËÈÊẼĔȆÍÌÎÏŇÑÓÖÒÔÕØŘŔŠŤÚŮÜÙÛÝŸŽáäâàãåčçćďéěëèêẽĕȇíìîïňñóöòôõøðřŕšťúůüùûýÿžþÞĐđ߯a",fr="AAAAAACCCDEEEEEEEEIIIINNOOOOOORRSTUUUUUYYZaaaaaacccdeeeeeeeeiiiinnooooooorrstuuuuuyyzbBDdBAa",Sr=e=>{let n=e.slice(0);for(let t=0;t<xe.length;t++)n=n.replace(new RegExp(xe.charAt(t),"g"),fr.charAt(t));return n},yr=e=>e.replace(/[·/_,:]/,"-");function le(e){const t=e.replace(/,/g,"").replace(/[*+~.()'"!:@&\[\]`/ %$#?{}><=_^]/g,"-");return yr(Sr(t)).toLowerCase()}const he=e=>e.toLowerCase(),ae=(e,n)=>{const t=n.split("/").filter(Boolean),{loaders:{collectionLoader:r}}=e;return Promise.all(t.map((i,a)=>r.load({slug:t.slice(0,a+1).join("/"),locale:Pn(e)})))},V=e=>tr(e)?e.slug:ve(e)?e.linkId:e.linkId??le(e.name),_n={id:({id:e})=>e.toString(),slug:e=>V(e),seo:e=>({title:e.title??e.name,description:e.metaTagDescription??e.description}),type:e=>ve(e)?"Brand":ze(e)?"Collection":e.fatherCategoryId===null?"Department":"Category",meta:async(e,n,t)=>{const r=V(e);if(ve(e))return{selectedFacets:[{key:"brand",value:r}]};if(ze(e))return{selectedFacets:[{key:"productclusterids",value:e.id}]};const{defaultLocale:i}=ne(t);return{selectedFacets:(await ae(t,r)).map((o,s)=>({key:`category-${s+1}`,value:i&&o.availableLinkIds?.[i]||o.linkId}))}},breadcrumbList:async(e,n,t)=>{const r=await ae(t,V(e));return{itemListElement:r.map((i,a)=>({item:`/${V(i)}`,name:i.name,position:a+1})),numberOfItems:r.length}},otherLocales:async(e,n,t)=>{const r=ne(t);if(!r.enabled)return null;const i=Object.keys(r.locales??{});if(i.length===0)return null;const a=V(e);if(a.split("/").filter(Boolean).length===0)return null;let o;try{o=await ae(t,a)}catch(s){return console.warn("[otherLocales] failed to load collection entities:",s),null}return i.map(s=>{const c=[];for(const u of o){const d=u.availableLinkIds?.[s];if(!d)return null;c.push(d)}return c.length>0?{locale:s,slug:he(c.join("/"))}:null}).filter(s=>s!==null)},canonicalSlug:async(e,n,t)=>{const r=V(e);if(r.split("/").filter(Boolean).length===0)return null;let i;try{i=await ae(t,r)}catch(o){return console.warn("[canonicalSlug] failed to load collection entities:",o),null}const a=i.map(o=>o.linkId);return a.every(o=>!!o)?he(a.join("/")):he(r)}},Rn={buy:"whoboughtalsobought",view:"whosawalsosaw",similars:"similars",viewAndBought:"whosawalsobought",accessories:"accessories",suggestions:"suggestions"},je=({key:e,value:n})=>{switch(e){case"price":return{key:e,value:n.replace("-to-",":")};case"channel":case"locale":case"buy":case"view":case"similars":case"viewAndBought":case"accessories":case"suggestions":return[];default:return{key:e,value:n}}},We=e=>{const n=e.split(":").map(Number);return n.length!==2||Number.isNaN(n[0])||Number.isNaN(n[1])?null:n},Ir=e=>typeof Rn[e]=="string",vr=e=>{const n=e?.filter(t=>Ir(t.key));if(Array.isArray(n)&&n.length>1)throw new E(`You passed ${n.length} cross selling facets but only one is allowed. Please leave one of the following facet: ${n.map(t=>t.key).join(",")}`);return n?.[0]??null},Or=e=>e?.find(n=>n.key==="slug")?.value??null,br=e=>e?.find(n=>n.key==="id")?.value??null,Ge=e=>e?.find(n=>n.key==="locale")?.value??null,He=e=>e?.find(n=>n.key==="channel")?.value??null,Oe=(e,n)=>{let t=0;for(let r=1;r<e.length;r++)n(e[t],e[r])>0&&(t=r);return e[t]},Cr={__resolveType:({type:e,values:n})=>e!=="TEXT"&&e!=="DELIVERY"?"StoreFacetRange":!n||n.length===0?"StoreFacetBoolean":n.every(t=>t.range)?"StoreFacetRange":"StoreFacetBoolean"},wr={key:({key:e})=>e,label:({name:e})=>e,values:({values:e})=>e.sort((n,t)=>n.name.localeCompare(t.name))},Ar={key:({key:e})=>e,label:({name:e})=>e,min:({values:e,key:n},t,{storage:{searchArgs:r}})=>{const i=We(r?.selectedFacets?.find(s=>s.key===n)?.value??""),o=Oe(e,(s,c)=>s.range.from-c.range.from)?.range?.from??0;return{selected:i?.[0]??o,absolute:o}},max:({values:e,key:n},t,{storage:{searchArgs:r}})=>{const i=We(r?.selectedFacets?.find(s=>s.key===n)?.value??""),o=Oe(e,(s,c)=>c.range.to-s.range.to)?.range?.to??0;return{selected:i?.[1]??o,absolute:o}}},Dr={value:({value:e})=>e,label:({name:e})=>e||"unknown",selected:({selected:e})=>e,quantity:({quantity:e})=>e},Pr=async(e,{data:n},{clients:{commerce:t}})=>{if(!n?.orderId)throw new E("Missing orderId");return{data:(await t.checkout.cancelOrder(n))?.data}};function Fn(e){if(!e||e.status!=="pending")return null;for(const n of e.dimensionStatus){if(n.status!=="pending")continue;const t=n.ruleCollection.find(r=>r.status==="pending"&&r.isUserNextAuthorizer);if(t)return{rule:t,orderAuthorizationId:e.id,dimensionId:n.id}}return null}function Er(e){if(!e||e.status!=="pending")return!1;const n=e.dimensionStatus.filter(t=>t.status==="pending").flatMap(t=>t.ruleCollection).filter(t=>t.status==="pending");return n.length===0?!1:n.every(t=>!t.isUserNextAuthorizer)}const kr=async(e,{data:n},{clients:{commerce:t}})=>{const r=await t.oms.processOrderAuthorization(n),i=Fn(r);return{isPendingForOtherAuthorizer:!i&&Er(r),ruleForAuthorization:i}},Tr=async(e,{data:n},{clients:{commerce:t}})=>{if(!n?.objectKey)throw new E("Missing objectKey");const r=n.orderFormId||(await t.orderEntry.createOrderForm()).orderFormId;return t.orderEntry.startOperation({objectKey:n.objectKey,orderFormId:r,sessionToken:n.sessionToken??void 0})},Ur=async(e,n,t)=>{if(!(await t.clients.commerce.recommendation.startRecommendationSession())?.recommendationsUserId)throw new Error("Failed to start recommendation session: no session data returned");return!0},_r=async(e,{data:n},{clients:{commerce:t}})=>({id:(await t.subscribeToNewsletter(n))?.Id}),Rr=async(e,{data:n},{clients:{commerce:t}})=>{const{fileContent:r,fileName:i,mimeType:a}=n;if(!r||!i||!a)throw new E("Missing required fields: fileContent, fileName, mimeType");const o=r.replaceAll(/\s/g,""),s=5*1024*1024;if(Math.floor(o.length*3/4)>s)throw new E("File exceeds maximum allowed size of 5MB");if(!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(o))throw new E("Invalid Base64 fileContent");const d=Buffer.from(o,"base64");return await t.orderEntry.uploadFile({fileBuffer:d,fileName:i,mimeType:a})};class re{static parse(n){try{const t=JSON.parse(n);return{seller:t.seller??"",regionId:t.regionId??"",salesChannel:t.salesChannel??"",hasOnlyDefaultSalesChannel:t.hasOnlyDefaultSalesChannel??!0}}catch(t){throw console.error(t),new Error("Malformed channel string")}}static stringify(n){return JSON.stringify(n)}}function Fr(e,n){return n==null||n===""||String(n)===String(e.salesChannel??"")?null:re.stringify({...e,salesChannel:String(n),hasOnlyDefaultSalesChannel:!1})}const de=(e,n)=>{e.storage.channel=re.parse(n)},be=(e,n)=>{e.storage.locale=n},ke=e=>rt.createHash("md5").update(e).digest("hex"),z={attachment:"ATTACHMENT",specification:"SPECIFICATION",attribute:"ATTRIBUTE",service:"SERVICE"};function Nn(e){return{name:e.name,value:e.content,valueReference:z.attachment}}function Nr(e){return{propertyID:e.id,name:e.name,value:e.value,valueReference:{valueReference:z.attribute,visible:e.visible}}}function Ln(e){return ke(`${e.name}:${JSON.stringify(e.value)}:${e.valueReference}`)}const Bn=(e,n)=>e<n?-1:e>n?1:0,Lr=(e,n)=>Bn(e.name,n.name),Br=e=>[...e??[]].sort(Lr),Xe=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),$r=e=>Xe(e)&&typeof e.name=="string"&&Xe(e.content),Mr=e=>({name:e.name,content:Object.fromEntries(Object.keys(e.content).sort(Bn).map(n=>[n,e.content[n]]))}),$n=(e,n)=>ke(`SERVICE:${e}:${JSON.stringify(Br((n??[]).filter($r)).map(Mr))}`),zr="SERVICE:unreadable";function Te(e){const n=e.attachments??[];return{propertyID:$n(e.id,n),name:e.name,value:{id:e.id,price:e.sellingPrice/100,attachments:n},valueReference:z.service}}const Vr=e=>{try{return JSON.parse(e)}catch{return null}},qr=e=>{const n=typeof e=="string"?Vr(e):e;if(n===null||typeof n!="object")return null;const{id:t,attachments:r}=n;return typeof t!="string"&&typeof t!="number"?null:{id:String(t),attachments:r}};function xr(e){const n=qr(e.value);return n?$n(n.id,Array.isArray(n.attachments)?n.attachments:[]):zr}const jr=e=>{const n=e.postalCode,t=e.geoCoordinates,r={addressType:e.addressType||null,postalCode:n||null,city:null,state:null,country:e.country||null,street:null,number:null,neighborhood:null,complement:null,reference:null,geoCoordinates:[]};if(t){const i=typeof t=="object"&&"latitude"in t?t.latitude:null,a=typeof t=="object"&&"longitude"in t?t.longitude:null;r.geoCoordinates=i!==null&&a!==null?[a,i]:[]}return[r]},Wr=(e,n,t)=>{const r=n.postalCode,i=n.geoCoordinates,a=e?.shippingData?.availableAddresses??[],o=e?.shippingData?.selectedAddresses??[];if(!t&&o.length>0)return[o[0]];if(t&&a.length>0)for(const s of a){if(r&&i&&(s.postalCode===r||s.geoCoordinates[0]===i.longitude&&s.geoCoordinates[1]===i.latitude))return[s];if(r&&!i&&s.postalCode===r)return[s];if(i&&!r&&s.geoCoordinates[0]===i.longitude&&s.geoCoordinates[1]===i.latitude)return[s]}return null},Mn=(e,n)=>{if(!Gr(n))return{updateShipping:!1,addressChanged:!1};if(!Jr(e))return{updateShipping:!1,addressChanged:!1};const[t]=e?.shippingData?.selectedAddresses??[];if(Hr(t,n.postalCode)||Xr(t,n.geoCoordinates)||Yr(t,n.addressType))return{updateShipping:!0,addressChanged:!0};const{logisticsInfo:r}=e.shippingData;return Kr(r,n)?{updateShipping:!0,addressChanged:!1}:{updateShipping:!1,addressChanged:!1}},Gr=e=>!!e.postalCode||e.geoCoordinates?.latitude&&e.geoCoordinates?.longitude,Hr=(e,n)=>typeof n=="string"&&e?.postalCode!==n,Xr=(e,n)=>typeof n?.latitude=="number"&&typeof n?.longitude=="number"&&(e?.geoCoordinates[0]!==n?.longitude||e?.geoCoordinates[1]!==n?.latitude),Yr=(e,n)=>typeof n=="string"&&e?.addressType!==n,Jr=e=>e.items.length!==0,Kr=(e,n)=>{const t=n?.deliveryMode?.deliveryChannel,r=n?.deliveryMode?.deliveryMethod,{startDate:i,endDate:a}=n?.deliveryMode?.deliveryWindow||{};return e.some(({selectedDeliveryChannel:o,selectedSla:s,slas:c})=>{const u=t&&o!==t,d=r&&s!==r;return c?.some(g=>u&&g.deliveryChannel===t||d&&g.id===r?!0:i&&a&&g.deliveryChannel===t&&g.id===r&&(!g?.deliveryWindow||g?.deliveryWindow?.startDateUtc!==i||g?.deliveryWindow?.endDateUtc!==a)&&g.availableDeliveryWindows?.some(f=>f?.startDateUtc===i&&f?.endDateUtc===a))})},zn=e=>e.valueReference===z.attachment,Qr=e=>e.valueReference===z.service,Zr=e=>(e.itemOffered.additionalProperty??[]).filter(Qr).map(xr).sort((n,t)=>n.localeCompare(t)),Vn=e=>{const n=Zr(e);return n.length>0?`services:${n.join("-")}`:void 0},Ce=e=>[e.itemOffered.sku,e.seller.identifier,e.price<.01?"Gift":void 0,e.itemOffered.additionalProperty?.filter(zn).map(Ln).join("-"),Vn(e)].filter(Boolean).join("::"),ue=(e,n)=>({listPrice:e.listPrice/100,price:e.sellingPrice/100,quantity:e.quantity,seller:{identifier:e.seller},itemOffered:{sku:e.id,image:[],name:e.name,additionalProperty:[...e.attachments.map(Nn),...(e.bundleItems??[]).map(Te)]},index:n}),ei=e=>({quantity:e.quantity,seller:e.seller.identifier,id:e.itemOffered.sku,index:e.index,attachments:(e.itemOffered.additionalProperty?.filter(zn)??[]).map(n=>({name:n.name,content:n.value})),...e.priceToken?{priceToken:e.priceToken}:{}}),Ye=e=>e.reduce((n,t)=>{const r=Ce(t);return n.has(r)||n.set(r,[]),n.get(r)?.push(t),n},new Map),ni=(e,n)=>{const t=({priceToken:s,...c},u)=>({...c,itemOffered:{sku:c.itemOffered.sku},services:Vn(c),index:u}),r=n.items.map(ue).map(t),i=e.acceptedOffer.map(t),a=e.orderNumber===n.orderFormId,o=Ee(r,i);return a&&o};function qn(e,n){return e?.some(t=>t.parentItemIndex!==null&&t.parentItemIndex!==void 0&&e[t.parentItemIndex]?.id===n)}function xn(e,n){return e?.some(t=>t.id===n&&t.parentItemIndex!==null)}const Je=e=>{const n=e.items.reduce((t,r,i)=>{const a=xn(e.items,r.id)||qn(e.items,r.id)?`${Ce(ue(r))}::${i}`:Ce(ue(r));return t[a]||(t[a]=[]),t[a].push(r),t},{});return{...e,items:Object.values(n).map(t=>{const[r]=t,i=t.reduce((o,s)=>o+s.quantity,0),a=t.reduce((o,s)=>o+(s?.priceDefinition?.total??(s?.quantity??0)*(s?.sellingPrice??0)),0);return{...r,quantity:i,sellingPrice:a/i}})}},we=async(e,n,t,r)=>({order:{orderNumber:e.orderFormId,acceptedOffer:e.items.map(async i=>({...i,product:await n.load(`${i.id}-invisibleItems`)})),shouldSplitItem:t,...r?{salesChannel:r}:{}},messages:e.messages.map(({text:i,status:a})=>({text:i,status:a.toUpperCase()}))}),jn=({items:e},n)=>{const t=e.map(r=>{const i=(r.bundleItems??[]).map(Te).map(({propertyID:a})=>a).sort((a,o)=>a.localeCompare(o));return{id:r.id,quantity:r.quantity,seller:r.seller,attachments:r.attachments,...i.length>0?{services:i}:{}}});return ke(JSON.stringify({sessionId:n?.id??"",items:t}))},Ke=async(e,n,t)=>{try{return await n.checkout.setCustomData({id:e.orderFormId,appId:"faststore",key:"cartEtag",value:jn(e,t)})}catch(r){throw console.error(`Error while setting custom data to orderForm.
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const pn=require("@graphql-tools/merge"),gn=require("@graphql-tools/schema"),H=require("@graphql-tools/utils"),pe=require("graphql"),z=require("@faststore/diagnostics"),ct=require("isomorphic-unfetch"),ae=require("cookie"),Ue=require("p-limit"),Se=require("dataloader"),lt=require("sanitize-html"),_e=require("fast-deep-equal"),dt=require("node:crypto");var mn=(e=>(e.Personal="personal",e.Shared="shared",e))(mn||{}),hn=(e=>(e.Accepted="accepted",e.Denied="denied",e.Pending="pending",e))(hn||{}),fn=(e=>(e.Brand="Brand",e.Category="Category",e.Cluster="Cluster",e.Collection="Collection",e.Department="Department",e.SubCategory="SubCategory",e))(fn||{}),Sn=(e=>(e.Boolean="BOOLEAN",e.Range="RANGE",e))(Sn||{}),yn=(e=>(e.DiscountDesc="discount_desc",e.NameAsc="name_asc",e.NameDesc="name_desc",e.OrdersDesc="orders_desc",e.PriceAsc="price_asc",e.PriceDesc="price_desc",e.ReleaseDesc="release_desc",e.ScoreDesc="score_desc",e))(yn||{}),In=(e=>(e.Error="ERROR",e.Info="INFO",e.Warning="WARNING",e))(In||{}),vn=(e=>(e.Input="Input",e.Output="Output",e))(vn||{});const ut=()=>function(n={}){const t=process.env.FS_DISCOVERY_APP_KEY??"",r=process.env.FS_DISCOVERY_APP_TOKEN??"";if(!t||!r)throw new J("No authentication AppKey and AppToken passed.");return{...n,"X-VTEX-API-AppKey":t,"X-VTEX-API-AppToken":r}},On=async e=>{const{clients:{commerce:n}}=e;try{if((await n.vtexid.validate())?.authStatus?.toLowerCase()!=="success")throw new re("Authentication required")}catch(t){const r=t.extensions?.status??t.status;throw r===401?new re("Authentication required"):r===403?new J("You are not allowed to access this resource"):new re("Authentication required")}},pt="auth",Cn={typeDefs:"directive @auth on FIELD_DEFINITION",transformer:e=>H.mapSchema(e,{[H.MapperKind.OBJECT_FIELD]:n=>{if(H.getDirective(e,n,pt)?.[0]){const r=n.resolve;n.resolve=async(i,a,o,s)=>(await On(o),r?.(i,a,o,s))}return n}})},gt="cacheControl",mt=(e,n)=>{const{scope:t="private",sMaxAge:r=0,staleWhileRevalidate:i=0}=e;return`${n?"private":t}, s-maxage=${r}, stale-while-revalidate=${i}`},Ne=(e,n)=>typeof e=="number"&&typeof n=="number"?e>n?n:e:typeof e=="number"?e:n,ht=(e,n)=>typeof e=="string"&&typeof n=="string"?e==="public"&&n==="public"?"public":"private":e||n,bn={typeDefs:"directive @cacheControl(sMaxAge: Int, staleWhileRevalidate: Int, scope: String) on FIELD_DEFINITION",transformer:e=>H.mapSchema(e,{[H.MapperKind.OBJECT_FIELD]:n=>{const t=H.getDirective(e,n,gt)?.[0];if(t){const{sMaxAge:r,staleWhileRevalidate:i,scope:a}=t,o=n.resolve;n.resolve=(s,c,d,g)=>(d.cacheControl={sMaxAge:Ne(d.cacheControl?.sMaxAge,r),staleWhileRevalidate:Ne(d.cacheControl?.staleWhileRevalidate,i),scope:ht(d.cacheControl?.scope,a)},o?.(s,c,d,g))}return n}})},wn=e=>(n,t)=>{const r=pn.mergeTypeDefs([...(e??[]).map(({typeDefs:i})=>i),t]);return(e??[]).reduce((i,{transformer:a})=>a?.(i)??i,gn.makeExecutableSchema({typeDefs:r,resolvers:n}))},An="@faststore/api",Dn="4.9.3-dev.0",Le={name:An,version:Dn},Pn=z.logger("@faststore/api"),ft=(e,n="Unknown Graphql Resolver")=>(t,r,i,a)=>{if(!i?.OTEL_ENABLED)return e(t,r,i,a);const o=z.OTELAPI.trace.getTracer("Graphql").startSpan(n,{kind:z.OTELAPI.SpanKind.INTERNAL,attributes:{timestamp:Date.now(),"@faststore_version":Dn,"@faststore_package_name":An,"@faststore_account_name":i.account,"@faststore_environment":process.env.NODE_ENV,"@faststore_resolver_parent_type":a?.parentType?.name,"@faststore_resolver_field_name":a?.fieldName}}),s=z.OTELAPI.trace.setSpan(z.OTELAPI.context.active(),o);try{const c=z.OTELAPI.context.with(s,()=>e(t,r,i,a));return c instanceof Promise?c.then(d=>(o.end(),d),d=>Be(d,o,n)):(o.end(),c)}catch(c){return Be(c,o,n)}};function Be(e,n,t){throw n.setStatus({code:z.OTELAPI.SpanStatusCode.ERROR}),n.recordException(e),n.end(),console.error(`Error at resolver: ${t}:
2
+ %o`,e),Pn("error",`Error at resolver: %s
3
+ %o`,t,e),e}class q extends Error{constructor(n,t){super(t),this.extensions=n,this.name="FastStoreError"}}class E extends q{constructor(n){super({status:400,type:"BadRequestError"},n)}}class re extends q{constructor(n){super({status:401,type:"UnauthorizedError"},n)}}class J extends q{constructor(n){super({status:403,type:"ForbiddenError"},n)}}class $ extends q{constructor(n){super({status:404,type:"NotFoundError"},n)}}const St=e=>e?.name==="FastStoreError",yt=e=>e?.extensions?.type==="BadRequestError",It=e=>e?.extensions?.type==="UnauthorizedError",En=e=>e?.extensions?.type==="ForbiddenError",X=e=>e?.extensions?.type==="NotFoundError",vt=`${Le.name}@${Le.version}`,y=async(e,n,t)=>{const r=await ct(e,{...n,headers:{...n?.headers??{},"User-Agent":vt}});if(r.ok)return t?.storeCookies&&t.storeCookies(r.headers),r.status!==204?r.json():void 0;console.error(e,n,r);const i=await r.text();if(typeof r?.status=="number")switch(r.status){case 400:throw new E(i);case 401:throw new re(i);case 403:throw new J(i);case 404:throw new $(i);default:throw new q({status:r.status,type:"UnknownError"},i)}throw new Error(i)},Ot=({account:e,environment:n})=>{const t=`https://${e}.${n}.com.br`;return{getLocalizedProduct:(r,i)=>y(`${t}/api/catalog-dataplane/product/${r}`,{method:"GET",headers:{"Accept-Language":i,"Content-Type":"application/json"}})}},kn=e=>{if(!e)return e;const n=new Map,t=e.split(";"),r=[];return t.forEach(i=>{const a=i.trim();if(a){const o=a.indexOf("=");if(o>0){const s=a.substring(0,o),c=a.substring(o+1);n.has(s)||r.push(s),n.set(s,c)}}}),r.map(i=>`${i}=${n.get(i)}`).join("; ")},Ct=/^([^=]+)=([^;]*)/,bt=(e,n)=>{const t=n.match(Ct);if(t){const r=t[1],i=t[2];e.storage.cookies.set(r,{value:i,setCookie:n})}},wt=(e,n)=>{n.getSetCookie().forEach(t=>bt(e,t))},At=e=>n=>wt(e,n),ve=e=>{if(!e.headers?.cookie)return null;const n=kn(e.headers.cookie),t=Array.from(e.storage.cookies.entries());return t.length===0?n:t.reduce((r,[i,{value:a}])=>Dt(r,i,a),n)},Tn=e=>function(t){const r=ve(e);return r?{...t,cookie:r}:t},B=(e,n)=>{const t=kn(e);return ae.parse(t)[`VtexIdclientAutCookie_${n}`]||""},Dt=(e,n,t)=>{const r=new RegExp(`(${n})=([^;]*)`),i=e.match(r);return i?e.replace(i[0],`${i[1]}=${t}`):`${e};${n}=${t}`};function W(e){if(!e)return null;try{return JSON.parse(Buffer.from(e.split(".")[1],"base64").toString())}catch{return null}}const Pt="storefront/faststore.recommendation-shelf@v4",ee={method:"POST",headers:{"content-type":"application/json"}},Et=e=>e.split("/").map(encodeURIComponent).join("/"),ye=e=>e?{headers:{"Accept-Language":e}}:void 0,kt=/^\d{4}-\d{2}-\d{2}$/,Tt=new Set(["Draft","Requested","InReview","Reviewed","Approved","Declined","Expired","ConvertedToCart","ConvertedToOrder"]);function Ut({page:e,perPage:n,status:t,createdAtFrom:r,createdAtTo:i,expiresAtFrom:a,expiresAtTo:o}){if(e!==void 0&&(!Number.isInteger(e)||e<1))throw new Error(`listUserQuotes: invalid page "${e}" — must be a positive integer`);if(n!==void 0&&(!Number.isInteger(n)||n<1))throw new Error(`listUserQuotes: invalid perPage "${n}" — must be a positive integer`);for(const[s,c]of[["createdAtFrom",r],["createdAtTo",i],["expiresAtFrom",a],["expiresAtTo",o]])if(c&&!kt.test(c))throw new Error(`listUserQuotes: invalid ${s} "${c}" — must be YYYY-MM-DD`);if(t&&t.length>0){const s=t.filter(c=>!Tt.has(c));if(s.length>0)throw new Error(`listUserQuotes: invalid status values: ${s.join(", ")}`)}}function _t({page:e,perPage:n,status:t,createdAtFrom:r,createdAtTo:i,expiresAtFrom:a,expiresAtTo:o,label:s}){const c=new URLSearchParams;return e&&c.append("pageNumber",e.toString()),n&&c.append("pageSize",n.toString()),t?.forEach(d=>c.append("status",d)),r&&c.append("createdAtFrom",r),i&&c.append("createdAtTo",i),a&&c.append("expiresAtFrom",a),o&&c.append("expiresAtTo",o),s?.trim()&&c.append("label",s.trim()),c}const Rt=({account:e,environment:n,incrementAddress:t,subDomainPrefix:r},i)=>{const a=`https://${e}.${n}.com.br`,o=At(i),s=Tn(i),c=ut(),d=new Headers(i.headers).get("x-forwarded-host")??i.headers?.host??"",g=r&&r.map(l=>l+".").find(l=>d.includes(l))||"",p=d.replace(g,""),f=`${a}/api/recommend-bff/v2`,h=s({accept:"application/json","content-type":"application/json","x-vtex-rec-origin":`${e}/${Pt}`}),v=(l={})=>{const u=B(ve(i)??"",e);return s({...l,"X-FORWARDED-HOST":p,...u?{[`VtexIdclientAutCookie_${e}`]:u}:{}})};return{catalog:{salesChannel:l=>y(`${a}/api/catalog_system/pub/saleschannel/${l}`,void 0,{storeCookies:o}),brand:{list:()=>y(`${a}/api/catalog_system/pub/brand/list`,void 0,{storeCookies:o})},category:{tree:(l=3)=>y(`${a}/api/catalog_system/pub/category/tree/${l}`,void 0,{storeCookies:o})},portal:{pagetype:l=>y(`${a}/api/catalog_system/pub/portal/pagetype/${l}`,void 0,{storeCookies:o})},byLinkId:{category:async(l,u)=>{try{return await y(`${a}/api/catalog_system/pub/category/by-linkid/${Et(l)}`,ye(u))}catch(m){if(X(m))return null;throw m}},brand:async(l,u)=>{try{return await y(`${a}/api/catalog_system/pub/brand/by-linkid/${encodeURIComponent(l)}`,ye(u))}catch(m){if(X(m))return null;throw m}},collection:async(l,u)=>{try{return await y(`${a}/api/catalog_system/pub/collection/by-linkid/${encodeURIComponent(l)}`,ye(u))}catch(m){if(X(m))return null;throw m}}},products:{crossselling:({type:l,productId:u,groupByProduct:m=!0})=>{const S=new URLSearchParams({sc:i.storage.channel.salesChannel,groupByProduct:m.toString()});return y(`${a}/api/catalog_system/pub/products/crossselling/${l}/${u}?${S}`,void 0,{storeCookies:o})}}},checkout:{simulation:(l,{salesChannel:u}=i.storage.channel)=>{const m=new URLSearchParams({sc:u}),S=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForms/simulation?${m.toString()}`,{...ee,headers:S,body:JSON.stringify(l)},{storeCookies:o})},shippingData:({id:l,index:u,deliveryMode:m,selectedAddresses:S},O)=>{const b=O?{startDateUtc:m?.deliveryWindow?.startDate,endDateUtc:m?.deliveryWindow?.endDate}:null,C={logisticsInfo:Array.from({length:u},(I,w)=>({itemIndex:w,selectedDeliveryChannel:m?.deliveryChannel||null,selectedSla:m?.deliveryMethod||null,deliveryWindow:b})),selectedAddresses:S,clearAddressIfPostalCodeNotFound:t},T=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForm/${l}/attachments/shippingData`,{...ee,headers:T,body:JSON.stringify(C)},{storeCookies:o})},marketingData:({id:l,marketingData:u})=>{const m=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForm/${l}/attachments/marketingData`,{headers:m,body:JSON.stringify(u),method:"POST"},{storeCookies:o})},clientPreferencesData:({id:l,clientPreferencesData:u})=>{const m=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForm/${l}/attachments/clientPreferencesData`,{headers:m,body:JSON.stringify(u),method:"POST"},{storeCookies:o})},orderForm:({id:l,refreshOutdatedData:u=!0,channel:m=i.storage.channel,preserveSalesChannel:S=!1})=>{const{salesChannel:O}=m,b=s({"content-type":"application/json","X-FORWARDED-HOST":p}),C=new URLSearchParams;(!S||!l)&&C.set("sc",O),l&&C.set("refreshOutdatedData",u.toString());const T=l?`/${l}`:"",I=`${a}/api/checkout/pub/orderForm${T}?${C}`;return y(I,{...ee,headers:b,...l?{}:{body:"{}"}},{storeCookies:o})},clearOrderFormMessages:({id:l})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForm/${l}/messages/clear`,{...ee,headers:u,body:"{}"})},updateOrderFormItems:({id:l,orderItems:u,allowOutdatedData:m="paymentData",salesChannel:S=i.storage.channel.salesChannel,shouldSplitItem:O=!0})=>{const b=new URLSearchParams({allowOutdatedData:m,sc:S}),C=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForm/${l}/items?${b}`,{headers:C,body:JSON.stringify({orderItems:u,noSplitItem:!O}),method:"PATCH"},{storeCookies:o})},setCustomData:({id:l,appId:u,key:m,value:S})=>{const O=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForm/${l}/customData/${u}/${m}`,{headers:O,body:JSON.stringify({value:S}),method:"PUT"})},region:async({postalCode:l,geoCoordinates:u,country:m,salesChannel:S})=>{const O=new URLSearchParams({country:m,sc:S??""});l?O.append("postalCode",l):O.append("geoCoordinates",`${u?.longitude};${u?.latitude}`);const b=`${a}/api/checkout/pub/regions/?${O.toString()}`,C=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(b,{headers:C},{storeCookies:o})},address:async({postalCode:l,country:u})=>{const m=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/postal-code/${u}/${l}`,{headers:m},{storeCookies:o})},cancelOrder:({orderId:l,customerEmail:u,reason:m})=>{const S=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orders/${l}/user-cancel-request`,{method:"POST",headers:S,body:JSON.stringify({customerEmail:u,reason:m})},{})},pickupPoints:({geoCoordinates:l})=>{if(!l)throw new Error("Missing required parameter for listing pickup points.");const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/logistics-shipping/pickuppoints/_search`,{method:"POST",headers:u,body:JSON.stringify({coordinate:l})},{storeCookies:o})}},session:l=>{const u=new URLSearchParams(l);u.set("items","profile.id,profile.email,profile.firstName,profile.lastName,profile.phone,shopper.firstName,shopper.lastName,shopper.organizationManager,shopper.availableContracts,shopper.activeContractId,store.channel,store.countryCode,store.cultureInfo,store.currencyCode,store.currencySymbol,authentication.customerId,authentication.storeUserId,authentication.storeUserEmail,authentication.unitId,authentication.unitName,checkout.regionId,public.postalCode");const m=s({"content-type":"application/json"}),S=ae.parse(i?.headers?.cookie??"")?.vtex_session;return y(`${a}/api/sessions?${u.toString()}`,{method:S?"PATCH":"POST",headers:m,body:"{}"},{storeCookies:o})},storeFront:{attachedContracts:l=>{const u=s({"content-type":"application/json"});return y(`https://${e}.myvtex.com/_v/store-front/units/${encodeURIComponent(l)}/contracts/attached?details=true`,{headers:u},{storeCookies:o})}},subscribeToNewsletter:l=>y(`${a}/api/dataentities/NL/documents/`,{...ee,body:JSON.stringify({...l,isNewsletterOptIn:!0}),method:"PATCH"},{storeCookies:o}),profile:{addresses:async l=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/profile-system/pvt/profiles/${l}/addresses`,{headers:u},{storeCookies:o})}},oms:{userOrder:({orderId:l})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/oms/user/orders/${l}`,{method:"GET",headers:u},{storeCookies:o})},listUserOrders:({page:l,status:u,dateInitial:m,dateFinal:S,text:O,clientEmail:b,perPage:C,pendingMyApproval:T})=>{const I=new URLSearchParams;if(m){const k=new Date(m).setHours(0,0,0,0);m=new Date(k).toISOString()}if(S){const k=new Date(S).setHours(23,59,59,999);S=new Date(k).toISOString()}O&&I.append("text",O),u&&u.length>0&&I.append("status",u.filter(Boolean).join(",")),m&&S?I.append("creation_date",`creationDate:[${m} TO ${S}]`):m?I.append("creation_date",`creationDate:[${m} TO *]`):S&&I.append("creation_date",`creationDate:[* TO ${S}]`),b&&I.append("clientEmail",b),l&&I.append("page",l.toString()),C&&I.append("per_page",C.toString()),T&&I.append("my_pending_approvals",String(!0));const w=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/oms/user/orders?${I.toString()}`,{method:"GET",headers:w},{storeCookies:o})},getCommercialAuthorizationsByOrderId:({orderId:l})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/${e}/commercial-authorizations/order/${l}`,{method:"GET",headers:u},{storeCookies:o})},processOrderAuthorization:async({orderAuthorizationId:l,dimensionId:u,ruleId:m,approved:S})=>{const O=s({"content-type":"application/json","X-FORWARDED-HOST":p}),T={params:{ruleId:m,dimensionId:u,score:S?100:0}};return y(`${a}/${e}/commercial-authorizations/${l}/callback`,{method:"POST",headers:O,body:JSON.stringify(T)},{storeCookies:o})}},savedCards:{listCreditCards:()=>{const l=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/saved-cards/credit-card?an=${e}`,{method:"GET",headers:l},{storeCookies:o})}},units:{getUnitByUserId:({userId:l})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/units/v1/${l}/unit`,{method:"GET",headers:u},{})},getOrgUnitById:({orgUnitId:l})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/units/v1/${l}`,{method:"GET",headers:u},{})},getScopesByOrgUnit:({orgUnitId:l})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/units/v1/${l}/scopes`,{method:"GET",headers:u},{})}},licenseManager:{getUserById:({userId:l})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/license-manager/users/${l}`,{method:"GET",headers:u},{})},getUserByEmail:({email:l})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/license-manager/pvt/users/${l}`,{method:"GET",headers:u},{})},getUserRoles:({userId:l})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/license-manager/storefront/users/${l}/roles`,{method:"GET",headers:u},{})},isResourceGranted:({userId:l,resourceKey:u})=>{const m=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/license-manager/storefront/bff/users/${l}/resources/${u}/granted?an=${e}`,{method:"GET",headers:m},{})}},masterData:{getContractById:({contractId:l})=>{if(!l)throw new E("Missing contractId to fetch CL fields.");const u=v({Accept:"application/json","content-type":"application/json"});return y(`${a}/api/dataentities/CL/documents/${l}?_fields=_all`,{method:"GET",headers:u},{})},getShopperById:({userId:l})=>{if(!l)throw new E("Missing userId to fetch shopper name.");const u=c({Accept:"application/json","content-type":"application/json","X-FORWARDED-HOST":p}),m=l.replace(/-/g,"");return y(`${a}/api/dataentities/shopper/search?_where=(userId=${m} OR userId=${l})&_fields=_all&_schema=v1`,{method:"GET",headers:u},{})}},quotes:{listUserQuotes:l=>{Ut(l);const u=_t(l),m=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/quoting/quotes?${u.toString()}`,{method:"GET",headers:m},{storeCookies:o})}},vtexid:{validate:()=>{const l=s({"content-type":"application/json","X-FORWARDED-HOST":p}),u=B(ve(i)??"",e);return y(`${a}/api/vtexid/credential/validate`,{headers:l,body:JSON.stringify({token:u}),method:"POST"},{storeCookies:o})}},orderEntry:{uploadFile:({fileBuffer:l,fileName:u,mimeType:m})=>{const S=s({"content-type":"application/json","X-FORWARDED-HOST":p}),O=`----FastStoreUploadBoundary${Date.now()}`,b=`\r
4
+ `,T=/^[a-zA-Z0-9][a-zA-Z0-9!#$&\-.^_]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&\-.^_+]*$/.test(m)?m:"application/octet-stream",I=u.replaceAll(/[\r\n"]/g,"_"),w=[`--${O}`,`Content-Disposition: form-data; name="file"; filename="${I}"`,`Content-Type: ${T}`,"",""].join(b),k=`${b}--${O}--${b}`,D=Buffer.from(w),_=Buffer.from(k),P=new Uint8Array(D.byteLength+l.byteLength+_.byteLength);let U=0;return P.set(D,U),U+=D.byteLength,P.set(l,U),U+=l.byteLength,P.set(_,U),y(`${a}/api/order-entry/upload?an=${e}`,{method:"POST",headers:{...S,"content-type":`multipart/form-data; boundary=${O}`},body:P.buffer},{})},startOperation:({objectKey:l,orderFormId:u,sessionToken:m})=>{const S=s({"content-type":"application/json","X-FORWARDED-HOST":p}),O=JSON.stringify({objectKey:l,orderFormId:u,operation:"CreateCart",...m?{sessionToken:m}:{}});return y(`${a}/api/order-entry/operation?an=${e}`,{method:"POST",headers:S,body:O},{})},getOperation:({operationId:l})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/order-entry/operation/${l}?an=${e}`,{method:"GET",headers:u},{})},createOrderForm:()=>{const l=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForm?sc=${i.storage.channel.salesChannel}`,{method:"POST",headers:l,body:"{}"},{})},getOrderFormItems:({orderFormId:l})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForm/${l}`,{method:"GET",headers:u},{})}},recommendation:{recommendations:({campaignVrn:l,userId:u,products:m=[],salesChannel:S,locale:O})=>{const b=new URLSearchParams({an:e,campaignVrn:l});return u&&b.append("userId",u),m.length>0&&b.append("products",m.join(",")),S&&b.append("salesChannel",S),O&&b.append("locale",O),y(`${f}/recommendations?${b.toString()}`,{headers:h},{storeCookies:o})},startRecommendationSession:()=>{const l=new URLSearchParams({an:e});return y(`${f}/users/start-session?${l.toString()}`,{method:"POST",headers:h},{storeCookies:o})}}}},ie=e=>e.discoveryConfig?.localization??{},Y=e=>ie(e).enabled===!0,Ft=e=>Object.keys(ie(e).locales??{}),Nt=e=>ie(e).defaultLocale,Un=e=>Y(e)&&e.storage.locale||void 0,Oe="fuzzy",Ce="operator",be="pickupPoint",$e="shipping",Me="delivery-options",Lt="in-stock",Bt="trade-policy",$t="region-id",Mt=new Set([Bt,$t,Oe,Ce,be]),zt=new Set(["zip-code","pickupPoint","country","coordinates","deliveryZonesHash","pickupPointsHash"]),ze=e=>encodeURI(decodeURI(e)),Vt=e=>encodeURIComponent(decodeURIComponent(e).normalize("NFD").replaceAll(/[\u0300-\u036f]/g,"")),qt=/^pickup-in-point-(.+)$/;function _n(e){if(!e)return{};try{const t=ae.parse(e).vtex_segment;if(!t)return{};const r=Buffer.from(t,"base64").toString("utf-8");return JSON.parse(r)}catch{return{}}}function xt(e){const n={},t=[];for(const r of e.split(";")){const i=r.indexOf("=");if(i<0)continue;const a=r.slice(0,i),o=r.slice(i+1);!a||!o||(zt.has(a)?n[a]=o:t.push({key:a,value:o}))}return{shipping:n,extraFacets:t}}function jt(e){const n=typeof e.facets=="string"?e.facets:"",{shipping:t,extraFacets:r}=xt(n);return{segmentParams:{sc:e.channel,regionId:e.regionId,country:e.countryCode??t.country,locale:e.cultureInfo,"zip-code":t["zip-code"],coordinates:t.coordinates,pickupPoint:t.pickupPoint,deliveryZonesHash:t.deliveryZonesHash,pickupPointHash:t.pickupPointsHash,utmSource:e.utm_source??void 0,utmCampaign:e.utm_campaign??void 0,utmiCampaign:e.utmi_campaign??void 0,campaigns:typeof e.campaigns=="string"?e.campaigns:void 0,priceTables:e.priceTables??void 0},extraFacets:r}}function Rn(e,n){const t=[["sc",n.sc],["regionId",n.regionId],["country",n.country],["locale",n.locale],["zip-code",n["zip-code"]],["coordinates",n.coordinates],["pickupPoint",n.pickupPoint],["deliveryZonesHash",n.deliveryZonesHash],["pickupPointHash",n.pickupPointHash],["utmSource",n.utmSource],["utmCampaign",n.utmCampaign],["utmiCampaign",n.utmiCampaign],["campaigns",n.campaigns],["priceTables",n.priceTables]];for(const[r,i]of t)i!=null&&i!==""&&e.append(r,String(i))}function Fn(e){return qt.exec(e)?.[1]}function Wt(e){const n=e.find(r=>r.key==="shipping"),t=n?Fn(n.value):void 0;if(t!==void 0)try{return decodeURIComponent(t)}catch{return t}}function Gt(e,n){const t=Wt(n);return t===void 0?e:{...e,pickupPoint:t}}function Ht(e){return e.map(n=>n.key!=="shipping"||Fn(n.value)===void 0?n:{...n,value:"pickup-in-point"})}function Xt(e,n){let t=[...e];const r=t.some(i=>i.key==="shipping");for(const i of n)(!r||i.key!=="shipping")&&t.push(i);return t.some(i=>i.key==="shipping"&&i.value==="ignore")&&(t=t.filter(i=>i.key!=="shipping")),Ht(t)}function Yt(e){return e.reduce((n,t)=>{let{key:r,value:i}=t;return r==="priceRange"&&(r="price",i=i.replace(" TO ",":")),r==="ft"?n:`${n}${ze(r)}/${Vt(ze(i)).replaceAll(/ |%20/g,"-")}/`},"")}const Jt=e=>e.key==="fuzzy"&&(e.value==="0"||e.value==="1"||e.value==="auto"),Kt=e=>e.key==="operator"&&(e.value==="and"||e.value==="or");function Qt(e,n){const{segmentParams:t,extraFacets:r}=jt(e??{}),i=n?.salesChannel??t.sc,a=n?.regionId??t.regionId,o=n?.locale??t.locale??"";return{segmentParams:{...t,...i?{sc:i}:{},...a?{regionId:a}:{},locale:o},extraFacets:r}}function Zt(e,n){const t=e.filter(({key:c})=>!Mt.has(c)),r=e.find(({key:c,value:d})=>c===$e&&d!=="all-delivery-methods")??null,i=e.find(({key:c,value:d})=>c===Me&&d!=="all-delivery-options")??null,a=[...t],o=a.some(({key:c})=>c===$e),s=a.some(({key:c})=>c===Me);return r!==null&&!o&&a.push(r),i!==null&&!s&&a.push(i),Xt(a,n)}function er(e,n){const t=e.find(({key:a})=>a===Oe)??null,r=e.find(({key:a})=>a===Ce)??null,i=e.find(({key:a})=>a===be)??null;t&&Jt(t)&&n.append(Oe,t.value),r&&Kt(r)&&n.append(Ce,r.value),i&&n.append(be,i.value)}function Ve(e,n,t,r){const{query:i="",page:a,count:o,sort:s,selectedFacets:c=[],showInvisibleItems:d,sponsoredCount:g,hideUnavailableItems:p,allowRedirect:f=!1}=e,h=new URLSearchParams;if(r.includePagination&&a!==void 0&&o!==void 0){const u=a*o,m=o===0?u:u+o-1;h.append("from",u.toString()),h.append("to",m.toString())}i&&h.append("query",i),r.includeSort&&s&&h.append("sort",s);const v=Gt(t.segmentParams,c);if(Rn(h,v??t.segmentParams),er(c,h),d&&h.append("show-invisible-items","true"),n?.hideUnavailableItems!==void 0){const u=c.find(({key:S})=>S===Lt),m=u?u.value:p?.toString()??n.hideUnavailableItems.toString();h.append("hideUnavailableItems",m)}n?.simulationBehavior!==void 0&&h.append("simulationBehavior",n.simulationBehavior.toString()),n?.showSponsored!==void 0&&h.append("showSponsored",n.showSponsored.toString()),g!==void 0&&h.append("sponsoredCount",g.toString()),f!==void 0&&h.append("allowRedirect",f.toString());const l=Yt(Zt(c,t.extraFacets));return{params:h,path:l}}function nr(e,n){const{field:t,value:r,hideUnavailableItems:i,showInvisibleItems:a}=e,o=new URLSearchParams({field:t??"",value:r??""});return Rn(o,n),i&&o.append("hideUnavailableItems","true"),a&&o.append("show-invisible-items","true"),o}function ne(e,n){return{path:e,params:n,toString(){const t=n.toString();return e?t?`${e}?${t}`:e:t?`?${t}`:""}}}function te(e){const{endpoint:n,segment:t,defaults:r,args:i={}}=e,a=Qt(t,r);switch(n){case"product-search":case"facets":{const{params:o,path:s}=Ve(i,r,a,{includePagination:!0,includeSort:!0});return ne(s,o)}case"catalog-count":{const{params:o,path:s}=Ve(i,r,a,{includePagination:!1,includeSort:!1});return ne(s,o)}case"products":{const o=nr(i,a.segmentParams);return ne("",o)}case"search-suggestions":{const o=new URLSearchParams({query:i.query?.toString()??"",locale:r?.locale??a.segmentParams.locale??""});return ne("",o)}case"top-searches":{const o=new URLSearchParams({locale:r?.locale??a.segmentParams.locale??""});return ne("",o)}default:{const o=n;throw new Error(`Unknown intelligent-search endpoint: ${o}`)}}}const tr=10;function rr(e){const{regionId:n,seller:t}=e.storage.channel;return(t?Buffer.from(`SW#${t}`).toString("base64"):void 0)??(n||void 0)}function ir(e){const t=_n(e.headers?.cookie).cultureInfo||"";return Y(e)?e.storage.locale||t:t||e.storage.locale||""}const ar=({account:e,environment:n,hideUnavailableItems:t,simulationBehavior:r,showSponsored:i,subDomainPrefix:a},o)=>{const s=`https://${e}.${n}.com.br`,c=Tn(o),d=_n(o.headers?.cookie),g=()=>({salesChannel:o.storage.channel.salesChannel,regionId:rr(o),locale:ir(o),hideUnavailableItems:t,simulationBehavior:r,showSponsored:i}),p=new Headers(o.headers).get("x-forwarded-host")??o.headers?.host??"",f=a&&a.map(I=>I+".").find(I=>p.includes(I))||"",h=p.replace(f,""),v=c({"content-type":"application/json","X-FORWARDED-HOST":h}),l=({type:I,...w})=>{const k=I==="facets"?"facets":"product-search",D=te({endpoint:k,segment:d,defaults:g(),args:w});return y(`${s}/api/intelligent-search/v1/${k}/${D.path}?${D.params.toString()}`,{headers:v})},u=I=>l({...I,type:"product_search"}),m=({field:I,value:w,hideUnavailableItems:k,showInvisibleItems:D})=>{const _=te({endpoint:"products",segment:d,defaults:g(),args:{field:I,value:w,hideUnavailableItems:k,showInvisibleItems:D}});return y(`${s}/api/intelligent-search/v1/products?${_.params.toString()}`,{headers:v})};return{facets:I=>l({...I,type:"facets"}),products:u,fetchProduct:m,productsByIdentifier:async({field:I,values:w,showInvisibleItems:k,hideUnavailableItems:D})=>{const _=Ue(tr);return(await Promise.all(w.map(U=>_(async()=>{try{return await m({field:I,value:U,hideUnavailableItems:D,showInvisibleItems:k})}catch{return null}})))).filter(U=>U!==null)},suggestedTerms:I=>{const w=te({endpoint:"search-suggestions",segment:d,defaults:g(),args:{query:I.query}});return y(`${s}/api/intelligent-search/v1/search-suggestions?${w.params.toString()}`,{headers:v})},topSearches:()=>{const I=te({endpoint:"top-searches",segment:d,defaults:g()});return y(`${s}/api/intelligent-search/v1/top-searches?${I.params.toString()}`,{headers:v})},productCount:I=>{const w=te({endpoint:"catalog-count",segment:d,defaults:g(),args:I});return y(`${s}/api/intelligent-search/v1/catalog-count/${w.path}?${w.params.toString()}`,{headers:v})}}},or=(e,n)=>{const t=ar(e,n),r=Rt(e,n),i=Ot(e);return{search:t,commerce:r,catalog:i}},sr=20,cr=e=>e.entityType==="category",we=e=>e.entityType==="brand",qe=e=>e.entityType==="collection",lr=(e,n)=>{const t=Ue(sr),r=async i=>Promise.all(i.map(a=>t(async()=>{const o=a.slug.toLowerCase(),s=a.locale,c=await n.commerce.catalog.byLinkId.category(o,s);if(c)return{...c,entityType:"category",slug:o};const d=await n.commerce.catalog.byLinkId.brand(o,s);if(d)return{...d,entityType:"brand"};const g=await n.commerce.catalog.byLinkId.collection(o,s);if(g)return{...g,entityType:"collection"};throw new $(`No catalog entity found for slug: ${a.slug}. Cascade exhausted (category → brand → collection).`)})));return new Se(r,{batch:!1,cacheKeyFn:({slug:i,locale:a})=>`${i.toLowerCase()}::${a??""}`})},dr=(e,n)=>{const t=async r=>Promise.all(r.map(i=>n.commerce.catalog.salesChannel(i)));return new Se(t)},ur=1,pr=(e,n)=>{const t=Ue(ur),r=async a=>{const o=a.reduce((p,{items:f})=>[...p,f],[]),s=[...o.flat()],c=await n.commerce.checkout.simulation({country:a[0].country,postalCode:a[0].postalCode,items:s}),d=c.items.reduce((p,f)=>{const h=f.requestIndex;return typeof h=="number"&&h<p.length&&(p[h]=f),p},Array(s.length).fill(null)),g=o.reduce((p,f)=>[...p,f.length+p[p.length-1]],[0]);return o.map((p,f)=>({...c,items:d.slice(g[f],g[f+1]).filter(h=>!!h)}))},i=async a=>t(r,a);return new Se(i,{maxBatchSize:50})},gr=(e,n)=>lt(e,n);function mr(e){return{...e,description:e.description?gr(e.description):e.description}}const L=(e,n)=>({...e,isVariantOf:mr(n)}),hr=({flags:e},n)=>{const t=async r=>{const i=r.map(g=>g.split("-")[0]),a=r.some(g=>g.split("-")[1]==="invisibleItems"),s=(await n.search.productsByIdentifier({field:"sku",values:i,showInvisibleItems:a,...e?.enableUnavailableItemsOnCart&&{hideUnavailableItems:!1}})).reduce((g,p)=>{for(const f of p.items)g[f.itemId]=L(f,p);return g},{}),c=i.map(g=>s[g]),d=i.filter(g=>!s[g]);if(d.length>0)throw new $(`Search API did not found the following skus: ${d.join(",")}`);return c};return new Se(t,{maxBatchSize:99})},fr=(e,n)=>{const{clients:t}=n,r=hr(e,t),i=pr(e,t),a=lr(e,t),o=dr(e,t);return{skuLoader:r,simulationLoader:i,collectionLoader:a,salesChannelLoader:o}},V=e=>e.AvailableQuantity>0,K=e=>e.spotPrice??0,Sr=e=>e.Price??0,xe=e=>e?"https://schema.org/InStock":"https://schema.org/OutOfStock",Nn=(e,n)=>V(e)&&!V(n)?-1:!V(e)&&V(n)?1:K(e)-K(n),yr=e=>e==="available",G=(e,n=0,t=1)=>{const r=n/t;return Math.round((e+r)*100)/100},Ir=(e,n={includeTaxes:!1})=>{const t=e.filter(V),r=t[t.length-1],i=r?K(r):0;return n.includeTaxes?G(i,r?.Tax,r?.product?.unitMultiplier):i},je=(e,n={includeTaxes:!1})=>{const[t]=e.filter(V),r=t?K(t):0;return n.includeTaxes?G(r,t?.Tax,t?.product?.unitMultiplier):r},vr={highPrice:e=>Ir(e),lowPrice:e=>je(e),lowPriceWithTaxes:e=>je(e,{includeTaxes:!0}),offerCount:e=>e.length,priceCurrency:async(e,n,t)=>{const{loaders:{salesChannelLoader:r},storage:{channel:i}}=t;return(await r.load(i.salesChannel)).CurrencyCode??""},offers:e=>e},Or={ratingValue:()=>5,reviewCount:()=>0},We="ÁÄÂÀÃÅČÇĆĎÉĚËÈÊẼĔȆÍÌÎÏŇÑÓÖÒÔÕØŘŔŠŤÚŮÜÙÛÝŸŽáäâàãåčçćďéěëèêẽĕȇíìîïňñóöòôõøðřŕšťúůüùûýÿžþÞĐđ߯a",Cr="AAAAAACCCDEEEEEEEEIIIINNOOOOOORRSTUUUUUYYZaaaaaacccdeeeeeeeeiiiinnooooooorrstuuuuuyyzbBDdBAa",br=e=>{let n=e.slice(0);for(let t=0;t<We.length;t++)n=n.replace(new RegExp(We.charAt(t),"g"),Cr.charAt(t));return n},wr=e=>e.replace(/[·/_,:]/,"-");function ge(e){const t=e.replace(/,/g,"").replace(/[*+~.()'"!:@&\[\]`/ %$#?{}><=_^]/g,"-");return wr(br(t)).toLowerCase()}const Ie=e=>e.toLowerCase(),le=(e,n)=>{const t=n.split("/").filter(Boolean),{loaders:{collectionLoader:r}}=e;return Promise.all(t.map((i,a)=>r.load({slug:t.slice(0,a+1).join("/"),locale:Un(e)})))},j=e=>cr(e)?e.slug:we(e)?e.linkId:e.linkId??ge(e.name),Ln={id:({id:e})=>e.toString(),slug:e=>j(e),seo:e=>({title:e.title??e.name,description:e.metaTagDescription??e.description}),type:e=>we(e)?"Brand":qe(e)?"Collection":e.fatherCategoryId===null?"Department":"Category",meta:async(e,n,t)=>{const r=j(e);if(we(e))return{selectedFacets:[{key:"brand",value:r}]};if(qe(e))return{selectedFacets:[{key:"productclusterids",value:e.id}]};const{defaultLocale:i}=ie(t);return{selectedFacets:(await le(t,r)).map((o,s)=>({key:`category-${s+1}`,value:i&&o.availableLinkIds?.[i]||o.linkId}))}},breadcrumbList:async(e,n,t)=>{const r=await le(t,j(e));return{itemListElement:r.map((i,a)=>({item:`/${j(i)}`,name:i.name,position:a+1})),numberOfItems:r.length}},otherLocales:async(e,n,t)=>{const r=ie(t);if(!r.enabled)return null;const i=Object.keys(r.locales??{});if(i.length===0)return null;const a=j(e);if(a.split("/").filter(Boolean).length===0)return null;let o;try{o=await le(t,a)}catch(s){return console.warn("[otherLocales] failed to load collection entities:",s),null}return i.map(s=>{const c=[];for(const d of o){const g=d.availableLinkIds?.[s];if(!g)return null;c.push(g)}return c.length>0?{locale:s,slug:Ie(c.join("/"))}:null}).filter(s=>s!==null)},canonicalSlug:async(e,n,t)=>{const r=j(e);if(r.split("/").filter(Boolean).length===0)return null;let i;try{i=await le(t,r)}catch(o){return console.warn("[canonicalSlug] failed to load collection entities:",o),null}const a=i.map(o=>o.linkId);return a.every(o=>!!o)?Ie(a.join("/")):Ie(r)}},Bn={buy:"whoboughtalsobought",view:"whosawalsosaw",similars:"similars",viewAndBought:"whosawalsobought",accessories:"accessories",suggestions:"suggestions"},Ge=({key:e,value:n})=>{switch(e){case"price":return{key:e,value:n.replace("-to-",":")};case"channel":case"locale":case"buy":case"view":case"similars":case"viewAndBought":case"accessories":case"suggestions":return[];default:return{key:e,value:n}}},He=e=>{const n=e.split(":").map(Number);return n.length!==2||Number.isNaN(n[0])||Number.isNaN(n[1])?null:n},Ar=e=>typeof Bn[e]=="string",Dr=e=>{const n=e?.filter(t=>Ar(t.key));if(Array.isArray(n)&&n.length>1)throw new E(`You passed ${n.length} cross selling facets but only one is allowed. Please leave one of the following facet: ${n.map(t=>t.key).join(",")}`);return n?.[0]??null},Pr=e=>e?.find(n=>n.key==="slug")?.value??null,Er=e=>e?.find(n=>n.key==="id")?.value??null,Xe=e=>e?.find(n=>n.key==="locale")?.value??null,Ye=e=>e?.find(n=>n.key==="channel")?.value??null,Ae=(e,n)=>{let t=0;for(let r=1;r<e.length;r++)n(e[t],e[r])>0&&(t=r);return e[t]},kr={__resolveType:({type:e,values:n})=>e!=="TEXT"&&e!=="DELIVERY"?"StoreFacetRange":!n||n.length===0?"StoreFacetBoolean":n.every(t=>t.range)?"StoreFacetRange":"StoreFacetBoolean"},Tr={key:({key:e})=>e,label:({name:e})=>e,values:({values:e})=>e.sort((n,t)=>n.name.localeCompare(t.name))},Ur={key:({key:e})=>e,label:({name:e})=>e,min:({values:e,key:n},t,{storage:{searchArgs:r}})=>{const i=He(r?.selectedFacets?.find(s=>s.key===n)?.value??""),o=Ae(e,(s,c)=>s.range.from-c.range.from)?.range?.from??0;return{selected:i?.[0]??o,absolute:o}},max:({values:e,key:n},t,{storage:{searchArgs:r}})=>{const i=He(r?.selectedFacets?.find(s=>s.key===n)?.value??""),o=Ae(e,(s,c)=>c.range.to-s.range.to)?.range?.to??0;return{selected:i?.[1]??o,absolute:o}}},_r={value:({value:e})=>e,label:({name:e})=>e||"unknown",selected:({selected:e})=>e,quantity:({quantity:e})=>e},Rr=async(e,{data:n},{clients:{commerce:t}})=>{if(!n?.orderId)throw new E("Missing orderId");return{data:(await t.checkout.cancelOrder(n))?.data}};function $n(e){if(!e||e.status!=="pending")return null;for(const n of e.dimensionStatus){if(n.status!=="pending")continue;const t=n.ruleCollection.find(r=>r.status==="pending"&&r.isUserNextAuthorizer);if(t)return{rule:t,orderAuthorizationId:e.id,dimensionId:n.id}}return null}function Fr(e){if(!e||e.status!=="pending")return!1;const n=e.dimensionStatus.filter(t=>t.status==="pending").flatMap(t=>t.ruleCollection).filter(t=>t.status==="pending");return n.length===0?!1:n.every(t=>!t.isUserNextAuthorizer)}const Nr=async(e,{data:n},{clients:{commerce:t}})=>{const r=await t.oms.processOrderAuthorization(n),i=$n(r);return{isPendingForOtherAuthorizer:!i&&Fr(r),ruleForAuthorization:i}},Lr=async(e,{data:n},{clients:{commerce:t}})=>{if(!n?.objectKey)throw new E("Missing objectKey");const r=n.orderFormId||(await t.orderEntry.createOrderForm()).orderFormId;return t.orderEntry.startOperation({objectKey:n.objectKey,orderFormId:r,sessionToken:n.sessionToken??void 0})},Br=async(e,n,t)=>{if(!(await t.clients.commerce.recommendation.startRecommendationSession())?.recommendationsUserId)throw new Error("Failed to start recommendation session: no session data returned");return!0},$r=async(e,{data:n},{clients:{commerce:t}})=>({id:(await t.subscribeToNewsletter(n))?.Id}),Mr=async(e,{data:n},{clients:{commerce:t}})=>{const{fileContent:r,fileName:i,mimeType:a}=n;if(!r||!i||!a)throw new E("Missing required fields: fileContent, fileName, mimeType");const o=r.replaceAll(/\s/g,""),s=5*1024*1024;if(Math.floor(o.length*3/4)>s)throw new E("File exceeds maximum allowed size of 5MB");if(!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(o))throw new E("Invalid Base64 fileContent");const g=Buffer.from(o,"base64");return await t.orderEntry.uploadFile({fileBuffer:g,fileName:i,mimeType:a})};class oe{static parse(n){try{const t=JSON.parse(n);return{seller:t.seller??"",regionId:t.regionId??"",salesChannel:t.salesChannel??"",hasOnlyDefaultSalesChannel:t.hasOnlyDefaultSalesChannel??!0}}catch(t){throw console.error(t),new Error("Malformed channel string")}}static stringify(n){return JSON.stringify(n)}}function zr(e,n){return n==null||n===""||String(n)===String(e.salesChannel??"")?null:oe.stringify({...e,salesChannel:String(n),hasOnlyDefaultSalesChannel:!1})}function Vr(e,n,t){return t!=null&&String(e.salesChannel??"")===t&&String(n??"")!==t?!1:e.items.length>0?!0:e.salesChannel==null||e.salesChannel===""?!1:String(e.salesChannel)===String(n??"")}const Mn=e=>{try{return JSON.parse(e??"")??{}}catch{return{}}};function zn(e,{localizationEnabled:n=!0}={}){const t=Mn(e).salesChannelSource;return t==="url"?n?t:void 0:t==="orderForm"?t:void 0}const Vn=e=>!!e?.localization?.enabled;function qn(e){const n=Mn(e).rejectedSalesChannel;return(typeof n=="string"||typeof n=="number")&&String(n)||void 0}function qr(e,n,t,r,i,a){const o=n??void 0,s=t??e.regionId,c=i?e.salesChannel||o:o??e.salesChannel,d=a!=null&&a!==String(c??"");return oe.stringify({salesChannel:c,regionId:s??void 0,seller:r,hasOnlyDefaultSalesChannel:!o,...i?{salesChannelSource:i}:{},...d?{rejectedSalesChannel:a}:{}})}const Je="1";function xr(e,n,t,r){const i=String(e.salesChannel??"");return n===void 0&&i===Je&&!!t&&t!==Je&&!new URLSearchParams(r).has("sc")?t:i}const me=(e,n)=>{e.storage.channel=oe.parse(n)},De=(e,n)=>{e.storage.locale=n},Re=e=>dt.createHash("md5").update(e).digest("hex"),x={attachment:"ATTACHMENT",specification:"SPECIFICATION",attribute:"ATTRIBUTE",service:"SERVICE"};function xn(e){return{name:e.name,value:e.content,valueReference:x.attachment}}function jr(e){return{propertyID:e.id,name:e.name,value:e.value,valueReference:{valueReference:x.attribute,visible:e.visible}}}function jn(e){return Re(`${e.name}:${JSON.stringify(e.value)}:${e.valueReference}`)}const Wn=(e,n)=>e<n?-1:e>n?1:0,Wr=(e,n)=>Wn(e.name,n.name),Gr=e=>[...e??[]].sort(Wr),Ke=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Hr=e=>Ke(e)&&typeof e.name=="string"&&Ke(e.content),Xr=e=>({name:e.name,content:Object.fromEntries(Object.keys(e.content).sort(Wn).map(n=>[n,e.content[n]]))}),Gn=(e,n)=>Re(`SERVICE:${e}:${JSON.stringify(Gr((n??[]).filter(Hr)).map(Xr))}`),Yr="SERVICE:unreadable";function Fe(e){const n=e.attachments??[];return{propertyID:Gn(e.id,n),name:e.name,value:{id:e.id,price:e.sellingPrice/100,attachments:n},valueReference:x.service}}const Jr=e=>{try{return JSON.parse(e)}catch{return null}},Kr=e=>{const n=typeof e=="string"?Jr(e):e;if(n===null||typeof n!="object")return null;const{id:t,attachments:r}=n;return typeof t!="string"&&typeof t!="number"?null:{id:String(t),attachments:r}};function Qr(e){const n=Kr(e.value);return n?Gn(n.id,Array.isArray(n.attachments)?n.attachments:[]):Yr}const Zr=e=>{const n=e.postalCode,t=e.geoCoordinates,r={addressType:e.addressType||null,postalCode:n||null,city:null,state:null,country:e.country||null,street:null,number:null,neighborhood:null,complement:null,reference:null,geoCoordinates:[]};if(t){const i=typeof t=="object"&&"latitude"in t?t.latitude:null,a=typeof t=="object"&&"longitude"in t?t.longitude:null;r.geoCoordinates=i!==null&&a!==null?[a,i]:[]}return[r]},ei=(e,n,t)=>{const r=n.postalCode,i=n.geoCoordinates,a=e?.shippingData?.availableAddresses??[],o=e?.shippingData?.selectedAddresses??[];if(!t&&o.length>0)return[o[0]];if(t&&a.length>0)for(const s of a){if(r&&i&&(s.postalCode===r||s.geoCoordinates[0]===i.longitude&&s.geoCoordinates[1]===i.latitude))return[s];if(r&&!i&&s.postalCode===r)return[s];if(i&&!r&&s.geoCoordinates[0]===i.longitude&&s.geoCoordinates[1]===i.latitude)return[s]}return null},Hn=(e,n)=>{if(!ni(n))return{updateShipping:!1,addressChanged:!1};if(!ai(e))return{updateShipping:!1,addressChanged:!1};const[t]=e?.shippingData?.selectedAddresses??[];if(ti(t,n.postalCode)||ri(t,n.geoCoordinates)||ii(t,n.addressType))return{updateShipping:!0,addressChanged:!0};const{logisticsInfo:r}=e.shippingData;return oi(r,n)?{updateShipping:!0,addressChanged:!1}:{updateShipping:!1,addressChanged:!1}},ni=e=>!!e.postalCode||e.geoCoordinates?.latitude&&e.geoCoordinates?.longitude,ti=(e,n)=>typeof n=="string"&&e?.postalCode!==n,ri=(e,n)=>typeof n?.latitude=="number"&&typeof n?.longitude=="number"&&(e?.geoCoordinates[0]!==n?.longitude||e?.geoCoordinates[1]!==n?.latitude),ii=(e,n)=>typeof n=="string"&&e?.addressType!==n,ai=e=>e.items.length!==0,oi=(e,n)=>{const t=n?.deliveryMode?.deliveryChannel,r=n?.deliveryMode?.deliveryMethod,{startDate:i,endDate:a}=n?.deliveryMode?.deliveryWindow||{};return e.some(({selectedDeliveryChannel:o,selectedSla:s,slas:c})=>{const d=t&&o!==t,g=r&&s!==r;return c?.some(p=>d&&p.deliveryChannel===t||g&&p.id===r?!0:i&&a&&p.deliveryChannel===t&&p.id===r&&(!p?.deliveryWindow||p?.deliveryWindow?.startDateUtc!==i||p?.deliveryWindow?.endDateUtc!==a)&&p.availableDeliveryWindows?.some(f=>f?.startDateUtc===i&&f?.endDateUtc===a))})},Xn=e=>e.valueReference===x.attachment,si=e=>e.valueReference===x.service,ci=e=>(e.itemOffered.additionalProperty??[]).filter(si).map(Qr).sort((n,t)=>n.localeCompare(t)),Yn=e=>{const n=ci(e);return n.length>0?`services:${n.join("-")}`:void 0},Pe=e=>[e.itemOffered.sku,e.seller.identifier,e.price<.01?"Gift":void 0,e.itemOffered.additionalProperty?.filter(Xn).map(jn).join("-"),Yn(e)].filter(Boolean).join("::"),he=(e,n)=>({listPrice:e.listPrice/100,price:e.sellingPrice/100,quantity:e.quantity,seller:{identifier:e.seller},itemOffered:{sku:e.id,image:[],name:e.name,additionalProperty:[...e.attachments.map(xn),...(e.bundleItems??[]).map(Fe)]},index:n}),li=e=>({quantity:e.quantity,seller:e.seller.identifier,id:e.itemOffered.sku,index:e.index,attachments:(e.itemOffered.additionalProperty?.filter(Xn)??[]).map(n=>({name:n.name,content:n.value})),...e.priceToken?{priceToken:e.priceToken}:{}}),Qe=e=>e.reduce((n,t)=>{const r=Pe(t);return n.has(r)||n.set(r,[]),n.get(r)?.push(t),n},new Map),di=(e,n)=>{const t=({priceToken:s,...c},d)=>({...c,itemOffered:{sku:c.itemOffered.sku},services:Yn(c),index:d}),r=n.items.map(he).map(t),i=e.acceptedOffer.map(t),a=e.orderNumber===n.orderFormId,o=_e(r,i);return a&&o};function Jn(e,n){return e?.some(t=>t.parentItemIndex!==null&&t.parentItemIndex!==void 0&&e[t.parentItemIndex]?.id===n)}function Kn(e,n){return e?.some(t=>t.id===n&&t.parentItemIndex!==null)}const Ze=e=>{const n=e.items.reduce((t,r,i)=>{const a=Kn(e.items,r.id)||Jn(e.items,r.id)?`${Pe(he(r))}::${i}`:Pe(he(r));return t[a]||(t[a]=[]),t[a].push(r),t},{});return{...e,items:Object.values(n).map(t=>{const[r]=t,i=t.reduce((o,s)=>o+s.quantity,0),a=t.reduce((o,s)=>o+(s?.priceDefinition?.total??(s?.quantity??0)*(s?.sellingPrice??0)),0);return{...r,quantity:i,sellingPrice:a/i}})}},Ee=async(e,n,t,r)=>({order:{orderNumber:e.orderFormId,acceptedOffer:e.items.map(async i=>({...i,product:await n.load(`${i.id}-invisibleItems`)})),shouldSplitItem:t,...r?{salesChannel:r}:{}},messages:e.messages.map(({text:i,status:a})=>({text:i,status:a.toUpperCase()}))}),Qn=({items:e},n)=>{const t=e.map(r=>{const i=(r.bundleItems??[]).map(Fe).map(({propertyID:a})=>a).sort((a,o)=>a.localeCompare(o));return{id:r.id,quantity:r.quantity,seller:r.seller,attachments:r.attachments,...i.length>0?{services:i}:{}}});return Re(JSON.stringify({sessionId:n?.id??"",items:t}))},en=async(e,n,t)=>{try{return await n.checkout.setCustomData({id:e.orderFormId,appId:"faststore",key:"cartEtag",value:Qn(e,t)})}catch(r){throw console.error(`Error while setting custom data to orderForm.
5
5
  Make sure to add the following custom app to the orderForm:
6
6
  {"fields":["cartEtag"],"id":"faststore","major":1}.
7
- More info at: https://developers.vtex.com/vtex-rest-api/docs/customizable-fields-with-checkout-api`),r}},ti=(e,n)=>{const r=e.customData?.customApps.find(a=>a.id==="faststore")?.fields?.cartEtag;return r==null?!0:jn(e,n)!==r},ri=async(e,{clients:{commerce:n}})=>n.checkout.clearOrderFormMessages({id:e}),Qe=async(e,n,{clients:{commerce:t}})=>{if(!n)return e;const{updateShipping:r,addressChanged:i}=Mn(e,n);if(r){const a=Wr(e,n,i),s=a||jr(n);return!!n.deliveryMode?.deliveryWindow&&await t.checkout.shippingData({id:e.orderFormId,index:e.items.length,deliveryMode:n.deliveryMode,selectedAddresses:s},!1),t.checkout.shippingData({id:e.orderFormId,index:e.items.length,deliveryMode:n.deliveryMode,selectedAddresses:s},!0)}return e},ii=(e,n)=>{if(!e)return"";const r=te.parse(e)[n];return r?r.split("=")[1]:""},Ze=(e,n)=>{const t=Fr(e.storage.channel,n.salesChannel);return t?(de(e,t),n.salesChannel?String(n.salesChannel):null):null},en=(e,n,t,r)=>r?we(e,n,t,r):null,ai=async(e,{cart:{order:n},session:t},r)=>{const i=ii(r.headers.cookie,"checkout.vtex.com"),{clients:{commerce:a},loaders:{skuLoader:o}}=r,s=t?.channel,c=t?.locale;s&&de(r,s),c&&be(r,c);const u=i||void 0,d=await a.checkout.orderForm({id:u,channel:r.storage.channel,preserveSalesChannel:!!u}),g=d.orderFormId;d.messages.length!==0&&await ri(g,r);const f=te.parse(r?.headers?.cookie??"")?.vtex_session,h=q(f),{acceptedOffer:v,shouldSplitItem:l}=n;if(ti(d,h)){const b=Ze(r,d),B=await Ke(d,a,h).then(Je);if(g)return we(B,o,l,b)}const m=Ze(r,d),S=Ye(v),O=Ye(d.items.map(ue)),w=Array.from(O.entries()),C=Array.from(S.entries()),{itemsToAdd:T,itemsToUpdate:I}=C.reduce((b,[B,Ue])=>{const _e=O.get(B);if(!_e)return Ue.forEach(J=>b.itemsToAdd.push(J)),b;const[ie,...Qn]=_e;if(xn(d.items,ie.itemOffered.sku)||qn(d.items,ie.itemOffered.sku))return b.itemsToUpdate.push(ie),b;const Zn=Ue.reduce((J,et)=>J+et.quantity,0);return b.itemsToUpdate.push({...ie,quantity:Zn}),Qn.forEach(J=>b.itemsToUpdate.push({...J,quantity:0})),b},{itemsToAdd:[],itemsToUpdate:[]}),A=w.filter(([b])=>!S.has(b)).flatMap(([,b])=>b.map(B=>({...B,quantity:0}))),D=[...T,...I,...A].map(ei),{updateShipping:k}=t?Mn(d,t):{updateShipping:!1};if(D.length===0&&!k)return en(d,o,l,m);let P;D.length>0?P=await a.checkout.updateOrderFormItems({id:d.orderFormId,orderItems:D,shouldSplitItem:l}).then(b=>Qe(b,t,r)):P=await Qe(d,t,r),P=await Promise.resolve(P).then(b=>{if(t?.marketingData){const B={...b.marketingData,...t.marketingData};return a.checkout.marketingData({id:d.orderFormId,marketingData:B})}return b}).then(b=>c&&b.clientPreferencesData?.locale!==c?a.checkout.clientPreferencesData({id:b.orderFormId,clientPreferencesData:{...b.clientPreferencesData,locale:c}}):b).then(b=>Ke(b,a,h)).then(Je);const R=Ee(d.messages,P.messages);return ni(n,P)&&R?en(P,o,l,m):we(P,o,l,m)};function oi(e,n,t,r){const i=e.hasOnlyDefaultSalesChannel===!1,a=n??void 0,o=t??e.regionId;return re.stringify({salesChannel:i?e.salesChannel||a:a??e.salesChannel,regionId:o??void 0,seller:r,hasOnlyDefaultSalesChannel:i?!1:!a})}const si=e=>{const n=(e?.corporateName??"").trim();return n||(e?.firstName??"").trim()},ci=e=>{if(!e||typeof e!="object")return!1;const n=e;return typeof n.customerId=="string"&&n.customerId.trim()!==""&&typeof n.contractName=="string"&&typeof n.isActive=="boolean"&&typeof n.isCurrent=="boolean"},li=e=>{const n=e?.availableContracts?.value;return Array.isArray(n)?n.filter(ci):[]},di=e=>e?.customerId?!!((e.contractName??"").trim()&&e.isActive):!1,nn=e=>e?.namespaces?.shopper?.activeContractId?.value?.trim()??e?.namespaces?.authentication?.customerId?.value?.trim()??e?.namespaces?.profile?.id?.value?.trim()??"",ui=e=>{if(!Array.isArray(e)||e.length===0)return"";const n=e.find(t=>t?.isDefault===!0)??e[0];return String(n?.id??"").trim()},pi=(e,n="",t="")=>{const r=n.trim(),i=t.trim();return e.filter(di).map(a=>({id:a.customerId,corporateName:a.contractName.trim(),isActive:r?a.customerId===r:a.isCurrent,isDefault:i!==""&&a.customerId===i}))},Wn=(e,n)=>{const t=si(e);return t||(n?.firstName?.value??"").trim()};async function gi(e,n,t){try{const r=await e.commerce.checkout.address({postalCode:t,country:n}),i=r.geoCoordinates?{latitude:r.geoCoordinates[1],longitude:r.geoCoordinates[0]}:null;return{city:r.city,geoCoordinates:i}}catch(r){throw console.error(`Error while getting geo coordinates for the current postal code (${t}) and country (${n}).
8
- `),r}}function mi(e,n,t,r,i,a){const o=new URLSearchParams(e);return o.has("facets")&&o.delete("facets"),o.set("sc",o.get("sc")??n.salesChannel),t&&o.set("postalCode",t),r&&o.set("country",r),i&&o.set("geoCoordinates",`${i.longitude},${i.latitude}`),o.set("locale",a),o}function hi(e,n){return{utmCampaign:e.get("utm_campaign")??n?.utmCampaign??"",utmMedium:e.get("utm_medium")??n?.utmMedium??"",utmSource:e.get("utm_source")??n?.utmSource??"",utmiCampaign:e.get("utmi_cp")??n?.utmiCampaign??"",utmiPage:e.get("utmi_p")??n?.utmiPage??"",utmiPart:e.get("utmi_pc")??n?.utmiPart??""}}async function fi(e,n,t){const r=q(N(n??"",t));let i=!1;if(r)try{i=(await e.commerce.vtexid.validate())?.authStatus?.toLowerCase()==="success"}catch(a){console.warn("JWT validation failed:",a),i=!1}return{isRepresentative:i?!!r?.isRepresentative:!1,customerId:i?r?.customerId:void 0,unitId:i?r?.unitId:void 0}}async function Si(e,n,t,r,i,a){return!n.seller||!(t||r)?void 0:(await e.commerce.checkout.region({postalCode:t,geoCoordinates:r,country:i,salesChannel:a}))?.[0]?.sellers.find(c=>n.seller===c.id)?.id}function tn(e){return typeof e?.value=="string"?e.value:""}function yi(e){if(!e.isRepresentative)return null;const n=tn(e.shopper?.firstName),t=tn(e.shopper?.lastName);return{isRepresentative:!0,customerId:e.authentication?.customerId?.value??e.customerId??"",unitName:e.authentication?.unitName?.value??"",unitId:e.authentication?.unitId?.value??e.unitId??"",firstName:n,lastName:t,userName:`${n} ${t}`.trim(),userEmail:e.authentication?.storeUserEmail?.value??"",savedPostalCode:e.publicData?.postalCode?.value??"",contractName:Wn(e.contract,e.profile),organizationManager:e.shopper?.organizationManager?.value??!1}}function Ii(e){return e?.id?{id:e.id?.value??"",email:e.email?.value??"",givenName:e.firstName?.value??"",familyName:e.lastName?.value??""}:null}const vi=async(e,{session:n,search:t},{clients:r,headers:i,account:a})=>{const o=re.parse(n.channel??""),s=String(n.postalCode??""),c=n.country??"";let u=n.city??null,d=n.geoCoordinates??null;if((!u||!d)&&s!==""&&c!==""){const P=await gi(r,c,s);u=P.city,d=P.geoCoordinates}const f=mi(t,o,s,c,d,n.locale),h=hi(f,n.marketingData),{isRepresentative:v,customerId:l,unitId:p}=await fi(r,i?.cookie,a),m=await r.commerce.session(f.toString()).catch(()=>null),S=m?.namespaces.profile??null,O=m?.namespaces.shopper??null,w=m?.namespaces.store??null,C=m?.namespaces.authentication??null,T=m?.namespaces.checkout??null,I=m?.namespaces.public??null;let A=null;if(v&&S?.id?.value)try{A=await r.commerce.masterData.getContractById({contractId:S.id.value})}catch{console.error(`Error while getting contract data for profile ID (${S.id.value}).
9
- `)}const D=await Si(r,o,s,d,c,f.get("sc")??o.salesChannel),k={...n,currency:{code:w?.currencyCode?.value??n.currency.code,symbol:w?.currencySymbol?.value??n.currency.symbol},country:w?.countryCode?.value??c,channel:oi(o,w?.channel?.value,T?.regionId?.value,D),b2b:yi({isRepresentative:v,authentication:C,shopper:O,publicData:I,profile:S,contract:A,customerId:l,unitId:p}),marketingData:h,person:Ii(S),geoCoordinates:d?.latitude&&d?.longitude&&d||null,city:u};return Ee(n,k)?null:k},Oi={validateCart:ai,validateSession:vi,subscribeToNewsletter:_r,cancelOrder:Pr,processOrderAuthorization:kr,uploadFileToOrderEntry:Rr,startOrderEntryOperation:Tr,startRecommendationSession:Ur};var Ae;(function(e){e.NAME="Name",e.DOCUMENT="Document",e.OPERATION_DEFINITION="OperationDefinition",e.VARIABLE_DEFINITION="VariableDefinition",e.SELECTION_SET="SelectionSet",e.FIELD="Field",e.ARGUMENT="Argument",e.FRAGMENT_SPREAD="FragmentSpread",e.INLINE_FRAGMENT="InlineFragment",e.FRAGMENT_DEFINITION="FragmentDefinition",e.VARIABLE="Variable",e.INT="IntValue",e.FLOAT="FloatValue",e.STRING="StringValue",e.BOOLEAN="BooleanValue",e.NULL="NullValue",e.ENUM="EnumValue",e.LIST="ListValue",e.OBJECT="ObjectValue",e.OBJECT_FIELD="ObjectField",e.DIRECTIVE="Directive",e.NAMED_TYPE="NamedType",e.LIST_TYPE="ListType",e.NON_NULL_TYPE="NonNullType",e.SCHEMA_DEFINITION="SchemaDefinition",e.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",e.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",e.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",e.FIELD_DEFINITION="FieldDefinition",e.INPUT_VALUE_DEFINITION="InputValueDefinition",e.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",e.UNION_TYPE_DEFINITION="UnionTypeDefinition",e.ENUM_TYPE_DEFINITION="EnumTypeDefinition",e.ENUM_VALUE_DEFINITION="EnumValueDefinition",e.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",e.DIRECTIVE_DEFINITION="DirectiveDefinition",e.SCHEMA_EXTENSION="SchemaExtension",e.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",e.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",e.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",e.UNION_TYPE_EXTENSION="UnionTypeExtension",e.ENUM_TYPE_EXTENSION="EnumTypeExtension",e.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension"})(Ae||(Ae={}));const bi=e=>typeof e=="string"?Gn(e):null;function Gn(e){try{return JSON.parse(e)}catch{return e}}const Ci=e=>typeof e=="object"?JSON.stringify(e):typeof e=="string"?e:null,wi=new ce.GraphQLScalarType({name:"ObjectOrString",description:"A string or the string representation of an object (a stringified object).",parseValue:bi,serialize:Ci,parseLiteral(e){return e.kind===Ae.STRING?Gn(e.value):null}}),U=e=>"Price"in e&&"seller"in e&&"product"in e,_=e=>"skuName"in e,Ai={priceCurrency:async(e,n,t)=>{const{loaders:{salesChannelLoader:r},storage:{channel:i}}=t;return(await r.load(i.salesChannel)).CurrencyCode??""},priceValidUntil:e=>U(e)?e.PriceValidUntil??"":_(e)?e.priceValidUntil??"":null,itemCondition:()=>"https://schema.org/NewCondition",availability:async e=>U(e)?Ve(M(e)):_(e)?Ve(pr(e.availability)):null,seller:(e,n,t)=>U(e)?{identifier:t.storage.channel?.seller||e.seller.sellerId||""}:_(e)?{identifier:e.seller}:null,price:e=>U(e)?X(e):_(e)?e.sellingPrice/100:null,priceWithTaxes:e=>U(e)?x(X(e),e?.Tax,e.product.unitMultiplier):_(e)?x(e.sellingPrice/100,e.tax/100,e.unitMultiplier):null,sellingPrice:e=>U(e)?ur(e):_(e)?e.sellingPrice/100:null,listPrice:e=>U(e)?e.ListPrice??0:_(e)?e.listPrice/100:null,listPriceWithTaxes:e=>U(e)?x(e.ListPrice??0,e?.Tax,e.product.unitMultiplier):_(e)?x(e.listPrice/100,e.tax/100,e.unitMultiplier):null,itemOffered:e=>U(e)?e.product:_(e)?{...e.product,attachmentsValues:e.attachments,servicesValues:e.bundleItems??[]}:null,quantity:e=>U(e)?e.AvailableQuantity??0:_(e)?e.quantity:null,isGift:e=>_(e)?e.isGift??!1:null,priceToken:e=>U(e)?e.PriceToken??null:null},Di=({linkText:e})=>`/${e}/p`,Pi=({offer:e,seller:n,product:t})=>({...e,product:t,seller:n}),Ei={imageText:"image",imageUrl:"https://storecomponents.vtexassets.com/assets/faststore/images/image___117a6d3e229a96ad0e0d0876352566e2.svg",imageLabel:"label"},oe=(e,n)=>`${e}-${n}`,rn=(e,n)=>`/${oe(e,n)}/p`,ki=e=>Array.isArray(e)&&e.length>0?e:null;function De(e){return e.replace(/^\/+|\/+$/g,"")}async function se(e,n,t){const r=`${n}:${t}`;e.storage.productTranslationsCache??=new Map;const i=e.storage.productTranslationsCache,a=i.get(r);if(a)return a;const o=(async()=>{try{const s=await e.clients.catalog.getLocalizedProduct(n,t);return{linkId:s.linkId,categories:s.categories??[],availableLinkIds:s.availableLinkIds??{}}}catch(s){return console.warn(`[getLocalizedProductEntry] failed to load product ${n} for locale ${t}:`,s),null}})();return i.set(r,o),o}const Ti=(e,n)=>{const t=e.findIndex(r=>De(r).split("/").at(-1)===n);return t<0?0:t},Ui={productID:({itemId:e})=>e,name:({isVariantOf:e,name:n})=>n??e.productName,slug:({isVariantOf:{linkText:e},itemId:n})=>oe(e,n),description:({isVariantOf:{description:e}})=>e,seo:({isVariantOf:e})=>({title:e.productTitle||e.productName,description:e.metaTagDescription||e.description,canonical:Di(e)}),brand:({isVariantOf:{brand:e}})=>({name:e}),unitMultiplier:({unitMultiplier:e})=>e,breadcrumbList:async(e,n,t)=>{const{isVariantOf:{categories:r,productName:i,linkText:a,categoryId:o,categoriesIds:s,productId:c},itemId:u}=e,d=Ti(s,o),g=r[d],f=De(g).split("/"),h=t.storage.locale;if(G(t)&&h){const v=await se(t,c,h);if(v){const l=new Set(De(s[d]).split("/").filter(Boolean)),p=v.categories.filter(S=>l.has(S.id.toString())).sort((S,O)=>S.fullPath.split("/").length-O.fullPath.split("/").length);if(p.length===f.length)return{itemListElement:[...p.map((S,O)=>({name:S.name,item:`/${S.fullPathUriName}/`,position:O+1})),{name:i,item:rn(v.linkId,u),position:f.length+1}],numberOfItems:f.length}}}return{itemListElement:[...f.map((v,l)=>{const p=`/${f.slice(0,l+1).map(le).join("/")}/`;return{name:v,item:p,position:l+1}}),{name:i,item:rn(a,u),position:f.length+1}],numberOfItems:f.length}},image:({images:e},n)=>{const t=(ki(e)??[Ei]).map(({imageUrl:s,imageText:c,imageLabel:u})=>({alternateName:c??"",url:s.replace("vteximg.com.br","vtexassets.com"),keywords:u}));if(typeof n!="object")return t;let{context:r,limit:i}=n;const a=r!=="generic";i=i||-1,i=i<=-1?void 0:i;let o=a?t.filter(({keywords:s})=>s===r):t;return o=o.length===0?t:o,o.slice(0,i)},sku:({itemId:e})=>e,gtin:({ean:e,referenceId:n})=>e||(n[0]?.Value??""),mpn:({isVariantOf:{manufacturerCode:e}})=>e??"",review:()=>[],aggregateRating:()=>({}),offers:e=>e.sellers.map(n=>Pi({offer:n.commertialOffer,seller:n,product:e})).sort(Un),isVariantOf:e=>e,additionalProperty:({variations:e=[],attachmentsValues:n=[],attributes:t=[],servicesValues:r=[]})=>{const i=e.flatMap(({name:c,values:u})=>u.map(d=>({name:c,value:d,valueReference:z.specification}))),a=n.map(Nn),o=t.map(Nr),s=r.map(Te);return[...i,...a,...o,...s]},hasSpecifications:({isVariantOf:e})=>!!e.skuSpecifications?.length,skuSpecifications:({isVariantOf:{skuSpecifications:e}})=>e??[],specificationGroups:({isVariantOf:{specificationGroups:e}})=>e,releaseDate:({isVariantOf:{releaseDate:e}})=>e??"",advertisement:({isVariantOf:{advertisement:e}})=>e,deliveryPromiseBadges:({isVariantOf:{deliveryPromisesBadges:e}})=>e,otherLocales:async(e,n,t)=>{if(!G(t))return null;const r=Et(t);if(r.length===0)return null;const i=e.isVariantOf.productId,a=e.itemId,o=t.storage.locale,s=await se(t,i,o);if(!s?.availableLinkIds)return null;const{availableLinkIds:c}=s;return r.map(u=>{const d=c[u];return d?{locale:u,slug:oe(d,a)}:null}).filter(u=>u!==null)},defaultLocaleSlug:async(e,n,t)=>{if(!G(t))return null;const r=kt(t);if(!r)return null;const{productId:i,linkText:a}=e.isVariantOf,o=e.itemId,c=(await se(t,i,t.storage.locale))?.availableLinkIds?.[r]??a;return oe(c,o)}},_i=new Set(["allSpecifications"]),Ri={hasVariant:e=>e.isVariantOf.items.map(n=>F(n,e.isVariantOf)),productGroupID:({isVariantOf:e})=>e.productId,productClusters:({isVariantOf:e})=>e.productClusters??[],name:e=>e.isVariantOf.productName,skuVariants:e=>e,additionalProperty:({isVariantOf:{specificationGroups:e}})=>e.filter(n=>!_i.has(n.name)).flatMap(({specifications:n})=>n.flatMap(({name:t,values:r})=>r.map(i=>({name:t,value:i,valueReference:z.specification}))))},Fi={propertyID:e=>e.propertyID||Ln(e),name:({name:e})=>e,value:({value:e})=>e,valueReference:({valueReference:e})=>e},pe=e=>{const n=e.flatMap(r=>r.sellers.map(i=>({offer:i.commertialOffer,sku:r}))),t=Oe(n,({offer:r},{offer:i})=>Un(r,i));return t?t.sku:e[0]},Hn=e=>e!==""&&!Number.isNaN(Number(e)),Ni=/^vrn:recommendations:[^:]+:[^:]+:[^:]+$/,Li=async(e,{campaignVrn:n,userId:t,products:r},i)=>{const{clients:{commerce:a}}=i,{salesChannel:o}=i.storage.channel,s=n?.trim();if(!s||!Ni.test(s))throw new E(`Invalid campaignVrn: "${n}"`);const c=t?.trim();if(t!=null&&!c)throw new E("Invalid userId: must be a non-empty string");if(r!=null&&(!Array.isArray(r)||r.some(h=>!h?.trim())))throw new E("Invalid products: must be an array of non-empty strings");const u=await a.recommendation.recommendations({campaignVrn:s,userId:c||void 0,products:r??[],salesChannel:o??void 0,locale:i.storage.locale}),{campaign:d,correlationId:g}=u;return{products:(u.products??[]).map(h=>{const v=pe(h.items);return v?F(v,h):null}).filter(h=>!!h),correlationId:g,campaign:d}},an={price_desc:"price:desc",price_asc:"price:asc",orders_desc:"orders:desc",name_desc:"name:desc",name_asc:"name:asc",release_desc:"release:desc",discount_desc:"discount:desc",score_desc:""};function Bi(e,n){let t;if(Object.hasOwn(n,e)?t=n[e]:Object.hasOwn(an,e)&&(t=an[e]),t===void 0)throw new E(`Unknown sort value: ${e}`);return t}const $i=async(e,{operationId:n},{clients:{commerce:t}})=>{if(!n)throw new E("Missing operationId");return t.orderEntry.getOperation({operationId:n})},Mi=async(e,{orderFormId:n},{clients:{commerce:t}})=>{if(!n)throw new E("Missing orderFormId");const{items:r}=await t.orderEntry.getOrderFormItems({orderFormId:n});return(r??[]).map(i=>({id:i.id,name:i.name,price:i.price,listPrice:i.listPrice,quantity:i.quantity,imageUrl:i.imageUrl??null,availability:i.availability,seller:i.seller,unitMultiplier:i.unitMultiplier??1}))};async function zi(e,n,t,r){const i=n.slice(0,n.lastIndexOf("-"));return(await se(e,t,r))?.linkId===i}const Xn="Invalid SkuId",Yn="Slug was set but the fetched sku does not satisfy the slug condition.",Vi="UseAdHocCard",qi=e=>W(e)||e instanceof Error&&(e.message===Xn||e.message.startsWith(Yn));async function xi(e,n,t,r){const{linkText:i,productId:a}=n.isVariantOf;if(!(!t||!i||t.startsWith(i)||G(e)&&r&&Hn(t.split("-").pop()??"")&&await zi(e,t,a,r)))throw new Error(`${Yn} slug: ${t}, linkText: ${i}`)}async function ji(e,n){if(n==null)throw new E("Missing slug or id");const{clients:{commerce:t,search:r}}=e,i=await t.catalog.portal.pagetype(`${n}/p`);if(i.pageType!=="Product"||!i.id)throw new L(`No product found for slug ${n}`);const a=await r.fetchProduct({field:"id",value:String(i.id)}).catch(()=>null);if(!a)throw new L(`No product found for id ${i.id}`);return F(pe(a.items),a)}const Wi={product:async(e,{locator:n},t)=>{const r=He(n),i=Ge(n),a=br(n),o=Or(n);r&&de(t,r),i&&be(t,i);const{loaders:{skuLoader:s}}=t;try{const c=a??o?.split("-").pop()??"";if(!Hn(c))throw new Error(Xn);const u=await s.load(c);return await xi(t,u,o,i),u}catch(c){if(!qi(c))throw c;return ji(t,o)}},collection:(e,{slug:n},t)=>{const{loaders:{collectionLoader:r}}=t;return r.load({slug:n,locale:Pn(t)})},search:async(e,{first:n,after:t,sort:r,term:i,selectedFacets:a,sponsoredCount:o},s)=>{const c=He(a),u=Ge(a),d=vr(a);c&&de(s,c),u&&be(s,u);const g=t?Number(t):0,f={page:Math.ceil(g/n)||0,count:n,query:i??void 0,sort:Bi(r??"score_desc",s.storage.customSortMap),selectedFacets:a?.flatMap(je)??[],sponsoredCount:o??void 0};if(d){const l=(await s.clients.commerce.catalog.products.crossselling({type:Rn[d.key],productId:d.value})).map(m=>m.productId).slice(0,n),p=s.clients.search.productsByIdentifier({field:"id",values:l}).then(m=>({products:m,recordsFiltered:m.length,pagination:{count:m.length,current:{index:0,proxyURL:""},before:[],after:[],perPage:n,next:{index:0,proxyURL:""},previous:{index:0,proxyURL:""},first:{index:0,proxyURL:""},last:{index:0,proxyURL:""}},sampling:!1,options:{sorts:[],counts:[]},translated:!1,locale:"",query:"",operator:"and",fuzzy:"0",searchId:""}));return{searchArgs:f,productSearchPromise:p}}const h=s.clients.search.products(f);return{searchArgs:f,productSearchPromise:h}},allProducts:async(e,{first:n,after:t},r)=>{const{clients:{search:i}}=r,a=t?Number(t):0,o=await i.products({page:Math.ceil(a/n),count:n}),s=o.products.flatMap(c=>c.items.map(u=>F(u,c))).filter(c=>c.sellers.length>0);return{pageInfo:{hasNextPage:o.pagination.after.length>0,hasPreviousPage:o.pagination.before.length>0,startCursor:"0",endCursor:o.recordsFiltered.toString(),totalCount:o.recordsFiltered},edges:s.map((c,u)=>({node:c,cursor:(a+u).toString()}))}},products:async(e,{productIds:n},t)=>{const{clients:{search:r}}=t;return n.length?(await r.productsByIdentifier({field:"id",values:n})).flatMap(a=>a.items.map(o=>F(o,a))).filter(a=>n.includes(a.itemId)&&a.sellers.length>0):[]},allCollections:async(e,{first:n,after:t},r)=>{const{clients:{commerce:i}}=r,a=t?Number(t):0,[o,s]=await Promise.all([i.catalog.brand.list(),i.catalog.category.tree()]),c=[],u=(h,v)=>{c.push({id:h.id,name:h.name,fatherCategoryId:v,linkId:le(h.name),title:h.Title,description:null,metaTagDescription:h.MetaTagDescription,availableLinkIds:null,entityType:"category",slug:new URL(h.url).pathname.slice(1).toLowerCase()});for(const l of h.children)u(l,h.id)};for(const h of s)u(h,null);const f=[...o.filter(h=>h.isActive).map(h=>({id:h.id,name:h.name,linkId:le(h.name),title:h.title,description:null,metaTagDescription:h.metaTagDescription,availableLinkIds:null,entityType:"brand"})),...c].filter(h=>!!_n.slug(h,null,r,null));return{pageInfo:{hasNextPage:f.length-a>n,hasPreviousPage:a>0,startCursor:"0",endCursor:(Math.min(n,f.length-a)-1).toString(),totalCount:f.length},edges:f.slice(a,a+n).map((h,v)=>({node:h,cursor:(a+v).toString()}))}},shipping:async(e,{country:n,items:t,postalCode:r},i)=>{const{loaders:{simulationLoader:a},clients:{commerce:o}}=i,[s,c]=await Promise.all([a.load({country:n,items:t,postalCode:r}),o.checkout.address({postalCode:r,country:n})]);return{...s,address:c}},redirect:async(e,{term:n,selectedFacets:t},r)=>{if(!n&&(!t||!t.length))return null;const{redirect:i}=await r.clients.search.products({page:1,count:1,query:n??void 0,selectedFacets:t?.flatMap(je)??[],allowRedirect:!0});return{url:i}},sellers:async(e,{postalCode:n,geoCoordinates:t,country:r,salesChannel:i},a)=>{const{clients:{commerce:o}}=a,c=(await o.checkout.region({postalCode:n,geoCoordinates:t,country:r,salesChannel:i}))?.[0],{id:u,sellers:d}=c;return{id:u,sellers:d}},profile:async(e,{id:n},t)=>{const{clients:{commerce:r}}=t,i=await r.profile.addresses(n);function a(s){return!s||Object.keys(s).length===0?[]:Object.values(s).map(c=>JSON.parse(c))}return{addresses:a(i)}},productCount:async(e,{term:n},t)=>{const{clients:{search:r}}=t;return await r.productCount({query:n??void 0})},userOrder:async(e,{orderId:n},t)=>{try{if(!n)throw new E("Missing orderId");const{clients:{commerce:r}}=t,i=await r.oms.userOrder({orderId:n});if(!i)throw new L(`No order found for id ${n}`);let a=null;try{const c=await r.oms.getCommercialAuthorizationsByOrderId({orderId:n});a=Fn(c)}catch{}const s=(await r.masterData.getShopperById({userId:i.purchaseAgentData?.purchaseAgents?.[0]?.userId??""})??[])[0]??{};return{orderId:i.orderId,creationDate:i.creationDate,totals:i.totals,items:i.items,shippingData:i.shippingData,paymentData:i.paymentData,customData:i.customData,status:i.status,statusDescription:i.statusDescription,allowCancellation:i.allowCancellation,storePreferencesData:i.storePreferencesData,clientProfileData:i.clientProfileData,canProcessOrderAuthorization:(i.status==="waiting-for-confirmation"||i.status==="waiting-for-authorization")&&!!a,ruleForAuthorization:a,shopper:{firstName:s?.firstName||"",lastName:s?.lastName||"",email:s?.email||"",phone:s?.phone||""},budgetData:i.budgetData??{budgets:[]}}}catch(r){const i=r.message;let a={};try{const s=JSON.parse(i);a=s.error||s}catch{a={message:i}}const o=a?.message||i;throw W(r)?new L(`No order found for id ${n}. ${o}.`):wn(r)?new H(`You are forbidden to interact with order with id ${n}. ${o}.`):r}},listUserOrders:async(e,n,t)=>{const{clients:{commerce:r}}=t,i=await r.oms.listUserOrders(n);return{list:i.list?.map(a=>({orderId:a.orderId,creationDate:a.creationDate,clientName:a.clientName,items:a.items,totalValue:a.totalValue,status:a.status,statusDescription:a.statusDescription,ShippingEstimatedDate:a.ShippingEstimatedDate,customFields:a.customFields,currencyCode:a.currencyCode})),paging:i.paging}},listCreditCards:async(e,n,t)=>{const{clients:{commerce:r}}=t;return{list:(await r.savedCards.listCreditCards())?.map(a=>({accountId:a.accountId,bin:a.bin,cardNumber:a.cardNumber,cardLabel:a.cardLabel,paymentSystem:a.paymentSystem,paymentSystemName:a.paymentSystemName,isDefault:a.isDefault,isActive:a.isActive,origin:a.origin}))}},hasAdHocCardAccess:async(e,n,t)=>{const{account:r,headers:i,clients:{commerce:a}}=t,s=q(N(i?.cookie??"",r))?.userId??"";if(!s)return!0;const c=await a.licenseManager.isResourceGranted({userId:s,resourceKey:Vi}).catch(()=>null);return typeof c=="boolean"?c:!0},listUserQuotes:async(e,n,t)=>{const{clients:{commerce:r}}=t,i=await r.quotes.listUserQuotes(n),a=[...new Set(i.items.map(c=>c.createdBy).filter(Boolean))],o=new Map;return await Promise.all(a.map(async c=>{try{const[u]=await r.masterData.getShopperById({userId:c});if(u){const d=[u.firstName,u.lastName].filter(Boolean).join(" ");d&&o.set(c,d)}}catch{}})),{list:i.items.map(c=>({id:c.id,status:c.status,label:c.label??null,createdAt:c.createdAt,expiresAt:c.expiresAt,amount:c.amount,createdBy:c.createdBy?o.get(c.createdBy)??c.createdBy:null})),paging:{total:i.totalItems,currentPage:i.pageNumber,perPage:i.pageSize}}},validateUser:async(e,n,t)=>({isValid:!0}),isOrganizationMember:async(e,n,t)=>{const{clients:{commerce:r}}=t;return!!(await r.session("").catch(()=>null))?.namespaces.authentication?.unitId?.value},userDetails:async(e,n,t)=>{const{account:r,headers:i,clients:{commerce:a}}=t,s=q(N(i?.cookie??"",r))?.userId??"",[c,u,d]=await Promise.all([a.session("").catch(()=>null),s?a.masterData.getShopperById({userId:s}).catch(()=>null):Promise.resolve(null),s?a.licenseManager.getUserRoles({userId:s}).catch(()=>null):Promise.resolve(null)]),g=u?.[0],f=c?.namespaces.authentication??null,h=`${(g?.firstName??"").trim()} ${(g?.lastName??"").trim()}`.trim();return{username:f?.storeUserEmail?.value??"",name:h,email:f?.storeUserEmail?.value??"",phone:g?.phone??"",role:d?.Roles?.map(v=>v.Name)??[],orgUnit:f?.unitName?.value??""}},accountProfile:async(e,n,t)=>{const{account:r,headers:i,clients:{commerce:a}}=t,o=q(N(i?.cookie??"",r));if(!o?.userId)return null;if(o?.isRepresentative){const c=await a.session("").catch(()=>null);if(!c)return null;const u=c.namespaces.profile??null,d=c.namespaces.shopper??null,g=c.namespaces.authentication??null,f=nn(c)||o?.customerId?.trim()||"";let h=null;if(f)try{h=await a.masterData.getContractById({contractId:f})}catch(p){console.error(`Error while getting contract data for contract ID (${f}).`,p)}const v=`${(d?.firstName?.value??"").trim()} ${(d?.lastName?.value??"").trim()}`.trim();return{name:Wn(h,u)||v||"",email:u?.email?.value||g?.storeUserEmail?.value||"",id:u?.id?.value||g?.customerId?.value||o?.customerId?.trim()||""}}const s=await a.licenseManager.getUserById({userId:o?.userId}).catch(()=>null);return{name:s?.name||"",email:s?.email||"",id:s?.id||""}},availableContracts:async(e,{orgUnitId:n},t)=>{if(!n)throw new E("Missing orgUnitId");const{account:r,headers:i,clients:{commerce:a}}=t,o=await a.session("").catch(()=>null),s=N(i?.cookie??"",r);let c=null;try{c=s?q(s):null}catch{c=null}const u=o?.namespaces.authentication?.unitId?.value?.trim()??c?.unitId?.trim()??"";if(!u||u!==n)throw new H("You are not allowed to list contracts for this organization unit");const d=li(o?.namespaces.shopper),g=nn(o)||c?.customerId?.trim()||"",f=await a.storeFront.attachedContracts(n).catch(v=>(console.warn("availableContracts: default contract lookup failed",v),null)),h=ui(f?.contracts);return pi(d,g,h)},pickupPoints:async(e,{geoCoordinates:n},t)=>{const{clients:{commerce:r}}=t;return await r.checkout.pickupPoints({geoCoordinates:n})},orderEntryOperation:$i,orderFormItems:Mi,recommendations:Li},Gi={reviewRating:()=>({ratingValue:5,bestRating:5}),author:()=>({name:""})},Hi=(e,n,t)=>n?e.key==="category-1":t?e.key==="brand":!1,Xi={suggestions:async(e,n,t)=>{const{clients:{search:r}}=t,{searchArgs:i}=e;if(!i.query)return{terms:(await r.topSearches()).searches.map(g=>({value:g.term,count:g.count})),products:[]};const{productSearchPromise:a}=e,[o,s]=await Promise.all([r.suggestedTerms(i),a]),c=s.products.map(d=>{const g=pe(d.items);return g&&F(g,d)}).filter(d=>!!d),{searches:u}=o;return{terms:u.map(d=>({value:d.term,count:d.count})),products:c}},products:async({productSearchPromise:e})=>{const n=await e,t=n.products.map(r=>{const i=pe(r.items);return i&&F(i,r)}).filter(r=>!!r);return{pageInfo:{hasNextPage:n.pagination.after.length>0,hasPreviousPage:n.pagination.before.length>0,startCursor:"0",endCursor:n.recordsFiltered.toString(),totalCount:n.recordsFiltered},edges:t.map((r,i)=>({node:r,cursor:i.toString()}))}},facets:async({searchArgs:e},n,t)=>{const{clients:{search:r}}=t;t.storage.searchArgs=e;const{facets:i=[]}=await r.facets(e),a=!e.query,o=e.selectedFacets?.length?e.selectedFacets[0].key==="category-1":!1,s=e.selectedFacets?.length?e.selectedFacets[0].key==="brand":!1;return i.filter(u=>!a||!Hi(u,o,s))},metadata:async({productSearchPromise:e})=>{const n=await e;return{isTermMisspelled:n.correction?.misspelled??!1,logicalOperator:n.operator,fuzzy:n.fuzzy}},searchId:async({productSearchPromise:e})=>(await e).searchId},Yi={title:({title:e})=>e??"",description:({description:e})=>e??"",canonical:({canonical:e})=>e??"",titleTemplate:()=>""},Ji=["bd","d","h","m"],Ki=e=>Ji.includes(e),Qi={bd:{0:"Today",1:"In 1 business day",other:"Up to # business days"},d:{0:"Today",1:"In 1 day",other:"Up to # days"},h:{0:"Now",1:"In 1 hour",other:"Up to # hours"},m:{0:"Now",1:"In 1 minute",other:"Up to # minutes"}},Jn=e=>{const[n,t]=[e.split(/\D+/)[0],e.split(/[0-9]+/)[1]],r=n!==""&&!Number.isNaN(Number(n)),i=Ki(t);if(!r||!i)return"";const a=Number(n)<2?Number(n):"other";return Qi[t][a].replace("#",n)??""},Zi={carrier:e=>e?.friendlyName??e?.name??"",price:e=>e?.price?e.price/100:e?.price,localizedEstimates:e=>e?.shippingEstimate?Jn(e.shippingEstimate):""},on="skuvariation";function sn(e,n){const t=`${on}${n}`.toLowerCase(),r=e.find(a=>a.imageLabel===t);if(r)return r;const i=e.find(a=>a.imageLabel===on);return i||e[0]}function ea(e,n,t){const r={};return e.forEach(i=>{const a=i.variations;if(a.length===0)return;const o=`${n}-${a.find(c=>c.name===n)?.values[0]??""}`,s=a.reduce((c,u)=>u.name===n?c:c+`-${u.name}-${u.values[0]}`,o);r[s]=`${t}-${i.itemId}`}),r}function cn(e){const n={};return e.forEach(t=>{n[t.name]=t.values[0]}),n}function na(e){const n={};return e?.forEach(t=>{n[t.field.originalName??t.field.name]=t.values.map(r=>r.originalName??r.name)}),n}function ta(e,n){return Number.isNaN(Number(e)-Number(n))?e<n?-1:e>n?1:0:Number(e)-Number(n)}function ra(e){const n=e;for(const t in e)e[t].every(i=>!Number.isNaN(Number(i.value)))&&e[t].sort((i,a)=>ta(i.value,a.value));return n}function ia(e,n,t){const r={},i=new Set;return e.forEach(a=>{if(a.variations.length===0)return;const o=a.variations.find(c=>c.name===n);if(!(o?.values[0]===t)){const c=`${n}-${o?.values[0]}`;if(!o||i.has(c))return;i.add(c);const u=sn(a.images,n),d={src:u.imageUrl,alt:u.imageLabel??"",label:`${n}: ${o.values[0]}`,value:o.values[0]};r[o.name]?r[o.name].push(d):r[o.name]=[d];return}a.variations.forEach(c=>{const u=`${c.name}-${c.values[0]}`;if(i.has(u))return;i.add(u);const d=sn(a.images,c.name),g={src:d.imageUrl,alt:d.imageText??"",label:`${c.name}: ${c.values[0]}`,value:c.values[0]};r[c.name]?r[c.name].push(g):r[c.name]=[g]})}),ra(r)}const aa={activeVariations:e=>cn(e.variations),allVariantsByName:e=>na(e.isVariantOf.skuSpecifications),slugsMap:(e,n)=>ea(e.isVariantOf.items,n.dominantVariantName??e.variations[0]?.name,e.isVariantOf.linkText),availableVariations:(e,n)=>{const t=n.dominantVariantName??e.variations[0]?.name,i=cn(e.variations)[t];return ia(e.isVariantOf.items,t,i)},allVariantProducts:e=>e.isVariantOf.items.map(n=>F(n,e.isVariantOf))},oa={"pickup-in-point":"Pickup",delivery:"Delivery",pickup:"Pickup","take-away":"Take away","":""},sa={deliveryOptionsData:e=>{const{shippingData:n,items:t}=e,r=n?.logisticsInfo||[],i=n?.selectedAddresses||n?.availableAddresses||[n?.address],a=r.reduce((u,d)=>{const g=d?.selectedSla||"",f=d?.selectedDeliveryChannel||d?.deliveryChannel||"",h=d?.deliveryCompany||"",v=d?.deliveryWindow,l=d?.pickupStoreInfo,p=d?.shippingEstimate||"",m=d?.shippingEstimate?Jn(d?.shippingEstimate):"",S=d?.shippingEstimateDate||"",O=d?.addressId||"",w=d?.itemIndex??0,C=t?.[w],T=C?.seller||"",I=`${g}|${f}|${h}|${T}|${p}|${S}|${O}|${v?.startDateUtc}|${v?.endDateUtc}`,A=i?.find(b=>b?.addressId===O),D=`${oa[f]||""} ${m} ${A?.neighborhood?`to ${A?.neighborhood}`:""}`.trim(),{taxPriceTagsTotal:k,taxPriceTags:P}=ca(C?.priceTags??[]),R=(C?.sellingPrice??0)*(C?.quantity??0)+(C?.tax??0)+(k??0);return u[I]||(u[I]={selectedSla:g,deliveryChannel:f,deliveryCompany:h,deliveryWindow:v,shippingEstimate:p,shippingEstimateDate:S,seller:T,friendlyShippingEstimate:m,friendlyDeliveryOptionName:D,address:A,pickupStoreInfo:l,quantityOfDifferentItems:0,total:0,items:[]}),u[I]&&(u[I].items?.push({id:C?.id||"",uniqueId:C?.uniqueId||"",name:C?.name||"",quantity:C?.quantity||0,price:C?.price||0,sellingPrice:C?.sellingPrice||0,imageUrl:C?.imageUrl||"",taxPriceTags:P??[],taxPriceTagsTotal:k??0,tax:C?.tax||0,total:R}),u[I].quantityOfDifferentItems=(u[I].quantityOfDifferentItems??0)+1,u[I].total=(u[I].total??0)+R),u},{}),o=Object.values(a),s=n?.contactInformation?.[0],c={name:`${s?.firstName??""} ${s?.lastName??""}`.trim()||o?.[0]?.address?.receiverName||"",email:s?.email||"",phone:s?.phone||""};return{deliveryOptions:o,contact:c}},customFields:e=>{const n=e?.customData?.customFields||[];return Object.values(n.reduce((t,r)=>{const i=r?.linkedEntity?.type||"",a=r?.linkedEntity?.id||"",o=`${i}|${a||""}`;return t[o]||(t[o]={type:i,id:a,fields:[]}),t[o].fields.push(...r?.fields||[]),t},{}))||[]}};function ca(e){const t=e.filter(i=>i?.name?.includes("TAX")),r=t.reduce((i,a)=>i+(a.rawValue?a.rawValue*100:0),0);return{taxPriceTags:t,taxPriceTagsTotal:r}}const la={StoreCollection:_n,StoreAggregateOffer:mr,StoreProduct:Ui,StoreSeo:Yi,StoreFacet:Cr,StoreFacetBoolean:wr,StoreFacetRange:Ar,StoreFacetValueBoolean:Dr,StoreOffer:Ai,StoreAggregateRating:hr,StoreReview:Gi,StoreProductGroup:Ri,StoreSearchResult:Xi,StorePropertyValue:Fi,SkuVariants:aa,ShippingSLA:Zi,UserOrderResult:sa,ObjectOrString:wi,Query:Wi,Mutation:Oi},da=()=>la,ua=`"""
7
+ More info at: https://developers.vtex.com/vtex-rest-api/docs/customizable-fields-with-checkout-api`),r}},ui=(e,n)=>{const r=e.customData?.customApps.find(a=>a.id==="faststore")?.fields?.cartEtag;return r==null?!0:Qn(e,n)!==r},pi=async(e,{clients:{commerce:n}})=>n.checkout.clearOrderFormMessages({id:e}),nn=async(e,n,{clients:{commerce:t}})=>{if(!n)return e;const{updateShipping:r,addressChanged:i}=Hn(e,n);if(r){const a=ei(e,n,i),s=a||Zr(n);return!!n.deliveryMode?.deliveryWindow&&await t.checkout.shippingData({id:e.orderFormId,index:e.items.length,deliveryMode:n.deliveryMode,selectedAddresses:s},!1),t.checkout.shippingData({id:e.orderFormId,index:e.items.length,deliveryMode:n.deliveryMode,selectedAddresses:s},!0)}return e},gi=(e,n)=>{if(!e)return"";const r=ae.parse(e)[n];return r?r.split("=")[1]:""},mi=async(e,n,t,r)=>{const{commerce:i}=e.clients,a=await i.checkout.orderForm({id:n,channel:e.storage.channel,preserveSalesChannel:!!n&&!t});return!n||Vr(a,e.storage.channel.salesChannel,r)?a:i.checkout.orderForm({id:n,channel:e.storage.channel})},tn=(e,n,t)=>{if(!t||n.items.length===0)return null;const r=zr(e.storage.channel,n.salesChannel);return r?(me(e,r),n.salesChannel?String(n.salesChannel):null):null},rn=(e,n,t,r)=>r?Ee(e,n,t,r):null,hi=async(e,{cart:{order:n},session:t},r)=>{const i=gi(r.headers.cookie,"checkout.vtex.com"),{clients:{commerce:a},loaders:{skuLoader:o}}=r,s=t?.channel,c=t?.locale,d=zn(s,{localizationEnabled:Vn(r.discoveryConfig)})==="url",g=qn(s);s&&me(r,s),c&&De(r,c);const p=await mi(r,i||void 0,d,g),f=p.orderFormId;p.messages.length!==0&&await pi(f,r);const h=ae.parse(r?.headers?.cookie??"")?.vtex_session,v=W(h),{acceptedOffer:l,shouldSplitItem:u}=n;if(ui(p,v)){const A=tn(r,p,!d),N=await en(p,a,v).then(Ze);if(f)return Ee(N,o,u,A)}const S=tn(r,p,!d),O=Qe(l),b=Qe(p.items.map(he)),C=Array.from(b.entries()),T=Array.from(O.entries()),{itemsToAdd:I,itemsToUpdate:w}=T.reduce((A,[N,Q])=>{const se=b.get(N);if(!se)return Q.forEach(Z=>A.itemsToAdd.push(Z)),A;const[M,...ce]=se;if(Kn(p.items,M.itemOffered.sku)||Jn(p.items,M.itemOffered.sku))return A.itemsToUpdate.push(M),A;const ot=Q.reduce((Z,st)=>Z+st.quantity,0);return A.itemsToUpdate.push({...M,quantity:ot}),ce.forEach(Z=>A.itemsToUpdate.push({...Z,quantity:0})),A},{itemsToAdd:[],itemsToUpdate:[]}),k=C.filter(([A])=>!O.has(A)).flatMap(([,A])=>A.map(N=>({...N,quantity:0}))),D=[...I,...w,...k].map(li),{updateShipping:_}=t?Hn(p,t):{updateShipping:!1};if(D.length===0&&!_)return rn(p,o,u,S);let P;D.length>0?P=await a.checkout.updateOrderFormItems({id:p.orderFormId,orderItems:D,shouldSplitItem:u}).then(A=>nn(A,t,r)):P=await nn(p,t,r),P=await Promise.resolve(P).then(A=>{if(t?.marketingData){const N={...A.marketingData,...t.marketingData};return a.checkout.marketingData({id:p.orderFormId,marketingData:N})}return A}).then(A=>c&&A.clientPreferencesData?.locale!==c?a.checkout.clientPreferencesData({id:A.orderFormId,clientPreferencesData:{...A.clientPreferencesData,locale:c}}):A).then(A=>en(A,a,v)).then(Ze);const U=_e(p.messages,P.messages);return di(n,P)&&U?rn(P,o,u,S):Ee(P,o,u,S)},fi=e=>{const n=(e?.corporateName??"").trim();return n||(e?.firstName??"").trim()},Si=e=>{if(!e||typeof e!="object")return!1;const n=e;return typeof n.customerId=="string"&&n.customerId.trim()!==""&&typeof n.contractName=="string"&&typeof n.isActive=="boolean"&&typeof n.isCurrent=="boolean"},yi=e=>{const n=e?.availableContracts?.value;return Array.isArray(n)?n.filter(Si):[]},Ii=e=>e?.customerId?!!((e.contractName??"").trim()&&e.isActive):!1,an=e=>e?.namespaces?.shopper?.activeContractId?.value?.trim()??e?.namespaces?.authentication?.customerId?.value?.trim()??e?.namespaces?.profile?.id?.value?.trim()??"",vi=e=>{if(!Array.isArray(e)||e.length===0)return"";const n=e.find(t=>t?.isDefault===!0)??e[0];return String(n?.id??"").trim()},Oi=(e,n="",t="")=>{const r=n.trim(),i=t.trim();return e.filter(Ii).map(a=>({id:a.customerId,corporateName:a.contractName.trim(),isActive:r?a.customerId===r:a.isCurrent,isDefault:i!==""&&a.customerId===i}))},Zn=(e,n)=>{const t=fi(e);return t||(n?.firstName?.value??"").trim()};async function Ci(e,n,t){try{const r=await e.commerce.checkout.address({postalCode:t,country:n}),i=r.geoCoordinates?{latitude:r.geoCoordinates[1],longitude:r.geoCoordinates[0]}:null;return{city:r.city,geoCoordinates:i}}catch(r){throw console.error(`Error while getting geo coordinates for the current postal code (${t}) and country (${n}).
8
+ `),r}}function bi(e,n,t,r,i,a){const o=new URLSearchParams(e);return o.has("facets")&&o.delete("facets"),o.set("sc",o.get("sc")??n.salesChannel),t&&o.set("postalCode",t),r&&o.set("country",r),i&&o.set("geoCoordinates",`${i.longitude},${i.latitude}`),o.set("locale",a),o}function wi(e,n){return{utmCampaign:e.get("utm_campaign")??n?.utmCampaign??"",utmMedium:e.get("utm_medium")??n?.utmMedium??"",utmSource:e.get("utm_source")??n?.utmSource??"",utmiCampaign:e.get("utmi_cp")??n?.utmiCampaign??"",utmiPage:e.get("utmi_p")??n?.utmiPage??"",utmiPart:e.get("utmi_pc")??n?.utmiPart??""}}async function Ai(e,n,t){const r=W(B(n??"",t));let i=!1;if(r)try{i=(await e.commerce.vtexid.validate())?.authStatus?.toLowerCase()==="success"}catch(a){console.warn("JWT validation failed:",a),i=!1}return{isRepresentative:i?!!r?.isRepresentative:!1,customerId:i?r?.customerId:void 0,unitId:i?r?.unitId:void 0}}async function Di(e,n,t,r,i,a){return!n.seller||!(t||r)?void 0:(await e.commerce.checkout.region({postalCode:t,geoCoordinates:r,country:i,salesChannel:a}))?.[0]?.sellers.find(c=>n.seller===c.id)?.id}function on(e){return typeof e?.value=="string"?e.value:""}function Pi(e){if(!e.isRepresentative)return null;const n=on(e.shopper?.firstName),t=on(e.shopper?.lastName);return{isRepresentative:!0,customerId:e.authentication?.customerId?.value??e.customerId??"",unitName:e.authentication?.unitName?.value??"",unitId:e.authentication?.unitId?.value??e.unitId??"",firstName:n,lastName:t,userName:`${n} ${t}`.trim(),userEmail:e.authentication?.storeUserEmail?.value??"",savedPostalCode:e.publicData?.postalCode?.value??"",contractName:Zn(e.contract,e.profile),organizationManager:e.shopper?.organizationManager?.value??!1}}function Ei(e){return e?.id?{id:e.id?.value??"",email:e.email?.value??"",givenName:e.firstName?.value??"",familyName:e.lastName?.value??""}:null}const ki=e=>e instanceof q&&(e.extensions.status===401||e.extensions.status===403),Ti=e=>e instanceof Error&&/sales\s*channel/i.test(e.message),Ui=(e,n,t,r)=>{if(n!=="orderForm"||t!==r)return!1;if(Ti(e))return!0;const i=`[validateSession] Session Manager rejected adopted sales channel ${t} with an unrecognized error; keeping the adoption.`,a=e instanceof Error?e.message:e;return console.warn(i,a),Pn("warn","%s %o",i,a),!1},_i=async(e,n,t,r)=>{const i={salesChannelSource:t,rejectedSalesChannel:void 0};try{return{...i,sessionData:await e.commerce.session(n.toString())}}catch(a){if(t==="url"||!ki(a))return{...i,sessionData:null};const o=n.get("sc")??void 0,s=Ui(a,t,o,r);n.delete("sc");const c=await e.commerce.session(n.toString()).catch(()=>null);return!c||!s?{...i,sessionData:c}:{sessionData:c,salesChannelSource:void 0,rejectedSalesChannel:o}}},Ri=async(e,{session:n,search:t},{clients:r,headers:i,account:a,storage:o,discoveryConfig:s})=>{const c=oe.parse(n.channel??""),d=zn(n.channel,{localizationEnabled:Vn(s)}),g={...c,salesChannel:xr(c,d,o?.channel?.salesChannel?String(o.channel.salesChannel):void 0,t)},p=String(n.postalCode??""),f=n.country??"";let h=n.city??null,v=n.geoCoordinates??null;if((!h||!v)&&p!==""&&f!==""){const ce=await Ci(r,f,p);h=ce.city,v=ce.geoCoordinates}const u=bi(t,g,p,f,v,n.locale),m=wi(u,n.marketingData),{isRepresentative:S,customerId:O,unitId:b}=await Ai(r,i?.cookie,a),{sessionData:C,salesChannelSource:T,rejectedSalesChannel:I}=await _i(r,u,d,String(g.salesChannel??"")),w=C?.namespaces.profile??null,k=C?.namespaces.shopper??null,D=C?.namespaces.store??null,_=C?.namespaces.authentication??null,P=C?.namespaces.checkout??null,U=C?.namespaces.public??null;let A=null;if(S&&w?.id?.value)try{A=await r.commerce.masterData.getContractById({contractId:w.id.value})}catch{console.error(`Error while getting contract data for profile ID (${w.id.value}).
9
+ `)}const N=await Di(r,g,p,v,f,u.get("sc")??D?.channel?.value??g.salesChannel),Q=Ei(w),se=(n.person?.id??null)===(Q?.id??null)?qn(n.channel):void 0,M={...n,currency:{code:D?.currencyCode?.value??n.currency.code,symbol:D?.currencySymbol?.value??n.currency.symbol},country:D?.countryCode?.value??f,channel:qr(g,D?.channel?.value,P?.regionId?.value,N,T,I??se),b2b:Pi({isRepresentative:S,authentication:_,shopper:k,publicData:U,profile:w,contract:A,customerId:O,unitId:b}),marketingData:m,person:Q,geoCoordinates:v?.latitude&&v?.longitude&&v||null,city:h};return _e(n,M)?null:M},Fi={validateCart:hi,validateSession:Ri,subscribeToNewsletter:$r,cancelOrder:Rr,processOrderAuthorization:Nr,uploadFileToOrderEntry:Mr,startOrderEntryOperation:Lr,startRecommendationSession:Br};var ke;(function(e){e.NAME="Name",e.DOCUMENT="Document",e.OPERATION_DEFINITION="OperationDefinition",e.VARIABLE_DEFINITION="VariableDefinition",e.SELECTION_SET="SelectionSet",e.FIELD="Field",e.ARGUMENT="Argument",e.FRAGMENT_SPREAD="FragmentSpread",e.INLINE_FRAGMENT="InlineFragment",e.FRAGMENT_DEFINITION="FragmentDefinition",e.VARIABLE="Variable",e.INT="IntValue",e.FLOAT="FloatValue",e.STRING="StringValue",e.BOOLEAN="BooleanValue",e.NULL="NullValue",e.ENUM="EnumValue",e.LIST="ListValue",e.OBJECT="ObjectValue",e.OBJECT_FIELD="ObjectField",e.DIRECTIVE="Directive",e.NAMED_TYPE="NamedType",e.LIST_TYPE="ListType",e.NON_NULL_TYPE="NonNullType",e.SCHEMA_DEFINITION="SchemaDefinition",e.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",e.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",e.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",e.FIELD_DEFINITION="FieldDefinition",e.INPUT_VALUE_DEFINITION="InputValueDefinition",e.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",e.UNION_TYPE_DEFINITION="UnionTypeDefinition",e.ENUM_TYPE_DEFINITION="EnumTypeDefinition",e.ENUM_VALUE_DEFINITION="EnumValueDefinition",e.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",e.DIRECTIVE_DEFINITION="DirectiveDefinition",e.SCHEMA_EXTENSION="SchemaExtension",e.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",e.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",e.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",e.UNION_TYPE_EXTENSION="UnionTypeExtension",e.ENUM_TYPE_EXTENSION="EnumTypeExtension",e.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension"})(ke||(ke={}));const Ni=e=>typeof e=="string"?et(e):null;function et(e){try{return JSON.parse(e)}catch{return e}}const Li=e=>typeof e=="object"?JSON.stringify(e):typeof e=="string"?e:null,Bi=new pe.GraphQLScalarType({name:"ObjectOrString",description:"A string or the string representation of an object (a stringified object).",parseValue:Ni,serialize:Li,parseLiteral(e){return e.kind===ke.STRING?et(e.value):null}}),R=e=>"Price"in e&&"seller"in e&&"product"in e,F=e=>"skuName"in e,$i={priceCurrency:async(e,n,t)=>{const{loaders:{salesChannelLoader:r},storage:{channel:i}}=t;return(await r.load(i.salesChannel)).CurrencyCode??""},priceValidUntil:e=>R(e)?e.PriceValidUntil??"":F(e)?e.priceValidUntil??"":null,itemCondition:()=>"https://schema.org/NewCondition",availability:async e=>R(e)?xe(V(e)):F(e)?xe(yr(e.availability)):null,seller:(e,n,t)=>R(e)?{identifier:t.storage.channel?.seller||e.seller.sellerId||""}:F(e)?{identifier:e.seller}:null,price:e=>R(e)?K(e):F(e)?e.sellingPrice/100:null,priceWithTaxes:e=>R(e)?G(K(e),e?.Tax,e.product.unitMultiplier):F(e)?G(e.sellingPrice/100,e.tax/100,e.unitMultiplier):null,sellingPrice:e=>R(e)?Sr(e):F(e)?e.sellingPrice/100:null,listPrice:e=>R(e)?e.ListPrice??0:F(e)?e.listPrice/100:null,listPriceWithTaxes:e=>R(e)?G(e.ListPrice??0,e?.Tax,e.product.unitMultiplier):F(e)?G(e.listPrice/100,e.tax/100,e.unitMultiplier):null,itemOffered:e=>R(e)?e.product:F(e)?{...e.product,attachmentsValues:e.attachments,servicesValues:e.bundleItems??[]}:null,quantity:e=>R(e)?e.AvailableQuantity??0:F(e)?e.quantity:null,isGift:e=>F(e)?e.isGift??!1:null,priceToken:e=>R(e)?e.PriceToken??null:null},Mi=({linkText:e})=>`/${e}/p`,zi=({offer:e,seller:n,product:t})=>({...e,product:t,seller:n}),Vi={imageText:"image",imageUrl:"https://storecomponents.vtexassets.com/assets/faststore/images/image___117a6d3e229a96ad0e0d0876352566e2.svg",imageLabel:"label"},de=(e,n)=>`${e}-${n}`,sn=(e,n)=>`/${de(e,n)}/p`,qi=e=>Array.isArray(e)&&e.length>0?e:null;function Te(e){return e.replace(/^\/+|\/+$/g,"")}async function ue(e,n,t){const r=`${n}:${t}`;e.storage.productTranslationsCache??=new Map;const i=e.storage.productTranslationsCache,a=i.get(r);if(a)return a;const o=(async()=>{try{const s=await e.clients.catalog.getLocalizedProduct(n,t);return{linkId:s.linkId,categories:s.categories??[],availableLinkIds:s.availableLinkIds??{}}}catch(s){return console.warn(`[getLocalizedProductEntry] failed to load product ${n} for locale ${t}:`,s),null}})();return i.set(r,o),o}const xi=(e,n)=>{const t=e.findIndex(r=>Te(r).split("/").at(-1)===n);return t<0?0:t},ji={productID:({itemId:e})=>e,name:({isVariantOf:e,name:n})=>n??e.productName,slug:({isVariantOf:{linkText:e},itemId:n})=>de(e,n),description:({isVariantOf:{description:e}})=>e,seo:({isVariantOf:e})=>({title:e.productTitle||e.productName,description:e.metaTagDescription||e.description,canonical:Mi(e)}),brand:({isVariantOf:{brand:e}})=>({name:e}),unitMultiplier:({unitMultiplier:e})=>e,breadcrumbList:async(e,n,t)=>{const{isVariantOf:{categories:r,productName:i,linkText:a,categoryId:o,categoriesIds:s,productId:c},itemId:d}=e,g=xi(s,o),p=r[g],f=Te(p).split("/"),h=t.storage.locale;if(Y(t)&&h){const v=await ue(t,c,h);if(v){const l=new Set(Te(s[g]).split("/").filter(Boolean)),u=v.categories.filter(S=>l.has(S.id.toString())).sort((S,O)=>S.fullPath.split("/").length-O.fullPath.split("/").length);if(u.length===f.length)return{itemListElement:[...u.map((S,O)=>({name:S.name,item:`/${S.fullPathUriName}/`,position:O+1})),{name:i,item:sn(v.linkId,d),position:f.length+1}],numberOfItems:f.length}}}return{itemListElement:[...f.map((v,l)=>{const u=`/${f.slice(0,l+1).map(ge).join("/")}/`;return{name:v,item:u,position:l+1}}),{name:i,item:sn(a,d),position:f.length+1}],numberOfItems:f.length}},image:({images:e},n)=>{const t=(qi(e)??[Vi]).map(({imageUrl:s,imageText:c,imageLabel:d})=>({alternateName:c??"",url:s.replace("vteximg.com.br","vtexassets.com"),keywords:d}));if(typeof n!="object")return t;let{context:r,limit:i}=n;const a=r!=="generic";i=i||-1,i=i<=-1?void 0:i;let o=a?t.filter(({keywords:s})=>s===r):t;return o=o.length===0?t:o,o.slice(0,i)},sku:({itemId:e})=>e,gtin:({ean:e,referenceId:n})=>e||(n[0]?.Value??""),mpn:({isVariantOf:{manufacturerCode:e}})=>e??"",review:()=>[],aggregateRating:()=>({}),offers:e=>e.sellers.map(n=>zi({offer:n.commertialOffer,seller:n,product:e})).sort(Nn),isVariantOf:e=>e,additionalProperty:({variations:e=[],attachmentsValues:n=[],attributes:t=[],servicesValues:r=[]})=>{const i=e.flatMap(({name:c,values:d})=>d.map(g=>({name:c,value:g,valueReference:x.specification}))),a=n.map(xn),o=t.map(jr),s=r.map(Fe);return[...i,...a,...o,...s]},hasSpecifications:({isVariantOf:e})=>!!e.skuSpecifications?.length,skuSpecifications:({isVariantOf:{skuSpecifications:e}})=>e??[],specificationGroups:({isVariantOf:{specificationGroups:e}})=>e,releaseDate:({isVariantOf:{releaseDate:e}})=>e??"",advertisement:({isVariantOf:{advertisement:e}})=>e,deliveryPromiseBadges:({isVariantOf:{deliveryPromisesBadges:e}})=>e,otherLocales:async(e,n,t)=>{if(!Y(t))return null;const r=Ft(t);if(r.length===0)return null;const i=e.isVariantOf.productId,a=e.itemId,o=t.storage.locale,s=await ue(t,i,o);if(!s?.availableLinkIds)return null;const{availableLinkIds:c}=s;return r.map(d=>{const g=c[d];return g?{locale:d,slug:de(g,a)}:null}).filter(d=>d!==null)},defaultLocaleSlug:async(e,n,t)=>{if(!Y(t))return null;const r=Nt(t);if(!r)return null;const{productId:i,linkText:a}=e.isVariantOf,o=e.itemId,c=(await ue(t,i,t.storage.locale))?.availableLinkIds?.[r]??a;return de(c,o)}},Wi=new Set(["allSpecifications"]),Gi={hasVariant:e=>e.isVariantOf.items.map(n=>L(n,e.isVariantOf)),productGroupID:({isVariantOf:e})=>e.productId,productClusters:({isVariantOf:e})=>e.productClusters??[],name:e=>e.isVariantOf.productName,skuVariants:e=>e,additionalProperty:({isVariantOf:{specificationGroups:e}})=>e.filter(n=>!Wi.has(n.name)).flatMap(({specifications:n})=>n.flatMap(({name:t,values:r})=>r.map(i=>({name:t,value:i,valueReference:x.specification}))))},Hi={propertyID:e=>e.propertyID||jn(e),name:({name:e})=>e,value:({value:e})=>e,valueReference:({valueReference:e})=>e},fe=e=>{const n=e.flatMap(r=>r.sellers.map(i=>({offer:i.commertialOffer,sku:r}))),t=Ae(n,({offer:r},{offer:i})=>Nn(r,i));return t?t.sku:e[0]},nt=e=>e!==""&&!Number.isNaN(Number(e)),Xi=/^vrn:recommendations:[^:]+:[^:]+:[^:]+$/,Yi=async(e,{campaignVrn:n,userId:t,products:r},i)=>{const{clients:{commerce:a}}=i,{salesChannel:o}=i.storage.channel,s=n?.trim();if(!s||!Xi.test(s))throw new E(`Invalid campaignVrn: "${n}"`);const c=t?.trim();if(t!=null&&!c)throw new E("Invalid userId: must be a non-empty string");if(r!=null&&(!Array.isArray(r)||r.some(h=>!h?.trim())))throw new E("Invalid products: must be an array of non-empty strings");const d=await a.recommendation.recommendations({campaignVrn:s,userId:c||void 0,products:r??[],salesChannel:o??void 0,locale:i.storage.locale}),{campaign:g,correlationId:p}=d;return{products:(d.products??[]).map(h=>{const v=fe(h.items);return v?L(v,h):null}).filter(h=>!!h),correlationId:p,campaign:g}},cn={price_desc:"price:desc",price_asc:"price:asc",orders_desc:"orders:desc",name_desc:"name:desc",name_asc:"name:asc",release_desc:"release:desc",discount_desc:"discount:desc",score_desc:""};function Ji(e,n){let t;if(Object.hasOwn(n,e)?t=n[e]:Object.hasOwn(cn,e)&&(t=cn[e]),t===void 0)throw new E(`Unknown sort value: ${e}`);return t}const Ki=async(e,{operationId:n},{clients:{commerce:t}})=>{if(!n)throw new E("Missing operationId");return t.orderEntry.getOperation({operationId:n})},Qi=async(e,{orderFormId:n},{clients:{commerce:t}})=>{if(!n)throw new E("Missing orderFormId");const{items:r}=await t.orderEntry.getOrderFormItems({orderFormId:n});return(r??[]).map(i=>({id:i.id,name:i.name,price:i.price,listPrice:i.listPrice,quantity:i.quantity,imageUrl:i.imageUrl??null,availability:i.availability,seller:i.seller,unitMultiplier:i.unitMultiplier??1}))};async function Zi(e,n,t,r){const i=n.slice(0,n.lastIndexOf("-"));return(await ue(e,t,r))?.linkId===i}const tt="Invalid SkuId",rt="Slug was set but the fetched sku does not satisfy the slug condition.",ea="UseAdHocCard",na=e=>X(e)||e instanceof Error&&(e.message===tt||e.message.startsWith(rt));async function ta(e,n,t,r){const{linkText:i,productId:a}=n.isVariantOf;if(!(!t||!i||t.startsWith(i)||Y(e)&&r&&nt(t.split("-").pop()??"")&&await Zi(e,t,a,r)))throw new Error(`${rt} slug: ${t}, linkText: ${i}`)}async function ra(e,n){if(n==null)throw new E("Missing slug or id");const{clients:{commerce:t,search:r}}=e,i=await t.catalog.portal.pagetype(`${n}/p`);if(i.pageType!=="Product"||!i.id)throw new $(`No product found for slug ${n}`);const a=await r.fetchProduct({field:"id",value:String(i.id)}).catch(()=>null);if(!a)throw new $(`No product found for id ${i.id}`);return L(fe(a.items),a)}const ia={product:async(e,{locator:n},t)=>{const r=Ye(n),i=Xe(n),a=Er(n),o=Pr(n);r&&me(t,r),i&&De(t,i);const{loaders:{skuLoader:s}}=t;try{const c=a??o?.split("-").pop()??"";if(!nt(c))throw new Error(tt);const d=await s.load(c);return await ta(t,d,o,i),d}catch(c){if(!na(c))throw c;return ra(t,o)}},collection:(e,{slug:n},t)=>{const{loaders:{collectionLoader:r}}=t;return r.load({slug:n,locale:Un(t)})},search:async(e,{first:n,after:t,sort:r,term:i,selectedFacets:a,sponsoredCount:o},s)=>{const c=Ye(a),d=Xe(a),g=Dr(a);c&&me(s,c),d&&De(s,d);const p=t?Number(t):0,f={page:Math.ceil(p/n)||0,count:n,query:i??void 0,sort:Ji(r??"score_desc",s.storage.customSortMap),selectedFacets:a?.flatMap(Ge)??[],sponsoredCount:o??void 0};if(g){const l=(await s.clients.commerce.catalog.products.crossselling({type:Bn[g.key],productId:g.value})).map(m=>m.productId).slice(0,n),u=s.clients.search.productsByIdentifier({field:"id",values:l}).then(m=>({products:m,recordsFiltered:m.length,pagination:{count:m.length,current:{index:0,proxyURL:""},before:[],after:[],perPage:n,next:{index:0,proxyURL:""},previous:{index:0,proxyURL:""},first:{index:0,proxyURL:""},last:{index:0,proxyURL:""}},sampling:!1,options:{sorts:[],counts:[]},translated:!1,locale:"",query:"",operator:"and",fuzzy:"0",searchId:""}));return{searchArgs:f,productSearchPromise:u}}const h=s.clients.search.products(f);return{searchArgs:f,productSearchPromise:h}},allProducts:async(e,{first:n,after:t},r)=>{const{clients:{search:i}}=r,a=t?Number(t):0,o=await i.products({page:Math.ceil(a/n),count:n}),s=o.products.flatMap(c=>c.items.map(d=>L(d,c))).filter(c=>c.sellers.length>0);return{pageInfo:{hasNextPage:o.pagination.after.length>0,hasPreviousPage:o.pagination.before.length>0,startCursor:"0",endCursor:o.recordsFiltered.toString(),totalCount:o.recordsFiltered},edges:s.map((c,d)=>({node:c,cursor:(a+d).toString()}))}},products:async(e,{productIds:n},t)=>{const{clients:{search:r}}=t;return n.length?(await r.productsByIdentifier({field:"id",values:n})).flatMap(a=>a.items.map(o=>L(o,a))).filter(a=>n.includes(a.itemId)&&a.sellers.length>0):[]},allCollections:async(e,{first:n,after:t},r)=>{const{clients:{commerce:i}}=r,a=t?Number(t):0,[o,s]=await Promise.all([i.catalog.brand.list(),i.catalog.category.tree()]),c=[],d=(h,v)=>{c.push({id:h.id,name:h.name,fatherCategoryId:v,linkId:ge(h.name),title:h.Title,description:null,metaTagDescription:h.MetaTagDescription,availableLinkIds:null,entityType:"category",slug:new URL(h.url).pathname.slice(1).toLowerCase()});for(const l of h.children)d(l,h.id)};for(const h of s)d(h,null);const f=[...o.filter(h=>h.isActive).map(h=>({id:h.id,name:h.name,linkId:ge(h.name),title:h.title,description:null,metaTagDescription:h.metaTagDescription,availableLinkIds:null,entityType:"brand"})),...c].filter(h=>!!Ln.slug(h,null,r,null));return{pageInfo:{hasNextPage:f.length-a>n,hasPreviousPage:a>0,startCursor:"0",endCursor:(Math.min(n,f.length-a)-1).toString(),totalCount:f.length},edges:f.slice(a,a+n).map((h,v)=>({node:h,cursor:(a+v).toString()}))}},shipping:async(e,{country:n,items:t,postalCode:r},i)=>{const{loaders:{simulationLoader:a},clients:{commerce:o}}=i,[s,c]=await Promise.all([a.load({country:n,items:t,postalCode:r}),o.checkout.address({postalCode:r,country:n})]);return{...s,address:c}},redirect:async(e,{term:n,selectedFacets:t},r)=>{if(!n&&(!t||!t.length))return null;const{redirect:i}=await r.clients.search.products({page:1,count:1,query:n??void 0,selectedFacets:t?.flatMap(Ge)??[],allowRedirect:!0});return{url:i}},sellers:async(e,{postalCode:n,geoCoordinates:t,country:r,salesChannel:i},a)=>{const{clients:{commerce:o}}=a,c=(await o.checkout.region({postalCode:n,geoCoordinates:t,country:r,salesChannel:i}))?.[0],{id:d,sellers:g}=c;return{id:d,sellers:g}},profile:async(e,{id:n},t)=>{const{clients:{commerce:r}}=t,i=await r.profile.addresses(n);function a(s){return!s||Object.keys(s).length===0?[]:Object.values(s).map(c=>JSON.parse(c))}return{addresses:a(i)}},productCount:async(e,{term:n},t)=>{const{clients:{search:r}}=t;return await r.productCount({query:n??void 0})},userOrder:async(e,{orderId:n},t)=>{try{if(!n)throw new E("Missing orderId");const{clients:{commerce:r}}=t,i=await r.oms.userOrder({orderId:n});if(!i)throw new $(`No order found for id ${n}`);let a=null;try{const c=await r.oms.getCommercialAuthorizationsByOrderId({orderId:n});a=$n(c)}catch{}const s=(await r.masterData.getShopperById({userId:i.purchaseAgentData?.purchaseAgents?.[0]?.userId??""})??[])[0]??{};return{orderId:i.orderId,creationDate:i.creationDate,totals:i.totals,items:i.items,shippingData:i.shippingData,paymentData:i.paymentData,customData:i.customData,status:i.status,statusDescription:i.statusDescription,allowCancellation:i.allowCancellation,storePreferencesData:i.storePreferencesData,clientProfileData:i.clientProfileData,canProcessOrderAuthorization:(i.status==="waiting-for-confirmation"||i.status==="waiting-for-authorization")&&!!a,ruleForAuthorization:a,shopper:{firstName:s?.firstName||"",lastName:s?.lastName||"",email:s?.email||"",phone:s?.phone||""},budgetData:i.budgetData??{budgets:[]}}}catch(r){const i=r.message;let a={};try{const s=JSON.parse(i);a=s.error||s}catch{a={message:i}}const o=a?.message||i;throw X(r)?new $(`No order found for id ${n}. ${o}.`):En(r)?new J(`You are forbidden to interact with order with id ${n}. ${o}.`):r}},listUserOrders:async(e,n,t)=>{const{clients:{commerce:r}}=t,i=await r.oms.listUserOrders(n);return{list:i.list?.map(a=>({orderId:a.orderId,creationDate:a.creationDate,clientName:a.clientName,items:a.items,totalValue:a.totalValue,status:a.status,statusDescription:a.statusDescription,ShippingEstimatedDate:a.ShippingEstimatedDate,customFields:a.customFields,currencyCode:a.currencyCode})),paging:i.paging}},listCreditCards:async(e,n,t)=>{const{clients:{commerce:r}}=t;return{list:(await r.savedCards.listCreditCards())?.map(a=>({accountId:a.accountId,bin:a.bin,cardNumber:a.cardNumber,cardLabel:a.cardLabel,paymentSystem:a.paymentSystem,paymentSystemName:a.paymentSystemName,isDefault:a.isDefault,isActive:a.isActive,origin:a.origin}))}},hasAdHocCardAccess:async(e,n,t)=>{const{account:r,headers:i,clients:{commerce:a}}=t,s=W(B(i?.cookie??"",r))?.userId??"";if(!s)return!0;const c=await a.licenseManager.isResourceGranted({userId:s,resourceKey:ea}).catch(()=>null);return typeof c=="boolean"?c:!0},listUserQuotes:async(e,n,t)=>{const{clients:{commerce:r}}=t,i=await r.quotes.listUserQuotes(n),a=[...new Set(i.items.map(c=>c.createdBy).filter(Boolean))],o=new Map;return await Promise.all(a.map(async c=>{try{const[d]=await r.masterData.getShopperById({userId:c});if(d){const g=[d.firstName,d.lastName].filter(Boolean).join(" ");g&&o.set(c,g)}}catch{}})),{list:i.items.map(c=>({id:c.id,status:c.status,label:c.label??null,createdAt:c.createdAt,expiresAt:c.expiresAt,amount:c.amount,createdBy:c.createdBy?o.get(c.createdBy)??c.createdBy:null})),paging:{total:i.totalItems,currentPage:i.pageNumber,perPage:i.pageSize}}},validateUser:async(e,n,t)=>({isValid:!0}),isOrganizationMember:async(e,n,t)=>{const{clients:{commerce:r}}=t;return!!(await r.session("").catch(()=>null))?.namespaces.authentication?.unitId?.value},userDetails:async(e,n,t)=>{const{account:r,headers:i,clients:{commerce:a}}=t,s=W(B(i?.cookie??"",r))?.userId??"",[c,d,g]=await Promise.all([a.session("").catch(()=>null),s?a.masterData.getShopperById({userId:s}).catch(()=>null):Promise.resolve(null),s?a.licenseManager.getUserRoles({userId:s}).catch(()=>null):Promise.resolve(null)]),p=d?.[0],f=c?.namespaces.authentication??null,h=`${(p?.firstName??"").trim()} ${(p?.lastName??"").trim()}`.trim();return{username:f?.storeUserEmail?.value??"",name:h,email:f?.storeUserEmail?.value??"",phone:p?.phone??"",role:g?.Roles?.map(v=>v.Name)??[],orgUnit:f?.unitName?.value??""}},accountProfile:async(e,n,t)=>{const{account:r,headers:i,clients:{commerce:a}}=t,o=W(B(i?.cookie??"",r));if(!o?.userId)return null;if(o?.isRepresentative){const c=await a.session("").catch(()=>null);if(!c)return null;const d=c.namespaces.profile??null,g=c.namespaces.shopper??null,p=c.namespaces.authentication??null,f=an(c)||o?.customerId?.trim()||"";let h=null;if(f)try{h=await a.masterData.getContractById({contractId:f})}catch(u){console.error(`Error while getting contract data for contract ID (${f}).`,u)}const v=`${(g?.firstName?.value??"").trim()} ${(g?.lastName?.value??"").trim()}`.trim();return{name:Zn(h,d)||v||"",email:d?.email?.value||p?.storeUserEmail?.value||"",id:d?.id?.value||p?.customerId?.value||o?.customerId?.trim()||""}}const s=await a.licenseManager.getUserById({userId:o?.userId}).catch(()=>null);return{name:s?.name||"",email:s?.email||"",id:s?.id||""}},availableContracts:async(e,{orgUnitId:n},t)=>{if(!n)throw new E("Missing orgUnitId");const{account:r,headers:i,clients:{commerce:a}}=t,o=await a.session("").catch(()=>null),s=B(i?.cookie??"",r);let c=null;try{c=s?W(s):null}catch{c=null}const d=o?.namespaces.authentication?.unitId?.value?.trim()??c?.unitId?.trim()??"";if(!d||d!==n)throw new J("You are not allowed to list contracts for this organization unit");const g=yi(o?.namespaces.shopper),p=an(o)||c?.customerId?.trim()||"",f=await a.storeFront.attachedContracts(n).catch(v=>(console.warn("availableContracts: default contract lookup failed",v),null)),h=vi(f?.contracts);return Oi(g,p,h)},pickupPoints:async(e,{geoCoordinates:n},t)=>{const{clients:{commerce:r}}=t;return await r.checkout.pickupPoints({geoCoordinates:n})},orderEntryOperation:Ki,orderFormItems:Qi,recommendations:Yi},aa={reviewRating:()=>({ratingValue:5,bestRating:5}),author:()=>({name:""})},oa=(e,n,t)=>n?e.key==="category-1":t?e.key==="brand":!1,sa={suggestions:async(e,n,t)=>{const{clients:{search:r}}=t,{searchArgs:i}=e;if(!i.query)return{terms:(await r.topSearches()).searches.map(p=>({value:p.term,count:p.count})),products:[]};const{productSearchPromise:a}=e,[o,s]=await Promise.all([r.suggestedTerms(i),a]),c=s.products.map(g=>{const p=fe(g.items);return p&&L(p,g)}).filter(g=>!!g),{searches:d}=o;return{terms:d.map(g=>({value:g.term,count:g.count})),products:c}},products:async({productSearchPromise:e})=>{const n=await e,t=n.products.map(r=>{const i=fe(r.items);return i&&L(i,r)}).filter(r=>!!r);return{pageInfo:{hasNextPage:n.pagination.after.length>0,hasPreviousPage:n.pagination.before.length>0,startCursor:"0",endCursor:n.recordsFiltered.toString(),totalCount:n.recordsFiltered},edges:t.map((r,i)=>({node:r,cursor:i.toString()}))}},facets:async({searchArgs:e},n,t)=>{const{clients:{search:r}}=t;t.storage.searchArgs=e;const{facets:i=[]}=await r.facets(e),a=!e.query,o=e.selectedFacets?.length?e.selectedFacets[0].key==="category-1":!1,s=e.selectedFacets?.length?e.selectedFacets[0].key==="brand":!1;return i.filter(d=>!a||!oa(d,o,s))},metadata:async({productSearchPromise:e})=>{const n=await e;return{isTermMisspelled:n.correction?.misspelled??!1,logicalOperator:n.operator,fuzzy:n.fuzzy}},searchId:async({productSearchPromise:e})=>(await e).searchId},ca={title:({title:e})=>e??"",description:({description:e})=>e??"",canonical:({canonical:e})=>e??"",titleTemplate:()=>""},la=["bd","d","h","m"],da=e=>la.includes(e),ua={bd:{0:"Today",1:"In 1 business day",other:"Up to # business days"},d:{0:"Today",1:"In 1 day",other:"Up to # days"},h:{0:"Now",1:"In 1 hour",other:"Up to # hours"},m:{0:"Now",1:"In 1 minute",other:"Up to # minutes"}},it=e=>{const[n,t]=[e.split(/\D+/)[0],e.split(/[0-9]+/)[1]],r=n!==""&&!Number.isNaN(Number(n)),i=da(t);if(!r||!i)return"";const a=Number(n)<2?Number(n):"other";return ua[t][a].replace("#",n)??""},pa={carrier:e=>e?.friendlyName??e?.name??"",price:e=>e?.price?e.price/100:e?.price,localizedEstimates:e=>e?.shippingEstimate?it(e.shippingEstimate):""},ln="skuvariation";function dn(e,n){const t=`${ln}${n}`.toLowerCase(),r=e.find(a=>a.imageLabel===t);if(r)return r;const i=e.find(a=>a.imageLabel===ln);return i||e[0]}function ga(e,n,t){const r={};return e.forEach(i=>{const a=i.variations;if(a.length===0)return;const o=`${n}-${a.find(c=>c.name===n)?.values[0]??""}`,s=a.reduce((c,d)=>d.name===n?c:c+`-${d.name}-${d.values[0]}`,o);r[s]=`${t}-${i.itemId}`}),r}function un(e){const n={};return e.forEach(t=>{n[t.name]=t.values[0]}),n}function ma(e){const n={};return e?.forEach(t=>{n[t.field.originalName??t.field.name]=t.values.map(r=>r.originalName??r.name)}),n}function ha(e,n){return Number.isNaN(Number(e)-Number(n))?e<n?-1:e>n?1:0:Number(e)-Number(n)}function fa(e){const n=e;for(const t in e)e[t].every(i=>!Number.isNaN(Number(i.value)))&&e[t].sort((i,a)=>ha(i.value,a.value));return n}function Sa(e,n,t){const r={},i=new Set;return e.forEach(a=>{if(a.variations.length===0)return;const o=a.variations.find(c=>c.name===n);if(!(o?.values[0]===t)){const c=`${n}-${o?.values[0]}`;if(!o||i.has(c))return;i.add(c);const d=dn(a.images,n),g={src:d.imageUrl,alt:d.imageLabel??"",label:`${n}: ${o.values[0]}`,value:o.values[0]};r[o.name]?r[o.name].push(g):r[o.name]=[g];return}a.variations.forEach(c=>{const d=`${c.name}-${c.values[0]}`;if(i.has(d))return;i.add(d);const g=dn(a.images,c.name),p={src:g.imageUrl,alt:g.imageText??"",label:`${c.name}: ${c.values[0]}`,value:c.values[0]};r[c.name]?r[c.name].push(p):r[c.name]=[p]})}),fa(r)}const ya={activeVariations:e=>un(e.variations),allVariantsByName:e=>ma(e.isVariantOf.skuSpecifications),slugsMap:(e,n)=>ga(e.isVariantOf.items,n.dominantVariantName??e.variations[0]?.name,e.isVariantOf.linkText),availableVariations:(e,n)=>{const t=n.dominantVariantName??e.variations[0]?.name,i=un(e.variations)[t];return Sa(e.isVariantOf.items,t,i)},allVariantProducts:e=>e.isVariantOf.items.map(n=>L(n,e.isVariantOf))},Ia={"pickup-in-point":"Pickup",delivery:"Delivery",pickup:"Pickup","take-away":"Take away","":""},va={deliveryOptionsData:e=>{const{shippingData:n,items:t}=e,r=n?.logisticsInfo||[],i=n?.selectedAddresses||n?.availableAddresses||[n?.address],a=r.reduce((d,g)=>{const p=g?.selectedSla||"",f=g?.selectedDeliveryChannel||g?.deliveryChannel||"",h=g?.deliveryCompany||"",v=g?.deliveryWindow,l=g?.pickupStoreInfo,u=g?.shippingEstimate||"",m=g?.shippingEstimate?it(g?.shippingEstimate):"",S=g?.shippingEstimateDate||"",O=g?.addressId||"",b=g?.itemIndex??0,C=t?.[b],T=C?.seller||"",I=`${p}|${f}|${h}|${T}|${u}|${S}|${O}|${v?.startDateUtc}|${v?.endDateUtc}`,w=i?.find(U=>U?.addressId===O),k=`${Ia[f]||""} ${m} ${w?.neighborhood?`to ${w?.neighborhood}`:""}`.trim(),{taxPriceTagsTotal:D,taxPriceTags:_}=Oa(C?.priceTags??[]),P=(C?.sellingPrice??0)*(C?.quantity??0)+(C?.tax??0)+(D??0);return d[I]||(d[I]={selectedSla:p,deliveryChannel:f,deliveryCompany:h,deliveryWindow:v,shippingEstimate:u,shippingEstimateDate:S,seller:T,friendlyShippingEstimate:m,friendlyDeliveryOptionName:k,address:w,pickupStoreInfo:l,quantityOfDifferentItems:0,total:0,items:[]}),d[I]&&(d[I].items?.push({id:C?.id||"",uniqueId:C?.uniqueId||"",name:C?.name||"",quantity:C?.quantity||0,price:C?.price||0,sellingPrice:C?.sellingPrice||0,imageUrl:C?.imageUrl||"",taxPriceTags:_??[],taxPriceTagsTotal:D??0,tax:C?.tax||0,total:P}),d[I].quantityOfDifferentItems=(d[I].quantityOfDifferentItems??0)+1,d[I].total=(d[I].total??0)+P),d},{}),o=Object.values(a),s=n?.contactInformation?.[0],c={name:`${s?.firstName??""} ${s?.lastName??""}`.trim()||o?.[0]?.address?.receiverName||"",email:s?.email||"",phone:s?.phone||""};return{deliveryOptions:o,contact:c}},customFields:e=>{const n=e?.customData?.customFields||[];return Object.values(n.reduce((t,r)=>{const i=r?.linkedEntity?.type||"",a=r?.linkedEntity?.id||"",o=`${i}|${a||""}`;return t[o]||(t[o]={type:i,id:a,fields:[]}),t[o].fields.push(...r?.fields||[]),t},{}))||[]}};function Oa(e){const t=e.filter(i=>i?.name?.includes("TAX")),r=t.reduce((i,a)=>i+(a.rawValue?a.rawValue*100:0),0);return{taxPriceTags:t,taxPriceTagsTotal:r}}const Ca={StoreCollection:Ln,StoreAggregateOffer:vr,StoreProduct:ji,StoreSeo:ca,StoreFacet:kr,StoreFacetBoolean:Tr,StoreFacetRange:Ur,StoreFacetValueBoolean:_r,StoreOffer:$i,StoreAggregateRating:Or,StoreReview:aa,StoreProductGroup:Gi,StoreSearchResult:sa,StorePropertyValue:Hi,SkuVariants:ya,ShippingSLA:pa,UserOrderResult:va,ObjectOrString:Bi,Query:ia,Mutation:Fi},ba=()=>Ca,wa=`"""
10
10
  Address information.
11
11
  """
12
12
  type Address {
@@ -51,7 +51,7 @@ type Address {
51
51
  """
52
52
  geoCoordinates: [Float]
53
53
  }
54
- `,pa=`"""
54
+ `,Aa=`"""
55
55
  Advertisement information about a specific product in a campaign
56
56
  """
57
57
  type Advertisement {
@@ -76,7 +76,7 @@ type Advertisement {
76
76
  """
77
77
  adResponseId: String!
78
78
  }
79
- `,ga=`"""
79
+ `,Da=`"""
80
80
  Aggregate offer information, for a given SKU that is available to be fulfilled by multiple sellers.
81
81
  """
82
82
  type StoreAggregateOffer {
@@ -105,7 +105,7 @@ type StoreAggregateOffer {
105
105
  """
106
106
  offers: [StoreOffer!]!
107
107
  }
108
- `,ma=`"""
108
+ `,Pa=`"""
109
109
  Average rating, based on multiple ratings or reviews.
110
110
  """
111
111
  type StoreAggregateRating {
@@ -118,7 +118,7 @@ type StoreAggregateRating {
118
118
  """
119
119
  reviewCount: Int!
120
120
  }
121
- `,ha=`"""
121
+ `,Ea=`"""
122
122
  information about the author of a product review or rating.
123
123
  """
124
124
  type StoreAuthor {
@@ -127,7 +127,7 @@ type StoreAuthor {
127
127
  """
128
128
  name: String!
129
129
  }
130
- `,fa=`"""
130
+ `,ka=`"""
131
131
  Brand of a given product.
132
132
  """
133
133
  type StoreBrand {
@@ -136,7 +136,7 @@ type StoreBrand {
136
136
  """
137
137
  name: String!
138
138
  }
139
- `,Sa=`"""
139
+ `,Ta=`"""
140
140
  Item of a list.
141
141
  """
142
142
  type StoreListItem {
@@ -167,7 +167,7 @@ type StoreBreadcrumbList {
167
167
  """
168
168
  numberOfItems: Int!
169
169
  }
170
- `,ya=`"""
170
+ `,Ua=`"""
171
171
  Shopping cart message.
172
172
  """
173
173
  type StoreCartMessage {
@@ -204,7 +204,7 @@ input IStoreCart {
204
204
  """
205
205
  order: IStoreOrder!
206
206
  }
207
- `,Ia=`"""
207
+ `,_a=`"""
208
208
  Product collection type. Possible values are \`Department\`, \`Category\`, \`Brand\` or \`Collection\`.
209
209
 
210
210
  \`SubCategory\` and \`Cluster\` are still declared for backward compatibility but are
@@ -330,7 +330,7 @@ type StoreCollectionLocale {
330
330
  """
331
331
  slug: String!
332
332
  }
333
- `,va=`"""
333
+ `,Ra=`"""
334
334
  Delivery Promise badge.
335
335
  """
336
336
  type DeliveryPromiseBadge {
@@ -339,7 +339,7 @@ type DeliveryPromiseBadge {
339
339
  """
340
340
  typeName: String
341
341
  }
342
- `,Oa=`union StoreFacet = StoreFacetRange | StoreFacetBoolean
342
+ `,Fa=`union StoreFacet = StoreFacetRange | StoreFacetBoolean
343
343
 
344
344
  """
345
345
  Search facet range information.
@@ -416,7 +416,7 @@ type StoreFacetValueBoolean {
416
416
  """
417
417
  quantity: Int
418
418
  }
419
- `,ba=`"""
419
+ `,Na=`"""
420
420
  Image.
421
421
  """
422
422
  type StoreImage {
@@ -443,7 +443,7 @@ input IStoreImage {
443
443
  """
444
444
  alternateName: String!
445
445
  }
446
- `,Ca=`type Mutation {
446
+ `,La=`type Mutation {
447
447
  """
448
448
  Checks for changes between the cart presented in the UI and the cart stored in the ecommerce platform. If changes are detected, it returns the cart stored on the platform. Otherwise, it returns \`null\`.
449
449
  """
@@ -485,7 +485,7 @@ input IStoreImage {
485
485
  """
486
486
  startRecommendationSession: Boolean!
487
487
  }
488
- `,wa=`"""
488
+ `,Ba=`"""
489
489
  Newsletter information.
490
490
  """
491
491
  type PersonNewsletter {
@@ -508,8 +508,8 @@ input IPersonNewsletter {
508
508
  """
509
509
  email: String!
510
510
  }
511
- `,Aa=`scalar ObjectOrString
512
- `,Da=`"""
511
+ `,$a=`scalar ObjectOrString
512
+ `,Ma=`"""
513
513
  Offer information.
514
514
  """
515
515
  type StoreOffer {
@@ -602,7 +602,7 @@ input IStoreOffer {
602
602
  """
603
603
  priceToken: String
604
604
  }
605
- `,Pa=`"""
605
+ `,za=`"""
606
606
  Information of a specific order.
607
607
  """
608
608
  type StoreOrder {
@@ -643,7 +643,7 @@ input IStoreOrder {
643
643
  """
644
644
  shouldSplitItem: Boolean
645
645
  }
646
- `,Ea=`"""
646
+ `,Va=`"""
647
647
  Commercial Authorization response.
648
648
  """
649
649
  type CommercialAuthorizationResponse {
@@ -1042,7 +1042,7 @@ type ProcessOrderAuthorizationRule {
1042
1042
  """
1043
1043
  rule: CommercialAuthorizationRule!
1044
1044
  }
1045
- `,ka=`"""
1045
+ `,qa=`"""
1046
1046
  Input for uploading a file to the Order Entry Service.
1047
1047
  The file is transmitted as a Base64-encoded string so it can travel
1048
1048
  through the standard GraphQL JSON pipeline without multipart support.
@@ -1103,7 +1103,7 @@ type StoreOrderFormCartItem {
1103
1103
  seller: String!
1104
1104
  unitMultiplier: Float
1105
1105
  }
1106
- `,Ta=`"""
1106
+ `,xa=`"""
1107
1107
  Organization.
1108
1108
  """
1109
1109
  type StoreOrganization {
@@ -1144,7 +1144,7 @@ type StoreContract {
1144
1144
  """
1145
1145
  isDefault: Boolean!
1146
1146
  }
1147
- `,Ua=`"""
1147
+ `,ja=`"""
1148
1148
  Whenever you make a query that allows for pagination, such as \`allProducts\` or \`allCollections\`, you can check \`StorePageInfo\` to learn more about the complete set of items and use it to paginate your queries.
1149
1149
  """
1150
1150
  type StorePageInfo {
@@ -1169,7 +1169,7 @@ type StorePageInfo {
1169
1169
  """
1170
1170
  totalCount: Int!
1171
1171
  }
1172
- `,_a=`"""
1172
+ `,Wa=`"""
1173
1173
  Input type for setting a new password.
1174
1174
  """
1175
1175
  input ISetPassword {
@@ -1212,7 +1212,7 @@ type SetPasswordResponse {
1212
1212
  """
1213
1213
  message: String
1214
1214
  }
1215
- `,Ra=`"""
1215
+ `,Ga=`"""
1216
1216
  Client profile data.
1217
1217
  """
1218
1218
  type StorePerson {
@@ -1255,7 +1255,7 @@ input IStorePerson {
1255
1255
  """
1256
1256
  familyName: String!
1257
1257
  }
1258
- `,Fa=`type PickupPointAddress {
1258
+ `,Ha=`type PickupPointAddress {
1259
1259
  """
1260
1260
  Address city.
1261
1261
  """
@@ -1334,7 +1334,7 @@ type PickupPoints {
1334
1334
  """
1335
1335
  pickupPointsHash: String
1336
1336
  }
1337
- `,Na=`"""
1337
+ `,Xa=`"""
1338
1338
  Product information. Products are variants within product groups, equivalent to VTEX [SKUs](https://help.vtex.com/en/tutorial/what-is-an-sku--1K75s4RXAQyOuGUYKMM68u#). For example, you may have a **Shirt** product group with associated products such as **Blue shirt size L**, **Green shirt size XL** and so on.
1339
1339
  """
1340
1340
  type StoreProduct {
@@ -1510,7 +1510,7 @@ input IStoreProduct {
1510
1510
  """
1511
1511
  additionalProperty: [IStorePropertyValue!]
1512
1512
  }
1513
- `,La=`"""
1513
+ `,Ya=`"""
1514
1514
  Product group information. Product groups are catalog entities that may contain variants. They are equivalent to VTEX [Products](https://help.vtex.com/en/tutorial/what-is-a-product--2zrB2gFCHyQokCKKE8kuAw#), whereas each variant is equivalent to a VTEX [SKU](https://help.vtex.com/en/tutorial/what-is-an-sku--1K75s4RXAQyOuGUYKMM68u#). For example, you may have a **Shirt** product group with associated products such as **Blue shirt size L**, **Green shirt size XL** and so on.
1515
1515
  """
1516
1516
  type StoreProductGroup {
@@ -1555,7 +1555,7 @@ type StoreProductCluster {
1555
1555
  """
1556
1556
  name: String!
1557
1557
  }
1558
- `,Ba=`type Profile {
1558
+ `,Ja=`type Profile {
1559
1559
  """
1560
1560
  Collection of user's address
1561
1561
  """
@@ -1616,7 +1616,7 @@ type ProfileAddress {
1616
1616
  """
1617
1617
  geoCoordinate: [Float]
1618
1618
  }
1619
- `,$a=`"""
1619
+ `,Ka=`"""
1620
1620
  Properties that can be associated with products and products groups.
1621
1621
  """
1622
1622
  type StorePropertyValue {
@@ -1656,7 +1656,7 @@ input IStorePropertyValue {
1656
1656
  """
1657
1657
  valueReference: ObjectOrString!
1658
1658
  }
1659
- `,Ma=`"""
1659
+ `,Qa=`"""
1660
1660
  Each product edge contains a \`node\`, with product information, and a \`cursor\`, that can be used as a reference for pagination.
1661
1661
  """
1662
1662
  type StoreProductEdge {
@@ -2305,7 +2305,7 @@ type StoreAccountProfile {
2305
2305
  email: String
2306
2306
  id: String
2307
2307
  }
2308
- `,za=`"""
2308
+ `,Za=`"""
2309
2309
  Summary of a quote returned in list results.
2310
2310
  """
2311
2311
  type UserQuoteSummary {
@@ -2370,7 +2370,7 @@ type UserQuoteListPaging {
2370
2370
  """
2371
2371
  perPage: Int!
2372
2372
  }
2373
- `,Va=`type RecommendationResponse {
2373
+ `,eo=`type RecommendationResponse {
2374
2374
  products: [StoreProduct!]!
2375
2375
  correlationId: String!
2376
2376
  campaign: RecommendationCampaign!
@@ -2381,7 +2381,7 @@ type RecommendationCampaign {
2381
2381
  title: String
2382
2382
  type: String!
2383
2383
  }
2384
- `,qa=`"""
2384
+ `,no=`"""
2385
2385
  Information of a given review rating.
2386
2386
  """
2387
2387
  type StoreReviewRating {
@@ -2408,7 +2408,7 @@ type StoreReview {
2408
2408
  """
2409
2409
  author: StoreAuthor!
2410
2410
  }
2411
- `,xa=`"""
2411
+ `,to=`"""
2412
2412
  Whether a saved card is personally owned by the buyer or shared by their
2413
2413
  Organization/Contract. Resolved server-side by the Saved-cards service from
2414
2414
  the buyer's \`useAdHocCard\` role — never inferred client-side.
@@ -2472,7 +2472,7 @@ type SavedCardListResult {
2472
2472
  """
2473
2473
  list: [SavedCard!]
2474
2474
  }
2475
- `,ja=`"""
2475
+ `,ro=`"""
2476
2476
  Search Engine Optimization (SEO) tags data.
2477
2477
  """
2478
2478
  type StoreSeo {
@@ -2493,7 +2493,7 @@ type StoreSeo {
2493
2493
  """
2494
2494
  canonical: String!
2495
2495
  }
2496
- `,Wa=`"""
2496
+ `,io=`"""
2497
2497
  Currency information.
2498
2498
  """
2499
2499
  type StoreCurrency {
@@ -2768,7 +2768,7 @@ input IStoreSession {
2768
2768
  """
2769
2769
  refreshAfter: String
2770
2770
  }
2771
- `,Ga=`"""
2771
+ `,ao=`"""
2772
2772
  Shipping Simulation item input.
2773
2773
  """
2774
2774
  input IShippingItem {
@@ -3099,7 +3099,7 @@ type MessageFields {
3099
3099
  """
3100
3100
  skuName: String
3101
3101
  }
3102
- `,Ha=`type SkuVariants {
3102
+ `,oo=`type SkuVariants {
3103
3103
  """
3104
3104
  SKU property values for the current SKU.
3105
3105
  """
@@ -3194,7 +3194,7 @@ Example:
3194
3194
  \`\`\`
3195
3195
  """
3196
3196
  scalar FormattedVariants
3197
- `,Xa=`"""
3197
+ `,so=`"""
3198
3198
  Status used to indicate a message type. For instance, a shopping cart informative or error message.
3199
3199
  """
3200
3200
  enum StoreStatus {
@@ -3202,7 +3202,7 @@ enum StoreStatus {
3202
3202
  WARNING
3203
3203
  ERROR
3204
3204
  }
3205
- `,Ya=`scalar JSONObject
3205
+ `,co=`scalar JSONObject
3206
3206
 
3207
3207
  type UserOrder {
3208
3208
  orderId: String
@@ -4026,4 +4026,4 @@ type UserOrderBudgetAllocationLinkedEntity {
4026
4026
  type: String
4027
4027
  id: String
4028
4028
  }
4029
- `,Ja=Object.assign({"./address.graphql":ua,"./advertisement.graphql":pa,"./aggregateOffer.graphql":ga,"./aggregateRating.graphql":ma,"./author.graphql":ha,"./brand.graphql":fa,"./breadcrumb.graphql":Sa,"./cart.graphql":ya,"./collection.graphql":Ia,"./deliveryPromisesBadge.graphql":va,"./facet.graphql":Oa,"./image.graphql":ba,"./mutation.graphql":Ca,"./newsletter.graphql":wa,"./objectOrString.graphql":Aa,"./offer.graphql":Da,"./order.graphql":Pa,"./orderCommercialAuthorizaton.graphql":Ea,"./orderEntry.graphql":ka,"./organization.graphql":Ta,"./pageInfo.graphql":Ua,"./password.graphql":_a,"./person.graphql":Ra,"./pickupPoints.graphql":Fa,"./product.graphql":Na,"./productGroup.graphql":La,"./profile.graphql":Ba,"./propertyValue.graphql":$a,"./query.graphql":Ma,"./quote.graphql":za,"./recommendation.graphql":Va,"./review.graphql":qa,"./savedCard.graphql":xa,"./seo.graphql":ja,"./session.graphql":Wa,"./shipping.graphql":Ga,"./skuVariants.graphql":Ha,"./status.graphql":Xa,"./userOrder.graphql":Ya}),Ka=ce.print(Object.values(Ja).map(e=>ce.parse(e)).reduce((e,n)=>ln.mergeTypeDefs([e,n],{sort:!0}))),Kn=Ka,Qa=async e=>n=>(n.storage={channel:re.parse(e.channel),flags:e.flags??{},locale:e.locale,customSortMap:e.customSortMap??{},cookies:new Map},n.account=e.account,n.OTEL_ENABLED=e.OTEL_ENABLED,n.discoveryConfig=e.discoveryConfig,n.clients=er(e,n),n.loaders=dr(e,n),n);function Za(){const e=da(),n={};for(const[t,r]of Object.entries(e))n[t]=Object.fromEntries(Object.entries(r).map(([i,a])=>typeof a!="function"?[i,a]:[i,dt(a,`${t}(${i})`)]));return n}function eo(e){const t=On([vn,In])(Za(),Kn);return e&&ce.isSchema(e)?dn.mergeSchemas({schemas:[t,e]}):t}exports.AuthDirective=In;exports.BadRequestError=E;exports.CacheControlDirective=vn;exports.CardOrigin=un;exports.CommercialAuthorizationStatus=pn;exports.FastStoreError=Y;exports.ForbiddenError=H;exports.GraphqlVtexContextFactory=Qa;exports.GraphqlVtexSchema=eo;exports.NotFoundError=L;exports.StoreCollectionType=gn;exports.StoreFacetType=mn;exports.StoreSort=hn;exports.StoreStatus=fn;exports.UnauthorizedError=ee;exports.UserOrderInvoiceType=Sn;exports.getAuthCookie=N;exports.isBadRequestError=pt;exports.isFastStoreError=ut;exports.isForbiddenError=wn;exports.isNotFoundError=W;exports.isUnauthorizedError=gt;exports.stringifyCacheControl=st;exports.typeDefs=Kn;exports.validateUserAuthentication=yn;exports.withDirectives=On;
4029
+ `,lo=Object.assign({"./address.graphql":wa,"./advertisement.graphql":Aa,"./aggregateOffer.graphql":Da,"./aggregateRating.graphql":Pa,"./author.graphql":Ea,"./brand.graphql":ka,"./breadcrumb.graphql":Ta,"./cart.graphql":Ua,"./collection.graphql":_a,"./deliveryPromisesBadge.graphql":Ra,"./facet.graphql":Fa,"./image.graphql":Na,"./mutation.graphql":La,"./newsletter.graphql":Ba,"./objectOrString.graphql":$a,"./offer.graphql":Ma,"./order.graphql":za,"./orderCommercialAuthorizaton.graphql":Va,"./orderEntry.graphql":qa,"./organization.graphql":xa,"./pageInfo.graphql":ja,"./password.graphql":Wa,"./person.graphql":Ga,"./pickupPoints.graphql":Ha,"./product.graphql":Xa,"./productGroup.graphql":Ya,"./profile.graphql":Ja,"./propertyValue.graphql":Ka,"./query.graphql":Qa,"./quote.graphql":Za,"./recommendation.graphql":eo,"./review.graphql":no,"./savedCard.graphql":to,"./seo.graphql":ro,"./session.graphql":io,"./shipping.graphql":ao,"./skuVariants.graphql":oo,"./status.graphql":so,"./userOrder.graphql":co}),uo=pe.print(Object.values(lo).map(e=>pe.parse(e)).reduce((e,n)=>pn.mergeTypeDefs([e,n],{sort:!0}))),at=uo,po=async e=>n=>(n.storage={channel:oe.parse(e.channel),flags:e.flags??{},locale:e.locale,customSortMap:e.customSortMap??{},cookies:new Map},n.account=e.account,n.OTEL_ENABLED=e.OTEL_ENABLED,n.discoveryConfig=e.discoveryConfig,n.clients=or(e,n),n.loaders=fr(e,n),n);function go(){const e=ba(),n={};for(const[t,r]of Object.entries(e))n[t]=Object.fromEntries(Object.entries(r).map(([i,a])=>typeof a!="function"?[i,a]:[i,ft(a,`${t}(${i})`)]));return n}function mo(e){const t=wn([bn,Cn])(go(),at);return e&&pe.isSchema(e)?gn.mergeSchemas({schemas:[t,e]}):t}exports.AuthDirective=Cn;exports.BadRequestError=E;exports.CacheControlDirective=bn;exports.CardOrigin=mn;exports.CommercialAuthorizationStatus=hn;exports.FastStoreError=q;exports.ForbiddenError=J;exports.GraphqlVtexContextFactory=po;exports.GraphqlVtexSchema=mo;exports.NotFoundError=$;exports.StoreCollectionType=fn;exports.StoreFacetType=Sn;exports.StoreSort=yn;exports.StoreStatus=In;exports.UnauthorizedError=re;exports.UserOrderInvoiceType=vn;exports.getAuthCookie=B;exports.isBadRequestError=yt;exports.isFastStoreError=St;exports.isForbiddenError=En;exports.isNotFoundError=X;exports.isUnauthorizedError=It;exports.stringifyCacheControl=mt;exports.typeDefs=at;exports.validateUserAuthentication=On;exports.withDirectives=wn;