@nosto/nosto-react 0.5.0 → 2.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(E,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("react"),require("react-dom/client")):typeof define=="function"&&define.amd?define(["exports","react","react-dom/client"],_):(E=typeof globalThis<"u"?globalThis:E||self,_(E["@nosto/nosto-react"]={},E.React,E.ReactDOM))})(this,function(E,_,We){"use strict";const ce=r=>String(r)==="[object Object]";function le(r){if(!ce(r))return!1;const o=r.constructor;if(o===void 0)return!0;const a=o.prototype;return!(!ce(a)||!a.hasOwnProperty("isPrototypeOf"))}function Z(r,o){if(r===o)return!0;if(r instanceof Date&&o instanceof Date)return r.getTime()===o.getTime();if(r instanceof Array&&o instanceof Array)return r.length!==o.length?!1:r.every((a,s)=>Z(a,o[s]));if(le(r)&&le(o)){const a=Object.entries(r);return a.length!==Object.keys(o).length?!1:a.every(([s,d])=>Z(d,o[s]))}return!1}function fe(r,o){return _.useEffect(r,Ve(o))}function Ve(r){const o=_.useRef(r),a=_.useRef(0);return Z(r,o.current)||(o.current=r,a.current+=1),_.useMemo(()=>o.current,[a.current])}const Q=_.createContext({account:"",currentVariation:"",responseMode:"HTML",clientScriptLoaded:!1});function B(){const r=_.useContext(Q);if(!r)throw new Error("No nosto context found");return r}function k(r,o,a){const{clientScriptLoaded:s,currentVariation:d,responseMode:v}=B();(a!=null&&a.deep?fe:_.useEffect)(()=>{s&&window.nostojs(g=>{g.defaultSession().setVariation(d).setResponseMode(v),r(g)})},[s,d,v,...o??[]])}var ee={exports:{}},W={};/**
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 de;function Ye(){if(de)return W;de=1;var r=_,o=Symbol.for("react.element"),a=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,d=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,v={key:!0,ref:!0,__self:!0,__source:!0};function l(g,y,T){var w,S={},j=null,F=null;T!==void 0&&(j=""+T),y.key!==void 0&&(j=""+y.key),y.ref!==void 0&&(F=y.ref);for(w in y)s.call(y,w)&&!v.hasOwnProperty(w)&&(S[w]=y[w]);if(g&&g.defaultProps)for(w in y=g.defaultProps,y)S[w]===void 0&&(S[w]=y[w]);return{$$typeof:o,type:g,key:j,ref:F,props:S,_owner:d.current}}return W.Fragment=a,W.jsx=l,W.jsxs=l,W}var V={};/**
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 me;function Me(){return me||(me=1,process.env.NODE_ENV!=="production"&&function(){var r=_,o=Symbol.for("react.element"),a=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),d=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),g=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),w=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),F=Symbol.for("react.offscreen"),M=Symbol.iterator,p="@@iterator";function N(e){if(e===null||typeof e!="object")return null;var t=M&&e[M]||e[p];return typeof t=="function"?t:null}var C=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function R(e){{for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];it("error",e,n)}}function it(e,t,n){{var i=C.ReactDebugCurrentFrame,f=i.getStackAddendum();f!==""&&(t+="%s",n=n.concat([f]));var m=n.map(function(c){return String(c)});m.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,m)}}var st=!1,ut=!1,ct=!1,lt=!1,ft=!1,pe;pe=Symbol.for("react.module.reference");function dt(e){return!!(typeof e=="string"||typeof e=="function"||e===s||e===v||ft||e===d||e===T||e===w||lt||e===F||st||ut||ct||typeof e=="object"&&e!==null&&(e.$$typeof===j||e.$$typeof===S||e.$$typeof===l||e.$$typeof===g||e.$$typeof===y||e.$$typeof===pe||e.getModuleId!==void 0))}function mt(e,t,n){var i=e.displayName;if(i)return i;var f=t.displayName||t.name||"";return f!==""?n+"("+f+")":n}function ge(e){return e.displayName||"Context"}function x(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 s:return"Fragment";case a:return"Portal";case v:return"Profiler";case d:return"StrictMode";case T:return"Suspense";case w:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case g:var t=e;return ge(t)+".Consumer";case l:var n=e;return ge(n._context)+".Provider";case y:return mt(e,e.render,"ForwardRef");case S:var i=e.displayName||null;return i!==null?i:x(e.type)||"Memo";case j:{var f=e,m=f._payload,c=f._init;try{return x(c(m))}catch{return null}}}return null}var L=Object.assign,U=0,ye,he,Ee,be,_e,we,Re;function Ce(){}Ce.__reactDisabledLog=!0;function vt(){{if(U===0){ye=console.log,he=console.info,Ee=console.warn,be=console.error,_e=console.group,we=console.groupCollapsed,Re=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ce,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}U++}}function pt(){{if(U--,U===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:L({},e,{value:ye}),info:L({},e,{value:he}),warn:L({},e,{value:Ee}),error:L({},e,{value:be}),group:L({},e,{value:_e}),groupCollapsed:L({},e,{value:we}),groupEnd:L({},e,{value:Re})})}U<0&&R("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var te=C.ReactCurrentDispatcher,re;function z(e,t,n){{if(re===void 0)try{throw Error()}catch(f){var i=f.stack.trim().match(/\n( *(at )?)/);re=i&&i[1]||""}return`
18
+ `+re+e}}var ne=!1,J;{var gt=typeof WeakMap=="function"?WeakMap:Map;J=new gt}function Pe(e,t){if(!e||ne)return"";{var n=J.get(e);if(n!==void 0)return n}var i;ne=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var m;m=te.current,te.current=null,vt();try{if(t){var c=function(){throw Error()};if(Object.defineProperty(c.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(c,[])}catch(A){i=A}Reflect.construct(e,[],c)}else{try{c.call()}catch(A){i=A}e.call(c.prototype)}}else{try{throw Error()}catch(A){i=A}e()}}catch(A){if(A&&i&&typeof A.stack=="string"){for(var u=A.stack.split(`
19
+ `),P=i.stack.split(`
20
+ `),h=u.length-1,b=P.length-1;h>=1&&b>=0&&u[h]!==P[b];)b--;for(;h>=1&&b>=0;h--,b--)if(u[h]!==P[b]){if(h!==1||b!==1)do if(h--,b--,b<0||u[h]!==P[b]){var O=`
21
+ `+u[h].replace(" at new "," at ");return e.displayName&&O.includes("<anonymous>")&&(O=O.replace("<anonymous>",e.displayName)),typeof e=="function"&&J.set(e,O),O}while(h>=1&&b>=0);break}}}finally{ne=!1,te.current=m,pt(),Error.prepareStackTrace=f}var $=e?e.displayName||e.name:"",$e=$?z($):"";return typeof e=="function"&&J.set(e,$e),$e}function yt(e,t,n){return Pe(e,!1)}function ht(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function G(e,t,n){if(e==null)return"";if(typeof e=="function")return Pe(e,ht(e));if(typeof e=="string")return z(e);switch(e){case T:return z("Suspense");case w:return z("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case y:return yt(e.render);case S:return G(e.type,t,n);case j:{var i=e,f=i._payload,m=i._init;try{return G(m(f),t,n)}catch{}}}return""}var K=Object.prototype.hasOwnProperty,Se={},Oe=C.ReactDebugCurrentFrame;function X(e){if(e){var t=e._owner,n=G(e.type,e._source,t?t.type:null);Oe.setExtraStackFrame(n)}else Oe.setExtraStackFrame(null)}function Et(e,t,n,i,f){{var m=Function.call.bind(K);for(var c in e)if(m(e,c)){var u=void 0;try{if(typeof e[c]!="function"){var P=Error((i||"React class")+": "+n+" type `"+c+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[c]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw P.name="Invariant Violation",P}u=e[c](t,c,i,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(h){u=h}u&&!(u instanceof Error)&&(X(f),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).",i||"React class",n,c,typeof u),X(null)),u instanceof Error&&!(u.message in Se)&&(Se[u.message]=!0,X(f),R("Failed %s type: %s",n,u.message),X(null))}}}var bt=Array.isArray;function oe(e){return bt(e)}function _t(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,n=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n}}function wt(e){try{return Te(e),!1}catch{return!0}}function Te(e){return""+e}function je(e){if(wt(e))return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",_t(e)),Te(e)}var q=C.ReactCurrentOwner,Rt={key:!0,ref:!0,__self:!0,__source:!0},Ne,xe,ae;ae={};function Ct(e){if(K.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function Pt(e){if(K.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function St(e,t){if(typeof e.ref=="string"&&q.current&&t&&q.current.stateNode!==t){var n=x(q.current.type);ae[n]||(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',x(q.current.type),e.ref),ae[n]=!0)}}function Ot(e,t){{var n=function(){Ne||(Ne=!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))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}}function Tt(e,t){{var n=function(){xe||(xe=!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))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}}var jt=function(e,t,n,i,f,m,c){var u={$$typeof:o,type:e,key:t,ref:n,props:c,_owner:m};return u._store={},Object.defineProperty(u._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(u,"_self",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.defineProperty(u,"_source",{configurable:!1,enumerable:!1,writable:!1,value:f}),Object.freeze&&(Object.freeze(u.props),Object.freeze(u)),u};function Nt(e,t,n,i,f){{var m,c={},u=null,P=null;n!==void 0&&(je(n),u=""+n),Pt(t)&&(je(t.key),u=""+t.key),Ct(t)&&(P=t.ref,St(t,f));for(m in t)K.call(t,m)&&!Rt.hasOwnProperty(m)&&(c[m]=t[m]);if(e&&e.defaultProps){var h=e.defaultProps;for(m in h)c[m]===void 0&&(c[m]=h[m])}if(u||P){var b=typeof e=="function"?e.displayName||e.name||"Unknown":e;u&&Ot(c,b),P&&Tt(c,b)}return jt(e,u,P,f,i,q.current,c)}}var ie=C.ReactCurrentOwner,Ae=C.ReactDebugCurrentFrame;function I(e){if(e){var t=e._owner,n=G(e.type,e._source,t?t.type:null);Ae.setExtraStackFrame(n)}else Ae.setExtraStackFrame(null)}var se;se=!1;function ue(e){return typeof e=="object"&&e!==null&&e.$$typeof===o}function ke(){{if(ie.current){var e=x(ie.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 xt(e){return""}var De={};function At(e){{var t=ke();if(!t){var n=typeof e=="string"?e:e.displayName||e.name;n&&(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 <`+n+">.")}return t}}function Fe(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var n=At(t);if(De[n])return;De[n]=!0;var i="";e&&e._owner&&e._owner!==ie.current&&(i=" It was passed a child from "+x(e._owner.type)+"."),I(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.',n,i),I(null)}}function Le(e,t){{if(typeof e!="object")return;if(oe(e))for(var n=0;n<e.length;n++){var i=e[n];ue(i)&&Fe(i,t)}else if(ue(e))e._store&&(e._store.validated=!0);else if(e){var f=N(e);if(typeof f=="function"&&f!==e.entries)for(var m=f.call(e),c;!(c=m.next()).done;)ue(c.value)&&Fe(c.value,t)}}}function kt(e){{var t=e.type;if(t==null||typeof t=="string")return;var n;if(typeof t=="function")n=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===y||t.$$typeof===S))n=t.propTypes;else return;if(n){var i=x(t);Et(n,e.props,"prop",i,e)}else if(t.PropTypes!==void 0&&!se){se=!0;var f=x(t);R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",f||"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 Dt(e){{for(var t=Object.keys(e.props),n=0;n<t.length;n++){var i=t[n];if(i!=="children"&&i!=="key"){I(e),R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",i),I(null);break}}e.ref!==null&&(I(e),R("Invalid attribute `ref` supplied to `React.Fragment`."),I(null))}}function Ie(e,t,n,i,f,m){{var c=dt(e);if(!c){var u="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(u+=" 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 P=xt();P?u+=P:u+=ke();var h;e===null?h="null":oe(e)?h="array":e!==void 0&&e.$$typeof===o?(h="<"+(x(e.type)||"Unknown")+" />",u=" Did you accidentally export a JSX literal instead of a component?"):h=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",h,u)}var b=Nt(e,t,n,f,m);if(b==null)return b;if(c){var O=t.children;if(O!==void 0)if(i)if(oe(O)){for(var $=0;$<O.length;$++)Le(O[$],e);Object.freeze&&Object.freeze(O)}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 Le(O,e)}return e===s?Dt(b):kt(b),b}}function Ft(e,t,n){return Ie(e,t,n,!0)}function Lt(e,t,n){return Ie(e,t,n,!1)}var It=Lt,$t=Ft;V.Fragment=s,V.jsx=It,V.jsxs=$t}()),V}process.env.NODE_ENV==="production"?ee.exports=Ye():ee.exports=Me();var ve=ee.exports;const H=ve.jsx,Ue=ve.Fragment;function qe(r){return _.cloneElement(r.recommendationComponent,{nostoRecommendation:r.nostoRecommendation})}function Be(r){if(!window.nostojs)throw new Error("Nosto has not yet been initialized");window.nostojs(o=>{o.placements.injectCampaigns(r.recommendations)})}function D(){const{responseMode:r,recommendationComponent:o}=B(),a=_.useRef({});if(r=="HTML")return{renderCampaigns:Be};function s(d){var l;const v=((l=d.campaigns)==null?void 0:l.recommendations)??{};for(const g in v){const y=v[g],T="#"+g,w=document.querySelector(T);w&&(a.current[g]||(a.current[g]=We.createRoot(w)),a.current[g].render(H(qe,{recommendationComponent:o,nostoRecommendation:y})))}}return{renderCampaigns:s}}function He(r){const{renderCampaigns:o}=D();return k(async a=>{const s=await a.defaultSession().viewNotFound().setPlacements(r.placements||a.placements.getPlacements()).load();o(s)}),null}function ze(r){const{renderCampaigns:o}=D();return k(async a=>{const s=await a.defaultSession().viewOther().setPlacements(r.placements||a.placements.getPlacements()).load();o(s)}),null}function Je(r){const{renderCampaigns:o}=D();return k(async a=>{const s=await a.defaultSession().viewCart().setPlacements(r.placements||a.placements.getPlacements()).load();o(s)}),null}function Ge(r){const{product:o,tagging:a,placements:s}=r,{renderCampaigns:d}=D();return k(async v=>{const l=await v.defaultSession().viewProduct(a??o).setPlacements(s||v.placements.getPlacements()).load();d(l)},[o,a==null?void 0:a.selected_sku_id]),null}function Ke(r){const{category:o,placements:a}=r,{renderCampaigns:s}=D();return k(async d=>{const v=await d.defaultSession().viewCategory(o).setPlacements(a||d.placements.getPlacements()).load();s(v)},[o]),null}function Xe(r){const{query:o,placements:a}=r,{renderCampaigns:s}=D();return k(async d=>{const v=await d.defaultSession().viewSearch(o).setPlacements(a||d.placements.getPlacements()).load();s(v)},[o]),null}function Y(r){return!r||typeof r!="object"||Ze(r)||Qe(r)?r:Array.isArray(r)?r.map(Y):Object.keys(r).reduce((o,a)=>{const s=a[0].toLowerCase()+a.slice(1).replace(/([A-Z]+)/g,(d,v)=>"_"+v.toLowerCase());return o[s]=Y(r[a]),o},{})}function Ze(r){return Object.prototype.toString.call(r)==="[object Date]"}function Qe(r){return Object.prototype.toString.call(r)==="[object RegExp]"}function et(r){const{order:o,placements:a}=r,{renderCampaigns:s}=D();return k(async d=>{const v=await d.defaultSession().addOrder(Y(o)).setPlacements(a||d.placements.getPlacements()).load();s(v)},[o],{deep:!0}),null}function tt(r){const{renderCampaigns:o}=D();return k(async a=>{const s=await a.defaultSession().viewFrontPage().setPlacements(r.placements||a.placements.getPlacements()).load();o(s)}),null}function rt(r){const{id:o,pageType:a}=r;return H("div",{className:"nosto_element",id:o},o+(a||""))}function nt(){return typeof window.nosto<"u"}function ot(r){const{account:o,multiCurrency:a=!1,host:s,children:d,recommendationComponent:v,shopifyMarkets:l}=r,[g,y]=_.useState(!1),T=_.useMemo(()=>g,[g]),w=a?r.currentVariation:"",S=_.isValidElement(v)?"JSON_ORIGINAL":"HTML";return _.useEffect(()=>{var j,F,M;if(window.nostojs||(window.nostojs=p=>{(window.nostojs.q=window.nostojs.q||[]).push(p)},window.nostojs(p=>p.setAutoLoad(!1))),!nt()&&!l){const p=document.createElement("script");p.type="text/javascript",p.src="//"+(s||"connect.nosto.com")+"/include/"+o,p.async=!0,p.setAttribute("nosto-client-script",""),p.onload=()=>{var N;typeof jest<"u"&&((N=window.nosto)==null||N.reload({site:"localhost"})),y(!0)},document.body.appendChild(p)}if(l){const p=document.querySelector("[nosto-client-script]"),N=document.querySelector("#nosto-sandbox");if(!p||(p==null?void 0:p.getAttribute("nosto-language"))!==(l==null?void 0:l.language)||(p==null?void 0:p.getAttribute("nosto-market-id"))!==(l==null?void 0:l.marketId)){g&&y(!1),(j=p==null?void 0:p.parentNode)==null||j.removeChild(p),(F=N==null?void 0:N.parentNode)==null||F.removeChild(N);const C=document.createElement("script");C.type="text/javascript",C.src="//"+(s||"connect.nosto.com")+`/script/shopify/market/nosto.js?merchant=${o}&market=${l.marketId||""}&locale=${((M=l==null?void 0:l.language)==null?void 0:M.toLowerCase())||""}`,C.async=!0,C.setAttribute("nosto-client-script",""),C.setAttribute("nosto-language",(l==null?void 0:l.language)||""),C.setAttribute("nosto-market-id",String(l==null?void 0:l.marketId)),C.onload=()=>{var R;typeof jest<"u"&&((R=window.nosto)==null||R.reload({site:"localhost"})),y(!0)},document.body.appendChild(C)}}},[g,l]),H(Q.Provider,{value:{account:o,clientScriptLoaded:T,currentVariation:w,responseMode:S,recommendationComponent:v},children:d})}function at(r){const{cart:o,customer:a}=r??{},{clientScriptLoaded:s}=B();return fe(()=>{const d=o?Y(o):void 0,v=a?Y(a):void 0;s&&window.nostojs(l=>{l.defaultSession().setResponseMode("HTML").setCart(d).setCustomer(v).viewOther().load()})},[s,o,a]),H(Ue,{})}E.Nosto404=He,E.NostoCategory=Ke,E.NostoCheckout=Je,E.NostoContext=Q,E.NostoHome=tt,E.NostoOrder=et,E.NostoOther=ze,E.NostoPlacement=rt,E.NostoProduct=Ge,E.NostoProvider=ot,E.NostoSearch=Xe,E.NostoSession=at,E.useNostoContext=B,Object.defineProperty(E,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": "2.0.0",
5
5
  "author": "Mridang Agarwalla, Dominik Gilg",
6
6
  "license": "ISC",
7
7
  "repository": {
@@ -48,6 +48,8 @@
48
48
  "prettier": "^2.0.5",
49
49
  "react": "*",
50
50
  "react-dom": "*",
51
+ "react-router": "^6.25.1",
52
+ "react-router-dom": "^6.25.1",
51
53
  "rimraf": "^3.0.2",
52
54
  "ts-jest": "^29.1.0",
53
55
  "typedoc": "^0.24.1",
@@ -1,5 +1,4 @@
1
- import { useNostoContext } from "./context"
2
- import { useNostoApi } from "../utils/hooks"
1
+ import { useNostoApi, useRenderCampaigns } from "../hooks"
3
2
 
4
3
  /**
5
4
  * You can personalise your cart and checkout pages by using the `Nosto404` component.
@@ -22,9 +21,7 @@ import { useNostoApi } from "../utils/hooks"
22
21
  * @group Components
23
22
  */
24
23
  export default function Nosto404(props: { placements?: string[] }) {
25
- const { recommendationComponent, useRenderCampaigns } = useNostoContext()
26
-
27
- const { renderCampaigns, pageTypeUpdated } = useRenderCampaigns("404")
24
+ const { renderCampaigns } = useRenderCampaigns()
28
25
 
29
26
  useNostoApi(
30
27
  async (api) => {
@@ -32,16 +29,7 @@ export default function Nosto404(props: { placements?: string[] }) {
32
29
  .viewNotFound()
33
30
  .setPlacements(props.placements || api.placements.getPlacements())
34
31
  .load()
35
- renderCampaigns(data, api)
36
- },
37
- [recommendationComponent, pageTypeUpdated]
38
- )
39
-
40
- return (
41
- <>
42
- <div className="nosto_page_type" style={{ display: "none" }}>
43
- notfound
44
- </div>
45
- </>
46
- )
32
+ renderCampaigns(data)
33
+ })
34
+ return null
47
35
  }
@@ -1,5 +1,4 @@
1
- import { useNostoContext } from "./context"
2
- import { useNostoApi } from "../utils/hooks"
1
+ import { useNostoApi, useRenderCampaigns } from "../hooks"
3
2
 
4
3
  /**
5
4
  * You can personalise your category and collection pages by using the NostoCategory component.
@@ -25,9 +24,7 @@ import { useNostoApi } from "../utils/hooks"
25
24
  */
26
25
  export default function NostoCategory(props: { category: string; placements?: string[] }) {
27
26
  const { category, placements } = props
28
- const { recommendationComponent, useRenderCampaigns } = useNostoContext()
29
-
30
- const { renderCampaigns, pageTypeUpdated } = useRenderCampaigns("home")
27
+ const { renderCampaigns } = useRenderCampaigns()
31
28
 
32
29
  useNostoApi(
33
30
  async (api) => {
@@ -35,19 +32,9 @@ export default function NostoCategory(props: { category: string; placements?: st
35
32
  .viewCategory(category)
36
33
  .setPlacements(placements || api.placements.getPlacements())
37
34
  .load()
38
- renderCampaigns(data, api)
35
+ renderCampaigns(data)
39
36
  },
40
- [category, recommendationComponent, pageTypeUpdated]
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
- </>
37
+ [category]
52
38
  )
39
+ return null
53
40
  }
@@ -1,5 +1,4 @@
1
- import { useNostoContext } from "./context"
2
- import { useNostoApi } from "../utils/hooks"
1
+ import { useNostoApi, useRenderCampaigns } from "../hooks"
3
2
 
4
3
  /**
5
4
  * You can personalise your cart and checkout pages by using the NostoCheckout component.
@@ -20,11 +19,8 @@ import { useNostoApi } from "../utils/hooks"
20
19
  *
21
20
  * @group Components
22
21
  */
23
-
24
22
  export default function NostoCheckout(props: { placements?: string[] }) {
25
- const { recommendationComponent, useRenderCampaigns } = useNostoContext()
26
-
27
- const { renderCampaigns, pageTypeUpdated } = useRenderCampaigns("checkout")
23
+ const { renderCampaigns } = useRenderCampaigns()
28
24
 
29
25
  useNostoApi(
30
26
  async (api) => {
@@ -32,16 +28,7 @@ export default function NostoCheckout(props: { placements?: string[] }) {
32
28
  .viewCart()
33
29
  .setPlacements(props.placements || api.placements.getPlacements())
34
30
  .load()
35
- renderCampaigns(data, api)
36
- },
37
- [recommendationComponent, pageTypeUpdated]
38
- )
39
-
40
- return (
41
- <>
42
- <div className="nosto_page_type" style={{ display: "none" }}>
43
- cart
44
- </div>
45
- </>
46
- )
31
+ renderCampaigns(data)
32
+ })
33
+ return null
47
34
  }
@@ -1,5 +1,4 @@
1
- import { useNostoContext } from "./context"
2
- import { useNostoApi } from "../utils/hooks"
1
+ import { useRenderCampaigns, useNostoApi } from "../hooks"
3
2
 
4
3
  /**
5
4
  * The `NostoHome` component must be used to personalise the home page. The component does not require any props.
@@ -25,9 +24,7 @@ import { useNostoApi } from "../utils/hooks"
25
24
  * @group Components
26
25
  */
27
26
  export default function NostoHome(props: { placements?: string[] }) {
28
- const { recommendationComponent, useRenderCampaigns } = useNostoContext()
29
-
30
- const { renderCampaigns, pageTypeUpdated } = useRenderCampaigns("home")
27
+ const { renderCampaigns } = useRenderCampaigns()
31
28
 
32
29
  useNostoApi(
33
30
  async (api) => {
@@ -35,16 +32,8 @@ export default function NostoHome(props: { placements?: string[] }) {
35
32
  .viewFrontPage()
36
33
  .setPlacements(props.placements || api.placements.getPlacements())
37
34
  .load()
38
- renderCampaigns(data, api)
39
- },
40
- [recommendationComponent, pageTypeUpdated]
41
- )
42
-
43
- return (
44
- <>
45
- <div className="nosto_page_type" style={{ display: "none" }}>
46
- front
47
- </div>
48
- </>
35
+ renderCampaigns(data)
36
+ }
49
37
  )
38
+ return null
50
39
  }
@@ -1,7 +1,6 @@
1
- import { Purchase } from "../types"
2
- import { useNostoContext } from "./context"
1
+ import { Order } from "../types"
2
+ import { useRenderCampaigns, useNostoApi } from "../hooks"
3
3
  import { snakeize } from "../utils/snakeize"
4
- import { useNostoApi } from "../utils/hooks"
5
4
 
6
5
  /**
7
6
  * You can personalise your order-confirmation/thank-you page by using the `NostoOrder` component.
@@ -23,13 +22,11 @@ import { useNostoApi } from "../utils/hooks"
23
22
  * @group Components
24
23
  */
25
24
  export default function NostoOrder(props: {
26
- order: { purchase: Purchase }
25
+ order: Order,
27
26
  placements?: string[]
28
27
  }) {
29
28
  const { order, placements } = props
30
- const { recommendationComponent, useRenderCampaigns } = useNostoContext()
31
-
32
- const { renderCampaigns, pageTypeUpdated } = useRenderCampaigns("order")
29
+ const { renderCampaigns } = useRenderCampaigns()
33
30
 
34
31
  useNostoApi(
35
32
  async (api) => {
@@ -37,19 +34,10 @@ export default function NostoOrder(props: {
37
34
  .addOrder(snakeize(order))
38
35
  .setPlacements(placements || api.placements.getPlacements())
39
36
  .load()
40
- renderCampaigns(data, api)
37
+ renderCampaigns(data)
41
38
  },
42
- [recommendationComponent, pageTypeUpdated]
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
- </>
39
+ [order],
40
+ { deep: true }
54
41
  )
42
+ return null
55
43
  }
@@ -1,5 +1,4 @@
1
- import { useNostoContext } from "./context"
2
- import { useNostoApi } from "../utils/hooks"
1
+ import { useRenderCampaigns, useNostoApi } from "../hooks"
3
2
 
4
3
  /**
5
4
  * You can personalise your miscellaneous pages by using the NostoOther component.
@@ -21,9 +20,7 @@ import { useNostoApi } from "../utils/hooks"
21
20
  * @group Components
22
21
  */
23
22
  export default function NostoOther(props: { placements?: string[] }) {
24
- const { recommendationComponent, useRenderCampaigns } = useNostoContext()
25
-
26
- const { renderCampaigns, pageTypeUpdated } = useRenderCampaigns("other")
23
+ const { renderCampaigns } = useRenderCampaigns()
27
24
 
28
25
  useNostoApi(
29
26
  async (api) => {
@@ -31,16 +28,7 @@ export default function NostoOther(props: { placements?: string[] }) {
31
28
  .viewOther()
32
29
  .setPlacements(props.placements || api.placements.getPlacements())
33
30
  .load()
34
- renderCampaigns(data, api)
35
- },
36
- [recommendationComponent, pageTypeUpdated]
37
- )
38
-
39
- return (
40
- <>
41
- <div className="nosto_page_type" style={{ display: "none" }}>
42
- other
43
- </div>
44
- </>
45
- )
31
+ renderCampaigns(data)
32
+ })
33
+ return null
46
34
  }
@@ -1,6 +1,5 @@
1
+ import { useRenderCampaigns, useNostoApi } from "../hooks"
1
2
  import { Product } from "../types"
2
- import { useNostoContext } from "./context"
3
- import { useNostoApi } from "../utils/hooks"
4
3
 
5
4
  /**
6
5
  * The NostoProduct component must be used to personalise the product page.
@@ -32,112 +31,17 @@ export default function NostoProduct(props: {
32
31
  placements?: string[]
33
32
  }) {
34
33
  const { product, tagging, placements } = props
35
- const { recommendationComponent, useRenderCampaigns } = useNostoContext()
36
-
37
- const { renderCampaigns, pageTypeUpdated } = useRenderCampaigns("product")
34
+ const { renderCampaigns } = useRenderCampaigns()
38
35
 
39
36
  useNostoApi(
40
37
  async (api) => {
41
38
  const data = await api.defaultSession()
42
- .viewProduct(product)
39
+ .viewProduct(tagging ?? product)
43
40
  .setPlacements(placements || api.placements.getPlacements())
44
41
  .load()
45
- renderCampaigns(data, api)
42
+ renderCampaigns(data)
46
43
  },
47
- [product, recommendationComponent, pageTypeUpdated],
48
- { deep: true }
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
- </>
44
+ [product, tagging?.selected_sku_id]
142
45
  )
46
+ return null
143
47
  }