@faststore/api 4.4.1-dev.0 → 4.5.0-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 +207 -41
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.mjs +1545 -1138
- package/dist/es/index.mjs.map +1 -1
- package/dist/src/__generated__/schema.d.ts +90 -0
- package/dist/src/__generated__/schema.d.ts.map +1 -1
- package/dist/src/platforms/vtex/clients/commerce/Contract.d.ts +1 -0
- package/dist/src/platforms/vtex/clients/commerce/Contract.d.ts.map +1 -1
- package/dist/src/platforms/vtex/clients/commerce/index.d.ts +16 -0
- package/dist/src/platforms/vtex/clients/commerce/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/clients/commerce/types/Quote.d.ts +26 -0
- package/dist/src/platforms/vtex/clients/commerce/types/Quote.d.ts.map +1 -0
- package/dist/src/platforms/vtex/clients/commerce/types/RecommendationResult.d.ts +25 -0
- package/dist/src/platforms/vtex/clients/commerce/types/RecommendationResult.d.ts.map +1 -0
- package/dist/src/platforms/vtex/clients/commerce/types/Session.d.ts +10 -0
- package/dist/src/platforms/vtex/clients/commerce/types/Session.d.ts.map +1 -1
- package/dist/src/platforms/vtex/clients/index.d.ts +7 -0
- package/dist/src/platforms/vtex/clients/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/index.d.ts +33 -0
- package/dist/src/platforms/vtex/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/getOrderEntryOperation.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/index.d.ts +33 -0
- package/dist/src/platforms/vtex/resolvers/index.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/mutation.d.ts +1 -0
- package/dist/src/platforms/vtex/resolvers/mutation.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/query.d.ts +33 -1
- package/dist/src/platforms/vtex/resolvers/query.d.ts.map +1 -1
- package/dist/src/platforms/vtex/resolvers/recommendations.d.ts +18 -0
- package/dist/src/platforms/vtex/resolvers/recommendations.d.ts.map +1 -0
- package/dist/src/platforms/vtex/resolvers/startRecommendationSession.d.ts +11 -0
- package/dist/src/platforms/vtex/resolvers/startRecommendationSession.d.ts.map +1 -0
- package/dist/src/platforms/vtex/resolvers/validateSession.d.ts.map +1 -1
- package/dist/src/platforms/vtex/utils/contract.d.ts +59 -0
- package/dist/src/platforms/vtex/utils/contract.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/__generated__/schema.ts +102 -0
- package/src/platforms/vtex/clients/commerce/Contract.ts +1 -0
- package/src/platforms/vtex/clients/commerce/index.ts +188 -3
- package/src/platforms/vtex/clients/commerce/types/Quote.ts +27 -0
- package/src/platforms/vtex/clients/commerce/types/RecommendationResult.ts +27 -0
- package/src/platforms/vtex/clients/commerce/types/Session.ts +9 -0
- package/src/platforms/vtex/resolvers/mutation.ts +2 -0
- package/src/platforms/vtex/resolvers/query.ts +137 -3
- package/src/platforms/vtex/resolvers/recommendations.ts +80 -0
- package/src/platforms/vtex/resolvers/startRecommendationSession.ts +30 -0
- package/src/platforms/vtex/resolvers/validateSession.ts +2 -1
- package/src/platforms/vtex/typeDefs/mutation.graphql +4 -0
- package/src/platforms/vtex/typeDefs/organization.graphql +18 -0
- package/src/platforms/vtex/typeDefs/query.graphql +68 -0
- package/src/platforms/vtex/typeDefs/quote.graphql +65 -0
- package/src/platforms/vtex/typeDefs/recommendation.graphql +11 -0
- package/src/platforms/vtex/utils/contract.ts +144 -0
package/dist/cjs/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ge=require("@graphql-tools/merge"),He=require("@graphql-tools/schema"),z=require("@graphql-tools/utils"),N=require("@faststore/diagnostics"),ee=require("graphql"),J=require("cookie"),kn=require("isomorphic-unfetch"),ve=require("p-limit"),ae=require("dataloader"),_n=require("sanitize-html"),Oe=require("fast-deep-equal"),Fn=require("node:crypto");var Xe=(e=>(e.Accepted="accepted",e.Denied="denied",e.Pending="pending",e))(Xe||{}),Ye=(e=>(e.Brand="Brand",e.Category="Category",e.Cluster="Cluster",e.Collection="Collection",e.Department="Department",e.SubCategory="SubCategory",e))(Ye||{}),Je=(e=>(e.Boolean="BOOLEAN",e.Range="RANGE",e))(Je||{}),Ke=(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))(Ke||{}),Qe=(e=>(e.Error="ERROR",e.Info="INFO",e.Warning="WARNING",e))(Qe||{}),Ze=(e=>(e.Input="Input",e.Output="Output",e))(Ze||{});const Rn=()=>function(n={}){const t=process.env.FS_DISCOVERY_APP_KEY??"",r=process.env.FS_DISCOVERY_APP_TOKEN??"";if(!t||!r)throw new K("No authentication AppKey and AppToken passed.");return{...n,"X-VTEX-API-AppKey":t,"X-VTEX-API-AppToken":r}},Nn=async e=>{const{clients:{commerce:n}}=e;try{if((await n.vtexid.validate())?.authStatus?.toLowerCase()!=="success")throw new Y("Authentication required")}catch(t){const r=t.extensions?.status??t.status;throw r===401?new Y("Authentication required"):r===403?new K("You are not allowed to access this resource"):new Y("Authentication required")}},Ln="auth",en={typeDefs:"directive @auth on FIELD_DEFINITION",transformer:e=>z.mapSchema(e,{[z.MapperKind.OBJECT_FIELD]:n=>{if(z.getDirective(e,n,Ln)?.[0]){const r=n.resolve;n.resolve=async(i,a,o,s)=>(await Nn(o),r?.(i,a,o,s))}return n}})},Bn="cacheControl",Mn=(e,n)=>{const{scope:t="private",sMaxAge:r=0,staleWhileRevalidate:i=0}=e;return`${n?"private":t}, s-maxage=${r}, stale-while-revalidate=${i}`},De=(e,n)=>typeof e=="number"&&typeof n=="number"?e>n?n:e:typeof e=="number"?e:n,$n=(e,n)=>typeof e=="string"&&typeof n=="string"?e==="public"&&n==="public"?"public":"private":e||n,nn={typeDefs:"directive @cacheControl(sMaxAge: Int, staleWhileRevalidate: Int, scope: String) on FIELD_DEFINITION",transformer:e=>z.mapSchema(e,{[z.MapperKind.OBJECT_FIELD]:n=>{const t=z.getDirective(e,n,Bn)?.[0];if(t){const{sMaxAge:r,staleWhileRevalidate:i,scope:a}=t,o=n.resolve;n.resolve=(s,l,d,g)=>(d.cacheControl={sMaxAge:De(d.cacheControl?.sMaxAge,r),staleWhileRevalidate:De(d.cacheControl?.staleWhileRevalidate,i),scope:$n(d.cacheControl?.scope,a)},o?.(s,l,d,g))}return n}})},tn=e=>(n,t)=>{const r=Ge.mergeTypeDefs([...(e??[]).map(({typeDefs:i})=>i),t]);return(e??[]).reduce((i,{transformer:a})=>a?.(i)??i,He.makeExecutableSchema({typeDefs:r,resolvers:n}))},ce="@faststore/api",le="4.4.0",Pe={name:ce,version:le},zn=(e,n)=>(t,r,i,a)=>{if((i?.OTEL?.enabled??!1)===!1)return e(t,r,i,a);const o=N.OTELAPI.trace.getTracer(ce,le),s=N.OTELAPI.propagation.extract(N.OTELAPI.context.active(),i.OTEL);return N.OTELAPI.context.with(s,()=>{const l=o.startSpan(n??"Unknown Graphql Resolver",{startTime:Date.now(),kind:N.OTELAPI.SpanKind.INTERNAL,attributes:{timestamp:Date.now(),"@faststore_version":le,"@faststore_package_name":ce,"@faststore_account_name":i.account,"@faststore_environment":process.env.NODE_ENV}});if(!l)return e(t,r,i,a);try{const d=e(t,r,i,a);return d instanceof Promise?d.then(g=>(l.end(),g)):(l.end(),d)}catch(d){throw l.end(),console.error(`Error when executing resolver: ${n}`,d),d}})};class q extends Error{constructor(n,t){super(t),this.extensions=n,this.name="FastStoreError"}}class T extends q{constructor(n){super({status:400,type:"BadRequestError"},n)}}class Y extends q{constructor(n){super({status:401,type:"UnauthorizedError"},n)}}class K extends q{constructor(n){super({status:403,type:"ForbiddenError"},n)}}class L extends q{constructor(n){super({status:404,type:"NotFoundError"},n)}}const Vn=e=>e?.name==="FastStoreError",xn=e=>e?.extensions?.type==="BadRequestError",qn=e=>e?.extensions?.type==="UnauthorizedError",rn=e=>e?.extensions?.type==="ForbiddenError",Ce=e=>e?.extensions?.type==="NotFoundError",jn=`${Pe.name}@${Pe.version}`,y=async(e,n,t)=>{const r=await kn(e,{...n,headers:{...n?.headers??{},"User-Agent":jn}});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 T(i);case 401:throw new Y(i);case 403:throw new K(i);case 404:throw new L(i);default:throw new q({status:r.status,type:"UnknownError"},i)}throw new Error(i)},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),l=a.substring(o+1);n.has(s)||r.push(s),n.set(s,l)}}}),r.map(i=>`${i}=${n.get(i)}`).join("; ")},Wn=/^([^=]+)=([^;]*)/,Gn=(e,n)=>{const t=n.match(Wn);if(t){const r=t[1],i=t[2];e.storage.cookies.set(r,{value:i,setCookie:n})}},Hn=(e,n)=>{n.getSetCookie().forEach(t=>Gn(e,t))},Xn=e=>n=>Hn(e,n),on=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}])=>Yn(r,i,a),n)},sn=e=>function(t){const r=on(e);return r?{...t,cookie:r}:t},ne=(e,n)=>{const t=an(e);return J.parse(t)[`VtexIdclientAutCookie_${n}`]||""},Yn=(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 te(e){return e?JSON.parse(Buffer.from(e.split(".")[1],"base64").toString()):null}const G={method:"POST",headers:{"content-type":"application/json"}},Jn=({account:e,environment:n,incrementAddress:t,subDomainPrefix:r},i)=>{const a=`https://${e}.${n}.com.br`,o=Xn(i),s=sn(i),l=Rn(),d=new Headers(i.headers).get("x-forwarded-host")??i.headers?.host??"",g=r&&r.map(c=>c+".").find(c=>d.includes(c))||"",p=d.replace(g,"");return{catalog:{salesChannel:c=>y(`${a}/api/catalog_system/pub/saleschannel/${c}`,void 0,{storeCookies:o}),brand:{list:()=>y(`${a}/api/catalog_system/pub/brand/list`,void 0,{storeCookies:o})},category:{tree:(c=3)=>y(`${a}/api/catalog_system/pub/category/tree/${c}`,void 0,{storeCookies:o})},portal:{pagetype:c=>y(`${a}/api/catalog_system/pub/portal/pagetype/${c}`,void 0,{storeCookies:o})},products:{crossselling:({type:c,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/${c}/${u}?${S}`,void 0,{storeCookies:o})}}},checkout:{simulation:(c,{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()}`,{...G,headers:S,body:JSON.stringify(c)},{storeCookies:o})},shippingData:({id:c,index:u,deliveryMode:m,selectedAddresses:S},f)=>{const I=f?{startDateUtc:m?.deliveryWindow?.startDate,endDateUtc:m?.deliveryWindow?.endDate}:null,D={logisticsInfo:Array.from({length:u},(P,O)=>({itemIndex:O,selectedDeliveryChannel:m?.deliveryChannel||null,selectedSla:m?.deliveryMethod||null,deliveryWindow:I})),selectedAddresses:S,clearAddressIfPostalCodeNotFound:t},E=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForm/${c}/attachments/shippingData`,{...G,headers:E,body:JSON.stringify(D)},{storeCookies:o})},marketingData:({id:c,marketingData:u})=>{const m=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForm/${c}/attachments/marketingData`,{headers:m,body:JSON.stringify(u),method:"POST"},{storeCookies:o})},clientPreferencesData:({id:c,clientPreferencesData:u})=>{const m=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForm/${c}/attachments/clientPreferencesData`,{headers:m,body:JSON.stringify(u),method:"POST"},{storeCookies:o})},orderForm:({id:c,refreshOutdatedData:u=!0,channel:m=i.storage.channel})=>{const{salesChannel:S}=m,f=s({"content-type":"application/json","X-FORWARDED-HOST":p}),I=new URLSearchParams({sc:S});c&&I.set("refreshOutdatedData",u.toString());const D=`${a}/api/checkout/pub/orderForm${c?`/${c}`:""}?${I.toString()}`;return y(D,{...G,headers:f,...c?{}:{body:"{}"}},{storeCookies:o})},clearOrderFormMessages:({id:c})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForm/${c}/messages/clear`,{...G,headers:u,body:"{}"})},updateOrderFormItems:({id:c,orderItems:u,allowOutdatedData:m="paymentData",salesChannel:S=i.storage.channel.salesChannel,shouldSplitItem:f=!0})=>{const I=new URLSearchParams({allowOutdatedData:m,sc:S}),D=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForm/${c}/items?${I}`,{headers:D,body:JSON.stringify({orderItems:u,noSplitItem:!f}),method:"PATCH"},{storeCookies:o})},setCustomData:({id:c,appId:u,key:m,value:S})=>{const f=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForm/${c}/customData/${u}/${m}`,{headers:f,body:JSON.stringify({value:S}),method:"PUT"})},region:async({postalCode:c,geoCoordinates:u,country:m,salesChannel:S})=>{const f=new URLSearchParams({country:m,sc:S??""});c?f.append("postalCode",c):f.append("geoCoordinates",`${u?.longitude};${u?.latitude}`);const I=`${a}/api/checkout/pub/regions/?${f.toString()}`,D=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(I,{headers:D},{storeCookies:o})},address:async({postalCode:c,country:u})=>{const m=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/postal-code/${u}/${c}`,{headers:m},{storeCookies:o})},cancelOrder:({orderId:c,customerEmail:u,reason:m})=>{const S=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orders/${c}/user-cancel-request`,{method:"POST",headers:S,body:JSON.stringify({customerEmail:u,reason:m})},{})},pickupPoints:({geoCoordinates:c})=>{if(!c)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:c})},{storeCookies:o})}},session:c=>{const u=new URLSearchParams(c);u.set("items","profile.id,profile.email,profile.firstName,profile.lastName,profile.phone,shopper.firstName,shopper.lastName,shopper.organizationManager,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=J.parse(i?.headers?.cookie??"")?.vtex_session;return y(`${a}/api/sessions?${u.toString()}`,{method:S?"PATCH":"POST",headers:m,body:"{}"},{storeCookies:o})},subscribeToNewsletter:c=>y(`${a}/api/dataentities/NL/documents/`,{...G,body:JSON.stringify({...c,isNewsletterOptIn:!0}),method:"PATCH"},{storeCookies:o}),profile:{addresses:async c=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/profile-system/pvt/profiles/${c}/addresses`,{headers:u},{storeCookies:o})}},oms:{userOrder:({orderId:c})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/oms/user/orders/${c}`,{method:"GET",headers:u},{storeCookies:o})},listUserOrders:({page:c,status:u,dateInitial:m,dateFinal:S,text:f,clientEmail:I,perPage:D,pendingMyApproval:E})=>{const P=new URLSearchParams;if(m){const w=new Date(m).setHours(0,0,0,0);m=new Date(w).toISOString()}if(S){const w=new Date(S).setHours(23,59,59,999);S=new Date(w).toISOString()}f&&P.append("text",f),u&&u.length>0&&P.append("status",u.filter(Boolean).join(",")),m&&S?P.append("creation_date",`creationDate:[${m} TO ${S}]`):m?P.append("creation_date",`creationDate:[${m} TO *]`):S&&P.append("creation_date",`creationDate:[* TO ${S}]`),I&&P.append("clientEmail",I),c&&P.append("page",c.toString()),D&&P.append("per_page",D.toString()),E&&P.append("my_pending_approvals",String(!0));const O=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/oms/user/orders?${P.toString()}`,{method:"GET",headers:O},{storeCookies:o})},getCommercialAuthorizationsByOrderId:({orderId:c})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/${e}/commercial-authorizations/order/${c}`,{method:"GET",headers:u},{storeCookies:o})},processOrderAuthorization:async({orderAuthorizationId:c,dimensionId:u,ruleId:m,approved:S})=>{const f=s({"content-type":"application/json","X-FORWARDED-HOST":p}),E={params:{ruleId:m,dimensionId:u,score:S?100:0}};return y(`${a}/${e}/commercial-authorizations/${c}/callback`,{method:"POST",headers:f,body:JSON.stringify(E)},{storeCookies:o})}},units:{getUnitByUserId:({userId:c})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/units/v1/${c}/unit`,{method:"GET",headers:u},{})},getOrgUnitById:({orgUnitId:c})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/units/v1/${c}`,{method:"GET",headers:u},{})},getScopesByOrgUnit:({orgUnitId:c})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/units/v1/${c}/scopes`,{method:"GET",headers:u},{})}},licenseManager:{getUserById:({userId:c})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/license-manager/users/${c}`,{method:"GET",headers:u},{})},getUserByEmail:({email:c})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/license-manager/pvt/users/${c}`,{method:"GET",headers:u},{})},getUserRoles:({userId:c})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/license-manager/storefront/users/${c}/roles`,{method:"GET",headers:u},{})}},masterData:{getContractById:({contractId:c})=>{if(!c)throw new T("Missing contractId to fetch CL fields.");const u=l({Accept:"application/json","content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/dataentities/CL/documents/${c}?_fields=_all`,{method:"GET",headers:u},{})},getShopperById:({userId:c})=>{if(!c)throw new T("Missing userId to fetch shopper name.");const u=l({Accept:"application/json","content-type":"application/json","X-FORWARDED-HOST":p}),m=c.replace(/-/g,"");return y(`${a}/api/dataentities/shopper/search?_where=(userId=${m} OR userId=${c})&_fields=_all&_schema=v1`,{method:"GET",headers:u},{})}},vtexid:{validate:()=>{const c=s({"content-type":"application/json","X-FORWARDED-HOST":p}),u=ne(on(i)??"",e);return y(`${a}/api/vtexid/credential/validate`,{headers:c,body:JSON.stringify({token:u}),method:"POST"},{storeCookies:o})}},orderEntry:{uploadFile:({fileBuffer:c,fileName:u,mimeType:m})=>{const S=s({"content-type":"application/json","X-FORWARDED-HOST":p}),f=`----FastStoreUploadBoundary${Date.now()}`,I=`\r
|
|
2
|
-
`,E=/^[a-zA-Z0-9][a-zA-Z0-9!#$&\-.^_]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&\-.^_+]*$/.test(m)?m:"application/octet-stream",P=u.replaceAll(/[\r\n"]/g,"_"),O=[`--${f}`,`Content-Disposition: form-data; name="file"; filename="${P}"`,`Content-Type: ${E}`,"",""].join(I),w=`${I}--${f}--${I}`,h=Buffer.from(O),b=Buffer.from(w),C=new Uint8Array(h.byteLength+c.byteLength+b.byteLength);let A=0;return C.set(h,A),A+=h.byteLength,C.set(c,A),A+=c.byteLength,C.set(b,A),y(`${a}/api/order-entry/upload?an=${e}`,{method:"POST",headers:{...S,"content-type":`multipart/form-data; boundary=${f}`},body:C.buffer},{})},startOperation:({objectKey:c,orderFormId:u,sessionToken:m})=>{const S=s({"content-type":"application/json","X-FORWARDED-HOST":p}),f=JSON.stringify({objectKey:c,orderFormId:u,operation:"CreateCart",...m?{sessionToken:m}:{}});return y(`${a}/api/order-entry/operation?an=${e}`,{method:"POST",headers:S,body:f},{})},getOperation:({operationId:c})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/order-entry/operation/${c}?an=${e}`,{method:"GET",headers:u},{})},createOrderForm:()=>{const c=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForm?sc=${i.storage.channel.salesChannel}`,{method:"POST",headers:c,body:"{}"},{})},getOrderFormItems:({orderFormId:c})=>{const u=s({"content-type":"application/json","X-FORWARDED-HOST":p});return y(`${a}/api/checkout/pub/orderForm/${c}`,{method:"GET",headers:u},{})}}}},de="fuzzy",ue="operator",pe="pickupPoint",we="shipping",Ae="delivery-options",Kn="in-stock",Qn="trade-policy",Zn="region-id",et=new Set([Qn,Zn,de,ue,pe]),nt=new Set(["zip-code","pickupPoint","country","coordinates","deliveryZonesHash","pickupPointsHash"]),tt=new Set(["productClusterIds"]),Ee=e=>encodeURI(decodeURI(e)),rt=e=>encodeURIComponent(decodeURIComponent(e).normalize("NFD").replaceAll(/[\u0300-\u036f]/g,"")),it=/^pickup-in-point-(.+)$/;function cn(e){if(!e)return{};try{const t=J.parse(e).vtex_segment;if(!t)return{};const r=Buffer.from(t,"base64").toString("utf-8");return JSON.parse(r)}catch{return{}}}function at(e){const n={},t={},r=[];for(const i of e.split(";")){const a=i.indexOf("=");if(a<0)continue;const o=i.slice(0,a),s=i.slice(a+1);!o||!s||(nt.has(o)?n[o]=s:tt.has(o)?t[o]=s:r.push({key:o,value:s}))}return{shipping:n,queryParams:t,extraFacets:r}}function ot(e){const n=typeof e.facets=="string"?e.facets:"",{shipping:t,queryParams:r,extraFacets:i}=at(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,productClusterIds:r.productClusterIds},extraFacets:i}}function ln(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],["productClusterId",n.productClusterIds]];for(const[r,i]of t)i!=null&&i!==""&&e.append(r,String(i))}function dn(e){return it.exec(e)?.[1]}function st(e){const n=e.find(r=>r.key==="shipping"),t=n?dn(n.value):void 0;if(t!==void 0)try{return decodeURIComponent(t)}catch{return t}}function ct(e,n){const t=st(n);return t===void 0?e:{...e,pickupPoint:t}}function lt(e){return e.map(n=>n.key!=="shipping"||dn(n.value)===void 0?n:{...n,value:"pickup-in-point"})}function dt(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")),lt(t)}function ut(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}${Ee(r)}/${rt(Ee(i)).replaceAll(/ |%20/g,"-")}/`},"")}const pt=e=>e.key==="fuzzy"&&(e.value==="0"||e.value==="1"||e.value==="auto"),gt=e=>e.key==="operator"&&(e.value==="and"||e.value==="or");function mt(e,n){const{segmentParams:t,extraFacets:r}=ot(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:l})=>!et.has(l)),r=e.find(({key:l,value:d})=>l===we&&d!=="all-delivery-methods")??null,i=e.find(({key:l,value:d})=>l===Ae&&d!=="all-delivery-options")??null,a=[...t],o=a.some(({key:l})=>l===we),s=a.some(({key:l})=>l===Ae);return r!==null&&!o&&a.push(r),i!==null&&!s&&a.push(i),dt(a,n)}function ft(e,n){const t=e.find(({key:a})=>a===de)??null,r=e.find(({key:a})=>a===ue)??null,i=e.find(({key:a})=>a===pe)??null;t&&pt(t)&&n.append(de,t.value),r&>(r)&&n.append(ue,r.value),i&&n.append(pe,i.value)}function Te(e,n,t,r){const{query:i="",page:a,count:o,sort:s,selectedFacets:l=[],showInvisibleItems:d,sponsoredCount:g,hideUnavailableItems:p,allowRedirect:c=!1}=e,u=new URLSearchParams;if(r.includePagination&&a!==void 0&&o!==void 0){const f=a*o,I=o===0?f:f+o-1;u.append("from",f.toString()),u.append("to",I.toString())}i&&u.append("query",i),r.includeSort&&s&&u.append("sort",s);const m=ct(t.segmentParams,l);if(ln(u,m??t.segmentParams),ft(l,u),d&&u.append("show-invisible-items","true"),n?.hideUnavailableItems!==void 0){const f=l.find(({key:D})=>D===Kn),I=f?f.value:p?.toString()??n.hideUnavailableItems.toString();u.append("hideUnavailableItems",I)}n?.simulationBehavior!==void 0&&u.append("simulationBehavior",n.simulationBehavior.toString()),n?.showSponsored!==void 0&&u.append("showSponsored",n.showSponsored.toString()),g!==void 0&&u.append("sponsoredCount",g.toString()),c!==void 0&&u.append("allowRedirect",c.toString());const S=ut(ht(l,t.extraFacets));return{params:u,path:S}}function St(e,n){const{field:t,value:r,hideUnavailableItems:i,showInvisibleItems:a}=e,o=new URLSearchParams({field:t??"",value:r??""});return ln(o,n),i&&o.append("hideUnavailableItems","true"),a&&o.append("show-invisible-items","true"),o}function H(e,n){return{path:e,params:n,toString(){const t=n.toString();return e?t?`${e}?${t}`:e:t?`?${t}`:""}}}function X(e){const{endpoint:n,segment:t,defaults:r,args:i={}}=e,a=mt(t,r);switch(n){case"product-search":case"facets":{const{params:o,path:s}=Te(i,r,a,{includePagination:!0,includeSort:!0});return H(s,o)}case"catalog-count":{const{params:o,path:s}=Te(i,r,a,{includePagination:!1,includeSort:!1});return H(s,o)}case"products":{const o=St(i,a.segmentParams);return H("",o)}case"search-suggestions":{const o=new URLSearchParams({query:i.query?.toString()??"",locale:r?.locale??a.segmentParams.locale??""});return H("",o)}case"top-searches":{const o=new URLSearchParams({locale:r?.locale??a.segmentParams.locale??""});return H("",o)}default:{const o=n;throw new Error(`Unknown intelligent-search endpoint: ${o}`)}}}const yt=10;function It(e){const{regionId:n,seller:t}=e.storage.channel;return(t?Buffer.from(`SW#${t}`).toString("base64"):void 0)??(n||void 0)}function vt(e){const n=cn(e.headers?.cookie);return e.storage.locale||n.cultureInfo||""}const Ot=({account:e,environment:n,hideUnavailableItems:t,simulationBehavior:r,showSponsored:i,subDomainPrefix:a},o)=>{const s=`https://${e}.${n}.com.br`,l=sn(o),d=cn(o.headers?.cookie),g=()=>({salesChannel:o.storage.channel.salesChannel,regionId:It(o),locale:vt(o),hideUnavailableItems:t,simulationBehavior:r,showSponsored:i}),p=new Headers(o.headers).get("x-forwarded-host")??o.headers?.host??"",c=a&&a.map(h=>h+".").find(h=>p.includes(h))||"",u=p.replace(c,""),m=l({"content-type":"application/json","X-FORWARDED-HOST":u}),S=({type:h,...b})=>{const C=h==="facets"?"facets":"product-search",A=X({endpoint:C,segment:d,defaults:g(),args:b});return y(`${s}/api/intelligent-search/v1/${C}/${A.path}?${A.params.toString()}`,{headers:m})},f=h=>S({...h,type:"product_search"}),I=({field:h,value:b,hideUnavailableItems:C,showInvisibleItems:A})=>{const v=X({endpoint:"products",segment:d,defaults:g(),args:{field:h,value:b,hideUnavailableItems:C,showInvisibleItems:A}});return y(`${s}/api/intelligent-search/v1/products?${v.params.toString()}`,{headers:m})};return{facets:h=>S({...h,type:"facets"}),products:f,fetchProduct:I,productsByIdentifier:async({field:h,values:b,showInvisibleItems:C,hideUnavailableItems:A})=>{const v=ve(yt);return(await Promise.all(b.map(_=>v(async()=>{try{return await I({field:h,value:_,hideUnavailableItems:A,showInvisibleItems:C})}catch{return null}})))).filter(_=>_!==null)},suggestedTerms:h=>{const b=X({endpoint:"search-suggestions",segment:d,defaults:g(),args:{query:h.query}});return y(`${s}/api/intelligent-search/v1/search-suggestions?${b.params.toString()}`,{headers:m})},topSearches:()=>{const h=X({endpoint:"top-searches",segment:d,defaults:g()});return y(`${s}/api/intelligent-search/v1/top-searches?${h.params.toString()}`,{headers:m})},productCount:h=>{const b=X({endpoint:"catalog-count",segment:d,defaults:g(),args:h});return y(`${s}/api/intelligent-search/v1/catalog-count/${b.path}?${b.params.toString()}`,{headers:m})}}},Ct=(e,n)=>{const t=Ot(e,n),r=Jn(e,n);return{search:t,commerce:r}},bt=20,Dt=new Set(["brand","category","department","subcategory","collection","cluster"]),V=e=>typeof e.pageType=="string"&&Dt.has(e.pageType.toLowerCase()),Pt=(e,n)=>{const t=ve(bt),r=async i=>Promise.all(i.map(a=>t(async()=>{const o=await n.commerce.catalog.portal.pagetype(a);if(V(o))return o;throw new L(`Catalog returned ${o.pageType} for slug: ${a}. This usually happens when there is more than one category with the same name in the same category tree level.`)})));return new ae(r,{batch:!1})},wt=(e,n)=>{const t=async r=>Promise.all(r.map(i=>n.commerce.catalog.salesChannel(i)));return new ae(t)},At=1,Et=(e,n)=>{const t=ve(At),r=async a=>{const o=a.reduce((p,{items:c})=>[...p,c],[]),s=[...o.flat()],l=await n.commerce.checkout.simulation({country:a[0].country,postalCode:a[0].postalCode,items:s}),d=l.items.reduce((p,c)=>{const u=c.requestIndex;return typeof u=="number"&&u<p.length&&(p[u]=c),p},Array(s.length).fill(null)),g=o.reduce((p,c)=>[...p,c.length+p[p.length-1]],[0]);return o.map((p,c)=>({...l,items:d.slice(g[c],g[c+1]).filter(u=>!!u)}))},i=async a=>t(r,a);return new ae(i,{maxBatchSize:50})},Tt=(e,n)=>_n(e,n);function Ut(e){return{...e,description:e.description?Tt(e.description):e.description}}const B=(e,n)=>({...e,isVariantOf:Ut(n)}),kt=({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 c of p.items)g[c.itemId]=B(c,p);return g},{}),l=i.map(g=>s[g]),d=i.filter(g=>!s[g]);if(d.length>0)throw new L(`Search API did not found the following skus: ${d.join(",")}`);return l};return new ae(t,{maxBatchSize:99})},_t=(e,{clients:n})=>{const t=kt(e,n),r=Et(e,n),i=Pt(e,n),a=wt(e,n);return{skuLoader:t,simulationLoader:r,collectionLoader:i,salesChannelLoader:a}},M=e=>e.AvailableQuantity>0,x=e=>e.spotPrice??0,Ft=e=>e.Price??0,Ue=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),Rt=e=>e==="available",$=(e,n=0,t=1)=>{const r=n/t;return Math.round((e+r)*100)/100},Nt=(e,n={includeTaxes:!1})=>{const t=e.filter(M),r=t[t.length-1],i=r?x(r):0;return n.includeTaxes?$(i,r?.Tax,r?.product?.unitMultiplier):i},ke=(e,n={includeTaxes:!1})=>{const[t]=e.filter(M),r=t?x(t):0;return n.includeTaxes?$(r,t?.Tax,t?.product?.unitMultiplier):r},Lt={highPrice:e=>Nt(e),lowPrice:e=>ke(e),lowPriceWithTaxes:e=>ke(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},Bt={ratingValue:()=>5,reviewCount:()=>0},_e="ÁÄÂÀÃÅČÇĆĎÉĚËÈÊẼĔȆÍÌÎÏŇÑÓÖÒÔÕØŘŔŠŤÚŮÜÙÛÝŸŽáäâàãåčçćďéěëèêẽĕȇíìîïňñóöòôõøðřŕšťúůüùûýÿžþÞĐđ߯a",Mt="AAAAAACCCDEEEEEEEEIIIINNOOOOOORRSTUUUUUYYZaaaaaacccdeeeeeeeeiiiinnooooooorrstuuuuuyyzbBDdBAa",$t=e=>{let n=e.slice(0);for(let t=0;t<_e.length;t++)n=n.replace(new RegExp(_e.charAt(t),"g"),Mt.charAt(t));return n},zt=e=>e.replace(/[·/_,:]/,"-");function pn(e){const t=e.replace(/,/g,"").replace(/[*+~.()'"!:@&\[\]`/ %$#?{}><=_^]/g,"-");return zt($t(t)).toLowerCase()}const Z=e=>e.type==="brand"||V(e)&&e.pageType.toLowerCase()==="brand",ge=e=>V(e)&&e.pageType.toLowerCase()==="collection",se=e=>Z(e)||ge(e)?pn(e.name):V(e)?new URL(`https://${e.url}`).pathname.slice(1).toLowerCase():new URL(e.url).pathname.slice(1).toLowerCase(),gn={id:({id:e})=>e.toString(),slug:e=>se(e),seo:e=>Z(e)||V(e)?{title:e.title??e.name,description:e.metaTagDescription}:{title:e.Title,description:e.MetaTagDescription},type:e=>Z(e)?"Brand":V(e)?e.pageType:e.level===0?"Department":"Category",meta:e=>{const n=se(e);return Z(e)?{selectedFacets:[{key:"brand",value:n}]}:ge(e)?{selectedFacets:[{key:"productclusterids",value:e.id}]}:{selectedFacets:n.split("/").map((t,r)=>({key:`category-${r+1}`,value:t}))}},breadcrumbList:async(e,n,t)=>{const{loaders:{collectionLoader:r}}=t,a=se(e).split("/").filter(l=>!!l),o=a.map((l,d)=>a.slice(0,d+1).join("/")),s=await Promise.all(o.map(async l=>{const d=await r.load(l);return{slug:l,...d}}));return{itemListElement:s.map((l,d)=>({item:ge(l)?`/${l.slug}`:new URL(`https://${l.url}`).pathname.toLowerCase(),name:l.name,position:d+1})),numberOfItems:s.length}}},mn={buy:"whoboughtalsobought",view:"whosawalsosaw",similars:"similars",viewAndBought:"whosawalsobought",accessories:"accessories",suggestions:"suggestions"},Fe=({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}}},Re=e=>{const n=e.split(":").map(Number);return n.length!==2||Number.isNaN(n[0])||Number.isNaN(n[1])?null:n},Vt=e=>typeof mn[e]=="string",xt=e=>{const n=e?.filter(t=>Vt(t.key));if(Array.isArray(n)&&n.length>1)throw new T(`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},qt=e=>e?.find(n=>n.key==="slug")?.value??null,jt=e=>e?.find(n=>n.key==="id")?.value??null,Ne=e=>e?.find(n=>n.key==="locale")?.value??null,Le=e=>e?.find(n=>n.key==="channel")?.value??null,me=(e,n)=>{let t=0;for(let r=1;r<e.length;r++)n(e[t],e[r])>0&&(t=r);return e[t]},Wt={__resolveType:({type:e,values:n})=>e!=="TEXT"&&e!=="DELIVERY"?"StoreFacetRange":!n||n.length===0?"StoreFacetBoolean":n.every(t=>t.range)?"StoreFacetRange":"StoreFacetBoolean"},Gt={key:({key:e})=>e,label:({name:e})=>e,values:({values:e})=>e.sort((n,t)=>n.name.localeCompare(t.name))},Ht={key:({key:e})=>e,label:({name:e})=>e,min:({values:e,key:n},t,{storage:{searchArgs:r}})=>{const i=Re(r?.selectedFacets?.find(s=>s.key===n)?.value??""),o=me(e,(s,l)=>s.range.from-l.range.from)?.range?.from??0;return{selected:i?.[0]??o,absolute:o}},max:({values:e,key:n},t,{storage:{searchArgs:r}})=>{const i=Re(r?.selectedFacets?.find(s=>s.key===n)?.value??""),o=me(e,(s,l)=>l.range.to-s.range.to)?.range?.to??0;return{selected:i?.[1]??o,absolute:o}}},Xt={value:({value:e})=>e,label:({name:e})=>e||"unknown",selected:({selected:e})=>e,quantity:({quantity:e})=>e},Yt=async(e,{data:n},{clients:{commerce:t}})=>{if(!n?.orderId)throw new T("Missing orderId");return{data:(await t.checkout.cancelOrder(n))?.data}};function hn(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 Jt(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 Kt=async(e,{data:n},{clients:{commerce:t}})=>{const r=await t.oms.processOrderAuthorization(n),i=hn(r);return{isPendingForOtherAuthorizer:!i&&Jt(r),ruleForAuthorization:i}},Qt=async(e,{data:n},{clients:{commerce:t}})=>{if(!n?.objectKey)throw new T("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})},Zt=async(e,{data:n},{clients:{commerce:t}})=>({id:(await t.subscribeToNewsletter(n))?.Id}),er=async(e,{data:n},{clients:{commerce:t}})=>{const{fileContent:r,fileName:i,mimeType:a}=n;if(!r||!i||!a)throw new T("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 T("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 T("Invalid Base64 fileContent");const g=Buffer.from(o,"base64");return await t.orderEntry.uploadFile({fileBuffer:g,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)}}const he=(e,n)=>{e.storage.channel=re.parse(n)},fe=(e,n)=>{e.storage.locale=n},fn=e=>Fn.createHash("md5").update(e).digest("hex"),Q={attachment:"ATTACHMENT",specification:"SPECIFICATION",attribute:"ATTRIBUTE"};function Sn(e){return{name:e.name,value:e.content,valueReference:Q.attachment}}function nr(e){return{propertyID:e.id,name:e.name,value:e.value,valueReference:{valueReference:Q.attribute,visible:e.visible}}}function yn(e){return fn(`${e.name}:${JSON.stringify(e.value)}:${e.valueReference}`)}const tr=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]},rr=(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},In=(e,n)=>{if(!ir(n))return{updateShipping:!1,addressChanged:!1};if(!cr(e))return{updateShipping:!1,addressChanged:!1};const[t]=e?.shippingData?.selectedAddresses??[];if(ar(t,n.postalCode)||or(t,n.geoCoordinates)||sr(t,n.addressType))return{updateShipping:!0,addressChanged:!0};const{logisticsInfo:r}=e.shippingData;return lr(r,n)?{updateShipping:!0,addressChanged:!1}:{updateShipping:!1,addressChanged:!1}},ir=e=>!!e.postalCode||e.geoCoordinates?.latitude&&e.geoCoordinates?.longitude,ar=(e,n)=>typeof n=="string"&&e?.postalCode!==n,or=(e,n)=>typeof n?.latitude=="number"&&typeof n?.longitude=="number"&&(e?.geoCoordinates[0]!==n?.longitude||e?.geoCoordinates[1]!==n?.latitude),sr=(e,n)=>typeof n=="string"&&e?.addressType!==n,cr=e=>e.items.length!==0,lr=(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:l})=>{const d=t&&o!==t,g=r&&s!==r;return l?.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(c=>c?.startDateUtc===i&&c?.endDateUtc===a))})},vn=e=>e.valueReference===Q.attachment,Se=e=>[e.itemOffered.sku,e.seller.identifier,e.price<.01?"Gift":void 0,e.itemOffered.additionalProperty?.filter(vn).map(yn).join("-")].filter(Boolean).join("::"),ie=(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(Sn)},index:n}),dr=e=>({quantity:e.quantity,seller:e.seller.identifier,id:e.itemOffered.sku,index:e.index,attachments:(e.itemOffered.additionalProperty?.filter(vn)??[]).map(n=>({name:n.name,content:n.value}))}),Be=e=>e.reduce((n,t)=>{const r=Se(t);return n.has(r)||n.set(r,[]),n.get(r)?.push(t),n},new Map),ur=(e,n)=>{const t=(s,l)=>({...s,itemOffered:{sku:s.itemOffered.sku},index:l}),r=n.items.map(ie).map(t),i=e.acceptedOffer.map(t),a=e.orderNumber===n.orderFormId,o=Oe(r,i);return a&&o};function On(e,n){return e?.some(t=>t.parentItemIndex!==null&&t.parentItemIndex!==void 0&&e[t.parentItemIndex]?.id===n)}function Cn(e,n){return e?.some(t=>t.id===n&&t.parentItemIndex!==null)}const Me=e=>{const n=e.items.reduce((t,r,i)=>{const a=Cn(e.items,r.id)||On(e.items,r.id)?`${Se(ie(r))}::${i}`:Se(ie(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}})}},$e=async(e,n,t)=>({order:{orderNumber:e.orderFormId,acceptedOffer:e.items.map(async r=>({...r,product:await n.load(`${r.id}-invisibleItems`)})),shouldSplitItem:t},messages:e.messages.map(({text:r,status:i})=>({text:r,status:i.toUpperCase()}))}),bn=({items:e},n)=>{const t=e.map(r=>({id:r.id,quantity:r.quantity,seller:r.seller,attachments:r.attachments}));return fn(JSON.stringify({sessionId:n?.id??"",items:t}))},ze=async(e,n,t)=>{try{return await n.checkout.setCustomData({id:e.orderFormId,appId:"faststore",key:"cartEtag",value:bn(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 He=require("@graphql-tools/merge"),Xe=require("@graphql-tools/schema"),z=require("@graphql-tools/utils"),L=require("@faststore/diagnostics"),te=require("graphql"),Z=require("cookie"),Rn=require("isomorphic-unfetch"),Oe=require("p-limit"),oe=require("dataloader"),kn=require("sanitize-html"),Ce=require("fast-deep-equal"),Fn=require("node:crypto");var Ye=(e=>(e.Accepted="accepted",e.Denied="denied",e.Pending="pending",e))(Ye||{}),Je=(e=>(e.Brand="Brand",e.Category="Category",e.Cluster="Cluster",e.Collection="Collection",e.Department="Department",e.SubCategory="SubCategory",e))(Je||{}),Ke=(e=>(e.Boolean="BOOLEAN",e.Range="RANGE",e))(Ke||{}),Qe=(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))(Qe||{}),Ze=(e=>(e.Error="ERROR",e.Info="INFO",e.Warning="WARNING",e))(Ze||{}),en=(e=>(e.Input="Input",e.Output="Output",e))(en||{});const Nn=()=>function(n={}){const t=process.env.FS_DISCOVERY_APP_KEY??"",r=process.env.FS_DISCOVERY_APP_TOKEN??"";if(!t||!r)throw new q("No authentication AppKey and AppToken passed.");return{...n,"X-VTEX-API-AppKey":t,"X-VTEX-API-AppToken":r}},Ln=async e=>{const{clients:{commerce:n}}=e;try{if((await n.vtexid.validate())?.authStatus?.toLowerCase()!=="success")throw new K("Authentication required")}catch(t){const r=t.extensions?.status??t.status;throw r===401?new K("Authentication required"):r===403?new q("You are not allowed to access this resource"):new K("Authentication required")}},Bn="auth",nn={typeDefs:"directive @auth on FIELD_DEFINITION",transformer:e=>z.mapSchema(e,{[z.MapperKind.OBJECT_FIELD]:n=>{if(z.getDirective(e,n,Bn)?.[0]){const r=n.resolve;n.resolve=async(i,a,o,s)=>(await Ln(o),r?.(i,a,o,s))}return n}})},Mn="cacheControl",$n=(e,n)=>{const{scope:t="private",sMaxAge:r=0,staleWhileRevalidate:i=0}=e;return`${n?"private":t}, s-maxage=${r}, stale-while-revalidate=${i}`},De=(e,n)=>typeof e=="number"&&typeof n=="number"?e>n?n:e:typeof e=="number"?e:n,zn=(e,n)=>typeof e=="string"&&typeof n=="string"?e==="public"&&n==="public"?"public":"private":e||n,tn={typeDefs:"directive @cacheControl(sMaxAge: Int, staleWhileRevalidate: Int, scope: String) on FIELD_DEFINITION",transformer:e=>z.mapSchema(e,{[z.MapperKind.OBJECT_FIELD]:n=>{const t=z.getDirective(e,n,Mn)?.[0];if(t){const{sMaxAge:r,staleWhileRevalidate:i,scope:a}=t,o=n.resolve;n.resolve=(s,c,l,p)=>(l.cacheControl={sMaxAge:De(l.cacheControl?.sMaxAge,r),staleWhileRevalidate:De(l.cacheControl?.staleWhileRevalidate,i),scope:zn(l.cacheControl?.scope,a)},o?.(s,c,l,p))}return n}})},rn=e=>(n,t)=>{const r=He.mergeTypeDefs([...(e??[]).map(({typeDefs:i})=>i),t]);return(e??[]).reduce((i,{transformer:a})=>a?.(i)??i,Xe.makeExecutableSchema({typeDefs:r,resolvers:n}))},le="@faststore/api",de="4.5.0-dev.0",Ae={name:le,version:de},xn=(e,n)=>(t,r,i,a)=>{if((i?.OTEL?.enabled??!1)===!1)return e(t,r,i,a);const o=L.OTELAPI.trace.getTracer(le,de),s=L.OTELAPI.propagation.extract(L.OTELAPI.context.active(),i.OTEL);return L.OTELAPI.context.with(s,()=>{const c=o.startSpan(n??"Unknown Graphql Resolver",{startTime:Date.now(),kind:L.OTELAPI.SpanKind.INTERNAL,attributes:{timestamp:Date.now(),"@faststore_version":de,"@faststore_package_name":le,"@faststore_account_name":i.account,"@faststore_environment":process.env.NODE_ENV}});if(!c)return e(t,r,i,a);try{const l=e(t,r,i,a);return l instanceof Promise?l.then(p=>(c.end(),p)):(c.end(),l)}catch(l){throw c.end(),console.error(`Error when executing resolver: ${n}`,l),l}})};class W extends Error{constructor(n,t){super(t),this.extensions=n,this.name="FastStoreError"}}class E extends W{constructor(n){super({status:400,type:"BadRequestError"},n)}}class K extends W{constructor(n){super({status:401,type:"UnauthorizedError"},n)}}class q extends W{constructor(n){super({status:403,type:"ForbiddenError"},n)}}class B extends W{constructor(n){super({status:404,type:"NotFoundError"},n)}}const qn=e=>e?.name==="FastStoreError",Vn=e=>e?.extensions?.type==="BadRequestError",jn=e=>e?.extensions?.type==="UnauthorizedError",an=e=>e?.extensions?.type==="ForbiddenError",be=e=>e?.extensions?.type==="NotFoundError",Wn=`${Ae.name}@${Ae.version}`,I=async(e,n,t)=>{const r=await Rn(e,{...n,headers:{...n?.headers??{},"User-Agent":Wn}});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 K(i);case 403:throw new q(i);case 404:throw new B(i);default:throw new W({status:r.status,type:"UnknownError"},i)}throw new Error(i)},on=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("; ")},Gn=/^([^=]+)=([^;]*)/,Hn=(e,n)=>{const t=n.match(Gn);if(t){const r=t[1],i=t[2];e.storage.cookies.set(r,{value:i,setCookie:n})}},Xn=(e,n)=>{n.getSetCookie().forEach(t=>Hn(e,t))},Yn=e=>n=>Xn(e,n),ue=e=>{if(!e.headers?.cookie)return null;const n=on(e.headers.cookie),t=Array.from(e.storage.cookies.entries());return t.length===0?n:t.reduce((r,[i,{value:a}])=>Jn(r,i,a),n)},sn=e=>function(t){const r=ue(e);return r?{...t,cookie:r}:t},x=(e,n)=>{const t=on(e);return Z.parse(t)[`VtexIdclientAutCookie_${n}`]||""},Jn=(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){return e?JSON.parse(Buffer.from(e.split(".")[1],"base64").toString()):null}const Kn="storefront/faststore.recommendation-shelf@v4",X={method:"POST",headers:{"content-type":"application/json"}},Qn=/^\d{4}-\d{2}-\d{2}$/,Zn=new Set(["Draft","Requested","InReview","Reviewed","Approved","Declined","Expired","ConvertedToCart","ConvertedToOrder"]);function et({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&&!Qn.test(c))throw new Error(`listUserQuotes: invalid ${s} "${c}" — must be YYYY-MM-DD`);if(t&&t.length>0){const s=t.filter(c=>!Zn.has(c));if(s.length>0)throw new Error(`listUserQuotes: invalid status values: ${s.join(", ")}`)}}function nt({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(l=>c.append("status",l)),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 tt=({account:e,environment:n,incrementAddress:t,subDomainPrefix:r},i)=>{const a=`https://${e}.${n}.com.br`,o=Yn(i),s=sn(i),c=Nn(),l=new Headers(i.headers).get("x-forwarded-host")??i.headers?.host??"",p=r&&r.map(d=>d+".").find(d=>l.includes(d))||"",u=l.replace(p,""),h=`${a}/api/recommend-bff/v2`,S=s({accept:"application/json","content-type":"application/json","x-vtex-rec-origin":`${e}/${Kn}`}),b=(d={})=>{const g=x(ue(i)??"",e);return s({...d,"X-FORWARDED-HOST":u,...g?{[`VtexIdclientAutCookie_${e}`]:g}:{}})};return{catalog:{salesChannel:d=>I(`${a}/api/catalog_system/pub/saleschannel/${d}`,void 0,{storeCookies:o}),brand:{list:()=>I(`${a}/api/catalog_system/pub/brand/list`,void 0,{storeCookies:o})},category:{tree:(d=3)=>I(`${a}/api/catalog_system/pub/category/tree/${d}`,void 0,{storeCookies:o})},portal:{pagetype:d=>I(`${a}/api/catalog_system/pub/portal/pagetype/${d}`,void 0,{storeCookies:o})},products:{crossselling:({type:d,productId:g,groupByProduct:m=!0})=>{const y=new URLSearchParams({sc:i.storage.channel.salesChannel,groupByProduct:m.toString()});return I(`${a}/api/catalog_system/pub/products/crossselling/${d}/${g}?${y}`,void 0,{storeCookies:o})}}},checkout:{simulation:(d,{salesChannel:g}=i.storage.channel)=>{const m=new URLSearchParams({sc:g}),y=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/checkout/pub/orderForms/simulation?${m.toString()}`,{...X,headers:y,body:JSON.stringify(d)},{storeCookies:o})},shippingData:({id:d,index:g,deliveryMode:m,selectedAddresses:y},C)=>{const w=C?{startDateUtc:m?.deliveryWindow?.startDate,endDateUtc:m?.deliveryWindow?.endDate}:null,v={logisticsInfo:Array.from({length:g},(f,D)=>({itemIndex:D,selectedDeliveryChannel:m?.deliveryChannel||null,selectedSla:m?.deliveryMethod||null,deliveryWindow:w})),selectedAddresses:y,clearAddressIfPostalCodeNotFound:t},P=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/checkout/pub/orderForm/${d}/attachments/shippingData`,{...X,headers:P,body:JSON.stringify(v)},{storeCookies:o})},marketingData:({id:d,marketingData:g})=>{const m=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/checkout/pub/orderForm/${d}/attachments/marketingData`,{headers:m,body:JSON.stringify(g),method:"POST"},{storeCookies:o})},clientPreferencesData:({id:d,clientPreferencesData:g})=>{const m=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/checkout/pub/orderForm/${d}/attachments/clientPreferencesData`,{headers:m,body:JSON.stringify(g),method:"POST"},{storeCookies:o})},orderForm:({id:d,refreshOutdatedData:g=!0,channel:m=i.storage.channel})=>{const{salesChannel:y}=m,C=s({"content-type":"application/json","X-FORWARDED-HOST":u}),w=new URLSearchParams({sc:y});d&&w.set("refreshOutdatedData",g.toString());const v=`${a}/api/checkout/pub/orderForm${d?`/${d}`:""}?${w.toString()}`;return I(v,{...X,headers:C,...d?{}:{body:"{}"}},{storeCookies:o})},clearOrderFormMessages:({id:d})=>{const g=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/checkout/pub/orderForm/${d}/messages/clear`,{...X,headers:g,body:"{}"})},updateOrderFormItems:({id:d,orderItems:g,allowOutdatedData:m="paymentData",salesChannel:y=i.storage.channel.salesChannel,shouldSplitItem:C=!0})=>{const w=new URLSearchParams({allowOutdatedData:m,sc:y}),v=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/checkout/pub/orderForm/${d}/items?${w}`,{headers:v,body:JSON.stringify({orderItems:g,noSplitItem:!C}),method:"PATCH"},{storeCookies:o})},setCustomData:({id:d,appId:g,key:m,value:y})=>{const C=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/checkout/pub/orderForm/${d}/customData/${g}/${m}`,{headers:C,body:JSON.stringify({value:y}),method:"PUT"})},region:async({postalCode:d,geoCoordinates:g,country:m,salesChannel:y})=>{const C=new URLSearchParams({country:m,sc:y??""});d?C.append("postalCode",d):C.append("geoCoordinates",`${g?.longitude};${g?.latitude}`);const w=`${a}/api/checkout/pub/regions/?${C.toString()}`,v=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(w,{headers:v},{storeCookies:o})},address:async({postalCode:d,country:g})=>{const m=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/checkout/pub/postal-code/${g}/${d}`,{headers:m},{storeCookies:o})},cancelOrder:({orderId:d,customerEmail:g,reason:m})=>{const y=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/checkout/pub/orders/${d}/user-cancel-request`,{method:"POST",headers:y,body:JSON.stringify({customerEmail:g,reason:m})},{})},pickupPoints:({geoCoordinates:d})=>{if(!d)throw new Error("Missing required parameter for listing pickup points.");const g=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/logistics-shipping/pickuppoints/_search`,{method:"POST",headers:g,body:JSON.stringify({coordinate:d})},{storeCookies:o})}},session:d=>{const g=new URLSearchParams(d);g.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"}),y=Z.parse(i?.headers?.cookie??"")?.vtex_session;return I(`${a}/api/sessions?${g.toString()}`,{method:y?"PATCH":"POST",headers:m,body:"{}"},{storeCookies:o})},subscribeToNewsletter:d=>I(`${a}/api/dataentities/NL/documents/`,{...X,body:JSON.stringify({...d,isNewsletterOptIn:!0}),method:"PATCH"},{storeCookies:o}),profile:{addresses:async d=>{const g=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/profile-system/pvt/profiles/${d}/addresses`,{headers:g},{storeCookies:o})}},oms:{userOrder:({orderId:d})=>{const g=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/oms/user/orders/${d}`,{method:"GET",headers:g},{storeCookies:o})},listUserOrders:({page:d,status:g,dateInitial:m,dateFinal:y,text:C,clientEmail:w,perPage:v,pendingMyApproval:P})=>{const f=new URLSearchParams;if(m){const A=new Date(m).setHours(0,0,0,0);m=new Date(A).toISOString()}if(y){const A=new Date(y).setHours(23,59,59,999);y=new Date(A).toISOString()}C&&f.append("text",C),g&&g.length>0&&f.append("status",g.filter(Boolean).join(",")),m&&y?f.append("creation_date",`creationDate:[${m} TO ${y}]`):m?f.append("creation_date",`creationDate:[${m} TO *]`):y&&f.append("creation_date",`creationDate:[* TO ${y}]`),w&&f.append("clientEmail",w),d&&f.append("page",d.toString()),v&&f.append("per_page",v.toString()),P&&f.append("my_pending_approvals",String(!0));const D=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/oms/user/orders?${f.toString()}`,{method:"GET",headers:D},{storeCookies:o})},getCommercialAuthorizationsByOrderId:({orderId:d})=>{const g=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/${e}/commercial-authorizations/order/${d}`,{method:"GET",headers:g},{storeCookies:o})},processOrderAuthorization:async({orderAuthorizationId:d,dimensionId:g,ruleId:m,approved:y})=>{const C=s({"content-type":"application/json","X-FORWARDED-HOST":u}),P={params:{ruleId:m,dimensionId:g,score:y?100:0}};return I(`${a}/${e}/commercial-authorizations/${d}/callback`,{method:"POST",headers:C,body:JSON.stringify(P)},{storeCookies:o})}},units:{getUnitByUserId:({userId:d})=>{const g=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/units/v1/${d}/unit`,{method:"GET",headers:g},{})},getOrgUnitById:({orgUnitId:d})=>{const g=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/units/v1/${d}`,{method:"GET",headers:g},{})},getScopesByOrgUnit:({orgUnitId:d})=>{const g=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/units/v1/${d}/scopes`,{method:"GET",headers:g},{})}},licenseManager:{getUserById:({userId:d})=>{const g=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/license-manager/users/${d}`,{method:"GET",headers:g},{})},getUserByEmail:({email:d})=>{const g=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/license-manager/pvt/users/${d}`,{method:"GET",headers:g},{})},getUserRoles:({userId:d})=>{const g=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/license-manager/storefront/users/${d}/roles`,{method:"GET",headers:g},{})}},masterData:{getContractById:({contractId:d})=>{if(!d)throw new E("Missing contractId to fetch CL fields.");const g=b({Accept:"application/json","content-type":"application/json"});return I(`${a}/api/dataentities/CL/documents/${d}?_fields=_all`,{method:"GET",headers:g},{})},getShopperById:({userId:d})=>{if(!d)throw new E("Missing userId to fetch shopper name.");const g=c({Accept:"application/json","content-type":"application/json","X-FORWARDED-HOST":u}),m=d.replace(/-/g,"");return I(`${a}/api/dataentities/shopper/search?_where=(userId=${m} OR userId=${d})&_fields=_all&_schema=v1`,{method:"GET",headers:g},{})}},quotes:{listUserQuotes:d=>{et(d);const g=nt(d),m=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/quoting/quotes?${g.toString()}`,{method:"GET",headers:m},{storeCookies:o})}},vtexid:{validate:()=>{const d=s({"content-type":"application/json","X-FORWARDED-HOST":u}),g=x(ue(i)??"",e);return I(`${a}/api/vtexid/credential/validate`,{headers:d,body:JSON.stringify({token:g}),method:"POST"},{storeCookies:o})}},orderEntry:{uploadFile:({fileBuffer:d,fileName:g,mimeType:m})=>{const y=s({"content-type":"application/json","X-FORWARDED-HOST":u}),C=`----FastStoreUploadBoundary${Date.now()}`,w=`\r
|
|
2
|
+
`,P=/^[a-zA-Z0-9][a-zA-Z0-9!#$&\-.^_]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&\-.^_+]*$/.test(m)?m:"application/octet-stream",f=g.replaceAll(/[\r\n"]/g,"_"),D=[`--${C}`,`Content-Disposition: form-data; name="file"; filename="${f}"`,`Content-Type: ${P}`,"",""].join(w),A=`${w}--${C}--${w}`,U=Buffer.from(D),O=Buffer.from(A),T=new Uint8Array(U.byteLength+d.byteLength+O.byteLength);let _=0;return T.set(U,_),_+=U.byteLength,T.set(d,_),_+=d.byteLength,T.set(O,_),I(`${a}/api/order-entry/upload?an=${e}`,{method:"POST",headers:{...y,"content-type":`multipart/form-data; boundary=${C}`},body:T.buffer},{})},startOperation:({objectKey:d,orderFormId:g,sessionToken:m})=>{const y=s({"content-type":"application/json","X-FORWARDED-HOST":u}),C=JSON.stringify({objectKey:d,orderFormId:g,operation:"CreateCart",...m?{sessionToken:m}:{}});return I(`${a}/api/order-entry/operation?an=${e}`,{method:"POST",headers:y,body:C},{})},getOperation:({operationId:d})=>{const g=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/order-entry/operation/${d}?an=${e}`,{method:"GET",headers:g},{})},createOrderForm:()=>{const d=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/checkout/pub/orderForm?sc=${i.storage.channel.salesChannel}`,{method:"POST",headers:d,body:"{}"},{})},getOrderFormItems:({orderFormId:d})=>{const g=s({"content-type":"application/json","X-FORWARDED-HOST":u});return I(`${a}/api/checkout/pub/orderForm/${d}`,{method:"GET",headers:g},{})}},recommendation:{recommendations:({campaignVrn:d,userId:g,products:m=[],salesChannel:y,locale:C})=>{const w=new URLSearchParams({an:e,campaignVrn:d});return g&&w.append("userId",g),m.length>0&&w.append("products",m.join(",")),y&&w.append("salesChannel",y),C&&w.append("locale",C),I(`${h}/recommendations?${w.toString()}`,{headers:S},{storeCookies:o})},startRecommendationSession:()=>{const d=new URLSearchParams({an:e});return I(`${h}/users/start-session?${d.toString()}`,{method:"POST",headers:S},{storeCookies:o})}}}},pe="fuzzy",ge="operator",me="pickupPoint",Pe="shipping",Ee="delivery-options",rt="in-stock",it="trade-policy",at="region-id",ot=new Set([it,at,pe,ge,me]),st=new Set(["zip-code","pickupPoint","country","coordinates","deliveryZonesHash","pickupPointsHash"]),ct=new Set(["productClusterIds"]),Ue=e=>encodeURI(decodeURI(e)),lt=e=>encodeURIComponent(decodeURIComponent(e).normalize("NFD").replaceAll(/[\u0300-\u036f]/g,"")),dt=/^pickup-in-point-(.+)$/;function cn(e){if(!e)return{};try{const t=Z.parse(e).vtex_segment;if(!t)return{};const r=Buffer.from(t,"base64").toString("utf-8");return JSON.parse(r)}catch{return{}}}function ut(e){const n={},t={},r=[];for(const i of e.split(";")){const a=i.indexOf("=");if(a<0)continue;const o=i.slice(0,a),s=i.slice(a+1);!o||!s||(st.has(o)?n[o]=s:ct.has(o)?t[o]=s:r.push({key:o,value:s}))}return{shipping:n,queryParams:t,extraFacets:r}}function pt(e){const n=typeof e.facets=="string"?e.facets:"",{shipping:t,queryParams:r,extraFacets:i}=ut(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,productClusterIds:r.productClusterIds},extraFacets:i}}function ln(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],["productClusterId",n.productClusterIds]];for(const[r,i]of t)i!=null&&i!==""&&e.append(r,String(i))}function dn(e){return dt.exec(e)?.[1]}function gt(e){const n=e.find(r=>r.key==="shipping"),t=n?dn(n.value):void 0;if(t!==void 0)try{return decodeURIComponent(t)}catch{return t}}function mt(e,n){const t=gt(n);return t===void 0?e:{...e,pickupPoint:t}}function ht(e){return e.map(n=>n.key!=="shipping"||dn(n.value)===void 0?n:{...n,value:"pickup-in-point"})}function ft(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 St(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}${Ue(r)}/${lt(Ue(i)).replaceAll(/ |%20/g,"-")}/`},"")}const yt=e=>e.key==="fuzzy"&&(e.value==="0"||e.value==="1"||e.value==="auto"),It=e=>e.key==="operator"&&(e.value==="and"||e.value==="or");function vt(e,n){const{segmentParams:t,extraFacets:r}=pt(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 Ot(e,n){const t=e.filter(({key:c})=>!ot.has(c)),r=e.find(({key:c,value:l})=>c===Pe&&l!=="all-delivery-methods")??null,i=e.find(({key:c,value:l})=>c===Ee&&l!=="all-delivery-options")??null,a=[...t],o=a.some(({key:c})=>c===Pe),s=a.some(({key:c})=>c===Ee);return r!==null&&!o&&a.push(r),i!==null&&!s&&a.push(i),ft(a,n)}function Ct(e,n){const t=e.find(({key:a})=>a===pe)??null,r=e.find(({key:a})=>a===ge)??null,i=e.find(({key:a})=>a===me)??null;t&&yt(t)&&n.append(pe,t.value),r&&It(r)&&n.append(ge,r.value),i&&n.append(me,i.value)}function Te(e,n,t,r){const{query:i="",page:a,count:o,sort:s,selectedFacets:c=[],showInvisibleItems:l,sponsoredCount:p,hideUnavailableItems:u,allowRedirect:h=!1}=e,S=new URLSearchParams;if(r.includePagination&&a!==void 0&&o!==void 0){const g=a*o,m=o===0?g:g+o-1;S.append("from",g.toString()),S.append("to",m.toString())}i&&S.append("query",i),r.includeSort&&s&&S.append("sort",s);const b=mt(t.segmentParams,c);if(ln(S,b??t.segmentParams),Ct(c,S),l&&S.append("show-invisible-items","true"),n?.hideUnavailableItems!==void 0){const g=c.find(({key:y})=>y===rt),m=g?g.value:u?.toString()??n.hideUnavailableItems.toString();S.append("hideUnavailableItems",m)}n?.simulationBehavior!==void 0&&S.append("simulationBehavior",n.simulationBehavior.toString()),n?.showSponsored!==void 0&&S.append("showSponsored",n.showSponsored.toString()),p!==void 0&&S.append("sponsoredCount",p.toString()),h!==void 0&&S.append("allowRedirect",h.toString());const d=St(Ot(c,t.extraFacets));return{params:S,path:d}}function bt(e,n){const{field:t,value:r,hideUnavailableItems:i,showInvisibleItems:a}=e,o=new URLSearchParams({field:t??"",value:r??""});return ln(o,n),i&&o.append("hideUnavailableItems","true"),a&&o.append("show-invisible-items","true"),o}function Y(e,n){return{path:e,params:n,toString(){const t=n.toString();return e?t?`${e}?${t}`:e:t?`?${t}`:""}}}function J(e){const{endpoint:n,segment:t,defaults:r,args:i={}}=e,a=vt(t,r);switch(n){case"product-search":case"facets":{const{params:o,path:s}=Te(i,r,a,{includePagination:!0,includeSort:!0});return Y(s,o)}case"catalog-count":{const{params:o,path:s}=Te(i,r,a,{includePagination:!1,includeSort:!1});return Y(s,o)}case"products":{const o=bt(i,a.segmentParams);return Y("",o)}case"search-suggestions":{const o=new URLSearchParams({query:i.query?.toString()??"",locale:r?.locale??a.segmentParams.locale??""});return Y("",o)}case"top-searches":{const o=new URLSearchParams({locale:r?.locale??a.segmentParams.locale??""});return Y("",o)}default:{const o=n;throw new Error(`Unknown intelligent-search endpoint: ${o}`)}}}const wt=10;function Dt(e){const{regionId:n,seller:t}=e.storage.channel;return(t?Buffer.from(`SW#${t}`).toString("base64"):void 0)??(n||void 0)}function At(e){const n=cn(e.headers?.cookie);return e.storage.locale||n.cultureInfo||""}const Pt=({account:e,environment:n,hideUnavailableItems:t,simulationBehavior:r,showSponsored:i,subDomainPrefix:a},o)=>{const s=`https://${e}.${n}.com.br`,c=sn(o),l=cn(o.headers?.cookie),p=()=>({salesChannel:o.storage.channel.salesChannel,regionId:Dt(o),locale:At(o),hideUnavailableItems:t,simulationBehavior:r,showSponsored:i}),u=new Headers(o.headers).get("x-forwarded-host")??o.headers?.host??"",h=a&&a.map(f=>f+".").find(f=>u.includes(f))||"",S=u.replace(h,""),b=c({"content-type":"application/json","X-FORWARDED-HOST":S}),d=({type:f,...D})=>{const A=f==="facets"?"facets":"product-search",U=J({endpoint:A,segment:l,defaults:p(),args:D});return I(`${s}/api/intelligent-search/v1/${A}/${U.path}?${U.params.toString()}`,{headers:b})},g=f=>d({...f,type:"product_search"}),m=({field:f,value:D,hideUnavailableItems:A,showInvisibleItems:U})=>{const O=J({endpoint:"products",segment:l,defaults:p(),args:{field:f,value:D,hideUnavailableItems:A,showInvisibleItems:U}});return I(`${s}/api/intelligent-search/v1/products?${O.params.toString()}`,{headers:b})};return{facets:f=>d({...f,type:"facets"}),products:g,fetchProduct:m,productsByIdentifier:async({field:f,values:D,showInvisibleItems:A,hideUnavailableItems:U})=>{const O=Oe(wt);return(await Promise.all(D.map(_=>O(async()=>{try{return await m({field:f,value:_,hideUnavailableItems:U,showInvisibleItems:A})}catch{return null}})))).filter(_=>_!==null)},suggestedTerms:f=>{const D=J({endpoint:"search-suggestions",segment:l,defaults:p(),args:{query:f.query}});return I(`${s}/api/intelligent-search/v1/search-suggestions?${D.params.toString()}`,{headers:b})},topSearches:()=>{const f=J({endpoint:"top-searches",segment:l,defaults:p()});return I(`${s}/api/intelligent-search/v1/top-searches?${f.params.toString()}`,{headers:b})},productCount:f=>{const D=J({endpoint:"catalog-count",segment:l,defaults:p(),args:f});return I(`${s}/api/intelligent-search/v1/catalog-count/${D.path}?${D.params.toString()}`,{headers:b})}}},Et=(e,n)=>{const t=Pt(e,n),r=tt(e,n);return{search:t,commerce:r}},Ut=20,Tt=new Set(["brand","category","department","subcategory","collection","cluster"]),V=e=>typeof e.pageType=="string"&&Tt.has(e.pageType.toLowerCase()),_t=(e,n)=>{const t=Oe(Ut),r=async i=>Promise.all(i.map(a=>t(async()=>{const o=await n.commerce.catalog.portal.pagetype(a);if(V(o))return o;throw new B(`Catalog returned ${o.pageType} for slug: ${a}. This usually happens when there is more than one category with the same name in the same category tree level.`)})));return new oe(r,{batch:!1})},Rt=(e,n)=>{const t=async r=>Promise.all(r.map(i=>n.commerce.catalog.salesChannel(i)));return new oe(t)},kt=1,Ft=(e,n)=>{const t=Oe(kt),r=async a=>{const o=a.reduce((u,{items:h})=>[...u,h],[]),s=[...o.flat()],c=await n.commerce.checkout.simulation({country:a[0].country,postalCode:a[0].postalCode,items:s}),l=c.items.reduce((u,h)=>{const S=h.requestIndex;return typeof S=="number"&&S<u.length&&(u[S]=h),u},Array(s.length).fill(null)),p=o.reduce((u,h)=>[...u,h.length+u[u.length-1]],[0]);return o.map((u,h)=>({...c,items:l.slice(p[h],p[h+1]).filter(S=>!!S)}))},i=async a=>t(r,a);return new oe(i,{maxBatchSize:50})},Nt=(e,n)=>kn(e,n);function Lt(e){return{...e,description:e.description?Nt(e.description):e.description}}const N=(e,n)=>({...e,isVariantOf:Lt(n)}),Bt=({flags:e},n)=>{const t=async r=>{const i=r.map(p=>p.split("-")[0]),a=r.some(p=>p.split("-")[1]==="invisibleItems"),s=(await n.search.productsByIdentifier({field:"sku",values:i,showInvisibleItems:a,...e?.enableUnavailableItemsOnCart&&{hideUnavailableItems:!1}})).reduce((p,u)=>{for(const h of u.items)p[h.itemId]=N(h,u);return p},{}),c=i.map(p=>s[p]),l=i.filter(p=>!s[p]);if(l.length>0)throw new B(`Search API did not found the following skus: ${l.join(",")}`);return c};return new oe(t,{maxBatchSize:99})},Mt=(e,{clients:n})=>{const t=Bt(e,n),r=Ft(e,n),i=_t(e,n),a=Rt(e,n);return{skuLoader:t,simulationLoader:r,collectionLoader:i,salesChannelLoader:a}},M=e=>e.AvailableQuantity>0,j=e=>e.spotPrice??0,$t=e=>e.Price??0,_e=e=>e?"https://schema.org/InStock":"https://schema.org/OutOfStock",un=(e,n)=>M(e)&&!M(n)?-1:!M(e)&&M(n)?1:j(e)-j(n),zt=e=>e==="available",$=(e,n=0,t=1)=>{const r=n/t;return Math.round((e+r)*100)/100},xt=(e,n={includeTaxes:!1})=>{const t=e.filter(M),r=t[t.length-1],i=r?j(r):0;return n.includeTaxes?$(i,r?.Tax,r?.product?.unitMultiplier):i},Re=(e,n={includeTaxes:!1})=>{const[t]=e.filter(M),r=t?j(t):0;return n.includeTaxes?$(r,t?.Tax,t?.product?.unitMultiplier):r},qt={highPrice:e=>xt(e),lowPrice:e=>Re(e),lowPriceWithTaxes:e=>Re(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},Vt={ratingValue:()=>5,reviewCount:()=>0},ke="ÁÄÂÀÃÅČÇĆĎÉĚËÈÊẼĔȆÍÌÎÏŇÑÓÖÒÔÕØŘŔŠŤÚŮÜÙÛÝŸŽáäâàãåčçćďéěëèêẽĕȇíìîïňñóöòôõøðřŕšťúůüùûýÿžþÞĐđ߯a",jt="AAAAAACCCDEEEEEEEEIIIINNOOOOOORRSTUUUUUYYZaaaaaacccdeeeeeeeeiiiinnooooooorrstuuuuuyyzbBDdBAa",Wt=e=>{let n=e.slice(0);for(let t=0;t<ke.length;t++)n=n.replace(new RegExp(ke.charAt(t),"g"),jt.charAt(t));return n},Gt=e=>e.replace(/[·/_,:]/,"-");function pn(e){const t=e.replace(/,/g,"").replace(/[*+~.()'"!:@&\[\]`/ %$#?{}><=_^]/g,"-");return Gt(Wt(t)).toLowerCase()}const ne=e=>e.type==="brand"||V(e)&&e.pageType.toLowerCase()==="brand",he=e=>V(e)&&e.pageType.toLowerCase()==="collection",ce=e=>ne(e)||he(e)?pn(e.name):V(e)?new URL(`https://${e.url}`).pathname.slice(1).toLowerCase():new URL(e.url).pathname.slice(1).toLowerCase(),gn={id:({id:e})=>e.toString(),slug:e=>ce(e),seo:e=>ne(e)||V(e)?{title:e.title??e.name,description:e.metaTagDescription}:{title:e.Title,description:e.MetaTagDescription},type:e=>ne(e)?"Brand":V(e)?e.pageType:e.level===0?"Department":"Category",meta:e=>{const n=ce(e);return ne(e)?{selectedFacets:[{key:"brand",value:n}]}:he(e)?{selectedFacets:[{key:"productclusterids",value:e.id}]}:{selectedFacets:n.split("/").map((t,r)=>({key:`category-${r+1}`,value:t}))}},breadcrumbList:async(e,n,t)=>{const{loaders:{collectionLoader:r}}=t,a=ce(e).split("/").filter(c=>!!c),o=a.map((c,l)=>a.slice(0,l+1).join("/")),s=await Promise.all(o.map(async c=>{const l=await r.load(c);return{slug:c,...l}}));return{itemListElement:s.map((c,l)=>({item:he(c)?`/${c.slug}`:new URL(`https://${c.url}`).pathname.toLowerCase(),name:c.name,position:l+1})),numberOfItems:s.length}}},mn={buy:"whoboughtalsobought",view:"whosawalsosaw",similars:"similars",viewAndBought:"whosawalsobought",accessories:"accessories",suggestions:"suggestions"},Fe=({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}}},Ne=e=>{const n=e.split(":").map(Number);return n.length!==2||Number.isNaN(n[0])||Number.isNaN(n[1])?null:n},Ht=e=>typeof mn[e]=="string",Xt=e=>{const n=e?.filter(t=>Ht(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},Yt=e=>e?.find(n=>n.key==="slug")?.value??null,Jt=e=>e?.find(n=>n.key==="id")?.value??null,Le=e=>e?.find(n=>n.key==="locale")?.value??null,Be=e=>e?.find(n=>n.key==="channel")?.value??null,fe=(e,n)=>{let t=0;for(let r=1;r<e.length;r++)n(e[t],e[r])>0&&(t=r);return e[t]},Kt={__resolveType:({type:e,values:n})=>e!=="TEXT"&&e!=="DELIVERY"?"StoreFacetRange":!n||n.length===0?"StoreFacetBoolean":n.every(t=>t.range)?"StoreFacetRange":"StoreFacetBoolean"},Qt={key:({key:e})=>e,label:({name:e})=>e,values:({values:e})=>e.sort((n,t)=>n.name.localeCompare(t.name))},Zt={key:({key:e})=>e,label:({name:e})=>e,min:({values:e,key:n},t,{storage:{searchArgs:r}})=>{const i=Ne(r?.selectedFacets?.find(s=>s.key===n)?.value??""),o=fe(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=Ne(r?.selectedFacets?.find(s=>s.key===n)?.value??""),o=fe(e,(s,c)=>c.range.to-s.range.to)?.range?.to??0;return{selected:i?.[1]??o,absolute:o}}},er={value:({value:e})=>e,label:({name:e})=>e||"unknown",selected:({selected:e})=>e,quantity:({quantity:e})=>e},nr=async(e,{data:n},{clients:{commerce:t}})=>{if(!n?.orderId)throw new E("Missing orderId");return{data:(await t.checkout.cancelOrder(n))?.data}};function hn(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 tr(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 rr=async(e,{data:n},{clients:{commerce:t}})=>{const r=await t.oms.processOrderAuthorization(n),i=hn(r);return{isPendingForOtherAuthorizer:!i&&tr(r),ruleForAuthorization:i}},ir=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})},ar=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},or=async(e,{data:n},{clients:{commerce:t}})=>({id:(await t.subscribeToNewsletter(n))?.Id}),sr=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 p=Buffer.from(o,"base64");return await t.orderEntry.uploadFile({fileBuffer:p,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)}}const Se=(e,n)=>{e.storage.channel=re.parse(n)},ye=(e,n)=>{e.storage.locale=n},fn=e=>Fn.createHash("md5").update(e).digest("hex"),ee={attachment:"ATTACHMENT",specification:"SPECIFICATION",attribute:"ATTRIBUTE"};function Sn(e){return{name:e.name,value:e.content,valueReference:ee.attachment}}function cr(e){return{propertyID:e.id,name:e.name,value:e.value,valueReference:{valueReference:ee.attribute,visible:e.visible}}}function yn(e){return fn(`${e.name}:${JSON.stringify(e.value)}:${e.valueReference}`)}const lr=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]},dr=(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},In=(e,n)=>{if(!ur(n))return{updateShipping:!1,addressChanged:!1};if(!hr(e))return{updateShipping:!1,addressChanged:!1};const[t]=e?.shippingData?.selectedAddresses??[];if(pr(t,n.postalCode)||gr(t,n.geoCoordinates)||mr(t,n.addressType))return{updateShipping:!0,addressChanged:!0};const{logisticsInfo:r}=e.shippingData;return fr(r,n)?{updateShipping:!0,addressChanged:!1}:{updateShipping:!1,addressChanged:!1}},ur=e=>!!e.postalCode||e.geoCoordinates?.latitude&&e.geoCoordinates?.longitude,pr=(e,n)=>typeof n=="string"&&e?.postalCode!==n,gr=(e,n)=>typeof n?.latitude=="number"&&typeof n?.longitude=="number"&&(e?.geoCoordinates[0]!==n?.longitude||e?.geoCoordinates[1]!==n?.latitude),mr=(e,n)=>typeof n=="string"&&e?.addressType!==n,hr=e=>e.items.length!==0,fr=(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 l=t&&o!==t,p=r&&s!==r;return c?.some(u=>l&&u.deliveryChannel===t||p&&u.id===r?!0:i&&a&&u.deliveryChannel===t&&u.id===r&&(!u?.deliveryWindow||u?.deliveryWindow?.startDateUtc!==i||u?.deliveryWindow?.endDateUtc!==a)&&u.availableDeliveryWindows?.some(h=>h?.startDateUtc===i&&h?.endDateUtc===a))})},vn=e=>e.valueReference===ee.attachment,Ie=e=>[e.itemOffered.sku,e.seller.identifier,e.price<.01?"Gift":void 0,e.itemOffered.additionalProperty?.filter(vn).map(yn).join("-")].filter(Boolean).join("::"),ie=(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(Sn)},index:n}),Sr=e=>({quantity:e.quantity,seller:e.seller.identifier,id:e.itemOffered.sku,index:e.index,attachments:(e.itemOffered.additionalProperty?.filter(vn)??[]).map(n=>({name:n.name,content:n.value}))}),Me=e=>e.reduce((n,t)=>{const r=Ie(t);return n.has(r)||n.set(r,[]),n.get(r)?.push(t),n},new Map),yr=(e,n)=>{const t=(s,c)=>({...s,itemOffered:{sku:s.itemOffered.sku},index:c}),r=n.items.map(ie).map(t),i=e.acceptedOffer.map(t),a=e.orderNumber===n.orderFormId,o=Ce(r,i);return a&&o};function On(e,n){return e?.some(t=>t.parentItemIndex!==null&&t.parentItemIndex!==void 0&&e[t.parentItemIndex]?.id===n)}function Cn(e,n){return e?.some(t=>t.id===n&&t.parentItemIndex!==null)}const $e=e=>{const n=e.items.reduce((t,r,i)=>{const a=Cn(e.items,r.id)||On(e.items,r.id)?`${Ie(ie(r))}::${i}`:Ie(ie(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}})}},ze=async(e,n,t)=>({order:{orderNumber:e.orderFormId,acceptedOffer:e.items.map(async r=>({...r,product:await n.load(`${r.id}-invisibleItems`)})),shouldSplitItem:t},messages:e.messages.map(({text:r,status:i})=>({text:r,status:i.toUpperCase()}))}),bn=({items:e},n)=>{const t=e.map(r=>({id:r.id,quantity:r.quantity,seller:r.seller,attachments:r.attachments}));return fn(JSON.stringify({sessionId:n?.id??"",items:t}))},xe=async(e,n,t)=>{try{return await n.checkout.setCustomData({id:e.orderFormId,appId:"faststore",key:"cartEtag",value:bn(e,t)})}catch(r){throw console.error(`Error while setting custom data to orderForm.
|
|
3
3
|
Make sure to add the following custom app to the orderForm:
|
|
4
4
|
{"fields":["cartEtag"],"id":"faststore","major":1}.
|
|
5
|
-
More info at: https://developers.vtex.com/vtex-rest-api/docs/customizable-fields-with-checkout-api`),r}},
|
|
6
|
-
`),r}}const
|
|
7
|
-
`)}let _;o.seller&&(s||g)&&(_=(await r.commerce.checkout.region({postalCode:s,geoCoordinates:g,country:l,salesChannel:u}))?.[0]?.sellers.find(oe=>o.seller===oe.id));const j={...n,currency:{code:b?.currencyCode?.value??n.currency.code,symbol:b?.currencySymbol?.value??n.currency.symbol},country:b?.countryCode?.value??l,channel:re.stringify({salesChannel:b?.channel?.value??o.salesChannel,regionId:A?.regionId?.value??o.regionId,seller:_?.id,hasOnlyDefaultSalesChannel:!b?.channel?.value}),b2b:D?{isRepresentative:D??!1,customerId:C?.customerId?.value??E??"",unitName:C?.unitName?.value??"",unitId:C?.unitId?.value??P??"",firstName:typeof h?.firstName?.value=="string"?h.firstName.value:"",lastName:typeof h?.lastName?.value=="string"?h.lastName.value:"",userName:`${typeof h?.firstName?.value=="string"?h.firstName.value:""} ${typeof h?.lastName?.value=="string"?h.lastName.value:""}`.trim(),userEmail:C?.storeUserEmail.value??"",savedPostalCode:v?.postalCode?.value??"",contractName:U?.corporateName??"",organizationManager:h?.organizationManager?.value??!1}:null,marketingData:S,person:w?.id?{id:w.id?.value??"",email:w.email?.value??"",givenName:w.firstName?.value??"",familyName:w.lastName?.value??""}:null,geoCoordinates:g?.latitude&&g?.longitude&&g||null,city:d};return Oe(n,j)?null:j},yr={validateCart:hr,validateSession:Sr,subscribeToNewsletter:Zt,cancelOrder:Yt,processOrderAuthorization:Kt,uploadFileToOrderEntry:er,startOrderEntryOperation:Qt};var ye;(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"})(ye||(ye={}));const Ir=e=>typeof e=="string"?Dn(e):null;function Dn(e){try{return JSON.parse(e)}catch{return e}}const vr=e=>typeof e=="object"?JSON.stringify(e):typeof e=="string"?e:null,Or=new ee.GraphQLScalarType({name:"ObjectOrString",description:"A string or the string representation of an object (a stringified object).",parseValue:Ir,serialize:vr,parseLiteral(e){return e.kind===ye.STRING?Dn(e.value):null}}),R=e=>"Price"in e&&"seller"in e&&"product"in e,F=e=>"skuName"in e,Cr={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)?Ue(M(e)):F(e)?Ue(Rt(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)?x(e):F(e)?e.sellingPrice/100:null,priceWithTaxes:e=>R(e)?$(x(e),e?.Tax,e.product.unitMultiplier):F(e)?$(e.sellingPrice/100,e.tax/100,e.unitMultiplier):null,sellingPrice:e=>R(e)?Ft(e):F(e)?e.sellingPrice/100:null,listPrice:e=>R(e)?e.ListPrice??0:F(e)?e.listPrice/100:null,listPriceWithTaxes:e=>R(e)?$(e.ListPrice??0,e?.Tax,e.product.unitMultiplier):F(e)?$(e.listPrice/100,e.tax/100,e.unitMultiplier):null,itemOffered:e=>R(e)?e.product:F(e)?{...e.product,attachmentsValues:e.attachments}:null,quantity:e=>R(e)?e.AvailableQuantity??0:F(e)?e.quantity:null,isGift:e=>F(e)?e.isGift??!1:null},br=({linkText:e})=>`/${e}/p`,Dr=({offer:e,seller:n,product:t})=>({...e,product:t,seller:n}),Pr={imageText:"image",imageUrl:"https://storecomponents.vtexassets.com/assets/faststore/images/image___117a6d3e229a96ad0e0d0876352566e2.svg",imageLabel:"label"},Pn=(e,n)=>`${e}-${n}`,wr=(e,n)=>`/${Pn(e,n)}/p`,Ar=e=>Array.isArray(e)&&e.length>0?e:null;function wn(e){return e.replace(/^\/+|\/+$/g,"")}const Er=(e,n)=>{const t=e.findIndex(r=>wn(r).split("/").at(-1)===n);return t<0?0:t},Tr={productID:({itemId:e})=>e,name:({isVariantOf:e,name:n})=>n??e.productName,slug:({isVariantOf:{linkText:e},itemId:n})=>Pn(e,n),description:({isVariantOf:{description:e}})=>e,seo:({isVariantOf:e})=>({title:e.productTitle||e.productName,description:e.metaTagDescription||e.description,canonical:br(e)}),brand:({isVariantOf:{brand:e}})=>({name:e}),unitMultiplier:({unitMultiplier:e})=>e,breadcrumbList:({isVariantOf:{categories:e,productName:n,linkText:t,categoryId:r,categoriesIds:i},itemId:a})=>{const o=Er(i,r),s=e[o],l=wn(s).split("/");return{itemListElement:[...l.map((d,g)=>{const p=`/${l.slice(0,g+1).map(pn).join("/")}/`;return{name:d,item:p,position:g+1}}),{name:n,item:wr(t,a),position:l.length+1}],numberOfItems:l.length}},image:({images:e},n)=>{const t=(Ar(e)??[Pr]).map(({imageUrl:s,imageText:l,imageLabel:d})=>({alternateName:l??"",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=>Dr({offer:n.commertialOffer,seller:n,product:e})).sort(un),isVariantOf:e=>e,additionalProperty:({variations:e=[],attachmentsValues:n=[],attributes:t=[]})=>{const r=e.flatMap(({name:o,values:s})=>s.map(l=>({name:o,value:l,valueReference:Q.specification}))),i=n.map(Sn),a=t.map(nr);return[...r,...i,...a]},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},Ur=new Set(["allSpecifications"]),kr={hasVariant:e=>e.isVariantOf.items.map(n=>B(n,e.isVariantOf)),productGroupID:({isVariantOf:e})=>e.productId,name:e=>e.isVariantOf.productName,skuVariants:e=>e,additionalProperty:({isVariantOf:{specificationGroups:e}})=>e.filter(n=>!Ur.has(n.name)).flatMap(({specifications:n})=>n.flatMap(({name:t,values:r})=>r.map(i=>({name:t,value:i,valueReference:Q.specification}))))},_r={propertyID:e=>e.propertyID||yn(e),name:({name:e})=>e,value:({value:e})=>e,valueReference:({valueReference:e})=>e},Fr=async(e,{operationId:n},{clients:{commerce:t}})=>{if(!n)throw new T("Missing operationId");return t.orderEntry.getOperation({operationId:n})},Rr=async(e,{orderFormId:n},{clients:{commerce:t}})=>{if(!n)throw new T("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}))},Ie=e=>{const n=e.flatMap(r=>r.sellers.map(i=>({offer:i.commertialOffer,sku:r}))),t=me(n,({offer:r},{offer:i})=>un(r,i));return t?t.sku:e[0]},Nr=e=>e!==""&&!Number.isNaN(Number(e)),xe={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:""},An="Invalid SkuId",Lr="Slug was set but the fetched sku does not satisfy the slug condition.",Br=e=>Ce(e)||e instanceof Error&&(e.message===An||e.message.startsWith(Lr)),Mr={product:async(e,{locator:n},t)=>{const r=Le(n),i=Ne(n),a=jt(n),o=qt(n);r&&he(t,r),i&&fe(t,i);const{loaders:{skuLoader:s},clients:{commerce:l,search:d}}=t;try{const g=a??o?.split("-").pop()??"";if(!Nr(g))throw new Error(An);const p=await s.load(g);if(o&&p.isVariantOf.linkText&&!o.startsWith(p.isVariantOf.linkText))throw new Error(`Slug was set but the fetched sku does not satisfy the slug condition. slug: ${o}, linkText: ${p.isVariantOf.linkText}`);return p}catch(g){if(!Br(g))throw g;if(o==null)throw new T("Missing slug or id");const p=await l.catalog.portal.pagetype(`${o}/p`);if(p.pageType!=="Product"||!p.id)throw new L(`No product found for slug ${o}`);const c=await d.fetchProduct({field:"id",value:String(p.id)}).catch(()=>null);if(!c)throw new L(`No product found for id ${p.id}`);const u=Ie(c.items);return B(u,c)}},collection:(e,{slug:n},t)=>{const{loaders:{collectionLoader:r}}=t;return r.load(n)},search:async(e,{first:n,after:t,sort:r,term:i,selectedFacets:a,sponsoredCount:o},s)=>{const l=Le(a),d=Ne(a),g=xt(a);l&&he(s,l),d&&fe(s,d);const p=t?Number(t):0,c={page:Math.ceil(p/n)||0,count:n,query:i??void 0,sort:xe[r??"score_desc"]??xe.score_desc,selectedFacets:a?.flatMap(Fe)??[],sponsoredCount:o??void 0};if(g){const S=(await s.clients.commerce.catalog.products.crossselling({type:mn[g.key],productId:g.value})).map(I=>I.productId).slice(0,n),f=s.clients.search.productsByIdentifier({field:"id",values:S}).then(I=>({products:I,recordsFiltered:I.length,pagination:{count:I.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:c,productSearchPromise:f}}const u=s.clients.search.products(c);return{searchArgs:c,productSearchPromise:u}},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(l=>l.items.map(d=>B(d,l))).filter(l=>l.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((l,d)=>({node:l,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=>B(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()]),l=[],d=(c,u)=>{l.push({...c,level:u});for(const m of c.children)d(m,u+1)};for(const c of s)d(c,0);const p=[...o.filter(c=>c.isActive).map(c=>({...c,type:"brand"})),...l].filter(c=>!!gn.slug(c,null,r,null));return{pageInfo:{hasNextPage:p.length-a>n,hasPreviousPage:a>0,startCursor:"0",endCursor:(Math.min(n,p.length-a)-1).toString(),totalCount:p.length},edges:p.slice(a,a+n).map((c,u)=>({node:c,cursor:(a+u).toString()}))}},shipping:async(e,{country:n,items:t,postalCode:r},i)=>{const{loaders:{simulationLoader:a},clients:{commerce:o}}=i,[s,l]=await Promise.all([a.load({country:n,items:t,postalCode:r}),o.checkout.address({postalCode:r,country:n})]);return{...s,address:l}},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(Fe)??[],allowRedirect:!0});return{url:i}},sellers:async(e,{postalCode:n,geoCoordinates:t,country:r,salesChannel:i},a)=>{const{clients:{commerce:o}}=a,l=(await o.checkout.region({postalCode:n,geoCoordinates:t,country:r,salesChannel:i}))?.[0],{id:d,sellers:g}=l;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(l=>JSON.parse(l))}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 T("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 l=await r.oms.getCommercialAuthorizationsByOrderId({orderId:n});a=hn(l)}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 Ce(r)?new L(`No order found for id ${n}. ${o}.`):rn(r)?new K(`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}},validateUser:async(e,n,t)=>({isValid:!0}),userDetails:async(e,n,t)=>{const{account:r,headers:i,clients:{commerce:a}}=t,s=te(ne(i?.cookie??"",r))?.userId??"",[l,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],c=l?.namespaces.authentication??null,u=`${(p?.firstName??"").trim()} ${(p?.lastName??"").trim()}`.trim();return{username:c?.storeUserEmail?.value??"",name:u,email:c?.storeUserEmail?.value??"",phone:p?.phone??"",role:g?.Roles?.map(m=>m.Name)??[],orgUnit:c?.unitName?.value??""}},accountProfile:async(e,n,t)=>{const{account:r,headers:i,clients:{commerce:a}}=t,o=te(ne(i?.cookie??"",r));if(!o?.userId)return null;if(o?.isRepresentative){const l=await a.session("").catch(()=>null);if(!l)return null;const d=l.namespaces.profile??null;return{name:((await a.masterData.getContractById({contractId:d?.id?.value??""}))?.corporateName??`${(d?.firstName?.value??"").trim()} ${(d?.lastName?.value??"").trim()}`.trim())||"",email:d?.email?.value||"",id:d?.id?.value||""}}const s=await a.licenseManager.getUserById({userId:o?.userId}).catch(()=>null);return{name:s?.name||"",email:s?.email||"",id:s?.id||""}},pickupPoints:async(e,{geoCoordinates:n},t)=>{const{clients:{commerce:r}}=t;return await r.checkout.pickupPoints({geoCoordinates:n})},orderEntryOperation:Fr,orderFormItems:Rr},$r={reviewRating:()=>({ratingValue:5,bestRating:5}),author:()=>({name:""})},zr=(e,n,t)=>n?e.key==="category-1":t?e.key==="brand":!1,Vr={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]),l=s.products.map(g=>{const p=Ie(g.items);return p&&B(p,g)}).filter(g=>!!g),{searches:d}=o;return{terms:d.map(g=>({value:g.term,count:g.count})),products:l}},products:async({productSearchPromise:e})=>{const n=await e,t=n.products.map(r=>{const i=Ie(r.items);return i&&B(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||!zr(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},xr={title:({title:e})=>e??"",description:({description:e})=>e??"",canonical:({canonical:e})=>e??"",titleTemplate:()=>""},qr=["bd","d","h","m"],jr=e=>qr.includes(e),Wr={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"}},En=e=>{const[n,t]=[e.split(/\D+/)[0],e.split(/[0-9]+/)[1]],r=n!==""&&!Number.isNaN(Number(n)),i=jr(t);if(!r||!i)return"";const a=Number(n)<2?Number(n):"other";return Wr[t][a].replace("#",n)??""},Gr={carrier:e=>e?.friendlyName??e?.name??"",price:e=>e?.price?e.price/100:e?.price,localizedEstimates:e=>e?.shippingEstimate?En(e.shippingEstimate):""},qe="skuvariation";function je(e,n){const t=`${qe}${n}`.toLowerCase(),r=e.find(a=>a.imageLabel===t);if(r)return r;const i=e.find(a=>a.imageLabel===qe);return i||e[0]}function Hr(e,n,t){const r={};return e.forEach(i=>{const a=i.variations;if(a.length===0)return;const o=`${n}-${a.find(l=>l.name===n)?.values[0]??""}`,s=a.reduce((l,d)=>d.name===n?l:l+`-${d.name}-${d.values[0]}`,o);r[s]=`${t}-${i.itemId}`}),r}function We(e){const n={};return e.forEach(t=>{n[t.name]=t.values[0]}),n}function Xr(e){const n={};return e?.forEach(t=>{n[t.field.originalName??t.field.name]=t.values.map(r=>r.originalName??r.name)}),n}function Yr(e,n){return Number.isNaN(Number(e)-Number(n))?e<n?-1:e>n?1:0:Number(e)-Number(n)}function Jr(e){const n=e;for(const t in e)e[t].every(i=>!Number.isNaN(Number(i.value)))&&e[t].sort((i,a)=>Yr(i.value,a.value));return n}function Kr(e,n,t){const r={},i=new Set;return e.forEach(a=>{if(a.variations.length===0)return;const o=a.variations.find(l=>l.name===n);if(!(o?.values[0]===t)){const l=`${n}-${o?.values[0]}`;if(!o||i.has(l))return;i.add(l);const d=je(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(l=>{const d=`${l.name}-${l.values[0]}`;if(i.has(d))return;i.add(d);const g=je(a.images,l.name),p={src:g.imageUrl,alt:g.imageText??"",label:`${l.name}: ${l.values[0]}`,value:l.values[0]};r[l.name]?r[l.name].push(p):r[l.name]=[p]})}),Jr(r)}const Qr={activeVariations:e=>We(e.variations),allVariantsByName:e=>Xr(e.isVariantOf.skuSpecifications),slugsMap:(e,n)=>Hr(e.isVariantOf.items,n.dominantVariantName??e.variations[0]?.name,e.isVariantOf.linkText),availableVariations:(e,n)=>{const t=n.dominantVariantName??e.variations[0]?.name,i=We(e.variations)[t];return Kr(e.isVariantOf.items,t,i)},allVariantProducts:e=>e.isVariantOf.items.map(n=>B(n,e.isVariantOf))},Zr={"pickup-in-point":"Pickup",delivery:"Delivery",pickup:"Pickup","take-away":"Take away","":""},ei={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||"",c=g?.selectedDeliveryChannel||g?.deliveryChannel||"",u=g?.deliveryCompany||"",m=g?.deliveryWindow,S=g?.pickupStoreInfo,f=g?.shippingEstimate||"",I=g?.shippingEstimate?En(g?.shippingEstimate):"",D=g?.shippingEstimateDate||"",E=g?.addressId||"",P=g?.itemIndex??0,O=t?.[P],w=O?.seller||"",h=`${p}|${c}|${u}|${w}|${f}|${D}|${E}|${m?.startDateUtc}|${m?.endDateUtc}`,b=i?.find(_=>_?.addressId===E),C=`${Zr[c]||""} ${I} ${b?.neighborhood?`to ${b?.neighborhood}`:""}`.trim(),{taxPriceTagsTotal:A,taxPriceTags:v}=ni(O?.priceTags??[]),U=(O?.sellingPrice??0)*(O?.quantity??0)+(O?.tax??0)+(A??0);return d[h]||(d[h]={selectedSla:p,deliveryChannel:c,deliveryCompany:u,deliveryWindow:m,shippingEstimate:f,shippingEstimateDate:D,seller:w,friendlyShippingEstimate:I,friendlyDeliveryOptionName:C,address:b,pickupStoreInfo:S,quantityOfDifferentItems:0,total:0,items:[]}),d[h]&&(d[h].items?.push({id:O?.id||"",uniqueId:O?.uniqueId||"",name:O?.name||"",quantity:O?.quantity||0,price:O?.price||0,sellingPrice:O?.sellingPrice||0,imageUrl:O?.imageUrl||"",taxPriceTags:v??[],taxPriceTagsTotal:A??0,tax:O?.tax||0,total:U}),d[h].quantityOfDifferentItems=(d[h].quantityOfDifferentItems??0)+1,d[h].total=(d[h].total??0)+U),d},{}),o=Object.values(a),s=n?.contactInformation?.[0],l={name:`${s?.firstName??""} ${s?.lastName??""}`.trim()||o?.[0]?.address?.receiverName||"",email:s?.email||"",phone:s?.phone||""};return{deliveryOptions:o,contact:l}},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 ni(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 ti={StoreCollection:gn,StoreAggregateOffer:Lt,StoreProduct:Tr,StoreSeo:xr,StoreFacet:Wt,StoreFacetBoolean:Gt,StoreFacetRange:Ht,StoreFacetValueBoolean:Xt,StoreOffer:Cr,StoreAggregateRating:Bt,StoreReview:$r,StoreProductGroup:kr,StoreSearchResult:Vr,StorePropertyValue:_r,SkuVariants:Qr,ShippingSLA:Gr,UserOrderResult:ei,ObjectOrString:Or,Query:Mr,Mutation:yr},ri=()=>ti,ii=`"""
|
|
5
|
+
More info at: https://developers.vtex.com/vtex-rest-api/docs/customizable-fields-with-checkout-api`),r}},Ir=(e,n)=>{const r=e.customData?.customApps.find(a=>a.id==="faststore")?.fields?.cartEtag;return r==null?!0:bn(e,n)!==r},vr=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}=In(e,n);if(r){const a=dr(e,n,i),s=a||lr(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},Or=(e,n)=>{if(!e)return"";const r=Z.parse(e)[n];return r?r.split("=")[1]:""},Cr=async(e,{cart:{order:n},session:t},r)=>{const i=Or(r.headers.cookie,"checkout.vtex.com"),{clients:{commerce:a},loaders:{skuLoader:o}}=r,s=t?.channel,c=t?.locale;s&&Se(r,s),c&&ye(r,c);const l=await a.checkout.orderForm({id:i||void 0,channel:r.storage.channel}),p=l.orderFormId;l.messages.length!==0&&await vr(p,r);const u=Z.parse(r?.headers?.cookie??"")?.vtex_session,h=Q(u),{acceptedOffer:S,shouldSplitItem:b}=n;if(Ir(l,h)){const O=await xe(l,a,h).then($e);if(p)return ze(O,o,b)}const g=Me(S),m=Me(l.items.map(ie)),y=Array.from(m.entries()),C=Array.from(g.entries()),{itemsToAdd:w,itemsToUpdate:v}=C.reduce((O,[T,_])=>{const G=m.get(T);if(!G)return _.forEach(H=>O.itemsToAdd.push(H)),O;const[R,...we]=G;if(Cn(l.items,R.itemOffered.sku)||On(l.items,R.itemOffered.sku))return O.itemsToUpdate.push(R),O;const se=_.reduce((H,_n)=>H+_n.quantity,0);return O.itemsToUpdate.push({...R,quantity:se}),we.forEach(H=>O.itemsToUpdate.push({...H,quantity:0})),O},{itemsToAdd:[],itemsToUpdate:[]}),P=y.filter(([O])=>!g.has(O)).flatMap(([,O])=>O.map(T=>({...T,quantity:0}))),f=[...w,...v,...P].map(Sr),{updateShipping:D}=t?In(l,t):{updateShipping:!1};if(f.length===0&&!D)return null;let A;f.length>0?A=await a.checkout.updateOrderFormItems({id:l.orderFormId,orderItems:f,shouldSplitItem:b}).then(O=>qe(O,t,r)):A=await qe(l,t,r),A=await Promise.resolve(A).then(O=>{if(t?.marketingData){const T={...O.marketingData,...t.marketingData};return a.checkout.marketingData({id:l.orderFormId,marketingData:T})}return O}).then(O=>c&&O.clientPreferencesData?.locale!==c?a.checkout.clientPreferencesData({id:O.orderFormId,clientPreferencesData:{...O.clientPreferencesData,locale:c}}):O).then(O=>xe(O,a,h)).then($e);const U=Ce(l.messages,A.messages);return yr(n,A)&&U?null:ze(A,o,b)},br=e=>{const n=(e?.corporateName??"").trim();return n||(e?.firstName??"").trim()},wr=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"},Dr=e=>{const n=e?.availableContracts?.value;return Array.isArray(n)?n.filter(wr):[]},Ar=e=>e?.customerId?!!((e.contractName??"").trim()&&e.isActive):!1,Pr=e=>e?.namespaces?.shopper?.activeContractId?.value?.trim()??e?.namespaces?.authentication?.customerId?.value?.trim()??e?.namespaces?.profile?.id?.value?.trim()??"",Er=(e,n="")=>{const t=n.trim();return e.filter(Ar).map(r=>({id:r.customerId,corporateName:r.contractName.trim(),isActive:t?r.customerId===t:r.isCurrent}))},wn=(e,n)=>{const t=br(e);return t||(n?.firstName?.value??"").trim()};async function Ur(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}).
|
|
6
|
+
`),r}}const Tr=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 l=n.city??null,p=n.geoCoordinates??null;if((!l||!p)&&s!==""&&c!==""){const R=await Ur(r,c,s);l=R.city,p=R.geoCoordinates}const h=new URLSearchParams(t);h.has("facets")&&h.delete("facets");const S=h.get("sc")??o.salesChannel;h.set("sc",S),s&&h.set("postalCode",s),c&&h.set("country",c),p&&h.set("geoCoordinates",`${p.longitude},${p.latitude}`),h.set("locale",n.locale);const{marketingData:b}=n,d={utmCampaign:h.get("utm_campaign")??b?.utmCampaign??"",utmMedium:h.get("utm_medium")??b?.utmMedium??"",utmSource:h.get("utm_source")??b?.utmSource??"",utmiCampaign:h.get("utmi_cp")??b?.utmiCampaign??"",utmiPage:h.get("utmi_p")??b?.utmiPage??"",utmiPart:h.get("utmi_pc")??b?.utmiPart??""},g=Q(x(i?.cookie??"",a));let m=!1;if(g)try{m=(await r.commerce.vtexid.validate())?.authStatus?.toLowerCase()==="success"}catch(R){console.warn("JWT validation failed:",R),m=!1}const y=m?g?.isRepresentative:!1,C=m?g?.customerId:void 0,w=m?g?.unitId:void 0,v=await r.commerce.session(h.toString()).catch(()=>null),P=v?.namespaces.profile??null,f=v?.namespaces.shopper??null,D=v?.namespaces.store??null,A=v?.namespaces.authentication??null,U=v?.namespaces.checkout??null,O=v?.namespaces.public??null;let T=null;if(y&&P?.id?.value)try{T=await r.commerce.masterData.getContractById({contractId:P.id.value})}catch{console.error(`Error while getting contract data for profile ID (${P.id.value}).
|
|
7
|
+
`)}let _;o.seller&&(s||p)&&(_=(await r.commerce.checkout.region({postalCode:s,geoCoordinates:p,country:c,salesChannel:S}))?.[0]?.sellers.find(se=>o.seller===se.id));const G={...n,currency:{code:D?.currencyCode?.value??n.currency.code,symbol:D?.currencySymbol?.value??n.currency.symbol},country:D?.countryCode?.value??c,channel:re.stringify({salesChannel:D?.channel?.value??o.salesChannel,regionId:U?.regionId?.value??o.regionId,seller:_?.id,hasOnlyDefaultSalesChannel:!D?.channel?.value}),b2b:y?{isRepresentative:y??!1,customerId:A?.customerId?.value??C??"",unitName:A?.unitName?.value??"",unitId:A?.unitId?.value??w??"",firstName:typeof f?.firstName?.value=="string"?f.firstName.value:"",lastName:typeof f?.lastName?.value=="string"?f.lastName.value:"",userName:`${typeof f?.firstName?.value=="string"?f.firstName.value:""} ${typeof f?.lastName?.value=="string"?f.lastName.value:""}`.trim(),userEmail:A?.storeUserEmail.value??"",savedPostalCode:O?.postalCode?.value??"",contractName:wn(T,P),organizationManager:f?.organizationManager?.value??!1}:null,marketingData:d,person:P?.id?{id:P.id?.value??"",email:P.email?.value??"",givenName:P.firstName?.value??"",familyName:P.lastName?.value??""}:null,geoCoordinates:p?.latitude&&p?.longitude&&p||null,city:l};return Ce(n,G)?null:G},_r={validateCart:Cr,validateSession:Tr,subscribeToNewsletter:or,cancelOrder:nr,processOrderAuthorization:rr,uploadFileToOrderEntry:sr,startOrderEntryOperation:ir,startRecommendationSession:ar};var ve;(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"})(ve||(ve={}));const Rr=e=>typeof e=="string"?Dn(e):null;function Dn(e){try{return JSON.parse(e)}catch{return e}}const kr=e=>typeof e=="object"?JSON.stringify(e):typeof e=="string"?e:null,Fr=new te.GraphQLScalarType({name:"ObjectOrString",description:"A string or the string representation of an object (a stringified object).",parseValue:Rr,serialize:kr,parseLiteral(e){return e.kind===ve.STRING?Dn(e.value):null}}),F=e=>"Price"in e&&"seller"in e&&"product"in e,k=e=>"skuName"in e,Nr={priceCurrency:async(e,n,t)=>{const{loaders:{salesChannelLoader:r},storage:{channel:i}}=t;return(await r.load(i.salesChannel)).CurrencyCode??""},priceValidUntil:e=>F(e)?e.PriceValidUntil??"":k(e)?e.priceValidUntil??"":null,itemCondition:()=>"https://schema.org/NewCondition",availability:async e=>F(e)?_e(M(e)):k(e)?_e(zt(e.availability)):null,seller:(e,n,t)=>F(e)?{identifier:t.storage.channel?.seller||e.seller.sellerId||""}:k(e)?{identifier:e.seller}:null,price:e=>F(e)?j(e):k(e)?e.sellingPrice/100:null,priceWithTaxes:e=>F(e)?$(j(e),e?.Tax,e.product.unitMultiplier):k(e)?$(e.sellingPrice/100,e.tax/100,e.unitMultiplier):null,sellingPrice:e=>F(e)?$t(e):k(e)?e.sellingPrice/100:null,listPrice:e=>F(e)?e.ListPrice??0:k(e)?e.listPrice/100:null,listPriceWithTaxes:e=>F(e)?$(e.ListPrice??0,e?.Tax,e.product.unitMultiplier):k(e)?$(e.listPrice/100,e.tax/100,e.unitMultiplier):null,itemOffered:e=>F(e)?e.product:k(e)?{...e.product,attachmentsValues:e.attachments}:null,quantity:e=>F(e)?e.AvailableQuantity??0:k(e)?e.quantity:null,isGift:e=>k(e)?e.isGift??!1:null},Lr=({linkText:e})=>`/${e}/p`,Br=({offer:e,seller:n,product:t})=>({...e,product:t,seller:n}),Mr={imageText:"image",imageUrl:"https://storecomponents.vtexassets.com/assets/faststore/images/image___117a6d3e229a96ad0e0d0876352566e2.svg",imageLabel:"label"},An=(e,n)=>`${e}-${n}`,$r=(e,n)=>`/${An(e,n)}/p`,zr=e=>Array.isArray(e)&&e.length>0?e:null;function Pn(e){return e.replace(/^\/+|\/+$/g,"")}const xr=(e,n)=>{const t=e.findIndex(r=>Pn(r).split("/").at(-1)===n);return t<0?0:t},qr={productID:({itemId:e})=>e,name:({isVariantOf:e,name:n})=>n??e.productName,slug:({isVariantOf:{linkText:e},itemId:n})=>An(e,n),description:({isVariantOf:{description:e}})=>e,seo:({isVariantOf:e})=>({title:e.productTitle||e.productName,description:e.metaTagDescription||e.description,canonical:Lr(e)}),brand:({isVariantOf:{brand:e}})=>({name:e}),unitMultiplier:({unitMultiplier:e})=>e,breadcrumbList:({isVariantOf:{categories:e,productName:n,linkText:t,categoryId:r,categoriesIds:i},itemId:a})=>{const o=xr(i,r),s=e[o],c=Pn(s).split("/");return{itemListElement:[...c.map((l,p)=>{const u=`/${c.slice(0,p+1).map(pn).join("/")}/`;return{name:l,item:u,position:p+1}}),{name:n,item:$r(t,a),position:c.length+1}],numberOfItems:c.length}},image:({images:e},n)=>{const t=(zr(e)??[Mr]).map(({imageUrl:s,imageText:c,imageLabel:l})=>({alternateName:c??"",url:s.replace("vteximg.com.br","vtexassets.com"),keywords:l}));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=>Br({offer:n.commertialOffer,seller:n,product:e})).sort(un),isVariantOf:e=>e,additionalProperty:({variations:e=[],attachmentsValues:n=[],attributes:t=[]})=>{const r=e.flatMap(({name:o,values:s})=>s.map(c=>({name:o,value:c,valueReference:ee.specification}))),i=n.map(Sn),a=t.map(cr);return[...r,...i,...a]},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},Vr=new Set(["allSpecifications"]),jr={hasVariant:e=>e.isVariantOf.items.map(n=>N(n,e.isVariantOf)),productGroupID:({isVariantOf:e})=>e.productId,name:e=>e.isVariantOf.productName,skuVariants:e=>e,additionalProperty:({isVariantOf:{specificationGroups:e}})=>e.filter(n=>!Vr.has(n.name)).flatMap(({specifications:n})=>n.flatMap(({name:t,values:r})=>r.map(i=>({name:t,value:i,valueReference:ee.specification}))))},Wr={propertyID:e=>e.propertyID||yn(e),name:({name:e})=>e,value:({value:e})=>e,valueReference:({valueReference:e})=>e},Gr=async(e,{operationId:n},{clients:{commerce:t}})=>{if(!n)throw new E("Missing operationId");return t.orderEntry.getOperation({operationId:n})},Hr=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}))},ae=e=>{const n=e.flatMap(r=>r.sellers.map(i=>({offer:i.commertialOffer,sku:r}))),t=fe(n,({offer:r},{offer:i})=>un(r,i));return t?t.sku:e[0]},Xr=e=>e!==""&&!Number.isNaN(Number(e)),Yr=/^vrn:recommendations:[^:]+:[^:]+:[^:]+$/,Jr=async(e,{campaignVrn:n,userId:t,products:r},i)=>{const{clients:{commerce:a}}=i,{salesChannel:o}=i.storage.channel,s=n?.trim();if(!s||!Yr.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(S=>!S?.trim())))throw new E("Invalid products: must be an array of non-empty strings");const l=await a.recommendation.recommendations({campaignVrn:s,userId:c||void 0,products:r??[],salesChannel:o??void 0,locale:i.storage.locale}),{campaign:p,correlationId:u}=l;return{products:(l.products??[]).map(S=>{const b=ae(S.items);return b?N(b,S):null}).filter(S=>!!S),correlationId:u,campaign:p}},Ve={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:""},En="Invalid SkuId",Kr="Slug was set but the fetched sku does not satisfy the slug condition.",Qr=e=>be(e)||e instanceof Error&&(e.message===En||e.message.startsWith(Kr)),Zr={product:async(e,{locator:n},t)=>{const r=Be(n),i=Le(n),a=Jt(n),o=Yt(n);r&&Se(t,r),i&&ye(t,i);const{loaders:{skuLoader:s},clients:{commerce:c,search:l}}=t;try{const p=a??o?.split("-").pop()??"";if(!Xr(p))throw new Error(En);const u=await s.load(p);if(o&&u.isVariantOf.linkText&&!o.startsWith(u.isVariantOf.linkText))throw new Error(`Slug was set but the fetched sku does not satisfy the slug condition. slug: ${o}, linkText: ${u.isVariantOf.linkText}`);return u}catch(p){if(!Qr(p))throw p;if(o==null)throw new E("Missing slug or id");const u=await c.catalog.portal.pagetype(`${o}/p`);if(u.pageType!=="Product"||!u.id)throw new B(`No product found for slug ${o}`);const h=await l.fetchProduct({field:"id",value:String(u.id)}).catch(()=>null);if(!h)throw new B(`No product found for id ${u.id}`);const S=ae(h.items);return N(S,h)}},collection:(e,{slug:n},t)=>{const{loaders:{collectionLoader:r}}=t;return r.load(n)},search:async(e,{first:n,after:t,sort:r,term:i,selectedFacets:a,sponsoredCount:o},s)=>{const c=Be(a),l=Le(a),p=Xt(a);c&&Se(s,c),l&&ye(s,l);const u=t?Number(t):0,h={page:Math.ceil(u/n)||0,count:n,query:i??void 0,sort:Ve[r??"score_desc"]??Ve.score_desc,selectedFacets:a?.flatMap(Fe)??[],sponsoredCount:o??void 0};if(p){const d=(await s.clients.commerce.catalog.products.crossselling({type:mn[p.key],productId:p.value})).map(m=>m.productId).slice(0,n),g=s.clients.search.productsByIdentifier({field:"id",values:d}).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:h,productSearchPromise:g}}const S=s.clients.search.products(h);return{searchArgs:h,productSearchPromise:S}},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(l=>N(l,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,l)=>({node:c,cursor:(a+l).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=>N(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=[],l=(h,S)=>{c.push({...h,level:S});for(const b of h.children)l(b,S+1)};for(const h of s)l(h,0);const u=[...o.filter(h=>h.isActive).map(h=>({...h,type:"brand"})),...c].filter(h=>!!gn.slug(h,null,r,null));return{pageInfo:{hasNextPage:u.length-a>n,hasPreviousPage:a>0,startCursor:"0",endCursor:(Math.min(n,u.length-a)-1).toString(),totalCount:u.length},edges:u.slice(a,a+n).map((h,S)=>({node:h,cursor:(a+S).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(Fe)??[],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:l,sellers:p}=c;return{id:l,sellers:p}},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 B(`No order found for id ${n}`);let a=null;try{const c=await r.oms.getCommercialAuthorizationsByOrderId({orderId:n});a=hn(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 be(r)?new B(`No order found for id ${n}. ${o}.`):an(r)?new q(`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}},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[l]=await r.masterData.getShopperById({userId:c});if(l){const p=[l.firstName,l.lastName].filter(Boolean).join(" ");p&&o.set(c,p)}}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(x(i?.cookie??"",r))?.userId??"",[c,l,p]=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)]),u=l?.[0],h=c?.namespaces.authentication??null,S=`${(u?.firstName??"").trim()} ${(u?.lastName??"").trim()}`.trim();return{username:h?.storeUserEmail?.value??"",name:S,email:h?.storeUserEmail?.value??"",phone:u?.phone??"",role:p?.Roles?.map(b=>b.Name)??[],orgUnit:h?.unitName?.value??""}},accountProfile:async(e,n,t)=>{const{account:r,headers:i,clients:{commerce:a}}=t,o=Q(x(i?.cookie??"",r));if(!o?.userId)return null;if(o?.isRepresentative){const c=await a.session("").catch(()=>null);if(!c)return null;const l=c.namespaces.profile??null,p=await a.masterData.getContractById({contractId:l?.id?.value??""});return{name:wn(p,l)||"",email:l?.email?.value||"",id:l?.id?.value||""}}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=x(i?.cookie??"",r);let c=null;try{c=s?Q(s):null}catch{c=null}const l=o?.namespaces.authentication?.unitId?.value?.trim()??c?.unitId?.trim()??"";if(!l||l!==n)throw new q("You are not allowed to list contracts for this organization unit");const p=Dr(o?.namespaces.shopper),u=Pr(o)||c?.customerId?.trim()||"";return Er(p,u)},pickupPoints:async(e,{geoCoordinates:n},t)=>{const{clients:{commerce:r}}=t;return await r.checkout.pickupPoints({geoCoordinates:n})},orderEntryOperation:Gr,orderFormItems:Hr,recommendations:Jr},ei={reviewRating:()=>({ratingValue:5,bestRating:5}),author:()=>({name:""})},ni=(e,n,t)=>n?e.key==="category-1":t?e.key==="brand":!1,ti={suggestions:async(e,n,t)=>{const{clients:{search:r}}=t,{searchArgs:i}=e;if(!i.query)return{terms:(await r.topSearches()).searches.map(u=>({value:u.term,count:u.count})),products:[]};const{productSearchPromise:a}=e,[o,s]=await Promise.all([r.suggestedTerms(i),a]),c=s.products.map(p=>{const u=ae(p.items);return u&&N(u,p)}).filter(p=>!!p),{searches:l}=o;return{terms:l.map(p=>({value:p.term,count:p.count})),products:c}},products:async({productSearchPromise:e})=>{const n=await e,t=n.products.map(r=>{const i=ae(r.items);return i&&N(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(l=>!a||!ni(l,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},ri={title:({title:e})=>e??"",description:({description:e})=>e??"",canonical:({canonical:e})=>e??"",titleTemplate:()=>""},ii=["bd","d","h","m"],ai=e=>ii.includes(e),oi={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"}},Un=e=>{const[n,t]=[e.split(/\D+/)[0],e.split(/[0-9]+/)[1]],r=n!==""&&!Number.isNaN(Number(n)),i=ai(t);if(!r||!i)return"";const a=Number(n)<2?Number(n):"other";return oi[t][a].replace("#",n)??""},si={carrier:e=>e?.friendlyName??e?.name??"",price:e=>e?.price?e.price/100:e?.price,localizedEstimates:e=>e?.shippingEstimate?Un(e.shippingEstimate):""},je="skuvariation";function We(e,n){const t=`${je}${n}`.toLowerCase(),r=e.find(a=>a.imageLabel===t);if(r)return r;const i=e.find(a=>a.imageLabel===je);return i||e[0]}function ci(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,l)=>l.name===n?c:c+`-${l.name}-${l.values[0]}`,o);r[s]=`${t}-${i.itemId}`}),r}function Ge(e){const n={};return e.forEach(t=>{n[t.name]=t.values[0]}),n}function li(e){const n={};return e?.forEach(t=>{n[t.field.originalName??t.field.name]=t.values.map(r=>r.originalName??r.name)}),n}function di(e,n){return Number.isNaN(Number(e)-Number(n))?e<n?-1:e>n?1:0:Number(e)-Number(n)}function ui(e){const n=e;for(const t in e)e[t].every(i=>!Number.isNaN(Number(i.value)))&&e[t].sort((i,a)=>di(i.value,a.value));return n}function pi(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 l=We(a.images,n),p={src:l.imageUrl,alt:l.imageLabel??"",label:`${n}: ${o.values[0]}`,value:o.values[0]};r[o.name]?r[o.name].push(p):r[o.name]=[p];return}a.variations.forEach(c=>{const l=`${c.name}-${c.values[0]}`;if(i.has(l))return;i.add(l);const p=We(a.images,c.name),u={src:p.imageUrl,alt:p.imageText??"",label:`${c.name}: ${c.values[0]}`,value:c.values[0]};r[c.name]?r[c.name].push(u):r[c.name]=[u]})}),ui(r)}const gi={activeVariations:e=>Ge(e.variations),allVariantsByName:e=>li(e.isVariantOf.skuSpecifications),slugsMap:(e,n)=>ci(e.isVariantOf.items,n.dominantVariantName??e.variations[0]?.name,e.isVariantOf.linkText),availableVariations:(e,n)=>{const t=n.dominantVariantName??e.variations[0]?.name,i=Ge(e.variations)[t];return pi(e.isVariantOf.items,t,i)},allVariantProducts:e=>e.isVariantOf.items.map(n=>N(n,e.isVariantOf))},mi={"pickup-in-point":"Pickup",delivery:"Delivery",pickup:"Pickup","take-away":"Take away","":""},hi={deliveryOptionsData:e=>{const{shippingData:n,items:t}=e,r=n?.logisticsInfo||[],i=n?.selectedAddresses||n?.availableAddresses||[n?.address],a=r.reduce((l,p)=>{const u=p?.selectedSla||"",h=p?.selectedDeliveryChannel||p?.deliveryChannel||"",S=p?.deliveryCompany||"",b=p?.deliveryWindow,d=p?.pickupStoreInfo,g=p?.shippingEstimate||"",m=p?.shippingEstimate?Un(p?.shippingEstimate):"",y=p?.shippingEstimateDate||"",C=p?.addressId||"",w=p?.itemIndex??0,v=t?.[w],P=v?.seller||"",f=`${u}|${h}|${S}|${P}|${g}|${y}|${C}|${b?.startDateUtc}|${b?.endDateUtc}`,D=i?.find(_=>_?.addressId===C),A=`${mi[h]||""} ${m} ${D?.neighborhood?`to ${D?.neighborhood}`:""}`.trim(),{taxPriceTagsTotal:U,taxPriceTags:O}=fi(v?.priceTags??[]),T=(v?.sellingPrice??0)*(v?.quantity??0)+(v?.tax??0)+(U??0);return l[f]||(l[f]={selectedSla:u,deliveryChannel:h,deliveryCompany:S,deliveryWindow:b,shippingEstimate:g,shippingEstimateDate:y,seller:P,friendlyShippingEstimate:m,friendlyDeliveryOptionName:A,address:D,pickupStoreInfo:d,quantityOfDifferentItems:0,total:0,items:[]}),l[f]&&(l[f].items?.push({id:v?.id||"",uniqueId:v?.uniqueId||"",name:v?.name||"",quantity:v?.quantity||0,price:v?.price||0,sellingPrice:v?.sellingPrice||0,imageUrl:v?.imageUrl||"",taxPriceTags:O??[],taxPriceTagsTotal:U??0,tax:v?.tax||0,total:T}),l[f].quantityOfDifferentItems=(l[f].quantityOfDifferentItems??0)+1,l[f].total=(l[f].total??0)+T),l},{}),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 fi(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 Si={StoreCollection:gn,StoreAggregateOffer:qt,StoreProduct:qr,StoreSeo:ri,StoreFacet:Kt,StoreFacetBoolean:Qt,StoreFacetRange:Zt,StoreFacetValueBoolean:er,StoreOffer:Nr,StoreAggregateRating:Vt,StoreReview:ei,StoreProductGroup:jr,StoreSearchResult:ti,StorePropertyValue:Wr,SkuVariants:gi,ShippingSLA:si,UserOrderResult:hi,ObjectOrString:Fr,Query:Zr,Mutation:_r},yi=()=>Si,Ii=`"""
|
|
8
8
|
Address information.
|
|
9
9
|
"""
|
|
10
10
|
type Address {
|
|
@@ -49,7 +49,7 @@ type Address {
|
|
|
49
49
|
"""
|
|
50
50
|
geoCoordinates: [Float]
|
|
51
51
|
}
|
|
52
|
-
`,
|
|
52
|
+
`,vi=`"""
|
|
53
53
|
Advertisement information about a specific product in a campaign
|
|
54
54
|
"""
|
|
55
55
|
type Advertisement {
|
|
@@ -74,7 +74,7 @@ type Advertisement {
|
|
|
74
74
|
"""
|
|
75
75
|
adResponseId: String!
|
|
76
76
|
}
|
|
77
|
-
`,
|
|
77
|
+
`,Oi=`"""
|
|
78
78
|
Aggregate offer information, for a given SKU that is available to be fulfilled by multiple sellers.
|
|
79
79
|
"""
|
|
80
80
|
type StoreAggregateOffer {
|
|
@@ -103,7 +103,7 @@ type StoreAggregateOffer {
|
|
|
103
103
|
"""
|
|
104
104
|
offers: [StoreOffer!]!
|
|
105
105
|
}
|
|
106
|
-
`,
|
|
106
|
+
`,Ci=`"""
|
|
107
107
|
Average rating, based on multiple ratings or reviews.
|
|
108
108
|
"""
|
|
109
109
|
type StoreAggregateRating {
|
|
@@ -116,7 +116,7 @@ type StoreAggregateRating {
|
|
|
116
116
|
"""
|
|
117
117
|
reviewCount: Int!
|
|
118
118
|
}
|
|
119
|
-
`,
|
|
119
|
+
`,bi=`"""
|
|
120
120
|
information about the author of a product review or rating.
|
|
121
121
|
"""
|
|
122
122
|
type StoreAuthor {
|
|
@@ -125,7 +125,7 @@ type StoreAuthor {
|
|
|
125
125
|
"""
|
|
126
126
|
name: String!
|
|
127
127
|
}
|
|
128
|
-
`,
|
|
128
|
+
`,wi=`"""
|
|
129
129
|
Brand of a given product.
|
|
130
130
|
"""
|
|
131
131
|
type StoreBrand {
|
|
@@ -134,7 +134,7 @@ type StoreBrand {
|
|
|
134
134
|
"""
|
|
135
135
|
name: String!
|
|
136
136
|
}
|
|
137
|
-
`,
|
|
137
|
+
`,Di=`"""
|
|
138
138
|
Item of a list.
|
|
139
139
|
"""
|
|
140
140
|
type StoreListItem {
|
|
@@ -165,7 +165,7 @@ type StoreBreadcrumbList {
|
|
|
165
165
|
"""
|
|
166
166
|
numberOfItems: Int!
|
|
167
167
|
}
|
|
168
|
-
`,
|
|
168
|
+
`,Ai=`"""
|
|
169
169
|
Shopping cart message.
|
|
170
170
|
"""
|
|
171
171
|
type StoreCartMessage {
|
|
@@ -202,7 +202,7 @@ input IStoreCart {
|
|
|
202
202
|
"""
|
|
203
203
|
order: IStoreOrder!
|
|
204
204
|
}
|
|
205
|
-
`,
|
|
205
|
+
`,Pi=`"""
|
|
206
206
|
Product collection type. Possible values are \`Department\`, \`Category\`, \`Brand\`, \`Cluster\`, \`SubCategory\` or \`Collection\`.
|
|
207
207
|
"""
|
|
208
208
|
enum StoreCollectionType {
|
|
@@ -285,7 +285,7 @@ type StoreCollection {
|
|
|
285
285
|
"""
|
|
286
286
|
type: StoreCollectionType!
|
|
287
287
|
}
|
|
288
|
-
`,
|
|
288
|
+
`,Ei=`"""
|
|
289
289
|
Delivery Promise badge.
|
|
290
290
|
"""
|
|
291
291
|
type DeliveryPromiseBadge {
|
|
@@ -294,7 +294,7 @@ type DeliveryPromiseBadge {
|
|
|
294
294
|
"""
|
|
295
295
|
typeName: String
|
|
296
296
|
}
|
|
297
|
-
`,
|
|
297
|
+
`,Ui=`union StoreFacet = StoreFacetRange | StoreFacetBoolean
|
|
298
298
|
|
|
299
299
|
"""
|
|
300
300
|
Search facet range information.
|
|
@@ -371,7 +371,7 @@ type StoreFacetValueBoolean {
|
|
|
371
371
|
"""
|
|
372
372
|
quantity: Int
|
|
373
373
|
}
|
|
374
|
-
`,
|
|
374
|
+
`,Ti=`"""
|
|
375
375
|
Image.
|
|
376
376
|
"""
|
|
377
377
|
type StoreImage {
|
|
@@ -398,7 +398,7 @@ input IStoreImage {
|
|
|
398
398
|
"""
|
|
399
399
|
alternateName: String!
|
|
400
400
|
}
|
|
401
|
-
`,
|
|
401
|
+
`,_i=`type Mutation {
|
|
402
402
|
"""
|
|
403
403
|
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\`.
|
|
404
404
|
"""
|
|
@@ -435,8 +435,12 @@ input IStoreImage {
|
|
|
435
435
|
startOrderEntryOperation(
|
|
436
436
|
data: IOrderEntryOperation!
|
|
437
437
|
): StoreOrderEntryOperationResult @auth
|
|
438
|
+
"""
|
|
439
|
+
Starts an anonymous personalization session for the current shopper.
|
|
440
|
+
"""
|
|
441
|
+
startRecommendationSession: Boolean!
|
|
438
442
|
}
|
|
439
|
-
`,
|
|
443
|
+
`,Ri=`"""
|
|
440
444
|
Newsletter information.
|
|
441
445
|
"""
|
|
442
446
|
type PersonNewsletter {
|
|
@@ -459,8 +463,8 @@ input IPersonNewsletter {
|
|
|
459
463
|
"""
|
|
460
464
|
email: String!
|
|
461
465
|
}
|
|
462
|
-
`,
|
|
463
|
-
`,
|
|
466
|
+
`,ki=`scalar ObjectOrString
|
|
467
|
+
`,Fi=`"""
|
|
464
468
|
Offer information.
|
|
465
469
|
"""
|
|
466
470
|
type StoreOffer {
|
|
@@ -543,7 +547,7 @@ input IStoreOffer {
|
|
|
543
547
|
"""
|
|
544
548
|
quantity: Int!
|
|
545
549
|
}
|
|
546
|
-
`,
|
|
550
|
+
`,Ni=`"""
|
|
547
551
|
Information of a specific order.
|
|
548
552
|
"""
|
|
549
553
|
type StoreOrder {
|
|
@@ -578,7 +582,7 @@ input IStoreOrder {
|
|
|
578
582
|
"""
|
|
579
583
|
shouldSplitItem: Boolean
|
|
580
584
|
}
|
|
581
|
-
`,
|
|
585
|
+
`,Li=`"""
|
|
582
586
|
Commercial Authorization response.
|
|
583
587
|
"""
|
|
584
588
|
type CommercialAuthorizationResponse {
|
|
@@ -977,7 +981,7 @@ type ProcessOrderAuthorizationRule {
|
|
|
977
981
|
"""
|
|
978
982
|
rule: CommercialAuthorizationRule!
|
|
979
983
|
}
|
|
980
|
-
`,
|
|
984
|
+
`,Bi=`"""
|
|
981
985
|
Input for uploading a file to the Order Entry Service.
|
|
982
986
|
The file is transmitted as a Base64-encoded string so it can travel
|
|
983
987
|
through the standard GraphQL JSON pipeline without multipart support.
|
|
@@ -1038,7 +1042,7 @@ type StoreOrderFormCartItem {
|
|
|
1038
1042
|
seller: String!
|
|
1039
1043
|
unitMultiplier: Float
|
|
1040
1044
|
}
|
|
1041
|
-
`,
|
|
1045
|
+
`,Mi=`"""
|
|
1042
1046
|
Organization.
|
|
1043
1047
|
"""
|
|
1044
1048
|
type StoreOrganization {
|
|
@@ -1057,7 +1061,25 @@ input IStoreOrganization {
|
|
|
1057
1061
|
"""
|
|
1058
1062
|
identifier: String!
|
|
1059
1063
|
}
|
|
1060
|
-
|
|
1064
|
+
|
|
1065
|
+
"""
|
|
1066
|
+
A commercial contract available to a buyer's Organization Unit.
|
|
1067
|
+
"""
|
|
1068
|
+
type StoreContract {
|
|
1069
|
+
"""
|
|
1070
|
+
Contract identifier (the contract/scope ID associated with the Organization Unit).
|
|
1071
|
+
"""
|
|
1072
|
+
id: ID!
|
|
1073
|
+
"""
|
|
1074
|
+
Human-readable corporate name of the contract (resolved from MasterData).
|
|
1075
|
+
"""
|
|
1076
|
+
corporateName: String!
|
|
1077
|
+
"""
|
|
1078
|
+
Indicates whether this contract is the one currently active in the session.
|
|
1079
|
+
"""
|
|
1080
|
+
isActive: Boolean!
|
|
1081
|
+
}
|
|
1082
|
+
`,$i=`"""
|
|
1061
1083
|
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.
|
|
1062
1084
|
"""
|
|
1063
1085
|
type StorePageInfo {
|
|
@@ -1082,7 +1104,7 @@ type StorePageInfo {
|
|
|
1082
1104
|
"""
|
|
1083
1105
|
totalCount: Int!
|
|
1084
1106
|
}
|
|
1085
|
-
`,
|
|
1107
|
+
`,zi=`"""
|
|
1086
1108
|
Input type for setting a new password.
|
|
1087
1109
|
"""
|
|
1088
1110
|
input ISetPassword {
|
|
@@ -1125,7 +1147,7 @@ type SetPasswordResponse {
|
|
|
1125
1147
|
"""
|
|
1126
1148
|
message: String
|
|
1127
1149
|
}
|
|
1128
|
-
`,
|
|
1150
|
+
`,xi=`"""
|
|
1129
1151
|
Client profile data.
|
|
1130
1152
|
"""
|
|
1131
1153
|
type StorePerson {
|
|
@@ -1168,7 +1190,7 @@ input IStorePerson {
|
|
|
1168
1190
|
"""
|
|
1169
1191
|
familyName: String!
|
|
1170
1192
|
}
|
|
1171
|
-
`,
|
|
1193
|
+
`,qi=`type PickupPointAddress {
|
|
1172
1194
|
"""
|
|
1173
1195
|
Address city.
|
|
1174
1196
|
"""
|
|
@@ -1247,7 +1269,7 @@ type PickupPoints {
|
|
|
1247
1269
|
"""
|
|
1248
1270
|
pickupPointsHash: String
|
|
1249
1271
|
}
|
|
1250
|
-
`,
|
|
1272
|
+
`,Vi=`"""
|
|
1251
1273
|
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.
|
|
1252
1274
|
"""
|
|
1253
1275
|
type StoreProduct {
|
|
@@ -1396,7 +1418,7 @@ input IStoreProduct {
|
|
|
1396
1418
|
"""
|
|
1397
1419
|
additionalProperty: [IStorePropertyValue!]
|
|
1398
1420
|
}
|
|
1399
|
-
`,
|
|
1421
|
+
`,ji=`"""
|
|
1400
1422
|
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.
|
|
1401
1423
|
"""
|
|
1402
1424
|
type StoreProductGroup {
|
|
@@ -1423,7 +1445,7 @@ type StoreProductGroup {
|
|
|
1423
1445
|
"""
|
|
1424
1446
|
skuVariants: SkuVariants
|
|
1425
1447
|
}
|
|
1426
|
-
`,
|
|
1448
|
+
`,Wi=`type Profile {
|
|
1427
1449
|
"""
|
|
1428
1450
|
Collection of user's address
|
|
1429
1451
|
"""
|
|
@@ -1484,7 +1506,7 @@ type ProfileAddress {
|
|
|
1484
1506
|
"""
|
|
1485
1507
|
geoCoordinate: [Float]
|
|
1486
1508
|
}
|
|
1487
|
-
`,
|
|
1509
|
+
`,Gi=`"""
|
|
1488
1510
|
Properties that can be associated with products and products groups.
|
|
1489
1511
|
"""
|
|
1490
1512
|
type StorePropertyValue {
|
|
@@ -1524,7 +1546,7 @@ input IStorePropertyValue {
|
|
|
1524
1546
|
"""
|
|
1525
1547
|
valueReference: ObjectOrString!
|
|
1526
1548
|
}
|
|
1527
|
-
`,
|
|
1549
|
+
`,Hi=`"""
|
|
1528
1550
|
Each product edge contains a \`node\`, with product information, and a \`cursor\`, that can be used as a reference for pagination.
|
|
1529
1551
|
"""
|
|
1530
1552
|
type StoreProductEdge {
|
|
@@ -1956,6 +1978,46 @@ type Query {
|
|
|
1956
1978
|
@auth
|
|
1957
1979
|
@cacheControl(scope: "private", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
1958
1980
|
|
|
1981
|
+
"""
|
|
1982
|
+
Returns the list of Quotes that the authenticated Buyer can view.
|
|
1983
|
+
"""
|
|
1984
|
+
listUserQuotes(
|
|
1985
|
+
"""
|
|
1986
|
+
Page number (1-based).
|
|
1987
|
+
"""
|
|
1988
|
+
page: Int
|
|
1989
|
+
"""
|
|
1990
|
+
Number of items per page.
|
|
1991
|
+
"""
|
|
1992
|
+
perPage: Int
|
|
1993
|
+
"""
|
|
1994
|
+
Filter by quote status values.
|
|
1995
|
+
"""
|
|
1996
|
+
status: [String]
|
|
1997
|
+
"""
|
|
1998
|
+
Filter quotes created on or after this ISO 8601 date-time.
|
|
1999
|
+
"""
|
|
2000
|
+
createdAtFrom: String
|
|
2001
|
+
"""
|
|
2002
|
+
Filter quotes created on or before this ISO 8601 date-time.
|
|
2003
|
+
"""
|
|
2004
|
+
createdAtTo: String
|
|
2005
|
+
"""
|
|
2006
|
+
Filter quotes expiring on or after this ISO 8601 date-time.
|
|
2007
|
+
"""
|
|
2008
|
+
expiresAtFrom: String
|
|
2009
|
+
"""
|
|
2010
|
+
Filter quotes expiring on or before this ISO 8601 date-time.
|
|
2011
|
+
"""
|
|
2012
|
+
expiresAtTo: String
|
|
2013
|
+
"""
|
|
2014
|
+
Filter quotes by label (partial match).
|
|
2015
|
+
"""
|
|
2016
|
+
label: String
|
|
2017
|
+
): UserQuoteListResult
|
|
2018
|
+
@auth
|
|
2019
|
+
@cacheControl(scope: "private", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
2020
|
+
|
|
1959
2021
|
"""
|
|
1960
2022
|
Returns information about the current user details.
|
|
1961
2023
|
"""
|
|
@@ -1977,6 +2039,25 @@ type Query {
|
|
|
1977
2039
|
@auth
|
|
1978
2040
|
@cacheControl(scope: "private", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
1979
2041
|
|
|
2042
|
+
"""
|
|
2043
|
+
Lists the commercial contracts associated with the given Organization Unit,
|
|
2044
|
+
resolved to human-readable corporate names. Governed: only contracts associated
|
|
2045
|
+
with the authenticated buyer's Organization Unit are returned.
|
|
2046
|
+
"""
|
|
2047
|
+
availableContracts(
|
|
2048
|
+
"""
|
|
2049
|
+
The Organization Unit identifier whose contracts will be listed.
|
|
2050
|
+
"""
|
|
2051
|
+
orgUnitId: String!
|
|
2052
|
+
): [StoreContract!]! @auth @cacheControl(scope: "private", sMaxAge: 0)
|
|
2053
|
+
|
|
2054
|
+
"""
|
|
2055
|
+
Returns whether the current authenticated user belongs to a B2B organization unit.
|
|
2056
|
+
"""
|
|
2057
|
+
isOrganizationMember: Boolean!
|
|
2058
|
+
@auth
|
|
2059
|
+
@cacheControl(scope: "private", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
2060
|
+
|
|
1980
2061
|
"""
|
|
1981
2062
|
Returns a list of pickup points near to the given geo coordinates.
|
|
1982
2063
|
"""
|
|
@@ -1996,6 +2077,15 @@ type Query {
|
|
|
1996
2077
|
Returns the items in an orderForm by its ID.
|
|
1997
2078
|
"""
|
|
1998
2079
|
orderFormItems(orderFormId: String!): [StoreOrderFormCartItem!]! @auth
|
|
2080
|
+
"""
|
|
2081
|
+
Returns personalized product recommendations for a given campaign.
|
|
2082
|
+
"""
|
|
2083
|
+
recommendations(
|
|
2084
|
+
campaignVrn: String!
|
|
2085
|
+
userId: String
|
|
2086
|
+
products: [String!]
|
|
2087
|
+
): RecommendationResponse!
|
|
2088
|
+
@cacheControl(scope: "private", sMaxAge: 120, staleWhileRevalidate: 3600)
|
|
1999
2089
|
}
|
|
2000
2090
|
|
|
2001
2091
|
type ValidateUserData {
|
|
@@ -2086,7 +2176,83 @@ type StoreAccountProfile {
|
|
|
2086
2176
|
email: String
|
|
2087
2177
|
id: String
|
|
2088
2178
|
}
|
|
2089
|
-
`,
|
|
2179
|
+
`,Xi=`"""
|
|
2180
|
+
Summary of a quote returned in list results.
|
|
2181
|
+
"""
|
|
2182
|
+
type UserQuoteSummary {
|
|
2183
|
+
"""
|
|
2184
|
+
Unique identifier of the quote.
|
|
2185
|
+
"""
|
|
2186
|
+
id: String!
|
|
2187
|
+
"""
|
|
2188
|
+
Status of the quote.
|
|
2189
|
+
"""
|
|
2190
|
+
status: String!
|
|
2191
|
+
"""
|
|
2192
|
+
Optional label assigned to the quote.
|
|
2193
|
+
"""
|
|
2194
|
+
label: String
|
|
2195
|
+
"""
|
|
2196
|
+
ISO 8601 date-time when the quote was created.
|
|
2197
|
+
"""
|
|
2198
|
+
createdAt: String!
|
|
2199
|
+
"""
|
|
2200
|
+
ISO 8601 date-time when the quote expires.
|
|
2201
|
+
"""
|
|
2202
|
+
expiresAt: String!
|
|
2203
|
+
"""
|
|
2204
|
+
Total amount of the quote.
|
|
2205
|
+
"""
|
|
2206
|
+
amount: Float!
|
|
2207
|
+
"""
|
|
2208
|
+
Name or email of the user who created the quote.
|
|
2209
|
+
"""
|
|
2210
|
+
createdBy: String
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
"""
|
|
2214
|
+
Result returned by the listUserQuotes query.
|
|
2215
|
+
"""
|
|
2216
|
+
type UserQuoteListResult {
|
|
2217
|
+
"""
|
|
2218
|
+
Array of quote summaries for the current page.
|
|
2219
|
+
"""
|
|
2220
|
+
list: [UserQuoteSummary!]!
|
|
2221
|
+
"""
|
|
2222
|
+
Pagination information.
|
|
2223
|
+
"""
|
|
2224
|
+
paging: UserQuoteListPaging!
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
"""
|
|
2228
|
+
Pagination metadata for the quotes list.
|
|
2229
|
+
"""
|
|
2230
|
+
type UserQuoteListPaging {
|
|
2231
|
+
"""
|
|
2232
|
+
Total number of quotes matching the query.
|
|
2233
|
+
"""
|
|
2234
|
+
total: Int!
|
|
2235
|
+
"""
|
|
2236
|
+
Current page number (1-based).
|
|
2237
|
+
"""
|
|
2238
|
+
currentPage: Int!
|
|
2239
|
+
"""
|
|
2240
|
+
Number of items per page.
|
|
2241
|
+
"""
|
|
2242
|
+
perPage: Int!
|
|
2243
|
+
}
|
|
2244
|
+
`,Yi=`type RecommendationResponse {
|
|
2245
|
+
products: [StoreProduct!]!
|
|
2246
|
+
correlationId: String!
|
|
2247
|
+
campaign: RecommendationCampaign!
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
type RecommendationCampaign {
|
|
2251
|
+
id: String!
|
|
2252
|
+
title: String
|
|
2253
|
+
type: String!
|
|
2254
|
+
}
|
|
2255
|
+
`,Ji=`"""
|
|
2090
2256
|
Information of a given review rating.
|
|
2091
2257
|
"""
|
|
2092
2258
|
type StoreReviewRating {
|
|
@@ -2113,7 +2279,7 @@ type StoreReview {
|
|
|
2113
2279
|
"""
|
|
2114
2280
|
author: StoreAuthor!
|
|
2115
2281
|
}
|
|
2116
|
-
`,
|
|
2282
|
+
`,Ki=`"""
|
|
2117
2283
|
Search Engine Optimization (SEO) tags data.
|
|
2118
2284
|
"""
|
|
2119
2285
|
type StoreSeo {
|
|
@@ -2134,7 +2300,7 @@ type StoreSeo {
|
|
|
2134
2300
|
"""
|
|
2135
2301
|
canonical: String!
|
|
2136
2302
|
}
|
|
2137
|
-
`,
|
|
2303
|
+
`,Qi=`"""
|
|
2138
2304
|
Currency information.
|
|
2139
2305
|
"""
|
|
2140
2306
|
type StoreCurrency {
|
|
@@ -2409,7 +2575,7 @@ input IStoreSession {
|
|
|
2409
2575
|
"""
|
|
2410
2576
|
refreshAfter: String
|
|
2411
2577
|
}
|
|
2412
|
-
`,
|
|
2578
|
+
`,Zi=`"""
|
|
2413
2579
|
Shipping Simulation item input.
|
|
2414
2580
|
"""
|
|
2415
2581
|
input IShippingItem {
|
|
@@ -2740,7 +2906,7 @@ type MessageFields {
|
|
|
2740
2906
|
"""
|
|
2741
2907
|
skuName: String
|
|
2742
2908
|
}
|
|
2743
|
-
`,
|
|
2909
|
+
`,ea=`type SkuVariants {
|
|
2744
2910
|
"""
|
|
2745
2911
|
SKU property values for the current SKU.
|
|
2746
2912
|
"""
|
|
@@ -2835,7 +3001,7 @@ Example:
|
|
|
2835
3001
|
\`\`\`
|
|
2836
3002
|
"""
|
|
2837
3003
|
scalar FormattedVariants
|
|
2838
|
-
`,
|
|
3004
|
+
`,na=`"""
|
|
2839
3005
|
Status used to indicate a message type. For instance, a shopping cart informative or error message.
|
|
2840
3006
|
"""
|
|
2841
3007
|
enum StoreStatus {
|
|
@@ -2843,7 +3009,7 @@ enum StoreStatus {
|
|
|
2843
3009
|
WARNING
|
|
2844
3010
|
ERROR
|
|
2845
3011
|
}
|
|
2846
|
-
|
|
3012
|
+
`,ta=`scalar JSONObject
|
|
2847
3013
|
|
|
2848
3014
|
type UserOrder {
|
|
2849
3015
|
orderId: String
|
|
@@ -3667,4 +3833,4 @@ type UserOrderBudgetAllocationLinkedEntity {
|
|
|
3667
3833
|
type: String
|
|
3668
3834
|
id: String
|
|
3669
3835
|
}
|
|
3670
|
-
`,
|
|
3836
|
+
`,ra=Object.assign({"./address.graphql":Ii,"./advertisement.graphql":vi,"./aggregateOffer.graphql":Oi,"./aggregateRating.graphql":Ci,"./author.graphql":bi,"./brand.graphql":wi,"./breadcrumb.graphql":Di,"./cart.graphql":Ai,"./collection.graphql":Pi,"./deliveryPromisesBadge.graphql":Ei,"./facet.graphql":Ui,"./image.graphql":Ti,"./mutation.graphql":_i,"./newsletter.graphql":Ri,"./objectOrString.graphql":ki,"./offer.graphql":Fi,"./order.graphql":Ni,"./orderCommercialAuthorizaton.graphql":Li,"./orderEntry.graphql":Bi,"./organization.graphql":Mi,"./pageInfo.graphql":$i,"./password.graphql":zi,"./person.graphql":xi,"./pickupPoints.graphql":qi,"./product.graphql":Vi,"./productGroup.graphql":ji,"./profile.graphql":Wi,"./propertyValue.graphql":Gi,"./query.graphql":Hi,"./quote.graphql":Xi,"./recommendation.graphql":Yi,"./review.graphql":Ji,"./seo.graphql":Ki,"./session.graphql":Qi,"./shipping.graphql":Zi,"./skuVariants.graphql":ea,"./status.graphql":na,"./userOrder.graphql":ta}),ia=te.print(Object.values(ra).map(e=>te.parse(e)).reduce((e,n)=>He.mergeTypeDefs([e,n],{sort:!0}))),Tn=ia,aa=async e=>L.OTELAPI.context.with(L.OTELAPI.propagation.extract(L.OTELAPI.context.active(),e.OTEL),()=>n=>(n.storage={channel:re.parse(e.channel),flags:e.flags??{},locale:e.locale,cookies:new Map},n.clients=Et(e,n),n.loaders=Mt(e,n),n.account=e.account,n.OTEL=e.OTEL,n.discoveryConfig=e.discoveryConfig,n));function oa(){const e=yi(),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,xn(a,`${t}(${i})`)]));return n}function sa(e){const t=rn([tn,nn])(oa(),Tn);return e&&te.isSchema(e)?Xe.mergeSchemas({schemas:[t,e]}):t}exports.AuthDirective=nn;exports.BadRequestError=E;exports.CacheControlDirective=tn;exports.CommercialAuthorizationStatus=Ye;exports.FastStoreError=W;exports.ForbiddenError=q;exports.GraphqlVtexContextFactory=aa;exports.GraphqlVtexSchema=sa;exports.NotFoundError=B;exports.StoreCollectionType=Je;exports.StoreFacetType=Ke;exports.StoreSort=Qe;exports.StoreStatus=Ze;exports.UnauthorizedError=K;exports.UserOrderInvoiceType=en;exports.isBadRequestError=Vn;exports.isFastStoreError=qn;exports.isForbiddenError=an;exports.isNotFoundError=be;exports.isUnauthorizedError=jn;exports.stringifyCacheControl=$n;exports.typeDefs=Tn;exports.withDirectives=rn;
|