tanya-chatbot 0.10.2 → 0.10.3

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.
@@ -15,6 +15,6 @@
15
15
  `,style:{background:"linear-gradient(170.1deg, #FFFFFF 60.03%, #E3DEEF 99.59%)"},children:[n.jsxs("div",{className:"flex justify-between p-3 bg-[#FFFFFF] border border-b-1 border-[#E5E5E5] ",children:[n.jsx("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:n.jsxs("div",{className:"flex flex-col gap-1",children:[n.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:[n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 15 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.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"}),n.jsx("path",{d:"M0 0.5H6.28488V4.25H0V0.5Z",fill:"white"})]}),n.jsx("p",{className:"text-[#FFFFFF] font-nunitoSans font-semibold",children:"TANYA"})]}),n.jsxs("p",{className:"text-[#5B5B5B] font-nunitoSans font-semibold",style:{fontStyle:"italic"},children:[" ","Your AI shopping assistant !"," "]})]})}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:"1.25rem",margin:"0.75rem"},children:n.jsx("button",{onClick:()=>y(!1),children:n.jsxs("svg",{width:"24",height:"25",viewBox:"0 0 24 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsxs("g",{clipPath:"url(#clip0_501_6036)",children:[n.jsx("path",{d:"M18 6.5L6 18.5",stroke:"#555555",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M6 6.5L18 18.5",stroke:"#555555",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),n.jsx("defs",{children:n.jsx("clipPath",{id:"clip0_501_6036",children:n.jsx("rect",{width:"24",height:"24",fill:"white",transform:"translate(0 0.5)"})})})]})})})]}),n.jsxs("div",{className:"flex h-full md:flex-row lg:flex-row",children:[n.jsxs("div",{className:`flex flex-col h-full ${Ue?"lg:w-2/3 w-full":"w-full"}`,children:[n.jsxs("div",{ref:H,className:"overflow-y-auto pr-5 pb-2 space-y-4 hide-scrollbar flex-grow mb-24",children:[(A==null?void 0:A.whomRequired)&&n.jsxs("div",{className:"mx-3 p-3 rounded-2xl bg-[#FFFFFF]",children:[n.jsx("div",{className:"flex gap-2 bg-[#FFFFFF]",children:n.jsx("p",{className:"font-bold font-nunitoSans text-[#494949]",children:"Is this for you or someone else?"})}),n.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:o.map(m=>n.jsx("button",{onClick:()=>Xe(m),className:"px-2 py-2 font-semibold text-xs text-[#18181B] bg-[#F3F3F3] rounded-2xl",style:{backgroundColor:xe===s[m]?"#FFFFFF":"#F3F3F3",borderColor:xe===s[m]?"#BBB3DD":""},children:m},m))})]}),k.map((m,T)=>{var M,W;return n.jsxs("div",{children:[n.jsx("div",{className:"flex justify-end",children:n.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:m.query})}),m.response&&m.response.includes("Thinking")?n.jsx("div",{children:n.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:nr(m.response)}})}):n.jsx("div",{children:n.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:nr(m.response)}})}),ke&&!m.response.includes("Thinking")&&((M=m.products)==null?void 0:M.length)==0&&n.jsx("div",{children:n.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"})}),(m==null?void 0:m.products)&&((W=m==null?void 0:m.products)==null?void 0:W.length)>0&&n.jsx(es,{chat:m.products,storeDetails:A}),(m==null?void 0:m.potentialQuestions.length)>0&&n.jsxs("div",{className:"my-2 px-4 text-sm text-gray-700",children:[n.jsx("p",{className:"font-nunitoSans font-bold text-sm text-[#494949]",style:{color:A.themeDarkColor},children:"Why not explore these inquiries..."}),m.potentialQuestions.split(",").map((B,$)=>n.jsx("button",{className:`cursor-pointer font-nunitoSans font-semibold text-[#232323] border bg-[#804C9E0D] border-${A.themeDarkColor} m-1 rounded-xl px-2 py-1`,onClick:()=>be(B),style:{backgroundColor:A.tanyaThemeColorLight},children:B},$))]}),(m==null?void 0:m.secondaryLoading)&&n.jsx("div",{className:"mt-3 mb-4 px-4",children:n.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:[n.jsxs("div",{className:"flex gap-1",children:[n.jsx("div",{className:"tanya-sparkle tanya-sparkle-1",children:"✨"}),n.jsx("div",{className:"tanya-sparkle tanya-sparkle-2",children:"✨"}),n.jsx("div",{className:"tanya-sparkle tanya-sparkle-3",children:"✨"})]}),n.jsx("div",{className:"tanya-shimmer"}),n.jsx("p",{className:"font-semibold tanya-pulse",style:{color:A.themeDarkColor},children:"I’ve found a special surprise crafted just for you… hang on a sec!"}),n.jsx("p",{className:"tanya-dots mt-1",style:{color:A.themeDarkColor},children:"• • •"})]})}),(m==null?void 0:m.secondaryResponse)&&n.jsx(n.Fragment,{children:n.jsxs("div",{className:"mt-3 mb-8 px-4 bg-indigo-300 rounded-tr-[5px]",children:[n.jsx("div",{className:"text-sm text-[#232323] bg-[#FFFFFF] px-7 py-4 rounded-br-xl rounded-bl-2xl w-full",style:{backgroundColor:A.tanyaThemeColorLight},dangerouslySetInnerHTML:{__html:nr(m.secondaryResponse)}}),m.productSnapshot&&n.jsx("div",{className:"mt-4 w-full",children:n.jsxs("div",{className:"flex gap-4 items-stretch rounded-2xl p-4",style:{backgroundColor:A.tanyaThemeColorLight},children:[n.jsx("div",{className:"flex-shrink-0 rounded-xl overflow-hidden border",style:{width:112,height:112,borderColor:"#eee"},children:m.productSnapshot.image?n.jsx("img",{src:m.productSnapshot.image,alt:m.productSnapshot.name,className:"w-full h-full object-cover"}):n.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs text-gray-500",children:"No Image"})}),n.jsxs("div",{className:"flex flex-col flex-1 justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"font-semibold text-[15px] leading-snug",children:m.productSnapshot.name}),n.jsx("p",{className:"mt-1 text-[14px] font-medium",children:m.productSnapshot.price!=null?new Intl.NumberFormat(void 0,{style:"currency",currency:(A==null?void 0:A.currency)||"USD"}).format(m.productSnapshot.price):""}),m.productSnapshot.points>0&&n.jsxs("p",{className:"mt-1 text-xs opacity-80",children:["You will earn"," ",n.jsxs("strong",{children:[m.productSnapshot.points," ","points"]})]})]}),n.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[n.jsxs("div",{className:"flex items-center border rounded-full overflow-hidden",children:[n.jsx("button",{className:"px-3 py-1 text-sm",onClick:()=>ye(B=>B.map(($,K)=>K===T&&$.productSnapshot?{...$,productSnapshot:{...$.productSnapshot,quantity:Math.max(1,$.productSnapshot.quantity-1)}}:$)),style:{background:"transparent",color:A.themeDarkColor},children:"−"}),n.jsx("div",{className:"px-3 py-1 text-sm select-none",children:m.productSnapshot.quantity}),n.jsx("button",{className:"px-3 py-1 text-sm",onClick:()=>ye(B=>B.map(($,K)=>K===T&&$.productSnapshot?{...$,productSnapshot:{...$.productSnapshot,quantity:$.productSnapshot.quantity+1}}:$)),style:{background:"transparent",color:A.themeDarkColor},children:"+"})]}),n.jsx("button",{onClick:()=>{wt(st(m.productSnapshot),m.productSnapshot.quantity)},disabled:_,className:"px-4 py-2 rounded-full font-medium",style:{background:A.tanyaThemeColor,color:(A==null?void 0:A.tanyaThemeContrastColor)||"#fff",opacity:_?.8:1},children:_?"Adding...":"Add to cart"})]})]})]})})]})}),n.jsx("div",{className:"mb-20"})]},T)})]}),n.jsx("div",{className:"flex flex-col gap-2 sticky bottom-0 left-0 right-0 bg-[#E3DEEF] z-50 px-4 py-2",children:n.jsx("div",{className:"p-[1px] rounded-xl",style:{background:"linear-gradient(180deg, #B09FFF 0%, #8D79F6 100%)"},children:n.jsxs("div",{className:"flex items-center bg-[#FFFFFF] flex-1 rounded-xl px-2 py-1",children:[n.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:J,autoFocus:!0,onChange:m=>te(m.target.value),onKeyDown:m=>{m.key==="Enter"&&!q&&be()}}),n.jsx("button",{type:"submit",disabled:q,className:"p-3",onClick:()=>be(),children:q?n.jsx("div",{className:"p-3 animate-spin rounded-full h-3 w-3 border-b-2",style:{borderBottom:"2px solid",color:A.tanyaThemeColor}}):n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:n.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"})})})]})})})]}),n.jsx(ns,{addToCartPwa:r})]})]})]})]})})};var mr=function(e,t){return mr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(r[s]=o[s])},mr(e,t)};function ss(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");mr(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var Ye=function(){return Ye=Object.assign||function(t){for(var r,o=1,s=arguments.length;o<s;o++){r=arguments[o];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},Ye.apply(this,arguments)};function as(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(e);s<o.length;s++)t.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(e,o[s])&&(r[o[s]]=e[o[s]]);return r}var or="Invariant Violation",rn=Object.setPrototypeOf,is=rn===void 0?function(e,t){return e.__proto__=t,e}:rn,Dn=(function(e){ss(t,e);function t(r){r===void 0&&(r=or);var o=e.call(this,typeof r=="number"?or+": "+r+" (see https://github.com/apollographql/invariant-packages)":r)||this;return o.framesToPop=1,o.name=or,is(o,t.prototype),o}return t})(Error);function rt(e,t){if(!e)throw new Dn(t)}var Mn=["debug","log","warn","error","silent"],ls=Mn.indexOf("log");function qt(e){return function(){if(Mn.indexOf(e)>=ls){var t=console[e]||console.log;return t.apply(console,arguments)}}}(function(e){e.debug=qt("debug"),e.log=qt("log"),e.warn=qt("warn"),e.error=qt("error")})(rt||(rt={}));var Bn="3.14.0";function ut(e){try{return e()}catch{}}const hr=ut(function(){return globalThis})||ut(function(){return window})||ut(function(){return self})||ut(function(){return global})||ut(function(){return ut.constructor("return this")()});var nn=new Map;function cs(e){var t=nn.get(e)||1;return nn.set(e,t+1),"".concat(e,":").concat(t,":").concat(Math.random().toString(36).slice(2))}function ds(e,t){var r=cs("stringifyForDisplay");return JSON.stringify(e,function(o,s){return s===void 0?r:s},t).split(JSON.stringify(r)).join("<undefined>")}function Rt(e){return function(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(typeof t=="number"){var s=t;t=kr(s),t||(t=Sr(s,r),r=[])}e.apply(void 0,[t].concat(r))}}var sr=Object.assign(function(t,r){for(var o=[],s=2;s<arguments.length;s++)o[s-2]=arguments[s];t||rt(t,kr(r,o)||Sr(r,o))},{debug:Rt(rt.debug),log:Rt(rt.log),warn:Rt(rt.warn),error:Rt(rt.error)});function qn(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return new Dn(kr(e,t)||Sr(e,t))}var on=Symbol.for("ApolloErrorMessageHandler_"+Bn);function Rn(e){if(typeof e=="string")return e;try{return ds(e,2).slice(0,1e3)}catch{return"<non-serializable>"}}function kr(e,t){if(t===void 0&&(t=[]),!!e)return hr[on]&&hr[on](e,t.map(Rn))}function Sr(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:Bn,message:e,args:t.map(Rn)})))}function us(e){return e.definitions.filter(function(t){return t.kind==="OperationDefinition"&&!!t.name}).map(function(t){return t.name.value})[0]||null}let le=null;const sn={};let fs=1;const ms=()=>class{constructor(){this.id=["slot",fs++,Date.now(),Math.random().toString(36).slice(2)].join(":")}hasValue(){for(let t=le;t;t=t.parent)if(this.id in t.slots){const r=t.slots[this.id];if(r===sn)break;return t!==le&&(le.slots[this.id]=r),!0}return le&&(le.slots[this.id]=sn),!1}getValue(){if(this.hasValue())return le.slots[this.id]}withValue(t,r,o,s){const a={__proto__:null,[this.id]:t},i=le;le={parent:i,slots:a};try{return r.apply(s,o)}finally{le=i}}static bind(t){const r=le;return function(){const o=le;try{return le=r,t.apply(this,arguments)}finally{le=o}}}static noContext(t,r,o){if(le){const s=le;try{return le=null,t.apply(o,r)}finally{le=s}}else return t.apply(o,r)}};function an(e){try{return e()}catch{}}const ar="@wry/context:Slot",hs=an(()=>globalThis)||an(()=>global)||Object.create(null),ln=hs,Nr=ln[ar]||Array[ar]||(function(e){try{Object.defineProperty(ln,ar,{value:e,enumerable:!1,writable:!1,configurable:!0})}finally{return e}})(ms()),{bind:Ga,noContext:Xa}=Nr;new Nr;function ps(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=gs(e))||t){r&&(e=r);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
16
16
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gs(e,t){if(e){if(typeof e=="string")return cn(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return cn(e,t)}}function cn(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function dn(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function Cr(e,t,r){return t&&dn(e.prototype,t),r&&dn(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var _r=function(){return typeof Symbol=="function"},Ir=function(e){return _r()&&!!Symbol[e]},Fr=function(e){return Ir(e)?Symbol[e]:"@@"+e};_r()&&!Ir("observable")&&(Symbol.observable=Symbol("observable"));var xs=Fr("iterator"),pr=Fr("observable"),Un=Fr("species");function Xt(e,t){var r=e[t];if(r!=null){if(typeof r!="function")throw new TypeError(r+" is not a function");return r}}function _t(e){var t=e.constructor;return t!==void 0&&(t=t[Un],t===null&&(t=void 0)),t!==void 0?t:ge}function ws(e){return e instanceof ge}function gt(e){gt.log?gt.log(e):setTimeout(function(){throw e})}function Ht(e){Promise.resolve().then(function(){try{e()}catch(t){gt(t)}})}function Hn(e){var t=e._cleanup;if(t!==void 0&&(e._cleanup=void 0,!!t))try{if(typeof t=="function")t();else{var r=Xt(t,"unsubscribe");r&&r.call(t)}}catch(o){gt(o)}}function gr(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function ys(e){var t=e._queue;if(t){e._queue=void 0,e._state="ready";for(var r=0;r<t.length&&(Vn(e,t[r].type,t[r].value),e._state!=="closed");++r);}}function Vn(e,t,r){e._state="running";var o=e._observer;try{var s=Xt(o,t);switch(t){case"next":s&&s.call(o,r);break;case"error":if(gr(e),s)s.call(o,r);else throw r;break;case"complete":gr(e),s&&s.call(o);break}}catch(a){gt(a)}e._state==="closed"?Hn(e):e._state==="running"&&(e._state="ready")}function ir(e,t,r){if(e._state!=="closed"){if(e._state==="buffering"){e._queue.push({type:t,value:r});return}if(e._state!=="ready"){e._state="buffering",e._queue=[{type:t,value:r}],Ht(function(){return ys(e)});return}Vn(e,t,r)}}var bs=(function(){function e(r,o){this._cleanup=void 0,this._observer=r,this._queue=void 0,this._state="initializing";var s=new vs(this);try{this._cleanup=o.call(void 0,s)}catch(a){s.error(a)}this._state==="initializing"&&(this._state="ready")}var t=e.prototype;return t.unsubscribe=function(){this._state!=="closed"&&(gr(this),Hn(this))},Cr(e,[{key:"closed",get:function(){return this._state==="closed"}}]),e})(),vs=(function(){function e(r){this._subscription=r}var t=e.prototype;return t.next=function(o){ir(this._subscription,"next",o)},t.error=function(o){ir(this._subscription,"error",o)},t.complete=function(){ir(this._subscription,"complete")},Cr(e,[{key:"closed",get:function(){return this._subscription._state==="closed"}}]),e})(),ge=(function(){function e(r){if(!(this instanceof e))throw new TypeError("Observable cannot be called as a function");if(typeof r!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=r}var t=e.prototype;return t.subscribe=function(o){return(typeof o!="object"||o===null)&&(o={next:o,error:arguments[1],complete:arguments[2]}),new bs(o,this._subscriber)},t.forEach=function(o){var s=this;return new Promise(function(a,i){if(typeof o!="function"){i(new TypeError(o+" is not a function"));return}function c(){l.unsubscribe(),a()}var l=s.subscribe({next:function(h){try{o(h,c)}catch(g){i(g),l.unsubscribe()}},error:i,complete:a})})},t.map=function(o){var s=this;if(typeof o!="function")throw new TypeError(o+" is not a function");var a=_t(this);return new a(function(i){return s.subscribe({next:function(c){try{c=o(c)}catch(l){return i.error(l)}i.next(c)},error:function(c){i.error(c)},complete:function(){i.complete()}})})},t.filter=function(o){var s=this;if(typeof o!="function")throw new TypeError(o+" is not a function");var a=_t(this);return new a(function(i){return s.subscribe({next:function(c){try{if(!o(c))return}catch(l){return i.error(l)}i.next(c)},error:function(c){i.error(c)},complete:function(){i.complete()}})})},t.reduce=function(o){var s=this;if(typeof o!="function")throw new TypeError(o+" is not a function");var a=_t(this),i=arguments.length>1,c=!1,l=arguments[1],h=l;return new a(function(g){return s.subscribe({next:function(w){var y=!c;if(c=!0,!y||i)try{h=o(h,w)}catch(C){return g.error(C)}else h=w},error:function(w){g.error(w)},complete:function(){if(!c&&!i)return g.error(new TypeError("Cannot reduce an empty sequence"));g.next(h),g.complete()}})})},t.concat=function(){for(var o=this,s=arguments.length,a=new Array(s),i=0;i<s;i++)a[i]=arguments[i];var c=_t(this);return new c(function(l){var h,g=0;function w(y){h=y.subscribe({next:function(C){l.next(C)},error:function(C){l.error(C)},complete:function(){g===a.length?(h=void 0,l.complete()):w(c.from(a[g++]))}})}return w(o),function(){h&&(h.unsubscribe(),h=void 0)}})},t.flatMap=function(o){var s=this;if(typeof o!="function")throw new TypeError(o+" is not a function");var a=_t(this);return new a(function(i){var c=[],l=s.subscribe({next:function(g){if(o)try{g=o(g)}catch(y){return i.error(y)}var w=a.from(g).subscribe({next:function(y){i.next(y)},error:function(y){i.error(y)},complete:function(){var y=c.indexOf(w);y>=0&&c.splice(y,1),h()}});c.push(w)},error:function(g){i.error(g)},complete:function(){h()}});function h(){l.closed&&c.length===0&&i.complete()}return function(){c.forEach(function(g){return g.unsubscribe()}),l.unsubscribe()}})},t[pr]=function(){return this},e.from=function(o){var s=typeof this=="function"?this:e;if(o==null)throw new TypeError(o+" is not an object");var a=Xt(o,pr);if(a){var i=a.call(o);if(Object(i)!==i)throw new TypeError(i+" is not an object");return ws(i)&&i.constructor===s?i:new s(function(c){return i.subscribe(c)})}if(Ir("iterator")&&(a=Xt(o,xs),a))return new s(function(c){Ht(function(){if(!c.closed){for(var l=ps(a.call(o)),h;!(h=l()).done;){var g=h.value;if(c.next(g),c.closed)return}c.complete()}})});if(Array.isArray(o))return new s(function(c){Ht(function(){if(!c.closed){for(var l=0;l<o.length;++l)if(c.next(o[l]),c.closed)return;c.complete()}})});throw new TypeError(o+" is not observable")},e.of=function(){for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];var i=typeof this=="function"?this:e;return new i(function(c){Ht(function(){if(!c.closed){for(var l=0;l<s.length;++l)if(c.next(s[l]),c.closed)return;c.complete()}})})},Cr(e,null,[{key:Un,get:function(){return this}}]),e})();_r()&&Object.defineProperty(ge,Symbol("extensions"),{value:{symbol:pr,hostReportError:gt},configurable:!0});function js(e){var t,r=e.Symbol;if(typeof r=="function")if(r.observable)t=r.observable;else{typeof r.for=="function"?t=r.for("https://github.com/benlesh/symbol-observable"):t=r("https://github.com/benlesh/symbol-observable");try{r.observable=t}catch{}}else t="@@observable";return t}var ht;typeof self<"u"?ht=self:typeof window<"u"?ht=window:typeof global<"u"?ht=global:typeof module<"u"?ht=module:ht=Function("return this")();js(ht);var un=ge.prototype,fn="@@observable";un[fn]||(un[fn]=function(){return this});function ks(e){for(var t=["query","operationName","variables","extensions","context"],r=0,o=Object.keys(e);r<o.length;r++){var s=o[r];if(t.indexOf(s)<0)throw qn(58,s)}return e}function Ss(e,t){var r=Ye({},e),o=function(a){typeof a=="function"?r=Ye(Ye({},r),a(r)):r=Ye(Ye({},r),a)},s=function(){return Ye({},r)};return Object.defineProperty(t,"setContext",{enumerable:!1,value:o}),Object.defineProperty(t,"getContext",{enumerable:!1,value:s}),t}function Ns(e){var t={variables:e.variables||{},extensions:e.extensions||{},operationName:e.operationName,query:e.query};return t.operationName||(t.operationName=typeof t.query!="string"?us(t.query)||void 0:""),t}var Cs=Symbol.for("apollo.deprecations"),_s=hr,Is=new Nr;function Fs(e){return _s[Cs]||(Is.getValue()||[]).includes(e)}function Ps(e,t){Fs(e)||t()}function mn(e,t){return t?t(e):ge.of()}function It(e){return typeof e=="function"?new Yn(e):e}function Ut(e){return e.request.length<=1}var Yn=(function(){function e(t){t&&(this.request=t)}return e.empty=function(){return new e(function(){return ge.of()})},e.from=function(t){return t.length===0?e.empty():t.map(It).reduce(function(r,o){return r.concat(o)})},e.split=function(t,r,o){var s=It(r),a=It(o||new e(mn)),i;return Ut(s)&&Ut(a)?i=new e(function(c){return t(c)?s.request(c)||ge.of():a.request(c)||ge.of()}):i=new e(function(c,l){return t(c)?s.request(c,l)||ge.of():a.request(c,l)||ge.of()}),Object.assign(i,{left:s,right:a})},e.execute=function(t,r){return t.request(Ss(r.context,Ns(ks(r))))||ge.of()},e.concat=function(t,r){var o=It(t);if(Ut(o))return globalThis.__DEV__!==!1&&sr.warn(47,o),o;var s=It(r),a;return Ut(s)?a=new e(function(i){return o.request(i,function(c){return s.request(c)||ge.of()})||ge.of()}):a=new e(function(i,c){return o.request(i,function(l){return s.request(l,c)||ge.of()})||ge.of()}),Object.assign(a,{left:o,right:s})},e.prototype.split=function(t,r,o){return this.concat(e.split(t,r,o||new e(mn)))},e.prototype.concat=function(t){return e.concat(this,t)},e.prototype.request=function(t,r){throw qn(48)},e.prototype.onError=function(t,r){if(globalThis.__DEV__!==!1&&Ps("onError",function(){globalThis.__DEV__!==!1&&sr.warn(49)}),r&&r.error)return r.error(t),!1;throw t},e.prototype.setOnError=function(t){return globalThis.__DEV__!==!1&&globalThis.__DEV__!==!1&&sr.warn(50),this.onError=t,this},e})();function Es(e){return new Yn(function(t,r){var o=as(t,[]);return new ge(function(s){var a,i=!1;return Promise.resolve(o).then(function(c){return e(c,t.getContext())}).then(t.setContext).then(function(){i||(a=r(t).subscribe({next:s.next.bind(s),error:s.error.bind(s),complete:s.complete.bind(s)}))}).catch(s.error.bind(s)),function(){i=!0,a&&a.unsubscribe()}})})}const Ts=async()=>{const e="https://auth.australia-southeast1.gcp.commercetools.com/oauth/token",o="Basic "+btoa(encodeURIComponent("tfegsSBVOYnR7e_yE-AjxVVN")+":"+encodeURIComponent("pyKWgHuTxuMwDygh9JH1ehLEaLvAhBo4"));try{const s=await de.post(e,new URLSearchParams({grant_type:"client_credentials"}),{headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:o}});return s.status===200&&s.data.access_token?s.data.access_token:(console.error("Failed to fetch token:",s.data),null)}catch(s){return de.isAxiosError(s)?console.error("Error fetching token:",s.response||s.message):console.error("Unexpected error:",s),null}},Os="https://api.australia-southeast1.gcp.commercetools.com/kt-demo/graphql",As=Wt.createHttpLink({uri:`${Os}`}),$s=Es(async(e,{headers:t})=>{const r=await Ts();return{headers:{...t,authorization:`Bearer ${r}`}}}),Ls=new Wt.ApolloClient({link:$s.concat(As),cache:new Wt.InMemoryCache,defaultOptions:{watchQuery:{fetchPolicy:"cache-and-network"}}}),zs=e=>{const{tanyaConfig:t}=e;return n.jsx(Wt.ApolloProvider,{client:Ls,children:n.jsx(Vo,{children:n.jsx(os,{tanyaConfig:t})})})};function Ds(e,t){const r=e.icons,o=e.aliases||Object.create(null),s=Object.create(null);function a(i){if(r[i])return s[i]=[];if(!(i in s)){s[i]=null;const c=o[i]&&o[i].parent,l=c&&a(c);l&&(s[i]=[c].concat(l))}return s[i]}return Object.keys(r).concat(Object.keys(o)).forEach(a),s}const Jn=Object.freeze({left:0,top:0,width:16,height:16}),Zt=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Pr=Object.freeze({...Jn,...Zt}),xr=Object.freeze({...Pr,body:"",hidden:!1});function Ms(e,t){const r={};!e.hFlip!=!t.hFlip&&(r.hFlip=!0),!e.vFlip!=!t.vFlip&&(r.vFlip=!0);const o=((e.rotate||0)+(t.rotate||0))%4;return o&&(r.rotate=o),r}function hn(e,t){const r=Ms(e,t);for(const o in xr)o in Zt?o in e&&!(o in r)&&(r[o]=Zt[o]):o in t?r[o]=t[o]:o in e&&(r[o]=e[o]);return r}function Bs(e,t,r){const o=e.icons,s=e.aliases||Object.create(null);let a={};function i(c){a=hn(o[c]||s[c],a)}return i(t),r.forEach(i),hn(e,a)}function Kn(e,t){const r=[];if(typeof e!="object"||typeof e.icons!="object")return r;e.not_found instanceof Array&&e.not_found.forEach(s=>{t(s,null),r.push(s)});const o=Ds(e);for(const s in o){const a=o[s];a&&(t(s,Bs(e,s,a)),r.push(s))}return r}const qs={provider:"",aliases:{},not_found:{},...Jn};function lr(e,t){for(const r in t)if(r in e&&typeof e[r]!=typeof t[r])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"||!lr(e,qs))return null;const r=t.icons;for(const s in r){const a=r[s];if(!s||typeof a.body!="string"||!lr(a,xr))return null}const o=t.aliases||Object.create(null);for(const s in o){const a=o[s],i=a.parent;if(!s||typeof i!="string"||!r[i]&&!o[i]||!lr(a,xr))return null}return t}const pn=Object.create(null);function Rs(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function xt(e,t){const r=pn[e]||(pn[e]=Object.create(null));return r[t]||(r[t]=Rs(e,t))}function Qn(e,t){return Wn(t)?Kn(t,(r,o)=>{o?e.icons[r]=o:e.missing.add(r)}):[]}function Us(e,t,r){try{if(typeof r.body=="string")return e.icons[t]={...r},!0}catch{}return!1}const Gn=/^[a-z0-9]+(-[a-z0-9]+)*$/,er=(e,t,r,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 c=s.pop(),l=s.pop(),h={provider:s.length>0?s[0]:o,prefix:l,name:c};return t&&!Vt(h)?null:h}const a=s[0],i=a.split("-");if(i.length>1){const c={provider:o,prefix:i.shift(),name:i.join("-")};return t&&!Vt(c)?null:c}if(r&&o===""){const c={provider:o,prefix:"",name:a};return t&&!Vt(c,r)?null:c}return null},Vt=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let At=!1;function Xn(e){return typeof e=="boolean"&&(At=e),At}function gn(e){const t=typeof e=="string"?er(e,!0,At):e;if(t){const r=xt(t.provider,t.prefix),o=t.name;return r.icons[o]||(r.missing.has(o)?null:void 0)}}function Hs(e,t){const r=er(e,!0,At);if(!r)return!1;const o=xt(r.provider,r.prefix);return t?Us(o,r.name,t):(o.missing.add(r.name),!0)}function Vs(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),At&&!t&&!e.prefix){let s=!1;return Wn(e)&&(e.prefix="",Kn(e,(a,i)=>{Hs(a,i)&&(s=!0)})),s}const r=e.prefix;if(!Vt({prefix:r,name:"a"}))return!1;const o=xt(t,r);return!!Qn(o,e)}const Zn=Object.freeze({width:null,height:null}),eo=Object.freeze({...Zn,...Zt}),Ys=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Js=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function xn(e,t,r){if(t===1)return e;if(r=r||100,typeof e=="number")return Math.ceil(e*t*r)/r;if(typeof e!="string")return e;const o=e.split(Ys);if(o===null||!o.length)return e;const s=[];let a=o.shift(),i=Js.test(a);for(;;){if(i){const c=parseFloat(a);isNaN(c)?s.push(a):s.push(Math.ceil(c*t*r)/r)}else s.push(a);if(a=o.shift(),a===void 0)return s.join("");i=!i}}function Ks(e,t="defs"){let r="";const o=e.indexOf("<"+t);for(;o>=0;){const s=e.indexOf(">",o),a=e.indexOf("</"+t);if(s===-1||a===-1)break;const i=e.indexOf(">",a);if(i===-1)break;r+=e.slice(s+1,a).trim(),e=e.slice(0,o).trim()+e.slice(i+1)}return{defs:r,content:e}}function Ws(e,t){return e?"<defs>"+e+"</defs>"+t:t}function Qs(e,t,r){const o=Ks(e);return Ws(o.defs,t+o.content+r)}const Gs=e=>e==="unset"||e==="undefined"||e==="none";function Xs(e,t){const r={...Pr,...e},o={...eo,...t},s={left:r.left,top:r.top,width:r.width,height:r.height};let a=r.body;[r,o].forEach(E=>{const v=[],_=E.hFlip,Y=E.vFlip;let q=E.rotate;_?Y?q+=2:(v.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),v.push("scale(-1 1)"),s.top=s.left=0):Y&&(v.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),v.push("scale(1 -1)"),s.top=s.left=0);let V;switch(q<0&&(q-=Math.floor(q/4)*4),q=q%4,q){case 1:V=s.height/2+s.top,v.unshift("rotate(90 "+V.toString()+" "+V.toString()+")");break;case 2:v.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:V=s.width/2+s.left,v.unshift("rotate(-90 "+V.toString()+" "+V.toString()+")");break}q%2===1&&(s.left!==s.top&&(V=s.left,s.left=s.top,s.top=V),s.width!==s.height&&(V=s.width,s.width=s.height,s.height=V)),v.length&&(a=Qs(a,'<g transform="'+v.join(" ")+'">',"</g>"))});const i=o.width,c=o.height,l=s.width,h=s.height;let g,w;i===null?(w=c===null?"1em":c==="auto"?h:c,g=xn(w,l/h)):(g=i==="auto"?l:i,w=c===null?xn(g,h/l):c==="auto"?h:c);const y={},C=(E,v)=>{Gs(v)||(y[E]=v.toString())};C("width",g),C("height",w);const j=[s.left,s.top,l,h];return y.viewBox=j.join(" "),{attributes:y,viewBox:j,body:a}}const Zs=/\sid="(\S+)"/g,ea="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let ta=0;function ra(e,t=ea){const r=[];let o;for(;o=Zs.exec(e);)r.push(o[1]);if(!r.length)return e;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return r.forEach(a=>{const i=typeof t=="function"?t(a):t+(ta++).toString(),c=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+c+')([")]|\\.[a-z])',"g"),"$1"+i+s+"$3")}),e=e.replace(new RegExp(s,"g"),""),e}const wr=Object.create(null);function na(e,t){wr[e]=t}function yr(e){return wr[e]||wr[""]}function Er(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 Tr=Object.create(null),Ft=["https://api.simplesvg.com","https://api.unisvg.com"],Yt=[];for(;Ft.length>0;)Ft.length===1||Math.random()>.5?Yt.push(Ft.shift()):Yt.push(Ft.pop());Tr[""]=Er({resources:["https://api.iconify.design"].concat(Yt)});function oa(e,t){const r=Er(t);return r===null?!1:(Tr[e]=r,!0)}function Or(e){return Tr[e]}const sa=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let wn=sa();function aa(e,t){const r=Or(e);if(!r)return 0;let o;if(!r.maxURL)o=0;else{let s=0;r.resources.forEach(i=>{s=Math.max(s,i.length)});const a=t+".json?icons=";o=r.maxURL-s-r.path.length-a.length}return o}function ia(e){return e===404}const la=(e,t,r)=>{const o=[],s=aa(e,t),a="icons";let i={type:a,provider:e,prefix:t,icons:[]},c=0;return r.forEach((l,h)=>{c+=l.length+1,c>=s&&h>0&&(o.push(i),i={type:a,provider:e,prefix:t,icons:[]},c=l.length),i.icons.push(l)}),o.push(i),o};function ca(e){if(typeof e=="string"){const t=Or(e);if(t)return t.path}return"/"}const da=(e,t,r)=>{if(!wn){r("abort",424);return}let o=ca(t.provider);switch(t.type){case"icons":{const a=t.prefix,c=t.icons.join(","),l=new URLSearchParams({icons:c});o+=a+".json?"+l.toString();break}case"custom":{const a=t.uri;o+=a.slice(0,1)==="/"?a.slice(1):a;break}default:r("abort",400);return}let s=503;wn(e+o).then(a=>{const i=a.status;if(i!==200){setTimeout(()=>{r(ia(i)?"abort":"next",i)});return}return s=501,a.json()}).then(a=>{if(typeof a!="object"||a===null){setTimeout(()=>{a===404?r("abort",a):r("next",s)});return}setTimeout(()=>{r("success",a)})}).catch(()=>{r("next",s)})},ua={prepare:la,send:da};function to(e,t){e.forEach(r=>{const o=r.loaderCallbacks;o&&(r.loaderCallbacks=o.filter(s=>s.id!==t))})}function fa(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let r=!1;const o=e.provider,s=e.prefix;t.forEach(a=>{const i=a.icons,c=i.pending.length;i.pending=i.pending.filter(l=>{if(l.prefix!==s)return!0;const h=l.name;if(e.icons[h])i.loaded.push({provider:o,prefix:s,name:h});else if(e.missing.has(h))i.missing.push({provider:o,prefix:s,name:h});else return r=!0,!0;return!1}),i.pending.length!==c&&(r||to([e],a.id),a.callback(i.loaded.slice(0),i.missing.slice(0),i.pending.slice(0),a.abort))})}))}let ma=0;function ha(e,t,r){const o=ma++,s=to.bind(null,r,o);if(!t.pending.length)return s;const a={id:o,icons:t,callback:e,abort:s};return r.forEach(i=>{(i.loaderCallbacks||(i.loaderCallbacks=[])).push(a)}),s}function pa(e){const t={loaded:[],missing:[],pending:[]},r=Object.create(null);e.sort((s,a)=>s.provider!==a.provider?s.provider.localeCompare(a.provider):s.prefix!==a.prefix?s.prefix.localeCompare(a.prefix):s.name.localeCompare(a.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 a=s.provider,i=s.prefix,c=s.name,l=r[a]||(r[a]=Object.create(null)),h=l[i]||(l[i]=xt(a,i));let g;c in h.icons?g=t.loaded:i===""||h.missing.has(c)?g=t.missing:g=t.pending;const w={provider:a,prefix:i,name:c};g.push(w)}),t}function ga(e,t=!0,r=!1){const o=[];return e.forEach(s=>{const a=typeof s=="string"?er(s,t,r):s;a&&o.push(a)}),o}const xa={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function wa(e,t,r,o){const s=e.resources.length,a=e.random?Math.floor(Math.random()*s):e.index;let i;if(e.random){let S=e.resources.slice(0);for(i=[];S.length>1;){const J=Math.floor(Math.random()*S.length);i.push(S[J]),S=S.slice(0,J).concat(S.slice(J+1))}i=i.concat(S)}else i=e.resources.slice(a).concat(e.resources.slice(0,a));const c=Date.now();let l="pending",h=0,g,w=null,y=[],C=[];typeof o=="function"&&C.push(o);function j(){w&&(clearTimeout(w),w=null)}function E(){l==="pending"&&(l="aborted"),j(),y.forEach(S=>{S.status==="pending"&&(S.status="aborted")}),y=[]}function v(S,J){J&&(C=[]),typeof S=="function"&&C.push(S)}function _(){return{startTime:c,payload:t,status:l,queriesSent:h,queriesPending:y.length,subscribe:v,abort:E}}function Y(){l="failed",C.forEach(S=>{S(void 0,g)})}function q(){y.forEach(S=>{S.status==="pending"&&(S.status="aborted")}),y=[]}function V(S,J,te){const xe=J!=="success";switch(y=y.filter(we=>we!==S),l){case"pending":break;case"failed":if(xe||!e.dataAfterTimeout)return;break;default:return}if(J==="abort"){g=te,Y();return}if(xe){g=te,y.length||(i.length?ke():Y());return}if(j(),q(),!e.random){const we=e.resources.indexOf(S.resource);we!==-1&&we!==e.index&&(e.index=we)}l="completed",C.forEach(we=>{we(te)})}function ke(){if(l!=="pending")return;j();const S=i.shift();if(S===void 0){if(y.length){w=setTimeout(()=>{j(),l==="pending"&&(q(),Y())},e.timeout);return}Y();return}const J={status:"pending",resource:S,callback:(te,xe)=>{V(J,te,xe)}};y.push(J),h++,w=setTimeout(ke,e.rotate),r(S,t,J.callback)}return setTimeout(ke),_}function ro(e){const t={...xa,...e};let r=[];function o(){r=r.filter(c=>c().status==="pending")}function s(c,l,h){const g=wa(t,c,l,(w,y)=>{o(),h&&h(w,y)});return r.push(g),g}function a(c){return r.find(l=>c(l))||null}return{query:s,find:a,setIndex:c=>{t.index=c},getIndex:()=>t.index,cleanup:o}}function yn(){}const cr=Object.create(null);function ya(e){if(!cr[e]){const t=Or(e);if(!t)return;const r=ro(t),o={config:t,redundancy:r};cr[e]=o}return cr[e]}function ba(e,t,r){let o,s;if(typeof e=="string"){const a=yr(e);if(!a)return r(void 0,424),yn;s=a.send;const i=ya(e);i&&(o=i.redundancy)}else{const a=Er(e);if(a){o=ro(a);const i=e.resources?e.resources[0]:"",c=yr(i);c&&(s=c.send)}}return!o||!s?(r(void 0,424),yn):o.query(t,s,r)().abort}function bn(){}function va(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,fa(e)}))}function ja(e){const t=[],r=[];return e.forEach(o=>{(o.match(Gn)?t:r).push(o)}),{valid:t,invalid:r}}function Pt(e,t,r){function o(){const s=e.pendingIcons;t.forEach(a=>{s&&s.delete(a),e.icons[a]||e.missing.add(a)})}if(r&&typeof r=="object")try{if(!Qn(e,r).length){o();return}}catch(s){console.error(s)}o(),va(e)}function vn(e,t){e instanceof Promise?e.then(r=>{t(r)}).catch(()=>{t(null)}):t(e)}function ka(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:r,prefix:o}=e,s=e.iconsToLoad;if(delete e.iconsToLoad,!s||!s.length)return;const a=e.loadIcon;if(e.loadIcons&&(s.length>1||!a)){vn(e.loadIcons(s,o,r),g=>{Pt(e,s,g)});return}if(a){s.forEach(g=>{const w=a(g,o,r);vn(w,y=>{const C=y?{prefix:o,icons:{[g]:y}}:null;Pt(e,[g],C)})});return}const{valid:i,invalid:c}=ja(s);if(c.length&&Pt(e,c,null),!i.length)return;const l=o.match(Gn)?yr(r):null;if(!l){Pt(e,i,null);return}l.prepare(r,o,i).forEach(g=>{ba(r,g,w=>{Pt(e,g.icons,w)})})}))}const Sa=(e,t)=>{const r=ga(e,!0,Xn()),o=pa(r);if(!o.pending.length){let l=!0;return t&&setTimeout(()=>{l&&t(o.loaded,o.missing,o.pending,bn)}),()=>{l=!1}}const s=Object.create(null),a=[];let i,c;return o.pending.forEach(l=>{const{provider:h,prefix:g}=l;if(g===c&&h===i)return;i=h,c=g,a.push(xt(h,g));const w=s[h]||(s[h]=Object.create(null));w[g]||(w[g]=[])}),o.pending.forEach(l=>{const{provider:h,prefix:g,name:w}=l,y=xt(h,g),C=y.pendingIcons||(y.pendingIcons=new Set);C.has(w)||(C.add(w),s[h][g].push(w))}),a.forEach(l=>{const h=s[l.provider][l.prefix];h.length&&ka(l,h)}),t?ha(t,o,a):bn};function Na(e,t){const r={...e};for(const o in t){const s=t[o],a=typeof s;o in Zn?(s===null||s&&(a==="string"||a==="number"))&&(r[o]=s):a===typeof r[o]&&(r[o]=o==="rotate"?s%4:s)}return r}const Ca=/[\s,]+/;function _a(e,t){t.split(Ca).forEach(r=>{switch(r.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function Ia(e,t=0){const r=e.replace(/^-?[0-9.]*/,"");function o(s){for(;s<0;)s+=4;return s%4}if(r===""){const s=parseInt(e);return isNaN(s)?0:o(s)}else if(r!==e){let s=0;switch(r){case"%":s=25;break;case"deg":s=90}if(s){let a=parseFloat(e.slice(0,e.length-r.length));return isNaN(a)?0:(a=a/s,a%1===0?o(a):0)}}return t}function Fa(e,t){let r=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const o in t)r+=" "+o+'="'+t[o]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+r+">"+e+"</svg>"}function Pa(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Ea(e){return"data:image/svg+xml,"+Pa(e)}function Ta(e){return'url("'+Ea(e)+'")'}let Et;function Oa(){try{Et=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{Et=null}}function Aa(e){return Et===void 0&&Oa(),Et?Et.createHTML(e):e}const no={...eo,inline:!1},$a={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},La={display:"inline-block"},br={backgroundColor:"currentColor"},oo={backgroundColor:"transparent"},jn={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},kn={WebkitMask:br,mask:br,background:oo};for(const e in kn){const t=kn[e];for(const r in jn)t[e+r]=jn[r]}const za={...no,inline:!0};function Sn(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const Da=(e,t,r)=>{const o=t.inline?za:no,s=Na(o,t),a=t.mode||"svg",i={},c=t.style||{},l={...a==="svg"?$a:{}};if(r){const v=er(r,!1,!0);if(v){const _=["iconify"],Y=["provider","prefix"];for(const q of Y)v[q]&&_.push("iconify--"+v[q]);l.className=_.join(" ")}}for(let v in t){const _=t[v];if(_!==void 0)switch(v){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":l.ref=_;break;case"className":l[v]=(l[v]?l[v]+" ":"")+_;break;case"inline":case"hFlip":case"vFlip":s[v]=_===!0||_==="true"||_===1;break;case"flip":typeof _=="string"&&_a(s,_);break;case"color":i.color=_;break;case"rotate":typeof _=="string"?s[v]=Ia(_):typeof _=="number"&&(s[v]=_);break;case"ariaHidden":case"aria-hidden":_!==!0&&_!=="true"&&delete l["aria-hidden"];break;default:o[v]===void 0&&(l[v]=_)}}const h=Xs(e,s),g=h.attributes;if(s.inline&&(i.verticalAlign="-0.125em"),a==="svg"){l.style={...i,...c},Object.assign(l,g);let v=0,_=t.id;return typeof _=="string"&&(_=_.replace(/-/g,"_")),l.dangerouslySetInnerHTML={__html:Aa(ra(h.body,_?()=>_+"ID"+v++:"iconifyReact"))},p.createElement("svg",l)}const{body:w,width:y,height:C}=e,j=a==="mask"||(a==="bg"?!1:w.indexOf("currentColor")!==-1),E=Fa(w,{...g,width:y+"",height:C+""});return l.style={...i,"--svg":Ta(E),width:Sn(g.width),height:Sn(g.height),...La,...j?br:oo,...c},p.createElement("span",l)};Xn(!0);na("",ua);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,r="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"||!Vs(o))&&console.error(r)}catch{console.error(r)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let r in t){const o="IconifyProviders["+r+"] is invalid.";try{const s=t[r];if(typeof s!="object"||!s||s.resources===void 0)continue;oa(r,s)||console.error(o)}catch{console.error(o)}}}}function so(e){const[t,r]=p.useState(!!e.ssr),[o,s]=p.useState({});function a(C){if(C){const j=e.icon;if(typeof j=="object")return{name:"",data:j};const E=gn(j);if(E)return{name:j,data:E}}return{name:""}}const[i,c]=p.useState(a(!!e.ssr));function l(){const C=o.callback;C&&(C(),s({}))}function h(C){if(JSON.stringify(i)!==JSON.stringify(C))return l(),c(C),!0}function g(){var C;const j=e.icon;if(typeof j=="object"){h({name:"",data:j});return}const E=gn(j);if(h({name:j,data:E}))if(E===void 0){const v=Sa([j],g);s({callback:v})}else E&&((C=e.onLoad)===null||C===void 0||C.call(e,j))}p.useEffect(()=>(r(!0),l),[]),p.useEffect(()=>{t&&g()},[e.icon,t]);const{name:w,data:y}=i;return y?Da({...Pr,...y},e,w):e.children?e.children:e.fallback?e.fallback:p.createElement("span",{})}const ce=p.forwardRef((e,t)=>so({...e,_ref:t}));p.forwardRef((e,t)=>so({inline:!0,...e,_ref:t}));const pt="USD",Ma=(e,t=pt)=>{const r=(e==null?void 0:e.prices)??[];if(!r.length)return null;const o=i=>{var h,g;const c=i.find(w=>{var y;return!!((y=w.discounted)!=null&&y.value)});if(c)return{cent:c.discounted.value.centAmount,cur:c.discounted.value.currencyCode,regularCent:(h=c.value)==null?void 0:h.centAmount};const l=(g=i[0])==null?void 0:g.value;return l?{cent:l.centAmount,cur:l.currencyCode}:null},s=r.filter(i=>{var c,l;return((l=((c=i.discounted)==null?void 0:c.value)||i.value)==null?void 0:l.currencyCode)===t}),a=o(s);return a||o(r)||null},Ba=(e,t)=>{if(!Array.isArray(e))return"";const r=e.find(o=>o.name===t)||e.find(o=>{var s;return((s=o.name)==null?void 0:s.toLowerCase())===t.toLowerCase()});return!r||!r.value?"":typeof r.value=="object"?r.value.label||"":r.value},qa=e=>{let t="";if(Array.isArray(e)){const r=e.find(o=>o.name==="size")||e.find(o=>o.name==="Size");r&&r.value&&(t=typeof r.value=="object"?r.value.label||"":r.value)}return{sizeLabel:t}},ft=e=>Ba((e==null?void 0:e.attributesRaw)??[],"color"),mt=e=>qa((e==null?void 0:e.attributesRaw)??[]).sizeLabel,Ve=e=>e.charAt(0).toUpperCase()+e.slice(1),Nn={standard:{label:"Standard Delivery",fee:0,subtitle:"Arrives in 4–6 days (Free)",icon:"mdi:clock-outline"},express:{label:"Express Delivery",fee:5,subtitle:"Arrives in 1–2 days (+$5)",icon:"mdi:flash"},sameday:{label:"Same-Day Delivery",fee:10,subtitle:"Available in select locations (+$10)",icon:"mdi:truck-fast-outline"}},Ra={standard:"GROUND",express:"2-DAY SHIPPING",sameday:"OVERNIGHT"},tt=(e,t)=>{try{return e.toLocaleString("en-US",{style:"currency",currency:t||"USD"})}catch{return`${t} ${e.toFixed(2)}`}},ao=e=>e==null?void 0:e.masterVariant,Cn=e=>Array.isArray(e==null?void 0:e.variants)?e.variants:[],Jt=e=>{const t=ao(e);return t?[t,...Cn(e)]:Cn(e)},Ua=(e,t=0)=>Jt(e)[t],Ha=e=>{var t,r;return((r=(t=e==null?void 0:e.images)==null?void 0:t[0])==null?void 0:r.url)??""},_n=(e,t)=>{var r,o,s,a,i,c,l,h;return Ha(t)||((a=(s=(o=(r=e.imageGroups)==null?void 0:r[0])==null?void 0:o.images)==null?void 0:s[0])==null?void 0:a.link)||((h=(l=(c=(i=e.image_groups)==null?void 0:i[0])==null?void 0:c.images)==null?void 0:l[0])==null?void 0:h.link)||""},In=e=>(e==null?void 0:e.name)||(e==null?void 0:e.title)||(e==null?void 0:e.productName)||"any",Kt=e=>{var a,i,c,l,h,g;const t=e?Ma(e,pt):null;if(t!=null&&t.cent&&(t!=null&&t.cur))return{amount:+(t.cent/100),currency:t.cur,regularAmount:t.regularCent?t.regularCent/100:void 0};const r=(c=(i=(a=e==null?void 0:e.prices)==null?void 0:a[0])==null?void 0:i.value)==null?void 0:c.centAmount,o=((g=(h=(l=e==null?void 0:e.prices)==null?void 0:l[0])==null?void 0:h.value)==null?void 0:g.currencyCode)??pt;return{amount:Number.isFinite(r)?+(Number(r)/100):0,currency:o}},Fn=(e,t)=>{const{amount:r}=Kt(t);if(r)return r;const o=(e==null?void 0:e.price)??(e==null?void 0:e.sellingPrice)??(e==null?void 0:e.unitPrice)??(e==null?void 0:e.mrp)??0,s=Number(o);return Number.isFinite(s)?s:0},Va=e=>{var t;return(e==null?void 0:e.sku)||((t=e==null?void 0:e.variant)==null?void 0:t.sku)||(e==null?void 0:e.selectedSku)||""},Ya=e=>{var t;return(e==null?void 0:e.color)||(e==null?void 0:e.selectedColor)||((t=e==null?void 0:e.variant)==null?void 0:t.color)||""},Ja=e=>{var t;return(e==null?void 0:e.size)||(e==null?void 0:e.selectedSize)||((t=e==null?void 0:e.variant)==null?void 0:t.size)||""},Pn=20,Ka=({open:e,onClose:t,product:r,index:o,addresses:s,addressLoading:a,variationAttributes:i})=>{const h=Jt(r),g=Math.min(Math.max(0,o||0),Math.max(0,h.length-1)),[w,y]=p.useState([]),[C,j]=p.useState(0),[E,v]=p.useState([]);p.useEffect(()=>{if(r!=null&&r.variants){const d=_(r.variants,r.imageGroups,i);y(d)}},[r]);const _=(d,f,u)=>{const{colorMap:x,sizeMap:b}=Y(u),O={};f==null||f.forEach(F=>{var ie,Ne,Ae;const D=(ie=F.variationAttributes)==null?void 0:ie.find($e=>$e.id==="color"),P=(Ae=(Ne=D==null?void 0:D.values)==null?void 0:Ne[0])==null?void 0:Ae.value;P&&(O[P]||(O[P]={}),O[P][F.viewType]=F.images)});const U=d.reduce((F,D)=>{const P=D.variationValues.color,ie=D.variationValues.size;return F[P]||(F[P]={color:P,name:x[P]||P,images:O[P]||{},variants:[]}),F[P].variants.push({size:ie,name:b[ie]||ie,...D}),F},{});return Object.values(U).sort((F,D)=>{const P=F.colorName||F.color||"",ie=D.colorName||D.color||"";return P.localeCompare(ie)}).map(F=>({...F,variants:F.variants.sort((D,P)=>Number(D.size)-Number(P.size))}))},Y=d=>{const f={},u={};return d==null||d.forEach(x=>{x.id==="color"&&x.values.forEach(b=>{f[b.value]=b.name}),x.id==="size"&&x.values.forEach(b=>{u[b.value]=b.name})}),{colorMap:f,sizeMap:u}},q=h.length,[V,ke]=p.useState(g),[S,J]=p.useState(null),[te,xe]=p.useState(null),we=p.useRef(null),st=p.useRef(null),k=Ua(r,V),[ye,H]=p.useState(""),[A,Ue]=p.useState(""),[at,Me]=p.useState(!1),[Xe,ue]=p.useState(!1),[Se,Ee]=p.useState(!1),[L,Ie]=p.useState(""),[be,re]=p.useState(!1),[fe,wt]=p.useState(null),[m,T]=p.useState([]),[M,W]=p.useState([]),[B,$]=p.useState([]),[K,X]=p.useState(!1),[R,ne]=p.useState(),[Te,Be]=p.useState(!0),[Q,me]=p.useState(!1),[ve,he]=p.useState(!1),[G,N]=p.useState({id:"001"}),[Z,z]=p.useState(!1),[oe,se]=p.useState(!1),[Fe,yt]=p.useState("card"),[Pe,ae]=p.useState(!1),[bt,je]=p.useState(!1),[I,ee]=p.useState(!1),[vt,jt]=p.useState(null),[$t,Ar]=p.useState(null),[tr,$r]=p.useState(""),[Lr,zr]=p.useState(!1),[kt,io]=p.useState(r==null?void 0:r.id),Lt=p.useRef(null);p.useEffect(()=>{const d=Jt(r),f=Math.min(Math.max(0,o||0),Math.max(0,d.length-1));ke(f);const u=ao(r),x=ft(u),b=mt(u);we.current=x||null,st.current=b||null,J(x||null),xe(b||null)},[o,r]),p.useEffect(()=>{Lt.current&&(Lt.current.scrollTop=Lt.current.scrollHeight)},[m,K,Q,ve,Z,oe,Pe,bt,I,at,Xe]);const it="var(--tanya)",Dr="var(--tanya-contrast)",zt=it,Oe="#804c9e",lo=()=>{console.log("AgenticShopping feedback:",{rating:$t,comment:tr}),zr(!0)},co=()=>{Ar(null),$r(""),zr(!0)},Mr=d=>{const u=((d==null?void 0:d.intentMandateId)||(d==null?void 0:d.intent_mandate_id)||(d==null?void 0:d.id)||null)??vt;return e?n.jsxs("div",{className:"mt-3 flex items-start gap-3 rounded-lg border border-green-200 bg-green-50 p-4 text-green-800",children:[n.jsx("div",{className:"success-tick-animation",children:n.jsx(ce,{icon:"mdi:check-circle",width:"28",color:"#16a34a"})}),n.jsxs("div",{className:"text-sm w-full",children:[n.jsx("div",{className:"font-semibold",children:"Success!"}),n.jsx("div",{children:"Your smart order has been saved. I’ll watch the price and auto-purchase when the conditions are met."}),u&&n.jsxs("div",{className:"mt-2 text-xs font-medium",children:["Your Smart Order ID: ",n.jsx("span",{className:"font-semibold text-blue-600 cursor-pointer underline",children:u})]}),!Lr&&n.jsxs("div",{className:"mt-4 rounded-lg bg-white/70 p-3 text-gray-900",children:[n.jsx("h4",{className:"font-semibold mb-1",children:"Please post your feedback here"}),n.jsx("p",{className:"text-sm text-gray-700 mb-3",children:"Rate us on how much our response was helpful"}),n.jsx("div",{className:"flex items-center gap-1 mb-3",children:[1,2,3,4,5].map(x=>n.jsx("button",{type:"button",onClick:()=>Ar(x),className:"p-0.5",children:n.jsx(ce,{icon:$t&&$t>=x?"mdi:star":"mdi:star-outline",width:"20",className:"text-yellow-500"})},x))}),n.jsx("label",{className:"block text-sm text-gray-700 mb-1",children:"Tell us more about the response"}),n.jsx("textarea",{value:tr,onChange:x=>$r(x.target.value),rows:3,className:"mt-1 w-full rounded-md border border-gray-300 p-2 text-sm outline-none focus:ring-1 focus:ring-gray-300",placeholder:"Your feedback helps us improve..."}),n.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[n.jsx("button",{type:"button",onClick:co,className:"px-4 py-2 rounded-full border text-sm font-medium hover:bg-gray-50",children:"Cancel"}),n.jsx("button",{type:"button",onClick:lo,className:"px-4 py-2 rounded-full text-sm font-semibold text-white shadow",style:{background:it},disabled:!$t&&!tr.trim(),children:"Submit"})]})]}),Lr&&n.jsx("div",{className:"mt-3 text-xs text-green-900 font-medium",children:"Thanks for your feedback! 💚"})]})]}):null},uo=async()=>{try{$(s);const d=JSON.parse(sessionStorage.getItem("customerData")||"{}");let f=(d==null?void 0:d.basketId)||localStorage.getItem(Tt);if(!f){const u=await Je(),x="Bearer "+(u==null?void 0:u.access_token),b=await jr(x);f=(b==null?void 0:b.basket_id)||b.basketId}fo(f),H(f)}catch(d){console.error("Error fetching addresses:",d)}},fo=async d=>{const f=await ts(d);console.log(f,"shipping methods"),v(f)};console.log(ye,"the basket id");const St=(d,f)=>{T(u=>[...u,{query:"",response:"__SNAPSHOT__",snapshotStage:d,snapshotPayload:f}])},Br=(d,f)=>{T(u=>u.map(x=>x.response==="__CARD__"?{...x,response:"__SNAPSHOT__",snapshotStage:d??x.snapshotStage,snapshotPayload:f??x.snapshotPayload}:x))},mo=()=>{T(d=>d.filter(f=>!(f.query===""&&f.response!=="__SNAPSHOT__"&&f.response!=="__TEXT__")))},Dt=()=>{je(!1),X(!1),he(!1),se(!1),me(!1),z(!1),ae(!1),ee(!1),re(!1),wt(null),mo(),Me(!1),ue(!1)},ho=()=>{X(!1),me(!1),he(!1),N("standard"),z(!1),se(!1),yt("card"),ae(!1),je(!1),ee(!1),Be(!0),wt(null),localStorage.removeItem("agentic_order"),localStorage.removeItem("agentic_order_address"),localStorage.removeItem("agentic_order_delivery"),localStorage.removeItem("agentic_order_payment"),localStorage.removeItem("agentic_order_final")},Mt=p.useMemo(()=>Jt(r).map((f,u)=>({index:u,variant:f,images:((f==null?void 0:f.images)||[]).map(x=>(x==null?void 0:x.url)||"").filter(Boolean)})),[r]),Nt=p.useMemo(()=>Mt.length?!!((S||void 0)&&(te||void 0)):!1,[Mt,S,te,k]),po=Se||be||!Nt,Ct=d=>{const f=Number((d==null?void 0:d.quantity)??1);return Number.isFinite(f)&&f>0?f:1},qr=d=>{const f=Ct(d),u=Number((d==null?void 0:d.max_price_minor)??0);return Number.isFinite(u)&&u>0?+(u/100):+(Fn(r,k)*f)},Rr=d=>{const f=fe,u=Kt(k),x=d||(f==null?void 0:f.currency)||u.currency||pt,b=qr(f),O=+(b*.08).toFixed(2),U=(G==null?void 0:G.price)||0;return{product_total:b,tax:O,shipping_fee:U,currency:x}},rr=async(d,f,u)=>{Br(),ho(),Ee(!0),re(!0),Me(!1),ue(!1);const x=M.slice(-Pn);try{const b=await ur(null,null);if(!b)throw new Error("Failed to fetch token");const O=localStorage.getItem("customerNumber"),U=localStorage.getItem("isLoggedIn"),D=`https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({registered:String(U||!1),userId:String(O||new Date().getTime())}).toString()}`,P=await fetch(`${D}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b}`},body:JSON.stringify({flowId:"MTMI0P4LC6",flowAliasId:"BCUA138F2Q",input:{instruction:`Use SKU ${f}. Currency is USD. ${d}`,metadata:{productId:(r==null?void 0:r.id)??null,skuId:f??null,variantIndex:u},context:x}})});if(!P.body)throw new Error("Readable stream not supported");const ie=P.body.getReader(),Ne=new TextDecoder;let Ae="",$e="",Ze="";for(;;){const{done:_e,value:He}=await ie.read();if(_e)break;Ae+=Ne.decode(He,{stream:!0});const lt=Ae.split(`
17
17
  `);Ae=lt.pop()||"";for(const ct of lt){if(!ct.startsWith("data:"))continue;const et=ct.slice(5).trim();try{const qe=JSON.parse(et),Le=qe.index,pe=qe.data;Le===0?$e=String(pe??""):Le===1&&(Ze=String(pe??""))}catch(qe){console.error("Error parsing JSON chunk:",qe)}}}let Ce=null;if($e){const _e=String($e).replace(/\\n/g,"").trim();if(_e.startsWith("{")&&_e.endsWith("}"))try{Ce=JSON.parse(_e),Ce.product_id=f,Ce.sku_id=f,localStorage.setItem("agentic_order",JSON.stringify(Ce))}catch(He){console.log(He)}}wt(Ce),Ce&&T(_e=>[..._e,{query:"",response:"__CARD__",snapshotPayload:{extractedDetails:Ce}}]),W(_e=>[..._e,{userQuery:d,mainResponse:$e||"",keywords:Ze||""}].slice(-Pn))}catch(b){console.error("Error sending message to Tanya:",b),re(!1)}finally{Ee(!1)}},Ur=async d=>{if(be||Se||!Nt)return;const f=L.trim();if(!f)return;T(x=>[...x,{query:f,response:""}]),Ie(""),Ue(f);const u=kt||"";if(q<=1){if(u){rr(f,u,V);return}ue(!0),re(!0);return}u?(Me(!0),re(!0)):(ue(!0),re(!0))},go=()=>{const d=kt;d&&rr(A,d,V)},xo=()=>{Me(!1),ue(!0),re(!0)},wo=()=>{if(!kt)return;rr(A,kt,V)},yo=async()=>{X(!0),he(!1),se(!1),je(!1),me(!1),z(!1),ae(!1),ee(!1),await uo(),console.log("calling"),Br("initial",{extractedDetails:fe??void 0})},bo=()=>{if(!R)return;const d=B.find(f=>String(f.addressId??f.id)===R)||null;d&&(localStorage.setItem("agentic_order_address",JSON.stringify(d)),me(!0),he(!0),z(!1),se(!1),ae(!1),je(!1),ee(!1),St("address",d))},vo=()=>{me(!1),he(!1),z(!1),se(!1),ae(!1),je(!1),ee(!1),localStorage.removeItem("agentic_order_address")},jo=()=>{G.id&&(localStorage.setItem("agentic_order_delivery",G.id),z(!0),se(!0),ae(!1),je(!1),ee(!1),St("delivery",{method:G.id,...G}))},Hr=()=>{he(!1),z(!1),se(!1),ae(!1),je(!1),ee(!1),re(!1),Dt(),T(d=>[...d,{query:"",response:"__TEXT__",snapshotPayload:{text:"No worries! I’ve cancelled this request. You can start again anytime — just tell me what you’d like to buy or track"}}])},ko=()=>{z(!1),se(!1),ae(!1),je(!1),ee(!1),localStorage.removeItem("agentic_order_delivery")},So=()=>{Fe&&(localStorage.setItem("agentic_order_payment",Fe),ae(!0),je(!0),ee(!1),St("payment",{method:Fe}))},No=()=>{se(!1),ae(!1),je(!1),ee(!1),re(!1),Dt(),T(d=>[...d,{query:"",response:"__TEXT__",snapshotPayload:{text:"No worries! I’ve cancelled this request. You can start again anytime — just tell me what you’d like to buy or track"}}])},Co=()=>{ae(!1),je(!1),ee(!1),localStorage.removeItem("agentic_order_payment")},_o=async()=>{try{Ee(!0);const d=fe||{},f=JSON.parse(localStorage.getItem("agentic_order_address")||"null"),u=localStorage.getItem("agentic_order_delivery"),x=localStorage.getItem("agentic_order_payment")||"card",{product_total:b,tax:O,shipping_fee:U,currency:F}=Rr(),D=d.shopper_id||localStorage.getItem("customerId")||void 0,P=(f==null?void 0:f.addressId)||(f==null?void 0:f.id)||void 0,ie=u?Ra[u]:"GROUND",Ne="card-visa",Ae=k==null?void 0:k.sku,$e=(r==null?void 0:r.id)||"",Ze=Ct(d),Ce=typeof d.max_price_minor=="number"?d.max_price_minor:Math.round(b*100),lt={shopper_id:D,shipping_address_id:P,shipping_method_id:ie,payment_method_id:Ne,sku:Ae,platform:"SFCC",storeCode:"Sites-SiteGenesis-Site",product_id:$e,quantity:Ze,max_price_minor:Ce,currency:F,instruction_text:A};if(console.log(D,P,"the selected ids"),!D||!P){console.error("Missing shopper_id or shipping_address_id for intent-mandate",{shopperId:D,shippingAddressId:P}),alert("Missing customer or address information. Please re-select address and try again."),Ee(!1);return}const et=(await Je()).access_token;if(!et)throw new Error("Failed to fetch auth token for intent-mandate");const{serverUrl:qe}=Ke(),Le=await fetch(`${qe}/api/intent-mandate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${et}`},body:JSON.stringify(lt)});if(!Le.ok){const Oo=await Le.text().catch(()=>"");console.error("intent-mandate failed",Le.status,Oo),alert("Something went wrong while saving your smart order. Please try again."),Ee(!1);return}const pe=await Le.json().catch(()=>null);console.log("intent-mandate success:",pe);const dt=(pe==null?void 0:pe.intent_mandate_id)||(pe==null?void 0:pe.intent_mandateId)||(pe==null?void 0:pe.key)||null;dt&&jt(dt);const Wr={...d,address:f,delivery:u,payment:x,summary:{product_total:b,tax:O,shipping_fee:U,currency:F},intent_mandate_id:dt};localStorage.setItem("agentic_order_final",JSON.stringify(Wr)),ee(!0),Be(!1),St("final",Wr),St("success",{intentMandateId:dt}),Dt()}catch(d){console.error("Error in handleConfirmWatch / intent-mandate:",d),alert("Unable to complete your smart order right now. Please try again in a moment.")}finally{Ee(!1)}},Vr=()=>{Dt(),T(d=>[...d,{query:"",response:"__TEXT__",snapshotPayload:{text:"No worries! I’ve cancelled this request. You can start again anytime — just tell me what you’d like to buy or track"}}])},Io=({selectedIndex:d})=>{var P;const f=((P=w[d])==null?void 0:P.images.large[0].link)||_n(r,k),u=In(r),x=kt||"",b=ft(k)||"",O=mt(k)||"",{amount:U}=Kt(k),F=!!(r!=null&&r.id),D=F;return n.jsx("div",{className:"mx-4 mt-2 rounded-xl border border-gray-200 bg-white p-4",children:n.jsxs("div",{className:"flex flex-col sm:flex-row items-center sm:items-center gap-4",children:[n.jsx("div",{className:"flex-shrink-0 flex justify-center sm:justify-start",children:n.jsx("div",{className:"w-[150px] h-[150px] rounded-lg bg-gray-50 border border-gray-200 flex items-center justify-center overflow-hidden",children:f?n.jsx("img",{src:f,alt:u,className:"object-contain w-full h-full"}):n.jsx(ce,{icon:"mdi:image-outline",width:"28",className:"opacity-60"})})}),n.jsxs("div",{className:"flex-grow flex flex-col justify-center text-center",children:[n.jsx("div",{className:"text-2xl font-bold text-gray-900 mb-1",children:u}),n.jsx("div",{className:"text-sm text-gray-700 mb-1",children:[x&&`SKU: ${x}`,b&&`Color: ${b}`,O&&`Size: ${O}`].filter(Boolean).join(" • ")||"—"}),n.jsx("div",{className:"mt-1 text-xl font-semibold text-gray-900",children:F?`$${r.price}`:"Currently unavailable"}),F&&!D&&n.jsx("div",{className:"mt-1 text-xs font-medium text-red-600",children:"Currently out of stock"})]})]})})},Yr=({showSubmit:d=!0})=>{const f={};Mt.map(x=>ft(x.variant)).filter(x=>!!x&&!f[x]&&(f[x]=!0));const u={};return Mt.map(x=>mt(x.variant)).filter(x=>!!x&&!u[x]&&(u[x]=!0)),n.jsxs("div",{className:"mx-4 mt-4 mb-2 rounded-xl border border-gray-200 bg-white p-4 animate-fade-in",children:[n.jsx("h3",{className:"font-semibold text-gray-800",children:"Choose a variant"}),n.jsxs("div",{className:"mt-4",children:[n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx("div",{className:"text-sm font-bold",children:"Color :"}),S&&n.jsx("div",{className:"text-sm text-gray-600",children:S})]}),n.jsx("div",{className:"flex flex-wrap gap-4 mt-2",children:w.map((x,b)=>{const O=x.name,U=S===O,F=x.images.large[0].disBaseLink||x.images.large[0].link;return n.jsx("div",{className:`flex flex-col items-center w-28 border rounded-md p-2
18
- ${U?"border-2 border-[#804c9e]":"border-gray-300"}`,children:n.jsx("button",{onClick:()=>{J(O),xe(null),ke(null),j(b)},className:"w-full h-20 flex items-center justify-center overflow-hidden",title:O,children:F?n.jsx("img",{src:F,alt:O,className:"w/full h-full object-contain"}):n.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs px-1",children:O})})},O)})})]}),S&&n.jsxs("div",{className:"mt-4",children:[n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx("div",{className:"text-sm font-bold",children:"Size :"}),te&&n.jsx("div",{className:"text-sm text-gray-600",children:te})]}),n.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:(()=>{const x=w.find(b=>b.name===S);return x?x.variants.map((b,O)=>{const U=b.name,F=te===U;return n.jsx("button",{onClick:()=>{xe(U),ke(O),io(b.productId)},className:`px-4 py-2 rounded-md border text-sm ${F?"border-2 border-[#804c9e] font-semibold":"border-gray-300"}`,title:U,children:U},`size-${U}`)}):null})()})]}),d&&n.jsx("div",{className:"mt-4 flex justify-end",children:n.jsx("button",{onClick:wo,className:"px-6 py-2.5 rounded-full font-semibold text-white shadow-md",style:{background:Oe},disabled:!Nt,children:"Submit"})})]})},Jr=(d,f=!0)=>{!(d!=null&&d.extractedDetails)&&d&&(d={extractedDetails:d});const u=(d==null?void 0:d.extractedDetails)||fe;if(!u)return null;const x=Ct(u),{currency:b}=Kt(k),O=Fn(r,k),U=Number((u==null?void 0:u.max_price_minor)??0),D=Number.isFinite(U)&&U>0?+(U/100):+(O*x),P=(u==null?void 0:u.currency)||b||pt,ie=k!=null&&k.sku?k.sku:u.product_id;return n.jsxs("div",{className:"px-6 pb-6 flex flex-col items-center space-y-4",style:{backgroundColor:"#e5dbeb"},children:[n.jsx("p",{className:"text-base font-semibold text-center mt-2",style:{color:Dr},children:"Here’s what I found from your instruction:"}),n.jsxs("div",{className:"w-full max-w-md bg-white rounded-xl shadow-inner p-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-y-2 text-sm",children:[n.jsx("p",{className:"font-semibold text-gray-600",children:"SKU:"}),n.jsx("p",{className:"text-gray-800",children:ie}),n.jsx("p",{className:"font-semibold text-gray-600",children:"Quantity:"}),n.jsx("p",{className:"text-gray-800",children:Ct(u)}),n.jsx("p",{className:"font-semibold text-gray-600",children:"Currency:"}),n.jsx("p",{className:"text-gray-800",children:P}),n.jsx("p",{className:"font-semibold text-gray-600",children:"Maximum Total Price:"}),n.jsx("p",{className:"text-gray-800",children:tt(D,P)})]}),n.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs",children:[ft(k)&&n.jsxs("span",{className:"rounded-full bg-gray-100 px-2 py-1",children:["Color: ",ft(k)]}),mt(k)&&n.jsxs("span",{className:"rounded-full bg-gray-100 px-2 py-1",children:["Size: ",mt(k)]}),(k==null?void 0:k.sku)&&n.jsxs("span",{className:"rounded-full bg-gray-100 px-2 py-1",children:["SKU: ",k.sku]})]})]}),!f&&n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"text-sm font-medium text-gray-700 text-center max-w-[90%] leading-relaxed",style:{color:Dr},children:["Would you like me to ",n.jsx("strong",{children:"lock this in"})," and monitor it for you?"]}),n.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[n.jsxs("button",{onClick:yo,disabled:K,className:`relative inline-flex items-center justify-center px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${K?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{background:Oe},children:[n.jsx(ce,{icon:"fluent:checkmark-circle-24-filled",className:"mr-2",width:"18",height:"18"}),"Yes, lock it in"]}),n.jsxs("button",{onClick:Vr,disabled:K,className:`relative inline-flex items-center justify-center px-6 py-2.5 rounded-full font-semibold border transition-all duration-300 ${K?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{borderColor:Oe,color:Oe},children:[n.jsx(ce,{icon:"fluent:dismiss-circle-24-filled",className:"mr-2",width:"18",height:"18"}),"No"]})]})]})]})},Kr=(d,f=!0)=>{var ct,et,qe,Le,pe;const u=d||{},x=((ct=u==null?void 0:u.summary)==null?void 0:ct.currency)||(fe==null?void 0:fe.currency)||pt,b=_n(r,k),O=In(r),U=k!=null&&k.sku?k.sku:(r==null?void 0:r.id)??(fe==null?void 0:fe.product_id),F=(k==null?void 0:k.sku)??Va(r),D=ft(k)||Ya(r),P=mt(k)||Ja(r),ie=Ct(u),Ne=((et=u==null?void 0:u.summary)==null?void 0:et.product_total)!=null?+u.summary.product_total:qr(u),Ae=ie>0?+(Ne/ie).toFixed(2):0,$e=Ne,Ze=((qe=u==null?void 0:u.summary)==null?void 0:qe.tax)??+(Ne*.08).toFixed(2),Ce=((Le=u==null?void 0:u.summary)==null?void 0:Le.shipping_fee)??((G==null?void 0:G.price)||0),_e=u!=null&&u.address?[u.address.addressLine1,u.address.addressLine2,u.address.street,[u.address.city,u.address.state,u.address.postalCode].filter(Boolean).join(", "),u.address.country].filter(Boolean).map(dt=>Ve(String(dt))).join(", "):"—",He=(u==null?void 0:u.payment)||"card",lt=He==="card"?n.jsxs(n.Fragment,{children:["Credit Card — Mastercard",n.jsx("br",{}),"•••• 7820 Exp: 12/26"]}):n.jsx(n.Fragment,{children:Ve(He)});return n.jsxs("div",{className:"mx-auto mt-3 mb-3 rounded-2xl bg-white",children:[n.jsx("div",{className:"px-6 pt-5 pb-3",children:n.jsxs("h3",{className:"font-semibold text-lg mb-2 text-gray-800 flex items-center gap-2",children:[n.jsx(ce,{icon:"mdi:receipt-text-check-outline",width:"24",color:it}),"All set! Here’s what your smart order looks like 🧾"]})}),n.jsx("div",{className:"px-6 pb-4",children:n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-12 gap-4 rounded-xl border border-gray-200 bg-gray-50 p-3",children:[n.jsx("div",{className:"sm:col-span-2 flex",children:n.jsx("div",{className:"w-30 h-26 sm:w-30 sm:h-26 overflow-hidden rounded-lg bg-white border border-gray-200 flex items-center justify-center mx-auto sm:mx-0",children:b?n.jsx("img",{src:b,alt:O,className:"w-full h-full object-contain"}):n.jsx(ce,{icon:"mdi:image-outline",width:"24",className:"opacity-50"})})}),n.jsxs("div",{className:"sm:col-span-10",children:[n.jsxs("div",{className:"mb-3",children:[n.jsx("div",{className:"text-lg text-center font-bold text-gray-900",children:O}),n.jsxs("div",{className:"text-xs text-center font-bold text-gray-600",children:[n.jsx("span",{className:"font-medium",children:"SKU:"})," ",U??"—"]}),(F||D||P)&&n.jsxs("div",{className:"text-xs text-gray-600 mt-0.5 text-center",children:[F&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-medium",children:"SKU:"})," ",F,"  "]}),D&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-medium",children:"Color:"})," ",D,"  "]}),P&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-medium",children:"Size:"})," ",P]})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md-grid-cols-3 md:grid-cols-3 gap-3",children:[n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-white p-3 text-center",children:[n.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:"Unit Price"}),n.jsx("div",{className:"mt-0.5 text-base font-bold text-gray-900",children:tt(Ae,x)})]}),n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-white p-3 text-center",children:[n.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:"Quantity"}),n.jsx("div",{className:"mt-0.5 text-base font-bold text-gray-900",children:ie})]}),n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-white p-3 text-center",children:[n.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:"Subtotal"}),n.jsx("div",{className:"mt-0.5 text-base font-bold text-gray-900",children:tt($e,x)})]})]})]})]})}),n.jsxs("div",{className:"px-6 pb-2",children:[n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 mb-3",children:[n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-gray-50 p-3",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"🏠 Address"}),n.jsx("div",{className:"mt-1 text-sm font-semibold text-gray-900 text-center",children:_e})]}),n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-gray-50 p-3",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"💳 Payment"}),n.jsx("div",{className:"mt-1 text-sm font-semibold text-gray-900 text-center",children:lt})]}),n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-gray-50 p-3",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"🚚 Delivery"}),n.jsx("div",{className:"mt-1 text-sm font-semibold text-gray-900 text-center",children:u!=null&&u.delivery&&((pe=Nn[u.delivery])==null?void 0:pe.name)||"—"})]})]}),n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[n.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-gray-200 bg-gray-50 p-4 text-center",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"💰 any(s)"}),n.jsx("div",{className:"mt-1 text-2xl font-bold text-gray-900",children:tt(Ne,x)})]}),n.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-gray-200 bg-gray-50 p-4 text-center",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"🏛️ Taxes"}),n.jsx("div",{className:"mt-1 text-2xl font-bold text-gray-900",children:tt(Ze,x)})]}),n.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-gray-200 bg-gray-50 p-4 text-center",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"🚚 Shipping"}),n.jsx("div",{className:"mt-1 text-2xl font-bold text-gray-900",children:tt(Ce,x)})]})]}),n.jsxs("div",{className:"mt-4 rounded-xl p-4 text-center text-white shadow-sm",style:{background:zt},children:[n.jsx("div",{className:"text-sm/5 opacity-95",children:"🔹 Total Payable"}),n.jsx("div",{className:"mt-1 text-3xl font-extrabold tracking-tight",children:tt(Ne+Ze+Ce,x)})]})]}),!f&&n.jsxs("div",{className:"px-6 pb-5",children:[!I&&n.jsx("p",{className:"mt-3 text-center text-sm text-gray-700",children:"Everything looks good! Do you want me to watch this product and buy it automatically when it meets your condition?"}),I&&Mr({intentMandateId:vt}),Te&&!I&&n.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-3",children:[n.jsx("button",{onClick:_o,className:"inline-flex items-center justify-center rounded-full px-6 py-2.5 font-semibold text-white shadow-md transition-transform duration-150 hover:-translate-y-0.5 hover:shadow-lg",style:{background:zt},children:"Confirm"}),n.jsx("button",{onClick:Vr,className:"inline-flex items-center justify-center rounded-full border px-6 py-2.5 font-semibold hover:bg-gray-50",style:{borderColor:zt,color:zt},children:"Cancel"})]})]})]})},Fo=d=>{if(!d)return null;const f=[d.addressLine1,d.addressLine2,d.street,[d.city,d.state,d.postalCode].filter(Boolean).join(", "),d.country].filter(u=>!!u).map(u=>Ve(u)).join(", ");return n.jsx("div",{className:"px-6 py-4",style:{backgroundColor:"var(--tanya-light)"},children:n.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx(ce,{icon:"mdi:home-map-marker",width:"20",color:it}),n.jsx("div",{className:"font-semibold text-gray-800",children:"Delivery Address"})]}),n.jsx("div",{className:"text-sm text-gray-800",children:f})]})})},Po=d=>{const f=d==null?void 0:d.method,u=f?Nn[f]:void 0;return n.jsx("div",{className:"px-6 py-4",style:{backgroundColor:"var(--tanya-light)"},children:n.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx(ce,{icon:"mdi:truck-delivery",width:"20",color:it}),n.jsx("div",{className:"font-semibold text-gray-800",children:"Delivery Method"})]}),n.jsx("div",{className:"text-sm text-gray-800",children:u?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ce,{icon:u.icon,width:"18"}),n.jsx("span",{className:"font-medium",children:u.label})]}),n.jsx("div",{className:"text-gray-600",children:u.subtitle})]}):"—"})]})})},Eo=d=>{const f=(d==null?void 0:d.method)||"card";return n.jsx("div",{className:"px-6 py-4",style:{backgroundColor:"var(--tanya-light)"},children:n.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx(ce,{icon:"mdi:credit-card-outline",width:"20",color:it}),n.jsx("div",{className:"font-semibold text-gray-800",children:"Payment Method"})]}),n.jsx("div",{className:"text-sm text-gray-800",children:f==="card"?n.jsxs(n.Fragment,{children:["Credit Card — Mastercard",n.jsx("br",{}),"•••• 7820   Exp: 12/26"]}):Ve(f)})]})})},To=(d,f)=>{const u=d.snapshotStage;if(!u||u==="address"&&K||u==="delivery"&&ve||u==="payment"&&oe||u==="final"&&bt)return null;switch(u){case"initial":return Jr(d.snapshotPayload,!f);case"address":return Fo(d.snapshotPayload);case"delivery":return Po(d.snapshotPayload);case"payment":return Eo(d.snapshotPayload);case"final":return Kr(d.snapshotPayload,!f);case"success":return Mr(d.snapshotPayload);default:return null}};return Lo.createPortal(n.jsxs("div",{className:"fixed inset-0",style:{zIndex:2147483647},"aria-modal":"true",role:"dialog",children:[n.jsx("div",{className:"absolute inset-0",style:{background:"rgba(0,0,0,0.25)"},onClick:t}),n.jsx("div",{className:"absolute right-0 ",children:n.jsxs("div",{className:"w-[64.7vw] h-screen bg-white rounded-xl overflow-hidden flex flex-col shadow-xl",children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",borderTopLeftRadius:"0.75rem",borderBottomLeftRadius:"0.75rem",padding:"0.25rem",background:Oe},children:[n.jsxs("div",{style:{display:"flex",color:"#ffffff",alignItems:"center",gap:"0.5rem"},children:[n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"25",viewBox:"0 0 256 256",children:n.jsxs("g",{fill:"currentColor",children:[n.jsx("path",{d:"m194.82 151.43l-55.09 20.3l-20.3 55.09a7.92 7.92 0 0 1-14.86 0l-20.3-55.09l-55.09-20.3a7.92 7.92 0 0 1 0-14.86l55.09-20.3l20.3-55.09a7.92 7.92 0 0 1 14.86 0l20.3 55.09l55.09 20.3a7.92 7.92 0 0 1 0 14.86",opacity:"0.2"}),n.jsx("path",{d:"M197.58 129.06L146 110l-19-51.62a15.92 15.92 0 0 0-29.88 0L78 110l-51.62 19a15.92 15.92 0 0 0 0 29.88L78 178l19 51.62a15.92 15.92 0 0 0 29.88 0L146 178l51.62-19a15.92 15.92 0 0 0 0-29.88ZM137 164.22a8 8 0 0 0-4.74 4.74L112 223.85L91.78 169a8 8 0 0 0-4.78-4.78L32.15 144L87 123.78a8 8 0 0 0 4.78-4.78L112 64.15L132.22 119a8 8 0 0 0 4.74 4.74L191.85 144ZM144 40a8 8 0 0 1 8-8h16V16a8 8 0 0 1 16 0v16h16a8 8 0 0 1 0 16h-16v16a8 8 0 0 1-16 0V48h-16a8 8 0 0 1-8-8m104 48a8 8 0 0 1-8 8h-8v8a8 8 0 0 1-16 0v-8h-8a8 8 0 0 1 0-16h8v-8a8 8 0 0 1 16 0v8h8a8 8 0 0 1 8 8"})]})}),n.jsx("div",{children:n.jsx("p",{className:"font-bold",children:"Agentic Shopping with TANYA"})})]}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:"1.25rem",margin:"0.75rem"},children:n.jsx(ce,{icon:"fluent:dismiss-24-filled",color:"#ffffff",width:"24",height:"24",className:"cursor-pointer",onClick:t})})]}),n.jsxs("div",{ref:Lt,className:"overflow-y-auto pr-5 pb-4 space-y-4 hide-scrollbar flex-grow",children:[n.jsxs("div",{className:"text-sm text-[16px] rounded-r-xl p-3 m-3 rounded-bl-xl w-3/4 text-tanya-contrast",style:{backgroundColor:"#e5dbeb"},children:["Welcome to your smart shopping companion!",n.jsxs("p",{children:["Simply share your instruction — like “If this product goes below $",parseInt(r.price)-5," grab it for me.”"]}),n.jsx("p",{children:"I’ll monitor it, calculate total prices, and place the order when your conditions are met."})]}),n.jsx(Io,{selectedIndex:C}),q>1&&n.jsx(Yr,{showSubmit:!1}),m.map((d,f)=>{var b;const u=f===m.length-1,x=!!d.snapshotStage;return n.jsxs("div",{children:[d.query&&n.jsx("div",{className:"flex justify-end",children:n.jsx("p",{className:"text-sm rounded-l-xl p-3 m-3 mb-4 rounded-br-xl max-w-[75%]",style:{color:"#ffffff",backgroundColor:"var(--tanya)"},children:d.query})}),d.response==="__TEXT__"&&((b=d.snapshotPayload)==null?void 0:b.text)&&n.jsx("div",{className:"mt-2",children:n.jsx("div",{className:"text-sm text-tanya-contrast px-7 py-4 rounded-r-xl rounded-bl-2xl w-full",style:{backgroundColor:"var(--tanya-light)",margin:"0.75rem"},children:n.jsx("div",{className:"flex items-center gap-2",children:n.jsx("p",{children:d.snapshotPayload.text})})})}),u&&at&&q>1&&n.jsxs("div",{className:"mx-4 mt-2 rounded-xl border border-gray-200 bg-white p-4 animate-fade-in",children:[n.jsxs("div",{className:"text-sm text-gray-800",children:["Proceed with color:"," ",n.jsx("span",{className:"font-semibold",children:S||"—"}),", size:"," ",n.jsx("span",{className:"font-semibold",children:te||"—"}),"?"]}),n.jsxs("div",{className:"mt-3 flex gap-3",children:[n.jsx("button",{onClick:go,className:"px-5 py-2 rounded-full text-white font-semibold",style:{background:Oe},children:"Yes"}),n.jsx("button",{onClick:xo,className:"px-5 py-2 rounded-full font-semibold border",style:{borderColor:Oe,color:Oe},children:"No, change SKU"})]})]}),u&&Xe&&n.jsx(Yr,{showSubmit:!0}),u&&Se&&n.jsx("div",{className:"mt-4",children:n.jsx("div",{className:"text-sm text-tanya-contrast px-7 py-4 rounded-r-xl rounded-bl-2xl w-full",style:{backgroundColor:"var(--tanya-light)",margin:"0.75rem"},children:n.jsx("div",{className:"flex items-center gap-2 tanya-pulse-text",children:n.jsx("p",{children:"Reading your instruction and setting things up…"})})})}),(x||d.response==="__CARD__")&&(!Se||!u)&&n.jsx("div",{className:"mt-6 mb-4 mx-4 animate-fade-in",style:{backgroundColor:"#fff",borderRadius:"1rem",boxShadow:"0 2px 8px rgba(0,0,0,0.08)",overflow:"hidden"},children:x?To(d,u):Jr(d.snapshotPayload,!1)})]},f)}),K&&n.jsxs("div",{className:"mt-6 mb-6 mx-6 rounded-xl p-6 shadow-md border border-gray-200 bg-white animate-fade-in",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("h3",{className:"font-semibold text-lg text-gray-800 flex items-center gap-2",children:[n.jsx(ce,{icon:"mdi:home-map-marker",width:"24",color:"var(--tanya-light)"}),"Select a Delivery Address"]}),Q&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ml-2 text-xs px-2 py-1 rounded-full bg-green-100 text-green-700 font-semibold",children:"Selected"}),!I&&n.jsx("button",{onClick:vo,className:"ml-2 text-xs px-2 py-1 rounded-full border hover:bg-gray-50",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},title:"Change address",children:"Change"})]})]}),n.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Choose where you’d like us to deliver this item."}),a?n.jsxs("div",{className:"flex items-center py-6",children:[n.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2",style:{borderBottomColor:"var(--tanya-light)"}}),n.jsx("p",{className:"ml-3 text-gray-600",children:"Fetching your addresses..."})]}):(B==null?void 0:B.length)>0?n.jsxs("div",{className:`space-y-3 ${Q?"opacity-70":""}`,children:[B.map(d=>{const f=[d.addressLine1,d.addressLine2].filter(Boolean).map(F=>Ve(F||"")).join(" "),u=Ve(d.city||""),x=`${Ve(d.state||"")}${d.state&&d.postalCode?", ":""}${d.postalCode||""}`,b=Ve(d.country||""),O=String(d.addressId??d.id),U=R===O;return n.jsxs("label",{className:`flex items-start gap-3 p-4 border rounded-lg cursor-pointer transition hover:shadow-sm ${U?"border-tanya-light":"border-gray-300"} ${Q?"pointer-events-none":""}`,title:Q?"Address already submitted":"",children:[n.jsx("input",{type:"radio",name:"address",className:"mt-1 accent-tanya-light",checked:U,disabled:Q,onChange:()=>ne(O),value:O}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"font-semibold text-gray-800",children:f||"Address"}),n.jsxs("div",{className:"text-sm text-gray-700",children:[u,n.jsx("br",{}),x,n.jsx("br",{}),b]})]})]},O)}),n.jsxs("div",{className:"flex justify-between pt-2",children:[n.jsx("button",{onClick:Hr,className:"px-6 py-2.5 rounded-full font-semibold border transition-all hover:-translate-y-0.5 hover:shadow-sm",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},children:"Cancel"}),n.jsx("button",{onClick:bo,disabled:Q,className:`px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${Q?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{background:Oe},children:Q?"Address Submitted":"Submit Address"})]})]}):n.jsx("div",{className:"text-center py-8 text-gray-600",children:"No addresses found. Please add a new one in your profile."})]}),ve&&n.jsxs("div",{className:"mt-2 mb-6 mx-6 rounded-xl p-6 shadow-md border border-gray-200 bg-white animate-fade-in",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("h3",{className:"font-semibold text-lg text-gray-800 flex items-center gap-2",children:[n.jsx(ce,{icon:"mdi:truck-delivery",width:"24",color:"var(--tanya-light)"}),"Great! Now choose how fast you want it delivered 🚚"]}),Z&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ml-2 text-xs px-2 py-1 rounded-full bg-green-100 text-green-700 font-semibold",children:"Selected"}),!I&&n.jsx("button",{onClick:ko,className:"ml-2 text-xs px-2 py-1 rounded-full border hover:bg-gray-50",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},title:"Change shipping method",children:"Change"})]})]}),n.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Which one would you like me to use for this order?"}),n.jsx("div",{className:`space-y-3 ${Z?"opacity-70":""}`,children:E.map(d=>{const f=G.id===d.id;return n.jsxs("label",{className:`flex items-start gap-3 p-4 border rounded-lg cursor-pointer transition hover:shadow-sm ${f?"border-tanya-light":"border-gray-300"} ${Z?"pointer-events-none":""}`,title:Z?"Delivery already submitted":"",children:[n.jsx("input",{type:"radio",name:"delivery",className:"mt-1 accent-tanya-light",checked:f,disabled:Z,onChange:()=>N(d)}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"font-semibold text-gray-800 flex items-center gap-2",children:d.name}),n.jsx("div",{className:"text-sm text-gray-700",children:d.description})]}),n.jsx("div",{className:"text-sm font-semibold text-gray-800",children:d.price===0?"Free":d.price})]},key)})}),n.jsxs("div",{className:"flex justify-between pt-4",children:[n.jsx("button",{onClick:Hr,className:"px-6 py-2.5 rounded-full font-semibold border transition-all hover:-translate-y-0.5 hover:shadow-sm",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},children:"Cancel"}),n.jsx("button",{onClick:jo,disabled:Z,className:`px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${Z?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{background:Oe},children:Z?"Delivery Submitted":"Submit Delivery Option"})]})]}),oe&&n.jsxs("div",{className:"mt-2 mb-6 mx-6 rounded-xl p-6 shadow-md border border-gray-200 bg-white animate-fade-in",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("h3",{className:"font-semibold text-lg text-gray-800 flex items-center gap-2",children:[n.jsx(ce,{icon:"mdi:credit-card-outline",width:"24",color:"var(--tanya-light)"}),"Almost done! 💳"]}),Pe&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ml-2 text-xs px-2 py-1 rounded-full bg-green-100 text-green-700 font-semibold",children:"Selected"}),!I&&n.jsx("button",{onClick:Co,className:"ml-2 text-xs px-2 py-1 rounded-full border hover:bg-gray-50",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},title:"Change payment method",children:"Change"})]})]}),n.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Please choose a payment method for this order:"}),n.jsx("div",{className:`space-y-3 ${Pe?"opacity-70":""}`,children:n.jsxs("label",{className:`flex items-start gap-3 p-4 border rounded-lg cursor-pointer transition hover:shadow-sm ${Fe==="card"?"border-tanya-light":"border-gray-300"} ${Pe?"pointer-events-none":""}`,title:Pe?"Payment already submitted":"",children:[n.jsx("input",{type:"radio",name:"payment",className:"mt-1 accent-tanya-light",checked:Fe==="card",disabled:Pe,onChange:()=>yt("card")}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"font-semibold text-gray-800 flex items-center gap-2",children:[n.jsx(ce,{icon:"mdi:credit-card-chip-outline",width:"18"})," ","Credit Card"]}),Fe==="card"&&n.jsxs("div",{className:"text-sm text-gray-700 mt-1",children:["Mastercard    •••• 7820",n.jsx("br",{}),"Expiry: 12/26"]})]})]})}),n.jsxs("div",{className:"flex justify-between pt-4",children:[n.jsx("button",{onClick:No,className:"px-6 py-2.5 rounded-full font-semibold border transition-all hover:-translate-y-0.5 hover:shadow-sm",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},children:"Cancel"}),n.jsx("button",{onClick:So,disabled:Pe,className:`px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${Pe?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{background:"var(--tanya)"},children:Pe?"Payment Submitted":"Submit Payment Method"})]})]}),bt&&Kr({...fe,address:JSON.parse(localStorage.getItem("agentic_order_address")||"null"),delivery:localStorage.getItem("agentic_order_delivery"),payment:localStorage.getItem("agentic_order_payment"),summary:Rr(fe==null?void 0:fe.currency)},!1)]}),n.jsxs("div",{className:"sticky bottom-0 w-[96%] drop-shadow-xl flex items-center rounded-full bg-white border border-gray-300 m-[15px]",children:[n.jsx("input",{placeholder:be?"Complete the current step…":Nt?`What would you like me to do? (e.g., If this product goes below $${parseInt(r.price)-5}, grab it for me.)`:"Please select a combination first.",disabled:po,className:`w-full rounded-full p-4 outline-none border-none focus:ring-0 focus:border-transparent disabled:bg-gray-100 disabled:cursor-not-allowed
18
+ ${U?"border-2 border-[#804c9e]":"border-gray-300"}`,children:n.jsx("button",{onClick:()=>{J(O),xe(null),ke(null),j(b)},className:"w-full h-20 flex items-center justify-center overflow-hidden",title:O,children:F?n.jsx("img",{src:F,alt:O,className:"w/full h-full object-contain"}):n.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs px-1",children:O})})},O)})})]}),S&&n.jsxs("div",{className:"mt-4",children:[n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx("div",{className:"text-sm font-bold",children:"Size :"}),te&&n.jsx("div",{className:"text-sm text-gray-600",children:te})]}),n.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:(()=>{const x=w.find(b=>b.name===S);return x?x.variants.map((b,O)=>{const U=b.name,F=te===U;return n.jsx("button",{onClick:()=>{xe(U),ke(O),io(b.productId)},className:`px-4 py-2 rounded-md border text-sm ${F?"border-2 border-[#804c9e] font-semibold":"border-gray-300"}`,title:U,children:U},`size-${U}`)}):null})()})]}),d&&n.jsx("div",{className:"mt-4 flex justify-end",children:n.jsx("button",{onClick:wo,className:"px-6 py-2.5 rounded-full font-semibold text-white shadow-md",style:{background:Oe},disabled:!Nt,children:"Submit"})})]})},Jr=(d,f=!0)=>{!(d!=null&&d.extractedDetails)&&d&&(d={extractedDetails:d});const u=(d==null?void 0:d.extractedDetails)||fe;if(!u)return null;const x=Ct(u),{currency:b}=Kt(k),O=Fn(r,k),U=Number((u==null?void 0:u.max_price_minor)??0),D=Number.isFinite(U)&&U>0?+(U/100):+(O*x),P=(u==null?void 0:u.currency)||b||pt,ie=k!=null&&k.sku?k.sku:u.product_id;return n.jsxs("div",{className:"px-6 pb-6 flex flex-col items-center space-y-4",style:{backgroundColor:"#e5dbeb"},children:[n.jsx("p",{className:"text-base font-semibold text-center mt-2",style:{color:Dr},children:"Here’s what I found from your instruction:"}),n.jsxs("div",{className:"w-full max-w-md bg-white rounded-xl shadow-inner p-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-y-2 text-sm",children:[n.jsx("p",{className:"font-semibold text-gray-600",children:"SKU:"}),n.jsx("p",{className:"text-gray-800",children:ie}),n.jsx("p",{className:"font-semibold text-gray-600",children:"Quantity:"}),n.jsx("p",{className:"text-gray-800",children:Ct(u)}),n.jsx("p",{className:"font-semibold text-gray-600",children:"Currency:"}),n.jsx("p",{className:"text-gray-800",children:P}),n.jsx("p",{className:"font-semibold text-gray-600",children:"Maximum Total Price:"}),n.jsx("p",{className:"text-gray-800",children:tt(D,P)})]}),n.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs",children:[ft(k)&&n.jsxs("span",{className:"rounded-full bg-gray-100 px-2 py-1",children:["Color: ",ft(k)]}),mt(k)&&n.jsxs("span",{className:"rounded-full bg-gray-100 px-2 py-1",children:["Size: ",mt(k)]}),(k==null?void 0:k.sku)&&n.jsxs("span",{className:"rounded-full bg-gray-100 px-2 py-1",children:["SKU: ",k.sku]})]})]}),!f&&n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"text-sm font-medium text-gray-700 text-center max-w-[90%] leading-relaxed",style:{color:Dr},children:["Would you like me to ",n.jsx("strong",{children:"lock this in"})," and monitor it for you?"]}),n.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[n.jsxs("button",{onClick:yo,disabled:K,className:`relative inline-flex items-center justify-center px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${K?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{background:Oe},children:[n.jsx(ce,{icon:"fluent:checkmark-circle-24-filled",className:"mr-2",width:"18",height:"18"}),"Yes, lock it in"]}),n.jsxs("button",{onClick:Vr,disabled:K,className:`relative inline-flex items-center justify-center px-6 py-2.5 rounded-full font-semibold border transition-all duration-300 ${K?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{borderColor:Oe,color:Oe},children:[n.jsx(ce,{icon:"fluent:dismiss-circle-24-filled",className:"mr-2",width:"18",height:"18"}),"No"]})]})]})]})},Kr=(d,f=!0)=>{var ct,et,qe,Le,pe;const u=d||{},x=((ct=u==null?void 0:u.summary)==null?void 0:ct.currency)||(fe==null?void 0:fe.currency)||pt,b=_n(r,k),O=In(r),U=k!=null&&k.sku?k.sku:(r==null?void 0:r.id)??(fe==null?void 0:fe.product_id),F=(k==null?void 0:k.sku)??Va(r),D=ft(k)||Ya(r),P=mt(k)||Ja(r),ie=Ct(u),Ne=((et=u==null?void 0:u.summary)==null?void 0:et.product_total)!=null?+u.summary.product_total:qr(u),Ae=ie>0?+(Ne/ie).toFixed(2):0,$e=Ne,Ze=((qe=u==null?void 0:u.summary)==null?void 0:qe.tax)??+(Ne*.08).toFixed(2),Ce=((Le=u==null?void 0:u.summary)==null?void 0:Le.shipping_fee)??((G==null?void 0:G.price)||0),_e=u!=null&&u.address?[u.address.addressLine1,u.address.addressLine2,u.address.street,[u.address.city,u.address.state,u.address.postalCode].filter(Boolean).join(", "),u.address.country].filter(Boolean).map(dt=>Ve(String(dt))).join(", "):"—",He=(u==null?void 0:u.payment)||"card",lt=He==="card"?n.jsxs(n.Fragment,{children:["Credit Card — Mastercard",n.jsx("br",{}),"•••• 7820 Exp: 12/26"]}):n.jsx(n.Fragment,{children:Ve(He)});return n.jsxs("div",{className:"mx-auto mt-3 mb-3 rounded-2xl bg-white",children:[n.jsx("div",{className:"px-6 pt-5 pb-3",children:n.jsxs("h3",{className:"font-semibold text-lg mb-2 text-gray-800 flex items-center gap-2",children:[n.jsx(ce,{icon:"mdi:receipt-text-check-outline",width:"24",color:it}),"All set! Here’s what your smart order looks like 🧾"]})}),n.jsx("div",{className:"px-6 pb-4",children:n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-12 gap-4 rounded-xl border border-gray-200 bg-gray-50 p-3",children:[n.jsx("div",{className:"sm:col-span-2 flex",children:n.jsx("div",{className:"w-30 h-26 sm:w-30 sm:h-26 overflow-hidden rounded-lg bg-white border border-gray-200 flex items-center justify-center mx-auto sm:mx-0",children:b?n.jsx("img",{src:b,alt:O,className:"w-full h-full object-contain"}):n.jsx(ce,{icon:"mdi:image-outline",width:"24",className:"opacity-50"})})}),n.jsxs("div",{className:"sm:col-span-10",children:[n.jsxs("div",{className:"mb-3",children:[n.jsx("div",{className:"text-lg text-center font-bold text-gray-900",children:O}),n.jsxs("div",{className:"text-xs text-center font-bold text-gray-600",children:[n.jsx("span",{className:"font-medium",children:"SKU:"})," ",U??"—"]}),(F||D||P)&&n.jsxs("div",{className:"text-xs text-gray-600 mt-0.5 text-center",children:[F&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-medium",children:"SKU:"})," ",F,"  "]}),D&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-medium",children:"Color:"})," ",D,"  "]}),P&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-medium",children:"Size:"})," ",P]})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md-grid-cols-3 md:grid-cols-3 gap-3",children:[n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-white p-3 text-center",children:[n.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:"Unit Price"}),n.jsx("div",{className:"mt-0.5 text-base font-bold text-gray-900",children:tt(Ae,x)})]}),n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-white p-3 text-center",children:[n.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:"Quantity"}),n.jsx("div",{className:"mt-0.5 text-base font-bold text-gray-900",children:ie})]}),n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-white p-3 text-center",children:[n.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:"Subtotal"}),n.jsx("div",{className:"mt-0.5 text-base font-bold text-gray-900",children:tt($e,x)})]})]})]})]})}),n.jsxs("div",{className:"px-6 pb-2",children:[n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 mb-3",children:[n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-gray-50 p-3",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"🏠 Address"}),n.jsx("div",{className:"mt-1 text-sm font-semibold text-gray-900 text-center",children:_e})]}),n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-gray-50 p-3",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"💳 Payment"}),n.jsx("div",{className:"mt-1 text-sm font-semibold text-gray-900 text-center",children:lt})]}),n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-gray-50 p-3",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"🚚 Delivery"}),n.jsx("div",{className:"mt-1 text-sm font-semibold text-gray-900 text-center",children:u!=null&&u.delivery&&((pe=Nn[u.delivery])==null?void 0:pe.name)||"—"})]})]}),n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[n.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-gray-200 bg-gray-50 p-4 text-center",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"💰 any(s)"}),n.jsx("div",{className:"mt-1 text-2xl font-bold text-gray-900",children:tt(Ne,x)})]}),n.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-gray-200 bg-gray-50 p-4 text-center",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"🏛️ Taxes"}),n.jsx("div",{className:"mt-1 text-2xl font-bold text-gray-900",children:tt(Ze,x)})]}),n.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-gray-200 bg-gray-50 p-4 text-center",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"🚚 Shipping"}),n.jsx("div",{className:"mt-1 text-2xl font-bold text-gray-900",children:tt(Ce,x)})]})]}),n.jsxs("div",{className:"mt-4 rounded-xl p-4 text-center text-white shadow-sm",style:{background:zt},children:[n.jsx("div",{className:"text-sm/5 opacity-95",children:"🔹 Total Payable"}),n.jsx("div",{className:"mt-1 text-3xl font-extrabold tracking-tight",children:tt(Ne+Ze+Ce,x)})]})]}),!f&&n.jsxs("div",{className:"px-6 pb-5",children:[!I&&n.jsx("p",{className:"mt-3 text-center text-sm text-gray-700",children:"Everything looks good! Do you want me to watch this product and buy it automatically when it meets your condition?"}),I&&Mr({intentMandateId:vt}),Te&&!I&&n.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-3",children:[n.jsx("button",{onClick:_o,className:"inline-flex items-center justify-center rounded-full px-6 py-2.5 font-semibold text-white shadow-md transition-transform duration-150 hover:-translate-y-0.5 hover:shadow-lg",style:{background:zt},children:"Confirm"}),n.jsx("button",{onClick:Vr,className:"inline-flex items-center justify-center rounded-full border px-6 py-2.5 font-semibold hover:bg-gray-50",style:{borderColor:zt,color:zt},children:"Cancel"})]})]})]})},Fo=d=>{if(!d)return null;const f=[d.addressLine1,d.addressLine2,d.street,[d.city,d.state,d.postalCode].filter(Boolean).join(", "),d.country].filter(u=>!!u).map(u=>Ve(u)).join(", ");return n.jsx("div",{className:"px-6 py-4",style:{backgroundColor:"var(--tanya-light)"},children:n.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx(ce,{icon:"mdi:home-map-marker",width:"20",color:it}),n.jsx("div",{className:"font-semibold text-gray-800",children:"Delivery Address"})]}),n.jsx("div",{className:"text-sm text-gray-800",children:f})]})})},Po=d=>{const f=d==null?void 0:d.method,u=f?Nn[f]:void 0;return n.jsx("div",{className:"px-6 py-4",style:{backgroundColor:"var(--tanya-light)"},children:n.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx(ce,{icon:"mdi:truck-delivery",width:"20",color:it}),n.jsx("div",{className:"font-semibold text-gray-800",children:"Delivery Method"})]}),n.jsx("div",{className:"text-sm text-gray-800",children:u?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ce,{icon:u.icon,width:"18"}),n.jsx("span",{className:"font-medium",children:u.label})]}),n.jsx("div",{className:"text-gray-600",children:u.subtitle})]}):"—"})]})})},Eo=d=>{const f=(d==null?void 0:d.method)||"card";return n.jsx("div",{className:"px-6 py-4",style:{backgroundColor:"var(--tanya-light)"},children:n.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx(ce,{icon:"mdi:credit-card-outline",width:"20",color:it}),n.jsx("div",{className:"font-semibold text-gray-800",children:"Payment Method"})]}),n.jsx("div",{className:"text-sm text-gray-800",children:f==="card"?n.jsxs(n.Fragment,{children:["Credit Card — Mastercard",n.jsx("br",{}),"•••• 7820   Exp: 12/26"]}):Ve(f)})]})})},To=(d,f)=>{const u=d.snapshotStage;if(!u||u==="address"&&K||u==="delivery"&&ve||u==="payment"&&oe||u==="final"&&bt)return null;switch(u){case"initial":return Jr(d.snapshotPayload,!f);case"address":return Fo(d.snapshotPayload);case"delivery":return Po(d.snapshotPayload);case"payment":return Eo(d.snapshotPayload);case"final":return Kr(d.snapshotPayload,!f);case"success":return Mr(d.snapshotPayload);default:return null}};return Lo.createPortal(n.jsxs("div",{className:"fixed inset-0",style:{zIndex:2147483647},"aria-modal":"true",role:"dialog",children:[n.jsx("div",{className:"absolute inset-0",style:{background:"rgba(0,0,0,0.25)"},onClick:t}),n.jsx("div",{className:"absolute right-0 ",children:n.jsxs("div",{className:"w-[64.7vw] h-screen bg-white rounded-xl overflow-hidden flex flex-col shadow-xl",children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",borderTopLeftRadius:"0.75rem",borderBottomLeftRadius:"0.75rem",padding:"0.25rem",background:Oe},children:[n.jsxs("div",{style:{display:"flex",color:"#ffffff",alignItems:"center",gap:"0.5rem"},children:[n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"25",viewBox:"0 0 256 256",children:n.jsxs("g",{fill:"currentColor",children:[n.jsx("path",{d:"m194.82 151.43l-55.09 20.3l-20.3 55.09a7.92 7.92 0 0 1-14.86 0l-20.3-55.09l-55.09-20.3a7.92 7.92 0 0 1 0-14.86l55.09-20.3l20.3-55.09a7.92 7.92 0 0 1 14.86 0l20.3 55.09l55.09 20.3a7.92 7.92 0 0 1 0 14.86",opacity:"0.2"}),n.jsx("path",{d:"M197.58 129.06L146 110l-19-51.62a15.92 15.92 0 0 0-29.88 0L78 110l-51.62 19a15.92 15.92 0 0 0 0 29.88L78 178l19 51.62a15.92 15.92 0 0 0 29.88 0L146 178l51.62-19a15.92 15.92 0 0 0 0-29.88ZM137 164.22a8 8 0 0 0-4.74 4.74L112 223.85L91.78 169a8 8 0 0 0-4.78-4.78L32.15 144L87 123.78a8 8 0 0 0 4.78-4.78L112 64.15L132.22 119a8 8 0 0 0 4.74 4.74L191.85 144ZM144 40a8 8 0 0 1 8-8h16V16a8 8 0 0 1 16 0v16h16a8 8 0 0 1 0 16h-16v16a8 8 0 0 1-16 0V48h-16a8 8 0 0 1-8-8m104 48a8 8 0 0 1-8 8h-8v8a8 8 0 0 1-16 0v-8h-8a8 8 0 0 1 0-16h8v-8a8 8 0 0 1 16 0v8h8a8 8 0 0 1 8 8"})]})}),n.jsx("div",{children:n.jsx("p",{className:"font-bold",children:"Agentic Shopping with TANYA"})})]}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:"1.25rem",margin:"0.75rem"},children:n.jsx(ce,{icon:"fluent:dismiss-24-filled",color:"#ffffff",width:"24",height:"24",className:"cursor-pointer",onClick:t})})]}),n.jsxs("div",{ref:Lt,className:"overflow-y-auto pr-5 pb-4 space-y-4 hide-scrollbar flex-grow",children:[n.jsxs("div",{className:"text-sm text-[16px] rounded-r-xl p-3 m-3 rounded-bl-xl w-3/4 text-tanya-contrast",style:{backgroundColor:"#e5dbeb"},children:["Welcome to your smart shopping companion!",n.jsxs("p",{children:["Simply share your instruction — like “If this product goes below $",parseInt(r.price)-5," grab it for me.”"]}),n.jsx("p",{children:"I’ll monitor it, calculate total prices, and place the order when your conditions are met."})]}),n.jsx(Io,{selectedIndex:C}),q>1&&n.jsx(Yr,{showSubmit:!1}),m.map((d,f)=>{var b;const u=f===m.length-1,x=!!d.snapshotStage;return n.jsxs("div",{children:[d.query&&n.jsx("div",{className:"flex justify-end",children:n.jsx("p",{className:"text-sm rounded-l-xl p-3 m-3 mb-4 rounded-br-xl max-w-[75%]",style:{color:"#ffffff",backgroundColor:"var(--tanya)"},children:d.query})}),d.response==="__TEXT__"&&((b=d.snapshotPayload)==null?void 0:b.text)&&n.jsx("div",{className:"mt-2",children:n.jsx("div",{className:"text-sm text-tanya-contrast px-7 py-4 rounded-r-xl rounded-bl-2xl w-full",style:{backgroundColor:"var(--tanya-light)",margin:"0.75rem"},children:n.jsx("div",{className:"flex items-center gap-2",children:n.jsx("p",{children:d.snapshotPayload.text})})})}),u&&at&&q>1&&n.jsxs("div",{className:"mx-4 mt-2 rounded-xl border border-gray-200 bg-white p-4 animate-fade-in",children:[n.jsxs("div",{className:"text-sm text-gray-800",children:["Proceed with color:"," ",n.jsx("span",{className:"font-semibold",children:S||"—"}),", size:"," ",n.jsx("span",{className:"font-semibold",children:te||"—"}),"?"]}),n.jsxs("div",{className:"mt-3 flex gap-3",children:[n.jsx("button",{onClick:go,className:"px-5 py-2 rounded-full text-white font-semibold",style:{background:Oe},children:"Yes"}),n.jsx("button",{onClick:xo,className:"px-5 py-2 rounded-full font-semibold border",style:{borderColor:Oe,color:Oe},children:"No, change SKU"})]})]}),u&&Xe&&n.jsx(Yr,{showSubmit:!0}),u&&Se&&n.jsx("div",{className:"mt-4",children:n.jsx("div",{className:"text-sm text-tanya-contrast px-7 py-4 rounded-r-xl rounded-bl-2xl w-full",style:{backgroundColor:"var(--tanya-light)",margin:"0.75rem"},children:n.jsx("div",{className:"flex items-center gap-2 tanya-pulse-text",children:n.jsx("p",{children:"Reading your instruction and setting things up…"})})})}),(x||d.response==="__CARD__")&&(!Se||!u)&&n.jsx("div",{className:"mt-6 mb-4 mx-4 animate-fade-in",style:{backgroundColor:"#fff",borderRadius:"1rem",boxShadow:"0 2px 8px rgba(0,0,0,0.08)",overflow:"hidden"},children:x?To(d,u):Jr(d.snapshotPayload,!1)})]},f)}),K&&n.jsxs("div",{className:"mt-6 mb-6 mx-6 rounded-xl p-6 shadow-md border border-gray-200 bg-white animate-fade-in",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("h3",{className:"font-semibold text-lg text-gray-800 flex items-center gap-2",children:[n.jsx(ce,{icon:"mdi:home-map-marker",width:"24",color:"var(--tanya-light)"}),"Select a Delivery Address"]}),Q&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ml-2 text-xs px-2 py-1 rounded-full bg-green-100 text-green-700 font-semibold",children:"Selected"}),!I&&n.jsx("button",{onClick:vo,className:"ml-2 text-xs px-2 py-1 rounded-full border hover:bg-gray-50",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},title:"Change address",children:"Change"})]})]}),n.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Choose where you’d like us to deliver this item."}),a?n.jsxs("div",{className:"flex items-center py-6",children:[n.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2",style:{borderBottomColor:"var(--tanya-light)"}}),n.jsx("p",{className:"ml-3 text-gray-600",children:"Fetching your addresses..."})]}):(B==null?void 0:B.length)>0?n.jsxs("div",{className:`space-y-3 ${Q?"opacity-70":""}`,children:[B.map(d=>{const f=[d.addressLine1,d.addressLine2].filter(Boolean).map(F=>Ve(F||"")).join(" "),u=Ve(d.city||""),x=`${Ve(d.state||"")}${d.state&&d.postalCode?", ":""}${d.postalCode||""}`,b=Ve(d.country||""),O=String(d.addressId??d.id),U=R===O;return n.jsxs("label",{className:`flex items-start gap-3 p-4 border rounded-lg cursor-pointer transition hover:shadow-sm ${U?"border-tanya-light":"border-gray-300"} ${Q?"pointer-events-none":""}`,title:Q?"Address already submitted":"",children:[n.jsx("input",{type:"radio",name:"address",className:"mt-1 accent-tanya-light",checked:U,disabled:Q,onChange:()=>ne(O),value:O}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"font-semibold text-gray-800",children:f||"Address"}),n.jsxs("div",{className:"text-sm text-gray-700",children:[u,n.jsx("br",{}),x,n.jsx("br",{}),b]})]})]},O)}),n.jsxs("div",{className:"flex justify-between pt-2",children:[n.jsx("button",{onClick:Hr,className:"px-6 py-2.5 rounded-full font-semibold border transition-all hover:-translate-y-0.5 hover:shadow-sm",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},children:"Cancel"}),n.jsx("button",{onClick:bo,disabled:Q,className:`px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${Q?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{background:Oe},children:Q?"Address Submitted":"Submit Address"})]})]}):n.jsx("div",{className:"text-center py-8 text-gray-600",children:"No addresses found. Please add a new one in your profile."})]}),ve&&n.jsxs("div",{className:"mt-2 mb-6 mx-6 rounded-xl p-6 shadow-md border border-gray-200 bg-white animate-fade-in",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("h3",{className:"font-semibold text-lg text-gray-800 flex items-center gap-2",children:[n.jsx(ce,{icon:"mdi:truck-delivery",width:"24",color:"var(--tanya-light)"}),"Great! Now choose how fast you want it delivered 🚚"]}),Z&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ml-2 text-xs px-2 py-1 rounded-full bg-green-100 text-green-700 font-semibold",children:"Selected"}),!I&&n.jsx("button",{onClick:ko,className:"ml-2 text-xs px-2 py-1 rounded-full border hover:bg-gray-50",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},title:"Change shipping method",children:"Change"})]})]}),n.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Which one would you like me to use for this order?"}),n.jsx("div",{className:`space-y-3 ${Z?"opacity-70":""}`,children:E.map(d=>{const f=G.id===d.id;return n.jsxs("label",{className:`flex items-start gap-3 p-4 border rounded-lg cursor-pointer transition hover:shadow-sm ${f?"border-tanya-light":"border-gray-300"} ${Z?"pointer-events-none":""}`,title:Z?"Delivery already submitted":"",children:[n.jsx("input",{type:"radio",name:"delivery",className:"mt-1 accent-tanya-light",checked:f,disabled:Z,onChange:()=>N(d)}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"font-semibold text-gray-800 flex items-center gap-2",children:d.name}),n.jsx("div",{className:"text-sm text-gray-700",children:d.description})]}),n.jsx("div",{className:"text-sm font-semibold text-gray-800",children:d.price===0?"Free":d.price})]},d.id)})}),n.jsxs("div",{className:"flex justify-between pt-4",children:[n.jsx("button",{onClick:Hr,className:"px-6 py-2.5 rounded-full font-semibold border transition-all hover:-translate-y-0.5 hover:shadow-sm",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},children:"Cancel"}),n.jsx("button",{onClick:jo,disabled:Z,className:`px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${Z?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{background:Oe},children:Z?"Delivery Submitted":"Submit Delivery Option"})]})]}),oe&&n.jsxs("div",{className:"mt-2 mb-6 mx-6 rounded-xl p-6 shadow-md border border-gray-200 bg-white animate-fade-in",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("h3",{className:"font-semibold text-lg text-gray-800 flex items-center gap-2",children:[n.jsx(ce,{icon:"mdi:credit-card-outline",width:"24",color:"var(--tanya-light)"}),"Almost done! 💳"]}),Pe&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ml-2 text-xs px-2 py-1 rounded-full bg-green-100 text-green-700 font-semibold",children:"Selected"}),!I&&n.jsx("button",{onClick:Co,className:"ml-2 text-xs px-2 py-1 rounded-full border hover:bg-gray-50",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},title:"Change payment method",children:"Change"})]})]}),n.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Please choose a payment method for this order:"}),n.jsx("div",{className:`space-y-3 ${Pe?"opacity-70":""}`,children:n.jsxs("label",{className:`flex items-start gap-3 p-4 border rounded-lg cursor-pointer transition hover:shadow-sm ${Fe==="card"?"border-tanya-light":"border-gray-300"} ${Pe?"pointer-events-none":""}`,title:Pe?"Payment already submitted":"",children:[n.jsx("input",{type:"radio",name:"payment",className:"mt-1 accent-tanya-light",checked:Fe==="card",disabled:Pe,onChange:()=>yt("card")}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"font-semibold text-gray-800 flex items-center gap-2",children:[n.jsx(ce,{icon:"mdi:credit-card-chip-outline",width:"18"})," ","Credit Card"]}),Fe==="card"&&n.jsxs("div",{className:"text-sm text-gray-700 mt-1",children:["Mastercard    •••• 7820",n.jsx("br",{}),"Expiry: 12/26"]})]})]})}),n.jsxs("div",{className:"flex justify-between pt-4",children:[n.jsx("button",{onClick:No,className:"px-6 py-2.5 rounded-full font-semibold border transition-all hover:-translate-y-0.5 hover:shadow-sm",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},children:"Cancel"}),n.jsx("button",{onClick:So,disabled:Pe,className:`px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${Pe?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{background:"var(--tanya)"},children:Pe?"Payment Submitted":"Submit Payment Method"})]})]}),bt&&Kr({...fe,address:JSON.parse(localStorage.getItem("agentic_order_address")||"null"),delivery:localStorage.getItem("agentic_order_delivery"),payment:localStorage.getItem("agentic_order_payment"),summary:Rr(fe==null?void 0:fe.currency)},!1)]}),n.jsxs("div",{className:"sticky bottom-0 w-[96%] drop-shadow-xl flex items-center rounded-full bg-white border border-gray-300 m-[15px]",children:[n.jsx("input",{placeholder:be?"Complete the current step…":Nt?`What would you like me to do? (e.g., If this product goes below $${parseInt(r.price)-5}, grab it for me.)`:"Please select a combination first.",disabled:po,className:`w-full rounded-full p-4 outline-none border-none focus:ring-0 focus:border-transparent disabled:bg-gray-100 disabled:cursor-not-allowed
19
19
  ${Nt?"":"placeholder:text-red-400 text-red-500"}`,value:L,onKeyDown:d=>{d.key==="Enter"&&!Se&&!be&&Ur()},onChange:d=>Ie(d.target.value)}),n.jsx("button",{type:"submit",disabled:Se||be,className:"mr-6 font-medium",style:{color:"var(--tanya-light)"},onClick:()=>Ur(),children:Se?n.jsx("div",{className:"m-3 animate-spin rounded-full h-6 w-6 border-b-2",style:{borderBottom:"2px solid"}}):n.jsx(ce,{icon:"fluent:send-48-filled",color:"var(--tanya-light)",width:"24",height:"24"})})]})]})})]}),document.body)};exports.AgenticShoppingButton=Ka;exports.TanyaChatbot=zs;exports.TanyaChatbotProvider=Mo;
20
20
  //# sourceMappingURL=tanya-chatbot.cjs.js.map