@nosto/nosto-react 0.5.0 → 1.0.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.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(R,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("react-dom/client")):typeof define=="function"&&define.amd?define(["exports","react","react-dom/client"],b):(R=typeof globalThis<"u"?globalThis:R||self,b(R["@nosto/nosto-react"]={},R.React,R.ReactDOM))})(this,function(R,b,ze){"use strict";const oe=b.createContext({account:"",currentVariation:"",pageType:"",responseMode:"HTML",clientScriptLoaded:!1,useRenderCampaigns:()=>({renderCampaigns:()=>{},pageTypeUpdated:!1})});function F(){const o=b.useContext(oe);if(!o)throw new Error("No nosto context found");return o}const Ce=o=>String(o)==="[object Object]";function be(o){if(!Ce(o))return!1;const s=o.constructor;if(s===void 0)return!0;const r=s.prototype;return!(!Ce(r)||!r.hasOwnProperty("isPrototypeOf"))}function se(o,s){if(o===s)return!0;if(o instanceof Date&&s instanceof Date)return o.getTime()===s.getTime();if(o instanceof Array&&s instanceof Array)return o.length!==s.length?!1:o.every((r,d)=>se(r,s[d]));if(be(o)&&be(s)){const r=Object.entries(o);return r.length!==Object.keys(s).length?!1:r.every(([d,m])=>se(m,s[d]))}return!1}function Ee(o,s){return b.useEffect(o,Ke(s))}function Ke(o){const s=b.useRef(o),r=b.useRef(0);return se(o,s.current)||(s.current=o,r.current+=1),b.useMemo(()=>s.current,[r.current])}function $(o,s,r){const{clientScriptLoaded:d,currentVariation:m,responseMode:u}=F();(r!=null&&r.deep?Ee:b.useEffect)(()=>{d&&window.nostojs(y=>{y.defaultSession().setVariation(m).setResponseMode(u),o(y)})},[d,m,u,...s??[]])}var ie={exports:{}},H={};/**
1
+ (function(C,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("react"),require("react-dom/client")):typeof define=="function"&&define.amd?define(["exports","react","react-dom/client"],h):(C=typeof globalThis<"u"?globalThis:C||self,h(C["@nosto/nosto-react"]={},C.React,C.ReactDOM))})(this,function(C,h,He){"use strict";const ne=h.createContext({account:"",currentVariation:"",pageType:"",responseMode:"HTML",clientScriptLoaded:!1,useRenderCampaigns:()=>({renderCampaigns:()=>{},pageTypeUpdated:!1})});function x(){const n=h.useContext(ne);if(!n)throw new Error("No nosto context found");return n}const ge=n=>String(n)==="[object Object]";function ye(n){if(!ge(n))return!1;const o=n.constructor;if(o===void 0)return!0;const a=o.prototype;return!(!ge(a)||!a.hasOwnProperty("isPrototypeOf"))}function oe(n,o){if(n===o)return!0;if(n instanceof Date&&o instanceof Date)return n.getTime()===o.getTime();if(n instanceof Array&&o instanceof Array)return n.length!==o.length?!1:n.every((a,u)=>oe(a,o[u]));if(ye(n)&&ye(o)){const a=Object.entries(n);return a.length!==Object.keys(o).length?!1:a.every(([u,d])=>oe(d,o[u]))}return!1}function he(n,o){return h.useEffect(n,Je(o))}function Je(n){const o=h.useRef(n),a=h.useRef(0);return oe(n,o.current)||(o.current=n,a.current+=1),h.useMemo(()=>o.current,[a.current])}function L(n,o,a){const{clientScriptLoaded:u,currentVariation:d,responseMode:c}=x();(a!=null&&a.deep?he:h.useEffect)(()=>{u&&window.nostojs(p=>{p.defaultSession().setVariation(d).setResponseMode(c),n(p)})},[u,d,c,...o??[]])}function ze(n){const{recommendationComponent:o,useRenderCampaigns:a}=x(),{renderCampaigns:u,pageTypeUpdated:d}=a("404");return L(async c=>{const i=await c.defaultSession().viewNotFound().setPlacements(n.placements||c.placements.getPlacements()).load();u(i,c)},[o,d]),null}function Ge(n){const{recommendationComponent:o,useRenderCampaigns:a}=x(),{renderCampaigns:u,pageTypeUpdated:d}=a("other");return L(async c=>{const i=await c.defaultSession().viewOther().setPlacements(n.placements||c.placements.getPlacements()).load();u(i,c)},[o,d]),null}function Ke(n){const{recommendationComponent:o,useRenderCampaigns:a}=x(),{renderCampaigns:u,pageTypeUpdated:d}=a("checkout");return L(async c=>{const i=await c.defaultSession().viewCart().setPlacements(n.placements||c.placements.getPlacements()).load();u(i,c)},[o,d]),null}function Xe(n){const{product:o,tagging:a,placements:u}=n,{recommendationComponent:d,useRenderCampaigns:c}=x(),{renderCampaigns:i,pageTypeUpdated:p}=c("product");return L(async v=>{const N=await v.defaultSession().viewProduct(a??o).setPlacements(u||v.placements.getPlacements()).load();i(N,v)},[o,d,p],{deep:!0}),null}function Ze(n){const{category:o,placements:a}=n,{recommendationComponent:u,useRenderCampaigns:d}=x(),{renderCampaigns:c,pageTypeUpdated:i}=d("home");return L(async p=>{const v=await p.defaultSession().viewCategory(o).setPlacements(a||p.placements.getPlacements()).load();c(v,p)},[o,u,i]),null}function Qe(n){const{query:o,placements:a}=n,{recommendationComponent:u,useRenderCampaigns:d}=x(),{renderCampaigns:c,pageTypeUpdated:i}=d("search");return L(async p=>{const v=await p.defaultSession().viewSearch(o).setPlacements(a||p.placements.getPlacements()).load();c(v,p)},[o,u,i]),null}function M(n){return!n||typeof n!="object"||et(n)||tt(n)?n:Array.isArray(n)?n.map(M):Object.keys(n).reduce((o,a)=>{const u=a[0].toLowerCase()+a.slice(1).replace(/([A-Z]+)/g,(d,c)=>"_"+c.toLowerCase());return o[u]=M(n[a]),o},{})}function et(n){return Object.prototype.toString.call(n)==="[object Date]"}function tt(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function rt(n){const{order:o,placements:a}=n,{recommendationComponent:u,useRenderCampaigns:d}=x(),{renderCampaigns:c,pageTypeUpdated:i}=d("order");return L(async p=>{const v=await p.defaultSession().addOrder(M(o)).setPlacements(a||p.placements.getPlacements()).load();c(v,p)},[u,i]),null}function nt(n){const{recommendationComponent:o,useRenderCampaigns:a}=x(),{renderCampaigns:u,pageTypeUpdated:d}=a("home");return L(async c=>{const i=await c.defaultSession().viewFrontPage().setPlacements(n.placements||c.placements.getPlacements()).load();u(i,c)},[o,d]),null}var ae={exports:{}},q={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Re;function Xe(){if(Re)return H;Re=1;var o=b,s=Symbol.for("react.element"),r=Symbol.for("react.fragment"),d=Object.prototype.hasOwnProperty,m=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function l(y,n,C){var N,P={},I=null,V=null;C!==void 0&&(I=""+C),n.key!==void 0&&(I=""+n.key),n.ref!==void 0&&(V=n.ref);for(N in n)d.call(n,N)&&!u.hasOwnProperty(N)&&(P[N]=n[N]);if(y&&y.defaultProps)for(N in n=y.defaultProps,n)P[N]===void 0&&(P[N]=n[N]);return{$$typeof:s,type:y,key:I,ref:V,props:P,_owner:m.current}}return H.Fragment=r,H.jsx=l,H.jsxs=l,H}var J={};/**
9
+ */var Ee;function ot(){if(Ee)return q;Ee=1;var n=h,o=Symbol.for("react.element"),a=Symbol.for("react.fragment"),u=Object.prototype.hasOwnProperty,d=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function i(p,v,N){var _,S={},k=null,I=null;N!==void 0&&(k=""+N),v.key!==void 0&&(k=""+v.key),v.ref!==void 0&&(I=v.ref);for(_ in v)u.call(v,_)&&!c.hasOwnProperty(_)&&(S[_]=v[_]);if(p&&p.defaultProps)for(_ in v=p.defaultProps,v)S[_]===void 0&&(S[_]=v[_]);return{$$typeof:o,type:p,key:k,ref:I,props:S,_owner:d.current}}return q.Fragment=a,q.jsx=i,q.jsxs=i,q}var B={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,12 +14,12 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var we;function Ze(){return we||(we=1,process.env.NODE_ENV!=="production"&&function(){var o=b,s=Symbol.for("react.element"),r=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),y=Symbol.for("react.context"),n=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),V=Symbol.for("react.offscreen"),Z=Symbol.iterator,le="@@iterator";function A(e){if(e===null||typeof e!="object")return null;var t=Z&&e[Z]||e[le];return typeof t=="function"?t:null}var g=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(e){{for(var t=arguments.length,a=new Array(t>1?t-1:0),c=1;c<t;c++)a[c-1]=arguments[c];_("error",e,a)}}function _(e,t,a){{var c=g.ReactDebugCurrentFrame,v=c.getStackAddendum();v!==""&&(t+="%s",a=a.concat([v]));var h=a.map(function(p){return String(p)});h.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,h)}}var O=!1,j=!1,W=!1,Y=!1,ue=!1,Q;Q=Symbol.for("react.module.reference");function k(e){return!!(typeof e=="string"||typeof e=="function"||e===d||e===u||ue||e===m||e===C||e===N||Y||e===V||O||j||W||typeof e=="object"&&e!==null&&(e.$$typeof===I||e.$$typeof===P||e.$$typeof===l||e.$$typeof===y||e.$$typeof===n||e.$$typeof===Q||e.getModuleId!==void 0))}function Se(e,t,a){var c=e.displayName;if(c)return c;var v=t.displayName||t.name||"";return v!==""?a+"("+v+")":a}function Ne(e){return e.displayName||"Context"}function L(e){if(e==null)return null;if(typeof e.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case d:return"Fragment";case r:return"Portal";case u:return"Profiler";case m:return"StrictMode";case C:return"Suspense";case N:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case y:var t=e;return Ne(t)+".Consumer";case l:var a=e;return Ne(a._context)+".Provider";case n:return Se(e,e.render,"ForwardRef");case P:var c=e.displayName||null;return c!==null?c:L(e.type)||"Memo";case I:{var v=e,h=v._payload,p=v._init;try{return L(p(h))}catch{return null}}}return null}var M=Object.assign,K=0,Te,Pe,ge,Oe,je,xe,Fe;function Ae(){}Ae.__reactDisabledLog=!0;function dr(){{if(K===0){Te=console.log,Pe=console.info,ge=console.warn,Oe=console.error,je=console.group,xe=console.groupCollapsed,Fe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ae,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}K++}}function fr(){{if(K--,K===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},e,{value:Te}),info:M({},e,{value:Pe}),warn:M({},e,{value:ge}),error:M({},e,{value:Oe}),group:M({},e,{value:je}),groupCollapsed:M({},e,{value:xe}),groupEnd:M({},e,{value:Fe})})}K<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var de=g.ReactCurrentDispatcher,fe;function ee(e,t,a){{if(fe===void 0)try{throw Error()}catch(v){var c=v.stack.trim().match(/\n( *(at )?)/);fe=c&&c[1]||""}return`
18
- `+fe+e}}var pe=!1,re;{var pr=typeof WeakMap=="function"?WeakMap:Map;re=new pr}function De(e,t){if(!e||pe)return"";{var a=re.get(e);if(a!==void 0)return a}var c;pe=!0;var v=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var h;h=de.current,de.current=null,dr();try{if(t){var p=function(){throw Error()};if(Object.defineProperty(p.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(p,[])}catch(U){c=U}Reflect.construct(e,[],p)}else{try{p.call()}catch(U){c=U}e.call(p.prototype)}}else{try{throw Error()}catch(U){c=U}e()}}catch(U){if(U&&c&&typeof U.stack=="string"){for(var f=U.stack.split(`
19
- `),T=c.stack.split(`
20
- `),E=f.length-1,S=T.length-1;E>=1&&S>=0&&f[E]!==T[S];)S--;for(;E>=1&&S>=0;E--,S--)if(f[E]!==T[S]){if(E!==1||S!==1)do if(E--,S--,S<0||f[E]!==T[S]){var x=`
21
- `+f[E].replace(" at new "," at ");return e.displayName&&x.includes("<anonymous>")&&(x=x.replace("<anonymous>",e.displayName)),typeof e=="function"&&re.set(e,x),x}while(E>=1&&S>=0);break}}}finally{pe=!1,de.current=h,fr(),Error.prepareStackTrace=v}var G=e?e.displayName||e.name:"",Je=G?ee(G):"";return typeof e=="function"&&re.set(e,Je),Je}function mr(e,t,a){return De(e,!1)}function vr(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function te(e,t,a){if(e==null)return"";if(typeof e=="function")return De(e,vr(e));if(typeof e=="string")return ee(e);switch(e){case C:return ee("Suspense");case N:return ee("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case n:return mr(e.render);case P:return te(e.type,t,a);case I:{var c=e,v=c._payload,h=c._init;try{return te(h(v),t,a)}catch{}}}return""}var ne=Object.prototype.hasOwnProperty,Ie={},Le=g.ReactDebugCurrentFrame;function ae(e){if(e){var t=e._owner,a=te(e.type,e._source,t?t.type:null);Le.setExtraStackFrame(a)}else Le.setExtraStackFrame(null)}function yr(e,t,a,c,v){{var h=Function.call.bind(ne);for(var p in e)if(h(e,p)){var f=void 0;try{if(typeof e[p]!="function"){var T=Error((c||"React class")+": "+a+" type `"+p+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[p]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw T.name="Invariant Violation",T}f=e[p](t,p,c,a,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(E){f=E}f&&!(f instanceof Error)&&(ae(v),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",c||"React class",a,p,typeof f),ae(null)),f instanceof Error&&!(f.message in Ie)&&(Ie[f.message]=!0,ae(v),w("Failed %s type: %s",a,f.message),ae(null))}}}var hr=Array.isArray;function me(e){return hr(e)}function _r(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,a=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return a}}function Cr(e){try{return Ue(e),!1}catch{return!0}}function Ue(e){return""+e}function $e(e){if(Cr(e))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",_r(e)),Ue(e)}var X=g.ReactCurrentOwner,br={key:!0,ref:!0,__self:!0,__source:!0},Ve,We,ve;ve={};function Er(e){if(ne.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function Rr(e){if(ne.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function wr(e,t){if(typeof e.ref=="string"&&X.current&&t&&X.current.stateNode!==t){var a=L(X.current.type);ve[a]||(w('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',L(X.current.type),e.ref),ve[a]=!0)}}function Sr(e,t){{var a=function(){Ve||(Ve=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};a.isReactWarning=!0,Object.defineProperty(e,"key",{get:a,configurable:!0})}}function Nr(e,t){{var a=function(){We||(We=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};a.isReactWarning=!0,Object.defineProperty(e,"ref",{get:a,configurable:!0})}}var Tr=function(e,t,a,c,v,h,p){var f={$$typeof:s,type:e,key:t,ref:a,props:p,_owner:h};return f._store={},Object.defineProperty(f._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(f,"_self",{configurable:!1,enumerable:!1,writable:!1,value:c}),Object.defineProperty(f,"_source",{configurable:!1,enumerable:!1,writable:!1,value:v}),Object.freeze&&(Object.freeze(f.props),Object.freeze(f)),f};function Pr(e,t,a,c,v){{var h,p={},f=null,T=null;a!==void 0&&($e(a),f=""+a),Rr(t)&&($e(t.key),f=""+t.key),Er(t)&&(T=t.ref,wr(t,v));for(h in t)ne.call(t,h)&&!br.hasOwnProperty(h)&&(p[h]=t[h]);if(e&&e.defaultProps){var E=e.defaultProps;for(h in E)p[h]===void 0&&(p[h]=E[h])}if(f||T){var S=typeof e=="function"?e.displayName||e.name||"Unknown":e;f&&Sr(p,S),T&&Nr(p,S)}return Tr(e,f,T,v,c,X.current,p)}}var ye=g.ReactCurrentOwner,Ye=g.ReactDebugCurrentFrame;function B(e){if(e){var t=e._owner,a=te(e.type,e._source,t?t.type:null);Ye.setExtraStackFrame(a)}else Ye.setExtraStackFrame(null)}var he;he=!1;function _e(e){return typeof e=="object"&&e!==null&&e.$$typeof===s}function Me(){{if(ye.current){var e=L(ye.current.type);if(e)return`
17
+ */var Ce;function at(){return Ce||(Ce=1,process.env.NODE_ENV!=="production"&&function(){var n=h,o=Symbol.for("react.element"),a=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),d=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),p=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),I=Symbol.for("react.offscreen"),G=Symbol.iterator,se="@@iterator";function A(e){if(e===null||typeof e!="object")return null;var t=G&&e[G]||e[se];return typeof t=="function"?t:null}var T=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function R(e){{for(var t=arguments.length,r=new Array(t>1?t-1:0),s=1;s<t;s++)r[s-1]=arguments[s];y("error",e,r)}}function y(e,t,r){{var s=T.ReactDebugCurrentFrame,m=s.getStackAddendum();m!==""&&(t+="%s",r=r.concat([m]));var g=r.map(function(f){return String(f)});g.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,g)}}var P=!1,O=!1,$=!1,U=!1,ie=!1,K;K=Symbol.for("react.module.reference");function X(e){return!!(typeof e=="string"||typeof e=="function"||e===u||e===c||ie||e===d||e===N||e===_||U||e===I||P||O||$||typeof e=="object"&&e!==null&&(e.$$typeof===k||e.$$typeof===S||e.$$typeof===i||e.$$typeof===p||e.$$typeof===v||e.$$typeof===K||e.getModuleId!==void 0))}function be(e,t,r){var s=e.displayName;if(s)return s;var m=t.displayName||t.name||"";return m!==""?r+"("+m+")":r}function _e(e){return e.displayName||"Context"}function D(e){if(e==null)return null;if(typeof e.tag=="number"&&R("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case u:return"Fragment";case a:return"Portal";case c:return"Profiler";case d:return"StrictMode";case N:return"Suspense";case _:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case p:var t=e;return _e(t)+".Consumer";case i:var r=e;return _e(r._context)+".Provider";case v:return be(e,e.render,"ForwardRef");case S:var s=e.displayName||null;return s!==null?s:D(e.type)||"Memo";case k:{var m=e,g=m._payload,f=m._init;try{return D(f(g))}catch{return null}}}return null}var W=Object.assign,H=0,we,Te,Se,Pe,Oe,je,xe;function Ne(){}Ne.__reactDisabledLog=!0;function lt(){{if(H===0){we=console.log,Te=console.info,Se=console.warn,Pe=console.error,Oe=console.group,je=console.groupCollapsed,xe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ne,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}H++}}function ft(){{if(H--,H===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:W({},e,{value:we}),info:W({},e,{value:Te}),warn:W({},e,{value:Se}),error:W({},e,{value:Pe}),group:W({},e,{value:Oe}),groupCollapsed:W({},e,{value:je}),groupEnd:W({},e,{value:xe})})}H<0&&R("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ce=T.ReactCurrentDispatcher,ue;function Z(e,t,r){{if(ue===void 0)try{throw Error()}catch(m){var s=m.stack.trim().match(/\n( *(at )?)/);ue=s&&s[1]||""}return`
18
+ `+ue+e}}var le=!1,Q;{var dt=typeof WeakMap=="function"?WeakMap:Map;Q=new dt}function Ae(e,t){if(!e||le)return"";{var r=Q.get(e);if(r!==void 0)return r}var s;le=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var g;g=ce.current,ce.current=null,lt();try{if(t){var f=function(){throw Error()};if(Object.defineProperty(f.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(f,[])}catch(F){s=F}Reflect.construct(e,[],f)}else{try{f.call()}catch(F){s=F}e.call(f.prototype)}}else{try{throw Error()}catch(F){s=F}e()}}catch(F){if(F&&s&&typeof F.stack=="string"){for(var l=F.stack.split(`
19
+ `),w=s.stack.split(`
20
+ `),E=l.length-1,b=w.length-1;E>=1&&b>=0&&l[E]!==w[b];)b--;for(;E>=1&&b>=0;E--,b--)if(l[E]!==w[b]){if(E!==1||b!==1)do if(E--,b--,b<0||l[E]!==w[b]){var j=`
21
+ `+l[E].replace(" at new "," at ");return e.displayName&&j.includes("<anonymous>")&&(j=j.replace("<anonymous>",e.displayName)),typeof e=="function"&&Q.set(e,j),j}while(E>=1&&b>=0);break}}}finally{le=!1,ce.current=g,ft(),Error.prepareStackTrace=m}var Y=e?e.displayName||e.name:"",Be=Y?Z(Y):"";return typeof e=="function"&&Q.set(e,Be),Be}function mt(e,t,r){return Ae(e,!1)}function pt(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function ee(e,t,r){if(e==null)return"";if(typeof e=="function")return Ae(e,pt(e));if(typeof e=="string")return Z(e);switch(e){case N:return Z("Suspense");case _:return Z("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case v:return mt(e.render);case S:return ee(e.type,t,r);case k:{var s=e,m=s._payload,g=s._init;try{return ee(g(m),t,r)}catch{}}}return""}var te=Object.prototype.hasOwnProperty,ke={},De=T.ReactDebugCurrentFrame;function re(e){if(e){var t=e._owner,r=ee(e.type,e._source,t?t.type:null);De.setExtraStackFrame(r)}else De.setExtraStackFrame(null)}function vt(e,t,r,s,m){{var g=Function.call.bind(te);for(var f in e)if(g(e,f)){var l=void 0;try{if(typeof e[f]!="function"){var w=Error((s||"React class")+": "+r+" type `"+f+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[f]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw w.name="Invariant Violation",w}l=e[f](t,f,s,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(E){l=E}l&&!(l instanceof Error)&&(re(m),R("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",s||"React class",r,f,typeof l),re(null)),l instanceof Error&&!(l.message in ke)&&(ke[l.message]=!0,re(m),R("Failed %s type: %s",r,l.message),re(null))}}}var gt=Array.isArray;function fe(e){return gt(e)}function yt(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,r=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r}}function ht(e){try{return Fe(e),!1}catch{return!0}}function Fe(e){return""+e}function Le(e){if(ht(e))return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",yt(e)),Fe(e)}var J=T.ReactCurrentOwner,Et={key:!0,ref:!0,__self:!0,__source:!0},Ie,$e,de;de={};function Ct(e){if(te.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function Rt(e){if(te.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function bt(e,t){if(typeof e.ref=="string"&&J.current&&t&&J.current.stateNode!==t){var r=D(J.current.type);de[r]||(R('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',D(J.current.type),e.ref),de[r]=!0)}}function _t(e,t){{var r=function(){Ie||(Ie=!0,R("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}}function wt(e,t){{var r=function(){$e||($e=!0,R("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}}var Tt=function(e,t,r,s,m,g,f){var l={$$typeof:o,type:e,key:t,ref:r,props:f,_owner:g};return l._store={},Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:m}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l};function St(e,t,r,s,m){{var g,f={},l=null,w=null;r!==void 0&&(Le(r),l=""+r),Rt(t)&&(Le(t.key),l=""+t.key),Ct(t)&&(w=t.ref,bt(t,m));for(g in t)te.call(t,g)&&!Et.hasOwnProperty(g)&&(f[g]=t[g]);if(e&&e.defaultProps){var E=e.defaultProps;for(g in E)f[g]===void 0&&(f[g]=E[g])}if(l||w){var b=typeof e=="function"?e.displayName||e.name||"Unknown":e;l&&_t(f,b),w&&wt(f,b)}return Tt(e,l,w,m,s,J.current,f)}}var me=T.ReactCurrentOwner,Ue=T.ReactDebugCurrentFrame;function V(e){if(e){var t=e._owner,r=ee(e.type,e._source,t?t.type:null);Ue.setExtraStackFrame(r)}else Ue.setExtraStackFrame(null)}var pe;pe=!1;function ve(e){return typeof e=="object"&&e!==null&&e.$$typeof===o}function We(){{if(me.current){var e=D(me.current.type);if(e)return`
22
22
 
23
- Check the render method of \``+e+"`."}return""}}function gr(e){return""}var qe={};function Or(e){{var t=Me();if(!t){var a=typeof e=="string"?e:e.displayName||e.name;a&&(t=`
23
+ Check the render method of \``+e+"`."}return""}}function Pt(e){return""}var Ve={};function Ot(e){{var t=We();if(!t){var r=typeof e=="string"?e:e.displayName||e.name;r&&(t=`
24
24
 
25
- Check the top-level render call using <`+a+">.")}return t}}function Be(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var a=Or(t);if(qe[a])return;qe[a]=!0;var c="";e&&e._owner&&e._owner!==ye.current&&(c=" It was passed a child from "+L(e._owner.type)+"."),B(e),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',a,c),B(null)}}function Ge(e,t){{if(typeof e!="object")return;if(me(e))for(var a=0;a<e.length;a++){var c=e[a];_e(c)&&Be(c,t)}else if(_e(e))e._store&&(e._store.validated=!0);else if(e){var v=A(e);if(typeof v=="function"&&v!==e.entries)for(var h=v.call(e),p;!(p=h.next()).done;)_e(p.value)&&Be(p.value,t)}}}function jr(e){{var t=e.type;if(t==null||typeof t=="string")return;var a;if(typeof t=="function")a=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===n||t.$$typeof===P))a=t.propTypes;else return;if(a){var c=L(t);yr(a,e.props,"prop",c,e)}else if(t.PropTypes!==void 0&&!he){he=!0;var v=L(t);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",v||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function xr(e){{for(var t=Object.keys(e.props),a=0;a<t.length;a++){var c=t[a];if(c!=="children"&&c!=="key"){B(e),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",c),B(null);break}}e.ref!==null&&(B(e),w("Invalid attribute `ref` supplied to `React.Fragment`."),B(null))}}function He(e,t,a,c,v,h){{var p=k(e);if(!p){var f="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(f+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var T=gr();T?f+=T:f+=Me();var E;e===null?E="null":me(e)?E="array":e!==void 0&&e.$$typeof===s?(E="<"+(L(e.type)||"Unknown")+" />",f=" Did you accidentally export a JSX literal instead of a component?"):E=typeof e,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",E,f)}var S=Pr(e,t,a,v,h);if(S==null)return S;if(p){var x=t.children;if(x!==void 0)if(c)if(me(x)){for(var G=0;G<x.length;G++)Ge(x[G],e);Object.freeze&&Object.freeze(x)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ge(x,e)}return e===d?xr(S):jr(S),S}}function Fr(e,t,a){return He(e,t,a,!0)}function Ar(e,t,a){return He(e,t,a,!1)}var Dr=Ar,Ir=Fr;J.Fragment=d,J.jsx=Dr,J.jsxs=Ir}()),J}process.env.NODE_ENV==="production"?ie.exports=Xe():ie.exports=Ze();var ce=ie.exports;const i=ce.jsx,q=ce.jsxs,D=ce.Fragment;function Qe(o){const{recommendationComponent:s,useRenderCampaigns:r}=F(),{renderCampaigns:d,pageTypeUpdated:m}=r("404");return $(async u=>{const l=await u.defaultSession().viewNotFound().setPlacements(o.placements||u.placements.getPlacements()).load();d(l,u)},[s,m]),i(D,{children:i("div",{className:"nosto_page_type",style:{display:"none"},children:"notfound"})})}function ke(o){const{recommendationComponent:s,useRenderCampaigns:r}=F(),{renderCampaigns:d,pageTypeUpdated:m}=r("other");return $(async u=>{const l=await u.defaultSession().viewOther().setPlacements(o.placements||u.placements.getPlacements()).load();d(l,u)},[s,m]),i(D,{children:i("div",{className:"nosto_page_type",style:{display:"none"},children:"other"})})}function er(o){const{recommendationComponent:s,useRenderCampaigns:r}=F(),{renderCampaigns:d,pageTypeUpdated:m}=r("checkout");return $(async u=>{const l=await u.defaultSession().viewCart().setPlacements(o.placements||u.placements.getPlacements()).load();d(l,u)},[s,m]),i(D,{children:i("div",{className:"nosto_page_type",style:{display:"none"},children:"cart"})})}function rr(o){const{product:s,tagging:r,placements:d}=o,{recommendationComponent:m,useRenderCampaigns:u}=F(),{renderCampaigns:l,pageTypeUpdated:y}=u("product");return $(async n=>{const C=await n.defaultSession().viewProduct(s).setPlacements(d||n.placements.getPlacements()).load();l(C,n)},[s,m,y],{deep:!0}),q(D,{children:[i("div",{className:"nosto_page_type",style:{display:"none"},children:"product"}),q("div",{className:"nosto_product",style:{display:"none"},children:[(r==null?void 0:r.variationId)&&i("span",{className:"variation_id",children:r.variationId}),s&&i("span",{className:"product_id",children:s}),(r==null?void 0:r.name)&&i("span",{className:"name",children:r.name}),(r==null?void 0:r.url)&&i("span",{className:"url",children:r.url.toString()}),(r==null?void 0:r.imageUrl)&&i("span",{className:"image_url",children:r.imageUrl.toString()}),(r==null?void 0:r.availability)&&i("span",{className:"availability",children:r.availability}),(r==null?void 0:r.price)&&i("span",{className:"price",children:r.price}),(r==null?void 0:r.listPrice)&&i("span",{className:"list_price",children:r.listPrice}),(r==null?void 0:r.priceCurrencyCode)&&i("span",{className:"price_currency_code",children:r.priceCurrencyCode}),(r==null?void 0:r.brand)&&i("span",{className:"brand",children:r.brand}),(r==null?void 0:r.description)&&i("span",{className:"description",children:r.description}),(r==null?void 0:r.googleCategory)&&i("span",{className:"description",children:r.googleCategory}),(r==null?void 0:r.condition)&&i("span",{className:"condition",children:r.condition}),(r==null?void 0:r.gender)&&i("span",{className:"gender",children:r.gender}),(r==null?void 0:r.ageGroup)&&i("span",{className:"age_group",children:r.ageGroup}),(r==null?void 0:r.gtin)&&i("span",{className:"gtin",children:r.gtin}),(r==null?void 0:r.category)&&(r==null?void 0:r.category.map((n,C)=>i("span",{className:"category",children:n},C))),(r==null?void 0:r.tags1)&&r.tags1.map((n,C)=>i("span",{className:"tag1",children:n},C)),(r==null?void 0:r.tags2)&&r.tags2.map((n,C)=>i("span",{className:"tag2",children:n},C)),(r==null?void 0:r.tags3)&&r.tags3.map((n,C)=>i("span",{className:"tag3",children:n},C)),(r==null?void 0:r.ratingValue)&&i("span",{className:"rating_value",children:r.ratingValue}),(r==null?void 0:r.reviewCount)&&i("span",{className:"review_count",children:r.reviewCount}),(r==null?void 0:r.alternateImageUrls)&&r.alternateImageUrls.map((n,C)=>i("span",{className:"alternate_image_url",children:n.toString()},C)),(r==null?void 0:r.customFields)&&Object.keys(r.customFields).map((n,C)=>r.customFields&&r.customFields[n]&&i("span",{className:n,children:r.customFields[n]},C)),(r==null?void 0:r.skus)&&r.skus.map((n,C)=>q("span",{className:"nosto_sku",children:[(n==null?void 0:n.id)&&i("span",{className:"product_id",children:n.id}),(n==null?void 0:n.name)&&i("span",{className:"name",children:n.name}),(n==null?void 0:n.price)&&i("span",{className:"price",children:n.price}),(n==null?void 0:n.listPrice)&&i("span",{className:"list_price",children:n.listPrice}),(n==null?void 0:n.url)&&i("span",{className:"url",children:n.url.toString()}),(n==null?void 0:n.imageUrl)&&i("span",{className:"image_url",children:n.imageUrl.toString()}),(n==null?void 0:n.gtin)&&i("span",{className:"gtin",children:n.gtin}),(n==null?void 0:n.availability)&&i("span",{className:"availability",children:n.availability}),(n==null?void 0:n.customFields)&&Object.keys(n.customFields).map((N,P)=>n.customFields&&n.customFields[N]&&i("span",{className:N,children:n.customFields[N]},P))]},C))]})]})}function tr(o){const{category:s,placements:r}=o,{recommendationComponent:d,useRenderCampaigns:m}=F(),{renderCampaigns:u,pageTypeUpdated:l}=m("home");return $(async y=>{const n=await y.defaultSession().viewCategory(s).setPlacements(r||y.placements.getPlacements()).load();u(n,y)},[s,d,l]),q(D,{children:[i("div",{className:"nosto_page_type",style:{display:"none"},children:"category"}),i("div",{className:"nosto_category",style:{display:"none"},children:s})]})}function nr(o){const{query:s,placements:r}=o,{recommendationComponent:d,useRenderCampaigns:m}=F(),{renderCampaigns:u,pageTypeUpdated:l}=m("search");return $(async y=>{const n=await y.defaultSession().viewSearch(s).setPlacements(r||y.placements.getPlacements()).load();u(n,y)},[s,d,l]),q(D,{children:[i("div",{className:"nosto_page_type",style:{display:"none"},children:"search"}),i("div",{className:"nosto_search",style:{display:"none"},children:s})]})}function z(o){return!o||typeof o!="object"||ar(o)||or(o)?o:Array.isArray(o)?o.map(z):Object.keys(o).reduce((s,r)=>{const d=r[0].toLowerCase()+r.slice(1).replace(/([A-Z]+)/g,(m,u)=>"_"+u.toLowerCase());return s[d]=z(o[r]),s},{})}function ar(o){return Object.prototype.toString.call(o)==="[object Date]"}function or(o){return Object.prototype.toString.call(o)==="[object RegExp]"}function sr(o){const{order:s,placements:r}=o,{recommendationComponent:d,useRenderCampaigns:m}=F(),{renderCampaigns:u,pageTypeUpdated:l}=m("order");return $(async y=>{const n=await y.defaultSession().addOrder(z(s)).setPlacements(r||y.placements.getPlacements()).load();u(n,y)},[d,l]),q(D,{children:[i("div",{className:"nosto_page_type",style:{display:"none"},children:"order"}),i("div",{className:"nosto_order",style:{display:"none"},children:s.purchase.number})]})}function ir(o){const{recommendationComponent:s,useRenderCampaigns:r}=F(),{renderCampaigns:d,pageTypeUpdated:m}=r("home");return $(async u=>{const l=await u.defaultSession().viewFrontPage().setPlacements(o.placements||u.placements.getPlacements()).load();d(l,u)},[s,m]),i(D,{children:i("div",{className:"nosto_page_type",style:{display:"none"},children:"front"})})}function cr(o){const{id:s,pageType:r}=o;return i("div",{className:"nosto_element",id:s},s+(r||""))}function lr(o){const{account:s,multiCurrency:r=!1,host:d,children:m,recommendationComponent:u,shopifyMarkets:l}=o,[y,n]=b.useState(!1),C=b.useMemo(()=>y,[y]),N=r?o.currentVariation:"",P=b.isValidElement(u)?"JSON_ORIGINAL":"HTML";function I(A){return b.cloneElement(u,{nostoRecommendation:A.nostoRecommendation})}const[V,Z]=b.useState("");function le(A=""){const g=b.useRef({});b.useEffect(()=>{V!==A&&Z(A)},[]);const w=A===V;function _(O,j){if(P=="HTML")j.placements.injectCampaigns(O.recommendations);else{const W=O.campaigns.recommendations;for(const Y in W){const ue=W[Y],Q="#"+Y,k=()=>document.querySelector(Q);k()&&(g.current[Y]||(g.current[Y]=ze.createRoot(k())),g.current[Y].render(i(I,{nostoRecommendation:ue})))}}}return{renderCampaigns:_,pageTypeUpdated:w}}return b.useEffect(()=>{var A,g,w;if(window.nostojs||(window.nostojs=_=>{(window.nostojs.q=window.nostojs.q||[]).push(_)},window.nostojs(_=>_.setAutoLoad(!1))),!document.querySelectorAll("[nosto-client-script]").length&&!l){const _=document.createElement("script");_.type="text/javascript",_.src="//"+(d||"connect.nosto.com")+"/include/"+s,_.async=!0,_.setAttribute("nosto-client-script",""),_.onload=()=>{var O;typeof jest<"u"&&((O=window.nosto)==null||O.reload({site:"localhost"})),n(!0)},document.body.appendChild(_)}if(l){const _=document.querySelector("[nosto-client-script]"),O=document.querySelector("#nosto-sandbox");if(!_||(_==null?void 0:_.getAttribute("nosto-language"))!==(l==null?void 0:l.language)||(_==null?void 0:_.getAttribute("nosto-market-id"))!==(l==null?void 0:l.marketId)){y&&n(!1),(A=_==null?void 0:_.parentNode)==null||A.removeChild(_),(g=O==null?void 0:O.parentNode)==null||g.removeChild(O);const j=document.createElement("script");j.type="text/javascript",j.src="//"+(d||"connect.nosto.com")+`/script/shopify/market/nosto.js?merchant=${s}&market=${l.marketId||""}&locale=${((w=l==null?void 0:l.language)==null?void 0:w.toLowerCase())||""}`,j.async=!0,j.setAttribute("nosto-client-script",""),j.setAttribute("nosto-language",(l==null?void 0:l.language)||""),j.setAttribute("nosto-market-id",String(l==null?void 0:l.marketId)),j.onload=()=>{var W;typeof jest<"u"&&((W=window.nosto)==null||W.reload({site:"localhost"})),n(!0)},document.body.appendChild(j)}}},[y,l]),i(oe.Provider,{value:{account:s,clientScriptLoaded:C,currentVariation:N,responseMode:P,recommendationComponent:u,useRenderCampaigns:le,pageType:V},children:m})}function ur(o){const{cart:s,customer:r}=o,{clientScriptLoaded:d}=F();return Ee(()=>{const m=s?z(s):void 0,u=r?z(r):void 0;d&&window.nostojs(l=>{l.defaultSession().setResponseMode("HTML").setCart(m).setCustomer(u).viewOther().load()})},[d,s,r]),i(D,{})}R.Nosto404=Qe,R.NostoCategory=tr,R.NostoCheckout=er,R.NostoContext=oe,R.NostoHome=ir,R.NostoOrder=sr,R.NostoOther=ke,R.NostoPlacement=cr,R.NostoProduct=rr,R.NostoProvider=lr,R.NostoSearch=nr,R.NostoSession=ur,R.useNostoContext=F,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
25
+ Check the top-level render call using <`+r+">.")}return t}}function Ye(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var r=Ot(t);if(Ve[r])return;Ve[r]=!0;var s="";e&&e._owner&&e._owner!==me.current&&(s=" It was passed a child from "+D(e._owner.type)+"."),V(e),R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,s),V(null)}}function Me(e,t){{if(typeof e!="object")return;if(fe(e))for(var r=0;r<e.length;r++){var s=e[r];ve(s)&&Ye(s,t)}else if(ve(e))e._store&&(e._store.validated=!0);else if(e){var m=A(e);if(typeof m=="function"&&m!==e.entries)for(var g=m.call(e),f;!(f=g.next()).done;)ve(f.value)&&Ye(f.value,t)}}}function jt(e){{var t=e.type;if(t==null||typeof t=="string")return;var r;if(typeof t=="function")r=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===v||t.$$typeof===S))r=t.propTypes;else return;if(r){var s=D(t);vt(r,e.props,"prop",s,e)}else if(t.PropTypes!==void 0&&!pe){pe=!0;var m=D(t);R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",m||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function xt(e){{for(var t=Object.keys(e.props),r=0;r<t.length;r++){var s=t[r];if(s!=="children"&&s!=="key"){V(e),R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",s),V(null);break}}e.ref!==null&&(V(e),R("Invalid attribute `ref` supplied to `React.Fragment`."),V(null))}}function qe(e,t,r,s,m,g){{var f=X(e);if(!f){var l="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(l+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var w=Pt();w?l+=w:l+=We();var E;e===null?E="null":fe(e)?E="array":e!==void 0&&e.$$typeof===o?(E="<"+(D(e.type)||"Unknown")+" />",l=" Did you accidentally export a JSX literal instead of a component?"):E=typeof e,R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",E,l)}var b=St(e,t,r,m,g);if(b==null)return b;if(f){var j=t.children;if(j!==void 0)if(s)if(fe(j)){for(var Y=0;Y<j.length;Y++)Me(j[Y],e);Object.freeze&&Object.freeze(j)}else R("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Me(j,e)}return e===u?xt(b):jt(b),b}}function Nt(e,t,r){return qe(e,t,r,!0)}function At(e,t,r){return qe(e,t,r,!1)}var kt=At,Dt=Nt;B.Fragment=u,B.jsx=kt,B.jsxs=Dt}()),B}process.env.NODE_ENV==="production"?ae.exports=ot():ae.exports=at();var Re=ae.exports;const z=Re.jsx,st=Re.Fragment;function it(n){const{id:o,pageType:a}=n;return z("div",{className:"nosto_element",id:o},o+(a||""))}function ct(n){const{account:o,multiCurrency:a=!1,host:u,children:d,recommendationComponent:c,shopifyMarkets:i}=n,[p,v]=h.useState(!1),N=h.useMemo(()=>p,[p]),_=a?n.currentVariation:"",S=h.isValidElement(c)?"JSON_ORIGINAL":"HTML";function k(A){return h.cloneElement(c,{nostoRecommendation:A.nostoRecommendation})}const[I,G]=h.useState("");function se(A=""){const T=h.useRef({});h.useEffect(()=>{I!==A&&G(A)},[]);const R=A===I;function y(P,O){if(S=="HTML")O.placements.injectCampaigns(P.recommendations);else{const $=P.campaigns.recommendations;for(const U in $){const ie=$[U],K="#"+U,X=()=>document.querySelector(K);X()&&(T.current[U]||(T.current[U]=He.createRoot(X())),T.current[U].render(z(k,{nostoRecommendation:ie})))}}}return{renderCampaigns:y,pageTypeUpdated:R}}return h.useEffect(()=>{var A,T,R;if(window.nostojs||(window.nostojs=y=>{(window.nostojs.q=window.nostojs.q||[]).push(y)},window.nostojs(y=>y.setAutoLoad(!1))),!document.querySelectorAll("[nosto-client-script]").length&&!i){const y=document.createElement("script");y.type="text/javascript",y.src="//"+(u||"connect.nosto.com")+"/include/"+o,y.async=!0,y.setAttribute("nosto-client-script",""),y.onload=()=>{var P;typeof jest<"u"&&((P=window.nosto)==null||P.reload({site:"localhost"})),v(!0)},document.body.appendChild(y)}if(i){const y=document.querySelector("[nosto-client-script]"),P=document.querySelector("#nosto-sandbox");if(!y||(y==null?void 0:y.getAttribute("nosto-language"))!==(i==null?void 0:i.language)||(y==null?void 0:y.getAttribute("nosto-market-id"))!==(i==null?void 0:i.marketId)){p&&v(!1),(A=y==null?void 0:y.parentNode)==null||A.removeChild(y),(T=P==null?void 0:P.parentNode)==null||T.removeChild(P);const O=document.createElement("script");O.type="text/javascript",O.src="//"+(u||"connect.nosto.com")+`/script/shopify/market/nosto.js?merchant=${o}&market=${i.marketId||""}&locale=${((R=i==null?void 0:i.language)==null?void 0:R.toLowerCase())||""}`,O.async=!0,O.setAttribute("nosto-client-script",""),O.setAttribute("nosto-language",(i==null?void 0:i.language)||""),O.setAttribute("nosto-market-id",String(i==null?void 0:i.marketId)),O.onload=()=>{var $;typeof jest<"u"&&(($=window.nosto)==null||$.reload({site:"localhost"})),v(!0)},document.body.appendChild(O)}}},[p,i]),z(ne.Provider,{value:{account:o,clientScriptLoaded:N,currentVariation:_,responseMode:S,recommendationComponent:c,useRenderCampaigns:se,pageType:I},children:d})}function ut(n){const{cart:o,customer:a}=n??{},{clientScriptLoaded:u}=x();return he(()=>{const d=o?M(o):void 0,c=a?M(a):void 0;u&&window.nostojs(i=>{i.defaultSession().setResponseMode("HTML").setCart(d).setCustomer(c).viewOther().load()})},[u,o,a]),z(st,{})}C.Nosto404=ze,C.NostoCategory=Ze,C.NostoCheckout=Ke,C.NostoContext=ne,C.NostoHome=nt,C.NostoOrder=rt,C.NostoOther=Ge,C.NostoPlacement=it,C.NostoProduct=Xe,C.NostoProvider=ct,C.NostoSearch=Qe,C.NostoSession=ut,C.useNostoContext=x,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nosto/nosto-react",
3
3
  "description": "Component library to simply implementing Nosto on React.",
4
- "version": "0.5.0",
4
+ "version": "1.0.0",
5
5
  "author": "Mridang Agarwalla, Dominik Gilg",
6
6
  "license": "ISC",
7
7
  "repository": {
@@ -36,12 +36,5 @@ export default function Nosto404(props: { placements?: string[] }) {
36
36
  },
37
37
  [recommendationComponent, pageTypeUpdated]
38
38
  )
39
-
40
- return (
41
- <>
42
- <div className="nosto_page_type" style={{ display: "none" }}>
43
- notfound
44
- </div>
45
- </>
46
- )
39
+ return null
47
40
  }
@@ -39,15 +39,5 @@ export default function NostoCategory(props: { category: string; placements?: st
39
39
  },
40
40
  [category, recommendationComponent, pageTypeUpdated]
41
41
  )
42
-
43
- return (
44
- <>
45
- <div className="nosto_page_type" style={{ display: "none" }}>
46
- category
47
- </div>
48
- <div className="nosto_category" style={{ display: "none" }}>
49
- {category}
50
- </div>
51
- </>
52
- )
42
+ return null
53
43
  }
@@ -20,7 +20,6 @@ import { useNostoApi } from "../utils/hooks"
20
20
  *
21
21
  * @group Components
22
22
  */
23
-
24
23
  export default function NostoCheckout(props: { placements?: string[] }) {
25
24
  const { recommendationComponent, useRenderCampaigns } = useNostoContext()
26
25
 
@@ -36,12 +35,5 @@ export default function NostoCheckout(props: { placements?: string[] }) {
36
35
  },
37
36
  [recommendationComponent, pageTypeUpdated]
38
37
  )
39
-
40
- return (
41
- <>
42
- <div className="nosto_page_type" style={{ display: "none" }}>
43
- cart
44
- </div>
45
- </>
46
- )
38
+ return null
47
39
  }
@@ -39,12 +39,5 @@ export default function NostoHome(props: { placements?: string[] }) {
39
39
  },
40
40
  [recommendationComponent, pageTypeUpdated]
41
41
  )
42
-
43
- return (
44
- <>
45
- <div className="nosto_page_type" style={{ display: "none" }}>
46
- front
47
- </div>
48
- </>
49
- )
42
+ return null
50
43
  }
@@ -1,4 +1,4 @@
1
- import { Purchase } from "../types"
1
+ import { Order } from "../types"
2
2
  import { useNostoContext } from "./context"
3
3
  import { snakeize } from "../utils/snakeize"
4
4
  import { useNostoApi } from "../utils/hooks"
@@ -23,7 +23,7 @@ import { useNostoApi } from "../utils/hooks"
23
23
  * @group Components
24
24
  */
25
25
  export default function NostoOrder(props: {
26
- order: { purchase: Purchase }
26
+ order: Order,
27
27
  placements?: string[]
28
28
  }) {
29
29
  const { order, placements } = props
@@ -41,15 +41,5 @@ export default function NostoOrder(props: {
41
41
  },
42
42
  [recommendationComponent, pageTypeUpdated]
43
43
  )
44
-
45
- return (
46
- <>
47
- <div className="nosto_page_type" style={{ display: "none" }}>
48
- order
49
- </div>
50
- <div className="nosto_order" style={{ display: "none" }}>
51
- {order.purchase.number}
52
- </div>
53
- </>
54
- )
44
+ return null
55
45
  }
@@ -35,12 +35,5 @@ export default function NostoOther(props: { placements?: string[] }) {
35
35
  },
36
36
  [recommendationComponent, pageTypeUpdated]
37
37
  )
38
-
39
- return (
40
- <>
41
- <div className="nosto_page_type" style={{ display: "none" }}>
42
- other
43
- </div>
44
- </>
45
- )
38
+ return null
46
39
  }
@@ -1,6 +1,6 @@
1
- import { Product } from "../types"
2
1
  import { useNostoContext } from "./context"
3
2
  import { useNostoApi } from "../utils/hooks"
3
+ import { Product } from "../types"
4
4
 
5
5
  /**
6
6
  * The NostoProduct component must be used to personalise the product page.
@@ -39,7 +39,7 @@ export default function NostoProduct(props: {
39
39
  useNostoApi(
40
40
  async (api) => {
41
41
  const data = await api.defaultSession()
42
- .viewProduct(product)
42
+ .viewProduct(tagging ?? product)
43
43
  .setPlacements(placements || api.placements.getPlacements())
44
44
  .load()
45
45
  renderCampaigns(data, api)
@@ -47,97 +47,5 @@ export default function NostoProduct(props: {
47
47
  [product, recommendationComponent, pageTypeUpdated],
48
48
  { deep: true }
49
49
  )
50
-
51
- return (
52
- <>
53
- <div className="nosto_page_type" style={{ display: "none" }}>
54
- product
55
- </div>
56
- <div className="nosto_product" style={{ display: "none" }}>
57
- {tagging?.variationId && <span className="variation_id">{tagging.variationId}</span>}
58
- {product && <span className="product_id">{product}</span>}
59
- {tagging?.name && <span className="name">{tagging.name}</span>}
60
- {tagging?.url && <span className="url">{tagging.url.toString()}</span>}
61
- {tagging?.imageUrl && <span className="image_url">{tagging.imageUrl.toString()}</span>}
62
- {tagging?.availability && <span className="availability">{tagging.availability}</span>}
63
- {tagging?.price && <span className="price">{tagging.price}</span>}
64
- {tagging?.listPrice && <span className="list_price">{tagging.listPrice}</span>}
65
- {tagging?.priceCurrencyCode && (
66
- <span className="price_currency_code">{tagging.priceCurrencyCode}</span>
67
- )}
68
- {tagging?.brand && <span className="brand">{tagging.brand}</span>}
69
- {tagging?.description && <span className="description">{tagging.description}</span>}
70
- {tagging?.googleCategory && <span className="description">{tagging.googleCategory}</span>}
71
- {tagging?.condition && <span className="condition">{tagging.condition}</span>}
72
- {tagging?.gender && <span className="gender">{tagging.gender}</span>}
73
- {tagging?.ageGroup && <span className="age_group">{tagging.ageGroup}</span>}
74
- {tagging?.gtin && <span className="gtin">{tagging.gtin}</span>}
75
- {tagging?.category &&
76
- tagging?.category.map((category, index) => (
77
- <span className="category" key={index}>
78
- {category}
79
- </span>
80
- ))}
81
- {tagging?.tags1 &&
82
- tagging.tags1.map((tag, index) => (
83
- <span className="tag1" key={index}>
84
- {tag}
85
- </span>
86
- ))}
87
- {tagging?.tags2 &&
88
- tagging.tags2.map((tag, index) => (
89
- <span className="tag2" key={index}>
90
- {tag}
91
- </span>
92
- ))}
93
- {tagging?.tags3 &&
94
- tagging.tags3.map((tag, index) => (
95
- <span className="tag3" key={index}>
96
- {tag}
97
- </span>
98
- ))}
99
- {tagging?.ratingValue && <span className="rating_value">{tagging.ratingValue}</span>}
100
- {tagging?.reviewCount && <span className="review_count">{tagging.reviewCount}</span>}
101
- {tagging?.alternateImageUrls &&
102
- tagging.alternateImageUrls.map((url, index) => (
103
- <span className="alternate_image_url" key={index}>
104
- {url.toString()}
105
- </span>
106
- ))}
107
- {tagging?.customFields &&
108
- Object.keys(tagging.customFields).map(
109
- (field, index) =>
110
- tagging.customFields &&
111
- tagging.customFields[field] && (
112
- <span className={field} key={index}>
113
- {tagging.customFields[field]}
114
- </span>
115
- )
116
- )}
117
- {tagging?.skus &&
118
- tagging.skus.map((sku, index) => (
119
- <span className="nosto_sku" key={index}>
120
- {sku?.id && <span className="product_id">{sku.id}</span>}
121
- {sku?.name && <span className="name">{sku.name}</span>}
122
- {sku?.price && <span className="price">{sku.price}</span>}
123
- {sku?.listPrice && <span className="list_price">{sku.listPrice}</span>}
124
- {sku?.url && <span className="url">{sku.url.toString()}</span>}
125
- {sku?.imageUrl && <span className="image_url">{sku.imageUrl.toString()}</span>}
126
- {sku?.gtin && <span className="gtin">{sku.gtin}</span>}
127
- {sku?.availability && <span className="availability">{sku.availability}</span>}
128
- {sku?.customFields &&
129
- Object.keys(sku.customFields).map(
130
- (field, index) =>
131
- sku.customFields &&
132
- sku.customFields[field] && (
133
- <span className={field} key={index}>
134
- {sku.customFields[field]}
135
- </span>
136
- )
137
- )}
138
- </span>
139
- ))}
140
- </div>
141
- </>
142
- )
50
+ return null
143
51
  }
@@ -40,15 +40,5 @@ export default function NostoSearch(props: { query: string; placements?: string[
40
40
  },
41
41
  [query, recommendationComponent, pageTypeUpdated]
42
42
  )
43
-
44
- return (
45
- <>
46
- <div className="nosto_page_type" style={{ display: "none" }}>
47
- search
48
- </div>
49
- <div className="nosto_search" style={{ display: "none" }}>
50
- {query}
51
- </div>
52
- </>
53
- )
43
+ return null
54
44
  }
@@ -13,8 +13,8 @@ import { useDeepCompareEffect } from "../utils/hooks"
13
13
  *
14
14
  * @group Essential Functions
15
15
  */
16
- export default function NostoSession(props: { cart: Cart; customer: Customer }) {
17
- const { cart, customer } = props
16
+ export default function NostoSession(props?: { cart?: Cart; customer?: Customer }) {
17
+ const { cart, customer } = props ?? {}
18
18
  const { clientScriptLoaded } = useNostoContext()
19
19
 
20
20
  useDeepCompareEffect(() => {
@@ -1,5 +1,5 @@
1
1
  import { createContext, useContext } from "react"
2
- import { NostoClient, Recommendation } from "../types"
2
+ import { NostoClient, Recommendation, RenderMode } from "../types"
3
3
 
4
4
  type AnyFunction = (...args: unknown[]) => unknown
5
5
 
@@ -11,7 +11,7 @@ export interface NostoContextType {
11
11
  clientScriptLoaded: boolean
12
12
  currentVariation?: string
13
13
  renderFunction?: AnyFunction
14
- responseMode: string
14
+ responseMode: RenderMode
15
15
  recommendationComponent?: React.ReactElement<{
16
16
  nostoRecommendation: Recommendation
17
17
  }>
package/src/index.ts CHANGED
@@ -1,3 +1,2 @@
1
- export type { Buyer, Cart, Customer, Item, Product, Purchase, Recommendation, SKU } from "./types"
2
-
1
+ export type { Cart, Customer, Product, Order, Recommendation } from "./types"
3
2
  export * from "./components"