@gymmymac/bob-widget 3.0.0 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +12 -12
- package/dist/index.mjs +545 -535
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var gs=t=>{throw TypeError(t)};var Dr=(t,e,r)=>e.has(t)||gs("Cannot "+r);var l=(t,e,r)=>(Dr(t,e,"read from private field"),r?r.call(t):e.get(t)),G=(t,e,r)=>e.has(t)?gs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),L=(t,e,r,n)=>(Dr(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),re=(t,e,r)=>(Dr(t,e,"access private method"),r);var jr=(t,e,r,n)=>({set _(i){L(t,e,i,r)},get _(){return l(t,e,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),
|
|
1
|
+
"use strict";var gs=t=>{throw TypeError(t)};var Dr=(t,e,r)=>e.has(t)||gs("Cannot "+r);var l=(t,e,r)=>(Dr(t,e,"read from private field"),r?r.call(t):e.get(t)),G=(t,e,r)=>e.has(t)?gs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),L=(t,e,r,n)=>(Dr(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),re=(t,e,r)=>(Dr(t,e,"access private method"),r);var jr=(t,e,r,n)=>({set _(i){L(t,e,i,r)},get _(){return l(t,e,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),Pn=require("@supabase/supabase-js");function On(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const Le=On(o),Mt="3.0.3",Mn=()=>Mt;var Ur={exports:{}},nr={};/**
|
|
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 bs;function An(){if(bs)return nr;bs=1;var t=o,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function h(u,y,k){var f,
|
|
9
|
+
*/var bs;function An(){if(bs)return nr;bs=1;var t=o,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function h(u,y,k){var f,g={},S=null,x=null;k!==void 0&&(S=""+k),y.key!==void 0&&(S=""+y.key),y.ref!==void 0&&(x=y.ref);for(f in y)n.call(y,f)&&!c.hasOwnProperty(f)&&(g[f]=y[f]);if(u&&u.defaultProps)for(f in y=u.defaultProps,y)g[f]===void 0&&(g[f]=y[f]);return{$$typeof:e,type:u,key:S,ref:x,props:g,_owner:i.current}}return nr.Fragment=r,nr.jsx=h,nr.jsxs=h,nr}var ir={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,23 +14,23 @@
|
|
|
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 ms;function Ln(){return ms||(ms=1,process.env.NODE_ENV!=="production"&&function(){var t=o,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),u=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),
|
|
18
|
-
`+xe+a}}var ve=!1,J;{var Be=typeof WeakMap=="function"?WeakMap:Map;J=new Be}function Ie(a,R){if(!a||ve)return"";{var
|
|
17
|
+
*/var ms;function Ln(){return ms||(ms=1,process.env.NODE_ENV!=="production"&&function(){var t=o,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),u=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),x=Symbol.for("react.offscreen"),j=Symbol.iterator,p="@@iterator";function E(a){if(a===null||typeof a!="object")return null;var R=j&&a[j]||a[p];return typeof R=="function"?R:null}var b=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function v(a){{for(var R=arguments.length,O=new Array(R>1?R-1:0),Y=1;Y<R;Y++)O[Y-1]=arguments[Y];d("error",a,O)}}function d(a,R,O){{var Y=b.ReactDebugCurrentFrame,Z=Y.getStackAddendum();Z!==""&&(R+="%s",O=O.concat([Z]));var oe=O.map(function(M){return String(M)});oe.unshift("Warning: "+R),Function.prototype.apply.call(console[a],console,oe)}}var _=!1,B=!1,A=!1,H=!1,I=!1,z;z=Symbol.for("react.module.reference");function m(a){return!!(typeof a=="string"||typeof a=="function"||a===n||a===c||I||a===i||a===k||a===f||H||a===x||_||B||A||typeof a=="object"&&a!==null&&(a.$$typeof===S||a.$$typeof===g||a.$$typeof===h||a.$$typeof===u||a.$$typeof===y||a.$$typeof===z||a.getModuleId!==void 0))}function T(a,R,O){var Y=a.displayName;if(Y)return Y;var Z=R.displayName||R.name||"";return Z!==""?O+"("+Z+")":O}function C(a){return a.displayName||"Context"}function N(a){if(a==null)return null;if(typeof a.tag=="number"&&v("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case n:return"Fragment";case r:return"Portal";case c:return"Profiler";case i:return"StrictMode";case k:return"Suspense";case f:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case u:var R=a;return C(R)+".Consumer";case h:var O=a;return C(O._context)+".Provider";case y:return T(a,a.render,"ForwardRef");case g:var Y=a.displayName||null;return Y!==null?Y:N(a.type)||"Memo";case S:{var Z=a,oe=Z._payload,M=Z._init;try{return N(M(oe))}catch{return null}}}return null}var w=Object.assign,q=0,$,X,Q,P,D,U,F;function W(){}W.__reactDisabledLog=!0;function ae(){{if(q===0){$=console.log,X=console.info,Q=console.warn,P=console.error,D=console.group,U=console.groupCollapsed,F=console.groupEnd;var a={configurable:!0,enumerable:!0,value:W,writable:!0};Object.defineProperties(console,{info:a,log:a,warn:a,error:a,group:a,groupCollapsed:a,groupEnd:a})}q++}}function Fe(){{if(q--,q===0){var a={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:w({},a,{value:$}),info:w({},a,{value:X}),warn:w({},a,{value:Q}),error:w({},a,{value:P}),group:w({},a,{value:D}),groupCollapsed:w({},a,{value:U}),groupEnd:w({},a,{value:F})})}q<0&&v("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ce=b.ReactCurrentDispatcher,xe;function je(a,R,O){{if(xe===void 0)try{throw Error()}catch(Z){var Y=Z.stack.trim().match(/\n( *(at )?)/);xe=Y&&Y[1]||""}return`
|
|
18
|
+
`+xe+a}}var ve=!1,J;{var Be=typeof WeakMap=="function"?WeakMap:Map;J=new Be}function Ie(a,R){if(!a||ve)return"";{var O=J.get(a);if(O!==void 0)return O}var Y;ve=!0;var Z=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var oe;oe=ce.current,ce.current=null,ae();try{if(R){var M=function(){throw Error()};if(Object.defineProperty(M.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(M,[])}catch(_e){Y=_e}Reflect.construct(a,[],M)}else{try{M.call()}catch(_e){Y=_e}a.call(M.prototype)}}else{try{throw Error()}catch(_e){Y=_e}a()}}catch(_e){if(_e&&Y&&typeof _e.stack=="string"){for(var ee=_e.stack.split(`
|
|
19
19
|
`),de=Y.stack.split(`
|
|
20
20
|
`),ie=ee.length-1,ne=de.length-1;ie>=1&&ne>=0&&ee[ie]!==de[ne];)ne--;for(;ie>=1&&ne>=0;ie--,ne--)if(ee[ie]!==de[ne]){if(ie!==1||ne!==1)do if(ie--,ne--,ne<0||ee[ie]!==de[ne]){var be=`
|
|
21
|
-
`+ee[ie].replace(" at new "," at ");return a.displayName&&be.includes("<anonymous>")&&(be=be.replace("<anonymous>",a.displayName)),typeof a=="function"&&J.set(a,be),be}while(ie>=1&&ne>=0);break}}}finally{ve=!1,ce.current=oe,Fe(),Error.prepareStackTrace=Z}var We=a?a.displayName||a.name:"",Ye=We?je(We):"";return typeof a=="function"&&J.set(a,Ye),Ye}function te(a,R,
|
|
21
|
+
`+ee[ie].replace(" at new "," at ");return a.displayName&&be.includes("<anonymous>")&&(be=be.replace("<anonymous>",a.displayName)),typeof a=="function"&&J.set(a,be),be}while(ie>=1&&ne>=0);break}}}finally{ve=!1,ce.current=oe,Fe(),Error.prepareStackTrace=Z}var We=a?a.displayName||a.name:"",Ye=We?je(We):"";return typeof a=="function"&&J.set(a,Ye),Ye}function te(a,R,O){return Ie(a,!1)}function Re(a){var R=a.prototype;return!!(R&&R.isReactComponent)}function fe(a,R,O){if(a==null)return"";if(typeof a=="function")return Ie(a,Re(a));if(typeof a=="string")return je(a);switch(a){case k:return je("Suspense");case f:return je("SuspenseList")}if(typeof a=="object")switch(a.$$typeof){case y:return te(a.render);case g:return fe(a.type,R,O);case S:{var Y=a,Z=Y._payload,oe=Y._init;try{return fe(oe(Z),R,O)}catch{}}}return""}var He=Object.prototype.hasOwnProperty,tt={},Pr=b.ReactDebugCurrentFrame;function Xt(a){if(a){var R=a._owner,O=fe(a.type,a._source,R?R.type:null);Pr.setExtraStackFrame(O)}else Pr.setExtraStackFrame(null)}function fs(a,R,O,Y,Z){{var oe=Function.call.bind(He);for(var M in a)if(oe(a,M)){var ee=void 0;try{if(typeof a[M]!="function"){var de=Error((Y||"React class")+": "+O+" type `"+M+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[M]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw de.name="Invariant Violation",de}ee=a[M](R,M,Y,O,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ie){ee=ie}ee&&!(ee instanceof Error)&&(Xt(Z),v("%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).",Y||"React class",O,M,typeof ee),Xt(null)),ee instanceof Error&&!(ee.message in tt)&&(tt[ee.message]=!0,Xt(Z),v("Failed %s type: %s",O,ee.message),Xt(null))}}}var ps=Array.isArray;function wr(a){return ps(a)}function kr(a){{var R=typeof Symbol=="function"&&Symbol.toStringTag,O=R&&a[Symbol.toStringTag]||a.constructor.name||"Object";return O}}function Sr(a){try{return Jt(a),!1}catch{return!0}}function Jt(a){return""+a}function Zt(a){if(Sr(a))return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",kr(a)),Jt(a)}var V=b.ReactCurrentOwner,ue={key:!0,ref:!0,__self:!0,__source:!0},pe,we;function rt(a){if(He.call(a,"ref")){var R=Object.getOwnPropertyDescriptor(a,"ref").get;if(R&&R.isReactWarning)return!1}return a.ref!==void 0}function er(a){if(He.call(a,"key")){var R=Object.getOwnPropertyDescriptor(a,"key").get;if(R&&R.isReactWarning)return!1}return a.key!==void 0}function mt(a,R){typeof a.ref=="string"&&V.current}function xt(a,R){{var O=function(){pe||(pe=!0,v("%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)",R))};O.isReactWarning=!0,Object.defineProperty(a,"key",{get:O,configurable:!0})}}function At(a,R){{var O=function(){we||(we=!0,v("%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)",R))};O.isReactWarning=!0,Object.defineProperty(a,"ref",{get:O,configurable:!0})}}var yt=function(a,R,O,Y,Z,oe,M){var ee={$$typeof:e,type:a,key:R,ref:O,props:M,_owner:oe};return ee._store={},Object.defineProperty(ee._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ee,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Y}),Object.defineProperty(ee,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Z}),Object.freeze&&(Object.freeze(ee.props),Object.freeze(ee)),ee};function vt(a,R,O,Y,Z){{var oe,M={},ee=null,de=null;O!==void 0&&(Zt(O),ee=""+O),er(R)&&(Zt(R.key),ee=""+R.key),rt(R)&&(de=R.ref,mt(R,Z));for(oe in R)He.call(R,oe)&&!ue.hasOwnProperty(oe)&&(M[oe]=R[oe]);if(a&&a.defaultProps){var ie=a.defaultProps;for(oe in ie)M[oe]===void 0&&(M[oe]=ie[oe])}if(ee||de){var ne=typeof a=="function"?a.displayName||a.name||"Unknown":a;ee&&xt(M,ne),de&&At(M,ne)}return yt(a,ee,de,Z,Y,V.current,M)}}var Ce=b.ReactCurrentOwner,wt=b.ReactDebugCurrentFrame;function De(a){if(a){var R=a._owner,O=fe(a.type,a._source,R?R.type:null);wt.setExtraStackFrame(O)}else wt.setExtraStackFrame(null)}var Pe;Pe=!1;function st(a){return typeof a=="object"&&a!==null&&a.$$typeof===e}function kt(){{if(Ce.current){var a=N(Ce.current.type);if(a)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+a+"`."}return""}}function nt(a){return""}var Ne={};function St(a){{var R=kt();if(!R){var
|
|
23
|
+
Check the render method of \``+a+"`."}return""}}function nt(a){return""}var Ne={};function St(a){{var R=kt();if(!R){var O=typeof a=="string"?a:a.displayName||a.name;O&&(R=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+
|
|
25
|
+
Check the top-level render call using <`+O+">.")}return R}}function ge(a,R){{if(!a._store||a._store.validated||a.key!=null)return;a._store.validated=!0;var O=St(R);if(Ne[O])return;Ne[O]=!0;var Y="";a&&a._owner&&a._owner!==Ce.current&&(Y=" It was passed a child from "+N(a._owner.type)+"."),De(a),v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',O,Y),De(null)}}function Oe(a,R){{if(typeof a!="object")return;if(wr(a))for(var O=0;O<a.length;O++){var Y=a[O];st(Y)&&ge(Y,R)}else if(st(a))a._store&&(a._store.validated=!0);else if(a){var Z=E(a);if(typeof Z=="function"&&Z!==a.entries)for(var oe=Z.call(a),M;!(M=oe.next()).done;)st(M.value)&&ge(M.value,R)}}}function Or(a){{var R=a.type;if(R==null||typeof R=="string")return;var O;if(typeof R=="function")O=R.propTypes;else if(typeof R=="object"&&(R.$$typeof===y||R.$$typeof===g))O=R.propTypes;else return;if(O){var Y=N(R);fs(O,a.props,"prop",Y,a)}else if(R.PropTypes!==void 0&&!Pe){Pe=!0;var Z=N(R);v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Z||"Unknown")}typeof R.getDefaultProps=="function"&&!R.getDefaultProps.isReactClassApproved&&v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Mr(a){{for(var R=Object.keys(a.props),O=0;O<R.length;O++){var Y=R[O];if(Y!=="children"&&Y!=="key"){De(a),v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Y),De(null);break}}a.ref!==null&&(De(a),v("Invalid attribute `ref` supplied to `React.Fragment`."),De(null))}}var qe={};function tr(a,R,O,Y,Z,oe){{var M=m(a);if(!M){var ee="";(a===void 0||typeof a=="object"&&a!==null&&Object.keys(a).length===0)&&(ee+=" 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 de=nt();de?ee+=de:ee+=kt();var ie;a===null?ie="null":wr(a)?ie="array":a!==void 0&&a.$$typeof===e?(ie="<"+(N(a.type)||"Unknown")+" />",ee=" Did you accidentally export a JSX literal instead of a component?"):ie=typeof a,v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ie,ee)}var ne=vt(a,R,O,Z,oe);if(ne==null)return ne;if(M){var be=R.children;if(be!==void 0)if(Y)if(wr(be)){for(var We=0;We<be.length;We++)Oe(be[We],a);Object.freeze&&Object.freeze(be)}else v("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 Oe(be,a)}if(He.call(R,"key")){var Ye=N(a),_e=Object.keys(R).filter(function(In){return In!=="key"}),Lr=_e.length>0?"{key: someKey, "+_e.join(": ..., ")+": ...}":"{key: someKey}";if(!qe[Ye+Lr]){var Bn=_e.length>0?"{"+_e.join(": ..., ")+": ...}":"{}";v(`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} />`,Lr,Ye,Bn,Ye),qe[Ye+Lr]=!0}}return a===n?Mr(ne):Pr(ne),ne}}function it(a,R,P){return tr(a,R,P,!0)}function rr(a,R,P){return tr(a,R,P,!1)}var sr=rr,Ar=it;ir.Fragment=n,ir.jsx=sr,ir.jsxs=Ar}()),ir}process.env.NODE_ENV==="production"?Ur.exports=An():Ur.exports=Ln();var s=Ur.exports,yr=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(){}},Dn={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Qe,_t,As,Wn=(As=class{constructor(){G(this,Qe,Dn);G(this,_t,!1)}setTimeoutProvider(t){process.env.NODE_ENV!=="production"&&l(this,_t)&&t!==l(this,Qe)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:l(this,Qe),provider:t}),L(this,Qe,t),process.env.NODE_ENV!=="production"&&L(this,_t,!1)}setTimeout(t,e){return process.env.NODE_ENV!=="production"&&L(this,_t,!0),l(this,Qe).setTimeout(t,e)}clearTimeout(t){l(this,Qe).clearTimeout(t)}setInterval(t,e){return process.env.NODE_ENV!=="production"&&L(this,_t,!0),l(this,Qe).setInterval(t,e)}clearInterval(t){l(this,Qe).clearInterval(t)}},Qe=new WeakMap,_t=new WeakMap,As),jt=new Wn;function zn(t){setTimeout(t,0)}var Pt=typeof window>"u"||"Deno"in globalThis;function Te(){}function $n(t,e){return typeof t=="function"?t(e):t}function Hr(t){return typeof t=="number"&&t>=0&&t!==1/0}function Ks(t,e){return Math.max(t+(e||0)-Date.now(),0)}function bt(t,e){return typeof t=="function"?t(e):t}function Ae(t,e){return typeof t=="function"?t(e):t}function xs(t,e){const{type:r="all",exact:n,fetchStatus:i,predicate:c,queryKey:h,stale:u}=t;if(h){if(n){if(e.queryHash!==as(h,e.options))return!1}else if(!hr(e.queryKey,h))return!1}if(r!=="all"){const y=e.isActive();if(r==="active"&&!y||r==="inactive"&&y)return!1}return!(typeof u=="boolean"&&e.isStale()!==u||i&&i!==e.state.fetchStatus||c&&!c(e))}function ys(t,e){const{exact:r,status:n,predicate:i,mutationKey:c}=t;if(c){if(!e.options.mutationKey)return!1;if(r){if(dr(e.options.mutationKey)!==dr(c))return!1}else if(!hr(e.options.mutationKey,c))return!1}return!(n&&e.state.status!==n||i&&!i(e))}function as(t,e){return((e==null?void 0:e.queryKeyHashFn)||dr)(t)}function dr(t){return JSON.stringify(t,(e,r)=>Kr(r)?Object.keys(r).sort().reduce((n,i)=>(n[i]=r[i],n),{}):r)}function hr(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>hr(t[r],e[r])):!1}var Un=Object.prototype.hasOwnProperty;function qr(t,e,r=0){if(t===e)return t;if(r>500)return e;const n=vs(t)&&vs(e);if(!n&&!(Kr(t)&&Kr(e)))return e;const c=(n?t:Object.keys(t)).length,h=n?e:Object.keys(e),u=h.length,y=n?new Array(u):{};let k=0;for(let f=0;f<u;f++){const p=n?f:h[f],S=t[p],x=e[p];if(S===x){y[p]=S,(n?f<c:Un.call(t,p))&&k++;continue}if(S===null||x===null||typeof S!="object"||typeof x!="object"){y[p]=x;continue}const j=qr(S,x,r+1);y[p]=j,j===S&&k++}return c===u&&k===c?t:y}function Qr(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 vs(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Kr(t){if(!ws(t))return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(!ws(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function ws(t){return Object.prototype.toString.call(t)==="[object Object]"}function Hn(t){return new Promise(e=>{jt.setTimeout(e,t)})}function Vr(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 qr(t,e)}catch(n){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}]: ${n}`),n}return qr(t,e)}return e}function qn(t,e,r=0){const n=[...t,e];return r&&n.length>r?n.slice(1):n}function Qn(t,e,r=0){const n=[e,...t];return r&&n.length>r?n.slice(0,-1):n}var Tr=Symbol();function Vs(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===Tr&&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===Tr?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Gs(t,e){return typeof t=="function"?t(...e):!!t}function Kn(t,e,r){let n=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(i??(i=e()),n||(n=!0,i.aborted?r():i.addEventListener("abort",r,{once:!0})),i)}),t}var Et,lt,At,Ls,Vn=(Ls=class extends yr{constructor(){super();G(this,Et);G(this,lt);G(this,At);L(this,At,e=>{if(!Pt&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){l(this,lt)||this.setEventListener(l(this,At))}onUnsubscribe(){var e;this.hasListeners()||((e=l(this,lt))==null||e.call(this),L(this,lt,void 0))}setEventListener(e){var r;L(this,At,e),(r=l(this,lt))==null||r.call(this),L(this,lt,e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(e){l(this,Et)!==e&&(L(this,Et,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof l(this,Et)=="boolean"?l(this,Et):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},Et=new WeakMap,lt=new WeakMap,At=new WeakMap,Ls),os=new Vn;function Gr(){let t,e;const r=new Promise((i,c)=>{t=i,e=c});r.status="pending",r.catch(()=>{});function n(i){Object.assign(r,i),delete r.resolve,delete r.reject}return r.resolve=i=>{n({status:"fulfilled",value:i}),t(i)},r.reject=i=>{n({status:"rejected",reason:i}),e(i)},r}var Gn=zn;function Yn(){let t=[],e=0,r=u=>{u()},n=u=>{u()},i=Gn;const c=u=>{e?t.push(u):i(()=>{r(u)})},h=()=>{const u=t;t=[],u.length&&i(()=>{n(()=>{u.forEach(y=>{r(y)})})})};return{batch:u=>{let y;e++;try{y=u()}finally{e--,e||h()}return y},batchCalls:u=>(...y)=>{c(()=>{u(...y)})},schedule:c,setNotifyFunction:u=>{r=u},setBatchNotifyFunction:u=>{n=u},setScheduler:u=>{i=u}}}var ye=Yn(),Lt,ct,Dt,Ds,Xn=(Ds=class extends yr{constructor(){super();G(this,Lt,!0);G(this,ct);G(this,Dt);L(this,Dt,e=>{if(!Pt&&window.addEventListener){const r=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){l(this,ct)||this.setEventListener(l(this,Dt))}onUnsubscribe(){var e;this.hasListeners()||((e=l(this,ct))==null||e.call(this),L(this,ct,void 0))}setEventListener(e){var r;L(this,Dt,e),(r=l(this,ct))==null||r.call(this),L(this,ct,e(this.setOnline.bind(this)))}setOnline(e){l(this,Lt)!==e&&(L(this,Lt,e),this.listeners.forEach(n=>{n(e)}))}isOnline(){return l(this,Lt)}},Lt=new WeakMap,ct=new WeakMap,Dt=new WeakMap,Ds),Rr=new Xn;function Jn(t){return Math.min(1e3*2**t,3e4)}function Ys(t){return(t??"online")==="online"?Rr.isOnline():!0}var Yr=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function Xs(t){let e=!1,r=0,n;const i=Gr(),c=()=>i.status!=="pending",h=g=>{var E;if(!c()){const b=new Yr(g);S(b),(E=t.onCancel)==null||E.call(t,b)}},u=()=>{e=!0},y=()=>{e=!1},k=()=>os.isFocused()&&(t.networkMode==="always"||Rr.isOnline())&&t.canRun(),f=()=>Ys(t.networkMode)&&t.canRun(),p=g=>{c()||(n==null||n(),i.resolve(g))},S=g=>{c()||(n==null||n(),i.reject(g))},x=()=>new Promise(g=>{var E;n=b=>{(c()||k())&&g(b)},(E=t.onPause)==null||E.call(t)}).then(()=>{var g;n=void 0,c()||(g=t.onContinue)==null||g.call(t)}),j=()=>{if(c())return;let g;const E=r===0?t.initialPromise:void 0;try{g=E??t.fn()}catch(b){g=Promise.reject(b)}Promise.resolve(g).then(p).catch(b=>{var A;if(c())return;const v=t.retry??(Pt?0:3),d=t.retryDelay??Jn,_=typeof d=="function"?d(r,b):d,B=v===!0||typeof v=="number"&&r<v||typeof v=="function"&&v(r,b);if(e||!B){S(b);return}r++,(A=t.onFail)==null||A.call(t,r,b),Hn(_).then(()=>k()?void 0:x()).then(()=>{e?S(b):j()})})};return{promise:i,status:()=>i.status,cancel:h,continue:()=>(n==null||n(),i),cancelRetry:u,continueRetry:y,canStart:f,start:()=>(f()?j():x().then(j),i)}}var Tt,Ws,Js=(Ws=class{constructor(){G(this,Tt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Hr(this.gcTime)&&L(this,Tt,jt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Pt?1/0:5*60*1e3))}clearGcTimeout(){l(this,Tt)&&(jt.clearTimeout(l(this,Tt)),L(this,Tt,void 0))}},Tt=new WeakMap,Ws),Rt,Wt,Me,Ct,me,pr,Nt,$e,Xe,zs,Zn=(zs=class extends Js{constructor(e){super();G(this,$e);G(this,Rt);G(this,Wt);G(this,Me);G(this,Ct);G(this,me);G(this,pr);G(this,Nt);L(this,Nt,!1),L(this,pr,e.defaultOptions),this.setOptions(e.options),this.observers=[],L(this,Ct,e.client),L(this,Me,l(this,Ct).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,L(this,Rt,Ss(this.options)),this.state=e.state??l(this,Rt),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=l(this,me))==null?void 0:e.promise}setOptions(e){if(this.options={...l(this,pr),...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=Ss(this.options);r.data!==void 0&&(this.setState(ks(r.data,r.dataUpdatedAt)),L(this,Rt,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&l(this,Me).remove(this)}setData(e,r){const n=Vr(this.state.data,e,this.options);return re(this,$e,Xe).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(e,r){re(this,$e,Xe).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var n,i;const r=(n=l(this,me))==null?void 0:n.promise;return(i=l(this,me))==null||i.cancel(e),r?r.then(Te).catch(Te):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(l(this,Rt))}isActive(){return this.observers.some(e=>Ae(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Tr||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>bt(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(n=>n.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=l(this,me))==null||r.continue()}onOnline(){var r;const e=this.observers.find(n=>n.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=l(this,me))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),l(this,Me).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(l(this,me)&&(l(this,Nt)?l(this,me).cancel({revert:!0}):l(this,me).cancelRetry()),this.scheduleGc()),l(this,Me).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||re(this,$e,Xe).call(this,{type:"invalidate"})}async fetch(e,r){var y,k,f,p,S,x,j,g,E,b,v,d;if(this.state.fetchStatus!=="idle"&&((y=l(this,me))==null?void 0:y.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(l(this,me))return l(this,me).continueRetry(),l(this,me).promise}if(e&&this.setOptions(e),!this.options.queryFn){const _=this.observers.find(B=>B.options.queryFn);_&&this.setOptions(_.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 n=new AbortController,i=_=>{Object.defineProperty(_,"signal",{enumerable:!0,get:()=>(L(this,Nt,!0),n.signal)})},c=()=>{const _=Vs(this.options,r),A=(()=>{const H={client:l(this,Ct),queryKey:this.queryKey,meta:this.meta};return i(H),H})();return L(this,Nt,!1),this.options.persister?this.options.persister(_,A,this):_(A)},u=(()=>{const _={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:l(this,Ct),state:this.state,fetchFn:c};return i(_),_})();(k=this.options.behavior)==null||k.onFetch(u,this),L(this,Wt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=u.fetchOptions)==null?void 0:f.meta))&&re(this,$e,Xe).call(this,{type:"fetch",meta:(p=u.fetchOptions)==null?void 0:p.meta}),L(this,me,Xs({initialPromise:r==null?void 0:r.initialPromise,fn:u.fetchFn,onCancel:_=>{_ instanceof Yr&&_.revert&&this.setState({...l(this,Wt),fetchStatus:"idle"}),n.abort()},onFail:(_,B)=>{re(this,$e,Xe).call(this,{type:"failed",failureCount:_,error:B})},onPause:()=>{re(this,$e,Xe).call(this,{type:"pause"})},onContinue:()=>{re(this,$e,Xe).call(this,{type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode,canRun:()=>!0}));try{const _=await l(this,me).start();if(_===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(_),(x=(S=l(this,Me).config).onSuccess)==null||x.call(S,_,this),(g=(j=l(this,Me).config).onSettled)==null||g.call(j,_,this.state.error,this),_}catch(_){if(_ instanceof Yr){if(_.silent)return l(this,me).promise;if(_.revert){if(this.state.data===void 0)throw _;return this.state.data}}throw re(this,$e,Xe).call(this,{type:"error",error:_}),(b=(E=l(this,Me).config).onError)==null||b.call(E,_,this),(d=(v=l(this,Me).config).onSettled)==null||d.call(v,this.state.data,_,this),_}finally{this.scheduleGc()}}},Rt=new WeakMap,Wt=new WeakMap,Me=new WeakMap,Ct=new WeakMap,me=new WeakMap,pr=new WeakMap,Nt=new WeakMap,$e=new WeakSet,Xe=function(e){const r=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Zs(n.data,this.options),fetchMeta:e.meta??null};case"success":const i={...n,...ks(e.data,e.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return L(this,Wt,e.manual?i:void 0),i;case"error":const c=e.error;return{...n,error:c,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:c,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=r(this.state),ye.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),l(this,Me).notify({query:this,type:"updated",action:e})})},zs);function Zs(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ys(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function ks(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Ss(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,n=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Ee,se,gr,ke,Ft,zt,Je,ut,br,$t,Ut,Bt,It,dt,Ht,le,lr,Xr,Jr,Zr,es,ts,rs,ss,en,$s,ei=($s=class extends yr{constructor(e,r){super();G(this,le);G(this,Ee);G(this,se);G(this,gr);G(this,ke);G(this,Ft);G(this,zt);G(this,Je);G(this,ut);G(this,br);G(this,$t);G(this,Ut);G(this,Bt);G(this,It);G(this,dt);G(this,Ht,new Set);this.options=r,L(this,Ee,e),L(this,ut,null),L(this,Je,Gr()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(l(this,se).addObserver(this),js(l(this,se),this.options)?re(this,le,lr).call(this):this.updateResult(),re(this,le,es).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ns(l(this,se),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ns(l(this,se),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,re(this,le,ts).call(this),re(this,le,rs).call(this),l(this,se).removeObserver(this)}setOptions(e){const r=this.options,n=l(this,se);if(this.options=l(this,Ee).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ae(this.options.enabled,l(this,se))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");re(this,le,ss).call(this),l(this,se).setOptions(this.options),r._defaulted&&!Qr(this.options,r)&&l(this,Ee).getQueryCache().notify({type:"observerOptionsUpdated",query:l(this,se),observer:this});const i=this.hasListeners();i&&_s(l(this,se),n,this.options,r)&&re(this,le,lr).call(this),this.updateResult(),i&&(l(this,se)!==n||Ae(this.options.enabled,l(this,se))!==Ae(r.enabled,l(this,se))||bt(this.options.staleTime,l(this,se))!==bt(r.staleTime,l(this,se)))&&re(this,le,Xr).call(this);const c=re(this,le,Jr).call(this);i&&(l(this,se)!==n||Ae(this.options.enabled,l(this,se))!==Ae(r.enabled,l(this,se))||c!==l(this,dt))&&re(this,le,Zr).call(this,c)}getOptimisticResult(e){const r=l(this,Ee).getQueryCache().build(l(this,Ee),e),n=this.createResult(r,e);return ri(this,n)&&(L(this,ke,n),L(this,zt,this.options),L(this,Ft,l(this,se).state)),n}getCurrentResult(){return l(this,ke)}trackResult(e,r){return new Proxy(e,{get:(n,i)=>(this.trackProp(i),r==null||r(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&l(this,Je).status==="pending"&&l(this,Je).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,i))})}trackProp(e){l(this,Ht).add(e)}getCurrentQuery(){return l(this,se)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=l(this,Ee).defaultQueryOptions(e),n=l(this,Ee).getQueryCache().build(l(this,Ee),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(e){return re(this,le,lr).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),l(this,ke)))}createResult(e,r){var z;const n=l(this,se),i=this.options,c=l(this,ke),h=l(this,Ft),u=l(this,zt),k=e!==n?e.state:l(this,gr),{state:f}=e;let p={...f},S=!1,x;if(r._optimisticResults){const m=this.hasListeners(),T=!m&&js(e,r),C=m&&_s(e,n,r,i);(T||C)&&(p={...p,...Zs(f.data,e.options)}),r._optimisticResults==="isRestoring"&&(p.fetchStatus="idle")}let{error:j,errorUpdatedAt:g,status:E}=p;x=p.data;let b=!1;if(r.placeholderData!==void 0&&x===void 0&&E==="pending"){let m;c!=null&&c.isPlaceholderData&&r.placeholderData===(u==null?void 0:u.placeholderData)?(m=c.data,b=!0):m=typeof r.placeholderData=="function"?r.placeholderData((z=l(this,Ut))==null?void 0:z.state.data,l(this,Ut)):r.placeholderData,m!==void 0&&(E="success",x=Vr(c==null?void 0:c.data,m,r),S=!0)}if(r.select&&x!==void 0&&!b)if(c&&x===(h==null?void 0:h.data)&&r.select===l(this,br))x=l(this,$t);else try{L(this,br,r.select),x=r.select(x),x=Vr(c==null?void 0:c.data,x,r),L(this,$t,x),L(this,ut,null)}catch(m){L(this,ut,m)}l(this,ut)&&(j=l(this,ut),x=l(this,$t),g=Date.now(),E="error");const v=p.fetchStatus==="fetching",d=E==="pending",_=E==="error",B=d&&v,A=x!==void 0,I={status:E,fetchStatus:p.fetchStatus,isPending:d,isSuccess:E==="success",isError:_,isInitialLoading:B,isLoading:B,data:x,dataUpdatedAt:p.dataUpdatedAt,error:j,errorUpdatedAt:g,failureCount:p.fetchFailureCount,failureReason:p.fetchFailureReason,errorUpdateCount:p.errorUpdateCount,isFetched:p.dataUpdateCount>0||p.errorUpdateCount>0,isFetchedAfterMount:p.dataUpdateCount>k.dataUpdateCount||p.errorUpdateCount>k.errorUpdateCount,isFetching:v,isRefetching:v&&!d,isLoadingError:_&&!A,isPaused:p.fetchStatus==="paused",isPlaceholderData:S,isRefetchError:_&&A,isStale:ls(e,r),refetch:this.refetch,promise:l(this,Je),isEnabled:Ae(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const m=I.data!==void 0,T=I.status==="error"&&!m,C=q=>{T?q.reject(I.error):m&&q.resolve(I.data)},N=()=>{const q=L(this,Je,I.promise=Gr());C(q)},w=l(this,Je);switch(w.status){case"pending":e.queryHash===n.queryHash&&C(w);break;case"fulfilled":(T||I.data!==w.value)&&N();break;case"rejected":(!T||I.error!==w.reason)&&N();break}}return I}updateResult(){const e=l(this,ke),r=this.createResult(l(this,se),this.options);if(L(this,Ft,l(this,se).state),L(this,zt,this.options),l(this,Ft).data!==void 0&&L(this,Ut,l(this,se)),Qr(r,e))return;L(this,ke,r);const n=()=>{if(!e)return!0;const{notifyOnChangeProps:i}=this.options,c=typeof i=="function"?i():i;if(c==="all"||!c&&!l(this,Ht).size)return!0;const h=new Set(c??l(this,Ht));return this.options.throwOnError&&h.add("error"),Object.keys(l(this,ke)).some(u=>{const y=u;return l(this,ke)[y]!==e[y]&&h.has(y)})};re(this,le,en).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&re(this,le,es).call(this)}},Ee=new WeakMap,se=new WeakMap,gr=new WeakMap,ke=new WeakMap,Ft=new WeakMap,zt=new WeakMap,Je=new WeakMap,ut=new WeakMap,br=new WeakMap,$t=new WeakMap,Ut=new WeakMap,Bt=new WeakMap,It=new WeakMap,dt=new WeakMap,Ht=new WeakMap,le=new WeakSet,lr=function(e){re(this,le,ss).call(this);let r=l(this,se).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(Te)),r},Xr=function(){re(this,le,ts).call(this);const e=bt(this.options.staleTime,l(this,se));if(Pt||l(this,ke).isStale||!Hr(e))return;const n=Ks(l(this,ke).dataUpdatedAt,e)+1;L(this,Bt,jt.setTimeout(()=>{l(this,ke).isStale||this.updateResult()},n))},Jr=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(l(this,se)):this.options.refetchInterval)??!1},Zr=function(e){re(this,le,rs).call(this),L(this,dt,e),!(Pt||Ae(this.options.enabled,l(this,se))===!1||!Hr(l(this,dt))||l(this,dt)===0)&&L(this,It,jt.setInterval(()=>{(this.options.refetchIntervalInBackground||os.isFocused())&&re(this,le,lr).call(this)},l(this,dt)))},es=function(){re(this,le,Xr).call(this),re(this,le,Zr).call(this,re(this,le,Jr).call(this))},ts=function(){l(this,Bt)&&(jt.clearTimeout(l(this,Bt)),L(this,Bt,void 0))},rs=function(){l(this,It)&&(jt.clearInterval(l(this,It)),L(this,It,void 0))},ss=function(){const e=l(this,Ee).getQueryCache().build(l(this,Ee),this.options);if(e===l(this,se))return;const r=l(this,se);L(this,se,e),L(this,gr,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},en=function(e){ye.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(l(this,ke))}),l(this,Ee).getQueryCache().notify({query:l(this,se),type:"observerResultsUpdated"})})},$s);function ti(t,e){return Ae(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function js(t,e){return ti(t,e)||t.state.data!==void 0&&ns(t,e,e.refetchOnMount)}function ns(t,e,r){if(Ae(e.enabled,t)!==!1&&bt(e.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&ls(t,e)}return!1}function _s(t,e,r,n){return(t!==e||Ae(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&ls(t,r)}function ls(t,e){return Ae(e.enabled,t)!==!1&&t.isStaleByTime(bt(e.staleTime,t))}function ri(t,e){return!Qr(t.getCurrentResult(),e)}function Es(t){return{onFetch:(e,r)=>{var f,p,S,x,j;const n=e.options,i=(S=(p=(f=e.fetchOptions)==null?void 0:f.meta)==null?void 0:p.fetchMore)==null?void 0:S.direction,c=((x=e.state.data)==null?void 0:x.pages)||[],h=((j=e.state.data)==null?void 0:j.pageParams)||[];let u={pages:[],pageParams:[]},y=0;const k=async()=>{let g=!1;const E=d=>{Kn(d,()=>e.signal,()=>g=!0)},b=Vs(e.options,e.fetchOptions),v=async(d,_,B)=>{if(g)return Promise.reject();if(_==null&&d.pages.length)return Promise.resolve(d);const H=(()=>{const T={client:e.client,queryKey:e.queryKey,pageParam:_,direction:B?"backward":"forward",meta:e.options.meta};return E(T),T})(),I=await b(H),{maxPages:z}=e.options,m=B?Qn:qn;return{pages:m(d.pages,I,z),pageParams:m(d.pageParams,_,z)}};if(i&&c.length){const d=i==="backward",_=d?si:Ts,B={pages:c,pageParams:h},A=_(n,B);u=await v(B,A,d)}else{const d=t??c.length;do{const _=y===0?h[0]??n.initialPageParam:Ts(n,u);if(y>0&&_==null)break;u=await v(u,_),y++}while(y<d)}return u};e.options.persister?e.fetchFn=()=>{var g,E;return(E=(g=e.options).persister)==null?void 0:E.call(g,k,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=k}}}function Ts(t,{pages:e,pageParams:r}){const n=e.length-1;return e.length>0?t.getNextPageParam(e[n],e,r[n],r):void 0}function si(t,{pages:e,pageParams:r}){var n;return e.length>0?(n=t.getPreviousPageParam)==null?void 0:n.call(t,e[0],e,r[0],r):void 0}var mr,Ke,Se,Ot,Ve,ot,Us,ni=(Us=class extends Js{constructor(e){super();G(this,Ve);G(this,mr);G(this,Ke);G(this,Se);G(this,Ot);L(this,mr,e.client),this.mutationId=e.mutationId,L(this,Se,e.mutationCache),L(this,Ke,[]),this.state=e.state||ii(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){l(this,Ke).includes(e)||(l(this,Ke).push(e),this.clearGcTimeout(),l(this,Se).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){L(this,Ke,l(this,Ke).filter(r=>r!==e)),this.scheduleGc(),l(this,Se).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){l(this,Ke).length||(this.state.status==="pending"?this.scheduleGc():l(this,Se).remove(this))}continue(){var e;return((e=l(this,Ot))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var h,u,y,k,f,p,S,x,j,g,E,b,v,d,_,B,A,H,I,z;const r=()=>{re(this,Ve,ot).call(this,{type:"continue"})},n={client:l(this,mr),meta:this.options.meta,mutationKey:this.options.mutationKey};L(this,Ot,Xs({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(new Error("No mutationFn found")),onFail:(m,T)=>{re(this,Ve,ot).call(this,{type:"failed",failureCount:m,error:T})},onPause:()=>{re(this,Ve,ot).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>l(this,Se).canRun(this)}));const i=this.state.status==="pending",c=!l(this,Ot).canStart();try{if(i)r();else{re(this,Ve,ot).call(this,{type:"pending",variables:e,isPaused:c}),await((u=(h=l(this,Se).config).onMutate)==null?void 0:u.call(h,e,this,n));const T=await((k=(y=this.options).onMutate)==null?void 0:k.call(y,e,n));T!==this.state.context&&re(this,Ve,ot).call(this,{type:"pending",context:T,variables:e,isPaused:c})}const m=await l(this,Ot).start();return await((p=(f=l(this,Se).config).onSuccess)==null?void 0:p.call(f,m,e,this.state.context,this,n)),await((x=(S=this.options).onSuccess)==null?void 0:x.call(S,m,e,this.state.context,n)),await((g=(j=l(this,Se).config).onSettled)==null?void 0:g.call(j,m,null,this.state.variables,this.state.context,this,n)),await((b=(E=this.options).onSettled)==null?void 0:b.call(E,m,null,e,this.state.context,n)),re(this,Ve,ot).call(this,{type:"success",data:m}),m}catch(m){try{await((d=(v=l(this,Se).config).onError)==null?void 0:d.call(v,m,e,this.state.context,this,n))}catch(T){Promise.reject(T)}try{await((B=(_=this.options).onError)==null?void 0:B.call(_,m,e,this.state.context,n))}catch(T){Promise.reject(T)}try{await((H=(A=l(this,Se).config).onSettled)==null?void 0:H.call(A,void 0,m,this.state.variables,this.state.context,this,n))}catch(T){Promise.reject(T)}try{await((z=(I=this.options).onSettled)==null?void 0:z.call(I,void 0,m,e,this.state.context,n))}catch(T){Promise.reject(T)}throw re(this,Ve,ot).call(this,{type:"error",error:m}),m}finally{l(this,Se).runNext(this)}}},mr=new WeakMap,Ke=new WeakMap,Se=new WeakMap,Ot=new WeakMap,Ve=new WeakSet,ot=function(e){const r=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,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{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),ye.batch(()=>{l(this,Ke).forEach(n=>{n.onMutationUpdate(e)}),l(this,Se).notify({mutation:this,type:"updated",action:e})})},Us);function ii(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ze,Ue,xr,Hs,ai=(Hs=class extends yr{constructor(e={}){super();G(this,Ze);G(this,Ue);G(this,xr);this.config=e,L(this,Ze,new Set),L(this,Ue,new Map),L(this,xr,0)}build(e,r,n){const i=new ni({client:e,mutationCache:this,mutationId:++jr(this,xr)._,options:e.defaultMutationOptions(r),state:n});return this.add(i),i}add(e){l(this,Ze).add(e);const r=_r(e);if(typeof r=="string"){const n=l(this,Ue).get(r);n?n.push(e):l(this,Ue).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(l(this,Ze).delete(e)){const r=_r(e);if(typeof r=="string"){const n=l(this,Ue).get(r);if(n)if(n.length>1){const i=n.indexOf(e);i!==-1&&n.splice(i,1)}else n[0]===e&&l(this,Ue).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=_r(e);if(typeof r=="string"){const n=l(this,Ue).get(r),i=n==null?void 0:n.find(c=>c.state.status==="pending");return!i||i===e}else return!0}runNext(e){var n;const r=_r(e);if(typeof r=="string"){const i=(n=l(this,Ue).get(r))==null?void 0:n.find(c=>c!==e&&c.state.isPaused);return(i==null?void 0:i.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ye.batch(()=>{l(this,Ze).forEach(e=>{this.notify({type:"removed",mutation:e})}),l(this,Ze).clear(),l(this,Ue).clear()})}getAll(){return Array.from(l(this,Ze))}find(e){const r={exact:!0,...e};return this.getAll().find(n=>ys(r,n))}findAll(e={}){return this.getAll().filter(r=>ys(e,r))}notify(e){ye.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return ye.batch(()=>Promise.all(e.map(r=>r.continue().catch(Te))))}},Ze=new WeakMap,Ue=new WeakMap,xr=new WeakMap,Hs);function _r(t){var e;return(e=t.options.scope)==null?void 0:e.id}var Ge,qs,oi=(qs=class extends yr{constructor(e={}){super();G(this,Ge);this.config=e,L(this,Ge,new Map)}build(e,r,n){const i=r.queryKey,c=r.queryHash??as(i,r);let h=this.get(c);return h||(h=new Zn({client:e,queryKey:i,queryHash:c,options:e.defaultQueryOptions(r),state:n,defaultOptions:e.getQueryDefaults(i)}),this.add(h)),h}add(e){l(this,Ge).has(e.queryHash)||(l(this,Ge).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=l(this,Ge).get(e.queryHash);r&&(e.destroy(),r===e&&l(this,Ge).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ye.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return l(this,Ge).get(e)}getAll(){return[...l(this,Ge).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(n=>xs(r,n))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(n=>xs(e,n)):r}notify(e){ye.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){ye.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ye.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Ge=new WeakMap,qs),he,ht,ft,qt,Qt,pt,Kt,Vt,Qs,li=(Qs=class{constructor(t={}){G(this,he);G(this,ht);G(this,ft);G(this,qt);G(this,Qt);G(this,pt);G(this,Kt);G(this,Vt);L(this,he,t.queryCache||new oi),L(this,ht,t.mutationCache||new ai),L(this,ft,t.defaultOptions||{}),L(this,qt,new Map),L(this,Qt,new Map),L(this,pt,0)}mount(){jr(this,pt)._++,l(this,pt)===1&&(L(this,Kt,os.subscribe(async t=>{t&&(await this.resumePausedMutations(),l(this,he).onFocus())})),L(this,Vt,Rr.subscribe(async t=>{t&&(await this.resumePausedMutations(),l(this,he).onOnline())})))}unmount(){var t,e;jr(this,pt)._--,l(this,pt)===0&&((t=l(this,Kt))==null||t.call(this),L(this,Kt,void 0),(e=l(this,Vt))==null||e.call(this),L(this,Vt,void 0))}isFetching(t){return l(this,he).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return l(this,ht).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=l(this,he).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=l(this,he).build(this,e),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(bt(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return l(this,he).findAll(t).map(({queryKey:e,state:r})=>{const n=r.data;return[e,n]})}setQueryData(t,e,r){const n=this.defaultQueryOptions({queryKey:t}),i=l(this,he).get(n.queryHash),c=i==null?void 0:i.state.data,h=$n(e,c);if(h!==void 0)return l(this,he).build(this,n).setData(h,{...r,manual:!0})}setQueriesData(t,e,r){return ye.batch(()=>l(this,he).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=l(this,he).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=l(this,he);ye.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=l(this,he);return ye.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},n=ye.batch(()=>l(this,he).findAll(t).map(i=>i.cancel(r)));return Promise.all(n).then(Te).catch(Te)}invalidateQueries(t,e={}){return ye.batch(()=>(l(this,he).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},n=ye.batch(()=>l(this,he).findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let c=i.fetch(void 0,r);return r.throwOnError||(c=c.catch(Te)),i.state.fetchStatus==="paused"?Promise.resolve():c}));return Promise.all(n).then(Te)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=l(this,he).build(this,e);return r.isStaleByTime(bt(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Te).catch(Te)}fetchInfiniteQuery(t){return t.behavior=Es(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Te).catch(Te)}ensureInfiniteQueryData(t){return t.behavior=Es(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Rr.isOnline()?l(this,ht).resumePausedMutations():Promise.resolve()}getQueryCache(){return l(this,he)}getMutationCache(){return l(this,ht)}getDefaultOptions(){return l(this,ft)}setDefaultOptions(t){L(this,ft,t)}setQueryDefaults(t,e){l(this,qt).set(dr(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...l(this,qt).values()],r={};return e.forEach(n=>{hr(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,e){l(this,Qt).set(dr(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...l(this,Qt).values()],r={};return e.forEach(n=>{hr(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={...l(this,ft).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=as(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===Tr&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...l(this,ft).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){l(this,he).clear(),l(this,ht).clear()}},he=new WeakMap,ht=new WeakMap,ft=new WeakMap,qt=new WeakMap,Qt=new WeakMap,pt=new WeakMap,Kt=new WeakMap,Vt=new WeakMap,Qs),tn=Le.createContext(void 0),rn=t=>{const e=Le.useContext(tn);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},ci=({client:t,children:e})=>(Le.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),s.jsx(tn.Provider,{value:t,children:e})),sn=Le.createContext(!1),ui=()=>Le.useContext(sn);sn.Provider;function di(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var hi=Le.createContext(di()),fi=()=>Le.useContext(hi),pi=(t,e,r)=>{const n=r!=null&&r.state.error&&typeof t.throwOnError=="function"?Gs(t.throwOnError,[r.state.error,r]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||n)&&(e.isReset()||(t.retryOnMount=!1))},gi=t=>{Le.useEffect(()=>{t.clearReset()},[t])},bi=({result:t,errorResetBoundary:e,throwOnError:r,query:n,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(i&&t.data===void 0||Gs(r,[t.error,n])),mi=t=>{if(t.suspense){const r=i=>i==="static"?i:Math.max(i??1e3,1e3),n=t.staleTime;t.staleTime=typeof n=="function"?(...i)=>r(n(...i)):r(n),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},xi=(t,e)=>t.isLoading&&t.isFetching&&!e,yi=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,Rs=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function vi(t,e,r){var S,x,j,g;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 n=ui(),i=fi(),c=rn(),h=c.defaultQueryOptions(t);(x=(S=c.getDefaultOptions().queries)==null?void 0:S._experimental_beforeQuery)==null||x.call(S,h);const u=c.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=n?"isRestoring":"optimistic",mi(h),pi(h,i,u),gi(i);const y=!c.getQueryCache().get(h.queryHash),[k]=Le.useState(()=>new e(c,h)),f=k.getOptimisticResult(h),p=!n&&t.subscribed!==!1;if(Le.useSyncExternalStore(Le.useCallback(E=>{const b=p?k.subscribe(ye.batchCalls(E)):Te;return k.updateResult(),b},[k,p]),()=>k.getCurrentResult(),()=>k.getCurrentResult()),Le.useEffect(()=>{k.setOptions(h)},[h,k]),yi(h,f))throw Rs(h,k,i);if(bi({result:f,errorResetBoundary:i,throwOnError:h.throwOnError,query:u,suspense:h.suspense}))throw f.error;if((g=(j=c.getDefaultOptions().queries)==null?void 0:j._experimental_afterQuery)==null||g.call(j,h,f),h.experimental_prefetchInRender&&!Pt&&xi(f,n)){const E=y?Rs(h,k,i):u==null?void 0:u.promise;E==null||E.catch(Te).finally(()=>{k.updateResult()})}return h.notifyOnChangeProps?f:k.trackResult(f)}function vr(t,e){return vi(t,ei)}const wi=()=>`bob_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;function nn({ga4Config:t,hostContext:e,callbacks:r,enabled:n=!0}){const i=o.useRef(wi()),c=o.useRef(!1),h=o.useCallback((d,_)=>{if(!(!(t!=null&&t.measurementId)||typeof window>"u")&&window.gtag){const B={..._,send_to:t.measurementId};t.debug&&console.log("[BobAnalytics] GA4 event:",d,B),window.gtag("event",d,B)}},[t]),u=o.useCallback((d,_={})=>{var A,H,I,z,m,T,C,N;if(!n)return;const B={event_name:d,timestamp:new Date().toISOString(),session_id:i.current,user_email:(A=e==null?void 0:e.user)==null?void 0:A.email,user_id:(H=e==null?void 0:e.user)==null?void 0:H.id,vehicle_id:(m=(z=(I=e==null?void 0:e.vehicle)==null?void 0:I.selectedVehicle)==null?void 0:z.vehicle_id)==null?void 0:m.toString(),rego:(C=(T=e==null?void 0:e.vehicle)==null?void 0:T.selectedVehicle)==null?void 0:C.rego,parameters:_};h(d,{session_id:B.session_id,user_email:B.user_email,vehicle_id:B.vehicle_id,..._}),(N=r==null?void 0:r.onAnalyticsEvent)==null||N.call(r,B),t!=null&&t.debug&&console.log("[BobAnalytics] Event tracked:",B)},[n,e,r,h,t==null?void 0:t.debug]),y=o.useCallback(()=>{var d,_,B;c.current||(c.current=!0,u("bob_session_start",{widget_version:Gt,has_vehicle:!!((d=e==null?void 0:e.vehicle)!=null&&d.selectedVehicle),has_user:!!((_=e==null?void 0:e.user)!=null&&_.id)||!!((B=e==null?void 0:e.user)!=null&&B.email)}))},[u,e]),k=o.useCallback((d,_)=>{u("bob_message_sent",{message_length:d,has_vehicle:_})},[u]),f=o.useCallback(d=>{u("bob_vehicle_identified",{vehicle_make:d.make||"unknown",vehicle_model:d.model||"unknown",vehicle_year:d.year||"unknown",rego:d.rego})},[u]),p=o.useCallback((d,_)=>{u("bob_parts_viewed",{part_count:d,vehicle_id:_})},[u]),S=o.useCallback(d=>{u("bob_product_clicked",{sku:d.sku,product_name:d.product_name,price:d.price,brand:d.brand})},[u]),x=o.useCallback(d=>{u("bob_product_viewed",{sku:d.sku,product_name:d.product_name,price:d.price,brand:d.brand})},[u]),j=o.useCallback(d=>{u("bob_add_to_cart",{sku:d.sku,product_name:d.product_name,price:d.price,brand:d.brand,quantity:d.quantity??1})},[u]),g=o.useCallback((d,_)=>{u("bob_checkout_started",{cart_value:d,item_count:_})},[u]),E=o.useCallback(d=>{const _=Math.ceil(d/5/150*60);u("bob_speech_played",{text_length:d,duration_estimate:_})},[u]),b=o.useCallback(d=>{u("bob_speech_failed",{text_length:d})},[u]),v=o.useCallback((d,_)=>{u("bob_error",{error_type:d,error_message:_})},[u]);return o.useEffect(()=>{y()},[y]),{trackEvent:u,sessionId:i.current,trackSessionStart:y,trackMessageSent:k,trackVehicleIdentified:f,trackPartsViewed:p,trackProductClicked:S,trackProductViewed:x,trackAddToCart:j,trackCheckoutStarted:g,trackSpeechPlayed:E,trackSpeechFailed:b,trackError:v}}const Nr=o.createContext(null);function an({children:t,bobConfig:e,hostApiConfig:r,hostContext:n={},callbacks:i={},queryClient:c,ga4Config:h,analyticsEnabled:u=!0,bottomOffset:y=0,zIndexBase:k=50}){const f=o.useMemo(()=>new li({defaultOptions:{queries:{retry:1,staleTime:3e5}}}),[]),p=c||f,S=!!c;o.useEffect(()=>{console.log(`[BobWidget] v${Gt} initialized`),console.log(`[BobWidget] QueryClient: ${S?"external (shared)":"internal"}`),console.log(`[BobWidget] Analytics: ${u?"enabled":"disabled"}`),h!=null&&h.measurementId&&console.log(`[BobWidget] GA4: ${h.measurementId}`)},[S,u,h==null?void 0:h.measurementId]);const x=o.useMemo(()=>On.createClient(e.supabaseUrl,e.supabaseKey),[e.supabaseUrl,e.supabaseKey]),[j,g]=o.useState(n);o.useEffect(()=>{g(n)},[n]);const E=o.useCallback(v=>{g(d=>({...d,...v}))},[]),b=o.useMemo(()=>({bobSupabase:x,bobConfig:e,hostApiConfig:r,hostContext:j,callbacks:i,updateHostContext:E,ga4Config:h,analyticsEnabled:u,bottomOffset:y,zIndexBase:k}),[x,e,r,j,i,E,h,u,y,k]);return s.jsx(ci,{client:p,children:s.jsx(Nr.Provider,{value:b,children:t})})}function et(){const t=o.useContext(Nr);if(!t)throw new Error("useBobContext must be used within a BobProvider");return t}function ki(){const{bobSupabase:t}=et();return t}function Yt(){const t=o.useContext(Nr);return(t==null?void 0:t.bobSupabase)||null}function Si(){const{hostContext:t}=et();return t}function ji(){const{hostApiConfig:t}=et();return t}function _i(){const{callbacks:t}=et();return t}function Ei(){const{ga4Config:t,analyticsEnabled:e}=et();return{ga4Config:t,enabled:e}}function cs(){const t=o.useContext(Nr);return t?{bottomOffset:t.bottomOffset,zIndexBase:t.zIndexBase}:{bottomOffset:0,zIndexBase:50}}const Ti=15e3,Ri={greeting_returning:/ah hey|you again|what you after this time/i,greeting_welcome:/g'?day|welcome.*carfix|bob.*here/i,ask_rego:/need your rego|rego.*get cracking|what('?s| is) your rego/i,vehicle_not_found:/couldn'?t find that|double.?check.*plate/i,no_parts_found:/nothing came up|no results|sorry.*search/i,checkout_ready:/ready to checkout|checkout.*ready|choice.*checkout/i,rego_searching:/let('?s| us) see what car|sweet.*searching|searching for/i},ar=new Map,Ci=t=>t.replace(/\bya\b/gi,"you"),on=({onStart:t,onEnd:e,onFailed:r}={})=>{const{bobConfig:n,supabase:i}=et(),[c,h]=o.useState(!1),u=o.useRef(null),y=o.useRef(null),k=o.useRef(!1),f=o.useRef([]),p=o.useRef(!1),S=o.useRef(!1),x=o.useRef(null),j=o.useRef(null),g=o.useRef(t),E=o.useRef(e),b=o.useRef(r);o.useEffect(()=>{g.current=t,E.current=e,b.current=r},[t,e,r]);const v=o.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null)},[]),d=o.useCallback(()=>{var C;k.current||(k.current=!0,console.log("[BobWidget TTS] Fallback: triggering onStart without audio"),(C=g.current)==null||C.call(g))},[]),_=o.useCallback(async C=>{if(ar.has(C)){const N=ar.get(C);return console.log(`[BobWidget TTS] Cache hit for clip: ${C}`,N?"found":"null"),N||null}try{console.log(`[BobWidget TTS] Fetching clip from DB: ${C}`);const{data:N,error:w}=await i.from("bob_audio_clips").select("audio_url").eq("clip_key",C).eq("is_active",!0).single();return w||!N?(console.log(`[BobWidget TTS] No clip found for: ${C}`),ar.set(C,null),null):(console.log(`[BobWidget TTS] Clip found: ${C} -> ${N.audio_url}`),ar.set(C,N),N)}catch(N){return console.warn(`[BobWidget TTS] Clip lookup failed for ${C}:`,N),ar.set(C,null),null}},[i]),B=o.useCallback(async C=>{for(const[N,w]of Object.entries(Ri))if(w.test(C)){console.log(`[BobWidget TTS] Pattern matched: ${N}`);const q=await _(N);if(q!=null&&q.audio_url)return q.audio_url}return null},[_]),A=o.useCallback(async()=>{var q,$,X;if(p.current||f.current.length===0)return;p.current=!0;const C=f.current.shift();if(!C){p.current=!1;return}const{text:N,isGreeting:w}=C;w&&(S.current=!0),k.current=!1,v(),u.current&&(u.current.pause(),u.current=null),y.current=setTimeout(()=>{var Q,O;console.warn("[BobWidget TTS] Timeout - triggering fallback callbacks"),d(),h(!1),S.current=!1,(Q=E.current)==null||Q.call(E),(O=b.current)==null||O.call(b),u.current=null,p.current=!1,A()},Ti);try{let Q=null;if(Q=await B(N),Q)console.log("[BobWidget TTS] Using pre-recorded audio (fast path)");else{console.log("[BobWidget TTS] No pre-recorded clip, using ElevenLabs TTS");const D=Ci(N),U=await fetch(`${n.supabaseUrl}/functions/v1/bob-tts-elevenlabs`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.supabaseKey}`},body:JSON.stringify({text:D})});if(!U.ok){const W=await U.json().catch(()=>({}));throw console.error("[BobWidget TTS] Request failed:",W),new Error("TTS request failed")}const F=await U.blob();Q=URL.createObjectURL(F)}const O=new Audio(Q);u.current=O,O.onplay=()=>{var D;v(),x.current=null,k.current||(k.current=!0,h(!0),console.log("[BobWidget TTS] Audio playing, triggering onStart (animation: TALKING)"),(D=g.current)==null||D.call(g))},O.onended=()=>{var D;v(),h(!1),S.current=!1,console.log("[BobWidget TTS] Audio ended, triggering onEnd (animation: COMPLETE/IDLE)"),(D=E.current)==null||D.call(E),u.current=null,p.current=!1,A()},O.onerror=D=>{var U,F;v(),console.warn("[BobWidget TTS] Audio playback error:",D),d(),h(!1),S.current=!1,(U=E.current)==null||U.call(E),(F=b.current)==null||F.call(b),u.current=null,p.current=!1,A()};try{await O.play()}catch(D){console.warn("[BobWidget TTS] Audio play() failed (autoplay policy):",D),v(),w&&(x.current=N,console.log("[BobWidget TTS] Greeting stored for retry on user interaction")),d(),h(!1),S.current=!1,(q=E.current)==null||q.call(E),p.current=!1,A()}}catch(Q){v(),console.error("[BobWidget TTS] Speech synthesis error:",Q),d(),h(!1),S.current=!1,($=E.current)==null||$.call(E),(X=b.current)==null||X.call(b),p.current=!1,A()}},[n.supabaseUrl,n.supabaseKey,v,d,B]),H=o.useCallback((C,N=!1)=>{if(C.trim()){if(N){if(j.current===C){console.log(`[BobWidget TTS] Ignoring duplicate greeting: "${C.substring(0,30)}..."`);return}j.current=C,x.current=null}if(S.current&&!N){console.log("[BobWidget TTS] Greeting playing - queueing message"),f.current.push({text:C,isGreeting:N});return}N?f.current.unshift({text:C,isGreeting:N}):f.current.push({text:C,isGreeting:N}),A()}},[A]),I=o.useCallback(()=>{if(x.current&&!u.current&&!p.current){console.log("[BobWidget TTS] Retrying pending greeting on user interaction");const C=x.current;x.current=null,H(C,!0)}},[H]),z=o.useCallback(()=>{v(),f.current=[],u.current&&(u.current.pause(),u.current=null),h(!1),S.current=!1,p.current=!1},[v]),m=o.useCallback(()=>{var C;(C=u.current)==null||C.pause()},[]),T=o.useCallback(()=>{var C;(C=u.current)==null||C.play()},[]);return o.useEffect(()=>()=>{v(),f.current=[],u.current&&(u.current.pause(),u.current=null)},[v]),{speak:H,stop:z,pause:m,resume:T,isSpeaking:c,isSupported:!0,retryPendingGreeting:I}},Cs="bob_last_visit",Ni=30;function ln(t=Ni){const[e,r]=o.useState(!1),[n,i]=o.useState(null);return o.useEffect(()=>{try{const c=localStorage.getItem(Cs),h=Date.now();if(c){const u=parseInt(c,10),y=(h-u)/(1e3*60*60*24);y<=t?(r(!0),i(new Date(u)),console.log(`[BobWidget] Returning user detected - last visit ${Math.round(y)} days ago`)):console.log(`[BobWidget] Previous visit was ${Math.round(y)} days ago - treating as new user`)}else console.log("[BobWidget] First time visitor detected");localStorage.setItem(Cs,String(h))}catch(c){console.warn("[BobWidget] Could not access localStorage for returning user detection:",c)}},[t]),{isReturningUser:e,lastVisitDate:n,daysSinceLastVisit:n?Math.round((Date.now()-n.getTime())/(1e3*60*60*24)):null}}const is=t=>{if(!t)return t;let e=t;return e=e.replace(/\b(retrieve_parts|lookup_vehicle|search_general_products|retrieve_service_packages|add_to_cart|get_cart|create_checkout|get_customer_context|get_product_details|search_products|check_vehicle_fitment|search_web)\s*\([^)]*\)/gi,""),e=e.replace(/\(\s*(vehicleid|vehicle_id|part_type|query|plate|user_email|sku)\s*=\s*[^)]+\)/gi,""),e=e.replace(/\b(retrieve_parts|lookup_vehicle|search_general_products|retrieve_service_packages|add_to_cart|get_cart|create_checkout|get_customer_context|get_product_details|search_products|check_vehicle_fitment|search_web)\s*\(/gi,""),e=e.replace(/\b(vehicleid|vehicle_id|part_type)\s*=\s*(['"]?[\w\s]+['"]?)\s*,?\s*/gi,""),e=e.replace(/```[\s\S]*?```/g,""),e=e.replace(/\(\s*\)/g,""),e=e.replace(/\s{2,}/g," "),e=e.trim(),e},Wr=t=>{let e=is(t);return e=e.replace(/[\[\]{}]/g,""),e=e.replace(/https?:\/\/[^\s]+/g,""),e=e.replace(/\bSKU\s*:?\s*\w+/gi,""),e},Fi=["what version","which version","software version","bob version","your version","current version","running version","version number","what ver","which ver"],Ns=["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"],Bi=["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"],cn=({setAnimationState:t,manualMode:e=!1,talkingState:r="talk",thinkingState:n="research",completeState:i="complete",idleState:c="idle",listenState:h="talk_pause",onStreamStart:u,onStreamComplete:y,onShowingProduct:k,onResearchStart:f,onReadyToSpeak:p,onHighlightPart:S,onHighlightProduct:x,onNoPartsFound:j,onAutoFetchComplete:g})=>{var kr,Sr,Jt,Zt;const{bobConfig:E,hostApiConfig:b,hostContext:v,callbacks:d,ga4Config:_,analyticsEnabled:B}=et(),A=nn({ga4Config:_,hostContext:v,callbacks:d,enabled:B}),{isReturningUser:H}=ln(),[I,z]=o.useState([]),[m,T]=o.useState(""),[C,N]=o.useState(!1),[w,q]=o.useState(!1),[$,X]=o.useState(null),Q=o.useRef(null),O=o.useRef(!1),D=o.useRef(!1),U=o.useRef(""),F=o.useRef(!1),W=o.useRef(null),ae=o.useRef(null),Fe=o.useRef([]),ce=o.useRef(!1),xe=o.useRef(null),je=()=>{W.current&&(clearTimeout(W.current),W.current=null)},{speak:ve,stop:J,isSpeaking:Be,retryPendingGreeting:Ie}=on({onStart:()=>{je(),F.current=!0,console.log("[BobWidget STATE] Speech STARTED - transitioning to TALK state"),A.trackSpeechPlayed(U.current.length),p==null||p(),e||(console.log("[BobWidget STATE] Setting state to:",r),te(r))},onEnd:()=>{je(),console.log("[BobWidget STATE] Speech ENDED - transitioning out of TALK state");const V=Ns.some(ue=>U.current.toLowerCase().includes(ue.toLowerCase()));e||(V&&k?(console.log("[BobWidget STATE] Has products - calling onShowingProduct"),k()):y?(console.log("[BobWidget STATE] Calling onStreamComplete"),y()):(console.log("[BobWidget STATE] Setting state to:",i),te(i),setTimeout(()=>{console.log("[BobWidget STATE] Post-complete transition to:",h),te(h)},2e3)))},onFailed:()=>{console.warn("[BobWidget] Speech synthesis failed - fallback triggered"),A.trackSpeechFailed(U.current.length)}});o.useEffect(()=>{var V;(V=Q.current)==null||V.scrollIntoView({behavior:"smooth"})},[I]),o.useEffect(()=>{var ue,pe;const V=(ue=v.vehicle)==null?void 0:ue.selectedVehicle;V&&!$&&(console.log("[BobWidget] Setting vehicle from host context:",V),X(V),(pe=d.onVehicleIdentified)==null||pe.call(d,V),A.trackVehicleIdentified({make:V.make,model:V.model,year:V.year,rego:V.rego}))},[(kr=v.vehicle)==null?void 0:kr.selectedVehicle]),o.useEffect(()=>{var V;if(I.length===0&&!D.current){D.current=!0;const ue=(V=v.vehicle)==null?void 0:V.selectedVehicle;let pe;H?(pe="Ah hey... you again! What you after this time?",console.log("[BobWidget] Using returning user greeting")):ue?pe=`G'day! Saw you've got the ${`${ue.year} ${ue.make} ${ue.model}`} - choice wagon! What can I help you find for it today?`:pe="G'day! Bob from CARFIX here. How can I help ya today?",z([{role:"assistant",content:pe}]),w||setTimeout(()=>{console.log("[BobWidget] Speaking initial greeting (priority)"),ve(pe,!0)},500)}},[(Sr=v.vehicle)==null?void 0:Sr.selectedVehicle,I.length,w,ve]),o.useEffect(()=>{const V=()=>{console.log("[BobWidget] User interaction detected - retrying pending greeting"),Ie(),document.removeEventListener("click",V),document.removeEventListener("touchstart",V)};return document.addEventListener("click",V,{once:!0}),document.addEventListener("touchstart",V,{once:!0}),()=>{document.removeEventListener("click",V),document.removeEventListener("touchstart",V)}},[Ie]),o.useEffect(()=>{var mt,xt;const V=(mt=v.vehicle)==null?void 0:mt.selectedVehicle;if(!V||O.current)return;const ue=V.vehicle_id??V.id,pe=Number.parseInt(String(ue),10);if(!Number.isFinite(pe)){console.warn("[BobWidget] Vehicle has invalid vehicle_id, cannot auto-fetch:",V);return}O.current=!0;const we={...V,vehicle_id:String(pe)},rt=(xt=v.user)==null?void 0:xt.email;(async()=>{var yt,vt;const Mt=`${E.supabaseUrl}/functions/v1/bob-chat`;try{const Ce=await fetch(Mt,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.supabaseKey}`},body:JSON.stringify({messages:[],vehicleContext:we,customerEmail:rt,autoFetchParts:!0,hostConfig:b,hostContext:v})});if(!Ce.ok||!Ce.body){console.error("[BobWidget] Auto-fetch failed:",Ce.status);return}const wt=Ce.body.getReader(),De=new TextDecoder;let Oe="";for(;;){const{done:st,value:kt}=await wt.read();if(st)break;Oe+=De.decode(kt,{stream:!0});let nt;for(;(nt=Oe.indexOf(`
|
|
31
|
-
`))!==-1;){let Ne=
|
|
32
|
-
`))!==-1;){let Z=qe.slice(0,Y);if(qe=qe.slice(Y+1),Z.endsWith("\r")&&(Z=Z.slice(0,-1)),Z.startsWith(":")||Z.trim()===""||!Z.startsWith("data: "))continue;const oe=Z.slice(6).trim();if(oe==="[DONE]"){tr=!0;break}try{const M=JSON.parse(oe);if(M.type==="vehicle_identified"&&M.vehicle){X(M.vehicle),(mt=d.onVehicleIdentified)==null||mt.call(d,M.vehicle),A.trackVehicleIdentified({make:M.vehicle.make,model:M.vehicle.model,year:M.vehicle.year,rego:M.vehicle.rego});continue}if(M.type==="service_packages_found"&&M.packages){(xt=d.onServicePackagesFound)==null||xt.call(d,M.packages);continue}if(M.type==="parts_found"&&M.parts){(
|
|
33
|
-
`+qe;break}}}let rr=it.replace(/\[VEHICLE_CONFIRMED:\{[\s\S]*?\}\]/g,"");rr=is(rr),U.current=rr;const sr=Ns.some(R=>it.toLowerCase().includes(R.toLowerCase())),Ar=it.toLowerCase();for(const R of Bi)if(Ar.includes(R.toLowerCase())){const P=R.replace(/s\s*$/i,"").toUpperCase();S==null||S(P);break}const a=it.match(/(?:go with|recommend|suggest|grab|try)\s+(?:the\s+)?(\w+)\s+(?:at|for)\s+\$(\d+(?:\.\d{2})?)/i);if(a){const[,R,P]=a;x==null||x({brand:R,price:parseFloat(P)})}if(!w&&U.current.trim()){if(F.current=!1,je(),ae.current){console.log("[BobWidget] Playing canned audio:",ae.current);const R=new Audio(ae.current);R.onplay=()=>{console.log("[BobWidget] Canned audio STARTED"),F.current=!0,p==null||p(),e||te(r)},R.onended=()=>{console.log("[BobWidget] Canned audio ENDED"),je(),e||(sr&&k?k():y?y():(te(i),setTimeout(()=>te(h),3e3)))},R.onerror=()=>{console.error("[BobWidget] Canned audio failed, falling back to TTS");const P=Wr(U.current);ve(P)},R.play().catch(()=>{console.error("[BobWidget] Canned audio autoplay blocked, falling back to TTS");const P=Wr(U.current);ve(P)}),ae.current=null}else{const R=Wr(U.current);ve(R)}W.current=setTimeout(()=>{F.current||(console.warn("[BobWidget] Speech fallback after 2s"),p==null||p(),e||(sr&&k?k():y?y():(te(i),setTimeout(()=>te(h),3e3))))},2e3)}else p==null||p(),e||(sr&&k?k():y?y():(te(i),setTimeout(()=>te(h),3e3)))}catch(ge){console.error("[BobWidget] Chat error:",ge);const Pe=ge instanceof Error?ge:new Error("Unknown error");(St=d.onError)==null||St.call(d,Pe),A.trackError(Pe.name||"ChatError",Pe.message||"Unknown chat error"),e||te(c)}},He=async()=>{if(!m.trim()||C)return;Ie(),J();const V={role:"user",content:m};z(we=>[...we,V]),T(""),A.trackMessageSent(m.length,!!$);const ue=m.toLowerCase();if(Fi.some(we=>ue.includes(we))){const we=`G'day mate! I'm running Bob v${Gt} - she's running sweet as! Anything else I can help ya with?`;z(rt=>[...rt,{role:"assistant",content:we}]),w||ve(we);return}N(!0),console.log("[BobWidget STATE] User sent message - switching to RESEARCH state:",n),f==null||f(),e||te(n),await fe(V),N(!1)};return{messages:I,input:m,setInput:T,isLoading:C,handleSend:He,handleKeyPress:V=>{V.key==="Enter"&&!V.shiftKey&&(V.preventDefault(),He())},handleInputFocus:()=>{Ie()},handleInputBlur:()=>{},chatEndRef:Q,clearMessages:()=>{z([{role:"assistant",content:"G'day! Bob from CARFIX here. How can I help ya today?"}])},isMuted:w,toggleMute:()=>{q(V=>!V),w||J()},isSpeaking:Be,identifiedVehicle:$,clearVehicle:()=>{X(null)}}},Ii={states:[],configs:[],uploadedImages:[],looks:[],activeLookId:null},un=t=>{const e=rn(),r=Yt();return o.useEffect(()=>{if(!r)return;const n=r.channel("animation-states-changes").on("postgres_changes",{event:"*",schema:"public",table:"animation_states"},()=>{e.invalidateQueries({queryKey:["bob-animation-data"]})}).subscribe(),i=r.channel("bob-animations-changes").on("postgres_changes",{event:"*",schema:"public",table:"bob_animations"},()=>{e.invalidateQueries({queryKey:["bob-animation-data"]})}).subscribe();return()=>{r.removeChannel(n),r.removeChannel(i)}},[e,r]),vr({queryKey:["bob-animation-data",t],queryFn:async()=>{var E;if(!r)return console.log("[useBobAnimationData] No supabase client, returning empty data"),Ii;const{data:n,error:i}=await r.from("bob_looks").select("*").order("display_order");if(i)throw i;const c=(n||[]).find(b=>b.is_active),h=t||(c==null?void 0:c.id)||n&&((E=n[0])==null?void 0:E.id)||null;if(!h)return{states:[],configs:[],uploadedImages:[],looks:n||[],activeLookId:null};const{data:u,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:k,error:f}=await r.from("bob_animations").select("*").eq("is_active",!0).eq("look_id",h).order("animation_state").order("sequence_order");if(f)throw f;const p=new Set((u||[]).map(b=>b.state_key)),S=(k||[]).filter(b=>p.has(b.animation_state)),{data:x,error:j}=await r.storage.from("bob-images").list();if(j)throw j;const g=(x||[]).map(b=>{const{data:v}=r.storage.from("bob-images").getPublicUrl(b.name);return v.publicUrl});return S.forEach(b=>{const v=new Image;v.src=b.image_url}),{states:u||[],configs:S,uploadedImages:g,looks:n||[],activeLookId:h}},staleTime:30*1e3,gcTime:5*60*1e3})},dn=(t={})=>{const{isSpeaking:e=!1}=t,[r,n]=o.useState(""),[i,c]=o.useState(0),[h,u]=o.useState(400),[y,k]=o.useState(!1),f=o.useRef(null),p=o.useRef(0),S=o.useRef(e),x=o.useRef(0),j=o.useRef(0),g=o.useRef(!1),E=o.useRef(0),{data:b,isLoading:v}=un(),d=o.useRef({}),{imageUrlsMap:_,alternateImages:B,offsetsMap:A,scalesMap:H,availableStates:I}=o.useMemo(()=>{if(!b)return{imageUrlsMap:{},alternateImages:{},offsetsMap:{},scalesMap:{},availableStates:[]};const N={},w={},q={},$={},X=b.states.map(Q=>Q.state_key);return X.forEach(Q=>{const O=b.configs.filter(W=>W.animation_state===Q),D=O.map(W=>W.image_url),U=O.map(W=>W.vertical_offset||0),F=O.map(W=>W.scale||100);if(D.length>0){const W=b.states.find(ae=>ae.state_key===Q);N[Q]={url:D[0],animation_speed:(W==null?void 0:W.animation_speed)||400,pause_duration:(W==null?void 0:W.pause_duration)||0,loop_count:(W==null?void 0:W.loop_count)||0},w[Q]=D,q[Q]=U,$[Q]=F}}),{imageUrlsMap:N,alternateImages:w,offsetsMap:q,scalesMap:$,availableStates:X}},[b]);o.useEffect(()=>{d.current=_},[_]),o.useEffect(()=>{const N=S.current;if(S.current=e,N&&!e){const w=r.toLowerCase();(w.includes("talk")||w==="talking")&&(console.log("[useBobAnimation] Speech ended while in talk state - forcing loop completion"),j.current=999)}},[e,r]);const z=o.useCallback(N=>{n(w=>w===N?w:(x.current=0,j.current=0,g.current=!1,c(0),N))},[]);o.useEffect(()=>{I.length>0&&!r&&n(I[0])},[I,r]),o.useEffect(()=>{const N=B[r];if(f.current!==null&&(cancelAnimationFrame(f.current),f.current=null),x.current=0,j.current=0,g.current=!1,p.current=0,c(0),!N||N.length<=1)return;const w=d.current[r],q=(w==null?void 0:w.animation_speed)||h||400,$=(w==null?void 0:w.loop_count)||0,X=(w==null?void 0:w.pause_duration)||0,Q=r.toLowerCase().includes("talk"),O=D=>{if(p.current===0&&(p.current=D),g.current){D-E.current>=X&&(g.current=!1,j.current=0,p.current=D),f.current=requestAnimationFrame(O);return}if(D-p.current>=q){p.current=D;const F=(x.current+1)%N.length;F===0?(j.current++,Q&&S.current?(x.current=F,c(F)):$>0&&j.current>=$?X>0&&(g.current=!0,E.current=D):(x.current=F,c(F))):(x.current=F,c(F))}f.current=requestAnimationFrame(O)};return f.current=requestAnimationFrame(O),()=>{f.current!==null&&(cancelAnimationFrame(f.current),f.current=null)}},[r,B,h]);const m=o.useCallback(()=>{const N=B[r];if(!N||N.length===0){const w=I.find(q=>{var $;return(($=B[q])==null?void 0:$.length)>0});return w?(console.warn(`[useBobAnimation] No images for "${r}", using fallback: ${w}`),B[w][0]):(console.error("[useBobAnimation] No valid images found for any state!"),"")}return N[i]||N[0]},[B,r,I,i]),T=o.useCallback(()=>{const N=A[r];if(!N||N.length===0){const w=I.find(q=>{var $;return(($=A[q])==null?void 0:$.length)>0});return w?A[w][0]:0}return N[i]||N[0]},[A,r,I,i]),C=o.useCallback(()=>{const N=H[r];if(!N||N.length===0){const w=I.find(q=>{var $;return(($=H[q])==null?void 0:$.length)>0});return w?H[w][0]:100}return N[i]||N[0]},[H,r,I,i]);return{animationState:r,setAnimationState:z,getCurrentImage:m,getCurrentOffset:T,getCurrentScale:C,imageUrls:_,availableStates:I,setTalkSpeed:u,manualMode:y,setManualMode:k,isLoading:v}},hn=()=>{const t=Yt(),{data:e=[],isLoading:r}=vr({queryKey:["bob-backdrops"],queryFn:async()=>{if(!t)return console.log("[useBobBackdrop] No supabase client, returning empty"),[];const{data:i,error:c}=await t.from("bob_backdrops").select("*").order("display_order",{ascending:!0});if(c)throw c;return i},staleTime:5*60*1e3,gcTime:10*60*1e3}),n=e.find(i=>i.is_active);return{backdrops:e,activeBackdrop:n,isLoading:r}},fn=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:n,counterHeightPercent:i=12,className:c="",verticalOffset:h=0,scale:u=100})=>{const y=h+i,k=55*(u/100);return s.jsx("div",{className:`flex flex-col items-center justify-center gap-6 w-full ${c}`,children:s.jsxs("div",{className:"relative w-full max-w-[600px] mx-auto aspect-[16/10] overflow-hidden",children:[r&&s.jsx("img",{src:r,alt:"Backdrop",className:"absolute inset-0 z-0 w-full h-full object-cover object-bottom"}),s.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:`${k}%`,maxWidth:`${220*(u/100)}px`,transformOrigin:"center bottom"}}),n&&s.jsx("img",{src:n,alt:"Counter",className:"absolute z-20 bottom-0 left-0 w-full object-cover object-bottom",style:{height:`${i}%`}})]})})},K={primary:"#0052CC",primaryHover:"#0047B3",secondary:"#38BDF8",foreground:"#0F172A",accent:"#FF8C00",success:"#22C55E",destructive:"#EF4444",performanceRed:"#DC2626",mutedForeground:"#64748B",background:"#FAFAFA",card:"#FFFFFF",border:"#E2E8F0",slateEconomy:"#475569"},Cr={Economy:{icon:"DollarSign",emoji:"💰",textColor:"#475569",background:"#F1F5F9",border:"#CBD5E1",description:"Smart savings"},Standard:{icon:"Star",emoji:"⭐",textColor:"#0052CC",background:"rgba(0,82,204,0.1)",border:"rgba(0,82,204,0.3)",description:"Best value",isRecommended:!0},Premium:{icon:"Award",emoji:"🏆",textColor:"#D97706",background:"#FEF3C7",border:"#FCD34D",description:"Superior quality"},Performance:{icon:"Zap",emoji:"⚡",textColor:"#DC2626",background:"#FEE2E2",border:"#FCA5A5",description:"Maximum power"}},zr={"Oil Change":"Neglecting oil changes leads to engine wear, overheating, and catastrophic failure costing thousands. Quality oil and filters keep your engine running smoothly. Each CFX Oil Change Service Pack includes premium oil and filter matched to your engine specifications.","Front Brake Service":"Your front brakes handle 70% of stopping power. Worn pads dangerously increase stopping distance. Quality brake components ensure confident, safe stops. Each CFX Front Brake Service Pack includes pads and rotors to restore your braking performance.","Rear Brake Service":"Rear brakes provide stability and balance during emergency stops. Worn components cause instability and longer stopping distances. Each CFX Rear Brake Service Pack includes quality pads/shoes and rotors/drums for complete rear brake renewal.","Timing Belt Service":"A snapped timing belt destroys engines instantly, causing $8,000+ in damage. Preventive replacement is essential for peace of mind. Each CFX Timing Belt Service Pack includes the belt, tensioner, and related components.",Wipers:"Worn wipers reduce visibility in rain, compromising safety. Quality blades provide streak-free, clear vision. Each CFX Wipers Service Pack includes the gear you need to change all of your vehicle's wiper blades to restore your driving vision.","Coolant Service":"Old coolant causes overheating, warped cylinder heads, and engine seizure. Fresh coolant protects your entire cooling system. Each CFX Coolant Service Pack includes quality coolant matched to your vehicle's requirements.","Air Filter Service":"Clogged air filters reduce engine performance by 10% and increase fuel consumption. Clean filters improve power and economy. Each CFX Air Filter Service Pack includes a precision-fit filter for optimal airflow.","Spark Plug Service":"Worn spark plugs cause misfires, poor fuel economy, and catalytic converter damage. Fresh plugs restore smooth, efficient running. Each CFX Spark Plug Service Pack includes quality plugs matched to your engine.","Battery Service":"A failing battery leaves you stranded without warning. Reliable power is essential for starting and electronics. Each CFX Battery Service Pack includes a quality battery sized for your vehicle's demands.","Cabin Filter":"Cabin filters clean the air you and your passengers breathe. Replace regularly to remove pollen, dust, and odours. Each CFX Cabin Filter Service Pack includes a quality filter for fresh, clean cabin air.","Fuel Filter Service":"Clogged fuel filters restrict flow, causing poor performance and potential engine damage. Clean fuel is critical for efficiency. Each CFX Fuel Filter Service Pack includes a quality filter for optimal fuel delivery.","Transmission Service":"Old transmission fluid causes rough shifting, slipping, and premature wear. Fresh fluid extends transmission life. Each CFX Transmission Service Pack includes quality fluid matched to your transmission type."},Oi="Keep your vehicle running safely and efficiently with quality parts matched to your specific make and model. Each CFX Service Pack includes everything you need for this essential maintenance.",fr={productImage:t=>`https://flpzjbasdsfwoeruyxgp.supabase.co/storage/v1/object/public/product_images/${t}.jpg`,brandLogo:t=>`https://flpzjbasdsfwoeruyxgp.supabase.co/storage/v1/object/public/brand_images/${t.replace(/\s+/g,"")}.jpg`,carfixImage:t=>`https://flpzjbasdsfwoeruyxgp.supabase.co/storage/v1/object/public/carfix_images/${t}_1.jpg`},pn={fitsVehicle:{background:"rgba(34,197,94,0.1)",text:"#22C55E",border:"rgba(34,197,94,0.2)",icon:"Check",label:"Fits Your Vehicle"},viscosity:{background:"#EFF6FF",text:"#1D4ED8",border:"#BFDBFE",icon:"Gauge"},volume:{background:"#ECFEFF",text:"#0E7490",border:"#A5F3FC",icon:"Droplets"},quantity:{background:"#F1F5F9",text:"#475569",border:"#CBD5E1"},partNumber:{background:"transparent",text:"#64748B",border:"transparent"},carfixValue:{background:"rgba(0,82,204,0.1)",text:"#0052CC",border:"rgba(0,82,204,0.2)",icon:"Sparkles",label:"CARFIX Value"},rotorPair:{background:"#EFF6FF",text:"#1D4ED8",border:"#BFDBFE",label:"Pair"}},ze={packageTitle:{fontSize:"20px",fontWeight:700},partslotName:{fontSize:"14px",fontWeight:600},productName:{fontSize:"14px",fontWeight:500},description:{fontSize:"14px",fontWeight:400},priceMain:{fontSize:"20px",fontWeight:700},priceSecondary:{fontSize:"12px",fontWeight:400},tierLabel:{fontSize:"14px",fontWeight:500},badgeText:{fontSize:"12px",fontWeight:500}};function gn(t){var n;const e=((n=t.name)==null?void 0:n.toLowerCase())||"",r=(t.partslotDescription||t.partslot_description||"").toLowerCase();return e.includes("rotor")||r.includes("disc rotor")||r.includes("brake rotor")||t.per_car_qty===2}function bn(t,e){return e?{displayPrice:t*2,unitPriceLabel:`$${t.toFixed(2)} each`}:{displayPrice:t}}function gt(t){return`$${t.toFixed(2)}`}function mn(t){if(zr[t])return zr[t];const e=t.toLowerCase();for(const[r,n]of Object.entries(zr))if(e.includes(r.toLowerCase())||r.toLowerCase().includes(e))return n;return Oi}const cr=({type:t,value:e,className:r=""})=>{const n=pn[t],i=e||("label"in n?n.label:""),c=()=>{if(!("icon"in n))return null;const h={width:12,height:12};switch(n.icon){case"Check":return s.jsx("svg",{style:h,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})});case"Sparkles":return s.jsxs("svg",{style:h,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M12 3l1.5 4.5L18 9l-4.5 1.5L12 15l-1.5-4.5L6 9l4.5-1.5L12 3z"}),s.jsx("path",{d:"M5 19l1 3 1-3 3-1-3-1-1-3-1 3-3 1 3 1z"})]});case"Gauge":return s.jsxs("svg",{style:h,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 6v6l4 2"})]});case"Droplets":return s.jsx("svg",{style:h,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{d:"M12 2.69l5.66 5.66a8 8 0 11-11.31 0z"})});default:return null}};return s.jsxs("span",{className:r,style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"9999px",fontSize:"12px",fontWeight:500,background:n.background,color:n.text,border:`1px solid ${n.border}`,whiteSpace:"nowrap"},children:[c(),i]})},us=({products:t,title:e,onProductClick:r,onAddToCart:n})=>!t||t.length===0?null:s.jsxs("div",{style:{marginTop:"16px",width:"100%"},children:[e&&s.jsxs("div",{style:{marginBottom:"12px",fontSize:ze.partslotName.fontSize,fontWeight:ze.partslotName.fontWeight,color:K.foreground,display:"flex",alignItems:"center",gap:"8px"},children:[s.jsx("span",{style:{fontSize:"18px"},children:"🚗"}),e]}),s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:t.slice(0,6).map((i,c)=>s.jsx(Pi,{product:i,onProductClick:r,onAddToCart:n,isRecommended:c===0},i.id||i.sku||c))}),t.length>6&&s.jsxs("div",{style:{marginTop:"12px",fontSize:"13px",color:K.mutedForeground,textAlign:"center"},children:["+ ",t.length-6," more options available"]})]}),Pi=({product:t,onProductClick:e,onAddToCart:r,isRecommended:n=!1})=>{const[i,c]=o.useState(!1),[h,u]=o.useState(!1),y=t.image_url||t.image||(t.sku?fr.productImage(t.sku):null),k=t.brand?fr.brandLogo(t.brand):null,f=t.brand||"Quality Part",p=t.name||"Product",S=t.price??0,x=t.partNumber||t.part_number,j=gn({name:t.name,partslotDescription:t.partslotDescription,per_car_qty:t.quantity}),{displayPrice:g,unitPriceLabel:E}=bn(S,j);return s.jsxs("div",{style:{background:K.card,borderRadius:"12px",border:`2px solid ${K.border}`,overflow:"hidden",cursor:e?"pointer":"default",transition:"all 0.2s ease"},onClick:()=>e==null?void 0:e(t),onMouseEnter:b=>{b.currentTarget.style.borderColor=`${K.primary}80`,b.currentTarget.style.boxShadow="0 10px 25px rgba(0,0,0,0.1)"},onMouseLeave:b=>{b.currentTarget.style.borderColor=K.border,b.currentTarget.style.boxShadow="none"},children:[t.partslotDescription&&s.jsxs("div",{style:{background:"rgba(0,0,0,0.03)",borderBottom:`1px solid ${K.border}`,padding:"10px 16px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[s.jsx("span",{style:{fontSize:ze.partslotName.fontSize,fontWeight:ze.partslotName.fontWeight,color:K.foreground},children:t.partslotDescription}),n&&s.jsx(cr,{type:"carfixValue"})]}),s.jsxs("div",{style:{padding:"16px",display:"flex",gap:"16px"},children:[s.jsx("div",{style:{width:"96px",minWidth:"96px",height:"96px",borderRadius:"8px",background:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",border:`1px solid ${K.border}`},children:y&&!i?s.jsx("img",{src:y,alt:p,style:{width:"100%",height:"100%",objectFit:"contain",padding:"4px"},onError:()=>c(!0)}):s.jsx("span",{style:{fontSize:"32px",opacity:.5},children:"🔧"})}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[k&&!h&&s.jsx("img",{src:k,alt:f,style:{height:"16px",width:"auto",objectFit:"contain"},onError:()=>u(!0)}),s.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:K.foreground,textTransform:"uppercase"},children:f})]}),s.jsx("div",{style:{fontSize:ze.productName.fontSize,fontWeight:ze.productName.fontWeight,color:K.foreground,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",lineHeight:"1.4",marginBottom:"8px"},children:p}),s.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"12px"},children:[s.jsx(cr,{type:"fitsVehicle"}),j&&s.jsx(cr,{type:"rotorPair"}),t.quantity&&t.quantity>1&&!j&&s.jsx(cr,{type:"quantity",value:`Qty: ${t.quantity}`}),x&&s.jsxs("span",{style:{fontSize:"12px",color:K.mutedForeground},children:["#",x]})]})]}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"space-between",minWidth:"100px"},children:[s.jsxs("div",{style:{textAlign:"right"},children:[s.jsx("div",{style:{fontSize:ze.priceMain.fontSize,fontWeight:ze.priceMain.fontWeight,color:K.foreground},children:gt(g)}),E&&s.jsx("div",{style:{fontSize:ze.priceSecondary.fontSize,color:K.mutedForeground},children:E}),s.jsx("div",{style:{fontSize:ze.priceSecondary.fontSize,color:K.mutedForeground},children:"inc GST"})]}),r&&s.jsx("button",{onClick:b=>{b.stopPropagation(),r(t)},style:{background:K.primary,color:"#FFFFFF",border:"none",borderRadius:"8px",padding:"8px 16px",fontSize:"13px",fontWeight:600,cursor:"pointer",transition:"all 0.2s ease",whiteSpace:"nowrap"},onMouseEnter:b=>{b.currentTarget.style.background=K.primaryHover},onMouseLeave:b=>{b.currentTarget.style.background=K.primary},onMouseDown:b=>{b.currentTarget.style.transform="scale(0.98)"},onMouseUp:b=>{b.currentTarget.style.transform="scale(1)"},children:"Add to Cart"})]})]})]})},xn=({messages:t,input:e,setInput:r,isLoading:n,onSend:i,onKeyPress:c,onInputFocus:h,onInputBlur:u,chatEndRef:y,isMuted:k=!1,onToggleMute:f,isSpeaking:p=!1,className:S="",onAddToCart:x,onProductClick:j})=>s.jsx("div",{className:S,style:{width:"100%",maxWidth:"72rem",margin:"0 auto",padding:"0 16px 32px 16px"},children:s.jsxs("div",{style:{backgroundColor:"rgba(20, 30, 50, 0.85)",border:"1px solid rgba(255,255,255,0.15)",borderRadius:"16px",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.3)",overflow:"hidden"},children:[s.jsx("div",{style:{padding:"16px",borderBottom:"1px solid rgba(255,255,255,0.1)",backgroundColor:"rgba(0,0,0,0.2)"},children:s.jsxs("div",{style:{display:"flex",gap:"8px"},children:[s.jsx("input",{value:e,onChange:g=>r(g.target.value),onKeyPress:c,onFocus:h,onBlur:u,placeholder:"Ask Bob about car parts...",disabled:n,style:{flex:1,padding:"12px 16px",border:"1px solid rgba(255,255,255,0.2)",borderRadius:"12px",backgroundColor:"rgba(255,255,255,0.1)",color:"white",fontSize:"16px",outline:"none"}}),f&&s.jsx("button",{onClick:f,style:{flexShrink:0,padding:"12px",border:"1px solid rgba(255,255,255,0.2)",borderRadius:"12px",backgroundColor:"rgba(255,255,255,0.1)",cursor:"pointer",minHeight:"unset",minWidth:"unset"},title:k?"Unmute Bob's voice":"Mute Bob's voice",children:k?"🔇":"🔊"}),s.jsx("button",{onClick:i,disabled:n||!e.trim(),style:{flexShrink:0,padding:"12px 20px",background:n||!e.trim()?"rgba(0, 102, 204, 0.3)":"linear-gradient(135deg, rgba(0, 102, 204, 0.95), rgba(0, 73, 153, 1))",color:"white",borderRadius:"12px",border:"1px solid rgba(255,255,255,0.2)",cursor:n||!e.trim()?"not-allowed":"pointer",opacity:n||!e.trim()?.5:1,minHeight:"unset",minWidth:"unset",fontWeight:600},children:"Send"})]})}),s.jsxs("div",{style:{overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"12px",height:"400px",background:"rgba(0,0,0,0.1)"},children:[[...t].reverse().map((g,E)=>{var b;return s.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:g.role==="user"?"flex-end":"flex-start"},children:s.jsxs("div",{style:{maxWidth:(b=g.suggestedProducts)!=null&&b.length?"100%":"80%",borderRadius:"16px",padding:"12px 16px",fontSize:"14px",backgroundColor:g.role==="user"?"linear-gradient(135deg, rgba(0, 102, 204, 0.9), rgba(0, 73, 153, 1))":"rgba(255,255,255,0.1)",background:g.role==="user"?"linear-gradient(135deg, rgba(0, 102, 204, 0.9), rgba(0, 73, 153, 1))":"rgba(255,255,255,0.08)",color:"white",border:"1px solid rgba(255,255,255,0.15)",boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},children:[g.content,g.role==="assistant"&&g.suggestedProducts&&g.suggestedProducts.length>0&&s.jsx(us,{products:g.suggestedProducts,title:g.suggestionsTitle,onAddToCart:x,onProductClick:j})]})},E)}),s.jsx("div",{ref:y})]})]})}),Mi=768,Ai=1024;function Fr(){const[t,e]=o.useState("mobile");return o.useEffect(()=>{const r=()=>{const n=window.innerWidth;n>=Ai?e("desktop"):n>=Mi?e("tablet"):e("mobile")};return r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),t}function ds(){const t=Fr();return Li(t)}function Li(t){switch(t){case"mobile":return{bobOffset:1,productWidth:1,uiScale:1,partialLeftPosition:-55,hiddenPosition:-100};case"tablet":return{bobOffset:.7,productWidth:.85,uiScale:1.1,partialLeftPosition:-25,hiddenPosition:-80};case"desktop":return{bobOffset:.5,productWidth:.6,uiScale:1.2,partialLeftPosition:-5,hiddenPosition:-60};default:return{bobOffset:1,productWidth:1,uiScale:1,partialLeftPosition:-20,hiddenPosition:-100}}}const Br=({currentImage:t,animationState:e,counterOverlayUrl:r,counterHeightPercent:n=15,scale:i=100,position:c="center",verticalOffset:h=0,hasArrived:u=!0})=>{const y=ds(),f=95*i/100,p=550*i/100,S=()=>{switch(c){case"center":return"50%";case"partial-left":return`${y.partialLeftPosition}%`;case"hidden":return`${y.hiddenPosition}%`;default:return"50%"}},x=()=>c==="center"?"translateX(-50%)":"translateX(0)",j=n-2+h,g=()=>c==="hidden"?"all 0.35s cubic-bezier(0.4, 0, 0.2, 1)":"all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1)";return s.jsxs("div",{className:"absolute inset-0 pointer-events-none",style:{overflow:"visible"},children:[s.jsx("div",{className:"absolute z-[60]",style:{bottom:`${j}%`,left:S(),maxHeight:`${100-n-2}%`,transform:x(),width:`${f}%`,maxWidth:`${p}px`,transition:g()+", opacity 0.6s ease-out",willChange:"transform, left, opacity",opacity:u?1:0},children:s.jsx("img",{src:t,alt:`Bob ${e}`,className:"w-full h-auto object-contain",style:{display:"block",maxHeight:"100%"}})}),r&&s.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-[70]",style:{height:`${n}%`,pointerEvents:"none"},children:s.jsx("img",{src:r,alt:"Shop counter",className:"w-full h-full object-cover object-top"})})]})},Er={background:"rgba(20, 30, 50, 0.92)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"28px",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255,255,255,0.1)"},yn={background:"linear-gradient(135deg, rgba(40, 60, 100, 0.95) 0%, rgba(20, 40, 80, 0.98) 100%)",border:"1px solid rgba(255, 255, 255, 0.4)",borderRadius:"32px",boxShadow:"0 12px 48px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255,255,255,0.15), inset 0 1px 0 rgba(255,255,255,0.2)"},Fs={background:"linear-gradient(135deg, rgba(255, 149, 0, 0.95) 0%, rgba(230, 134, 0, 1) 100%)",backdropFilter:"blur(12px) saturate(180%)",WebkitBackdropFilter:"blur(12px) saturate(180%)",border:"1px solid rgba(255, 255, 255, 0.35)",borderRadius:"24px",boxShadow:"0 10px 40px rgba(255, 149, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.3)"},vn={background:"linear-gradient(135deg, rgba(0, 102, 204, 0.95) 0%, rgba(0, 73, 153, 1) 100%)",backdropFilter:"blur(16px) saturate(180%)",WebkitBackdropFilter:"blur(16px) saturate(180%)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"32px",boxShadow:"0 10px 40px rgba(0, 102, 204, 0.4), inset 0 1px 0 rgba(255,255,255,0.25)"},wn={background:"rgba(255, 255, 255, 0.08)",backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"28px",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3)"},ur={primary:{color:"rgba(255, 255, 255, 1)",textShadow:"0 1px 3px rgba(0,0,0,0.5)"}},Di={background:"rgba(255, 255, 255, 0.12)",borderRadius:"20px",border:"1px solid rgba(255, 255, 255, 0.15)"},Wi={background:"rgba(255, 255, 255, 0.15)",border:"1px solid rgba(255, 255, 255, 0.25)",borderRadius:"12px"},zi={width:"4px",height:"4px",borderRadius:"50%",background:"rgba(255, 255, 255, 0.6)",boxShadow:"0 0 8px rgba(255, 255, 255, 0.4)"},kn=({product:t,isSpotlighted:e=!1,onProductClick:r,onAddToCart:n})=>{const[i,c]=o.useState(!1),h=()=>{r==null||r(t)},u=k=>{k.stopPropagation(),n==null||n(t)},y=e?yn:Er;return s.jsxs("div",{onClick:h,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),className:"relative w-full cursor-pointer glass-card",style:{...y,padding:"16px",transform:i?"scale(1.04) translateY(-4px)":"scale(1) translateY(0)",boxShadow:i?"0 16px 56px rgba(0, 0, 0, 0.4), 0 0 24px rgba(255,255,255,0.08)":y.boxShadow,transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease-out"},children:[e&&s.jsxs("div",{className:"absolute -top-2.5 -right-2.5 z-10 flex items-center gap-1.5 px-3 py-1.5 text-xs font-bold",style:{background:"linear-gradient(135deg, rgba(0, 102, 204, 0.95) 0%, rgba(0, 73, 153, 1) 100%)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"20px",boxShadow:"0 8px 24px rgba(0, 102, 204, 0.5)",color:"white"},children:[s.jsx("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 20 20",children:s.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"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"flex-shrink-0 flex items-center justify-center overflow-hidden",style:{...Di,width:"92px",height:"92px"},children:t.image_url?s.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-2",loading:"lazy"}):s.jsx("div",{className:"flex flex-col items-center justify-center",style:{color:"rgba(255,255,255,0.4)"},children:s.jsx("svg",{className:"w-8 h-8",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"font-bold line-clamp-2 leading-tight",style:{fontSize:"16px",letterSpacing:"-0.01em",...ur.primary},children:t.name}),t.brand&&s.jsx("div",{className:"flex items-center gap-1.5 mt-1.5",children:s.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5",style:{...Wi,color:"rgba(255, 255, 255, 0.9)"},children:[s.jsx("svg",{className:"w-2.5 h-2.5",fill:"currentColor",viewBox:"0 0 20 20",children:s.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]})}),s.jsx("p",{className:"font-extrabold mt-2",style:{fontSize:"22px",letterSpacing:"-0.02em",color:"#FFD700",textShadow:"0 2px 6px rgba(0, 0, 0, 0.5), 0 0 12px rgba(255, 215, 0, 0.3)"},children:t.price>0?`$${t.price.toFixed(2)}`:"POA"})]}),s.jsx("button",{onClick:u,className:"flex-shrink-0 flex items-center justify-center glass-button",style:{...Fs,width:"56px",height:"56px",transition:"transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease-out"},onMouseEnter:k=>{k.currentTarget.style.transform="scale(1.08) translateY(-2px)",k.currentTarget.style.boxShadow="0 14px 48px rgba(255, 149, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.4)"},onMouseLeave:k=>{k.currentTarget.style.transform="scale(1) translateY(0)",k.currentTarget.style.boxShadow=Fs.boxShadow},children:s.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M12 4v16m8-8H4"})})})]}),t.partslotDescription&&s.jsx("div",{className:"mt-3 pt-3",style:{borderTop:"1px solid rgba(255, 255, 255, 0.15)"},children:s.jsx("span",{className:"text-xs font-medium",style:{color:"rgba(255, 255, 255, 0.6)"},children:t.partslotDescription})})]})},Bs=(t,e)=>{if(!t||!e)return!1;const r=t.toLowerCase();return e.toLowerCase().replace(/s\b/g,"").split(/\s+/).filter(Boolean).every(i=>r.includes(i))},$i=(t,e)=>{var i;const r=((i=t.brand)==null?void 0:i.toLowerCase())===e.brand.toLowerCase(),n=Math.abs(t.price-e.price)<1;return r&&n},Ui=({product:t,isSpotlighted:e,spotlightedRef:r,onProductClick:n,viewportSize:i})=>i==="desktop"?s.jsxs("div",{ref:e?r:void 0,onClick:()=>n==null?void 0:n(t),className:`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&&s.jsx(Is,{variant:"horizontal"}),s.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?s.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"}):s.jsx(Os,{size:"lg"})}),s.jsxs("div",{className:"flex-1 p-4 flex flex-col justify-between",children:[s.jsxs("div",{children:[s.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&&s.jsx("div",{className:"flex items-center gap-2 mb-2",children:s.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:[s.jsx("svg",{className:"w-3 h-3 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20",children:s.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]})})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-2xl font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"POA"}),s.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:c=>{c.stopPropagation(),n==null||n(t)},children:"View"})]})]})]}):i==="tablet"?s.jsxs("div",{ref:e?r:void 0,onClick:()=>n==null?void 0:n(t),className:`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&&s.jsx(Is,{}),s.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?s.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-4"}):s.jsx(Os,{size:"md"})}),s.jsxs("div",{className:"p-4",children:[s.jsx("p",{className:"text-base font-semibold text-gray-900 line-clamp-2 mb-1",children:t.name}),t.brand&&s.jsxs("p",{className:"text-sm text-gray-600 font-medium mb-2 flex items-center gap-1",children:[s.jsx("span",{className:"w-1.5 h-1.5 bg-blue-500 rounded-full"}),t.brand]}),s.jsx("div",{className:"flex items-center justify-between",children:s.jsx("span",{className:"text-xl font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"POA"})}),s.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:c=>{c.stopPropagation(),n==null||n(t)},children:"View Details"})]})]}):s.jsx("div",{ref:e?r:void 0,children:s.jsx(kn,{product:t,isSpotlighted:e,onProductClick:n})}),Is=({variant:t="default"})=>s.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:[s.jsx("svg",{className:"h-3 w-3",fill:"currentColor",viewBox:"0 0 20 20",children:s.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"]}),Os=({size:t})=>{const e={sm:"h-8 w-8",md:"h-10 w-10",lg:"h-12 w-12"};return s.jsxs("div",{className:"flex flex-col items-center justify-center text-gray-400",children:[s.jsx("svg",{className:e[t],fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})}),s.jsx("span",{className:"text-xs font-medium uppercase tracking-wide mt-1",children:"No Image"})]})},Ir=({products:t,servicePackages:e,highlightedPartType:r,highlightedProduct:n,onProductClick:i,onPackageSelect:c,isResearching:h,visible:u=!0,counterHeightPercent:y=22,hasVehicle:k=!1,onAddToCart:f})=>{const p=Fr();ds();const S=o.useRef(null),x=o.useRef({}),j=o.useRef(null),g=30,E=20,[b,v]=o.useState(g),d=o.useRef(null),[_,B]=o.useState(null),[A,H]=o.useState({});o.useEffect(()=>{v(g)},[t.length]),o.useEffect(()=>{if(!d.current)return;const D=new IntersectionObserver(U=>{U[0].isIntersecting&&b<t.length&&v(F=>Math.min(F+E,t.length))},{threshold:.1});return D.observe(d.current),()=>D.disconnect()},[b,t.length]);const I=o.useMemo(()=>t.slice(0,b),[t,b]),z=o.useMemo(()=>{const D={};return I.forEach(F=>{const W=F.partslotDescription||"Other Parts";D[W]||(D[W]=[]),D[W].push(F)}),Object.keys(D).sort((F,W)=>F.localeCompare(W)).map(F=>({name:F,products:D[F]}))},[I]);o.useEffect(()=>{var D;if(r){const U=z.find(F=>Bs(F.name,r));U&&x.current[U.name]&&((D=x.current[U.name])==null||D.scrollIntoView({behavior:"smooth",block:"start"}))}},[r,z]),o.useEffect(()=>{n&&j.current&&j.current.scrollIntoView({behavior:"smooth",block:"center"})},[n]);const[m,T]=o.useState(0),C=D=>{const U=D.currentTarget,F=U.scrollHeight-U.clientHeight;if(F>0){const W=U.scrollTop/F;T(Math.max(0,Math.min(1,W)))}},N=t.length>0||e.length>0,w=h&&!N,q=N&&!w,$=u||N,X=p==="mobile"?92:p==="tablet"?65:48,Q=p==="desktop"?"580px":p==="tablet"?"500px":"100%",O=p==="mobile"?`calc(${k?"56px":"8px"} + env(safe-area-inset-top, 4px))`:"6px";return s.jsxs(s.Fragment,{children:[N&&u&&s.jsx("div",{style:{position:"fixed",right:"2px",top:`calc(${m*65+18}%)`,...zi,opacity:.8,transition:"top 0.1s ease-out",zIndex:100,pointerEvents:"none"}}),s.jsxs("div",{ref:S,onScroll:C,className:`absolute overflow-y-auto overflow-x-hidden z-30 flex flex-col gap-3 md:gap-4 transition-all duration-400 ease-out product-scroll ${$?"opacity-100 translate-x-0":"opacity-0 translate-x-12 pointer-events-none"}`,style:{width:`${X}%`,maxWidth:Q,right:"0",left:"auto",top:O,bottom:p==="mobile"?"calc(180px + env(safe-area-inset-bottom, 0px))":"52px",paddingTop:"4px",paddingRight:"6px",paddingLeft:"12px",paddingBottom:"8px",scrollbarWidth:"none",msOverflowStyle:"none"},children:[s.jsx("div",{className:"sticky top-0 z-10 -mx-1 px-3 py-2.5",style:{background:"linear-gradient(135deg, rgba(0, 102, 204, 0.85) 0%, rgba(0, 73, 153, 0.9) 100%)",backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)",borderRadius:"24px",boxShadow:"0 10px 40px rgba(0, 102, 204, 0.4)",border:"1px solid rgba(255, 255, 255, 0.25)"},children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[h&&N?s.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center",style:{background:"rgba(255,255,255,0.2)"},children:s.jsx("div",{className:"w-3.5 h-3.5 border-2 border-white border-t-transparent rounded-full animate-spin"})}):s.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center",style:{background:"rgba(255,255,255,0.2)"},children:s.jsx("svg",{className:"w-3.5 h-3.5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})}),s.jsx("span",{style:{...ur.primary,fontWeight:700,fontSize:"14px",letterSpacing:"0.025em"},children:h&&N?"Updating...":"Bob's Shelf"})]}),s.jsxs("span",{style:{color:"rgba(255,255,255,0.8)",fontSize:"12px",fontWeight:500},children:[t.length+e.length," ",t.length+e.length===1?"item":"items"]})]})}),w&&s.jsx("div",{className:"p-5",style:{...Er},children:s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[s.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center",style:{background:"rgba(0, 102, 204, 0.2)"},children:s.jsx("div",{className:"w-6 h-6 border-2 border-t-transparent rounded-full animate-spin",style:{borderColor:"rgba(255,255,255,0.8)",borderTopColor:"transparent"}})}),s.jsxs("div",{children:[s.jsx("p",{style:{...ur.primary,fontWeight:600,fontSize:"14px"},children:"Searching shelves..."}),s.jsx("p",{style:{color:"rgba(255,255,255,0.6)",fontSize:"12px",marginTop:"2px"},children:"Finding the best parts for you"})]})]})}),!w&&!N&&s.jsx("div",{className:"p-5",style:{...Er,background:"rgba(255, 149, 0, 0.15)"},children:s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[s.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center",style:{background:"rgba(255, 149, 0, 0.3)"},children:s.jsx("svg",{className:"w-5 h-5",style:{color:"#FF9500"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),s.jsxs("div",{children:[s.jsx("p",{style:{...ur.primary,fontWeight:600,fontSize:"14px"},children:"No products to display"}),s.jsxs("p",{style:{color:"rgba(255,255,255,0.6)",fontSize:"12px",marginTop:"2px"},children:["Products: ",t.length," | Packages: ",e.length]})]})]})}),q&&e.length>0&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 px-1",children:[s.jsx("div",{className:"w-6 h-6 rounded-lg flex items-center justify-center",style:{background:`linear-gradient(135deg, ${K.primary} 0%, ${K.primaryHover} 100%)`,boxShadow:`0 4px 12px ${K.primary}66`},children:s.jsx("svg",{className:"h-3.5 w-3.5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})})}),s.jsx("span",{className:"text-xs font-bold uppercase tracking-widest",style:{color:"white",textShadow:"0 1px 3px rgba(0,0,0,0.4)"},children:"CFX Service Packs"})]}),e.map(D=>{var je,ve;const U=(D.preparedTiers||[]).filter(J=>!J.isHidden),F=((je=U.find(J=>J.isRecommended))==null?void 0:je.tierName)||((ve=U[0])==null?void 0:ve.tierName)||"",W=A[D.id]||F,ae=U.find(J=>J.tierName===W),ce=mn(D.title).split(".")[0]+".",xe=_===D.id;return s.jsxs("div",{className:"overflow-hidden transition-all duration-300",style:{background:K.card,borderRadius:"16px",border:`1px solid ${K.border}`,boxShadow:"0 4px 20px rgba(0,0,0,0.08)"},children:[s.jsx("div",{className:"px-4 py-3",style:{background:`linear-gradient(135deg, ${K.primary} 0%, ${K.primaryHover} 100%)`},children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/20 flex items-center justify-center flex-shrink-0",children:s.jsx("svg",{className:"h-5 w-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-white font-bold text-base leading-tight truncate",children:D.title}),D.estimated_time&&s.jsx("div",{className:"flex items-center gap-3 mt-0.5",children:s.jsxs("span",{className:"text-white/70 text-xs flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),D.estimated_time]})})]})]})}),s.jsx("div",{className:"px-4 py-3 border-b",style:{borderColor:K.border},children:s.jsx("p",{className:"text-sm leading-relaxed",style:{color:K.mutedForeground},children:ce})}),U.length>0&&s.jsxs("div",{className:"p-3",children:[s.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide mb-2 px-1",style:{color:K.mutedForeground},children:"Choose Your Value Level"}),s.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${Math.min(U.length,4)}, 1fr)`},children:U.map(J=>{const Be=Cr[J.tierName],Ie=J.tierName===W;return s.jsxs("div",{onClick:()=>H(te=>({...te,[D.id]:J.tierName})),className:"relative rounded-xl text-center transition-all cursor-pointer",style:{padding:U.length>=4?"6px 4px":"8px",background:J.isRecommended?`${K.primary}10`:Ie?`${K.primary}05`:K.background,border:`2px solid ${J.isRecommended?K.primary:Ie?K.primary+"80":K.border}`},children:[J.isRecommended&&s.jsx("div",{className:"absolute -top-2 left-1/2 -translate-x-1/2 px-2 py-0.5 rounded-full text-[9px] font-bold uppercase tracking-wide whitespace-nowrap",style:{background:"#22C55E",color:"white"},children:"Recommended"}),s.jsxs("p",{className:"text-sm font-bold mt-1",style:{color:(Be==null?void 0:Be.textColor)||K.foreground},children:[Be==null?void 0:Be.emoji," ",J.displayName]}),s.jsx("div",{className:"flex flex-col items-center gap-1 mt-2",style:{minHeight:U.length>=4?"40px":"48px"},children:J.brands.slice(0,1).map((te,Re)=>{const fe=`https://flpzjbasdsfwoeruyxgp.supabase.co/storage/v1/object/public/brand_images/${te.fullName.replace(/\s+/g,"")}.jpg`;return s.jsx("div",{className:"w-full bg-white rounded-lg flex items-center justify-center overflow-hidden",style:{height:U.length>=4?"36px":"44px",maxWidth:U.length>=4?"64px":"80px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",border:"1px solid #F1F5F9"},children:s.jsx("img",{src:te.imageUrl,alt:te.fullName,className:"w-auto object-contain",style:{height:U.length>=4?"26px":"32px"},onError:He=>{const tt=He.target;tt.src!==fe?tt.src=fe:(tt.style.display="none",tt.parentElement.innerHTML=`<span class="text-[10px] font-semibold text-gray-600 truncate px-1">${te.fullName}</span>`)}})},Re)})}),s.jsxs("p",{className:"text-[10px] mt-2",style:{color:K.mutedForeground},children:[J.productCount," ",J.productCount===1?"part":"parts"]}),s.jsx("p",{className:"text-base font-bold mt-1",style:{color:K.foreground},children:gt(J.totalPrice)}),s.jsx("p",{className:"text-[10px]",style:{color:K.mutedForeground},children:"inc GST"}),s.jsxs("button",{onClick:te=>{te.stopPropagation();const Re=J.products.map(fe=>({id:fe.sku,name:fe.name,brand:fe.brand,price:fe.displayPrice,sku:fe.sku,partNumber:fe.partNumber||void 0,image_url:fe.productImageUrl,partslotDescription:fe.partslotName,quantity:1}));f==null||f(Re)},className:"w-full mt-2 py-1.5 rounded-lg text-[10px] font-semibold transition-all flex items-center justify-center gap-1",style:{background:J.isRecommended?K.primary:"#F1F5F9",color:J.isRecommended?"white":"#475569",border:J.isRecommended?"none":"1px solid #E2E8F0"},children:[s.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z"})}),"Add"]})]},J.tierName)})})]}),s.jsxs("div",{onClick:()=>B(xe?null:D.id),className:"flex items-center justify-center gap-1.5 py-2 cursor-pointer hover:bg-gray-50 transition-colors border-t",style:{borderColor:K.border},children:[s.jsx("span",{className:"text-xs",style:{color:K.mutedForeground},children:xe?"Hide details":"Show details"}),s.jsx("svg",{className:`w-4 h-4 transition-transform duration-200 ${xe?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",style:{color:K.mutedForeground},children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),xe&&ae&&s.jsx("div",{className:"px-4 pb-4 border-t animate-in slide-in-from-top-2 duration-200",style:{borderColor:K.border},children:s.jsxs("div",{className:"pt-3",children:[s.jsxs("p",{className:"text-xs font-semibold uppercase tracking-wide mb-3",style:{color:K.mutedForeground},children:[ae.displayName," Tier Products"]}),s.jsx("div",{className:"space-y-2",children:ae.products.map(J=>s.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg",style:{background:K.background,border:`1px solid ${K.border}`},children:[s.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-white rounded-lg overflow-hidden flex items-center justify-center",children:J.productImageUrl?s.jsx("img",{src:J.productImageUrl,alt:J.name,className:"w-full h-full object-contain p-1"}):s.jsx("svg",{className:"w-6 h-6 text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-xs font-medium truncate",style:{color:K.foreground},children:J.name}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px]",style:{color:K.mutedForeground},children:J.brand}),J.isRotor&&s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-blue-100 text-blue-700 font-medium",children:"Pair"})]}),s.jsx("p",{className:"text-[10px] mt-0.5",style:{color:K.mutedForeground},children:J.partslotName})]}),s.jsxs("div",{className:"text-right flex-shrink-0",children:[s.jsx("p",{className:"text-sm font-bold",style:{color:K.primary},children:gt(J.displayPrice)}),J.isRotor&&s.jsxs("p",{className:"text-[9px]",style:{color:K.mutedForeground},children:["$",J.price.toFixed(2)," ea"]})]})]},J.sku))})]})})]},D.id)})]}),q&&z.map(({name:D,products:U})=>{const F=r&&Bs(D,r);return s.jsxs("section",{ref:W=>{x.current[D]=W},className:"transition-all duration-300",style:{...F?yn:Er,background:F?"linear-gradient(135deg, rgba(0, 82, 164, 0.85) 0%, rgba(0, 51, 102, 0.9) 100%)":"rgba(20, 30, 50, 0.75)"},children:[s.jsxs("div",{className:"px-3 py-2.5 flex items-center justify-between",style:{background:F?"rgba(0, 102, 204, 0.8)":"rgba(0, 51, 102, 0.7)",borderBottom:"1px solid rgba(255,255,255,0.1)"},children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",style:{background:F?"linear-gradient(135deg, rgba(0, 102, 204, 0.9) 0%, rgba(0, 73, 153, 1) 100%)":"rgba(255,255,255,0.2)"},children:s.jsx("svg",{className:"h-3 w-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})}),s.jsx("span",{className:"text-xs font-bold truncate uppercase tracking-wide",style:{color:"white",textShadow:"0 1px 3px rgba(0,0,0,0.6)"},children:D})]}),s.jsx("span",{className:"text-[10px] font-bold px-2.5 py-1 rounded-full flex-shrink-0",style:{background:"rgba(255, 149, 0, 0.9)",color:"white",boxShadow:"0 2px 8px rgba(255, 149, 0, 0.4)"},children:U.length})]}),s.jsx("div",{className:"p-3 flex flex-col gap-3",children:U.map((W,ae)=>{const Fe=!!(n&&$i(W,n));return s.jsx(Ui,{product:W,isSpotlighted:Fe,spotlightedRef:j,onProductClick:i,viewportSize:p},`${W.id}-${ae}`)})})]},D)}),b<t.length&&s.jsx("div",{ref:d,className:"flex items-center justify-center py-4",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",style:{color:"rgba(255,255,255,0.6)"},children:[s.jsx("div",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}),s.jsxs("span",{children:["Loading more (",b," of ",t.length,")..."]})]})}),s.jsx("div",{className:"h-4"})]})]})},hs=({onTranscript:t,onSpeechEnd:e,language:r="en-NZ",mode:n="toggle"}={})=>{const[i,c]=o.useState(!1),[h,u]=o.useState(""),[y,k]=o.useState(""),[f,p]=o.useState(null),[S,x]=o.useState(!1),j=o.useRef(null),g=o.useRef(""),E=o.useRef(t),b=o.useRef(e),v=o.useRef(null),d=15e3;o.useEffect(()=>{E.current=t,b.current=e},[t,e]),o.useEffect(()=>{const H=window.SpeechRecognition||window.webkitSpeechRecognition;if(H){x(!0);const I=new H;I.continuous=n==="ptt",I.interimResults=!0,I.lang=r,I.maxAlternatives=1,I.onstart=()=>{c(!0),p(null)},I.onresult=z=>{let m="",T="";for(let C=z.resultIndex;C<z.results.length;C++){const N=z.results[C][0].transcript;z.results[C].isFinal?T+=N:m+=N}T&&(g.current=T,u(T),E.current&&E.current(T)),k(m)},I.onerror=z=>{switch(c(!1),z.error){case"no-speech":p("No speech detected. Please try again.");break;case"audio-capture":p("No microphone found. Please check your device.");break;case"not-allowed":p("Microphone permission denied. Please allow access.");break;default:p("Speech recognition error. Please try again.")}},I.onend=()=>{v.current&&(clearTimeout(v.current),v.current=null),c(!1),k(""),g.current&&b.current&&b.current(g.current),g.current=""},j.current=I}return()=>{j.current&&j.current.stop()}},[r,n]);const _=()=>{j.current&&!i&&(u(""),k(""),p(null),v.current=setTimeout(()=>{console.warn("[SpeechRecognition] Safety timeout - forcing stop after 15s"),j.current&&j.current.abort(),c(!1),k("")},d),j.current.start())},B=()=>{v.current&&(clearTimeout(v.current),v.current=null),j.current&&i&&j.current.stop()};return{isListening:i,transcript:h,interimTranscript:y,error:f,isSupported:S,startListening:_,stopListening:B,toggleListening:()=>{i?B():_()}}},Sn=({messages:t,input:e,setInput:r,isLoading:n,onSend:i,onKeyPress:c,onInputFocus:h,onInputBlur:u,chatEndRef:y,isMuted:k=!1,onToggleMute:f,isSpeaking:p=!1,onAddToCart:S,onProductClick:x})=>{var Q;const[j,g]=o.useState(!1),E=o.useRef(null),b=o.useRef(!1),{bottomOffset:v,zIndexBase:d}=cs(),{isListening:_,interimTranscript:B,error:A,isSupported:H,startListening:I,stopListening:z}=hs({onTranscript:O=>r(O),language:"en-NZ",mode:"ptt"});o.useEffect(()=>{B&&r(B)},[B,r]);const m=o.useCallback(()=>{n||b.current||(b.current=!0,navigator.vibrate&&navigator.vibrate(30),I())},[n,I]),T=o.useCallback(()=>{b.current&&(b.current=!1,navigator.vibrate&&navigator.vibrate([20,50,20]),z(),setTimeout(()=>{i()},150))},[z,i]),C=[...t].reverse().find(O=>O.role==="assistant"),N=((Q=C==null?void 0:C.suggestedProducts)==null?void 0:Q.length)||0,w=C!=null&&C.content?C.content.length>50?C.content.slice(0,50)+"...":C.content:"Ask Bob about car parts...",q=N>0?` (${N} products)`:"",$={idle:{...vn},active:{background:"linear-gradient(135deg, rgba(255, 149, 0, 0.95) 0%, rgba(230, 134, 0, 1) 100%)",backdropFilter:"blur(16px) saturate(180%)",WebkitBackdropFilter:"blur(16px) saturate(180%)",border:"1px solid rgba(255, 255, 255, 0.4)",borderRadius:"32px",boxShadow:"0 12px 48px rgba(255, 149, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.3)"},disabled:{background:"rgba(156, 163, 175, 0.5)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"32px",boxShadow:"0 4px 16px rgba(0, 0, 0, 0.2)"}},X=n?$.disabled:_?$.active:$.idle;return s.jsxs("div",{ref:E,style:{position:"fixed",bottom:`${v}px`,left:0,right:0,...wn,borderRadius:"28px 28px 0 0",borderBottom:"none",transition:"all 0.3s ease-out",boxShadow:"0 -10px 40px rgba(0, 0, 0, 0.3)",height:j?"55vh":"auto",zIndex:d+60,paddingBottom:v>0?"8px":"env(safe-area-inset-bottom, 8px)"},children:[s.jsx("button",{onClick:()=>g(!j),style:{position:"absolute",top:"-20px",left:"50%",transform:"translateX(-50%)",background:"rgba(255, 255, 255, 0.15)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:"1px solid rgba(255, 255, 255, 0.25)",borderRadius:"9999px",padding:"6px",boxShadow:"0 4px 16px rgba(0, 0, 0, 0.2)",zIndex:d+70,cursor:"pointer",minHeight:"unset",minWidth:"unset"},"aria-label":j?"Collapse chat":"Expand chat",children:j?s.jsx("svg",{style:{height:"16px",width:"16px",color:"rgba(255,255,255,0.8)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}):s.jsx("svg",{style:{height:"16px",width:"16px",color:"rgba(255,255,255,0.8)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),!j&&s.jsx("div",{onClick:()=>g(!0),style:{padding:"8px 12px 2px 12px",cursor:"pointer"},children:s.jsxs("p",{style:{fontSize:"12px",color:"white",textShadow:"0 1px 3px rgba(0,0,0,0.6)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[w,q&&s.jsx("span",{style:{color:"rgba(255,200,0,0.9)",fontWeight:600},children:q})]})}),j&&s.jsxs("div",{style:{height:"calc(100% - 100px)",overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"8px"},className:"glass-scroll",children:[[...t].reverse().map((O,D)=>{var U;return s.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:O.role==="user"?"flex-end":"flex-start"},children:s.jsxs("div",{style:{maxWidth:(U=O.suggestedProducts)!=null&&U.length?"100%":"85%",borderRadius:"16px",padding:"10px 14px",fontSize:"14px",background:O.role==="user"?"linear-gradient(135deg, rgba(0, 102, 204, 0.9) 0%, rgba(0, 73, 153, 0.95) 100%)":"rgba(255, 255, 255, 0.12)",backdropFilter:"blur(12px)",border:"1px solid rgba(255, 255, 255, 0.2)",color:"rgba(255, 255, 255, 0.95)",textShadow:"0 1px 2px rgba(0,0,0,0.2)"},children:[O.content,O.role==="assistant"&&O.suggestedProducts&&O.suggestedProducts.length>0&&s.jsx(us,{products:O.suggestedProducts,title:O.suggestionsTitle,onAddToCart:S,onProductClick:x})]})},D)}),s.jsx("div",{ref:y})]}),H&&s.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"12px 16px 8px 16px"},children:s.jsx("button",{onTouchStart:m,onTouchEnd:T,onTouchCancel:T,onMouseDown:m,onMouseUp:T,onMouseLeave:T,onClick:_?T:void 0,disabled:n,"aria-label":"Hold to talk to Bob",className:"glass-button",style:{width:"200px",height:"64px",minHeight:"unset",minWidth:"unset",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",touchAction:"none",cursor:n?"not-allowed":"pointer",opacity:n?.6:1,transform:_?"scale(1.04)":"scale(1)",transition:"transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, background 0.15s ease",...X},title:"Hold to talk",children:s.jsx("span",{style:{fontSize:"22px",fontWeight:800,letterSpacing:"0.15em",...ur.primary,textTransform:"uppercase",fontFamily:"system-ui, -apple-system, sans-serif"},children:_?"LISTENING":"TALK"})})}),s.jsxs("div",{style:{padding:"4px 12px 8px 12px",borderTop:"1px solid rgba(255, 255, 255, 0.15)"},children:[A&&s.jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"#FF9500"},children:A}),s.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[f&&s.jsx("button",{onClick:f,style:{flexShrink:0,height:"40px",width:"40px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"12px",background:"rgba(255, 255, 255, 0.1)",backdropFilter:"blur(8px)",color:p?"#0066CC":"rgba(255,255,255,0.7)",cursor:"pointer",border:"1px solid rgba(255, 255, 255, 0.2)",minHeight:"unset",minWidth:"unset"},title:k?"Unmute":"Mute",children:k?s.jsxs("svg",{style:{height:"18px",width:"18px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.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"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]}):s.jsx("svg",{style:{height:"18px",width:"18px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})})}),s.jsx("input",{type:"text",value:e,onChange:O=>r(O.target.value),onKeyPress:c,onFocus:h,onBlur:u,placeholder:"Or type here...",disabled:n,className:"high-contrast-input",style:{flex:1,height:"40px",fontSize:"16px",padding:"0 14px",background:"rgba(0, 51, 102, 0.85)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:"2px solid rgba(255, 255, 255, 0.35)",borderRadius:"20px",color:"white",outline:"none",opacity:n?.5:1}})]})]})]})},jn=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:n,counterHeightPercent:i=22,messages:c,input:h,setInput:u,isLoading:y,onSend:k,onKeyPress:f,onInputFocus:p,onInputBlur:S,chatEndRef:x,isMuted:j,onToggleMute:g,isSpeaking:E,products:b,servicePackages:v,highlightedPartType:d,highlightedProduct:_,onProductClick:B,onPackageSelect:A,isResearching:H,vehicle:I,onChangeVehicle:z,bobOffset:m=0,bobScale:T=100})=>{console.log("[MobileBobLayout] Rendering with:",{currentImage:(t==null?void 0:t.substring(0,50))||"EMPTY",backdropUrl:(r==null?void 0:r.substring(0,50))||"NONE",counterOverlayUrl:(n==null?void 0:n.substring(0,50))||"NONE"});const C=typeof window<"u"&&window.self!==window.top,N=Fr(),[w,q]=o.useState("center"),[$,X]=o.useState("hidden"),Q=b.length>0||v.length>0,U=(()=>{switch(N){case"desktop":return 70;case"tablet":return 80;case"mobile":return 140;default:return 140}})()*T/100;o.useEffect(()=>{if(H&&$!=="loading"&&$!=="visible")X("loading"),w==="center"&&q("left");else if(Q&&$!=="visible")if(w==="center"){q("left"),X("transitioning");const W=setTimeout(()=>{X("visible")},400);return()=>clearTimeout(W)}else X("visible");else!Q&&!H&&$!=="hidden"&&(X("hidden"),q("center"))},[Q,H,$,w]);const F=$!=="hidden";return s.jsxs("div",{className:"fixed inset-0 overflow-hidden",style:{height:"100dvh",touchAction:"manipulation"},children:[r&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"absolute inset-0 z-0",style:{backgroundImage:`url(${r})`,backgroundSize:"cover",backgroundPosition:"center bottom",filter:"blur(4px) brightness(0.85)",transform:"scale(1.05)"}}),s.jsx("div",{className:"absolute inset-0 z-[1]",style:{background:"linear-gradient(to bottom, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.35) 100%)"}})]}),s.jsx(Br,{currentImage:t,animationState:e,counterOverlayUrl:n,counterHeightPercent:i,scale:U,position:w,verticalOffset:m}),I&&!C&&s.jsx("div",{style:{position:"absolute",top:"8px",left:"8px",right:"8px",zIndex:20},children:s.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:[s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("p",{style:{fontSize:"12px",fontWeight:500,color:"#111827",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[I.year," ",I.make," ",I.model]}),I.rego&&s.jsx("p",{style:{fontSize:"10px",color:"#6b7280"},children:I.rego})]}),z&&s.jsx("button",{onClick:z,style:{fontSize:"12px",color:"#2563eb",marginLeft:"8px",flexShrink:0,background:"none",border:"none",cursor:"pointer",minHeight:"unset",minWidth:"unset"},children:"Change"})]})}),s.jsx(Ir,{products:b,servicePackages:v,highlightedPartType:d,highlightedProduct:_,onProductClick:B,onPackageSelect:A,isResearching:H,visible:F,counterHeightPercent:i,hasVehicle:!!I}),s.jsx(Sn,{messages:c,input:h,setInput:u,isLoading:y,onSend:k,onKeyPress:f,onInputFocus:p,onInputBlur:S,chatEndRef:x,isMuted:j,onToggleMute:g,isSpeaking:E,onAddToCart:B,onProductClick:B})]})},_n=({messages:t,input:e,setInput:r,isLoading:n,onSend:i,onKeyPress:c,onInputFocus:h,onInputBlur:u,chatEndRef:y,isMuted:k=!1,onToggleMute:f,isSpeaking:p=!1})=>{const[S,x]=o.useState(!1),j=o.useRef(null),g=o.useRef(!1),{bottomOffset:E,zIndexBase:b}=cs(),{isListening:v,interimTranscript:d,error:_,isSupported:B,startListening:A,stopListening:H}=hs({onTranscript:w=>r(w),language:"en-NZ",mode:"ptt"});o.useEffect(()=>{d&&r(d)},[d,r]);const I=o.useCallback(()=>{n||g.current||(g.current=!0,navigator.vibrate&&navigator.vibrate(30),A())},[n,A]),z=o.useCallback(()=>{g.current&&(g.current=!1,navigator.vibrate&&navigator.vibrate([20,50,20]),H(),setTimeout(()=>{i()},150))},[H,i]),m=[...t].reverse().find(w=>w.role==="assistant"),T=m!=null&&m.content?m.content.length>50?m.content.slice(0,50)+"...":m.content:"Ask Bob about car parts...",C={idle:{...vn},active:{background:"linear-gradient(135deg, rgba(255, 149, 0, 0.95) 0%, rgba(230, 134, 0, 1) 100%)",backdropFilter:"blur(16px) saturate(180%)",WebkitBackdropFilter:"blur(16px) saturate(180%)",border:"1px solid rgba(255, 255, 255, 0.4)",borderRadius:"50%",boxShadow:"0 12px 48px rgba(255, 149, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.3)"},disabled:{background:"rgba(156, 163, 175, 0.5)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"50%",boxShadow:"0 4px 16px rgba(0, 0, 0, 0.2)"}},N=n?C.disabled:v?C.active:C.idle;return s.jsxs("div",{ref:j,style:{position:"absolute",bottom:`${E}px`,left:0,right:0,...wn,borderRadius:"28px 28px 0 0",borderBottom:"none",transition:"all 0.3s ease-out",boxShadow:"0 -10px 40px rgba(0, 0, 0, 0.3)",height:S?"55%":"70px",overflow:S?"visible":"hidden",zIndex:b+10,paddingBottom:E>0?"8px":"env(safe-area-inset-bottom, 8px)"},children:[s.jsx("button",{onClick:()=>x(!S),style:{position:"absolute",top:"-20px",left:"50%",transform:"translateX(-50%)",background:"rgba(255, 255, 255, 0.15)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:"1px solid rgba(255, 255, 255, 0.25)",borderRadius:"9999px",padding:"6px",boxShadow:"0 4px 16px rgba(0, 0, 0, 0.2)",zIndex:b+20,cursor:"pointer",minHeight:"unset",minWidth:"unset"},"aria-label":S?"Collapse chat":"Expand chat",children:S?s.jsx("svg",{style:{height:"16px",width:"16px",color:"rgba(255,255,255,0.8)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}):s.jsx("svg",{style:{height:"16px",width:"16px",color:"rgba(255,255,255,0.8)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),!S&&s.jsx("div",{onClick:()=>x(!0),style:{padding:"6px 12px 4px 12px",height:"26px",overflow:"hidden",cursor:"pointer"},children:s.jsx("p",{style:{fontSize:"12px",color:"white",textShadow:"0 1px 3px rgba(0,0,0,0.6)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T})}),S&&s.jsxs("div",{style:{height:"calc(100% - 100px)",overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"8px"},className:"glass-scroll",children:[[...t].reverse().map((w,q)=>s.jsx("div",{style:{display:"flex",justifyContent:w.role==="user"?"flex-end":"flex-start"},children:s.jsx("div",{style:{maxWidth:"85%",borderRadius:"16px",padding:"10px 14px",fontSize:"14px",background:w.role==="user"?"linear-gradient(135deg, rgba(0, 102, 204, 0.9) 0%, rgba(0, 73, 153, 0.95) 100%)":"rgba(255, 255, 255, 0.12)",backdropFilter:"blur(12px)",border:"1px solid rgba(255, 255, 255, 0.2)",color:"rgba(255, 255, 255, 0.95)",textShadow:"0 1px 2px rgba(0,0,0,0.2)"},children:w.content})},q)),s.jsx("div",{ref:y})]}),s.jsxs("div",{style:{padding:S?"8px 12px 4px 12px":"4px 12px 4px 12px",borderTop:S?"1px solid rgba(255, 255, 255, 0.15)":"none"},children:[v&&s.jsxs("div",{style:{marginBottom:"8px",fontSize:"12px",color:"rgba(255,255,255,0.7)",display:"flex",alignItems:"center",gap:"8px"},children:[s.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",backgroundColor:"#FF9500",borderRadius:"50%",animation:"pulse 2s infinite"}}),"Listening..."]}),_&&s.jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"#FF9500"},children:_}),s.jsxs("div",{style:{display:"flex",gap:"6px",alignItems:"center"},children:[f&&S&&s.jsx("button",{onClick:f,style:{flexShrink:0,height:"36px",width:"36px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"10px",background:"rgba(255, 255, 255, 0.1)",backdropFilter:"blur(8px)",color:p?"#0066CC":"rgba(255,255,255,0.7)",cursor:"pointer",border:"1px solid rgba(255, 255, 255, 0.2)",minHeight:"unset",minWidth:"unset"},title:k?"Unmute":"Mute",children:k?s.jsxs("svg",{style:{height:"16px",width:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.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"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]}):s.jsx("svg",{style:{height:"16px",width:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})})}),s.jsx("input",{type:"text",value:e,onChange:w=>r(w.target.value),onKeyPress:c,onFocus:h,onBlur:u,placeholder:"Message Bob...",disabled:n,className:"high-contrast-input",style:{flex:1,height:"40px",fontSize:"16px",padding:"0 14px",background:"rgba(0, 51, 102, 0.85)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:"2px solid rgba(255, 255, 255, 0.35)",borderRadius:"20px",color:"white",outline:"none",opacity:n?.5:1}}),B&&s.jsxs("div",{style:{position:"relative",marginLeft:"4px"},children:[v&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",width:"72px",height:"72px",borderRadius:"50%",border:"2px solid #FF9500",transform:"translate(-50%, -50%)",animation:"ptt-wave 1.5s ease-out infinite",opacity:0,pointerEvents:"none"}}),s.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",width:"72px",height:"72px",borderRadius:"50%",border:"2px solid #FF9500",transform:"translate(-50%, -50%)",animation:"ptt-wave 1.5s ease-out infinite 0.5s",opacity:0,pointerEvents:"none"}})]}),!v&&!n&&s.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"}}),s.jsxs("button",{onTouchStart:I,onTouchEnd:z,onTouchCancel:z,onMouseDown:I,onMouseUp:z,onMouseLeave:z,disabled:n,"aria-label":"Hold to talk to Bob",className:"glass-button",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:n?"not-allowed":"pointer",opacity:n?.6:1,transform:v?"scale(1.08)":"scale(1)",transition:"transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease",zIndex:b+25,...N},title:"Hold to talk",children:[s.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:s.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"})}),v&&s.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"}})]})]})]})]})]})},Hi=({product:t,onBack:e,onAddToCart:r,onNavigateToProductPage:n})=>{const i=t.productUrl||t.product_url,c=t.partNumber||t.part_number,h=!!i||!!n;return s.jsxs("div",{className:"absolute inset-0 z-35 flex flex-col bg-white/95 backdrop-blur-md overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-gray-200 bg-white/80 backdrop-blur-sm",children:s.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:[s.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back to Products"]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.jsx("div",{className:"aspect-square bg-gradient-to-br from-gray-50 to-gray-100 flex items-center justify-center",children:t.image_url?s.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-4"}):s.jsxs("div",{className:"flex flex-col items-center justify-center text-gray-400",children:[s.jsx("svg",{className:"h-16 w-16 mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})}),s.jsx("span",{className:"text-sm font-medium uppercase tracking-wide",children:"No Image Available"})]})}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-gray-900 mb-1",children:t.name}),t.brand&&s.jsx("p",{className:"text-sm text-gray-600 font-medium",children:t.brand})]}),s.jsxs("div",{className:"bg-blue-50 rounded-xl p-4",children:[s.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Price"}),s.jsx("p",{className:"text-2xl font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"Price on Request"}),t.price>0&&s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Inc. GST"})]}),s.jsxs("div",{className:"space-y-3",children:[t.partslotDescription&&s.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[s.jsx("span",{className:"text-sm text-gray-500",children:"Category"}),s.jsx("span",{className:"text-sm font-medium text-gray-900",children:t.partslotDescription})]}),t.sku&&s.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[s.jsx("span",{className:"text-sm text-gray-500",children:"SKU"}),s.jsx("span",{className:"text-sm font-medium text-gray-900",children:t.sku})]}),c&&s.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[s.jsx("span",{className:"text-sm text-gray-500",children:"Part Number"}),s.jsx("span",{className:"text-sm font-medium text-gray-900",children:c})]})]}),h&&s.jsx("a",{href:i||"#",onClick:u=>{n&&(u.preventDefault(),n(t))},target:i&&!n?"_blank":void 0,rel:i&&!n?"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 →"})]})]}),s.jsx("div",{className:"p-4 border-t border-gray-200 bg-white/95 backdrop-blur-sm",children:s.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"})})]})},En=({package:t,onBack:e,onAddToCart:r,onNavigateToProductPage:n})=>{var S;const[i,c]=o.useState(!1),h=o.useMemo(()=>!t.preparedTiers||t.preparedTiers.length===0?[]:t.preparedTiers.filter(x=>!x.isHidden),[t.preparedTiers]),u=h.length>0,y=x=>{r==null||r(x.products)},k=x=>x===2?"grid-cols-2":x===3?"grid-cols-3":"grid-cols-2",f=mn(t.title),p=((S=h[0])==null?void 0:S.productCount)||0;return s.jsxs("div",{className:"absolute inset-0 z-35 flex flex-col bg-[#FAFAFA] overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-[#E2E8F0] bg-white shadow-sm",children:s.jsxs("button",{onClick:e,className:"flex items-center gap-1.5 text-[#0052CC] font-medium text-sm hover:text-[#0047B3] active:scale-95 transition-all",children:[s.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back"]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.jsxs("div",{className:"px-4 pt-4 pb-4",style:{background:"linear-gradient(135deg, rgba(0,82,204,0.05) 0%, rgba(56,189,248,0.05) 100%)"},children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center flex-shrink-0 bg-white shadow-md",children:t.icon_url?s.jsx("img",{src:t.icon_url,alt:"",className:"w-8 h-8 object-contain"}):s.jsx("svg",{className:"w-7 h-7 text-[#0052CC]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h1",{className:"text-xl font-bold text-[#0F172A]",children:t.title}),s.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-[#64748B]",children:[t.estimated_time&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),t.estimated_time]}),t.difficulty_level&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.42 15.17L17.25 21A2.652 2.652 0 0021 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 11-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 004.486-6.336l-3.276 3.277a3.004 3.004 0 01-2.25-2.25l3.276-3.276a4.5 4.5 0 00-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085"})}),t.difficulty_level]})]})]})]}),s.jsx("p",{className:"text-sm text-[#64748B] mt-3 leading-relaxed",children:f})]}),s.jsxs("div",{className:"px-4 py-3 flex items-center justify-center gap-2 border-b border-[#E2E8F0] bg-white",children:[s.jsx("span",{className:"font-semibold text-[#0F172A] text-sm",children:"Choose Your Value Level"}),s.jsx("span",{className:"text-[#64748B] text-xs cursor-help",title:"Select the quality tier that suits your needs",children:"ⓘ"})]}),s.jsx("div",{className:"p-4",children:u?s.jsx("div",{className:`grid ${k(h.length)} gap-3`,children:h.map(x=>{const j=Cr[x.tierName];return s.jsxs("div",{className:"relative rounded-2xl overflow-hidden bg-white shadow-md flex flex-col",style:{border:x.isRecommended?"2px solid #0052CC":"1px solid #E2E8F0"},children:[x.isRecommended&&s.jsx("div",{className:"absolute top-0 left-0 right-0 px-2 py-1 text-[9px] font-bold text-white text-center",style:{background:"linear-gradient(135deg, #0052CC 0%, #38BDF8 100%)"},children:"★ RECOMMENDED"}),s.jsxs("div",{className:`p-3 flex-1 flex flex-col ${x.isRecommended?"pt-7":""}`,children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[s.jsx("span",{className:"text-lg",children:j==null?void 0:j.emoji}),s.jsxs("div",{children:[s.jsx("span",{className:"font-bold text-sm block",style:{color:(j==null?void 0:j.textColor)||K.foreground},children:x.displayName}),s.jsx("span",{className:"text-[10px] text-[#64748B] hidden md:block",children:x.description||(j==null?void 0:j.description)})]})]}),s.jsx("div",{className:"flex items-center gap-1.5 mb-3 min-h-[42px] flex-wrap",children:x.brands.slice(0,3).map(g=>s.jsx("div",{className:"h-10 px-2 bg-white rounded-xl flex items-center justify-center shadow-md border border-[#F1F5F9]",children:s.jsx("img",{src:g.imageUrl,alt:g.fullName,className:"h-6 w-auto object-contain",onError:E=>{const b=E.target,v=`${fr.storageBase}/brand_images/${g.fullName.replace(/\s+/g,"")}.jpg`;if(b.src!==v)b.src=v;else{const d=b.parentElement;d&&(d.innerHTML=`<span class="text-[10px] font-medium text-slate-700 px-1 truncate max-w-[60px]">${g.name}</span>`)}}})},g.name))}),s.jsxs("p",{className:"text-xs text-[#64748B] hidden md:block mb-2",children:[x.productCount," part",x.productCount!==1?"s":""," included"]}),s.jsxs("div",{className:"mt-auto",children:[s.jsx("p",{className:"text-xl font-bold",style:{color:x.isRecommended?"#0052CC":"#0F172A"},children:gt(x.totalPrice)}),s.jsx("p",{className:"text-[10px] text-[#64748B] hidden md:block",children:"inc GST"})]}),s.jsxs("button",{onClick:()=>y(x),className:`mt-3 w-full px-3 py-2.5 rounded-xl text-xs font-semibold transition-all hover:scale-[1.02] active:scale-95 flex items-center justify-center gap-1.5 ${x.isRecommended?"bg-[#0052CC] text-white shadow-md hover:bg-[#0047B3]":"bg-slate-100 text-slate-700 border border-slate-200 hover:bg-slate-200"}`,children:[s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z"})}),"Add to Cart"]})]})]},x.tierName)})}):s.jsxs("div",{className:"rounded-2xl p-6 bg-white border border-[#E2E8F0] shadow-md text-center",children:[s.jsx("svg",{className:"w-12 h-12 mx-auto text-[#94A3B8] mb-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})}),s.jsx("p",{className:"text-sm font-medium text-[#64748B]",children:"Package details not available for this vehicle"}),s.jsx("p",{className:"text-xs text-[#94A3B8] mt-1",children:"Please try refreshing or contact support"})]})}),u&&s.jsxs("div",{className:"px-4 pb-4",children:[s.jsxs("button",{onClick:()=>c(!i),className:"w-full flex items-center justify-between p-3 rounded-xl bg-white border border-[#E2E8F0] hover:bg-slate-50 transition-all shadow-sm",children:[s.jsxs("span",{className:"text-sm font-medium text-[#0F172A]",children:[i?"▼":"▶"," View Product Details"]}),s.jsxs("span",{className:"text-xs text-[#64748B]",children:[p," product",p!==1?"s":""]})]}),i&&s.jsx("div",{className:"mt-3 space-y-4 bg-white rounded-xl border border-[#E2E8F0] p-3",children:h.map(x=>{if(x.products.length===0)return null;const j=Cr[x.tierName];return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 pb-1 border-b border-[#E2E8F0]",children:[s.jsx("span",{className:"text-lg",children:j==null?void 0:j.emoji}),s.jsx("span",{className:"font-semibold text-sm",style:{color:j==null?void 0:j.textColor},children:x.displayName}),s.jsxs("span",{className:"text-xs text-[#64748B]",children:["(",x.products.length," parts)"]})]}),s.jsx("div",{className:"space-y-2",children:x.products.map((g,E)=>{var d;const b=(d=t.carfixValueProducts)==null?void 0:d.includes(g.sku),v=g.unitPrice??g.price;return s.jsxs("div",{className:"flex items-center gap-3 p-2.5 rounded-xl transition-all hover:bg-slate-50 cursor-pointer border border-[#E2E8F0]",onClick:()=>n==null?void 0:n(g.sku),children:[s.jsx("div",{className:"w-14 h-14 flex-shrink-0 rounded-lg bg-white overflow-hidden border border-[#E2E8F0]",children:s.jsx("img",{src:g.productImageUrl||fr.productImage(g.sku),alt:g.name,className:"w-full h-full object-contain p-1.5",onError:_=>{_.target.src="/placeholder.svg"}})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("span",{className:"text-xs font-semibold text-[#0F172A]",children:g.brandFullName||g.brand}),b&&s.jsx("span",{className:"px-1.5 py-0.5 text-[8px] font-bold rounded-full",style:{background:"rgba(0, 82, 204, 0.1)",color:"#0052CC"},children:"CFX VALUE"}),g.isMultiQty&&g.perCarQty>1&&s.jsxs("span",{className:"px-1.5 py-0.5 text-[8px] font-bold rounded-full",style:{background:"#F0FDF4",color:"#15803D"},children:["×",g.perCarQty]}),g.isRotor&&s.jsx("span",{className:"px-1.5 py-0.5 text-[8px] font-bold rounded-full",style:{background:"#EFF6FF",color:"#1D4ED8"},children:"Pair"})]}),s.jsx("p",{className:"text-xs text-[#64748B] line-clamp-1",children:g.name})]}),s.jsxs("div",{className:"text-right flex-shrink-0",children:[s.jsx("p",{className:"text-sm font-bold text-[#0F172A]",children:gt(g.displayPrice)}),g.isMultiQty&&g.perCarQty>1&&s.jsxs("p",{className:"text-[10px] text-[#64748B]",children:[g.perCarQty,"× ",gt(v)," each"]}),g.isRotor&&!g.isMultiQty&&s.jsxs("p",{className:"text-[10px] text-[#64748B]",children:[gt(v)," each"]})]})]},`${g.sku}-${E}`)})})]},x.tierName)})})]}),t.bundle_discount_percentage&&t.bundle_discount_percentage>0&&s.jsx("div",{className:"px-4 pb-4",children:s.jsx("div",{className:"rounded-xl p-3 text-center",style:{background:"rgba(34,197,94,0.1)",border:"1px solid rgba(34,197,94,0.2)"},children:s.jsxs("span",{className:"text-sm font-semibold text-[#22C55E]",children:["Bundle saves you ",t.bundle_discount_percentage,"%"]})})})]})]})},Tn=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:n,counterHeightPercent:i=22,messages:c,input:h,setInput:u,isLoading:y,onSend:k,onKeyPress:f,onInputFocus:p,onInputBlur:S,chatEndRef:x,isMuted:j,onToggleMute:g,isSpeaking:E,products:b,servicePackages:v,highlightedPartType:d,highlightedProduct:_,onProductClick:B,onPackageSelect:A,isResearching:H,onAddToCart:I,onNavigateToProductPage:z,vehicle:m,onChangeVehicle:T,bobOffset:C=0,bobScale:N=100})=>{const[w,q]=o.useState("center"),[$,X]=o.useState("hidden"),[Q,O]=o.useState("products"),[D,U]=o.useState(null),[F,W]=o.useState(null),ae=b.length>0||v.length>0,xe=(Q==="productDetail"?70:w==="center"&&!ae?140:98)*N/100;o.useEffect(()=>{if(H&&$!=="loading"&&$!=="visible")X("loading"),w==="center"&&q("left");else if(ae&&$!=="visible")if(w==="center"){q("left"),X("transitioning");const te=setTimeout(()=>{X("visible")},400);return()=>clearTimeout(te)}else X("visible");else!ae&&!H&&$!=="hidden"&&(X("hidden"),q("center"))},[ae,H,$,w]);const je=te=>{if(z){z(te),B==null||B(te);return}U(te),O("productDetail"),B==null||B(te)},ve=()=>{U(null),W(null),O("products")},J=te=>{console.log("[ContainedMobileBobLayout] Package selected:",te.title),W(te),O("packageDetail"),A==null||A(te)},Be=$!=="hidden"&&Q==="products",Ie=$!=="hidden";return s.jsxs("div",{className:"absolute inset-0 overflow-hidden",style:{touchAction:"manipulation"},children:[r&&s.jsx("div",{className:"absolute inset-0 z-0 transition-all duration-500 ease-out",style:{backgroundImage:`url(${r})`,backgroundSize:"cover",backgroundPosition:"center bottom",filter:Ie?"blur(8px) brightness(0.9)":"blur(0px) brightness(1)",transform:"scale(1.05)"}}),s.jsx(Br,{currentImage:t,animationState:e,counterOverlayUrl:n,counterHeightPercent:i,scale:xe,position:w,verticalOffset:C}),m&&Q==="products"&&s.jsx("div",{style:{position:"absolute",top:"8px",left:"8px",right:"8px",zIndex:20},children:s.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:[s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("p",{style:{fontSize:"12px",fontWeight:500,color:"#111827",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[m.year," ",m.make," ",m.model]}),m.rego&&s.jsx("p",{style:{fontSize:"10px",color:"#6b7280"},children:m.rego})]}),T&&s.jsx("button",{onClick:T,style:{fontSize:"12px",color:"#2563eb",marginLeft:"8px",flexShrink:0,background:"none",border:"none",cursor:"pointer",minHeight:"unset",minWidth:"unset"},children:"Change"})]})}),s.jsx(Ir,{products:b,servicePackages:v,highlightedPartType:d,highlightedProduct:_,onProductClick:je,onPackageSelect:J,isResearching:H,visible:Be,counterHeightPercent:i,hasVehicle:!!m}),Q==="productDetail"&&D&&s.jsx(Hi,{product:D,onBack:ve,onAddToCart:I,onNavigateToProductPage:z}),Q==="packageDetail"&&F&&s.jsx(En,{package:F,onBack:ve,onNavigateToProductPage:te=>{const Re=b.find(fe=>fe.sku===te);Re&&z&&z(Re)}}),Q==="products"&&s.jsx(_n,{messages:c,input:h,setInput:u,isLoading:y,onSend:k,onKeyPress:f,onInputFocus:p,onInputBlur:S,chatEndRef:x,isMuted:j,onToggleMute:g,isSpeaking:E})]})},Rn=({variant:t="inline",initialState:e="idle",showChat:r=!0,className:n="",backdropUrl:i,counterOverlayUrl:c,counterHeightPercent:h,defaultBobImage:u,verticalOffset:y=0,scale:k=100})=>{const{callbacks:f}=et(),[p,S]=o.useState(!1),{animationState:x,setAnimationState:j,getCurrentImage:g,getCurrentOffset:E,getCurrentScale:b,availableStates:v}=dn({isSpeaking:p}),{activeBackdrop:d}=hn(),[_,B]=o.useState([]),[A,H]=o.useState([]),[I,z]=o.useState(null),[m,T]=o.useState(null),[C,N]=o.useState(!1),w=cn({setAnimationState:j,manualMode:!1,onReadyToSpeak:()=>{console.log("[BobWidget] Ready to speak")},onStreamComplete:()=>{j(v.find(F=>F.includes("idle"))||"idle")},onResearchStart:()=>{N(!0)},onHighlightPart:F=>{z(F),setTimeout(()=>z(null),8e3)},onHighlightProduct:F=>{T(F),setTimeout(()=>T(null),8e3)},onAutoFetchComplete:()=>{N(!1)}});o.useEffect(()=>{S(w.isSpeaking)},[w.isSpeaking]),o.useEffect(()=>{const F=f.onPartsFound,W=f.onServicePackagesFound;return f.onPartsFound=ae=>{if(N(!1),!ae||ae.length===0){console.log("[Bob] Clearing products (empty array received)"),B([]),F==null||F(ae);return}const Fe=ae.map((ce,xe)=>({id:ce.SKU||ce.sku||`part-${xe}`,name:ce["Part Product Type"]||ce.partslot_description||ce.name||"Unknown Part",brand:ce.Brand||ce.brand,price:ce["Metro Retail Price"]||ce.price||0,sku:ce.SKU||ce.sku,partNumber:ce["Part Number"]||ce.part_number,partslotDescription:ce["Part Product Type"]||ce.partslot_description,image_url:ce.image_url}));console.log("[Bob] Products mapped and setting state:",Fe.length,"products"),B(Fe),F==null||F(ae)},f.onServicePackagesFound=ae=>{if(!ae||ae.length===0){console.log("[Bob] Clearing service packages (empty array received)"),H([]),W==null||W(ae);return}H(ae),W==null||W(ae)},()=>{f.onPartsFound=F,f.onServicePackagesFound=W}},[f]);const q=i||(d==null?void 0:d.image_url),$=c||(d==null?void 0:d.counter_overlay_url)||void 0,X=h||(d==null?void 0:d.counter_height_percent)||12,Q=g()||u||"",O=E(),D=b();if(t==="mobile"||t==="fullscreen")return s.jsx(jn,{currentImage:Q,animationState:x,backdropUrl:q,counterOverlayUrl:$,counterHeightPercent:X,bobOffset:O,bobScale:D,messages:w.messages,input:w.input,setInput:w.setInput,isLoading:w.isLoading,onSend:w.handleSend,onKeyPress:w.handleKeyPress,onInputFocus:w.handleInputFocus,onInputBlur:w.handleInputBlur,chatEndRef:w.chatEndRef,isMuted:w.isMuted,onToggleMute:w.toggleMute,isSpeaking:w.isSpeaking,products:_,servicePackages:A,highlightedPartType:I,highlightedProduct:m,onAddToCart:F=>{var W;return(W=f.onAddToCart)==null?void 0:W.call(f,{product_id:F.id,product_name:F.name,quantity:1,unit_price:F.price,sku:F.sku,brand:F.brand})},onNavigateToProductPage:F=>{var W;return(W=f.onNavigateToProductPage)==null?void 0:W.call(f,F)},onPackageSelect:F=>console.log("[BobWidget] Package selected:",F),isResearching:C,vehicle:w.identifiedVehicle});if(t==="inline"&&r)return s.jsx("div",{className:`relative w-full h-full ${n}`,children:s.jsx(Tn,{currentImage:Q,animationState:x,backdropUrl:q,counterOverlayUrl:$,counterHeightPercent:X,bobOffset:O,bobScale:D,messages:w.messages,input:w.input,setInput:w.setInput,isLoading:w.isLoading,onSend:w.handleSend,onKeyPress:w.handleKeyPress,onInputFocus:w.handleInputFocus,onInputBlur:w.handleInputBlur,chatEndRef:w.chatEndRef,isMuted:w.isMuted,onToggleMute:w.toggleMute,isSpeaking:w.isSpeaking,products:_,servicePackages:A,highlightedPartType:I,highlightedProduct:m,onAddToCart:F=>{var W;return(W=f.onAddToCart)==null?void 0:W.call(f,{product_id:F.id,product_name:F.name,quantity:1,unit_price:F.price,sku:F.sku,brand:F.brand})},onNavigateToProductPage:F=>{var W;return(W=f.onNavigateToProductPage)==null?void 0:W.call(f,F)},onPackageSelect:F=>console.log("[BobWidget] Package selected:",F),isResearching:C,vehicle:w.identifiedVehicle})});const U={inline:"",floating:"fixed bottom-4 right-4 w-96 z-50 shadow-2xl rounded-lg overflow-hidden"};return s.jsxs("div",{className:`${U[t]||""} ${n}`,children:[Q&&s.jsx(fn,{currentImage:Q,animationState:x,backdropUrl:q,counterOverlayUrl:$,counterHeightPercent:X,verticalOffset:O,scale:D}),r&&s.jsx(xn,{messages:w.messages,input:w.input,setInput:w.setInput,isLoading:w.isLoading,onSend:w.handleSend,onKeyPress:w.handleKeyPress,onInputFocus:w.handleInputFocus,onInputBlur:w.handleInputBlur,chatEndRef:w.chatEndRef,isMuted:w.isMuted,onToggleMute:w.toggleMute,isSpeaking:w.isSpeaking})]})},qi=({bobConfig:t,hostApiConfig:e,hostContext:r,callbacks:n,variant:i="mobile",initialState:c,showChat:h,className:u,backdropUrl:y,counterOverlayUrl:k,counterHeightPercent:f,defaultBobImage:p,verticalOffset:S,scale:x,ga4Config:j,analyticsEnabled:g=!0,bottomOffset:E=0,zIndexBase:b=50})=>s.jsx("div",{className:"bob-widget-root",style:{width:"100%",height:"100%"},children:s.jsx(an,{bobConfig:t,hostApiConfig:e,hostContext:r,callbacks:n,ga4Config:j,analyticsEnabled:g,bottomOffset:E,zIndexBase:b,children:s.jsx(Rn,{variant:i,initialState:c,showChat:h,className:u,backdropUrl:y,counterOverlayUrl:k,counterHeightPercent:f,defaultBobImage:p,verticalOffset:S,scale:x})})}),Qi=({children:t,isSpeaking:e=!1,hasProducts:r=!1,onVisibilityChange:n,onPositionChange:i,currentPosition:c="center"})=>{const[h,u]=o.useState(!1),[y,k]=o.useState(0),f=o.useRef(null),p=o.useRef(0),S=o.useRef(0),x=o.useRef(!1),j=.25;o.useEffect(()=>{e&&c==="hidden"&&(i==null||i("partial-left"),n==null||n(!0))},[e,c,i,n]);const g=o.useCallback(_=>{p.current=_.touches[0].clientX,S.current=_.touches[0].clientY,x.current=!1,u(!0)},[]),E=o.useCallback(_=>{if(!h)return;const B=_.touches[0].clientX,A=_.touches[0].clientY,H=B-p.current,I=A-S.current;!x.current&&Math.abs(H)>10&&(x.current=Math.abs(H)>Math.abs(I)),x.current&&(_.preventDefault(),k(H))},[h]),b=o.useCallback(()=>{var I;if(!h)return;u(!1);const _=((I=f.current)==null?void 0:I.offsetWidth)||300,B=Math.abs(y)/_,A=y<0,H=y>0;A?c==="center"&&B>j?(i==null||i("partial-left"),n==null||n(!0)):c==="partial-left"&&B>j&&(i==null||i("hidden"),n==null||n(!1)):H&&(c==="hidden"&&B>j?(i==null||i("partial-left"),n==null||n(!0)):c==="partial-left"&&B>j&&!r&&(i==null||i("center"),n==null||n(!0))),k(0)},[h,y,c,r,i,n]),v=o.useCallback(()=>{i==null||i("partial-left"),n==null||n(!0)},[i,n]),d=()=>h&&y!==0?`translateX(${Math.max(-100,Math.min(100,y))}px)`:"translateX(0)";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{ref:f,style:{position:"fixed",inset:0,width:"100vw",height:"100dvh",transform:d(),transition:h?"none":"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",willChange:"transform"},onTouchStart:g,onTouchMove:E,onTouchEnd:b,children:[t,c==="center"&&!h&&s.jsx("div",{className:"absolute left-2 top-1/2 -translate-y-1/2 pointer-events-none",style:{animation:"swipeHint 3s ease-in-out 2s 1",opacity:0},children:s.jsx("svg",{className:"w-6 h-6 text-white/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),c==="hidden"&&s.jsx("button",{onClick:v,className:"fixed left-0 top-1/2 -translate-y-1/2 z-50 flex items-center justify-center",style:{writingMode:"vertical-rl",textOrientation:"mixed",background:"linear-gradient(180deg, #0066CC 0%, #004999 100%)",padding:"16px 8px",borderTopRightRadius:"12px",borderBottomRightRadius:"12px",boxShadow:"4px 0 12px rgba(0, 102, 204, 0.3)",animation:"slideInFromLeft 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",border:"none",cursor:"pointer"},children:s.jsx("span",{className:"text-white font-bold text-lg tracking-wider",children:"BOB"})}),s.jsx("style",{children:`
|
|
30
|
+
<%s key={someKey} {...props} />`,Lr,Ye,Bn,Ye),qe[Ye+Lr]=!0}}return a===n?Mr(ne):Or(ne),ne}}function it(a,R,O){return tr(a,R,O,!0)}function rr(a,R,O){return tr(a,R,O,!1)}var sr=rr,Ar=it;ir.Fragment=n,ir.jsx=sr,ir.jsxs=Ar}()),ir}process.env.NODE_ENV==="production"?Ur.exports=An():Ur.exports=Ln();var s=Ur.exports,yr=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(){}},Dn={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Qe,_t,As,Wn=(As=class{constructor(){G(this,Qe,Dn);G(this,_t,!1)}setTimeoutProvider(t){process.env.NODE_ENV!=="production"&&l(this,_t)&&t!==l(this,Qe)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:l(this,Qe),provider:t}),L(this,Qe,t),process.env.NODE_ENV!=="production"&&L(this,_t,!1)}setTimeout(t,e){return process.env.NODE_ENV!=="production"&&L(this,_t,!0),l(this,Qe).setTimeout(t,e)}clearTimeout(t){l(this,Qe).clearTimeout(t)}setInterval(t,e){return process.env.NODE_ENV!=="production"&&L(this,_t,!0),l(this,Qe).setInterval(t,e)}clearInterval(t){l(this,Qe).clearInterval(t)}},Qe=new WeakMap,_t=new WeakMap,As),jt=new Wn;function zn(t){setTimeout(t,0)}var Ot=typeof window>"u"||"Deno"in globalThis;function Te(){}function $n(t,e){return typeof t=="function"?t(e):t}function Hr(t){return typeof t=="number"&&t>=0&&t!==1/0}function Ks(t,e){return Math.max(t+(e||0)-Date.now(),0)}function bt(t,e){return typeof t=="function"?t(e):t}function Ae(t,e){return typeof t=="function"?t(e):t}function xs(t,e){const{type:r="all",exact:n,fetchStatus:i,predicate:c,queryKey:h,stale:u}=t;if(h){if(n){if(e.queryHash!==as(h,e.options))return!1}else if(!hr(e.queryKey,h))return!1}if(r!=="all"){const y=e.isActive();if(r==="active"&&!y||r==="inactive"&&y)return!1}return!(typeof u=="boolean"&&e.isStale()!==u||i&&i!==e.state.fetchStatus||c&&!c(e))}function ys(t,e){const{exact:r,status:n,predicate:i,mutationKey:c}=t;if(c){if(!e.options.mutationKey)return!1;if(r){if(dr(e.options.mutationKey)!==dr(c))return!1}else if(!hr(e.options.mutationKey,c))return!1}return!(n&&e.state.status!==n||i&&!i(e))}function as(t,e){return((e==null?void 0:e.queryKeyHashFn)||dr)(t)}function dr(t){return JSON.stringify(t,(e,r)=>Kr(r)?Object.keys(r).sort().reduce((n,i)=>(n[i]=r[i],n),{}):r)}function hr(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>hr(t[r],e[r])):!1}var Un=Object.prototype.hasOwnProperty;function qr(t,e,r=0){if(t===e)return t;if(r>500)return e;const n=vs(t)&&vs(e);if(!n&&!(Kr(t)&&Kr(e)))return e;const c=(n?t:Object.keys(t)).length,h=n?e:Object.keys(e),u=h.length,y=n?new Array(u):{};let k=0;for(let f=0;f<u;f++){const g=n?f:h[f],S=t[g],x=e[g];if(S===x){y[g]=S,(n?f<c:Un.call(t,g))&&k++;continue}if(S===null||x===null||typeof S!="object"||typeof x!="object"){y[g]=x;continue}const j=qr(S,x,r+1);y[g]=j,j===S&&k++}return c===u&&k===c?t:y}function Qr(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 vs(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Kr(t){if(!ws(t))return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(!ws(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function ws(t){return Object.prototype.toString.call(t)==="[object Object]"}function Hn(t){return new Promise(e=>{jt.setTimeout(e,t)})}function Vr(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 qr(t,e)}catch(n){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}]: ${n}`),n}return qr(t,e)}return e}function qn(t,e,r=0){const n=[...t,e];return r&&n.length>r?n.slice(1):n}function Qn(t,e,r=0){const n=[e,...t];return r&&n.length>r?n.slice(0,-1):n}var Tr=Symbol();function Vs(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===Tr&&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===Tr?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Gs(t,e){return typeof t=="function"?t(...e):!!t}function Kn(t,e,r){let n=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(i??(i=e()),n||(n=!0,i.aborted?r():i.addEventListener("abort",r,{once:!0})),i)}),t}var Et,lt,Lt,Ls,Vn=(Ls=class extends yr{constructor(){super();G(this,Et);G(this,lt);G(this,Lt);L(this,Lt,e=>{if(!Ot&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){l(this,lt)||this.setEventListener(l(this,Lt))}onUnsubscribe(){var e;this.hasListeners()||((e=l(this,lt))==null||e.call(this),L(this,lt,void 0))}setEventListener(e){var r;L(this,Lt,e),(r=l(this,lt))==null||r.call(this),L(this,lt,e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(e){l(this,Et)!==e&&(L(this,Et,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof l(this,Et)=="boolean"?l(this,Et):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},Et=new WeakMap,lt=new WeakMap,Lt=new WeakMap,Ls),os=new Vn;function Gr(){let t,e;const r=new Promise((i,c)=>{t=i,e=c});r.status="pending",r.catch(()=>{});function n(i){Object.assign(r,i),delete r.resolve,delete r.reject}return r.resolve=i=>{n({status:"fulfilled",value:i}),t(i)},r.reject=i=>{n({status:"rejected",reason:i}),e(i)},r}var Gn=zn;function Yn(){let t=[],e=0,r=u=>{u()},n=u=>{u()},i=Gn;const c=u=>{e?t.push(u):i(()=>{r(u)})},h=()=>{const u=t;t=[],u.length&&i(()=>{n(()=>{u.forEach(y=>{r(y)})})})};return{batch:u=>{let y;e++;try{y=u()}finally{e--,e||h()}return y},batchCalls:u=>(...y)=>{c(()=>{u(...y)})},schedule:c,setNotifyFunction:u=>{r=u},setBatchNotifyFunction:u=>{n=u},setScheduler:u=>{i=u}}}var ye=Yn(),Dt,ct,Wt,Ds,Xn=(Ds=class extends yr{constructor(){super();G(this,Dt,!0);G(this,ct);G(this,Wt);L(this,Wt,e=>{if(!Ot&&window.addEventListener){const r=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){l(this,ct)||this.setEventListener(l(this,Wt))}onUnsubscribe(){var e;this.hasListeners()||((e=l(this,ct))==null||e.call(this),L(this,ct,void 0))}setEventListener(e){var r;L(this,Wt,e),(r=l(this,ct))==null||r.call(this),L(this,ct,e(this.setOnline.bind(this)))}setOnline(e){l(this,Dt)!==e&&(L(this,Dt,e),this.listeners.forEach(n=>{n(e)}))}isOnline(){return l(this,Dt)}},Dt=new WeakMap,ct=new WeakMap,Wt=new WeakMap,Ds),Rr=new Xn;function Jn(t){return Math.min(1e3*2**t,3e4)}function Ys(t){return(t??"online")==="online"?Rr.isOnline():!0}var Yr=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function Xs(t){let e=!1,r=0,n;const i=Gr(),c=()=>i.status!=="pending",h=p=>{var E;if(!c()){const b=new Yr(p);S(b),(E=t.onCancel)==null||E.call(t,b)}},u=()=>{e=!0},y=()=>{e=!1},k=()=>os.isFocused()&&(t.networkMode==="always"||Rr.isOnline())&&t.canRun(),f=()=>Ys(t.networkMode)&&t.canRun(),g=p=>{c()||(n==null||n(),i.resolve(p))},S=p=>{c()||(n==null||n(),i.reject(p))},x=()=>new Promise(p=>{var E;n=b=>{(c()||k())&&p(b)},(E=t.onPause)==null||E.call(t)}).then(()=>{var p;n=void 0,c()||(p=t.onContinue)==null||p.call(t)}),j=()=>{if(c())return;let p;const E=r===0?t.initialPromise:void 0;try{p=E??t.fn()}catch(b){p=Promise.reject(b)}Promise.resolve(p).then(g).catch(b=>{var A;if(c())return;const v=t.retry??(Ot?0:3),d=t.retryDelay??Jn,_=typeof d=="function"?d(r,b):d,B=v===!0||typeof v=="number"&&r<v||typeof v=="function"&&v(r,b);if(e||!B){S(b);return}r++,(A=t.onFail)==null||A.call(t,r,b),Hn(_).then(()=>k()?void 0:x()).then(()=>{e?S(b):j()})})};return{promise:i,status:()=>i.status,cancel:h,continue:()=>(n==null||n(),i),cancelRetry:u,continueRetry:y,canStart:f,start:()=>(f()?j():x().then(j),i)}}var Tt,Ws,Js=(Ws=class{constructor(){G(this,Tt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Hr(this.gcTime)&&L(this,Tt,jt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Ot?1/0:5*60*1e3))}clearGcTimeout(){l(this,Tt)&&(jt.clearTimeout(l(this,Tt)),L(this,Tt,void 0))}},Tt=new WeakMap,Ws),Rt,zt,Me,Ct,me,pr,Nt,$e,Xe,zs,Zn=(zs=class extends Js{constructor(e){super();G(this,$e);G(this,Rt);G(this,zt);G(this,Me);G(this,Ct);G(this,me);G(this,pr);G(this,Nt);L(this,Nt,!1),L(this,pr,e.defaultOptions),this.setOptions(e.options),this.observers=[],L(this,Ct,e.client),L(this,Me,l(this,Ct).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,L(this,Rt,Ss(this.options)),this.state=e.state??l(this,Rt),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=l(this,me))==null?void 0:e.promise}setOptions(e){if(this.options={...l(this,pr),...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=Ss(this.options);r.data!==void 0&&(this.setState(ks(r.data,r.dataUpdatedAt)),L(this,Rt,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&l(this,Me).remove(this)}setData(e,r){const n=Vr(this.state.data,e,this.options);return re(this,$e,Xe).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(e,r){re(this,$e,Xe).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var n,i;const r=(n=l(this,me))==null?void 0:n.promise;return(i=l(this,me))==null||i.cancel(e),r?r.then(Te).catch(Te):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(l(this,Rt))}isActive(){return this.observers.some(e=>Ae(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Tr||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>bt(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(n=>n.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=l(this,me))==null||r.continue()}onOnline(){var r;const e=this.observers.find(n=>n.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=l(this,me))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),l(this,Me).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(l(this,me)&&(l(this,Nt)?l(this,me).cancel({revert:!0}):l(this,me).cancelRetry()),this.scheduleGc()),l(this,Me).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||re(this,$e,Xe).call(this,{type:"invalidate"})}async fetch(e,r){var y,k,f,g,S,x,j,p,E,b,v,d;if(this.state.fetchStatus!=="idle"&&((y=l(this,me))==null?void 0:y.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(l(this,me))return l(this,me).continueRetry(),l(this,me).promise}if(e&&this.setOptions(e),!this.options.queryFn){const _=this.observers.find(B=>B.options.queryFn);_&&this.setOptions(_.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 n=new AbortController,i=_=>{Object.defineProperty(_,"signal",{enumerable:!0,get:()=>(L(this,Nt,!0),n.signal)})},c=()=>{const _=Vs(this.options,r),A=(()=>{const H={client:l(this,Ct),queryKey:this.queryKey,meta:this.meta};return i(H),H})();return L(this,Nt,!1),this.options.persister?this.options.persister(_,A,this):_(A)},u=(()=>{const _={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:l(this,Ct),state:this.state,fetchFn:c};return i(_),_})();(k=this.options.behavior)==null||k.onFetch(u,this),L(this,zt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=u.fetchOptions)==null?void 0:f.meta))&&re(this,$e,Xe).call(this,{type:"fetch",meta:(g=u.fetchOptions)==null?void 0:g.meta}),L(this,me,Xs({initialPromise:r==null?void 0:r.initialPromise,fn:u.fetchFn,onCancel:_=>{_ instanceof Yr&&_.revert&&this.setState({...l(this,zt),fetchStatus:"idle"}),n.abort()},onFail:(_,B)=>{re(this,$e,Xe).call(this,{type:"failed",failureCount:_,error:B})},onPause:()=>{re(this,$e,Xe).call(this,{type:"pause"})},onContinue:()=>{re(this,$e,Xe).call(this,{type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode,canRun:()=>!0}));try{const _=await l(this,me).start();if(_===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(_),(x=(S=l(this,Me).config).onSuccess)==null||x.call(S,_,this),(p=(j=l(this,Me).config).onSettled)==null||p.call(j,_,this.state.error,this),_}catch(_){if(_ instanceof Yr){if(_.silent)return l(this,me).promise;if(_.revert){if(this.state.data===void 0)throw _;return this.state.data}}throw re(this,$e,Xe).call(this,{type:"error",error:_}),(b=(E=l(this,Me).config).onError)==null||b.call(E,_,this),(d=(v=l(this,Me).config).onSettled)==null||d.call(v,this.state.data,_,this),_}finally{this.scheduleGc()}}},Rt=new WeakMap,zt=new WeakMap,Me=new WeakMap,Ct=new WeakMap,me=new WeakMap,pr=new WeakMap,Nt=new WeakMap,$e=new WeakSet,Xe=function(e){const r=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Zs(n.data,this.options),fetchMeta:e.meta??null};case"success":const i={...n,...ks(e.data,e.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return L(this,zt,e.manual?i:void 0),i;case"error":const c=e.error;return{...n,error:c,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:c,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=r(this.state),ye.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),l(this,Me).notify({query:this,type:"updated",action:e})})},zs);function Zs(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ys(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function ks(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Ss(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,n=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Ee,se,gr,ke,Ft,$t,Je,ut,br,Ut,Ht,Bt,It,dt,qt,le,lr,Xr,Jr,Zr,es,ts,rs,ss,en,$s,ei=($s=class extends yr{constructor(e,r){super();G(this,le);G(this,Ee);G(this,se);G(this,gr);G(this,ke);G(this,Ft);G(this,$t);G(this,Je);G(this,ut);G(this,br);G(this,Ut);G(this,Ht);G(this,Bt);G(this,It);G(this,dt);G(this,qt,new Set);this.options=r,L(this,Ee,e),L(this,ut,null),L(this,Je,Gr()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(l(this,se).addObserver(this),js(l(this,se),this.options)?re(this,le,lr).call(this):this.updateResult(),re(this,le,es).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ns(l(this,se),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ns(l(this,se),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,re(this,le,ts).call(this),re(this,le,rs).call(this),l(this,se).removeObserver(this)}setOptions(e){const r=this.options,n=l(this,se);if(this.options=l(this,Ee).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ae(this.options.enabled,l(this,se))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");re(this,le,ss).call(this),l(this,se).setOptions(this.options),r._defaulted&&!Qr(this.options,r)&&l(this,Ee).getQueryCache().notify({type:"observerOptionsUpdated",query:l(this,se),observer:this});const i=this.hasListeners();i&&_s(l(this,se),n,this.options,r)&&re(this,le,lr).call(this),this.updateResult(),i&&(l(this,se)!==n||Ae(this.options.enabled,l(this,se))!==Ae(r.enabled,l(this,se))||bt(this.options.staleTime,l(this,se))!==bt(r.staleTime,l(this,se)))&&re(this,le,Xr).call(this);const c=re(this,le,Jr).call(this);i&&(l(this,se)!==n||Ae(this.options.enabled,l(this,se))!==Ae(r.enabled,l(this,se))||c!==l(this,dt))&&re(this,le,Zr).call(this,c)}getOptimisticResult(e){const r=l(this,Ee).getQueryCache().build(l(this,Ee),e),n=this.createResult(r,e);return ri(this,n)&&(L(this,ke,n),L(this,$t,this.options),L(this,Ft,l(this,se).state)),n}getCurrentResult(){return l(this,ke)}trackResult(e,r){return new Proxy(e,{get:(n,i)=>(this.trackProp(i),r==null||r(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&l(this,Je).status==="pending"&&l(this,Je).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,i))})}trackProp(e){l(this,qt).add(e)}getCurrentQuery(){return l(this,se)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=l(this,Ee).defaultQueryOptions(e),n=l(this,Ee).getQueryCache().build(l(this,Ee),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(e){return re(this,le,lr).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),l(this,ke)))}createResult(e,r){var z;const n=l(this,se),i=this.options,c=l(this,ke),h=l(this,Ft),u=l(this,$t),k=e!==n?e.state:l(this,gr),{state:f}=e;let g={...f},S=!1,x;if(r._optimisticResults){const m=this.hasListeners(),T=!m&&js(e,r),C=m&&_s(e,n,r,i);(T||C)&&(g={...g,...Zs(f.data,e.options)}),r._optimisticResults==="isRestoring"&&(g.fetchStatus="idle")}let{error:j,errorUpdatedAt:p,status:E}=g;x=g.data;let b=!1;if(r.placeholderData!==void 0&&x===void 0&&E==="pending"){let m;c!=null&&c.isPlaceholderData&&r.placeholderData===(u==null?void 0:u.placeholderData)?(m=c.data,b=!0):m=typeof r.placeholderData=="function"?r.placeholderData((z=l(this,Ht))==null?void 0:z.state.data,l(this,Ht)):r.placeholderData,m!==void 0&&(E="success",x=Vr(c==null?void 0:c.data,m,r),S=!0)}if(r.select&&x!==void 0&&!b)if(c&&x===(h==null?void 0:h.data)&&r.select===l(this,br))x=l(this,Ut);else try{L(this,br,r.select),x=r.select(x),x=Vr(c==null?void 0:c.data,x,r),L(this,Ut,x),L(this,ut,null)}catch(m){L(this,ut,m)}l(this,ut)&&(j=l(this,ut),x=l(this,Ut),p=Date.now(),E="error");const v=g.fetchStatus==="fetching",d=E==="pending",_=E==="error",B=d&&v,A=x!==void 0,I={status:E,fetchStatus:g.fetchStatus,isPending:d,isSuccess:E==="success",isError:_,isInitialLoading:B,isLoading:B,data:x,dataUpdatedAt:g.dataUpdatedAt,error:j,errorUpdatedAt:p,failureCount:g.fetchFailureCount,failureReason:g.fetchFailureReason,errorUpdateCount:g.errorUpdateCount,isFetched:g.dataUpdateCount>0||g.errorUpdateCount>0,isFetchedAfterMount:g.dataUpdateCount>k.dataUpdateCount||g.errorUpdateCount>k.errorUpdateCount,isFetching:v,isRefetching:v&&!d,isLoadingError:_&&!A,isPaused:g.fetchStatus==="paused",isPlaceholderData:S,isRefetchError:_&&A,isStale:ls(e,r),refetch:this.refetch,promise:l(this,Je),isEnabled:Ae(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const m=I.data!==void 0,T=I.status==="error"&&!m,C=q=>{T?q.reject(I.error):m&&q.resolve(I.data)},N=()=>{const q=L(this,Je,I.promise=Gr());C(q)},w=l(this,Je);switch(w.status){case"pending":e.queryHash===n.queryHash&&C(w);break;case"fulfilled":(T||I.data!==w.value)&&N();break;case"rejected":(!T||I.error!==w.reason)&&N();break}}return I}updateResult(){const e=l(this,ke),r=this.createResult(l(this,se),this.options);if(L(this,Ft,l(this,se).state),L(this,$t,this.options),l(this,Ft).data!==void 0&&L(this,Ht,l(this,se)),Qr(r,e))return;L(this,ke,r);const n=()=>{if(!e)return!0;const{notifyOnChangeProps:i}=this.options,c=typeof i=="function"?i():i;if(c==="all"||!c&&!l(this,qt).size)return!0;const h=new Set(c??l(this,qt));return this.options.throwOnError&&h.add("error"),Object.keys(l(this,ke)).some(u=>{const y=u;return l(this,ke)[y]!==e[y]&&h.has(y)})};re(this,le,en).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&re(this,le,es).call(this)}},Ee=new WeakMap,se=new WeakMap,gr=new WeakMap,ke=new WeakMap,Ft=new WeakMap,$t=new WeakMap,Je=new WeakMap,ut=new WeakMap,br=new WeakMap,Ut=new WeakMap,Ht=new WeakMap,Bt=new WeakMap,It=new WeakMap,dt=new WeakMap,qt=new WeakMap,le=new WeakSet,lr=function(e){re(this,le,ss).call(this);let r=l(this,se).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(Te)),r},Xr=function(){re(this,le,ts).call(this);const e=bt(this.options.staleTime,l(this,se));if(Ot||l(this,ke).isStale||!Hr(e))return;const n=Ks(l(this,ke).dataUpdatedAt,e)+1;L(this,Bt,jt.setTimeout(()=>{l(this,ke).isStale||this.updateResult()},n))},Jr=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(l(this,se)):this.options.refetchInterval)??!1},Zr=function(e){re(this,le,rs).call(this),L(this,dt,e),!(Ot||Ae(this.options.enabled,l(this,se))===!1||!Hr(l(this,dt))||l(this,dt)===0)&&L(this,It,jt.setInterval(()=>{(this.options.refetchIntervalInBackground||os.isFocused())&&re(this,le,lr).call(this)},l(this,dt)))},es=function(){re(this,le,Xr).call(this),re(this,le,Zr).call(this,re(this,le,Jr).call(this))},ts=function(){l(this,Bt)&&(jt.clearTimeout(l(this,Bt)),L(this,Bt,void 0))},rs=function(){l(this,It)&&(jt.clearInterval(l(this,It)),L(this,It,void 0))},ss=function(){const e=l(this,Ee).getQueryCache().build(l(this,Ee),this.options);if(e===l(this,se))return;const r=l(this,se);L(this,se,e),L(this,gr,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},en=function(e){ye.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(l(this,ke))}),l(this,Ee).getQueryCache().notify({query:l(this,se),type:"observerResultsUpdated"})})},$s);function ti(t,e){return Ae(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function js(t,e){return ti(t,e)||t.state.data!==void 0&&ns(t,e,e.refetchOnMount)}function ns(t,e,r){if(Ae(e.enabled,t)!==!1&&bt(e.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&ls(t,e)}return!1}function _s(t,e,r,n){return(t!==e||Ae(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&ls(t,r)}function ls(t,e){return Ae(e.enabled,t)!==!1&&t.isStaleByTime(bt(e.staleTime,t))}function ri(t,e){return!Qr(t.getCurrentResult(),e)}function Es(t){return{onFetch:(e,r)=>{var f,g,S,x,j;const n=e.options,i=(S=(g=(f=e.fetchOptions)==null?void 0:f.meta)==null?void 0:g.fetchMore)==null?void 0:S.direction,c=((x=e.state.data)==null?void 0:x.pages)||[],h=((j=e.state.data)==null?void 0:j.pageParams)||[];let u={pages:[],pageParams:[]},y=0;const k=async()=>{let p=!1;const E=d=>{Kn(d,()=>e.signal,()=>p=!0)},b=Vs(e.options,e.fetchOptions),v=async(d,_,B)=>{if(p)return Promise.reject();if(_==null&&d.pages.length)return Promise.resolve(d);const H=(()=>{const T={client:e.client,queryKey:e.queryKey,pageParam:_,direction:B?"backward":"forward",meta:e.options.meta};return E(T),T})(),I=await b(H),{maxPages:z}=e.options,m=B?Qn:qn;return{pages:m(d.pages,I,z),pageParams:m(d.pageParams,_,z)}};if(i&&c.length){const d=i==="backward",_=d?si:Ts,B={pages:c,pageParams:h},A=_(n,B);u=await v(B,A,d)}else{const d=t??c.length;do{const _=y===0?h[0]??n.initialPageParam:Ts(n,u);if(y>0&&_==null)break;u=await v(u,_),y++}while(y<d)}return u};e.options.persister?e.fetchFn=()=>{var p,E;return(E=(p=e.options).persister)==null?void 0:E.call(p,k,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=k}}}function Ts(t,{pages:e,pageParams:r}){const n=e.length-1;return e.length>0?t.getNextPageParam(e[n],e,r[n],r):void 0}function si(t,{pages:e,pageParams:r}){var n;return e.length>0?(n=t.getPreviousPageParam)==null?void 0:n.call(t,e[0],e,r[0],r):void 0}var mr,Ke,Se,Pt,Ve,ot,Us,ni=(Us=class extends Js{constructor(e){super();G(this,Ve);G(this,mr);G(this,Ke);G(this,Se);G(this,Pt);L(this,mr,e.client),this.mutationId=e.mutationId,L(this,Se,e.mutationCache),L(this,Ke,[]),this.state=e.state||ii(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){l(this,Ke).includes(e)||(l(this,Ke).push(e),this.clearGcTimeout(),l(this,Se).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){L(this,Ke,l(this,Ke).filter(r=>r!==e)),this.scheduleGc(),l(this,Se).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){l(this,Ke).length||(this.state.status==="pending"?this.scheduleGc():l(this,Se).remove(this))}continue(){var e;return((e=l(this,Pt))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var h,u,y,k,f,g,S,x,j,p,E,b,v,d,_,B,A,H,I,z;const r=()=>{re(this,Ve,ot).call(this,{type:"continue"})},n={client:l(this,mr),meta:this.options.meta,mutationKey:this.options.mutationKey};L(this,Pt,Xs({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(new Error("No mutationFn found")),onFail:(m,T)=>{re(this,Ve,ot).call(this,{type:"failed",failureCount:m,error:T})},onPause:()=>{re(this,Ve,ot).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>l(this,Se).canRun(this)}));const i=this.state.status==="pending",c=!l(this,Pt).canStart();try{if(i)r();else{re(this,Ve,ot).call(this,{type:"pending",variables:e,isPaused:c}),await((u=(h=l(this,Se).config).onMutate)==null?void 0:u.call(h,e,this,n));const T=await((k=(y=this.options).onMutate)==null?void 0:k.call(y,e,n));T!==this.state.context&&re(this,Ve,ot).call(this,{type:"pending",context:T,variables:e,isPaused:c})}const m=await l(this,Pt).start();return await((g=(f=l(this,Se).config).onSuccess)==null?void 0:g.call(f,m,e,this.state.context,this,n)),await((x=(S=this.options).onSuccess)==null?void 0:x.call(S,m,e,this.state.context,n)),await((p=(j=l(this,Se).config).onSettled)==null?void 0:p.call(j,m,null,this.state.variables,this.state.context,this,n)),await((b=(E=this.options).onSettled)==null?void 0:b.call(E,m,null,e,this.state.context,n)),re(this,Ve,ot).call(this,{type:"success",data:m}),m}catch(m){try{await((d=(v=l(this,Se).config).onError)==null?void 0:d.call(v,m,e,this.state.context,this,n))}catch(T){Promise.reject(T)}try{await((B=(_=this.options).onError)==null?void 0:B.call(_,m,e,this.state.context,n))}catch(T){Promise.reject(T)}try{await((H=(A=l(this,Se).config).onSettled)==null?void 0:H.call(A,void 0,m,this.state.variables,this.state.context,this,n))}catch(T){Promise.reject(T)}try{await((z=(I=this.options).onSettled)==null?void 0:z.call(I,void 0,m,e,this.state.context,n))}catch(T){Promise.reject(T)}throw re(this,Ve,ot).call(this,{type:"error",error:m}),m}finally{l(this,Se).runNext(this)}}},mr=new WeakMap,Ke=new WeakMap,Se=new WeakMap,Pt=new WeakMap,Ve=new WeakSet,ot=function(e){const r=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,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{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),ye.batch(()=>{l(this,Ke).forEach(n=>{n.onMutationUpdate(e)}),l(this,Se).notify({mutation:this,type:"updated",action:e})})},Us);function ii(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ze,Ue,xr,Hs,ai=(Hs=class extends yr{constructor(e={}){super();G(this,Ze);G(this,Ue);G(this,xr);this.config=e,L(this,Ze,new Set),L(this,Ue,new Map),L(this,xr,0)}build(e,r,n){const i=new ni({client:e,mutationCache:this,mutationId:++jr(this,xr)._,options:e.defaultMutationOptions(r),state:n});return this.add(i),i}add(e){l(this,Ze).add(e);const r=_r(e);if(typeof r=="string"){const n=l(this,Ue).get(r);n?n.push(e):l(this,Ue).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(l(this,Ze).delete(e)){const r=_r(e);if(typeof r=="string"){const n=l(this,Ue).get(r);if(n)if(n.length>1){const i=n.indexOf(e);i!==-1&&n.splice(i,1)}else n[0]===e&&l(this,Ue).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=_r(e);if(typeof r=="string"){const n=l(this,Ue).get(r),i=n==null?void 0:n.find(c=>c.state.status==="pending");return!i||i===e}else return!0}runNext(e){var n;const r=_r(e);if(typeof r=="string"){const i=(n=l(this,Ue).get(r))==null?void 0:n.find(c=>c!==e&&c.state.isPaused);return(i==null?void 0:i.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ye.batch(()=>{l(this,Ze).forEach(e=>{this.notify({type:"removed",mutation:e})}),l(this,Ze).clear(),l(this,Ue).clear()})}getAll(){return Array.from(l(this,Ze))}find(e){const r={exact:!0,...e};return this.getAll().find(n=>ys(r,n))}findAll(e={}){return this.getAll().filter(r=>ys(e,r))}notify(e){ye.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return ye.batch(()=>Promise.all(e.map(r=>r.continue().catch(Te))))}},Ze=new WeakMap,Ue=new WeakMap,xr=new WeakMap,Hs);function _r(t){var e;return(e=t.options.scope)==null?void 0:e.id}var Ge,qs,oi=(qs=class extends yr{constructor(e={}){super();G(this,Ge);this.config=e,L(this,Ge,new Map)}build(e,r,n){const i=r.queryKey,c=r.queryHash??as(i,r);let h=this.get(c);return h||(h=new Zn({client:e,queryKey:i,queryHash:c,options:e.defaultQueryOptions(r),state:n,defaultOptions:e.getQueryDefaults(i)}),this.add(h)),h}add(e){l(this,Ge).has(e.queryHash)||(l(this,Ge).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=l(this,Ge).get(e.queryHash);r&&(e.destroy(),r===e&&l(this,Ge).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ye.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return l(this,Ge).get(e)}getAll(){return[...l(this,Ge).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(n=>xs(r,n))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(n=>xs(e,n)):r}notify(e){ye.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){ye.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ye.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Ge=new WeakMap,qs),he,ht,ft,Qt,Kt,pt,Vt,Gt,Qs,li=(Qs=class{constructor(t={}){G(this,he);G(this,ht);G(this,ft);G(this,Qt);G(this,Kt);G(this,pt);G(this,Vt);G(this,Gt);L(this,he,t.queryCache||new oi),L(this,ht,t.mutationCache||new ai),L(this,ft,t.defaultOptions||{}),L(this,Qt,new Map),L(this,Kt,new Map),L(this,pt,0)}mount(){jr(this,pt)._++,l(this,pt)===1&&(L(this,Vt,os.subscribe(async t=>{t&&(await this.resumePausedMutations(),l(this,he).onFocus())})),L(this,Gt,Rr.subscribe(async t=>{t&&(await this.resumePausedMutations(),l(this,he).onOnline())})))}unmount(){var t,e;jr(this,pt)._--,l(this,pt)===0&&((t=l(this,Vt))==null||t.call(this),L(this,Vt,void 0),(e=l(this,Gt))==null||e.call(this),L(this,Gt,void 0))}isFetching(t){return l(this,he).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return l(this,ht).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=l(this,he).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=l(this,he).build(this,e),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(bt(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return l(this,he).findAll(t).map(({queryKey:e,state:r})=>{const n=r.data;return[e,n]})}setQueryData(t,e,r){const n=this.defaultQueryOptions({queryKey:t}),i=l(this,he).get(n.queryHash),c=i==null?void 0:i.state.data,h=$n(e,c);if(h!==void 0)return l(this,he).build(this,n).setData(h,{...r,manual:!0})}setQueriesData(t,e,r){return ye.batch(()=>l(this,he).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=l(this,he).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=l(this,he);ye.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=l(this,he);return ye.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},n=ye.batch(()=>l(this,he).findAll(t).map(i=>i.cancel(r)));return Promise.all(n).then(Te).catch(Te)}invalidateQueries(t,e={}){return ye.batch(()=>(l(this,he).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},n=ye.batch(()=>l(this,he).findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let c=i.fetch(void 0,r);return r.throwOnError||(c=c.catch(Te)),i.state.fetchStatus==="paused"?Promise.resolve():c}));return Promise.all(n).then(Te)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=l(this,he).build(this,e);return r.isStaleByTime(bt(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Te).catch(Te)}fetchInfiniteQuery(t){return t.behavior=Es(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Te).catch(Te)}ensureInfiniteQueryData(t){return t.behavior=Es(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Rr.isOnline()?l(this,ht).resumePausedMutations():Promise.resolve()}getQueryCache(){return l(this,he)}getMutationCache(){return l(this,ht)}getDefaultOptions(){return l(this,ft)}setDefaultOptions(t){L(this,ft,t)}setQueryDefaults(t,e){l(this,Qt).set(dr(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...l(this,Qt).values()],r={};return e.forEach(n=>{hr(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,e){l(this,Kt).set(dr(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...l(this,Kt).values()],r={};return e.forEach(n=>{hr(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={...l(this,ft).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=as(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===Tr&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...l(this,ft).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){l(this,he).clear(),l(this,ht).clear()}},he=new WeakMap,ht=new WeakMap,ft=new WeakMap,Qt=new WeakMap,Kt=new WeakMap,pt=new WeakMap,Vt=new WeakMap,Gt=new WeakMap,Qs),tn=Le.createContext(void 0),rn=t=>{const e=Le.useContext(tn);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},ci=({client:t,children:e})=>(Le.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),s.jsx(tn.Provider,{value:t,children:e})),sn=Le.createContext(!1),ui=()=>Le.useContext(sn);sn.Provider;function di(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var hi=Le.createContext(di()),fi=()=>Le.useContext(hi),pi=(t,e,r)=>{const n=r!=null&&r.state.error&&typeof t.throwOnError=="function"?Gs(t.throwOnError,[r.state.error,r]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||n)&&(e.isReset()||(t.retryOnMount=!1))},gi=t=>{Le.useEffect(()=>{t.clearReset()},[t])},bi=({result:t,errorResetBoundary:e,throwOnError:r,query:n,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(i&&t.data===void 0||Gs(r,[t.error,n])),mi=t=>{if(t.suspense){const r=i=>i==="static"?i:Math.max(i??1e3,1e3),n=t.staleTime;t.staleTime=typeof n=="function"?(...i)=>r(n(...i)):r(n),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},xi=(t,e)=>t.isLoading&&t.isFetching&&!e,yi=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,Rs=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function vi(t,e,r){var S,x,j,p;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 n=ui(),i=fi(),c=rn(),h=c.defaultQueryOptions(t);(x=(S=c.getDefaultOptions().queries)==null?void 0:S._experimental_beforeQuery)==null||x.call(S,h);const u=c.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=n?"isRestoring":"optimistic",mi(h),pi(h,i,u),gi(i);const y=!c.getQueryCache().get(h.queryHash),[k]=Le.useState(()=>new e(c,h)),f=k.getOptimisticResult(h),g=!n&&t.subscribed!==!1;if(Le.useSyncExternalStore(Le.useCallback(E=>{const b=g?k.subscribe(ye.batchCalls(E)):Te;return k.updateResult(),b},[k,g]),()=>k.getCurrentResult(),()=>k.getCurrentResult()),Le.useEffect(()=>{k.setOptions(h)},[h,k]),yi(h,f))throw Rs(h,k,i);if(bi({result:f,errorResetBoundary:i,throwOnError:h.throwOnError,query:u,suspense:h.suspense}))throw f.error;if((p=(j=c.getDefaultOptions().queries)==null?void 0:j._experimental_afterQuery)==null||p.call(j,h,f),h.experimental_prefetchInRender&&!Ot&&xi(f,n)){const E=y?Rs(h,k,i):u==null?void 0:u.promise;E==null||E.catch(Te).finally(()=>{k.updateResult()})}return h.notifyOnChangeProps?f:k.trackResult(f)}function vr(t,e){return vi(t,ei)}const wi=()=>`bob_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;function nn({ga4Config:t,hostContext:e,callbacks:r,enabled:n=!0}){const i=o.useRef(wi()),c=o.useRef(!1),h=o.useCallback((d,_)=>{if(!(!(t!=null&&t.measurementId)||typeof window>"u")&&window.gtag){const B={..._,send_to:t.measurementId};t.debug&&console.log("[BobAnalytics] GA4 event:",d,B),window.gtag("event",d,B)}},[t]),u=o.useCallback((d,_={})=>{var A,H,I,z,m,T,C,N;if(!n)return;const B={event_name:d,timestamp:new Date().toISOString(),session_id:i.current,user_email:(A=e==null?void 0:e.user)==null?void 0:A.email,user_id:(H=e==null?void 0:e.user)==null?void 0:H.id,vehicle_id:(m=(z=(I=e==null?void 0:e.vehicle)==null?void 0:I.selectedVehicle)==null?void 0:z.vehicle_id)==null?void 0:m.toString(),rego:(C=(T=e==null?void 0:e.vehicle)==null?void 0:T.selectedVehicle)==null?void 0:C.rego,parameters:_};h(d,{session_id:B.session_id,user_email:B.user_email,vehicle_id:B.vehicle_id,..._}),(N=r==null?void 0:r.onAnalyticsEvent)==null||N.call(r,B),t!=null&&t.debug&&console.log("[BobAnalytics] Event tracked:",B)},[n,e,r,h,t==null?void 0:t.debug]),y=o.useCallback(()=>{var d,_,B;c.current||(c.current=!0,u("bob_session_start",{widget_version:Mt,has_vehicle:!!((d=e==null?void 0:e.vehicle)!=null&&d.selectedVehicle),has_user:!!((_=e==null?void 0:e.user)!=null&&_.id)||!!((B=e==null?void 0:e.user)!=null&&B.email)}))},[u,e]),k=o.useCallback((d,_)=>{u("bob_message_sent",{message_length:d,has_vehicle:_})},[u]),f=o.useCallback(d=>{u("bob_vehicle_identified",{vehicle_make:d.make||"unknown",vehicle_model:d.model||"unknown",vehicle_year:d.year||"unknown",rego:d.rego})},[u]),g=o.useCallback((d,_)=>{u("bob_parts_viewed",{part_count:d,vehicle_id:_})},[u]),S=o.useCallback(d=>{u("bob_product_clicked",{sku:d.sku,product_name:d.product_name,price:d.price,brand:d.brand})},[u]),x=o.useCallback(d=>{u("bob_product_viewed",{sku:d.sku,product_name:d.product_name,price:d.price,brand:d.brand})},[u]),j=o.useCallback(d=>{u("bob_add_to_cart",{sku:d.sku,product_name:d.product_name,price:d.price,brand:d.brand,quantity:d.quantity??1})},[u]),p=o.useCallback((d,_)=>{u("bob_checkout_started",{cart_value:d,item_count:_})},[u]),E=o.useCallback(d=>{const _=Math.ceil(d/5/150*60);u("bob_speech_played",{text_length:d,duration_estimate:_})},[u]),b=o.useCallback(d=>{u("bob_speech_failed",{text_length:d})},[u]),v=o.useCallback((d,_)=>{u("bob_error",{error_type:d,error_message:_})},[u]);return o.useEffect(()=>{y()},[y]),{trackEvent:u,sessionId:i.current,trackSessionStart:y,trackMessageSent:k,trackVehicleIdentified:f,trackPartsViewed:g,trackProductClicked:S,trackProductViewed:x,trackAddToCart:j,trackCheckoutStarted:p,trackSpeechPlayed:E,trackSpeechFailed:b,trackError:v}}const Nr=o.createContext(null);function an({children:t,bobConfig:e,hostApiConfig:r,hostContext:n={},callbacks:i={},queryClient:c,ga4Config:h,analyticsEnabled:u=!0,bottomOffset:y=0,zIndexBase:k=50}){const f=o.useMemo(()=>new li({defaultOptions:{queries:{retry:1,staleTime:3e5}}}),[]),g=c||f,S=!!c;o.useEffect(()=>{console.log(`[BobWidget] v${Mt} initialized`),console.log(`[BobWidget] QueryClient: ${S?"external (shared)":"internal"}`),console.log(`[BobWidget] Analytics: ${u?"enabled":"disabled"}`),h!=null&&h.measurementId&&console.log(`[BobWidget] GA4: ${h.measurementId}`)},[S,u,h==null?void 0:h.measurementId]);const x=o.useMemo(()=>Pn.createClient(e.supabaseUrl,e.supabaseKey),[e.supabaseUrl,e.supabaseKey]),[j,p]=o.useState(n);o.useEffect(()=>{p(n)},[n]);const E=o.useCallback(v=>{p(d=>({...d,...v}))},[]),b=o.useMemo(()=>({bobSupabase:x,bobConfig:e,hostApiConfig:r,hostContext:j,callbacks:i,updateHostContext:E,ga4Config:h,analyticsEnabled:u,bottomOffset:y,zIndexBase:k}),[x,e,r,j,i,E,h,u,y,k]);return s.jsx(ci,{client:g,children:s.jsx(Nr.Provider,{value:b,children:t})})}function et(){const t=o.useContext(Nr);if(!t)throw new Error("useBobContext must be used within a BobProvider");return t}function ki(){const{bobSupabase:t}=et();return t}function Yt(){const t=o.useContext(Nr);return(t==null?void 0:t.bobSupabase)||null}function Si(){const{hostContext:t}=et();return t}function ji(){const{hostApiConfig:t}=et();return t}function _i(){const{callbacks:t}=et();return t}function Ei(){const{ga4Config:t,analyticsEnabled:e}=et();return{ga4Config:t,enabled:e}}function cs(){const t=o.useContext(Nr);return t?{bottomOffset:t.bottomOffset,zIndexBase:t.zIndexBase}:{bottomOffset:0,zIndexBase:50}}const Ti=15e3,Ri={greeting_returning:/ah hey|you again|what you after this time/i,greeting_welcome:/g'?day|welcome.*carfix|bob.*here/i,ask_rego:/need your rego|rego.*get cracking|what('?s| is) your rego/i,vehicle_not_found:/couldn'?t find that|double.?check.*plate/i,no_parts_found:/nothing came up|no results|sorry.*search/i,checkout_ready:/ready to checkout|checkout.*ready|choice.*checkout/i,rego_searching:/let('?s| us) see what car|sweet.*searching|searching for/i},ar=new Map,Ci=t=>t.replace(/\bya\b/gi,"you"),on=({onStart:t,onEnd:e,onFailed:r}={})=>{const{bobConfig:n,supabase:i}=et(),[c,h]=o.useState(!1),u=o.useRef(null),y=o.useRef(null),k=o.useRef(!1),f=o.useRef([]),g=o.useRef(!1),S=o.useRef(!1),x=o.useRef(null),j=o.useRef(null),p=o.useRef(t),E=o.useRef(e),b=o.useRef(r);o.useEffect(()=>{p.current=t,E.current=e,b.current=r},[t,e,r]);const v=o.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null)},[]),d=o.useCallback(()=>{var C;k.current||(k.current=!0,console.log("[BobWidget TTS] Fallback: triggering onStart without audio"),(C=p.current)==null||C.call(p))},[]),_=o.useCallback(async C=>{if(ar.has(C)){const N=ar.get(C);return console.log(`[BobWidget TTS] Cache hit for clip: ${C}`,N?"found":"null"),N||null}try{console.log(`[BobWidget TTS] Fetching clip from DB: ${C}`);const{data:N,error:w}=await i.from("bob_audio_clips").select("audio_url").eq("clip_key",C).eq("is_active",!0).single();return w||!N?(console.log(`[BobWidget TTS] No clip found for: ${C}`),ar.set(C,null),null):(console.log(`[BobWidget TTS] Clip found: ${C} -> ${N.audio_url}`),ar.set(C,N),N)}catch(N){return console.warn(`[BobWidget TTS] Clip lookup failed for ${C}:`,N),ar.set(C,null),null}},[i]),B=o.useCallback(async C=>{for(const[N,w]of Object.entries(Ri))if(w.test(C)){console.log(`[BobWidget TTS] Pattern matched: ${N}`);const q=await _(N);if(q!=null&&q.audio_url)return q.audio_url}return null},[_]),A=o.useCallback(async()=>{var q,$,X;if(g.current||f.current.length===0)return;g.current=!0;const C=f.current.shift();if(!C){g.current=!1;return}const{text:N,isGreeting:w}=C;w&&(S.current=!0),k.current=!1,v(),u.current&&(u.current.pause(),u.current=null),y.current=setTimeout(()=>{var Q,P;console.warn("[BobWidget TTS] Timeout - triggering fallback callbacks"),d(),h(!1),S.current=!1,(Q=E.current)==null||Q.call(E),(P=b.current)==null||P.call(b),u.current=null,g.current=!1,A()},Ti);try{let Q=null;if(Q=await B(N),Q)console.log("[BobWidget TTS] Using pre-recorded audio (fast path)");else{console.log("[BobWidget TTS] No pre-recorded clip, using ElevenLabs TTS");const D=Ci(N),U=await fetch(`${n.supabaseUrl}/functions/v1/bob-tts-elevenlabs`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.supabaseKey}`},body:JSON.stringify({text:D})});if(!U.ok){const W=await U.json().catch(()=>({}));throw console.error("[BobWidget TTS] Request failed:",W),new Error("TTS request failed")}const F=await U.blob();Q=URL.createObjectURL(F)}const P=new Audio(Q);u.current=P,P.onplay=()=>{var D;v(),x.current=null,k.current||(k.current=!0,h(!0),console.log("[BobWidget TTS] Audio playing, triggering onStart (animation: TALKING)"),(D=p.current)==null||D.call(p))},P.onended=()=>{var D;v(),h(!1),S.current=!1,console.log("[BobWidget TTS] Audio ended, triggering onEnd (animation: COMPLETE/IDLE)"),(D=E.current)==null||D.call(E),u.current=null,g.current=!1,A()},P.onerror=D=>{var U,F;v(),console.warn("[BobWidget TTS] Audio playback error:",D),d(),h(!1),S.current=!1,(U=E.current)==null||U.call(E),(F=b.current)==null||F.call(b),u.current=null,g.current=!1,A()};try{await P.play()}catch(D){console.warn("[BobWidget TTS] Audio play() failed (autoplay policy):",D),v(),w&&(x.current=N,console.log("[BobWidget TTS] Greeting stored for retry on user interaction")),d(),h(!1),S.current=!1,(q=E.current)==null||q.call(E),g.current=!1,A()}}catch(Q){v(),console.error("[BobWidget TTS] Speech synthesis error:",Q),d(),h(!1),S.current=!1,($=E.current)==null||$.call(E),(X=b.current)==null||X.call(b),g.current=!1,A()}},[n.supabaseUrl,n.supabaseKey,v,d,B]),H=o.useCallback((C,N=!1)=>{if(C.trim()){if(N){if(j.current===C){console.log(`[BobWidget TTS] Ignoring duplicate greeting: "${C.substring(0,30)}..."`);return}j.current=C,x.current=null}if(S.current&&!N){console.log("[BobWidget TTS] Greeting playing - queueing message"),f.current.push({text:C,isGreeting:N});return}N?f.current.unshift({text:C,isGreeting:N}):f.current.push({text:C,isGreeting:N}),A()}},[A]),I=o.useCallback(()=>{if(x.current&&!u.current&&!g.current){console.log("[BobWidget TTS] Retrying pending greeting on user interaction");const C=x.current;x.current=null,H(C,!0)}},[H]),z=o.useCallback(()=>{v(),f.current=[],u.current&&(u.current.pause(),u.current=null),h(!1),S.current=!1,g.current=!1},[v]),m=o.useCallback(()=>{var C;(C=u.current)==null||C.pause()},[]),T=o.useCallback(()=>{var C;(C=u.current)==null||C.play()},[]);return o.useEffect(()=>()=>{v(),f.current=[],u.current&&(u.current.pause(),u.current=null)},[v]),{speak:H,stop:z,pause:m,resume:T,isSpeaking:c,isSupported:!0,retryPendingGreeting:I}},Cs="bob_last_visit",Ni=30;function ln(t=Ni){const[e,r]=o.useState(!1),[n,i]=o.useState(null);return o.useEffect(()=>{try{const c=localStorage.getItem(Cs),h=Date.now();if(c){const u=parseInt(c,10),y=(h-u)/(1e3*60*60*24);y<=t?(r(!0),i(new Date(u)),console.log(`[BobWidget] Returning user detected - last visit ${Math.round(y)} days ago`)):console.log(`[BobWidget] Previous visit was ${Math.round(y)} days ago - treating as new user`)}else console.log("[BobWidget] First time visitor detected");localStorage.setItem(Cs,String(h))}catch(c){console.warn("[BobWidget] Could not access localStorage for returning user detection:",c)}},[t]),{isReturningUser:e,lastVisitDate:n,daysSinceLastVisit:n?Math.round((Date.now()-n.getTime())/(1e3*60*60*24)):null}}const is=t=>{if(!t)return t;let e=t;return e=e.replace(/\b(retrieve_parts|lookup_vehicle|search_general_products|retrieve_service_packages|add_to_cart|get_cart|create_checkout|get_customer_context|get_product_details|search_products|check_vehicle_fitment|search_web)\s*\([^)]*\)/gi,""),e=e.replace(/\(\s*(vehicleid|vehicle_id|part_type|query|plate|user_email|sku)\s*=\s*[^)]+\)/gi,""),e=e.replace(/\b(retrieve_parts|lookup_vehicle|search_general_products|retrieve_service_packages|add_to_cart|get_cart|create_checkout|get_customer_context|get_product_details|search_products|check_vehicle_fitment|search_web)\s*\(/gi,""),e=e.replace(/\b(vehicleid|vehicle_id|part_type)\s*=\s*(['"]?[\w\s]+['"]?)\s*,?\s*/gi,""),e=e.replace(/```[\s\S]*?```/g,""),e=e.replace(/\(\s*\)/g,""),e=e.replace(/\s{2,}/g," "),e=e.trim(),e},Wr=t=>{let e=is(t);return e=e.replace(/[\[\]{}]/g,""),e=e.replace(/https?:\/\/[^\s]+/g,""),e=e.replace(/\bSKU\s*:?\s*\w+/gi,""),e},Fi=["what version","which version","software version","bob version","your version","current version","running version","version number","what ver","which ver"],Ns=["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"],Bi=["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"],cn=({setAnimationState:t,manualMode:e=!1,talkingState:r="talk",thinkingState:n="research",completeState:i="complete",idleState:c="idle",listenState:h="talk_pause",onStreamStart:u,onStreamComplete:y,onShowingProduct:k,onResearchStart:f,onReadyToSpeak:g,onHighlightPart:S,onHighlightProduct:x,onNoPartsFound:j,onAutoFetchComplete:p})=>{var kr,Sr,Jt,Zt;const{bobConfig:E,hostApiConfig:b,hostContext:v,callbacks:d,ga4Config:_,analyticsEnabled:B}=et(),A=nn({ga4Config:_,hostContext:v,callbacks:d,enabled:B}),{isReturningUser:H}=ln(),[I,z]=o.useState([]),[m,T]=o.useState(""),[C,N]=o.useState(!1),[w,q]=o.useState(!1),[$,X]=o.useState(null),Q=o.useRef(null),P=o.useRef(!1),D=o.useRef(!1),U=o.useRef(""),F=o.useRef(!1),W=o.useRef(null),ae=o.useRef(null),Fe=o.useRef([]),ce=o.useRef(!1),xe=o.useRef(null),je=()=>{W.current&&(clearTimeout(W.current),W.current=null)},{speak:ve,stop:J,isSpeaking:Be,retryPendingGreeting:Ie}=on({onStart:()=>{je(),F.current=!0,console.log("[BobWidget STATE] Speech STARTED - transitioning to TALK state"),A.trackSpeechPlayed(U.current.length),g==null||g(),e||(console.log("[BobWidget STATE] Setting state to:",r),te(r))},onEnd:()=>{je(),console.log("[BobWidget STATE] Speech ENDED - transitioning out of TALK state");const V=Ns.some(ue=>U.current.toLowerCase().includes(ue.toLowerCase()));e||(V&&k?(console.log("[BobWidget STATE] Has products - calling onShowingProduct"),k()):y?(console.log("[BobWidget STATE] Calling onStreamComplete"),y()):(console.log("[BobWidget STATE] Setting state to:",i),te(i),setTimeout(()=>{console.log("[BobWidget STATE] Post-complete transition to:",h),te(h)},2e3)))},onFailed:()=>{console.warn("[BobWidget] Speech synthesis failed - fallback triggered"),A.trackSpeechFailed(U.current.length)}});o.useEffect(()=>{var V;(V=Q.current)==null||V.scrollIntoView({behavior:"smooth"})},[I]),o.useEffect(()=>{var ue,pe;const V=(ue=v.vehicle)==null?void 0:ue.selectedVehicle;V&&!$&&(console.log("[BobWidget] Setting vehicle from host context:",V),X(V),(pe=d.onVehicleIdentified)==null||pe.call(d,V),A.trackVehicleIdentified({make:V.make,model:V.model,year:V.year,rego:V.rego}))},[(kr=v.vehicle)==null?void 0:kr.selectedVehicle]),o.useEffect(()=>{var V;if(I.length===0&&!D.current){D.current=!0;const ue=(V=v.vehicle)==null?void 0:V.selectedVehicle;let pe;H?(pe="Ah hey... you again! What you after this time?",console.log("[BobWidget] Using returning user greeting")):ue?pe=`G'day! Saw you've got the ${`${ue.year} ${ue.make} ${ue.model}`} - choice wagon! What can I help you find for it today?`:pe="G'day! Bob from CARFIX here. How can I help ya today?",z([{role:"assistant",content:pe}]),w||setTimeout(()=>{console.log("[BobWidget] Speaking initial greeting (priority)"),ve(pe,!0)},500)}},[(Sr=v.vehicle)==null?void 0:Sr.selectedVehicle,I.length,w,ve]),o.useEffect(()=>{const V=()=>{console.log("[BobWidget] User interaction detected - retrying pending greeting"),Ie(),document.removeEventListener("click",V),document.removeEventListener("touchstart",V)};return document.addEventListener("click",V,{once:!0}),document.addEventListener("touchstart",V,{once:!0}),()=>{document.removeEventListener("click",V),document.removeEventListener("touchstart",V)}},[Ie]),o.useEffect(()=>{var mt,xt;const V=(mt=v.vehicle)==null?void 0:mt.selectedVehicle;if(!V||P.current)return;const ue=V.vehicle_id??V.id,pe=Number.parseInt(String(ue),10);if(!Number.isFinite(pe)){console.warn("[BobWidget] Vehicle has invalid vehicle_id, cannot auto-fetch:",V);return}P.current=!0;const we={...V,vehicle_id:String(pe)},rt=(xt=v.user)==null?void 0:xt.email;(async()=>{var yt,vt;const At=`${E.supabaseUrl}/functions/v1/bob-chat`;try{const Ce=await fetch(At,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.supabaseKey}`},body:JSON.stringify({messages:[],vehicleContext:we,customerEmail:rt,autoFetchParts:!0,hostConfig:b,hostContext:v})});if(!Ce.ok||!Ce.body){console.error("[BobWidget] Auto-fetch failed:",Ce.status);return}const wt=Ce.body.getReader(),De=new TextDecoder;let Pe="";for(;;){const{done:st,value:kt}=await wt.read();if(st)break;Pe+=De.decode(kt,{stream:!0});let nt;for(;(nt=Pe.indexOf(`
|
|
31
|
+
`))!==-1;){let Ne=Pe.slice(0,nt);if(Pe=Pe.slice(nt+1),Ne.endsWith("\r")&&(Ne=Ne.slice(0,-1)),Ne.startsWith(":")||Ne.trim()===""||!Ne.startsWith("data: "))continue;const St=Ne.slice(6).trim();if(St==="[DONE]")break;try{const ge=JSON.parse(St);ge.type==="service_packages_found"&&ge.packages&&((yt=d.onServicePackagesFound)==null||yt.call(d,ge.packages)),ge.type==="parts_found"&&ge.parts&&((vt=d.onPartsFound)==null||vt.call(d,ge.parts),A.trackPartsViewed(Array.isArray(ge.parts)?ge.parts.length:0,String(pe)))}catch{}}}p==null||p()}catch(Ce){console.error("[BobWidget] Auto-fetch error:",Ce)}})()},[(Jt=v.vehicle)==null?void 0:Jt.selectedVehicle,(Zt=v.user)==null?void 0:Zt.email]);const te=V=>{try{t(V)}catch{console.warn(`[BobWidget] State "${V}" not available`)}},Re=()=>{if(Fe.current.length===0){ce.current=!1,e||te(n);return}ce.current=!0;const V=Fe.current.shift(),ue=new Audio(V);xe.current=ue,ue.onplay=()=>{console.log("[BobWidget] Searching audio STARTED:",V),e||te(r)},ue.onended=()=>{console.log("[BobWidget] Searching audio ENDED, playing next..."),xe.current=null,Re()},ue.onerror=()=>{console.warn("[BobWidget] Searching audio failed:",V),xe.current=null,Re()},ue.play().catch(()=>{console.warn("[BobWidget] Searching audio autoplay blocked:",V),xe.current=null,Re()})},fe=async V=>{var we,rt,er,mt,xt,At,yt,vt,Ce,wt,De,Pe,st,kt,nt,Ne,St;const ue=`${E.supabaseUrl}/functions/v1/bob-chat`,pe=(we=v.user)==null?void 0:we.email;try{const ge={messages:[...I,V],hostConfig:b,hostContext:v};$&&(ge.vehicleContext=$),pe&&(ge.customerEmail=pe);const Oe=await fetch(ue,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.supabaseKey}`},body:JSON.stringify(ge)});if(!Oe.ok){if(Oe.status===429){(rt=d.onError)==null||rt.call(d,new Error("Rate limit exceeded"));return}if(Oe.status===402){(er=d.onError)==null||er.call(d,new Error("Payment required"));return}throw new Error("Failed to start stream")}if(!Oe.body)throw new Error("No response body");const Or=Oe.body.getReader(),Mr=new TextDecoder;let qe="",tr=!1,it="";for(;!tr;){const{done:R,value:O}=await Or.read();if(R)break;qe+=Mr.decode(O,{stream:!0});let Y;for(;(Y=qe.indexOf(`
|
|
32
|
+
`))!==-1;){let Z=qe.slice(0,Y);if(qe=qe.slice(Y+1),Z.endsWith("\r")&&(Z=Z.slice(0,-1)),Z.startsWith(":")||Z.trim()===""||!Z.startsWith("data: "))continue;const oe=Z.slice(6).trim();if(oe==="[DONE]"){tr=!0;break}try{const M=JSON.parse(oe);if(M.type==="vehicle_identified"&&M.vehicle){X(M.vehicle),(mt=d.onVehicleIdentified)==null||mt.call(d,M.vehicle),A.trackVehicleIdentified({make:M.vehicle.make,model:M.vehicle.model,year:M.vehicle.year,rego:M.vehicle.rego});continue}if(M.type==="service_packages_found"&&M.packages){(xt=d.onServicePackagesFound)==null||xt.call(d,M.packages);continue}if(M.type==="parts_found"&&M.parts){(At=d.onPartsFound)==null||At.call(d,M.parts),A.trackPartsViewed(Array.isArray(M.parts)?M.parts.length:0,(yt=$==null?void 0:$.vehicle_id)==null?void 0:yt.toString());continue}if(M.type==="bob_suggestions"&&M.products){console.log("[useBobChat] Received bob_suggestions:",M.products.length,"products",M.title),z(de=>{var be;const ie=[...de],ne=ie[ie.length-1];return console.log("[useBobChat] Attaching to message:",ne==null?void 0:ne.role,(be=ne==null?void 0:ne.content)==null?void 0:be.slice(0,40)),(ne==null?void 0:ne.role)==="assistant"?ie.map((We,Ye)=>Ye===ie.length-1?{...We,suggestedProducts:M.products,suggestionsTitle:M.title}:We):ie}),(vt=d.onPartsFound)==null||vt.call(d,M.products),A.trackPartsViewed(Array.isArray(M.products)?M.products.length:0,(Ce=$==null?void 0:$.vehicle_id)==null?void 0:Ce.toString());continue}if(M.type==="no_parts_found"){(wt=d.onPartsFound)==null||wt.call(d,[]),(De=d.onServicePackagesFound)==null||De.call(d,[]),j==null||j();continue}if(M.type==="audio_hint"&&M.audio_url){console.log("[useBobChat] Audio hint received:",M.clip_key,M.audio_url),ae.current=M.audio_url;continue}if(M.type==="bob_searching"&&M.audio_url){console.log("[useBobChat] Bob searching:",M.search_type,M.clip_key),Fe.current.push(M.audio_url),!ce.current&&!w&&Re();continue}if(M.type==="cart_updated"&&M.items){(Pe=d.onCartUpdated)==null||Pe.call(d,M.items);continue}const ee=(nt=(kt=(st=M.choices)==null?void 0:st[0])==null?void 0:kt.delta)==null?void 0:nt.content;if(ee){it+=ee;let de=it.replace(/\[VEHICLE_CONFIRMED:\{[\s\S]*?\}\]/g,"");de=is(de),z(ie=>{const ne=ie[ie.length-1];return(ne==null?void 0:ne.role)==="assistant"?ie.map((be,We)=>We===ie.length-1?{...be,content:de}:be):[...ie,{role:"assistant",content:de}]}),(Ne=d.onBobMessage)==null||Ne.call(d,de)}}catch{qe=Z+`
|
|
33
|
+
`+qe;break}}}let rr=it.replace(/\[VEHICLE_CONFIRMED:\{[\s\S]*?\}\]/g,"");rr=is(rr),U.current=rr;const sr=Ns.some(R=>it.toLowerCase().includes(R.toLowerCase())),Ar=it.toLowerCase();for(const R of Bi)if(Ar.includes(R.toLowerCase())){const O=R.replace(/s\s*$/i,"").toUpperCase();S==null||S(O);break}const a=it.match(/(?:go with|recommend|suggest|grab|try)\s+(?:the\s+)?(\w+)\s+(?:at|for)\s+\$(\d+(?:\.\d{2})?)/i);if(a){const[,R,O]=a;x==null||x({brand:R,price:parseFloat(O)})}if(!w&&U.current.trim()){if(F.current=!1,je(),ae.current){console.log("[BobWidget] Playing canned audio:",ae.current);const R=new Audio(ae.current);R.onplay=()=>{console.log("[BobWidget] Canned audio STARTED"),F.current=!0,g==null||g(),e||te(r)},R.onended=()=>{console.log("[BobWidget] Canned audio ENDED"),je(),e||(sr&&k?k():y?y():(te(i),setTimeout(()=>te(h),3e3)))},R.onerror=()=>{console.error("[BobWidget] Canned audio failed, falling back to TTS");const O=Wr(U.current);ve(O)},R.play().catch(()=>{console.error("[BobWidget] Canned audio autoplay blocked, falling back to TTS");const O=Wr(U.current);ve(O)}),ae.current=null}else{const R=Wr(U.current);ve(R)}W.current=setTimeout(()=>{F.current||(console.warn("[BobWidget] Speech fallback after 2s"),g==null||g(),e||(sr&&k?k():y?y():(te(i),setTimeout(()=>te(h),3e3))))},2e3)}else g==null||g(),e||(sr&&k?k():y?y():(te(i),setTimeout(()=>te(h),3e3)))}catch(ge){console.error("[BobWidget] Chat error:",ge);const Oe=ge instanceof Error?ge:new Error("Unknown error");(St=d.onError)==null||St.call(d,Oe),A.trackError(Oe.name||"ChatError",Oe.message||"Unknown chat error"),e||te(c)}},He=async()=>{if(!m.trim()||C)return;Ie(),J();const V={role:"user",content:m};z(we=>[...we,V]),T(""),A.trackMessageSent(m.length,!!$);const ue=m.toLowerCase();if(Fi.some(we=>ue.includes(we))){const we=`G'day mate! I'm running Bob v${Mt} - she's running sweet as! Anything else I can help ya with?`;z(rt=>[...rt,{role:"assistant",content:we}]),w||ve(we);return}N(!0),console.log("[BobWidget STATE] User sent message - switching to RESEARCH state:",n),f==null||f(),e||te(n),await fe(V),N(!1)};return{messages:I,input:m,setInput:T,isLoading:C,handleSend:He,handleKeyPress:V=>{V.key==="Enter"&&!V.shiftKey&&(V.preventDefault(),He())},handleInputFocus:()=>{Ie()},handleInputBlur:()=>{},chatEndRef:Q,clearMessages:()=>{z([{role:"assistant",content:"G'day! Bob from CARFIX here. How can I help ya today?"}])},isMuted:w,toggleMute:()=>{q(V=>!V),w||J()},isSpeaking:Be,identifiedVehicle:$,clearVehicle:()=>{X(null)}}},Ii={states:[],configs:[],uploadedImages:[],looks:[],activeLookId:null},un=t=>{const e=rn(),r=Yt();return o.useEffect(()=>{if(!r)return;const n=r.channel("animation-states-changes").on("postgres_changes",{event:"*",schema:"public",table:"animation_states"},()=>{e.invalidateQueries({queryKey:["bob-animation-data"]})}).subscribe(),i=r.channel("bob-animations-changes").on("postgres_changes",{event:"*",schema:"public",table:"bob_animations"},()=>{e.invalidateQueries({queryKey:["bob-animation-data"]})}).subscribe();return()=>{r.removeChannel(n),r.removeChannel(i)}},[e,r]),vr({queryKey:["bob-animation-data",t],queryFn:async()=>{var E;if(!r)return console.log("[useBobAnimationData] No supabase client, returning empty data"),Ii;const{data:n,error:i}=await r.from("bob_looks").select("*").order("display_order");if(i)throw i;const c=(n||[]).find(b=>b.is_active),h=t||(c==null?void 0:c.id)||n&&((E=n[0])==null?void 0:E.id)||null;if(!h)return{states:[],configs:[],uploadedImages:[],looks:n||[],activeLookId:null};const{data:u,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:k,error:f}=await r.from("bob_animations").select("*").eq("is_active",!0).eq("look_id",h).order("animation_state").order("sequence_order");if(f)throw f;const g=new Set((u||[]).map(b=>b.state_key)),S=(k||[]).filter(b=>g.has(b.animation_state)),{data:x,error:j}=await r.storage.from("bob-images").list();if(j)throw j;const p=(x||[]).map(b=>{const{data:v}=r.storage.from("bob-images").getPublicUrl(b.name);return v.publicUrl});return S.forEach(b=>{const v=new Image;v.src=b.image_url}),{states:u||[],configs:S,uploadedImages:p,looks:n||[],activeLookId:h}},staleTime:30*1e3,gcTime:5*60*1e3})},dn=(t={})=>{const{isSpeaking:e=!1}=t,[r,n]=o.useState(""),[i,c]=o.useState(0),[h,u]=o.useState(400),[y,k]=o.useState(!1),f=o.useRef(null),g=o.useRef(0),S=o.useRef(e),x=o.useRef(0),j=o.useRef(0),p=o.useRef(!1),E=o.useRef(0),{data:b,isLoading:v}=un(),d=o.useRef({}),{imageUrlsMap:_,alternateImages:B,offsetsMap:A,scalesMap:H,availableStates:I}=o.useMemo(()=>{if(!b)return{imageUrlsMap:{},alternateImages:{},offsetsMap:{},scalesMap:{},availableStates:[]};const N={},w={},q={},$={},X=b.states.map(Q=>Q.state_key);return X.forEach(Q=>{const P=b.configs.filter(W=>W.animation_state===Q),D=P.map(W=>W.image_url),U=P.map(W=>W.vertical_offset||0),F=P.map(W=>W.scale||100);if(D.length>0){const W=b.states.find(ae=>ae.state_key===Q);N[Q]={url:D[0],animation_speed:(W==null?void 0:W.animation_speed)||400,pause_duration:(W==null?void 0:W.pause_duration)||0,loop_count:(W==null?void 0:W.loop_count)||0},w[Q]=D,q[Q]=U,$[Q]=F}}),{imageUrlsMap:N,alternateImages:w,offsetsMap:q,scalesMap:$,availableStates:X}},[b]);o.useEffect(()=>{d.current=_},[_]),o.useEffect(()=>{const N=S.current;if(S.current=e,N&&!e){const w=r.toLowerCase();(w.includes("talk")||w==="talking")&&(console.log("[useBobAnimation] Speech ended while in talk state - forcing loop completion"),j.current=999)}},[e,r]);const z=o.useCallback(N=>{n(w=>w===N?w:(x.current=0,j.current=0,p.current=!1,c(0),N))},[]);o.useEffect(()=>{I.length>0&&!r&&n(I[0])},[I,r]),o.useEffect(()=>{const N=B[r];if(f.current!==null&&(cancelAnimationFrame(f.current),f.current=null),x.current=0,j.current=0,p.current=!1,g.current=0,c(0),!N||N.length<=1)return;const w=d.current[r],q=(w==null?void 0:w.animation_speed)||h||400,$=(w==null?void 0:w.loop_count)||0,X=(w==null?void 0:w.pause_duration)||0,Q=r.toLowerCase().includes("talk"),P=D=>{if(g.current===0&&(g.current=D),p.current){D-E.current>=X&&(p.current=!1,j.current=0,g.current=D),f.current=requestAnimationFrame(P);return}if(D-g.current>=q){g.current=D;const F=(x.current+1)%N.length;F===0?(j.current++,Q&&S.current?(x.current=F,c(F)):$>0&&j.current>=$?X>0&&(p.current=!0,E.current=D):(x.current=F,c(F))):(x.current=F,c(F))}f.current=requestAnimationFrame(P)};return f.current=requestAnimationFrame(P),()=>{f.current!==null&&(cancelAnimationFrame(f.current),f.current=null)}},[r,B,h]);const m=o.useCallback(()=>{const N=B[r];if(!N||N.length===0){const w=I.find(q=>{var $;return(($=B[q])==null?void 0:$.length)>0});return w?(console.warn(`[useBobAnimation] No images for "${r}", using fallback: ${w}`),B[w][0]):(console.error("[useBobAnimation] No valid images found for any state!"),"")}return N[i]||N[0]},[B,r,I,i]),T=o.useCallback(()=>{const N=A[r];if(!N||N.length===0){const w=I.find(q=>{var $;return(($=A[q])==null?void 0:$.length)>0});return w?A[w][0]:0}return N[i]||N[0]},[A,r,I,i]),C=o.useCallback(()=>{const N=H[r];if(!N||N.length===0){const w=I.find(q=>{var $;return(($=H[q])==null?void 0:$.length)>0});return w?H[w][0]:100}return N[i]||N[0]},[H,r,I,i]);return{animationState:r,setAnimationState:z,getCurrentImage:m,getCurrentOffset:T,getCurrentScale:C,imageUrls:_,availableStates:I,setTalkSpeed:u,manualMode:y,setManualMode:k,isLoading:v}},hn=()=>{const t=Yt(),{data:e=[],isLoading:r}=vr({queryKey:["bob-backdrops"],queryFn:async()=>{if(!t)return console.log("[useBobBackdrop] No supabase client, returning empty"),[];const{data:i,error:c}=await t.from("bob_backdrops").select("*").order("display_order",{ascending:!0});if(c)throw c;return i},staleTime:5*60*1e3,gcTime:10*60*1e3}),n=e.find(i=>i.is_active);return{backdrops:e,activeBackdrop:n,isLoading:r}},fn=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:n,counterHeightPercent:i=12,className:c="",verticalOffset:h=0,scale:u=100})=>{const y=h+i,k=55*(u/100);return s.jsx("div",{className:`flex flex-col items-center justify-center gap-6 w-full ${c}`,children:s.jsxs("div",{className:"relative w-full max-w-[600px] mx-auto aspect-[16/10] overflow-hidden",children:[r&&s.jsx("img",{src:r,alt:"Backdrop",className:"absolute inset-0 z-0 w-full h-full object-cover object-bottom"}),s.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:`${k}%`,maxWidth:`${220*(u/100)}px`,transformOrigin:"center bottom"}}),n&&s.jsx("img",{src:n,alt:"Counter",className:"absolute z-20 bottom-0 left-0 w-full object-cover object-bottom",style:{height:`${i}%`}})]})})},K={primary:"#0052CC",primaryHover:"#0047B3",secondary:"#38BDF8",foreground:"#0F172A",accent:"#FF8C00",success:"#22C55E",destructive:"#EF4444",performanceRed:"#DC2626",mutedForeground:"#64748B",background:"#FAFAFA",card:"#FFFFFF",border:"#E2E8F0",slateEconomy:"#475569"},Cr={Economy:{icon:"DollarSign",emoji:"💰",textColor:"#475569",background:"#F1F5F9",border:"#CBD5E1",description:"Smart savings"},Standard:{icon:"Star",emoji:"⭐",textColor:"#0052CC",background:"rgba(0,82,204,0.1)",border:"rgba(0,82,204,0.3)",description:"Best value",isRecommended:!0},Premium:{icon:"Award",emoji:"🏆",textColor:"#D97706",background:"#FEF3C7",border:"#FCD34D",description:"Superior quality"},Performance:{icon:"Zap",emoji:"⚡",textColor:"#DC2626",background:"#FEE2E2",border:"#FCA5A5",description:"Maximum power"}},zr={"Oil Change":"Neglecting oil changes leads to engine wear, overheating, and catastrophic failure costing thousands. Quality oil and filters keep your engine running smoothly. Each CFX Oil Change Service Pack includes premium oil and filter matched to your engine specifications.","Front Brake Service":"Your front brakes handle 70% of stopping power. Worn pads dangerously increase stopping distance. Quality brake components ensure confident, safe stops. Each CFX Front Brake Service Pack includes pads and rotors to restore your braking performance.","Rear Brake Service":"Rear brakes provide stability and balance during emergency stops. Worn components cause instability and longer stopping distances. Each CFX Rear Brake Service Pack includes quality pads/shoes and rotors/drums for complete rear brake renewal.","Timing Belt Service":"A snapped timing belt destroys engines instantly, causing $8,000+ in damage. Preventive replacement is essential for peace of mind. Each CFX Timing Belt Service Pack includes the belt, tensioner, and related components.",Wipers:"Worn wipers reduce visibility in rain, compromising safety. Quality blades provide streak-free, clear vision. Each CFX Wipers Service Pack includes the gear you need to change all of your vehicle's wiper blades to restore your driving vision.","Coolant Service":"Old coolant causes overheating, warped cylinder heads, and engine seizure. Fresh coolant protects your entire cooling system. Each CFX Coolant Service Pack includes quality coolant matched to your vehicle's requirements.","Air Filter Service":"Clogged air filters reduce engine performance by 10% and increase fuel consumption. Clean filters improve power and economy. Each CFX Air Filter Service Pack includes a precision-fit filter for optimal airflow.","Spark Plug Service":"Worn spark plugs cause misfires, poor fuel economy, and catalytic converter damage. Fresh plugs restore smooth, efficient running. Each CFX Spark Plug Service Pack includes quality plugs matched to your engine.","Battery Service":"A failing battery leaves you stranded without warning. Reliable power is essential for starting and electronics. Each CFX Battery Service Pack includes a quality battery sized for your vehicle's demands.","Cabin Filter":"Cabin filters clean the air you and your passengers breathe. Replace regularly to remove pollen, dust, and odours. Each CFX Cabin Filter Service Pack includes a quality filter for fresh, clean cabin air.","Fuel Filter Service":"Clogged fuel filters restrict flow, causing poor performance and potential engine damage. Clean fuel is critical for efficiency. Each CFX Fuel Filter Service Pack includes a quality filter for optimal fuel delivery.","Transmission Service":"Old transmission fluid causes rough shifting, slipping, and premature wear. Fresh fluid extends transmission life. Each CFX Transmission Service Pack includes quality fluid matched to your transmission type."},Pi="Keep your vehicle running safely and efficiently with quality parts matched to your specific make and model. Each CFX Service Pack includes everything you need for this essential maintenance.",fr={productImage:t=>`https://flpzjbasdsfwoeruyxgp.supabase.co/storage/v1/object/public/product_images/${t}.jpg`,brandLogo:t=>`https://flpzjbasdsfwoeruyxgp.supabase.co/storage/v1/object/public/brand_images/${t.replace(/\s+/g,"")}.jpg`,carfixImage:t=>`https://flpzjbasdsfwoeruyxgp.supabase.co/storage/v1/object/public/carfix_images/${t}_1.jpg`},pn={fitsVehicle:{background:"rgba(34,197,94,0.1)",text:"#22C55E",border:"rgba(34,197,94,0.2)",icon:"Check",label:"Fits Your Vehicle"},viscosity:{background:"#EFF6FF",text:"#1D4ED8",border:"#BFDBFE",icon:"Gauge"},volume:{background:"#ECFEFF",text:"#0E7490",border:"#A5F3FC",icon:"Droplets"},quantity:{background:"#F1F5F9",text:"#475569",border:"#CBD5E1"},partNumber:{background:"transparent",text:"#64748B",border:"transparent"},carfixValue:{background:"rgba(0,82,204,0.1)",text:"#0052CC",border:"rgba(0,82,204,0.2)",icon:"Sparkles",label:"CARFIX Value"},rotorPair:{background:"#EFF6FF",text:"#1D4ED8",border:"#BFDBFE",label:"Pair"}},ze={packageTitle:{fontSize:"20px",fontWeight:700},partslotName:{fontSize:"14px",fontWeight:600},productName:{fontSize:"14px",fontWeight:500},description:{fontSize:"14px",fontWeight:400},priceMain:{fontSize:"20px",fontWeight:700},priceSecondary:{fontSize:"12px",fontWeight:400},tierLabel:{fontSize:"14px",fontWeight:500},badgeText:{fontSize:"12px",fontWeight:500}};function gn(t){var n;const e=((n=t.name)==null?void 0:n.toLowerCase())||"",r=(t.partslotDescription||t.partslot_description||"").toLowerCase();return e.includes("rotor")||r.includes("disc rotor")||r.includes("brake rotor")||t.per_car_qty===2}function bn(t,e){return e?{displayPrice:t*2,unitPriceLabel:`$${t.toFixed(2)} each`}:{displayPrice:t}}function gt(t){return`$${t.toFixed(2)}`}function mn(t){if(zr[t])return zr[t];const e=t.toLowerCase();for(const[r,n]of Object.entries(zr))if(e.includes(r.toLowerCase())||r.toLowerCase().includes(e))return n;return Pi}const cr=({type:t,value:e,className:r=""})=>{const n=pn[t],i=e||("label"in n?n.label:""),c=()=>{if(!("icon"in n))return null;const h={width:12,height:12};switch(n.icon){case"Check":return s.jsx("svg",{style:h,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})});case"Sparkles":return s.jsxs("svg",{style:h,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M12 3l1.5 4.5L18 9l-4.5 1.5L12 15l-1.5-4.5L6 9l4.5-1.5L12 3z"}),s.jsx("path",{d:"M5 19l1 3 1-3 3-1-3-1-1-3-1 3-3 1 3 1z"})]});case"Gauge":return s.jsxs("svg",{style:h,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 6v6l4 2"})]});case"Droplets":return s.jsx("svg",{style:h,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("path",{d:"M12 2.69l5.66 5.66a8 8 0 11-11.31 0z"})});default:return null}};return s.jsxs("span",{className:r,style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"9999px",fontSize:"12px",fontWeight:500,background:n.background,color:n.text,border:`1px solid ${n.border}`,whiteSpace:"nowrap"},children:[c(),i]})},us=({products:t,title:e,onProductClick:r,onAddToCart:n})=>!t||t.length===0?null:s.jsxs("div",{style:{marginTop:"16px",width:"100%"},children:[e&&s.jsxs("div",{style:{marginBottom:"12px",fontSize:ze.partslotName.fontSize,fontWeight:ze.partslotName.fontWeight,color:K.foreground,display:"flex",alignItems:"center",gap:"8px"},children:[s.jsx("span",{style:{fontSize:"18px"},children:"🚗"}),e]}),s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:t.slice(0,6).map((i,c)=>s.jsx(Oi,{product:i,onProductClick:r,onAddToCart:n,isRecommended:c===0},i.id||i.sku||c))}),t.length>6&&s.jsxs("div",{style:{marginTop:"12px",fontSize:"13px",color:K.mutedForeground,textAlign:"center"},children:["+ ",t.length-6," more options available"]})]}),Oi=({product:t,onProductClick:e,onAddToCart:r,isRecommended:n=!1})=>{const[i,c]=o.useState(!1),[h,u]=o.useState(!1),y=t.image_url||t.image||(t.sku?fr.productImage(t.sku):null),k=t.brand?fr.brandLogo(t.brand):null,f=t.brand||"Quality Part",g=t.name||"Product",S=t.price??0,x=t.partNumber||t.part_number,j=gn({name:t.name,partslotDescription:t.partslotDescription,per_car_qty:t.quantity}),{displayPrice:p,unitPriceLabel:E}=bn(S,j);return s.jsxs("div",{style:{background:K.card,borderRadius:"12px",border:`2px solid ${K.border}`,overflow:"hidden",cursor:e?"pointer":"default",transition:"all 0.2s ease"},onClick:()=>e==null?void 0:e(t),onMouseEnter:b=>{b.currentTarget.style.borderColor=`${K.primary}80`,b.currentTarget.style.boxShadow="0 10px 25px rgba(0,0,0,0.1)"},onMouseLeave:b=>{b.currentTarget.style.borderColor=K.border,b.currentTarget.style.boxShadow="none"},children:[t.partslotDescription&&s.jsxs("div",{style:{background:"rgba(0,0,0,0.03)",borderBottom:`1px solid ${K.border}`,padding:"10px 16px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[s.jsx("span",{style:{fontSize:ze.partslotName.fontSize,fontWeight:ze.partslotName.fontWeight,color:K.foreground},children:t.partslotDescription}),n&&s.jsx(cr,{type:"carfixValue"})]}),s.jsxs("div",{style:{padding:"16px",display:"flex",gap:"16px"},children:[s.jsx("div",{style:{width:"96px",minWidth:"96px",height:"96px",borderRadius:"8px",background:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",border:`1px solid ${K.border}`},children:y&&!i?s.jsx("img",{src:y,alt:g,style:{width:"100%",height:"100%",objectFit:"contain",padding:"4px"},onError:()=>c(!0)}):s.jsx("span",{style:{fontSize:"32px",opacity:.5},children:"🔧"})}),s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[k&&!h&&s.jsx("img",{src:k,alt:f,style:{height:"16px",width:"auto",objectFit:"contain"},onError:()=>u(!0)}),s.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:K.foreground,textTransform:"uppercase"},children:f})]}),s.jsx("div",{style:{fontSize:ze.productName.fontSize,fontWeight:ze.productName.fontWeight,color:K.foreground,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",lineHeight:"1.4",marginBottom:"8px"},children:g}),s.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"12px"},children:[s.jsx(cr,{type:"fitsVehicle"}),j&&s.jsx(cr,{type:"rotorPair"}),t.quantity&&t.quantity>1&&!j&&s.jsx(cr,{type:"quantity",value:`Qty: ${t.quantity}`}),x&&s.jsxs("span",{style:{fontSize:"12px",color:K.mutedForeground},children:["#",x]})]})]}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"space-between",minWidth:"100px"},children:[s.jsxs("div",{style:{textAlign:"right"},children:[s.jsx("div",{style:{fontSize:ze.priceMain.fontSize,fontWeight:ze.priceMain.fontWeight,color:K.foreground},children:gt(p)}),E&&s.jsx("div",{style:{fontSize:ze.priceSecondary.fontSize,color:K.mutedForeground},children:E}),s.jsx("div",{style:{fontSize:ze.priceSecondary.fontSize,color:K.mutedForeground},children:"inc GST"})]}),r&&s.jsx("button",{onClick:b=>{b.stopPropagation(),r(t)},style:{background:K.primary,color:"#FFFFFF",border:"none",borderRadius:"8px",padding:"8px 16px",fontSize:"13px",fontWeight:600,cursor:"pointer",transition:"all 0.2s ease",whiteSpace:"nowrap"},onMouseEnter:b=>{b.currentTarget.style.background=K.primaryHover},onMouseLeave:b=>{b.currentTarget.style.background=K.primary},onMouseDown:b=>{b.currentTarget.style.transform="scale(0.98)"},onMouseUp:b=>{b.currentTarget.style.transform="scale(1)"},children:"Add to Cart"})]})]})]})},xn=({messages:t,input:e,setInput:r,isLoading:n,onSend:i,onKeyPress:c,onInputFocus:h,onInputBlur:u,chatEndRef:y,isMuted:k=!1,onToggleMute:f,isSpeaking:g=!1,className:S="",onAddToCart:x,onProductClick:j})=>s.jsx("div",{className:S,style:{width:"100%",maxWidth:"72rem",margin:"0 auto",padding:"0 16px 32px 16px"},children:s.jsxs("div",{style:{backgroundColor:"rgba(20, 30, 50, 0.85)",border:"1px solid rgba(255,255,255,0.15)",borderRadius:"16px",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.3)",overflow:"hidden"},children:[s.jsx("div",{style:{padding:"16px",borderBottom:"1px solid rgba(255,255,255,0.1)",backgroundColor:"rgba(0,0,0,0.2)"},children:s.jsxs("div",{style:{display:"flex",gap:"8px"},children:[s.jsx("input",{value:e,onChange:p=>r(p.target.value),onKeyPress:c,onFocus:h,onBlur:u,placeholder:"Ask Bob about car parts...",disabled:n,style:{flex:1,padding:"12px 16px",border:"1px solid rgba(255,255,255,0.2)",borderRadius:"12px",backgroundColor:"rgba(255,255,255,0.1)",color:"white",fontSize:"16px",outline:"none"}}),f&&s.jsx("button",{onClick:f,style:{flexShrink:0,padding:"12px",border:"1px solid rgba(255,255,255,0.2)",borderRadius:"12px",backgroundColor:"rgba(255,255,255,0.1)",cursor:"pointer",minHeight:"unset",minWidth:"unset"},title:k?"Unmute Bob's voice":"Mute Bob's voice",children:k?"🔇":"🔊"}),s.jsx("button",{onClick:i,disabled:n||!e.trim(),style:{flexShrink:0,padding:"12px 20px",background:n||!e.trim()?"rgba(0, 102, 204, 0.3)":"linear-gradient(135deg, rgba(0, 102, 204, 0.95), rgba(0, 73, 153, 1))",color:"white",borderRadius:"12px",border:"1px solid rgba(255,255,255,0.2)",cursor:n||!e.trim()?"not-allowed":"pointer",opacity:n||!e.trim()?.5:1,minHeight:"unset",minWidth:"unset",fontWeight:600},children:"Send"})]})}),s.jsxs("div",{style:{overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"12px",height:"400px",background:"rgba(0,0,0,0.1)"},children:[[...t].reverse().map((p,E)=>{var b;return s.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:p.role==="user"?"flex-end":"flex-start"},children:s.jsxs("div",{style:{maxWidth:(b=p.suggestedProducts)!=null&&b.length?"100%":"80%",borderRadius:"16px",padding:"12px 16px",fontSize:"14px",backgroundColor:p.role==="user"?"linear-gradient(135deg, rgba(0, 102, 204, 0.9), rgba(0, 73, 153, 1))":"rgba(255,255,255,0.1)",background:p.role==="user"?"linear-gradient(135deg, rgba(0, 102, 204, 0.9), rgba(0, 73, 153, 1))":"rgba(255,255,255,0.08)",color:"white",border:"1px solid rgba(255,255,255,0.15)",boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},children:[p.content,p.role==="assistant"&&p.suggestedProducts&&p.suggestedProducts.length>0&&s.jsx(us,{products:p.suggestedProducts,title:p.suggestionsTitle,onAddToCart:x,onProductClick:j})]})},E)}),s.jsx("div",{ref:y})]})]})}),Mi=768,Ai=1024;function Fr(){const[t,e]=o.useState("mobile");return o.useEffect(()=>{const r=()=>{const n=window.innerWidth;n>=Ai?e("desktop"):n>=Mi?e("tablet"):e("mobile")};return r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),t}function ds(){const t=Fr();return Li(t)}function Li(t){switch(t){case"mobile":return{bobOffset:1,productWidth:1,uiScale:1,partialLeftPosition:-55,hiddenPosition:-100};case"tablet":return{bobOffset:.7,productWidth:.85,uiScale:1.1,partialLeftPosition:-25,hiddenPosition:-80};case"desktop":return{bobOffset:.5,productWidth:.6,uiScale:1.2,partialLeftPosition:-5,hiddenPosition:-60};default:return{bobOffset:1,productWidth:1,uiScale:1,partialLeftPosition:-20,hiddenPosition:-100}}}const Br=({currentImage:t,animationState:e,counterOverlayUrl:r,counterHeightPercent:n=15,scale:i=100,position:c="center",verticalOffset:h=0,hasArrived:u=!0})=>{const y=ds(),f=95*i/100,g=550*i/100,S=()=>{switch(c){case"center":return"50%";case"partial-left":return`${y.partialLeftPosition}%`;case"hidden":return`${y.hiddenPosition}%`;default:return"50%"}},x=()=>c==="center"?"translateX(-50%)":"translateX(0)",j=n-2+h,p=()=>c==="hidden"?"all 0.35s cubic-bezier(0.4, 0, 0.2, 1)":"all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1)";return s.jsxs("div",{className:"absolute inset-0 pointer-events-none",style:{overflow:"visible"},children:[s.jsx("div",{className:"absolute z-[60]",style:{bottom:`${j}%`,left:S(),maxHeight:`${100-n-2}%`,transform:x(),width:`${f}%`,maxWidth:`${g}px`,transition:p()+", opacity 0.6s ease-out",willChange:"transform, left, opacity",opacity:u?1:0},children:s.jsx("img",{src:t,alt:`Bob ${e}`,className:"w-full h-auto object-contain",style:{display:"block",maxHeight:"100%"}})}),r&&s.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-[70]",style:{height:`${n}%`,pointerEvents:"none"},children:s.jsx("img",{src:r,alt:"Shop counter",className:"w-full h-full object-cover object-top"})})]})},Er={background:"rgba(20, 30, 50, 0.92)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"28px",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255,255,255,0.1)"},yn={background:"linear-gradient(135deg, rgba(40, 60, 100, 0.95) 0%, rgba(20, 40, 80, 0.98) 100%)",border:"1px solid rgba(255, 255, 255, 0.4)",borderRadius:"32px",boxShadow:"0 12px 48px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255,255,255,0.15), inset 0 1px 0 rgba(255,255,255,0.2)"},Fs={background:"linear-gradient(135deg, rgba(255, 149, 0, 0.95) 0%, rgba(230, 134, 0, 1) 100%)",backdropFilter:"blur(12px) saturate(180%)",WebkitBackdropFilter:"blur(12px) saturate(180%)",border:"1px solid rgba(255, 255, 255, 0.35)",borderRadius:"24px",boxShadow:"0 10px 40px rgba(255, 149, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.3)"},vn={background:"linear-gradient(135deg, rgba(0, 102, 204, 0.95) 0%, rgba(0, 73, 153, 1) 100%)",backdropFilter:"blur(16px) saturate(180%)",WebkitBackdropFilter:"blur(16px) saturate(180%)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"32px",boxShadow:"0 10px 40px rgba(0, 102, 204, 0.4), inset 0 1px 0 rgba(255,255,255,0.25)"},wn={background:"rgba(255, 255, 255, 0.08)",backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"28px",boxShadow:"0 10px 40px rgba(0, 0, 0, 0.3)"},ur={primary:{color:"rgba(255, 255, 255, 1)",textShadow:"0 1px 3px rgba(0,0,0,0.5)"}},Di={background:"rgba(255, 255, 255, 0.12)",borderRadius:"20px",border:"1px solid rgba(255, 255, 255, 0.15)"},Wi={background:"rgba(255, 255, 255, 0.15)",border:"1px solid rgba(255, 255, 255, 0.25)",borderRadius:"12px"},zi={width:"4px",height:"4px",borderRadius:"50%",background:"rgba(255, 255, 255, 0.6)",boxShadow:"0 0 8px rgba(255, 255, 255, 0.4)"},kn=({product:t,isSpotlighted:e=!1,onProductClick:r,onAddToCart:n})=>{const[i,c]=o.useState(!1),h=()=>{r==null||r(t)},u=k=>{k.stopPropagation(),n==null||n(t)},y=e?yn:Er;return s.jsxs("div",{onClick:h,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),className:"relative w-full cursor-pointer glass-card",style:{...y,padding:"16px",transform:i?"scale(1.04) translateY(-4px)":"scale(1) translateY(0)",boxShadow:i?"0 16px 56px rgba(0, 0, 0, 0.4), 0 0 24px rgba(255,255,255,0.08)":y.boxShadow,transition:"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease-out"},children:[e&&s.jsxs("div",{className:"absolute -top-2.5 -right-2.5 z-10 flex items-center gap-1.5 px-3 py-1.5 text-xs font-bold",style:{background:"linear-gradient(135deg, rgba(0, 102, 204, 0.95) 0%, rgba(0, 73, 153, 1) 100%)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"20px",boxShadow:"0 8px 24px rgba(0, 102, 204, 0.5)",color:"white"},children:[s.jsx("svg",{className:"w-3.5 h-3.5",fill:"currentColor",viewBox:"0 0 20 20",children:s.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"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"flex-shrink-0 flex items-center justify-center overflow-hidden",style:{...Di,width:"92px",height:"92px"},children:t.image_url?s.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-2",loading:"lazy"}):s.jsx("div",{className:"flex flex-col items-center justify-center",style:{color:"rgba(255,255,255,0.4)"},children:s.jsx("svg",{className:"w-8 h-8",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"font-bold line-clamp-2 leading-tight",style:{fontSize:"16px",letterSpacing:"-0.01em",...ur.primary},children:t.name}),t.brand&&s.jsx("div",{className:"flex items-center gap-1.5 mt-1.5",children:s.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5",style:{...Wi,color:"rgba(255, 255, 255, 0.9)"},children:[s.jsx("svg",{className:"w-2.5 h-2.5",fill:"currentColor",viewBox:"0 0 20 20",children:s.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]})}),s.jsx("p",{className:"font-extrabold mt-2",style:{fontSize:"22px",letterSpacing:"-0.02em",color:"#FFD700",textShadow:"0 2px 6px rgba(0, 0, 0, 0.5), 0 0 12px rgba(255, 215, 0, 0.3)"},children:t.price>0?`$${t.price.toFixed(2)}`:"POA"})]}),s.jsx("button",{onClick:u,className:"flex-shrink-0 flex items-center justify-center glass-button",style:{...Fs,width:"56px",height:"56px",transition:"transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease-out"},onMouseEnter:k=>{k.currentTarget.style.transform="scale(1.08) translateY(-2px)",k.currentTarget.style.boxShadow="0 14px 48px rgba(255, 149, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.4)"},onMouseLeave:k=>{k.currentTarget.style.transform="scale(1) translateY(0)",k.currentTarget.style.boxShadow=Fs.boxShadow},children:s.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M12 4v16m8-8H4"})})})]}),t.partslotDescription&&s.jsx("div",{className:"mt-3 pt-3",style:{borderTop:"1px solid rgba(255, 255, 255, 0.15)"},children:s.jsx("span",{className:"text-xs font-medium",style:{color:"rgba(255, 255, 255, 0.6)"},children:t.partslotDescription})})]})},Bs=(t,e)=>{if(!t||!e)return!1;const r=t.toLowerCase();return e.toLowerCase().replace(/s\b/g,"").split(/\s+/).filter(Boolean).every(i=>r.includes(i))},$i=(t,e)=>{var i;const r=((i=t.brand)==null?void 0:i.toLowerCase())===e.brand.toLowerCase(),n=Math.abs(t.price-e.price)<1;return r&&n},Ui=({product:t,isSpotlighted:e,spotlightedRef:r,onProductClick:n,viewportSize:i})=>i==="desktop"?s.jsxs("div",{ref:e?r:void 0,onClick:()=>n==null?void 0:n(t),className:`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&&s.jsx(Is,{variant:"horizontal"}),s.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?s.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"}):s.jsx(Ps,{size:"lg"})}),s.jsxs("div",{className:"flex-1 p-4 flex flex-col justify-between",children:[s.jsxs("div",{children:[s.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&&s.jsx("div",{className:"flex items-center gap-2 mb-2",children:s.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:[s.jsx("svg",{className:"w-3 h-3 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20",children:s.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]})})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-2xl font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"POA"}),s.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:c=>{c.stopPropagation(),n==null||n(t)},children:"View"})]})]})]}):i==="tablet"?s.jsxs("div",{ref:e?r:void 0,onClick:()=>n==null?void 0:n(t),className:`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&&s.jsx(Is,{}),s.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?s.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-4"}):s.jsx(Ps,{size:"md"})}),s.jsxs("div",{className:"p-4",children:[s.jsx("p",{className:"text-base font-semibold text-gray-900 line-clamp-2 mb-1",children:t.name}),t.brand&&s.jsxs("p",{className:"text-sm text-gray-600 font-medium mb-2 flex items-center gap-1",children:[s.jsx("span",{className:"w-1.5 h-1.5 bg-blue-500 rounded-full"}),t.brand]}),s.jsx("div",{className:"flex items-center justify-between",children:s.jsx("span",{className:"text-xl font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"POA"})}),s.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:c=>{c.stopPropagation(),n==null||n(t)},children:"View Details"})]})]}):s.jsx("div",{ref:e?r:void 0,children:s.jsx(kn,{product:t,isSpotlighted:e,onProductClick:n})}),Is=({variant:t="default"})=>s.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:[s.jsx("svg",{className:"h-3 w-3",fill:"currentColor",viewBox:"0 0 20 20",children:s.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"]}),Ps=({size:t})=>{const e={sm:"h-8 w-8",md:"h-10 w-10",lg:"h-12 w-12"};return s.jsxs("div",{className:"flex flex-col items-center justify-center text-gray-400",children:[s.jsx("svg",{className:e[t],fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})}),s.jsx("span",{className:"text-xs font-medium uppercase tracking-wide mt-1",children:"No Image"})]})},Ir=({products:t,servicePackages:e,highlightedPartType:r,highlightedProduct:n,onProductClick:i,onPackageSelect:c,isResearching:h,visible:u=!0,counterHeightPercent:y=22,hasVehicle:k=!1,onAddToCart:f})=>{const g=Fr();ds();const S=o.useRef(null),x=o.useRef({}),j=o.useRef(null),p=30,E=20,[b,v]=o.useState(p),d=o.useRef(null),[_,B]=o.useState(null),[A,H]=o.useState({});o.useEffect(()=>{v(p)},[t.length]),o.useEffect(()=>{if(!d.current)return;const D=new IntersectionObserver(U=>{U[0].isIntersecting&&b<t.length&&v(F=>Math.min(F+E,t.length))},{threshold:.1});return D.observe(d.current),()=>D.disconnect()},[b,t.length]);const I=o.useMemo(()=>t.slice(0,b),[t,b]),z=o.useMemo(()=>{const D={};return I.forEach(F=>{const W=F.partslotDescription||"Other Parts";D[W]||(D[W]=[]),D[W].push(F)}),Object.keys(D).sort((F,W)=>F.localeCompare(W)).map(F=>({name:F,products:D[F]}))},[I]);o.useEffect(()=>{var D;if(r){const U=z.find(F=>Bs(F.name,r));U&&x.current[U.name]&&((D=x.current[U.name])==null||D.scrollIntoView({behavior:"smooth",block:"start"}))}},[r,z]),o.useEffect(()=>{n&&j.current&&j.current.scrollIntoView({behavior:"smooth",block:"center"})},[n]);const[m,T]=o.useState(0),C=D=>{const U=D.currentTarget,F=U.scrollHeight-U.clientHeight;if(F>0){const W=U.scrollTop/F;T(Math.max(0,Math.min(1,W)))}},N=t.length>0||e.length>0,w=h&&!N,q=N&&!w,$=u||N,X=g==="mobile"?92:g==="tablet"?65:48,Q=g==="desktop"?"580px":g==="tablet"?"500px":"100%",P=g==="mobile"?`calc(${k?"56px":"8px"} + env(safe-area-inset-top, 4px))`:"6px";return s.jsxs(s.Fragment,{children:[N&&u&&s.jsx("div",{style:{position:"fixed",right:"2px",top:`calc(${m*65+18}%)`,...zi,opacity:.8,transition:"top 0.1s ease-out",zIndex:100,pointerEvents:"none"}}),s.jsxs("div",{ref:S,onScroll:C,className:`absolute overflow-y-auto overflow-x-hidden z-30 flex flex-col gap-3 md:gap-4 transition-all duration-400 ease-out product-scroll ${$?"opacity-100 translate-x-0":"opacity-0 translate-x-12 pointer-events-none"}`,style:{width:`${X}%`,maxWidth:Q,right:"0",left:"auto",top:P,bottom:g==="mobile"?"calc(180px + env(safe-area-inset-bottom, 0px))":"52px",paddingTop:"4px",paddingRight:"6px",paddingLeft:"12px",paddingBottom:"8px",scrollbarWidth:"none",msOverflowStyle:"none"},children:[s.jsx("div",{className:"sticky top-0 z-10 -mx-1 px-3 py-2.5",style:{background:"linear-gradient(135deg, rgba(0, 102, 204, 0.85) 0%, rgba(0, 73, 153, 0.9) 100%)",backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)",borderRadius:"24px",boxShadow:"0 10px 40px rgba(0, 102, 204, 0.4)",border:"1px solid rgba(255, 255, 255, 0.25)"},children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[h&&N?s.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center",style:{background:"rgba(255,255,255,0.2)"},children:s.jsx("div",{className:"w-3.5 h-3.5 border-2 border-white border-t-transparent rounded-full animate-spin"})}):s.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center",style:{background:"rgba(255,255,255,0.2)"},children:s.jsx("svg",{className:"w-3.5 h-3.5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})}),s.jsx("span",{style:{...ur.primary,fontWeight:700,fontSize:"14px",letterSpacing:"0.025em"},children:h&&N?"Updating...":"Bob's Shelf"})]}),s.jsxs("span",{style:{color:"rgba(255,255,255,0.8)",fontSize:"12px",fontWeight:500},children:[t.length+e.length," ",t.length+e.length===1?"item":"items"]})]})}),w&&s.jsx("div",{className:"p-5",style:{...Er},children:s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[s.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center",style:{background:"rgba(0, 102, 204, 0.2)"},children:s.jsx("div",{className:"w-6 h-6 border-2 border-t-transparent rounded-full animate-spin",style:{borderColor:"rgba(255,255,255,0.8)",borderTopColor:"transparent"}})}),s.jsxs("div",{children:[s.jsx("p",{style:{...ur.primary,fontWeight:600,fontSize:"14px"},children:"Searching shelves..."}),s.jsx("p",{style:{color:"rgba(255,255,255,0.6)",fontSize:"12px",marginTop:"2px"},children:"Finding the best parts for you"})]})]})}),!w&&!N&&s.jsx("div",{className:"p-5",style:{...Er,background:"rgba(255, 149, 0, 0.15)"},children:s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[s.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center",style:{background:"rgba(255, 149, 0, 0.3)"},children:s.jsx("svg",{className:"w-5 h-5",style:{color:"#FF9500"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),s.jsxs("div",{children:[s.jsx("p",{style:{...ur.primary,fontWeight:600,fontSize:"14px"},children:"No products to display"}),s.jsxs("p",{style:{color:"rgba(255,255,255,0.6)",fontSize:"12px",marginTop:"2px"},children:["Products: ",t.length," | Packages: ",e.length]})]})]})}),q&&e.length>0&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 px-1",children:[s.jsx("div",{className:"w-6 h-6 rounded-lg flex items-center justify-center",style:{background:`linear-gradient(135deg, ${K.primary} 0%, ${K.primaryHover} 100%)`,boxShadow:`0 4px 12px ${K.primary}66`},children:s.jsx("svg",{className:"h-3.5 w-3.5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})})}),s.jsx("span",{className:"text-xs font-bold uppercase tracking-widest",style:{color:"white",textShadow:"0 1px 3px rgba(0,0,0,0.4)"},children:"CFX Service Packs"})]}),e.map(D=>{var je,ve;const U=(D.preparedTiers||[]).filter(J=>!J.isHidden),F=((je=U.find(J=>J.isRecommended))==null?void 0:je.tierName)||((ve=U[0])==null?void 0:ve.tierName)||"",W=A[D.id]||F,ae=U.find(J=>J.tierName===W),ce=mn(D.title).split(".")[0]+".",xe=_===D.id;return s.jsxs("div",{className:"overflow-hidden transition-all duration-300",style:{background:K.card,borderRadius:"16px",border:`1px solid ${K.border}`,boxShadow:"0 4px 20px rgba(0,0,0,0.08)"},children:[s.jsx("div",{className:"px-4 py-3",style:{background:`linear-gradient(135deg, ${K.primary} 0%, ${K.primaryHover} 100%)`},children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/20 flex items-center justify-center flex-shrink-0",children:s.jsx("svg",{className:"h-5 w-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-white font-bold text-base leading-tight truncate",children:D.title}),D.estimated_time&&s.jsx("div",{className:"flex items-center gap-3 mt-0.5",children:s.jsxs("span",{className:"text-white/70 text-xs flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),D.estimated_time]})})]})]})}),s.jsx("div",{className:"px-4 py-3 border-b",style:{borderColor:K.border},children:s.jsx("p",{className:"text-sm leading-relaxed",style:{color:K.mutedForeground},children:ce})}),U.length>0&&s.jsxs("div",{className:"p-3",children:[s.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide mb-2 px-1",style:{color:K.mutedForeground},children:"Choose Your Value Level"}),s.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${Math.min(U.length,4)}, 1fr)`},children:U.map(J=>{const Be=Cr[J.tierName],Ie=J.tierName===W;return s.jsxs("div",{onClick:()=>H(te=>({...te,[D.id]:J.tierName})),className:"relative rounded-xl text-center transition-all cursor-pointer",style:{padding:U.length>=4?"6px 4px":"8px",background:J.isRecommended?`${K.primary}10`:Ie?`${K.primary}05`:K.background,border:`2px solid ${J.isRecommended?K.primary:Ie?K.primary+"80":K.border}`},children:[J.isRecommended&&s.jsx("div",{className:"absolute -top-2 left-1/2 -translate-x-1/2 px-2 py-0.5 rounded-full text-[9px] font-bold uppercase tracking-wide whitespace-nowrap",style:{background:"#22C55E",color:"white"},children:"Recommended"}),s.jsxs("p",{className:"text-sm font-bold mt-1",style:{color:(Be==null?void 0:Be.textColor)||K.foreground},children:[Be==null?void 0:Be.emoji," ",J.displayName]}),s.jsx("div",{className:"flex flex-col items-center gap-1 mt-2",style:{minHeight:U.length>=4?"40px":"48px"},children:J.brands.slice(0,1).map((te,Re)=>{const fe=`https://flpzjbasdsfwoeruyxgp.supabase.co/storage/v1/object/public/brand_images/${te.fullName.replace(/\s+/g,"")}.jpg`;return s.jsx("div",{className:"w-full bg-white rounded-lg flex items-center justify-center overflow-hidden",style:{height:U.length>=4?"36px":"44px",maxWidth:U.length>=4?"64px":"80px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",border:"1px solid #F1F5F9"},children:s.jsx("img",{src:te.imageUrl,alt:te.fullName,className:"w-auto object-contain",style:{height:U.length>=4?"26px":"32px"},onError:He=>{const tt=He.target;tt.src!==fe?tt.src=fe:(tt.style.display="none",tt.parentElement.innerHTML=`<span class="text-[10px] font-semibold text-gray-600 truncate px-1">${te.fullName}</span>`)}})},Re)})}),s.jsxs("p",{className:"text-[10px] mt-2",style:{color:K.mutedForeground},children:[J.productCount," ",J.productCount===1?"part":"parts"]}),s.jsx("p",{className:"text-base font-bold mt-1",style:{color:K.foreground},children:gt(J.totalPrice)}),s.jsx("p",{className:"text-[10px]",style:{color:K.mutedForeground},children:"inc GST"}),s.jsxs("button",{onClick:te=>{te.stopPropagation();const Re=J.products.map(fe=>({id:fe.sku,name:fe.name,brand:fe.brand,price:fe.displayPrice,sku:fe.sku,partNumber:fe.partNumber||void 0,image_url:fe.productImageUrl,partslotDescription:fe.partslotName,quantity:1}));f==null||f(Re)},className:"w-full mt-2 py-1.5 rounded-lg text-[10px] font-semibold transition-all flex items-center justify-center gap-1",style:{background:J.isRecommended?K.primary:"#F1F5F9",color:J.isRecommended?"white":"#475569",border:J.isRecommended?"none":"1px solid #E2E8F0"},children:[s.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z"})}),"Add"]})]},J.tierName)})})]}),s.jsxs("div",{onClick:()=>B(xe?null:D.id),className:"flex items-center justify-center gap-1.5 py-2 cursor-pointer hover:bg-gray-50 transition-colors border-t",style:{borderColor:K.border},children:[s.jsx("span",{className:"text-xs",style:{color:K.mutedForeground},children:xe?"Hide details":"Show details"}),s.jsx("svg",{className:`w-4 h-4 transition-transform duration-200 ${xe?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",style:{color:K.mutedForeground},children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),xe&&ae&&s.jsx("div",{className:"px-4 pb-4 border-t animate-in slide-in-from-top-2 duration-200",style:{borderColor:K.border},children:s.jsxs("div",{className:"pt-3",children:[s.jsxs("p",{className:"text-xs font-semibold uppercase tracking-wide mb-3",style:{color:K.mutedForeground},children:[ae.displayName," Tier Products"]}),s.jsx("div",{className:"space-y-2",children:ae.products.map(J=>s.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg",style:{background:K.background,border:`1px solid ${K.border}`},children:[s.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-white rounded-lg overflow-hidden flex items-center justify-center",children:J.productImageUrl?s.jsx("img",{src:J.productImageUrl,alt:J.name,className:"w-full h-full object-contain p-1"}):s.jsx("svg",{className:"w-6 h-6 text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-xs font-medium truncate",style:{color:K.foreground},children:J.name}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px]",style:{color:K.mutedForeground},children:J.brand}),J.isRotor&&s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-blue-100 text-blue-700 font-medium",children:"Pair"})]}),s.jsx("p",{className:"text-[10px] mt-0.5",style:{color:K.mutedForeground},children:J.partslotName})]}),s.jsxs("div",{className:"text-right flex-shrink-0",children:[s.jsx("p",{className:"text-sm font-bold",style:{color:K.primary},children:gt(J.displayPrice)}),J.isRotor&&s.jsxs("p",{className:"text-[9px]",style:{color:K.mutedForeground},children:["$",J.price.toFixed(2)," ea"]})]})]},J.sku))})]})})]},D.id)})]}),q&&z.map(({name:D,products:U})=>{const F=r&&Bs(D,r);return s.jsxs("section",{ref:W=>{x.current[D]=W},className:"transition-all duration-300",style:{...F?yn:Er,background:F?"linear-gradient(135deg, rgba(0, 82, 164, 0.85) 0%, rgba(0, 51, 102, 0.9) 100%)":"rgba(20, 30, 50, 0.75)"},children:[s.jsxs("div",{className:"px-3 py-2.5 flex items-center justify-between",style:{background:F?"rgba(0, 102, 204, 0.8)":"rgba(0, 51, 102, 0.7)",borderBottom:"1px solid rgba(255,255,255,0.1)"},children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",style:{background:F?"linear-gradient(135deg, rgba(0, 102, 204, 0.9) 0%, rgba(0, 73, 153, 1) 100%)":"rgba(255,255,255,0.2)"},children:s.jsx("svg",{className:"h-3 w-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})})}),s.jsx("span",{className:"text-xs font-bold truncate uppercase tracking-wide",style:{color:"white",textShadow:"0 1px 3px rgba(0,0,0,0.6)"},children:D})]}),s.jsx("span",{className:"text-[10px] font-bold px-2.5 py-1 rounded-full flex-shrink-0",style:{background:"rgba(255, 149, 0, 0.9)",color:"white",boxShadow:"0 2px 8px rgba(255, 149, 0, 0.4)"},children:U.length})]}),s.jsx("div",{className:"p-3 flex flex-col gap-3",children:U.map((W,ae)=>{const Fe=!!(n&&$i(W,n));return s.jsx(Ui,{product:W,isSpotlighted:Fe,spotlightedRef:j,onProductClick:i,viewportSize:g},`${W.id}-${ae}`)})})]},D)}),b<t.length&&s.jsx("div",{ref:d,className:"flex items-center justify-center py-4",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",style:{color:"rgba(255,255,255,0.6)"},children:[s.jsx("div",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}),s.jsxs("span",{children:["Loading more (",b," of ",t.length,")..."]})]})}),s.jsx("div",{className:"h-4"})]})]})},hs=({onTranscript:t,onSpeechEnd:e,language:r="en-NZ",mode:n="toggle"}={})=>{const[i,c]=o.useState(!1),[h,u]=o.useState(""),[y,k]=o.useState(""),[f,g]=o.useState(null),[S,x]=o.useState(!1),j=o.useRef(null),p=o.useRef(""),E=o.useRef(t),b=o.useRef(e),v=o.useRef(null),d=15e3;o.useEffect(()=>{E.current=t,b.current=e},[t,e]),o.useEffect(()=>{const H=window.SpeechRecognition||window.webkitSpeechRecognition;if(H){x(!0);const I=new H;I.continuous=n==="ptt",I.interimResults=!0,I.lang=r,I.maxAlternatives=1,I.onstart=()=>{c(!0),g(null)},I.onresult=z=>{let m="",T="";for(let C=z.resultIndex;C<z.results.length;C++){const N=z.results[C][0].transcript;z.results[C].isFinal?T+=N:m+=N}T&&(p.current=T,u(T),E.current&&E.current(T)),k(m)},I.onerror=z=>{switch(c(!1),z.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.")}},I.onend=()=>{v.current&&(clearTimeout(v.current),v.current=null),c(!1),k(""),p.current&&b.current&&b.current(p.current),p.current=""},j.current=I}return()=>{j.current&&j.current.stop()}},[r,n]);const _=()=>{j.current&&!i&&(u(""),k(""),g(null),v.current=setTimeout(()=>{console.warn("[SpeechRecognition] Safety timeout - forcing stop after 15s"),j.current&&j.current.abort(),c(!1),k("")},d),j.current.start())},B=()=>{v.current&&(clearTimeout(v.current),v.current=null),j.current&&i&&j.current.stop()};return{isListening:i,transcript:h,interimTranscript:y,error:f,isSupported:S,startListening:_,stopListening:B,toggleListening:()=>{i?B():_()}}},Sn=({messages:t,input:e,setInput:r,isLoading:n,onSend:i,onKeyPress:c,onInputFocus:h,onInputBlur:u,chatEndRef:y,isMuted:k=!1,onToggleMute:f,isSpeaking:g=!1,onAddToCart:S,onProductClick:x})=>{var Q;const[j,p]=o.useState(!1),E=o.useRef(null),b=o.useRef(!1),{bottomOffset:v,zIndexBase:d}=cs(),{isListening:_,interimTranscript:B,error:A,isSupported:H,startListening:I,stopListening:z}=hs({onTranscript:P=>r(P),language:"en-NZ",mode:"ptt"});o.useEffect(()=>{B&&r(B)},[B,r]);const m=o.useCallback(()=>{n||b.current||(b.current=!0,navigator.vibrate&&navigator.vibrate(30),I())},[n,I]),T=o.useCallback(()=>{b.current&&(b.current=!1,navigator.vibrate&&navigator.vibrate([20,50,20]),z(),setTimeout(()=>{i()},150))},[z,i]),C=[...t].reverse().find(P=>P.role==="assistant"),N=((Q=C==null?void 0:C.suggestedProducts)==null?void 0:Q.length)||0,w=C!=null&&C.content?C.content.length>50?C.content.slice(0,50)+"...":C.content:"Ask Bob about car parts...",q=N>0?` (${N} products)`:"",$={idle:{...vn},active:{background:"linear-gradient(135deg, rgba(255, 149, 0, 0.95) 0%, rgba(230, 134, 0, 1) 100%)",backdropFilter:"blur(16px) saturate(180%)",WebkitBackdropFilter:"blur(16px) saturate(180%)",border:"1px solid rgba(255, 255, 255, 0.4)",borderRadius:"32px",boxShadow:"0 12px 48px rgba(255, 149, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.3)"},disabled:{background:"rgba(156, 163, 175, 0.5)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"32px",boxShadow:"0 4px 16px rgba(0, 0, 0, 0.2)"}},X=n?$.disabled:_?$.active:$.idle;return s.jsxs("div",{ref:E,style:{position:"fixed",bottom:`${v}px`,left:0,right:0,...wn,borderRadius:"28px 28px 0 0",borderBottom:"none",transition:"all 0.3s ease-out",boxShadow:"0 -10px 40px rgba(0, 0, 0, 0.3)",height:j?"55vh":"auto",zIndex:d+60,paddingBottom:v>0?"8px":"env(safe-area-inset-bottom, 8px)"},children:[s.jsx("button",{onClick:()=>p(!j),style:{position:"absolute",top:"-20px",left:"50%",transform:"translateX(-50%)",background:"rgba(255, 255, 255, 0.15)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:"1px solid rgba(255, 255, 255, 0.25)",borderRadius:"9999px",padding:"6px",boxShadow:"0 4px 16px rgba(0, 0, 0, 0.2)",zIndex:d+70,cursor:"pointer",minHeight:"unset",minWidth:"unset"},"aria-label":j?"Collapse chat":"Expand chat",children:j?s.jsx("svg",{style:{height:"16px",width:"16px",color:"rgba(255,255,255,0.8)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}):s.jsx("svg",{style:{height:"16px",width:"16px",color:"rgba(255,255,255,0.8)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),!j&&s.jsx("div",{onClick:()=>p(!0),style:{padding:"8px 12px 2px 12px",cursor:"pointer"},children:s.jsxs("p",{style:{fontSize:"12px",color:"white",textShadow:"0 1px 3px rgba(0,0,0,0.6)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[w,q&&s.jsx("span",{style:{color:"rgba(255,200,0,0.9)",fontWeight:600},children:q})]})}),j&&s.jsxs("div",{style:{height:"calc(100% - 100px)",overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"8px"},className:"glass-scroll",children:[[...t].reverse().map((P,D)=>{var U;return s.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:P.role==="user"?"flex-end":"flex-start"},children:s.jsxs("div",{style:{maxWidth:(U=P.suggestedProducts)!=null&&U.length?"100%":"85%",borderRadius:"16px",padding:"10px 14px",fontSize:"14px",background:P.role==="user"?"linear-gradient(135deg, rgba(0, 102, 204, 0.9) 0%, rgba(0, 73, 153, 0.95) 100%)":"rgba(255, 255, 255, 0.12)",backdropFilter:"blur(12px)",border:"1px solid rgba(255, 255, 255, 0.2)",color:"rgba(255, 255, 255, 0.95)",textShadow:"0 1px 2px rgba(0,0,0,0.2)"},children:[P.content,P.role==="assistant"&&P.suggestedProducts&&P.suggestedProducts.length>0&&s.jsx(us,{products:P.suggestedProducts,title:P.suggestionsTitle,onAddToCart:S,onProductClick:x})]})},D)}),s.jsx("div",{ref:y})]}),H&&s.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"12px 16px 8px 16px"},children:s.jsx("button",{onTouchStart:m,onTouchEnd:T,onTouchCancel:T,onMouseDown:m,onMouseUp:T,onMouseLeave:T,onClick:_?T:void 0,disabled:n,"aria-label":"Hold to talk to Bob",className:"glass-button",style:{width:"200px",height:"64px",minHeight:"unset",minWidth:"unset",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",touchAction:"none",cursor:n?"not-allowed":"pointer",opacity:n?.6:1,transform:_?"scale(1.04)":"scale(1)",transition:"transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, background 0.15s ease",...X},title:"Hold to talk",children:s.jsx("span",{style:{fontSize:"22px",fontWeight:800,letterSpacing:"0.15em",...ur.primary,textTransform:"uppercase",fontFamily:"system-ui, -apple-system, sans-serif"},children:_?"LISTENING":"TALK"})})}),s.jsxs("div",{style:{padding:"4px 12px 8px 12px",borderTop:"1px solid rgba(255, 255, 255, 0.15)"},children:[A&&s.jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"#FF9500"},children:A}),s.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[f&&s.jsx("button",{onClick:f,style:{flexShrink:0,height:"40px",width:"40px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"12px",background:"rgba(255, 255, 255, 0.1)",backdropFilter:"blur(8px)",color:g?"#0066CC":"rgba(255,255,255,0.7)",cursor:"pointer",border:"1px solid rgba(255, 255, 255, 0.2)",minHeight:"unset",minWidth:"unset"},title:k?"Unmute":"Mute",children:k?s.jsxs("svg",{style:{height:"18px",width:"18px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.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"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]}):s.jsx("svg",{style:{height:"18px",width:"18px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})})}),s.jsx("input",{type:"text",value:e,onChange:P=>r(P.target.value),onKeyPress:c,onFocus:h,onBlur:u,placeholder:"Or type here...",disabled:n,className:"high-contrast-input",style:{flex:1,height:"40px",fontSize:"16px",padding:"0 14px",background:"rgba(0, 51, 102, 0.85)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:"2px solid rgba(255, 255, 255, 0.35)",borderRadius:"20px",color:"white",outline:"none",opacity:n?.5:1}})]})]})]})},jn=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:n,counterHeightPercent:i=22,messages:c,input:h,setInput:u,isLoading:y,onSend:k,onKeyPress:f,onInputFocus:g,onInputBlur:S,chatEndRef:x,isMuted:j,onToggleMute:p,isSpeaking:E,products:b,servicePackages:v,highlightedPartType:d,highlightedProduct:_,onProductClick:B,onPackageSelect:A,isResearching:H,vehicle:I,onChangeVehicle:z,bobOffset:m=0,bobScale:T=100})=>{console.log("[MobileBobLayout] Rendering with:",{currentImage:(t==null?void 0:t.substring(0,50))||"EMPTY",backdropUrl:(r==null?void 0:r.substring(0,50))||"NONE",counterOverlayUrl:(n==null?void 0:n.substring(0,50))||"NONE"});const C=typeof window<"u"&&window.self!==window.top,N=Fr(),[w,q]=o.useState("center"),[$,X]=o.useState("hidden"),Q=b.length>0||v.length>0,U=(()=>{switch(N){case"desktop":return 70;case"tablet":return 80;case"mobile":return 140;default:return 140}})()*T/100;o.useEffect(()=>{if(H&&$!=="loading"&&$!=="visible")X("loading"),w==="center"&&q("left");else if(Q&&$!=="visible")if(w==="center"){q("left"),X("transitioning");const W=setTimeout(()=>{X("visible")},400);return()=>clearTimeout(W)}else X("visible");else!Q&&!H&&$!=="hidden"&&(X("hidden"),q("center"))},[Q,H,$,w]);const F=$!=="hidden";return s.jsxs("div",{className:"fixed inset-0 overflow-hidden",style:{height:"100dvh",touchAction:"manipulation"},children:[r&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"absolute inset-0 z-0",style:{backgroundImage:`url(${r})`,backgroundSize:"cover",backgroundPosition:"center bottom",filter:"blur(4px) brightness(0.85)",transform:"scale(1.05)"}}),s.jsx("div",{className:"absolute inset-0 z-[1]",style:{background:"linear-gradient(to bottom, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.35) 100%)"}})]}),s.jsx(Br,{currentImage:t,animationState:e,counterOverlayUrl:n,counterHeightPercent:i,scale:U,position:w,verticalOffset:m}),I&&!C&&s.jsx("div",{style:{position:"absolute",top:"8px",left:"8px",right:"8px",zIndex:20},children:s.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:[s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("p",{style:{fontSize:"12px",fontWeight:500,color:"#111827",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[I.year," ",I.make," ",I.model]}),I.rego&&s.jsx("p",{style:{fontSize:"10px",color:"#6b7280"},children:I.rego})]}),z&&s.jsx("button",{onClick:z,style:{fontSize:"12px",color:"#2563eb",marginLeft:"8px",flexShrink:0,background:"none",border:"none",cursor:"pointer",minHeight:"unset",minWidth:"unset"},children:"Change"})]})}),s.jsx(Ir,{products:b,servicePackages:v,highlightedPartType:d,highlightedProduct:_,onProductClick:B,onPackageSelect:A,isResearching:H,visible:F,counterHeightPercent:i,hasVehicle:!!I}),s.jsx(Sn,{messages:c,input:h,setInput:u,isLoading:y,onSend:k,onKeyPress:f,onInputFocus:g,onInputBlur:S,chatEndRef:x,isMuted:j,onToggleMute:p,isSpeaking:E,onAddToCart:B,onProductClick:B})]})},_n=({messages:t,input:e,setInput:r,isLoading:n,onSend:i,onKeyPress:c,onInputFocus:h,onInputBlur:u,chatEndRef:y,isMuted:k=!1,onToggleMute:f,isSpeaking:g=!1})=>{const[S,x]=o.useState(!1),j=o.useRef(null),p=o.useRef(!1),{bottomOffset:E,zIndexBase:b}=cs(),{isListening:v,interimTranscript:d,error:_,isSupported:B,startListening:A,stopListening:H}=hs({onTranscript:w=>r(w),language:"en-NZ",mode:"ptt"});o.useEffect(()=>{d&&r(d)},[d,r]);const I=o.useCallback(()=>{n||p.current||(p.current=!0,navigator.vibrate&&navigator.vibrate(30),A())},[n,A]),z=o.useCallback(()=>{p.current&&(p.current=!1,navigator.vibrate&&navigator.vibrate([20,50,20]),H(),setTimeout(()=>{i()},150))},[H,i]),m=[...t].reverse().find(w=>w.role==="assistant"),T=m!=null&&m.content?m.content.length>50?m.content.slice(0,50)+"...":m.content:"Ask Bob about car parts...",C={idle:{...vn},active:{background:"linear-gradient(135deg, rgba(255, 149, 0, 0.95) 0%, rgba(230, 134, 0, 1) 100%)",backdropFilter:"blur(16px) saturate(180%)",WebkitBackdropFilter:"blur(16px) saturate(180%)",border:"1px solid rgba(255, 255, 255, 0.4)",borderRadius:"50%",boxShadow:"0 12px 48px rgba(255, 149, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.3)"},disabled:{background:"rgba(156, 163, 175, 0.5)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:"1px solid rgba(255, 255, 255, 0.2)",borderRadius:"50%",boxShadow:"0 4px 16px rgba(0, 0, 0, 0.2)"}},N=n?C.disabled:v?C.active:C.idle;return s.jsxs("div",{ref:j,style:{position:"absolute",bottom:`${E}px`,left:0,right:0,...wn,borderRadius:"28px 28px 0 0",borderBottom:"none",transition:"all 0.3s ease-out",boxShadow:"0 -10px 40px rgba(0, 0, 0, 0.3)",height:S?"55%":"70px",overflow:S?"visible":"hidden",zIndex:b+10,paddingBottom:E>0?"8px":"env(safe-area-inset-bottom, 8px)"},children:[s.jsx("button",{onClick:()=>x(!S),style:{position:"absolute",top:"-20px",left:"50%",transform:"translateX(-50%)",background:"rgba(255, 255, 255, 0.15)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:"1px solid rgba(255, 255, 255, 0.25)",borderRadius:"9999px",padding:"6px",boxShadow:"0 4px 16px rgba(0, 0, 0, 0.2)",zIndex:b+20,cursor:"pointer",minHeight:"unset",minWidth:"unset"},"aria-label":S?"Collapse chat":"Expand chat",children:S?s.jsx("svg",{style:{height:"16px",width:"16px",color:"rgba(255,255,255,0.8)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}):s.jsx("svg",{style:{height:"16px",width:"16px",color:"rgba(255,255,255,0.8)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),!S&&s.jsx("div",{onClick:()=>x(!0),style:{padding:"6px 12px 4px 12px",height:"26px",overflow:"hidden",cursor:"pointer"},children:s.jsx("p",{style:{fontSize:"12px",color:"white",textShadow:"0 1px 3px rgba(0,0,0,0.6)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T})}),S&&s.jsxs("div",{style:{height:"calc(100% - 100px)",overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"8px"},className:"glass-scroll",children:[[...t].reverse().map((w,q)=>s.jsx("div",{style:{display:"flex",justifyContent:w.role==="user"?"flex-end":"flex-start"},children:s.jsx("div",{style:{maxWidth:"85%",borderRadius:"16px",padding:"10px 14px",fontSize:"14px",background:w.role==="user"?"linear-gradient(135deg, rgba(0, 102, 204, 0.9) 0%, rgba(0, 73, 153, 0.95) 100%)":"rgba(255, 255, 255, 0.12)",backdropFilter:"blur(12px)",border:"1px solid rgba(255, 255, 255, 0.2)",color:"rgba(255, 255, 255, 0.95)",textShadow:"0 1px 2px rgba(0,0,0,0.2)"},children:w.content})},q)),s.jsx("div",{ref:y})]}),s.jsxs("div",{style:{padding:S?"8px 12px 4px 12px":"4px 12px 4px 12px",borderTop:S?"1px solid rgba(255, 255, 255, 0.15)":"none"},children:[v&&s.jsxs("div",{style:{marginBottom:"8px",fontSize:"12px",color:"rgba(255,255,255,0.7)",display:"flex",alignItems:"center",gap:"8px"},children:[s.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",backgroundColor:"#FF9500",borderRadius:"50%",animation:"pulse 2s infinite"}}),"Listening..."]}),_&&s.jsx("div",{style:{marginBottom:"8px",fontSize:"12px",color:"#FF9500"},children:_}),s.jsxs("div",{style:{display:"flex",gap:"6px",alignItems:"center"},children:[f&&S&&s.jsx("button",{onClick:f,style:{flexShrink:0,height:"36px",width:"36px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"10px",background:"rgba(255, 255, 255, 0.1)",backdropFilter:"blur(8px)",color:g?"#0066CC":"rgba(255,255,255,0.7)",cursor:"pointer",border:"1px solid rgba(255, 255, 255, 0.2)",minHeight:"unset",minWidth:"unset"},title:k?"Unmute":"Mute",children:k?s.jsxs("svg",{style:{height:"16px",width:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.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"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]}):s.jsx("svg",{style:{height:"16px",width:"16px"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})})}),s.jsx("input",{type:"text",value:e,onChange:w=>r(w.target.value),onKeyPress:c,onFocus:h,onBlur:u,placeholder:"Message Bob...",disabled:n,className:"high-contrast-input",style:{flex:1,height:"40px",fontSize:"16px",padding:"0 14px",background:"rgba(0, 51, 102, 0.85)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",border:"2px solid rgba(255, 255, 255, 0.35)",borderRadius:"20px",color:"white",outline:"none",opacity:n?.5:1}}),B&&s.jsxs("div",{style:{position:"relative",marginLeft:"4px"},children:[v&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",width:"72px",height:"72px",borderRadius:"50%",border:"2px solid #FF9500",transform:"translate(-50%, -50%)",animation:"ptt-wave 1.5s ease-out infinite",opacity:0,pointerEvents:"none"}}),s.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",width:"72px",height:"72px",borderRadius:"50%",border:"2px solid #FF9500",transform:"translate(-50%, -50%)",animation:"ptt-wave 1.5s ease-out infinite 0.5s",opacity:0,pointerEvents:"none"}})]}),!v&&!n&&s.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"}}),s.jsxs("button",{onTouchStart:I,onTouchEnd:z,onTouchCancel:z,onMouseDown:I,onMouseUp:z,onMouseLeave:z,disabled:n,"aria-label":"Hold to talk to Bob",className:"glass-button",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:n?"not-allowed":"pointer",opacity:n?.6:1,transform:v?"scale(1.08)":"scale(1)",transition:"transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease",zIndex:b+25,...N},title:"Hold to talk",children:[s.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:s.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"})}),v&&s.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"}})]})]})]})]})]})},Hi=({product:t,onBack:e,onAddToCart:r,onNavigateToProductPage:n})=>{const i=t.productUrl||t.product_url,c=t.partNumber||t.part_number,h=!!i||!!n;return s.jsxs("div",{className:"absolute inset-0 z-35 flex flex-col bg-white/95 backdrop-blur-md overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-gray-200 bg-white/80 backdrop-blur-sm",children:s.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:[s.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back to Products"]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.jsx("div",{className:"aspect-square bg-gradient-to-br from-gray-50 to-gray-100 flex items-center justify-center",children:t.image_url?s.jsx("img",{src:t.image_url,alt:t.name,className:"w-full h-full object-contain p-4"}):s.jsxs("div",{className:"flex flex-col items-center justify-center text-gray-400",children:[s.jsx("svg",{className:"h-16 w-16 mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})}),s.jsx("span",{className:"text-sm font-medium uppercase tracking-wide",children:"No Image Available"})]})}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-gray-900 mb-1",children:t.name}),t.brand&&s.jsx("p",{className:"text-sm text-gray-600 font-medium",children:t.brand})]}),s.jsxs("div",{className:"bg-blue-50 rounded-xl p-4",children:[s.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Price"}),s.jsx("p",{className:"text-2xl font-bold text-blue-600",children:t.price>0?`$${t.price.toFixed(2)}`:"Price on Request"}),t.price>0&&s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Inc. GST"})]}),s.jsxs("div",{className:"space-y-3",children:[t.partslotDescription&&s.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[s.jsx("span",{className:"text-sm text-gray-500",children:"Category"}),s.jsx("span",{className:"text-sm font-medium text-gray-900",children:t.partslotDescription})]}),t.sku&&s.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[s.jsx("span",{className:"text-sm text-gray-500",children:"SKU"}),s.jsx("span",{className:"text-sm font-medium text-gray-900",children:t.sku})]}),c&&s.jsxs("div",{className:"flex justify-between py-2 border-b border-gray-100",children:[s.jsx("span",{className:"text-sm text-gray-500",children:"Part Number"}),s.jsx("span",{className:"text-sm font-medium text-gray-900",children:c})]})]}),h&&s.jsx("a",{href:i||"#",onClick:u=>{n&&(u.preventDefault(),n(t))},target:i&&!n?"_blank":void 0,rel:i&&!n?"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 →"})]})]}),s.jsx("div",{className:"p-4 border-t border-gray-200 bg-white/95 backdrop-blur-sm",children:s.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"})})]})},En=({package:t,onBack:e,onAddToCart:r,onNavigateToProductPage:n})=>{var S;const[i,c]=o.useState(!1),h=o.useMemo(()=>!t.preparedTiers||t.preparedTiers.length===0?[]:t.preparedTiers.filter(x=>!x.isHidden),[t.preparedTiers]),u=h.length>0,y=x=>{r==null||r(x.products)},k=x=>x===2?"grid-cols-2":x===3?"grid-cols-3":"grid-cols-2",f=mn(t.title),g=((S=h[0])==null?void 0:S.productCount)||0;return s.jsxs("div",{className:"absolute inset-0 z-35 flex flex-col bg-[#FAFAFA] overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-[#E2E8F0] bg-white shadow-sm",children:s.jsxs("button",{onClick:e,className:"flex items-center gap-1.5 text-[#0052CC] font-medium text-sm hover:text-[#0047B3] active:scale-95 transition-all",children:[s.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back"]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.jsxs("div",{className:"px-4 pt-4 pb-4",style:{background:"linear-gradient(135deg, rgba(0,82,204,0.05) 0%, rgba(56,189,248,0.05) 100%)"},children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center flex-shrink-0 bg-white shadow-md",children:t.icon_url?s.jsx("img",{src:t.icon_url,alt:"",className:"w-8 h-8 object-contain"}):s.jsx("svg",{className:"w-7 h-7 text-[#0052CC]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h1",{className:"text-xl font-bold text-[#0F172A]",children:t.title}),s.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-[#64748B]",children:[t.estimated_time&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),t.estimated_time]}),t.difficulty_level&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.42 15.17L17.25 21A2.652 2.652 0 0021 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 11-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 004.486-6.336l-3.276 3.277a3.004 3.004 0 01-2.25-2.25l3.276-3.276a4.5 4.5 0 00-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085"})}),t.difficulty_level]})]})]})]}),s.jsx("p",{className:"text-sm text-[#64748B] mt-3 leading-relaxed",children:f})]}),s.jsxs("div",{className:"px-4 py-3 flex items-center justify-center gap-2 border-b border-[#E2E8F0] bg-white",children:[s.jsx("span",{className:"font-semibold text-[#0F172A] text-sm",children:"Choose Your Value Level"}),s.jsx("span",{className:"text-[#64748B] text-xs cursor-help",title:"Select the quality tier that suits your needs",children:"ⓘ"})]}),s.jsx("div",{className:"p-4",children:u?s.jsx("div",{className:`grid ${k(h.length)} gap-3`,children:h.map(x=>{const j=Cr[x.tierName];return s.jsxs("div",{className:"relative rounded-2xl overflow-hidden bg-white shadow-md flex flex-col",style:{border:x.isRecommended?"2px solid #0052CC":"1px solid #E2E8F0"},children:[x.isRecommended&&s.jsx("div",{className:"absolute top-0 left-0 right-0 px-2 py-1 text-[9px] font-bold text-white text-center",style:{background:"linear-gradient(135deg, #0052CC 0%, #38BDF8 100%)"},children:"★ RECOMMENDED"}),s.jsxs("div",{className:`p-3 flex-1 flex flex-col ${x.isRecommended?"pt-7":""}`,children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[s.jsx("span",{className:"text-lg",children:j==null?void 0:j.emoji}),s.jsxs("div",{children:[s.jsx("span",{className:"font-bold text-sm block",style:{color:(j==null?void 0:j.textColor)||K.foreground},children:x.displayName}),s.jsx("span",{className:"text-[10px] text-[#64748B] hidden md:block",children:x.description||(j==null?void 0:j.description)})]})]}),s.jsx("div",{className:"flex items-center gap-1.5 mb-3 min-h-[42px] flex-wrap",children:x.brands.slice(0,3).map(p=>s.jsx("div",{className:"h-10 px-2 bg-white rounded-xl flex items-center justify-center shadow-md border border-[#F1F5F9]",children:s.jsx("img",{src:p.imageUrl,alt:p.fullName,className:"h-6 w-auto object-contain",onError:E=>{const b=E.target,v=`${fr.storageBase}/brand_images/${p.fullName.replace(/\s+/g,"")}.jpg`;if(b.src!==v)b.src=v;else{const d=b.parentElement;d&&(d.innerHTML=`<span class="text-[10px] font-medium text-slate-700 px-1 truncate max-w-[60px]">${p.name}</span>`)}}})},p.name))}),s.jsxs("p",{className:"text-xs text-[#64748B] hidden md:block mb-2",children:[x.productCount," part",x.productCount!==1?"s":""," included"]}),s.jsxs("div",{className:"mt-auto",children:[s.jsx("p",{className:"text-xl font-bold",style:{color:x.isRecommended?"#0052CC":"#0F172A"},children:gt(x.totalPrice)}),s.jsx("p",{className:"text-[10px] text-[#64748B] hidden md:block",children:"inc GST"})]}),s.jsxs("button",{onClick:()=>y(x),className:`mt-3 w-full px-3 py-2.5 rounded-xl text-xs font-semibold transition-all hover:scale-[1.02] active:scale-95 flex items-center justify-center gap-1.5 ${x.isRecommended?"bg-[#0052CC] text-white shadow-md hover:bg-[#0047B3]":"bg-slate-100 text-slate-700 border border-slate-200 hover:bg-slate-200"}`,children:[s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z"})}),"Add to Cart"]})]})]},x.tierName)})}):s.jsxs("div",{className:"rounded-2xl p-6 bg-white border border-[#E2E8F0] shadow-md text-center",children:[s.jsx("svg",{className:"w-12 h-12 mx-auto text-[#94A3B8] mb-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})}),s.jsx("p",{className:"text-sm font-medium text-[#64748B]",children:"Package details not available for this vehicle"}),s.jsx("p",{className:"text-xs text-[#94A3B8] mt-1",children:"Please try refreshing or contact support"})]})}),u&&s.jsxs("div",{className:"px-4 pb-4",children:[s.jsxs("button",{onClick:()=>c(!i),className:"w-full flex items-center justify-between p-3 rounded-xl bg-white border border-[#E2E8F0] hover:bg-slate-50 transition-all shadow-sm",children:[s.jsxs("span",{className:"text-sm font-medium text-[#0F172A]",children:[i?"▼":"▶"," View Product Details"]}),s.jsxs("span",{className:"text-xs text-[#64748B]",children:[g," product",g!==1?"s":""]})]}),i&&s.jsx("div",{className:"mt-3 space-y-4 bg-white rounded-xl border border-[#E2E8F0] p-3",children:h.map(x=>{if(x.products.length===0)return null;const j=Cr[x.tierName];return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 pb-1 border-b border-[#E2E8F0]",children:[s.jsx("span",{className:"text-lg",children:j==null?void 0:j.emoji}),s.jsx("span",{className:"font-semibold text-sm",style:{color:j==null?void 0:j.textColor},children:x.displayName}),s.jsxs("span",{className:"text-xs text-[#64748B]",children:["(",x.products.length," parts)"]})]}),s.jsx("div",{className:"space-y-2",children:x.products.map((p,E)=>{var d;const b=(d=t.carfixValueProducts)==null?void 0:d.includes(p.sku),v=p.unitPrice??p.price;return s.jsxs("div",{className:"flex items-center gap-3 p-2.5 rounded-xl transition-all hover:bg-slate-50 cursor-pointer border border-[#E2E8F0]",onClick:()=>n==null?void 0:n(p.sku),children:[s.jsx("div",{className:"w-14 h-14 flex-shrink-0 rounded-lg bg-white overflow-hidden border border-[#E2E8F0]",children:s.jsx("img",{src:p.productImageUrl||fr.productImage(p.sku),alt:p.name,className:"w-full h-full object-contain p-1.5",onError:_=>{_.target.src="/placeholder.svg"}})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("span",{className:"text-xs font-semibold text-[#0F172A]",children:p.brandFullName||p.brand}),b&&s.jsx("span",{className:"px-1.5 py-0.5 text-[8px] font-bold rounded-full",style:{background:"rgba(0, 82, 204, 0.1)",color:"#0052CC"},children:"CFX VALUE"}),p.isMultiQty&&p.perCarQty>1&&s.jsxs("span",{className:"px-1.5 py-0.5 text-[8px] font-bold rounded-full",style:{background:"#F0FDF4",color:"#15803D"},children:["×",p.perCarQty]}),p.isRotor&&s.jsx("span",{className:"px-1.5 py-0.5 text-[8px] font-bold rounded-full",style:{background:"#EFF6FF",color:"#1D4ED8"},children:"Pair"})]}),s.jsx("p",{className:"text-xs text-[#64748B] line-clamp-1",children:p.name})]}),s.jsxs("div",{className:"text-right flex-shrink-0",children:[s.jsx("p",{className:"text-sm font-bold text-[#0F172A]",children:gt(p.displayPrice)}),p.isMultiQty&&p.perCarQty>1&&s.jsxs("p",{className:"text-[10px] text-[#64748B]",children:[p.perCarQty,"× ",gt(v)," each"]}),p.isRotor&&!p.isMultiQty&&s.jsxs("p",{className:"text-[10px] text-[#64748B]",children:[gt(v)," each"]})]})]},`${p.sku}-${E}`)})})]},x.tierName)})})]}),t.bundle_discount_percentage&&t.bundle_discount_percentage>0&&s.jsx("div",{className:"px-4 pb-4",children:s.jsx("div",{className:"rounded-xl p-3 text-center",style:{background:"rgba(34,197,94,0.1)",border:"1px solid rgba(34,197,94,0.2)"},children:s.jsxs("span",{className:"text-sm font-semibold text-[#22C55E]",children:["Bundle saves you ",t.bundle_discount_percentage,"%"]})})})]})]})},Tn=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:n,counterHeightPercent:i=22,messages:c,input:h,setInput:u,isLoading:y,onSend:k,onKeyPress:f,onInputFocus:g,onInputBlur:S,chatEndRef:x,isMuted:j,onToggleMute:p,isSpeaking:E,products:b,servicePackages:v,highlightedPartType:d,highlightedProduct:_,onProductClick:B,onPackageSelect:A,isResearching:H,onAddToCart:I,onNavigateToProductPage:z,vehicle:m,onChangeVehicle:T,bobOffset:C=0,bobScale:N=100})=>{const[w,q]=o.useState("center"),[$,X]=o.useState("hidden"),[Q,P]=o.useState("products"),[D,U]=o.useState(null),[F,W]=o.useState(null),ae=b.length>0||v.length>0,xe=(Q==="productDetail"?70:w==="center"&&!ae?140:98)*N/100;o.useEffect(()=>{if(H&&$!=="loading"&&$!=="visible")X("loading"),w==="center"&&q("left");else if(ae&&$!=="visible")if(w==="center"){q("left"),X("transitioning");const te=setTimeout(()=>{X("visible")},400);return()=>clearTimeout(te)}else X("visible");else!ae&&!H&&$!=="hidden"&&(X("hidden"),q("center"))},[ae,H,$,w]);const je=te=>{if(z){z(te),B==null||B(te);return}U(te),P("productDetail"),B==null||B(te)},ve=()=>{U(null),W(null),P("products")},J=te=>{console.log("[ContainedMobileBobLayout] Package selected:",te.title),W(te),P("packageDetail"),A==null||A(te)},Be=$!=="hidden"&&Q==="products",Ie=$!=="hidden";return s.jsxs("div",{className:"absolute inset-0 overflow-hidden",style:{touchAction:"manipulation"},children:[r&&s.jsx("div",{className:"absolute inset-0 z-0 transition-all duration-500 ease-out",style:{backgroundImage:`url(${r})`,backgroundSize:"cover",backgroundPosition:"center bottom",filter:Ie?"blur(8px) brightness(0.9)":"blur(0px) brightness(1)",transform:"scale(1.05)"}}),s.jsx(Br,{currentImage:t,animationState:e,counterOverlayUrl:n,counterHeightPercent:i,scale:xe,position:w,verticalOffset:C}),m&&Q==="products"&&s.jsx("div",{style:{position:"absolute",top:"8px",left:"8px",right:"8px",zIndex:20},children:s.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:[s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("p",{style:{fontSize:"12px",fontWeight:500,color:"#111827",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[m.year," ",m.make," ",m.model]}),m.rego&&s.jsx("p",{style:{fontSize:"10px",color:"#6b7280"},children:m.rego})]}),T&&s.jsx("button",{onClick:T,style:{fontSize:"12px",color:"#2563eb",marginLeft:"8px",flexShrink:0,background:"none",border:"none",cursor:"pointer",minHeight:"unset",minWidth:"unset"},children:"Change"})]})}),s.jsx(Ir,{products:b,servicePackages:v,highlightedPartType:d,highlightedProduct:_,onProductClick:je,onPackageSelect:J,isResearching:H,visible:Be,counterHeightPercent:i,hasVehicle:!!m}),Q==="productDetail"&&D&&s.jsx(Hi,{product:D,onBack:ve,onAddToCart:I,onNavigateToProductPage:z}),Q==="packageDetail"&&F&&s.jsx(En,{package:F,onBack:ve,onNavigateToProductPage:te=>{const Re=b.find(fe=>fe.sku===te);Re&&z&&z(Re)}}),Q==="products"&&s.jsx(_n,{messages:c,input:h,setInput:u,isLoading:y,onSend:k,onKeyPress:f,onInputFocus:g,onInputBlur:S,chatEndRef:x,isMuted:j,onToggleMute:p,isSpeaking:E})]})},Rn=({variant:t="inline",initialState:e="idle",showChat:r=!0,className:n="",backdropUrl:i,counterOverlayUrl:c,counterHeightPercent:h,defaultBobImage:u,verticalOffset:y=0,scale:k=100})=>{const{callbacks:f}=et(),[g,S]=o.useState(!1),{animationState:x,setAnimationState:j,getCurrentImage:p,getCurrentOffset:E,getCurrentScale:b,availableStates:v}=dn({isSpeaking:g}),{activeBackdrop:d}=hn(),[_,B]=o.useState([]),[A,H]=o.useState([]),[I,z]=o.useState(null),[m,T]=o.useState(null),[C,N]=o.useState(!1),w=cn({setAnimationState:j,manualMode:!1,onReadyToSpeak:()=>{console.log("[BobWidget] Ready to speak")},onStreamComplete:()=>{j(v.find(F=>F.includes("idle"))||"idle")},onResearchStart:()=>{N(!0)},onHighlightPart:F=>{z(F),setTimeout(()=>z(null),8e3)},onHighlightProduct:F=>{T(F),setTimeout(()=>T(null),8e3)},onAutoFetchComplete:()=>{N(!1)}});o.useEffect(()=>{S(w.isSpeaking)},[w.isSpeaking]),o.useEffect(()=>{const F=f.onPartsFound,W=f.onServicePackagesFound;return f.onPartsFound=ae=>{if(N(!1),!ae||ae.length===0){console.log("[Bob] Clearing products (empty array received)"),B([]),F==null||F(ae);return}const Fe=ae.map((ce,xe)=>({id:ce.SKU||ce.sku||`part-${xe}`,name:ce["Part Product Type"]||ce.partslot_description||ce.name||"Unknown Part",brand:ce.Brand||ce.brand,price:ce["Metro Retail Price"]||ce.price||0,sku:ce.SKU||ce.sku,partNumber:ce["Part Number"]||ce.part_number,partslotDescription:ce["Part Product Type"]||ce.partslot_description,image_url:ce.image_url}));console.log("[Bob] Products mapped and setting state:",Fe.length,"products"),B(Fe),F==null||F(ae)},f.onServicePackagesFound=ae=>{if(!ae||ae.length===0){console.log("[Bob] Clearing service packages (empty array received)"),H([]),W==null||W(ae);return}H(ae),W==null||W(ae)},()=>{f.onPartsFound=F,f.onServicePackagesFound=W}},[f]);const q=i||(d==null?void 0:d.image_url),$=c||(d==null?void 0:d.counter_overlay_url)||void 0,X=h||(d==null?void 0:d.counter_height_percent)||12,Q=p()||u||"",P=E(),D=b();if(t==="mobile"||t==="fullscreen")return s.jsx(jn,{currentImage:Q,animationState:x,backdropUrl:q,counterOverlayUrl:$,counterHeightPercent:X,bobOffset:P,bobScale:D,messages:w.messages,input:w.input,setInput:w.setInput,isLoading:w.isLoading,onSend:w.handleSend,onKeyPress:w.handleKeyPress,onInputFocus:w.handleInputFocus,onInputBlur:w.handleInputBlur,chatEndRef:w.chatEndRef,isMuted:w.isMuted,onToggleMute:w.toggleMute,isSpeaking:w.isSpeaking,products:_,servicePackages:A,highlightedPartType:I,highlightedProduct:m,onAddToCart:F=>{var W;return(W=f.onAddToCart)==null?void 0:W.call(f,{product_id:F.id,product_name:F.name,quantity:1,unit_price:F.price,sku:F.sku,brand:F.brand})},onNavigateToProductPage:F=>{var W;return(W=f.onNavigateToProductPage)==null?void 0:W.call(f,F)},onPackageSelect:F=>console.log("[BobWidget] Package selected:",F),isResearching:C,vehicle:w.identifiedVehicle});if(t==="inline"&&r)return s.jsx("div",{className:`relative w-full h-full ${n}`,children:s.jsx(Tn,{currentImage:Q,animationState:x,backdropUrl:q,counterOverlayUrl:$,counterHeightPercent:X,bobOffset:P,bobScale:D,messages:w.messages,input:w.input,setInput:w.setInput,isLoading:w.isLoading,onSend:w.handleSend,onKeyPress:w.handleKeyPress,onInputFocus:w.handleInputFocus,onInputBlur:w.handleInputBlur,chatEndRef:w.chatEndRef,isMuted:w.isMuted,onToggleMute:w.toggleMute,isSpeaking:w.isSpeaking,products:_,servicePackages:A,highlightedPartType:I,highlightedProduct:m,onAddToCart:F=>{var W;return(W=f.onAddToCart)==null?void 0:W.call(f,{product_id:F.id,product_name:F.name,quantity:1,unit_price:F.price,sku:F.sku,brand:F.brand})},onNavigateToProductPage:F=>{var W;return(W=f.onNavigateToProductPage)==null?void 0:W.call(f,F)},onPackageSelect:F=>console.log("[BobWidget] Package selected:",F),isResearching:C,vehicle:w.identifiedVehicle})});const U={inline:"",floating:"fixed bottom-4 right-4 w-96 z-50 shadow-2xl rounded-lg overflow-hidden"};return s.jsxs("div",{className:`${U[t]||""} ${n}`,children:[Q&&s.jsx(fn,{currentImage:Q,animationState:x,backdropUrl:q,counterOverlayUrl:$,counterHeightPercent:X,verticalOffset:P,scale:D}),r&&s.jsx(xn,{messages:w.messages,input:w.input,setInput:w.setInput,isLoading:w.isLoading,onSend:w.handleSend,onKeyPress:w.handleKeyPress,onInputFocus:w.handleInputFocus,onInputBlur:w.handleInputBlur,chatEndRef:w.chatEndRef,isMuted:w.isMuted,onToggleMute:w.toggleMute,isSpeaking:w.isSpeaking})]})},qi=({bobConfig:t,hostApiConfig:e,hostContext:r,callbacks:n,variant:i="mobile",initialState:c,showChat:h,className:u,backdropUrl:y,counterOverlayUrl:k,counterHeightPercent:f,defaultBobImage:g,verticalOffset:S,scale:x,ga4Config:j,analyticsEnabled:p=!0,bottomOffset:E=0,zIndexBase:b=50})=>(o.useEffect(()=>{console.log("[BobWidget] Initialized",{version:Mt,variant:i,bottomOffset:E,zIndexBase:b,bobConfigUrl:t.supabaseUrl,hostApiBaseUrl:e.baseUrl,analyticsEnabled:p})},[i,E,b,t.supabaseUrl,e.baseUrl,p]),s.jsx("div",{className:"bob-widget-root",style:{width:"100%",height:"100%"},children:s.jsx(an,{bobConfig:t,hostApiConfig:e,hostContext:r,callbacks:n,ga4Config:j,analyticsEnabled:p,bottomOffset:E,zIndexBase:b,children:s.jsx(Rn,{variant:i,initialState:c,showChat:h,className:u,backdropUrl:y,counterOverlayUrl:k,counterHeightPercent:f,defaultBobImage:g,verticalOffset:S,scale:x})})})),Qi=({children:t,isSpeaking:e=!1,hasProducts:r=!1,onVisibilityChange:n,onPositionChange:i,currentPosition:c="center"})=>{const[h,u]=o.useState(!1),[y,k]=o.useState(0),f=o.useRef(null),g=o.useRef(0),S=o.useRef(0),x=o.useRef(!1),j=.25;o.useEffect(()=>{e&&c==="hidden"&&(i==null||i("partial-left"),n==null||n(!0))},[e,c,i,n]);const p=o.useCallback(_=>{g.current=_.touches[0].clientX,S.current=_.touches[0].clientY,x.current=!1,u(!0)},[]),E=o.useCallback(_=>{if(!h)return;const B=_.touches[0].clientX,A=_.touches[0].clientY,H=B-g.current,I=A-S.current;!x.current&&Math.abs(H)>10&&(x.current=Math.abs(H)>Math.abs(I)),x.current&&(_.preventDefault(),k(H))},[h]),b=o.useCallback(()=>{var I;if(!h)return;u(!1);const _=((I=f.current)==null?void 0:I.offsetWidth)||300,B=Math.abs(y)/_,A=y<0,H=y>0;A?c==="center"&&B>j?(i==null||i("partial-left"),n==null||n(!0)):c==="partial-left"&&B>j&&(i==null||i("hidden"),n==null||n(!1)):H&&(c==="hidden"&&B>j?(i==null||i("partial-left"),n==null||n(!0)):c==="partial-left"&&B>j&&!r&&(i==null||i("center"),n==null||n(!0))),k(0)},[h,y,c,r,i,n]),v=o.useCallback(()=>{i==null||i("partial-left"),n==null||n(!0)},[i,n]),d=()=>h&&y!==0?`translateX(${Math.max(-100,Math.min(100,y))}px)`:"translateX(0)";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{ref:f,style:{position:"fixed",inset:0,width:"100vw",height:"100dvh",transform:d(),transition:h?"none":"transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",willChange:"transform"},onTouchStart:p,onTouchMove:E,onTouchEnd:b,children:[t,c==="center"&&!h&&s.jsx("div",{className:"absolute left-2 top-1/2 -translate-y-1/2 pointer-events-none",style:{animation:"swipeHint 3s ease-in-out 2s 1",opacity:0},children:s.jsx("svg",{className:"w-6 h-6 text-white/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),c==="hidden"&&s.jsx("button",{onClick:v,className:"fixed left-0 top-1/2 -translate-y-1/2 z-50 flex items-center justify-center",style:{writingMode:"vertical-rl",textOrientation:"mixed",background:"linear-gradient(180deg, #0066CC 0%, #004999 100%)",padding:"16px 8px",borderTopRightRadius:"12px",borderBottomRightRadius:"12px",boxShadow:"4px 0 12px rgba(0, 102, 204, 0.3)",animation:"slideInFromLeft 0.3s cubic-bezier(0.34, 1.56, 0.64, 1)",border:"none",cursor:"pointer"},children:s.jsx("span",{className:"text-white font-bold text-lg tracking-wider",children:"BOB"})}),s.jsx("style",{children:`
|
|
34
34
|
@keyframes slideInFromLeft {
|
|
35
35
|
from {
|
|
36
36
|
transform: translateX(-100%) translateY(-50%);
|
|
@@ -52,4 +52,4 @@ React keys must be passed directly to JSX without using spread:
|
|
|
52
52
|
transform: translateX(-10px) translateY(-50%);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
`})]})},at={primary:"216 100% 40%",secondary:"199 95% 74%",success:"33 100% 50%",background:"223 46% 13%",backgroundMode:"dark",sparkDealColor:"33 100% 50%",primaryHex:"#0066CC",secondaryHex:"#7DD3FC",successHex:"#FF9500",backgroundHex:"#111827",sparkDealHex:"#FF9500"};function or(t){const e=t.match(/(\d+\.?\d*)\s+(\d+\.?\d*)%?\s+(\d+\.?\d*)%?/);if(!e)return"#000000";const r=parseFloat(e[1]),n=parseFloat(e[2])/100,i=parseFloat(e[3])/100,c=(1-Math.abs(2*i-1))*n,h=c*(1-Math.abs(r/60%2-1)),u=i-c/2;let y=0,k=0,f=0;r<60?(y=c,k=h):r<120?(y=h,k=c):r<180?(k=c,f=h):r<240?(k=h,f=c):r<300?(y=h,f=c):(y=c,f=h);const p=S=>Math.round((S+u)*255).toString(16).padStart(2,"0");return`#${p(y)}${p(k)}${p(f)}`}function Cn(){const t=Yt();return vr({queryKey:["bob-theme-settings"],queryFn:async()=>{var f,p,S,x,j,g,E,b,v,d,_;if(!t)return console.log("[useThemeSettings] No supabase client, using defaults"),at;const{data:e,error:r}=await t.from("bob_theme_settings").select("setting_key, color_value, hex_preview").in("setting_key",["matrix_primary","matrix_secondary","matrix_success","matrix_background","matrix_background_mode","matrix_spark_deal_color"]);if(r)return console.error("[useThemeSettings] Error fetching:",r),at;if(!e||e.length===0)return at;const n=new Map(e.map(B=>[B.setting_key,B])),i=((f=n.get("matrix_primary"))==null?void 0:f.color_value)||at.primary,c=((p=n.get("matrix_secondary"))==null?void 0:p.color_value)||at.secondary,h=((S=n.get("matrix_success"))==null?void 0:S.color_value)||at.success,u=((x=n.get("matrix_background"))==null?void 0:x.color_value)||at.background,y=((j=n.get("matrix_spark_deal_color"))==null?void 0:j.color_value)||at.sparkDealColor,k=((g=n.get("matrix_background_mode"))==null?void 0:g.color_value)||"dark";return{primary:i,secondary:c,success:h,background:u,backgroundMode:k,sparkDealColor:y,primaryHex:((E=n.get("matrix_primary"))==null?void 0:E.hex_preview)||or(i),secondaryHex:((b=n.get("matrix_secondary"))==null?void 0:b.hex_preview)||or(c),successHex:((v=n.get("matrix_success"))==null?void 0:v.hex_preview)||or(h),backgroundHex:((d=n.get("matrix_background"))==null?void 0:d.hex_preview)||or(u),sparkDealHex:((_=n.get("matrix_spark_deal_color"))==null?void 0:_.hex_preview)||or(y)}},staleTime:60*1e3,gcTime:5*60*1e3})}const $r={enabled:!0,inRain:!0,rainFrequency:.15,primingEnabled:!0,bannerEnabled:!0,delayMs:2e3,scrollSpeed:5e3,maxPerSession:3,minResearchTime:1500,bobCommentary:!1};function Ki(){const t=Yt();return vr({queryKey:["spark-deals-settings"],queryFn:async()=>{if(!t)return $r;const{data:e,error:r}=await t.from("bob_settings").select("setting_key, setting_value").like("setting_key","spark_deals_%");if(r)return console.error("[useSparkDealsSettings] Error:",r),$r;if(!e||e.length===0)return $r;const n=new Map(e.map(i=>[i.setting_key,i.setting_value]));return{enabled:n.get("spark_deals_enabled")==="true",inRain:n.get("spark_deals_in_rain")==="true",rainFrequency:parseFloat(n.get("spark_deals_rain_frequency")||"0.15"),primingEnabled:n.get("spark_deals_priming_enabled")==="true",bannerEnabled:n.get("spark_deals_banner_enabled")==="true",delayMs:parseInt(n.get("spark_deals_delay_ms")||"2000",10),scrollSpeed:parseInt(n.get("spark_deals_scroll_speed")||"5000",10),maxPerSession:parseInt(n.get("spark_deals_max_per_session")||"3",10),minResearchTime:parseInt(n.get("spark_deals_min_research_time")||"1500",10),bobCommentary:n.get("spark_deals_bob_commentary")==="true"}},staleTime:60*1e3,gcTime:5*60*1e3})}function Nn(t=!0){const e=Yt();return vr({queryKey:["spark-deals"],queryFn:async()=>{if(!e)return console.log("[useSparkDeals] No supabase client"),[];try{return console.error("[useSparkDeals] Missing VITE_SUPABASE_URL"),[]}catch(r){return console.error("[useSparkDeals] Error:",r),[]}},enabled:t,staleTime:5*60*1e3,gcTime:10*60*1e3})}function Vi(t){const e=[];return t.forEach(r=>{e.push(`$${r.price.toFixed(0)}`),r.brand&&e.push(r.brand.toUpperCase());const n=r.product_name.split(" ")[0];n&&n.length>2&&e.push(n.toUpperCase())}),e}const Fn=({deals:t,currentDealIndex:e,onDealChange:r,onDealClick:n,scrollSpeed:i,theme:c})=>{const[h,u]=o.useState(!1),[y,k]=o.useState(100),f=t[e],p=c.sparkDealHex||"#FF9500",S=c.backgroundMode!=="light";o.useEffect(()=>{if(!f)return;u(!0),k(100);const g=setTimeout(()=>{k(0)},50),E=setTimeout(()=>{k(-100)},i-500),b=setTimeout(()=>{const v=(e+1)%t.length;r(v),u(!1)},i);return()=>{clearTimeout(g),clearTimeout(E),clearTimeout(b)}},[e,f,i,t.length,r]);const x=o.useCallback(()=>{f&&n(f)},[f,n]);if(!f)return null;const j=f.original_price?Math.round((1-f.price/f.original_price)*100):null;return s.jsxs("div",{className:"absolute bottom-20 left-0 right-0 z-20 overflow-hidden pointer-events-none",style:{height:"72px"},children:[s.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-auto",style:{transform:`translateX(${y}%)`,transition:"transform 0.5s ease-out"},children:s.jsxs("button",{onClick:x,className:"group flex items-center gap-4 px-6 py-3 rounded-xl shadow-2xl transition-all hover:scale-105 active:scale-95",style:{background:S?"linear-gradient(135deg, rgba(0, 0, 0, 0.85) 0%, rgba(17, 24, 39, 0.9) 100%)":"linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.98) 100%)",border:`2px solid ${p}`,boxShadow:`0 8px 32px -4px ${p}40, 0 4px 16px -2px rgba(0,0,0,0.2)`},children:[s.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center shrink-0",style:{background:`${p}20`},children:s.jsx("svg",{className:"w-5 h-5",fill:p,viewBox:"0 0 24 24",children:s.jsx("path",{d:"M11.645 20.91l-.007-.003-.022-.012a15.247 15.247 0 01-.383-.218 25.18 25.18 0 01-4.244-3.17C4.688 15.36 2.25 12.174 2.25 8.25 2.25 5.322 4.714 3 7.688 3A5.5 5.5 0 0112 5.052 5.5 5.5 0 0116.313 3c2.973 0 5.437 2.322 5.437 5.25 0 3.925-2.438 7.111-4.739 9.256a25.175 25.175 0 01-4.244 3.17 15.247 15.247 0 01-.383.219l-.022.012-.007.004-.003.001a.752.752 0 01-.704 0l-.003-.001z"})})}),s.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs font-bold uppercase tracking-wider",style:{color:p},children:"⚡ Spark Deal"}),j&&j>0&&s.jsxs("span",{className:"text-xs font-bold px-2 py-0.5 rounded-full",style:{background:p,color:S?"#000":"#fff"},children:[j,"% OFF"]})]}),s.jsxs("p",{className:"text-sm font-semibold truncate max-w-[200px]",style:{color:S?"#fff":"#111827"},children:[f.brand," ",f.product_name]})]}),s.jsxs("div",{className:"flex flex-col items-end shrink-0",children:[f.original_price&&f.original_price>f.price&&s.jsxs("span",{className:"text-xs line-through",style:{color:S?"#9ca3af":"#6b7280"},children:["$",f.original_price.toFixed(2)]}),s.jsxs("span",{className:"text-xl font-bold",style:{color:p},children:["$",f.price.toFixed(2)]})]}),s.jsx("svg",{className:"w-5 h-5 opacity-60 group-hover:opacity-100 group-hover:translate-x-1 transition-all",fill:"none",stroke:p,strokeWidth:2,viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})]})}),t.length>1&&s.jsx("div",{className:"absolute bottom-1 left-0 right-0 flex justify-center gap-1.5",children:t.map((g,E)=>s.jsx("div",{className:"w-1.5 h-1.5 rounded-full transition-all",style:{background:E===e?p:`${p}40`,transform:E===e?"scale(1.3)":"scale(1)"}},E))})]})},Ps=["*",":","=",">","<","+","-","|","•","○","●","◆","◇","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","K","M","N","P","R","S","T","X","Z","#","@","$","%","&","~","^","/","\\","[","]","{","}"],Ms=["BR","KE","OI","FI","LT","SP","RK","EN","GN","PT","CL","UT","AX","WH","EL","TI","RE","PA","DS","RO","TR","BT","HP","CV","XL"],Gi=({phase:t,message:e,onComplete:r,onSparkDealClick:n,subliminalBrands:i=[]})=>{const c=o.useRef(null),h=o.useRef(),u=o.useRef([]),y=o.useRef(0),[k,f]=o.useState(0),[p,S]=o.useState(!1),[x,j]=o.useState(0),{data:g}=Cn(),{data:E}=Ki(),{data:b}=Nn(t!=="hidden"&&(E==null?void 0:E.enabled)),v=g||{primaryHex:"#0066CC",secondaryHex:"#004999",successHex:"#FF9500",backgroundHex:"#111827",sparkDealHex:"#FF9500",backgroundMode:"dark"},d=E||{enabled:!0,inRain:!0,rainFrequency:.15,primingEnabled:!0,bannerEnabled:!0,delayMs:2e3,scrollSpeed:5e3,maxPerSession:3,minResearchTime:1500},_=b&&d.inRain?[...Vi(b),...i]:i,B=.08,A=o.useCallback(()=>_.length>0&&Math.random()<B?{char:_[Math.floor(Math.random()*_.length)],isSubliminal:!0}:Math.random()<.15?{char:Ms[Math.floor(Math.random()*Ms.length)],isSubliminal:!1}:{char:Ps[Math.floor(Math.random()*Ps.length)],isSubliminal:!1},[_]),H=o.useCallback((T,C)=>T.isSubliminal?v.sparkDealHex:t==="success"?v.successHex:Math.sin(C*2+T.x*.01)*.5+.5>.5?v.primaryHex:v.secondaryHex,[t,v]),I=o.useCallback((T,C)=>{const N=[],w=Math.floor(T/25);for(let q=0;q<w;q++){const{char:$,isSubliminal:X}=A();N.push({x:q*25+12,y:Math.random()*C,speed:1.5+Math.random()*3.5,char:$,isSubliminal:X,opacity:.2+Math.random()*.6,size:X?13:9+Math.random()*3,glowIntensity:X?.6:0,changeCounter:Math.floor(Math.random()*30)})}u.current=N},[A]);o.useEffect(()=>{if(t==="hidden"){h.current&&cancelAnimationFrame(h.current);return}const T=c.current;if(!T)return;const C=T.getContext("2d");if(!C)return;const N=()=>{T.width=T.offsetWidth*window.devicePixelRatio,T.height=T.offsetHeight*window.devicePixelRatio,C.scale(window.devicePixelRatio,window.devicePixelRatio),I(T.offsetWidth,T.offsetHeight)};N(),y.current=Date.now();const w=()=>{const q=T.offsetWidth,$=T.offsetHeight,Q=(Date.now()-y.current)/1e3;if(C.clearRect(0,0,q,$),u.current.forEach(O=>{const D=H(O,Q);if(C.font=`bold ${O.size}px monospace`,C.fillStyle=D,C.globalAlpha=O.opacity,O.isSubliminal&&O.glowIntensity>0?(C.shadowColor=v.sparkDealHex,C.shadowBlur=8*O.glowIntensity):C.shadowBlur=0,C.fillText(O.char,O.x,O.y),O.y+=O.speed,O.changeCounter++,O.changeCounter>20+Math.random()*40){const{char:U,isSubliminal:F}=A();O.char=U,O.isSubliminal=F,O.size=F?13:9+Math.random()*3,O.glowIntensity=F?.6:0,O.changeCounter=0}if(O.y>$+20){const{char:U,isSubliminal:F}=A();O.y=-20,O.char=U,O.isSubliminal=F,O.speed=1.5+Math.random()*3.5,O.opacity=.2+Math.random()*.6,O.size=F?13:9+Math.random()*3,O.glowIntensity=F?.6:0,O.changeCounter=0}}),C.globalAlpha=1,C.shadowBlur=0,t==="success"){const O=Math.max(0,1-Q*2);O>0&&(C.fillStyle=`rgba(255, 149, 0, ${O*.3})`,C.fillRect(0,0,q,$)),Q>.5&&r&&r()}h.current=requestAnimationFrame(w)};return w(),window.addEventListener("resize",N),()=>{h.current&&cancelAnimationFrame(h.current),window.removeEventListener("resize",N)}},[t,v,A,H,I,r]),o.useEffect(()=>{if(t==="hidden"||!b||b.length===0||!d.bannerEnabled){S(!1);return}if(x>=d.maxPerSession)return;const T=setTimeout(()=>{S(!0)},d.delayMs);return()=>clearTimeout(T)},[t,b,d,x]);const z=o.useCallback(T=>{f(T),j(C=>C+1)},[]),m=o.useCallback(T=>{console.log("[MatrixLoader] Spark deal clicked:",T.product_name),n==null||n(T)},[n]);return t==="hidden"?null:s.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center overflow-hidden pointer-events-none",style:{background:"transparent"},children:[s.jsx("canvas",{ref:c,className:"absolute inset-0 w-full h-full",style:{opacity:.85}}),p&&b&&b.length>0&&s.jsx(Fn,{deals:b.slice(0,d.maxPerSession),currentDealIndex:k,onDealChange:z,onDealClick:m,scrollSpeed:d.scrollSpeed,theme:v})]})},Yi=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:n,counterHeightPercent:i=22,products:c,servicePackages:h,highlightedPartType:u,highlightedProduct:y,onProductClick:k,onPackageSelect:f,isResearching:p,vehicle:S,onChangeVehicle:x,bobOffset:j=0,bobScale:g=100,bobHasArrived:E=!0,externalBobPosition:b,onBobPositionChange:v})=>{const d=typeof window<"u"&&window.self!==window.top,_=Fr(),B=ds(),[A,H]=o.useState("center"),[I,z]=o.useState("hidden"),m=b??A,T=o.useCallback(Q=>{H(Q),v==null||v(Q)},[v]),C=c.length>0||h.length>0,q=(()=>{switch(_){case"desktop":return 80*B.uiScale;case"tablet":return 90*B.uiScale;case"mobile":return 140;default:return 140}})()*g/100;o.useEffect(()=>{if(p&&I!=="loading"&&I!=="visible")z("loading"),m==="center"&&T("partial-left");else if(C&&I!=="visible")if(m==="center"){T("partial-left"),z("transitioning");const Q=setTimeout(()=>{z("visible")},400);return()=>clearTimeout(Q)}else z("visible");else!C&&!p&&I!=="hidden"&&(z("hidden"),T("center"))},[C,p,I,m,T]);const $=I!=="hidden",X=$&&C;return s.jsxs("div",{className:"absolute inset-0 overflow-hidden",style:{width:"100%",height:"100%",touchAction:"manipulation"},children:[r&&s.jsxs(s.Fragment,{children:[s.jsx("img",{src:r,alt:"Shop backdrop",className:"absolute inset-0 z-0 w-full h-full object-cover object-center transition-all duration-500",style:{pointerEvents:"none",filter:X?"blur(8px)":"none",transform:X?"scale(1.02)":"scale(1)"}}),s.jsx("div",{className:"absolute inset-0 z-[1] transition-opacity duration-500 pointer-events-none",style:{background:"rgba(0, 0, 0, 0.15)",opacity:X?1:0}})]}),s.jsx(Br,{currentImage:t,animationState:e,counterOverlayUrl:n,counterHeightPercent:i,scale:q,position:m,verticalOffset:j,hasArrived:E}),S&&!d&&s.jsx("div",{style:{position:"absolute",top:"8px",left:"8px",right:"8px",zIndex:20},children:s.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:[s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("p",{style:{fontSize:"12px",fontWeight:500,color:"#111827",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[S.year," ",S.make," ",S.model]}),S.rego&&s.jsx("p",{style:{fontSize:"10px",color:"#6b7280"},children:S.rego})]}),x&&s.jsx("button",{onClick:x,style:{fontSize:"12px",color:"#2563eb",marginLeft:"8px",flexShrink:0,background:"none",border:"none",cursor:"pointer",minHeight:"unset",minWidth:"unset"},children:"Change"})]})}),s.jsx(Ir,{products:c,servicePackages:h,highlightedPartType:u,highlightedProduct:y,onProductClick:k,onPackageSelect:f,isResearching:p,visible:$,counterHeightPercent:i,hasVehicle:!!S})]})},Xi=6e4,Ji=({states:t,setAnimationState:e,manualMode:r})=>{const[n,i]=o.useState("page_load"),[c,h]=o.useState(!1),u=o.useRef(null),y=o.useCallback(m=>{const T=t.find(C=>C.chat_trigger===m&&C.is_active);return console.log(`[StateTransitions] Looking for trigger: "${m}" -> found:`,(T==null?void 0:T.state_key)||"none"),T},[t]),k=o.useCallback(()=>t.find(m=>m.chat_trigger==="processing_input"||m.state_key==="research"||m.state_key==="researching"||m.title.toLowerCase().includes("research")||m.title.toLowerCase().includes("thinking")),[t]),f=o.useCallback(()=>t.find(m=>m.chat_trigger==="streaming_response"||m.state_key==="talk"||m.state_key==="talking"||m.title.toLowerCase().includes("talk")),[t]),p=o.useCallback(()=>t.find(m=>m.chat_trigger==="awaiting_input"||m.state_key==="talk_pause"||m.state_key==="listening"||m.title.toLowerCase().includes("listen")||m.title.toLowerCase().includes("pause")),[t]),S=o.useCallback(()=>{const m=t.find(T=>T.chat_trigger==="response_complete"||T.state_key==="complete"||T.title.toLowerCase().includes("complete"));return m||t.find(T=>T.state_key==="idle"||T.title.toLowerCase().includes("idle"))},[t]),x=o.useCallback(()=>t.find(m=>m.chat_trigger==="idle"||m.state_key==="idle"||m.title.toLowerCase().includes("idle")),[t]),j=o.useCallback(m=>{const T=t.find(C=>C.state_key===m);return{speed:(T==null?void 0:T.animation_speed)||400,pauseDuration:(T==null?void 0:T.pause_duration)||0,loopCount:(T==null?void 0:T.loop_count)||0}},[t]),g=o.useCallback(()=>{u.current&&(clearTimeout(u.current),u.current=null)},[]),E=o.useCallback(()=>{g(),!r&&(u.current=setTimeout(()=>{const m=x();m&&(i("idle"),e(m.state_key))},Xi))},[r,x,e,g]),b=o.useCallback(m=>{if(r)return;const T=y(m);T&&e(T.state_key)},[r,y,e]),v=o.useCallback(()=>{if(r)return;const m=p();m&&(i("awaiting_input"),e(m.state_key),E())},[r,p,e,E]),d=o.useCallback(()=>{c||r||(h(!0),i("page_load"),b("page_load"),setTimeout(()=>{v()},3e3))},[c,r,b,v]),_=o.useCallback(()=>{if(r)return;g(),i("processing_input");const m=k();console.log("[StateTransitions] User input - switching to RESEARCH:",m==null?void 0:m.state_key),m?e(m.state_key):b("processing_input")},[r,g,k,e,b]),B=o.useCallback(()=>{if(r)return;g(),i("streaming_response");const m=f();console.log("[StateTransitions] Speech started - switching to TALK:",m==null?void 0:m.state_key),m&&e(m.state_key)},[r,g,f,e]),A=o.useCallback(()=>{if(r)return;const m=S();console.log("[StateTransitions] Speech ended - switching to COMPLETE:",m==null?void 0:m.state_key),m&&e(m.state_key),setTimeout(()=>{r||v()},2e3)},[r,S,e,v]),H=o.useCallback(()=>{g(),i("streaming_response"),console.log("[StateTransitions] Stream started (API response)")},[g]),I=o.useCallback(()=>{i("response_complete"),console.log("[StateTransitions] Stream complete (API finished)");const m=S();m&&e(m.state_key),setTimeout(()=>{v()},2e3)},[S,e,v]),z=o.useCallback(()=>{if(r)return;i("showing_product"),console.log("[StateTransitions] Showing products");const m=t.find(T=>T.chat_trigger==="showing_product"||T.state_key==="showing_product");m&&e(m.state_key),setTimeout(()=>{v()},3e3)},[r,t,e,v]);return o.useEffect(()=>()=>g(),[g]),{chatStage:n,initialize:d,onUserInput:_,onSpeechStart:B,onSpeechEnd:A,onStreamStart:H,onStreamComplete:I,onShowingProduct:z,getStateSettings:j}};console.log(`[BobWidget] Package loaded - v${Gt}`);exports.BADGE_CONFIG=pn;exports.BOB_VERSION=Gt;exports.Bob=Rn;exports.BobCharacter=fn;exports.BobProvider=an;exports.BobSuggestions=us;exports.BobWidget=qi;exports.CARFIX_COLORS=K;exports.ChatInterface=xn;exports.ContainedChatDrawer=_n;exports.ContainedMobileBobLayout=Tn;exports.IMAGE_URLS=fr;exports.MatrixProductLoader=Gi;exports.MobileBobCharacter=Br;exports.MobileBobLayout=jn;exports.MobileBobLayoutCore=Yi;exports.MobileChatDrawer=Sn;exports.MobileProductColumn=Ir;exports.ProductBadge=cr;exports.ProductTile=kn;exports.QUALITY_TIER_CONFIG=Cr;exports.ServicePackageDetailView=En;exports.SparkDealBanner=Fn;exports.SwipeableBob=Qi;exports.TYPOGRAPHY=ze;exports.formatNZD=gt;exports.getBobVersion=Mn;exports.getDisplayPrice=bn;exports.isRotorProduct=gn;exports.useBobAnalytics=nn;exports.useBobAnalyticsConfig=Ei;exports.useBobAnimation=dn;exports.useBobAnimationData=un;exports.useBobBackdrop=hn;exports.useBobCallbacks=_i;exports.useBobChat=cn;exports.useBobContext=et;exports.useBobLayoutConfig=cs;exports.useBobStateTransitions=Ji;exports.useBobSupabase=ki;exports.useBobSupabaseSafe=Yt;exports.useHostApiConfig=ji;exports.useHostContext=Si;exports.useReturningUser=ln;exports.useSparkDeals=Nn;exports.useSpeechRecognition=hs;exports.useSpeechSynthesis=on;exports.useThemeSettings=Cn;
|
|
55
|
+
`})]})},at={primary:"216 100% 40%",secondary:"199 95% 74%",success:"33 100% 50%",background:"223 46% 13%",backgroundMode:"dark",sparkDealColor:"33 100% 50%",primaryHex:"#0066CC",secondaryHex:"#7DD3FC",successHex:"#FF9500",backgroundHex:"#111827",sparkDealHex:"#FF9500"};function or(t){const e=t.match(/(\d+\.?\d*)\s+(\d+\.?\d*)%?\s+(\d+\.?\d*)%?/);if(!e)return"#000000";const r=parseFloat(e[1]),n=parseFloat(e[2])/100,i=parseFloat(e[3])/100,c=(1-Math.abs(2*i-1))*n,h=c*(1-Math.abs(r/60%2-1)),u=i-c/2;let y=0,k=0,f=0;r<60?(y=c,k=h):r<120?(y=h,k=c):r<180?(k=c,f=h):r<240?(k=h,f=c):r<300?(y=h,f=c):(y=c,f=h);const g=S=>Math.round((S+u)*255).toString(16).padStart(2,"0");return`#${g(y)}${g(k)}${g(f)}`}function Cn(){const t=Yt();return vr({queryKey:["bob-theme-settings"],queryFn:async()=>{var f,g,S,x,j,p,E,b,v,d,_;if(!t)return console.log("[useThemeSettings] No supabase client, using defaults"),at;const{data:e,error:r}=await t.from("bob_theme_settings").select("setting_key, color_value, hex_preview").in("setting_key",["matrix_primary","matrix_secondary","matrix_success","matrix_background","matrix_background_mode","matrix_spark_deal_color"]);if(r)return console.error("[useThemeSettings] Error fetching:",r),at;if(!e||e.length===0)return at;const n=new Map(e.map(B=>[B.setting_key,B])),i=((f=n.get("matrix_primary"))==null?void 0:f.color_value)||at.primary,c=((g=n.get("matrix_secondary"))==null?void 0:g.color_value)||at.secondary,h=((S=n.get("matrix_success"))==null?void 0:S.color_value)||at.success,u=((x=n.get("matrix_background"))==null?void 0:x.color_value)||at.background,y=((j=n.get("matrix_spark_deal_color"))==null?void 0:j.color_value)||at.sparkDealColor,k=((p=n.get("matrix_background_mode"))==null?void 0:p.color_value)||"dark";return{primary:i,secondary:c,success:h,background:u,backgroundMode:k,sparkDealColor:y,primaryHex:((E=n.get("matrix_primary"))==null?void 0:E.hex_preview)||or(i),secondaryHex:((b=n.get("matrix_secondary"))==null?void 0:b.hex_preview)||or(c),successHex:((v=n.get("matrix_success"))==null?void 0:v.hex_preview)||or(h),backgroundHex:((d=n.get("matrix_background"))==null?void 0:d.hex_preview)||or(u),sparkDealHex:((_=n.get("matrix_spark_deal_color"))==null?void 0:_.hex_preview)||or(y)}},staleTime:60*1e3,gcTime:5*60*1e3})}const $r={enabled:!0,inRain:!0,rainFrequency:.15,primingEnabled:!0,bannerEnabled:!0,delayMs:2e3,scrollSpeed:5e3,maxPerSession:3,minResearchTime:1500,bobCommentary:!1};function Ki(){const t=Yt();return vr({queryKey:["spark-deals-settings"],queryFn:async()=>{if(!t)return $r;const{data:e,error:r}=await t.from("bob_settings").select("setting_key, setting_value").like("setting_key","spark_deals_%");if(r)return console.error("[useSparkDealsSettings] Error:",r),$r;if(!e||e.length===0)return $r;const n=new Map(e.map(i=>[i.setting_key,i.setting_value]));return{enabled:n.get("spark_deals_enabled")==="true",inRain:n.get("spark_deals_in_rain")==="true",rainFrequency:parseFloat(n.get("spark_deals_rain_frequency")||"0.15"),primingEnabled:n.get("spark_deals_priming_enabled")==="true",bannerEnabled:n.get("spark_deals_banner_enabled")==="true",delayMs:parseInt(n.get("spark_deals_delay_ms")||"2000",10),scrollSpeed:parseInt(n.get("spark_deals_scroll_speed")||"5000",10),maxPerSession:parseInt(n.get("spark_deals_max_per_session")||"3",10),minResearchTime:parseInt(n.get("spark_deals_min_research_time")||"1500",10),bobCommentary:n.get("spark_deals_bob_commentary")==="true"}},staleTime:60*1e3,gcTime:5*60*1e3})}function Nn(t=!0){const e=Yt();return vr({queryKey:["spark-deals"],queryFn:async()=>{if(!e)return console.log("[useSparkDeals] No supabase client"),[];try{return console.error("[useSparkDeals] Missing VITE_SUPABASE_URL"),[]}catch(r){return console.error("[useSparkDeals] Error:",r),[]}},enabled:t,staleTime:5*60*1e3,gcTime:10*60*1e3})}function Vi(t){const e=[];return t.forEach(r=>{e.push(`$${r.price.toFixed(0)}`),r.brand&&e.push(r.brand.toUpperCase());const n=r.product_name.split(" ")[0];n&&n.length>2&&e.push(n.toUpperCase())}),e}const Fn=({deals:t,currentDealIndex:e,onDealChange:r,onDealClick:n,scrollSpeed:i,theme:c})=>{const[h,u]=o.useState(!1),[y,k]=o.useState(100),f=t[e],g=c.sparkDealHex||"#FF9500",S=c.backgroundMode!=="light";o.useEffect(()=>{if(!f)return;u(!0),k(100);const p=setTimeout(()=>{k(0)},50),E=setTimeout(()=>{k(-100)},i-500),b=setTimeout(()=>{const v=(e+1)%t.length;r(v),u(!1)},i);return()=>{clearTimeout(p),clearTimeout(E),clearTimeout(b)}},[e,f,i,t.length,r]);const x=o.useCallback(()=>{f&&n(f)},[f,n]);if(!f)return null;const j=f.original_price?Math.round((1-f.price/f.original_price)*100):null;return s.jsxs("div",{className:"absolute bottom-20 left-0 right-0 z-20 overflow-hidden pointer-events-none",style:{height:"72px"},children:[s.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-auto",style:{transform:`translateX(${y}%)`,transition:"transform 0.5s ease-out"},children:s.jsxs("button",{onClick:x,className:"group flex items-center gap-4 px-6 py-3 rounded-xl shadow-2xl transition-all hover:scale-105 active:scale-95",style:{background:S?"linear-gradient(135deg, rgba(0, 0, 0, 0.85) 0%, rgba(17, 24, 39, 0.9) 100%)":"linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.98) 100%)",border:`2px solid ${g}`,boxShadow:`0 8px 32px -4px ${g}40, 0 4px 16px -2px rgba(0,0,0,0.2)`},children:[s.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center shrink-0",style:{background:`${g}20`},children:s.jsx("svg",{className:"w-5 h-5",fill:g,viewBox:"0 0 24 24",children:s.jsx("path",{d:"M11.645 20.91l-.007-.003-.022-.012a15.247 15.247 0 01-.383-.218 25.18 25.18 0 01-4.244-3.17C4.688 15.36 2.25 12.174 2.25 8.25 2.25 5.322 4.714 3 7.688 3A5.5 5.5 0 0112 5.052 5.5 5.5 0 0116.313 3c2.973 0 5.437 2.322 5.437 5.25 0 3.925-2.438 7.111-4.739 9.256a25.175 25.175 0 01-4.244 3.17 15.247 15.247 0 01-.383.219l-.022.012-.007.004-.003.001a.752.752 0 01-.704 0l-.003-.001z"})})}),s.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs font-bold uppercase tracking-wider",style:{color:g},children:"⚡ Spark Deal"}),j&&j>0&&s.jsxs("span",{className:"text-xs font-bold px-2 py-0.5 rounded-full",style:{background:g,color:S?"#000":"#fff"},children:[j,"% OFF"]})]}),s.jsxs("p",{className:"text-sm font-semibold truncate max-w-[200px]",style:{color:S?"#fff":"#111827"},children:[f.brand," ",f.product_name]})]}),s.jsxs("div",{className:"flex flex-col items-end shrink-0",children:[f.original_price&&f.original_price>f.price&&s.jsxs("span",{className:"text-xs line-through",style:{color:S?"#9ca3af":"#6b7280"},children:["$",f.original_price.toFixed(2)]}),s.jsxs("span",{className:"text-xl font-bold",style:{color:g},children:["$",f.price.toFixed(2)]})]}),s.jsx("svg",{className:"w-5 h-5 opacity-60 group-hover:opacity-100 group-hover:translate-x-1 transition-all",fill:"none",stroke:g,strokeWidth:2,viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})]})}),t.length>1&&s.jsx("div",{className:"absolute bottom-1 left-0 right-0 flex justify-center gap-1.5",children:t.map((p,E)=>s.jsx("div",{className:"w-1.5 h-1.5 rounded-full transition-all",style:{background:E===e?g:`${g}40`,transform:E===e?"scale(1.3)":"scale(1)"}},E))})]})},Os=["*",":","=",">","<","+","-","|","•","○","●","◆","◇","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","K","M","N","P","R","S","T","X","Z","#","@","$","%","&","~","^","/","\\","[","]","{","}"],Ms=["BR","KE","OI","FI","LT","SP","RK","EN","GN","PT","CL","UT","AX","WH","EL","TI","RE","PA","DS","RO","TR","BT","HP","CV","XL"],Gi=({phase:t,message:e,onComplete:r,onSparkDealClick:n,subliminalBrands:i=[]})=>{const c=o.useRef(null),h=o.useRef(),u=o.useRef([]),y=o.useRef(0),[k,f]=o.useState(0),[g,S]=o.useState(!1),[x,j]=o.useState(0),{data:p}=Cn(),{data:E}=Ki(),{data:b}=Nn(t!=="hidden"&&(E==null?void 0:E.enabled)),v=p||{primaryHex:"#0066CC",secondaryHex:"#004999",successHex:"#FF9500",backgroundHex:"#111827",sparkDealHex:"#FF9500",backgroundMode:"dark"},d=E||{enabled:!0,inRain:!0,rainFrequency:.15,primingEnabled:!0,bannerEnabled:!0,delayMs:2e3,scrollSpeed:5e3,maxPerSession:3,minResearchTime:1500},_=b&&d.inRain?[...Vi(b),...i]:i,B=.08,A=o.useCallback(()=>_.length>0&&Math.random()<B?{char:_[Math.floor(Math.random()*_.length)],isSubliminal:!0}:Math.random()<.15?{char:Ms[Math.floor(Math.random()*Ms.length)],isSubliminal:!1}:{char:Os[Math.floor(Math.random()*Os.length)],isSubliminal:!1},[_]),H=o.useCallback((T,C)=>T.isSubliminal?v.sparkDealHex:t==="success"?v.successHex:Math.sin(C*2+T.x*.01)*.5+.5>.5?v.primaryHex:v.secondaryHex,[t,v]),I=o.useCallback((T,C)=>{const N=[],w=Math.floor(T/25);for(let q=0;q<w;q++){const{char:$,isSubliminal:X}=A();N.push({x:q*25+12,y:Math.random()*C,speed:1.5+Math.random()*3.5,char:$,isSubliminal:X,opacity:.2+Math.random()*.6,size:X?13:9+Math.random()*3,glowIntensity:X?.6:0,changeCounter:Math.floor(Math.random()*30)})}u.current=N},[A]);o.useEffect(()=>{if(t==="hidden"){h.current&&cancelAnimationFrame(h.current);return}const T=c.current;if(!T)return;const C=T.getContext("2d");if(!C)return;const N=()=>{T.width=T.offsetWidth*window.devicePixelRatio,T.height=T.offsetHeight*window.devicePixelRatio,C.scale(window.devicePixelRatio,window.devicePixelRatio),I(T.offsetWidth,T.offsetHeight)};N(),y.current=Date.now();const w=()=>{const q=T.offsetWidth,$=T.offsetHeight,Q=(Date.now()-y.current)/1e3;if(C.clearRect(0,0,q,$),u.current.forEach(P=>{const D=H(P,Q);if(C.font=`bold ${P.size}px monospace`,C.fillStyle=D,C.globalAlpha=P.opacity,P.isSubliminal&&P.glowIntensity>0?(C.shadowColor=v.sparkDealHex,C.shadowBlur=8*P.glowIntensity):C.shadowBlur=0,C.fillText(P.char,P.x,P.y),P.y+=P.speed,P.changeCounter++,P.changeCounter>20+Math.random()*40){const{char:U,isSubliminal:F}=A();P.char=U,P.isSubliminal=F,P.size=F?13:9+Math.random()*3,P.glowIntensity=F?.6:0,P.changeCounter=0}if(P.y>$+20){const{char:U,isSubliminal:F}=A();P.y=-20,P.char=U,P.isSubliminal=F,P.speed=1.5+Math.random()*3.5,P.opacity=.2+Math.random()*.6,P.size=F?13:9+Math.random()*3,P.glowIntensity=F?.6:0,P.changeCounter=0}}),C.globalAlpha=1,C.shadowBlur=0,t==="success"){const P=Math.max(0,1-Q*2);P>0&&(C.fillStyle=`rgba(255, 149, 0, ${P*.3})`,C.fillRect(0,0,q,$)),Q>.5&&r&&r()}h.current=requestAnimationFrame(w)};return w(),window.addEventListener("resize",N),()=>{h.current&&cancelAnimationFrame(h.current),window.removeEventListener("resize",N)}},[t,v,A,H,I,r]),o.useEffect(()=>{if(t==="hidden"||!b||b.length===0||!d.bannerEnabled){S(!1);return}if(x>=d.maxPerSession)return;const T=setTimeout(()=>{S(!0)},d.delayMs);return()=>clearTimeout(T)},[t,b,d,x]);const z=o.useCallback(T=>{f(T),j(C=>C+1)},[]),m=o.useCallback(T=>{console.log("[MatrixLoader] Spark deal clicked:",T.product_name),n==null||n(T)},[n]);return t==="hidden"?null:s.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center overflow-hidden pointer-events-none",style:{background:"transparent"},children:[s.jsx("canvas",{ref:c,className:"absolute inset-0 w-full h-full",style:{opacity:.85}}),g&&b&&b.length>0&&s.jsx(Fn,{deals:b.slice(0,d.maxPerSession),currentDealIndex:k,onDealChange:z,onDealClick:m,scrollSpeed:d.scrollSpeed,theme:v})]})},Yi=({currentImage:t,animationState:e,backdropUrl:r,counterOverlayUrl:n,counterHeightPercent:i=22,products:c,servicePackages:h,highlightedPartType:u,highlightedProduct:y,onProductClick:k,onPackageSelect:f,isResearching:g,vehicle:S,onChangeVehicle:x,bobOffset:j=0,bobScale:p=100,bobHasArrived:E=!0,externalBobPosition:b,onBobPositionChange:v})=>{const d=typeof window<"u"&&window.self!==window.top,_=Fr(),B=ds(),[A,H]=o.useState("center"),[I,z]=o.useState("hidden"),m=b??A,T=o.useCallback(Q=>{H(Q),v==null||v(Q)},[v]),C=c.length>0||h.length>0,q=(()=>{switch(_){case"desktop":return 80*B.uiScale;case"tablet":return 90*B.uiScale;case"mobile":return 140;default:return 140}})()*p/100;o.useEffect(()=>{if(g&&I!=="loading"&&I!=="visible")z("loading"),m==="center"&&T("partial-left");else if(C&&I!=="visible")if(m==="center"){T("partial-left"),z("transitioning");const Q=setTimeout(()=>{z("visible")},400);return()=>clearTimeout(Q)}else z("visible");else!C&&!g&&I!=="hidden"&&(z("hidden"),T("center"))},[C,g,I,m,T]);const $=I!=="hidden",X=$&&C;return s.jsxs("div",{className:"absolute inset-0 overflow-hidden",style:{width:"100%",height:"100%",touchAction:"manipulation"},children:[r&&s.jsxs(s.Fragment,{children:[s.jsx("img",{src:r,alt:"Shop backdrop",className:"absolute inset-0 z-0 w-full h-full object-cover object-center transition-all duration-500",style:{pointerEvents:"none",filter:X?"blur(8px)":"none",transform:X?"scale(1.02)":"scale(1)"}}),s.jsx("div",{className:"absolute inset-0 z-[1] transition-opacity duration-500 pointer-events-none",style:{background:"rgba(0, 0, 0, 0.15)",opacity:X?1:0}})]}),s.jsx(Br,{currentImage:t,animationState:e,counterOverlayUrl:n,counterHeightPercent:i,scale:q,position:m,verticalOffset:j,hasArrived:E}),S&&!d&&s.jsx("div",{style:{position:"absolute",top:"8px",left:"8px",right:"8px",zIndex:20},children:s.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:[s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("p",{style:{fontSize:"12px",fontWeight:500,color:"#111827",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[S.year," ",S.make," ",S.model]}),S.rego&&s.jsx("p",{style:{fontSize:"10px",color:"#6b7280"},children:S.rego})]}),x&&s.jsx("button",{onClick:x,style:{fontSize:"12px",color:"#2563eb",marginLeft:"8px",flexShrink:0,background:"none",border:"none",cursor:"pointer",minHeight:"unset",minWidth:"unset"},children:"Change"})]})}),s.jsx(Ir,{products:c,servicePackages:h,highlightedPartType:u,highlightedProduct:y,onProductClick:k,onPackageSelect:f,isResearching:g,visible:$,counterHeightPercent:i,hasVehicle:!!S})]})},Xi=6e4,Ji=({states:t,setAnimationState:e,manualMode:r})=>{const[n,i]=o.useState("page_load"),[c,h]=o.useState(!1),u=o.useRef(null),y=o.useCallback(m=>{const T=t.find(C=>C.chat_trigger===m&&C.is_active);return console.log(`[StateTransitions] Looking for trigger: "${m}" -> found:`,(T==null?void 0:T.state_key)||"none"),T},[t]),k=o.useCallback(()=>t.find(m=>m.chat_trigger==="processing_input"||m.state_key==="research"||m.state_key==="researching"||m.title.toLowerCase().includes("research")||m.title.toLowerCase().includes("thinking")),[t]),f=o.useCallback(()=>t.find(m=>m.chat_trigger==="streaming_response"||m.state_key==="talk"||m.state_key==="talking"||m.title.toLowerCase().includes("talk")),[t]),g=o.useCallback(()=>t.find(m=>m.chat_trigger==="awaiting_input"||m.state_key==="talk_pause"||m.state_key==="listening"||m.title.toLowerCase().includes("listen")||m.title.toLowerCase().includes("pause")),[t]),S=o.useCallback(()=>{const m=t.find(T=>T.chat_trigger==="response_complete"||T.state_key==="complete"||T.title.toLowerCase().includes("complete"));return m||t.find(T=>T.state_key==="idle"||T.title.toLowerCase().includes("idle"))},[t]),x=o.useCallback(()=>t.find(m=>m.chat_trigger==="idle"||m.state_key==="idle"||m.title.toLowerCase().includes("idle")),[t]),j=o.useCallback(m=>{const T=t.find(C=>C.state_key===m);return{speed:(T==null?void 0:T.animation_speed)||400,pauseDuration:(T==null?void 0:T.pause_duration)||0,loopCount:(T==null?void 0:T.loop_count)||0}},[t]),p=o.useCallback(()=>{u.current&&(clearTimeout(u.current),u.current=null)},[]),E=o.useCallback(()=>{p(),!r&&(u.current=setTimeout(()=>{const m=x();m&&(i("idle"),e(m.state_key))},Xi))},[r,x,e,p]),b=o.useCallback(m=>{if(r)return;const T=y(m);T&&e(T.state_key)},[r,y,e]),v=o.useCallback(()=>{if(r)return;const m=g();m&&(i("awaiting_input"),e(m.state_key),E())},[r,g,e,E]),d=o.useCallback(()=>{c||r||(h(!0),i("page_load"),b("page_load"),setTimeout(()=>{v()},3e3))},[c,r,b,v]),_=o.useCallback(()=>{if(r)return;p(),i("processing_input");const m=k();console.log("[StateTransitions] User input - switching to RESEARCH:",m==null?void 0:m.state_key),m?e(m.state_key):b("processing_input")},[r,p,k,e,b]),B=o.useCallback(()=>{if(r)return;p(),i("streaming_response");const m=f();console.log("[StateTransitions] Speech started - switching to TALK:",m==null?void 0:m.state_key),m&&e(m.state_key)},[r,p,f,e]),A=o.useCallback(()=>{if(r)return;const m=S();console.log("[StateTransitions] Speech ended - switching to COMPLETE:",m==null?void 0:m.state_key),m&&e(m.state_key),setTimeout(()=>{r||v()},2e3)},[r,S,e,v]),H=o.useCallback(()=>{p(),i("streaming_response"),console.log("[StateTransitions] Stream started (API response)")},[p]),I=o.useCallback(()=>{i("response_complete"),console.log("[StateTransitions] Stream complete (API finished)");const m=S();m&&e(m.state_key),setTimeout(()=>{v()},2e3)},[S,e,v]),z=o.useCallback(()=>{if(r)return;i("showing_product"),console.log("[StateTransitions] Showing products");const m=t.find(T=>T.chat_trigger==="showing_product"||T.state_key==="showing_product");m&&e(m.state_key),setTimeout(()=>{v()},3e3)},[r,t,e,v]);return o.useEffect(()=>()=>p(),[p]),{chatStage:n,initialize:d,onUserInput:_,onSpeechStart:B,onSpeechEnd:A,onStreamStart:H,onStreamComplete:I,onShowingProduct:z,getStateSettings:j}};console.log(`[BobWidget] Package loaded - v${Mt}`);exports.BADGE_CONFIG=pn;exports.BOB_VERSION=Mt;exports.Bob=Rn;exports.BobCharacter=fn;exports.BobProvider=an;exports.BobSuggestions=us;exports.BobWidget=qi;exports.CARFIX_COLORS=K;exports.ChatInterface=xn;exports.ContainedChatDrawer=_n;exports.ContainedMobileBobLayout=Tn;exports.IMAGE_URLS=fr;exports.MatrixProductLoader=Gi;exports.MobileBobCharacter=Br;exports.MobileBobLayout=jn;exports.MobileBobLayoutCore=Yi;exports.MobileChatDrawer=Sn;exports.MobileProductColumn=Ir;exports.ProductBadge=cr;exports.ProductTile=kn;exports.QUALITY_TIER_CONFIG=Cr;exports.ServicePackageDetailView=En;exports.SparkDealBanner=Fn;exports.SwipeableBob=Qi;exports.TYPOGRAPHY=ze;exports.formatNZD=gt;exports.getBobVersion=Mn;exports.getDisplayPrice=bn;exports.isRotorProduct=gn;exports.useBobAnalytics=nn;exports.useBobAnalyticsConfig=Ei;exports.useBobAnimation=dn;exports.useBobAnimationData=un;exports.useBobBackdrop=hn;exports.useBobCallbacks=_i;exports.useBobChat=cn;exports.useBobContext=et;exports.useBobLayoutConfig=cs;exports.useBobStateTransitions=Ji;exports.useBobSupabase=ki;exports.useBobSupabaseSafe=Yt;exports.useHostApiConfig=ji;exports.useHostContext=Si;exports.useReturningUser=ln;exports.useSparkDeals=Nn;exports.useSpeechRecognition=hs;exports.useSpeechSynthesis=on;exports.useThemeSettings=Cn;
|