@gymmymac/bob-widget 1.2.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var zr=t=>{throw TypeError(t)};var vr=(t,e,r)=>e.has(t)||zr("Cannot "+r);var a=(t,e,r)=>(vr(t,e,"read from private field"),r?r.call(t):e.get(t)),M=(t,e,r)=>e.has(t)?zr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),_=(t,e,r,s)=>(vr(t,e,"write to private field"),s?s.call(t,r):e.set(t,r),r),q=(t,e,r)=>(vr(t,e,"access private method"),r);var fr=(t,e,r,s)=>({set _(o){_(t,e,o,r)},get _(){return a(t,e,s)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),Ys=require("@supabase/supabase-js");function Js(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const Ee=Js(u),lr="1.2.2",Xs=()=>lr;var wr={exports:{}},Xt={};/**
1
+ "use strict";var Xr=t=>{throw TypeError(t)};var wr=(t,e,r)=>e.has(t)||Xr("Cannot "+r);var a=(t,e,r)=>(wr(t,e,"read from private field"),r?r.call(t):e.get(t)),A=(t,e,r)=>e.has(t)?Xr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),I=(t,e,r,s)=>(wr(t,e,"write to private field"),s?s.call(t,r):e.set(t,r),r),Q=(t,e,r)=>(wr(t,e,"access private method"),r);var pr=(t,e,r,s)=>({set _(o){I(t,e,o,r)},get _(){return a(t,e,s)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),Zs=require("@supabase/supabase-js");function en(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const ke=en(d),zt="1.4.0",tn=()=>zt;var Sr={exports:{}},tr={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Hr;function Zs(){if(Hr)return Xt;Hr=1;var t=u,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,o=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(x,h,w){var d,g={},m=null,S=null;w!==void 0&&(m=""+w),h.key!==void 0&&(m=""+h.key),h.ref!==void 0&&(S=h.ref);for(d in h)s.call(h,d)&&!l.hasOwnProperty(d)&&(g[d]=h[d]);if(x&&x.defaultProps)for(d in h=x.defaultProps,h)g[d]===void 0&&(g[d]=h[d]);return{$$typeof:e,type:x,key:m,ref:S,props:g,_owner:o.current}}return Xt.Fragment=r,Xt.jsx=c,Xt.jsxs=c,Xt}var Zt={};/**
9
+ */var Zr;function rn(){if(Zr)return tr;Zr=1;var t=d,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,o=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function h(c,y,v){var p,x={},g=null,j=null;v!==void 0&&(g=""+v),y.key!==void 0&&(g=""+y.key),y.ref!==void 0&&(j=y.ref);for(p in y)s.call(y,p)&&!u.hasOwnProperty(p)&&(x[p]=y[p]);if(c&&c.defaultProps)for(p in y=c.defaultProps,y)x[p]===void 0&&(x[p]=y[p]);return{$$typeof:e,type:c,key:g,ref:j,props:x,_owner:o.current}}return tr.Fragment=r,tr.jsx=h,tr.jsxs=h,tr}var rr={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,20 +14,20 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var Gr;function en(){return Gr||(Gr=1,process.env.NODE_ENV!=="production"&&function(){var t=u,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),x=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),S=Symbol.for("react.offscreen"),P=Symbol.iterator,E="@@iterator";function R(i){if(i===null||typeof i!="object")return null;var y=P&&i[P]||i[E];return typeof y=="function"?y:null}var k=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function f(i){{for(var y=arguments.length,I=new Array(y>1?y-1:0),A=1;A<y;A++)I[A-1]=arguments[A];j("error",i,I)}}function j(i,y,I){{var A=k.ReactDebugCurrentFrame,V=A.getStackAddendum();V!==""&&(y+="%s",I=I.concat([V]));var G=I.map(function($){return String($)});G.unshift("Warning: "+y),Function.prototype.apply.call(console[i],console,G)}}var b=!1,p=!1,C=!1,O=!1,N=!1,B;B=Symbol.for("react.module.reference");function v(i){return!!(typeof i=="string"||typeof i=="function"||i===s||i===l||N||i===o||i===w||i===d||O||i===S||b||p||C||typeof i=="object"&&i!==null&&(i.$$typeof===m||i.$$typeof===g||i.$$typeof===c||i.$$typeof===x||i.$$typeof===h||i.$$typeof===B||i.getModuleId!==void 0))}function F(i,y,I){var A=i.displayName;if(A)return A;var V=y.displayName||y.name||"";return V!==""?I+"("+V+")":I}function K(i){return i.displayName||"Context"}function T(i){if(i==null)return null;if(typeof i.tag=="number"&&f("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case s:return"Fragment";case r:return"Portal";case l:return"Profiler";case o:return"StrictMode";case w:return"Suspense";case d:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case x:var y=i;return K(y)+".Consumer";case c:var I=i;return K(I._context)+".Provider";case h:return F(i,i.render,"ForwardRef");case g:var A=i.displayName||null;return A!==null?A:T(i.type)||"Memo";case m:{var V=i,G=V._payload,$=V._init;try{return T($(G))}catch{return null}}}return null}var L=Object.assign,Y=0,J,X,oe,ce,xe,D,H;function Re(){}Re.__reactDisabledLog=!0;function fe(){{if(Y===0){J=console.log,X=console.info,oe=console.warn,ce=console.error,xe=console.group,D=console.groupCollapsed,H=console.groupEnd;var i={configurable:!0,enumerable:!0,value:Re,writable:!0};Object.defineProperties(console,{info:i,log:i,warn:i,error:i,group:i,groupCollapsed:i,groupEnd:i})}Y++}}function ee(){{if(Y--,Y===0){var i={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:L({},i,{value:J}),info:L({},i,{value:X}),warn:L({},i,{value:oe}),error:L({},i,{value:ce}),group:L({},i,{value:xe}),groupCollapsed:L({},i,{value:D}),groupEnd:L({},i,{value:H})})}Y<0&&f("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Fe=k.ReactCurrentDispatcher,Ot;function ot(i,y,I){{if(Ot===void 0)try{throw Error()}catch(V){var A=V.stack.trim().match(/\n( *(at )?)/);Ot=A&&A[1]||""}return`
18
- `+Ot+i}}var It=!1,ye;{var Vr=typeof WeakMap=="function"?WeakMap:Map;ye=new Vr}function gr(i,y){if(!i||It)return"";{var I=ye.get(i);if(I!==void 0)return I}var A;It=!0;var V=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var G;G=Fe.current,Fe.current=null,fe();try{if(y){var $=function(){throw Error()};if(Object.defineProperty($.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct($,[])}catch(be){A=be}Reflect.construct(i,[],$)}else{try{$.call()}catch(be){A=be}i.call($.prototype)}}else{try{throw Error()}catch(be){A=be}i()}}catch(be){if(be&&A&&typeof be.stack=="string"){for(var U=be.stack.split(`
19
- `),ue=A.stack.split(`
20
- `),te=U.length-1,re=ue.length-1;te>=1&&re>=0&&U[te]!==ue[re];)re--;for(;te>=1&&re>=0;te--,re--)if(U[te]!==ue[re]){if(te!==1||re!==1)do if(te--,re--,re<0||U[te]!==ue[re]){var Se=`
21
- `+U[te].replace(" at new "," at ");return i.displayName&&Se.includes("<anonymous>")&&(Se=Se.replace("<anonymous>",i.displayName)),typeof i=="function"&&ye.set(i,Se),Se}while(te>=1&&re>=0);break}}}finally{It=!1,Fe.current=G,ee(),Error.prepareStackTrace=V}var Ft=i?i.displayName||i.name:"",gt=Ft?ot(Ft):"";return typeof i=="function"&&ye.set(i,gt),gt}function ur(i,y,I){return gr(i,!1)}function dr(i){var y=i.prototype;return!!(y&&y.isReactComponent)}function lt(i,y,I){if(i==null)return"";if(typeof i=="function")return gr(i,dr(i));if(typeof i=="string")return ot(i);switch(i){case w:return ot("Suspense");case d:return ot("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case h:return ur(i.render);case g:return lt(i.type,y,I);case m:{var A=i,V=A._payload,G=A._init;try{return lt(G(V),y,I)}catch{}}}return""}var Ke=Object.prototype.hasOwnProperty,W={},se=k.ReactDebugCurrentFrame;function ne(i){if(i){var y=i._owner,I=lt(i.type,i._source,y?y.type:null);se.setExtraStackFrame(I)}else se.setExtraStackFrame(null)}function pe(i,y,I,A,V){{var G=Function.call.bind(Ke);for(var $ in i)if(G(i,$)){var U=void 0;try{if(typeof i[$]!="function"){var ue=Error((A||"React class")+": "+I+" type `"+$+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[$]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ue.name="Invariant Violation",ue}U=i[$](y,$,A,I,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(te){U=te}U&&!(U instanceof Error)&&(ne(V),f("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",A||"React class",I,$,typeof U),ne(null)),U instanceof Error&&!(U.message in W)&&(W[U.message]=!0,ne(V),f("Failed %s type: %s",I,U.message),ne(null))}}}var Ve=Array.isArray;function ct(i){return Ve(i)}function ut(i){{var y=typeof Symbol=="function"&&Symbol.toStringTag,I=y&&i[Symbol.toStringTag]||i.constructor.name||"Object";return I}}function dt(i){try{return ht(i),!1}catch{return!0}}function ht(i){return""+i}function ze(i){if(dt(i))return f("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ut(i)),ht(i)}var He=k.ReactCurrentOwner,Te={key:!0,ref:!0,__self:!0,__source:!0},ft,pt;function Me(i){if(Ke.call(i,"ref")){var y=Object.getOwnPropertyDescriptor(i,"ref").get;if(y&&y.isReactWarning)return!1}return i.ref!==void 0}function ke(i){if(Ke.call(i,"key")){var y=Object.getOwnPropertyDescriptor(i,"key").get;if(y&&y.isReactWarning)return!1}return i.key!==void 0}function We(i,y){typeof i.ref=="string"&&He.current}function bt(i,y){{var I=function(){ft||(ft=!0,f("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",y))};I.isReactWarning=!0,Object.defineProperty(i,"key",{get:I,configurable:!0})}}function _e(i,y){{var I=function(){pt||(pt=!0,f("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",y))};I.isReactWarning=!0,Object.defineProperty(i,"ref",{get:I,configurable:!0})}}var ve=function(i,y,I,A,V,G,$){var U={$$typeof:e,type:i,key:y,ref:I,props:$,_owner:G};return U._store={},Object.defineProperty(U._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(U,"_self",{configurable:!1,enumerable:!1,writable:!1,value:A}),Object.defineProperty(U,"_source",{configurable:!1,enumerable:!1,writable:!1,value:V}),Object.freeze&&(Object.freeze(U.props),Object.freeze(U)),U};function Oe(i,y,I,A,V){{var G,$={},U=null,ue=null;I!==void 0&&(ze(I),U=""+I),ke(y)&&(ze(y.key),U=""+y.key),Me(y)&&(ue=y.ref,We(y,V));for(G in y)Ke.call(y,G)&&!Te.hasOwnProperty(G)&&($[G]=y[G]);if(i&&i.defaultProps){var te=i.defaultProps;for(G in te)$[G]===void 0&&($[G]=te[G])}if(U||ue){var re=typeof i=="function"?i.displayName||i.name||"Unknown":i;U&&bt($,re),ue&&_e($,re)}return ve(i,U,ue,V,A,He.current,$)}}var Be=k.ReactCurrentOwner,zt=k.ReactDebugCurrentFrame;function Ge(i){if(i){var y=i._owner,I=lt(i.type,i._source,y?y.type:null);zt.setExtraStackFrame(I)}else zt.setExtraStackFrame(null)}var Pt;Pt=!1;function we(i){return typeof i=="object"&&i!==null&&i.$$typeof===e}function Ye(){{if(Be.current){var i=T(Be.current.type);if(i)return`
17
+ */var es;function sn(){return es||(es=1,process.env.NODE_ENV!=="production"&&function(){var t=d,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),c=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),j=Symbol.for("react.offscreen"),C=Symbol.iterator,R="@@iterator";function _(i){if(i===null||typeof i!="object")return null;var w=C&&i[C]||i[R];return typeof w=="function"?w:null}var E=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function m(i){{for(var w=arguments.length,P=new Array(w>1?w-1:0),L=1;L<w;L++)P[L-1]=arguments[L];l("error",i,P)}}function l(i,w,P){{var L=E.ReactDebugCurrentFrame,K=L.getStackAddendum();K!==""&&(w+="%s",P=P.concat([K]));var Y=P.map(function(z){return String(z)});Y.unshift("Warning: "+w),Function.prototype.apply.call(console[i],console,Y)}}var f=!1,b=!1,S=!1,O=!1,B=!1,M;M=Symbol.for("react.module.reference");function k(i){return!!(typeof i=="string"||typeof i=="function"||i===s||i===u||B||i===o||i===v||i===p||O||i===j||f||b||S||typeof i=="object"&&i!==null&&(i.$$typeof===g||i.$$typeof===x||i.$$typeof===h||i.$$typeof===c||i.$$typeof===y||i.$$typeof===M||i.getModuleId!==void 0))}function N(i,w,P){var L=i.displayName;if(L)return L;var K=w.displayName||w.name||"";return K!==""?P+"("+K+")":P}function T(i){return i.displayName||"Context"}function D(i){if(i==null)return null;if(typeof i.tag=="number"&&m("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case s:return"Fragment";case r:return"Portal";case u:return"Profiler";case o:return"StrictMode";case v:return"Suspense";case p:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case c:var w=i;return T(w)+".Consumer";case h:var P=i;return T(P._context)+".Provider";case y:return N(i,i.render,"ForwardRef");case x:var L=i.displayName||null;return L!==null?L:D(i.type)||"Memo";case g:{var K=i,Y=K._payload,z=K._init;try{return D(z(Y))}catch{return null}}}return null}var F=Object.assign,$=0,J,se,ue,Re,U,G,ne;function Le(){}Le.__reactDisabledLog=!0;function Z(){{if($===0){J=console.log,se=console.info,ue=console.warn,Re=console.error,U=console.group,G=console.groupCollapsed,ne=console.groupEnd;var i={configurable:!0,enumerable:!0,value:Le,writable:!0};Object.defineProperties(console,{info:i,log:i,warn:i,error:i,group:i,groupCollapsed:i,groupEnd:i})}$++}}function Qe(){{if($--,$===0){var i={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:F({},i,{value:J}),info:F({},i,{value:se}),warn:F({},i,{value:ue}),error:F({},i,{value:Re}),group:F({},i,{value:U}),groupCollapsed:F({},i,{value:G}),groupEnd:F({},i,{value:ne})})}$<0&&m("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ct=E.ReactCurrentDispatcher,de;function Ve(i,w,P){{if(de===void 0)try{throw Error()}catch(K){var L=K.stack.trim().match(/\n( *(at )?)/);de=L&&L[1]||""}return`
18
+ `+de+i}}var ze=!1,we;{var Gr=typeof WeakMap=="function"?WeakMap:Map;we=new Gr}function xr(i,w){if(!i||ze)return"";{var P=we.get(i);if(P!==void 0)return P}var L;ze=!0;var K=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Y;Y=ct.current,ct.current=null,Z();try{if(w){var z=function(){throw Error()};if(Object.defineProperty(z.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(z,[])}catch(ge){L=ge}Reflect.construct(i,[],z)}else{try{z.call()}catch(ge){L=ge}i.call(z.prototype)}}else{try{throw Error()}catch(ge){L=ge}i()}}catch(ge){if(ge&&L&&typeof ge.stack=="string"){for(var q=ge.stack.split(`
19
+ `),fe=L.stack.split(`
20
+ `),re=q.length-1,ie=fe.length-1;re>=1&&ie>=0&&q[re]!==fe[ie];)ie--;for(;re>=1&&ie>=0;re--,ie--)if(q[re]!==fe[ie]){if(re!==1||ie!==1)do if(re--,ie--,ie<0||q[re]!==fe[ie]){var Se=`
21
+ `+q[re].replace(" at new "," at ");return i.displayName&&Se.includes("<anonymous>")&&(Se=Se.replace("<anonymous>",i.displayName)),typeof i=="function"&&we.set(i,Se),Se}while(re>=1&&ie>=0);break}}}finally{ze=!1,ct.current=Y,Qe(),Error.prepareStackTrace=K}var Nt=i?i.displayName||i.name:"",ft=Nt?Ve(Nt):"";return typeof i=="function"&&we.set(i,ft),ft}function Yr(i,w,P){return xr(i,!1)}function Jr(i){var w=i.prototype;return!!(w&&w.isReactComponent)}function Kt(i,w,P){if(i==null)return"";if(typeof i=="function")return xr(i,Jr(i));if(typeof i=="string")return Ve(i);switch(i){case v:return Ve("Suspense");case p:return Ve("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case y:return Yr(i.render);case x:return Kt(i.type,w,P);case g:{var L=i,K=L._payload,Y=L._init;try{return Kt(Y(K),w,P)}catch{}}}return""}var Ke=Object.prototype.hasOwnProperty,Ht={},Gt=E.ReactDebugCurrentFrame;function ut(i){if(i){var w=i._owner,P=Kt(i.type,i._source,w?w.type:null);Gt.setExtraStackFrame(P)}else Gt.setExtraStackFrame(null)}function W(i,w,P,L,K){{var Y=Function.call.bind(Ke);for(var z in i)if(Y(i,z)){var q=void 0;try{if(typeof i[z]!="function"){var fe=Error((L||"React class")+": "+P+" type `"+z+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[z]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw fe.name="Invariant Violation",fe}q=i[z](w,z,L,P,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(re){q=re}q&&!(q instanceof Error)&&(ut(K),m("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",L||"React class",P,z,typeof q),ut(null)),q instanceof Error&&!(q.message in Ht)&&(Ht[q.message]=!0,ut(K),m("Failed %s type: %s",P,q.message),ut(null))}}}var oe=Array.isArray;function ae(i){return oe(i)}function me(i){{var w=typeof Symbol=="function"&&Symbol.toStringTag,P=w&&i[Symbol.toStringTag]||i.constructor.name||"Object";return P}}function He(i){try{return Rt(i),!1}catch{return!0}}function Rt(i){return""+i}function Ge(i){if(He(i))return m("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",me(i)),Rt(i)}var Ye=E.ReactCurrentOwner,_t={key:!0,ref:!0,__self:!0,__source:!0},Je,Xe;function _e(i){if(Ke.call(i,"ref")){var w=Object.getOwnPropertyDescriptor(i,"ref").get;if(w&&w.isReactWarning)return!1}return i.ref!==void 0}function Ct(i){if(Ke.call(i,"key")){var w=Object.getOwnPropertyDescriptor(i,"key").get;if(w&&w.isReactWarning)return!1}return i.key!==void 0}function Tt(i,w){typeof i.ref=="string"&&Ye.current}function Ie(i,w){{var P=function(){Je||(Je=!0,m("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",w))};P.isReactWarning=!0,Object.defineProperty(i,"key",{get:P,configurable:!0})}}function Ot(i,w){{var P=function(){Xe||(Xe=!0,m("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",w))};P.isReactWarning=!0,Object.defineProperty(i,"ref",{get:P,configurable:!0})}}var Ce=function(i,w,P,L,K,Y,z){var q={$$typeof:e,type:i,key:w,ref:P,props:z,_owner:Y};return q._store={},Object.defineProperty(q._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(q,"_self",{configurable:!1,enumerable:!1,writable:!1,value:L}),Object.defineProperty(q,"_source",{configurable:!1,enumerable:!1,writable:!1,value:K}),Object.freeze&&(Object.freeze(q.props),Object.freeze(q)),q};function he(i,w,P,L,K){{var Y,z={},q=null,fe=null;P!==void 0&&(Ge(P),q=""+P),Ct(w)&&(Ge(w.key),q=""+w.key),_e(w)&&(fe=w.ref,Tt(w,K));for(Y in w)Ke.call(w,Y)&&!_t.hasOwnProperty(Y)&&(z[Y]=w[Y]);if(i&&i.defaultProps){var re=i.defaultProps;for(Y in re)z[Y]===void 0&&(z[Y]=re[Y])}if(q||fe){var ie=typeof i=="function"?i.displayName||i.name||"Unknown":i;q&&Ie(z,ie),fe&&Ot(z,ie)}return Ce(i,q,fe,K,L,Ye.current,z)}}var ve=E.ReactCurrentOwner,dt=E.ReactDebugCurrentFrame;function ee(i){if(i){var w=i._owner,P=Kt(i.type,i._source,w?w.type:null);dt.setExtraStackFrame(P)}else dt.setExtraStackFrame(null)}var It;It=!1;function Pe(i){return typeof i=="object"&&i!==null&&i.$$typeof===e}function Yt(){{if(ve.current){var i=D(ve.current.type);if(i)return`
22
22
 
23
- Check the render method of \``+i+"`."}return""}}function Ht(i){return""}var Ie={};function hr(i){{var y=Ye();if(!y){var I=typeof i=="string"?i:i.displayName||i.name;I&&(y=`
23
+ Check the render method of \``+i+"`."}return""}}function yr(i){return""}var Jt={};function Ne(i){{var w=Yt();if(!w){var P=typeof i=="string"?i:i.displayName||i.name;P&&(w=`
24
24
 
25
- Check the top-level render call using <`+I+">.")}return y}}function ie(i,y){{if(!i._store||i._store.validated||i.key!=null)return;i._store.validated=!0;var I=hr(y);if(Ie[I])return;Ie[I]=!0;var A="";i&&i._owner&&i._owner!==Be.current&&(A=" It was passed a child from "+T(i._owner.type)+"."),Ge(i),f('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',I,A),Ge(null)}}function Gt(i,y){{if(typeof i!="object")return;if(ct(i))for(var I=0;I<i.length;I++){var A=i[I];we(A)&&ie(A,y)}else if(we(i))i._store&&(i._store.validated=!0);else if(i){var V=R(i);if(typeof V=="function"&&V!==i.entries)for(var G=V.call(i),$;!($=G.next()).done;)we($.value)&&ie($.value,y)}}}function Yt(i){{var y=i.type;if(y==null||typeof y=="string")return;var I;if(typeof y=="function")I=y.propTypes;else if(typeof y=="object"&&(y.$$typeof===h||y.$$typeof===g))I=y.propTypes;else return;if(I){var A=T(y);pe(I,i.props,"prop",A,i)}else if(y.PropTypes!==void 0&&!Pt){Pt=!0;var V=T(y);f("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",V||"Unknown")}typeof y.getDefaultProps=="function"&&!y.getDefaultProps.isReactClassApproved&&f("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function mt(i){{for(var y=Object.keys(i.props),I=0;I<y.length;I++){var A=y[I];if(A!=="children"&&A!=="key"){Ge(i),f("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",A),Ge(null);break}}i.ref!==null&&(Ge(i),f("Invalid attribute `ref` supplied to `React.Fragment`."),Ge(null))}}var Nt={};function Jt(i,y,I,A,V,G){{var $=v(i);if(!$){var U="";(i===void 0||typeof i=="object"&&i!==null&&Object.keys(i).length===0)&&(U+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var ue=Ht();ue?U+=ue:U+=Ye();var te;i===null?te="null":ct(i)?te="array":i!==void 0&&i.$$typeof===e?(te="<"+(T(i.type)||"Unknown")+" />",U=" Did you accidentally export a JSX literal instead of a component?"):te=typeof i,f("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",te,U)}var re=Oe(i,y,I,V,G);if(re==null)return re;if($){var Se=y.children;if(Se!==void 0)if(A)if(ct(Se)){for(var Ft=0;Ft<Se.length;Ft++)Gt(Se[Ft],i);Object.freeze&&Object.freeze(Se)}else f("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Gt(Se,i)}if(Ke.call(y,"key")){var gt=T(i),be=Object.keys(y).filter(function(Gs){return Gs!=="key"}),yr=be.length>0?"{key: someKey, "+be.join(": ..., ")+": ...}":"{key: someKey}";if(!Nt[gt+yr]){var Hs=be.length>0?"{"+be.join(": ..., ")+": ...}":"{}";f(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+P+">.")}return w}}function Ze(i,w){{if(!i._store||i._store.validated||i.key!=null)return;i._store.validated=!0;var P=Ne(w);if(Jt[P])return;Jt[P]=!0;var L="";i&&i._owner&&i._owner!==ve.current&&(L=" It was passed a child from "+D(i._owner.type)+"."),ee(i),m('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',P,L),ee(null)}}function Pt(i,w){{if(typeof i!="object")return;if(ae(i))for(var P=0;P<i.length;P++){var L=i[P];Pe(L)&&Ze(L,w)}else if(Pe(i))i._store&&(i._store.validated=!0);else if(i){var K=_(i);if(typeof K=="function"&&K!==i.entries)for(var Y=K.call(i),z;!(z=Y.next()).done;)Pe(z.value)&&Ze(z.value,w)}}}function Fe(i){{var w=i.type;if(w==null||typeof w=="string")return;var P;if(typeof w=="function")P=w.propTypes;else if(typeof w=="object"&&(w.$$typeof===y||w.$$typeof===x))P=w.propTypes;else return;if(P){var L=D(w);W(P,i.props,"prop",L,i)}else if(w.PropTypes!==void 0&&!It){It=!0;var K=D(w);m("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",K||"Unknown")}typeof w.getDefaultProps=="function"&&!w.getDefaultProps.isReactClassApproved&&m("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function hr(i){{for(var w=Object.keys(i.props),P=0;P<w.length;P++){var L=w[P];if(L!=="children"&&L!=="key"){ee(i),m("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",L),ee(null);break}}i.ref!==null&&(ee(i),m("Invalid attribute `ref` supplied to `React.Fragment`."),ee(null))}}var X={};function Xt(i,w,P,L,K,Y){{var z=k(i);if(!z){var q="";(i===void 0||typeof i=="object"&&i!==null&&Object.keys(i).length===0)&&(q+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var fe=yr();fe?q+=fe:q+=Yt();var re;i===null?re="null":ae(i)?re="array":i!==void 0&&i.$$typeof===e?(re="<"+(D(i.type)||"Unknown")+" />",q=" Did you accidentally export a JSX literal instead of a component?"):re=typeof i,m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",re,q)}var ie=he(i,w,P,K,Y);if(ie==null)return ie;if(z){var Se=w.children;if(Se!==void 0)if(L)if(ae(Se)){for(var Nt=0;Nt<Se.length;Nt++)Pt(Se[Nt],i);Object.freeze&&Object.freeze(Se)}else m("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Pt(Se,i)}if(Ke.call(w,"key")){var ft=D(i),ge=Object.keys(w).filter(function(Xs){return Xs!=="key"}),vr=ge.length>0?"{key: someKey, "+ge.join(": ..., ")+": ...}":"{key: someKey}";if(!X[ft+vr]){var Js=ge.length>0?"{"+ge.join(": ..., ")+": ...}":"{}";m(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,yr,gt,Hs,gt),Nt[gt+yr]=!0}}return i===s?mt(re):Yt(re),re}}function xr(i,y,I){return Jt(i,y,I,!0)}function Ks(i,y,I){return Jt(i,y,I,!1)}var Vs=Ks,zs=xr;Zt.Fragment=s,Zt.jsx=Vs,Zt.jsxs=zs}()),Zt}process.env.NODE_ENV==="production"?wr.exports=Zs():wr.exports=en();var n=wr.exports,cr=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},tn={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Ae,yt,us,rn=(us=class{constructor(){M(this,Ae,tn);M(this,yt,!1)}setTimeoutProvider(t){process.env.NODE_ENV!=="production"&&a(this,yt)&&t!==a(this,Ae)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:a(this,Ae),provider:t}),_(this,Ae,t),process.env.NODE_ENV!=="production"&&_(this,yt,!1)}setTimeout(t,e){return process.env.NODE_ENV!=="production"&&_(this,yt,!0),a(this,Ae).setTimeout(t,e)}clearTimeout(t){a(this,Ae).clearTimeout(t)}setInterval(t,e){return process.env.NODE_ENV!=="production"&&_(this,yt,!0),a(this,Ae).setInterval(t,e)}clearInterval(t){a(this,Ae).clearInterval(t)}},Ae=new WeakMap,yt=new WeakMap,us),xt=new rn;function sn(t){setTimeout(t,0)}var _t=typeof window>"u"||"Deno"in globalThis;function ge(){}function nn(t,e){return typeof t=="function"?t(e):t}function Sr(t){return typeof t=="number"&&t>=0&&t!==1/0}function vs(t,e){return Math.max(t+(e||0)-Date.now(),0)}function it(t,e){return typeof t=="function"?t(e):t}function Ce(t,e){return typeof t=="function"?t(e):t}function Yr(t,e){const{type:r="all",exact:s,fetchStatus:o,predicate:l,queryKey:c,stale:x}=t;if(c){if(s){if(e.queryHash!==Ar(c,e.options))return!1}else if(!rr(e.queryKey,c))return!1}if(r!=="all"){const h=e.isActive();if(r==="active"&&!h||r==="inactive"&&h)return!1}return!(typeof x=="boolean"&&e.isStale()!==x||o&&o!==e.state.fetchStatus||l&&!l(e))}function Jr(t,e){const{exact:r,status:s,predicate:o,mutationKey:l}=t;if(l){if(!e.options.mutationKey)return!1;if(r){if(tr(e.options.mutationKey)!==tr(l))return!1}else if(!rr(e.options.mutationKey,l))return!1}return!(s&&e.state.status!==s||o&&!o(e))}function Ar(t,e){return((e==null?void 0:e.queryKeyHashFn)||tr)(t)}function tr(t){return JSON.stringify(t,(e,r)=>Er(r)?Object.keys(r).sort().reduce((s,o)=>(s[o]=r[o],s),{}):r)}function rr(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>rr(t[r],e[r])):!1}var an=Object.prototype.hasOwnProperty;function jr(t,e){if(t===e)return t;const r=Xr(t)&&Xr(e);if(!r&&!(Er(t)&&Er(e)))return e;const o=(r?t:Object.keys(t)).length,l=r?e:Object.keys(e),c=l.length,x=r?new Array(c):{};let h=0;for(let w=0;w<c;w++){const d=r?w:l[w],g=t[d],m=e[d];if(g===m){x[d]=g,(r?w<o:an.call(t,d))&&h++;continue}if(g===null||m===null||typeof g!="object"||typeof m!="object"){x[d]=m;continue}const S=jr(g,m);x[d]=S,S===g&&h++}return o===c&&h===o?t:x}function Cr(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const r in t)if(t[r]!==e[r])return!1;return!0}function Xr(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Er(t){if(!Zr(t))return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(!Zr(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Zr(t){return Object.prototype.toString.call(t)==="[object Object]"}function on(t){return new Promise(e=>{xt.setTimeout(e,t)})}function Rr(t,e,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(t,e);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return jr(t,e)}catch(s){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${s}`),s}return jr(t,e)}return e}function ln(t,e,r=0){const s=[...t,e];return r&&s.length>r?s.slice(1):s}function cn(t,e,r=0){const s=[e,...t];return r&&s.length>r?s.slice(0,-1):s}var br=Symbol();function ws(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===br&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===br?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function un(t,e){return typeof t=="function"?t(...e):!!t}function dn(t,e,r){let s=!1,o;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(o??(o=e()),s||(s=!0,o.aborted?r():o.addEventListener("abort",r,{once:!0})),o)}),t}var vt,Xe,Mt,ds,hn=(ds=class extends cr{constructor(){super();M(this,vt);M(this,Xe);M(this,Mt);_(this,Mt,e=>{if(!_t&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){a(this,Xe)||this.setEventListener(a(this,Mt))}onUnsubscribe(){var e;this.hasListeners()||((e=a(this,Xe))==null||e.call(this),_(this,Xe,void 0))}setEventListener(e){var r;_(this,Mt,e),(r=a(this,Xe))==null||r.call(this),_(this,Xe,e(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(e){a(this,vt)!==e&&(_(this,vt,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof a(this,vt)=="boolean"?a(this,vt):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},vt=new WeakMap,Xe=new WeakMap,Mt=new WeakMap,ds),Dr=new hn;function Tr(){let t,e;const r=new Promise((o,l)=>{t=o,e=l});r.status="pending",r.catch(()=>{});function s(o){Object.assign(r,o),delete r.resolve,delete r.reject}return r.resolve=o=>{s({status:"fulfilled",value:o}),t(o)},r.reject=o=>{s({status:"rejected",reason:o}),e(o)},r}var fn=sn;function pn(){let t=[],e=0,r=x=>{x()},s=x=>{x()},o=fn;const l=x=>{e?t.push(x):o(()=>{r(x)})},c=()=>{const x=t;t=[],x.length&&o(()=>{s(()=>{x.forEach(h=>{r(h)})})})};return{batch:x=>{let h;e++;try{h=x()}finally{e--,e||c()}return h},batchCalls:x=>(...h)=>{l(()=>{x(...h)})},schedule:l,setNotifyFunction:x=>{r=x},setBatchNotifyFunction:x=>{s=x},setScheduler:x=>{o=x}}}var le=pn(),Bt,Ze,At,hs,bn=(hs=class extends cr{constructor(){super();M(this,Bt,!0);M(this,Ze);M(this,At);_(this,At,e=>{if(!_t&&window.addEventListener){const r=()=>e(!0),s=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",s)}}})}onSubscribe(){a(this,Ze)||this.setEventListener(a(this,At))}onUnsubscribe(){var e;this.hasListeners()||((e=a(this,Ze))==null||e.call(this),_(this,Ze,void 0))}setEventListener(e){var r;_(this,At,e),(r=a(this,Ze))==null||r.call(this),_(this,Ze,e(this.setOnline.bind(this)))}setOnline(e){a(this,Bt)!==e&&(_(this,Bt,e),this.listeners.forEach(s=>{s(e)}))}isOnline(){return a(this,Bt)}},Bt=new WeakMap,Ze=new WeakMap,At=new WeakMap,hs),mr=new bn;function mn(t){return Math.min(1e3*2**t,3e4)}function Ss(t){return(t??"online")==="online"?mr.isOnline():!0}var kr=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function js(t){let e=!1,r=0,s;const o=Tr(),l=()=>o.status!=="pending",c=E=>{var R;if(!l()){const k=new kr(E);m(k),(R=t.onCancel)==null||R.call(t,k)}},x=()=>{e=!0},h=()=>{e=!1},w=()=>Dr.isFocused()&&(t.networkMode==="always"||mr.isOnline())&&t.canRun(),d=()=>Ss(t.networkMode)&&t.canRun(),g=E=>{l()||(s==null||s(),o.resolve(E))},m=E=>{l()||(s==null||s(),o.reject(E))},S=()=>new Promise(E=>{var R;s=k=>{(l()||w())&&E(k)},(R=t.onPause)==null||R.call(t)}).then(()=>{var E;s=void 0,l()||(E=t.onContinue)==null||E.call(t)}),P=()=>{if(l())return;let E;const R=r===0?t.initialPromise:void 0;try{E=R??t.fn()}catch(k){E=Promise.reject(k)}Promise.resolve(E).then(g).catch(k=>{var C;if(l())return;const f=t.retry??(_t?0:3),j=t.retryDelay??mn,b=typeof j=="function"?j(r,k):j,p=f===!0||typeof f=="number"&&r<f||typeof f=="function"&&f(r,k);if(e||!p){m(k);return}r++,(C=t.onFail)==null||C.call(t,r,k),on(b).then(()=>w()?void 0:S()).then(()=>{e?m(k):P()})})};return{promise:o,status:()=>o.status,cancel:c,continue:()=>(s==null||s(),o),cancelRetry:x,continueRetry:h,canStart:d,start:()=>(d()?P():S().then(P),o)}}var wt,fs,Cs=(fs=class{constructor(){M(this,wt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Sr(this.gcTime)&&_(this,wt,xt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(_t?1/0:5*60*1e3))}clearGcTimeout(){a(this,wt)&&(xt.clearTimeout(a(this,wt)),_(this,wt,void 0))}},wt=new WeakMap,fs),St,Dt,je,jt,ae,sr,Ct,Pe,qe,ps,gn=(ps=class extends Cs{constructor(e){super();M(this,Pe);M(this,St);M(this,Dt);M(this,je);M(this,jt);M(this,ae);M(this,sr);M(this,Ct);_(this,Ct,!1),_(this,sr,e.defaultOptions),this.setOptions(e.options),this.observers=[],_(this,jt,e.client),_(this,je,a(this,jt).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,_(this,St,ts(this.options)),this.state=e.state??a(this,St),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=a(this,ae))==null?void 0:e.promise}setOptions(e){if(this.options={...a(this,sr),...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=ts(this.options);r.data!==void 0&&(this.setState(es(r.data,r.dataUpdatedAt)),_(this,St,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&a(this,je).remove(this)}setData(e,r){const s=Rr(this.state.data,e,this.options);return q(this,Pe,qe).call(this,{data:s,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),s}setState(e,r){q(this,Pe,qe).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var s,o;const r=(s=a(this,ae))==null?void 0:s.promise;return(o=a(this,ae))==null||o.cancel(e),r?r.then(ge).catch(ge):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(a(this,St))}isActive(){return this.observers.some(e=>Ce(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===br||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>it(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!vs(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(s=>s.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=a(this,ae))==null||r.continue()}onOnline(){var r;const e=this.observers.find(s=>s.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=a(this,ae))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),a(this,je).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(a(this,ae)&&(a(this,Ct)?a(this,ae).cancel({revert:!0}):a(this,ae).cancelRetry()),this.scheduleGc()),a(this,je).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||q(this,Pe,qe).call(this,{type:"invalidate"})}async fetch(e,r){var h,w,d,g,m,S,P,E,R,k,f,j;if(this.state.fetchStatus!=="idle"&&((h=a(this,ae))==null?void 0:h.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(a(this,ae))return a(this,ae).continueRetry(),a(this,ae).promise}if(e&&this.setOptions(e),!this.options.queryFn){const b=this.observers.find(p=>p.options.queryFn);b&&this.setOptions(b.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const s=new AbortController,o=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(_(this,Ct,!0),s.signal)})},l=()=>{const b=ws(this.options,r),C=(()=>{const O={client:a(this,jt),queryKey:this.queryKey,meta:this.meta};return o(O),O})();return _(this,Ct,!1),this.options.persister?this.options.persister(b,C,this):b(C)},x=(()=>{const b={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:a(this,jt),state:this.state,fetchFn:l};return o(b),b})();(w=this.options.behavior)==null||w.onFetch(x,this),_(this,Dt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=x.fetchOptions)==null?void 0:d.meta))&&q(this,Pe,qe).call(this,{type:"fetch",meta:(g=x.fetchOptions)==null?void 0:g.meta}),_(this,ae,js({initialPromise:r==null?void 0:r.initialPromise,fn:x.fetchFn,onCancel:b=>{b instanceof kr&&b.revert&&this.setState({...a(this,Dt),fetchStatus:"idle"}),s.abort()},onFail:(b,p)=>{q(this,Pe,qe).call(this,{type:"failed",failureCount:b,error:p})},onPause:()=>{q(this,Pe,qe).call(this,{type:"pause"})},onContinue:()=>{q(this,Pe,qe).call(this,{type:"continue"})},retry:x.options.retry,retryDelay:x.options.retryDelay,networkMode:x.options.networkMode,canRun:()=>!0}));try{const b=await a(this,ae).start();if(b===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(b),(S=(m=a(this,je).config).onSuccess)==null||S.call(m,b,this),(E=(P=a(this,je).config).onSettled)==null||E.call(P,b,this.state.error,this),b}catch(b){if(b instanceof kr){if(b.silent)return a(this,ae).promise;if(b.revert){if(this.state.data===void 0)throw b;return this.state.data}}throw q(this,Pe,qe).call(this,{type:"error",error:b}),(k=(R=a(this,je).config).onError)==null||k.call(R,b,this),(j=(f=a(this,je).config).onSettled)==null||j.call(f,this.state.data,b,this),b}finally{this.scheduleGc()}}},St=new WeakMap,Dt=new WeakMap,je=new WeakMap,jt=new WeakMap,ae=new WeakMap,sr=new WeakMap,Ct=new WeakMap,Pe=new WeakSet,qe=function(e){const r=s=>{switch(e.type){case"failed":return{...s,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...Es(s.data,this.options),fetchMeta:e.meta??null};case"success":const o={...s,...es(e.data,e.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return _(this,Dt,e.manual?o:void 0),o;case"error":const l=e.error;return{...s,error:l,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:l,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...e.state}}};this.state=r(this.state),le.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),a(this,je).notify({query:this,type:"updated",action:e})})},ps);function Es(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ss(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function es(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function ts(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,s=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var me,Q,nr,de,Et,Lt,Qe,et,ir,Ut,Wt,Rt,Tt,tt,qt,z,er,_r,Or,Ir,Pr,Nr,Fr,Mr,Rs,bs,xn=(bs=class extends cr{constructor(e,r){super();M(this,z);M(this,me);M(this,Q);M(this,nr);M(this,de);M(this,Et);M(this,Lt);M(this,Qe);M(this,et);M(this,ir);M(this,Ut);M(this,Wt);M(this,Rt);M(this,Tt);M(this,tt);M(this,qt,new Set);this.options=r,_(this,me,e),_(this,et,null),_(this,Qe,Tr()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(a(this,Q).addObserver(this),rs(a(this,Q),this.options)?q(this,z,er).call(this):this.updateResult(),q(this,z,Pr).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Br(a(this,Q),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Br(a(this,Q),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,q(this,z,Nr).call(this),q(this,z,Fr).call(this),a(this,Q).removeObserver(this)}setOptions(e){const r=this.options,s=a(this,Q);if(this.options=a(this,me).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ce(this.options.enabled,a(this,Q))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");q(this,z,Mr).call(this),a(this,Q).setOptions(this.options),r._defaulted&&!Cr(this.options,r)&&a(this,me).getQueryCache().notify({type:"observerOptionsUpdated",query:a(this,Q),observer:this});const o=this.hasListeners();o&&ss(a(this,Q),s,this.options,r)&&q(this,z,er).call(this),this.updateResult(),o&&(a(this,Q)!==s||Ce(this.options.enabled,a(this,Q))!==Ce(r.enabled,a(this,Q))||it(this.options.staleTime,a(this,Q))!==it(r.staleTime,a(this,Q)))&&q(this,z,_r).call(this);const l=q(this,z,Or).call(this);o&&(a(this,Q)!==s||Ce(this.options.enabled,a(this,Q))!==Ce(r.enabled,a(this,Q))||l!==a(this,tt))&&q(this,z,Ir).call(this,l)}getOptimisticResult(e){const r=a(this,me).getQueryCache().build(a(this,me),e),s=this.createResult(r,e);return vn(this,s)&&(_(this,de,s),_(this,Lt,this.options),_(this,Et,a(this,Q).state)),s}getCurrentResult(){return a(this,de)}trackResult(e,r){return new Proxy(e,{get:(s,o)=>(this.trackProp(o),r==null||r(o),o==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&a(this,Qe).status==="pending"&&a(this,Qe).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,o))})}trackProp(e){a(this,qt).add(e)}getCurrentQuery(){return a(this,Q)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=a(this,me).defaultQueryOptions(e),s=a(this,me).getQueryCache().build(a(this,me),r);return s.fetch().then(()=>this.createResult(s,r))}fetch(e){return q(this,z,er).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),a(this,de)))}createResult(e,r){var B;const s=a(this,Q),o=this.options,l=a(this,de),c=a(this,Et),x=a(this,Lt),w=e!==s?e.state:a(this,nr),{state:d}=e;let g={...d},m=!1,S;if(r._optimisticResults){const v=this.hasListeners(),F=!v&&rs(e,r),K=v&&ss(e,s,r,o);(F||K)&&(g={...g,...Es(d.data,e.options)}),r._optimisticResults==="isRestoring"&&(g.fetchStatus="idle")}let{error:P,errorUpdatedAt:E,status:R}=g;S=g.data;let k=!1;if(r.placeholderData!==void 0&&S===void 0&&R==="pending"){let v;l!=null&&l.isPlaceholderData&&r.placeholderData===(x==null?void 0:x.placeholderData)?(v=l.data,k=!0):v=typeof r.placeholderData=="function"?r.placeholderData((B=a(this,Wt))==null?void 0:B.state.data,a(this,Wt)):r.placeholderData,v!==void 0&&(R="success",S=Rr(l==null?void 0:l.data,v,r),m=!0)}if(r.select&&S!==void 0&&!k)if(l&&S===(c==null?void 0:c.data)&&r.select===a(this,ir))S=a(this,Ut);else try{_(this,ir,r.select),S=r.select(S),S=Rr(l==null?void 0:l.data,S,r),_(this,Ut,S),_(this,et,null)}catch(v){_(this,et,v)}a(this,et)&&(P=a(this,et),S=a(this,Ut),E=Date.now(),R="error");const f=g.fetchStatus==="fetching",j=R==="pending",b=R==="error",p=j&&f,C=S!==void 0,N={status:R,fetchStatus:g.fetchStatus,isPending:j,isSuccess:R==="success",isError:b,isInitialLoading:p,isLoading:p,data:S,dataUpdatedAt:g.dataUpdatedAt,error:P,errorUpdatedAt:E,failureCount:g.fetchFailureCount,failureReason:g.fetchFailureReason,errorUpdateCount:g.errorUpdateCount,isFetched:g.dataUpdateCount>0||g.errorUpdateCount>0,isFetchedAfterMount:g.dataUpdateCount>w.dataUpdateCount||g.errorUpdateCount>w.errorUpdateCount,isFetching:f,isRefetching:f&&!j,isLoadingError:b&&!C,isPaused:g.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:b&&C,isStale:Lr(e,r),refetch:this.refetch,promise:a(this,Qe),isEnabled:Ce(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const v=T=>{N.status==="error"?T.reject(N.error):N.data!==void 0&&T.resolve(N.data)},F=()=>{const T=_(this,Qe,N.promise=Tr());v(T)},K=a(this,Qe);switch(K.status){case"pending":e.queryHash===s.queryHash&&v(K);break;case"fulfilled":(N.status==="error"||N.data!==K.value)&&F();break;case"rejected":(N.status!=="error"||N.error!==K.reason)&&F();break}}return N}updateResult(){const e=a(this,de),r=this.createResult(a(this,Q),this.options);if(_(this,Et,a(this,Q).state),_(this,Lt,this.options),a(this,Et).data!==void 0&&_(this,Wt,a(this,Q)),Cr(r,e))return;_(this,de,r);const s=()=>{if(!e)return!0;const{notifyOnChangeProps:o}=this.options,l=typeof o=="function"?o():o;if(l==="all"||!l&&!a(this,qt).size)return!0;const c=new Set(l??a(this,qt));return this.options.throwOnError&&c.add("error"),Object.keys(a(this,de)).some(x=>{const h=x;return a(this,de)[h]!==e[h]&&c.has(h)})};q(this,z,Rs).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&q(this,z,Pr).call(this)}},me=new WeakMap,Q=new WeakMap,nr=new WeakMap,de=new WeakMap,Et=new WeakMap,Lt=new WeakMap,Qe=new WeakMap,et=new WeakMap,ir=new WeakMap,Ut=new WeakMap,Wt=new WeakMap,Rt=new WeakMap,Tt=new WeakMap,tt=new WeakMap,qt=new WeakMap,z=new WeakSet,er=function(e){q(this,z,Mr).call(this);let r=a(this,Q).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(ge)),r},_r=function(){q(this,z,Nr).call(this);const e=it(this.options.staleTime,a(this,Q));if(_t||a(this,de).isStale||!Sr(e))return;const s=vs(a(this,de).dataUpdatedAt,e)+1;_(this,Rt,xt.setTimeout(()=>{a(this,de).isStale||this.updateResult()},s))},Or=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(a(this,Q)):this.options.refetchInterval)??!1},Ir=function(e){q(this,z,Fr).call(this),_(this,tt,e),!(_t||Ce(this.options.enabled,a(this,Q))===!1||!Sr(a(this,tt))||a(this,tt)===0)&&_(this,Tt,xt.setInterval(()=>{(this.options.refetchIntervalInBackground||Dr.isFocused())&&q(this,z,er).call(this)},a(this,tt)))},Pr=function(){q(this,z,_r).call(this),q(this,z,Ir).call(this,q(this,z,Or).call(this))},Nr=function(){a(this,Rt)&&(xt.clearTimeout(a(this,Rt)),_(this,Rt,void 0))},Fr=function(){a(this,Tt)&&(xt.clearInterval(a(this,Tt)),_(this,Tt,void 0))},Mr=function(){const e=a(this,me).getQueryCache().build(a(this,me),this.options);if(e===a(this,Q))return;const r=a(this,Q);_(this,Q,e),_(this,nr,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},Rs=function(e){le.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(a(this,de))}),a(this,me).getQueryCache().notify({query:a(this,Q),type:"observerResultsUpdated"})})},bs);function yn(t,e){return Ce(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function rs(t,e){return yn(t,e)||t.state.data!==void 0&&Br(t,e,e.refetchOnMount)}function Br(t,e,r){if(Ce(e.enabled,t)!==!1&&it(e.staleTime,t)!=="static"){const s=typeof r=="function"?r(t):r;return s==="always"||s!==!1&&Lr(t,e)}return!1}function ss(t,e,r,s){return(t!==e||Ce(s.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&Lr(t,r)}function Lr(t,e){return Ce(e.enabled,t)!==!1&&t.isStaleByTime(it(e.staleTime,t))}function vn(t,e){return!Cr(t.getCurrentResult(),e)}function ns(t){return{onFetch:(e,r)=>{var d,g,m,S,P;const s=e.options,o=(m=(g=(d=e.fetchOptions)==null?void 0:d.meta)==null?void 0:g.fetchMore)==null?void 0:m.direction,l=((S=e.state.data)==null?void 0:S.pages)||[],c=((P=e.state.data)==null?void 0:P.pageParams)||[];let x={pages:[],pageParams:[]},h=0;const w=async()=>{let E=!1;const R=j=>{dn(j,()=>e.signal,()=>E=!0)},k=ws(e.options,e.fetchOptions),f=async(j,b,p)=>{if(E)return Promise.reject();if(b==null&&j.pages.length)return Promise.resolve(j);const O=(()=>{const F={client:e.client,queryKey:e.queryKey,pageParam:b,direction:p?"backward":"forward",meta:e.options.meta};return R(F),F})(),N=await k(O),{maxPages:B}=e.options,v=p?cn:ln;return{pages:v(j.pages,N,B),pageParams:v(j.pageParams,b,B)}};if(o&&l.length){const j=o==="backward",b=j?wn:is,p={pages:l,pageParams:c},C=b(s,p);x=await f(p,C,j)}else{const j=t??l.length;do{const b=h===0?c[0]??s.initialPageParam:is(s,x);if(h>0&&b==null)break;x=await f(x,b),h++}while(h<j)}return x};e.options.persister?e.fetchFn=()=>{var E,R;return(R=(E=e.options).persister)==null?void 0:R.call(E,w,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=w}}}function is(t,{pages:e,pageParams:r}){const s=e.length-1;return e.length>0?t.getNextPageParam(e[s],e,r[s],r):void 0}function wn(t,{pages:e,pageParams:r}){var s;return e.length>0?(s=t.getPreviousPageParam)==null?void 0:s.call(t,e[0],e,r[0],r):void 0}var ar,De,he,kt,Le,Je,ms,Sn=(ms=class extends Cs{constructor(e){super();M(this,Le);M(this,ar);M(this,De);M(this,he);M(this,kt);_(this,ar,e.client),this.mutationId=e.mutationId,_(this,he,e.mutationCache),_(this,De,[]),this.state=e.state||jn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){a(this,De).includes(e)||(a(this,De).push(e),this.clearGcTimeout(),a(this,he).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){_(this,De,a(this,De).filter(r=>r!==e)),this.scheduleGc(),a(this,he).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){a(this,De).length||(this.state.status==="pending"?this.scheduleGc():a(this,he).remove(this))}continue(){var e;return((e=a(this,kt))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var c,x,h,w,d,g,m,S,P,E,R,k,f,j,b,p,C,O,N,B;const r=()=>{q(this,Le,Je).call(this,{type:"continue"})},s={client:a(this,ar),meta:this.options.meta,mutationKey:this.options.mutationKey};_(this,kt,js({fn:()=>this.options.mutationFn?this.options.mutationFn(e,s):Promise.reject(new Error("No mutationFn found")),onFail:(v,F)=>{q(this,Le,Je).call(this,{type:"failed",failureCount:v,error:F})},onPause:()=>{q(this,Le,Je).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>a(this,he).canRun(this)}));const o=this.state.status==="pending",l=!a(this,kt).canStart();try{if(o)r();else{q(this,Le,Je).call(this,{type:"pending",variables:e,isPaused:l}),await((x=(c=a(this,he).config).onMutate)==null?void 0:x.call(c,e,this,s));const F=await((w=(h=this.options).onMutate)==null?void 0:w.call(h,e,s));F!==this.state.context&&q(this,Le,Je).call(this,{type:"pending",context:F,variables:e,isPaused:l})}const v=await a(this,kt).start();return await((g=(d=a(this,he).config).onSuccess)==null?void 0:g.call(d,v,e,this.state.context,this,s)),await((S=(m=this.options).onSuccess)==null?void 0:S.call(m,v,e,this.state.context,s)),await((E=(P=a(this,he).config).onSettled)==null?void 0:E.call(P,v,null,this.state.variables,this.state.context,this,s)),await((k=(R=this.options).onSettled)==null?void 0:k.call(R,v,null,e,this.state.context,s)),q(this,Le,Je).call(this,{type:"success",data:v}),v}catch(v){try{await((j=(f=a(this,he).config).onError)==null?void 0:j.call(f,v,e,this.state.context,this,s))}catch(F){Promise.reject(F)}try{await((p=(b=this.options).onError)==null?void 0:p.call(b,v,e,this.state.context,s))}catch(F){Promise.reject(F)}try{await((O=(C=a(this,he).config).onSettled)==null?void 0:O.call(C,void 0,v,this.state.variables,this.state.context,this,s))}catch(F){Promise.reject(F)}try{await((B=(N=this.options).onSettled)==null?void 0:B.call(N,void 0,v,e,this.state.context,s))}catch(F){Promise.reject(F)}throw q(this,Le,Je).call(this,{type:"error",error:v}),v}finally{a(this,he).runNext(this)}}},ar=new WeakMap,De=new WeakMap,he=new WeakMap,kt=new WeakMap,Le=new WeakSet,Je=function(e){const r=s=>{switch(e.type){case"failed":return{...s,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...s,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:e.error,failureCount:s.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),le.batch(()=>{a(this,De).forEach(s=>{s.onMutationUpdate(e)}),a(this,he).notify({mutation:this,type:"updated",action:e})})},ms);function jn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var $e,Ne,or,gs,Cn=(gs=class extends cr{constructor(e={}){super();M(this,$e);M(this,Ne);M(this,or);this.config=e,_(this,$e,new Set),_(this,Ne,new Map),_(this,or,0)}build(e,r,s){const o=new Sn({client:e,mutationCache:this,mutationId:++fr(this,or)._,options:e.defaultMutationOptions(r),state:s});return this.add(o),o}add(e){a(this,$e).add(e);const r=pr(e);if(typeof r=="string"){const s=a(this,Ne).get(r);s?s.push(e):a(this,Ne).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(a(this,$e).delete(e)){const r=pr(e);if(typeof r=="string"){const s=a(this,Ne).get(r);if(s)if(s.length>1){const o=s.indexOf(e);o!==-1&&s.splice(o,1)}else s[0]===e&&a(this,Ne).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=pr(e);if(typeof r=="string"){const s=a(this,Ne).get(r),o=s==null?void 0:s.find(l=>l.state.status==="pending");return!o||o===e}else return!0}runNext(e){var s;const r=pr(e);if(typeof r=="string"){const o=(s=a(this,Ne).get(r))==null?void 0:s.find(l=>l!==e&&l.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){le.batch(()=>{a(this,$e).forEach(e=>{this.notify({type:"removed",mutation:e})}),a(this,$e).clear(),a(this,Ne).clear()})}getAll(){return Array.from(a(this,$e))}find(e){const r={exact:!0,...e};return this.getAll().find(s=>Jr(r,s))}findAll(e={}){return this.getAll().filter(r=>Jr(e,r))}notify(e){le.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return le.batch(()=>Promise.all(e.map(r=>r.continue().catch(ge))))}},$e=new WeakMap,Ne=new WeakMap,or=new WeakMap,gs);function pr(t){var e;return(e=t.options.scope)==null?void 0:e.id}var Ue,xs,En=(xs=class extends cr{constructor(e={}){super();M(this,Ue);this.config=e,_(this,Ue,new Map)}build(e,r,s){const o=r.queryKey,l=r.queryHash??Ar(o,r);let c=this.get(l);return c||(c=new gn({client:e,queryKey:o,queryHash:l,options:e.defaultQueryOptions(r),state:s,defaultOptions:e.getQueryDefaults(o)}),this.add(c)),c}add(e){a(this,Ue).has(e.queryHash)||(a(this,Ue).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=a(this,Ue).get(e.queryHash);r&&(e.destroy(),r===e&&a(this,Ue).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){le.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return a(this,Ue).get(e)}getAll(){return[...a(this,Ue).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(s=>Yr(r,s))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(s=>Yr(e,s)):r}notify(e){le.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){le.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){le.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Ue=new WeakMap,xs),Z,rt,st,Qt,$t,nt,Kt,Vt,ys,Rn=(ys=class{constructor(t={}){M(this,Z);M(this,rt);M(this,st);M(this,Qt);M(this,$t);M(this,nt);M(this,Kt);M(this,Vt);_(this,Z,t.queryCache||new En),_(this,rt,t.mutationCache||new Cn),_(this,st,t.defaultOptions||{}),_(this,Qt,new Map),_(this,$t,new Map),_(this,nt,0)}mount(){fr(this,nt)._++,a(this,nt)===1&&(_(this,Kt,Dr.subscribe(async t=>{t&&(await this.resumePausedMutations(),a(this,Z).onFocus())})),_(this,Vt,mr.subscribe(async t=>{t&&(await this.resumePausedMutations(),a(this,Z).onOnline())})))}unmount(){var t,e;fr(this,nt)._--,a(this,nt)===0&&((t=a(this,Kt))==null||t.call(this),_(this,Kt,void 0),(e=a(this,Vt))==null||e.call(this),_(this,Vt,void 0))}isFetching(t){return a(this,Z).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return a(this,rt).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=a(this,Z).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=a(this,Z).build(this,e),s=r.state.data;return s===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(it(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(s))}getQueriesData(t){return a(this,Z).findAll(t).map(({queryKey:e,state:r})=>{const s=r.data;return[e,s]})}setQueryData(t,e,r){const s=this.defaultQueryOptions({queryKey:t}),o=a(this,Z).get(s.queryHash),l=o==null?void 0:o.state.data,c=nn(e,l);if(c!==void 0)return a(this,Z).build(this,s).setData(c,{...r,manual:!0})}setQueriesData(t,e,r){return le.batch(()=>a(this,Z).findAll(t).map(({queryKey:s})=>[s,this.setQueryData(s,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=a(this,Z).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=a(this,Z);le.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=a(this,Z);return le.batch(()=>(r.findAll(t).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},s=le.batch(()=>a(this,Z).findAll(t).map(o=>o.cancel(r)));return Promise.all(s).then(ge).catch(ge)}invalidateQueries(t,e={}){return le.batch(()=>(a(this,Z).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const r={...e,cancelRefetch:e.cancelRefetch??!0},s=le.batch(()=>a(this,Z).findAll(t).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let l=o.fetch(void 0,r);return r.throwOnError||(l=l.catch(ge)),o.state.fetchStatus==="paused"?Promise.resolve():l}));return Promise.all(s).then(ge)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=a(this,Z).build(this,e);return r.isStaleByTime(it(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(ge).catch(ge)}fetchInfiniteQuery(t){return t.behavior=ns(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(ge).catch(ge)}ensureInfiniteQueryData(t){return t.behavior=ns(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return mr.isOnline()?a(this,rt).resumePausedMutations():Promise.resolve()}getQueryCache(){return a(this,Z)}getMutationCache(){return a(this,rt)}getDefaultOptions(){return a(this,st)}setDefaultOptions(t){_(this,st,t)}setQueryDefaults(t,e){a(this,Qt).set(tr(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...a(this,Qt).values()],r={};return e.forEach(s=>{rr(t,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(t,e){a(this,$t).set(tr(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...a(this,$t).values()],r={};return e.forEach(s=>{rr(t,s.mutationKey)&&Object.assign(r,s.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={...a(this,st).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Ar(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===br&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...a(this,st).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){a(this,Z).clear(),a(this,rt).clear()}},Z=new WeakMap,rt=new WeakMap,st=new WeakMap,Qt=new WeakMap,$t=new WeakMap,nt=new WeakMap,Kt=new WeakMap,Vt=new WeakMap,ys),Ts=Ee.createContext(void 0),ks=t=>{const e=Ee.useContext(Ts);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Tn=({client:t,children:e})=>(Ee.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),n.jsx(Ts.Provider,{value:t,children:e})),_s=Ee.createContext(!1),kn=()=>Ee.useContext(_s);_s.Provider;function _n(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var On=Ee.createContext(_n()),In=()=>Ee.useContext(On),Pn=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Nn=t=>{Ee.useEffect(()=>{t.clearReset()},[t])},Fn=({result:t,errorResetBoundary:e,throwOnError:r,query:s,suspense:o})=>t.isError&&!e.isReset()&&!t.isFetching&&s&&(o&&t.data===void 0||un(r,[t.error,s])),Mn=t=>{if(t.suspense){const r=o=>o==="static"?o:Math.max(o??1e3,1e3),s=t.staleTime;t.staleTime=typeof s=="function"?(...o)=>r(s(...o)):r(s),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},Bn=(t,e)=>t.isLoading&&t.isFetching&&!e,An=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,as=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function Dn(t,e,r){var g,m,S,P,E;if(process.env.NODE_ENV!=="production"&&(typeof t!="object"||Array.isArray(t)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const s=kn(),o=In(),l=ks(),c=l.defaultQueryOptions(t);(m=(g=l.getDefaultOptions().queries)==null?void 0:g._experimental_beforeQuery)==null||m.call(g,c),process.env.NODE_ENV!=="production"&&(c.queryFn||console.error(`[${c.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),c._optimisticResults=s?"isRestoring":"optimistic",Mn(c),Pn(c,o),Nn(o);const x=!l.getQueryCache().get(c.queryHash),[h]=Ee.useState(()=>new e(l,c)),w=h.getOptimisticResult(c),d=!s&&t.subscribed!==!1;if(Ee.useSyncExternalStore(Ee.useCallback(R=>{const k=d?h.subscribe(le.batchCalls(R)):ge;return h.updateResult(),k},[h,d]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),Ee.useEffect(()=>{h.setOptions(c)},[c,h]),An(c,w))throw as(c,h,o);if(Fn({result:w,errorResetBoundary:o,throwOnError:c.throwOnError,query:l.getQueryCache().get(c.queryHash),suspense:c.suspense}))throw w.error;if((P=(S=l.getDefaultOptions().queries)==null?void 0:S._experimental_afterQuery)==null||P.call(S,c,w),c.experimental_prefetchInRender&&!_t&&Bn(w,s)){const R=x?as(c,h,o):(E=l.getQueryCache().get(c.queryHash))==null?void 0:E.promise;R==null||R.catch(ge).finally(()=>{h.updateResult()})}return c.notifyOnChangeProps?w:h.trackResult(w)}function Os(t,e){return Dn(t,xn)}const Is=u.createContext(null);function Ps({children:t,bobConfig:e,hostApiConfig:r,hostContext:s={},callbacks:o={},queryClient:l}){const c=u.useMemo(()=>new Rn({defaultOptions:{queries:{retry:1,staleTime:3e5}}}),[]),x=l||c,h=!!l;u.useEffect(()=>{console.log(`[BobWidget] v${lr} initialized`),console.log(`[BobWidget] QueryClient: ${h?"external (shared)":"internal"}`)},[h]);const w=u.useMemo(()=>Ys.createClient(e.supabaseUrl,e.supabaseKey),[e.supabaseUrl,e.supabaseKey]),[d,g]=u.useState(s);u.useEffect(()=>{g(s)},[s]);const m=u.useCallback(P=>{g(E=>({...E,...P}))},[]),S=u.useMemo(()=>({bobSupabase:w,bobConfig:e,hostApiConfig:r,hostContext:d,callbacks:o,updateHostContext:m}),[w,e,r,d,o,m]);return n.jsx(Tn,{client:x,children:n.jsx(Is.Provider,{value:S,children:t})})}function at(){const t=u.useContext(Is);if(!t)throw new Error("useBobContext must be used within a BobProvider");return t}function Ur(){const{bobSupabase:t}=at();return t}function Ln(){const{hostContext:t}=at();return t}function Un(){const{hostApiConfig:t}=at();return t}function Wn(){const{callbacks:t}=at();return t}const os=8e3,Ns=({onStart:t,onEnd:e,onFailed:r}={})=>{const{bobConfig:s}=at(),[o,l]=u.useState(!1),c=u.useRef(null),x=u.useRef(null),h=u.useRef(!1),w=u.useRef(t),d=u.useRef(e),g=u.useRef(r);u.useEffect(()=>{w.current=t,d.current=e,g.current=r},[t,e,r]);const m=u.useCallback(()=>{x.current&&(clearTimeout(x.current),x.current=null)},[]),S=u.useCallback(()=>{var f;h.current||(h.current=!0,console.log("[BobWidget TTS] Fallback: triggering onStart without audio"),(f=w.current)==null||f.call(w))},[]),P=u.useCallback(async f=>{var j,b,p;if(f.trim()){h.current=!1,m(),c.current&&(c.current.pause(),c.current=null),x.current=setTimeout(()=>{var C,O;console.warn("[BobWidget TTS] Timeout after 5s - triggering fallback callbacks"),S(),l(!1),(C=d.current)==null||C.call(d),(O=g.current)==null||O.call(g),c.current=null},os);try{const C=new AbortController,O=setTimeout(()=>C.abort(),os-1e3),N=await fetch(`${s.supabaseUrl}/functions/v1/bob-tts`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s.supabaseKey}`},body:JSON.stringify({text:f}),signal:C.signal});if(clearTimeout(O),!N.ok){const F=await N.json().catch(()=>({}));throw console.error("[BobWidget TTS] Request failed:",F),new Error("TTS request failed")}const{audioContent:B}=await N.json(),v=new Audio(`data:audio/mp3;base64,${B}`);c.current=v,v.onplay=()=>{var F;m(),h.current||(h.current=!0,l(!0),console.log("[BobWidget TTS] Audio playing, triggering onStart"),(F=w.current)==null||F.call(w))},v.onended=()=>{var F;m(),l(!1),(F=d.current)==null||F.call(d),c.current=null},v.onerror=F=>{var K,T;m(),console.warn("[BobWidget TTS] Audio playback error:",F),S(),l(!1),(K=d.current)==null||K.call(d),(T=g.current)==null||T.call(g),c.current=null};try{await v.play()}catch(F){console.warn("[BobWidget TTS] Audio play() failed (autoplay policy), will retry on user interaction:",F),m(),S(),l(!1),(j=d.current)==null||j.call(d)}}catch(C){m(),console.error("[BobWidget TTS] Speech synthesis error:",C),S(),l(!1),(b=d.current)==null||b.call(d),(p=g.current)==null||p.call(g)}}},[s.supabaseUrl,s.supabaseKey,m,S]),E=u.useCallback(()=>{m(),c.current&&(c.current.pause(),c.current=null),l(!1)},[m]),R=u.useCallback(()=>{var f;(f=c.current)==null||f.pause()},[]),k=u.useCallback(()=>{var f;(f=c.current)==null||f.play()},[]);return u.useEffect(()=>()=>{m(),c.current&&(c.current.pause(),c.current=null)},[m]),{speak:P,stop:E,pause:R,resume:k,isSpeaking:o,isSupported:!0}},qn=["what version","which version","software version","bob version","your version","current version","running version","version number","what ver","which ver"],ls=["recommend","suggest","need","part","filter","brake","rotor","oil","price","$","stock","available","pads","disc","spark plug","battery","clutch","alternator","starter","muffler","exhaust","service pack","add-on","tyre shine","windscreen wash"],Qn=["WIPER BLADE FRONT","WIPER BLADE REAR","WIPER BLADE SET","BRAKE PAD KIT","BRAKE PAD KIT FRONT","BRAKE PAD KIT REAR","BRAKE ROTOR","BRAKE ROTOR FRONT","BRAKE ROTOR REAR","BRAKE DISC","AIR FILTER","OIL FILTER","CABIN FILTER","FUEL FILTER","SPARK PLUG SET","SPARK PLUG","BALL JOINT","TIE ROD END","CONTROL ARM","WHEEL BEARING","CV JOINT","DRIVE SHAFT","TIMING BELT KIT","SERPENTINE BELT","DRIVE BELT","SHOCK ABSORBER","STRUT","COIL SPRING","CLUTCH KIT","CLUTCH PLATE","ALTERNATOR","STARTER MOTOR","WATER PUMP","THERMOSTAT","RADIATOR","RADIATOR HOSE","EXHAUST","MUFFLER","CATALYTIC CONVERTER","brake pads","brake rotors","brake discs","brakes","air filter","oil filter","cabin filter","fuel filter","spark plugs","spark plug","wiper","wipers","battery","batteries","clutch","clutch kit","alternator","starter motor","muffler","exhaust","cv joint","axle","timing belt","serpentine belt","shock absorber","struts","suspension"],Fs=({setAnimationState:t,manualMode:e=!1,talkingState:r="talk",thinkingState:s="research",completeState:o="complete",idleState:l="idle",listenState:c="talk_pause",onStreamStart:x,onStreamComplete:h,onShowingProduct:w,onResearchStart:d,onReadyToSpeak:g,onHighlightPart:m,onHighlightProduct:S,onNoPartsFound:P,onAutoFetchComplete:E})=>{var ur,dr,lt,Ke;const{bobConfig:R,hostApiConfig:k,hostContext:f,callbacks:j}=at(),[b,p]=u.useState([]),[C,O]=u.useState(""),[N,B]=u.useState(!1),[v,F]=u.useState(!1),[K,T]=u.useState(null),L=u.useRef(null),Y=u.useRef(!1),J=u.useRef(!1),X=u.useRef(""),oe=u.useRef(!1),ce=u.useRef(null),xe=()=>{ce.current&&(clearTimeout(ce.current),ce.current=null)},{speak:D,stop:H,isSpeaking:Re}=Ns({onStart:()=>{xe(),oe.current=!0,console.log("[BobWidget] Speech started - revealing products"),g==null||g(),e||fe(r)},onEnd:()=>{xe();const W=ls.some(se=>X.current.toLowerCase().includes(se.toLowerCase()));e||(W&&w?w():h?h():(fe(o),setTimeout(()=>fe(c),3e3)))},onFailed:()=>{console.warn("[BobWidget] Speech synthesis failed - fallback triggered")}});u.useEffect(()=>{var W;(W=L.current)==null||W.scrollIntoView({behavior:"smooth"})},[b]),u.useEffect(()=>{var se,ne;const W=(se=f.vehicle)==null?void 0:se.selectedVehicle;W&&!K&&(console.log("[BobWidget] Setting vehicle from host context:",W),T(W),(ne=j.onVehicleIdentified)==null||ne.call(j,W))},[(ur=f.vehicle)==null?void 0:ur.selectedVehicle]),u.useEffect(()=>{var W;if(b.length===0&&!J.current){J.current=!0;const se=(W=f.vehicle)==null?void 0:W.selectedVehicle;let ne;se?ne=`G'day! Saw you've got the ${`${se.year} ${se.make} ${se.model}`} - choice wagon! What can I help you find for it today?`:ne="G'day! Bob from CARFIX here. How can I help ya today?",p([{role:"assistant",content:ne}]),v||setTimeout(()=>{console.log("[BobWidget] Speaking initial greeting"),D(ne)},800)}},[(dr=f.vehicle)==null?void 0:dr.selectedVehicle,b.length,v,D]),u.useEffect(()=>{var ut,dt;const W=(ut=f.vehicle)==null?void 0:ut.selectedVehicle;if(!W||Y.current)return;const se=W.vehicle_id??W.id,ne=Number.parseInt(String(se),10);if(!Number.isFinite(ne)){console.warn("[BobWidget] Vehicle has invalid vehicle_id, cannot auto-fetch:",W);return}Y.current=!0;const pe={...W,vehicle_id:String(ne)},Ve=(dt=f.user)==null?void 0:dt.email;(async()=>{var ze,He;const ht=`${R.supabaseUrl}/functions/v1/bob-chat`;try{const Te=await fetch(ht,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${R.supabaseKey}`},body:JSON.stringify({messages:[],vehicleContext:pe,customerEmail:Ve,autoFetchParts:!0,hostConfig:k,hostContext:f})});if(!Te.ok||!Te.body){console.error("[BobWidget] Auto-fetch failed:",Te.status);return}const ft=Te.body.getReader(),pt=new TextDecoder;let Me="";for(;;){const{done:ke,value:We}=await ft.read();if(ke)break;Me+=pt.decode(We,{stream:!0});let bt;for(;(bt=Me.indexOf(`
31
- `))!==-1;){let _e=Me.slice(0,bt);if(Me=Me.slice(bt+1),_e.endsWith("\r")&&(_e=_e.slice(0,-1)),_e.startsWith(":")||_e.trim()===""||!_e.startsWith("data: "))continue;const ve=_e.slice(6).trim();if(ve==="[DONE]")break;try{const Oe=JSON.parse(ve);Oe.type==="service_packages_found"&&Oe.packages&&((ze=j.onServicePackagesFound)==null||ze.call(j,Oe.packages)),Oe.type==="parts_found"&&Oe.parts&&((He=j.onPartsFound)==null||He.call(j,Oe.parts))}catch{}}}E==null||E()}catch(Te){console.error("[BobWidget] Auto-fetch error:",Te)}})()},[(lt=f.vehicle)==null?void 0:lt.selectedVehicle,(Ke=f.user)==null?void 0:Ke.email]);const fe=W=>{try{t(W)}catch{console.warn(`[BobWidget] State "${W}" not available`)}},ee=async W=>{var pe,Ve,ct,ut,dt,ht,ze,He,Te,ft,pt,Me;const se=`${R.supabaseUrl}/functions/v1/bob-chat`,ne=(pe=f.user)==null?void 0:pe.email;try{const ke={messages:[...b,W],hostConfig:k,hostContext:f};K&&(ke.vehicleContext=K),ne&&(ke.customerEmail=ne);const We=await fetch(se,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${R.supabaseKey}`},body:JSON.stringify(ke)});if(!We.ok){if(We.status===429){(Ve=j.onError)==null||Ve.call(j,new Error("Rate limit exceeded"));return}if(We.status===402){(ct=j.onError)==null||ct.call(j,new Error("Payment required"));return}throw new Error("Failed to start stream")}if(!We.body)throw new Error("No response body");const bt=We.body.getReader(),_e=new TextDecoder;let ve="",Oe=!1,Be="";for(;!Oe;){const{done:we,value:Ye}=await bt.read();if(we)break;ve+=_e.decode(Ye,{stream:!0});let Ht;for(;(Ht=ve.indexOf(`
32
- `))!==-1;){let Ie=ve.slice(0,Ht);if(ve=ve.slice(Ht+1),Ie.endsWith("\r")&&(Ie=Ie.slice(0,-1)),Ie.startsWith(":")||Ie.trim()===""||!Ie.startsWith("data: "))continue;const hr=Ie.slice(6).trim();if(hr==="[DONE]"){Oe=!0;break}try{const ie=JSON.parse(hr);if(ie.type==="vehicle_identified"&&ie.vehicle){T(ie.vehicle),(ut=j.onVehicleIdentified)==null||ut.call(j,ie.vehicle);continue}if(ie.type==="service_packages_found"&&ie.packages){(dt=j.onServicePackagesFound)==null||dt.call(j,ie.packages);continue}if(ie.type==="parts_found"&&ie.parts){(ht=j.onPartsFound)==null||ht.call(j,ie.parts);continue}if(ie.type==="no_parts_found"){P==null||P();continue}if(ie.type==="cart_updated"&&ie.items){(ze=j.onCartUpdated)==null||ze.call(j,ie.items);continue}const Gt=(ft=(Te=(He=ie.choices)==null?void 0:He[0])==null?void 0:Te.delta)==null?void 0:ft.content;if(Gt){Be+=Gt;const Yt=Be.replace(/\[VEHICLE_CONFIRMED:\{[\s\S]*?\}\]/g,"");p(mt=>{const Nt=mt[mt.length-1];return(Nt==null?void 0:Nt.role)==="assistant"?mt.map((Jt,xr)=>xr===mt.length-1?{...Jt,content:Yt}:Jt):[...mt,{role:"assistant",content:Yt}]}),(pt=j.onBobMessage)==null||pt.call(j,Yt)}}catch{ve=Ie+`
33
- `+ve;break}}}X.current=Be.replace(/\[VEHICLE_CONFIRMED:\{[\s\S]*?\}\]/g,"");const zt=ls.some(we=>Be.toLowerCase().includes(we.toLowerCase())),Ge=Be.toLowerCase();for(const we of Qn)if(Ge.includes(we.toLowerCase())){const Ye=we.replace(/s\s*$/i,"").toUpperCase();m==null||m(Ye);break}const Pt=Be.match(/(?:go with|recommend|suggest|grab|try)\s+(?:the\s+)?(\w+)\s+(?:at|for)\s+\$(\d+(?:\.\d{2})?)/i);if(Pt){const[,we,Ye]=Pt;S==null||S({brand:we,price:parseFloat(Ye)})}!v&&X.current.trim()?(oe.current=!1,xe(),D(X.current),ce.current=setTimeout(()=>{oe.current||(console.warn("[BobWidget] Speech fallback after 2s"),g==null||g(),e||(zt&&w?w():h?h():(fe(o),setTimeout(()=>fe(c),3e3))))},2e3)):(g==null||g(),e||(zt&&w?w():h?h():(fe(o),setTimeout(()=>fe(c),3e3))))}catch(ke){console.error("[BobWidget] Chat error:",ke),(Me=j.onError)==null||Me.call(j,ke instanceof Error?ke:new Error("Unknown error")),e||fe(l)}},Fe=async()=>{if(!C.trim()||N)return;H();const W={role:"user",content:C};p(pe=>[...pe,W]),O("");const se=C.toLowerCase();if(qn.some(pe=>se.includes(pe))){const pe=`G'day mate! I'm running Bob v${lr} - she's running sweet as! Anything else I can help ya with?`;p(Ve=>[...Ve,{role:"assistant",content:pe}]),v||D(pe);return}B(!0),d==null||d(),e||fe(s),await ee(W),B(!1)};return{messages:b,input:C,setInput:O,isLoading:N,handleSend:Fe,handleKeyPress:W=>{W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),Fe())},handleInputFocus:()=>{},handleInputBlur:()=>{},chatEndRef:L,clearMessages:()=>{p([{role:"assistant",content:"G'day! Bob from CARFIX here. How can I help ya today?"}])},isMuted:v,toggleMute:()=>{F(W=>!W),v||H()},isSpeaking:Re,identifiedVehicle:K,clearVehicle:()=>{T(null)}}},Ms=t=>{const e=ks(),r=Ur();return u.useEffect(()=>{const s=r.channel("animation-states-changes").on("postgres_changes",{event:"*",schema:"public",table:"animation_states"},()=>{e.invalidateQueries({queryKey:["bob-animation-data"]})}).subscribe(),o=r.channel("bob-animations-changes").on("postgres_changes",{event:"*",schema:"public",table:"bob_animations"},()=>{e.invalidateQueries({queryKey:["bob-animation-data"]})}).subscribe();return()=>{r.removeChannel(s),r.removeChannel(o)}},[e,r]),Os({queryKey:["bob-animation-data",t],queryFn:async()=>{var R;const{data:s,error:o}=await r.from("bob_looks").select("*").order("display_order");if(o)throw o;const l=(s||[]).find(k=>k.is_active),c=t||(l==null?void 0:l.id)||s&&((R=s[0])==null?void 0:R.id)||null;if(!c)return{states:[],configs:[],uploadedImages:[],looks:s||[],activeLookId:null};const{data:x,error:h}=await r.from("animation_states").select("*").eq("is_active",!0).eq("look_id",c).order("display_order");if(h)throw h;const{data:w,error:d}=await r.from("bob_animations").select("*").eq("is_active",!0).eq("look_id",c).order("animation_state").order("sequence_order");if(d)throw d;const g=new Set((x||[]).map(k=>k.state_key)),m=(w||[]).filter(k=>g.has(k.animation_state)),{data:S,error:P}=await r.storage.from("bob-images").list();if(P)throw P;const E=(S||[]).map(k=>{const{data:f}=r.storage.from("bob-images").getPublicUrl(k.name);return f.publicUrl});return m.forEach(k=>{const f=new Image;f.src=k.image_url}),{states:x||[],configs:m,uploadedImages:E,looks:s||[],activeLookId:c}},staleTime:30*1e3,gcTime:5*60*1e3})},Bs=()=>{const[t,e]=u.useState(""),[r,s]=u.useState(0),[o,l]=u.useState(400),[c,x]=u.useState(!1),h=u.useRef(),{data:w,isLoading:d}=Ms(),g=u.useRef({}),{imageUrlsMap:m,alternateImages:S,offsetsMap:P,scalesMap:E,availableStates:R}=u.useMemo(()=>{if(!w)return{imageUrlsMap:{},alternateImages:{},offsetsMap:{},scalesMap:{},availableStates:[]};const b={},p={},C={},O={},N=w.states.map(B=>B.state_key);return N.forEach(B=>{const v=w.configs.filter(L=>L.animation_state===B),F=v.map(L=>L.image_url),K=v.map(L=>L.vertical_offset||0),T=v.map(L=>L.scale||100);if(F.length>0){const L=w.states.find(Y=>Y.state_key===B);b[B]={url:F[0],animation_speed:(L==null?void 0:L.animation_speed)||400,pause_duration:(L==null?void 0:L.pause_duration)||0,loop_count:(L==null?void 0:L.loop_count)||0},p[B]=F,C[B]=K,O[B]=T}}),{imageUrlsMap:b,alternateImages:p,offsetsMap:C,scalesMap:O,availableStates:N}},[w]);return u.useEffect(()=>{g.current=m},[m]),u.useEffect(()=>{R.length>0&&!t&&e(R[0])},[R,t]),u.useEffect(()=>{const b=S[t];if(h.current&&clearInterval(h.current),b&&b.length>1){s(0);const p=g.current[t],C=(p==null?void 0:p.animation_speed)||o||400,O=(p==null?void 0:p.loop_count)||0,N=(p==null?void 0:p.pause_duration)||0;let B=0,v=!1;const F=()=>{h.current=setInterval(()=>{v||s(K=>{const T=(K+1)%b.length;return T===0&&(B++,O>0&&B>=O)?(clearInterval(h.current),N>0&&(v=!0,setTimeout(()=>{B=0,v=!1,F()},N)),K):T})},C)};F()}else s(0);return()=>{h.current&&clearInterval(h.current)}},[t,S]),{animationState:t,setAnimationState:e,getCurrentImage:()=>{const b=S[t];if(!b||b.length===0){const p=R.find(C=>{var O;return((O=S[C])==null?void 0:O.length)>0});return p?S[p][0]:""}return b[r]||b[0]},getCurrentOffset:()=>{const b=P[t];if(!b||b.length===0){const p=R.find(C=>{var O;return((O=P[C])==null?void 0:O.length)>0});return p?P[p][0]:0}return b[r]||b[0]},getCurrentScale:()=>{const b=E[t];if(!b||b.length===0){const p=R.find(C=>{var O;return((O=E[C])==null?void 0:O.length)>0});return p?E[p][0]:100}return b[r]||b[0]},imageUrls:m,availableStates:R,setTalkSpeed:l,manualMode:c,setManualMode:x,isLoading:d}},As=()=>{const t=Ur(),{data:e=[],isLoading:r}=Os({queryKey:["bob-backdrops"],queryFn:async()=>{const{data:o,error:l}=await t.from("bob_backdrops").select("*").order("display_order",{ascending:!0});if(l)throw l;return o},staleTime:5*60*1e3,gcTime:10*60*1e3}),s=e.find(o=>o.is_active);return{backdrops:e,activeBackdrop:s,isLoading:r}},Ds=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:s,counterHeightPercent:o=12,className:l="",verticalOffset:c=0,scale:x=100})=>{const h=c+o,w=55*(x/100);return n.jsx("div",{className:`flex flex-col items-center justify-center gap-6 w-full ${l}`,children:n.jsxs("div",{className:"relative w-full max-w-[600px] mx-auto aspect-[16/10] overflow-hidden",children:[r&&n.jsx("img",{src:r,alt:"Backdrop",className:"absolute inset-0 z-0 w-full h-full object-cover object-bottom"}),n.jsx("img",{src:t,alt:`Bob ${e}`,className:"absolute z-10 h-auto object-contain left-1/2 -translate-x-1/2",style:{bottom:`${h}%`,width:`${w}%`,maxWidth:`${220*(x/100)}px`,transformOrigin:"center bottom"}}),s&&n.jsx("img",{src:s,alt:"Counter",className:"absolute z-20 bottom-0 left-0 w-full object-cover object-bottom",style:{height:`${o}%`}})]})})},Ls=({messages:t,input:e,setInput:r,isLoading:s,onSend:o,onKeyPress:l,onInputFocus:c,onInputBlur:x,chatEndRef:h,isMuted:w=!1,onToggleMute:d,isSpeaking:g=!1,className:m=""})=>n.jsx("div",{className:m,style:{width:"100%",maxWidth:"72rem",margin:"0 auto",padding:"0 16px 32px 16px"},children:n.jsxs("div",{style:{backgroundColor:"white",border:"1px solid #e5e7eb",borderRadius:"8px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",overflow:"hidden"},children:[n.jsx("div",{style:{padding:"16px",borderBottom:"1px solid #e5e7eb",backgroundColor:"#f9fafb"},children:n.jsxs("div",{style:{display:"flex",gap:"8px"},children:[n.jsx("input",{value:e,onChange:S=>r(S.target.value),onKeyPress:l,onFocus:c,onBlur:x,placeholder:"Ask Bob about car parts...",disabled:s,style:{flex:1,padding:"8px 16px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",color:"#111827",fontSize:"16px",outline:"none"}}),d&&n.jsx("button",{onClick:d,style:{flexShrink:0,padding:"8px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",cursor:"pointer",minHeight:"unset",minWidth:"unset"},title:w?"Unmute Bob's voice":"Mute Bob's voice",children:w?"🔇":"🔊"}),n.jsx("button",{onClick:o,disabled:s||!e.trim(),style:{flexShrink:0,padding:"8px 16px",backgroundColor:s||!e.trim()?"#93c5fd":"#2563eb",color:"white",borderRadius:"6px",border:"none",cursor:s||!e.trim()?"not-allowed":"pointer",opacity:s||!e.trim()?.5:1,minHeight:"unset",minWidth:"unset"},children:"Send"})]})}),n.jsxs("div",{style:{overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"12px",height:"400px"},children:[[...t].reverse().map((S,P)=>n.jsx("div",{style:{display:"flex",justifyContent:S.role==="user"?"flex-end":"flex-start"},children:n.jsx("div",{style:{maxWidth:"80%",borderRadius:"8px",padding:"8px 16px",fontSize:"14px",backgroundColor:S.role==="user"?"#2563eb":"#f3f4f6",color:S.role==="user"?"white":"#111827"},children:S.content})},P)),n.jsx("div",{ref:h})]})]})}),Wr=({currentImage:t,animationState:e,counterOverlayUrl:r,counterHeightPercent:s=15,scale:o=100,position:l="center",verticalOffset:c=0})=>{const x=65*o/100,h=320*o/100,w=l==="center"?"5%":"-25%",d=s-2+c;return n.jsxs("div",{className:"absolute inset-0 pointer-events-none overflow-hidden",children:[n.jsx("div",{className:"absolute left-0 z-40",style:{bottom:`${d}%`,maxHeight:`${100-s-5}%`,transform:`translateX(${w})`,width:`${x}%`,maxWidth:`${h}px`,transition:"transform 0.4s ease-out"},children:n.jsx("img",{src:t,alt:`Bob ${e}`,className:"w-full h-auto object-contain",style:{display:"block",maxHeight:"100%"}})}),r&&n.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-50",style:{height:`${s}%`,pointerEvents:"none"},children:n.jsx("img",{src:r,alt:"Shop counter",className:"w-full h-full object-cover object-top"})})]})},cs=(t,e)=>{if(!t||!e)return!1;const r=t.toLowerCase();return e.toLowerCase().replace(/s\b/g,"").split(/\s+/).filter(Boolean).every(o=>r.includes(o))},$n=(t,e)=>{var o;const r=((o=t.brand)==null?void 0:o.toLowerCase())===e.brand.toLowerCase(),s=Math.abs(t.price-e.price)<1;return r&&s},Kn=({product:t,isSpotlighted:e,spotlightedRef:r,onProductClick:s})=>n.jsxs("div",{ref:e?r:void 0,onClick:()=>s==null?void 0:s(t),className:`md:hidden cursor-pointer active:scale-[0.98] transition-all duration-200 bg-white rounded-xl border relative overflow-hidden ${e?"ring-2 ring-blue-500 shadow-lg border-blue-200":"border-gray-100 shadow-md"}`,style:{backgroundColor:"white",borderRadius:"12px",border:e?"1px solid #bfdbfe":"1px solid #f3f4f6",boxShadow:e?"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)":"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},children:[e&&n.jsx(qr,{}),n.jsx("div",{className:"aspect-[16/10] bg-gradient-to-br from-gray-50 to-gray-100 flex items-center justify-center overflow-hidden",children:t.image_url?n.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-2"}):n.jsx(Qr,{size:"sm"})}),n.jsxs("div",{className:"p-2.5",children:[n.jsx("p",{className:"text-sm font-semibold text-gray-900 line-clamp-1 mb-0.5",children:t.name}),t.brand&&n.jsx("p",{className:"text-xs text-gray-500 mb-1.5",children:t.brand}),n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"text-base font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"POA"}),n.jsx("button",{className:"bg-blue-600 text-white text-xs font-semibold px-3 py-1.5 rounded-lg hover:bg-blue-700 active:bg-blue-800 transition-colors",onClick:o=>{o.stopPropagation(),s==null||s(t)},children:"View"})]})]})]}),Vn=({product:t,isSpotlighted:e,spotlightedRef:r,onProductClick:s})=>n.jsxs("div",{ref:e?r:void 0,onClick:()=>s==null?void 0:s(t),className:`hidden md:block lg:hidden cursor-pointer transition-all duration-300 bg-white rounded-2xl border relative overflow-hidden hover:shadow-xl hover:scale-[1.02] hover:-translate-y-1 ${e?"ring-2 ring-blue-500 shadow-xl border-blue-200":"border-gray-100 shadow-lg"}`,children:[e&&n.jsx(qr,{}),n.jsx("div",{className:"aspect-[4/3] bg-gradient-to-br from-gray-50 to-gray-100 flex items-center justify-center overflow-hidden",children:t.image_url?n.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-4"}):n.jsx(Qr,{size:"md"})}),n.jsxs("div",{className:"p-4",children:[n.jsx("p",{className:"text-base font-semibold text-gray-900 line-clamp-2 mb-1",children:t.name}),t.brand&&n.jsxs("p",{className:"text-sm text-gray-600 font-medium mb-2 flex items-center gap-1",children:[n.jsx("span",{className:"w-1.5 h-1.5 bg-blue-500 rounded-full"}),t.brand]}),n.jsx("div",{className:"flex items-center justify-between",children:n.jsx("span",{className:"text-xl font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"POA"})}),n.jsx("button",{className:"mt-3 w-full bg-gradient-to-r from-blue-600 to-blue-500 text-white text-sm font-semibold py-2.5 rounded-xl hover:from-blue-700 hover:to-blue-600 active:from-blue-800 active:to-blue-700 transition-all shadow-md",onClick:o=>{o.stopPropagation(),s==null||s(t)},children:"View Details"})]})]}),zn=({product:t,isSpotlighted:e,spotlightedRef:r,onProductClick:s})=>n.jsxs("div",{ref:e?r:void 0,onClick:()=>s==null?void 0:s(t),className:`hidden lg:flex flex-row cursor-pointer transition-all duration-300 bg-white rounded-2xl border relative overflow-hidden hover:shadow-2xl hover:scale-[1.01] hover:-translate-y-0.5 group ${e?"ring-2 ring-blue-500 shadow-xl border-blue-200":"border-gray-100 shadow-lg"}`,style:{minHeight:"140px"},children:[e&&n.jsx(qr,{variant:"horizontal"}),n.jsx("div",{className:"w-36 shrink-0 bg-gradient-to-br from-gray-50 to-gray-100 flex items-center justify-center overflow-hidden",children:t.image_url?n.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-3 group-hover:scale-105 transition-transform duration-300"}):n.jsx(Qr,{size:"lg"})}),n.jsxs("div",{className:"flex-1 p-4 flex flex-col justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-base font-semibold text-gray-900 line-clamp-2 mb-1 group-hover:text-blue-700 transition-colors",children:t.name}),t.brand&&n.jsx("div",{className:"flex items-center gap-2 mb-2",children:n.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-gray-600 bg-gray-100 px-2 py-0.5 rounded-full",children:[n.jsx("svg",{className:"w-3 h-3 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20",children:n.jsx("path",{fillRule:"evenodd",d:"M6.267 3.455a3.066 3.066 0 001.745-.723 3.066 3.066 0 013.976 0 3.066 3.066 0 001.745.723 3.066 3.066 0 012.812 2.812c.051.643.304 1.254.723 1.745a3.066 3.066 0 010 3.976 3.066 3.066 0 00-.723 1.745 3.066 3.066 0 01-2.812 2.812 3.066 3.066 0 00-1.745.723 3.066 3.066 0 01-3.976 0 3.066 3.066 0 00-1.745-.723 3.066 3.066 0 01-2.812-2.812 3.066 3.066 0 00-.723-1.745 3.066 3.066 0 010-3.976 3.066 3.066 0 00.723-1.745 3.066 3.066 0 012.812-2.812zm7.44 5.252a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),t.brand]})})]}),n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("span",{className:"text-2xl font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"POA"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{className:"px-4 py-2 border border-gray-200 text-gray-700 text-sm font-medium rounded-lg hover:bg-gray-50 hover:border-gray-300 transition-all opacity-0 group-hover:opacity-100",onClick:o=>{o.stopPropagation(),s==null||s(t)},children:"Details"}),n.jsx("button",{className:"px-4 py-2 bg-gradient-to-r from-blue-600 to-blue-500 text-white text-sm font-semibold rounded-lg hover:from-blue-700 hover:to-blue-600 transition-all shadow-md",onClick:o=>{o.stopPropagation(),s==null||s(t)},children:"View"})]})]})]})]}),qr=({variant:t="default"})=>n.jsxs("span",{className:`absolute bg-gradient-to-r from-blue-600 to-blue-500 text-white text-xs px-2.5 py-1 rounded-full z-20 flex items-center gap-1 font-semibold shadow-md ${t==="horizontal"?"top-2 left-2":"top-3 right-3"}`,children:[n.jsx("svg",{className:"h-3 w-3",fill:"currentColor",viewBox:"0 0 20 20",children:n.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})}),"Bob's Pick"]}),Qr=({size:t})=>{const e={sm:"h-8 w-8",md:"h-10 w-10",lg:"h-12 w-12"};return n.jsxs("div",{className:"flex flex-col items-center justify-center text-gray-400",children:[n.jsx("svg",{className:e[t],fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),n.jsx("span",{className:"text-xs font-medium uppercase tracking-wide mt-1",children:"No Image"})]})},$r=({products:t,servicePackages:e,highlightedPartType:r,highlightedProduct:s,onProductClick:o,onPackageSelect:l,isResearching:c,visible:x=!0,counterHeightPercent:h=22,hasVehicle:w=!1})=>{const d=u.useRef(null),g=u.useRef({}),m=u.useRef(null),S=u.useMemo(()=>{const f={};return t.forEach(b=>{const p=b.partslotDescription||"Other Parts";f[p]||(f[p]=[]),f[p].push(b)}),Object.keys(f).sort((b,p)=>b.localeCompare(p)).map(b=>({name:b,products:f[b]}))},[t]);u.useEffect(()=>{var f;if(r){const j=S.find(b=>cs(b.name,r));j&&g.current[j.name]&&((f=g.current[j.name])==null||f.scrollIntoView({behavior:"smooth",block:"start"}))}},[r,S]),u.useEffect(()=>{s&&m.current&&m.current.scrollIntoView({behavior:"smooth",block:"center"})},[s]);const P=t.length>0||e.length>0,E=c,R=P&&!c,k=w?"56px":"8px";return n.jsxs("div",{ref:d,className:`absolute right-2 md:right-3 lg:right-4 w-[52%] md:w-[55%] lg:w-[58%] max-w-[280px] md:max-w-[400px] lg:max-w-[520px] overflow-y-auto overflow-x-hidden z-30 flex flex-col gap-3 md:gap-4 lg:gap-5 pb-4 transition-all duration-300 ease-out ${x?"opacity-100 translate-x-0":"opacity-0 translate-x-8 pointer-events-none"}`,style:{top:k,bottom:"calc(70px + env(safe-area-inset-bottom, 8px))",paddingTop:"env(safe-area-inset-top, 4px)"},children:[E&&n.jsx("div",{className:"rounded-xl bg-white/90 backdrop-blur-sm p-4 shadow-lg border border-gray-100",children:n.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-600",children:[n.jsx("div",{className:"w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full animate-spin"}),n.jsx("span",{className:"font-medium",children:"Finding parts..."})]})}),R&&e.length>0&&n.jsxs("div",{className:"space-y-2 md:space-y-3",children:[n.jsxs("div",{className:"text-xs font-bold text-blue-700 flex items-center gap-1.5 px-1 uppercase tracking-wide",children:[n.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})}),"Service Packages"]}),e.map(f=>n.jsxs("div",{onClick:()=>l==null?void 0:l(f),className:"cursor-pointer active:scale-[0.98] transition-all bg-white rounded-xl md:rounded-2xl border border-gray-100 p-3 md:p-4 shadow-md hover:shadow-lg md:hover:scale-[1.02]",children:[n.jsx("p",{className:"text-sm md:text-base font-semibold text-gray-900 line-clamp-2 mb-1",children:f.title}),n.jsxs("p",{className:"text-lg md:text-xl font-bold text-blue-600",children:["From $",f.from_price.toFixed(0)]})]},f.id))]}),R&&S.map(({name:f,products:j})=>{const b=r&&cs(f,r);return n.jsxs("section",{ref:p=>{g.current[f]=p},className:`rounded-xl md:rounded-2xl transition-all ${b?"ring-2 ring-blue-500 bg-blue-50/80 p-2 md:p-3 shadow-lg":""}`,children:[n.jsxs("h3",{className:"text-xs md:text-sm font-bold mb-2 md:mb-3 flex items-center gap-1.5 px-1 text-gray-800 uppercase tracking-wide",children:[n.jsx("svg",{className:"h-3.5 w-3.5 md:h-4 md:w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})}),n.jsx("span",{className:"truncate",children:f}),n.jsxs("span",{className:"text-[10px] md:text-xs text-gray-500 font-medium",children:["(",j.length,")"]})]}),n.jsx("div",{className:"flex flex-col gap-3 md:grid md:grid-cols-2 md:gap-4 lg:flex lg:flex-col lg:gap-4",children:j.map((p,C)=>{const O=s&&$n(p,s);return n.jsxs(u.Fragment,{children:[n.jsx(Kn,{product:p,isSpotlighted:O,spotlightedRef:m,onProductClick:o}),n.jsx(Vn,{product:p,isSpotlighted:O,spotlightedRef:m,onProductClick:o}),n.jsx(zn,{product:p,isSpotlighted:O,spotlightedRef:m,onProductClick:o})]},`${p.id}-${C}`)})})]},f)})]})},Kr=({onTranscript:t,onSpeechEnd:e,language:r="en-NZ",mode:s="toggle"}={})=>{const[o,l]=u.useState(!1),[c,x]=u.useState(""),[h,w]=u.useState(""),[d,g]=u.useState(null),[m,S]=u.useState(!1),P=u.useRef(null),E=u.useRef(""),R=u.useRef(t),k=u.useRef(e);u.useEffect(()=>{R.current=t,k.current=e},[t,e]),u.useEffect(()=>{const p=window.SpeechRecognition||window.webkitSpeechRecognition;if(p){S(!0);const C=new p;C.continuous=s==="ptt",C.interimResults=!0,C.lang=r,C.maxAlternatives=1,C.onstart=()=>{l(!0),g(null)},C.onresult=O=>{let N="",B="";for(let v=O.resultIndex;v<O.results.length;v++){const F=O.results[v][0].transcript;O.results[v].isFinal?B+=F:N+=F}B&&(E.current=B,x(B),R.current&&R.current(B)),w(N)},C.onerror=O=>{switch(l(!1),O.error){case"no-speech":g("No speech detected. Please try again.");break;case"audio-capture":g("No microphone found. Please check your device.");break;case"not-allowed":g("Microphone permission denied. Please allow access.");break;default:g("Speech recognition error. Please try again.")}},C.onend=()=>{l(!1),w(""),E.current&&k.current&&k.current(E.current),E.current=""},P.current=C}return()=>{P.current&&P.current.stop()}},[r,s]);const f=()=>{P.current&&!o&&(x(""),w(""),g(null),P.current.start())},j=()=>{P.current&&o&&P.current.stop()};return{isListening:o,transcript:c,interimTranscript:h,error:d,isSupported:m,startListening:f,stopListening:j,toggleListening:()=>{o?j():f()}}},Us=({messages:t,input:e,setInput:r,isLoading:s,onSend:o,onKeyPress:l,onInputFocus:c,onInputBlur:x,chatEndRef:h,isMuted:w=!1,onToggleMute:d,isSpeaking:g=!1})=>{const[m,S]=u.useState(!1),P=u.useRef(null),E=u.useRef(!1),{isListening:R,interimTranscript:k,error:f,isSupported:j,startListening:b,stopListening:p}=Kr({onTranscript:v=>r(v),language:"en-NZ",mode:"ptt"});u.useEffect(()=>{k&&r(k)},[k,r]);const C=u.useCallback(()=>{s||E.current||(E.current=!0,navigator.vibrate&&navigator.vibrate(10),b())},[s,b]),O=u.useCallback(()=>{E.current&&(E.current=!1,navigator.vibrate&&navigator.vibrate(10),p(),setTimeout(()=>{o()},150))},[p,o]),N=[...t].reverse().find(v=>v.role==="assistant"),B=N!=null&&N.content?N.content.length>50?N.content.slice(0,50)+"...":N.content:"Ask Bob about car parts...";return n.jsxs("div",{ref:P,style:{position:"fixed",bottom:0,left:0,right:0,backgroundColor:"rgba(255, 255, 255, 0.95)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",borderTop:"1px solid #e5e7eb",transition:"all 0.3s ease-out",boxShadow:"0 -4px 20px rgba(0, 0, 0, 0.15)",height:m?"55vh":"auto",zIndex:60,paddingBottom:"env(safe-area-inset-bottom, 8px)"},children:[n.jsx("button",{onClick:()=>S(!m),style:{position:"absolute",top:"-20px",left:"50%",transform:"translateX(-50%)",backgroundColor:"white",border:"1px solid #e5e7eb",borderRadius:"9999px",padding:"6px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",zIndex:40,cursor:"pointer",minHeight:"unset",minWidth:"unset"},"aria-label":m?"Collapse chat":"Expand chat",children:m?n.jsx("svg",{style:{height:"16px",width:"16px",color:"#6b7280"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}):n.jsx("svg",{style:{height:"16px",width:"16px",color:"#6b7280"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),!m&&n.jsx("div",{onClick:()=>S(!0),style:{padding:"8px 12px 2px 12px",cursor:"pointer"},children:n.jsx("p",{style:{fontSize:"12px",color:"#6b7280",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B})}),m&&n.jsxs("div",{style:{height:"calc(100% - 100px)",overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"8px"},children:[[...t].reverse().map((v,F)=>n.jsx("div",{style:{display:"flex",justifyContent:v.role==="user"?"flex-end":"flex-start"},children:n.jsx("div",{style:{maxWidth:"85%",borderRadius:"8px",padding:"8px 12px",fontSize:"14px",backgroundColor:v.role==="user"?"#2563eb":"#f3f4f6",color:v.role==="user"?"white":"#111827"},children:v.content})},F)),n.jsx("div",{ref:h})]}),n.jsxs("div",{style:{padding:m?"8px 8px 6px 8px":"2px 8px 6px 8px",borderTop:m?"1px solid #e5e7eb":"none"},children:[R&&n.jsxs("div",{style:{marginBottom:"8px",fontSize:"12px",color:"#6b7280",display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",backgroundColor:"#ef4444",borderRadius:"50%",animation:"pulse 2s infinite"}}),"Listening..."]}),f&&n.jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"#ef4444"},children:f}),n.jsxs("div",{style:{display:"flex",gap:"6px",alignItems:"center"},children:[d&&m&&n.jsx("button",{onClick:d,style:{flexShrink:0,height:"36px",width:"36px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"6px",backgroundColor:"transparent",color:g?"#2563eb":"#4b5563",cursor:"pointer",border:"none",minHeight:"unset",minWidth:"unset"},title:w?"Unmute":"Mute",children:w?n.jsxs("svg",{style:{height:"16px",width:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"}),n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]}):n.jsx("svg",{style:{height:"16px",width:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"})})}),n.jsx("input",{type:"text",value:e,onChange:v=>r(v.target.value),onKeyPress:l,onFocus:c,onBlur:x,placeholder:"Message Bob...",disabled:s,style:{flex:1,height:"40px",fontSize:"16px",padding:"0 12px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",color:"#111827",outline:"none",opacity:s?.5:1}}),j&&n.jsx("button",{onTouchStart:C,onTouchEnd:O,onTouchCancel:O,onMouseDown:C,onMouseUp:O,onMouseLeave:O,disabled:s,style:{flexShrink:0,height:"48px",width:"48px",minHeight:"unset",minWidth:"unset",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",touchAction:"none",backgroundColor:R?"#ef4444":"#2563eb",color:"white",border:"none",cursor:"pointer",opacity:s?.5:1,transform:R?"scale(1.1)":"scale(1)",boxShadow:R?"0 0 0 2px rgba(239, 68, 68, 0.3)":"none",transition:"transform 0.15s ease, background-color 0.15s ease"},title:"Hold to talk",children:n.jsx("svg",{style:{height:"20px",width:"20px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})})]})]})]})},Ws=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:s,counterHeightPercent:o=22,messages:l,input:c,setInput:x,isLoading:h,onSend:w,onKeyPress:d,onInputFocus:g,onInputBlur:m,chatEndRef:S,isMuted:P,onToggleMute:E,isSpeaking:R,products:k,servicePackages:f,highlightedPartType:j,highlightedProduct:b,onProductClick:p,onPackageSelect:C,isResearching:O,vehicle:N,onChangeVehicle:B,bobOffset:v=0,bobScale:F=100})=>{const K=typeof window<"u"&&window.self!==window.top,[T,L]=u.useState("center"),[Y,J]=u.useState("hidden"),X=k.length>0||f.length>0,xe=(T==="center"&&!X?200:130)*F/100;u.useEffect(()=>{if(O&&Y!=="loading"&&Y!=="visible")J("loading"),T==="center"&&L("left");else if(X&&Y!=="visible")if(T==="center"){L("left"),J("transitioning");const H=setTimeout(()=>{J("visible")},400);return()=>clearTimeout(H)}else J("visible");else!X&&!O&&Y!=="hidden"&&(J("hidden"),L("center"))},[X,O,Y,T]);const D=Y!=="hidden";return n.jsxs("div",{className:"fixed inset-0 overflow-hidden",style:{height:"100dvh",touchAction:"manipulation"},children:[r&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"absolute inset-0 z-0",style:{backgroundImage:`url(${r})`,backgroundSize:"cover",backgroundPosition:"center bottom",filter:"blur(12px) brightness(0.7)",transform:"scale(1.1)"}}),n.jsx("div",{className:"absolute inset-0 z-[1]",style:{background:"linear-gradient(to bottom, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.6) 100%)"}})]}),n.jsx(Wr,{currentImage:t,animationState:e,counterOverlayUrl:s,counterHeightPercent:o,scale:xe,position:T,verticalOffset:v}),N&&!K&&n.jsx("div",{style:{position:"absolute",top:"8px",left:"8px",right:"8px",zIndex:20},children:n.jsxs("div",{style:{backgroundColor:"rgba(255, 255, 255, 0.9)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",borderRadius:"8px",padding:"8px 12px",paddingTop:"calc(env(safe-area-inset-top, 4px) + 8px)",border:"1px solid #e5e7eb",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("p",{style:{fontSize:"12px",fontWeight:500,color:"#111827",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[N.year," ",N.make," ",N.model]}),N.rego&&n.jsx("p",{style:{fontSize:"10px",color:"#6b7280"},children:N.rego})]}),B&&n.jsx("button",{onClick:B,style:{fontSize:"12px",color:"#2563eb",marginLeft:"8px",flexShrink:0,background:"none",border:"none",cursor:"pointer",minHeight:"unset",minWidth:"unset"},children:"Change"})]})}),n.jsx($r,{products:k,servicePackages:f,highlightedPartType:j,highlightedProduct:b,onProductClick:p,onPackageSelect:C,isResearching:O,visible:D,counterHeightPercent:o,hasVehicle:!!N}),n.jsx(Us,{messages:l,input:c,setInput:x,isLoading:h,onSend:w,onKeyPress:d,onInputFocus:g,onInputBlur:m,chatEndRef:S,isMuted:P,onToggleMute:E,isSpeaking:R})]})},qs=({messages:t,input:e,setInput:r,isLoading:s,onSend:o,onKeyPress:l,onInputFocus:c,onInputBlur:x,chatEndRef:h,isMuted:w=!1,onToggleMute:d,isSpeaking:g=!1})=>{const[m,S]=u.useState(!1),P=u.useRef(null),E=u.useRef(!1),{isListening:R,interimTranscript:k,error:f,isSupported:j,startListening:b,stopListening:p}=Kr({onTranscript:v=>r(v),language:"en-NZ",mode:"ptt"});u.useEffect(()=>{k&&r(k)},[k,r]);const C=u.useCallback(()=>{s||E.current||(E.current=!0,navigator.vibrate&&navigator.vibrate(10),b())},[s,b]),O=u.useCallback(()=>{E.current&&(E.current=!1,navigator.vibrate&&navigator.vibrate(10),p(),setTimeout(()=>{o()},150))},[p,o]),N=[...t].reverse().find(v=>v.role==="assistant"),B=N!=null&&N.content?N.content.length>50?N.content.slice(0,50)+"...":N.content:"Ask Bob about car parts...";return n.jsxs("div",{ref:P,style:{position:"absolute",bottom:0,left:0,right:0,backgroundColor:"rgba(255, 255, 255, 0.95)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",borderTop:"1px solid #e5e7eb",transition:"all 0.3s ease-out",boxShadow:"0 -4px 20px rgba(0, 0, 0, 0.15)",height:m?"55%":"70px",overflow:m?"visible":"hidden",zIndex:60,paddingBottom:"env(safe-area-inset-bottom, 8px)"},children:[n.jsx("button",{onClick:()=>S(!m),style:{position:"absolute",top:"-20px",left:"50%",transform:"translateX(-50%)",backgroundColor:"white",border:"1px solid #e5e7eb",borderRadius:"9999px",padding:"6px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",zIndex:70,cursor:"pointer",minHeight:"unset",minWidth:"unset"},"aria-label":m?"Collapse chat":"Expand chat",children:m?n.jsx("svg",{style:{height:"16px",width:"16px",color:"#6b7280"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}):n.jsx("svg",{style:{height:"16px",width:"16px",color:"#6b7280"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),!m&&n.jsx("div",{onClick:()=>S(!0),style:{padding:"6px 12px 4px 12px",height:"26px",overflow:"hidden",cursor:"pointer"},children:n.jsx("p",{style:{fontSize:"12px",color:"#6b7280",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B})}),m&&n.jsxs("div",{style:{height:"calc(100% - 100px)",overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"8px"},children:[[...t].reverse().map((v,F)=>n.jsx("div",{style:{display:"flex",justifyContent:v.role==="user"?"flex-end":"flex-start"},children:n.jsx("div",{style:{maxWidth:"85%",borderRadius:"8px",padding:"8px 12px",fontSize:"14px",backgroundColor:v.role==="user"?"#2563eb":"#f3f4f6",color:v.role==="user"?"white":"#111827"},children:v.content})},F)),n.jsx("div",{ref:h})]}),n.jsxs("div",{style:{padding:m?"8px 12px 4px 12px":"4px 12px 4px 12px",borderTop:m?"1px solid #e5e7eb":"none"},children:[R&&n.jsxs("div",{style:{marginBottom:"8px",fontSize:"12px",color:"#6b7280",display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",backgroundColor:"#ef4444",borderRadius:"50%",animation:"pulse 2s infinite"}}),"Listening..."]}),f&&n.jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"#ef4444"},children:f}),n.jsxs("div",{style:{display:"flex",gap:"6px",alignItems:"center"},children:[d&&m&&n.jsx("button",{onClick:d,style:{flexShrink:0,height:"36px",width:"36px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"6px",backgroundColor:"transparent",color:g?"#2563eb":"#4b5563",cursor:"pointer",border:"none",minHeight:"unset",minWidth:"unset"},title:w?"Unmute":"Mute",children:w?n.jsxs("svg",{style:{height:"16px",width:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"}),n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]}):n.jsx("svg",{style:{height:"16px",width:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"})})}),n.jsx("input",{type:"text",value:e,onChange:v=>r(v.target.value),onKeyPress:l,onFocus:c,onBlur:x,placeholder:"Message Bob...",disabled:s,style:{flex:1,height:"40px",fontSize:"16px",padding:"0 12px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",color:"#111827",outline:"none",opacity:s?.5:1}}),j&&n.jsx("button",{onTouchStart:C,onTouchEnd:O,onTouchCancel:O,onMouseDown:C,onMouseUp:O,onMouseLeave:O,disabled:s,style:{flexShrink:0,height:"48px",width:"48px",minHeight:"unset",minWidth:"unset",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",touchAction:"none",backgroundColor:R?"#ef4444":"#2563eb",color:"white",border:"none",cursor:"pointer",opacity:s?.5:1,transform:R?"scale(1.1)":"scale(1)",boxShadow:R?"0 0 0 2px rgba(239, 68, 68, 0.3)":"none",transition:"transform 0.15s ease, background-color 0.15s ease"},title:"Hold to talk",children:n.jsx("svg",{style:{height:"20px",width:"20px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})})]})]})]})},Hn=({product:t,onBack:e,onAddToCart:r,onNavigateToProductPage:s})=>{const o=t.product_url||s;return n.jsxs("div",{className:"absolute inset-0 z-35 flex flex-col bg-white/95 backdrop-blur-md overflow-hidden",children:[n.jsx("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-gray-200 bg-white/80 backdrop-blur-sm",children:n.jsxs("button",{onClick:e,className:"flex items-center gap-1.5 text-blue-600 font-medium text-sm hover:text-blue-700 active:scale-95 transition-all",children:[n.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back to Products"]})}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[n.jsx("div",{className:"aspect-square bg-gradient-to-br from-gray-50 to-gray-100 flex items-center justify-center",children:t.image_url?n.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-4"}):n.jsxs("div",{className:"flex flex-col items-center justify-center text-gray-400",children:[n.jsx("svg",{className:"h-16 w-16 mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),n.jsx("span",{className:"text-sm font-medium uppercase tracking-wide",children:"No Image Available"})]})}),n.jsxs("div",{className:"p-4 space-y-4",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-xl font-bold text-gray-900 mb-1",children:t.name}),t.brand&&n.jsx("p",{className:"text-sm text-gray-600 font-medium",children:t.brand})]}),n.jsxs("div",{className:"bg-blue-50 rounded-xl p-4",children:[n.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Price"}),n.jsx("p",{className:"text-2xl font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"Price on Request"}),t.price>0&&n.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Inc. GST"})]}),n.jsxs("div",{className:"space-y-3",children:[t.partslotDescription&&n.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[n.jsx("span",{className:"text-sm text-gray-500",children:"Category"}),n.jsx("span",{className:"text-sm font-medium text-gray-900",children:t.partslotDescription})]}),t.sku&&n.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[n.jsx("span",{className:"text-sm text-gray-500",children:"SKU"}),n.jsx("span",{className:"text-sm font-medium text-gray-900",children:t.sku})]}),t.part_number&&n.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[n.jsx("span",{className:"text-sm text-gray-500",children:"Part Number"}),n.jsx("span",{className:"text-sm font-medium text-gray-900",children:t.part_number})]})]}),o&&n.jsx("a",{href:t.product_url||"#",onClick:l=>{s&&(l.preventDefault(),s(t))},target:t.product_url&&!s?"_blank":void 0,rel:t.product_url&&!s?"noopener noreferrer":void 0,className:"block text-center text-blue-600 text-sm font-medium hover:underline py-2",children:"View Full Details on CARFIX →"})]})]}),n.jsx("div",{className:"p-4 border-t border-gray-200 bg-white/95 backdrop-blur-sm",children:n.jsx("button",{onClick:()=>r==null?void 0:r(t),className:"w-full bg-blue-600 text-white text-base font-semibold py-3 rounded-xl hover:bg-blue-700 active:bg-blue-800 transition-colors shadow-lg",children:"Add to Cart"})})]})},Qs=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:s,counterHeightPercent:o=22,messages:l,input:c,setInput:x,isLoading:h,onSend:w,onKeyPress:d,onInputFocus:g,onInputBlur:m,chatEndRef:S,isMuted:P,onToggleMute:E,isSpeaking:R,products:k,servicePackages:f,highlightedPartType:j,highlightedProduct:b,onProductClick:p,onPackageSelect:C,isResearching:O,onAddToCart:N,onNavigateToProductPage:B,vehicle:v,onChangeVehicle:F,bobOffset:K=0,bobScale:T=100})=>{const[L,Y]=u.useState("center"),[J,X]=u.useState("hidden"),[oe,ce]=u.useState("products"),[xe,D]=u.useState(null),H=k.length>0||f.length>0,ee=(oe==="productDetail"?65:L==="center"&&!H?130:85)*T/100;u.useEffect(()=>{if(O&&J!=="loading"&&J!=="visible")X("loading"),L==="center"&&Y("left");else if(H&&J!=="visible")if(L==="center"){Y("left"),X("transitioning");const ye=setTimeout(()=>{X("visible")},400);return()=>clearTimeout(ye)}else X("visible");else!H&&!O&&J!=="hidden"&&(X("hidden"),Y("center"))},[H,O,J,L]);const Fe=ye=>{if(B){B(ye),p==null||p(ye);return}D(ye),ce("productDetail"),p==null||p(ye)},Ot=()=>{D(null),ce("products")},ot=J!=="hidden"&&oe==="products",It=J!=="hidden";return n.jsxs("div",{className:"absolute inset-0 overflow-hidden",style:{touchAction:"manipulation"},children:[r&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"absolute inset-0 z-0 transition-all duration-500 ease-out",style:{backgroundImage:`url(${r})`,backgroundSize:"cover",backgroundPosition:"center bottom",filter:It?"blur(12px) brightness(0.7)":"blur(0px) brightness(1)",transform:"scale(1.1)"}}),n.jsx("div",{className:"absolute inset-0 z-[1]",style:{background:"linear-gradient(to bottom, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.6) 100%)"}})]}),n.jsx(Wr,{currentImage:t,animationState:e,counterOverlayUrl:s,counterHeightPercent:o,scale:ee,position:L,verticalOffset:K}),v&&oe==="products"&&n.jsx("div",{style:{position:"absolute",top:"8px",left:"8px",right:"8px",zIndex:20},children:n.jsxs("div",{style:{backgroundColor:"rgba(255, 255, 255, 0.9)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",borderRadius:"8px",padding:"8px 12px",border:"1px solid #e5e7eb",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("p",{style:{fontSize:"12px",fontWeight:500,color:"#111827",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[v.year," ",v.make," ",v.model]}),v.rego&&n.jsx("p",{style:{fontSize:"10px",color:"#6b7280"},children:v.rego})]}),F&&n.jsx("button",{onClick:F,style:{fontSize:"12px",color:"#2563eb",marginLeft:"8px",flexShrink:0,background:"none",border:"none",cursor:"pointer",minHeight:"unset",minWidth:"unset"},children:"Change"})]})}),n.jsx($r,{products:k,servicePackages:f,highlightedPartType:j,highlightedProduct:b,onProductClick:Fe,onPackageSelect:C,isResearching:O,visible:ot,counterHeightPercent:o,hasVehicle:!!v}),oe==="productDetail"&&xe&&n.jsx(Hn,{product:xe,onBack:Ot,onAddToCart:N,onNavigateToProductPage:B}),oe==="products"&&n.jsx(qs,{messages:l,input:c,setInput:x,isLoading:h,onSend:w,onKeyPress:d,onInputFocus:g,onInputBlur:m,chatEndRef:S,isMuted:P,onToggleMute:E,isSpeaking:R})]})},$s=({variant:t="inline",initialState:e="idle",showChat:r=!0,className:s="",backdropUrl:o,counterOverlayUrl:l,counterHeightPercent:c,defaultBobImage:x,verticalOffset:h=0,scale:w=100})=>{const{callbacks:d}=at(),{animationState:g,setAnimationState:m,getCurrentImage:S,getCurrentOffset:P,getCurrentScale:E,availableStates:R,isLoading:k}=Bs(),{activeBackdrop:f}=As(),[j,b]=u.useState([]),[p,C]=u.useState([]),[O,N]=u.useState(null),[B,v]=u.useState(null),[F,K]=u.useState(!1),T=Fs({setAnimationState:m,manualMode:!1,onReadyToSpeak:()=>{console.log("[BobWidget] Ready to speak")},onStreamComplete:()=>{m(R.find(D=>D.includes("idle"))||"idle")},onResearchStart:()=>{K(!0)},onHighlightPart:D=>{N(D),setTimeout(()=>N(null),8e3)},onHighlightProduct:D=>{v(D),setTimeout(()=>v(null),8e3)},onAutoFetchComplete:()=>{K(!1)}});u.useEffect(()=>{const D=d.onPartsFound,H=d.onServicePackagesFound;return d.onPartsFound=Re=>{K(!1);const fe=Re.map((ee,Fe)=>({id:ee.SKU||ee.sku||`part-${Fe}`,name:ee["Part Product Type"]||ee.partslot_description||"Unknown Part",brand:ee.Brand||ee.brand,price:ee["Metro Retail Price"]||ee.price||0,sku:ee.SKU||ee.sku,partNumber:ee["Part Number"]||ee.part_number,partslotDescription:ee["Part Product Type"]||ee.partslot_description,image_url:ee.image_url}));b(fe),D==null||D(Re)},d.onServicePackagesFound=Re=>{C(Re),H==null||H(Re)},()=>{d.onPartsFound=D,d.onServicePackagesFound=H}},[d]);const L=o||(f==null?void 0:f.image_url),Y=l||(f==null?void 0:f.counter_overlay_url)||void 0,J=c||(f==null?void 0:f.counter_height_percent)||12,X=S()||x||"",oe=P(),ce=E();if(t==="mobile"||t==="fullscreen")return n.jsx(Ws,{currentImage:X,animationState:g,backdropUrl:L,counterOverlayUrl:Y,counterHeightPercent:J,bobOffset:oe,bobScale:ce,messages:T.messages,input:T.input,setInput:T.setInput,isLoading:T.isLoading,onSend:T.handleSend,onKeyPress:T.handleKeyPress,onInputFocus:T.handleInputFocus,onInputBlur:T.handleInputBlur,chatEndRef:T.chatEndRef,isMuted:T.isMuted,onToggleMute:T.toggleMute,isSpeaking:T.isSpeaking,products:j,servicePackages:p,highlightedPartType:O,highlightedProduct:B,onAddToCart:D=>{var H;return(H=d.onAddToCart)==null?void 0:H.call(d,{product_id:D.id,product_name:D.name,quantity:1,unit_price:D.price,sku:D.sku,brand:D.brand})},onNavigateToProductPage:D=>{var H;return(H=d.onNavigateToProductPage)==null?void 0:H.call(d,D)},onPackageSelect:D=>console.log("[BobWidget] Package selected:",D),isResearching:F,vehicle:T.identifiedVehicle});if(t==="inline"&&r)return n.jsx("div",{className:`relative w-full h-full ${s}`,children:n.jsx(Qs,{currentImage:X,animationState:g,backdropUrl:L,counterOverlayUrl:Y,counterHeightPercent:J,bobOffset:oe,bobScale:ce,messages:T.messages,input:T.input,setInput:T.setInput,isLoading:T.isLoading,onSend:T.handleSend,onKeyPress:T.handleKeyPress,onInputFocus:T.handleInputFocus,onInputBlur:T.handleInputBlur,chatEndRef:T.chatEndRef,isMuted:T.isMuted,onToggleMute:T.toggleMute,isSpeaking:T.isSpeaking,products:j,servicePackages:p,highlightedPartType:O,highlightedProduct:B,onAddToCart:D=>{var H;return(H=d.onAddToCart)==null?void 0:H.call(d,{product_id:D.id,product_name:D.name,quantity:1,unit_price:D.price,sku:D.sku,brand:D.brand})},onNavigateToProductPage:D=>{var H;return(H=d.onNavigateToProductPage)==null?void 0:H.call(d,D)},onPackageSelect:D=>console.log("[BobWidget] Package selected:",D),isResearching:F,vehicle:T.identifiedVehicle})});const xe={inline:"",floating:"fixed bottom-4 right-4 w-96 z-50 shadow-2xl rounded-lg overflow-hidden"};return n.jsxs("div",{className:`${xe[t]||""} ${s}`,children:[X&&n.jsx(Ds,{currentImage:X,animationState:g,backdropUrl:L,counterOverlayUrl:Y,counterHeightPercent:J,verticalOffset:oe,scale:ce}),r&&n.jsx(Ls,{messages:T.messages,input:T.input,setInput:T.setInput,isLoading:T.isLoading,onSend:T.handleSend,onKeyPress:T.handleKeyPress,onInputFocus:T.handleInputFocus,onInputBlur:T.handleInputBlur,chatEndRef:T.chatEndRef,isMuted:T.isMuted,onToggleMute:T.toggleMute,isSpeaking:T.isSpeaking})]})},Gn=({bobConfig:t,hostApiConfig:e,hostContext:r,callbacks:s,variant:o="mobile",initialState:l,showChat:c,className:x,backdropUrl:h,counterOverlayUrl:w,counterHeightPercent:d,defaultBobImage:g,verticalOffset:m,scale:S})=>n.jsx("div",{className:"bob-widget-root",style:{width:"100%",height:"100%"},children:n.jsx(Ps,{bobConfig:t,hostApiConfig:e,hostContext:r,callbacks:s,children:n.jsx($s,{variant:o,initialState:l,showChat:c,className:x,backdropUrl:h,counterOverlayUrl:w,counterHeightPercent:d,defaultBobImage:g,verticalOffset:m,scale:S})})}),Yn=6e4,Jn=({states:t,setAnimationState:e,manualMode:r})=>{const[s,o]=u.useState("page_load"),[l,c]=u.useState(!1),x=u.useRef(null),h=u.useCallback(p=>t.find(C=>C.chat_trigger===p&&C.is_active),[t]),w=u.useCallback(()=>t.find(p=>p.chat_trigger==="awaiting_input"||p.state_key==="talk_pause"||p.title.toLowerCase().includes("listen")||p.title.toLowerCase().includes("pause")),[t]),d=u.useCallback(()=>t.find(p=>p.state_key==="idle"||p.title.toLowerCase().includes("idle")),[t]),g=u.useCallback(p=>{const C=t.find(O=>O.state_key===p);return{speed:(C==null?void 0:C.animation_speed)||400,pauseDuration:(C==null?void 0:C.pause_duration)||0,loopCount:(C==null?void 0:C.loop_count)||0}},[t]),m=u.useCallback(()=>{x.current&&(clearTimeout(x.current),x.current=null)},[]),S=u.useCallback(()=>{m(),!r&&(x.current=setTimeout(()=>{const p=d();p&&(o("idle"),e(p.state_key))},Yn))},[r,d,e,m]),P=u.useCallback(p=>{if(r)return;const C=h(p);C&&e(C.state_key)},[r,h,e]),E=u.useCallback(()=>{if(r)return;const p=w();p&&(o("awaiting_input"),e(p.state_key),S())},[r,w,e,S]),R=u.useCallback(()=>{l||r||(c(!0),o("page_load"),P("page_load"),setTimeout(()=>{E()},3e3))},[l,r,P,E]),k=u.useCallback(()=>{m(),o("processing_input"),P("processing_input")},[P,m]),f=u.useCallback(()=>{m(),o("streaming_response"),P("streaming_response")},[P,m]),j=u.useCallback(()=>{o("response_complete"),P("response_complete"),setTimeout(()=>{E()},3e3)},[P,E]),b=u.useCallback(()=>{o("showing_product");const p=t.find(C=>C.chat_trigger==="showing_product"||C.state_key==="showing_product");p&&e(p.state_key),setTimeout(()=>{E()},4e3)},[t,e,E]);return u.useEffect(()=>()=>m(),[m]),{chatStage:s,initialize:R,onUserInput:k,onStreamStart:f,onStreamComplete:j,onShowingProduct:b,getStateSettings:g}};console.log(`[BobWidget] Package loaded - v${lr}`);exports.BOB_VERSION=lr;exports.Bob=$s;exports.BobCharacter=Ds;exports.BobProvider=Ps;exports.BobWidget=Gn;exports.ChatInterface=Ls;exports.ContainedChatDrawer=qs;exports.ContainedMobileBobLayout=Qs;exports.MobileBobCharacter=Wr;exports.MobileBobLayout=Ws;exports.MobileChatDrawer=Us;exports.MobileProductColumn=$r;exports.getBobVersion=Xs;exports.useBobAnimation=Bs;exports.useBobAnimationData=Ms;exports.useBobBackdrop=As;exports.useBobCallbacks=Wn;exports.useBobChat=Fs;exports.useBobContext=at;exports.useBobStateTransitions=Jn;exports.useBobSupabase=Ur;exports.useHostApiConfig=Un;exports.useHostContext=Ln;exports.useSpeechRecognition=Kr;exports.useSpeechSynthesis=Ns;
30
+ <%s key={someKey} {...props} />`,vr,ft,Js,ft),X[ft+vr]=!0}}return i===s?hr(ie):Fe(ie),ie}}function Zt(i,w,P){return Xt(i,w,P,!0)}function ht(i,w,P){return Xt(i,w,P,!1)}var er=ht,fr=Zt;rr.Fragment=s,rr.jsx=er,rr.jsxs=fr}()),rr}process.env.NODE_ENV==="production"?Sr.exports=rn():Sr.exports=sn();var n=Sr.exports,dr=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},nn={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Me,bt,bs,an=(bs=class{constructor(){A(this,Me,nn);A(this,bt,!1)}setTimeoutProvider(t){process.env.NODE_ENV!=="production"&&a(this,bt)&&t!==a(this,Me)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:a(this,Me),provider:t}),I(this,Me,t),process.env.NODE_ENV!=="production"&&I(this,bt,!1)}setTimeout(t,e){return process.env.NODE_ENV!=="production"&&I(this,bt,!0),a(this,Me).setTimeout(t,e)}clearTimeout(t){a(this,Me).clearTimeout(t)}setInterval(t,e){return process.env.NODE_ENV!=="production"&&I(this,bt,!0),a(this,Me).setInterval(t,e)}clearInterval(t){a(this,Me).clearInterval(t)}},Me=new WeakMap,bt=new WeakMap,bs),pt=new an;function on(t){setTimeout(t,0)}var kt=typeof window>"u"||"Deno"in globalThis;function ye(){}function ln(t,e){return typeof t=="function"?t(e):t}function jr(t){return typeof t=="number"&&t>=0&&t!==1/0}function ks(t,e){return Math.max(t+(e||0)-Date.now(),0)}function lt(t,e){return typeof t=="function"?t(e):t}function Ee(t,e){return typeof t=="function"?t(e):t}function ts(t,e){const{type:r="all",exact:s,fetchStatus:o,predicate:u,queryKey:h,stale:c}=t;if(h){if(s){if(e.queryHash!==Dr(h,e.options))return!1}else if(!ir(e.queryKey,h))return!1}if(r!=="all"){const y=e.isActive();if(r==="active"&&!y||r==="inactive"&&y)return!1}return!(typeof c=="boolean"&&e.isStale()!==c||o&&o!==e.state.fetchStatus||u&&!u(e))}function rs(t,e){const{exact:r,status:s,predicate:o,mutationKey:u}=t;if(u){if(!e.options.mutationKey)return!1;if(r){if(nr(e.options.mutationKey)!==nr(u))return!1}else if(!ir(e.options.mutationKey,u))return!1}return!(s&&e.state.status!==s||o&&!o(e))}function Dr(t,e){return((e==null?void 0:e.queryKeyHashFn)||nr)(t)}function nr(t){return JSON.stringify(t,(e,r)=>Rr(r)?Object.keys(r).sort().reduce((s,o)=>(s[o]=r[o],s),{}):r)}function ir(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>ir(t[r],e[r])):!1}var cn=Object.prototype.hasOwnProperty;function Er(t,e){if(t===e)return t;const r=ss(t)&&ss(e);if(!r&&!(Rr(t)&&Rr(e)))return e;const o=(r?t:Object.keys(t)).length,u=r?e:Object.keys(e),h=u.length,c=r?new Array(h):{};let y=0;for(let v=0;v<h;v++){const p=r?v:u[v],x=t[p],g=e[p];if(x===g){c[p]=x,(r?v<o:cn.call(t,p))&&y++;continue}if(x===null||g===null||typeof x!="object"||typeof g!="object"){c[p]=g;continue}const j=Er(x,g);c[p]=j,j===x&&y++}return o===h&&y===o?t:c}function kr(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const r in t)if(t[r]!==e[r])return!1;return!0}function ss(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Rr(t){if(!ns(t))return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(!ns(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function ns(t){return Object.prototype.toString.call(t)==="[object Object]"}function un(t){return new Promise(e=>{pt.setTimeout(e,t)})}function _r(t,e,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(t,e);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return Er(t,e)}catch(s){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${s}`),s}return Er(t,e)}return e}function dn(t,e,r=0){const s=[...t,e];return r&&s.length>r?s.slice(1):s}function hn(t,e,r=0){const s=[e,...t];return r&&s.length>r?s.slice(0,-1):s}var mr=Symbol();function Rs(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===mr&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===mr?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function _s(t,e){return typeof t=="function"?t(...e):!!t}function fn(t,e,r){let s=!1,o;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(o??(o=e()),s||(s=!0,o.aborted?r():o.addEventListener("abort",r,{once:!0})),o)}),t}var mt,tt,Ft,ms,pn=(ms=class extends dr{constructor(){super();A(this,mt);A(this,tt);A(this,Ft);I(this,Ft,e=>{if(!kt&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){a(this,tt)||this.setEventListener(a(this,Ft))}onUnsubscribe(){var e;this.hasListeners()||((e=a(this,tt))==null||e.call(this),I(this,tt,void 0))}setEventListener(e){var r;I(this,Ft,e),(r=a(this,tt))==null||r.call(this),I(this,tt,e(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(e){a(this,mt)!==e&&(I(this,mt,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof a(this,mt)=="boolean"?a(this,mt):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},mt=new WeakMap,tt=new WeakMap,Ft=new WeakMap,ms),Lr=new pn;function Cr(){let t,e;const r=new Promise((o,u)=>{t=o,e=u});r.status="pending",r.catch(()=>{});function s(o){Object.assign(r,o),delete r.resolve,delete r.reject}return r.resolve=o=>{s({status:"fulfilled",value:o}),t(o)},r.reject=o=>{s({status:"rejected",reason:o}),e(o)},r}var bn=on;function mn(){let t=[],e=0,r=c=>{c()},s=c=>{c()},o=bn;const u=c=>{e?t.push(c):o(()=>{r(c)})},h=()=>{const c=t;t=[],c.length&&o(()=>{s(()=>{c.forEach(y=>{r(y)})})})};return{batch:c=>{let y;e++;try{y=c()}finally{e--,e||h()}return y},batchCalls:c=>(...y)=>{u(()=>{c(...y)})},schedule:u,setNotifyFunction:c=>{r=c},setBatchNotifyFunction:c=>{s=c},setScheduler:c=>{o=c}}}var ce=mn(),Mt,rt,Bt,gs,gn=(gs=class extends dr{constructor(){super();A(this,Mt,!0);A(this,rt);A(this,Bt);I(this,Bt,e=>{if(!kt&&window.addEventListener){const r=()=>e(!0),s=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",s)}}})}onSubscribe(){a(this,rt)||this.setEventListener(a(this,Bt))}onUnsubscribe(){var e;this.hasListeners()||((e=a(this,rt))==null||e.call(this),I(this,rt,void 0))}setEventListener(e){var r;I(this,Bt,e),(r=a(this,rt))==null||r.call(this),I(this,rt,e(this.setOnline.bind(this)))}setOnline(e){a(this,Mt)!==e&&(I(this,Mt,e),this.listeners.forEach(s=>{s(e)}))}isOnline(){return a(this,Mt)}},Mt=new WeakMap,rt=new WeakMap,Bt=new WeakMap,gs),gr=new gn;function xn(t){return Math.min(1e3*2**t,3e4)}function Cs(t){return(t??"online")==="online"?gr.isOnline():!0}var Tr=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function Ts(t){let e=!1,r=0,s;const o=Cr(),u=()=>o.status!=="pending",h=R=>{var _;if(!u()){const E=new Tr(R);g(E),(_=t.onCancel)==null||_.call(t,E)}},c=()=>{e=!0},y=()=>{e=!1},v=()=>Lr.isFocused()&&(t.networkMode==="always"||gr.isOnline())&&t.canRun(),p=()=>Cs(t.networkMode)&&t.canRun(),x=R=>{u()||(s==null||s(),o.resolve(R))},g=R=>{u()||(s==null||s(),o.reject(R))},j=()=>new Promise(R=>{var _;s=E=>{(u()||v())&&R(E)},(_=t.onPause)==null||_.call(t)}).then(()=>{var R;s=void 0,u()||(R=t.onContinue)==null||R.call(t)}),C=()=>{if(u())return;let R;const _=r===0?t.initialPromise:void 0;try{R=_??t.fn()}catch(E){R=Promise.reject(E)}Promise.resolve(R).then(x).catch(E=>{var S;if(u())return;const m=t.retry??(kt?0:3),l=t.retryDelay??xn,f=typeof l=="function"?l(r,E):l,b=m===!0||typeof m=="number"&&r<m||typeof m=="function"&&m(r,E);if(e||!b){g(E);return}r++,(S=t.onFail)==null||S.call(t,r,E),un(f).then(()=>v()?void 0:j()).then(()=>{e?g(E):C()})})};return{promise:o,status:()=>o.status,cancel:h,continue:()=>(s==null||s(),o),cancelRetry:c,continueRetry:y,canStart:p,start:()=>(p()?C():j().then(C),o)}}var gt,xs,Os=(xs=class{constructor(){A(this,gt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),jr(this.gcTime)&&I(this,gt,pt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(kt?1/0:5*60*1e3))}clearGcTimeout(){a(this,gt)&&(pt.clearTimeout(a(this,gt)),I(this,gt,void 0))}},gt=new WeakMap,xs),xt,At,je,yt,le,ar,vt,Te,Ue,ys,yn=(ys=class extends Os{constructor(e){super();A(this,Te);A(this,xt);A(this,At);A(this,je);A(this,yt);A(this,le);A(this,ar);A(this,vt);I(this,vt,!1),I(this,ar,e.defaultOptions),this.setOptions(e.options),this.observers=[],I(this,yt,e.client),I(this,je,a(this,yt).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,I(this,xt,as(this.options)),this.state=e.state??a(this,xt),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=a(this,le))==null?void 0:e.promise}setOptions(e){if(this.options={...a(this,ar),...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=as(this.options);r.data!==void 0&&(this.setState(is(r.data,r.dataUpdatedAt)),I(this,xt,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&a(this,je).remove(this)}setData(e,r){const s=_r(this.state.data,e,this.options);return Q(this,Te,Ue).call(this,{data:s,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),s}setState(e,r){Q(this,Te,Ue).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var s,o;const r=(s=a(this,le))==null?void 0:s.promise;return(o=a(this,le))==null||o.cancel(e),r?r.then(ye).catch(ye):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(a(this,xt))}isActive(){return this.observers.some(e=>Ee(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===mr||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>lt(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!ks(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(s=>s.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=a(this,le))==null||r.continue()}onOnline(){var r;const e=this.observers.find(s=>s.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=a(this,le))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),a(this,je).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(a(this,le)&&(a(this,vt)?a(this,le).cancel({revert:!0}):a(this,le).cancelRetry()),this.scheduleGc()),a(this,je).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Q(this,Te,Ue).call(this,{type:"invalidate"})}async fetch(e,r){var y,v,p,x,g,j,C,R,_,E,m,l;if(this.state.fetchStatus!=="idle"&&((y=a(this,le))==null?void 0:y.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(a(this,le))return a(this,le).continueRetry(),a(this,le).promise}if(e&&this.setOptions(e),!this.options.queryFn){const f=this.observers.find(b=>b.options.queryFn);f&&this.setOptions(f.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const s=new AbortController,o=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(I(this,vt,!0),s.signal)})},u=()=>{const f=Rs(this.options,r),S=(()=>{const O={client:a(this,yt),queryKey:this.queryKey,meta:this.meta};return o(O),O})();return I(this,vt,!1),this.options.persister?this.options.persister(f,S,this):f(S)},c=(()=>{const f={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:a(this,yt),state:this.state,fetchFn:u};return o(f),f})();(v=this.options.behavior)==null||v.onFetch(c,this),I(this,At,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=c.fetchOptions)==null?void 0:p.meta))&&Q(this,Te,Ue).call(this,{type:"fetch",meta:(x=c.fetchOptions)==null?void 0:x.meta}),I(this,le,Ts({initialPromise:r==null?void 0:r.initialPromise,fn:c.fetchFn,onCancel:f=>{f instanceof Tr&&f.revert&&this.setState({...a(this,At),fetchStatus:"idle"}),s.abort()},onFail:(f,b)=>{Q(this,Te,Ue).call(this,{type:"failed",failureCount:f,error:b})},onPause:()=>{Q(this,Te,Ue).call(this,{type:"pause"})},onContinue:()=>{Q(this,Te,Ue).call(this,{type:"continue"})},retry:c.options.retry,retryDelay:c.options.retryDelay,networkMode:c.options.networkMode,canRun:()=>!0}));try{const f=await a(this,le).start();if(f===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(f),(j=(g=a(this,je).config).onSuccess)==null||j.call(g,f,this),(R=(C=a(this,je).config).onSettled)==null||R.call(C,f,this.state.error,this),f}catch(f){if(f instanceof Tr){if(f.silent)return a(this,le).promise;if(f.revert){if(this.state.data===void 0)throw f;return this.state.data}}throw Q(this,Te,Ue).call(this,{type:"error",error:f}),(E=(_=a(this,je).config).onError)==null||E.call(_,f,this),(l=(m=a(this,je).config).onSettled)==null||l.call(m,this.state.data,f,this),f}finally{this.scheduleGc()}}},xt=new WeakMap,At=new WeakMap,je=new WeakMap,yt=new WeakMap,le=new WeakMap,ar=new WeakMap,vt=new WeakMap,Te=new WeakSet,Ue=function(e){const r=s=>{switch(e.type){case"failed":return{...s,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...Is(s.data,this.options),fetchMeta:e.meta??null};case"success":const o={...s,...is(e.data,e.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return I(this,At,e.manual?o:void 0),o;case"error":const u=e.error;return{...s,error:u,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:u,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...e.state}}};this.state=r(this.state),ce.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),a(this,je).notify({query:this,type:"updated",action:e})})},ys);function Is(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Cs(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function is(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function as(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,s=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var xe,V,or,pe,wt,Dt,We,st,lr,Lt,Ut,St,jt,nt,Wt,H,sr,Or,Ir,Pr,Nr,Fr,Mr,Br,Ps,vs,vn=(vs=class extends dr{constructor(e,r){super();A(this,H);A(this,xe);A(this,V);A(this,or);A(this,pe);A(this,wt);A(this,Dt);A(this,We);A(this,st);A(this,lr);A(this,Lt);A(this,Ut);A(this,St);A(this,jt);A(this,nt);A(this,Wt,new Set);this.options=r,I(this,xe,e),I(this,st,null),I(this,We,Cr()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(a(this,V).addObserver(this),os(a(this,V),this.options)?Q(this,H,sr).call(this):this.updateResult(),Q(this,H,Nr).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ar(a(this,V),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ar(a(this,V),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Q(this,H,Fr).call(this),Q(this,H,Mr).call(this),a(this,V).removeObserver(this)}setOptions(e){const r=this.options,s=a(this,V);if(this.options=a(this,xe).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ee(this.options.enabled,a(this,V))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Q(this,H,Br).call(this),a(this,V).setOptions(this.options),r._defaulted&&!kr(this.options,r)&&a(this,xe).getQueryCache().notify({type:"observerOptionsUpdated",query:a(this,V),observer:this});const o=this.hasListeners();o&&ls(a(this,V),s,this.options,r)&&Q(this,H,sr).call(this),this.updateResult(),o&&(a(this,V)!==s||Ee(this.options.enabled,a(this,V))!==Ee(r.enabled,a(this,V))||lt(this.options.staleTime,a(this,V))!==lt(r.staleTime,a(this,V)))&&Q(this,H,Or).call(this);const u=Q(this,H,Ir).call(this);o&&(a(this,V)!==s||Ee(this.options.enabled,a(this,V))!==Ee(r.enabled,a(this,V))||u!==a(this,nt))&&Q(this,H,Pr).call(this,u)}getOptimisticResult(e){const r=a(this,xe).getQueryCache().build(a(this,xe),e),s=this.createResult(r,e);return Sn(this,s)&&(I(this,pe,s),I(this,Dt,this.options),I(this,wt,a(this,V).state)),s}getCurrentResult(){return a(this,pe)}trackResult(e,r){return new Proxy(e,{get:(s,o)=>(this.trackProp(o),r==null||r(o),o==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&a(this,We).status==="pending"&&a(this,We).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,o))})}trackProp(e){a(this,Wt).add(e)}getCurrentQuery(){return a(this,V)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=a(this,xe).defaultQueryOptions(e),s=a(this,xe).getQueryCache().build(a(this,xe),r);return s.fetch().then(()=>this.createResult(s,r))}fetch(e){return Q(this,H,sr).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),a(this,pe)))}createResult(e,r){var M;const s=a(this,V),o=this.options,u=a(this,pe),h=a(this,wt),c=a(this,Dt),v=e!==s?e.state:a(this,or),{state:p}=e;let x={...p},g=!1,j;if(r._optimisticResults){const k=this.hasListeners(),N=!k&&os(e,r),T=k&&ls(e,s,r,o);(N||T)&&(x={...x,...Is(p.data,e.options)}),r._optimisticResults==="isRestoring"&&(x.fetchStatus="idle")}let{error:C,errorUpdatedAt:R,status:_}=x;j=x.data;let E=!1;if(r.placeholderData!==void 0&&j===void 0&&_==="pending"){let k;u!=null&&u.isPlaceholderData&&r.placeholderData===(c==null?void 0:c.placeholderData)?(k=u.data,E=!0):k=typeof r.placeholderData=="function"?r.placeholderData((M=a(this,Ut))==null?void 0:M.state.data,a(this,Ut)):r.placeholderData,k!==void 0&&(_="success",j=_r(u==null?void 0:u.data,k,r),g=!0)}if(r.select&&j!==void 0&&!E)if(u&&j===(h==null?void 0:h.data)&&r.select===a(this,lr))j=a(this,Lt);else try{I(this,lr,r.select),j=r.select(j),j=_r(u==null?void 0:u.data,j,r),I(this,Lt,j),I(this,st,null)}catch(k){I(this,st,k)}a(this,st)&&(C=a(this,st),j=a(this,Lt),R=Date.now(),_="error");const m=x.fetchStatus==="fetching",l=_==="pending",f=_==="error",b=l&&m,S=j!==void 0,B={status:_,fetchStatus:x.fetchStatus,isPending:l,isSuccess:_==="success",isError:f,isInitialLoading:b,isLoading:b,data:j,dataUpdatedAt:x.dataUpdatedAt,error:C,errorUpdatedAt:R,failureCount:x.fetchFailureCount,failureReason:x.fetchFailureReason,errorUpdateCount:x.errorUpdateCount,isFetched:x.dataUpdateCount>0||x.errorUpdateCount>0,isFetchedAfterMount:x.dataUpdateCount>v.dataUpdateCount||x.errorUpdateCount>v.errorUpdateCount,isFetching:m,isRefetching:m&&!l,isLoadingError:f&&!S,isPaused:x.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:f&&S,isStale:Ur(e,r),refetch:this.refetch,promise:a(this,We),isEnabled:Ee(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const k=D=>{B.status==="error"?D.reject(B.error):B.data!==void 0&&D.resolve(B.data)},N=()=>{const D=I(this,We,B.promise=Cr());k(D)},T=a(this,We);switch(T.status){case"pending":e.queryHash===s.queryHash&&k(T);break;case"fulfilled":(B.status==="error"||B.data!==T.value)&&N();break;case"rejected":(B.status!=="error"||B.error!==T.reason)&&N();break}}return B}updateResult(){const e=a(this,pe),r=this.createResult(a(this,V),this.options);if(I(this,wt,a(this,V).state),I(this,Dt,this.options),a(this,wt).data!==void 0&&I(this,Ut,a(this,V)),kr(r,e))return;I(this,pe,r);const s=()=>{if(!e)return!0;const{notifyOnChangeProps:o}=this.options,u=typeof o=="function"?o():o;if(u==="all"||!u&&!a(this,Wt).size)return!0;const h=new Set(u??a(this,Wt));return this.options.throwOnError&&h.add("error"),Object.keys(a(this,pe)).some(c=>{const y=c;return a(this,pe)[y]!==e[y]&&h.has(y)})};Q(this,H,Ps).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Q(this,H,Nr).call(this)}},xe=new WeakMap,V=new WeakMap,or=new WeakMap,pe=new WeakMap,wt=new WeakMap,Dt=new WeakMap,We=new WeakMap,st=new WeakMap,lr=new WeakMap,Lt=new WeakMap,Ut=new WeakMap,St=new WeakMap,jt=new WeakMap,nt=new WeakMap,Wt=new WeakMap,H=new WeakSet,sr=function(e){Q(this,H,Br).call(this);let r=a(this,V).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(ye)),r},Or=function(){Q(this,H,Fr).call(this);const e=lt(this.options.staleTime,a(this,V));if(kt||a(this,pe).isStale||!jr(e))return;const s=ks(a(this,pe).dataUpdatedAt,e)+1;I(this,St,pt.setTimeout(()=>{a(this,pe).isStale||this.updateResult()},s))},Ir=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(a(this,V)):this.options.refetchInterval)??!1},Pr=function(e){Q(this,H,Mr).call(this),I(this,nt,e),!(kt||Ee(this.options.enabled,a(this,V))===!1||!jr(a(this,nt))||a(this,nt)===0)&&I(this,jt,pt.setInterval(()=>{(this.options.refetchIntervalInBackground||Lr.isFocused())&&Q(this,H,sr).call(this)},a(this,nt)))},Nr=function(){Q(this,H,Or).call(this),Q(this,H,Pr).call(this,Q(this,H,Ir).call(this))},Fr=function(){a(this,St)&&(pt.clearTimeout(a(this,St)),I(this,St,void 0))},Mr=function(){a(this,jt)&&(pt.clearInterval(a(this,jt)),I(this,jt,void 0))},Br=function(){const e=a(this,xe).getQueryCache().build(a(this,xe),this.options);if(e===a(this,V))return;const r=a(this,V);I(this,V,e),I(this,or,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},Ps=function(e){ce.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(a(this,pe))}),a(this,xe).getQueryCache().notify({query:a(this,V),type:"observerResultsUpdated"})})},vs);function wn(t,e){return Ee(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function os(t,e){return wn(t,e)||t.state.data!==void 0&&Ar(t,e,e.refetchOnMount)}function Ar(t,e,r){if(Ee(e.enabled,t)!==!1&&lt(e.staleTime,t)!=="static"){const s=typeof r=="function"?r(t):r;return s==="always"||s!==!1&&Ur(t,e)}return!1}function ls(t,e,r,s){return(t!==e||Ee(s.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&Ur(t,r)}function Ur(t,e){return Ee(e.enabled,t)!==!1&&t.isStaleByTime(lt(e.staleTime,t))}function Sn(t,e){return!kr(t.getCurrentResult(),e)}function cs(t){return{onFetch:(e,r)=>{var p,x,g,j,C;const s=e.options,o=(g=(x=(p=e.fetchOptions)==null?void 0:p.meta)==null?void 0:x.fetchMore)==null?void 0:g.direction,u=((j=e.state.data)==null?void 0:j.pages)||[],h=((C=e.state.data)==null?void 0:C.pageParams)||[];let c={pages:[],pageParams:[]},y=0;const v=async()=>{let R=!1;const _=l=>{fn(l,()=>e.signal,()=>R=!0)},E=Rs(e.options,e.fetchOptions),m=async(l,f,b)=>{if(R)return Promise.reject();if(f==null&&l.pages.length)return Promise.resolve(l);const O=(()=>{const N={client:e.client,queryKey:e.queryKey,pageParam:f,direction:b?"backward":"forward",meta:e.options.meta};return _(N),N})(),B=await E(O),{maxPages:M}=e.options,k=b?hn:dn;return{pages:k(l.pages,B,M),pageParams:k(l.pageParams,f,M)}};if(o&&u.length){const l=o==="backward",f=l?jn:us,b={pages:u,pageParams:h},S=f(s,b);c=await m(b,S,l)}else{const l=t??u.length;do{const f=y===0?h[0]??s.initialPageParam:us(s,c);if(y>0&&f==null)break;c=await m(c,f),y++}while(y<l)}return c};e.options.persister?e.fetchFn=()=>{var R,_;return(_=(R=e.options).persister)==null?void 0:_.call(R,v,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=v}}}function us(t,{pages:e,pageParams:r}){const s=e.length-1;return e.length>0?t.getNextPageParam(e[s],e,r[s],r):void 0}function jn(t,{pages:e,pageParams:r}){var s;return e.length>0?(s=t.getPreviousPageParam)==null?void 0:s.call(t,e[0],e,r[0],r):void 0}var cr,Be,be,Et,Ae,et,ws,En=(ws=class extends Os{constructor(e){super();A(this,Ae);A(this,cr);A(this,Be);A(this,be);A(this,Et);I(this,cr,e.client),this.mutationId=e.mutationId,I(this,be,e.mutationCache),I(this,Be,[]),this.state=e.state||kn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){a(this,Be).includes(e)||(a(this,Be).push(e),this.clearGcTimeout(),a(this,be).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){I(this,Be,a(this,Be).filter(r=>r!==e)),this.scheduleGc(),a(this,be).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){a(this,Be).length||(this.state.status==="pending"?this.scheduleGc():a(this,be).remove(this))}continue(){var e;return((e=a(this,Et))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var h,c,y,v,p,x,g,j,C,R,_,E,m,l,f,b,S,O,B,M;const r=()=>{Q(this,Ae,et).call(this,{type:"continue"})},s={client:a(this,cr),meta:this.options.meta,mutationKey:this.options.mutationKey};I(this,Et,Ts({fn:()=>this.options.mutationFn?this.options.mutationFn(e,s):Promise.reject(new Error("No mutationFn found")),onFail:(k,N)=>{Q(this,Ae,et).call(this,{type:"failed",failureCount:k,error:N})},onPause:()=>{Q(this,Ae,et).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>a(this,be).canRun(this)}));const o=this.state.status==="pending",u=!a(this,Et).canStart();try{if(o)r();else{Q(this,Ae,et).call(this,{type:"pending",variables:e,isPaused:u}),await((c=(h=a(this,be).config).onMutate)==null?void 0:c.call(h,e,this,s));const N=await((v=(y=this.options).onMutate)==null?void 0:v.call(y,e,s));N!==this.state.context&&Q(this,Ae,et).call(this,{type:"pending",context:N,variables:e,isPaused:u})}const k=await a(this,Et).start();return await((x=(p=a(this,be).config).onSuccess)==null?void 0:x.call(p,k,e,this.state.context,this,s)),await((j=(g=this.options).onSuccess)==null?void 0:j.call(g,k,e,this.state.context,s)),await((R=(C=a(this,be).config).onSettled)==null?void 0:R.call(C,k,null,this.state.variables,this.state.context,this,s)),await((E=(_=this.options).onSettled)==null?void 0:E.call(_,k,null,e,this.state.context,s)),Q(this,Ae,et).call(this,{type:"success",data:k}),k}catch(k){try{await((l=(m=a(this,be).config).onError)==null?void 0:l.call(m,k,e,this.state.context,this,s))}catch(N){Promise.reject(N)}try{await((b=(f=this.options).onError)==null?void 0:b.call(f,k,e,this.state.context,s))}catch(N){Promise.reject(N)}try{await((O=(S=a(this,be).config).onSettled)==null?void 0:O.call(S,void 0,k,this.state.variables,this.state.context,this,s))}catch(N){Promise.reject(N)}try{await((M=(B=this.options).onSettled)==null?void 0:M.call(B,void 0,k,e,this.state.context,s))}catch(N){Promise.reject(N)}throw Q(this,Ae,et).call(this,{type:"error",error:k}),k}finally{a(this,be).runNext(this)}}},cr=new WeakMap,Be=new WeakMap,be=new WeakMap,Et=new WeakMap,Ae=new WeakSet,et=function(e){const r=s=>{switch(e.type){case"failed":return{...s,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...s,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:e.error,failureCount:s.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),ce.batch(()=>{a(this,Be).forEach(s=>{s.onMutationUpdate(e)}),a(this,be).notify({mutation:this,type:"updated",action:e})})},ws);function kn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var qe,Oe,ur,Ss,Rn=(Ss=class extends dr{constructor(e={}){super();A(this,qe);A(this,Oe);A(this,ur);this.config=e,I(this,qe,new Set),I(this,Oe,new Map),I(this,ur,0)}build(e,r,s){const o=new En({client:e,mutationCache:this,mutationId:++pr(this,ur)._,options:e.defaultMutationOptions(r),state:s});return this.add(o),o}add(e){a(this,qe).add(e);const r=br(e);if(typeof r=="string"){const s=a(this,Oe).get(r);s?s.push(e):a(this,Oe).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(a(this,qe).delete(e)){const r=br(e);if(typeof r=="string"){const s=a(this,Oe).get(r);if(s)if(s.length>1){const o=s.indexOf(e);o!==-1&&s.splice(o,1)}else s[0]===e&&a(this,Oe).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=br(e);if(typeof r=="string"){const s=a(this,Oe).get(r),o=s==null?void 0:s.find(u=>u.state.status==="pending");return!o||o===e}else return!0}runNext(e){var s;const r=br(e);if(typeof r=="string"){const o=(s=a(this,Oe).get(r))==null?void 0:s.find(u=>u!==e&&u.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ce.batch(()=>{a(this,qe).forEach(e=>{this.notify({type:"removed",mutation:e})}),a(this,qe).clear(),a(this,Oe).clear()})}getAll(){return Array.from(a(this,qe))}find(e){const r={exact:!0,...e};return this.getAll().find(s=>rs(r,s))}findAll(e={}){return this.getAll().filter(r=>rs(e,r))}notify(e){ce.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return ce.batch(()=>Promise.all(e.map(r=>r.continue().catch(ye))))}},qe=new WeakMap,Oe=new WeakMap,ur=new WeakMap,Ss);function br(t){var e;return(e=t.options.scope)==null?void 0:e.id}var De,js,_n=(js=class extends dr{constructor(e={}){super();A(this,De);this.config=e,I(this,De,new Map)}build(e,r,s){const o=r.queryKey,u=r.queryHash??Dr(o,r);let h=this.get(u);return h||(h=new yn({client:e,queryKey:o,queryHash:u,options:e.defaultQueryOptions(r),state:s,defaultOptions:e.getQueryDefaults(o)}),this.add(h)),h}add(e){a(this,De).has(e.queryHash)||(a(this,De).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=a(this,De).get(e.queryHash);r&&(e.destroy(),r===e&&a(this,De).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ce.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return a(this,De).get(e)}getAll(){return[...a(this,De).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(s=>ts(r,s))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(s=>ts(e,s)):r}notify(e){ce.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){ce.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ce.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},De=new WeakMap,js),te,it,at,qt,$t,ot,Qt,Vt,Es,Cn=(Es=class{constructor(t={}){A(this,te);A(this,it);A(this,at);A(this,qt);A(this,$t);A(this,ot);A(this,Qt);A(this,Vt);I(this,te,t.queryCache||new _n),I(this,it,t.mutationCache||new Rn),I(this,at,t.defaultOptions||{}),I(this,qt,new Map),I(this,$t,new Map),I(this,ot,0)}mount(){pr(this,ot)._++,a(this,ot)===1&&(I(this,Qt,Lr.subscribe(async t=>{t&&(await this.resumePausedMutations(),a(this,te).onFocus())})),I(this,Vt,gr.subscribe(async t=>{t&&(await this.resumePausedMutations(),a(this,te).onOnline())})))}unmount(){var t,e;pr(this,ot)._--,a(this,ot)===0&&((t=a(this,Qt))==null||t.call(this),I(this,Qt,void 0),(e=a(this,Vt))==null||e.call(this),I(this,Vt,void 0))}isFetching(t){return a(this,te).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return a(this,it).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=a(this,te).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=a(this,te).build(this,e),s=r.state.data;return s===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(lt(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(s))}getQueriesData(t){return a(this,te).findAll(t).map(({queryKey:e,state:r})=>{const s=r.data;return[e,s]})}setQueryData(t,e,r){const s=this.defaultQueryOptions({queryKey:t}),o=a(this,te).get(s.queryHash),u=o==null?void 0:o.state.data,h=ln(e,u);if(h!==void 0)return a(this,te).build(this,s).setData(h,{...r,manual:!0})}setQueriesData(t,e,r){return ce.batch(()=>a(this,te).findAll(t).map(({queryKey:s})=>[s,this.setQueryData(s,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=a(this,te).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=a(this,te);ce.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=a(this,te);return ce.batch(()=>(r.findAll(t).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},s=ce.batch(()=>a(this,te).findAll(t).map(o=>o.cancel(r)));return Promise.all(s).then(ye).catch(ye)}invalidateQueries(t,e={}){return ce.batch(()=>(a(this,te).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const r={...e,cancelRefetch:e.cancelRefetch??!0},s=ce.batch(()=>a(this,te).findAll(t).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let u=o.fetch(void 0,r);return r.throwOnError||(u=u.catch(ye)),o.state.fetchStatus==="paused"?Promise.resolve():u}));return Promise.all(s).then(ye)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=a(this,te).build(this,e);return r.isStaleByTime(lt(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(ye).catch(ye)}fetchInfiniteQuery(t){return t.behavior=cs(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(ye).catch(ye)}ensureInfiniteQueryData(t){return t.behavior=cs(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return gr.isOnline()?a(this,it).resumePausedMutations():Promise.resolve()}getQueryCache(){return a(this,te)}getMutationCache(){return a(this,it)}getDefaultOptions(){return a(this,at)}setDefaultOptions(t){I(this,at,t)}setQueryDefaults(t,e){a(this,qt).set(nr(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...a(this,qt).values()],r={};return e.forEach(s=>{ir(t,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(t,e){a(this,$t).set(nr(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...a(this,$t).values()],r={};return e.forEach(s=>{ir(t,s.mutationKey)&&Object.assign(r,s.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={...a(this,at).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Dr(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===mr&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...a(this,at).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){a(this,te).clear(),a(this,it).clear()}},te=new WeakMap,it=new WeakMap,at=new WeakMap,qt=new WeakMap,$t=new WeakMap,ot=new WeakMap,Qt=new WeakMap,Vt=new WeakMap,Es),Ns=ke.createContext(void 0),Fs=t=>{const e=ke.useContext(Ns);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Tn=({client:t,children:e})=>(ke.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),n.jsx(Ns.Provider,{value:t,children:e})),Ms=ke.createContext(!1),On=()=>ke.useContext(Ms);Ms.Provider;function In(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Pn=ke.createContext(In()),Nn=()=>ke.useContext(Pn),Fn=(t,e,r)=>{const s=r!=null&&r.state.error&&typeof t.throwOnError=="function"?_s(t.throwOnError,[r.state.error,r]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||s)&&(e.isReset()||(t.retryOnMount=!1))},Mn=t=>{ke.useEffect(()=>{t.clearReset()},[t])},Bn=({result:t,errorResetBoundary:e,throwOnError:r,query:s,suspense:o})=>t.isError&&!e.isReset()&&!t.isFetching&&s&&(o&&t.data===void 0||_s(r,[t.error,s])),An=t=>{if(t.suspense){const r=o=>o==="static"?o:Math.max(o??1e3,1e3),s=t.staleTime;t.staleTime=typeof s=="function"?(...o)=>r(s(...o)):r(s),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},Dn=(t,e)=>t.isLoading&&t.isFetching&&!e,Ln=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,ds=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function Un(t,e,r){var g,j,C,R;if(process.env.NODE_ENV!=="production"&&(typeof t!="object"||Array.isArray(t)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const s=On(),o=Nn(),u=Fs(),h=u.defaultQueryOptions(t);(j=(g=u.getDefaultOptions().queries)==null?void 0:g._experimental_beforeQuery)==null||j.call(g,h);const c=u.getQueryCache().get(h.queryHash);process.env.NODE_ENV!=="production"&&(h.queryFn||console.error(`[${h.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),h._optimisticResults=s?"isRestoring":"optimistic",An(h),Fn(h,o,c),Mn(o);const y=!u.getQueryCache().get(h.queryHash),[v]=ke.useState(()=>new e(u,h)),p=v.getOptimisticResult(h),x=!s&&t.subscribed!==!1;if(ke.useSyncExternalStore(ke.useCallback(_=>{const E=x?v.subscribe(ce.batchCalls(_)):ye;return v.updateResult(),E},[v,x]),()=>v.getCurrentResult(),()=>v.getCurrentResult()),ke.useEffect(()=>{v.setOptions(h)},[h,v]),Ln(h,p))throw ds(h,v,o);if(Bn({result:p,errorResetBoundary:o,throwOnError:h.throwOnError,query:c,suspense:h.suspense}))throw p.error;if((R=(C=u.getDefaultOptions().queries)==null?void 0:C._experimental_afterQuery)==null||R.call(C,h,p),h.experimental_prefetchInRender&&!kt&&Dn(p,s)){const _=y?ds(h,v,o):c==null?void 0:c.promise;_==null||_.catch(ye).finally(()=>{v.updateResult()})}return h.notifyOnChangeProps?p:v.trackResult(p)}function Bs(t,e){return Un(t,vn)}const Wn=()=>`bob_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;function As({ga4Config:t,hostContext:e,callbacks:r,enabled:s=!0}){const o=d.useRef(Wn()),u=d.useRef(!1),h=d.useCallback((l,f)=>{if(!(!(t!=null&&t.measurementId)||typeof window>"u")&&window.gtag){const b={...f,send_to:t.measurementId};t.debug&&console.log("[BobAnalytics] GA4 event:",l,b),window.gtag("event",l,b)}},[t]),c=d.useCallback((l,f={})=>{var S,O,B,M,k,N,T,D;if(!s)return;const b={event_name:l,timestamp:new Date().toISOString(),session_id:o.current,user_email:(S=e==null?void 0:e.user)==null?void 0:S.email,user_id:(O=e==null?void 0:e.user)==null?void 0:O.id,vehicle_id:(k=(M=(B=e==null?void 0:e.vehicle)==null?void 0:B.selectedVehicle)==null?void 0:M.vehicle_id)==null?void 0:k.toString(),rego:(T=(N=e==null?void 0:e.vehicle)==null?void 0:N.selectedVehicle)==null?void 0:T.rego,parameters:f};h(l,{session_id:b.session_id,user_email:b.user_email,vehicle_id:b.vehicle_id,...f}),(D=r==null?void 0:r.onAnalyticsEvent)==null||D.call(r,b),t!=null&&t.debug&&console.log("[BobAnalytics] Event tracked:",b)},[s,e,r,h,t==null?void 0:t.debug]),y=d.useCallback(()=>{var l,f,b;u.current||(u.current=!0,c("bob_session_start",{widget_version:zt,has_vehicle:!!((l=e==null?void 0:e.vehicle)!=null&&l.selectedVehicle),has_user:!!((f=e==null?void 0:e.user)!=null&&f.id)||!!((b=e==null?void 0:e.user)!=null&&b.email)}))},[c,e]),v=d.useCallback((l,f)=>{c("bob_message_sent",{message_length:l,has_vehicle:f})},[c]),p=d.useCallback(l=>{c("bob_vehicle_identified",{vehicle_make:l.make||"unknown",vehicle_model:l.model||"unknown",vehicle_year:l.year||"unknown",rego:l.rego})},[c]),x=d.useCallback((l,f)=>{c("bob_parts_viewed",{part_count:l,vehicle_id:f})},[c]),g=d.useCallback(l=>{c("bob_product_clicked",{sku:l.sku,product_name:l.product_name,price:l.price,brand:l.brand})},[c]),j=d.useCallback(l=>{c("bob_product_viewed",{sku:l.sku,product_name:l.product_name,price:l.price,brand:l.brand})},[c]),C=d.useCallback(l=>{c("bob_add_to_cart",{sku:l.sku,product_name:l.product_name,price:l.price,brand:l.brand,quantity:l.quantity??1})},[c]),R=d.useCallback((l,f)=>{c("bob_checkout_started",{cart_value:l,item_count:f})},[c]),_=d.useCallback(l=>{const f=Math.ceil(l/5/150*60);c("bob_speech_played",{text_length:l,duration_estimate:f})},[c]),E=d.useCallback(l=>{c("bob_speech_failed",{text_length:l})},[c]),m=d.useCallback((l,f)=>{c("bob_error",{error_type:l,error_message:f})},[c]);return d.useEffect(()=>{y()},[y]),{trackEvent:c,sessionId:o.current,trackSessionStart:y,trackMessageSent:v,trackVehicleIdentified:p,trackPartsViewed:x,trackProductClicked:g,trackProductViewed:j,trackAddToCart:C,trackCheckoutStarted:R,trackSpeechPlayed:_,trackSpeechFailed:E,trackError:m}}const Wr=d.createContext(null);function Ds({children:t,bobConfig:e,hostApiConfig:r,hostContext:s={},callbacks:o={},queryClient:u,ga4Config:h,analyticsEnabled:c=!0,bottomOffset:y=0,zIndexBase:v=50}){const p=d.useMemo(()=>new Cn({defaultOptions:{queries:{retry:1,staleTime:3e5}}}),[]),x=u||p,g=!!u;d.useEffect(()=>{console.log(`[BobWidget] v${zt} initialized`),console.log(`[BobWidget] QueryClient: ${g?"external (shared)":"internal"}`),console.log(`[BobWidget] Analytics: ${c?"enabled":"disabled"}`),h!=null&&h.measurementId&&console.log(`[BobWidget] GA4: ${h.measurementId}`)},[g,c,h==null?void 0:h.measurementId]);const j=d.useMemo(()=>Zs.createClient(e.supabaseUrl,e.supabaseKey),[e.supabaseUrl,e.supabaseKey]),[C,R]=d.useState(s);d.useEffect(()=>{R(s)},[s]);const _=d.useCallback(m=>{R(l=>({...l,...m}))},[]),E=d.useMemo(()=>({bobSupabase:j,bobConfig:e,hostApiConfig:r,hostContext:C,callbacks:o,updateHostContext:_,ga4Config:h,analyticsEnabled:c,bottomOffset:y,zIndexBase:v}),[j,e,r,C,o,_,h,c,y,v]);return n.jsx(Tn,{client:x,children:n.jsx(Wr.Provider,{value:E,children:t})})}function $e(){const t=d.useContext(Wr);if(!t)throw new Error("useBobContext must be used within a BobProvider");return t}function qr(){const{bobSupabase:t}=$e();return t}function qn(){const{hostContext:t}=$e();return t}function $n(){const{hostApiConfig:t}=$e();return t}function Qn(){const{callbacks:t}=$e();return t}function Vn(){const{ga4Config:t,analyticsEnabled:e}=$e();return{ga4Config:t,enabled:e}}function $r(){const t=d.useContext(Wr);return t?{bottomOffset:t.bottomOffset,zIndexBase:t.zIndexBase}:{bottomOffset:0,zIndexBase:50}}const hs=8e3,Ls=({onStart:t,onEnd:e,onFailed:r}={})=>{const{bobConfig:s}=$e(),[o,u]=d.useState(!1),h=d.useRef(null),c=d.useRef(null),y=d.useRef(!1),v=d.useRef(t),p=d.useRef(e),x=d.useRef(r);d.useEffect(()=>{v.current=t,p.current=e,x.current=r},[t,e,r]);const g=d.useCallback(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]),j=d.useCallback(()=>{var m;y.current||(y.current=!0,console.log("[BobWidget TTS] Fallback: triggering onStart without audio"),(m=v.current)==null||m.call(v))},[]),C=d.useCallback(async m=>{var l,f,b;if(m.trim()){y.current=!1,g(),h.current&&(h.current.pause(),h.current=null),c.current=setTimeout(()=>{var S,O;console.warn("[BobWidget TTS] Timeout after 5s - triggering fallback callbacks"),j(),u(!1),(S=p.current)==null||S.call(p),(O=x.current)==null||O.call(x),h.current=null},hs);try{const S=new AbortController,O=setTimeout(()=>S.abort(),hs-1e3),B=await fetch(`${s.supabaseUrl}/functions/v1/bob-tts`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s.supabaseKey}`},body:JSON.stringify({text:m}),signal:S.signal});if(clearTimeout(O),!B.ok){const N=await B.json().catch(()=>({}));throw console.error("[BobWidget TTS] Request failed:",N),new Error("TTS request failed")}const{audioContent:M}=await B.json(),k=new Audio(`data:audio/mp3;base64,${M}`);h.current=k,k.onplay=()=>{var N;g(),y.current||(y.current=!0,u(!0),console.log("[BobWidget TTS] Audio playing, triggering onStart"),(N=v.current)==null||N.call(v))},k.onended=()=>{var N;g(),u(!1),(N=p.current)==null||N.call(p),h.current=null},k.onerror=N=>{var T,D;g(),console.warn("[BobWidget TTS] Audio playback error:",N),j(),u(!1),(T=p.current)==null||T.call(p),(D=x.current)==null||D.call(x),h.current=null};try{await k.play()}catch(N){console.warn("[BobWidget TTS] Audio play() failed (autoplay policy), will retry on user interaction:",N),g(),j(),u(!1),(l=p.current)==null||l.call(p)}}catch(S){g(),console.error("[BobWidget TTS] Speech synthesis error:",S),j(),u(!1),(f=p.current)==null||f.call(p),(b=x.current)==null||b.call(x)}}},[s.supabaseUrl,s.supabaseKey,g,j]),R=d.useCallback(()=>{g(),h.current&&(h.current.pause(),h.current=null),u(!1)},[g]),_=d.useCallback(()=>{var m;(m=h.current)==null||m.pause()},[]),E=d.useCallback(()=>{var m;(m=h.current)==null||m.play()},[]);return d.useEffect(()=>()=>{g(),h.current&&(h.current.pause(),h.current=null)},[g]),{speak:C,stop:R,pause:_,resume:E,isSpeaking:o,isSupported:!0}},zn=["what version","which version","software version","bob version","your version","current version","running version","version number","what ver","which ver"],fs=["recommend","suggest","need","part","filter","brake","rotor","oil","price","$","stock","available","pads","disc","spark plug","battery","clutch","alternator","starter","muffler","exhaust","service pack","add-on","tyre shine","windscreen wash"],Kn=["WIPER BLADE FRONT","WIPER BLADE REAR","WIPER BLADE SET","BRAKE PAD KIT","BRAKE PAD KIT FRONT","BRAKE PAD KIT REAR","BRAKE ROTOR","BRAKE ROTOR FRONT","BRAKE ROTOR REAR","BRAKE DISC","AIR FILTER","OIL FILTER","CABIN FILTER","FUEL FILTER","SPARK PLUG SET","SPARK PLUG","BALL JOINT","TIE ROD END","CONTROL ARM","WHEEL BEARING","CV JOINT","DRIVE SHAFT","TIMING BELT KIT","SERPENTINE BELT","DRIVE BELT","SHOCK ABSORBER","STRUT","COIL SPRING","CLUTCH KIT","CLUTCH PLATE","ALTERNATOR","STARTER MOTOR","WATER PUMP","THERMOSTAT","RADIATOR","RADIATOR HOSE","EXHAUST","MUFFLER","CATALYTIC CONVERTER","brake pads","brake rotors","brake discs","brakes","air filter","oil filter","cabin filter","fuel filter","spark plugs","spark plug","wiper","wipers","battery","batteries","clutch","clutch kit","alternator","starter motor","muffler","exhaust","cv joint","axle","timing belt","serpentine belt","shock absorber","struts","suspension"],Us=({setAnimationState:t,manualMode:e=!1,talkingState:r="talk",thinkingState:s="research",completeState:o="complete",idleState:u="idle",listenState:h="talk_pause",onStreamStart:c,onStreamComplete:y,onShowingProduct:v,onResearchStart:p,onReadyToSpeak:x,onHighlightPart:g,onHighlightProduct:j,onNoPartsFound:C,onAutoFetchComplete:R})=>{var Ke,Ht,Gt,ut;const{bobConfig:_,hostApiConfig:E,hostContext:m,callbacks:l,ga4Config:f,analyticsEnabled:b}=$e(),S=As({ga4Config:f,hostContext:m,callbacks:l,enabled:b}),[O,B]=d.useState([]),[M,k]=d.useState(""),[N,T]=d.useState(!1),[D,F]=d.useState(!1),[$,J]=d.useState(null),se=d.useRef(null),ue=d.useRef(!1),Re=d.useRef(!1),U=d.useRef(""),G=d.useRef(!1),ne=d.useRef(null),Le=()=>{ne.current&&(clearTimeout(ne.current),ne.current=null)},{speak:Z,stop:Qe,isSpeaking:ct}=Ls({onStart:()=>{Le(),G.current=!0,console.log("[BobWidget] Speech started - revealing products"),S.trackSpeechPlayed(U.current.length),x==null||x(),e||de(r)},onEnd:()=>{Le();const W=fs.some(oe=>U.current.toLowerCase().includes(oe.toLowerCase()));e||(W&&v?v():y?y():(de(o),setTimeout(()=>de(h),3e3)))},onFailed:()=>{console.warn("[BobWidget] Speech synthesis failed - fallback triggered"),S.trackSpeechFailed(U.current.length)}});d.useEffect(()=>{var W;(W=se.current)==null||W.scrollIntoView({behavior:"smooth"})},[O]),d.useEffect(()=>{var oe,ae;const W=(oe=m.vehicle)==null?void 0:oe.selectedVehicle;W&&!$&&(console.log("[BobWidget] Setting vehicle from host context:",W),J(W),(ae=l.onVehicleIdentified)==null||ae.call(l,W),S.trackVehicleIdentified({make:W.make,model:W.model,year:W.year,rego:W.rego}))},[(Ke=m.vehicle)==null?void 0:Ke.selectedVehicle]),d.useEffect(()=>{var W;if(O.length===0&&!Re.current){Re.current=!0;const oe=(W=m.vehicle)==null?void 0:W.selectedVehicle;let ae;oe?ae=`G'day! Saw you've got the ${`${oe.year} ${oe.make} ${oe.model}`} - choice wagon! What can I help you find for it today?`:ae="G'day! Bob from CARFIX here. How can I help ya today?",B([{role:"assistant",content:ae}]),D||setTimeout(()=>{console.log("[BobWidget] Speaking initial greeting"),Z(ae)},800)}},[(Ht=m.vehicle)==null?void 0:Ht.selectedVehicle,O.length,D,Z]),d.useEffect(()=>{var Ge,Ye;const W=(Ge=m.vehicle)==null?void 0:Ge.selectedVehicle;if(!W||ue.current)return;const oe=W.vehicle_id??W.id,ae=Number.parseInt(String(oe),10);if(!Number.isFinite(ae)){console.warn("[BobWidget] Vehicle has invalid vehicle_id, cannot auto-fetch:",W);return}ue.current=!0;const me={...W,vehicle_id:String(ae)},He=(Ye=m.user)==null?void 0:Ye.email;(async()=>{var Je,Xe;const _t=`${_.supabaseUrl}/functions/v1/bob-chat`;try{const _e=await fetch(_t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${_.supabaseKey}`},body:JSON.stringify({messages:[],vehicleContext:me,customerEmail:He,autoFetchParts:!0,hostConfig:E,hostContext:m})});if(!_e.ok||!_e.body){console.error("[BobWidget] Auto-fetch failed:",_e.status);return}const Ct=_e.body.getReader(),Tt=new TextDecoder;let Ie="";for(;;){const{done:Ot,value:Ce}=await Ct.read();if(Ot)break;Ie+=Tt.decode(Ce,{stream:!0});let he;for(;(he=Ie.indexOf(`
31
+ `))!==-1;){let ve=Ie.slice(0,he);if(Ie=Ie.slice(he+1),ve.endsWith("\r")&&(ve=ve.slice(0,-1)),ve.startsWith(":")||ve.trim()===""||!ve.startsWith("data: "))continue;const dt=ve.slice(6).trim();if(dt==="[DONE]")break;try{const ee=JSON.parse(dt);ee.type==="service_packages_found"&&ee.packages&&((Je=l.onServicePackagesFound)==null||Je.call(l,ee.packages)),ee.type==="parts_found"&&ee.parts&&((Xe=l.onPartsFound)==null||Xe.call(l,ee.parts),S.trackPartsViewed(Array.isArray(ee.parts)?ee.parts.length:0,String(ae)))}catch{}}}R==null||R()}catch(_e){console.error("[BobWidget] Auto-fetch error:",_e)}})()},[(Gt=m.vehicle)==null?void 0:Gt.selectedVehicle,(ut=m.user)==null?void 0:ut.email]);const de=W=>{try{t(W)}catch{console.warn(`[BobWidget] State "${W}" not available`)}},Ve=async W=>{var me,He,Rt,Ge,Ye,_t,Je,Xe,_e,Ct,Tt,Ie,Ot;const oe=`${_.supabaseUrl}/functions/v1/bob-chat`,ae=(me=m.user)==null?void 0:me.email;try{const Ce={messages:[...O,W],hostConfig:E,hostContext:m};$&&(Ce.vehicleContext=$),ae&&(Ce.customerEmail=ae);const he=await fetch(oe,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${_.supabaseKey}`},body:JSON.stringify(Ce)});if(!he.ok){if(he.status===429){(He=l.onError)==null||He.call(l,new Error("Rate limit exceeded"));return}if(he.status===402){(Rt=l.onError)==null||Rt.call(l,new Error("Payment required"));return}throw new Error("Failed to start stream")}if(!he.body)throw new Error("No response body");const ve=he.body.getReader(),dt=new TextDecoder;let ee="",It=!1,Pe="";for(;!It;){const{done:Ne,value:Ze}=await ve.read();if(Ne)break;ee+=dt.decode(Ze,{stream:!0});let Pt;for(;(Pt=ee.indexOf(`
32
+ `))!==-1;){let Fe=ee.slice(0,Pt);if(ee=ee.slice(Pt+1),Fe.endsWith("\r")&&(Fe=Fe.slice(0,-1)),Fe.startsWith(":")||Fe.trim()===""||!Fe.startsWith("data: "))continue;const hr=Fe.slice(6).trim();if(hr==="[DONE]"){It=!0;break}try{const X=JSON.parse(hr);if(X.type==="vehicle_identified"&&X.vehicle){J(X.vehicle),(Ge=l.onVehicleIdentified)==null||Ge.call(l,X.vehicle),S.trackVehicleIdentified({make:X.vehicle.make,model:X.vehicle.model,year:X.vehicle.year,rego:X.vehicle.rego});continue}if(X.type==="service_packages_found"&&X.packages){(Ye=l.onServicePackagesFound)==null||Ye.call(l,X.packages);continue}if(X.type==="parts_found"&&X.parts){(_t=l.onPartsFound)==null||_t.call(l,X.parts),S.trackPartsViewed(Array.isArray(X.parts)?X.parts.length:0,(Je=$==null?void 0:$.vehicle_id)==null?void 0:Je.toString());continue}if(X.type==="no_parts_found"){C==null||C();continue}if(X.type==="cart_updated"&&X.items){(Xe=l.onCartUpdated)==null||Xe.call(l,X.items);continue}const Xt=(Tt=(Ct=(_e=X.choices)==null?void 0:_e[0])==null?void 0:Ct.delta)==null?void 0:Tt.content;if(Xt){Pe+=Xt;const Zt=Pe.replace(/\[VEHICLE_CONFIRMED:\{[\s\S]*?\}\]/g,"");B(ht=>{const er=ht[ht.length-1];return(er==null?void 0:er.role)==="assistant"?ht.map((fr,i)=>i===ht.length-1?{...fr,content:Zt}:fr):[...ht,{role:"assistant",content:Zt}]}),(Ie=l.onBobMessage)==null||Ie.call(l,Zt)}}catch{ee=Fe+`
33
+ `+ee;break}}}U.current=Pe.replace(/\[VEHICLE_CONFIRMED:\{[\s\S]*?\}\]/g,"");const Yt=fs.some(Ne=>Pe.toLowerCase().includes(Ne.toLowerCase())),yr=Pe.toLowerCase();for(const Ne of Kn)if(yr.includes(Ne.toLowerCase())){const Ze=Ne.replace(/s\s*$/i,"").toUpperCase();g==null||g(Ze);break}const Jt=Pe.match(/(?:go with|recommend|suggest|grab|try)\s+(?:the\s+)?(\w+)\s+(?:at|for)\s+\$(\d+(?:\.\d{2})?)/i);if(Jt){const[,Ne,Ze]=Jt;j==null||j({brand:Ne,price:parseFloat(Ze)})}!D&&U.current.trim()?(G.current=!1,Le(),Z(U.current),ne.current=setTimeout(()=>{G.current||(console.warn("[BobWidget] Speech fallback after 2s"),x==null||x(),e||(Yt&&v?v():y?y():(de(o),setTimeout(()=>de(h),3e3))))},2e3)):(x==null||x(),e||(Yt&&v?v():y?y():(de(o),setTimeout(()=>de(h),3e3))))}catch(Ce){console.error("[BobWidget] Chat error:",Ce);const he=Ce instanceof Error?Ce:new Error("Unknown error");(Ot=l.onError)==null||Ot.call(l,he),S.trackError(he.name||"ChatError",he.message||"Unknown chat error"),e||de(u)}},ze=async()=>{if(!M.trim()||N)return;Qe();const W={role:"user",content:M};B(me=>[...me,W]),k(""),S.trackMessageSent(M.length,!!$);const oe=M.toLowerCase();if(zn.some(me=>oe.includes(me))){const me=`G'day mate! I'm running Bob v${zt} - she's running sweet as! Anything else I can help ya with?`;B(He=>[...He,{role:"assistant",content:me}]),D||Z(me);return}T(!0),p==null||p(),e||de(s),await Ve(W),T(!1)};return{messages:O,input:M,setInput:k,isLoading:N,handleSend:ze,handleKeyPress:W=>{W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),ze())},handleInputFocus:()=>{},handleInputBlur:()=>{},chatEndRef:se,clearMessages:()=>{B([{role:"assistant",content:"G'day! Bob from CARFIX here. How can I help ya today?"}])},isMuted:D,toggleMute:()=>{F(W=>!W),D||Qe()},isSpeaking:ct,identifiedVehicle:$,clearVehicle:()=>{J(null)}}},Ws=t=>{const e=Fs(),r=qr();return d.useEffect(()=>{const s=r.channel("animation-states-changes").on("postgres_changes",{event:"*",schema:"public",table:"animation_states"},()=>{e.invalidateQueries({queryKey:["bob-animation-data"]})}).subscribe(),o=r.channel("bob-animations-changes").on("postgres_changes",{event:"*",schema:"public",table:"bob_animations"},()=>{e.invalidateQueries({queryKey:["bob-animation-data"]})}).subscribe();return()=>{r.removeChannel(s),r.removeChannel(o)}},[e,r]),Bs({queryKey:["bob-animation-data",t],queryFn:async()=>{var _;const{data:s,error:o}=await r.from("bob_looks").select("*").order("display_order");if(o)throw o;const u=(s||[]).find(E=>E.is_active),h=t||(u==null?void 0:u.id)||s&&((_=s[0])==null?void 0:_.id)||null;if(!h)return{states:[],configs:[],uploadedImages:[],looks:s||[],activeLookId:null};const{data:c,error:y}=await r.from("animation_states").select("*").eq("is_active",!0).eq("look_id",h).order("display_order");if(y)throw y;const{data:v,error:p}=await r.from("bob_animations").select("*").eq("is_active",!0).eq("look_id",h).order("animation_state").order("sequence_order");if(p)throw p;const x=new Set((c||[]).map(E=>E.state_key)),g=(v||[]).filter(E=>x.has(E.animation_state)),{data:j,error:C}=await r.storage.from("bob-images").list();if(C)throw C;const R=(j||[]).map(E=>{const{data:m}=r.storage.from("bob-images").getPublicUrl(E.name);return m.publicUrl});return g.forEach(E=>{const m=new Image;m.src=E.image_url}),{states:c||[],configs:g,uploadedImages:R,looks:s||[],activeLookId:h}},staleTime:30*1e3,gcTime:5*60*1e3})},qs=()=>{const[t,e]=d.useState(""),[r,s]=d.useState(0),[o,u]=d.useState(400),[h,c]=d.useState(!1),y=d.useRef(),{data:v,isLoading:p}=Ws(),x=d.useRef({}),{imageUrlsMap:g,alternateImages:j,offsetsMap:C,scalesMap:R,availableStates:_}=d.useMemo(()=>{if(!v)return{imageUrlsMap:{},alternateImages:{},offsetsMap:{},scalesMap:{},availableStates:[]};const f={},b={},S={},O={},B=v.states.map(M=>M.state_key);return B.forEach(M=>{const k=v.configs.filter(F=>F.animation_state===M),N=k.map(F=>F.image_url),T=k.map(F=>F.vertical_offset||0),D=k.map(F=>F.scale||100);if(N.length>0){const F=v.states.find($=>$.state_key===M);f[M]={url:N[0],animation_speed:(F==null?void 0:F.animation_speed)||400,pause_duration:(F==null?void 0:F.pause_duration)||0,loop_count:(F==null?void 0:F.loop_count)||0},b[M]=N,S[M]=T,O[M]=D}}),{imageUrlsMap:f,alternateImages:b,offsetsMap:S,scalesMap:O,availableStates:B}},[v]);return d.useEffect(()=>{x.current=g},[g]),d.useEffect(()=>{_.length>0&&!t&&e(_[0])},[_,t]),d.useEffect(()=>{const f=j[t];if(y.current&&clearInterval(y.current),f&&f.length>1){s(0);const b=x.current[t],S=(b==null?void 0:b.animation_speed)||o||400,O=(b==null?void 0:b.loop_count)||0,B=(b==null?void 0:b.pause_duration)||0;let M=0,k=!1;const N=()=>{y.current=setInterval(()=>{k||s(T=>{const D=(T+1)%f.length;return D===0&&(M++,O>0&&M>=O)?(clearInterval(y.current),B>0&&(k=!0,setTimeout(()=>{M=0,k=!1,N()},B)),T):D})},S)};N()}else s(0);return()=>{y.current&&clearInterval(y.current)}},[t,j]),{animationState:t,setAnimationState:e,getCurrentImage:()=>{const f=j[t];if(!f||f.length===0){const b=_.find(S=>{var O;return((O=j[S])==null?void 0:O.length)>0});return b?j[b][0]:""}return f[r]||f[0]},getCurrentOffset:()=>{const f=C[t];if(!f||f.length===0){const b=_.find(S=>{var O;return((O=C[S])==null?void 0:O.length)>0});return b?C[b][0]:0}return f[r]||f[0]},getCurrentScale:()=>{const f=R[t];if(!f||f.length===0){const b=_.find(S=>{var O;return((O=R[S])==null?void 0:O.length)>0});return b?R[b][0]:100}return f[r]||f[0]},imageUrls:g,availableStates:_,setTalkSpeed:u,manualMode:h,setManualMode:c,isLoading:p}},$s=()=>{const t=qr(),{data:e=[],isLoading:r}=Bs({queryKey:["bob-backdrops"],queryFn:async()=>{const{data:o,error:u}=await t.from("bob_backdrops").select("*").order("display_order",{ascending:!0});if(u)throw u;return o},staleTime:5*60*1e3,gcTime:10*60*1e3}),s=e.find(o=>o.is_active);return{backdrops:e,activeBackdrop:s,isLoading:r}},Qs=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:s,counterHeightPercent:o=12,className:u="",verticalOffset:h=0,scale:c=100})=>{const y=h+o,v=55*(c/100);return n.jsx("div",{className:`flex flex-col items-center justify-center gap-6 w-full ${u}`,children:n.jsxs("div",{className:"relative w-full max-w-[600px] mx-auto aspect-[16/10] overflow-hidden",children:[r&&n.jsx("img",{src:r,alt:"Backdrop",className:"absolute inset-0 z-0 w-full h-full object-cover object-bottom"}),n.jsx("img",{src:t,alt:`Bob ${e}`,className:"absolute z-10 h-auto object-contain left-1/2 -translate-x-1/2",style:{bottom:`${y}%`,width:`${v}%`,maxWidth:`${220*(c/100)}px`,transformOrigin:"center bottom"}}),s&&n.jsx("img",{src:s,alt:"Counter",className:"absolute z-20 bottom-0 left-0 w-full object-cover object-bottom",style:{height:`${o}%`}})]})})},Vs=({messages:t,input:e,setInput:r,isLoading:s,onSend:o,onKeyPress:u,onInputFocus:h,onInputBlur:c,chatEndRef:y,isMuted:v=!1,onToggleMute:p,isSpeaking:x=!1,className:g=""})=>n.jsx("div",{className:g,style:{width:"100%",maxWidth:"72rem",margin:"0 auto",padding:"0 16px 32px 16px"},children:n.jsxs("div",{style:{backgroundColor:"white",border:"1px solid #e5e7eb",borderRadius:"8px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",overflow:"hidden"},children:[n.jsx("div",{style:{padding:"16px",borderBottom:"1px solid #e5e7eb",backgroundColor:"#f9fafb"},children:n.jsxs("div",{style:{display:"flex",gap:"8px"},children:[n.jsx("input",{value:e,onChange:j=>r(j.target.value),onKeyPress:u,onFocus:h,onBlur:c,placeholder:"Ask Bob about car parts...",disabled:s,style:{flex:1,padding:"8px 16px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",color:"#111827",fontSize:"16px",outline:"none"}}),p&&n.jsx("button",{onClick:p,style:{flexShrink:0,padding:"8px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",cursor:"pointer",minHeight:"unset",minWidth:"unset"},title:v?"Unmute Bob's voice":"Mute Bob's voice",children:v?"🔇":"🔊"}),n.jsx("button",{onClick:o,disabled:s||!e.trim(),style:{flexShrink:0,padding:"8px 16px",backgroundColor:s||!e.trim()?"#93c5fd":"#2563eb",color:"white",borderRadius:"6px",border:"none",cursor:s||!e.trim()?"not-allowed":"pointer",opacity:s||!e.trim()?.5:1,minHeight:"unset",minWidth:"unset"},children:"Send"})]})}),n.jsxs("div",{style:{overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"12px",height:"400px"},children:[[...t].reverse().map((j,C)=>n.jsx("div",{style:{display:"flex",justifyContent:j.role==="user"?"flex-end":"flex-start"},children:n.jsx("div",{style:{maxWidth:"80%",borderRadius:"8px",padding:"8px 16px",fontSize:"14px",backgroundColor:j.role==="user"?"#2563eb":"#f3f4f6",color:j.role==="user"?"white":"#111827"},children:j.content})},C)),n.jsx("div",{ref:y})]})]})}),Qr=({currentImage:t,animationState:e,counterOverlayUrl:r,counterHeightPercent:s=15,scale:o=100,position:u="center",verticalOffset:h=0})=>{const c=65*o/100,y=320*o/100,v=u==="center"?"5%":"-25%",p=s-2+h;return n.jsxs("div",{className:"absolute inset-0 pointer-events-none overflow-hidden",children:[n.jsx("div",{className:"absolute left-0 z-40",style:{bottom:`${p}%`,maxHeight:`${100-s-5}%`,transform:`translateX(${v})`,width:`${c}%`,maxWidth:`${y}px`,transition:"transform 0.4s ease-out"},children:n.jsx("img",{src:t,alt:`Bob ${e}`,className:"w-full h-auto object-contain",style:{display:"block",maxHeight:"100%"}})}),r&&n.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-50",style:{height:`${s}%`,pointerEvents:"none"},children:n.jsx("img",{src:r,alt:"Shop counter",className:"w-full h-full object-cover object-top"})})]})},ps=(t,e)=>{if(!t||!e)return!1;const r=t.toLowerCase();return e.toLowerCase().replace(/s\b/g,"").split(/\s+/).filter(Boolean).every(o=>r.includes(o))},Hn=(t,e)=>{var o;const r=((o=t.brand)==null?void 0:o.toLowerCase())===e.brand.toLowerCase(),s=Math.abs(t.price-e.price)<1;return r&&s},Gn=({product:t,isSpotlighted:e,spotlightedRef:r,onProductClick:s})=>n.jsxs("div",{ref:e?r:void 0,onClick:()=>s==null?void 0:s(t),className:`md:hidden cursor-pointer active:scale-[0.98] transition-all duration-200 bg-white rounded-xl border relative overflow-hidden ${e?"ring-2 ring-blue-500 shadow-lg border-blue-200":"border-gray-100 shadow-md"}`,style:{backgroundColor:"white",borderRadius:"12px",border:e?"1px solid #bfdbfe":"1px solid #f3f4f6",boxShadow:e?"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)":"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"},children:[e&&n.jsx(Vr,{}),n.jsx("div",{className:"aspect-[16/10] bg-gradient-to-br from-gray-50 to-gray-100 flex items-center justify-center overflow-hidden",children:t.image_url?n.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-2"}):n.jsx(zr,{size:"sm"})}),n.jsxs("div",{className:"p-2.5",children:[n.jsx("p",{className:"text-sm font-semibold text-gray-900 line-clamp-1 mb-0.5",children:t.name}),t.brand&&n.jsx("p",{className:"text-xs text-gray-500 mb-1.5",children:t.brand}),n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("span",{className:"text-base font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"POA"}),n.jsx("button",{className:"bg-blue-600 text-white text-xs font-semibold px-3 py-1.5 rounded-lg hover:bg-blue-700 active:bg-blue-800 transition-colors",onClick:o=>{o.stopPropagation(),s==null||s(t)},children:"View"})]})]})]}),Yn=({product:t,isSpotlighted:e,spotlightedRef:r,onProductClick:s})=>n.jsxs("div",{ref:e?r:void 0,onClick:()=>s==null?void 0:s(t),className:`hidden md:block lg:hidden cursor-pointer transition-all duration-300 bg-white rounded-2xl border relative overflow-hidden hover:shadow-xl hover:scale-[1.02] hover:-translate-y-1 ${e?"ring-2 ring-blue-500 shadow-xl border-blue-200":"border-gray-100 shadow-lg"}`,children:[e&&n.jsx(Vr,{}),n.jsx("div",{className:"aspect-[4/3] bg-gradient-to-br from-gray-50 to-gray-100 flex items-center justify-center overflow-hidden",children:t.image_url?n.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-4"}):n.jsx(zr,{size:"md"})}),n.jsxs("div",{className:"p-4",children:[n.jsx("p",{className:"text-base font-semibold text-gray-900 line-clamp-2 mb-1",children:t.name}),t.brand&&n.jsxs("p",{className:"text-sm text-gray-600 font-medium mb-2 flex items-center gap-1",children:[n.jsx("span",{className:"w-1.5 h-1.5 bg-blue-500 rounded-full"}),t.brand]}),n.jsx("div",{className:"flex items-center justify-between",children:n.jsx("span",{className:"text-xl font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"POA"})}),n.jsx("button",{className:"mt-3 w-full bg-gradient-to-r from-blue-600 to-blue-500 text-white text-sm font-semibold py-2.5 rounded-xl hover:from-blue-700 hover:to-blue-600 active:from-blue-800 active:to-blue-700 transition-all shadow-md",onClick:o=>{o.stopPropagation(),s==null||s(t)},children:"View Details"})]})]}),Jn=({product:t,isSpotlighted:e,spotlightedRef:r,onProductClick:s})=>n.jsxs("div",{ref:e?r:void 0,onClick:()=>s==null?void 0:s(t),className:`hidden lg:flex flex-row cursor-pointer transition-all duration-300 bg-white rounded-2xl border relative overflow-hidden hover:shadow-2xl hover:scale-[1.01] hover:-translate-y-0.5 group ${e?"ring-2 ring-blue-500 shadow-xl border-blue-200":"border-gray-100 shadow-lg"}`,style:{minHeight:"140px"},children:[e&&n.jsx(Vr,{variant:"horizontal"}),n.jsx("div",{className:"w-36 shrink-0 bg-gradient-to-br from-gray-50 to-gray-100 flex items-center justify-center overflow-hidden",children:t.image_url?n.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-3 group-hover:scale-105 transition-transform duration-300"}):n.jsx(zr,{size:"lg"})}),n.jsxs("div",{className:"flex-1 p-4 flex flex-col justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-base font-semibold text-gray-900 line-clamp-2 mb-1 group-hover:text-blue-700 transition-colors",children:t.name}),t.brand&&n.jsx("div",{className:"flex items-center gap-2 mb-2",children:n.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-gray-600 bg-gray-100 px-2 py-0.5 rounded-full",children:[n.jsx("svg",{className:"w-3 h-3 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20",children:n.jsx("path",{fillRule:"evenodd",d:"M6.267 3.455a3.066 3.066 0 001.745-.723 3.066 3.066 0 013.976 0 3.066 3.066 0 001.745.723 3.066 3.066 0 012.812 2.812c.051.643.304 1.254.723 1.745a3.066 3.066 0 010 3.976 3.066 3.066 0 00-.723 1.745 3.066 3.066 0 01-2.812 2.812 3.066 3.066 0 00-1.745.723 3.066 3.066 0 01-3.976 0 3.066 3.066 0 00-1.745-.723 3.066 3.066 0 01-2.812-2.812 3.066 3.066 0 00-.723-1.745 3.066 3.066 0 010-3.976 3.066 3.066 0 00.723-1.745 3.066 3.066 0 012.812-2.812zm7.44 5.252a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),t.brand]})})]}),n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("span",{className:"text-2xl font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"POA"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{className:"px-4 py-2 border border-gray-200 text-gray-700 text-sm font-medium rounded-lg hover:bg-gray-50 hover:border-gray-300 transition-all opacity-0 group-hover:opacity-100",onClick:o=>{o.stopPropagation(),s==null||s(t)},children:"Details"}),n.jsx("button",{className:"px-4 py-2 bg-gradient-to-r from-blue-600 to-blue-500 text-white text-sm font-semibold rounded-lg hover:from-blue-700 hover:to-blue-600 transition-all shadow-md",onClick:o=>{o.stopPropagation(),s==null||s(t)},children:"View"})]})]})]})]}),Vr=({variant:t="default"})=>n.jsxs("span",{className:`absolute bg-gradient-to-r from-blue-600 to-blue-500 text-white text-xs px-2.5 py-1 rounded-full z-20 flex items-center gap-1 font-semibold shadow-md ${t==="horizontal"?"top-2 left-2":"top-3 right-3"}`,children:[n.jsx("svg",{className:"h-3 w-3",fill:"currentColor",viewBox:"0 0 20 20",children:n.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})}),"Bob's Pick"]}),zr=({size:t})=>{const e={sm:"h-8 w-8",md:"h-10 w-10",lg:"h-12 w-12"};return n.jsxs("div",{className:"flex flex-col items-center justify-center text-gray-400",children:[n.jsx("svg",{className:e[t],fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),n.jsx("span",{className:"text-xs font-medium uppercase tracking-wide mt-1",children:"No Image"})]})},Kr=({products:t,servicePackages:e,highlightedPartType:r,highlightedProduct:s,onProductClick:o,onPackageSelect:u,isResearching:h,visible:c=!0,counterHeightPercent:y=22,hasVehicle:v=!1})=>{const p=d.useRef(null),x=d.useRef({}),g=d.useRef(null),j=d.useMemo(()=>{const m={};return t.forEach(f=>{const b=f.partslotDescription||"Other Parts";m[b]||(m[b]=[]),m[b].push(f)}),Object.keys(m).sort((f,b)=>f.localeCompare(b)).map(f=>({name:f,products:m[f]}))},[t]);d.useEffect(()=>{var m;if(r){const l=j.find(f=>ps(f.name,r));l&&x.current[l.name]&&((m=x.current[l.name])==null||m.scrollIntoView({behavior:"smooth",block:"start"}))}},[r,j]),d.useEffect(()=>{s&&g.current&&g.current.scrollIntoView({behavior:"smooth",block:"center"})},[s]);const C=t.length>0||e.length>0,R=h,_=C&&!h,E=v?"56px":"8px";return n.jsxs("div",{ref:p,className:`absolute right-2 md:right-3 lg:right-4 w-[52%] md:w-[55%] lg:w-[58%] max-w-[280px] md:max-w-[400px] lg:max-w-[520px] overflow-y-auto overflow-x-hidden z-30 flex flex-col gap-3 md:gap-4 lg:gap-5 pb-4 transition-all duration-300 ease-out ${c?"opacity-100 translate-x-0":"opacity-0 translate-x-8 pointer-events-none"}`,style:{top:E,bottom:"calc(70px + env(safe-area-inset-bottom, 8px))",paddingTop:"env(safe-area-inset-top, 4px)"},children:[R&&n.jsx("div",{className:"rounded-xl bg-white/90 backdrop-blur-sm p-4 shadow-lg border border-gray-100",children:n.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-600",children:[n.jsx("div",{className:"w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full animate-spin"}),n.jsx("span",{className:"font-medium",children:"Finding parts..."})]})}),_&&e.length>0&&n.jsxs("div",{className:"space-y-2 md:space-y-3",children:[n.jsxs("div",{className:"text-xs font-bold text-blue-700 flex items-center gap-1.5 px-1 uppercase tracking-wide",children:[n.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})}),"Service Packages"]}),e.map(m=>n.jsxs("div",{onClick:()=>u==null?void 0:u(m),className:"cursor-pointer active:scale-[0.98] transition-all bg-white rounded-xl md:rounded-2xl border border-gray-100 p-3 md:p-4 shadow-md hover:shadow-lg md:hover:scale-[1.02]",children:[n.jsx("p",{className:"text-sm md:text-base font-semibold text-gray-900 line-clamp-2 mb-1",children:m.title}),n.jsxs("p",{className:"text-lg md:text-xl font-bold text-blue-600",children:["From $",m.from_price.toFixed(0)]})]},m.id))]}),_&&j.map(({name:m,products:l})=>{const f=r&&ps(m,r);return n.jsxs("section",{ref:b=>{x.current[m]=b},className:`rounded-xl md:rounded-2xl transition-all ${f?"ring-2 ring-blue-500 bg-blue-50/80 p-2 md:p-3 shadow-lg":""}`,children:[n.jsxs("h3",{className:"text-xs md:text-sm font-bold mb-2 md:mb-3 flex items-center gap-1.5 px-1 text-gray-800 uppercase tracking-wide",children:[n.jsx("svg",{className:"h-3.5 w-3.5 md:h-4 md:w-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})}),n.jsx("span",{className:"truncate",children:m}),n.jsxs("span",{className:"text-[10px] md:text-xs text-gray-500 font-medium",children:["(",l.length,")"]})]}),n.jsx("div",{className:"flex flex-col gap-3 md:grid md:grid-cols-2 md:gap-4 lg:flex lg:flex-col lg:gap-4",children:l.map((b,S)=>{const O=!!(s&&Hn(b,s));return n.jsxs(d.Fragment,{children:[n.jsx(Gn,{product:b,isSpotlighted:O,spotlightedRef:g,onProductClick:o}),n.jsx(Yn,{product:b,isSpotlighted:O,spotlightedRef:g,onProductClick:o}),n.jsx(Jn,{product:b,isSpotlighted:O,spotlightedRef:g,onProductClick:o})]},`${b.id}-${S}`)})})]},m)})]})},Hr=({onTranscript:t,onSpeechEnd:e,language:r="en-NZ",mode:s="toggle"}={})=>{const[o,u]=d.useState(!1),[h,c]=d.useState(""),[y,v]=d.useState(""),[p,x]=d.useState(null),[g,j]=d.useState(!1),C=d.useRef(null),R=d.useRef(""),_=d.useRef(t),E=d.useRef(e);d.useEffect(()=>{_.current=t,E.current=e},[t,e]),d.useEffect(()=>{const b=window.SpeechRecognition||window.webkitSpeechRecognition;if(b){j(!0);const S=new b;S.continuous=s==="ptt",S.interimResults=!0,S.lang=r,S.maxAlternatives=1,S.onstart=()=>{u(!0),x(null)},S.onresult=O=>{let B="",M="";for(let k=O.resultIndex;k<O.results.length;k++){const N=O.results[k][0].transcript;O.results[k].isFinal?M+=N:B+=N}M&&(R.current=M,c(M),_.current&&_.current(M)),v(B)},S.onerror=O=>{switch(u(!1),O.error){case"no-speech":x("No speech detected. Please try again.");break;case"audio-capture":x("No microphone found. Please check your device.");break;case"not-allowed":x("Microphone permission denied. Please allow access.");break;default:x("Speech recognition error. Please try again.")}},S.onend=()=>{u(!1),v(""),R.current&&E.current&&E.current(R.current),R.current=""},C.current=S}return()=>{C.current&&C.current.stop()}},[r,s]);const m=()=>{C.current&&!o&&(c(""),v(""),x(null),C.current.start())},l=()=>{C.current&&o&&C.current.stop()};return{isListening:o,transcript:h,interimTranscript:y,error:p,isSupported:g,startListening:m,stopListening:l,toggleListening:()=>{o?l():m()}}},zs=({messages:t,input:e,setInput:r,isLoading:s,onSend:o,onKeyPress:u,onInputFocus:h,onInputBlur:c,chatEndRef:y,isMuted:v=!1,onToggleMute:p,isSpeaking:x=!1})=>{const[g,j]=d.useState(!1),C=d.useRef(null),R=d.useRef(!1),{bottomOffset:_,zIndexBase:E}=$r(),{isListening:m,interimTranscript:l,error:f,isSupported:b,startListening:S,stopListening:O}=Hr({onTranscript:F=>r(F),language:"en-NZ",mode:"ptt"});d.useEffect(()=>{l&&r(l)},[l,r]);const B=d.useCallback(()=>{s||R.current||(R.current=!0,navigator.vibrate&&navigator.vibrate(30),S())},[s,S]),M=d.useCallback(()=>{R.current&&(R.current=!1,navigator.vibrate&&navigator.vibrate([20,50,20]),O(),setTimeout(()=>{o()},150))},[O,o]),k=[...t].reverse().find(F=>F.role==="assistant"),N=k!=null&&k.content?k.content.length>50?k.content.slice(0,50)+"...":k.content:"Ask Bob about car parts...",T={idle:{background:"#22c55e",border:"4px solid #1a1a1a",boxShadow:"6px 6px 0 #1a1a1a",transform:"translate(0, 0)"},active:{background:"#f59e0b",border:"4px solid #1a1a1a",boxShadow:"2px 2px 0 #1a1a1a",transform:"translate(4px, 4px)"},disabled:{background:"#9ca3af",border:"4px solid #6b7280",boxShadow:"4px 4px 0 #6b7280",transform:"translate(0, 0)"}},D=s?T.disabled:m?T.active:T.idle;return n.jsxs("div",{ref:C,style:{position:"fixed",bottom:`${_}px`,left:0,right:0,backgroundColor:"rgba(255, 255, 255, 0.95)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",borderTop:"1px solid #e5e7eb",transition:"all 0.3s ease-out",boxShadow:"0 -4px 20px rgba(0, 0, 0, 0.15)",height:g?"55vh":"auto",zIndex:E+10,paddingBottom:_>0?"8px":"env(safe-area-inset-bottom, 8px)"},children:[n.jsx("button",{onClick:()=>j(!g),style:{position:"absolute",top:"-20px",left:"50%",transform:"translateX(-50%)",backgroundColor:"white",border:"1px solid #e5e7eb",borderRadius:"9999px",padding:"6px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",zIndex:E+20,cursor:"pointer",minHeight:"unset",minWidth:"unset"},"aria-label":g?"Collapse chat":"Expand chat",children:g?n.jsx("svg",{style:{height:"16px",width:"16px",color:"#6b7280"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}):n.jsx("svg",{style:{height:"16px",width:"16px",color:"#6b7280"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),!g&&n.jsx("div",{onClick:()=>j(!0),style:{padding:"8px 12px 2px 12px",cursor:"pointer"},children:n.jsx("p",{style:{fontSize:"12px",color:"#6b7280",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N})}),g&&n.jsxs("div",{style:{height:"calc(100% - 100px)",overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"8px"},children:[[...t].reverse().map((F,$)=>n.jsx("div",{style:{display:"flex",justifyContent:F.role==="user"?"flex-end":"flex-start"},children:n.jsx("div",{style:{maxWidth:"85%",borderRadius:"8px",padding:"8px 12px",fontSize:"14px",backgroundColor:F.role==="user"?"#2563eb":"#f3f4f6",color:F.role==="user"?"white":"#111827"},children:F.content})},$)),n.jsx("div",{ref:y})]}),b&&n.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"12px 16px 8px 16px"},children:n.jsx("button",{onTouchStart:B,onTouchEnd:M,onTouchCancel:M,onMouseDown:B,onMouseUp:M,onMouseLeave:M,disabled:s,"aria-label":"Hold to talk to Bob",style:{width:"200px",height:"64px",minHeight:"unset",minWidth:"unset",borderRadius:"32px",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",touchAction:"none",cursor:s?"not-allowed":"pointer",opacity:s?.6:1,transition:"transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease",...D},title:"Hold to talk",children:n.jsx("span",{style:{fontSize:"24px",fontWeight:800,letterSpacing:"0.15em",color:"#1a1a1a",textTransform:"uppercase",fontFamily:"system-ui, -apple-system, sans-serif"},children:m?"LISTENING":"TALK"})})}),n.jsxs("div",{style:{padding:"4px 12px 8px 12px",borderTop:"1px solid #e5e7eb"},children:[f&&n.jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"#ef4444"},children:f}),n.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[p&&n.jsx("button",{onClick:p,style:{flexShrink:0,height:"40px",width:"40px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"8px",backgroundColor:"transparent",color:x?"#2563eb":"#4b5563",cursor:"pointer",border:"2px solid #d1d5db",minHeight:"unset",minWidth:"unset"},title:v?"Unmute":"Mute",children:v?n.jsxs("svg",{style:{height:"18px",width:"18px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"}),n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]}):n.jsx("svg",{style:{height:"18px",width:"18px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"})})}),n.jsx("input",{type:"text",value:e,onChange:F=>r(F.target.value),onKeyPress:u,onFocus:h,onBlur:c,placeholder:"Or type here...",disabled:s,style:{flex:1,height:"40px",fontSize:"16px",padding:"0 12px",border:"2px solid #d1d5db",borderRadius:"8px",backgroundColor:"white",color:"#111827",outline:"none",opacity:s?.5:1}})]})]})]})},Ks=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:s,counterHeightPercent:o=22,messages:u,input:h,setInput:c,isLoading:y,onSend:v,onKeyPress:p,onInputFocus:x,onInputBlur:g,chatEndRef:j,isMuted:C,onToggleMute:R,isSpeaking:_,products:E,servicePackages:m,highlightedPartType:l,highlightedProduct:f,onProductClick:b,onPackageSelect:S,isResearching:O,vehicle:B,onChangeVehicle:M,bobOffset:k=0,bobScale:N=100})=>{const T=typeof window<"u"&&window.self!==window.top,[D,F]=d.useState("center"),[$,J]=d.useState("hidden"),se=E.length>0||m.length>0,U=(D==="center"&&!se?200:130)*N/100;d.useEffect(()=>{if(O&&$!=="loading"&&$!=="visible")J("loading"),D==="center"&&F("left");else if(se&&$!=="visible")if(D==="center"){F("left"),J("transitioning");const ne=setTimeout(()=>{J("visible")},400);return()=>clearTimeout(ne)}else J("visible");else!se&&!O&&$!=="hidden"&&(J("hidden"),F("center"))},[se,O,$,D]);const G=$!=="hidden";return n.jsxs("div",{className:"fixed inset-0 overflow-hidden",style:{height:"100dvh",touchAction:"manipulation"},children:[r&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"absolute inset-0 z-0",style:{backgroundImage:`url(${r})`,backgroundSize:"cover",backgroundPosition:"center bottom",filter:"blur(12px) brightness(0.7)",transform:"scale(1.1)"}}),n.jsx("div",{className:"absolute inset-0 z-[1]",style:{background:"linear-gradient(to bottom, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.6) 100%)"}})]}),n.jsx(Qr,{currentImage:t,animationState:e,counterOverlayUrl:s,counterHeightPercent:o,scale:U,position:D,verticalOffset:k}),B&&!T&&n.jsx("div",{style:{position:"absolute",top:"8px",left:"8px",right:"8px",zIndex:20},children:n.jsxs("div",{style:{backgroundColor:"rgba(255, 255, 255, 0.9)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",borderRadius:"8px",padding:"8px 12px",paddingTop:"calc(env(safe-area-inset-top, 4px) + 8px)",border:"1px solid #e5e7eb",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("p",{style:{fontSize:"12px",fontWeight:500,color:"#111827",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[B.year," ",B.make," ",B.model]}),B.rego&&n.jsx("p",{style:{fontSize:"10px",color:"#6b7280"},children:B.rego})]}),M&&n.jsx("button",{onClick:M,style:{fontSize:"12px",color:"#2563eb",marginLeft:"8px",flexShrink:0,background:"none",border:"none",cursor:"pointer",minHeight:"unset",minWidth:"unset"},children:"Change"})]})}),n.jsx(Kr,{products:E,servicePackages:m,highlightedPartType:l,highlightedProduct:f,onProductClick:b,onPackageSelect:S,isResearching:O,visible:G,counterHeightPercent:o,hasVehicle:!!B}),n.jsx(zs,{messages:u,input:h,setInput:c,isLoading:y,onSend:v,onKeyPress:p,onInputFocus:x,onInputBlur:g,chatEndRef:j,isMuted:C,onToggleMute:R,isSpeaking:_})]})},Hs=({messages:t,input:e,setInput:r,isLoading:s,onSend:o,onKeyPress:u,onInputFocus:h,onInputBlur:c,chatEndRef:y,isMuted:v=!1,onToggleMute:p,isSpeaking:x=!1})=>{const[g,j]=d.useState(!1),C=d.useRef(null),R=d.useRef(!1),{bottomOffset:_,zIndexBase:E}=$r(),{isListening:m,interimTranscript:l,error:f,isSupported:b,startListening:S,stopListening:O}=Hr({onTranscript:F=>r(F),language:"en-NZ",mode:"ptt"});d.useEffect(()=>{l&&r(l)},[l,r]);const B=d.useCallback(()=>{s||R.current||(R.current=!0,navigator.vibrate&&navigator.vibrate(30),S())},[s,S]),M=d.useCallback(()=>{R.current&&(R.current=!1,navigator.vibrate&&navigator.vibrate([20,50,20]),O(),setTimeout(()=>{o()},150))},[O,o]),k=[...t].reverse().find(F=>F.role==="assistant"),N=k!=null&&k.content?k.content.length>50?k.content.slice(0,50)+"...":k.content:"Ask Bob about car parts...",T={idle:{background:"linear-gradient(145deg, #22c55e 0%, #16a34a 100%)",boxShadow:"0 6px 20px rgba(34, 197, 94, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.2), 0 0 0 4px #15803d"},active:{background:"linear-gradient(145deg, #f59e0b 0%, #d97706 100%)",boxShadow:"0 2px 8px rgba(245, 158, 11, 0.5), inset 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 0 4px #b45309"},disabled:{background:"linear-gradient(145deg, #9ca3af 0%, #6b7280 100%)",boxShadow:"0 2px 8px rgba(156, 163, 175, 0.3), 0 0 0 4px #4b5563"}},D=s?T.disabled:m?T.active:T.idle;return n.jsxs("div",{ref:C,style:{position:"absolute",bottom:`${_}px`,left:0,right:0,backgroundColor:"rgba(255, 255, 255, 0.95)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",borderTop:"1px solid #e5e7eb",transition:"all 0.3s ease-out",boxShadow:"0 -4px 20px rgba(0, 0, 0, 0.15)",height:g?"55%":"70px",overflow:g?"visible":"hidden",zIndex:E+10,paddingBottom:_>0?"8px":"env(safe-area-inset-bottom, 8px)"},children:[n.jsx("button",{onClick:()=>j(!g),style:{position:"absolute",top:"-20px",left:"50%",transform:"translateX(-50%)",backgroundColor:"white",border:"1px solid #e5e7eb",borderRadius:"9999px",padding:"6px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",zIndex:E+20,cursor:"pointer",minHeight:"unset",minWidth:"unset"},"aria-label":g?"Collapse chat":"Expand chat",children:g?n.jsx("svg",{style:{height:"16px",width:"16px",color:"#6b7280"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}):n.jsx("svg",{style:{height:"16px",width:"16px",color:"#6b7280"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),!g&&n.jsx("div",{onClick:()=>j(!0),style:{padding:"6px 12px 4px 12px",height:"26px",overflow:"hidden",cursor:"pointer"},children:n.jsx("p",{style:{fontSize:"12px",color:"#6b7280",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N})}),g&&n.jsxs("div",{style:{height:"calc(100% - 100px)",overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"8px"},children:[[...t].reverse().map((F,$)=>n.jsx("div",{style:{display:"flex",justifyContent:F.role==="user"?"flex-end":"flex-start"},children:n.jsx("div",{style:{maxWidth:"85%",borderRadius:"8px",padding:"8px 12px",fontSize:"14px",backgroundColor:F.role==="user"?"#2563eb":"#f3f4f6",color:F.role==="user"?"white":"#111827"},children:F.content})},$)),n.jsx("div",{ref:y})]}),n.jsxs("div",{style:{padding:g?"8px 12px 4px 12px":"4px 12px 4px 12px",borderTop:g?"1px solid #e5e7eb":"none"},children:[m&&n.jsxs("div",{style:{marginBottom:"8px",fontSize:"12px",color:"#6b7280",display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",backgroundColor:"#ef4444",borderRadius:"50%",animation:"pulse 2s infinite"}}),"Listening..."]}),f&&n.jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"#ef4444"},children:f}),n.jsxs("div",{style:{display:"flex",gap:"6px",alignItems:"center"},children:[p&&g&&n.jsx("button",{onClick:p,style:{flexShrink:0,height:"36px",width:"36px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"6px",backgroundColor:"transparent",color:x?"#2563eb":"#4b5563",cursor:"pointer",border:"none",minHeight:"unset",minWidth:"unset"},title:v?"Unmute":"Mute",children:v?n.jsxs("svg",{style:{height:"16px",width:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"}),n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]}):n.jsx("svg",{style:{height:"16px",width:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"})})}),n.jsx("input",{type:"text",value:e,onChange:F=>r(F.target.value),onKeyPress:u,onFocus:h,onBlur:c,placeholder:"Message Bob...",disabled:s,style:{flex:1,height:"40px",fontSize:"16px",padding:"0 12px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",color:"#111827",outline:"none",opacity:s?.5:1}}),b&&n.jsxs("div",{style:{position:"relative",marginLeft:"4px"},children:[m&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",width:"72px",height:"72px",borderRadius:"50%",border:"2px solid #f59e0b",transform:"translate(-50%, -50%)",animation:"ptt-wave 1.5s ease-out infinite",opacity:0,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",width:"72px",height:"72px",borderRadius:"50%",border:"2px solid #f59e0b",transform:"translate(-50%, -50%)",animation:"ptt-wave 1.5s ease-out infinite 0.5s",opacity:0,pointerEvents:"none"}})]}),!m&&!s&&n.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",width:"72px",height:"72px",borderRadius:"50%",transform:"translate(-50%, -50%)",animation:"ptt-pulse 2s ease-in-out infinite",pointerEvents:"none"}}),n.jsxs("button",{onTouchStart:B,onTouchEnd:M,onTouchCancel:M,onMouseDown:B,onMouseUp:M,onMouseLeave:M,disabled:s,"aria-label":"Hold to talk to Bob",style:{position:"relative",flexShrink:0,height:"72px",width:"72px",minHeight:"unset",minWidth:"unset",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",touchAction:"none",color:"white",border:"none",cursor:s?"not-allowed":"pointer",opacity:s?.6:1,transform:m?"scale(1.15)":"scale(1)",transition:"transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease",zIndex:E+25,...D},title:"Hold to talk",children:[n.jsx("svg",{style:{height:"28px",width:"28px",filter:"drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2))"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})}),m&&n.jsx("div",{style:{position:"absolute",top:"8px",right:"8px",width:"12px",height:"12px",borderRadius:"50%",backgroundColor:"#fef3c7",animation:"ptt-dot 0.6s ease-in-out infinite alternate"}})]})]})]})]})]})},Xn=({product:t,onBack:e,onAddToCart:r,onNavigateToProductPage:s})=>{const o=t.productUrl||t.product_url,u=t.partNumber||t.part_number,h=!!o||!!s;return n.jsxs("div",{className:"absolute inset-0 z-35 flex flex-col bg-white/95 backdrop-blur-md overflow-hidden",children:[n.jsx("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-gray-200 bg-white/80 backdrop-blur-sm",children:n.jsxs("button",{onClick:e,className:"flex items-center gap-1.5 text-blue-600 font-medium text-sm hover:text-blue-700 active:scale-95 transition-all",children:[n.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back to Products"]})}),n.jsxs("div",{className:"flex-1 overflow-y-auto",children:[n.jsx("div",{className:"aspect-square bg-gradient-to-br from-gray-50 to-gray-100 flex items-center justify-center",children:t.image_url?n.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-4"}):n.jsxs("div",{className:"flex flex-col items-center justify-center text-gray-400",children:[n.jsx("svg",{className:"h-16 w-16 mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),n.jsx("span",{className:"text-sm font-medium uppercase tracking-wide",children:"No Image Available"})]})}),n.jsxs("div",{className:"p-4 space-y-4",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-xl font-bold text-gray-900 mb-1",children:t.name}),t.brand&&n.jsx("p",{className:"text-sm text-gray-600 font-medium",children:t.brand})]}),n.jsxs("div",{className:"bg-blue-50 rounded-xl p-4",children:[n.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Price"}),n.jsx("p",{className:"text-2xl font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"Price on Request"}),t.price>0&&n.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Inc. GST"})]}),n.jsxs("div",{className:"space-y-3",children:[t.partslotDescription&&n.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[n.jsx("span",{className:"text-sm text-gray-500",children:"Category"}),n.jsx("span",{className:"text-sm font-medium text-gray-900",children:t.partslotDescription})]}),t.sku&&n.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[n.jsx("span",{className:"text-sm text-gray-500",children:"SKU"}),n.jsx("span",{className:"text-sm font-medium text-gray-900",children:t.sku})]}),u&&n.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[n.jsx("span",{className:"text-sm text-gray-500",children:"Part Number"}),n.jsx("span",{className:"text-sm font-medium text-gray-900",children:u})]})]}),h&&n.jsx("a",{href:o||"#",onClick:c=>{s&&(c.preventDefault(),s(t))},target:o&&!s?"_blank":void 0,rel:o&&!s?"noopener noreferrer":void 0,className:"block text-center text-blue-600 text-sm font-medium hover:underline py-2",children:"View Full Details on CARFIX →"})]})]}),n.jsx("div",{className:"p-4 border-t border-gray-200 bg-white/95 backdrop-blur-sm",children:n.jsx("button",{onClick:()=>r==null?void 0:r(t),className:"w-full bg-blue-600 text-white text-base font-semibold py-3 rounded-xl hover:bg-blue-700 active:bg-blue-800 transition-colors shadow-lg",children:"Add to Cart"})})]})},Gs=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:s,counterHeightPercent:o=22,messages:u,input:h,setInput:c,isLoading:y,onSend:v,onKeyPress:p,onInputFocus:x,onInputBlur:g,chatEndRef:j,isMuted:C,onToggleMute:R,isSpeaking:_,products:E,servicePackages:m,highlightedPartType:l,highlightedProduct:f,onProductClick:b,onPackageSelect:S,isResearching:O,onAddToCart:B,onNavigateToProductPage:M,vehicle:k,onChangeVehicle:N,bobOffset:T=0,bobScale:D=100})=>{const[F,$]=d.useState("center"),[J,se]=d.useState("hidden"),[ue,Re]=d.useState("products"),[U,G]=d.useState(null),ne=E.length>0||m.length>0,Qe=(ue==="productDetail"?65:F==="center"&&!ne?130:85)*D/100;d.useEffect(()=>{if(O&&J!=="loading"&&J!=="visible")se("loading"),F==="center"&&$("left");else if(ne&&J!=="visible")if(F==="center"){$("left"),se("transitioning");const we=setTimeout(()=>{se("visible")},400);return()=>clearTimeout(we)}else se("visible");else!ne&&!O&&J!=="hidden"&&(se("hidden"),$("center"))},[ne,O,J,F]);const ct=we=>{if(M){M(we),b==null||b(we);return}G(we),Re("productDetail"),b==null||b(we)},de=()=>{G(null),Re("products")},Ve=J!=="hidden"&&ue==="products",ze=J!=="hidden";return n.jsxs("div",{className:"absolute inset-0 overflow-hidden",style:{touchAction:"manipulation"},children:[r&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"absolute inset-0 z-0 transition-all duration-500 ease-out",style:{backgroundImage:`url(${r})`,backgroundSize:"cover",backgroundPosition:"center bottom",filter:ze?"blur(12px) brightness(0.7)":"blur(0px) brightness(1)",transform:"scale(1.1)"}}),n.jsx("div",{className:"absolute inset-0 z-[1]",style:{background:"linear-gradient(to bottom, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.6) 100%)"}})]}),n.jsx(Qr,{currentImage:t,animationState:e,counterOverlayUrl:s,counterHeightPercent:o,scale:Qe,position:F,verticalOffset:T}),k&&ue==="products"&&n.jsx("div",{style:{position:"absolute",top:"8px",left:"8px",right:"8px",zIndex:20},children:n.jsxs("div",{style:{backgroundColor:"rgba(255, 255, 255, 0.9)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",borderRadius:"8px",padding:"8px 12px",border:"1px solid #e5e7eb",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsxs("p",{style:{fontSize:"12px",fontWeight:500,color:"#111827",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[k.year," ",k.make," ",k.model]}),k.rego&&n.jsx("p",{style:{fontSize:"10px",color:"#6b7280"},children:k.rego})]}),N&&n.jsx("button",{onClick:N,style:{fontSize:"12px",color:"#2563eb",marginLeft:"8px",flexShrink:0,background:"none",border:"none",cursor:"pointer",minHeight:"unset",minWidth:"unset"},children:"Change"})]})}),n.jsx(Kr,{products:E,servicePackages:m,highlightedPartType:l,highlightedProduct:f,onProductClick:ct,onPackageSelect:S,isResearching:O,visible:Ve,counterHeightPercent:o,hasVehicle:!!k}),ue==="productDetail"&&U&&n.jsx(Xn,{product:U,onBack:de,onAddToCart:B,onNavigateToProductPage:M}),ue==="products"&&n.jsx(Hs,{messages:u,input:h,setInput:c,isLoading:y,onSend:v,onKeyPress:p,onInputFocus:x,onInputBlur:g,chatEndRef:j,isMuted:C,onToggleMute:R,isSpeaking:_})]})},Ys=({variant:t="inline",initialState:e="idle",showChat:r=!0,className:s="",backdropUrl:o,counterOverlayUrl:u,counterHeightPercent:h,defaultBobImage:c,verticalOffset:y=0,scale:v=100})=>{const{callbacks:p}=$e(),{animationState:x,setAnimationState:g,getCurrentImage:j,getCurrentOffset:C,getCurrentScale:R,availableStates:_}=qs(),{activeBackdrop:E}=$s(),[m,l]=d.useState([]),[f,b]=d.useState([]),[S,O]=d.useState(null),[B,M]=d.useState(null),[k,N]=d.useState(!1),T=Us({setAnimationState:g,manualMode:!1,onReadyToSpeak:()=>{console.log("[BobWidget] Ready to speak")},onStreamComplete:()=>{g(_.find(U=>U.includes("idle"))||"idle")},onResearchStart:()=>{N(!0)},onHighlightPart:U=>{O(U),setTimeout(()=>O(null),8e3)},onHighlightProduct:U=>{M(U),setTimeout(()=>M(null),8e3)},onAutoFetchComplete:()=>{N(!1)}});d.useEffect(()=>{const U=p.onPartsFound,G=p.onServicePackagesFound;return p.onPartsFound=ne=>{N(!1);const Le=ne.map((Z,Qe)=>({id:Z.SKU||Z.sku||`part-${Qe}`,name:Z["Part Product Type"]||Z.partslot_description||"Unknown Part",brand:Z.Brand||Z.brand,price:Z["Metro Retail Price"]||Z.price||0,sku:Z.SKU||Z.sku,partNumber:Z["Part Number"]||Z.part_number,partslotDescription:Z["Part Product Type"]||Z.partslot_description,image_url:Z.image_url}));l(Le),U==null||U(ne)},p.onServicePackagesFound=ne=>{b(ne),G==null||G(ne)},()=>{p.onPartsFound=U,p.onServicePackagesFound=G}},[p]);const D=o||(E==null?void 0:E.image_url),F=u||(E==null?void 0:E.counter_overlay_url)||void 0,$=h||(E==null?void 0:E.counter_height_percent)||12,J=j()||c||"",se=C(),ue=R();if(t==="mobile"||t==="fullscreen")return n.jsx(Ks,{currentImage:J,animationState:x,backdropUrl:D,counterOverlayUrl:F,counterHeightPercent:$,bobOffset:se,bobScale:ue,messages:T.messages,input:T.input,setInput:T.setInput,isLoading:T.isLoading,onSend:T.handleSend,onKeyPress:T.handleKeyPress,onInputFocus:T.handleInputFocus,onInputBlur:T.handleInputBlur,chatEndRef:T.chatEndRef,isMuted:T.isMuted,onToggleMute:T.toggleMute,isSpeaking:T.isSpeaking,products:m,servicePackages:f,highlightedPartType:S,highlightedProduct:B,onAddToCart:U=>{var G;return(G=p.onAddToCart)==null?void 0:G.call(p,{product_id:U.id,product_name:U.name,quantity:1,unit_price:U.price,sku:U.sku,brand:U.brand})},onNavigateToProductPage:U=>{var G;return(G=p.onNavigateToProductPage)==null?void 0:G.call(p,U)},onPackageSelect:U=>console.log("[BobWidget] Package selected:",U),isResearching:k,vehicle:T.identifiedVehicle});if(t==="inline"&&r)return n.jsx("div",{className:`relative w-full h-full ${s}`,children:n.jsx(Gs,{currentImage:J,animationState:x,backdropUrl:D,counterOverlayUrl:F,counterHeightPercent:$,bobOffset:se,bobScale:ue,messages:T.messages,input:T.input,setInput:T.setInput,isLoading:T.isLoading,onSend:T.handleSend,onKeyPress:T.handleKeyPress,onInputFocus:T.handleInputFocus,onInputBlur:T.handleInputBlur,chatEndRef:T.chatEndRef,isMuted:T.isMuted,onToggleMute:T.toggleMute,isSpeaking:T.isSpeaking,products:m,servicePackages:f,highlightedPartType:S,highlightedProduct:B,onAddToCart:U=>{var G;return(G=p.onAddToCart)==null?void 0:G.call(p,{product_id:U.id,product_name:U.name,quantity:1,unit_price:U.price,sku:U.sku,brand:U.brand})},onNavigateToProductPage:U=>{var G;return(G=p.onNavigateToProductPage)==null?void 0:G.call(p,U)},onPackageSelect:U=>console.log("[BobWidget] Package selected:",U),isResearching:k,vehicle:T.identifiedVehicle})});const Re={inline:"",floating:"fixed bottom-4 right-4 w-96 z-50 shadow-2xl rounded-lg overflow-hidden"};return n.jsxs("div",{className:`${Re[t]||""} ${s}`,children:[J&&n.jsx(Qs,{currentImage:J,animationState:x,backdropUrl:D,counterOverlayUrl:F,counterHeightPercent:$,verticalOffset:se,scale:ue}),r&&n.jsx(Vs,{messages:T.messages,input:T.input,setInput:T.setInput,isLoading:T.isLoading,onSend:T.handleSend,onKeyPress:T.handleKeyPress,onInputFocus:T.handleInputFocus,onInputBlur:T.handleInputBlur,chatEndRef:T.chatEndRef,isMuted:T.isMuted,onToggleMute:T.toggleMute,isSpeaking:T.isSpeaking})]})},Zn=({bobConfig:t,hostApiConfig:e,hostContext:r,callbacks:s,variant:o="mobile",initialState:u,showChat:h,className:c,backdropUrl:y,counterOverlayUrl:v,counterHeightPercent:p,defaultBobImage:x,verticalOffset:g,scale:j,ga4Config:C,analyticsEnabled:R=!0,bottomOffset:_=0,zIndexBase:E=50})=>n.jsx("div",{className:"bob-widget-root",style:{width:"100%",height:"100%"},children:n.jsx(Ds,{bobConfig:t,hostApiConfig:e,hostContext:r,callbacks:s,ga4Config:C,analyticsEnabled:R,bottomOffset:_,zIndexBase:E,children:n.jsx(Ys,{variant:o,initialState:u,showChat:h,className:c,backdropUrl:y,counterOverlayUrl:v,counterHeightPercent:p,defaultBobImage:x,verticalOffset:g,scale:j})})}),ei=6e4,ti=({states:t,setAnimationState:e,manualMode:r})=>{const[s,o]=d.useState("page_load"),[u,h]=d.useState(!1),c=d.useRef(null),y=d.useCallback(b=>t.find(S=>S.chat_trigger===b&&S.is_active),[t]),v=d.useCallback(()=>t.find(b=>b.chat_trigger==="awaiting_input"||b.state_key==="talk_pause"||b.title.toLowerCase().includes("listen")||b.title.toLowerCase().includes("pause")),[t]),p=d.useCallback(()=>t.find(b=>b.state_key==="idle"||b.title.toLowerCase().includes("idle")),[t]),x=d.useCallback(b=>{const S=t.find(O=>O.state_key===b);return{speed:(S==null?void 0:S.animation_speed)||400,pauseDuration:(S==null?void 0:S.pause_duration)||0,loopCount:(S==null?void 0:S.loop_count)||0}},[t]),g=d.useCallback(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]),j=d.useCallback(()=>{g(),!r&&(c.current=setTimeout(()=>{const b=p();b&&(o("idle"),e(b.state_key))},ei))},[r,p,e,g]),C=d.useCallback(b=>{if(r)return;const S=y(b);S&&e(S.state_key)},[r,y,e]),R=d.useCallback(()=>{if(r)return;const b=v();b&&(o("awaiting_input"),e(b.state_key),j())},[r,v,e,j]),_=d.useCallback(()=>{u||r||(h(!0),o("page_load"),C("page_load"),setTimeout(()=>{R()},3e3))},[u,r,C,R]),E=d.useCallback(()=>{g(),o("processing_input"),C("processing_input")},[C,g]),m=d.useCallback(()=>{g(),o("streaming_response"),C("streaming_response")},[C,g]),l=d.useCallback(()=>{o("response_complete"),C("response_complete"),setTimeout(()=>{R()},3e3)},[C,R]),f=d.useCallback(()=>{o("showing_product");const b=t.find(S=>S.chat_trigger==="showing_product"||S.state_key==="showing_product");b&&e(b.state_key),setTimeout(()=>{R()},4e3)},[t,e,R]);return d.useEffect(()=>()=>g(),[g]),{chatStage:s,initialize:_,onUserInput:E,onStreamStart:m,onStreamComplete:l,onShowingProduct:f,getStateSettings:x}};console.log(`[BobWidget] Package loaded - v${zt}`);exports.BOB_VERSION=zt;exports.Bob=Ys;exports.BobCharacter=Qs;exports.BobProvider=Ds;exports.BobWidget=Zn;exports.ChatInterface=Vs;exports.ContainedChatDrawer=Hs;exports.ContainedMobileBobLayout=Gs;exports.MobileBobCharacter=Qr;exports.MobileBobLayout=Ks;exports.MobileChatDrawer=zs;exports.MobileProductColumn=Kr;exports.getBobVersion=tn;exports.useBobAnalytics=As;exports.useBobAnalyticsConfig=Vn;exports.useBobAnimation=qs;exports.useBobAnimationData=Ws;exports.useBobBackdrop=$s;exports.useBobCallbacks=Qn;exports.useBobChat=Us;exports.useBobContext=$e;exports.useBobLayoutConfig=$r;exports.useBobStateTransitions=ti;exports.useBobSupabase=qr;exports.useHostApiConfig=$n;exports.useHostContext=qn;exports.useSpeechRecognition=Hr;exports.useSpeechSynthesis=Ls;