tanya-chatbot 0.0.9 → 0.0.11
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/tanya-chatbot.cjs.js +11 -10
- package/dist/tanya-chatbot.cjs.js.map +1 -1
- package/dist/tanya-chatbot.es.js +1854 -956
- package/dist/tanya-chatbot.es.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),j=require("react"),Kt=require("@radix-ui/react-popover");require("clsx");require("tailwind-merge");const M=require("axios");require("crypto-js");const we=require("react-redux"),Gt=require("@reduxjs/toolkit"),nt=require("@iconify/react"),W=require("react-toastify");function Wt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const St=Wt(Kt),be=e=>{const t=new CustomEvent("reactCartUpdated",{detail:{cartUpdated:!0,basketId:e}});window.dispatchEvent(t)};function Qt({...e}){return r.jsx(St.Root,{"data-slot":"popover",...e})}function Yt({...e}){return r.jsx(St.Trigger,{"data-slot":"popover-trigger",...e})}const de=()=>({aiConversationUrl:"https://mdv3qwfi2j.execute-api.us-east-1.amazonaws.com/dev/api/bedrock/invoke/stream",xAPIKey:"BJBtjpPkqGatuoa3qJqdR8aHXSsHkgvGaootbubi",serverUrl:"https://tanya-sfcc-server.vercel.app/",basePath:"sc-api"}),kt=async()=>{const e="https://tanya-sfcc-server.vercel.app/";try{const t=await M.post(`${e}api/auth/token-bm-grant?baseUrl=${oe()}&siteId=${X()}`);return t.status===200&&t.data.access_token?t.data.access_token:(console.error("Failed to fetch token:",t.data),null)}catch(t){return M.isAxiosError(t)?console.error("Error fetching token:",t.response||t.message):console.error("Unexpected error:",t),null}},It=async e=>{const t="https://tanya-sfcc-server.vercel.app/";try{const n=JSON.parse(sessionStorage.getItem("customerData")||"{}").dwsid,o=await M.post(`${t}api/auth/token-existing-guest-customer?dwsid=${n}&baseUrl=${oe()}&siteId=${X()}&pubCfg=${re()}&envRef=${ie()}&orgRef=${ae()}`,{},{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`}});return o.status===200&&o.data?o.data:null}catch(n){return M.isAxiosError(n)?console.error("Error creating basket:",n.response||n.message):console.error("Unexpected error:",n),null}};async function Le(){const e=localStorage.getItem("expires_in"),t=localStorage.getItem("access_token"),n=JSON.parse(sessionStorage.getItem("customerData")||"{}").isGuest;if(e&&t&&new Date().getTime()<parseInt(e)&&n===JSON.parse(localStorage.getItem("isGuest")||"false"))return console.log("access token found in local storage"),{access_token:t,expires_in:e};const{serverUrl:o}=de(),s=JSON.parse(sessionStorage.getItem("customerData")||"{}").dwsid,i=JSON.parse(sessionStorage.getItem("customerData")||"{}").usrRef;try{const a=n?"unregister-auth":"register-auth",l=await M.get(`${o}sc-api/${a}?dwsid=${s}&email=${i}&pubCfg=${re()}&envRef=${ie()}&orgRef=${ae()}&siteId=${X()}`);return localStorage.setItem("access_token",l.data.access_token),localStorage.setItem("expires_in",String(new Date().getTime()+l.data.expires_in*1e3)),localStorage.setItem("isGuest",n.toString()),console.log(l.data),l.data}catch(a){console.log(a)}}const oe=()=>sessionStorage.getItem("Host"),X=()=>sessionStorage.getItem("SiteId"),re=()=>sessionStorage.getItem("pubCfg"),ie=()=>sessionStorage.getItem("envRef"),ae=()=>sessionStorage.getItem("orgRef"),st=async(e,t)=>{const{serverUrl:n,basePath:o}=de();try{const s=oe();return(await M.get(`${n}${o}/search-sfcc?baseUrl=${s}&query=${e}&siteId=${X()}&pubCfg=${re()}&envRef=${ie()}&orgRef=${ae()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}})).data.hits}catch(s){throw console.error("Error fetching search results:",s),s}},Ct=async e=>{if(!e)throw new Error("Product ID is required");const{serverUrl:t,basePath:n}=de(),o=oe();console.log("calling access");const{access_token:s}=await Le();return console.log(s),(await M.get(`${t}${n}/product-sfcc/${e}?baseUrl=${o}&siteId=${X()}&pubCfg=${re()}&envRef=${ie()}&orgRef=${ae()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}})).data},Zt=async e=>{if(!e)throw new Error("customerId is required");const t=await kt(),{customer_token:n}=await It(t),{serverUrl:o,basePath:s}=de(),a=(await Le()).access_token;return(await M.get(`${o}${s}/get-interest?baseUrl=${oe()}&customerId=${e}&siteId=${X()}&pubCfg=${re()}&envRef=${ie()}&orgRef=${ae()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}})).data},ot=e=>String(typeof e=="string"?e:e["en-US"]||e),rt=e=>e!=null&&e.image?[e.image]:"variants"in e?e.variants[0].images:e.masterVariant.images.map(t=>t.url),Xt=(e,t)=>e.toLocaleString("en-US",{style:"currency",currency:t||"USD"}),it=e=>{var t,n,o;return"variants"in e?{centAmount:(t=e.variants[0])==null?void 0:t.prices.EUR.max,currencyCode:"DOL"}:{centAmount:(n=e.masterVariant)==null?void 0:n.prices[0].value.centAmount,currencyCode:(o=e.masterVariant)==null?void 0:o.prices[0].value.currencyCode}},en=e=>e.charAt(0).toUpperCase()+e.slice(1),at=(e,t)=>e.length<t?e:e.slice(0,t)+"...",Re=e=>e.split("\\n").map((t,n)=>{const o=t.match(/^(\d+)\.\s(.+)/);return o?`<p key=${n} class="mb-2"><strong>${o[1]}.</strong> ${o[2]}</p>`:t.trim()?`<p key=${n} class="mb-2">${t}</p>`:"<br/>"}).join("");function tn(e,t){const n=e.icons,o=e.aliases||Object.create(null),s=Object.create(null);function i(a){if(n[a])return s[a]=[];if(!(a in s)){s[a]=null;const l=o[a]&&o[a].parent,c=l&&i(l);c&&(s[a]=[l].concat(c))}return s[a]}return Object.keys(n).concat(Object.keys(o)).forEach(i),s}const Ft=Object.freeze({left:0,top:0,width:16,height:16}),$e=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Qe=Object.freeze({...Ft,...$e}),Ve=Object.freeze({...Qe,body:"",hidden:!1});function nn(e,t){const n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);const o=((e.rotate||0)+(t.rotate||0))%4;return o&&(n.rotate=o),n}function ct(e,t){const n=nn(e,t);for(const o in Ve)o in $e?o in e&&!(o in n)&&(n[o]=$e[o]):o in t?n[o]=t[o]:o in e&&(n[o]=e[o]);return n}function sn(e,t,n){const o=e.icons,s=e.aliases||Object.create(null);let i={};function a(l){i=ct(o[l]||s[l],i)}return a(t),n.forEach(a),ct(e,i)}function Nt(e,t){const n=[];if(typeof e!="object"||typeof e.icons!="object")return n;e.not_found instanceof Array&&e.not_found.forEach(s=>{t(s,null),n.push(s)});const o=tn(e);for(const s in o){const i=o[s];i&&(t(s,sn(e,s,i)),n.push(s))}return n}const on={provider:"",aliases:{},not_found:{},...Ft};function He(e,t){for(const n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function Tt(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!He(e,on))return null;const n=t.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!He(i,Ve))return null}const o=t.aliases||Object.create(null);for(const s in o){const i=o[s],a=i.parent;if(!s||typeof a!="string"||!n[a]&&!o[a]||!He(i,Ve))return null}return t}const lt=Object.create(null);function rn(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function je(e,t){const n=lt[e]||(lt[e]=Object.create(null));return n[t]||(n[t]=rn(e,t))}function _t(e,t){return Tt(t)?Nt(t,(n,o)=>{o?e.icons[n]=o:e.missing.add(n)}):[]}function an(e,t,n){try{if(typeof n.body=="string")return e.icons[t]={...n},!0}catch{}return!1}const Pt=/^[a-z0-9]+(-[a-z0-9]+)*$/,De=(e,t,n,o="")=>{const s=e.split(":");if(e.slice(0,1)==="@"){if(s.length<2||s.length>3)return null;o=s.shift().slice(1)}if(s.length>3||!s.length)return null;if(s.length>1){const l=s.pop(),c=s.pop(),d={provider:s.length>0?s[0]:o,prefix:c,name:l};return t&&!Pe(d)?null:d}const i=s[0],a=i.split("-");if(a.length>1){const l={provider:o,prefix:a.shift(),name:a.join("-")};return t&&!Pe(l)?null:l}if(n&&o===""){const l={provider:o,prefix:"",name:i};return t&&!Pe(l,n)?null:l}return null},Pe=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let Ne=!1;function Et(e){return typeof e=="boolean"&&(Ne=e),Ne}function ut(e){const t=typeof e=="string"?De(e,!0,Ne):e;if(t){const n=je(t.provider,t.prefix),o=t.name;return n.icons[o]||(n.missing.has(o)?null:void 0)}}function cn(e,t){const n=De(e,!0,Ne);if(!n)return!1;const o=je(n.provider,n.prefix);return t?an(o,n.name,t):(o.missing.add(n.name),!0)}function ln(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),Ne&&!t&&!e.prefix){let s=!1;return Tt(e)&&(e.prefix="",Nt(e,(i,a)=>{cn(i,a)&&(s=!0)})),s}const n=e.prefix;if(!Pe({prefix:n,name:"a"}))return!1;const o=je(t,n);return!!_t(o,e)}const $t=Object.freeze({width:null,height:null}),At=Object.freeze({...$t,...$e}),un=/(-?[0-9.]*[0-9]+[0-9.]*)/g,dn=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function dt(e,t,n){if(t===1)return e;if(n=n||100,typeof e=="number")return Math.ceil(e*t*n)/n;if(typeof e!="string")return e;const o=e.split(un);if(o===null||!o.length)return e;const s=[];let i=o.shift(),a=dn.test(i);for(;;){if(a){const l=parseFloat(i);isNaN(l)?s.push(i):s.push(Math.ceil(l*t*n)/n)}else s.push(i);if(i=o.shift(),i===void 0)return s.join("");a=!a}}function fn(e,t="defs"){let n="";const o=e.indexOf("<"+t);for(;o>=0;){const s=e.indexOf(">",o),i=e.indexOf("</"+t);if(s===-1||i===-1)break;const a=e.indexOf(">",i);if(a===-1)break;n+=e.slice(s+1,i).trim(),e=e.slice(0,o).trim()+e.slice(a+1)}return{defs:n,content:e}}function pn(e,t){return e?"<defs>"+e+"</defs>"+t:t}function hn(e,t,n){const o=fn(e);return pn(o.defs,t+o.content+n)}const mn=e=>e==="unset"||e==="undefined"||e==="none";function gn(e,t){const n={...Qe,...e},o={...At,...t},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,o].forEach(C=>{const h=[],b=C.hFlip,D=C.vFlip;let P=C.rotate;b?D?P+=2:(h.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),h.push("scale(-1 1)"),s.top=s.left=0):D&&(h.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),h.push("scale(1 -1)"),s.top=s.left=0);let A;switch(P<0&&(P-=Math.floor(P/4)*4),P=P%4,P){case 1:A=s.height/2+s.top,h.unshift("rotate(90 "+A.toString()+" "+A.toString()+")");break;case 2:h.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:A=s.width/2+s.left,h.unshift("rotate(-90 "+A.toString()+" "+A.toString()+")");break}P%2===1&&(s.left!==s.top&&(A=s.left,s.left=s.top,s.top=A),s.width!==s.height&&(A=s.width,s.width=s.height,s.height=A)),h.length&&(i=hn(i,'<g transform="'+h.join(" ")+'">',"</g>"))});const a=o.width,l=o.height,c=s.width,d=s.height;let f,m;a===null?(m=l===null?"1em":l==="auto"?d:l,f=dt(m,c/d)):(f=a==="auto"?c:a,m=l===null?dt(f,d/c):l==="auto"?d:l);const w={},p=(C,h)=>{mn(h)||(w[C]=h.toString())};p("width",f),p("height",m);const v=[s.left,s.top,c,d];return w.viewBox=v.join(" "),{attributes:w,viewBox:v,body:i}}const xn=/\sid="(\S+)"/g,yn="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let wn=0;function bn(e,t=yn){const n=[];let o;for(;o=xn.exec(e);)n.push(o[1]);if(!n.length)return e;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const a=typeof t=="function"?t(i):t+(wn++).toString(),l=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+l+')([")]|\\.[a-z])',"g"),"$1"+a+s+"$3")}),e=e.replace(new RegExp(s,"g"),""),e}const Je=Object.create(null);function vn(e,t){Je[e]=t}function Ke(e){return Je[e]||Je[""]}function Ye(e){let t;if(typeof e.resources=="string")t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const Ze=Object.create(null),ke=["https://api.simplesvg.com","https://api.unisvg.com"],Ee=[];for(;ke.length>0;)ke.length===1||Math.random()>.5?Ee.push(ke.shift()):Ee.push(ke.pop());Ze[""]=Ye({resources:["https://api.iconify.design"].concat(Ee)});function jn(e,t){const n=Ye(t);return n===null?!1:(Ze[e]=n,!0)}function Xe(e){return Ze[e]}const Sn=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let ft=Sn();function kn(e,t){const n=Xe(e);if(!n)return 0;let o;if(!n.maxURL)o=0;else{let s=0;n.resources.forEach(a=>{s=Math.max(s,a.length)});const i=t+".json?icons=";o=n.maxURL-s-n.path.length-i.length}return o}function In(e){return e===404}const Cn=(e,t,n)=>{const o=[],s=kn(e,t),i="icons";let a={type:i,provider:e,prefix:t,icons:[]},l=0;return n.forEach((c,d)=>{l+=c.length+1,l>=s&&d>0&&(o.push(a),a={type:i,provider:e,prefix:t,icons:[]},l=c.length),a.icons.push(c)}),o.push(a),o};function Fn(e){if(typeof e=="string"){const t=Xe(e);if(t)return t.path}return"/"}const Nn=(e,t,n)=>{if(!ft){n("abort",424);return}let o=Fn(t.provider);switch(t.type){case"icons":{const i=t.prefix,l=t.icons.join(","),c=new URLSearchParams({icons:l});o+=i+".json?"+c.toString();break}case"custom":{const i=t.uri;o+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let s=503;ft(e+o).then(i=>{const a=i.status;if(a!==200){setTimeout(()=>{n(In(a)?"abort":"next",a)});return}return s=501,i.json()}).then(i=>{if(typeof i!="object"||i===null){setTimeout(()=>{i===404?n("abort",i):n("next",s)});return}setTimeout(()=>{n("success",i)})}).catch(()=>{n("next",s)})},Tn={prepare:Cn,send:Nn};function Ot(e,t){e.forEach(n=>{const o=n.loaderCallbacks;o&&(n.loaderCallbacks=o.filter(s=>s.id!==t))})}function _n(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1;const o=e.provider,s=e.prefix;t.forEach(i=>{const a=i.icons,l=a.pending.length;a.pending=a.pending.filter(c=>{if(c.prefix!==s)return!0;const d=c.name;if(e.icons[d])a.loaded.push({provider:o,prefix:s,name:d});else if(e.missing.has(d))a.missing.push({provider:o,prefix:s,name:d});else return n=!0,!0;return!1}),a.pending.length!==l&&(n||Ot([e],i.id),i.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),i.abort))})}))}let Pn=0;function En(e,t,n){const o=Pn++,s=Ot.bind(null,n,o);if(!t.pending.length)return s;const i={id:o,icons:t,callback:e,abort:s};return n.forEach(a=>{(a.loaderCallbacks||(a.loaderCallbacks=[])).push(i)}),s}function $n(e){const t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((s,i)=>s.provider!==i.provider?s.provider.localeCompare(i.provider):s.prefix!==i.prefix?s.prefix.localeCompare(i.prefix):s.name.localeCompare(i.name));let o={provider:"",prefix:"",name:""};return e.forEach(s=>{if(o.name===s.name&&o.prefix===s.prefix&&o.provider===s.provider)return;o=s;const i=s.provider,a=s.prefix,l=s.name,c=n[i]||(n[i]=Object.create(null)),d=c[a]||(c[a]=je(i,a));let f;l in d.icons?f=t.loaded:a===""||d.missing.has(l)?f=t.missing:f=t.pending;const m={provider:i,prefix:a,name:l};f.push(m)}),t}function An(e,t=!0,n=!1){const o=[];return e.forEach(s=>{const i=typeof s=="string"?De(s,t,n):s;i&&o.push(i)}),o}const On={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Ln(e,t,n,o){const s=e.resources.length,i=e.random?Math.floor(Math.random()*s):e.index;let a;if(e.random){let S=e.resources.slice(0);for(a=[];S.length>1;){const L=Math.floor(Math.random()*S.length);a.push(S[L]),S=S.slice(0,L).concat(S.slice(L+1))}a=a.concat(S)}else a=e.resources.slice(i).concat(e.resources.slice(0,i));const l=Date.now();let c="pending",d=0,f,m=null,w=[],p=[];typeof o=="function"&&p.push(o);function v(){m&&(clearTimeout(m),m=null)}function C(){c==="pending"&&(c="aborted"),v(),w.forEach(S=>{S.status==="pending"&&(S.status="aborted")}),w=[]}function h(S,L){L&&(p=[]),typeof S=="function"&&p.push(S)}function b(){return{startTime:l,payload:t,status:c,queriesSent:d,queriesPending:w.length,subscribe:h,abort:C}}function D(){c="failed",p.forEach(S=>{S(void 0,f)})}function P(){w.forEach(S=>{S.status==="pending"&&(S.status="aborted")}),w=[]}function A(S,L,q){const R=L!=="success";switch(w=w.filter(E=>E!==S),c){case"pending":break;case"failed":if(R||!e.dataAfterTimeout)return;break;default:return}if(L==="abort"){f=q,D();return}if(R){f=q,w.length||(a.length?Q():D());return}if(v(),P(),!e.random){const E=e.resources.indexOf(S.resource);E!==-1&&E!==e.index&&(e.index=E)}c="completed",p.forEach(E=>{E(q)})}function Q(){if(c!=="pending")return;v();const S=a.shift();if(S===void 0){if(w.length){m=setTimeout(()=>{v(),c==="pending"&&(P(),D())},e.timeout);return}D();return}const L={status:"pending",resource:S,callback:(q,R)=>{A(L,q,R)}};w.push(L),d++,m=setTimeout(Q,e.rotate),n(S,t,L.callback)}return setTimeout(Q),b}function Lt(e){const t={...On,...e};let n=[];function o(){n=n.filter(l=>l().status==="pending")}function s(l,c,d){const f=Ln(t,l,c,(m,w)=>{o(),d&&d(m,w)});return n.push(f),f}function i(l){return n.find(c=>l(c))||null}return{query:s,find:i,setIndex:l=>{t.index=l},getIndex:()=>t.index,cleanup:o}}function pt(){}const ze=Object.create(null);function Dn(e){if(!ze[e]){const t=Xe(e);if(!t)return;const n=Lt(t),o={config:t,redundancy:n};ze[e]=o}return ze[e]}function Mn(e,t,n){let o,s;if(typeof e=="string"){const i=Ke(e);if(!i)return n(void 0,424),pt;s=i.send;const a=Dn(e);a&&(o=a.redundancy)}else{const i=Ye(e);if(i){o=Lt(i);const a=e.resources?e.resources[0]:"",l=Ke(a);l&&(s=l.send)}}return!o||!s?(n(void 0,424),pt):o.query(t,s,n)().abort}function ht(){}function Un(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,_n(e)}))}function Bn(e){const t=[],n=[];return e.forEach(o=>{(o.match(Pt)?t:n).push(o)}),{valid:t,invalid:n}}function Ie(e,t,n){function o(){const s=e.pendingIcons;t.forEach(i=>{s&&s.delete(i),e.icons[i]||e.missing.add(i)})}if(n&&typeof n=="object")try{if(!_t(e,n).length){o();return}}catch(s){console.error(s)}o(),Un(e)}function mt(e,t){e instanceof Promise?e.then(n=>{t(n)}).catch(()=>{t(null)}):t(e)}function qn(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:n,prefix:o}=e,s=e.iconsToLoad;if(delete e.iconsToLoad,!s||!s.length)return;const i=e.loadIcon;if(e.loadIcons&&(s.length>1||!i)){mt(e.loadIcons(s,o,n),f=>{Ie(e,s,f)});return}if(i){s.forEach(f=>{const m=i(f,o,n);mt(m,w=>{const p=w?{prefix:o,icons:{[f]:w}}:null;Ie(e,[f],p)})});return}const{valid:a,invalid:l}=Bn(s);if(l.length&&Ie(e,l,null),!a.length)return;const c=o.match(Pt)?Ke(n):null;if(!c){Ie(e,a,null);return}c.prepare(n,o,a).forEach(f=>{Mn(n,f,m=>{Ie(e,f.icons,m)})})}))}const Rn=(e,t)=>{const n=An(e,!0,Et()),o=$n(n);if(!o.pending.length){let c=!0;return t&&setTimeout(()=>{c&&t(o.loaded,o.missing,o.pending,ht)}),()=>{c=!1}}const s=Object.create(null),i=[];let a,l;return o.pending.forEach(c=>{const{provider:d,prefix:f}=c;if(f===l&&d===a)return;a=d,l=f,i.push(je(d,f));const m=s[d]||(s[d]=Object.create(null));m[f]||(m[f]=[])}),o.pending.forEach(c=>{const{provider:d,prefix:f,name:m}=c,w=je(d,f),p=w.pendingIcons||(w.pendingIcons=new Set);p.has(m)||(p.add(m),s[d][f].push(m))}),i.forEach(c=>{const d=s[c.provider][c.prefix];d.length&&qn(c,d)}),t?En(t,o,i):ht};function Hn(e,t){const n={...e};for(const o in t){const s=t[o],i=typeof s;o in $t?(s===null||s&&(i==="string"||i==="number"))&&(n[o]=s):i===typeof n[o]&&(n[o]=o==="rotate"?s%4:s)}return n}const zn=/[\s,]+/;function Vn(e,t){t.split(zn).forEach(n=>{switch(n.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function Jn(e,t=0){const n=e.replace(/^-?[0-9.]*/,"");function o(s){for(;s<0;)s+=4;return s%4}if(n===""){const s=parseInt(e);return isNaN(s)?0:o(s)}else if(n!==e){let s=0;switch(n){case"%":s=25;break;case"deg":s=90}if(s){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i=i/s,i%1===0?o(i):0)}}return t}function Kn(e,t){let n=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const o in t)n+=" "+o+'="'+t[o]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}function Gn(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Wn(e){return"data:image/svg+xml,"+Gn(e)}function Qn(e){return'url("'+Wn(e)+'")'}let Fe;function Yn(){try{Fe=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{Fe=null}}function Zn(e){return Fe===void 0&&Yn(),Fe?Fe.createHTML(e):e}const Dt={...At,inline:!1},Xn={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},es={display:"inline-block"},Ge={backgroundColor:"currentColor"},Mt={backgroundColor:"transparent"},gt={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},xt={WebkitMask:Ge,mask:Ge,background:Mt};for(const e in xt){const t=xt[e];for(const n in gt)t[e+n]=gt[n]}const ts={...Dt,inline:!0};function yt(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const ns=(e,t,n)=>{const o=t.inline?ts:Dt,s=Hn(o,t),i=t.mode||"svg",a={},l=t.style||{},c={...i==="svg"?Xn:{}};if(n){const h=De(n,!1,!0);if(h){const b=["iconify"],D=["provider","prefix"];for(const P of D)h[P]&&b.push("iconify--"+h[P]);c.className=b.join(" ")}}for(let h in t){const b=t[h];if(b!==void 0)switch(h){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":c.ref=b;break;case"className":c[h]=(c[h]?c[h]+" ":"")+b;break;case"inline":case"hFlip":case"vFlip":s[h]=b===!0||b==="true"||b===1;break;case"flip":typeof b=="string"&&Vn(s,b);break;case"color":a.color=b;break;case"rotate":typeof b=="string"?s[h]=Jn(b):typeof b=="number"&&(s[h]=b);break;case"ariaHidden":case"aria-hidden":b!==!0&&b!=="true"&&delete c["aria-hidden"];break;default:o[h]===void 0&&(c[h]=b)}}const d=gn(e,s),f=d.attributes;if(s.inline&&(a.verticalAlign="-0.125em"),i==="svg"){c.style={...a,...l},Object.assign(c,f);let h=0,b=t.id;return typeof b=="string"&&(b=b.replace(/-/g,"_")),c.dangerouslySetInnerHTML={__html:Zn(bn(d.body,b?()=>b+"ID"+h++:"iconifyReact"))},j.createElement("svg",c)}const{body:m,width:w,height:p}=e,v=i==="mask"||(i==="bg"?!1:m.indexOf("currentColor")!==-1),C=Kn(m,{...f,width:w+"",height:p+""});return c.style={...a,"--svg":Qn(C),width:yt(f.width),height:yt(f.height),...es,...v?Ge:Mt,...l},j.createElement("span",c)};Et(!0);vn("",Tn);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof t=="object"&&t!==null&&(t instanceof Array?t:[t]).forEach(o=>{try{(typeof o!="object"||o===null||o instanceof Array||typeof o.icons!="object"||typeof o.prefix!="string"||!ln(o))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let n in t){const o="IconifyProviders["+n+"] is invalid.";try{const s=t[n];if(typeof s!="object"||!s||s.resources===void 0)continue;jn(n,s)||console.error(o)}catch{console.error(o)}}}}function Ut(e){const[t,n]=j.useState(!!e.ssr),[o,s]=j.useState({});function i(p){if(p){const v=e.icon;if(typeof v=="object")return{name:"",data:v};const C=ut(v);if(C)return{name:v,data:C}}return{name:""}}const[a,l]=j.useState(i(!!e.ssr));function c(){const p=o.callback;p&&(p(),s({}))}function d(p){if(JSON.stringify(a)!==JSON.stringify(p))return c(),l(p),!0}function f(){var p;const v=e.icon;if(typeof v=="object"){d({name:"",data:v});return}const C=ut(v);if(d({name:v,data:C}))if(C===void 0){const h=Rn([v],f);s({callback:h})}else C&&((p=e.onLoad)===null||p===void 0||p.call(e,v))}j.useEffect(()=>(n(!0),c),[]),j.useEffect(()=>{t&&f()},[e.icon,t]);const{name:m,data:w}=a;return w?ns({...Qe,...w},e,m):e.children?e.children:e.fallback?e.fallback:j.createElement("span",{})}const wt=j.forwardRef((e,t)=>Ut({...e,_ref:t}));j.forwardRef((e,t)=>Ut({inline:!0,...e,_ref:t}));const ss={product:null},Bt=Gt.createSlice({name:"product",initialState:ss,reducers:{setProduct:(e,t)=>{e.product=t.payload}}}),{setProduct:We}=Bt.actions;Bt.reducer;function os(){const e=()=>window.innerWidth<425?1:window.innerWidth<768?2:4,[t,n]=j.useState(e);return j.useEffect(()=>{const o=()=>n(e());return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),t}const rs=({product:e})=>{const t=we.useDispatch(),n=os(),[o,s]=j.useState(0),i=()=>{s(c=>c+n>=e.length?0:c+n)},a=()=>{s(c=>c-n<0?e.length-(e.length%n||n):c-n)},l=async c=>{const d=await Ct(c);t(We(d))};return r.jsx("div",{className:"mt-2 overflow-x-hidden",children:r.jsxs("div",{className:"flex items-center justify-center gap-4 relative",children:[(e==null?void 0:e.length)>n&&r.jsx("button",{onClick:a,className:"absolute z-50 left-0 text-[#000000] bg-[#ffffff] rounded-full p-2 flex items-center h-fit",children:r.jsx(wt,{icon:"mdi:chevron-left",width:"25"})}),r.jsx("div",{className:"flex gap-5 justify-center flex-1 overflow-hidden",children:e.slice(o,o+n).map(c=>{var d,f,m,w;return r.jsxs("div",{className:"flex-shrink-0 flex flex-col w-[150px] h-[200px] p-2 items-center justify-between cursor-pointer bg-[#FFFFFF] rounded-[10px] shadow-[0px_2px_2px_0px_#9292BC40]",onClick:()=>{l(c.product_id??c.productId)},children:[r.jsx("div",{className:"w-full p-2 flex items-center justify-center bg-white",children:r.jsx("img",{src:((d=rt(c)[0])==null?void 0:d.link)||rt(c)[0]||"https://via.placeholder.com/120",alt:c!=null&&c.productName?c.productName:"Product",className:"w-28 h-28 rounded-[10px] transition-transform duration-300 hover:scale-125 object-cover"})}),r.jsxs("div",{className:"text-white w-full p-2 text-[12px] text-center h-[60px]",children:[r.jsxs("div",{className:"relative inline-block group",children:[r.jsx("div",{className:"w-full line-clamp-1 overflow-hidden text-ellipsis text-[#000000] font-medium font-nunitoSans",children:c!=null&&c.productName?c.productName:c!=null&&c.product_name?c.product_name:at(ot((f=c==null?void 0:c.name)==null?void 0:f["en-US"]),60)||"Product"}),r.jsx("div",{className:"absolute left-0 top-full mt-1 w-max max-w-[200px] p-2 bg-white shadow-lg text-black text-xs rounded opacity-0 transition-opacity duration-300 group-hover:opacity-100 z-50 pointer-events-auto",style:{position:"absolute",top:"-100%",left:"0",marginBottom:"5px",zIndex:50},children:c!=null&&c.productName?c.productName:c!=null&&c.product_name?c.product_name:at(ot((m=c==null?void 0:c.name)==null?void 0:m["en-US"]),60)||"Product"})]}),r.jsxs("div",{className:" flex text-center items-center gap-2 text-[14px] text-[#14121F] font-bold font-nunitoSans text-base mb-1",children:[r.jsx("p",{children:Xt(c!=null&&c.price?Number(c==null?void 0:c.price):it(c).centAmount||0,(w=it(c))==null?void 0:w.currencyCode)}),r.jsxs("p",{className:"text-[#14121F] font-normal line-through text-sm font-nunitoSans truncate",children:["$",Number(c==null?void 0:c.price).toFixed(2)??5]})]})]})]},c.productId)})}),(e==null?void 0:e.length)>n&&r.jsx("button",{onClick:i,className:"absolute z-50 right-0 text-[#000000] bg-[#ffffff] rounded-full p-2 flex items-center h-fit",children:r.jsx(wt,{icon:"mdi:chevron-right",width:"25"})})]})})},is=({chat:e,storeDetails:t})=>r.jsx("div",{className:"bg-[#FFFFFF] px-7 py-4 rounded-r-xl rounded-bl-2xl w-full",children:e.map((n,o)=>r.jsxs("div",{className:"mb-4 p-3 rounded-xl",style:{background:"linear-gradient(109.52deg, #F0EEF5 36.91%, #F4F3EE 100.34%"},children:[r.jsx("div",{className:"font-nunitoSans font-bold text-sm text-[#494949] p-2 w-fit rounded-[20px]",children:en(n.keyword)||"No keyword"}),r.jsx(rs,{product:n.items,storeDetails:t})]},o))}),qt=async(e,t)=>{const{serverUrl:n,basePath:o}=de(),s=`${n}`;console.log(`customer_token
|
|
2
|
-
`,e);try{return(await M.post(`${
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),Je=require("@apollo/client"),me=require("react-redux"),bt=require("@reduxjs/toolkit"),S=require("react"),Jn=require("@radix-ui/react-popover");require("clsx");require("tailwind-merge");const M=require("axios");require("crypto-js");const Ot=require("@iconify/react"),Y=require("react-toastify");function Kn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const dn=Kn(Jn),Gn={store:{storeCode:"",storeName:"",storeDescription:"",activeCatalogId:0,isDefault:!1,logoDarkBg:"",logoLightBg:"",logoTransparent:"",catalogs:[],themeColor:"",themeContrastColor:"",tanyaThemeColor:"",tanyaThemeColorLight:"",favicon:"",websiteTitle:"",flowId:"",aliasId:"",searchConfigs:{endpoint:"",accessKey:"",secretKey:""},homePageCategories:[],carouselImages:{web:[],mobile:[]},otherImages:{web:[],mobile:[]}}},pn=bt.createSlice({name:"store",initialState:Gn,reducers:{setStore:(e,t)=>{e.store=t.payload}}}),{setStore:Jo}=pn.actions,Wn=pn.reducer,Qn={product:null},hn=bt.createSlice({name:"product",initialState:Qn,reducers:{setProduct:(e,t)=>{e.product=t.payload}}}),{setProduct:ut}=hn.actions,Yn=hn.reducer,Zn=bt.configureStore({reducer:{store:Wn,product:Yn}}),Xn=({children:e})=>a.jsx(me.Provider,{store:Zn,children:e}),Ce=e=>{const t=new CustomEvent("reactCartUpdated",{detail:{cartUpdated:!0,basketId:e}});window.dispatchEvent(t)};function er({...e}){return a.jsx(dn.Root,{"data-slot":"popover",...e})}function tr({...e}){return a.jsx(dn.Trigger,{"data-slot":"popover-trigger",...e})}const ge=()=>({aiConversationUrl:"https://mdv3qwfi2j.execute-api.us-east-1.amazonaws.com/dev/api/bedrock/invoke/stream",xAPIKey:"BJBtjpPkqGatuoa3qJqdR8aHXSsHkgvGaootbubi",serverUrl:"https://tanya-sfcc-server.vercel.app/",basePath:"sc-api"}),mn=async()=>{const e="https://tanya-sfcc-server.vercel.app/";try{const t=await M.post(`${e}api/auth/token-bm-grant?baseUrl=${ae()}&siteId=${te()}`);return t.status===200&&t.data.access_token?t.data.access_token:(console.error("Failed to fetch token:",t.data),null)}catch(t){return M.isAxiosError(t)?console.error("Error fetching token:",t.response||t.message):console.error("Unexpected error:",t),null}},gn=async e=>{const t="https://tanya-sfcc-server.vercel.app/";try{const n=JSON.parse(sessionStorage.getItem("customerData")||"{}").dwsid,r=await M.post(`${t}api/auth/token-existing-guest-customer?dwsid=${n}&baseUrl=${ae()}&siteId=${te()}&pubCfg=${ce()}&envRef=${le()}&orgRef=${ue()}`,{},{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`}});return r.status===200&&r.data?r.data:null}catch(n){return M.isAxiosError(n)?console.error("Error creating basket:",n.response||n.message):console.error("Unexpected error:",n),null}};async function Ye(){const e=localStorage.getItem("expires_in"),t=localStorage.getItem("access_token"),n=JSON.parse(sessionStorage.getItem("customerData")||"{}").isGuest;if(e&&t&&new Date().getTime()<parseInt(e)&&n===JSON.parse(localStorage.getItem("isGuest")||"false"))return console.log("access token found in local storage"),{access_token:t,expires_in:e};const{serverUrl:r}=ge(),o=JSON.parse(sessionStorage.getItem("customerData")||"{}").dwsid,s=JSON.parse(sessionStorage.getItem("customerData")||"{}").usrRef;try{const i=n?"unregister-auth":"register-auth",l=await M.get(`${r}sc-api/${i}?dwsid=${o}&email=${s}&pubCfg=${ce()}&envRef=${le()}&orgRef=${ue()}&siteId=${te()}`);return localStorage.setItem("access_token",l.data.access_token),localStorage.setItem("expires_in",String(new Date().getTime()+l.data.expires_in*1e3)),localStorage.setItem("isGuest",n.toString()),console.log(l.data),l.data}catch(i){console.log(i)}}const ae=()=>sessionStorage.getItem("Host"),te=()=>sessionStorage.getItem("SiteId"),ce=()=>sessionStorage.getItem("pubCfg"),le=()=>sessionStorage.getItem("envRef"),ue=()=>sessionStorage.getItem("orgRef"),$t=async(e,t)=>{const{serverUrl:n,basePath:r}=ge();try{const o=ae();return(await M.get(`${n}${r}/search-sfcc?baseUrl=${o}&query=${e}&siteId=${te()}&pubCfg=${ce()}&envRef=${le()}&orgRef=${ue()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}})).data.hits}catch(o){throw console.error("Error fetching search results:",o),o}},yn=async e=>{if(!e)throw new Error("Product ID is required");const{serverUrl:t,basePath:n}=ge(),r=ae();console.log("calling access");const{access_token:o}=await Ye();return console.log(o),(await M.get(`${t}${n}/product-sfcc/${e}?baseUrl=${r}&siteId=${te()}&pubCfg=${ce()}&envRef=${le()}&orgRef=${ue()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`}})).data},nr=async e=>{if(!e)throw new Error("customerId is required");const t=await mn(),{customer_token:n}=await gn(t),{serverUrl:r,basePath:o}=ge(),i=(await Ye()).access_token;return(await M.get(`${r}${o}/get-interest?baseUrl=${ae()}&customerId=${e}&siteId=${te()}&pubCfg=${ce()}&envRef=${le()}&orgRef=${ue()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`}})).data},At=e=>String(typeof e=="string"?e:e["en-US"]||e),Lt=e=>e!=null&&e.image?[e.image]:"variants"in e?e.variants[0].images:e.masterVariant.images.map(t=>t.url),rr=(e,t)=>e.toLocaleString("en-US",{style:"currency",currency:t||"USD"}),Dt=e=>{var t,n,r;return"variants"in e?{centAmount:(t=e.variants[0])==null?void 0:t.prices.EUR.max,currencyCode:"DOL"}:{centAmount:(n=e.masterVariant)==null?void 0:n.prices[0].value.centAmount,currencyCode:(r=e.masterVariant)==null?void 0:r.prices[0].value.currencyCode}},or=e=>e.charAt(0).toUpperCase()+e.slice(1),qt=(e,t)=>e.length<t?e:e.slice(0,t)+"...",rt=e=>e.split("\\n").map((t,n)=>{const r=t.match(/^(\d+)\.\s(.+)/);return r?`<p key=${n} class="mb-2"><strong>${r[1]}.</strong> ${r[2]}</p>`:t.trim()?`<p key=${n} class="mb-2">${t}</p>`:"<br/>"}).join("");function sr(e,t){const n=e.icons,r=e.aliases||Object.create(null),o=Object.create(null);function s(i){if(n[i])return o[i]=[];if(!(i in o)){o[i]=null;const l=r[i]&&r[i].parent,c=l&&s(l);c&&(o[i]=[l].concat(c))}return o[i]}return Object.keys(n).concat(Object.keys(r)).forEach(s),o}const xn=Object.freeze({left:0,top:0,width:16,height:16}),Ke=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),wt=Object.freeze({...xn,...Ke}),ft=Object.freeze({...wt,body:"",hidden:!1});function ir(e,t){const n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);const r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function Mt(e,t){const n=ir(e,t);for(const r in ft)r in Ke?r in e&&!(r in n)&&(n[r]=Ke[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function ar(e,t,n){const r=e.icons,o=e.aliases||Object.create(null);let s={};function i(l){s=Mt(r[l]||o[l],s)}return i(t),n.forEach(i),Mt(e,s)}function bn(e,t){const n=[];if(typeof e!="object"||typeof e.icons!="object")return n;e.not_found instanceof Array&&e.not_found.forEach(o=>{t(o,null),n.push(o)});const r=sr(e);for(const o in r){const s=r[o];s&&(t(o,ar(e,o,s)),n.push(o))}return n}const cr={provider:"",aliases:{},not_found:{},...xn};function ot(e,t){for(const n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function wn(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!ot(e,cr))return null;const n=t.icons;for(const o in n){const s=n[o];if(!o||typeof s.body!="string"||!ot(s,ft))return null}const r=t.aliases||Object.create(null);for(const o in r){const s=r[o],i=s.parent;if(!o||typeof i!="string"||!n[i]&&!r[i]||!ot(s,ft))return null}return t}const Ut=Object.create(null);function lr(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function Ne(e,t){const n=Ut[e]||(Ut[e]=Object.create(null));return n[t]||(n[t]=lr(e,t))}function vn(e,t){return wn(t)?bn(t,(n,r)=>{r?e.icons[n]=r:e.missing.add(n)}):[]}function ur(e,t,n){try{if(typeof n.body=="string")return e.icons[t]={...n},!0}catch{}return!1}const Sn=/^[a-z0-9]+(-[a-z0-9]+)*$/,Ze=(e,t,n,r="")=>{const o=e.split(":");if(e.slice(0,1)==="@"){if(o.length<2||o.length>3)return null;r=o.shift().slice(1)}if(o.length>3||!o.length)return null;if(o.length>1){const l=o.pop(),c=o.pop(),u={provider:o.length>0?o[0]:r,prefix:c,name:l};return t&&!He(u)?null:u}const s=o[0],i=s.split("-");if(i.length>1){const l={provider:r,prefix:i.shift(),name:i.join("-")};return t&&!He(l)?null:l}if(n&&r===""){const l={provider:r,prefix:"",name:s};return t&&!He(l,n)?null:l}return null},He=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let De=!1;function jn(e){return typeof e=="boolean"&&(De=e),De}function Bt(e){const t=typeof e=="string"?Ze(e,!0,De):e;if(t){const n=Ne(t.provider,t.prefix),r=t.name;return n.icons[r]||(n.missing.has(r)?null:void 0)}}function fr(e,t){const n=Ze(e,!0,De);if(!n)return!1;const r=Ne(n.provider,n.prefix);return t?ur(r,n.name,t):(r.missing.add(n.name),!0)}function dr(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),De&&!t&&!e.prefix){let o=!1;return wn(e)&&(e.prefix="",bn(e,(s,i)=>{fr(s,i)&&(o=!0)})),o}const n=e.prefix;if(!He({prefix:n,name:"a"}))return!1;const r=Ne(t,n);return!!vn(r,e)}const kn=Object.freeze({width:null,height:null}),In=Object.freeze({...kn,...Ke}),pr=/(-?[0-9.]*[0-9]+[0-9.]*)/g,hr=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Rt(e,t,n){if(t===1)return e;if(n=n||100,typeof e=="number")return Math.ceil(e*t*n)/n;if(typeof e!="string")return e;const r=e.split(pr);if(r===null||!r.length)return e;const o=[];let s=r.shift(),i=hr.test(s);for(;;){if(i){const l=parseFloat(s);isNaN(l)?o.push(s):o.push(Math.ceil(l*t*n)/n)}else o.push(s);if(s=r.shift(),s===void 0)return o.join("");i=!i}}function mr(e,t="defs"){let n="";const r=e.indexOf("<"+t);for(;r>=0;){const o=e.indexOf(">",r),s=e.indexOf("</"+t);if(o===-1||s===-1)break;const i=e.indexOf(">",s);if(i===-1)break;n+=e.slice(o+1,s).trim(),e=e.slice(0,r).trim()+e.slice(i+1)}return{defs:n,content:e}}function gr(e,t){return e?"<defs>"+e+"</defs>"+t:t}function yr(e,t,n){const r=mr(e);return gr(r.defs,t+r.content+n)}const xr=e=>e==="unset"||e==="undefined"||e==="none";function br(e,t){const n={...wt,...e},r={...In,...t},o={left:n.left,top:n.top,width:n.width,height:n.height};let s=n.body;[n,r].forEach(C=>{const g=[],w=C.hFlip,U=C.vFlip;let T=C.rotate;w?U?T+=2:(g.push("translate("+(o.width+o.left).toString()+" "+(0-o.top).toString()+")"),g.push("scale(-1 1)"),o.top=o.left=0):U&&(g.push("translate("+(0-o.left).toString()+" "+(o.height+o.top).toString()+")"),g.push("scale(1 -1)"),o.top=o.left=0);let $;switch(T<0&&(T-=Math.floor(T/4)*4),T=T%4,T){case 1:$=o.height/2+o.top,g.unshift("rotate(90 "+$.toString()+" "+$.toString()+")");break;case 2:g.unshift("rotate(180 "+(o.width/2+o.left).toString()+" "+(o.height/2+o.top).toString()+")");break;case 3:$=o.width/2+o.left,g.unshift("rotate(-90 "+$.toString()+" "+$.toString()+")");break}T%2===1&&(o.left!==o.top&&($=o.left,o.left=o.top,o.top=$),o.width!==o.height&&($=o.width,o.width=o.height,o.height=$)),g.length&&(s=yr(s,'<g transform="'+g.join(" ")+'">',"</g>"))});const i=r.width,l=r.height,c=o.width,u=o.height;let d,p;i===null?(p=l===null?"1em":l==="auto"?u:l,d=Rt(p,c/u)):(d=i==="auto"?c:i,p=l===null?Rt(d,u/c):l==="auto"?u:l);const h={},m=(C,g)=>{xr(g)||(h[C]=g.toString())};m("width",d),m("height",p);const v=[o.left,o.top,c,u];return h.viewBox=v.join(" "),{attributes:h,viewBox:v,body:s}}const wr=/\sid="(\S+)"/g,vr="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Sr=0;function jr(e,t=vr){const n=[];let r;for(;r=wr.exec(e);)n.push(r[1]);if(!n.length)return e;const o="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(s=>{const i=typeof t=="function"?t(s):t+(Sr++).toString(),l=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+l+')([")]|\\.[a-z])',"g"),"$1"+i+o+"$3")}),e=e.replace(new RegExp(o,"g"),""),e}const dt=Object.create(null);function kr(e,t){dt[e]=t}function pt(e){return dt[e]||dt[""]}function vt(e){let t;if(typeof e.resources=="string")t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const St=Object.create(null),Te=["https://api.simplesvg.com","https://api.unisvg.com"],ze=[];for(;Te.length>0;)Te.length===1||Math.random()>.5?ze.push(Te.shift()):ze.push(Te.pop());St[""]=vt({resources:["https://api.iconify.design"].concat(ze)});function Ir(e,t){const n=vt(t);return n===null?!1:(St[e]=n,!0)}function jt(e){return St[e]}const Cr=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let Ht=Cr();function _r(e,t){const n=jt(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let o=0;n.resources.forEach(i=>{o=Math.max(o,i.length)});const s=t+".json?icons=";r=n.maxURL-o-n.path.length-s.length}return r}function Nr(e){return e===404}const Fr=(e,t,n)=>{const r=[],o=_r(e,t),s="icons";let i={type:s,provider:e,prefix:t,icons:[]},l=0;return n.forEach((c,u)=>{l+=c.length+1,l>=o&&u>0&&(r.push(i),i={type:s,provider:e,prefix:t,icons:[]},l=c.length),i.icons.push(c)}),r.push(i),r};function Er(e){if(typeof e=="string"){const t=jt(e);if(t)return t.path}return"/"}const Tr=(e,t,n)=>{if(!Ht){n("abort",424);return}let r=Er(t.provider);switch(t.type){case"icons":{const s=t.prefix,l=t.icons.join(","),c=new URLSearchParams({icons:l});r+=s+".json?"+c.toString();break}case"custom":{const s=t.uri;r+=s.slice(0,1)==="/"?s.slice(1):s;break}default:n("abort",400);return}let o=503;Ht(e+r).then(s=>{const i=s.status;if(i!==200){setTimeout(()=>{n(Nr(i)?"abort":"next",i)});return}return o=501,s.json()}).then(s=>{if(typeof s!="object"||s===null){setTimeout(()=>{s===404?n("abort",s):n("next",o)});return}setTimeout(()=>{n("success",s)})}).catch(()=>{n("next",o)})},Pr={prepare:Fr,send:Tr};function Cn(e,t){e.forEach(n=>{const r=n.loaderCallbacks;r&&(n.loaderCallbacks=r.filter(o=>o.id!==t))})}function Or(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1;const r=e.provider,o=e.prefix;t.forEach(s=>{const i=s.icons,l=i.pending.length;i.pending=i.pending.filter(c=>{if(c.prefix!==o)return!0;const u=c.name;if(e.icons[u])i.loaded.push({provider:r,prefix:o,name:u});else if(e.missing.has(u))i.missing.push({provider:r,prefix:o,name:u});else return n=!0,!0;return!1}),i.pending.length!==l&&(n||Cn([e],s.id),s.callback(i.loaded.slice(0),i.missing.slice(0),i.pending.slice(0),s.abort))})}))}let $r=0;function Ar(e,t,n){const r=$r++,o=Cn.bind(null,n,r);if(!t.pending.length)return o;const s={id:r,icons:t,callback:e,abort:o};return n.forEach(i=>{(i.loaderCallbacks||(i.loaderCallbacks=[])).push(s)}),o}function Lr(e){const t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((o,s)=>o.provider!==s.provider?o.provider.localeCompare(s.provider):o.prefix!==s.prefix?o.prefix.localeCompare(s.prefix):o.name.localeCompare(s.name));let r={provider:"",prefix:"",name:""};return e.forEach(o=>{if(r.name===o.name&&r.prefix===o.prefix&&r.provider===o.provider)return;r=o;const s=o.provider,i=o.prefix,l=o.name,c=n[s]||(n[s]=Object.create(null)),u=c[i]||(c[i]=Ne(s,i));let d;l in u.icons?d=t.loaded:i===""||u.missing.has(l)?d=t.missing:d=t.pending;const p={provider:s,prefix:i,name:l};d.push(p)}),t}function Dr(e,t=!0,n=!1){const r=[];return e.forEach(o=>{const s=typeof o=="string"?Ze(o,t,n):o;s&&r.push(s)}),r}const qr={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Mr(e,t,n,r){const o=e.resources.length,s=e.random?Math.floor(Math.random()*o):e.index;let i;if(e.random){let j=e.resources.slice(0);for(i=[];j.length>1;){const L=Math.floor(Math.random()*j.length);i.push(j[L]),j=j.slice(0,L).concat(j.slice(L+1))}i=i.concat(j)}else i=e.resources.slice(s).concat(e.resources.slice(0,s));const l=Date.now();let c="pending",u=0,d,p=null,h=[],m=[];typeof r=="function"&&m.push(r);function v(){p&&(clearTimeout(p),p=null)}function C(){c==="pending"&&(c="aborted"),v(),h.forEach(j=>{j.status==="pending"&&(j.status="aborted")}),h=[]}function g(j,L){L&&(m=[]),typeof j=="function"&&m.push(j)}function w(){return{startTime:l,payload:t,status:c,queriesSent:u,queriesPending:h.length,subscribe:g,abort:C}}function U(){c="failed",m.forEach(j=>{j(void 0,d)})}function T(){h.forEach(j=>{j.status==="pending"&&(j.status="aborted")}),h=[]}function $(j,L,H){const z=L!=="success";switch(h=h.filter(P=>P!==j),c){case"pending":break;case"failed":if(z||!e.dataAfterTimeout)return;break;default:return}if(L==="abort"){d=H,U();return}if(z){d=H,h.length||(i.length?Z():U());return}if(v(),T(),!e.random){const P=e.resources.indexOf(j.resource);P!==-1&&P!==e.index&&(e.index=P)}c="completed",m.forEach(P=>{P(H)})}function Z(){if(c!=="pending")return;v();const j=i.shift();if(j===void 0){if(h.length){p=setTimeout(()=>{v(),c==="pending"&&(T(),U())},e.timeout);return}U();return}const L={status:"pending",resource:j,callback:(H,z)=>{$(L,H,z)}};h.push(L),u++,p=setTimeout(Z,e.rotate),n(j,t,L.callback)}return setTimeout(Z),w}function _n(e){const t={...qr,...e};let n=[];function r(){n=n.filter(l=>l().status==="pending")}function o(l,c,u){const d=Mr(t,l,c,(p,h)=>{r(),u&&u(p,h)});return n.push(d),d}function s(l){return n.find(c=>l(c))||null}return{query:o,find:s,setIndex:l=>{t.index=l},getIndex:()=>t.index,cleanup:r}}function zt(){}const st=Object.create(null);function Ur(e){if(!st[e]){const t=jt(e);if(!t)return;const n=_n(t),r={config:t,redundancy:n};st[e]=r}return st[e]}function Br(e,t,n){let r,o;if(typeof e=="string"){const s=pt(e);if(!s)return n(void 0,424),zt;o=s.send;const i=Ur(e);i&&(r=i.redundancy)}else{const s=vt(e);if(s){r=_n(s);const i=e.resources?e.resources[0]:"",l=pt(i);l&&(o=l.send)}}return!r||!o?(n(void 0,424),zt):r.query(t,o,n)().abort}function Vt(){}function Rr(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,Or(e)}))}function Hr(e){const t=[],n=[];return e.forEach(r=>{(r.match(Sn)?t:n).push(r)}),{valid:t,invalid:n}}function Pe(e,t,n){function r(){const o=e.pendingIcons;t.forEach(s=>{o&&o.delete(s),e.icons[s]||e.missing.add(s)})}if(n&&typeof n=="object")try{if(!vn(e,n).length){r();return}}catch(o){console.error(o)}r(),Rr(e)}function Jt(e,t){e instanceof Promise?e.then(n=>{t(n)}).catch(()=>{t(null)}):t(e)}function zr(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:n,prefix:r}=e,o=e.iconsToLoad;if(delete e.iconsToLoad,!o||!o.length)return;const s=e.loadIcon;if(e.loadIcons&&(o.length>1||!s)){Jt(e.loadIcons(o,r,n),d=>{Pe(e,o,d)});return}if(s){o.forEach(d=>{const p=s(d,r,n);Jt(p,h=>{const m=h?{prefix:r,icons:{[d]:h}}:null;Pe(e,[d],m)})});return}const{valid:i,invalid:l}=Hr(o);if(l.length&&Pe(e,l,null),!i.length)return;const c=r.match(Sn)?pt(n):null;if(!c){Pe(e,i,null);return}c.prepare(n,r,i).forEach(d=>{Br(n,d,p=>{Pe(e,d.icons,p)})})}))}const Vr=(e,t)=>{const n=Dr(e,!0,jn()),r=Lr(n);if(!r.pending.length){let c=!0;return t&&setTimeout(()=>{c&&t(r.loaded,r.missing,r.pending,Vt)}),()=>{c=!1}}const o=Object.create(null),s=[];let i,l;return r.pending.forEach(c=>{const{provider:u,prefix:d}=c;if(d===l&&u===i)return;i=u,l=d,s.push(Ne(u,d));const p=o[u]||(o[u]=Object.create(null));p[d]||(p[d]=[])}),r.pending.forEach(c=>{const{provider:u,prefix:d,name:p}=c,h=Ne(u,d),m=h.pendingIcons||(h.pendingIcons=new Set);m.has(p)||(m.add(p),o[u][d].push(p))}),s.forEach(c=>{const u=o[c.provider][c.prefix];u.length&&zr(c,u)}),t?Ar(t,r,s):Vt};function Jr(e,t){const n={...e};for(const r in t){const o=t[r],s=typeof o;r in kn?(o===null||o&&(s==="string"||s==="number"))&&(n[r]=o):s===typeof n[r]&&(n[r]=r==="rotate"?o%4:o)}return n}const Kr=/[\s,]+/;function Gr(e,t){t.split(Kr).forEach(n=>{switch(n.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function Wr(e,t=0){const n=e.replace(/^-?[0-9.]*/,"");function r(o){for(;o<0;)o+=4;return o%4}if(n===""){const o=parseInt(e);return isNaN(o)?0:r(o)}else if(n!==e){let o=0;switch(n){case"%":o=25;break;case"deg":o=90}if(o){let s=parseFloat(e.slice(0,e.length-n.length));return isNaN(s)?0:(s=s/o,s%1===0?r(s):0)}}return t}function Qr(e,t){let n=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const r in t)n+=" "+r+'="'+t[r]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}function Yr(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Zr(e){return"data:image/svg+xml,"+Yr(e)}function Xr(e){return'url("'+Zr(e)+'")'}let Le;function eo(){try{Le=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{Le=null}}function to(e){return Le===void 0&&eo(),Le?Le.createHTML(e):e}const Nn={...In,inline:!1},no={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},ro={display:"inline-block"},ht={backgroundColor:"currentColor"},Fn={backgroundColor:"transparent"},Kt={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},Gt={WebkitMask:ht,mask:ht,background:Fn};for(const e in Gt){const t=Gt[e];for(const n in Kt)t[e+n]=Kt[n]}const oo={...Nn,inline:!0};function Wt(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const so=(e,t,n)=>{const r=t.inline?oo:Nn,o=Jr(r,t),s=t.mode||"svg",i={},l=t.style||{},c={...s==="svg"?no:{}};if(n){const g=Ze(n,!1,!0);if(g){const w=["iconify"],U=["provider","prefix"];for(const T of U)g[T]&&w.push("iconify--"+g[T]);c.className=w.join(" ")}}for(let g in t){const w=t[g];if(w!==void 0)switch(g){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":c.ref=w;break;case"className":c[g]=(c[g]?c[g]+" ":"")+w;break;case"inline":case"hFlip":case"vFlip":o[g]=w===!0||w==="true"||w===1;break;case"flip":typeof w=="string"&&Gr(o,w);break;case"color":i.color=w;break;case"rotate":typeof w=="string"?o[g]=Wr(w):typeof w=="number"&&(o[g]=w);break;case"ariaHidden":case"aria-hidden":w!==!0&&w!=="true"&&delete c["aria-hidden"];break;default:r[g]===void 0&&(c[g]=w)}}const u=br(e,o),d=u.attributes;if(o.inline&&(i.verticalAlign="-0.125em"),s==="svg"){c.style={...i,...l},Object.assign(c,d);let g=0,w=t.id;return typeof w=="string"&&(w=w.replace(/-/g,"_")),c.dangerouslySetInnerHTML={__html:to(jr(u.body,w?()=>w+"ID"+g++:"iconifyReact"))},S.createElement("svg",c)}const{body:p,width:h,height:m}=e,v=s==="mask"||(s==="bg"?!1:p.indexOf("currentColor")!==-1),C=Qr(p,{...d,width:h+"",height:m+""});return c.style={...i,"--svg":Xr(C),width:Wt(d.width),height:Wt(d.height),...ro,...v?ht:Fn,...l},S.createElement("span",c)};jn(!0);kr("",Pr);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,n="Invalid IconifyPreload syntax.";typeof t=="object"&&t!==null&&(t instanceof Array?t:[t]).forEach(r=>{try{(typeof r!="object"||r===null||r instanceof Array||typeof r.icons!="object"||typeof r.prefix!="string"||!dr(r))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let n in t){const r="IconifyProviders["+n+"] is invalid.";try{const o=t[n];if(typeof o!="object"||!o||o.resources===void 0)continue;Ir(n,o)||console.error(r)}catch{console.error(r)}}}}function En(e){const[t,n]=S.useState(!!e.ssr),[r,o]=S.useState({});function s(m){if(m){const v=e.icon;if(typeof v=="object")return{name:"",data:v};const C=Bt(v);if(C)return{name:v,data:C}}return{name:""}}const[i,l]=S.useState(s(!!e.ssr));function c(){const m=r.callback;m&&(m(),o({}))}function u(m){if(JSON.stringify(i)!==JSON.stringify(m))return c(),l(m),!0}function d(){var m;const v=e.icon;if(typeof v=="object"){u({name:"",data:v});return}const C=Bt(v);if(u({name:v,data:C}))if(C===void 0){const g=Vr([v],d);o({callback:g})}else C&&((m=e.onLoad)===null||m===void 0||m.call(e,v))}S.useEffect(()=>(n(!0),c),[]),S.useEffect(()=>{t&&d()},[e.icon,t]);const{name:p,data:h}=i;return h?so({...wt,...h},e,p):e.children?e.children:e.fallback?e.fallback:S.createElement("span",{})}const Qt=S.forwardRef((e,t)=>En({...e,_ref:t}));S.forwardRef((e,t)=>En({inline:!0,...e,_ref:t}));function io(){const e=()=>window.innerWidth<425?1:window.innerWidth<768?2:4,[t,n]=S.useState(e);return S.useEffect(()=>{const r=()=>n(e());return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),t}const ao=({product:e})=>{const t=me.useDispatch(),n=io(),[r,o]=S.useState(0),s=()=>{o(c=>c+n>=e.length?0:c+n)},i=()=>{o(c=>c-n<0?e.length-(e.length%n||n):c-n)},l=async c=>{const u=await yn(c);t(ut(u))};return a.jsx("div",{className:"mt-2 overflow-x-hidden",children:a.jsxs("div",{className:"flex items-center justify-center gap-4 relative",children:[(e==null?void 0:e.length)>n&&a.jsx("button",{onClick:i,className:"absolute z-50 left-0 text-[#000000] bg-[#ffffff] rounded-full p-2 flex items-center h-fit",children:a.jsx(Qt,{icon:"mdi:chevron-left",width:"25"})}),a.jsx("div",{className:"flex gap-5 justify-center flex-1 overflow-hidden",children:e.slice(r,r+n).map(c=>{var u,d,p,h;return a.jsxs("div",{className:"flex-shrink-0 flex flex-col w-[150px] h-[200px] p-2 items-center justify-between cursor-pointer bg-[#FFFFFF] rounded-[10px] shadow-[0px_2px_2px_0px_#9292BC40]",onClick:()=>{l(c.product_id??c.productId)},children:[a.jsx("div",{className:"w-full p-2 flex items-center justify-center bg-white",children:a.jsx("img",{src:((u=Lt(c)[0])==null?void 0:u.link)||Lt(c)[0]||"https://via.placeholder.com/120",alt:c!=null&&c.productName?c.productName:"Product",className:"w-28 h-28 rounded-[10px] transition-transform duration-300 hover:scale-125 object-cover"})}),a.jsxs("div",{className:"text-white w-full p-2 text-[12px] text-center h-[60px]",children:[a.jsxs("div",{className:"relative inline-block group",children:[a.jsx("div",{className:"w-full line-clamp-1 overflow-hidden text-ellipsis text-[#000000] font-medium font-nunitoSans",children:c!=null&&c.productName?c.productName:c!=null&&c.product_name?c.product_name:qt(At((d=c==null?void 0:c.name)==null?void 0:d["en-US"]),60)||"Product"}),a.jsx("div",{className:"absolute left-0 top-full mt-1 w-max max-w-[200px] p-2 bg-white shadow-lg text-black text-xs rounded opacity-0 transition-opacity duration-300 group-hover:opacity-100 z-50 pointer-events-auto",style:{position:"absolute",top:"-100%",left:"0",marginBottom:"5px",zIndex:50},children:c!=null&&c.productName?c.productName:c!=null&&c.product_name?c.product_name:qt(At((p=c==null?void 0:c.name)==null?void 0:p["en-US"]),60)||"Product"})]}),a.jsxs("div",{className:" flex text-center items-center gap-2 text-[14px] text-[#14121F] font-bold font-nunitoSans text-base mb-1",children:[a.jsx("p",{children:rr(c!=null&&c.price?Number(c==null?void 0:c.price):Dt(c).centAmount||0,(h=Dt(c))==null?void 0:h.currencyCode)}),a.jsxs("p",{className:"text-[#14121F] font-normal line-through text-sm font-nunitoSans truncate",children:["$",Number(c==null?void 0:c.price).toFixed(2)??5]})]})]})]},c.productId)})}),(e==null?void 0:e.length)>n&&a.jsx("button",{onClick:s,className:"absolute z-50 right-0 text-[#000000] bg-[#ffffff] rounded-full p-2 flex items-center h-fit",children:a.jsx(Qt,{icon:"mdi:chevron-right",width:"25"})})]})})},co=({chat:e,storeDetails:t})=>a.jsx("div",{className:"bg-[#FFFFFF] px-7 py-4 rounded-r-xl rounded-bl-2xl w-full",children:e.map((n,r)=>a.jsxs("div",{className:"mb-4 p-3 rounded-xl",style:{background:"linear-gradient(109.52deg, #F0EEF5 36.91%, #F4F3EE 100.34%"},children:[a.jsx("div",{className:"font-nunitoSans font-bold text-sm text-[#494949] p-2 w-fit rounded-[20px]",children:or(n.keyword)||"No keyword"}),a.jsx(ao,{product:n.items,storeDetails:t})]},r))}),Tn=async(e,t)=>{const{serverUrl:n,basePath:r}=ge(),o=`${n}`;console.log(`customer_token
|
|
2
|
+
`,e);try{return(await M.post(`${o}${r}/basket/create?baseUrl=${ae()}&siteId=${te()}&pubCfg=${ce()}&envRef=${le()}&orgRef=${ue()}`,t,{headers:{"Content-Type":"application/json",Authorization:e}})).data}catch(s){return M.isAxiosError(s)?console.error("Error creating basket:",s.response||s.message):console.error("Unexpected error:",s),null}},Ge=async(e,t,n)=>{const{serverUrl:r,basePath:o}=ge(),s=`${r}`;try{const i=await M.post(`${s}${o}/basket/add-product/${e}?baseUrl=${ae()}&siteId=${te()}&pubCfg=${ce()}&envRef=${le()}&orgRef=${ue()}`,t,{headers:{"Content-Type":"application/json",Authorization:n}});return i.status===200&&i.data?i.data:null}catch(i){return M.isAxiosError(i)?console.error("Error adding products to basket:",i.response||i.message):console.error("Unexpected error:",i),null}},Pn=async({basketId:e,customer_token:t})=>{var s;const{serverUrl:n,basePath:r}=ge(),o=`${n}`;try{const i=await M.get(`${o}${r}/basket/${e}?baseUrl=${ae()}&siteId=${te()}&pubCfg=${ce()}&envRef=${le()}&orgRef=${ue()}`,{headers:{"Content-Type":"application/json",Authorization:t}});return{status:i.status,data:i.data}}catch(i){return M.isAxiosError(i)?{status:(s=i.response)==null?void 0:s.status,data:null}:{status:null,data:null}}},Yt="sfcc_basket_id",Zt="sfcc_customer_token",qe="sfcc_token_expiry",lo=300*1e3,Oe="1.0.0";const _e=e=>{try{e?localStorage.setItem(Yt,e):localStorage.removeItem(Yt)}catch(t){console.error("Error saving basket ID to storage:",t)}},We=e=>{try{if(e){localStorage.setItem(Zt,e);const t=Date.now()+lo;localStorage.setItem(qe,t.toString())}else localStorage.removeItem(Zt)}catch(t){console.error("Error storing token:",t)}},Xt=300,uo=()=>{var l,c,u,d,p,h;const e=me.useDispatch(),t=me.useSelector(m=>m.product.product),n=me.useSelector(m=>m.store.store),[r,o]=S.useState(!!t);if(S.useEffect(()=>{o(!!t)},[t]),!t)return null;const s=async()=>{var m,v,C,g,w,U,T,$,Z,j,L,H,z,P,ye,E;console.log(t,"the prod");try{if(!((v=(m=t==null?void 0:t.variants)==null?void 0:m[0])!=null&&v.product_id)&&!(t.type.item||t.type.bundle)&&!((g=(C=t==null?void 0:t.variants)==null?void 0:C[0])!=null&&g.productId)){Y.toast.error("Variants not available",{position:"bottom-right",autoClose:1e3}),console.error("No product variant found");return}const O=[{product_id:((w=t.variants)==null?void 0:w[0].product_id)||((U=t.variants)==null?void 0:U[0].productId)||(t==null?void 0:t.id),quantity:1}];console.log(O,"the product data");const Ee=JSON.parse(sessionStorage.getItem("customerData")||"{}"),fe=Ee==null?void 0:Ee.basketId,Xe=!1,ne=localStorage.getItem(qe),de=Date.now();if(!Xe||!ne||de>=parseInt(ne)){let V="";{const xe=await Ye();console.log("token from auth data"),V="Bearer "+xe.access_token}if(!V){console.error("Failed to get customer_token");return}const et=de+300*1e3;if(We(V),localStorage.setItem(qe,et.toString()),fe){const xe=await Pn({basketId:fe,customer_token:V});if(console.log(fe,"basket id from customer"),xe.status===200&&xe){const re=await Ge(fe,O,V);(((T=re==null?void 0:re.product_items)==null?void 0:T.length)>0||(($=re==null?void 0:re.productItems)==null?void 0:$.length)>0)&&(Y.toast.success("Added to cart",{position:"bottom-right",autoClose:3e3,hideProgressBar:!1,closeOnClick:!0,pauseOnHover:!0,draggable:!0}),Ce(fe));return}}const tt={productItems:[{productId:((Z=t.variants)==null?void 0:Z[0].product_id)||((j=t.variants)==null?void 0:j[0].productId)||(t==null?void 0:t.id),quantity:1}]};console.log("before create basket");const x=await Tn(V,tt);if(console.log(x,x==null?void 0:x.basket_id,x==null?void 0:x.basketId,"the basket response"),!(x!=null&&x.basket_id)&&!(x!=null&&x.basketId)){console.error("Failed to create basket");return}console.log("setting stored id",(x==null?void 0:x.basket_id)||(x==null?void 0:x.basketId)),_e((x==null?void 0:x.basket_id)||(x==null?void 0:x.basketId)),console.log("adding product to basket");const J=await Ge((x==null?void 0:x.basket_id)||(x==null?void 0:x.basketId),O,V);console.log("object added to basket"),(((L=J==null?void 0:J.product_items)==null?void 0:L.length)>0||((H=J==null?void 0:J.productItems)==null?void 0:H.length)>0)&&Y.toast.success("Added to cart",{position:"bottom-right",autoClose:3e3,hideProgressBar:!1,closeOnClick:!0,pauseOnHover:!0,draggable:!0}),Ce(x.basket_id||(x==null?void 0:x.basketId))}}catch(O){console.error("Error adding to cart:",O),Y.toast.error("Failed to add product to cart",{position:"bottom-right",autoClose:3e3}),((z=O==null?void 0:O.response)==null?void 0:z.status)===404||((P=O==null?void 0:O.response)==null?void 0:P.status)===401?(((ye=O==null?void 0:O.response)==null?void 0:ye.status)===404&&_e(null),((E=O==null?void 0:O.response)==null?void 0:E.status)===401&&(_e(null),We(null))):(console.error("Failed to add product to basket:",O.message),Y.toast.error("Failed to add product to cart",{position:"bottom-right",autoClose:3e3}))}finally{Ce()}},i=()=>{t&&(window.location.href=t.c_pdpUrl)};return console.log(t,"the prod"),a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-40 bg-black/30",onClick:()=>{o(!1),setTimeout(()=>e(ut(null)),Xt)}}),a.jsxs("div",{className:`
|
|
3
3
|
flex flex-col gap-2 items-center h-[90vh] absolute right-0 bottom-0 z-50 w-full md:w-1/2 md:h-[100vh] lg:w-1/2 lg:h-[100vh] shadow-xl p-2 border-l-2 bg-white border-gray-200 overflow-y-scroll
|
|
4
4
|
transition-all duration-300
|
|
5
|
-
${
|
|
6
|
-
`,style:{willChange:"transform, opacity"},onClick:
|
|
5
|
+
${r?"translate-y-0 md:translate-y-0 md:translate-x-0 opacity-100":"translate-y-full md:translate-y-0 md:translate-x-full opacity-0 pointer-events-none"}
|
|
6
|
+
`,style:{willChange:"transform, opacity"},onClick:m=>m.stopPropagation(),children:[a.jsxs("div",{className:"mt-3 flex flex-row justify-between w-full ",children:[a.jsx("div",{children:a.jsx("p",{className:"text-[#000000] font-bold font-nunitoSans",children:t.name})}),a.jsx("div",{children:a.jsx(Ot.Icon,{icon:"mdi:close",className:"text-[#555555] w-6 h-6 cursor-pointer",onClick:()=>{o(!1),setTimeout(()=>e(ut(null)),Xt)}})})]}),a.jsxs("div",{className:"flex flex-row gap-2 items-center flex-wrap",children:[a.jsx("div",{className:"flex flex-row items-center justify-center w-[120px] h-[120px] my-5",children:a.jsx("img",{src:(d=(u=(c=(l=t.imageGroups)==null?void 0:l[0])==null?void 0:c.images)==null?void 0:u[0])==null?void 0:d.link,alt:t.name,className:"rounded-[10px]"})}),a.jsx("div",{className:"flex flex-col items-center gap-2",children:t.imageGroups.slice(1,2).map(m=>m.images.slice(1,2).map(v=>a.jsx("img",{src:v.link,alt:t.name,className:"rounded-[10px] w-[60px] h-[60px]"},v.link)))})]}),a.jsxs("div",{className:"flex flex-row items-center justify-between w-full",children:[a.jsxs("div",{className:"flex flex-row items-center gap-2",children:[a.jsxs("p",{className:"text-[#14121F] font-bold font-nunitoSans",children:[" ","$",t.price.toFixed(2)]})," ",a.jsxs("p",{className:"text-[#14121F] font-normal line-through text-sm font-nunitoSans",children:[" ","$",(t.price+5).toFixed(2)]})]}),a.jsx("div",{children:a.jsx("p",{className:"text-[#EC5050] font-bold font-nunitoSans",children:t.discount})})]}),a.jsx("div",{className:"mt-2 w-full border-t-2 border-gray-200"}),a.jsxs("div",{className:"w-full text-left",children:[a.jsx("div",{className:"text-[#323135] font-bold font-nunitoSans mt-3 text-[14px]",children:"Product Details"}),a.jsx("div",{className:"text-[#68656E] font-normal font-nunitoSans text-xs pl-2 mt-3",dangerouslySetInnerHTML:{__html:t.short_description||t.longDescription}})]}),a.jsxs("div",{className:"mt-4 flex flex-col gap-2 w-full p-2",children:[a.jsx("div",{className:"flex flex-row items-center gap-2",children:a.jsxs("div",{className:"flex items-center gap-2 text-left font-nunitoSans",children:[a.jsxs("div",{className:"text-[#323135] font-bold",children:[((p=t==null?void 0:t.rating)==null?void 0:p.rate)||0," /"," ",a.jsx("span",{className:"text-[#68656E]",children:"5"})]}),a.jsx("div",{className:"text-[#323135] font-semibold text-sm",children:"Overall Rating"}),a.jsxs("div",{className:"text-[#68656E] font-semibold text-sm",children:[((h=t==null?void 0:t.rating)==null?void 0:h.count)||0," ratings"]})]})}),a.jsx("div",{className:"mt-2 flex flex-row items-center gap-2",children:Array.from({length:5}).map((m,v)=>{var C;return a.jsx(Ot.Icon,{icon:"mdi:star",width:"20",height:"20",className:`text-yellow-500
|
|
7
7
|
${((C=t==null?void 0:t.rating)==null?void 0:C.rate)>v?"text-yellow-500":"text-gray-300"}
|
|
8
|
-
`},v)})})]}),
|
|
9
|
-
`);
|
|
10
|
-
`);
|
|
8
|
+
`},v)})})]}),a.jsxs("div",{className:"flex flex-col items-center justify-between font-nunitoSans font-semibold w-5/6 text-black gap-2",style:{marginTop:"150px"},children:[a.jsx("button",{className:"rounded-[5px] shadow-sm text-[#FBFBFC] bg-[#6851C6] p-2 w-full text-center cursor-pointer",style:{backgroundColor:n.tanyaThemeColor},onClick:s,children:"Add to Cart"}),a.jsx("button",{className:"rounded-[5px] shadow-sm text-[#FBFBFC] bg-[#6851C6] p-2 w-full text-center cursor-pointer mb-16",style:{backgroundColor:n.tanyaThemeColor},onClick:i,children:"View more"})]})]})]})},fo=()=>{const e=["Myself","My Child","My Grandchild","Niece/Nephew","My Friends","Others"],t={Myself:"himself/herself","My Child":"his/her child","My Grandchild":"his/her grandchild","Niece/Nephew":"his/her niece/nephew","My Friends":"his/her friends",Others:"others"},n=S.useRef(null),r=S.useRef(null),o=S.useRef(null),s=S.useRef(null),[i,l]=S.useState(null),[c,u]=S.useState(!1),[d,p]=S.useState(!1),[h,m]=S.useState(!1),[v,C]=S.useState(!1),[g,w]=S.useState(!1),[U,T]=S.useState(!1),[$,Z]=S.useState(""),[j,L]=S.useState(""),H=f=>({id:f.id,title:f.name,image:f.image??"",price:f.price??0}),[z,P]=S.useState([]),ye=S.useRef(null),E=me.useSelector(f=>f.store.store),O=me.useSelector(f=>f.product.product),Ee=()=>{m(!0),setTimeout(()=>p(!0),10)},fe=()=>{p(!1),setTimeout(()=>m(!1),300)};S.useEffect(()=>{c?Ee():fe()},[c]);const Xe=f=>{L(t[f])};S.useEffect(()=>{ye.current&&(ye.current.scrollTop+=150)},[z]);let ne=null,de=null;const V=async()=>{if(ne&&de&&Date.now()<de)return ne;try{const f="https://us-east-1lsr29ln3u.auth.us-east-1.amazoncognito.com/oauth2/token",F=new URLSearchParams({grant_type:"client_credentials",client_id:"4i8rd70sgt961tc4dhskgf08c",client_secret:"bnsfq1220loh2cn2cm2ttn8fdhdpt0u8m1fgj8vfk2rn61aurjg",scope:"default-m2m-resource-server-8xzfzo/read"}),I=await fetch(f,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:F});if(!I.ok)throw new Error(`Token request failed! status: ${I.status}`);const N=await I.json();ne=N.access_token;const b=N.expires_in||3600;return de=Date.now()+(b-60)*1e3,ne}catch(f){return console.error("Error obtaining JWT token:",f),ne=null,de=null,null}},et=async()=>{const f=await Ye();f!=null&&l(f)};S.useEffect(()=>{et(),console.log("scapi environment v1")},[]);const tt=async()=>{const f=JSON.parse(sessionStorage.getItem("customerData")||"{}").customerId;return(await nr(f||"")).c_interests},x=async(f,F)=>{console.log("in secondary flow",Oe);const I=await tt();if(console.log(I,"interests of customer",Oe),!!I)try{P(W=>W.map((X,ee)=>ee===W.length-1?{...X,secondaryLoading:!0}:X));const N=await V();if(!N)throw new Error("Failed to fetch token");const b=localStorage.getItem("customerNumber"),k=localStorage.getItem("isLoggedIn"),be=`https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({registered:String(k||!1),userId:String(b||new Date().getTime())}).toString()}`,we=JSON.stringify({flowId:"Q166PR519W",flowAliasId:"HKFUVLWVH2",input:{loyaltyPoints:"",productName:f,productPoints:String(F||0),interests:I}}),K=await fetch(be,{signal:AbortSignal.timeout(3e4),method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:we});if(!K.body)throw new Error("Readable stream not supported");const ve=K.body.getReader(),Se=new TextDecoder;let G="";for(;;){const{done:W,value:X}=await ve.read();if(W)break;G+=Se.decode(X,{stream:!0});const ee=G.split(`
|
|
9
|
+
`);G=ee.pop()||"";for(const oe of ee)if(oe.startsWith("data:")){const y=oe.slice(5).trim();try{const Q=JSON.parse(y);Q.index===0&&P(A=>A.map((B,se)=>se===A.length-1?{...B,secondaryResponse:Q.data,secondaryLoading:!1}:B))}catch(Q){P(A=>A.map((B,se)=>se===A.length-1?{...B,secondaryLoading:!1}:B)),console.error("Secondary flow JSON parse error:",Q)}}}}catch(N){console.error("Secondary flow error:",N)}},J=async f=>{const F=f||$.trim();if(F){w(!0),Z(""),n.current=null,r.current=null,o.current=null,s.current=null,P(I=>[...I,{query:F,response:"Thinking for what suits you best...",potentialQuestions:"",products:[],keywords:"Thinking for best products..."}]);try{const I=j,N=localStorage.getItem("customerNumber"),b=localStorage.getItem("isLoggedIn"),k=await V();if(!k)throw new Error("Failed to obtain access token");const be=`https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({registered:String(b||!1),userId:String(N||new Date().getTime())}).toString()}`,we=JSON.stringify({flowId:"MMHQKYI1NE",flowAliasId:"SZF9ZK1ATE",input:{userPrompt:F,whom:I}}),K=await fetch(be,{signal:AbortSignal.timeout(3e4),method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${k}`},body:we});if(!K.ok)throw new Error(`HTTP error! status: ${K.status}`);if(!K.body)throw new Error("Readable stream not supported");const ve=K.body.getReader(),Se=new TextDecoder;let G="",W="";for(;;){T(!0);const{done:X,value:ee}=await ve.read();if(X)break;G+=Se.decode(ee,{stream:!0});const oe=G.split(`
|
|
10
|
+
`);G=oe.pop()||"";for(const y of oe)if(y.startsWith("data:")){const Q=y.slice(5).trim();try{const A=JSON.parse(Q);A.index==1&&(W=A.data),P(B=>B.map((se,Me)=>Me===B.length-1?{...se,[A.index==0?"response":A.index==1?"keywords":A.index==2?"potentialQuestions":"end"]:A.data}:se))}catch(A){console.error("Error parsing JSON:",A)}}}re(xe(W))}catch(I){console.error("Error sending message to Tanya:",I)}finally{w(!1)}}},xe=f=>{const F=f.match(/top five relevant product or category names are: (.*)/i),b=(F?F[1]:f).split(", ").map(R=>R.replace(/\s*(Toys|Bags|Miniature|etc\.*)\s*/gi,"").trim());return[...new Set(b)].filter(Boolean).join(",")},re=async f=>{if(console.log(i==null?void 0:i.access_token,"access_token"),typeof f=="string"){console.log(f,"keywords");const F=f.split(",");for(const I of F){const N=await $t(I,i==null?void 0:i.access_token);if(T(!1),(N==null?void 0:N.length)>0&&(P(b=>b.map((k,R)=>R===b.length-1?{...k,products:[...k.products||[],{keyword:I,items:N,loading:!1}]}:k)),!n.current||r.current==null)){const b=N[0];n.current=String((b==null?void 0:b.product_name)??""),o.current=b.image.link,r.current=b.product_id;const k=typeof(b==null?void 0:b.price)=="number"?b.price:void 0;s.current=typeof k=="number"&&Number.isFinite(k)?k:null}}}else for(const F of f){const I=await $t(F,i==null?void 0:i.access_token);T(!1),(I==null?void 0:I.length)>0&&P(N=>N.map((b,k)=>k===N.length-1?{...b,products:[...b.products||[],{keyword:F,items:I,loading:!1}]}:b))}if(n.current){P(I=>I.map((N,b)=>b===I.length-1?{...N,productSnapshot:{id:r.current,name:n.current,image:o.current,price:s.current??null,points:0,quantity:1}}:N));const F=JSON.parse(sessionStorage.getItem("customerData")||"{}");(F==null?void 0:F.isGuest)==!1?(console.log("running secondary flow",Oe),x(n.current,0)):console.log("not running secondary flow",Oe)}T(!1)},Rn=async(f,F)=>{var I,N,b,k,R,be,we,K,ve,Se,G,W,X,ee,oe;C(!0);try{const y=await yn(f.id);if(!((N=(I=y==null?void 0:y.variants)==null?void 0:I[0])!=null&&N.product_id||(k=(b=y==null?void 0:y.variants)==null?void 0:b[0])!=null&&k.productId)&&!(y.type.item||y.type.bundle)){C(!1),Y.toast.error("Variants not found",{position:"bottom-right",autoClose:1e3}),console.error("No product variant found");return}const Q=[{product_id:((R=y.variants)==null?void 0:R[0].product_id)||((be=y.variants)==null?void 0:be[0].productId)||(y==null?void 0:y.id),quantity:F}];console.log(Q,"product data","app version",Oe);const A=JSON.parse(sessionStorage.getItem("customerData")||"{}"),B=A==null?void 0:A.basketId,se=!1,Me=localStorage.getItem(qe),Tt=Date.now();if(!se||!Me||Tt>=parseInt(Me)){const Hn=await mn();let{customer_token:pe}=await gn(Hn);if(pe="Bearer "+i.access_token,!pe){console.error("Failed to get customer_token");return}const zn=Tt+300*1e3;if(We(pe),localStorage.setItem(qe,zn.toString()),B){const Pt=await Pn({basketId:B,customer_token:pe});if(Pt.status===200&&Pt){const nt=await Ge(B,Q,pe);((we=nt==null?void 0:nt.product_items)==null?void 0:we.length)>0&&(Y.toast.success("Added to cart",{position:"bottom-right",autoClose:3e3,hideProgressBar:!1,closeOnClick:!0,pauseOnHover:!0,draggable:!0}),Ce(B),C(!1));return}}const Vn={productItems:[{productId:((K=y.variants)==null?void 0:K[0].product_id)||((ve=y.variants)==null?void 0:ve[0].productId)||(y==null?void 0:y.id),quantity:1}]},_=await Tn(pe,Vn);if(console.log(_,_==null?void 0:_.basket_id,_==null?void 0:_.basketId,"the basket response"),!(_!=null&&_.basket_id||!(_!=null&&_.basketId))){C(!1),console.error("Failed to create basket");return}_e((_==null?void 0:_.basket_id)||(_==null?void 0:_.basketId));const je=await Ge((_==null?void 0:_.basket_id)||(_==null?void 0:_.basketId),Q,pe);(((Se=je==null?void 0:je.product_items)==null?void 0:Se.length)>0||((G=je==null?void 0:je.productItems)==null?void 0:G.length)>0)&&Y.toast.success("Added to cart",{position:"bottom-right",autoClose:3e3,hideProgressBar:!1,closeOnClick:!0,pauseOnHover:!0,draggable:!0}),Ce(_.basket_id||(_==null?void 0:_.basketId))}}catch(y){C(!1),console.error("Error adding to cart:",y),Y.toast.error("Failed to add product to cart",{position:"bottom-right",autoClose:3e3}),((W=y==null?void 0:y.response)==null?void 0:W.status)===404||((X=y==null?void 0:y.response)==null?void 0:X.status)===401?(((ee=y==null?void 0:y.response)==null?void 0:ee.status)===404&&_e(null),((oe=y==null?void 0:y.response)==null?void 0:oe.status)===401&&(_e(null),We(null))):(console.error("Failed to add product to basket:",y.message),Y.toast.error("Failed to add product to cart",{position:"bottom-right",autoClose:3e3}))}finally{Ce()}C(!1)};return a.jsx("div",{className:"relative flex justify-center",children:a.jsxs(er,{open:c,onOpenChange:u,children:[a.jsx(tr,{onClick:()=>u(!0),style:{},className:"flex items-center rounded-lg cursor-pointer hover:opacity-90 transition-opacity",children:a.jsx("div",{className:"flex flex-col p-[5px]",children:a.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsxs("g",{clipPath:"url(#clip0_958_585)",children:[a.jsx("path",{d:"M30.0002 5C31.7683 5 33.464 5.70238 34.7142 6.95262C35.9644 8.20286 36.6668 9.89856 36.6668 11.6667V25C36.6668 26.7681 35.9644 28.4638 34.7142 29.714C33.464 30.9643 31.7683 31.6667 30.0002 31.6667H25.6902L21.1785 36.1783C20.8915 36.4653 20.5097 36.6377 20.1046 36.6631C19.6996 36.6886 19.2992 36.5654 18.9785 36.3167L18.8218 36.1783L14.3085 31.6667H10.0002C8.28976 31.6667 6.64478 31.0093 5.40548 29.8305C4.16617 28.6516 3.42735 27.0416 3.34183 25.3333L3.3335 25V11.6667C3.3335 9.89856 4.03588 8.20286 5.28612 6.95262C6.53636 5.70238 8.23205 5 10.0002 5H30.0002Z",fill:"url(#paint0_linear_958_585)"}),a.jsx("path",{d:"M28.3335 15.6511V11.6667C28.3335 11.6667 22.2774 12.6042 20.1148 15.4167C17.9521 18.2292 18.6644 26.6667 18.6644 26.6667H22.5321C22.5321 26.6667 22.0614 18.9323 23.4989 17.2917C24.9364 15.6511 28.3335 15.6511 28.3335 15.6511Z",fill:"white"}),a.jsx("path",{d:"M13.3335 11.6667H19.6184V15.4167H13.3335V11.6667Z",fill:"white"})]}),a.jsxs("defs",{children:[a.jsxs("linearGradient",{id:"paint0_linear_958_585",x1:"20.0002",y1:"5",x2:"35.0002",y2:"30",gradientUnits:"userSpaceOnUse",children:[a.jsx("stop",{stopColor:"#452697"}),a.jsx("stop",{offset:"1",stopColor:"#7C5BFF"})]}),a.jsx("clipPath",{id:"clip0_958_585",children:a.jsx("rect",{width:"40",height:"40",fill:"white"})})]})]})})}),h&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-40 bg-black/30",onClick:()=>u(!1)}),a.jsxs("div",{className:`
|
|
11
11
|
fixed z-50 h-screen w-[100vw] sm:w-[80vw] md:w-[770px] border-0 bg-white lg:rounded-l-xl overflow-hidden flex flex-col shadow-[0px_4px_10px_0px_#5F499840]
|
|
12
12
|
top-0 right-0
|
|
13
13
|
transition-transform duration-300 ease-in-out
|
|
14
14
|
lg:transform
|
|
15
|
-
${
|
|
15
|
+
${d?"lg:translate-x-0":"lg:translate-x-full"}
|
|
16
16
|
// For mobile: animate from bottom
|
|
17
|
-
${
|
|
17
|
+
${d?"translate-y-0":"translate-y-full"}
|
|
18
18
|
lg:translate-y-0
|
|
19
|
-
`,style:{background:"linear-gradient(170.1deg, #FFFFFF 60.03%, #E3DEEF 99.59%)"},children:[r.jsxs("div",{className:"flex justify-between p-3 bg-[#FFFFFF] border border-b-1 border-[#E5E5E5] ",children:[r.jsx("div",{style:{display:"flex",color:_.tanyaThemeContrastColor,alignItems:"center",gap:"0.5rem"},children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.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:[r.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 15 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.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"}),r.jsx("path",{d:"M0 0.5H6.28488V4.25H0V0.5Z",fill:"white"})]}),r.jsx("p",{className:"text-[#FFFFFF] font-nunitoSans font-semibold",children:"TANYA"})]}),r.jsxs("p",{className:"text-[#5B5B5B] font-nunitoSans font-semibold",style:{fontStyle:"italic"},children:[" ","Your AI shopping assistant !"," "]})]})}),r.jsx("div",{style:{display:"flex",alignItems:"center",gap:"1.25rem",margin:"0.75rem"},children:r.jsx("button",{onClick:()=>d(!1),children:r.jsxs("svg",{width:"24",height:"25",viewBox:"0 0 24 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsxs("g",{clipPath:"url(#clip0_501_6036)",children:[r.jsx("path",{d:"M18 6.5L6 18.5",stroke:"#555555",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M6 6.5L18 18.5",stroke:"#555555",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),r.jsx("defs",{children:r.jsx("clipPath",{id:"clip0_501_6036",children:r.jsx("rect",{width:"24",height:"24",fill:"white",transform:"translate(0 0.5)"})})})]})})})]}),r.jsxs("div",{className:"flex h-full md:flex-row lg:flex-row",children:[r.jsxs("div",{className:`flex flex-col h-full ${$?"lg:w-2/3 w-full":"w-full"}`,children:[r.jsxs("div",{ref:fe,className:"overflow-y-auto pr-5 pb-2 space-y-4 hide-scrollbar flex-grow mb-24",children:[(_==null?void 0:_.whomRequired)&&r.jsxs("div",{className:"mx-3 p-3 rounded-2xl bg-[#FFFFFF]",children:[r.jsx("div",{className:"flex gap-2 bg-[#FFFFFF]",children:r.jsx("p",{className:"font-bold font-nunitoSans text-[#494949]",children:"Is this for you or someone else?"})}),r.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(u=>r.jsx("button",{onClick:()=>Me(u),className:"px-2 py-2 font-semibold text-xs text-[#18181B] bg-[#F3F3F3] rounded-2xl",style:{backgroundColor:S===t[u]?"#FFFFFF":"#F3F3F3",borderColor:S===t[u]?"#BBB3DD":""},children:u},u))})]}),R.map((u,T)=>{var I,N;return r.jsxs("div",{children:[r.jsx("div",{className:"flex justify-end",children:r.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:u.query})}),u.response&&u.response.includes("Thinking")?r.jsx("div",{children:r.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:Re(u.response)}})}):r.jsx("div",{children:r.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:Re(u.response)}})}),D&&!u.response.includes("Thinking")&&((I=u.products)==null?void 0:I.length)==0&&r.jsx("div",{children:r.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"})}),(u==null?void 0:u.products)&&((N=u==null?void 0:u.products)==null?void 0:N.length)>0&&r.jsx(is,{chat:u.products,storeDetails:_}),u.potentialQuestions.length>0&&r.jsxs("div",{className:"my-2 px-4 text-sm text-gray-700",children:[r.jsx("p",{className:"font-nunitoSans font-bold text-sm text-[#494949]",style:{color:_.themeDarkColor},children:"Why not explore these inquiries..."}),u.potentialQuestions.split(",").map((y,k)=>r.jsx("button",{className:`cursor-pointer font-nunitoSans font-semibold text-[#232323] border bg-[#804C9E0D] border-${_.themeDarkColor} m-1 rounded-xl px-2 py-1`,onClick:()=>z(y),style:{backgroundColor:_.tanyaThemeColorLight},children:y},k))]}),u.secondaryLoading&&r.jsx("div",{className:"mt-3 mb-4 px-4",children:r.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:[r.jsxs("div",{className:"flex gap-1",children:[r.jsx("div",{className:"tanya-sparkle tanya-sparkle-1",children:"✨"}),r.jsx("div",{className:"tanya-sparkle tanya-sparkle-2",children:"✨"}),r.jsx("div",{className:"tanya-sparkle tanya-sparkle-3",children:"✨"})]}),r.jsx("div",{className:"tanya-shimmer"}),r.jsx("p",{className:"font-semibold tanya-pulse",style:{color:_.themeDarkColor},children:"I’ve found a special surprise crafted just for you… hang on a sec!"}),r.jsx("p",{className:"tanya-dots mt-1",style:{color:_.themeDarkColor},children:"• • •"})]})}),u.secondaryResponse&&r.jsx(r.Fragment,{children:r.jsxs("div",{className:"mt-3 mb-8 px-4 bg-indigo-300 rounded-tr-[5px]",children:[r.jsx("div",{className:"text-sm text-[#232323] bg-[#FFFFFF] px-7 py-4 rounded-br-xl rounded-bl-2xl w-full",style:{backgroundColor:_.tanyaThemeColorLight},dangerouslySetInnerHTML:{__html:Re(u.secondaryResponse)}}),u.productSnapshot&&r.jsx("div",{className:"mt-4 w-full",children:r.jsxs("div",{className:"flex gap-4 items-stretch rounded-2xl p-4",style:{backgroundColor:_.tanyaThemeColorLight},children:[r.jsx("div",{className:"flex-shrink-0 rounded-xl overflow-hidden border",style:{width:112,height:112,borderColor:"#eee"},children:u.productSnapshot.image?r.jsx("img",{src:u.productSnapshot.image,alt:u.productSnapshot.name,className:"w-full h-full object-cover"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs text-gray-500",children:"No Image"})}),r.jsxs("div",{className:"flex flex-col flex-1 justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold text-[15px] leading-snug",children:u.productSnapshot.name}),r.jsx("p",{className:"mt-1 text-[14px] font-medium",children:u.productSnapshot.price!=null?new Intl.NumberFormat(void 0,{style:"currency",currency:(_==null?void 0:_.currency)||"USD"}).format(u.productSnapshot.price):""}),u.productSnapshot.points>0&&r.jsxs("p",{className:"mt-1 text-xs opacity-80",children:["You will earn"," ",r.jsxs("strong",{children:[u.productSnapshot.points," ","points"]})]})]}),r.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[r.jsxs("div",{className:"flex items-center border rounded-full overflow-hidden",children:[r.jsx("button",{className:"px-3 py-1 text-sm",onClick:()=>E(y=>y.map((k,B)=>B===T&&k.productSnapshot?{...k,productSnapshot:{...k.productSnapshot,quantity:Math.max(1,k.productSnapshot.quantity-1)}}:k)),style:{background:"transparent",color:_.themeDarkColor},children:"−"}),r.jsx("div",{className:"px-3 py-1 text-sm select-none",children:u.productSnapshot.quantity}),r.jsx("button",{className:"px-3 py-1 text-sm",onClick:()=>E(y=>y.map((k,B)=>B===T&&k.productSnapshot?{...k,productSnapshot:{...k.productSnapshot,quantity:k.productSnapshot.quantity+1}}:k)),style:{background:"transparent",color:_.themeDarkColor},children:"+"})]}),r.jsx("button",{onClick:()=>{Ht(q(u.productSnapshot),u.productSnapshot.quantity)},disabled:v,className:"px-4 py-2 rounded-full font-medium",style:{background:_.tanyaThemeColor,color:(_==null?void 0:_.tanyaThemeContrastColor)||"#fff",opacity:v?.8:1},children:v?"Adding...":"Add to cart"})]})]})]})})]})}),r.jsx("div",{className:"mb-20"})]},T)})]}),r.jsx("div",{className:"flex flex-col gap-2 sticky bottom-0 left-0 right-0 bg-[#E3DEEF] z-50 px-4 py-2",children:r.jsx("div",{className:"p-[1px] rounded-xl",style:{background:"linear-gradient(180deg, #B09FFF 0%, #8D79F6 100%)"},children:r.jsxs("div",{className:"flex items-center bg-[#FFFFFF] flex-1 rounded-xl px-2 py-1",children:[r.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:A,autoFocus:!0,onChange:u=>Q(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!h&&z()}}),r.jsx("button",{type:"submit",disabled:h,className:"p-3",onClick:()=>z(),children:h?r.jsx("div",{className:"p-3 animate-spin rounded-full h-3 w-3 border-b-2",style:{borderBottom:"2px solid",color:_.tanyaThemeColor}}):r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:r.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"})})})]})})})]}),r.jsx(cs,{})]})]})]})]})})};exports.TanyaChatbot=ls;
|
|
19
|
+
`,style:{background:"linear-gradient(170.1deg, #FFFFFF 60.03%, #E3DEEF 99.59%)"},children:[a.jsxs("div",{className:"flex justify-between p-3 bg-[#FFFFFF] border border-b-1 border-[#E5E5E5] ",children:[a.jsx("div",{style:{display:"flex",color:E.tanyaThemeContrastColor,alignItems:"center",gap:"0.5rem"},children:a.jsxs("div",{className:"flex flex-col gap-1",children:[a.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:[a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 15 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.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"}),a.jsx("path",{d:"M0 0.5H6.28488V4.25H0V0.5Z",fill:"white"})]}),a.jsx("p",{className:"text-[#FFFFFF] font-nunitoSans font-semibold",children:"TANYA"})]}),a.jsxs("p",{className:"text-[#5B5B5B] font-nunitoSans font-semibold",style:{fontStyle:"italic"},children:[" ","Your AI shopping assistant !"," "]})]})}),a.jsx("div",{style:{display:"flex",alignItems:"center",gap:"1.25rem",margin:"0.75rem"},children:a.jsx("button",{onClick:()=>u(!1),children:a.jsxs("svg",{width:"24",height:"25",viewBox:"0 0 24 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[a.jsxs("g",{clipPath:"url(#clip0_501_6036)",children:[a.jsx("path",{d:"M18 6.5L6 18.5",stroke:"#555555",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),a.jsx("path",{d:"M6 6.5L18 18.5",stroke:"#555555",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),a.jsx("defs",{children:a.jsx("clipPath",{id:"clip0_501_6036",children:a.jsx("rect",{width:"24",height:"24",fill:"white",transform:"translate(0 0.5)"})})})]})})})]}),a.jsxs("div",{className:"flex h-full md:flex-row lg:flex-row",children:[a.jsxs("div",{className:`flex flex-col h-full ${O?"lg:w-2/3 w-full":"w-full"}`,children:[a.jsxs("div",{ref:ye,className:"overflow-y-auto pr-5 pb-2 space-y-4 hide-scrollbar flex-grow mb-24",children:[(E==null?void 0:E.whomRequired)&&a.jsxs("div",{className:"mx-3 p-3 rounded-2xl bg-[#FFFFFF]",children:[a.jsx("div",{className:"flex gap-2 bg-[#FFFFFF]",children:a.jsx("p",{className:"font-bold font-nunitoSans text-[#494949]",children:"Is this for you or someone else?"})}),a.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(f=>a.jsx("button",{onClick:()=>Xe(f),className:"px-2 py-2 font-semibold text-xs text-[#18181B] bg-[#F3F3F3] rounded-2xl",style:{backgroundColor:j===t[f]?"#FFFFFF":"#F3F3F3",borderColor:j===t[f]?"#BBB3DD":""},children:f},f))})]}),z.map((f,F)=>{var I,N;return a.jsxs("div",{children:[a.jsx("div",{className:"flex justify-end",children:a.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:f.query})}),f.response&&f.response.includes("Thinking")?a.jsx("div",{children:a.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:rt(f.response)}})}):a.jsx("div",{children:a.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:rt(f.response)}})}),U&&!f.response.includes("Thinking")&&((I=f.products)==null?void 0:I.length)==0&&a.jsx("div",{children:a.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"})}),(f==null?void 0:f.products)&&((N=f==null?void 0:f.products)==null?void 0:N.length)>0&&a.jsx(co,{chat:f.products,storeDetails:E}),f.potentialQuestions.length>0&&a.jsxs("div",{className:"my-2 px-4 text-sm text-gray-700",children:[a.jsx("p",{className:"font-nunitoSans font-bold text-sm text-[#494949]",style:{color:E.themeDarkColor},children:"Why not explore these inquiries..."}),f.potentialQuestions.split(",").map((b,k)=>a.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:()=>J(b),style:{backgroundColor:E.tanyaThemeColorLight},children:b},k))]}),f.secondaryLoading&&a.jsx("div",{className:"mt-3 mb-4 px-4",children:a.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:[a.jsxs("div",{className:"flex gap-1",children:[a.jsx("div",{className:"tanya-sparkle tanya-sparkle-1",children:"✨"}),a.jsx("div",{className:"tanya-sparkle tanya-sparkle-2",children:"✨"}),a.jsx("div",{className:"tanya-sparkle tanya-sparkle-3",children:"✨"})]}),a.jsx("div",{className:"tanya-shimmer"}),a.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!"}),a.jsx("p",{className:"tanya-dots mt-1",style:{color:E.themeDarkColor},children:"• • •"})]})}),f.secondaryResponse&&a.jsx(a.Fragment,{children:a.jsxs("div",{className:"mt-3 mb-8 px-4 bg-indigo-300 rounded-tr-[5px]",children:[a.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:rt(f.secondaryResponse)}}),f.productSnapshot&&a.jsx("div",{className:"mt-4 w-full",children:a.jsxs("div",{className:"flex gap-4 items-stretch rounded-2xl p-4",style:{backgroundColor:E.tanyaThemeColorLight},children:[a.jsx("div",{className:"flex-shrink-0 rounded-xl overflow-hidden border",style:{width:112,height:112,borderColor:"#eee"},children:f.productSnapshot.image?a.jsx("img",{src:f.productSnapshot.image,alt:f.productSnapshot.name,className:"w-full h-full object-cover"}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs text-gray-500",children:"No Image"})}),a.jsxs("div",{className:"flex flex-col flex-1 justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-semibold text-[15px] leading-snug",children:f.productSnapshot.name}),a.jsx("p",{className:"mt-1 text-[14px] font-medium",children:f.productSnapshot.price!=null?new Intl.NumberFormat(void 0,{style:"currency",currency:(E==null?void 0:E.currency)||"USD"}).format(f.productSnapshot.price):""}),f.productSnapshot.points>0&&a.jsxs("p",{className:"mt-1 text-xs opacity-80",children:["You will earn"," ",a.jsxs("strong",{children:[f.productSnapshot.points," ","points"]})]})]}),a.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center border rounded-full overflow-hidden",children:[a.jsx("button",{className:"px-3 py-1 text-sm",onClick:()=>P(b=>b.map((k,R)=>R===F&&k.productSnapshot?{...k,productSnapshot:{...k.productSnapshot,quantity:Math.max(1,k.productSnapshot.quantity-1)}}:k)),style:{background:"transparent",color:E.themeDarkColor},children:"−"}),a.jsx("div",{className:"px-3 py-1 text-sm select-none",children:f.productSnapshot.quantity}),a.jsx("button",{className:"px-3 py-1 text-sm",onClick:()=>P(b=>b.map((k,R)=>R===F&&k.productSnapshot?{...k,productSnapshot:{...k.productSnapshot,quantity:k.productSnapshot.quantity+1}}:k)),style:{background:"transparent",color:E.themeDarkColor},children:"+"})]}),a.jsx("button",{onClick:()=>{Rn(H(f.productSnapshot),f.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"})]})]})]})})]})}),a.jsx("div",{className:"mb-20"})]},F)})]}),a.jsx("div",{className:"flex flex-col gap-2 sticky bottom-0 left-0 right-0 bg-[#E3DEEF] z-50 px-4 py-2",children:a.jsx("div",{className:"p-[1px] rounded-xl",style:{background:"linear-gradient(180deg, #B09FFF 0%, #8D79F6 100%)"},children:a.jsxs("div",{className:"flex items-center bg-[#FFFFFF] flex-1 rounded-xl px-2 py-1",children:[a.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:f=>Z(f.target.value),onKeyDown:f=>{f.key==="Enter"&&!g&&J()}}),a.jsx("button",{type:"submit",disabled:g,className:"p-3",onClick:()=>J(),children:g?a.jsx("div",{className:"p-3 animate-spin rounded-full h-3 w-3 border-b-2",style:{borderBottom:"2px solid",color:E.tanyaThemeColor}}):a.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:a.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"})})})]})})})]}),a.jsx(uo,{})]})]})]})]})})};var mt=function(e,t){return mt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},mt(e,t)};function po(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");mt(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var ie=function(){return ie=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},ie.apply(this,arguments)};function ho(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}var it="Invariant Violation",en=Object.setPrototypeOf,mo=en===void 0?function(e,t){return e.__proto__=t,e}:en,On=(function(e){po(t,e);function t(n){n===void 0&&(n=it);var r=e.call(this,typeof n=="number"?it+": "+n+" (see https://github.com/apollographql/invariant-packages)":n)||this;return r.framesToPop=1,r.name=it,mo(r,t.prototype),r}return t})(Error);function he(e,t){if(!e)throw new On(t)}var $n=["debug","log","warn","error","silent"],go=$n.indexOf("log");function Ue(e){return function(){if($n.indexOf(e)>=go){var t=console[e]||console.log;return t.apply(console,arguments)}}}(function(e){e.debug=Ue("debug"),e.log=Ue("log"),e.warn=Ue("warn"),e.error=Ue("error")})(he||(he={}));var An="3.14.0";function ke(e){try{return e()}catch{}}const gt=ke(function(){return globalThis})||ke(function(){return window})||ke(function(){return self})||ke(function(){return global})||ke(function(){return ke.constructor("return this")()});var tn=new Map;function yo(e){var t=tn.get(e)||1;return tn.set(e,t+1),"".concat(e,":").concat(t,":").concat(Math.random().toString(36).slice(2))}function xo(e,t){var n=yo("stringifyForDisplay");return JSON.stringify(e,function(r,o){return o===void 0?n:o},t).split(JSON.stringify(n)).join("<undefined>")}function Be(e){return function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];if(typeof t=="number"){var o=t;t=kt(o),t||(t=It(o,n),n=[])}e.apply(void 0,[t].concat(n))}}var at=Object.assign(function(t,n){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];t||he(t,kt(n,r)||It(n,r))},{debug:Be(he.debug),log:Be(he.log),warn:Be(he.warn),error:Be(he.error)});function Ln(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return new On(kt(e,t)||It(e,t))}var nn=Symbol.for("ApolloErrorMessageHandler_"+An);function Dn(e){if(typeof e=="string")return e;try{return xo(e,2).slice(0,1e3)}catch{return"<non-serializable>"}}function kt(e,t){if(t===void 0&&(t=[]),!!e)return gt[nn]&>[nn](e,t.map(Dn))}function It(e,t){if(t===void 0&&(t=[]),!!e)return"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({version:An,message:e,args:t.map(Dn)})))}function bo(e){return e.definitions.filter(function(t){return t.kind==="OperationDefinition"&&!!t.name}).map(function(t){return t.name.value})[0]||null}let D=null;const rn={};let wo=1;const vo=()=>class{constructor(){this.id=["slot",wo++,Date.now(),Math.random().toString(36).slice(2)].join(":")}hasValue(){for(let t=D;t;t=t.parent)if(this.id in t.slots){const n=t.slots[this.id];if(n===rn)break;return t!==D&&(D.slots[this.id]=n),!0}return D&&(D.slots[this.id]=rn),!1}getValue(){if(this.hasValue())return D.slots[this.id]}withValue(t,n,r,o){const s={__proto__:null,[this.id]:t},i=D;D={parent:i,slots:s};try{return n.apply(o,r)}finally{D=i}}static bind(t){const n=D;return function(){const r=D;try{return D=n,t.apply(this,arguments)}finally{D=r}}}static noContext(t,n,r){if(D){const o=D;try{return D=null,t.apply(r,n)}finally{D=o}}else return t.apply(r,n)}};function on(e){try{return e()}catch{}}const ct="@wry/context:Slot",So=on(()=>globalThis)||on(()=>global)||Object.create(null),sn=So,Ct=sn[ct]||Array[ct]||(function(e){try{Object.defineProperty(sn,ct,{value:e,enumerable:!1,writable:!1,configurable:!0})}finally{return e}})(vo()),{bind:Go,noContext:Wo}=Ct;new Ct;function jo(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=ko(e))||t){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}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 ko(e,t){if(e){if(typeof e=="string")return an(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return an(e,t)}}function an(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function cn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _t(e,t,n){return t&&cn(e.prototype,t),n&&cn(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var Nt=function(){return typeof Symbol=="function"},Ft=function(e){return Nt()&&!!Symbol[e]},Et=function(e){return Ft(e)?Symbol[e]:"@@"+e};Nt()&&!Ft("observable")&&(Symbol.observable=Symbol("observable"));var Io=Et("iterator"),yt=Et("observable"),qn=Et("species");function Qe(e,t){var n=e[t];if(n!=null){if(typeof n!="function")throw new TypeError(n+" is not a function");return n}}function $e(e){var t=e.constructor;return t!==void 0&&(t=t[qn],t===null&&(t=void 0)),t!==void 0?t:q}function Co(e){return e instanceof q}function Fe(e){Fe.log?Fe.log(e):setTimeout(function(){throw e})}function Ve(e){Promise.resolve().then(function(){try{e()}catch(t){Fe(t)}})}function Mn(e){var t=e._cleanup;if(t!==void 0&&(e._cleanup=void 0,!!t))try{if(typeof t=="function")t();else{var n=Qe(t,"unsubscribe");n&&n.call(t)}}catch(r){Fe(r)}}function xt(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function _o(e){var t=e._queue;if(t){e._queue=void 0,e._state="ready";for(var n=0;n<t.length&&(Un(e,t[n].type,t[n].value),e._state!=="closed");++n);}}function Un(e,t,n){e._state="running";var r=e._observer;try{var o=Qe(r,t);switch(t){case"next":o&&o.call(r,n);break;case"error":if(xt(e),o)o.call(r,n);else throw n;break;case"complete":xt(e),o&&o.call(r);break}}catch(s){Fe(s)}e._state==="closed"?Mn(e):e._state==="running"&&(e._state="ready")}function lt(e,t,n){if(e._state!=="closed"){if(e._state==="buffering"){e._queue.push({type:t,value:n});return}if(e._state!=="ready"){e._state="buffering",e._queue=[{type:t,value:n}],Ve(function(){return _o(e)});return}Un(e,t,n)}}var No=(function(){function e(n,r){this._cleanup=void 0,this._observer=n,this._queue=void 0,this._state="initializing";var o=new Fo(this);try{this._cleanup=r.call(void 0,o)}catch(s){o.error(s)}this._state==="initializing"&&(this._state="ready")}var t=e.prototype;return t.unsubscribe=function(){this._state!=="closed"&&(xt(this),Mn(this))},_t(e,[{key:"closed",get:function(){return this._state==="closed"}}]),e})(),Fo=(function(){function e(n){this._subscription=n}var t=e.prototype;return t.next=function(r){lt(this._subscription,"next",r)},t.error=function(r){lt(this._subscription,"error",r)},t.complete=function(){lt(this._subscription,"complete")},_t(e,[{key:"closed",get:function(){return this._subscription._state==="closed"}}]),e})(),q=(function(){function e(n){if(!(this instanceof e))throw new TypeError("Observable cannot be called as a function");if(typeof n!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=n}var t=e.prototype;return t.subscribe=function(r){return(typeof r!="object"||r===null)&&(r={next:r,error:arguments[1],complete:arguments[2]}),new No(r,this._subscriber)},t.forEach=function(r){var o=this;return new Promise(function(s,i){if(typeof r!="function"){i(new TypeError(r+" is not a function"));return}function l(){c.unsubscribe(),s()}var c=o.subscribe({next:function(u){try{r(u,l)}catch(d){i(d),c.unsubscribe()}},error:i,complete:s})})},t.map=function(r){var o=this;if(typeof r!="function")throw new TypeError(r+" is not a function");var s=$e(this);return new s(function(i){return o.subscribe({next:function(l){try{l=r(l)}catch(c){return i.error(c)}i.next(l)},error:function(l){i.error(l)},complete:function(){i.complete()}})})},t.filter=function(r){var o=this;if(typeof r!="function")throw new TypeError(r+" is not a function");var s=$e(this);return new s(function(i){return o.subscribe({next:function(l){try{if(!r(l))return}catch(c){return i.error(c)}i.next(l)},error:function(l){i.error(l)},complete:function(){i.complete()}})})},t.reduce=function(r){var o=this;if(typeof r!="function")throw new TypeError(r+" is not a function");var s=$e(this),i=arguments.length>1,l=!1,c=arguments[1],u=c;return new s(function(d){return o.subscribe({next:function(p){var h=!l;if(l=!0,!h||i)try{u=r(u,p)}catch(m){return d.error(m)}else u=p},error:function(p){d.error(p)},complete:function(){if(!l&&!i)return d.error(new TypeError("Cannot reduce an empty sequence"));d.next(u),d.complete()}})})},t.concat=function(){for(var r=this,o=arguments.length,s=new Array(o),i=0;i<o;i++)s[i]=arguments[i];var l=$e(this);return new l(function(c){var u,d=0;function p(h){u=h.subscribe({next:function(m){c.next(m)},error:function(m){c.error(m)},complete:function(){d===s.length?(u=void 0,c.complete()):p(l.from(s[d++]))}})}return p(r),function(){u&&(u.unsubscribe(),u=void 0)}})},t.flatMap=function(r){var o=this;if(typeof r!="function")throw new TypeError(r+" is not a function");var s=$e(this);return new s(function(i){var l=[],c=o.subscribe({next:function(d){if(r)try{d=r(d)}catch(h){return i.error(h)}var p=s.from(d).subscribe({next:function(h){i.next(h)},error:function(h){i.error(h)},complete:function(){var h=l.indexOf(p);h>=0&&l.splice(h,1),u()}});l.push(p)},error:function(d){i.error(d)},complete:function(){u()}});function u(){c.closed&&l.length===0&&i.complete()}return function(){l.forEach(function(d){return d.unsubscribe()}),c.unsubscribe()}})},t[yt]=function(){return this},e.from=function(r){var o=typeof this=="function"?this:e;if(r==null)throw new TypeError(r+" is not an object");var s=Qe(r,yt);if(s){var i=s.call(r);if(Object(i)!==i)throw new TypeError(i+" is not an object");return Co(i)&&i.constructor===o?i:new o(function(l){return i.subscribe(l)})}if(Ft("iterator")&&(s=Qe(r,Io),s))return new o(function(l){Ve(function(){if(!l.closed){for(var c=jo(s.call(r)),u;!(u=c()).done;){var d=u.value;if(l.next(d),l.closed)return}l.complete()}})});if(Array.isArray(r))return new o(function(l){Ve(function(){if(!l.closed){for(var c=0;c<r.length;++c)if(l.next(r[c]),l.closed)return;l.complete()}})});throw new TypeError(r+" is not observable")},e.of=function(){for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];var i=typeof this=="function"?this:e;return new i(function(l){Ve(function(){if(!l.closed){for(var c=0;c<o.length;++c)if(l.next(o[c]),l.closed)return;l.complete()}})})},_t(e,null,[{key:qn,get:function(){return this}}]),e})();Nt()&&Object.defineProperty(q,Symbol("extensions"),{value:{symbol:yt,hostReportError:Fe},configurable:!0});function Eo(e){var t,n=e.Symbol;if(typeof n=="function")if(n.observable)t=n.observable;else{typeof n.for=="function"?t=n.for("https://github.com/benlesh/symbol-observable"):t=n("https://github.com/benlesh/symbol-observable");try{n.observable=t}catch{}}else t="@@observable";return t}var Ie;typeof self<"u"?Ie=self:typeof window<"u"?Ie=window:typeof global<"u"?Ie=global:typeof module<"u"?Ie=module:Ie=Function("return this")();Eo(Ie);var ln=q.prototype,un="@@observable";ln[un]||(ln[un]=function(){return this});function To(e){for(var t=["query","operationName","variables","extensions","context"],n=0,r=Object.keys(e);n<r.length;n++){var o=r[n];if(t.indexOf(o)<0)throw Ln(58,o)}return e}function Po(e,t){var n=ie({},e),r=function(s){typeof s=="function"?n=ie(ie({},n),s(n)):n=ie(ie({},n),s)},o=function(){return ie({},n)};return Object.defineProperty(t,"setContext",{enumerable:!1,value:r}),Object.defineProperty(t,"getContext",{enumerable:!1,value:o}),t}function Oo(e){var t={variables:e.variables||{},extensions:e.extensions||{},operationName:e.operationName,query:e.query};return t.operationName||(t.operationName=typeof t.query!="string"?bo(t.query)||void 0:""),t}var $o=Symbol.for("apollo.deprecations"),Ao=gt,Lo=new Ct;function Do(e){return Ao[$o]||(Lo.getValue()||[]).includes(e)}function qo(e,t){Do(e)||t()}function fn(e,t){return t?t(e):q.of()}function Ae(e){return typeof e=="function"?new Bn(e):e}function Re(e){return e.request.length<=1}var Bn=(function(){function e(t){t&&(this.request=t)}return e.empty=function(){return new e(function(){return q.of()})},e.from=function(t){return t.length===0?e.empty():t.map(Ae).reduce(function(n,r){return n.concat(r)})},e.split=function(t,n,r){var o=Ae(n),s=Ae(r||new e(fn)),i;return Re(o)&&Re(s)?i=new e(function(l){return t(l)?o.request(l)||q.of():s.request(l)||q.of()}):i=new e(function(l,c){return t(l)?o.request(l,c)||q.of():s.request(l,c)||q.of()}),Object.assign(i,{left:o,right:s})},e.execute=function(t,n){return t.request(Po(n.context,Oo(To(n))))||q.of()},e.concat=function(t,n){var r=Ae(t);if(Re(r))return globalThis.__DEV__!==!1&&at.warn(47,r),r;var o=Ae(n),s;return Re(o)?s=new e(function(i){return r.request(i,function(l){return o.request(l)||q.of()})||q.of()}):s=new e(function(i,l){return r.request(i,function(c){return o.request(c,l)||q.of()})||q.of()}),Object.assign(s,{left:r,right:o})},e.prototype.split=function(t,n,r){return this.concat(e.split(t,n,r||new e(fn)))},e.prototype.concat=function(t){return e.concat(this,t)},e.prototype.request=function(t,n){throw Ln(48)},e.prototype.onError=function(t,n){if(globalThis.__DEV__!==!1&&qo("onError",function(){globalThis.__DEV__!==!1&&at.warn(49)}),n&&n.error)return n.error(t),!1;throw t},e.prototype.setOnError=function(t){return globalThis.__DEV__!==!1&&globalThis.__DEV__!==!1&&at.warn(50),this.onError=t,this},e})();function Mo(e){return new Bn(function(t,n){var r=ho(t,[]);return new q(function(o){var s,i=!1;return Promise.resolve(r).then(function(l){return e(l,t.getContext())}).then(t.setContext).then(function(){i||(s=n(t).subscribe({next:o.next.bind(o),error:o.error.bind(o),complete:o.complete.bind(o)}))}).catch(o.error.bind(o)),function(){i=!0,s&&s.unsubscribe()}})})}const Uo=async()=>{const e="https://auth.australia-southeast1.gcp.commercetools.com/oauth/token",r="Basic "+btoa(encodeURIComponent("tfegsSBVOYnR7e_yE-AjxVVN")+":"+encodeURIComponent("pyKWgHuTxuMwDygh9JH1ehLEaLvAhBo4"));try{const o=await M.post(e,new URLSearchParams({grant_type:"client_credentials"}),{headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:r}});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}},Bo="https://api.australia-southeast1.gcp.commercetools.com/kt-demo/graphql",Ro=Je.createHttpLink({uri:`${Bo}`}),Ho=Mo(async(e,{headers:t})=>{const n=await Uo();return{headers:{...t,authorization:`Bearer ${n}`}}}),zo=new Je.ApolloClient({link:Ho.concat(Ro),cache:new Je.InMemoryCache,defaultOptions:{watchQuery:{fetchPolicy:"cache-and-network"}}}),Vo=()=>a.jsx(Je.ApolloProvider,{client:zo,children:a.jsx(Xn,{children:a.jsx(fo,{})})});exports.TanyaChatbot=Vo;
|
|
20
21
|
//# sourceMappingURL=tanya-chatbot.cjs.js.map
|