@salesforce/storefront-next-runtime 0.3.1 → 0.4.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +82 -0
  2. package/dist/DesignComponent.js +37 -12
  3. package/dist/DesignComponent.js.map +1 -1
  4. package/dist/DesignContext.js +47 -2
  5. package/dist/DesignContext.js.map +1 -1
  6. package/dist/DesignFrame.js +1 -1
  7. package/dist/DesignRegion.js +1 -1
  8. package/dist/config.d.ts +4 -4
  9. package/dist/custom-global-preferences.d.ts +20 -0
  10. package/dist/custom-global-preferences.d.ts.map +1 -0
  11. package/dist/custom-global-preferences.js +28 -0
  12. package/dist/custom-global-preferences.js.map +1 -0
  13. package/dist/custom-site-preferences.d.ts +20 -0
  14. package/dist/custom-site-preferences.d.ts.map +1 -0
  15. package/dist/custom-site-preferences.js +28 -0
  16. package/dist/custom-site-preferences.js.map +1 -0
  17. package/dist/data-store-custom-global-preferences.d.ts +2 -0
  18. package/dist/data-store-custom-global-preferences.js +6 -0
  19. package/dist/data-store-custom-site-preferences.d.ts +2 -0
  20. package/dist/data-store-custom-site-preferences.js +6 -0
  21. package/dist/data-store-gcp-preferences.d.ts +2 -0
  22. package/dist/data-store-gcp-preferences.js +6 -0
  23. package/dist/data-store.d.ts +97 -0
  24. package/dist/data-store.d.ts.map +1 -0
  25. package/dist/data-store.js +42 -0
  26. package/dist/data-store.js.map +1 -0
  27. package/dist/design-data.d.ts +82 -88
  28. package/dist/design-data.d.ts.map +1 -1
  29. package/dist/design-data.js +95 -57
  30. package/dist/design-data.js.map +1 -1
  31. package/dist/design-messaging.d.ts +2 -2
  32. package/dist/design-react-core.d.ts +2 -2
  33. package/dist/events.d.ts +34 -6
  34. package/dist/events.d.ts.map +1 -1
  35. package/dist/events.js +6 -6
  36. package/dist/events.js.map +1 -1
  37. package/dist/gcp-preferences.d.ts +52 -0
  38. package/dist/gcp-preferences.d.ts.map +1 -0
  39. package/dist/gcp-preferences.js +61 -0
  40. package/dist/gcp-preferences.js.map +1 -0
  41. package/dist/i18n-client.d.ts +38 -0
  42. package/dist/i18n-client.d.ts.map +1 -0
  43. package/dist/i18n-client.js +72 -0
  44. package/dist/i18n-client.js.map +1 -0
  45. package/dist/i18n.d.ts +63 -0
  46. package/dist/i18n.d.ts.map +1 -0
  47. package/dist/i18n.js +98 -0
  48. package/dist/i18n.js.map +1 -0
  49. package/dist/index.d.ts +60 -1
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/messaging-api.js +3 -1
  52. package/dist/messaging-api.js.map +1 -1
  53. package/dist/scapi.d.ts +247 -2
  54. package/dist/scapi.d.ts.map +1 -1
  55. package/dist/scapi.js +1 -1
  56. package/dist/scapi.js.map +1 -1
  57. package/dist/site-context.d.ts +93 -17
  58. package/dist/site-context.d.ts.map +1 -1
  59. package/dist/site-context.js +2 -417
  60. package/dist/site-context2.js +513 -0
  61. package/dist/site-context2.js.map +1 -0
  62. package/dist/types2.d.ts +210 -0
  63. package/dist/types2.d.ts.map +1 -1
  64. package/dist/utils.js +179 -0
  65. package/dist/utils.js.map +1 -0
  66. package/package.json +63 -4
  67. package/dist/site-context.js.map +0 -1
package/dist/scapi.js CHANGED
@@ -1,2 +1,2 @@
1
- const e=/\{[^{}]+\}/g,t=()=>typeof process==`object`&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici;function n(){return Math.random().toString(36).slice(2,11)}function r(e){let{baseUrl:r=``,Request:i=globalThis.Request,fetch:a=globalThis.fetch,querySerializer:o,bodySerializer:s,headers:c,requestInitExt:l=void 0,...u}={...e};l=t()?l:void 0,r=g(r);let f=[];async function _(e,t){let{baseUrl:_,fetch:v=a,Request:y=i,headers:b,params:x={},parseAs:S=`json`,querySerializer:C,bodySerializer:w=s??p,body:T,middleware:E=[],...D}=t||{},O=r;_&&(O=g(_)??r);let k=typeof o==`function`?o:d(o);C&&(k=typeof C==`function`?C:d({...typeof o==`object`?o:{},...C}));let A=T===void 0?void 0:w(T,h(c,b,x.header)),j=h(A===void 0||A instanceof FormData?{}:{"Content-Type":`application/json`},c,b,x.header),M=[...f,...E],N={redirect:`follow`,...u,...D,body:A,headers:j},P,F,I=new y(m(e,{baseUrl:O,params:x,querySerializer:k}),N),L;for(let e in D)e in I||(I[e]=D[e]);if(M.length){P=n(),F=Object.freeze({baseUrl:O,fetch:v,parseAs:S,querySerializer:k,bodySerializer:w});for(let t of M)if(t&&typeof t==`object`&&typeof t.onRequest==`function`){let n=await t.onRequest({request:I,schemaPath:e,params:x,options:F,id:P});if(n)if(n instanceof y)I=n;else if(n instanceof Response){L=n;break}else throw Error(`onRequest: must return new Request() or Response() when modifying the request`)}}if(!L){try{L=await v(I,l)}catch(t){let n=t;if(M.length)for(let t=M.length-1;t>=0;t--){let r=M[t];if(r&&typeof r==`object`&&typeof r.onError==`function`){let t=await r.onError({request:I,error:n,schemaPath:e,params:x,options:F,id:P});if(t){if(t instanceof Response){n=void 0,L=t;break}if(t instanceof Error){n=t;continue}throw Error(`onError: must return new Response() or instance of Error`)}}}if(n)throw n}if(M.length)for(let t=M.length-1;t>=0;t--){let n=M[t];if(n&&typeof n==`object`&&typeof n.onResponse==`function`){let t=await n.onResponse({request:I,response:L,schemaPath:e,params:x,options:F,id:P});if(t){if(!(t instanceof Response))throw Error(`onResponse: must return new Response() when modifying the response`);L=t}}}}if(L.status===204||I.method===`HEAD`||L.headers.get(`Content-Length`)===`0`)return L.ok?{data:void 0,response:L}:{error:void 0,response:L};if(L.ok)return S===`stream`?{data:L.body,response:L}:{data:await L[S](),response:L};let R=await L.text();try{R=JSON.parse(R)}catch{}return{error:R,response:L}}return{request(e,t,n){return _(t,{...n,method:e.toUpperCase()})},GET(e,t){return _(e,{...t,method:`GET`})},PUT(e,t){return _(e,{...t,method:`PUT`})},POST(e,t){return _(e,{...t,method:`POST`})},DELETE(e,t){return _(e,{...t,method:`DELETE`})},OPTIONS(e,t){return _(e,{...t,method:`OPTIONS`})},HEAD(e,t){return _(e,{...t,method:`HEAD`})},PATCH(e,t){return _(e,{...t,method:`PATCH`})},TRACE(e,t){return _(e,{...t,method:`TRACE`})},use(...e){for(let t of e)if(t){if(typeof t!=`object`||!(`onRequest`in t||`onResponse`in t||`onError`in t))throw Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");f.push(t)}},eject(...e){for(let t of e){let e=f.indexOf(t);e!==-1&&f.splice(e,1)}}}}var i=class{constructor(e,t){this.client=e,this.url=t}GET=e=>this.client.GET(this.url,e);PUT=e=>this.client.PUT(this.url,e);POST=e=>this.client.POST(this.url,e);DELETE=e=>this.client.DELETE(this.url,e);OPTIONS=e=>this.client.OPTIONS(this.url,e);HEAD=e=>this.client.HEAD(this.url,e);PATCH=e=>this.client.PATCH(this.url,e);TRACE=e=>this.client.TRACE(this.url,e)},a=class{constructor(){this.client=null}get(e,t){let n=new i(e,t);return this.client[t]=n,n}};function o(e){let t=new a,n=new Proxy(e,t);function r(){}r.prototype=n;let i=new r;return t.client=i,i}function s(e){return o(r(e))}function c(e,t,n){if(t==null)return``;if(typeof t==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${n?.allowReserved===!0?t:encodeURIComponent(t)}`}function l(e,t,n){if(!t||typeof t!=`object`)return``;let r=[],i={simple:`,`,label:`.`,matrix:`;`}[n.style]||`&`;if(n.style!==`deepObject`&&n.explode===!1){for(let e in t)r.push(e,n.allowReserved===!0?t[e]:encodeURIComponent(t[e]));let i=r.join(`,`);switch(n.style){case`form`:return`${e}=${i}`;case`label`:return`.${i}`;case`matrix`:return`;${e}=${i}`;default:return i}}for(let i in t){let a=n.style===`deepObject`?`${e}[${i}]`:i;r.push(c(a,t[i],n))}let a=r.join(i);return n.style===`label`||n.style===`matrix`?`${i}${a}`:a}function u(e,t,n){if(!Array.isArray(t))return``;if(n.explode===!1){let r={form:`,`,spaceDelimited:`%20`,pipeDelimited:`|`}[n.style]||`,`,i=(n.allowReserved===!0?t:t.map(e=>encodeURIComponent(e))).join(r);switch(n.style){case`simple`:return i;case`label`:return`.${i}`;case`matrix`:return`;${e}=${i}`;default:return`${e}=${i}`}}let r={simple:`,`,label:`.`,matrix:`;`}[n.style]||`&`,i=[];for(let r of t)n.style===`simple`||n.style===`label`?i.push(n.allowReserved===!0?r:encodeURIComponent(r)):i.push(c(e,r,n));return n.style===`label`||n.style===`matrix`?`${r}${i.join(r)}`:i.join(r)}function d(e){return function(t){let n=[];if(t&&typeof t==`object`)for(let r in t){let i=t[r];if(i!=null){if(Array.isArray(i)){if(i.length===0)continue;n.push(u(r,i,{style:`form`,explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}));continue}if(typeof i==`object`){n.push(l(r,i,{style:`deepObject`,explode:!0,...e?.object,allowReserved:e?.allowReserved||!1}));continue}n.push(c(r,i,e))}}return n.join(`&`)}}function f(t,n){let r=t;for(let i of t.match(e)??[]){let e=i.substring(1,i.length-1),t=!1,a=`simple`;if(e.endsWith(`*`)&&(t=!0,e=e.substring(0,e.length-1)),e.startsWith(`.`)?(a=`label`,e=e.substring(1)):e.startsWith(`;`)&&(a=`matrix`,e=e.substring(1)),!n||n[e]===void 0||n[e]===null)continue;let o=n[e];if(Array.isArray(o)){r=r.replace(i,u(e,o,{style:a,explode:t}));continue}if(typeof o==`object`){r=r.replace(i,l(e,o,{style:a,explode:t}));continue}if(a===`matrix`){r=r.replace(i,`;${c(e,o)}`);continue}r=r.replace(i,a===`label`?`.${encodeURIComponent(o)}`:encodeURIComponent(o))}return r}function p(e,t){return e instanceof FormData?e:t&&(t.get instanceof Function?t.get(`Content-Type`)??t.get(`content-type`):t[`Content-Type`]??t[`content-type`])===`application/x-www-form-urlencoded`?new URLSearchParams(e).toString():JSON.stringify(e)}function m(e,t){let n=`${t.baseUrl}${e}`;t.params?.path&&(n=f(n,t.params.path));let r=t.querySerializer(t.params.query??{});return r.startsWith(`?`)&&(r=r.substring(1)),r&&(n+=`?${r}`),n}function h(...e){let t=new Headers;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n instanceof Headers?n.entries():Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,r)}return t}function g(e){return e.endsWith(`/`)?e.substring(0,e.length-1):e}var _=class e extends Error{status;statusText;headers;body;rawBody;url;method;constructor(t){let n=`API Error ${t.status}: ${t.statusText} (${t.method} ${t.url})`;super(n),this.name=`ApiError`,this.status=t.status,this.statusText=t.statusText,this.headers=t.headers,this.body=t.body,this.rawBody=t.rawBody,this.url=t.url,this.method=t.method,Error.captureStackTrace&&Error.captureStackTrace(this,e)}toJSON(){return{name:this.name,message:this.message,status:this.status,statusText:this.statusText,body:this.body,rawBody:this.rawBody,url:this.url,method:this.method,headers:Object.fromEntries(this.headers.entries())}}},v=class extends Error{constructor(e=`Access token is invalid or revoked`){super(e),this.name=`AuthTokenInvalidError`}};const y=[`/oauth2/token`,`/oauth2/authorize`,`/oauth2/logout`,`/oauth2/login`,`/oauth2/passwordless`,`/oauth2/password`,`/oauth2/session-bridge`,`/oauth2/trusted-agent`,`/oauth2/trusted-system`,`/oauth2/revoke`,`/oauth2/introspect`];function b(e,t){return t?{...e,params:{...e?.params,path:{organizationId:t.organizationId,...e?.params?.path},query:{siteId:t.siteId,...t.locale?{locale:t.locale}:{},...e?.params?.query}}}:e}const x=e=>{try{let t=new URL(e);return y.some(e=>t.pathname.includes(e))}catch{return y.some(t=>e.includes(t))}};function S(e,t,n,r){return new Proxy(e,{get(e,i){if(typeof i==`string`&&i in t){let{m:a,b:o,s}=t[i],c=o+s;return async function(t){let i=a.toUpperCase(),o=e[i];if(typeof o!=`function`)throw Error(`Client method ${i} not found. This is likely a bug in the proxy client.`);let s=b(t,n),l=s===void 0?await o.call(e,c):await o.call(e,c,s);if(l.error!==void 0){let e=l.response;if(e.status===401&&!x(e.url))throw r?.onAuthTokenInvalid?.(e),new v;let t=l.error,n;n=t&&typeof t==`object`&&`type`in t&&`title`in t&&`detail`in t?t:{type:`Unknown Error`,title:e.statusText||`API Error`,detail:`The API returned a ${e.status} error. See rawBody for details.`};let a;try{a=typeof t==`string`?t:JSON.stringify(t)}catch{a=String(t)}throw new _({status:e.status,statusText:e.statusText,headers:e.headers,body:n,rawBody:a,url:e.url,method:i})}return{data:l.data,response:l.response}}}if(i===`use`||i===`eject`){let t=e[i];return typeof t==`function`?t.bind(e):t}}})}const C=[`refine`],w=[`refine`];function T(e){let t=new Map;for(let n of e){let e=n.indexOf(`=`);if(e===-1)continue;let r=n.substring(0,e),i=n.substring(e+1);t.has(r)||t.set(r,[]);let a=t.get(r);a&&a.push(i)}return Array.from(t.entries()).map(([e,t])=>`${e}=${t.join(`|`)}`)}function E(e){if(!e||typeof e!=`object`)return``;let t=d({array:{style:`form`,explode:!1}}),n=d({array:{style:`form`,explode:!0}}),r=[];for(let[i,a]of Object.entries(e)){if(a==null)continue;let e=a;w.includes(i)&&Array.isArray(a)&&(e=T(a));let o=(C.includes(i)?n:t)({[i]:e});o&&r.push(o)}return r.join(`&`)}function D(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function O(){let e=new Uint8Array(128);crypto.getRandomValues(e);let t=``;for(let n=0;n<e.length;n++)t+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`[e[n]%64];return t}async function k(e){let t=new TextEncoder().encode(e),n=D(await crypto.subtle.digest(`SHA-256`,t));if(n.length===0)throw Error(`Problem generating code challenge`);return n}function A(e){let t=new URL(e),n=new URLSearchParams(t.search),r=n.get(`usid`)??``;return{code:n.get(`code`)??``,usid:r}}function j(e,t){let n=`${e}:${t}`;return`Basic ${btoa(n)}`}function M(e,t){let n=e.headers.get(`set-cookie`);if(!n)return;let r=RegExp(`${t}=([^;]+)`);return n.match(r)?.[1]}const N={"Content-Type":`application/x-www-form-urlencoded`};function P(e){let{shopperLoginClient:t,clientId:n,clientSecret:r,redirectUri:i,siteId:a,baseUrl:o,organizationId:s,proxyHost:c}=e,l=!!r;function u(e){let t=M(e.response,`dwsid`);return{...e.data,dwsid:t}}async function d(e={}){let{usid:i,dnt:o}=e,s=await t.getAccessToken({params:{...r&&{header:{Authorization:j(n,r)}}},headers:N,body:{grant_type:`client_credentials`,channel_id:a,...i&&{usid:i},...o!==void 0&&{dnt:o.toString()}}});return{data:s.data,response:s.response}}async function f(e={}){let{usid:r,dnt:o}=e,s=O(),c=await k(s),{code:l,usid:u}=A((await t.authorizeCustomer({params:{query:{client_id:n,channel_id:a,redirect_uri:i,response_type:`code`,hint:`guest`,code_challenge:c,...r&&{usid:r}}},redirect:`manual`})).response.headers.get(`location`)||``);if(!l)throw Error(`Failed to get authorization code from guest login`);let d=await t.getAccessToken({params:{},headers:N,body:{grant_type:`authorization_code_pkce`,client_id:n,channel_id:a,code:l,code_verifier:s,redirect_uri:i,usid:u,...o!==void 0&&{dnt:o.toString()}}});return{data:d.data,response:d.response}}return{loginAsGuest:async(e={})=>u(c||l?await d(e):await f(e)),loginWithCredentials:async e=>{let{username:o,password:s,usid:c,dnt:d}=e,f=O(),p=await k(f),{code:m,usid:h}=A((await t.authenticateCustomer({params:{header:{Authorization:`Basic ${btoa(`${o}:${s}`)}`}},headers:N,body:{client_id:n,channel_id:a,redirect_uri:i,response_type:`code`,code_challenge:p,...c&&{usid:c}},redirect:`manual`})).response.headers.get(`location`)||``);if(!m)throw Error(`Failed to get authorization code from credentials login`);let g={grant_type:`authorization_code_pkce`,client_id:n,channel_id:a,code:m,code_verifier:f,redirect_uri:i,usid:h,...d!==void 0&&{dnt:d.toString()}};if(l&&r){let e=await t.getAccessToken({params:{header:{Authorization:j(n,r)}},headers:N,body:g});return u({data:e.data,response:e.response})}let _=await t.getAccessToken({params:{},headers:N,body:g});return u({data:_.data,response:_.response})},refreshToken:async e=>{let{refreshToken:i,dnt:o}=e,s={grant_type:`refresh_token`,refresh_token:i,client_id:n,channel_id:a,...o!==void 0&&{dnt:o.toString()}};if(l&&r){let e=await t.getAccessToken({params:{header:{Authorization:j(n,r)}},headers:N,body:s});return u({data:e.data,response:e.response})}let c=await t.getAccessToken({params:{},headers:N,body:s});return u({data:c.data,response:c.response})},logout:async e=>{let{accessToken:r,refreshToken:i}=e;return(await t.logoutCustomer({params:{header:{Authorization:`Bearer ${r}`},query:{client_id:n,channel_id:a,refresh_token:i}}})).data},social:{getAuthorizationUrl:async e=>{let{hint:t,redirectUri:r,usid:c}=e,l=O(),u=await k(l),d=r||i,f=o.endsWith(`/`)?o:`${o}/`,p=`shopper/auth/v1/organizations/${s}/oauth2/authorize`,m=new URL(p,f);return m.searchParams.set(`client_id`,n),m.searchParams.set(`channel_id`,a),m.searchParams.set(`redirect_uri`,d),m.searchParams.set(`response_type`,`code`),m.searchParams.set(`hint`,t),m.searchParams.set(`code_challenge`,u),c&&m.searchParams.set(`usid`,c),{url:m.toString(),codeVerifier:l}},exchangeCode:async e=>{let{code:i,codeVerifier:o,redirectUri:s,usid:c,dnt:d}=e,f={grant_type:`authorization_code_pkce`,client_id:n,channel_id:a,code:i,code_verifier:o,redirect_uri:s,...c&&{usid:c},...d!==void 0&&{dnt:d.toString()}};if(l&&r){let e=await t.getAccessToken({params:{header:{Authorization:j(n,r)}},headers:N,body:f});return u({data:e.data,response:e.response})}let p=await t.getAccessToken({params:{},headers:N,body:f});return u({data:p.data,response:p.response})}},passwordless:{authorize:async e=>{let{userId:i,callbackUri:o,usid:s,mode:c=`email`,locale:l,registerCustomer:u,lastName:d,email:f,firstName:p,phoneNumber:m,customerNo:h}=e;if(!r)throw Error(`Client secret is required for passwordless login`);if(c===`callback`&&!o)throw Error(`callbackUri is required for callback mode`);let g={user_id:i,mode:c,channel_id:a,...c===`callback`&&o&&{callback_uri:o},...s&&{usid:s},...l&&{locale:l},...u&&d&&{last_name:d},...u&&f&&{email:f},...u&&p&&{first_name:p},...m&&{phone_number:m},...h&&{customer_no:h}};return t.authorizePasswordlessCustomer({params:{header:{Authorization:j(n,r)},...u===!0&&{query:{register_customer:`true`}}},headers:N,body:g})},exchangeToken:async e=>{let{pwdlessLoginToken:i,usid:a,dnt:o}=e;if(!r)throw Error(`Client secret is required for passwordless token exchange`);let s=O(),c=await t.getPasswordLessAccessToken({params:{header:{Authorization:j(n,r)}},headers:N,body:{grant_type:`client_credentials`,hint:`pwdless_login`,pwdless_login_token:i,code_verifier:s,...a&&{usid:a},...o!==void 0&&{dnt:o.toString()}}});return u({data:c.data,response:c.response})}},password:{requestReset:async e=>{let{userId:i,callbackUri:o,mode:s=`email`,locale:c,codeChallenge:u,hint:d=`cross_device`}=e;if(s===`callback`&&!o)throw Error(`callbackUri is required when mode is "callback"`);let f={...N};return l&&r&&(f.Authorization=j(n,r)),t.getPasswordResetToken({params:{},headers:f,body:{user_id:i,mode:s,channel_id:a,client_id:n,...s===`callback`&&o&&{callback_uri:o},hint:d,...c&&{locale:c},...u&&{code_challenge:u}}})},reset:async e=>{let{userId:i,token:o,newPassword:s,codeVerifier:c,hint:u=`cross_device`}=e,d={client_id:n,user_id:i,pwd_action_token:o,new_password:s,channel_id:a,hint:u,...c&&{code_verifier:c}};return l&&r?t.resetPassword({params:{header:{Authorization:j(n,r)}},headers:N,body:d}):t.resetPassword({params:{},headers:N,body:d})}}}}function F(e){let{shopperBasketsClient:t}=e;async function n(e){let n=e.params?.path?.basketId,r=e.body.currency,i=async()=>{try{let{data:e}=await t.createBasket({params:{query:{populateCustomerDetails:!0}},body:{currency:r}});return e}catch(e){if(e instanceof _){let n=e.body?.basketIds,r=(Array.isArray(n)?n:[n].filter(Boolean)).at(0);if((e.status===429||e.status===400)&&r){let{data:e}=await t.getBasket({params:{path:{basketId:r}}});return e}}throw e}};if(n)try{let{data:e}=await t.getBasket({params:{path:{basketId:n}}});return e}catch(e){if(e instanceof _){if(e.status===404||e.status===400)return i();let n=e.body?.basketIds,r=(Array.isArray(n)?n:[n].filter(Boolean)).at(0);if(e.status===429&&r){let{data:e}=await t.getBasket({params:{path:{basketId:r}}});return e}}throw e}return i()}return{getOrCreateBasket:n}}function I(e){return e.replace(/^f_ecom_/,``)}const L=`/organizations/{organizationId}/baskets`,R={createBasket:{m:`POST`,b:L,s:``},transferBasket:{m:`POST`,b:L,s:`/actions/transfer`},mergeBasket:{m:`POST`,b:L,s:`/actions/merge`},getBasket:{m:`GET`,b:L,s:`/{basketId}`},deleteBasket:{m:`DELETE`,b:L,s:`/{basketId}`},updateBasket:{m:`PATCH`,b:L,s:`/{basketId}`},updateAsAgentBasket:{m:`PUT`,b:L,s:`/{basketId}/agent`},updateBillingAddressForBasket:{m:`PUT`,b:L,s:`/{basketId}/billing-address`},addCouponToBasket:{m:`POST`,b:L,s:`/{basketId}/coupons`},removeCouponFromBasket:{m:`DELETE`,b:L,s:`/{basketId}/coupons/{couponItemId}`},updateCustomerForBasket:{m:`PUT`,b:L,s:`/{basketId}/customer`},addGiftCertificateItemToBasket:{m:`POST`,b:L,s:`/{basketId}/gift-certificate-items`},removeGiftCertificateItemFromBasket:{m:`DELETE`,b:L,s:`/{basketId}/gift-certificate-items/{giftCertificateItemId}`},updateGiftCertificateItemInBasket:{m:`PATCH`,b:L,s:`/{basketId}/gift-certificate-items/{giftCertificateItemId}`},addItemToBasket:{m:`POST`,b:L,s:`/{basketId}/items`},updateItemsInBasket:{m:`PATCH`,b:L,s:`/{basketId}/items`},removeItemFromBasket:{m:`DELETE`,b:L,s:`/{basketId}/items/{itemId}`},updateItemInBasket:{m:`PATCH`,b:L,s:`/{basketId}/items/{itemId}`},addTaxesForBasketItem:{m:`PUT`,b:L,s:`/{basketId}/items/{itemId}/taxes`},addPaymentInstrumentToBasket:{m:`POST`,b:L,s:`/{basketId}/payment-instruments`},removePaymentInstrumentFromBasket:{m:`DELETE`,b:L,s:`/{basketId}/payment-instruments/{paymentInstrumentId}`},updatePaymentInstrumentInBasket:{m:`PATCH`,b:L,s:`/{basketId}/payment-instruments/{paymentInstrumentId}`},getPaymentMethodsForBasket:{m:`GET`,b:L,s:`/{basketId}/payment-methods`},addPriceAdjustmentToBasket:{m:`POST`,b:L,s:`/{basketId}/price-adjustments`},removePriceAdjustmentFromBasket:{m:`DELETE`,b:L,s:`/{basketId}/price-adjustments/{priceAdjustmentId}`},updatePriceAdjustmentInBasket:{m:`PATCH`,b:L,s:`/{basketId}/price-adjustments/{priceAdjustmentId}`},getPriceBooksForBasket:{m:`GET`,b:L,s:`/{basketId}/price-books`},addPriceBooksToBasket:{m:`PUT`,b:L,s:`/{basketId}/price-books`},createShipmentForBasket:{m:`POST`,b:L,s:`/{basketId}/shipments`},removeShipmentFromBasket:{m:`DELETE`,b:L,s:`/{basketId}/shipments/{shipmentId}`},updateShipmentForBasket:{m:`PATCH`,b:L,s:`/{basketId}/shipments/{shipmentId}`},updateShippingAddressForShipment:{m:`PUT`,b:L,s:`/{basketId}/shipments/{shipmentId}/shipping-address`},updateShippingMethodForShipment:{m:`PUT`,b:L,s:`/{basketId}/shipments/{shipmentId}/shipping-method`},getShippingMethodsForShipment:{m:`GET`,b:L,s:`/{basketId}/shipments/{shipmentId}/shipping-methods`},updateAsStorefrontBasket:{m:`PUT`,b:L,s:`/{basketId}/storefront`},getTaxesFromBasket:{m:`GET`,b:L,s:`/{basketId}/taxes`},addTaxesForBasket:{m:`PUT`,b:L,s:`/{basketId}/taxes`}},z=`/organizations/{organizationId}/baskets`,ee={createBasket:{m:`POST`,b:z,s:``},transferBasket:{m:`POST`,b:z,s:`/actions/transfer`},mergeBasket:{m:`POST`,b:z,s:`/actions/merge`},getBasket:{m:`GET`,b:z,s:`/{basketId}`},deleteBasket:{m:`DELETE`,b:z,s:`/{basketId}`},updateBasket:{m:`PATCH`,b:z,s:`/{basketId}`},updateAsAgentBasket:{m:`PUT`,b:z,s:`/{basketId}/agent`},updateBillingAddressForBasket:{m:`PUT`,b:z,s:`/{basketId}/billing-address`},addCouponToBasket:{m:`POST`,b:z,s:`/{basketId}/coupons`},removeCouponFromBasket:{m:`DELETE`,b:z,s:`/{basketId}/coupons/{couponItemId}`},updateCustomerForBasket:{m:`PUT`,b:z,s:`/{basketId}/customer`},addGiftCertificateItemToBasket:{m:`POST`,b:z,s:`/{basketId}/gift-certificate-items`},removeGiftCertificateItemFromBasket:{m:`DELETE`,b:z,s:`/{basketId}/gift-certificate-items/{giftCertificateItemId}`},updateGiftCertificateItemInBasket:{m:`PATCH`,b:z,s:`/{basketId}/gift-certificate-items/{giftCertificateItemId}`},addItemToBasket:{m:`POST`,b:z,s:`/{basketId}/items`},updateItemsInBasket:{m:`PATCH`,b:z,s:`/{basketId}/items`},removeItemFromBasket:{m:`DELETE`,b:z,s:`/{basketId}/items/{itemId}`},updateItemInBasket:{m:`PATCH`,b:z,s:`/{basketId}/items/{itemId}`},addTaxesForBasketItem:{m:`PUT`,b:z,s:`/{basketId}/items/{itemId}/taxes`},addPaymentInstrumentToBasket:{m:`POST`,b:z,s:`/{basketId}/payment-instruments`},removePaymentInstrumentFromBasket:{m:`DELETE`,b:z,s:`/{basketId}/payment-instruments/{paymentInstrumentId}`},updatePaymentInstrumentInBasket:{m:`PATCH`,b:z,s:`/{basketId}/payment-instruments/{paymentInstrumentId}`},getPaymentMethodsForBasket:{m:`GET`,b:z,s:`/{basketId}/payment-methods`},addPriceAdjustmentToBasket:{m:`POST`,b:z,s:`/{basketId}/price-adjustments`},removePriceAdjustmentFromBasket:{m:`DELETE`,b:z,s:`/{basketId}/price-adjustments/{priceAdjustmentId}`},updatePriceAdjustmentInBasket:{m:`PATCH`,b:z,s:`/{basketId}/price-adjustments/{priceAdjustmentId}`},getPriceBooksForBasket:{m:`GET`,b:z,s:`/{basketId}/price-books`},addPriceBooksToBasket:{m:`PUT`,b:z,s:`/{basketId}/price-books`},createShipmentForBasket:{m:`POST`,b:z,s:`/{basketId}/shipments`},removeShipmentFromBasket:{m:`DELETE`,b:z,s:`/{basketId}/shipments/{shipmentId}`},updateShipmentForBasket:{m:`PATCH`,b:z,s:`/{basketId}/shipments/{shipmentId}`},updateShippingAddressForShipment:{m:`PUT`,b:z,s:`/{basketId}/shipments/{shipmentId}/shipping-address`},updateShippingMethodForShipment:{m:`PUT`,b:z,s:`/{basketId}/shipments/{shipmentId}/shipping-method`},getShippingMethodsForShipment:{m:`GET`,b:z,s:`/{basketId}/shipments/{shipmentId}/shipping-methods`},updateAsStorefrontBasket:{m:`PUT`,b:z,s:`/{basketId}/storefront`},getTaxesFromBasket:{m:`GET`,b:z,s:`/{basketId}/taxes`},addTaxesForBasket:{m:`PUT`,b:z,s:`/{basketId}/taxes`}},te={getConfigurations:{m:`GET`,b:`/organizations/{organizationId}`,s:`/configurations`}},B=`/organizations/{organizationId}/subscriptions`,V={getSubscriptions:{m:`GET`,b:B,s:``},updateSubscription:{m:`POST`,b:B,s:``},updateSubscriptions:{m:`POST`,b:B,s:`/actions/bulk`}},H=`/organizations/{organizationId}/shopper-context/{usid}`,ne={getShopperContext:{m:`GET`,b:H,s:``},createShopperContext:{m:`PUT`,b:H,s:``},deleteShopperContext:{m:`DELETE`,b:H,s:``},updateShopperContext:{m:`PATCH`,b:H,s:``}},U=`/organizations/{organizationId}`,W={registerCustomer:{m:`POST`,b:U,s:`/customers`},resetPassword:{m:`POST`,b:U,s:`/customers/password/actions/reset`},getResetPasswordToken:{m:`POST`,b:U,s:`/customers/password/actions/create-reset-token`},getExternalProfile:{m:`GET`,b:U,s:`/customers/external-profile`},registerExternalProfile:{m:`POST`,b:U,s:`/customers/external-profile`},getCustomer:{m:`GET`,b:U,s:`/customers/{customerId}`},updateCustomer:{m:`PATCH`,b:U,s:`/customers/{customerId}`},createCustomerAddress:{m:`POST`,b:U,s:`/customers/{customerId}/addresses`},getCustomerAddress:{m:`GET`,b:U,s:`/customers/{customerId}/addresses/{addressName}`},removeCustomerAddress:{m:`DELETE`,b:U,s:`/customers/{customerId}/addresses/{addressName}`},updateCustomerAddress:{m:`PATCH`,b:U,s:`/customers/{customerId}/addresses/{addressName}`},getCustomerBaskets:{m:`GET`,b:U,s:`/customers/{customerId}/baskets`},getCustomerOrders:{m:`GET`,b:U,s:`/customers/{customerId}/orders`},updateCustomerPassword:{m:`PUT`,b:U,s:`/customers/{customerId}/password`},createCustomerPaymentInstrument:{m:`POST`,b:U,s:`/customers/{customerId}/payment-instruments`},getCustomerPaymentInstrument:{m:`GET`,b:U,s:`/customers/{customerId}/payment-instruments/{paymentInstrumentId}`},deleteCustomerPaymentInstrument:{m:`DELETE`,b:U,s:`/customers/{customerId}/payment-instruments/{paymentInstrumentId}`},updateCustomerPaymentInstrument:{m:`PATCH`,b:U,s:`/customers/{customerId}/payment-instruments/{paymentInstrumentId}`},getCustomerProductLists:{m:`GET`,b:U,s:`/customers/{customerId}/product-lists`},createCustomerProductList:{m:`POST`,b:U,s:`/customers/{customerId}/product-lists`},getCustomerProductList:{m:`GET`,b:U,s:`/customers/{customerId}/product-lists/{listId}`},deleteCustomerProductList:{m:`DELETE`,b:U,s:`/customers/{customerId}/product-lists/{listId}`},updateCustomerProductList:{m:`PATCH`,b:U,s:`/customers/{customerId}/product-lists/{listId}`},createCustomerProductListItem:{m:`POST`,b:U,s:`/customers/{customerId}/product-lists/{listId}/items`},getCustomerProductListItem:{m:`GET`,b:U,s:`/customers/{customerId}/product-lists/{listId}/items/{itemId}`},deleteCustomerProductListItem:{m:`DELETE`,b:U,s:`/customers/{customerId}/product-lists/{listId}/items/{itemId}`},updateCustomerProductListItem:{m:`PATCH`,b:U,s:`/customers/{customerId}/product-lists/{listId}/items/{itemId}`},getPublicProductListsBySearchTerm:{m:`GET`,b:U,s:`/product-lists`},getPublicProductList:{m:`GET`,b:U,s:`/product-lists/{listId}`},getPublicProductListItems:{m:`GET`,b:U,s:`/product-lists/{listId}/items`},getProductListItem:{m:`GET`,b:U,s:`/product-lists/{listId}/items/{itemId}`}},G=`/organizations/{organizationId}`,K={getPages:{m:`GET`,b:G,s:`/pages`},getPage:{m:`GET`,b:G,s:`/pages/{pageId}`},getContent:{m:`GET`,b:G,s:`/contents/{id}`},getMultipleContent:{m:`GET`,b:G,s:`/contents`},searchContent:{m:`GET`,b:G,s:`/content-search`},getContentFolder:{m:`GET`,b:G,s:`/folders/{id}`},getContentFolders:{m:`GET`,b:G,s:`/folders`}},q={getGiftCertificate:{m:`POST`,b:`/organizations/{organizationId}`,s:`/gift-certificate`}},J=`/organizations/{organizationId}/oauth2`,re={authenticateCustomer:{m:`POST`,b:J,s:`/login`},authorizePasswordlessCustomer:{m:`POST`,b:J,s:`/passwordless/login`},logoutCustomer:{m:`GET`,b:J,s:`/logout`},authorizeCustomer:{m:`GET`,b:J,s:`/authorize`},getAccessToken:{m:`POST`,b:J,s:`/token`},getSessionBridgeAccessToken:{m:`POST`,b:J,s:`/session-bridge/token`},getTrustedSystemAccessToken:{m:`POST`,b:J,s:`/trusted-system/token`},getTrustedAgentAuthorizationToken:{m:`GET`,b:J,s:`/trusted-agent/authorize`},getTrustedAgentAccessToken:{m:`POST`,b:J,s:`/trusted-agent/token`},getPasswordResetToken:{m:`POST`,b:J,s:`/password/reset`},resetPassword:{m:`POST`,b:J,s:`/password/action`},getPasswordLessAccessToken:{m:`POST`,b:J,s:`/passwordless/token`},revokeToken:{m:`POST`,b:J,s:`/revoke`},introspectToken:{m:`POST`,b:J,s:`/introspect`},getUserInfo:{m:`GET`,b:J,s:`/userinfo`},getWellknownOpenidConfiguration:{m:`GET`,b:J,s:`/.well-known/openid-configuration`},getJwksUri:{m:`GET`,b:J,s:`/jwks`},authorizeWebauthnRegistration:{m:`POST`,b:J,s:`/webauthn/register/authorize`},startWebauthnUserRegistration:{m:`POST`,b:J,s:`/webauthn/register/start`},finishWebauthnUserRegistration:{m:`POST`,b:J,s:`/webauthn/register/finish`},startWebauthnAuthentication:{m:`POST`,b:J,s:`/webauthn/authenticate/start`},finishWebauthnAuthentication:{m:`POST`,b:J,s:`/webauthn/authenticate/finish`}},Y=`/organizations/{organizationId}/orders`,ie={createOrder:{m:`POST`,b:Y,s:``},getOrder:{m:`GET`,b:Y,s:`/{orderNo}`},guestOrderLookup:{m:`POST`,b:Y,s:`/{orderNo}/lookup`},failOrder:{m:`POST`,b:Y,s:`/{orderNo}/actions/fail`},createPaymentInstrumentForOrder:{m:`POST`,b:Y,s:`/{orderNo}/payment-instruments`},removePaymentInstrumentFromOrder:{m:`DELETE`,b:Y,s:`/{orderNo}/payment-instruments/{paymentInstrumentId}`},updatePaymentInstrumentForOrder:{m:`PATCH`,b:Y,s:`/{orderNo}/payment-instruments/{paymentInstrumentId}`},getPaymentMethodsForOrder:{m:`GET`,b:Y,s:`/{orderNo}/payment-methods`},getTaxesFromOrder:{m:`GET`,b:Y,s:`/{orderNo}/taxes`}},ae={getPaymentConfiguration:{m:`GET`,b:`/organizations/{organizationId}`,s:`/payment-configuration`}},X=`/organizations/{organizationId}`,oe={getProducts:{m:`GET`,b:X,s:`/products`},getProduct:{m:`GET`,b:X,s:`/products/{id}`},getCategories:{m:`GET`,b:X,s:`/categories`},getCategory:{m:`GET`,b:X,s:`/categories/{id}`}},Z=`/organizations/{organizationId}/promotions`,se={getPromotions:{m:`GET`,b:Z,s:``},getPromotionsForCampaign:{m:`GET`,b:Z,s:`/campaigns/{campaignId}`}},Q=`/organizations/{organizationId}`,ce={productSearch:{m:`GET`,b:Q,s:`/product-search`},getSearchSuggestions:{m:`GET`,b:Q,s:`/search-suggestions`}},le={getUrlMapping:{m:`GET`,b:`/organizations/{organizationId}`,s:`/url-mapping`}},$=`/organizations/{organizationId}/store`,ue={getStores:{m:`GET`,b:$,s:`s`},searchStores:{m:`GET`,b:$,s:`-search`}};function de(e){let{baseUrl:t,fetch:n,querySerializer:i,organizationId:a,siteId:o,locale:s,clientId:c,clientSecret:l,redirectUri:u,onAuthTokenInvalid:d,proxyHost:f,...p}=e,m=!!f,h=m?I(a):a,g={baseUrl:t,organizationId:h,siteId:o,clientId:c,redirectUri:u},_=Object.entries(g).filter(([,e])=>!e).map(([e])=>e);if(_.length>0)throw Error(`Missing required configuration: ${_.join(`, `)}. These parameters are required for creating Commerce API clients.`);let v={...n?{fetch:n}:{},querySerializer:i||E,...p},b={organizationId:h,siteId:o,...s?{locale:s}:{}},x=d?{onAuthTokenInvalid:d}:void 0,C={organizationId:h,siteId:o},w=S(r({baseUrl:`${t}/checkout/shopper-baskets/v1`,...v}),R,b,x),T=S(r({baseUrl:`${t}/checkout/shopper-baskets/v2`,...v}),ee,b,x),D=S(r({baseUrl:`${t}/configuration/shopper-configurations/v1`,...v}),te,C,x),O=S(r({baseUrl:`${t}/shopper/shopper-consents/v1`,...v}),V,b,x),k=S(r({baseUrl:`${t}/shopper/shopper-context/v1`,...v}),ne,C,x),A=S(r({baseUrl:`${t}/customer/shopper-customers/v1`,...v}),W,C,x),j=S(r({baseUrl:`${t}/experience/shopper-experience/v1`,...v}),K,b,x),M=S(r({baseUrl:`${t}/pricing/shopper-gift-certificates/v1`,...v}),q,C,x),N=S(r({baseUrl:`${t}/shopper/auth/v1`,...v}),re,C,x),L=S(r({baseUrl:`${t}/checkout/shopper-orders/v1`,...v}),ie,b,x),z=S(r({baseUrl:`${t}/checkout/shopper-payments/v1`,...v}),ae,C,x),B=S(r({baseUrl:`${t}/product/shopper-products/v1`,...v}),oe,b,x),H=S(r({baseUrl:`${t}/pricing/shopper-promotions/v1`,...v}),se,b,x),U=S(r({baseUrl:`${t}/search/shopper-search/v1`,...v}),ce,b,x),G=S(r({baseUrl:`${t}/site/shopper-seo/v1`,...v}),le,b,x),J=S(r({baseUrl:`${t}/store/shopper-stores/v1`,...v}),ue,b,x),Y=[w,T,D,O,k,A,j,M,N,L,z,B,H,U,G,J];if(m&&h!==a){let e={onRequest({request:e}){let t=new URL(e.url);return y.some(e=>t.pathname.includes(e))?e:(t.pathname=t.pathname.replace(`/organizations/${h}/`,`/organizations/${a}/`),new Request(t,e))}};Y.forEach(t=>t.use(e))}return{shopperBasketsV1:w,shopperBasketsV2:T,shopperConfigurations:D,shopperConsents:O,shopperContext:k,shopperCustomers:A,shopperExperience:j,shopperGiftCertificates:M,shopperLogin:N,shopperOrders:L,shopperPayments:z,shopperProducts:B,shopperPromotions:H,shopperSearch:U,shopperSeo:G,shopperStores:J,auth:P({shopperLoginClient:N,clientId:c,clientSecret:l,redirectUri:u,organizationId:h,siteId:o,baseUrl:t,proxyHost:f}),basket:F({shopperBasketsClient:T}),use:e=>{Y.forEach(t=>t.use(e))}}}export{_ as ApiError,v as AuthTokenInvalidError,y as SLAS_AUTH_ENDPOINTS,F as createBasketHelpers,S as createClient,de as createCommerceApiClients,m as createFinalURL,s as createPathBasedClient,d as createQuerySerializer,p as defaultBodySerializer,f as defaultPathSerializer,h as mergeHeaders,n as randomID,g as removeTrailingSlash,u as serializeArrayParam,l as serializeObjectParam,c as serializePrimitiveParam,o as wrapAsPathBasedClient};
1
+ const e=/\{[^{}]+\}/g,t=()=>typeof process==`object`&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici;function n(){return Math.random().toString(36).slice(2,11)}function r(e){let{baseUrl:r=``,Request:i=globalThis.Request,fetch:a=globalThis.fetch,querySerializer:o,bodySerializer:s,headers:c,requestInitExt:l=void 0,...u}={...e};l=t()?l:void 0,r=g(r);let f=[];async function _(e,t){let{baseUrl:_,fetch:v=a,Request:y=i,headers:b,params:x={},parseAs:S=`json`,querySerializer:C,bodySerializer:w=s??p,body:T,middleware:E=[],...D}=t||{},O=r;_&&(O=g(_)??r);let k=typeof o==`function`?o:d(o);C&&(k=typeof C==`function`?C:d({...typeof o==`object`?o:{},...C}));let A=T===void 0?void 0:w(T,h(c,b,x.header)),j=h(A===void 0||A instanceof FormData?{}:{"Content-Type":`application/json`},c,b,x.header),M=[...f,...E],N={redirect:`follow`,...u,...D,body:A,headers:j},P,F,I=new y(m(e,{baseUrl:O,params:x,querySerializer:k}),N),L;for(let e in D)e in I||(I[e]=D[e]);if(M.length){P=n(),F=Object.freeze({baseUrl:O,fetch:v,parseAs:S,querySerializer:k,bodySerializer:w});for(let t of M)if(t&&typeof t==`object`&&typeof t.onRequest==`function`){let n=await t.onRequest({request:I,schemaPath:e,params:x,options:F,id:P});if(n)if(n instanceof y)I=n;else if(n instanceof Response){L=n;break}else throw Error(`onRequest: must return new Request() or Response() when modifying the request`)}}if(!L){try{L=await v(I,l)}catch(t){let n=t;if(M.length)for(let t=M.length-1;t>=0;t--){let r=M[t];if(r&&typeof r==`object`&&typeof r.onError==`function`){let t=await r.onError({request:I,error:n,schemaPath:e,params:x,options:F,id:P});if(t){if(t instanceof Response){n=void 0,L=t;break}if(t instanceof Error){n=t;continue}throw Error(`onError: must return new Response() or instance of Error`)}}}if(n)throw n}if(M.length)for(let t=M.length-1;t>=0;t--){let n=M[t];if(n&&typeof n==`object`&&typeof n.onResponse==`function`){let t=await n.onResponse({request:I,response:L,schemaPath:e,params:x,options:F,id:P});if(t){if(!(t instanceof Response))throw Error(`onResponse: must return new Response() when modifying the response`);L=t}}}}if(L.status===204||I.method===`HEAD`||L.headers.get(`Content-Length`)===`0`)return L.ok?{data:void 0,response:L}:{error:void 0,response:L};if(L.ok)return S===`stream`?{data:L.body,response:L}:{data:await L[S](),response:L};let R=await L.text();try{R=JSON.parse(R)}catch{}return{error:R,response:L}}return{request(e,t,n){return _(t,{...n,method:e.toUpperCase()})},GET(e,t){return _(e,{...t,method:`GET`})},PUT(e,t){return _(e,{...t,method:`PUT`})},POST(e,t){return _(e,{...t,method:`POST`})},DELETE(e,t){return _(e,{...t,method:`DELETE`})},OPTIONS(e,t){return _(e,{...t,method:`OPTIONS`})},HEAD(e,t){return _(e,{...t,method:`HEAD`})},PATCH(e,t){return _(e,{...t,method:`PATCH`})},TRACE(e,t){return _(e,{...t,method:`TRACE`})},use(...e){for(let t of e)if(t){if(typeof t!=`object`||!(`onRequest`in t||`onResponse`in t||`onError`in t))throw Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");f.push(t)}},eject(...e){for(let t of e){let e=f.indexOf(t);e!==-1&&f.splice(e,1)}}}}var i=class{constructor(e,t){this.client=e,this.url=t}GET=e=>this.client.GET(this.url,e);PUT=e=>this.client.PUT(this.url,e);POST=e=>this.client.POST(this.url,e);DELETE=e=>this.client.DELETE(this.url,e);OPTIONS=e=>this.client.OPTIONS(this.url,e);HEAD=e=>this.client.HEAD(this.url,e);PATCH=e=>this.client.PATCH(this.url,e);TRACE=e=>this.client.TRACE(this.url,e)},a=class{constructor(){this.client=null}get(e,t){let n=new i(e,t);return this.client[t]=n,n}};function o(e){let t=new a,n=new Proxy(e,t);function r(){}r.prototype=n;let i=new r;return t.client=i,i}function s(e){return o(r(e))}function c(e,t,n){if(t==null)return``;if(typeof t==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${n?.allowReserved===!0?t:encodeURIComponent(t)}`}function l(e,t,n){if(!t||typeof t!=`object`)return``;let r=[],i={simple:`,`,label:`.`,matrix:`;`}[n.style]||`&`;if(n.style!==`deepObject`&&n.explode===!1){for(let e in t)r.push(e,n.allowReserved===!0?t[e]:encodeURIComponent(t[e]));let i=r.join(`,`);switch(n.style){case`form`:return`${e}=${i}`;case`label`:return`.${i}`;case`matrix`:return`;${e}=${i}`;default:return i}}for(let i in t){let a=n.style===`deepObject`?`${e}[${i}]`:i;r.push(c(a,t[i],n))}let a=r.join(i);return n.style===`label`||n.style===`matrix`?`${i}${a}`:a}function u(e,t,n){if(!Array.isArray(t))return``;if(n.explode===!1){let r={form:`,`,spaceDelimited:`%20`,pipeDelimited:`|`}[n.style]||`,`,i=(n.allowReserved===!0?t:t.map(e=>encodeURIComponent(e))).join(r);switch(n.style){case`simple`:return i;case`label`:return`.${i}`;case`matrix`:return`;${e}=${i}`;default:return`${e}=${i}`}}let r={simple:`,`,label:`.`,matrix:`;`}[n.style]||`&`,i=[];for(let r of t)n.style===`simple`||n.style===`label`?i.push(n.allowReserved===!0?r:encodeURIComponent(r)):i.push(c(e,r,n));return n.style===`label`||n.style===`matrix`?`${r}${i.join(r)}`:i.join(r)}function d(e){return function(t){let n=[];if(t&&typeof t==`object`)for(let r in t){let i=t[r];if(i!=null){if(Array.isArray(i)){if(i.length===0)continue;n.push(u(r,i,{style:`form`,explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}));continue}if(typeof i==`object`){n.push(l(r,i,{style:`deepObject`,explode:!0,...e?.object,allowReserved:e?.allowReserved||!1}));continue}n.push(c(r,i,e))}}return n.join(`&`)}}function f(t,n){let r=t;for(let i of t.match(e)??[]){let e=i.substring(1,i.length-1),t=!1,a=`simple`;if(e.endsWith(`*`)&&(t=!0,e=e.substring(0,e.length-1)),e.startsWith(`.`)?(a=`label`,e=e.substring(1)):e.startsWith(`;`)&&(a=`matrix`,e=e.substring(1)),!n||n[e]===void 0||n[e]===null)continue;let o=n[e];if(Array.isArray(o)){r=r.replace(i,u(e,o,{style:a,explode:t}));continue}if(typeof o==`object`){r=r.replace(i,l(e,o,{style:a,explode:t}));continue}if(a===`matrix`){r=r.replace(i,`;${c(e,o)}`);continue}r=r.replace(i,a===`label`?`.${encodeURIComponent(o)}`:encodeURIComponent(o))}return r}function p(e,t){return e instanceof FormData?e:t&&(t.get instanceof Function?t.get(`Content-Type`)??t.get(`content-type`):t[`Content-Type`]??t[`content-type`])===`application/x-www-form-urlencoded`?new URLSearchParams(e).toString():JSON.stringify(e)}function m(e,t){let n=`${t.baseUrl}${e}`;t.params?.path&&(n=f(n,t.params.path));let r=t.querySerializer(t.params.query??{});return r.startsWith(`?`)&&(r=r.substring(1)),r&&(n+=`?${r}`),n}function h(...e){let t=new Headers;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n instanceof Headers?n.entries():Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,r)}return t}function g(e){return e.endsWith(`/`)?e.substring(0,e.length-1):e}var _=class e extends Error{status;statusText;headers;body;rawBody;url;method;constructor(t){let n=`API Error ${t.status}: ${t.statusText} (${t.method} ${t.url})`;super(n),this.name=`ApiError`,this.status=t.status,this.statusText=t.statusText,this.headers=t.headers,this.body=t.body,this.rawBody=t.rawBody,this.url=t.url,this.method=t.method,Error.captureStackTrace&&Error.captureStackTrace(this,e)}toJSON(){return{name:this.name,message:this.message,status:this.status,statusText:this.statusText,body:this.body,rawBody:this.rawBody,url:this.url,method:this.method,headers:Object.fromEntries(this.headers.entries())}}},v=class extends Error{constructor(e=`Access token is invalid or revoked`){super(e),this.name=`AuthTokenInvalidError`}};const y=[`/oauth2/token`,`/oauth2/authorize`,`/oauth2/logout`,`/oauth2/login`,`/oauth2/passwordless`,`/oauth2/password`,`/oauth2/session-bridge`,`/oauth2/trusted-agent`,`/oauth2/trusted-system`,`/oauth2/revoke`,`/oauth2/introspect`];function b(e,t){return t?{...e,params:{...e?.params,path:{organizationId:t.organizationId,...e?.params?.path},query:{siteId:t.siteId,...t.locale?{locale:t.locale}:{},...e?.params?.query}}}:e}const x=e=>{try{let t=new URL(e);return y.some(e=>t.pathname.includes(e))}catch{return y.some(t=>e.includes(t))}};function S(e,t,n,r){return new Proxy(e,{get(e,i){if(typeof i==`string`&&i in t){let{m:a,b:o,s}=t[i],c=o+s;return async function(t){let i=a.toUpperCase(),o=e[i];if(typeof o!=`function`)throw Error(`Client method ${i} not found. This is likely a bug in the proxy client.`);let s=b(t,n),l=s===void 0?await o.call(e,c):await o.call(e,c,s);if(l.error!==void 0){let e=l.response;if(e.status===401&&!x(e.url))throw r?.onAuthTokenInvalid?.(e),new v;let t=l.error,n;n=t&&typeof t==`object`&&`type`in t&&`title`in t&&`detail`in t?t:{type:`Unknown Error`,title:e.statusText||`API Error`,detail:`The API returned a ${e.status} error. See rawBody for details.`};let a;try{a=typeof t==`string`?t:JSON.stringify(t)}catch{a=String(t)}throw new _({status:e.status,statusText:e.statusText,headers:e.headers,body:n,rawBody:a,url:e.url,method:i})}return{data:l.data,response:l.response}}}if(i===`use`||i===`eject`){let t=e[i];return typeof t==`function`?t.bind(e):t}}})}const C=[`refine`],w=[`refine`];function T(e){let t=new Map;for(let n of e){let e=n.indexOf(`=`);if(e===-1)continue;let r=n.substring(0,e),i=n.substring(e+1);t.has(r)||t.set(r,[]);let a=t.get(r);a&&a.push(i)}return Array.from(t.entries()).map(([e,t])=>`${e}=${t.join(`|`)}`)}function E(e){if(!e||typeof e!=`object`)return``;let t=d({array:{style:`form`,explode:!1}}),n=d({array:{style:`form`,explode:!0}}),r=[];for(let[i,a]of Object.entries(e)){if(a==null)continue;let e=a;w.includes(i)&&Array.isArray(a)&&(e=T(a));let o=(C.includes(i)?n:t)({[i]:e});o&&r.push(o)}return r.join(`&`)}function D(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function O(){let e=new Uint8Array(128);crypto.getRandomValues(e);let t=``;for(let n=0;n<e.length;n++)t+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`[e[n]%64];return t}async function k(e){let t=new TextEncoder().encode(e),n=D(await crypto.subtle.digest(`SHA-256`,t));if(n.length===0)throw Error(`Problem generating code challenge`);return n}function A(e){let t=new URL(e),n=new URLSearchParams(t.search),r=n.get(`usid`)??``;return{code:n.get(`code`)??``,usid:r}}function j(e,t){let n=`${e}:${t}`;return`Basic ${btoa(n)}`}function M(e,t){let n=e.headers.get(`set-cookie`);if(!n)return;let r=RegExp(`${t}=([^;]+)`);return n.match(r)?.[1]}const N={"Content-Type":`application/x-www-form-urlencoded`};function P(e){let{shopperLoginClient:t,clientId:n,clientSecret:r,redirectUri:i,siteId:a,baseUrl:o,organizationId:s,proxyHost:c}=e,l=!!r;function u(e){let t=M(e.response,`dwsid`);return{...e.data,dwsid:t}}async function d(e={}){let{usid:i,dnt:o}=e,s=await t.getAccessToken({params:{...r&&{header:{Authorization:j(n,r)}}},headers:N,body:{grant_type:`client_credentials`,channel_id:a,...i&&{usid:i},...o!==void 0&&{dnt:o.toString()}}});return{data:s.data,response:s.response}}async function f(e={}){let{usid:r,dnt:o}=e,s=O(),c=await k(s),{code:l,usid:u}=A((await t.authorizeCustomer({params:{query:{client_id:n,channel_id:a,redirect_uri:i,response_type:`code`,hint:`guest`,code_challenge:c,...r&&{usid:r}}},redirect:`manual`})).response.headers.get(`location`)||``);if(!l)throw Error(`Failed to get authorization code from guest login`);let d=await t.getAccessToken({params:{},headers:N,body:{grant_type:`authorization_code_pkce`,client_id:n,channel_id:a,code:l,code_verifier:s,redirect_uri:i,usid:u,...o!==void 0&&{dnt:o.toString()}}});return{data:d.data,response:d.response}}return{loginAsGuest:async(e={})=>u(c||l?await d(e):await f(e)),loginWithCredentials:async e=>{let{username:o,password:s,usid:c,dnt:d}=e,f=O(),p=await k(f),{code:m,usid:h}=A((await t.authenticateCustomer({params:{header:{Authorization:`Basic ${btoa(`${o}:${s}`)}`}},headers:N,body:{client_id:n,channel_id:a,redirect_uri:i,response_type:`code`,code_challenge:p,...c&&{usid:c}},redirect:`manual`})).response.headers.get(`location`)||``);if(!m)throw Error(`Failed to get authorization code from credentials login`);let g={grant_type:`authorization_code_pkce`,client_id:n,channel_id:a,code:m,code_verifier:f,redirect_uri:i,usid:h,...d!==void 0&&{dnt:d.toString()}};if(l&&r){let e=await t.getAccessToken({params:{header:{Authorization:j(n,r)}},headers:N,body:g});return u({data:e.data,response:e.response})}let _=await t.getAccessToken({params:{},headers:N,body:g});return u({data:_.data,response:_.response})},refreshToken:async e=>{let{refreshToken:i,dnt:o}=e,s={grant_type:`refresh_token`,refresh_token:i,client_id:n,channel_id:a,...o!==void 0&&{dnt:o.toString()}};if(l&&r){let e=await t.getAccessToken({params:{header:{Authorization:j(n,r)}},headers:N,body:s});return u({data:e.data,response:e.response})}let c=await t.getAccessToken({params:{},headers:N,body:s});return u({data:c.data,response:c.response})},logout:async e=>{let{accessToken:r,refreshToken:i}=e;return(await t.logoutCustomer({params:{header:{Authorization:`Bearer ${r}`},query:{client_id:n,channel_id:a,refresh_token:i}}})).data},social:{getAuthorizationUrl:async e=>{let{hint:t,redirectUri:r,usid:c}=e,l=O(),u=await k(l),d=r||i,f=o.endsWith(`/`)?o:`${o}/`,p=`shopper/auth/v1/organizations/${s}/oauth2/authorize`,m=new URL(p,f);return m.searchParams.set(`client_id`,n),m.searchParams.set(`channel_id`,a),m.searchParams.set(`redirect_uri`,d),m.searchParams.set(`response_type`,`code`),m.searchParams.set(`hint`,t),m.searchParams.set(`code_challenge`,u),c&&m.searchParams.set(`usid`,c),{url:m.toString(),codeVerifier:l}},exchangeCode:async e=>{let{code:i,codeVerifier:o,redirectUri:s,usid:c,dnt:d}=e,f={grant_type:`authorization_code_pkce`,client_id:n,channel_id:a,code:i,code_verifier:o,redirect_uri:s,...c&&{usid:c},...d!==void 0&&{dnt:d.toString()}};if(l&&r){let e=await t.getAccessToken({params:{header:{Authorization:j(n,r)}},headers:N,body:f});return u({data:e.data,response:e.response})}let p=await t.getAccessToken({params:{},headers:N,body:f});return u({data:p.data,response:p.response})}},passwordless:{authorize:async e=>{let{userId:i,callbackUri:o,usid:s,mode:c=`email`,locale:l,registerCustomer:u,lastName:d,email:f,firstName:p,phoneNumber:m,customerNo:h}=e;if(!r)throw Error(`Client secret is required for passwordless login`);if(c===`callback`&&!o)throw Error(`callbackUri is required for callback mode`);let g={user_id:i,mode:c,channel_id:a,...c===`callback`&&o&&{callback_uri:o},...s&&{usid:s},...l&&{locale:l},...u&&d&&{last_name:d},...u&&f&&{email:f},...u&&p&&{first_name:p},...m&&{phone_number:m},...h&&{customer_no:h}};return t.authorizePasswordlessCustomer({params:{header:{Authorization:j(n,r)},...u===!0&&{query:{register_customer:`true`}}},headers:N,body:g})},exchangeToken:async e=>{let{pwdlessLoginToken:i,usid:a,dnt:o}=e;if(!r)throw Error(`Client secret is required for passwordless token exchange`);let s=O(),c=await t.getPasswordLessAccessToken({params:{header:{Authorization:j(n,r)}},headers:N,body:{grant_type:`client_credentials`,hint:`pwdless_login`,pwdless_login_token:i,code_verifier:s,...a&&{usid:a},...o!==void 0&&{dnt:o.toString()}}});return u({data:c.data,response:c.response})}},password:{requestReset:async e=>{let{userId:i,callbackUri:o,mode:s=`email`,locale:c,codeChallenge:u,hint:d=`cross_device`}=e;if(s===`callback`&&!o)throw Error(`callbackUri is required when mode is "callback"`);let f={...N};return l&&r&&(f.Authorization=j(n,r)),t.getPasswordResetToken({params:{},headers:f,body:{user_id:i,mode:s,channel_id:a,client_id:n,...s===`callback`&&o&&{callback_uri:o},hint:d,...c&&{locale:c},...u&&{code_challenge:u}}})},reset:async e=>{let{userId:i,token:o,newPassword:s,codeVerifier:c,hint:u=`cross_device`}=e,d={client_id:n,user_id:i,pwd_action_token:o,new_password:s,channel_id:a,hint:u,...c&&{code_verifier:c}};return l&&r?t.resetPassword({params:{header:{Authorization:j(n,r)}},headers:N,body:d}):t.resetPassword({params:{},headers:N,body:d})}}}}function F(e){let{shopperBasketsClient:t}=e;async function n(e){let n=e.params?.path?.basketId,r=e.body.currency,i=async()=>{try{let{data:e}=await t.createBasket({params:{query:{populateCustomerDetails:!0}},body:{currency:r}});return e}catch(e){if(e instanceof _){let n=e.body?.basketIds,r=(Array.isArray(n)?n:[n].filter(Boolean)).at(0);if((e.status===429||e.status===400)&&r){let{data:e}=await t.getBasket({params:{path:{basketId:r}}});return e}}throw e}};if(n)try{let{data:e}=await t.getBasket({params:{path:{basketId:n}}});return e}catch(e){if(e instanceof _){if(e.status===404||e.status===400)return i();let n=e.body?.basketIds,r=(Array.isArray(n)?n:[n].filter(Boolean)).at(0);if(e.status===429&&r){let{data:e}=await t.getBasket({params:{path:{basketId:r}}});return e}}throw e}return i()}return{getOrCreateBasket:n}}function I(e){return e.replace(/^f_ecom_/,``)}const L=`/organizations/{organizationId}/baskets`,R={createBasket:{m:`POST`,b:L,s:``},transferBasket:{m:`POST`,b:L,s:`/actions/transfer`},mergeBasket:{m:`POST`,b:L,s:`/actions/merge`},getBasket:{m:`GET`,b:L,s:`/{basketId}`},deleteBasket:{m:`DELETE`,b:L,s:`/{basketId}`},updateBasket:{m:`PATCH`,b:L,s:`/{basketId}`},updateAsAgentBasket:{m:`PUT`,b:L,s:`/{basketId}/agent`},updateBillingAddressForBasket:{m:`PUT`,b:L,s:`/{basketId}/billing-address`},addCouponToBasket:{m:`POST`,b:L,s:`/{basketId}/coupons`},removeCouponFromBasket:{m:`DELETE`,b:L,s:`/{basketId}/coupons/{couponItemId}`},updateCustomerForBasket:{m:`PUT`,b:L,s:`/{basketId}/customer`},addGiftCertificateItemToBasket:{m:`POST`,b:L,s:`/{basketId}/gift-certificate-items`},removeGiftCertificateItemFromBasket:{m:`DELETE`,b:L,s:`/{basketId}/gift-certificate-items/{giftCertificateItemId}`},updateGiftCertificateItemInBasket:{m:`PATCH`,b:L,s:`/{basketId}/gift-certificate-items/{giftCertificateItemId}`},addItemToBasket:{m:`POST`,b:L,s:`/{basketId}/items`},updateItemsInBasket:{m:`PATCH`,b:L,s:`/{basketId}/items`},removeItemFromBasket:{m:`DELETE`,b:L,s:`/{basketId}/items/{itemId}`},updateItemInBasket:{m:`PATCH`,b:L,s:`/{basketId}/items/{itemId}`},addTaxesForBasketItem:{m:`PUT`,b:L,s:`/{basketId}/items/{itemId}/taxes`},addPaymentInstrumentToBasket:{m:`POST`,b:L,s:`/{basketId}/payment-instruments`},removePaymentInstrumentFromBasket:{m:`DELETE`,b:L,s:`/{basketId}/payment-instruments/{paymentInstrumentId}`},updatePaymentInstrumentInBasket:{m:`PATCH`,b:L,s:`/{basketId}/payment-instruments/{paymentInstrumentId}`},getPaymentMethodsForBasket:{m:`GET`,b:L,s:`/{basketId}/payment-methods`},addPriceAdjustmentToBasket:{m:`POST`,b:L,s:`/{basketId}/price-adjustments`},removePriceAdjustmentFromBasket:{m:`DELETE`,b:L,s:`/{basketId}/price-adjustments/{priceAdjustmentId}`},updatePriceAdjustmentInBasket:{m:`PATCH`,b:L,s:`/{basketId}/price-adjustments/{priceAdjustmentId}`},getPriceBooksForBasket:{m:`GET`,b:L,s:`/{basketId}/price-books`},addPriceBooksToBasket:{m:`PUT`,b:L,s:`/{basketId}/price-books`},createShipmentForBasket:{m:`POST`,b:L,s:`/{basketId}/shipments`},removeShipmentFromBasket:{m:`DELETE`,b:L,s:`/{basketId}/shipments/{shipmentId}`},updateShipmentForBasket:{m:`PATCH`,b:L,s:`/{basketId}/shipments/{shipmentId}`},updateShippingAddressForShipment:{m:`PUT`,b:L,s:`/{basketId}/shipments/{shipmentId}/shipping-address`},updateShippingMethodForShipment:{m:`PUT`,b:L,s:`/{basketId}/shipments/{shipmentId}/shipping-method`},getShippingMethodsForShipment:{m:`GET`,b:L,s:`/{basketId}/shipments/{shipmentId}/shipping-methods`},updateAsStorefrontBasket:{m:`PUT`,b:L,s:`/{basketId}/storefront`},getTaxesFromBasket:{m:`GET`,b:L,s:`/{basketId}/taxes`},addTaxesForBasket:{m:`PUT`,b:L,s:`/{basketId}/taxes`}},z=`/organizations/{organizationId}/baskets`,ee={createBasket:{m:`POST`,b:z,s:``},transferBasket:{m:`POST`,b:z,s:`/actions/transfer`},mergeBasket:{m:`POST`,b:z,s:`/actions/merge`},getBasket:{m:`GET`,b:z,s:`/{basketId}`},deleteBasket:{m:`DELETE`,b:z,s:`/{basketId}`},updateBasket:{m:`PATCH`,b:z,s:`/{basketId}`},updateAsAgentBasket:{m:`PUT`,b:z,s:`/{basketId}/agent`},updateBillingAddressForBasket:{m:`PUT`,b:z,s:`/{basketId}/billing-address`},addCouponToBasket:{m:`POST`,b:z,s:`/{basketId}/coupons`},removeCouponFromBasket:{m:`DELETE`,b:z,s:`/{basketId}/coupons/{couponItemId}`},updateCustomerForBasket:{m:`PUT`,b:z,s:`/{basketId}/customer`},addGiftCertificateItemToBasket:{m:`POST`,b:z,s:`/{basketId}/gift-certificate-items`},removeGiftCertificateItemFromBasket:{m:`DELETE`,b:z,s:`/{basketId}/gift-certificate-items/{giftCertificateItemId}`},updateGiftCertificateItemInBasket:{m:`PATCH`,b:z,s:`/{basketId}/gift-certificate-items/{giftCertificateItemId}`},addItemToBasket:{m:`POST`,b:z,s:`/{basketId}/items`},updateItemsInBasket:{m:`PATCH`,b:z,s:`/{basketId}/items`},removeItemFromBasket:{m:`DELETE`,b:z,s:`/{basketId}/items/{itemId}`},updateItemInBasket:{m:`PATCH`,b:z,s:`/{basketId}/items/{itemId}`},addTaxesForBasketItem:{m:`PUT`,b:z,s:`/{basketId}/items/{itemId}/taxes`},addPaymentInstrumentToBasket:{m:`POST`,b:z,s:`/{basketId}/payment-instruments`},removePaymentInstrumentFromBasket:{m:`DELETE`,b:z,s:`/{basketId}/payment-instruments/{paymentInstrumentId}`},updatePaymentInstrumentInBasket:{m:`PATCH`,b:z,s:`/{basketId}/payment-instruments/{paymentInstrumentId}`},getPaymentMethodsForBasket:{m:`GET`,b:z,s:`/{basketId}/payment-methods`},addPriceAdjustmentToBasket:{m:`POST`,b:z,s:`/{basketId}/price-adjustments`},removePriceAdjustmentFromBasket:{m:`DELETE`,b:z,s:`/{basketId}/price-adjustments/{priceAdjustmentId}`},updatePriceAdjustmentInBasket:{m:`PATCH`,b:z,s:`/{basketId}/price-adjustments/{priceAdjustmentId}`},getPriceBooksForBasket:{m:`GET`,b:z,s:`/{basketId}/price-books`},addPriceBooksToBasket:{m:`PUT`,b:z,s:`/{basketId}/price-books`},createShipmentForBasket:{m:`POST`,b:z,s:`/{basketId}/shipments`},removeShipmentFromBasket:{m:`DELETE`,b:z,s:`/{basketId}/shipments/{shipmentId}`},updateShipmentForBasket:{m:`PATCH`,b:z,s:`/{basketId}/shipments/{shipmentId}`},updateShippingAddressForShipment:{m:`PUT`,b:z,s:`/{basketId}/shipments/{shipmentId}/shipping-address`},updateShippingMethodForShipment:{m:`PUT`,b:z,s:`/{basketId}/shipments/{shipmentId}/shipping-method`},getShippingMethodsForShipment:{m:`GET`,b:z,s:`/{basketId}/shipments/{shipmentId}/shipping-methods`},updateAsStorefrontBasket:{m:`PUT`,b:z,s:`/{basketId}/storefront`},getTaxesFromBasket:{m:`GET`,b:z,s:`/{basketId}/taxes`},addTaxesForBasket:{m:`PUT`,b:z,s:`/{basketId}/taxes`}},te={getConfigurations:{m:`GET`,b:`/organizations/{organizationId}`,s:`/configurations`}},B=`/organizations/{organizationId}/subscriptions`,V={getSubscriptions:{m:`GET`,b:B,s:``},updateSubscription:{m:`POST`,b:B,s:``},updateSubscriptions:{m:`POST`,b:B,s:`/actions/bulk`}},H=`/organizations/{organizationId}/shopper-context/{usid}`,ne={getShopperContext:{m:`GET`,b:H,s:``},createShopperContext:{m:`PUT`,b:H,s:``},deleteShopperContext:{m:`DELETE`,b:H,s:``},updateShopperContext:{m:`PATCH`,b:H,s:``}},U=`/organizations/{organizationId}`,W={registerCustomer:{m:`POST`,b:U,s:`/customers`},resetPassword:{m:`POST`,b:U,s:`/customers/password/actions/reset`},getResetPasswordToken:{m:`POST`,b:U,s:`/customers/password/actions/create-reset-token`},getExternalProfile:{m:`GET`,b:U,s:`/customers/external-profile`},registerExternalProfile:{m:`POST`,b:U,s:`/customers/external-profile`},getCustomer:{m:`GET`,b:U,s:`/customers/{customerId}`},updateCustomer:{m:`PATCH`,b:U,s:`/customers/{customerId}`},createCustomerAddress:{m:`POST`,b:U,s:`/customers/{customerId}/addresses`},getCustomerAddress:{m:`GET`,b:U,s:`/customers/{customerId}/addresses/{addressName}`},removeCustomerAddress:{m:`DELETE`,b:U,s:`/customers/{customerId}/addresses/{addressName}`},updateCustomerAddress:{m:`PATCH`,b:U,s:`/customers/{customerId}/addresses/{addressName}`},getCustomerBaskets:{m:`GET`,b:U,s:`/customers/{customerId}/baskets`},getCustomerOrders:{m:`GET`,b:U,s:`/customers/{customerId}/orders`},updateCustomerPassword:{m:`PUT`,b:U,s:`/customers/{customerId}/password`},createCustomerPaymentInstrument:{m:`POST`,b:U,s:`/customers/{customerId}/payment-instruments`},getCustomerPaymentInstrument:{m:`GET`,b:U,s:`/customers/{customerId}/payment-instruments/{paymentInstrumentId}`},deleteCustomerPaymentInstrument:{m:`DELETE`,b:U,s:`/customers/{customerId}/payment-instruments/{paymentInstrumentId}`},updateCustomerPaymentInstrument:{m:`PATCH`,b:U,s:`/customers/{customerId}/payment-instruments/{paymentInstrumentId}`},getCustomerProductLists:{m:`GET`,b:U,s:`/customers/{customerId}/product-lists`},createCustomerProductList:{m:`POST`,b:U,s:`/customers/{customerId}/product-lists`},getCustomerProductList:{m:`GET`,b:U,s:`/customers/{customerId}/product-lists/{listId}`},deleteCustomerProductList:{m:`DELETE`,b:U,s:`/customers/{customerId}/product-lists/{listId}`},updateCustomerProductList:{m:`PATCH`,b:U,s:`/customers/{customerId}/product-lists/{listId}`},createCustomerProductListItem:{m:`POST`,b:U,s:`/customers/{customerId}/product-lists/{listId}/items`},getCustomerProductListItem:{m:`GET`,b:U,s:`/customers/{customerId}/product-lists/{listId}/items/{itemId}`},deleteCustomerProductListItem:{m:`DELETE`,b:U,s:`/customers/{customerId}/product-lists/{listId}/items/{itemId}`},updateCustomerProductListItem:{m:`PATCH`,b:U,s:`/customers/{customerId}/product-lists/{listId}/items/{itemId}`},getPublicProductListsBySearchTerm:{m:`GET`,b:U,s:`/product-lists`},getPublicProductList:{m:`GET`,b:U,s:`/product-lists/{listId}`},getPublicProductListItems:{m:`GET`,b:U,s:`/product-lists/{listId}/items`},getProductListItem:{m:`GET`,b:U,s:`/product-lists/{listId}/items/{itemId}`}},G=`/organizations/{organizationId}`,K={getPages:{m:`GET`,b:G,s:`/pages`},getPage:{m:`GET`,b:G,s:`/pages/{pageId}`},getContent:{m:`GET`,b:G,s:`/contents/{id}`},getMultipleContent:{m:`GET`,b:G,s:`/contents`},searchContent:{m:`GET`,b:G,s:`/content-search`},getContentFolder:{m:`GET`,b:G,s:`/folders/{id}`},getContentFolders:{m:`GET`,b:G,s:`/folders`},resolveQualifiers:{m:`POST`,b:G,s:`/qualifiers/resolve`}},q={getGiftCertificate:{m:`POST`,b:`/organizations/{organizationId}`,s:`/gift-certificate`}},J=`/organizations/{organizationId}/oauth2`,re={authenticateCustomer:{m:`POST`,b:J,s:`/login`},authorizePasswordlessCustomer:{m:`POST`,b:J,s:`/passwordless/login`},logoutCustomer:{m:`GET`,b:J,s:`/logout`},authorizeCustomer:{m:`GET`,b:J,s:`/authorize`},getAccessToken:{m:`POST`,b:J,s:`/token`},getSessionBridgeAccessToken:{m:`POST`,b:J,s:`/session-bridge/token`},getTrustedSystemAccessToken:{m:`POST`,b:J,s:`/trusted-system/token`},getTrustedAgentAuthorizationToken:{m:`GET`,b:J,s:`/trusted-agent/authorize`},getTrustedAgentAccessToken:{m:`POST`,b:J,s:`/trusted-agent/token`},getPasswordResetToken:{m:`POST`,b:J,s:`/password/reset`},resetPassword:{m:`POST`,b:J,s:`/password/action`},getPasswordLessAccessToken:{m:`POST`,b:J,s:`/passwordless/token`},revokeToken:{m:`POST`,b:J,s:`/revoke`},introspectToken:{m:`POST`,b:J,s:`/introspect`},getUserInfo:{m:`GET`,b:J,s:`/userinfo`},getWellknownOpenidConfiguration:{m:`GET`,b:J,s:`/.well-known/openid-configuration`},getJwksUri:{m:`GET`,b:J,s:`/jwks`},authorizeWebauthnRegistration:{m:`POST`,b:J,s:`/webauthn/register/authorize`},startWebauthnUserRegistration:{m:`POST`,b:J,s:`/webauthn/register/start`},finishWebauthnUserRegistration:{m:`POST`,b:J,s:`/webauthn/register/finish`},startWebauthnAuthentication:{m:`POST`,b:J,s:`/webauthn/authenticate/start`},finishWebauthnAuthentication:{m:`POST`,b:J,s:`/webauthn/authenticate/finish`}},Y=`/organizations/{organizationId}/orders`,ie={createOrder:{m:`POST`,b:Y,s:``},getOrder:{m:`GET`,b:Y,s:`/{orderNo}`},guestOrderLookup:{m:`POST`,b:Y,s:`/{orderNo}/lookup`},failOrder:{m:`POST`,b:Y,s:`/{orderNo}/actions/fail`},createPaymentInstrumentForOrder:{m:`POST`,b:Y,s:`/{orderNo}/payment-instruments`},removePaymentInstrumentFromOrder:{m:`DELETE`,b:Y,s:`/{orderNo}/payment-instruments/{paymentInstrumentId}`},updatePaymentInstrumentForOrder:{m:`PATCH`,b:Y,s:`/{orderNo}/payment-instruments/{paymentInstrumentId}`},getPaymentMethodsForOrder:{m:`GET`,b:Y,s:`/{orderNo}/payment-methods`},getTaxesFromOrder:{m:`GET`,b:Y,s:`/{orderNo}/taxes`}},ae={getPaymentConfiguration:{m:`GET`,b:`/organizations/{organizationId}`,s:`/payment-configuration`}},X=`/organizations/{organizationId}`,oe={getProducts:{m:`GET`,b:X,s:`/products`},getProduct:{m:`GET`,b:X,s:`/products/{id}`},getCategories:{m:`GET`,b:X,s:`/categories`},getCategory:{m:`GET`,b:X,s:`/categories/{id}`}},Z=`/organizations/{organizationId}/promotions`,se={getPromotions:{m:`GET`,b:Z,s:``},getPromotionsForCampaign:{m:`GET`,b:Z,s:`/campaigns/{campaignId}`}},Q=`/organizations/{organizationId}`,ce={productSearch:{m:`GET`,b:Q,s:`/product-search`},getSearchSuggestions:{m:`GET`,b:Q,s:`/search-suggestions`}},le={getUrlMapping:{m:`GET`,b:`/organizations/{organizationId}`,s:`/url-mapping`}},$=`/organizations/{organizationId}/store`,ue={getStores:{m:`GET`,b:$,s:`s`},searchStores:{m:`GET`,b:$,s:`-search`}};function de(e){let{baseUrl:t,fetch:n,querySerializer:i,organizationId:a,siteId:o,locale:s,clientId:c,clientSecret:l,redirectUri:u,onAuthTokenInvalid:d,proxyHost:f,...p}=e,m=!!f,h=m?I(a):a,g={baseUrl:t,organizationId:h,siteId:o,clientId:c,redirectUri:u},_=Object.entries(g).filter(([,e])=>!e).map(([e])=>e);if(_.length>0)throw Error(`Missing required configuration: ${_.join(`, `)}. These parameters are required for creating Commerce API clients.`);let v={...n?{fetch:n}:{},querySerializer:i||E,...p},b={organizationId:h,siteId:o,...s?{locale:s}:{}},x=d?{onAuthTokenInvalid:d}:void 0,C={organizationId:h,siteId:o},w=S(r({baseUrl:`${t}/checkout/shopper-baskets/v1`,...v}),R,b,x),T=S(r({baseUrl:`${t}/checkout/shopper-baskets/v2`,...v}),ee,b,x),D=S(r({baseUrl:`${t}/configuration/shopper-configurations/v1`,...v}),te,C,x),O=S(r({baseUrl:`${t}/shopper/shopper-consents/v1`,...v}),V,b,x),k=S(r({baseUrl:`${t}/shopper/shopper-context/v1`,...v}),ne,C,x),A=S(r({baseUrl:`${t}/customer/shopper-customers/v1`,...v}),W,C,x),j=S(r({baseUrl:`${t}/experience/shopper-experience/v1`,...v}),K,b,x),M=S(r({baseUrl:`${t}/pricing/shopper-gift-certificates/v1`,...v}),q,C,x),N=S(r({baseUrl:`${t}/shopper/auth/v1`,...v}),re,C,x),L=S(r({baseUrl:`${t}/checkout/shopper-orders/v1`,...v}),ie,b,x),z=S(r({baseUrl:`${t}/checkout/shopper-payments/v1`,...v}),ae,C,x),B=S(r({baseUrl:`${t}/product/shopper-products/v1`,...v}),oe,b,x),H=S(r({baseUrl:`${t}/pricing/shopper-promotions/v1`,...v}),se,b,x),U=S(r({baseUrl:`${t}/search/shopper-search/v1`,...v}),ce,b,x),G=S(r({baseUrl:`${t}/site/shopper-seo/v1`,...v}),le,b,x),J=S(r({baseUrl:`${t}/store/shopper-stores/v1`,...v}),ue,b,x),Y=[w,T,D,O,k,A,j,M,N,L,z,B,H,U,G,J];if(m&&h!==a){let e={onRequest({request:e}){let t=new URL(e.url);return y.some(e=>t.pathname.includes(e))?e:(t.pathname=t.pathname.replace(`/organizations/${h}/`,`/organizations/${a}/`),new Request(t,e))}};Y.forEach(t=>t.use(e))}return{shopperBasketsV1:w,shopperBasketsV2:T,shopperConfigurations:D,shopperConsents:O,shopperContext:k,shopperCustomers:A,shopperExperience:j,shopperGiftCertificates:M,shopperLogin:N,shopperOrders:L,shopperPayments:z,shopperProducts:B,shopperPromotions:H,shopperSearch:U,shopperSeo:G,shopperStores:J,auth:P({shopperLoginClient:N,clientId:c,clientSecret:l,redirectUri:u,organizationId:h,siteId:o,baseUrl:t,proxyHost:f}),basket:F({shopperBasketsClient:T}),use:e=>{Y.forEach(t=>t.use(e))}}}export{_ as ApiError,v as AuthTokenInvalidError,y as SLAS_AUTH_ENDPOINTS,F as createBasketHelpers,S as createClient,de as createCommerceApiClients,m as createFinalURL,r as createOpenApiFetchClient,s as createPathBasedClient,d as createQuerySerializer,p as defaultBodySerializer,f as defaultPathSerializer,E as defaultQuerySerializer,h as mergeHeaders,n as randomID,g as removeTrailingSlash,u as serializeArrayParam,l as serializeObjectParam,c as serializePrimitiveParam,o as wrapAsPathBasedClient};
2
2
  //# sourceMappingURL=scapi.js.map