tanya-chatbot 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,5 +17,5 @@
17
17
  ${f?"translate-y-0":"translate-y-full"}
18
18
  lg:translate-y-0
19
19
  `,style:{background:"linear-gradient(170.1deg, #FFFFFF 60.03%, #E3DEEF 99.59%)"},children:[i.jsxs("div",{className:"flex justify-between p-3 bg-[#FFFFFF] border border-b-1 border-[#E5E5E5] ",children:[i.jsx("div",{style:{display:"flex",color:E.tanyaThemeContrastColor,alignItems:"center",gap:"0.5rem"},children:i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsxs("div",{className:"flex gap-2 w-28 h-12 text-center items-center p-2 border rounded-l-[20px] rounded-tr-[20px]",style:{background:"linear-gradient(265.62deg, #6851C6 5.24%, #8668FF 98.49%)"},children:[i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 15 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i.jsx("path",{d:"M15 4.48438V0.5C15 0.5 8.94395 1.4375 6.78127 4.25C4.61859 7.0625 5.33095 15.5 5.33095 15.5H9.19857C9.19857 15.5 8.72793 7.76562 10.1654 6.125C11.6029 4.48438 15 4.48438 15 4.48438Z",fill:"white"}),i.jsx("path",{d:"M0 0.5H6.28488V4.25H0V0.5Z",fill:"white"})]}),i.jsx("p",{className:"text-[#FFFFFF] font-nunitoSans font-semibold",children:"TANYA"})]}),i.jsxs("p",{className:"text-[#5B5B5B] font-nunitoSans font-semibold",style:{fontStyle:"italic"},children:[" ","Your AI shopping assistant !"," "]})]})}),i.jsx("div",{style:{display:"flex",alignItems:"center",gap:"1.25rem",margin:"0.75rem"},children:i.jsx("button",{onClick:()=>u(!1),children:i.jsxs("svg",{width:"24",height:"25",viewBox:"0 0 24 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i.jsxs("g",{clipPath:"url(#clip0_501_6036)",children:[i.jsx("path",{d:"M18 6.5L6 18.5",stroke:"#555555",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M6 6.5L18 18.5",stroke:"#555555",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),i.jsx("defs",{children:i.jsx("clipPath",{id:"clip0_501_6036",children:i.jsx("rect",{width:"24",height:"24",fill:"white",transform:"translate(0 0.5)"})})})]})})})]}),i.jsxs("div",{className:"flex h-full md:flex-row lg:flex-row",children:[i.jsxs("div",{className:`flex flex-col h-full ${O?"lg:w-2/3 w-full":"w-full"}`,children:[i.jsxs("div",{ref:wt,className:"overflow-y-auto pr-5 pb-2 space-y-4 hide-scrollbar flex-grow mb-24",children:[(E==null?void 0:E.whomRequired)&&i.jsxs("div",{className:"mx-3 p-3 rounded-2xl bg-[#FFFFFF]",children:[i.jsx("div",{className:"flex gap-2 bg-[#FFFFFF]",children:i.jsx("p",{className:"font-bold font-nunitoSans text-[#494949]",children:"Is this for you or someone else?"})}),i.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:t.map(d=>i.jsx("button",{onClick:()=>Zt(d),className:"px-2 py-2 font-semibold text-xs text-[#18181B] bg-[#F3F3F3] rounded-2xl",style:{backgroundColor:S===e[d]?"#FFFFFF":"#F3F3F3",borderColor:S===e[d]?"#BBB3DD":""},children:d},d))})]}),H.map((d,N)=>{var C,F;return i.jsxs("div",{children:[i.jsx("div",{className:"flex justify-end",children:i.jsx("p",{className:"text-sm font-nunitoSans font-bold text-[#000000] bg-[#E2DBFF] border border-[#C9C2DE] rounded-l-xl p-2 m-3 mb-4 rounded-br-xl max-w-[75%]",children:d.query})}),d.response&&d.response.includes("Thinking")?i.jsx("div",{children:i.jsx("div",{className:"font-nunitoSans animate-pulse font-bold text-sm text-[#494949] bg-[#FFFFFF] px-7 py-1 rounded-r-xl rounded-bl-2xl w-full",dangerouslySetInnerHTML:{__html:ne(d.response)}})}):i.jsx("div",{children:i.jsx("div",{className:"font-nunitoSans font-bold text-sm text-[#494949] bg-[#FFFFFF] px-7 py-1 rounded-r-xl rounded-bl-2xl w-full",dangerouslySetInnerHTML:{__html:ne(d.response)}})}),q&&!d.response.includes("Thinking")&&((C=d.products)==null?void 0:C.length)==0&&i.jsx("div",{children:i.jsx("p",{className:"text-sm animate-pulse font-nunitoSans font-bold text-[#000000] bg-[#E2DBFF] border border-[#C9C2DE] rounded-l-xl p-2 m-3 mb-4 rounded-br-xl max-w-[75%]",children:"Finding best products for you"})}),(d==null?void 0:d.products)&&((F=d==null?void 0:d.products)==null?void 0:F.length)>0&&i.jsx(uo,{chat:d.products,storeDetails:E}),d.potentialQuestions.length>0&&i.jsxs("div",{className:"my-2 px-4 text-sm text-gray-700",children:[i.jsx("p",{className:"font-nunitoSans font-bold text-sm text-[#494949]",style:{color:E.themeDarkColor},children:"Why not explore these inquiries..."}),d.potentialQuestions.split(",").map((y,j)=>i.jsx("button",{className:`cursor-pointer font-nunitoSans font-semibold text-[#232323] border bg-[#804C9E0D] border-${E.themeDarkColor} m-1 rounded-xl px-2 py-1`,onClick:()=>Y(y),style:{backgroundColor:E.tanyaThemeColorLight},children:y},j))]}),d.secondaryLoading&&i.jsx("div",{className:"mt-3 mb-4 px-4",children:i.jsxs("div",{className:"tanya-surprise-wrapper bg-indigo-300 text-sm px-7 py-4 rounded-r-xl rounded-bl-2xl w-full relative overflow-hidden",style:{margin:"0.75rem"},children:[i.jsxs("div",{className:"flex gap-1",children:[i.jsx("div",{className:"tanya-sparkle tanya-sparkle-1",children:"✨"}),i.jsx("div",{className:"tanya-sparkle tanya-sparkle-2",children:"✨"}),i.jsx("div",{className:"tanya-sparkle tanya-sparkle-3",children:"✨"})]}),i.jsx("div",{className:"tanya-shimmer"}),i.jsx("p",{className:"font-semibold tanya-pulse",style:{color:E.themeDarkColor},children:"I’ve found a special surprise crafted just for you… hang on a sec!"}),i.jsx("p",{className:"tanya-dots mt-1",style:{color:E.themeDarkColor},children:"• • •"})]})}),d.secondaryResponse&&i.jsx(i.Fragment,{children:i.jsxs("div",{className:"mt-3 mb-8 px-4 bg-indigo-300 rounded-tr-[5px]",children:[i.jsx("div",{className:"text-sm text-[#232323] bg-[#FFFFFF] px-7 py-4 rounded-br-xl rounded-bl-2xl w-full",style:{backgroundColor:E.tanyaThemeColorLight},dangerouslySetInnerHTML:{__html:ne(d.secondaryResponse)}}),d.productSnapshot&&i.jsx("div",{className:"mt-4 w-full",children:i.jsxs("div",{className:"flex gap-4 items-stretch rounded-2xl p-4",style:{backgroundColor:E.tanyaThemeColorLight},children:[i.jsx("div",{className:"flex-shrink-0 rounded-xl overflow-hidden border",style:{width:112,height:112,borderColor:"#eee"},children:d.productSnapshot.image?i.jsx("img",{src:d.productSnapshot.image,alt:d.productSnapshot.name,className:"w-full h-full object-cover"}):i.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs text-gray-500",children:"No Image"})}),i.jsxs("div",{className:"flex flex-col flex-1 justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"font-semibold text-[15px] leading-snug",children:d.productSnapshot.name}),i.jsx("p",{className:"mt-1 text-[14px] font-medium",children:d.productSnapshot.price!=null?new Intl.NumberFormat(void 0,{style:"currency",currency:(E==null?void 0:E.currency)||"USD"}).format(d.productSnapshot.price):""}),d.productSnapshot.points>0&&i.jsxs("p",{className:"mt-1 text-xs opacity-80",children:["You will earn"," ",i.jsxs("strong",{children:[d.productSnapshot.points," ","points"]})]})]}),i.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[i.jsxs("div",{className:"flex items-center border rounded-full overflow-hidden",children:[i.jsx("button",{className:"px-3 py-1 text-sm",onClick:()=>P(y=>y.map((j,B)=>B===N&&j.productSnapshot?{...j,productSnapshot:{...j.productSnapshot,quantity:Math.max(1,j.productSnapshot.quantity-1)}}:j)),style:{background:"transparent",color:E.themeDarkColor},children:"−"}),i.jsx("div",{className:"px-3 py-1 text-sm select-none",children:d.productSnapshot.quantity}),i.jsx("button",{className:"px-3 py-1 text-sm",onClick:()=>P(y=>y.map((j,B)=>B===N&&j.productSnapshot?{...j,productSnapshot:{...j.productSnapshot,quantity:j.productSnapshot.quantity+1}}:j)),style:{background:"transparent",color:E.themeDarkColor},children:"+"})]}),i.jsx("button",{onClick:()=>{Ur(R(d.productSnapshot),d.productSnapshot.quantity)},disabled:v,className:"px-4 py-2 rounded-full font-medium",style:{background:E.tanyaThemeColor,color:(E==null?void 0:E.tanyaThemeContrastColor)||"#fff",opacity:v?.8:1},children:v?"Adding...":"Add to cart"})]})]})]})})]})}),i.jsx("div",{className:"mb-20"})]},N)})]}),i.jsx("div",{className:"flex flex-col gap-2 sticky bottom-0 left-0 right-0 bg-[#E3DEEF] z-50 px-4 py-2",children:i.jsx("div",{className:"p-[1px] rounded-xl",style:{background:"linear-gradient(180deg, #B09FFF 0%, #8D79F6 100%)"},children:i.jsxs("div",{className:"flex items-center bg-[#FFFFFF] flex-1 rounded-xl px-2 py-1",children:[i.jsx("input",{className:"flex-1 bg-[#FFFFFF] text-[#232323] outline-none border-none px-2 py-2 text-sm",placeholder:"How can I help you...",value:$,autoFocus:!0,onChange:d=>X(d.target.value),onKeyDown:d=>{d.key==="Enter"&&!m&&Y()}}),i.jsx("button",{type:"submit",disabled:m,className:"p-3",onClick:()=>Y(),children:m?i.jsx("div",{className:"p-3 animate-spin rounded-full h-3 w-3 border-b-2",style:{borderBottom:"2px solid",color:E.tanyaThemeColor}}):i.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:i.jsx("path",{d:"M16.6357 13.6701L18.3521 8.5208C19.8516 4.02242 20.6013 1.77322 19.414 0.585948C18.2268 -0.601312 15.9776 0.148418 11.4792 1.64788L6.32987 3.36432C2.69923 4.57453 0.883923 5.17964 0.368062 6.06698C-0.122688 6.91112 -0.122688 7.95369 0.368062 8.7978C0.883923 9.6852 2.69923 10.2903 6.32987 11.5005C6.77981 11.6505 7.28601 11.5434 7.62294 11.2096L13.1286 5.75495C13.4383 5.44808 13.9382 5.45041 14.245 5.76015C14.5519 6.06989 14.5496 6.56975 14.2398 6.87662L8.8231 12.2432C8.4518 12.6111 8.3342 13.1742 8.4995 13.6701C9.7097 17.3007 10.3148 19.1161 11.2022 19.6319C12.0463 20.1227 13.0889 20.1227 13.933 19.6319C14.8204 19.1161 15.4255 17.3008 16.6357 13.6701Z",fill:"#6952C7"})})})]})})})]}),i.jsx(po,{})]})]})]})]})})};var ge=function(t,e){return ge=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=n[o])},ge(t,e)};function go(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ge(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var at=function(){return at=Object.assign||function(e){for(var r,n=1,o=arguments.length;n<o;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},at.apply(this,arguments)};function mo(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r}var ae="Invariant Violation",tr=Object.setPrototypeOf,wo=tr===void 0?function(t,e){return t.__proto__=e,t}:tr,Pr=(function(t){go(e,t);function e(r){r===void 0&&(r=ae);var n=t.call(this,typeof r=="number"?ae+": "+r+" (see https://github.com/apollographql/invariant-packages)":r)||this;return n.framesToPop=1,n.name=ae,wo(n,e.prototype),n}return e})(Error);function ht(t,e){if(!t)throw new Pr(e)}var Or=["debug","log","warn","error","silent"],xo=Or.indexOf("log");function qt(t){return function(){if(Or.indexOf(t)>=xo){var e=console[t]||console.log;return e.apply(console,arguments)}}}(function(t){t.debug=qt("debug"),t.log=qt("log"),t.warn=qt("warn"),t.error=qt("error")})(ht||(ht={}));var $r="3.14.0";function jt(t){try{return t()}catch{}}const me=jt(function(){return globalThis})||jt(function(){return window})||jt(function(){return self})||jt(function(){return global})||jt(function(){return jt.constructor("return this")()});var er=new Map;function yo(t){var e=er.get(t)||1;return er.set(t,e+1),"".concat(t,":").concat(e,":").concat(Math.random().toString(36).slice(2))}function bo(t,e){var r=yo("stringifyForDisplay");return JSON.stringify(t,function(n,o){return o===void 0?r:o},e).split(JSON.stringify(r)).join("<undefined>")}function Ut(t){return function(e){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if(typeof e=="number"){var o=e;e=je(o),e||(e=Ce(o,r),r=[])}t.apply(void 0,[e].concat(r))}}var ie=Object.assign(function(e,r){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];e||ht(e,je(r,n)||Ce(r,n))},{debug:Ut(ht.debug),log:Ut(ht.log),warn:Ut(ht.warn),error:Ut(ht.error)});function Ar(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return new Pr(je(t,e)||Ce(t,e))}var rr=Symbol.for("ApolloErrorMessageHandler_"+$r);function Lr(t){if(typeof t=="string")return t;try{return bo(t,2).slice(0,1e3)}catch{return"<non-serializable>"}}function je(t,e){if(e===void 0&&(e=[]),!!t)return me[rr]&&me[rr](t,e.map(Lr))}function Ce(t,e){if(e===void 0&&(e=[]),!!t)return"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({version:$r,message:t,args:e.map(Lr)})))}function vo(t){return t.definitions.filter(function(e){return e.kind==="OperationDefinition"&&!!e.name}).map(function(e){return e.name.value})[0]||null}let z=null;const nr={};let ko=1;const So=()=>class{constructor(){this.id=["slot",ko++,Date.now(),Math.random().toString(36).slice(2)].join(":")}hasValue(){for(let e=z;e;e=e.parent)if(this.id in e.slots){const r=e.slots[this.id];if(r===nr)break;return e!==z&&(z.slots[this.id]=r),!0}return z&&(z.slots[this.id]=nr),!1}getValue(){if(this.hasValue())return z.slots[this.id]}withValue(e,r,n,o){const s={__proto__:null,[this.id]:e},a=z;z={parent:a,slots:s};try{return r.apply(o,n)}finally{z=a}}static bind(e){const r=z;return function(){const n=z;try{return z=r,e.apply(this,arguments)}finally{z=n}}}static noContext(e,r,n){if(z){const o=z;try{return z=null,e.apply(n,r)}finally{z=o}}else return e.apply(n,r)}};function or(t){try{return t()}catch{}}const ce="@wry/context:Slot",jo=or(()=>globalThis)||or(()=>global)||Object.create(null),sr=jo,Ie=sr[ce]||Array[ce]||(function(t){try{Object.defineProperty(sr,ce,{value:t,enumerable:!1,writable:!1,configurable:!0})}finally{return t}})(So()),{bind:Wo,noContext:Qo}=Ie;new Ie;function Co(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=Io(t))||e){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
20
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Io(t,e){if(t){if(typeof t=="string")return ar(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ar(t,e)}}function ar(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function ir(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _e(t,e,r){return e&&ir(t.prototype,e),r&&ir(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}var Fe=function(){return typeof Symbol=="function"},Ne=function(t){return Fe()&&!!Symbol[t]},Ee=function(t){return Ne(t)?Symbol[t]:"@@"+t};Fe()&&!Ne("observable")&&(Symbol.observable=Symbol("observable"));var _o=Ee("iterator"),we=Ee("observable"),zr=Ee("species");function Wt(t,e){var r=t[e];if(r!=null){if(typeof r!="function")throw new TypeError(r+" is not a function");return r}}function $t(t){var e=t.constructor;return e!==void 0&&(e=e[zr],e===null&&(e=void 0)),e!==void 0?e:D}function Fo(t){return t instanceof D}function Nt(t){Nt.log?Nt.log(t):setTimeout(function(){throw t})}function Vt(t){Promise.resolve().then(function(){try{t()}catch(e){Nt(e)}})}function Dr(t){var e=t._cleanup;if(e!==void 0&&(t._cleanup=void 0,!!e))try{if(typeof e=="function")e();else{var r=Wt(e,"unsubscribe");r&&r.call(e)}}catch(n){Nt(n)}}function xe(t){t._observer=void 0,t._queue=void 0,t._state="closed"}function No(t){var e=t._queue;if(e){t._queue=void 0,t._state="ready";for(var r=0;r<e.length&&(Mr(t,e[r].type,e[r].value),t._state!=="closed");++r);}}function Mr(t,e,r){t._state="running";var n=t._observer;try{var o=Wt(n,e);switch(e){case"next":o&&o.call(n,r);break;case"error":if(xe(t),o)o.call(n,r);else throw r;break;case"complete":xe(t),o&&o.call(n);break}}catch(s){Nt(s)}t._state==="closed"?Dr(t):t._state==="running"&&(t._state="ready")}function le(t,e,r){if(t._state!=="closed"){if(t._state==="buffering"){t._queue.push({type:e,value:r});return}if(t._state!=="ready"){t._state="buffering",t._queue=[{type:e,value:r}],Vt(function(){return No(t)});return}Mr(t,e,r)}}var Eo=(function(){function t(r,n){this._cleanup=void 0,this._observer=r,this._queue=void 0,this._state="initializing";var o=new To(this);try{this._cleanup=n.call(void 0,o)}catch(s){o.error(s)}this._state==="initializing"&&(this._state="ready")}var e=t.prototype;return e.unsubscribe=function(){this._state!=="closed"&&(xe(this),Dr(this))},_e(t,[{key:"closed",get:function(){return this._state==="closed"}}]),t})(),To=(function(){function t(r){this._subscription=r}var e=t.prototype;return e.next=function(n){le(this._subscription,"next",n)},e.error=function(n){le(this._subscription,"error",n)},e.complete=function(){le(this._subscription,"complete")},_e(t,[{key:"closed",get:function(){return this._subscription._state==="closed"}}]),t})(),D=(function(){function t(r){if(!(this instanceof t))throw new TypeError("Observable cannot be called as a function");if(typeof r!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=r}var e=t.prototype;return e.subscribe=function(n){return(typeof n!="object"||n===null)&&(n={next:n,error:arguments[1],complete:arguments[2]}),new Eo(n,this._subscriber)},e.forEach=function(n){var o=this;return new Promise(function(s,a){if(typeof n!="function"){a(new TypeError(n+" is not a function"));return}function l(){c.unsubscribe(),s()}var c=o.subscribe({next:function(u){try{n(u,l)}catch(f){a(f),c.unsubscribe()}},error:a,complete:s})})},e.map=function(n){var o=this;if(typeof n!="function")throw new TypeError(n+" is not a function");var s=$t(this);return new s(function(a){return o.subscribe({next:function(l){try{l=n(l)}catch(c){return a.error(c)}a.next(l)},error:function(l){a.error(l)},complete:function(){a.complete()}})})},e.filter=function(n){var o=this;if(typeof n!="function")throw new TypeError(n+" is not a function");var s=$t(this);return new s(function(a){return o.subscribe({next:function(l){try{if(!n(l))return}catch(c){return a.error(c)}a.next(l)},error:function(l){a.error(l)},complete:function(){a.complete()}})})},e.reduce=function(n){var o=this;if(typeof n!="function")throw new TypeError(n+" is not a function");var s=$t(this),a=arguments.length>1,l=!1,c=arguments[1],u=c;return new s(function(f){return o.subscribe({next:function(p){var h=!l;if(l=!0,!h||a)try{u=n(u,p)}catch(g){return f.error(g)}else u=p},error:function(p){f.error(p)},complete:function(){if(!l&&!a)return f.error(new TypeError("Cannot reduce an empty sequence"));f.next(u),f.complete()}})})},e.concat=function(){for(var n=this,o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];var l=$t(this);return new l(function(c){var u,f=0;function p(h){u=h.subscribe({next:function(g){c.next(g)},error:function(g){c.error(g)},complete:function(){f===s.length?(u=void 0,c.complete()):p(l.from(s[f++]))}})}return p(n),function(){u&&(u.unsubscribe(),u=void 0)}})},e.flatMap=function(n){var o=this;if(typeof n!="function")throw new TypeError(n+" is not a function");var s=$t(this);return new s(function(a){var l=[],c=o.subscribe({next:function(f){if(n)try{f=n(f)}catch(h){return a.error(h)}var p=s.from(f).subscribe({next:function(h){a.next(h)},error:function(h){a.error(h)},complete:function(){var h=l.indexOf(p);h>=0&&l.splice(h,1),u()}});l.push(p)},error:function(f){a.error(f)},complete:function(){u()}});function u(){c.closed&&l.length===0&&a.complete()}return function(){l.forEach(function(f){return f.unsubscribe()}),c.unsubscribe()}})},e[we]=function(){return this},t.from=function(n){var o=typeof this=="function"?this:t;if(n==null)throw new TypeError(n+" is not an object");var s=Wt(n,we);if(s){var a=s.call(n);if(Object(a)!==a)throw new TypeError(a+" is not an object");return Fo(a)&&a.constructor===o?a:new o(function(l){return a.subscribe(l)})}if(Ne("iterator")&&(s=Wt(n,_o),s))return new o(function(l){Vt(function(){if(!l.closed){for(var c=Co(s.call(n)),u;!(u=c()).done;){var f=u.value;if(l.next(f),l.closed)return}l.complete()}})});if(Array.isArray(n))return new o(function(l){Vt(function(){if(!l.closed){for(var c=0;c<n.length;++c)if(l.next(n[c]),l.closed)return;l.complete()}})});throw new TypeError(n+" is not observable")},t.of=function(){for(var n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];var a=typeof this=="function"?this:t;return new a(function(l){Vt(function(){if(!l.closed){for(var c=0;c<o.length;++c)if(l.next(o[c]),l.closed)return;l.complete()}})})},_e(t,null,[{key:zr,get:function(){return this}}]),t})();Fe()&&Object.defineProperty(D,Symbol("extensions"),{value:{symbol:we,hostReportError:Nt},configurable:!0});function Po(t){var e,r=t.Symbol;if(typeof r=="function")if(r.observable)e=r.observable;else{typeof r.for=="function"?e=r.for("https://github.com/benlesh/symbol-observable"):e=r("https://github.com/benlesh/symbol-observable");try{r.observable=e}catch{}}else e="@@observable";return e}var Ct;typeof self<"u"?Ct=self:typeof window<"u"?Ct=window:typeof global<"u"?Ct=global:typeof module<"u"?Ct=module:Ct=Function("return this")();Po(Ct);var cr=D.prototype,lr="@@observable";cr[lr]||(cr[lr]=function(){return this});function Oo(t){for(var e=["query","operationName","variables","extensions","context"],r=0,n=Object.keys(t);r<n.length;r++){var o=n[r];if(e.indexOf(o)<0)throw Ar(58,o)}return t}function $o(t,e){var r=at({},t),n=function(s){typeof s=="function"?r=at(at({},r),s(r)):r=at(at({},r),s)},o=function(){return at({},r)};return Object.defineProperty(e,"setContext",{enumerable:!1,value:n}),Object.defineProperty(e,"getContext",{enumerable:!1,value:o}),e}function Ao(t){var e={variables:t.variables||{},extensions:t.extensions||{},operationName:t.operationName,query:t.query};return e.operationName||(e.operationName=typeof e.query!="string"?vo(e.query)||void 0:""),e}var Lo=Symbol.for("apollo.deprecations"),zo=me,Do=new Ie;function Mo(t){return zo[Lo]||(Do.getValue()||[]).includes(t)}function qo(t,e){Mo(t)||e()}function ur(t,e){return e?e(t):D.of()}function At(t){return typeof t=="function"?new qr(t):t}function Bt(t){return t.request.length<=1}var qr=(function(){function t(e){e&&(this.request=e)}return t.empty=function(){return new t(function(){return D.of()})},t.from=function(e){return e.length===0?t.empty():e.map(At).reduce(function(r,n){return r.concat(n)})},t.split=function(e,r,n){var o=At(r),s=At(n||new t(ur)),a;return Bt(o)&&Bt(s)?a=new t(function(l){return e(l)?o.request(l)||D.of():s.request(l)||D.of()}):a=new t(function(l,c){return e(l)?o.request(l,c)||D.of():s.request(l,c)||D.of()}),Object.assign(a,{left:o,right:s})},t.execute=function(e,r){return e.request($o(r.context,Ao(Oo(r))))||D.of()},t.concat=function(e,r){var n=At(e);if(Bt(n))return globalThis.__DEV__!==!1&&ie.warn(47,n),n;var o=At(r),s;return Bt(o)?s=new t(function(a){return n.request(a,function(l){return o.request(l)||D.of()})||D.of()}):s=new t(function(a,l){return n.request(a,function(c){return o.request(c,l)||D.of()})||D.of()}),Object.assign(s,{left:n,right:o})},t.prototype.split=function(e,r,n){return this.concat(t.split(e,r,n||new t(ur)))},t.prototype.concat=function(e){return t.concat(this,e)},t.prototype.request=function(e,r){throw Ar(48)},t.prototype.onError=function(e,r){if(globalThis.__DEV__!==!1&&qo("onError",function(){globalThis.__DEV__!==!1&&ie.warn(49)}),r&&r.error)return r.error(e),!1;throw e},t.prototype.setOnError=function(e){return globalThis.__DEV__!==!1&&globalThis.__DEV__!==!1&&ie.warn(50),this.onError=e,this},t})();function Uo(t){return new qr(function(e,r){var n=mo(e,[]);return new D(function(o){var s,a=!1;return Promise.resolve(n).then(function(l){return t(l,e.getContext())}).then(e.setContext).then(function(){a||(s=r(e).subscribe({next:o.next.bind(o),error:o.error.bind(o),complete:o.complete.bind(o)}))}).catch(o.error.bind(o)),function(){a=!0,s&&s.unsubscribe()}})})}const Bo=async()=>{const t="https://auth.australia-southeast1.gcp.commercetools.com/oauth/token",n="Basic "+btoa(encodeURIComponent("tfegsSBVOYnR7e_yE-AjxVVN")+":"+encodeURIComponent("pyKWgHuTxuMwDygh9JH1ehLEaLvAhBo4"));try{const o=await M.post(t,new URLSearchParams({grant_type:"client_credentials"}),{headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:n}});return o.status===200&&o.data.access_token?o.data.access_token:(console.error("Failed to fetch token:",o.data),null)}catch(o){return M.isAxiosError(o)?console.error("Error fetching token:",o.response||o.message):console.error("Unexpected error:",o),null}},Ro="https://api.australia-southeast1.gcp.commercetools.com/kt-demo/graphql",Ho=Yt.createHttpLink({uri:`${Ro}`}),Vo=Uo(async(t,{headers:e})=>{const r=await Bo();return{headers:{...e,authorization:`Bearer ${r}`}}}),Yo=new Yt.ApolloClient({link:Vo.concat(Ho),cache:new Yt.InMemoryCache,defaultOptions:{watchQuery:{fetchPolicy:"cache-and-network"}}}),Jo=()=>i.jsx(Yt.ApolloProvider,{client:Yo,children:i.jsx(tn,{children:i.jsx(ho,{})})});exports.TanyaChatbot=Jo;exports.TanyaChatbotProvider=Kr;
20
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Io(t,e){if(t){if(typeof t=="string")return ar(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ar(t,e)}}function ar(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function ir(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _e(t,e,r){return e&&ir(t.prototype,e),r&&ir(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}var Fe=function(){return typeof Symbol=="function"},Ne=function(t){return Fe()&&!!Symbol[t]},Ee=function(t){return Ne(t)?Symbol[t]:"@@"+t};Fe()&&!Ne("observable")&&(Symbol.observable=Symbol("observable"));var _o=Ee("iterator"),we=Ee("observable"),zr=Ee("species");function Wt(t,e){var r=t[e];if(r!=null){if(typeof r!="function")throw new TypeError(r+" is not a function");return r}}function $t(t){var e=t.constructor;return e!==void 0&&(e=e[zr],e===null&&(e=void 0)),e!==void 0?e:D}function Fo(t){return t instanceof D}function Nt(t){Nt.log?Nt.log(t):setTimeout(function(){throw t})}function Vt(t){Promise.resolve().then(function(){try{t()}catch(e){Nt(e)}})}function Dr(t){var e=t._cleanup;if(e!==void 0&&(t._cleanup=void 0,!!e))try{if(typeof e=="function")e();else{var r=Wt(e,"unsubscribe");r&&r.call(e)}}catch(n){Nt(n)}}function xe(t){t._observer=void 0,t._queue=void 0,t._state="closed"}function No(t){var e=t._queue;if(e){t._queue=void 0,t._state="ready";for(var r=0;r<e.length&&(Mr(t,e[r].type,e[r].value),t._state!=="closed");++r);}}function Mr(t,e,r){t._state="running";var n=t._observer;try{var o=Wt(n,e);switch(e){case"next":o&&o.call(n,r);break;case"error":if(xe(t),o)o.call(n,r);else throw r;break;case"complete":xe(t),o&&o.call(n);break}}catch(s){Nt(s)}t._state==="closed"?Dr(t):t._state==="running"&&(t._state="ready")}function le(t,e,r){if(t._state!=="closed"){if(t._state==="buffering"){t._queue.push({type:e,value:r});return}if(t._state!=="ready"){t._state="buffering",t._queue=[{type:e,value:r}],Vt(function(){return No(t)});return}Mr(t,e,r)}}var Eo=(function(){function t(r,n){this._cleanup=void 0,this._observer=r,this._queue=void 0,this._state="initializing";var o=new To(this);try{this._cleanup=n.call(void 0,o)}catch(s){o.error(s)}this._state==="initializing"&&(this._state="ready")}var e=t.prototype;return e.unsubscribe=function(){this._state!=="closed"&&(xe(this),Dr(this))},_e(t,[{key:"closed",get:function(){return this._state==="closed"}}]),t})(),To=(function(){function t(r){this._subscription=r}var e=t.prototype;return e.next=function(n){le(this._subscription,"next",n)},e.error=function(n){le(this._subscription,"error",n)},e.complete=function(){le(this._subscription,"complete")},_e(t,[{key:"closed",get:function(){return this._subscription._state==="closed"}}]),t})(),D=(function(){function t(r){if(!(this instanceof t))throw new TypeError("Observable cannot be called as a function");if(typeof r!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=r}var e=t.prototype;return e.subscribe=function(n){return(typeof n!="object"||n===null)&&(n={next:n,error:arguments[1],complete:arguments[2]}),new Eo(n,this._subscriber)},e.forEach=function(n){var o=this;return new Promise(function(s,a){if(typeof n!="function"){a(new TypeError(n+" is not a function"));return}function l(){c.unsubscribe(),s()}var c=o.subscribe({next:function(u){try{n(u,l)}catch(f){a(f),c.unsubscribe()}},error:a,complete:s})})},e.map=function(n){var o=this;if(typeof n!="function")throw new TypeError(n+" is not a function");var s=$t(this);return new s(function(a){return o.subscribe({next:function(l){try{l=n(l)}catch(c){return a.error(c)}a.next(l)},error:function(l){a.error(l)},complete:function(){a.complete()}})})},e.filter=function(n){var o=this;if(typeof n!="function")throw new TypeError(n+" is not a function");var s=$t(this);return new s(function(a){return o.subscribe({next:function(l){try{if(!n(l))return}catch(c){return a.error(c)}a.next(l)},error:function(l){a.error(l)},complete:function(){a.complete()}})})},e.reduce=function(n){var o=this;if(typeof n!="function")throw new TypeError(n+" is not a function");var s=$t(this),a=arguments.length>1,l=!1,c=arguments[1],u=c;return new s(function(f){return o.subscribe({next:function(p){var h=!l;if(l=!0,!h||a)try{u=n(u,p)}catch(g){return f.error(g)}else u=p},error:function(p){f.error(p)},complete:function(){if(!l&&!a)return f.error(new TypeError("Cannot reduce an empty sequence"));f.next(u),f.complete()}})})},e.concat=function(){for(var n=this,o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];var l=$t(this);return new l(function(c){var u,f=0;function p(h){u=h.subscribe({next:function(g){c.next(g)},error:function(g){c.error(g)},complete:function(){f===s.length?(u=void 0,c.complete()):p(l.from(s[f++]))}})}return p(n),function(){u&&(u.unsubscribe(),u=void 0)}})},e.flatMap=function(n){var o=this;if(typeof n!="function")throw new TypeError(n+" is not a function");var s=$t(this);return new s(function(a){var l=[],c=o.subscribe({next:function(f){if(n)try{f=n(f)}catch(h){return a.error(h)}var p=s.from(f).subscribe({next:function(h){a.next(h)},error:function(h){a.error(h)},complete:function(){var h=l.indexOf(p);h>=0&&l.splice(h,1),u()}});l.push(p)},error:function(f){a.error(f)},complete:function(){u()}});function u(){c.closed&&l.length===0&&a.complete()}return function(){l.forEach(function(f){return f.unsubscribe()}),c.unsubscribe()}})},e[we]=function(){return this},t.from=function(n){var o=typeof this=="function"?this:t;if(n==null)throw new TypeError(n+" is not an object");var s=Wt(n,we);if(s){var a=s.call(n);if(Object(a)!==a)throw new TypeError(a+" is not an object");return Fo(a)&&a.constructor===o?a:new o(function(l){return a.subscribe(l)})}if(Ne("iterator")&&(s=Wt(n,_o),s))return new o(function(l){Vt(function(){if(!l.closed){for(var c=Co(s.call(n)),u;!(u=c()).done;){var f=u.value;if(l.next(f),l.closed)return}l.complete()}})});if(Array.isArray(n))return new o(function(l){Vt(function(){if(!l.closed){for(var c=0;c<n.length;++c)if(l.next(n[c]),l.closed)return;l.complete()}})});throw new TypeError(n+" is not observable")},t.of=function(){for(var n=arguments.length,o=new Array(n),s=0;s<n;s++)o[s]=arguments[s];var a=typeof this=="function"?this:t;return new a(function(l){Vt(function(){if(!l.closed){for(var c=0;c<o.length;++c)if(l.next(o[c]),l.closed)return;l.complete()}})})},_e(t,null,[{key:zr,get:function(){return this}}]),t})();Fe()&&Object.defineProperty(D,Symbol("extensions"),{value:{symbol:we,hostReportError:Nt},configurable:!0});function Po(t){var e,r=t.Symbol;if(typeof r=="function")if(r.observable)e=r.observable;else{typeof r.for=="function"?e=r.for("https://github.com/benlesh/symbol-observable"):e=r("https://github.com/benlesh/symbol-observable");try{r.observable=e}catch{}}else e="@@observable";return e}var Ct;typeof self<"u"?Ct=self:typeof window<"u"?Ct=window:typeof global<"u"?Ct=global:typeof module<"u"?Ct=module:Ct=Function("return this")();Po(Ct);var cr=D.prototype,lr="@@observable";cr[lr]||(cr[lr]=function(){return this});function Oo(t){for(var e=["query","operationName","variables","extensions","context"],r=0,n=Object.keys(t);r<n.length;r++){var o=n[r];if(e.indexOf(o)<0)throw Ar(58,o)}return t}function $o(t,e){var r=at({},t),n=function(s){typeof s=="function"?r=at(at({},r),s(r)):r=at(at({},r),s)},o=function(){return at({},r)};return Object.defineProperty(e,"setContext",{enumerable:!1,value:n}),Object.defineProperty(e,"getContext",{enumerable:!1,value:o}),e}function Ao(t){var e={variables:t.variables||{},extensions:t.extensions||{},operationName:t.operationName,query:t.query};return e.operationName||(e.operationName=typeof e.query!="string"?vo(e.query)||void 0:""),e}var Lo=Symbol.for("apollo.deprecations"),zo=me,Do=new Ie;function Mo(t){return zo[Lo]||(Do.getValue()||[]).includes(t)}function qo(t,e){Mo(t)||e()}function ur(t,e){return e?e(t):D.of()}function At(t){return typeof t=="function"?new qr(t):t}function Bt(t){return t.request.length<=1}var qr=(function(){function t(e){e&&(this.request=e)}return t.empty=function(){return new t(function(){return D.of()})},t.from=function(e){return e.length===0?t.empty():e.map(At).reduce(function(r,n){return r.concat(n)})},t.split=function(e,r,n){var o=At(r),s=At(n||new t(ur)),a;return Bt(o)&&Bt(s)?a=new t(function(l){return e(l)?o.request(l)||D.of():s.request(l)||D.of()}):a=new t(function(l,c){return e(l)?o.request(l,c)||D.of():s.request(l,c)||D.of()}),Object.assign(a,{left:o,right:s})},t.execute=function(e,r){return e.request($o(r.context,Ao(Oo(r))))||D.of()},t.concat=function(e,r){var n=At(e);if(Bt(n))return globalThis.__DEV__!==!1&&ie.warn(47,n),n;var o=At(r),s;return Bt(o)?s=new t(function(a){return n.request(a,function(l){return o.request(l)||D.of()})||D.of()}):s=new t(function(a,l){return n.request(a,function(c){return o.request(c,l)||D.of()})||D.of()}),Object.assign(s,{left:n,right:o})},t.prototype.split=function(e,r,n){return this.concat(t.split(e,r,n||new t(ur)))},t.prototype.concat=function(e){return t.concat(this,e)},t.prototype.request=function(e,r){throw Ar(48)},t.prototype.onError=function(e,r){if(globalThis.__DEV__!==!1&&qo("onError",function(){globalThis.__DEV__!==!1&&ie.warn(49)}),r&&r.error)return r.error(e),!1;throw e},t.prototype.setOnError=function(e){return globalThis.__DEV__!==!1&&globalThis.__DEV__!==!1&&ie.warn(50),this.onError=e,this},t})();function Uo(t){return new qr(function(e,r){var n=mo(e,[]);return new D(function(o){var s,a=!1;return Promise.resolve(n).then(function(l){return t(l,e.getContext())}).then(e.setContext).then(function(){a||(s=r(e).subscribe({next:o.next.bind(o),error:o.error.bind(o),complete:o.complete.bind(o)}))}).catch(o.error.bind(o)),function(){a=!0,s&&s.unsubscribe()}})})}const Bo=async()=>{const t="https://auth.australia-southeast1.gcp.commercetools.com/oauth/token",n="Basic "+btoa(encodeURIComponent("tfegsSBVOYnR7e_yE-AjxVVN")+":"+encodeURIComponent("pyKWgHuTxuMwDygh9JH1ehLEaLvAhBo4"));try{const o=await M.post(t,new URLSearchParams({grant_type:"client_credentials"}),{headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:n}});return o.status===200&&o.data.access_token?o.data.access_token:(console.error("Failed to fetch token:",o.data),null)}catch(o){return M.isAxiosError(o)?console.error("Error fetching token:",o.response||o.message):console.error("Unexpected error:",o),null}},Ro="https://api.australia-southeast1.gcp.commercetools.com/kt-demo/graphql",Ho=Yt.createHttpLink({uri:`${Ro}`}),Vo=Uo(async(t,{headers:e})=>{const r=await Bo();return{headers:{...e,authorization:`Bearer ${r}`}}}),Yo=new Yt.ApolloClient({link:Vo.concat(Ho),cache:new Yt.InMemoryCache,defaultOptions:{watchQuery:{fetchPolicy:"cache-and-network"}}}),Jo=t=>{const{tanyaConfig:e}=t,{clientID:r,host:n,organizationID:o,shortCode:s,siteId:a}=e;return console.log(e,"tanyaConfig"),sessionStorage.setItem("Host",n),sessionStorage.setItem("SiteId",a),sessionStorage.setItem("pubCfg",r),sessionStorage.setItem("envRef",s),sessionStorage.setItem("orgRef",o),i.jsx(Yt.ApolloProvider,{client:Yo,children:i.jsx(tn,{children:i.jsx(ho,{})})})};exports.TanyaChatbot=Jo;exports.TanyaChatbotProvider=Kr;
21
21
  //# sourceMappingURL=tanya-chatbot.cjs.js.map